/* 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
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 */