usb: hub: Support USB 3.0 hubs
Subsystems (2)
cover usb: hub: Support USB 3.0 hubs
This series is a follow-up series to previous series [1] that adds support for USB 3.0 hubs.
USB 3.0 hubs have slightly different hub descriptor format, as well as different port status bit positions. These needs to be properly handled by U-Boot USB core stack codes. xHCI driver has also been updated to correctly set up context structures that are required for devices behind a 3.0 hub to work.
Besides USB 3.0 hubs support, this series also adds support for low speed/full speed devices connected behind a high speed hub with the xHC controller. It turns out the 'Transaction Translator' part in the xHC data structure is missing.
Note there is one error during testing USB keyboard when CONFIG_USB_KEYBOARD is on.
"Failed to get keyboard state from device 413c:2105"
The enumeration process did pass and the error was thrown in the USB keyboard driver. This was due to the interrupt transfer is still not supported by xHCI driver, as of today.
This series is available at u-boot-x86/xhci-working2 for testing.
[1] https://lists.denx.de/pipermail/u-boot/2017-June/296166.html
Bin Meng (16):
usb: xhci-pci: Drop non-DM version of xhci-pci driver
usb: xhci-pci: Clean up the driver a little bit
usb: Remove unnecessary work in usb_setup_descriptor()
usb: hub: Use 'struct usb_hub_device' as hub device's uclass_priv
usb: hub: Add a new API to test if a hub device is root hub
usb: xhci: Change to use usb_hub_is_root_hub() API
usb: hub: Translate USB 3.0 hub port status into old version
usb: hub: Support 'set hub depth' request for USB 3.0 hubs
usb: xhci: Change xhci_setup_addressable_virt_dev() signature
usb: xhci: Program 'route string' in the input slot context
usb: hub: Parse and save TT details from device descriptor
dm: usb: Add a new USB controller operation 'update_hub_device'
usb: hub: Call usb_update_hub_device() after hub descriptor is fetched
usb: xhci: Implement update_hub_device() operation
usb: xhci: Correct TT_SLOT and TT_PORT macros
usb: xhci: Enable TT to support LS/FS devices behind a HS hub
common/usb.c | 40 +++++----- common/usb_hub.c | 166 +++++++++++++++++++++++++++++++++++++++++- drivers/usb/host/usb-uclass.c | 13 +++- drivers/usb/host/xhci-mem.c | 40 +++++++++- drivers/usb/host/xhci-pci.c | 68 +---------------- drivers/usb/host/xhci.c | 85 +++++++++++++++------ drivers/usb/host/xhci.h | 8 +- include/usb.h | 46 +++++++++++- include/usb_defs.h | 15 ++++ 9 files changed, 357 insertions(+), 124 deletions(-)
Signature · 1 line
2.9.2
PATCH 1/16 usb: xhci-pci: Drop non-DM version of xhci-pci driver
As there is no board that currently uses xhci-pci driver without DM USB, drop its support and leave only DM support.
---
drivers/usb/host/xhci-pci.c | 52 --------------------------------------------- 1 file changed, 52 deletions(-)
drivers/usb/host/xhci-pci.c +0 -52
@@ -14,56 +14,6 @@#include "xhci.h" -#ifndef CONFIG_DM_USB - -/* -* Create the appropriate control structures to manage a new XHCI host -* controller. -*/ -int xhci_hcd_init (int index,struct xhci_hccr **ret_hccr, -struct xhci_hcor **ret_hcor) -{ -struct xhci_hccr *hccr; -struct xhci_hcor *hcor; -pci_dev_t pdev; -uint32_t cmd; -int len; - - pdev =pci_find_class (PCI_CLASS_SERIAL_USB_XHCI , index); -if (pdev <0 ) { -printf ("XHCI host controller not found\n" ); -return -1 ; - } - - hccr = (struct xhci_hccr *)pci_map_bar (pdev, -PCI_BASE_ADDRESS_0 ,PCI_REGION_MEM ); - len =HC_LENGTH (xhci_readl (&hccr->cr_capbase)); - hcor = (struct xhci_hcor *)((uint32_t )hccr + len); - -debug ("XHCI-PCI init hccr 0x%x and hcor 0x%x hc_length %d\n" , - (uint32_t )hccr, (uint32_t )hcor, len); - - *ret_hccr = hccr; - *ret_hcor = hcor; - -/* enable busmaster */ -pci_read_config_dword (pdev,PCI_COMMAND , &cmd); - cmd |=PCI_COMMAND_MASTER ; -pci_write_config_dword (pdev,PCI_COMMAND , cmd); - -return 0 ; -} - -/* -* Destroy the appropriate control structures corresponding * to the XHCI host -* controller -*/ -void xhci_hcd_stop (int index) -{ -} - -#else -struct xhci_pci_priv {struct xhci_ctrl ctrl;/* Needs to come first in this struct! */ };
@@ -137,5 +87,3 @@ static struct pci_device_id xhci_pci_supported[] = { };U_BOOT_PCI_DEVICE (xhci_pci, xhci_pci_supported); - -#endif /* CONFIG_DM_USB */
Signature · 1 line
2.9.2
PATCH 1/16 usb: xhci-pci: Drop non-DM version of xhci-pci driver
Quoted 2 lines · Bin Meng
As there is no board that currently uses xhci-pci driver without DM USB, drop its support and leave only DM support.
You should add something into the Kconfig to make this driver depend on DM_USB ; unless it's already there.
Quoted 74 lines
Signed-off-by Bin Meng <[email protected]>---
drivers/usb/host/xhci-pci.c | 52 --------------------------------------------- 1 file changed, 52 deletions(-)drivers/usb/host/xhci-pci.c +0
-52@@ -14,56 +14,6 @@#include "xhci.h" -#ifndef CONFIG_DM_USB - -/* -* Create the appropriate control structures to manage a new XHCI host -* controller. -*/ -int xhci_hcd_init (int index,struct xhci_hccr **ret_hccr, -struct xhci_hcor **ret_hcor) -{ -struct xhci_hccr *hccr; -struct xhci_hcor *hcor; -pci_dev_t pdev; -uint32_t cmd; -int len; - - pdev =pci_find_class (PCI_CLASS_SERIAL_USB_XHCI , index); -if (pdev <0 ) { -printf ("XHCI host controller not found\n" ); -return -1 ; - } - - hccr = (struct xhci_hccr *)pci_map_bar (pdev, -PCI_BASE_ADDRESS_0 ,PCI_REGION_MEM ); - len =HC_LENGTH (xhci_readl (&hccr->cr_capbase)); - hcor = (struct xhci_hcor *)((uint32_t )hccr + len); - -debug ("XHCI-PCI init hccr 0x%x and hcor 0x%x hc_length %d\n" , - (uint32_t )hccr, (uint32_t )hcor, len); - - *ret_hccr = hccr; - *ret_hcor = hcor; - -/* enable busmaster */ -pci_read_config_dword (pdev,PCI_COMMAND , &cmd); - cmd |=PCI_COMMAND_MASTER ; -pci_write_config_dword (pdev,PCI_COMMAND , cmd); - -return 0 ; -} - -/* -* Destroy the appropriate control structures corresponding * to the XHCI host -* controller -*/ -void xhci_hcd_stop (int index) -{ -} - -#else -struct xhci_pci_priv {struct xhci_ctrl ctrl;/* Needs to come first in this struct! */ };@@ -137,5 +87,3 @@ static struct pci_device_id xhci_pci_supported[] = { };U_BOOT_PCI_DEVICE (xhci_pci, xhci_pci_supported); - -#endif /* CONFIG_DM_USB */
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/16 usb: xhci-pci: Drop non-DM version of xhci-pci driver
In reply to Bin MengQuoted 9 lines · Bin Meng
As there is no board that currently uses xhci-pci driver without DM USB, drop its support and leave only DM support.
Signed-off-by Bin Meng <[email protected]>---
drivers/usb/host/xhci-pci.c | 52 --------------------------------------------- 1 file changed, 52 deletions(-)
Note for Marek: CONFIG_USB_XHCI_PCI is not in Kconfig yet.
PATCH 2/16 usb: xhci-pci: Clean up the driver a little bit
In reply to Bin MengThis cleans up the driver a little bit.
---
drivers/usb/host/xhci-pci.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-)
drivers/usb/host/xhci-pci.c +2 -14
@@ -8,16 +8,10 @@#include <common.h> #include <dm.h> -#include <errno.h> #include <pci.h> #include <usb.h> -#include "xhci.h" -struct xhci_pci_priv { -struct xhci_ctrl ctrl;/* Needs to come first in this struct! */ -}; -static void xhci_pci_init (struct udevice *dev,struct xhci_hccr **ret_hccr,struct xhci_hcor **ret_hcor) {
@@ -55,13 +49,7 @@ static int xhci_pci_probe(struct udevice *dev)static int xhci_pci_remove (struct udevice *dev) { -int ret; - - ret =xhci_deregister (dev); -if (ret) -return ret; - -return 0 ; +return xhci_deregister (dev); }static const struct udevice_id xhci_pci_ids[] = {
@@ -77,7 +65,7 @@ U_BOOT_DRIVER(xhci_pci) = { .of_match = xhci_pci_ids, .ops = &xhci_usb_ops, .platdata_auto_alloc_size = sizeof(struct usb_platdata), - .priv_auto_alloc_size = sizeof(struct xhci_pci_priv), + .priv_auto_alloc_size = sizeof(struct xhci_ctrl), .flags = DM_FLAG_ALLOC_PRIV_DMA, };
Signature · 1 line
2.9.2
PATCH 2/16 usb: xhci-pci: Clean up the driver a little bit
Quoted 31 lines · Bin Meng
This cleans up the driver a little bit.
Signed-off-by Bin Meng <[email protected]>---
drivers/usb/host/xhci-pci.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-)drivers/usb/host/xhci-pci.c +0
-6@@ -8,16 +8,10 @@#include <common.h> #include <dm.h> -#include <errno.h> #include <pci.h> #include <usb.h> -#include "xhci.h" -struct xhci_pci_priv { -struct xhci_ctrl ctrl;/* Needs to come first in this struct! */ -}; -static void xhci_pci_init (struct udevice *dev,struct xhci_hccr **ret_hccr,struct xhci_hcor **ret_hcor) {@@ -55,13 +49,7 @@ static int xhci_pci_probe(struct udevice *dev)
drivers/usb/host/xhci-pci.c static int xhci_pci_probe(struct udevice *dev) · line 52
Quoted 10 lines
drivers/usb/host/xhci-pci.c +1
-7static int xhci_pci_remove (struct udevice *dev) { -int ret; - - ret =xhci_deregister (dev); -if (ret) -return ret; - -return 0 ; +return xhci_deregister (dev);
Can you insert xhci_deregister directly into the callbacks structure and nuke xhci_pci_remove() altogether ?
Quoted 13 lines
drivers/usb/host/xhci-pci.c +1
-1}static const struct udevice_id xhci_pci_ids[] = {@@ -77,7 +65,7 @@ U_BOOT_DRIVER(xhci_pci) = { .of_match = xhci_pci_ids, .ops = &xhci_usb_ops, .platdata_auto_alloc_size = sizeof(struct usb_platdata), - .priv_auto_alloc_size = sizeof(struct xhci_pci_priv), + .priv_auto_alloc_size = sizeof(struct xhci_ctrl), .flags = DM_FLAG_ALLOC_PRIV_DMA, };
Signature · 2 lines
Best regards, Marek Vasut
PATCH 2/16 usb: xhci-pci: Clean up the driver a little bit
Quoted 32 lines · Marek Vasut
Quoted 31 lines · Bin Meng
This cleans up the driver a little bit.
Signed-off-by Bin Meng <[email protected]>---
drivers/usb/host/xhci-pci.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-)drivers/usb/host/xhci-pci.c +0
-6@@ -8,16 +8,10 @@#include <common.h> #include <dm.h> -#include <errno.h> #include <pci.h> #include <usb.h> -#include "xhci.h" -struct xhci_pci_priv { -struct xhci_ctrl ctrl;/* Needs to come first in this struct! */ -}; -static void xhci_pci_init (struct udevice *dev,struct xhci_hccr **ret_hccr,struct xhci_hcor **ret_hcor) {@@ -55,13 +49,7 @@ static int xhci_pci_probe(struct udevice *dev)
Quoted 13 lines
drivers/usb/host/xhci-pci.c static int xhci_pci_probe(struct udevice *dev) · line 52
Quoted 10 lines
drivers/usb/host/xhci-pci.c +1
-7static int xhci_pci_remove (struct udevice *dev) { -int ret; - - ret =xhci_deregister (dev); -if (ret) -return ret; - -return 0 ; +return xhci_deregister (dev);Can you insert
xhci_deregisterdirectly into the callbacks structure and nukexhci_pci_remove()altogether ?
Either way:
Quoted 19 lines
Quoted 6 lines
drivers/usb/host/xhci-pci.c +0
-0}static const struct udevice_id xhci_pci_ids[] = {drivers/usb/host/xhci-pci.c U_BOOT_DRIVER(xhci_pci) = { · line 71
Quoted 8 lines
drivers/usb/host/xhci-pci.c +1
-1@@ -77,7 +65,7 @@ U_BOOT_DRIVER(xhci_pci) = { .of_match = xhci_pci_ids, .ops = &xhci_usb_ops, .platdata_auto_alloc_size = sizeof(struct usb_platdata), - .priv_auto_alloc_size = sizeof(struct xhci_pci_priv), + .priv_auto_alloc_size = sizeof(struct xhci_ctrl), .flags = DM_FLAG_ALLOC_PRIV_DMA, };--
Best regards,
Marek Vasut
PATCH 3/16 usb: Remove unnecessary work in usb_setup_descriptor()
In reply to Bin MengThe only work we need do in usb_setup_descriptor() is to initialize dev->descriptor.bMaxPacketSize0, when do_read is false. Other steps are the same as do_read being true.
While we are here, update the comment block to be within 80 cols.
---
common/usb.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-)
common/usb.c +18 -22
@@ -962,37 +962,33 @@ static int usb_setup_descriptor(struct usb_device *dev, bool do_read)* some more, or keeps on retransmitting the 8 byte header. */ -if (dev->speed ==USB_SPEED_LOW ) { - dev->descriptor.bMaxPacketSize0 =8 ; - dev->maxpacketsize =PACKET_SIZE_8 ; - }else { - dev->descriptor.bMaxPacketSize0 =64 ; - dev->maxpacketsize =PACKET_SIZE_64 ; - } - dev->epmaxpacketin[0 ] = dev->descriptor.bMaxPacketSize0; - dev->epmaxpacketout[0 ] = dev->descriptor.bMaxPacketSize0; -if (do_read) {int err;/* -* Validate we've received only at least 8 bytes, not that we've -* received the entire descriptor. The reasoning is: -* - The code only uses fields in the first 8 bytes, so that's all we -* need to have fetched at this stage. -* - The smallest maxpacket size is 8 bytes. Before we know the actual -* maxpacket the device uses, the USB controller may only accept a -* single packet. Consequently we are only guaranteed to receive 1 -* packet (at least 8 bytes) even in a non-error case. +* Validate we've received only at least 8 bytes, not that +* we've received the entire descriptor. The reasoning is: +* - The code only uses fields in the first 8 bytes, so that's +* all we need to have fetched at this stage. +* - The smallest maxpacket size is 8 bytes. Before we know +* the actual maxpacket the device uses, the USB controller +* may only accept a single packet. Consequently we are only +* guaranteed to receive 1 packet (at least 8 bytes) even in +* a non-error case. * -* At least the DWC2 controller needs to be programmed with the number -* of packets in addition to the number of bytes. A request for 64 -* bytes of data with the maxpacket guessed as 64 (above) yields a -* request for 1 packet. +* At least the DWC2 controller needs to be programmed with +* the number of packets in addition to the number of bytes. +* A request for 64 bytes of data with the maxpacket guessed +* as 64 (above) yields a request for 1 packet. */ err =get_descriptor_len (dev,64 ,8 );if (err)return err; + }else { +if (dev->speed ==USB_SPEED_LOW ) + dev->descriptor.bMaxPacketSize0 =8 ; +else + dev->descriptor.bMaxPacketSize0 =64 ; } dev->epmaxpacketin[0 ] = dev->descriptor.bMaxPacketSize0;
Signature · 1 line
2.9.2
PATCH 3/16 usb: Remove unnecessary work in usb_setup_descriptor()
Hi,
Quoted 63 lines · Bin Meng
The only work we need do in
usb_setup_descriptor()is to initializedev->descriptor.bMaxPacketSize0, whendo_readis false. Other steps are the same asdo_readbeing true.While we are here, update the comment block to be within 80 cols.
Signed-off-by Bin Meng <[email protected]>---
common/usb.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-)common/usb.c +13
-22@@ -962,37 +962,33 @@ static int usb_setup_descriptor(struct usb_device *dev, bool do_read)* some more, or keeps on retransmitting the 8 byte header. */ -if (dev->speed ==USB_SPEED_LOW ) { - dev->descriptor.bMaxPacketSize0 =8 ; - dev->maxpacketsize =PACKET_SIZE_8 ; - }else { - dev->descriptor.bMaxPacketSize0 =64 ; - dev->maxpacketsize =PACKET_SIZE_64 ; - } - dev->epmaxpacketin[0 ] = dev->descriptor.bMaxPacketSize0; - dev->epmaxpacketout[0 ] = dev->descriptor.bMaxPacketSize0; -if (do_read) {int err;/* -* Validate we've received only at least 8 bytes, not that we've -* received the entire descriptor. The reasoning is: -* - The code only uses fields in the first 8 bytes, so that's all we -* need to have fetched at this stage. -* - The smallest maxpacket size is 8 bytes. Before we know the actual -* maxpacket the device uses, the USB controller may only accept a -* single packet. Consequently we are only guaranteed to receive 1 -* packet (at least 8 bytes) even in a non-error case. +* Validate we've received only at least 8 bytes, not that +* we've received the entire descriptor. The reasoning is: +* - The code only uses fields in the first 8 bytes, so that's +* all we need to have fetched at this stage. +* - The smallest maxpacket size is 8 bytes. Before we know +* the actual maxpacket the device uses, the USB controller +* may only accept a single packet. Consequently we are only +* guaranteed to receive 1 packet (at least 8 bytes) even in +* a non-error case. * -* At least the DWC2 controller needs to be programmed with the number -* of packets in addition to the number of bytes. A request for 64 -* bytes of data with the maxpacket guessed as 64 (above) yields a -* request for 1 packet. +* At least the DWC2 controller needs to be programmed with +* the number of packets in addition to the number of bytes. +* A request for 64 bytes of data with the maxpacket guessed +* as 64 (above) yields a request for 1 packet. */ err =get_descriptor_len (dev,64 ,8 );if (err)
common/usb.c static int usb_setup_descriptor(struct usb_device *dev, bool do_read)
Quoted 10 lines
common/usb.c +5
-1return err; + }else { +if (dev->speed ==USB_SPEED_LOW ) + dev->descriptor.bMaxPacketSize0 =8 ; +else + dev->descriptor.bMaxPacketSize0 =64 ; } dev->epmaxpacketin[0 ] = dev->descriptor.bMaxPacketSize0; --
For some reason that I don't understand, this patch breaks EHCI. dev->maxpacketsize is equal to zero with this patch, which leads to a 'divide error' exception in ehci_submit_async(). Not sure if anyone has some hints?
For now, I will just drop this patch in v2. This needs be further revisited.
Regards,
Bin
PATCH 3/16 usb: Remove unnecessary work in usb_setup_descriptor()
Hi,
Quoted 74 lines · On Fri, 30 Jun 2017 11:49:56 +0800 Bin Meng wrote:
Hi,
Quoted 71 lines · Bin Meng
The only work we need do in
usb_setup_descriptor()is to initializedev->descriptor.bMaxPacketSize0, whendo_readis false. Other steps are the same asdo_readbeing true.While we are here, update the comment block to be within 80 cols.
Signed-off-by Bin Meng <[email protected]>---
common/usb.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-)common/usb.c +18
-22@@ -962,37 +962,33 @@ static int usb_setup_descriptor(struct usb_device *dev, bool do_read)* some more, or keeps on retransmitting the 8 byte header. */ -if (dev->speed ==USB_SPEED_LOW ) { - dev->descriptor.bMaxPacketSize0 =8 ; - dev->maxpacketsize =PACKET_SIZE_8 ; - }else { - dev->descriptor.bMaxPacketSize0 =64 ; - dev->maxpacketsize =PACKET_SIZE_64 ; - } - dev->epmaxpacketin[0 ] = dev->descriptor.bMaxPacketSize0; - dev->epmaxpacketout[0 ] = dev->descriptor.bMaxPacketSize0; -if (do_read) {int err;/* -* Validate we've received only at least 8 bytes, not that we've -* received the entire descriptor. The reasoning is: -* - The code only uses fields in the first 8 bytes, so that's all we -* need to have fetched at this stage. -* - The smallest maxpacket size is 8 bytes. Before we know the actual -* maxpacket the device uses, the USB controller may only accept a -* single packet. Consequently we are only guaranteed to receive 1 -* packet (at least 8 bytes) even in a non-error case. +* Validate we've received only at least 8 bytes, not that +* we've received the entire descriptor. The reasoning is: +* - The code only uses fields in the first 8 bytes, so that's +* all we need to have fetched at this stage. +* - The smallest maxpacket size is 8 bytes. Before we know +* the actual maxpacket the device uses, the USB controller +* may only accept a single packet. Consequently we are only +* guaranteed to receive 1 packet (at least 8 bytes) even in +* a non-error case. * -* At least the DWC2 controller needs to be programmed with the number -* of packets in addition to the number of bytes. A request for 64 -* bytes of data with the maxpacket guessed as 64 (above) yields a -* request for 1 packet. +* At least the DWC2 controller needs to be programmed with +* the number of packets in addition to the number of bytes. +* A request for 64 bytes of data with the maxpacket guessed +* as 64 (above) yields a request for 1 packet. */ err =get_descriptor_len (dev,64 ,8 );if (err)return err; + }else { +if (dev->speed ==USB_SPEED_LOW ) + dev->descriptor.bMaxPacketSize0 =8 ; +else + dev->descriptor.bMaxPacketSize0 =64 ; }
Quoted 8 lines
common/usb.c static int usb_setup_descriptor(struct usb_device *dev, bool do_read)
Quoted 2 lines
common/usb.c +0
-1dev->epmaxpacketin[0 ] = dev->descriptor.bMaxPacketSize0; --For some reason that I don't understand, this patch breaks EHCI.
dev->maxpacketsizeis equal to zero with this patch, which leads to a 'divide error' exception inehci_submit_async(). Not sure if anyone has some hints?
In the do_read case the dev->descriptor.bMaxPacketSize0 is not set up.
Lothar Waßmann
PATCH 3/16 usb: Remove unnecessary work in usb_setup_descriptor()
Hi Lothar,
Quoted 85 lines · Lothar Waßmann
Hi,
Quoted 74 lines · On Fri, 30 Jun 2017 11:49:56 +0800 Bin Meng wrote:
Hi,
Quoted 71 lines · Bin Meng
The only work we need do in
usb_setup_descriptor()is to initializedev->descriptor.bMaxPacketSize0, whendo_readis false. Other steps are the same asdo_readbeing true.While we are here, update the comment block to be within 80 cols.
Signed-off-by Bin Meng <[email protected]>---
common/usb.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-)common/usb.c +18
-22@@ -962,37 +962,33 @@ static int usb_setup_descriptor(struct usb_device *dev, bool do_read)* some more, or keeps on retransmitting the 8 byte header. */ -if (dev->speed ==USB_SPEED_LOW ) { - dev->descriptor.bMaxPacketSize0 =8 ; - dev->maxpacketsize =PACKET_SIZE_8 ; - }else { - dev->descriptor.bMaxPacketSize0 =64 ; - dev->maxpacketsize =PACKET_SIZE_64 ; - } - dev->epmaxpacketin[0 ] = dev->descriptor.bMaxPacketSize0; - dev->epmaxpacketout[0 ] = dev->descriptor.bMaxPacketSize0; -if (do_read) {int err;/* -* Validate we've received only at least 8 bytes, not that we've -* received the entire descriptor. The reasoning is: -* - The code only uses fields in the first 8 bytes, so that's all we -* need to have fetched at this stage. -* - The smallest maxpacket size is 8 bytes. Before we know the actual -* maxpacket the device uses, the USB controller may only accept a -* single packet. Consequently we are only guaranteed to receive 1 -* packet (at least 8 bytes) even in a non-error case. +* Validate we've received only at least 8 bytes, not that +* we've received the entire descriptor. The reasoning is: +* - The code only uses fields in the first 8 bytes, so that's +* all we need to have fetched at this stage. +* - The smallest maxpacket size is 8 bytes. Before we know +* the actual maxpacket the device uses, the USB controller +* may only accept a single packet. Consequently we are only +* guaranteed to receive 1 packet (at least 8 bytes) even in +* a non-error case. * -* At least the DWC2 controller needs to be programmed with the number -* of packets in addition to the number of bytes. A request for 64 -* bytes of data with the maxpacket guessed as 64 (above) yields a -* request for 1 packet. +* At least the DWC2 controller needs to be programmed with +* the number of packets in addition to the number of bytes. +* A request for 64 bytes of data with the maxpacket guessed +* as 64 (above) yields a request for 1 packet. */ err =get_descriptor_len (dev,64 ,8 );if (err)return err; + }else { +if (dev->speed ==USB_SPEED_LOW ) + dev->descriptor.bMaxPacketSize0 =8 ; +else + dev->descriptor.bMaxPacketSize0 =64 ; }Quoted 8 lines
common/usb.c static int usb_setup_descriptor(struct usb_device *dev, bool do_read)
Quoted 2 lines
common/usb.c +0
-1dev->epmaxpacketin[0 ] = dev->descriptor.bMaxPacketSize0; --For some reason that I don't understand, this patch breaks EHCI.
dev->maxpacketsizeis equal to zero with this patch, which leads to a 'divide error' exception inehci_submit_async(). Not sure if anyone has some hints?
Quoted 2 lines
In the
do_readcase thedev->descriptor.bMaxPacketSize0is not set up.
In that case, dev->descriptor.bMaxPacketSize0 was read from device. Am I missing anything?
Regards,
Bin
PATCH 3/16 usb: Remove unnecessary work in usb_setup_descriptor()
In reply to Bin MengQuoted 24 lines · On Freitag, 30. Juni 2017 05:49:56 CEST Bin Meng wrote:
Hi,
Quoted 21 lines · Bin Meng
The only work we need do in
usb_setup_descriptor()is to initializedev->descriptor.bMaxPacketSize0, whendo_readis false. Other steps are the same asdo_readbeing true.While we are here, update the comment block to be within 80 cols.
Signed-off-by Bin Meng <[email protected]>---
common/usb.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-)common/usb.c +0
-0@@ -962,37 +962,33 @@ static int usb_setup_descriptor(struct usb_device*dev, bool do_read)> * some more, or keeps on retransmitting the 8 byte header. */
Quoted 10 lines
common/usb.c static int usb_setup_descriptor(struct usb_device *dev, bool do_read) · line 974
Quoted 10 lines
common/usb.c +0
-10-if (dev->speed ==USB_SPEED_LOW ) { - dev->descriptor.bMaxPacketSize0 =8 ; - dev->maxpacketsize =PACKET_SIZE_8 ; - }else { - dev->descriptor.bMaxPacketSize0 =64 ; - dev->maxpacketsize =PACKET_SIZE_64 ; - } - dev->epmaxpacketin[0 ] = dev->descriptor.bMaxPacketSize0; - dev->epmaxpacketout[0 ] = dev->descriptor.bMaxPacketSize0; -
You remove the initialization of dev->maxpacketsize here ...
Quoted 3 lines
Quoted 3 lines
common/usb.c +0
-0if (do_read) {
[...]
Quoted 7 lines
Quoted 7 lines
*/ err = get_descriptor_len(dev, 64, 8); if (err) return err;
... and probably return early here. Can you add some debug output to get_descriptor_len(...) (len, expected len, return code)?
Quoted 11 lines
Quoted 11 lines
common/usb.c +5
-0+ }else { +if (dev->speed ==USB_SPEED_LOW ) + dev->descriptor.bMaxPacketSize0 =8 ; +else + dev->descriptor.bMaxPacketSize0 =64 ; } dev->epmaxpacketin[0 ] = dev->descriptor.bMaxPacketSize0;
Quoted 8 lines
Quoted 1 line
--
For some reason that I don't understand, this patch breaks EHCI.
dev->maxpacketsizeis equal to zero with this patch, which leads to a 'divide error' exception inehci_submit_async(). Not sure if anyone has some hints?For now, I will just drop this patch in v2. This needs be further revisited.
Kind regards,
Stefan
PATCH 3/16 usb: Remove unnecessary work in usb_setup_descriptor()
Hi Stefan,
Quoted 45 lines · On Sun, Jul 2, 2017 at 1:29 AM, <[email protected]> wrote:
Quoted 24 lines · On Freitag, 30. Juni 2017 05:49:56 CEST Bin Meng wrote:
Hi,
Quoted 21 lines · Bin Meng
The only work we need do in
usb_setup_descriptor()is to initializedev->descriptor.bMaxPacketSize0, whendo_readis false. Other steps are the same asdo_readbeing true.While we are here, update the comment block to be within 80 cols.
Signed-off-by Bin Meng <[email protected]>---
common/usb.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-)common/usb.c +0
-0@@ -962,37 +962,33 @@ static int usb_setup_descriptor(struct usb_device*dev, bool do_read)> * some more, or keeps on retransmitting the 8 byte header. */ Quoted 10 lines
common/usb.c static int usb_setup_descriptor(struct usb_device *dev, bool do_read) · line 974
Quoted 10 lines
common/usb.c +0
-10-if (dev->speed ==USB_SPEED_LOW ) { - dev->descriptor.bMaxPacketSize0 =8 ; - dev->maxpacketsize =PACKET_SIZE_8 ; - }else { - dev->descriptor.bMaxPacketSize0 =64 ; - dev->maxpacketsize =PACKET_SIZE_64 ; - } - dev->epmaxpacketin[0 ] = dev->descriptor.bMaxPacketSize0; - dev->epmaxpacketout[0 ] = dev->descriptor.bMaxPacketSize0; -You remove the initialization of
dev->maxpacketsizehere ...Quoted 3 lines
Quoted 3 lines
common/usb.c +0
-0if (do_read) {[...]
Quoted 3 lines
Quoted 3 lines
*/
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
err = get_descriptor_len(dev, 64, 8); if (err) return err;... and probably return early here. Can you add some debug output to
get_descriptor_len(...)(len, expected len, return code)?
The get_descriptor_len() was successful, so it is not caused by the "if (err)" branch.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
common/usb.c +5
-0+ }else { +if (dev->speed ==USB_SPEED_LOW ) + dev->descriptor.bMaxPacketSize0 =8 ; +else + dev->descriptor.bMaxPacketSize0 =64 ; } dev->epmaxpacketin[0 ] = dev->descriptor.bMaxPacketSize0;
Quoted 9 lines
Quoted 8 lines
Quoted 1 line
--
For some reason that I don't understand, this patch breaks EHCI.
dev->maxpacketsizeis equal to zero with this patch, which leads to a 'divide error' exception inehci_submit_async(). Not sure if anyone has some hints?For now, I will just drop this patch in v2. This needs be further revisited.
Regards,
Bin
PATCH 4/16 usb: hub: Use 'struct usb_hub_device' as hub device's uclass_priv
In reply to Bin MengUse USB hub device's dev->uclass_priv to point to 'usb_hub_device' so that with driver model usb_hub_reset() and usb_hub_allocate() are no longer needed.
---
common/usb_hub.c | 10 +++++++++- drivers/usb/host/usb-uclass.c | 2 -- 2 files changed, 9 insertions(+), 3 deletions(-)
common/usb_hub.c +9 -1
@@ -58,9 +58,10 @@ struct usb_device_scan {struct list_head list; }; -/* TODO(sjg at chromium.org): Remove this when CONFIG_DM_USB is defined */ +#ifndef CONFIG_DM_USB static struct usb_hub_device hub_dev[USB_MAX_HUB ];static int usb_hub_index; +#endif static LIST_HEAD (usb_scan_list);__weak void usb_hub_reset_devices (int port)
@@ -167,6 +168,7 @@ static void usb_hub_power_on(struct usb_hub_device *hub) max(100, (int)pgood_delay) + 1000); } +#ifndef CONFIG_DM_USB void usb_hub_reset (void ) { usb_hub_index =0 ;
@@ -183,6 +185,7 @@ static struct usb_hub_device *usb_hub_allocate(void)printf ("ERROR: USB_MAX_HUB (%d) reached\n" ,USB_MAX_HUB ); return NULL; } +#endif #define MAX_TRIES 5
@@ -557,10 +560,14 @@ static int usb_hub_configure(struct usb_device *dev)__maybe_unused struct usb_hub_status *hubsts;int ret; +#ifndef CONFIG_DM_USB /* "allocate" Hub device */ hub =usb_hub_allocate ();if (hub ==NULL )return -ENOMEM ; +#else + hub =dev_get_uclass_priv (dev->dev); +#endif hub->pusb_dev = dev;/* Get the the hub descriptor */ ret =usb_get_hub_descriptor (dev, buffer,4 );
@@ -795,6 +802,7 @@ UCLASS_DRIVER(usb_hub) = { .child_pre_probe = usb_child_pre_probe, .per_child_auto_alloc_size = sizeof(struct usb_device), .per_child_platdata_auto_alloc_size = sizeof(struct usb_dev_platdata), + .per_device_auto_alloc_size = sizeof(struct usb_hub_device), };static const struct usb_device_id hub_id_table[] = {
drivers/usb/host/usb-uclass.c +0 -2
@@ -177,7 +177,6 @@ int usb_stop(void)#ifdef CONFIG_USB_STORAGE usb_stor_reset ();#endif -usb_hub_reset (); uc_priv->companion_device_count =0 ; usb_started =0 ;
@@ -230,7 +229,6 @@ int usb_init(void)int ret; asynch_allowed =1 ; -usb_hub_reset (); ret =uclass_get (UCLASS_USB , &uc);if (ret)
Signature · 1 line
2.9.2
PATCH 4/16 usb: hub: Use 'struct usb_hub_device' as hub device's uclass_priv
Quoted 5 lines · Bin Meng
Use USB hub device's
dev->uclass_privto point to 'usb_hub_device' so that with driver modelusb_hub_reset()andusb_hub_allocate()are no longer needed.Signed-off-by Bin Meng <[email protected]>
Can you trim down the ifdeffery somehow or keep it more contained ? I don't like having the code polluted by ifdefs all over the place, so maybe factor out the specialties into function and put ifdef around that or somesuch.
Quoted 82 lines
---
common/usb_hub.c | 10 +++++++++- drivers/usb/host/usb-uclass.c | 2 -- 2 files changed, 9 insertions(+), 3 deletions(-)common/usb_hub.c +9
-1@@ -58,9 +58,10 @@ struct usb_device_scan {struct list_head list; }; -/* TODO(sjg at chromium.org): Remove this when CONFIG_DM_USB is defined */ +#ifndef CONFIG_DM_USB static struct usb_hub_device hub_dev[USB_MAX_HUB ];static int usb_hub_index; +#endif static LIST_HEAD (usb_scan_list);__weak void usb_hub_reset_devices (int port)@@ -167,6 +168,7 @@ static void usb_hub_power_on(struct usb_hub_device *hub) max(100, (int)pgood_delay) + 1000); } +#ifndef CONFIG_DM_USB void usb_hub_reset (void ) { usb_hub_index =0 ;@@ -183,6 +185,7 @@ static struct usb_hub_device *usb_hub_allocate(void)printf ("ERROR: USB_MAX_HUB (%d) reached\n" ,USB_MAX_HUB ); return NULL; } +#endif #define MAX_TRIES 5@@ -557,10 +560,14 @@ static int usb_hub_configure(struct usb_device *dev)__maybe_unused struct usb_hub_status *hubsts;int ret; +#ifndef CONFIG_DM_USB /* "allocate" Hub device */ hub =usb_hub_allocate ();if (hub ==NULL )return -ENOMEM ; +#else + hub =dev_get_uclass_priv (dev->dev); +#endif hub->pusb_dev = dev;/* Get the the hub descriptor */ ret =usb_get_hub_descriptor (dev, buffer,4 );@@ -795,6 +802,7 @@ UCLASS_DRIVER(usb_hub) = { .child_pre_probe = usb_child_pre_probe, .per_child_auto_alloc_size = sizeof(struct usb_device), .per_child_platdata_auto_alloc_size = sizeof(struct usb_dev_platdata), + .per_device_auto_alloc_size = sizeof(struct usb_hub_device), };static const struct usb_device_id hub_id_table[] = {drivers/usb/host/usb-uclass.c +0
-2@@ -177,7 +177,6 @@ int usb_stop(void)#ifdef CONFIG_USB_STORAGE usb_stor_reset ();#endif -usb_hub_reset (); uc_priv->companion_device_count =0 ; usb_started =0 ;@@ -230,7 +229,6 @@ int usb_init(void)int ret; asynch_allowed =1 ; -usb_hub_reset (); ret =uclass_get (UCLASS_USB , &uc);if (ret)
Signature · 2 lines
Best regards, Marek Vasut
PATCH 4/16 usb: hub: Use 'struct usb_hub_device' as hub device's uclass_priv
In reply to Bin MengQuoted 10 lines · Bin Meng
Use USB hub device's
dev->uclass_privto point to 'usb_hub_device' so that with driver modelusb_hub_reset()andusb_hub_allocate()are no longer needed.Signed-off-by Bin Meng <[email protected]>---
common/usb_hub.c | 10 +++++++++- drivers/usb/host/usb-uclass.c | 2 -- 2 files changed, 9 insertions(+), 3 deletions(-)
PATCH 5/16 usb: hub: Add a new API to test if a hub device is root hub
In reply to Bin MengSometimes we need know if a given hub device is root hub or not. Add a new API to test this.
---
common/usb_hub.c | 10 ++++++++++ include/usb.h | 8 ++++++++ 2 files changed, 18 insertions(+)
common/usb_hub.c +10 -0
@@ -74,6 +74,16 @@ static inline bool usb_hub_is_superspeed(struct usb_device *hdev)return hdev->descriptor.bDeviceProtocol ==3 ; } +#ifdef CONFIG_DM_USB +bool usb_hub_is_root_hub (struct udevice *hub) +{ +if (device_get_uclass_id (hub->parent) !=UCLASS_USB_HUB ) +return true; + +return false; +} +#endif +static int usb_get_hub_descriptor (struct usb_device *dev,void *data,int size) {unsigned short dtype =USB_DT_HUB ;
include/usb.h +8 -0
@@ -776,6 +776,14 @@ int usb_setup_device(struct usb_device *dev, bool do_read, struct usb_device *parent);/** +* usb_hub_is_root_hub() - Test whether a hub device is root hub or not +* +* @hub: USB hub device to test +* @return: true if the hub device is root hub, false otherwise. +*/ +bool usb_hub_is_root_hub (struct udevice *hub); + +/** * usb_hub_scan() - Scan a hub and find its devices * * @hub: Hub device to scan
Signature · 1 line
2.9.2
PATCH 5/16 usb: hub: Add a new API to test if a hub device is root hub
Quoted 15 lines · Bin Meng
Sometimes we need know if a given hub device is root hub or not. Add a new API to test this.
Signed-off-by Bin Meng <[email protected]>---
common/usb_hub.c | 10 ++++++++++ include/usb.h | 8 ++++++++ 2 files changed, 18 insertions(+)common/usb_hub.c +0
-0
common/usb_hub.c static inline bool usb_hub_is_superspeed(struct usb_device *hdev) · line 80
Quoted 7 lines
common/usb_hub.c +4
-0@@ -74,6 +74,16 @@ static inline bool usb_hub_is_superspeed(struct usb_device *hdev)return hdev->descriptor.bDeviceProtocol ==3 ; } +#ifdef CONFIG_DM_USB +bool usb_hub_is_root_hub (struct udevice *hub) +{ +if (device_get_uclass_id (hub->parent) !=UCLASS_USB_HUB )
Can this call fail ?
Quoted 29 lines
common/usb_hub.c +6
-0+return true; + + return false; +} +#endif +static int usb_get_hub_descriptor (struct usb_device *dev,void *data,int size) {unsigned short dtype =USB_DT_HUB ;include/usb.h +8
-0@@ -776,6 +776,14 @@ int usb_setup_device(struct usb_device *dev, bool do_read, struct usb_device *parent);/** +* usb_hub_is_root_hub() - Test whether a hub device is root hub or not +* +* @hub: USB hub device to test +* @return: true if the hub device is root hub, false otherwise. +*/ +bool usb_hub_is_root_hub (struct udevice *hub); + +/** * usb_hub_scan() - Scan a hub and find its devices * * @hub: Hub device to scan
Signature · 2 lines
Best regards, Marek Vasut
PATCH 5/16 usb: hub: Add a new API to test if a hub device is root hub
Hi Marek,
Quoted 19 lines · Marek Vasut
Quoted 18 lines · Bin Meng
Sometimes we need know if a given hub device is root hub or not. Add a new API to test this.
Signed-off-by Bin Meng <[email protected]>---
common/usb_hub.c | 10 ++++++++++ include/usb.h | 8 ++++++++ 2 files changed, 18 insertions(+)common/usb_hub.c +0
-0@@ -74,6 +74,16 @@ static inline bool usb_hub_is_superspeed(struct usb_device *hdev)return hdev->descriptor.bDeviceProtocol ==3 ; }
Quoted 6 lines
common/usb_hub.c static inline bool usb_hub_is_superspeed(struct usb_device *hdev) · line 80
Quoted 4 lines
common/usb_hub.c +4
-0+#ifdef CONFIG_DM_USB +bool usb_hub_is_root_hub (struct udevice *hub) +{ +if (device_get_uclass_id (hub->parent) !=UCLASS_USB_HUB )Can this call fail ?
No,
Regards,
Bin
PATCH 5/16 usb: hub: Add a new API to test if a hub device is root hub
In reply to Bin MengQuoted 15 lines · Bin Meng
Sometimes we need know if a given hub device is root hub or not. Add a new API to test this.
Signed-off-by Bin Meng <[email protected]>---
common/usb_hub.c | 10 ++++++++++ include/usb.h | 8 ++++++++ 2 files changed, 18 insertions(+)common/usb_hub.c +0
-0
common/usb_hub.c static inline bool usb_hub_is_superspeed(struct usb_device *hdev) · line 78
Quoted 5 lines
common/usb_hub.c +2
-0@@ -74,6 +74,16 @@ static inline bool usb_hub_is_superspeed(struct usb_device *hdev)return hdev->descriptor.bDeviceProtocol ==3 ; } +#ifdef CONFIG_DM_USB +bool usb_hub_is_root_hub (struct udevice *hub)
Actually , this is the is_root_hub() from the 6/16 , right , not a new API. If you want to factor out stuff , just do that , but also remove the is_root_hub() and do the conversion in the same patch.
Quoted 31 lines
common/usb_hub.c +8
-0+{ +if (device_get_uclass_id (hub->parent) !=UCLASS_USB_HUB ) +return true; + +return false; +} +#endif +static int usb_get_hub_descriptor (struct usb_device *dev,void *data,int size) {unsigned short dtype =USB_DT_HUB ;include/usb.h +8
-0@@ -776,6 +776,14 @@ int usb_setup_device(struct usb_device *dev, bool do_read, struct usb_device *parent);/** +* usb_hub_is_root_hub() - Test whether a hub device is root hub or not +* +* @hub: USB hub device to test +* @return: true if the hub device is root hub, false otherwise. +*/ +bool usb_hub_is_root_hub (struct udevice *hub); + +/** * usb_hub_scan() - Scan a hub and find its devices * * @hub: Hub device to scan
Signature · 2 lines
Best regards, Marek Vasut
PATCH 5/16 usb: hub: Add a new API to test if a hub device is root hub
Hi Marek,
Quoted 19 lines · Marek Vasut
Quoted 18 lines · Bin Meng
Sometimes we need know if a given hub device is root hub or not. Add a new API to test this.
Signed-off-by Bin Meng <[email protected]>---
common/usb_hub.c | 10 ++++++++++ include/usb.h | 8 ++++++++ 2 files changed, 18 insertions(+)common/usb_hub.c +0
-0@@ -74,6 +74,16 @@ static inline bool usb_hub_is_superspeed(struct usb_device *hdev)return hdev->descriptor.bDeviceProtocol ==3 ; }
Quoted 7 lines
common/usb_hub.c static inline bool usb_hub_is_superspeed(struct usb_device *hdev) · line 78
Quoted 2 lines
common/usb_hub.c +2
-0+#ifdef CONFIG_DM_USB +bool usb_hub_is_root_hub (struct udevice *hub)Actually , this is the
is_root_hub()from the 6/16 , right , not a new API. If you want to factor out stuff , just do that , but also remove theis_root_hub()and do the conversion in the same patch.
Correct, is_root_hub() is static within xhci.c and only used by part of the xHCI driver. To other USB codes, this is a new API. The two patches (5/16, 6/16) are still self-contained, as each is against a single module. But if you would like to do the two in one patch, let me know and I will do in v2.
[snip]
Regards,
Bin
PATCH 5/16 usb: hub: Add a new API to test if a hub device is root hub
Quoted 30 lines · Bin Meng
Hi Marek,
Quoted 19 lines · Marek Vasut
Quoted 18 lines · Bin Meng
Sometimes we need know if a given hub device is root hub or not. Add a new API to test this.
Signed-off-by Bin Meng <[email protected]>---
common/usb_hub.c | 10 ++++++++++ include/usb.h | 8 ++++++++ 2 files changed, 18 insertions(+)common/usb_hub.c +0
-0@@ -74,6 +74,16 @@ static inline bool usb_hub_is_superspeed(struct usb_device *hdev)return hdev->descriptor.bDeviceProtocol ==3 ; }Quoted 7 lines
common/usb_hub.c static inline bool usb_hub_is_superspeed(struct usb_device *hdev) · line 78
Quoted 2 lines
common/usb_hub.c +2
-0+#ifdef CONFIG_DM_USB +bool usb_hub_is_root_hub (struct udevice *hub)Actually , this is the
is_root_hub()from the 6/16 , right , not a new API. If you want to factor out stuff , just do that , but also remove theis_root_hub()and do the conversion in the same patch.
Quoted 5 lines
Correct,
is_root_hub()is static withinxhci.cand only used by part of the xHCI driver. To other USB codes, this is a new API. The two patches (5/16, 6/16) are still self-contained, as each is against a single module. But if you would like to do the two in one patch, let me know and I will do in v2.
I'd like a patch which pulls this out of xhci driver, yes.
Quoted 5 lines
[snip]
Regards,
Bin
Signature · 2 lines
Best regards, Marek Vasut
PATCH 6/16 usb: xhci: Change to use usb_hub_is_root_hub() API
In reply to Bin MengNow that we have a generic public API, remove the xHCI driver's own version is_root_hub() and use the new API.
While we are here, remove the unused/commented out get_usb_device().
---
drivers/usb/host/xhci.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-)
drivers/usb/host/xhci.c +2 -22
@@ -1116,26 +1116,6 @@ int usb_lowlevel_stop(int index)#endif /* CONFIG_DM_USB */ #ifdef CONFIG_DM_USB -/* -static struct usb_device *get_usb_device(struct udevice *dev) -{ -struct usb_device *udev; - -if (device_get_uclass_id(dev) == UCLASS_USB) -udev = dev_get_uclass_priv(dev); -else -udev = dev_get_parent_priv(dev); - -return udev; -} -*/ -static bool is_root_hub (struct udevice *dev) -{ -if (device_get_uclass_id (dev->parent) !=UCLASS_USB_HUB ) -return true; - -return false; -} static int xhci_submit_control_msg(struct udevice *dev, struct usb_device *udev, unsigned long pipe, void *buffer, int length,
@@ -1150,10 +1130,10 @@ static int xhci_submit_control_msg(struct udevice *dev, struct usb_device *udev, hub = udev->dev;if (device_get_uclass_id (hub) ==UCLASS_USB_HUB ) {/* Figure out our port number on the root hub */ -if (is_root_hub (hub)) { +if (usb_hub_is_root_hub (hub)) { root_portnr = udev->portnr; }else { -while (!is_root_hub (hub->parent)) +while (!usb_hub_is_root_hub (hub->parent)) hub = hub->parent; uhop =dev_get_parent_priv (hub); root_portnr = uhop->portnr;
Signature · 1 line
2.9.2
PATCH 6/16 usb: xhci: Change to use usb_hub_is_root_hub() API
Quoted 10 lines · Bin Meng
Now that we have a generic public API, remove the xHCI driver's own version
is_root_hub()and use the new API.While we are here, remove the unused/commented out
get_usb_device().Signed-off-by Bin Meng <[email protected]>---
drivers/usb/host/xhci.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-)
PATCH 7/16 usb: hub: Translate USB 3.0 hub port status into old version
In reply to Bin MengUSB 3.0 hub port status field has different bit positions from 2.0 hubs. Since U-Boot only understands the old version, translate the new one into the old one.
Since we are going to add USB 3.0 hub support, this feature is only available with driver model USB.
---
common/usb_hub.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-)
common/usb_hub.c +32 -1
@@ -119,9 +119,40 @@ static int usb_get_hub_status(struct usb_device *dev, void *data)int usb_get_port_status (struct usb_device *dev,int port,void *data) { -return usb_control_msg (dev,usb_rcvctrlpipe (dev,0 ), +int ret; + + ret =usb_control_msg (dev,usb_rcvctrlpipe (dev,0 ),USB_REQ_GET_STATUS ,USB_DIR_IN |USB_RT_PORT ,0 , port, data,sizeof (struct usb_port_status ),USB_CNTL_TIMEOUT ); + +#ifdef CONFIG_DM_USB +if (ret <0 ) +return ret; + +/* +* Translate the USB 3.0 hub port status field into the old version +* that U-Boot understands. Do this only when the hub is not root hub. +* For root hub, the port status field has already been translated +* in the host controller driver (see xhci_submit_root() in xhci.c). +* +* Note: this only supports driver model. +*/ + +if (!usb_hub_is_root_hub (dev->dev) &&usb_hub_is_superspeed (dev)) { +struct usb_port_status *status = (struct usb_port_status *)data; +u16 tmp = (status->wPortStatus) &USB_SS_PORT_STAT_MASK ; + +if (status->wPortStatus &USB_SS_PORT_STAT_POWER ) + tmp |=USB_PORT_STAT_POWER ; +if ((status->wPortStatus &USB_SS_PORT_STAT_SPEED ) == +USB_SS_PORT_STAT_SPEED_5GBPS ) + tmp |=USB_PORT_STAT_SUPER_SPEED ; + + status->wPortStatus = tmp; + } +#endif + +return ret; }
Signature · 1 line
2.9.2
PATCH 7/16 usb: hub: Translate USB 3.0 hub port status into old version
Quoted 3 lines · Bin Meng
USB 3.0 hub port status field has different bit positions from 2.0 hubs. Since U-Boot only understands the old version, translate the new one into the old one.
This is quite hairy. I'd rather see some protocol version agnostic flag field rather than patching the wPortStatus and co.
Quoted 56 lines
Since we are going to add USB 3.0 hub support, this feature is only available with driver model USB.
Signed-off-by Bin Meng <[email protected]>---
common/usb_hub.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-)common/usb_hub.c +32
-1@@ -119,9 +119,40 @@ static int usb_get_hub_status(struct usb_device *dev, void *data)int usb_get_port_status (struct usb_device *dev,int port,void *data) { -return usb_control_msg (dev,usb_rcvctrlpipe (dev,0 ), +int ret; + + ret =usb_control_msg (dev,usb_rcvctrlpipe (dev,0 ),USB_REQ_GET_STATUS ,USB_DIR_IN |USB_RT_PORT ,0 , port, data,sizeof (struct usb_port_status ),USB_CNTL_TIMEOUT ); + +#ifdef CONFIG_DM_USB +if (ret <0 ) +return ret; + +/* +* Translate the USB 3.0 hub port status field into the old version +* that U-Boot understands. Do this only when the hub is not root hub. +* For root hub, the port status field has already been translated +* in the host controller driver (see xhci_submit_root() in xhci.c). +* +* Note: this only supports driver model. +*/ + +if (!usb_hub_is_root_hub (dev->dev) &&usb_hub_is_superspeed (dev)) { +struct usb_port_status *status = (struct usb_port_status *)data; +u16 tmp = (status->wPortStatus) &USB_SS_PORT_STAT_MASK ; + +if (status->wPortStatus &USB_SS_PORT_STAT_POWER ) + tmp |=USB_PORT_STAT_POWER ; +if ((status->wPortStatus &USB_SS_PORT_STAT_SPEED ) == +USB_SS_PORT_STAT_SPEED_5GBPS ) + tmp |=USB_PORT_STAT_SUPER_SPEED ; + + status->wPortStatus = tmp; + } +#endif + +return ret; }
Signature · 2 lines
Best regards, Marek Vasut
PATCH 7/16 usb: hub: Translate USB 3.0 hub port status into old version
Hi Marek,
Quoted 8 lines · Marek Vasut
Quoted 3 lines · Bin Meng
USB 3.0 hub port status field has different bit positions from 2.0 hubs. Since U-Boot only understands the old version, translate the new one into the old one.
This is quite hairy. I'd rather see some protocol version agnostic flag field rather than patching the wPortStatus and co.
I am not sure how do do that in a clean way. If we return the raw 3.0 hub port status data, that means we need change lot of hub codes here and there to do different parsing.
Quoted 9 lines
Quoted 9 lines
Since we are going to add USB 3.0 hub support, this feature is only available with driver model USB.
Signed-off-by Bin Meng <[email protected]>---
common/usb_hub.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-)
[snip]
Regards,
Bin
PATCH 7/16 usb: hub: Translate USB 3.0 hub port status into old version
Quoted 8 lines · Bin Meng
Hi Marek,
Quoted 5 lines · Marek Vasut
Quoted 3 lines · Bin Meng
USB 3.0 hub port status field has different bit positions from 2.0 hubs. Since U-Boot only understands the old version, translate the new one into the old one.
Quoted 7 lines
Quoted 3 lines
This is quite hairy. I'd rather see some protocol version agnostic flag field rather than patching the wPortStatus and co.
I am not sure how do do that in a clean way. If we return the raw 3.0 hub port status data, that means we need change lot of hub codes here and there to do different parsing.
How does Linux handle this?
Signature · 2 lines
Best regards, Marek Vasut
PATCH 7/16 usb: hub: Translate USB 3.0 hub port status into old version
Hi Marek,
Quoted 13 lines · Marek Vasut
Quoted 12 lines · Bin Meng
Hi Marek,
Quoted 8 lines · Marek Vasut
Quoted 3 lines · Bin Meng
USB 3.0 hub port status field has different bit positions from 2.0 hubs. Since U-Boot only understands the old version, translate the new one into the old one.
This is quite hairy. I'd rather see some protocol version agnostic flag field rather than patching the wPortStatus and co.
Quoted 5 lines
Quoted 3 lines
I am not sure how do do that in a clean way. If we return the raw 3.0 hub port status data, that means we need change lot of hub codes here and there to do different parsing.
How does Linux handle this?
Looks Linux is doing different parsing depending on hub is 3.0 or 2.0, at least for the power bit that I was just looking at. Do you want to do that?
Regards,
Bin
PATCH 7/16 usb: hub: Translate USB 3.0 hub port status into old version
Hi Marek,
Quoted 20 lines · Bin Meng
Hi Marek,
Quoted 17 lines · Marek Vasut
Quoted 15 lines · Bin Meng
Hi Marek,
Quoted 8 lines · Marek Vasut
Quoted 3 lines · Bin Meng
USB 3.0 hub port status field has different bit positions from 2.0 hubs. Since U-Boot only understands the old version, translate the new one into the old one.
This is quite hairy. I'd rather see some protocol version agnostic flag field rather than patching the wPortStatus and co.
I am not sure how do do that in a clean way. If we return the raw 3.0 hub port status data, that means we need change lot of hub codes here and there to do different parsing.
Quoted 5 lines
Quoted 1 line
How does Linux handle this?
Looks Linux is doing different parsing depending on hub is 3.0 or 2.0, at least for the power bit that I was just looking at. Do you want to do that?
OK, I will do something similar like Linux in v2.
Regards,
Bin
PATCH 7/16 usb: hub: Translate USB 3.0 hub port status into old version
Quoted 23 lines · Bin Meng
Hi Marek,
Quoted 20 lines · Bin Meng
Hi Marek,
Quoted 17 lines · Marek Vasut
Quoted 15 lines · Bin Meng
Hi Marek,
Quoted 8 lines · Marek Vasut
Quoted 3 lines · Bin Meng
USB 3.0 hub port status field has different bit positions from 2.0 hubs. Since U-Boot only understands the old version, translate the new one into the old one.
This is quite hairy. I'd rather see some protocol version agnostic flag field rather than patching the wPortStatus and co.
I am not sure how do do that in a clean way. If we return the raw 3.0 hub port status data, that means we need change lot of hub codes here and there to do different parsing.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
How does Linux handle this?
Looks Linux is doing different parsing depending on hub is 3.0 or 2.0, at least for the power bit that I was just looking at. Do you want to do that?
OK, I will do something similar like Linux in v2.
Thanks
Signature · 2 lines
Best regards, Marek Vasut
PATCH 7/16 usb: hub: Translate USB 3.0 hub port status into old version
Hi Marek,
Quoted 26 lines · Marek Vasut
Quoted 25 lines · Bin Meng
Hi Marek,
Quoted 22 lines · Bin Meng
Hi Marek,
Quoted 18 lines · Marek Vasut
Quoted 8 lines · Bin Meng
Hi Marek,
Quoted 5 lines · Marek Vasut
Quoted 3 lines · Bin Meng
USB 3.0 hub port status field has different bit positions from 2.0 hubs. Since U-Boot only understands the old version, translate the new one into the old one.
Quoted 7 lines
Quoted 3 lines
This is quite hairy. I'd rather see some protocol version agnostic flag field rather than patching the wPortStatus and co.
I am not sure how do do that in a clean way. If we return the raw 3.0 hub port status data, that means we need change lot of hub codes here and there to do different parsing.
How does Linux handle this?
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Looks Linux is doing different parsing depending on hub is 3.0 or 2.0, at least for the power bit that I was just looking at. Do you want to do that?
OK, I will do something similar like Linux in v2.
Thanks
After I checked Linux codes in depth, it looks current way of handling 3.0 port status translation in this patch is the minimum way to fix the 3.0 hub port status problem in U-Boot. What Linux does is, one xHCI controller registers two buses, that one is USB 3.0 and the other is USB 2.0. All 3.0 devices will only show on the 3.0 bus, while all 1.0/2.0 devices will show on the 2.0 bus. We can certainly do similar thing in U-Boot, but I am afraid that will lead to a overhaul to current USB stack and xHCI driver. And most important, that support will be only under DM, which is something you don't like to see.
Regards,
Bin
PATCH 7/16 usb: hub: Translate USB 3.0 hub port status into old version
Quoted 38 lines · Bin Meng
Hi Marek,
Quoted 26 lines · Marek Vasut
Quoted 25 lines · Bin Meng
Hi Marek,
Quoted 22 lines · Bin Meng
Hi Marek,
Quoted 18 lines · Marek Vasut
Quoted 8 lines · Bin Meng
Hi Marek,
Quoted 5 lines · Marek Vasut
Quoted 3 lines · Bin Meng
USB 3.0 hub port status field has different bit positions from 2.0 hubs. Since U-Boot only understands the old version, translate the new one into the old one.
Quoted 7 lines
Quoted 3 lines
This is quite hairy. I'd rather see some protocol version agnostic flag field rather than patching the wPortStatus and co.
I am not sure how do do that in a clean way. If we return the raw 3.0 hub port status data, that means we need change lot of hub codes here and there to do different parsing.
How does Linux handle this?
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Looks Linux is doing different parsing depending on hub is 3.0 or 2.0, at least for the power bit that I was just looking at. Do you want to do that?
OK, I will do something similar like Linux in v2.
Thanks
Quoted 9 lines
After I checked Linux codes in depth, it looks current way of handling 3.0 port status translation in this patch is the minimum way to fix the 3.0 hub port status problem in U-Boot. What Linux does is, one xHCI controller registers two buses, that one is USB 3.0 and the other is USB 2.0. All 3.0 devices will only show on the 3.0 bus, while all 1.0/2.0 devices will show on the 2.0 bus. We can certainly do similar thing in U-Boot, but I am afraid that will lead to a overhaul to current USB stack and xHCI driver. And most important, that support will be only under DM, which is something you don't like to see.
IMO we should not be adding features to non-DM USB.
Anyway:
PATCH 8/16 usb: hub: Support 'set hub depth' request for USB 3.0 hubs
In reply to Bin MengUSB 3.0 hub uses a hub depth value multiplied by four as an offset into the 'route string' to locate the bits it uses to determine the downstream port number. We shall set the hub depth value of a USB 3.0 hub after it is configured.
---
common/usb_hub.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/usb.h | 1 + include/usb_defs.h | 3 +++ 3 files changed, 56 insertions(+)
common/usb_hub.c +52 -0
@@ -82,6 +82,16 @@ bool usb_hub_is_root_hub(struct udevice *hub) return false; } + +static int usb_set_hub_depth (struct usb_device *dev,int depth) +{ +if (depth <0 || depth >4 ) +return -EINVAL ; + +return usb_control_msg (dev,usb_sndctrlpipe (dev,0 ), +USB_REQ_SET_HUB_DEPTH ,USB_DIR_OUT |USB_RT_HUB , + depth,0 ,NULL ,0 ,USB_CNTL_TIMEOUT ); +}#endif static int usb_get_hub_descriptor (struct usb_device *dev,void *data,int size)
@@ -719,6 +729,48 @@ static int usb_hub_configure(struct usb_device *dev)debug ("%sover-current condition exists\n" , (le16_to_cpu (hubsts->wHubStatus) &HUB_STATUS_OVERCURRENT ) ? \"" :"no " ); + +#ifdef CONFIG_DM_USB +/* +* A maximum of seven tiers are allowed in a USB topology, and the +* root hub occupies the first tier. The last tier ends with a normal +* USB device. USB 3.0 hubs use a 20-bit field called 'route string' +* to route packet to the designated downstream port. The hub uses a +* hub depth value multiplied by four as an offset into the 'route +* string' to locate the bits it uses to determine the downstream +* port number. +*/ +if (usb_hub_is_root_hub (dev->dev)) { + hub->hub_depth =-1 ; + }else { +struct udevice *hdev; +int depth =0 ; + + hdev = dev->dev->parent; +while (!usb_hub_is_root_hub (hdev)) { + depth++; + hdev = hdev->parent; + } + + hub->hub_depth = depth; + +if (usb_hub_is_superspeed (dev)) { +debug ("set hub (%p) depth to %d\n" , dev, depth); +/* +* This request sets the value that the hub uses to +* determine the index into the 'route string index' +* for this hub. +*/ + ret =usb_set_hub_depth (dev, depth); +if (ret <0 ) { +debug ("%s: failed to set hub depth (%lX)\n" , + __func__, dev->status); +return ret; + } + } + } +#endif +usb_hub_power_on (hub);/*
include/usb.h +1 -0
@@ -570,6 +570,7 @@ struct usb_hub_device {ulong connect_timeout;/* Device connection timeout in ms */ ulong query_delay;/* Device query delay in ms */ int overcurrent_count[USB_MAXCHILDREN ];/* Over-current counter */ +int hub_depth;/* USB 3.0 hub depth */ };#ifdef CONFIG_DM_USB
include/usb_defs.h +3 -0
@@ -306,6 +306,9 @@/* Mask for wIndex in get/set port feature */ #define USB_HUB_PORT_MASK 0xf +/* Hub class request codes */ +#define USB_REQ_SET_HUB_DEPTH 0x0c +/* * CBI style */
Signature · 1 line
2.9.2
PATCH 8/16 usb: hub: Support 'set hub depth' request for USB 3.0 hubs
Quoted 5 lines · Bin Meng
USB 3.0 hub uses a hub depth value multiplied by four as an offset into the 'route string' to locate the bits it uses to determine the downstream port number. We shall set the hub depth value of a USB 3.0 hub after it is configured.
Quoted 7 lines
Signed-off-by Bin Meng <[email protected]>---
common/usb_hub.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/usb.h | 1 + include/usb_defs.h | 3 +++ 3 files changed, 56 insertions(+)
nit below
Quoted 23 lines
common/usb_hub.c +10
-0@@ -82,6 +82,16 @@ bool usb_hub_is_root_hub(struct udevice *hub) return false; } + +static int usb_set_hub_depth (struct usb_device *dev,int depth) +{ +if (depth <0 || depth >4 ) +return -EINVAL ; + +return usb_control_msg (dev,usb_sndctrlpipe (dev,0 ), +USB_REQ_SET_HUB_DEPTH ,USB_DIR_OUT |USB_RT_HUB , + depth,0 ,NULL ,0 ,USB_CNTL_TIMEOUT ); +}#endif static int usb_get_hub_descriptor (struct usb_device *dev,void *data,int size)
common/usb_hub.c static int usb_hub_configure(struct usb_device *dev) · line 738
Quoted 10 lines
common/usb_hub.c +7
-0@@ -719,6 +729,48 @@ static int usb_hub_configure(struct usb_device *dev)debug ("%sover-current condition exists\n" , (le16_to_cpu (hubsts->wHubStatus) &HUB_STATUS_OVERCURRENT ) ? \"" :"no " ); + +#ifdef CONFIG_DM_USB +/* +* A maximum of seven tiers are allowed in a USB topology, and the +* root hub occupies the first tier. The last tier ends with a normal +* USB device. USB 3.0 hubs use a 20-bit field called 'route string' +* to route packet to the designated downstream port. The hub uses a
should this be 'packets'?
[..]
PATCH 9/16 usb: xhci: Change xhci_setup_addressable_virt_dev() signature
In reply to Bin MengFor future extension, change xhci_setup_addressable_virt_dev() signature to accept a pointer to 'struct usb_device', instead of its members slot_id & speed, as the struct already contains these two plus some other useful information of the device.
---
drivers/usb/host/xhci-mem.c | 6 ++++-- drivers/usb/host/xhci.c | 3 +-- drivers/usb/host/xhci.h | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-)
drivers/usb/host/xhci-mem.c +4 -2
@@ -713,14 +713,16 @@ void xhci_slot_copy(struct xhci_ctrl *ctrl, struct xhci_container_ctx *in_ctx,* @param udev pointer to the Device Data Structure * @return returns negative value on failure else 0 on success */ -void xhci_setup_addressable_virt_dev (struct xhci_ctrl *ctrl,int slot_id, -int speed,int hop_portnr) +void xhci_setup_addressable_virt_dev (struct xhci_ctrl *ctrl, +struct usb_device *udev,int hop_portnr) {struct xhci_virt_device *virt_dev;struct xhci_ep_ctx *ep0_ctx;struct xhci_slot_ctx *slot_ctx;u32 port_num =0 ;u64 trb_64 =0 ; +int slot_id = udev->slot_id; +int speed = udev->speed; virt_dev = ctrl->devs[slot_id];
drivers/usb/host/xhci.c +1 -2
@@ -415,8 +415,7 @@ static int xhci_address_device(struct usb_device *udev, int root_portnr)* so setting up the slot context. */ debug ("Setting up addressable devices %p\n" , ctrl->dcbaa); -xhci_setup_addressable_virt_dev (ctrl, udev->slot_id, udev->speed, - root_portnr); +xhci_setup_addressable_virt_dev (ctrl, udev, root_portnr); ctrl_ctx =xhci_get_input_control_ctx (virt_dev->in_ctx); ctrl_ctx->add_flags =cpu_to_le32 (SLOT_FLAG |EP0_FLAG );
drivers/usb/host/xhci.h +2 -2
@@ -1247,8 +1247,8 @@ void xhci_endpoint_copy(struct xhci_ctrl *ctrl,void xhci_slot_copy (struct xhci_ctrl *ctrl,struct xhci_container_ctx *in_ctx,struct xhci_container_ctx *out_ctx); -void xhci_setup_addressable_virt_dev (struct xhci_ctrl *ctrl,int slot_id, -int speed,int hop_portnr); +void xhci_setup_addressable_virt_dev (struct xhci_ctrl *ctrl, +struct usb_device *udev,int hop_portnr);void xhci_queue_command (struct xhci_ctrl *ctrl,u8 *ptr,u32 slot_id,u32 ep_index,trb_type cmd);void xhci_acknowledge_event (struct xhci_ctrl *ctrl);
Signature · 1 line
2.9.2
PATCH 9/16 usb: xhci: Change xhci_setup_addressable_virt_dev() signature
Quoted 4 lines · Bin Meng
For future extension, change
xhci_setup_addressable_virt_dev()signature to accept a pointer to 'structusb_device', instead of its membersslot_id& speed, as the struct already contains these two plus some other useful information of the device.
I am guessing this is because you need the other info in a subsequent patch.
Quoted 8 lines
Signed-off-by Bin Meng <[email protected]>---
drivers/usb/host/xhci-mem.c | 6 ++++-- drivers/usb/host/xhci.c | 3 +-- drivers/usb/host/xhci.h | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-)
PATCH 10/16 usb: xhci: Program 'route string' in the input slot context
In reply to Bin MengxHCI spec says: the values of the 'route string' field shall be initialized by the first 'Address Device' command issued to a device slot, and shall not be modified by any other command.
So far U-Boot does not program this field, and it does not prevent SS device directly attached to root port, or HS device behind an HS hub, from working, due to the fact that 'route string' is used by the xHC to target SS packets. But in order to enumerate devices behind an SS hub, this field must be programmed.
With this commit and along with previous commits, now SS & HS devices attached to a USB 3.0 hub can be enumerated by U-Boot.
As usual, this new feature is only available when DM is on.
---
Test logs: two USB 3.0 hubs (one tier2, one tier3) => usb tree
USB device tree:
1 Hub (5 Gb/s, 0mA)
| U-Boot XHCI Host Controller
|
+-2 Hub (5 Gb/s, 0mA)
| | GenesysLogic USB3.0 Hub
| |
| +-4 Hub (5 Gb/s, 0mA)
| | | VIA Labs, Inc. USB3.0 Hub
| | |
| | +-7 Mass Storage (5 Gb/s, 76mA)
| | JetFlash Mass Storage Device 16Q6ZPH20GF3E8UQ
| |
| +-8 Vendor specific (5 Gb/s, 36mA)
| Realtek USB 10/100/1000 LAN 00E04C680977
|
+-3 Hub (480 Mb/s, 100mA)
| GenesysLogic USB2.0 Hub
|
+-5 Mass Storage (480 Mb/s, 200mA)
| Netac OnlyDisk FF00ECB60800FFFF1526
|
+-6 Hub (480 Mb/s, 0mA)
VIA Labs, Inc. USB2.0 Hubdrivers/usb/host/xhci-mem.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/usb/host/xhci-mem.c +19 -1
@@ -723,6 +723,9 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl,u64 trb_64 =0 ;int slot_id = udev->slot_id;int speed = udev->speed; +int route =0 ; +struct usb_device *dev = udev; +struct usb_hub_device *hub; virt_dev = ctrl->devs[slot_id];
@@ -733,7 +736,22 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl, slot_ctx =xhci_get_slot_ctx (ctrl, virt_dev->in_ctx);/* Only the control endpoint is valid - one endpoint context */ - slot_ctx->dev_info |=cpu_to_le32 (LAST_CTX (1 ) |0 ); + slot_ctx->dev_info |=cpu_to_le32 (LAST_CTX (1 )); + +#ifdef CONFIG_DM_USB +/* Calculate the route string for this device */ + port_num = dev->portnr; +while (!usb_hub_is_root_hub (dev->dev)) { + hub =dev_get_uclass_priv (dev->dev); + route |= port_num << (hub->hub_depth *4 ); + dev =dev_get_parent_priv (dev->dev); + port_num = dev->portnr; + dev =dev_get_parent_priv (dev->dev->parent); + } + +debug ("hub (%p) route string %x\n" , udev, route); +#endif + slot_ctx->dev_info |= route;switch (speed) {case USB_SPEED_SUPER :
Signature · 1 line
2.9.2
PATCH 10/16 usb: xhci: Program 'route string' in the input slot context
Quoted 10 lines · Bin Meng
xHCI spec says: the values of the 'route string' field shall be initialized by the first 'Address Device' command issued to a device slot, and shall not be modified by any other command.
So far U-Boot does not program this field, and it does not prevent SS device directly attached to root port, or HS device behind an HS hub, from working, due to the fact that 'route string' is used by the xHC to target SS packets. But in order to enumerate devices behind an SS hub, this field must be programmed.
Quoted 4 lines
With this commit and along with previous commits, now SS & HS devices attached to a USB 3.0 hub can be enumerated by U-Boot.
As usual, this new feature is only available when DM is on.
Great, but I really dislike the ifdef pollution, so this needs to be sorted out.
Quoted 72 lines
Signed-off-by Bin Meng <[email protected]>---
Test logs: two USB 3.0 hubs (one tier2, one tier3) => usb tree
USB device tree:
1 Hub (5 Gb/s, 0mA)
| U-Boot XHCI Host Controller
|+-2 Hub (5 Gb/s, 0mA) | | GenesysLogic USB3.0 Hub | | | +-4 Hub (5 Gb/s, 0mA) | | | VIA Labs, Inc. USB3.0 Hub | | | | | +-7 Mass Storage (5 Gb/s, 76mA) | | JetFlash Mass Storage Device 16Q6ZPH20GF3E8UQ | | | +-8 Vendor specific (5 Gb/s, 36mA) | Realtek USB 10/100/1000 LAN 00E04C680977 | +-3 Hub (480 Mb/s, 100mA) | GenesysLogic USB2.0 Hub | +-5 Mass Storage (480 Mb/s, 200mA) | Netac OnlyDisk FF00ECB60800FFFF1526 | +-6 Hub (480 Mb/s, 0mA) VIA Labs, Inc. USB2.0 Hubdrivers/usb/host/xhci-mem.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)drivers/usb/host/xhci-mem.c +19
-1@@ -723,6 +723,9 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl,u64 trb_64 =0 ;int slot_id = udev->slot_id;int speed = udev->speed; +int route =0 ; +struct usb_device *dev = udev; +struct usb_hub_device *hub; virt_dev = ctrl->devs[slot_id];@@ -733,7 +736,22 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl, slot_ctx =xhci_get_slot_ctx (ctrl, virt_dev->in_ctx);/* Only the control endpoint is valid - one endpoint context */ - slot_ctx->dev_info |=cpu_to_le32 (LAST_CTX (1 ) |0 ); + slot_ctx->dev_info |=cpu_to_le32 (LAST_CTX (1 )); + +#ifdef CONFIG_DM_USB +/* Calculate the route string for this device */ + port_num = dev->portnr; +while (!usb_hub_is_root_hub (dev->dev)) { + hub =dev_get_uclass_priv (dev->dev); + route |= port_num << (hub->hub_depth *4 ); + dev =dev_get_parent_priv (dev->dev); + port_num = dev->portnr; + dev =dev_get_parent_priv (dev->dev->parent); + } + +debug ("hub (%p) route string %x\n" , udev, route); +#endif + slot_ctx->dev_info |= route;switch (speed) {case USB_SPEED_SUPER :
Signature · 2 lines
Best regards, Marek Vasut
PATCH 10/16 usb: xhci: Program 'route string' in the input slot context
Hi Marek,
Quoted 11 lines · Marek Vasut
Quoted 10 lines · Bin Meng
xHCI spec says: the values of the 'route string' field shall be initialized by the first 'Address Device' command issued to a device slot, and shall not be modified by any other command.
So far U-Boot does not program this field, and it does not prevent SS device directly attached to root port, or HS device behind an HS hub, from working, due to the fact that 'route string' is used by the xHC to target SS packets. But in order to enumerate devices behind an SS hub, this field must be programmed.
Quoted 7 lines
Quoted 4 lines
With this commit and along with previous commits, now SS & HS devices attached to a USB 3.0 hub can be enumerated by U-Boot.
As usual, this new feature is only available when DM is on.
Great, but I really dislike the ifdef pollution, so this needs to be sorted out.
The ifdef was needed due to it calls DM APIs or access DM udevice. I have no intention to add a new feature to the non-DM driver. Eventually we can get rid of all these ifdefs when all boards are converted to use DM USB.
Quoted 23 lines
Quoted 23 lines
Signed-off-by Bin Meng <[email protected]>---
Test logs: two USB 3.0 hubs (one tier2, one tier3) => usb tree
USB device tree:
1 Hub (5 Gb/s, 0mA)
| U-Boot XHCI Host Controller
|+-2 Hub (5 Gb/s, 0mA) | | GenesysLogic USB3.0 Hub | | | +-4 Hub (5 Gb/s, 0mA) | | | VIA Labs, Inc. USB3.0 Hub | | | | | +-7 Mass Storage (5 Gb/s, 76mA) | | JetFlash Mass Storage Device 16Q6ZPH20GF3E8UQ | | | +-8 Vendor specific (5 Gb/s, 36mA) | Realtek USB 10/100/1000 LAN 00E04C680977 | +-3 Hub (480 Mb/s, 100mA)
Quoted 8 lines
Quoted 8 lines
| GenesysLogic USB2.0 Hub | +-5 Mass Storage (480 Mb/s, 200mA) | Netac OnlyDisk FF00ECB60800FFFF1526 | +-6 Hub (480 Mb/s, 0mA) VIA Labs, Inc. USB2.0 Hub
[snip]
Regards,
Bin
PATCH 10/16 usb: xhci: Program 'route string' in the input slot context
Quoted 17 lines · Bin Meng
Hi Marek,
Quoted 14 lines · Marek Vasut
Quoted 13 lines · Bin Meng
xHCI spec says: the values of the 'route string' field shall be initialized by the first 'Address Device' command issued to a device slot, and shall not be modified by any other command.
So far U-Boot does not program this field, and it does not prevent SS device directly attached to root port, or HS device behind an HS hub, from working, due to the fact that 'route string' is used by the xHC to target SS packets. But in order to enumerate devices behind an SS hub, this field must be programmed.
With this commit and along with previous commits, now SS & HS devices attached to a USB 3.0 hub can be enumerated by U-Boot.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
As usual, this new feature is only available when DM is on.
Great, but I really dislike the ifdef pollution, so this needs to be sorted out.
The ifdef was needed due to it calls DM APIs or access DM udevice. I have no intention to add a new feature to the non-DM driver.
But then this creates a massive disparity, it's like we're growing two USB stacks.
Quoted 40 lines
Eventually we can get rid of all these ifdefs when all boards are converted to use DM USB.
Quoted 23 lines
Quoted 23 lines
Signed-off-by Bin Meng <[email protected]>---
Test logs: two USB 3.0 hubs (one tier2, one tier3) => usb tree
USB device tree:
1 Hub (5 Gb/s, 0mA)
| U-Boot XHCI Host Controller
|+-2 Hub (5 Gb/s, 0mA) | | GenesysLogic USB3.0 Hub | | | +-4 Hub (5 Gb/s, 0mA) | | | VIA Labs, Inc. USB3.0 Hub | | | | | +-7 Mass Storage (5 Gb/s, 76mA) | | JetFlash Mass Storage Device 16Q6ZPH20GF3E8UQ | | | +-8 Vendor specific (5 Gb/s, 36mA) | Realtek USB 10/100/1000 LAN 00E04C680977 | +-3 Hub (480 Mb/s, 100mA)Quoted 8 lines
Quoted 8 lines
| GenesysLogic USB2.0 Hub | +-5 Mass Storage (480 Mb/s, 200mA) | Netac OnlyDisk FF00ECB60800FFFF1526 | +-6 Hub (480 Mb/s, 0mA) VIA Labs, Inc. USB2.0 Hub[snip]
Regards,
Bin
Signature · 2 lines
Best regards, Marek Vasut
PATCH 10/16 usb: xhci: Program 'route string' in the input slot context
Hi Marek,
Quoted 20 lines · Marek Vasut
Quoted 19 lines · Bin Meng
Hi Marek,
Quoted 16 lines · Marek Vasut
Quoted 14 lines · Bin Meng
xHCI spec says: the values of the 'route string' field shall be initialized by the first 'Address Device' command issued to a device slot, and shall not be modified by any other command.
So far U-Boot does not program this field, and it does not prevent SS device directly attached to root port, or HS device behind an HS hub, from working, due to the fact that 'route string' is used by the xHC to target SS packets. But in order to enumerate devices behind an SS hub, this field must be programmed.
With this commit and along with previous commits, now SS & HS devices attached to a USB 3.0 hub can be enumerated by U-Boot.
As usual, this new feature is only available when DM is on.
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Great, but I really dislike the ifdef pollution, so this needs to be sorted out.
The ifdef was needed due to it calls DM APIs or access DM udevice. I have no intention to add a new feature to the non-DM driver.
But then this creates a massive disparity, it's like we're growing two USB stacks.
Yep, unfortunately. But if we continue adding new features/fixes to the old non-DM stuff, I am not sure how this can encourage people to switch to DM. Maybe I can check all boards that use xHCI to see if they are switched to DM?
[snip]
Regards,
Bin
PATCH 10/16 usb: xhci: Program 'route string' in the input slot context
Hi Bin,
Quoted 27 lines · Bin Meng
Quoted 26 lines · Marek Vasut
Quoted 24 lines · Bin Meng
Hi Marek,
Quoted 11 lines · Marek Vasut
Quoted 10 lines · Bin Meng
xHCI spec says: the values of the 'route string' field shall be initialized by the first 'Address Device' command issued to a device slot, and shall not be modified by any other command.
So far U-Boot does not program this field, and it does not prevent SS device directly attached to root port, or HS device behind an HS hub, from working, due to the fact that 'route string' is used by the xHC to target SS packets. But in order to enumerate devices behind an SS hub, this field must be programmed.
Quoted 7 lines
Quoted 4 lines
With this commit and along with previous commits, now SS & HS devices attached to a USB 3.0 hub can be enumerated by U-Boot.
As usual, this new feature is only available when DM is on.
Great, but I really dislike the ifdef pollution, so this needs to be sorted out.
The ifdef was needed due to it calls DM APIs or access DM udevice. I have no intention to add a new feature to the non-DM driver.
Quoted 7 lines
Quoted 3 lines
But then this creates a massive disparity, it's like we're growing two USB stacks.
Yep, unfortunately. But if we continue adding new features/fixes to the old non-DM stuff, I am not sure how this can encourage people to switch to DM.
Correct. We definitely don't want to add new features to non-DM drivers / IF, if this is non-trivial.
Quoted 2 lines
Maybe I can check all boards that use xHCI to see if they are switched to DM?
xHCI is still quite new in U-Boot, so I would expect that all platforms using it, are using DM or at least not far away from using it. Yes, please check all xHCI "users", if they use DM. Then we know if and which users need some "persuasion" to switch over to DM soon. ;)
Thanks,
Stefan
PATCH 10/16 usb: xhci: Program 'route string' in the input slot context
Hi Stefan,
Quoted 55 lines · Stefan Roese
Hi Bin,
Quoted 35 lines · Bin Meng
Quoted 33 lines · Marek Vasut
Quoted 29 lines · Bin Meng
Hi Marek,
Quoted 13 lines · Marek Vasut
Quoted 11 lines · Bin Meng
xHCI spec says: the values of the 'route string' field shall be initialized by the first 'Address Device' command issued to a device slot, and shall not be modified by any other command.
So far U-Boot does not program this field, and it does not prevent SS device directly attached to root port, or HS device behind an HS hub, from working, due to the fact that 'route string' is used by the xHC to target SS packets. But in order to enumerate devices behind an SS hub, this field must be programmed.
Quoted 8 lines
Quoted 4 lines
With this commit and along with previous commits, now SS & HS devices attached to a USB 3.0 hub can be enumerated by U-Boot.
As usual, this new feature is only available when DM is on.
Great, but I really dislike the ifdef pollution, so this needs to be sorted out.
The ifdef was needed due to it calls DM APIs or access DM udevice. I have no intention to add a new feature to the non-DM driver.
Quoted 7 lines
Quoted 3 lines
But then this creates a massive disparity, it's like we're growing two USB stacks.
Yep, unfortunately. But if we continue adding new features/fixes to the old non-DM stuff, I am not sure how this can encourage people to switch to DM.
Correct. We definitely don't want to add new features to non-DM drivers / IF, if this is non-trivial.
Quoted 2 lines
Maybe I can check all boards that use xHCI to see if they are switched to DM?
Quoted 5 lines
xHCI is still quite new in U-Boot, so I would expect that all platforms using it, are using DM or at least not far away from using it. Yes, please check all xHCI "users", if they use DM. Then we know if and which users need some "persuasion" to switch over to DM soon. ;)
I checked all boards that have CONFIG_USB_XHCI_HCD defined but without CONFIG_DM_USB. Here is the list.
configs/uniphier_v8_defconfig:36:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig:62:CONFIG_USB_XHCI_HCD=y configs/am57xx_evm_nodt_defconfig:53:CONFIG_USB_XHCI_HCD=y configs/evb-rk3328_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_lpuart_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/uniphier_pxs2_ld6b_defconfig:44:CONFIG_USB_XHCI_HCD=y configs/ls1012ardb_qspi_SECURE_BOOT_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig:57:CONFIG_USB_XHCI_HCD=y configs/k2e_hs_evm_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_sdcard_qspi_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_ethboot_defconfig:48:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_ep_defconfig:70:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_nand_defconfig:57:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_qspi_defconfig:50:CONFIG_USB_XHCI_HCD=y configs/k2g_evm_defconfig:45:CONFIG_USB_XHCI_HCD=y configs/am57xx_evm_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/am43xx_hs_evm_defconfig:49:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_defconfig:39:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_defconfig:42:CONFIG_USB_XHCI_HCD=y configs/firefly-rk3399_defconfig:59:CONFIG_USB_XHCI_HCD=y configs/puma-rk3399_defconfig:78:CONFIG_USB_XHCI_HCD=y configs/cl-som-am57x_defconfig:55:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_nor_SECURE_BOOT_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/uniphier_pro4_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zcu102_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_SECURE_BOOT_defconfig:42:CONFIG_USB_XHCI_HCD=y configs/cm_t43_defconfig:67:CONFIG_USB_XHCI_HCD=y configs/k2g_hs_evm_defconfig:36:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_qspiboot_defconfig:45:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_qspi_defconfig:50:CONFIG_USB_XHCI_HCD=y configs/am57xx_hs_evm_defconfig:67:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zcu102_revB_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_sdcard_ifc_defconfig:55:CONFIG_USB_XHCI_HCD=y configs/uniphier_ld20_defconfig:39:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_usbhost_boot_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_sdcard_qspi_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/evb-rk3399_defconfig:60:CONFIG_USB_XHCI_HCD=y configs/k2hk_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/k2hk_hs_evm_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/k2e_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_sdcard_ifc_defconfig:54:CONFIG_USB_XHCI_HCD=y configs/k2l_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y
So it looks we have lots of conversion work to be done by many board maintainers. I am not sure how to proceed on this.
Regards,
Bin
PATCH 10/16 usb: xhci: Program 'route string' in the input slot context
Quoted 111 lines · Bin Meng
Hi Stefan,
Quoted 55 lines · Stefan Roese
Hi Bin,
Quoted 35 lines · Bin Meng
Quoted 33 lines · Marek Vasut
Quoted 29 lines · Bin Meng
Hi Marek,
Quoted 13 lines · Marek Vasut
Quoted 11 lines · Bin Meng
xHCI spec says: the values of the 'route string' field shall be initialized by the first 'Address Device' command issued to a device slot, and shall not be modified by any other command.
So far U-Boot does not program this field, and it does not prevent SS device directly attached to root port, or HS device behind an HS hub, from working, due to the fact that 'route string' is used by the xHC to target SS packets. But in order to enumerate devices behind an SS hub, this field must be programmed.
Quoted 8 lines
Quoted 4 lines
With this commit and along with previous commits, now SS & HS devices attached to a USB 3.0 hub can be enumerated by U-Boot.
As usual, this new feature is only available when DM is on.
Great, but I really dislike the ifdef pollution, so this needs to be sorted out.
The ifdef was needed due to it calls DM APIs or access DM udevice. I have no intention to add a new feature to the non-DM driver.
Quoted 7 lines
Quoted 3 lines
But then this creates a massive disparity, it's like we're growing two USB stacks.
Yep, unfortunately. But if we continue adding new features/fixes to the old non-DM stuff, I am not sure how this can encourage people to switch to DM.
Correct. We definitely don't want to add new features to non-DM drivers / IF, if this is non-trivial.
Quoted 2 lines
Maybe I can check all boards that use xHCI to see if they are switched to DM?
Quoted 5 lines
xHCI is still quite new in U-Boot, so I would expect that all platforms using it, are using DM or at least not far away from using it. Yes, please check all xHCI "users", if they use DM. Then we know if and which users need some "persuasion" to switch over to DM soon. ;)
I checked all boards that have
CONFIG_USB_XHCI_HCDdefined but withoutCONFIG_DM_USB. Here is the list.configs/uniphier_v8_defconfig:36:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig:62:CONFIG_USB_XHCI_HCD=y configs/am57xx_evm_nodt_defconfig:53:CONFIG_USB_XHCI_HCD=y configs/evb-rk3328_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_lpuart_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/uniphier_pxs2_ld6b_defconfig:44:CONFIG_USB_XHCI_HCD=y configs/ls1012ardb_qspi_SECURE_BOOT_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig:57:CONFIG_USB_XHCI_HCD=y configs/k2e_hs_evm_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_sdcard_qspi_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_ethboot_defconfig:48:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_ep_defconfig:70:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_nand_defconfig:57:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_qspi_defconfig:50:CONFIG_USB_XHCI_HCD=y configs/k2g_evm_defconfig:45:CONFIG_USB_XHCI_HCD=y configs/am57xx_evm_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/am43xx_hs_evm_defconfig:49:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_defconfig:39:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_defconfig:42:CONFIG_USB_XHCI_HCD=y configs/firefly-rk3399_defconfig:59:CONFIG_USB_XHCI_HCD=y configs/puma-rk3399_defconfig:78:CONFIG_USB_XHCI_HCD=y configs/cl-som-am57x_defconfig:55:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_nor_SECURE_BOOT_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/uniphier_pro4_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zcu102_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_SECURE_BOOT_defconfig:42:CONFIG_USB_XHCI_HCD=y configs/cm_t43_defconfig:67:CONFIG_USB_XHCI_HCD=y configs/k2g_hs_evm_defconfig:36:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_qspiboot_defconfig:45:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_qspi_defconfig:50:CONFIG_USB_XHCI_HCD=y configs/am57xx_hs_evm_defconfig:67:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zcu102_revB_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_sdcard_ifc_defconfig:55:CONFIG_USB_XHCI_HCD=y configs/uniphier_ld20_defconfig:39:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_usbhost_boot_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_sdcard_qspi_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/evb-rk3399_defconfig:60:CONFIG_USB_XHCI_HCD=y configs/k2hk_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/k2hk_hs_evm_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/k2e_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_sdcard_ifc_defconfig:54:CONFIG_USB_XHCI_HCD=y configs/k2l_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y
Quoted 2 lines
So it looks we have lots of conversion work to be done by many board maintainers. I am not sure how to proceed on this.
Could the USB_DM be implied on these boards ?
Signature · 2 lines
Best regards, Marek Vasut
PATCH 10/16 usb: xhci: Program 'route string' in the input slot context
In reply to Bin MengHi Bin,
Quoted 111 lines · Bin Meng
Hi Stefan,
Quoted 55 lines · Stefan Roese
Hi Bin,
Quoted 35 lines · Bin Meng
Quoted 33 lines · Marek Vasut
Quoted 29 lines · Bin Meng
Hi Marek,
Quoted 13 lines · Marek Vasut
Quoted 11 lines · Bin Meng
xHCI spec says: the values of the 'route string' field shall be initialized by the first 'Address Device' command issued to a device slot, and shall not be modified by any other command.
So far U-Boot does not program this field, and it does not prevent SS device directly attached to root port, or HS device behind an HS hub, from working, due to the fact that 'route string' is used by the xHC to target SS packets. But in order to enumerate devices behind an SS hub, this field must be programmed.
Quoted 8 lines
Quoted 4 lines
With this commit and along with previous commits, now SS & HS devices attached to a USB 3.0 hub can be enumerated by U-Boot.
As usual, this new feature is only available when DM is on.
Great, but I really dislike the ifdef pollution, so this needs to be sorted out.
The ifdef was needed due to it calls DM APIs or access DM udevice. I have no intention to add a new feature to the non-DM driver.
Quoted 7 lines
Quoted 3 lines
But then this creates a massive disparity, it's like we're growing two USB stacks.
Yep, unfortunately. But if we continue adding new features/fixes to the old non-DM stuff, I am not sure how this can encourage people to switch to DM.
Correct. We definitely don't want to add new features to non-DM drivers / IF, if this is non-trivial.
Quoted 2 lines
Maybe I can check all boards that use xHCI to see if they are switched to DM?
Quoted 5 lines
xHCI is still quite new in U-Boot, so I would expect that all platforms using it, are using DM or at least not far away from using it. Yes, please check all xHCI "users", if they use DM. Then we know if and which users need some "persuasion" to switch over to DM soon. ;)
I checked all boards that have
CONFIG_USB_XHCI_HCDdefined but withoutCONFIG_DM_USB. Here is the list.configs/uniphier_v8_defconfig:36:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig:62:CONFIG_USB_XHCI_HCD=y configs/am57xx_evm_nodt_defconfig:53:CONFIG_USB_XHCI_HCD=y configs/evb-rk3328_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_lpuart_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/uniphier_pxs2_ld6b_defconfig:44:CONFIG_USB_XHCI_HCD=y configs/ls1012ardb_qspi_SECURE_BOOT_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig:57:CONFIG_USB_XHCI_HCD=y configs/k2e_hs_evm_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_sdcard_qspi_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_ethboot_defconfig:48:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_ep_defconfig:70:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_nand_defconfig:57:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_qspi_defconfig:50:CONFIG_USB_XHCI_HCD=y configs/k2g_evm_defconfig:45:CONFIG_USB_XHCI_HCD=y configs/am57xx_evm_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/am43xx_hs_evm_defconfig:49:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_defconfig:39:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_defconfig:42:CONFIG_USB_XHCI_HCD=y configs/firefly-rk3399_defconfig:59:CONFIG_USB_XHCI_HCD=y configs/puma-rk3399_defconfig:78:CONFIG_USB_XHCI_HCD=y configs/cl-som-am57x_defconfig:55:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_nor_SECURE_BOOT_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/uniphier_pro4_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zcu102_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_SECURE_BOOT_defconfig:42:CONFIG_USB_XHCI_HCD=y configs/cm_t43_defconfig:67:CONFIG_USB_XHCI_HCD=y configs/k2g_hs_evm_defconfig:36:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_qspiboot_defconfig:45:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_qspi_defconfig:50:CONFIG_USB_XHCI_HCD=y configs/am57xx_hs_evm_defconfig:67:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zcu102_revB_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_sdcard_ifc_defconfig:55:CONFIG_USB_XHCI_HCD=y configs/uniphier_ld20_defconfig:39:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_usbhost_boot_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_sdcard_qspi_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/evb-rk3399_defconfig:60:CONFIG_USB_XHCI_HCD=y configs/k2hk_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/k2hk_hs_evm_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/k2e_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_sdcard_ifc_defconfig:54:CONFIG_USB_XHCI_HCD=y configs/k2l_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y
Quoted 2 lines
So it looks we have lots of conversion work to be done by many board maintainers. I am not sure how to proceed on this.
Marek reminded me, that he thinks that most of these platforms above will most likely select DM_USB implicitly via Kconfig.
I did a quick check and it seems that at least these platforms have DM_USB enabled:
ARCH_ZYNQARCH_ZYNQMPARCH_UNIPHIERARCH_ROCKCHIP
and other from above very likely as well.
Before you invest more time and effort into implementing the xHCI additions in a "non-DM cleaner way", I suggest to find out which targets really use xHCI without USB_DM. An easy check would be to add some #error to the non-DM part and run this commit through buildman / travis.
What do you think?
Thanks,
Stefan
PATCH 10/16 usb: xhci: Program 'route string' in the input slot context
Hi Stefan,
Quoted 147 lines · Stefan Roese
Hi Bin,
Quoted 126 lines · Bin Meng
Hi Stefan,
Quoted 67 lines · Stefan Roese
Hi Bin,
Quoted 44 lines · Bin Meng
Quoted 41 lines · Marek Vasut
Quoted 35 lines · Bin Meng
Hi Marek,
Quoted 19 lines · Marek Vasut
Quoted 16 lines · Bin Meng
xHCI spec says: the values of the 'route string' field shall be initialized by the first 'Address Device' command issued to a device slot, and shall not be modified by any other command.
So far U-Boot does not program this field, and it does not prevent SS device directly attached to root port, or HS device behind an HS hub, from working, due to the fact that 'route string' is used by the xHC to target SS packets. But in order to enumerate devices behind an SS hub, this field must be programmed.
With this commit and along with previous commits, now SS & HS devices
attached to a USB 3.0 hub can be enumerated by U-Boot.Quoted 6 lines
Quoted 1 line
As usual, this new feature is only available when DM is on.
Great, but I really dislike the ifdef pollution, so this needs to be sorted out.
The ifdef was needed due to it calls DM APIs or access DM udevice. I have no intention to add a new feature to the non-DM driver.
Quoted 7 lines
Quoted 3 lines
But then this creates a massive disparity, it's like we're growing two USB stacks.
Yep, unfortunately. But if we continue adding new features/fixes to the old non-DM stuff, I am not sure how this can encourage people to switch to DM.
Correct. We definitely don't want to add new features to non-DM drivers / IF, if this is non-trivial.
Quoted 2 lines
Maybe I can check all boards that use xHCI to see if they are switched to DM?
Quoted 5 lines
xHCI is still quite new in U-Boot, so I would expect that all platforms using it, are using DM or at least not far away from using it. Yes, please check all xHCI "users", if they use DM. Then we know if and which users need some "persuasion" to switch over to DM soon. ;)
I checked all boards that have
CONFIG_USB_XHCI_HCDdefined but withoutCONFIG_DM_USB. Here is the list.configs/uniphier_v8_defconfig:36:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig:62:CONFIG_USB_XHCI_HCD=y configs/am57xx_evm_nodt_defconfig:53:CONFIG_USB_XHCI_HCD=y configs/evb-rk3328_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_lpuart_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/uniphier_pxs2_ld6b_defconfig:44:CONFIG_USB_XHCI_HCD=y configs/ls1012ardb_qspi_SECURE_BOOT_defconfig:43:CONFIG_USB_XHCI_HCD=y
configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig:57:CONFIG_USB_XHCI_HCD=y configs/k2e_hs_evm_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_sdcard_qspi_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_ethboot_defconfig:48:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_ep_defconfig:70:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_nand_defconfig:57:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_qspi_defconfig:50:CONFIG_USB_XHCI_HCD=y configs/k2g_evm_defconfig:45:CONFIG_USB_XHCI_HCD=y configs/am57xx_evm_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/am43xx_hs_evm_defconfig:49:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_defconfig:39:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_defconfig:42:CONFIG_USB_XHCI_HCD=y configs/firefly-rk3399_defconfig:59:CONFIG_USB_XHCI_HCD=y configs/puma-rk3399_defconfig:78:CONFIG_USB_XHCI_HCD=y configs/cl-som-am57x_defconfig:55:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_nor_SECURE_BOOT_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/uniphier_pro4_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zcu102_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_SECURE_BOOT_defconfig:42:CONFIG_USB_XHCI_HCD=y configs/cm_t43_defconfig:67:CONFIG_USB_XHCI_HCD=y configs/k2g_hs_evm_defconfig:36:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_qspiboot_defconfig:45:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_qspi_defconfig:50:CONFIG_USB_XHCI_HCD=y configs/am57xx_hs_evm_defconfig:67:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zcu102_revB_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_sdcard_ifc_defconfig:55:CONFIG_USB_XHCI_HCD=y configs/uniphier_ld20_defconfig:39:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_usbhost_boot_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_sdcard_qspi_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/evb-rk3399_defconfig:60:CONFIG_USB_XHCI_HCD=y configs/k2hk_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/k2hk_hs_evm_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/k2e_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_sdcard_ifc_defconfig:54:CONFIG_USB_XHCI_HCD=y configs/k2l_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y
Quoted 2 lines
So it looks we have lots of conversion work to be done by many board maintainers. I am not sure how to proceed on this.
Marek reminded me, that he thinks that most of these platforms above will most likely select
DM_USBimplicitly viaKconfig.I did a quick check and it seems that at least these platforms have
DM_USBenabled:
ARCH_ZYNQARCH_ZYNQMPARCH_UNIPHIERARCH_ROCKCHIPand other from above very likely as well.
Quoted 7 lines
Before you invest more time and effort into implementing the xHCI additions in a "non-DM cleaner way", I suggest to find out which targets really use xHCI without
USB_DM. An easy check would be to add some #error to the non-DM part and run this commit through buildman / travis.What do you think?
Ah, that's really a good idea. Thanks for the hints! I will launch a buildman testing soon.
Regards,
Bin
PATCH 10/16 usb: xhci: Program 'route string' in the input slot context
Hi Stefan,
Quoted 156 lines · Bin Meng
Hi Stefan,
Quoted 153 lines · Stefan Roese
Hi Bin,
Quoted 126 lines · Bin Meng
Hi Stefan,
Quoted 67 lines · Stefan Roese
Hi Bin,
Quoted 44 lines · Bin Meng
Quoted 41 lines · Marek Vasut
Quoted 35 lines · Bin Meng
Hi Marek,
Quoted 19 lines · Marek Vasut
Quoted 16 lines · Bin Meng
xHCI spec says: the values of the 'route string' field shall be initialized by the first 'Address Device' command issued to a device slot, and shall not be modified by any other command.
So far U-Boot does not program this field, and it does not prevent SS device directly attached to root port, or HS device behind an HS hub, from working, due to the fact that 'route string' is used by the xHC to target SS packets. But in order to enumerate devices behind an SS hub, this field must be programmed.
With this commit and along with previous commits, now SS & HS devices
attached to a USB 3.0 hub can be enumerated by U-Boot.Quoted 6 lines
Quoted 1 line
As usual, this new feature is only available when DM is on.
Great, but I really dislike the ifdef pollution, so this needs to be sorted out.
The ifdef was needed due to it calls DM APIs or access DM udevice. I have no intention to add a new feature to the non-DM driver.
Quoted 7 lines
Quoted 3 lines
But then this creates a massive disparity, it's like we're growing two USB stacks.
Yep, unfortunately. But if we continue adding new features/fixes to the old non-DM stuff, I am not sure how this can encourage people to switch to DM.
Correct. We definitely don't want to add new features to non-DM drivers / IF, if this is non-trivial.
Quoted 2 lines
Maybe I can check all boards that use xHCI to see if they are switched to DM?
Quoted 5 lines
xHCI is still quite new in U-Boot, so I would expect that all platforms using it, are using DM or at least not far away from using it. Yes, please check all xHCI "users", if they use DM. Then we know if and which users need some "persuasion" to switch over to DM soon. ;)
I checked all boards that have
CONFIG_USB_XHCI_HCDdefined but withoutCONFIG_DM_USB. Here is the list.configs/uniphier_v8_defconfig:36:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig:62:CONFIG_USB_XHCI_HCD=y configs/am57xx_evm_nodt_defconfig:53:CONFIG_USB_XHCI_HCD=y configs/evb-rk3328_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_lpuart_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/uniphier_pxs2_ld6b_defconfig:44:CONFIG_USB_XHCI_HCD=y configs/ls1012ardb_qspi_SECURE_BOOT_defconfig:43:CONFIG_USB_XHCI_HCD=y
configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig:57:CONFIG_USB_XHCI_HCD=y configs/k2e_hs_evm_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_sdcard_qspi_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_ethboot_defconfig:48:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_ep_defconfig:70:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_nand_defconfig:57:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_qspi_defconfig:50:CONFIG_USB_XHCI_HCD=y configs/k2g_evm_defconfig:45:CONFIG_USB_XHCI_HCD=y configs/am57xx_evm_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/am43xx_hs_evm_defconfig:49:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_defconfig:39:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_defconfig:42:CONFIG_USB_XHCI_HCD=y configs/firefly-rk3399_defconfig:59:CONFIG_USB_XHCI_HCD=y configs/puma-rk3399_defconfig:78:CONFIG_USB_XHCI_HCD=y configs/cl-som-am57x_defconfig:55:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_nor_SECURE_BOOT_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/uniphier_pro4_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zcu102_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_SECURE_BOOT_defconfig:42:CONFIG_USB_XHCI_HCD=y configs/cm_t43_defconfig:67:CONFIG_USB_XHCI_HCD=y configs/k2g_hs_evm_defconfig:36:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_qspiboot_defconfig:45:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_qspi_defconfig:50:CONFIG_USB_XHCI_HCD=y configs/am57xx_hs_evm_defconfig:67:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zcu102_revB_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_sdcard_ifc_defconfig:55:CONFIG_USB_XHCI_HCD=y configs/uniphier_ld20_defconfig:39:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_usbhost_boot_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_sdcard_qspi_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/evb-rk3399_defconfig:60:CONFIG_USB_XHCI_HCD=y configs/k2hk_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/k2hk_hs_evm_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/k2e_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_sdcard_ifc_defconfig:54:CONFIG_USB_XHCI_HCD=y configs/k2l_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y
Quoted 2 lines
So it looks we have lots of conversion work to be done by many board maintainers. I am not sure how to proceed on this.
Marek reminded me, that he thinks that most of these platforms above will most likely select
DM_USBimplicitly viaKconfig.I did a quick check and it seems that at least these platforms have
DM_USBenabled:
ARCH_ZYNQARCH_ZYNQMPARCH_UNIPHIERARCH_ROCKCHIPand other from above very likely as well.
Before you invest more time and effort into implementing the xHCI additions in a "non-DM cleaner way", I suggest to find out which targets really use xHCI without
USB_DM. An easy check would be to add some #error to the non-DM part and run this commit through buildman / travis.
Quoted 5 lines
Quoted 1 line
What do you think?
Ah, that's really a good idea. Thanks for the hints! I will launch a buildman testing soon.
Looks we have a smaller list indeed. Here is the buildman results:
ls1012ardb_qspi_SECURE_BOOTls1021atwr_nor_SECURE_BOOTam43xx_hs_evmam57xx_hs_evmls1021aqds_nandls1021atwr_norls1021atwr_qspicm_t43ls1021atwr_nor_lpuartls1021aqds_sdcard_qspik2hk_hs_evmam43xx_evmls1021aqds_qspiam57xx_evm_nodtk2g_hs_evmls1021atwr_sdcard_qspiam43xx_evm_ethbootls1021aqds_sdcard_ifck2l_evmam43xx_evm_usbhost_bootam43xx_evm_qspibootk2g_evmam57xx_evmls1021atwr_sdcard_ifc
cl-som-am57xk2hk_evmk2e_evmls1021atwr_sdcard_ifc_SECURE_BOOTls1021aqds_nor_SECURE_BOOTk2e_hs_evm
Regards,
Bin
PATCH 10/16 usb: xhci: Program 'route string' in the input slot context
Hi Bin,
Quoted 189 lines · Bin Meng
Hi Stefan,
Quoted 156 lines · Bin Meng
Hi Stefan,
Quoted 153 lines · Stefan Roese
Hi Bin,
Quoted 126 lines · Bin Meng
Hi Stefan,
Quoted 67 lines · Stefan Roese
Hi Bin,
Quoted 44 lines · Bin Meng
Quoted 41 lines · Marek Vasut
Quoted 35 lines · Bin Meng
Hi Marek,
Quoted 19 lines · Marek Vasut
Quoted 16 lines · Bin Meng
xHCI spec says: the values of the 'route string' field shall be initialized by the first 'Address Device' command issued to a device slot, and shall not be modified by any other command.
So far U-Boot does not program this field, and it does not prevent SS device directly attached to root port, or HS device behind an HS hub, from working, due to the fact that 'route string' is used by the xHC to target SS packets. But in order to enumerate devices behind an SS hub, this field must be programmed.
With this commit and along with previous commits, now SS & HS devices
attached to a USB 3.0 hub can be enumerated by U-Boot.Quoted 6 lines
Quoted 1 line
As usual, this new feature is only available when DM is on.
Great, but I really dislike the ifdef pollution, so this needs to be sorted out.
The ifdef was needed due to it calls DM APIs or access DM udevice. I have no intention to add a new feature to the non-DM driver.
Quoted 7 lines
Quoted 3 lines
But then this creates a massive disparity, it's like we're growing two USB stacks.
Yep, unfortunately. But if we continue adding new features/fixes to the old non-DM stuff, I am not sure how this can encourage people to switch to DM.
Correct. We definitely don't want to add new features to non-DM drivers / IF, if this is non-trivial.
Quoted 2 lines
Maybe I can check all boards that use xHCI to see if they are switched to DM?
Quoted 5 lines
xHCI is still quite new in U-Boot, so I would expect that all platforms using it, are using DM or at least not far away from using it. Yes, please check all xHCI "users", if they use DM. Then we know if and which users need some "persuasion" to switch over to DM soon. ;)
I checked all boards that have
CONFIG_USB_XHCI_HCDdefined but withoutCONFIG_DM_USB. Here is the list.configs/uniphier_v8_defconfig:36:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig:62:CONFIG_USB_XHCI_HCD=y configs/am57xx_evm_nodt_defconfig:53:CONFIG_USB_XHCI_HCD=y configs/evb-rk3328_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_lpuart_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/uniphier_pxs2_ld6b_defconfig:44:CONFIG_USB_XHCI_HCD=y configs/ls1012ardb_qspi_SECURE_BOOT_defconfig:43:CONFIG_USB_XHCI_HCD=y
configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig:57:CONFIG_USB_XHCI_HCD=y configs/k2e_hs_evm_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_sdcard_qspi_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_ethboot_defconfig:48:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_ep_defconfig:70:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_nand_defconfig:57:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_qspi_defconfig:50:CONFIG_USB_XHCI_HCD=y configs/k2g_evm_defconfig:45:CONFIG_USB_XHCI_HCD=y configs/am57xx_evm_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/am43xx_hs_evm_defconfig:49:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_defconfig:39:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_defconfig:42:CONFIG_USB_XHCI_HCD=y configs/firefly-rk3399_defconfig:59:CONFIG_USB_XHCI_HCD=y configs/puma-rk3399_defconfig:78:CONFIG_USB_XHCI_HCD=y configs/cl-som-am57x_defconfig:55:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_nor_SECURE_BOOT_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/uniphier_pro4_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zcu102_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_SECURE_BOOT_defconfig:42:CONFIG_USB_XHCI_HCD=y configs/cm_t43_defconfig:67:CONFIG_USB_XHCI_HCD=y configs/k2g_hs_evm_defconfig:36:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_qspiboot_defconfig:45:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_qspi_defconfig:50:CONFIG_USB_XHCI_HCD=y configs/am57xx_hs_evm_defconfig:67:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zcu102_revB_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_sdcard_ifc_defconfig:55:CONFIG_USB_XHCI_HCD=y configs/uniphier_ld20_defconfig:39:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_usbhost_boot_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_sdcard_qspi_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/evb-rk3399_defconfig:60:CONFIG_USB_XHCI_HCD=y configs/k2hk_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/k2hk_hs_evm_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/k2e_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_sdcard_ifc_defconfig:54:CONFIG_USB_XHCI_HCD=y configs/k2l_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y
Quoted 2 lines
So it looks we have lots of conversion work to be done by many board maintainers. I am not sure how to proceed on this.
Marek reminded me, that he thinks that most of these platforms above will most likely select
DM_USBimplicitly viaKconfig.I did a quick check and it seems that at least these platforms have
DM_USBenabled:
ARCH_ZYNQARCH_ZYNQMPARCH_UNIPHIERARCH_ROCKCHIPand other from above very likely as well.
Before you invest more time and effort into implementing the xHCI additions in a "non-DM cleaner way", I suggest to find out which targets really use xHCI without
USB_DM. An easy check would be to add some #error to the non-DM part and run this commit through buildman / travis.Quoted 5 lines
Quoted 1 line
What do you think?
Ah, that's really a good idea. Thanks for the hints! I will launch a buildman testing soon.
Looks we have a smaller list indeed. Here is the buildman results:
ls1012ardb_qspi_SECURE_BOOTls1021atwr_nor_SECURE_BOOTam43xx_hs_evmam57xx_hs_evmls1021aqds_nandls1021atwr_norls1021atwr_qspicm_t43ls1021atwr_nor_lpuartls1021aqds_sdcard_qspik2hk_hs_evmam43xx_evmls1021aqds_qspiam57xx_evm_nodtk2g_hs_evmls1021atwr_sdcard_qspiam43xx_evm_ethbootls1021aqds_sdcard_ifck2l_evmam43xx_evm_usbhost_bootam43xx_evm_qspibootk2g_evm
Quoted 8 lines
am57xx_evmls1021atwr_sdcard_ifc
cl-som-am57xk2hk_evmk2e_evmls1021atwr_sdcard_ifc_SECURE_BOOTls1021aqds_nor_SECURE_BOOTk2e_hs_evm
Thanks. So this leaves only some platforms using xHCI without DM_USB enabled indeed. I suspect that most of them don't have DM_USB enabled just because of oversight. Let me write a short mail to the maintainers, to see if they can enable DM_USB to make the way free for a complete DM based xHCI support.
Thanks,
Stefan
PATCH 10/16 usb: xhci: Program 'route string' in the input slot context
Hi Stefan,
Quoted 229 lines · Stefan Roese
Hi Bin,
Quoted 215 lines · Bin Meng
Hi Stefan,
Quoted 180 lines · Bin Meng
Hi Stefan,
Quoted 176 lines · Stefan Roese
Hi Bin,
Quoted 147 lines · Bin Meng
Hi Stefan,
Quoted 83 lines · Stefan Roese
Hi Bin,
Quoted 56 lines · Bin Meng
Quoted 52 lines · Marek Vasut
Quoted 44 lines · Bin Meng
Hi Marek,
Quoted 23 lines · Marek Vasut
Quoted 19 lines · Bin Meng
xHCI spec says: the values of the 'route string' field shall be initialized by the first 'Address Device' command issued to a device slot, and shall not be modified by any other command.
So far U-Boot does not program this field, and it does not prevent
SS device directly attached to root port, or HS device behind an HS
hub, from working, due to the fact that 'route string' is used by the xHC to target SS packets. But in order to enumerate devices behind an SS hub, this field must be programmed.With this commit and along with previous commits, now SS & HS devices
attached to a USB 3.0 hub can be enumerated by U-Boot.Quoted 8 lines
Quoted 1 line
As usual, this new feature is only available when DM is on.
Great, but I really dislike the ifdef pollution, so this needs to be
sorted out.The ifdef was needed due to it calls DM APIs or access DM udevice. I
have no intention to add a new feature to the non-DM driver.Quoted 8 lines
Quoted 4 lines
But then this creates a massive disparity, it's like we're growing two
USB stacks.Yep, unfortunately. But if we continue adding new features/fixes to the old non-DM stuff, I am not sure how this can encourage people to switch to DM.
Correct. We definitely don't want to add new features to non-DM drivers / IF, if this is non-trivial.
Quoted 2 lines
Maybe I can check all boards that use xHCI to see if they are switched to DM?
Quoted 5 lines
xHCI is still quite new in U-Boot, so I would expect that all platforms using it, are using DM or at least not far away from using it. Yes, please check all xHCI "users", if they use DM. Then we know if and which users need some "persuasion" to switch over to DM soon. ;)
I checked all boards that have
CONFIG_USB_XHCI_HCDdefined but withoutCONFIG_DM_USB. Here is the list.configs/uniphier_v8_defconfig:36:CONFIG_USB_XHCI_HCD=y
configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig:62:CONFIG_USB_XHCI_HCD=y configs/am57xx_evm_nodt_defconfig:53:CONFIG_USB_XHCI_HCD=y configs/evb-rk3328_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_lpuart_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/uniphier_pxs2_ld6b_defconfig:44:CONFIG_USB_XHCI_HCD=y configs/ls1012ardb_qspi_SECURE_BOOT_defconfig:43:CONFIG_USB_XHCI_HCD=y
configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig:57:CONFIG_USB_XHCI_HCD=y configs/k2e_hs_evm_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_sdcard_qspi_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_ethboot_defconfig:48:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_ep_defconfig:70:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_nand_defconfig:57:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_qspi_defconfig:50:CONFIG_USB_XHCI_HCD=y configs/k2g_evm_defconfig:45:CONFIG_USB_XHCI_HCD=y configs/am57xx_evm_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/am43xx_hs_evm_defconfig:49:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_defconfig:39:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_defconfig:42:CONFIG_USB_XHCI_HCD=y configs/firefly-rk3399_defconfig:59:CONFIG_USB_XHCI_HCD=y configs/puma-rk3399_defconfig:78:CONFIG_USB_XHCI_HCD=y configs/cl-som-am57x_defconfig:55:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_nor_SECURE_BOOT_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/uniphier_pro4_defconfig:43:CONFIG_USB_XHCI_HCD=y
configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zcu102_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_SECURE_BOOT_defconfig:42:CONFIG_USB_XHCI_HCD=y configs/cm_t43_defconfig:67:CONFIG_USB_XHCI_HCD=y configs/k2g_hs_evm_defconfig:36:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_qspiboot_defconfig:45:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_qspi_defconfig:50:CONFIG_USB_XHCI_HCD=y configs/am57xx_hs_evm_defconfig:67:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zcu102_revB_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_sdcard_ifc_defconfig:55:CONFIG_USB_XHCI_HCD=y configs/uniphier_ld20_defconfig:39:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_usbhost_boot_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_sdcard_qspi_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/evb-rk3399_defconfig:60:CONFIG_USB_XHCI_HCD=y configs/k2hk_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/k2hk_hs_evm_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/k2e_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_sdcard_ifc_defconfig:54:CONFIG_USB_XHCI_HCD=y configs/k2l_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y
Quoted 2 lines
So it looks we have lots of conversion work to be done by many board maintainers. I am not sure how to proceed on this.
Marek reminded me, that he thinks that most of these platforms above will most likely select
DM_USBimplicitly viaKconfig.I did a quick check and it seems that at least these platforms have
DM_USBenabled:
ARCH_ZYNQARCH_ZYNQMPARCH_UNIPHIERARCH_ROCKCHIPand other from above very likely as well.
Before you invest more time and effort into implementing the xHCI additions in a "non-DM cleaner way", I suggest to find out which targets really use xHCI without
USB_DM. An easy check would be to add some #error to the non-DM part and run this commit through buildman / travis.Quoted 6 lines
Quoted 1 line
What do you think?
Ah, that's really a good idea. Thanks for the hints! I will launch a buildman testing soon.
Looks we have a smaller list indeed. Here is the buildman results:
ls1012ardb_qspi_SECURE_BOOTls1021atwr_nor_SECURE_BOOTam43xx_hs_evmam57xx_hs_evmls1021aqds_nandls1021atwr_norls1021atwr_qspicm_t43ls1021atwr_nor_lpuartls1021aqds_sdcard_qspik2hk_hs_evmam43xx_evmls1021aqds_qspiam57xx_evm_nodtk2g_hs_evmls1021atwr_sdcard_qspiam43xx_evm_ethbootls1021aqds_sdcard_ifck2l_evmam43xx_evm_usbhost_bootam43xx_evm_qspibootk2g_evmQuoted 8 lines
am57xx_evmls1021atwr_sdcard_ifc
cl-som-am57xk2hk_evmk2e_evmls1021atwr_sdcard_ifc_SECURE_BOOTls1021aqds_nor_SECURE_BOOTk2e_hs_evm
Quoted 5 lines
Thanks. So this leaves only some platforms using xHCI without
DM_USBenabled indeed. I suspect that most of them don't haveDM_USBenabled just because of oversight. Let me write a short mail to the maintainers, to see if they can enableDM_USBto make the way free for a complete DM based xHCI support.
Thank you for your help. I see at least ls1021a_xxx boards are because of oversight as some other ls1021a boards have DM_USB.
Regards,
Bin
PATCH 10/16 usb: xhci: Program 'route string' in the input slot context
Hi Bin,
Quoted 232 lines · Bin Meng
Hi Stefan,
Quoted 229 lines · Stefan Roese
Hi Bin,
Quoted 223 lines · Bin Meng
Hi Stefan,
Quoted 180 lines · Bin Meng
Hi Stefan,
Quoted 176 lines · Stefan Roese
Hi Bin,
Quoted 147 lines · Bin Meng
Hi Stefan,
Quoted 83 lines · Stefan Roese
Hi Bin,
Quoted 56 lines · Bin Meng
Quoted 52 lines · Marek Vasut
Quoted 44 lines · Bin Meng
Hi Marek,
Quoted 23 lines · Marek Vasut
Quoted 19 lines · Bin Meng
xHCI spec says: the values of the 'route string' field shall be initialized by the first 'Address Device' command issued to a device slot, and shall not be modified by any other command.
So far U-Boot does not program this field, and it does not prevent
SS device directly attached to root port, or HS device behind an HS
hub, from working, due to the fact that 'route string' is used by the xHC to target SS packets. But in order to enumerate devices behind an SS hub, this field must be programmed.With this commit and along with previous commits, now SS & HS devices
attached to a USB 3.0 hub can be enumerated by U-Boot.Quoted 8 lines
Quoted 1 line
As usual, this new feature is only available when DM is on.
Great, but I really dislike the ifdef pollution, so this needs to be
sorted out.The ifdef was needed due to it calls DM APIs or access DM udevice. I
have no intention to add a new feature to the non-DM driver.Quoted 8 lines
Quoted 4 lines
But then this creates a massive disparity, it's like we're growing two
USB stacks.Yep, unfortunately. But if we continue adding new features/fixes to the old non-DM stuff, I am not sure how this can encourage people to switch to DM.
Correct. We definitely don't want to add new features to non-DM drivers / IF, if this is non-trivial.
Quoted 2 lines
Maybe I can check all boards that use xHCI to see if they are switched to DM?
Quoted 5 lines
xHCI is still quite new in U-Boot, so I would expect that all platforms using it, are using DM or at least not far away from using it. Yes, please check all xHCI "users", if they use DM. Then we know if and which users need some "persuasion" to switch over to DM soon. ;)
I checked all boards that have
CONFIG_USB_XHCI_HCDdefined but withoutCONFIG_DM_USB. Here is the list.configs/uniphier_v8_defconfig:36:CONFIG_USB_XHCI_HCD=y
configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig:62:CONFIG_USB_XHCI_HCD=y configs/am57xx_evm_nodt_defconfig:53:CONFIG_USB_XHCI_HCD=y configs/evb-rk3328_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_lpuart_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/uniphier_pxs2_ld6b_defconfig:44:CONFIG_USB_XHCI_HCD=y configs/ls1012ardb_qspi_SECURE_BOOT_defconfig:43:CONFIG_USB_XHCI_HCD=y
configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig:57:CONFIG_USB_XHCI_HCD=y configs/k2e_hs_evm_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_sdcard_qspi_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_ethboot_defconfig:48:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_ep_defconfig:70:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_nand_defconfig:57:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_qspi_defconfig:50:CONFIG_USB_XHCI_HCD=y configs/k2g_evm_defconfig:45:CONFIG_USB_XHCI_HCD=y configs/am57xx_evm_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/am43xx_hs_evm_defconfig:49:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_defconfig:39:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_defconfig:42:CONFIG_USB_XHCI_HCD=y configs/firefly-rk3399_defconfig:59:CONFIG_USB_XHCI_HCD=y configs/puma-rk3399_defconfig:78:CONFIG_USB_XHCI_HCD=y configs/cl-som-am57x_defconfig:55:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_nor_SECURE_BOOT_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/uniphier_pro4_defconfig:43:CONFIG_USB_XHCI_HCD=y
configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zcu102_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_nor_SECURE_BOOT_defconfig:42:CONFIG_USB_XHCI_HCD=y configs/cm_t43_defconfig:67:CONFIG_USB_XHCI_HCD=y configs/k2g_hs_evm_defconfig:36:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_qspiboot_defconfig:45:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_qspi_defconfig:50:CONFIG_USB_XHCI_HCD=y configs/am57xx_hs_evm_defconfig:67:CONFIG_USB_XHCI_HCD=y configs/xilinx_zynqmp_zcu102_revB_defconfig:63:CONFIG_USB_XHCI_HCD=y configs/ls1021aqds_sdcard_ifc_defconfig:55:CONFIG_USB_XHCI_HCD=y configs/uniphier_ld20_defconfig:39:CONFIG_USB_XHCI_HCD=y configs/am43xx_evm_usbhost_boot_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_sdcard_qspi_defconfig:61:CONFIG_USB_XHCI_HCD=y configs/evb-rk3399_defconfig:60:CONFIG_USB_XHCI_HCD=y configs/k2hk_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/k2hk_hs_evm_defconfig:34:CONFIG_USB_XHCI_HCD=y configs/k2e_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y configs/ls1021atwr_sdcard_ifc_defconfig:54:CONFIG_USB_XHCI_HCD=y configs/k2l_evm_defconfig:43:CONFIG_USB_XHCI_HCD=y
Quoted 2 lines
So it looks we have lots of conversion work to be done by many board maintainers. I am not sure how to proceed on this.
Marek reminded me, that he thinks that most of these platforms above will most likely select
DM_USBimplicitly viaKconfig.I did a quick check and it seems that at least these platforms have
DM_USBenabled:
ARCH_ZYNQARCH_ZYNQMPARCH_UNIPHIERARCH_ROCKCHIPand other from above very likely as well.
Before you invest more time and effort into implementing the xHCI additions in a "non-DM cleaner way", I suggest to find out which targets really use xHCI without
USB_DM. An easy check would be to add some #error to the non-DM part and run this commit through buildman / travis.Quoted 6 lines
Quoted 1 line
What do you think?
Ah, that's really a good idea. Thanks for the hints! I will launch a buildman testing soon.
Looks we have a smaller list indeed. Here is the buildman results:
ls1012ardb_qspi_SECURE_BOOTls1021atwr_nor_SECURE_BOOTam43xx_hs_evmam57xx_hs_evmls1021aqds_nandls1021atwr_norls1021atwr_qspicm_t43ls1021atwr_nor_lpuartls1021aqds_sdcard_qspik2hk_hs_evmam43xx_evmls1021aqds_qspiam57xx_evm_nodtk2g_hs_evmls1021atwr_sdcard_qspiam43xx_evm_ethbootls1021aqds_sdcard_ifck2l_evmam43xx_evm_usbhost_bootam43xx_evm_qspibootk2g_evmam57xx_evmls1021atwr_sdcard_ifc
cl-som-am57xk2hk_evmk2e_evmls1021atwr_sdcard_ifc_SECURE_BOOTls1021aqds_nor_SECURE_BOOTk2e_hs_evm
Quoted 8 lines
Quoted 5 lines
Thanks. So this leaves only some platforms using xHCI without
DM_USBenabled indeed. I suspect that most of them don't haveDM_USBenabled just because of oversight. Let me write a short mail to the maintainers, to see if they can enableDM_USBto make the way free for a complete DM based xHCI support.Thank you for your help. I see at least
ls1021a_xxxboards are because of oversight as some other ls1021a boards haveDM_USB.
Yes, I noticed this as well. I just sent a mail to all the maintainers of those boards. Lets see, what they respond... ;)
Thanks,
Stefan
PATCH 10/16 usb: xhci: Program 'route string' in the input slot context
In reply to Stefan RoeseQuoted 34 lines · Stefan Roese
Hi Bin,
Quoted 31 lines · Bin Meng
Quoted 29 lines · Marek Vasut
Quoted 17 lines · Bin Meng
Hi Marek,
Quoted 14 lines · Marek Vasut
Quoted 13 lines · Bin Meng
xHCI spec says: the values of the 'route string' field shall be initialized by the first 'Address Device' command issued to a device slot, and shall not be modified by any other command.
So far U-Boot does not program this field, and it does not prevent SS device directly attached to root port, or HS device behind an HS hub, from working, due to the fact that 'route string' is used by the xHC to target SS packets. But in order to enumerate devices behind an SS hub, this field must be programmed.
With this commit and along with previous commits, now SS & HS devices attached to a USB 3.0 hub can be enumerated by U-Boot.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
As usual, this new feature is only available when DM is on.
Great, but I really dislike the ifdef pollution, so this needs to be sorted out.
The ifdef was needed due to it calls DM APIs or access DM udevice. I have no intention to add a new feature to the non-DM driver.
But then this creates a massive disparity, it's like we're growing two USB stacks.
Quoted 6 lines
Quoted 3 lines
Yep, unfortunately. But if we continue adding new features/fixes to the old non-DM stuff, I am not sure how this can encourage people to switch to DM.
Correct. We definitely don't want to add new features to non-DM drivers / IF, if this is non-trivial.
Fine, but we also don't want to grow two distinct stacks with a boatload of ifdefs all over the place. That's a nightmare to maintain. I think I mentioned that already, but I'd be far more accepting to this solution if we could at least keep the added ifdefs to minimum and somehow keep them in one place instead of adding them all over the code.
Quoted 11 lines
Quoted 2 lines
Maybe I can check all boards that use xHCI to see if they are switched to DM?
xHCI is still quite new in U-Boot, so I would expect that all platforms using it, are using DM or at least not far away from using it. Yes, please check all xHCI "users", if they use DM. Then we know if and which users need some "persuasion" to switch over to DM soon. ;)
Thanks,
Stefan
Signature · 2 lines
Best regards, Marek Vasut
PATCH 10/16 usb: xhci: Program 'route string' in the input slot context
Hi Marek,
Quoted 39 lines · Marek Vasut
Quoted 38 lines · Stefan Roese
Hi Bin,
Quoted 34 lines · Bin Meng
Quoted 20 lines · Marek Vasut
Quoted 19 lines · Bin Meng
Hi Marek,
Quoted 16 lines · Marek Vasut
Quoted 14 lines · Bin Meng
xHCI spec says: the values of the 'route string' field shall be initialized by the first 'Address Device' command issued to a device slot, and shall not be modified by any other command.
So far U-Boot does not program this field, and it does not prevent SS device directly attached to root port, or HS device behind an HS hub, from working, due to the fact that 'route string' is used by the xHC to target SS packets. But in order to enumerate devices behind an SS hub, this field must be programmed.
With this commit and along with previous commits, now SS & HS devices attached to a USB 3.0 hub can be enumerated by U-Boot.
As usual, this new feature is only available when DM is on.
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Great, but I really dislike the ifdef pollution, so this needs to be sorted out.
The ifdef was needed due to it calls DM APIs or access DM udevice. I have no intention to add a new feature to the non-DM driver.
But then this creates a massive disparity, it's like we're growing two USB stacks.
Yep, unfortunately. But if we continue adding new features/fixes to the old non-DM stuff, I am not sure how this can encourage people to switch to DM.
Quoted 9 lines
Quoted 2 lines
Correct. We definitely don't want to add new features to non-DM drivers / IF, if this is non-trivial.
Fine, but we also don't want to grow two distinct stacks with a boatload of ifdefs all over the place. That's a nightmare to maintain. I think I mentioned that already, but I'd be far more accepting to this solution if we could at least keep the added ifdefs to minimum and somehow keep them in one place instead of adding them all over the code.
OK, I will see if I can do some additional work to remove the #ifdefs or limit them in a minimum way, even if that means I have to bring (part of) this feature to the non-DM driver.
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Maybe I can check all boards that use xHCI to see if they are switched to DM?
xHCI is still quite new in U-Boot, so I would expect that all platforms using it, are using DM or at least not far away from using it. Yes, please check all xHCI "users", if they use DM. Then we know if and which users need some "persuasion" to switch over to DM soon. ;)
[snip]
Regards,
Bin
PATCH 10/16 usb: xhci: Program 'route string' in the input slot context
In reply to Marek VasutHi Marek,
Quoted 39 lines · Marek Vasut
Quoted 38 lines · Stefan Roese
Hi Bin,
Quoted 34 lines · Bin Meng
Quoted 20 lines · Marek Vasut
Quoted 19 lines · Bin Meng
Hi Marek,
Quoted 16 lines · Marek Vasut
Quoted 14 lines · Bin Meng
xHCI spec says: the values of the 'route string' field shall be initialized by the first 'Address Device' command issued to a device slot, and shall not be modified by any other command.
So far U-Boot does not program this field, and it does not prevent SS device directly attached to root port, or HS device behind an HS hub, from working, due to the fact that 'route string' is used by the xHC to target SS packets. But in order to enumerate devices behind an SS hub, this field must be programmed.
With this commit and along with previous commits, now SS & HS devices attached to a USB 3.0 hub can be enumerated by U-Boot.
As usual, this new feature is only available when DM is on.
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Great, but I really dislike the ifdef pollution, so this needs to be sorted out.
The ifdef was needed due to it calls DM APIs or access DM udevice. I have no intention to add a new feature to the non-DM driver.
But then this creates a massive disparity, it's like we're growing two USB stacks.
Yep, unfortunately. But if we continue adding new features/fixes to the old non-DM stuff, I am not sure how this can encourage people to switch to DM.
Quoted 8 lines
Quoted 2 lines
Correct. We definitely don't want to add new features to non-DM drivers / IF, if this is non-trivial.
Fine, but we also don't want to grow two distinct stacks with a boatload of ifdefs all over the place. That's a nightmare to maintain. I think I mentioned that already, but I'd be far more accepting to this solution if we could at least keep the added ifdefs to minimum and somehow keep them in one place instead of adding them all over the code.
One idea is to set a deadline (e.g. end of year) for all boards to move to DM_USB, and turn off USB for those that don't make it? In some areas the old code is quite a significant impediment to progress / productivity.
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
Maybe I can check all boards that use xHCI to see if they are switched to DM?
xHCI is still quite new in U-Boot, so I would expect that all platforms using it, are using DM or at least not far away from using it. Yes, please check all xHCI "users", if they use DM. Then we know if and which users need some "persuasion" to switch over to DM soon. ;)
Regards,
Simon
PATCH 11/16 usb: hub: Parse and save TT details from device descriptor
In reply to Bin MengA high speed hub has a special responsibility to handle full speed/ low speed devices connected on downstream ports. In this case, the hub must isolate the high speed signaling environment from the full speed/low speed signaling environment with the help of Transaction Translator (TT). TT details are provided by hub descriptors and we parse and save it to hub uclass_priv for later use.
---
common/usb_hub.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/usb.h | 16 ++++++++++++++++ include/usb_defs.h | 12 ++++++++++++ 3 files changed, 78 insertions(+)
common/usb_hub.c +50 -0
@@ -693,6 +693,56 @@ static int usb_hub_configure(struct usb_device *dev)break ; } +switch (dev->descriptor.bDeviceProtocol) { +case USB_HUB_PR_FS : +break ; +case USB_HUB_PR_HS_SINGLE_TT : +debug ("Single TT\n" ); +break ; +case USB_HUB_PR_HS_MULTI_TT : + ret =usb_set_interface (dev,0 ,1 ); +if (ret ==0 ) { +debug ("TT per port\n" ); + hub->tt.multi = true; + }else { +debug ("Using single TT (err %d)\n" , ret); + } +break ; +case USB_HUB_PR_SS : +/* USB 3.0 hubs don't have a TT */ +break ; +default : +debug ("Unrecognized hub protocol %d\n" , + dev->descriptor.bDeviceProtocol); +break ; + } + +/* Note 8 FS bit times == (8 bits / 12000000 bps) ~= 666ns */ +switch (hubCharacteristics &HUB_CHAR_TTTT ) { +case HUB_TTTT_8_BITS : +if (dev->descriptor.bDeviceProtocol !=0 ) { + hub->tt.think_time =666 ; +debug ("TT requires at most %d FS bit times (%d ns)\n" , +8 , hub->tt.think_time); + } +break ; +case HUB_TTTT_16_BITS : + hub->tt.think_time =666 *2 ; +debug ("TT requires at most %d FS bit times (%d ns)\n" , +16 , hub->tt.think_time); +break ; +case HUB_TTTT_24_BITS : + hub->tt.think_time =666 *3 ; +debug ("TT requires at most %d FS bit times (%d ns)\n" , +24 , hub->tt.think_time); +break ; +case HUB_TTTT_32_BITS : + hub->tt.think_time =666 *4 ; +debug ("TT requires at most %d FS bit times (%d ns)\n" , +32 , hub->tt.think_time); +break ; + } +debug ("power on to power good time: %dms\n" , descriptor->bPwrOn2PwrGood *2 ); debug("hub controller current requirement: %dmA\n",
include/usb.h +16 -0
@@ -537,6 +537,21 @@ struct usb_hub_status {unsigned short wHubChange; } __attribute__ ((packed)); +/* +* Hub Device descriptor +* USB Hub class device protocols +*/ +#define USB_HUB_PR_FS 0/* Full speed hub */ +#define USB_HUB_PR_HS_NO_TT 0/* Hi-speed hub without TT */ +#define USB_HUB_PR_HS_SINGLE_TT 1/* Hi-speed hub with single TT */ +#define USB_HUB_PR_HS_MULTI_TT 2/* Hi-speed hub with multiple TT */ +#define USB_HUB_PR_SS 3/* Super speed hub */ + +/* Transaction Translator Think Times, in bits */ +#define HUB_TTTT_8_BITS 0x00 +#define HUB_TTTT_16_BITS 0x20 +#define HUB_TTTT_24_BITS 0x40 +#define HUB_TTTT_32_BITS 0x60/* Hub descriptor */ struct usb_hub_descriptor {
@@ -571,6 +586,7 @@ struct usb_hub_device {ulong query_delay;/* Device query delay in ms */ int overcurrent_count[USB_MAXCHILDREN ];/* Over-current counter */ int hub_depth;/* USB 3.0 hub depth */ +struct usb_tt tt;/* Transaction Translator */ };#ifdef CONFIG_DM_USB
include/usb_defs.h +12 -0
@@ -293,6 +293,7 @@#define HUB_CHAR_LPSM 0x0003#define HUB_CHAR_COMPOUND 0x0004#define HUB_CHAR_OCPM 0x0018 +#define HUB_CHAR_TTTT 0x0060/* TT Think Time mask */ /* * Hub Status & Hub Change bit masks
@@ -310,6 +311,17 @@#define USB_REQ_SET_HUB_DEPTH 0x0c/* +* As of USB 2.0, full/low speed devices are segregated into trees. +* One type grows from USB 1.1 host controllers (OHCI, UHCI etc). +* The other type grows from high speed hubs when they connect to +* full/low speed devices using "Transaction Translators" (TTs). +*/ +struct usb_tt { +bool multi;/* true means one TT per port */ +unsigned think_time;/* think time in ns */ +}; + +/* * CBI style */
Signature · 1 line
2.9.2
PATCH 11/16 usb: hub: Parse and save TT details from device descriptor
Quoted 7 lines · Bin Meng
A high speed hub has a special responsibility to handle full speed/ low speed devices connected on downstream ports. In this case, the hub must isolate the high speed signaling environment from the full speed/low speed signaling environment with the help of Transaction Translator (TT). TT details are provided by hub descriptors and we parse and save it to hub
uclass_privfor later use.
Quoted 7 lines
Signed-off-by Bin Meng <[email protected]>---
common/usb_hub.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/usb.h | 16 ++++++++++++++++ include/usb_defs.h | 12 ++++++++++++ 3 files changed, 78 insertions(+)
PATCH 12/16 dm: usb: Add a new USB controller operation 'update_hub_device'
In reply to Bin MengFor USB host controllers like xHC, its internal representation of hub needs to be updated after the hub descriptor is fetched. This adds a new op that does this.
---
drivers/usb/host/usb-uclass.c | 11 +++++++++++ include/usb.h | 21 ++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-)
drivers/usb/host/usb-uclass.c +11 -0
@@ -139,6 +139,17 @@ int usb_reset_root_port(struct usb_device *udev)return ops->reset_root_port (bus, udev); } +int usb_update_hub_device (struct usb_device *udev) +{ +struct udevice *bus = udev->controller_dev; +struct dm_usb_ops *ops =usb_get_ops (bus); + +if (!ops->update_hub_device) +return -ENOSYS ; + +return ops->update_hub_device (bus, udev); +} +int usb_stop (void ) {struct udevice *bus;
include/usb.h +20 -1
@@ -758,6 +758,14 @@ struct dm_usb_ops {* reset_root_port() - Reset usb root port */ int (*reset_root_port)(struct udevice *bus,struct usb_device *udev); + +/** +* update_hub_device() - Update HCD's internal representation of hub +* +* After a hub descriptor is fetched, notify HCD so that its internal +* representation of this hub can be updated (xHCI) +*/ +int (*update_hub_device)(struct udevice *bus,struct usb_device *udev); };#define usb_get_ops (dev) ((struct dm_usb_ops *)(dev)->driver->ops)
@@ -949,6 +957,17 @@ int usb_new_device(struct usb_device *dev);int usb_alloc_device (struct usb_device *dev);/** +* update_hub_device() - Update HCD's internal representation of hub +* +* After a hub descriptor is fetched, notify HCD so that its internal +* representation of this hub can be updated. +* +* @dev: Hub device +* @return 0 if OK, -ve on error +*/ +int usb_update_hub_device (struct usb_device *dev); + +/** * usb_emul_setup_device() - Set up a new USB device emulation * * This is normally called when a new emulation device is bound. It tells
@@ -961,7 +980,7 @@ int usb_alloc_device(struct usb_device *dev);* @desc_list: List of points or USB descriptors, terminated by NULL. * The first entry must be struct usb_device_descriptor, * and others follow on after that. -* @return 0 if OK, -ve on error +* @return 0 if OK, -ENOSYS if not implemented, other -ve on error */ int usb_emul_setup_device (struct udevice *dev,int maxpacketsize,struct usb_string *strings,void **desc_list);
Signature · 1 line
2.9.2
PATCH 12/16 dm: usb: Add a new USB controller operation 'update_hub_device'
Quoted 11 lines · Bin Meng
For USB host controllers like xHC, its internal representation of hub needs to be updated after the hub descriptor is fetched. This adds a new op that does this.
Signed-off-by Bin Meng <[email protected]>---
drivers/usb/host/usb-uclass.c | 11 +++++++++++ include/usb.h | 21 ++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-)
PATCH 13/16 usb: hub: Call usb_update_hub_device() after hub descriptor is fetched
In reply to Bin MengAfter fetching hub descriptor, we need call USB uclass operation update_hub_device() to notify HCD to do some preparation work.
---
common/usb_hub.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
common/usb_hub.c +11 -0
@@ -782,6 +782,17 @@ static int usb_hub_configure(struct usb_device *dev)#ifdef CONFIG_DM_USB /* +* Update USB host controller's internal representation of this hub +* after the hub descriptor is fetched. +*/ + ret =usb_update_hub_device (dev); +if (ret <0 && ret != -ENOSYS ) { +debug ("%s: failed to update hub device for HCD (%x)\n" , + __func__, ret); +return ret; + } + +/* * A maximum of seven tiers are allowed in a USB topology, and the * root hub occupies the first tier. The last tier ends with a normal * USB device. USB 3.0 hubs use a 20-bit field called 'route string'
Signature · 1 line
2.9.2
PATCH 13/16 usb: hub: Call usb_update_hub_device() after hub descriptor is fetched
Quoted 1 line · Bin Meng
After fetching hub descriptor, we need call USB uclass operation
need to call
Quoted 7 lines
update_hub_device()to notify HCD to do some preparation work.Signed-off-by Bin Meng <[email protected]>---
common/usb_hub.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
PATCH 14/16 usb: xhci: Implement update_hub_device() operation
In reply to Bin MengThere is no way to know whether the attached device is a hub or not in advance before device's descriptor is fetched. But once we know it's a high speed hub, per xHCI spec, we need tell xHC it's a hub device by initializing hub related fields in the input slot context.
---
drivers/usb/host/xhci.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+)
drivers/usb/host/xhci.c +58 -0
@@ -1170,6 +1170,63 @@ static int xhci_alloc_device(struct udevice *dev, struct usb_device *udev)return _xhci_alloc_device (udev); } +static int xhci_update_hub_device (struct udevice *dev,struct usb_device *udev) +{ +struct xhci_ctrl *ctrl =dev_get_priv (dev); +struct usb_hub_device *hub =dev_get_uclass_priv (udev->dev); +struct xhci_virt_device *virt_dev; +struct xhci_input_control_ctx *ctrl_ctx; +struct xhci_container_ctx *out_ctx; +struct xhci_container_ctx *in_ctx; +struct xhci_slot_ctx *slot_ctx; +int slot_id = udev->slot_id; +unsigned think_time; + +debug ("%s: dev='%s', udev=%p\n" , __func__, dev->name, udev); + +/* Ignore root hubs */ +if (usb_hub_is_root_hub (udev->dev)) +return 0 ; + + virt_dev = ctrl->devs[slot_id]; +BUG_ON (!virt_dev); + + out_ctx = virt_dev->out_ctx; + in_ctx = virt_dev->in_ctx; + + ctrl_ctx =xhci_get_input_control_ctx (in_ctx); +/* Initialize the input context control */ + ctrl_ctx->add_flags |=cpu_to_le32 (SLOT_FLAG ); + ctrl_ctx->drop_flags =0 ; + +xhci_inval_cache ((uintptr_t )out_ctx->bytes, out_ctx->size); + +/* slot context */ +xhci_slot_copy (ctrl, in_ctx, out_ctx); + slot_ctx =xhci_get_slot_ctx (ctrl, in_ctx); + +/* Update hub related fields */ + slot_ctx->dev_info |=cpu_to_le32 (DEV_HUB ); +if (hub->tt.multi && udev->speed ==USB_SPEED_HIGH ) + slot_ctx->dev_info |=cpu_to_le32 (DEV_MTT ); + slot_ctx->dev_info2 |=cpu_to_le32 (XHCI_MAX_PORTS (udev->maxchild)); +/* +* Set TT think time - convert from ns to FS bit times. +* +* 0 = 8 FS bit times, 1 = 16 FS bit times, +* 2 = 24 FS bit times, 3 = 32 FS bit times. +* +* This field shall be 0 if the device is not a high-spped hub. +*/ + think_time = hub->tt.think_time; +if (think_time !=0 ) + think_time = (think_time /666 ) -1 ; +if (udev->speed ==USB_SPEED_HIGH ) + slot_ctx->tt_info |=cpu_to_le32 (TT_THINK_TIME (think_time)); + +return xhci_configure_endpoints (udev, false); +} +int xhci_register (struct udevice *dev,struct xhci_hccr *hccr,struct xhci_hcor *hcor) {
@@ -1222,6 +1279,7 @@ struct dm_usb_ops xhci_usb_ops = { .bulk = xhci_submit_bulk_msg, .interrupt = xhci_submit_int_msg, .alloc_device = xhci_alloc_device, + .update_hub_device = xhci_update_hub_device, };#endif
Signature · 1 line
2.9.2
PATCH 14/16 usb: xhci: Implement update_hub_device() operation
Hi Bin,
Quoted 2 lines · Bin Meng
There is no way to know whether the attached device is a hub or not in advance before device's descriptor is fetched. But once
nits:
before the device's
Quoted 1 line
we know it's a high speed hub, per xHCI spec, we need tell xHC
per the xHCI
we need to tell
Quoted 1 line
it's a hub device by initializing hub related fields in the
hub-related
Quoted 7 lines
input slot context.
Signed-off-by Bin Meng <[email protected]>---
drivers/usb/host/xhci.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+)
Quoted 50 lines
drivers/usb/host/xhci.c +41
-0@@ -1170,6 +1170,63 @@ static int xhci_alloc_device(struct udevice *dev, struct usb_device *udev)return _xhci_alloc_device (udev); } +static int xhci_update_hub_device (struct udevice *dev,struct usb_device *udev) +{ +struct xhci_ctrl *ctrl =dev_get_priv (dev); +struct usb_hub_device *hub =dev_get_uclass_priv (udev->dev); +struct xhci_virt_device *virt_dev; +struct xhci_input_control_ctx *ctrl_ctx; +struct xhci_container_ctx *out_ctx; +struct xhci_container_ctx *in_ctx; +struct xhci_slot_ctx *slot_ctx; +int slot_id = udev->slot_id; +unsigned think_time; + +debug ("%s: dev='%s', udev=%p\n" , __func__, dev->name, udev); + +/* Ignore root hubs */ +if (usb_hub_is_root_hub (udev->dev)) +return 0 ; + + virt_dev = ctrl->devs[slot_id]; +BUG_ON (!virt_dev); + + out_ctx = virt_dev->out_ctx; + in_ctx = virt_dev->in_ctx; + + ctrl_ctx =xhci_get_input_control_ctx (in_ctx); +/* Initialize the input context control */ + ctrl_ctx->add_flags |=cpu_to_le32 (SLOT_FLAG ); + ctrl_ctx->drop_flags =0 ; + +xhci_inval_cache ((uintptr_t )out_ctx->bytes, out_ctx->size); + +/* slot context */ +xhci_slot_copy (ctrl, in_ctx, out_ctx); + slot_ctx =xhci_get_slot_ctx (ctrl, in_ctx); + +/* Update hub related fields */ + slot_ctx->dev_info |=cpu_to_le32 (DEV_HUB ); +if (hub->tt.multi && udev->speed ==USB_SPEED_HIGH ) + slot_ctx->dev_info |=cpu_to_le32 (DEV_MTT ); + slot_ctx->dev_info2 |=cpu_to_le32 (XHCI_MAX_PORTS (udev->maxchild)); +/*
drivers/usb/host/xhci.c static int xhci_alloc_device(struct udevice *dev, struct usb_device *udev) · line 1223
Quoted 10 lines
drivers/usb/host/xhci.c +10
-0+* Set TT think time - convert from ns to FS bit times. +* +* 0 = 8 FS bit times, 1 = 16 FS bit times, +* 2 = 24 FS bit times, 3 = 32 FS bit times. +* +* This field shall be 0 if the device is not a high-spped hub. +*/ + think_time = hub->tt.think_time; +if (think_time !=0 ) + think_time = (think_time /666 ) -1 ;
What is 666? Can you add a comment?
Quoted 18 lines
drivers/usb/host/xhci.c +7
-1+if (udev->speed ==USB_SPEED_HIGH ) + slot_ctx->tt_info |=cpu_to_le32 (TT_THINK_TIME (think_time)); + +return xhci_configure_endpoints (udev, false); +} +int xhci_register (struct udevice *dev,struct xhci_hccr *hccr,struct xhci_hcor *hcor) {@@ -1222,6 +1279,7 @@ struct dm_usb_ops xhci_usb_ops = { .bulk = xhci_submit_bulk_msg, .interrupt = xhci_submit_int_msg, .alloc_device = xhci_alloc_device, + .update_hub_device = xhci_update_hub_device, };#endif --
Quoted 2 lines
2.9.2
Regards,
Simon
PATCH 15/16 usb: xhci: Correct TT_SLOT and TT_PORT macros
In reply to Bin MengThese two macros really need a parameter to make them useful.
---
drivers/usb/host/xhci.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/host/xhci.h +2 -2
@@ -548,12 +548,12 @@ struct xhci_slot_ctx {* The Slot ID of the hub that isolates the high speed signaling from * this low or full-speed device. '0' if attached to root hub port. */ -#define TT_SLOT (0xff) +#define TT_SLOT (p) (((p) & 0xff) << 0)/* * The number of the downstream facing port of the high-speed hub * '0' if the device is not low or full speed. */ -#define TT_PORT (0xff << 8) +#define TT_PORT (p) (((p) & 0xff) << 8)#define TT_THINK_TIME (p) (((p) & 0x3) << 16)/* dev_state bitmasks */
Signature · 1 line
2.9.2
PATCH 15/16 usb: xhci: Correct TT_SLOT and TT_PORT macros
Quoted 7 lines · Bin Meng
These two macros really need a parameter to make them useful.
Signed-off-by Bin Meng <[email protected]>---
drivers/usb/host/xhci.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
PATCH 16/16 usb: xhci: Enable TT to support LS/FS devices behind a HS hub
In reply to Bin MengSo far LS/FS devices directly attached to xHC root port can be successfully enumerated by xHCI driver, but if they are connected behind a hub, the enumeration process fails to address the device.
It turns out xHCI driver still misses a part that in the device's input slot context, all Transaction Translator (TT) related fields are not programmed. The xHCI spec defines how to enable TT.
Now LS/FS devices like USB keyboard/mouse can be enumerated behind a high speed hub.
---
drivers/usb/host/xhci-mem.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/usb/host/xhci-mem.c +14 -0
@@ -771,6 +771,20 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl,BUG (); } +#ifdef CONFIG_DM_USB +/* Set up TT fields to support FS/LS devices */ +if (speed ==USB_SPEED_LOW || speed ==USB_SPEED_FULL ) { + dev =dev_get_parent_priv (udev->dev); +if (dev->speed ==USB_SPEED_HIGH ) { + hub =dev_get_uclass_priv (udev->dev); +if (hub->tt.multi) + slot_ctx->dev_info |=cpu_to_le32 (DEV_MTT ); + slot_ctx->tt_info |=cpu_to_le32 (TT_PORT (udev->portnr)); + slot_ctx->tt_info |=cpu_to_le32 (TT_SLOT (dev->slot_id)); + } + } +#endif + port_num = hop_portnr;debug ("port_num = %d\n" , port_num);
Signature · 1 line
2.9.2
PATCH 16/16 usb: xhci: Enable TT to support LS/FS devices behind a HS hub
Quoted 8 lines · Bin Meng
So far LS/FS devices directly attached to xHC root port can be successfully enumerated by xHCI driver, but if they are connected behind a hub, the enumeration process fails to address the device.
It turns out xHCI driver still misses a part that in the device's input slot context, all Transaction Translator (TT) related fields are not programmed. The xHCI spec defines how to enable TT.
Quoted 8 lines
Now LS/FS devices like USB keyboard/mouse can be enumerated behind a high speed hub.
Signed-off-by Bin Meng <[email protected]>---
drivers/usb/host/xhci-mem.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)