mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-27 16:01:27 +00:00
usb: hub: Change USB hub descriptor to match USB 3.0 hubs
USB 3.0 hubs have a slightly different hub descriptor than USB 2.0 hubs, with a fixed (rather than variable length) size. Change the host controller drivers that access those last two fields (DeviceRemovable and PortPowerCtrlMask) to use the union. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Stefan Roese <sr@denx.de> Tested-by: Stefan Roese <sr@denx.de>
This commit is contained in:
parent
53771a490e
commit
337fc7e665
5 changed files with 31 additions and 14 deletions
|
@ -583,17 +583,19 @@ static int usb_hub_configure(struct usb_device *dev)
|
||||||
&descriptor->wHubCharacteristics)),
|
&descriptor->wHubCharacteristics)),
|
||||||
&hub->desc.wHubCharacteristics);
|
&hub->desc.wHubCharacteristics);
|
||||||
/* set the bitmap */
|
/* set the bitmap */
|
||||||
bitmap = (unsigned char *)&hub->desc.DeviceRemovable[0];
|
bitmap = (unsigned char *)&hub->desc.u.hs.DeviceRemovable[0];
|
||||||
/* devices not removable by default */
|
/* devices not removable by default */
|
||||||
memset(bitmap, 0xff, (USB_MAXCHILDREN+1+7)/8);
|
memset(bitmap, 0xff, (USB_MAXCHILDREN+1+7)/8);
|
||||||
bitmap = (unsigned char *)&hub->desc.PortPowerCtrlMask[0];
|
bitmap = (unsigned char *)&hub->desc.u.hs.PortPowerCtrlMask[0];
|
||||||
memset(bitmap, 0xff, (USB_MAXCHILDREN+1+7)/8); /* PowerMask = 1B */
|
memset(bitmap, 0xff, (USB_MAXCHILDREN+1+7)/8); /* PowerMask = 1B */
|
||||||
|
|
||||||
for (i = 0; i < ((hub->desc.bNbrPorts + 1 + 7)/8); i++)
|
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++)
|
for (i = 0; i < ((hub->desc.bNbrPorts + 1 + 7)/8); i++)
|
||||||
hub->desc.PortPowerCtrlMask[i] = descriptor->PortPowerCtrlMask[i];
|
hub->desc.u.hs.PortPowerCtrlMask[i] =
|
||||||
|
descriptor->u.hs.PortPowerCtrlMask[i];
|
||||||
|
|
||||||
dev->maxchild = descriptor->bNbrPorts;
|
dev->maxchild = descriptor->bNbrPorts;
|
||||||
debug("%d ports detected\n", dev->maxchild);
|
debug("%d ports detected\n", dev->maxchild);
|
||||||
|
@ -637,7 +639,7 @@ static int usb_hub_configure(struct usb_device *dev)
|
||||||
|
|
||||||
for (i = 0; i < dev->maxchild; i++)
|
for (i = 0; i < dev->maxchild; i++)
|
||||||
debug("port %d is%s removable\n", i + 1,
|
debug("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" : "");
|
(1 << ((i + 1) % 8)) ? " not" : "");
|
||||||
|
|
||||||
if (sizeof(struct usb_hub_status) > USB_BUFSIZ) {
|
if (sizeof(struct usb_hub_status) > USB_BUFSIZ) {
|
||||||
|
|
|
@ -96,7 +96,12 @@ static struct usb_hub_descriptor hub_desc = {
|
||||||
1 << 7),
|
1 << 7),
|
||||||
.bPwrOn2PwrGood = 2,
|
.bPwrOn2PwrGood = 2,
|
||||||
.bHubContrCurrent = 5,
|
.bHubContrCurrent = 5,
|
||||||
.DeviceRemovable = {0, 0xff}, /* all ports removeable */
|
{
|
||||||
|
{
|
||||||
|
/* all ports removeable */
|
||||||
|
.DeviceRemovable = {0, 0xff}
|
||||||
|
}
|
||||||
|
}
|
||||||
#if SANDBOX_NUM_PORTS > 8
|
#if SANDBOX_NUM_PORTS > 8
|
||||||
#error "This code sets up an incorrect mask"
|
#error "This code sets up an incorrect mask"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -52,8 +52,8 @@ static struct descriptor {
|
||||||
0, /* wHubCharacteristics */
|
0, /* wHubCharacteristics */
|
||||||
10, /* bPwrOn2PwrGood */
|
10, /* bPwrOn2PwrGood */
|
||||||
0, /* bHubCntrCurrent */
|
0, /* bHubCntrCurrent */
|
||||||
{}, /* Device removable */
|
{ /* Device removable */
|
||||||
{} /* at most 7 ports! XXX */
|
} /* at most 7 ports! XXX */
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
0x12, /* bLength */
|
0x12, /* bLength */
|
||||||
|
|
|
@ -50,8 +50,8 @@ static struct descriptor {
|
||||||
cpu_to_le16(0x8), /* wHubCharacteristics */
|
cpu_to_le16(0x8), /* wHubCharacteristics */
|
||||||
10, /* bPwrOn2PwrGood */
|
10, /* bPwrOn2PwrGood */
|
||||||
0, /* bHubCntrCurrent */
|
0, /* bHubCntrCurrent */
|
||||||
{}, /* Device removable */
|
{ /* Device removable */
|
||||||
{} /* at most 7 ports! XXX */
|
} /* at most 7 ports! XXX */
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
0x12, /* bLength */
|
0x12, /* bLength */
|
||||||
|
|
|
@ -546,10 +546,20 @@ struct usb_hub_descriptor {
|
||||||
unsigned short wHubCharacteristics;
|
unsigned short wHubCharacteristics;
|
||||||
unsigned char bPwrOn2PwrGood;
|
unsigned char bPwrOn2PwrGood;
|
||||||
unsigned char bHubContrCurrent;
|
unsigned char bHubContrCurrent;
|
||||||
unsigned char DeviceRemovable[(USB_MAXCHILDREN+1+7)/8];
|
/* 2.0 and 3.0 hubs differ here */
|
||||||
unsigned char PortPowerCtrlMask[(USB_MAXCHILDREN+1+7)/8];
|
union {
|
||||||
/* DeviceRemovable and PortPwrCtrlMask want to be variable-length
|
struct {
|
||||||
bitmaps that hold max 255 entries. (bit0 is ignored) */
|
/* add 1 bit for hub status change; round to bytes */
|
||||||
|
__u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8];
|
||||||
|
__u8 PortPowerCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8];
|
||||||
|
} __attribute__ ((packed)) hs;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
__u8 bHubHdrDecLat;
|
||||||
|
__le16 wHubDelay;
|
||||||
|
__le16 DeviceRemovable;
|
||||||
|
} __attribute__ ((packed)) ss;
|
||||||
|
} u;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue