From 82ee1e6cde3d9500f3dfc9cefc259b89e87a8865 Mon Sep 17 00:00:00 2001 From: Fabien Parent Date: Tue, 13 Oct 2015 17:34:50 +0200 Subject: [PATCH] greybus: es2: implement cport reset control request Toshiba UniPro IP requires to reset the CPort that has been used in a previous connection. This commit implement a new control request in order to reset CPorts on an APBridgeA. Signed-off-by: Fabien Parent Reviewed-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/es2.c | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/staging/greybus/es2.c b/drivers/staging/greybus/es2.c index 22b67d2ff9df..f0770389df71 100644 --- a/drivers/staging/greybus/es2.c +++ b/drivers/staging/greybus/es2.c @@ -58,6 +58,9 @@ static DEFINE_KFIFO(apb1_log_fifo, char, APB1_LOG_SIZE); /* vendor request to get the number of cports available */ #define REQUEST_CPORT_COUNT 0x04 +/* vendor request to reset a cport state */ +#define REQUEST_RESET_CPORT 0x05 + /* * @endpoint: bulk in endpoint for CPort data * @urb: array of urbs for the CPort in messages @@ -376,10 +379,44 @@ static void message_cancel(struct gb_message *message) usb_free_urb(urb); } +static int cport_reset(struct greybus_host_device *hd, u16 cport_id) +{ + struct es1_ap_dev *es1 = hd_to_es1(hd); + struct usb_device *udev = es1->usb_dev; + int retval; + + retval = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), + REQUEST_RESET_CPORT, + USB_DIR_OUT | USB_TYPE_VENDOR | + USB_RECIP_INTERFACE, 0, cport_id, + NULL, 0, ES1_TIMEOUT); + if (retval < 0) { + dev_err(&udev->dev, "failed to reset cport %hu: %d\n", cport_id, + retval); + return retval; + } + + return 0; +} + +static int cport_enable(struct greybus_host_device *hd, u16 cport_id) +{ + int retval; + + if (cport_id != GB_SVC_CPORT_ID) { + retval = cport_reset(hd, cport_id); + if (retval) + return retval; + } + + return 0; +} + static struct greybus_host_driver es1_driver = { .hd_priv_size = sizeof(struct es1_ap_dev), .message_send = message_send, .message_cancel = message_cancel, + .cport_enable = cport_enable, }; /* Common function to report consistent warnings based on URB status */ -- 2.20.1