Sunday, August 18, 2024

USB notes

Switching USB speed

An example from imx8mp

drivers/usb/dwc3/core.c does the speed set

    dwc->maximum_speed = usb_get_maximum_speed(dev);

usb_get_maximum_speed() gets it from dt 'maximum-speed'

From usb/generic.txt

Generic USB Properties
Optional properties:
 - maximum-speed: tells USB controllers we want to work up to a certain
speed. Valid arguments are "super-speed-plus",
"super-speed", "high-speed", "full-speed" and
"low-speed". In case this isn't passed via DT, USB
controllers should default to their maximum HW
capability.

imx8mp usb controller usb_dwc3_x dt doesn't specifically specify maximum-speed

usb3_phy0: usb-phy@381f0040 {
compatible = "fsl,imx8mp-usb-phy";
:
};
usb3_0: usb@32f10100 {
compatible = "fsl,imx8mp-dwc3";
:
usb_dwc3_0: dwc3@38100000 {
compatible = "snps,dwc3";
                                :
                        };
                };


From dwc3.txt

DWC3- USB3 CONTROLLER. Complies to the generic USB binding properties as described in 'usb/generic.txt'

From imx8mp reference manual

USB1 base address: 3810_0000h

USB2 base address: 3820_0000h

To change usb speed, we can update the dt

&usb_dwc3_0 {
    maximum-speed = "high-speed";
    :
};

Or, you can use a module param passed from kernel command-line

static int usb_maximum_speed = USB_SPEED_SUPER;
module_param(usb_maximum_speed, int, 0660);
    dwc->maximum_speed = usb_maximum_speed;

Pass it from command-line

Kernel command line: console=.. dwc3.usb_maximum_speed=3

Check usb version and speed using lsusb

$ lsusb -s 3:14 -v | grep -i bcdusb
Couldn't open device, some information will be missing
  bcdUSB               2.01


$ lsusb --tree
:
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/12p, 480M
    :
    |__ Port 6: Dev 14, If 0, Class=Communications, Driver=rndis_host, 480M
    |__ Port 6: Dev 14, If 1, Class=CDC Data, Driver=rndis_host, 480M
    |__ Port 6: Dev 14, If 2, Class=Communications, Driver=cdc_acm, 480M
    |__ Port 6: Dev 14, If 3, Class=CDC Data, Driver=cdc_acm, 480M


No comments: