9
0
Fork 0

USB: Use descriptors from ch11.h

Use the descriptors from ch11.h instead of duplicating them
in usb.h. usb_hub_descriptor now contains a union .u to differentiate
HS hub descriptor from SS hub descriptor.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sebastian Hesselbarth 2014-07-23 15:51:50 +02:00 committed by Sascha Hauer
parent f261bce3a6
commit 6931e9007c
3 changed files with 8 additions and 33 deletions

View File

@ -332,17 +332,17 @@ static int usb_hub_configure(struct usb_device *dev)
hub->desc.wHubCharacteristics =
le16_to_cpu(descriptor->wHubCharacteristics);
/* set the bitmap */
bitmap = (unsigned char *)&hub->desc.DeviceRemovable[0];
bitmap = (unsigned char *)&hub->desc.u.hs.DeviceRemovable[0];
/* devices not removable by default */
memset(bitmap, 0xff, (USB_MAXCHILDREN+1+7)/8);
bitmap = (unsigned char *)&hub->desc.PortPowerCtrlMask[0];
bitmap = (unsigned char *)&hub->desc.u.hs.PortPwrCtrlMask[0];
memset(bitmap, 0xff, (USB_MAXCHILDREN+1+7)/8); /* PowerMask = 1B */
for (i = 0; i < ((hub->desc.bNbrPorts + 1 + 7)/8); i++)
hub->desc.DeviceRemovable[i] = descriptor->DeviceRemovable[i];
hub->desc.u.hs.DeviceRemovable[i] = descriptor->u.hs.DeviceRemovable[i];
for (i = 0; i < ((hub->desc.bNbrPorts + 1 + 7)/8); i++)
hub->desc.PortPowerCtrlMask[i] = descriptor->PortPowerCtrlMask[i];
hub->desc.u.hs.PortPwrCtrlMask[i] = descriptor->u.hs.PortPwrCtrlMask[i];
dev->maxchild = descriptor->bNbrPorts;
dev_dbg(&dev->dev, "%d ports detected\n", dev->maxchild);
@ -385,7 +385,7 @@ static int usb_hub_configure(struct usb_device *dev)
for (i = 0; i < dev->maxchild; i++)
dev_dbg(&dev->dev, "port %d is%s removable\n", i + 1,
hub->desc.DeviceRemovable[(i + 1) / 8] & \
hub->desc.u.hs.DeviceRemovable[(i + 1) / 8] & \
(1 << ((i + 1) % 8)) ? " not" : "");
if (sizeof(struct usb_hub_status) > USB_BUFSIZ) {

View File

@ -69,8 +69,8 @@ static struct descriptor {
.wHubCharacteristics = 0,
.bPwrOn2PwrGood = 10,
.bHubContrCurrent = 0,
.DeviceRemovable = {},
.PortPowerCtrlMask = {}
.u.hs.DeviceRemovable = {},
.u.hs.PortPwrCtrlMask = {}
},
.device = {
.bLength = USB_DT_DEVICE_SIZE,

View File

@ -24,6 +24,7 @@
#include <driver.h>
#include <usb/ch9.h>
#include <usb/ch11.h>
#include <usb/usb_defs.h>
#include <asm/byteorder.h>
@ -311,32 +312,6 @@ void usb_rescan(void);
/*************************************************************************
* Hub Stuff
*/
struct usb_port_status {
unsigned short wPortStatus;
unsigned short wPortChange;
} __attribute__ ((packed));
struct usb_hub_status {
unsigned short wHubStatus;
unsigned short wHubChange;
} __attribute__ ((packed));
/* Hub descriptor */
struct usb_hub_descriptor {
unsigned char bLength;
unsigned char bDescriptorType;
unsigned char bNbrPorts;
unsigned short wHubCharacteristics;
unsigned char bPwrOn2PwrGood;
unsigned char bHubContrCurrent;
unsigned char DeviceRemovable[(USB_MAXCHILDREN+1+7)/8];
unsigned char PortPowerCtrlMask[(USB_MAXCHILDREN+1+7)/8];
/* DeviceRemovable and PortPwrCtrlMask want to be variable-length
bitmaps that hold max 255 entries. (bit0 is ignored) */
} __attribute__ ((packed));
struct usb_hub_device {
struct usb_device *pusb_dev;
struct usb_hub_descriptor desc;