From: mpi Date: Fri, 8 Aug 2014 14:20:05 +0000 (+0000) Subject: Super Speed hub descriptor definition and routine, required for upcoming X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=02819723c26d3291fb398f3a49d4dcde49492ab4;p=openbsd Super Speed hub descriptor definition and routine, required for upcoming external USB 3.0 hub support. --- diff --git a/sys/dev/usb/usb.h b/sys/dev/usb/usb.h index eb4bbe06a10..98c71b0284d 100644 --- a/sys/dev/usb/usb.h +++ b/sys/dev/usb/usb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: usb.h,v 1.46 2014/03/08 11:47:26 mpi Exp $ */ +/* $OpenBSD: usb.h,v 1.47 2014/08/08 14:20:05 mpi Exp $ */ /* $NetBSD: usb.h,v 1.69 2002/09/22 23:20:50 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb.h,v 1.14 1999/11/17 22:33:46 n_hibma Exp $ */ @@ -328,9 +328,21 @@ typedef struct { uByte DeviceRemovable[32]; /* max 255 ports */ #define UHD_NOT_REMOV(desc, i) \ (((desc)->DeviceRemovable[(i)/8] >> ((i) % 8)) & 1) - /* deprecated */ uByte PortPowerCtrlMask[1]; } __packed usb_hub_descriptor_t; -#define USB_HUB_DESCRIPTOR_SIZE 9 /* includes deprecated PortPowerCtrlMask */ +#define USB_HUB_DESCRIPTOR_SIZE 8 + +typedef struct { + uByte bDescLength; + uByte bDescriptorType; + uByte bNbrPorts; + uWord wHubCharacteristics; + uByte bPwrOn2PwrGood; /* delay in 2 ms units */ + uByte bHubContrCurrent; + uByte bHubHdrDecLat; + uWord wHubDelay; + uByte DeviceRemovable[32]; /* max 255 ports */ +} __packed usb_hub_ss_descriptor_t; +#define USB_HUB_SS_DESCRIPTOR_SIZE 11 typedef struct { uByte bLength; diff --git a/sys/dev/usb/usbdi_util.c b/sys/dev/usb/usbdi_util.c index 50629ab82c3..ba5d8e5bad2 100644 --- a/sys/dev/usb/usbdi_util.c +++ b/sys/dev/usb/usbdi_util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usbdi_util.c,v 1.37 2014/07/09 15:47:54 mpi Exp $ */ +/* $OpenBSD: usbdi_util.c,v 1.38 2014/08/08 14:20:05 mpi Exp $ */ /* $NetBSD: usbdi_util.c,v 1.40 2002/07/11 21:14:36 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdi_util.c,v 1.14 1999/11/17 22:33:50 n_hibma Exp $ */ @@ -113,6 +113,21 @@ usbd_get_hub_descriptor(struct usbd_device *dev, usb_hub_descriptor_t *hd, return (usbd_do_request(dev, &req, hd)); } +usbd_status +usbd_get_hub_ss_descriptor(struct usbd_device *dev, usb_hub_ss_descriptor_t *hd, + uint8_t nports) +{ + usb_device_request_t req; + uint16_t len = USB_HUB_SS_DESCRIPTOR_SIZE + (nports + 1) / 8; + + req.bmRequestType = UT_READ_CLASS_DEVICE; + req.bRequest = UR_GET_DESCRIPTOR; + USETW2(req.wValue, UDESC_SS_HUB, 0); + USETW(req.wIndex, 0); + USETW(req.wLength, len); + return (usbd_do_request(dev, &req, hd)); +} + usbd_status usbd_get_port_status(struct usbd_device *dev, int port, usb_port_status_t *ps) { diff --git a/sys/dev/usb/usbdi_util.h b/sys/dev/usb/usbdi_util.h index b79622a6a90..85d8d884045 100644 --- a/sys/dev/usb/usbdi_util.h +++ b/sys/dev/usb/usbdi_util.h @@ -1,4 +1,4 @@ -/* $OpenBSD: usbdi_util.h,v 1.26 2014/07/09 15:47:54 mpi Exp $ */ +/* $OpenBSD: usbdi_util.h,v 1.27 2014/08/08 14:20:05 mpi Exp $ */ /* $NetBSD: usbdi_util.h,v 1.28 2002/07/11 21:14:36 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdi_util.h,v 1.9 1999/11/17 22:33:50 n_hibma Exp $ */ @@ -44,6 +44,8 @@ usbd_status usbd_get_device_status(struct usbd_device *, usb_status_t *); usbd_status usbd_get_hub_status(struct usbd_device *, usb_hub_status_t *); usbd_status usbd_get_hub_descriptor(struct usbd_device *, usb_hub_descriptor_t *, uint8_t); +usbd_status usbd_get_hub_ss_descriptor(struct usbd_device *, + usb_hub_ss_descriptor_t *, uint8_t); struct usb_hid_descriptor *usbd_get_hid_descriptor(struct usbd_device *, usb_interface_descriptor_t *); usbd_status usbd_get_report(struct usbd_device *, int, int, int, void *,