
On Sat, 9 Dec 2023 18:10:56 +0000 Shantur Rathore i@shantur.com wrote:
Hi,
Currently when a hub is turned on, all the ports are powered on. This works well for hubs which have individual power control.
For the hubs without individual power control this has no effect. Mostly in these scenarios the hub port is powered before the USB controller is enabled, this can lead to some devices in unexpected state.
With this patch, we explicitly reset the port while powering up hub This resets the port for hubs without port power control and has no effect on hubs with port power control as the port is still off.
Before this patch AMicro AM8180 based NVME to USB adapter won't be detected as a USB3.0 Mass Storage device but with this it works as expected.
Tested working after this patch:
- AMicro AM8180 based NVME to USB Adapter
- Kingston DataTraveler 3.0
- GenesysLogic USB3.0 Hub
The drives were tested while connected directly and via the hub.
so this broke USB operation on some Allwinner boards. The ports still enumerate correctly, but no devices are detected. With mainline (containing this patch), and a USB stick connected: starting USB... Bus usb@5200000: USB EHCI 1.00 Bus usb@5200400: USB OHCI 1.0 scanning bus usb@5200000 for devices... 1 USB Device(s) found scanning bus usb@5200400 for devices... 1 USB Device(s) found scanning usb for storage devices... 0 Storage Device(s) found
With this patch here reverted: starting USB... Bus usb@5200000: USB EHCI 1.00 Bus usb@5200400: USB OHCI 1.0 scanning bus usb@5200000 for devices... 2 USB Device(s) found scanning bus usb@5200400 for devices... 1 USB Device(s) found scanning usb for storage devices... 1 Storage Device(s) found
I have no clue why this happens, there is no discrete hub anywhere in this setup, so I guess the code runs for the root hub here? I am attaching a log with DEBUG enabled for common/usb_hub.c, for both cases.
Any clues, debug suggestions, or even a fix are warmly welcome.
Cheers, Andre
Changes in v3:
- Split up patches as seperate series
Changes in v2:
- As requested, added fix for regulator-always-on in RockPro64
common/usb_hub.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/common/usb_hub.c b/common/usb_hub.c index 70279f301d..3fb7e14d10 100644 --- a/common/usb_hub.c +++ b/common/usb_hub.c @@ -174,8 +174,10 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
debug("enabling power on all ports\n"); for (i = 0; i < dev->maxchild; i++) {
usb_set_port_feature(dev, i + 1, USB_PORT_FEAT_RESET);
usb_set_port_feature(dev, i + 1, USB_PORT_FEAT_POWER);debug("Reset : port %d returns %lX\n", i + 1, dev->status);
debug("port %d returns %lX\n", i + 1, dev->status);
}debug("PowerOn : port %d returns %lX\n", i + 1, dev->status);
#ifdef CONFIG_SANDBOX