Hi Roger,
Am 31.08.2018 um 09:32 schrieb Roger Quadros rogerq@ti.com:
Nikolaus,
On 30/08/18 20:17, H. Nikolaus Schaller wrote:
Hi Roger,
Am 30.08.2018 um 16:15 schrieb Roger Quadros rogerq@ti.com:
Hi Nikolaus,
Sorry for the delay. My reply below.
no problem - we have enough other issues to work on (e.g. TILER, AESS) :)
On 05/07/18 11:22, Tony Lindgren wrote:
Hi,
- H. Nikolaus Schaller hns@goldelico.com [180704 18:06]:
Hi Tony, I have seen two small issues:
a) USB client mode works fine, except that on first plug in of the cable I see NOHZ warnings (which seem to be harmless):
dhcpcd[2317]: version 6.0.5 starting dhcpcd[2317]: wlan0: waiting for carrier dhcpcd[2317]: usb0: waiting for carrier dhcpcd[2317]: wlan0: carrier acquired dhcpcd[2317]: wlan0: carrier lost dhcpcd[2317]: wlan0: waiting for carrier [ 23.626353] wlcore: down [ 46.919138] g_ether gadget: high-speed config #1: CDC Ethernet (ECM) [ 47.285640] bq24296: VBUS became available [ 47.290052] bq24296_update_input_current_limit(6) [ 48.531529] IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready [ 48.593338] NOHZ: local_softirq_pending 08 [ 48.826821] NOHZ: local_softirq_pending 08 [ 48.987261] NOHZ: local_softirq_pending 08 [ 49.288690] NOHZ: local_softirq_pending 08 [ 49.381113] NOHZ: local_softirq_pending 08 [ 49.610246] NOHZ: local_softirq_pending 08 [ 49.774833] NOHZ: local_softirq_pending 08 [ 49.888948] NOHZ: local_softirq_pending 08 [ 50.143018] NOHZ: local_softirq_pending 08 [ 50.168652] NOHZ: local_softirq_pending 08 dhcpcd[2317]: timed out dhcpcd[2317]: allowing 8 seconds for IPv4LL timeout dhcpcd[2317]: usb0: carrier acquired dhcpcd[2317]: usb0: soliciting an IPv6 router dhcpcd[2317]: usb0: using IPv4LL address 169.254.83.144 dhcpcd[2317]: usb0: adding host route to 169.254.83.144 via 127.0.0.1 dhcpcd[2317]: usb0: adding route to 169.254.0.0/16 dhcpcd[2317]: forked to background, child pid 2812 [FAIL] startpar: service(s) returned failure: isc-dhcp-server ... failed!
Debian GNU/Linux 8 letux console
letux login: root Password:
It is the same on omap5uevm:
root@letux:~# [ 2858.377258] g_ether gadget: high-speed config #1: CDC Ethernet (ECM) [ 2859.205770] IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready [ 2859.279922] NOHZ: local_softirq_pending 08 [ 2859.481076] NOHZ: local_softirq_pending 08 [ 2859.800392] NOHZ: local_softirq_pending 08 [ 2859.913331] NOHZ: local_softirq_pending 08 [ 2860.052946] NOHZ: local_softirq_pending 08 [ 2860.232251] NOHZ: local_softirq_pending 08 [ 2860.280545] NOHZ: local_softirq_pending 08 [ 2860.445238] NOHZ: local_softirq_pending 08 [ 2860.541821] NOHZ: local_softirq_pending 08 [ 2860.808122] NOHZ: local_softirq_pending 08
root@letux:~# [ 2872.169307] g_ether gadget: high-speed config #1: CDC Ethernet (ECM)
b) OTG mode detects cable plugin (extcon) and turns on power but dwc3 does not try to find the connected device
root@letux:~# [ 692.970418] bq24296: VBUS became unavailable [ 850.289966] bq24296_otg_is_enabled(1) [ 850.294997] bq24296_otg_enable(1) [ 858.377691] bq24296_otg_disable(1) [ 864.544944] bq24296_otg_is_enabled(1) [ 864.549017] bq24296_otg_enable(1) [ 866.834895] bq24296_otg_disable(1)
Same on omap5uevm (just power can be measured, not the bq24296 printk of course).
otg mode was never tested on omap5uevm.
omap5.dtsi sets dwc3 controller's dr_mode to "peripheral". And it remains like that. So we need to set it to "otg" in the boards that need dual-role support.
Ah, ok. That explains a lot!
I had only verified that we have enabled OTG support in the CONFIG.
The other missing piece for omap5uevm is how to enable the VBUS regulator that is on the PMIC (palmas). Unlike later SoCs (AM43/DRA7) omap5 doesn't have a DRVVBUS pin that can turn on an external VBUS regulator. So this must be done by SW.
Powering the external device seems to work, when I plug in an USB-Host cable, I get 5V output. If I remember correctly (I have no access to the EVM in the next days), there is an extcon dedicated to detecting the ID pin and turning on SMPS10.
Which driver is it using? Is it upstream? But if it is taking care of turning on/off vbus independently then it should be fine. We don't have to plug it to the dwc3 driver.
The USB2 PHY that we use model in omap5.dtsi is a generic-phy and does not implement otg_set_vbus(). VBUS regulator is managed by PMIC. So we need to model the PMIC VBUS regulator as a 2nd USB2 PHY and implement otg->set_host() and otg->set_peripheral() for it.
Any ideas how to fix / debug?
Can I see your board's device tree file?
For tests on the EVM, I use the upstream omap5-uevm.dts which is based on omap5-board-common.dtsi.
Can you see dwc3 otg interrupts in /proc/interrupts when you plug/unplug a host adapter?
Yes, I'll test that asap.
You could also apply the below patch so we know what role the controller is in.
diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c index 218371f..56c94cd 100644 --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -327,6 +327,20 @@ static void dwc3_otg_device_exit(struct dwc3 *dwc) dwc3_writel(dwc->regs, DWC3_OCTL, reg); }
+static char * otg_role_string(int role) +{
- switch (role) {
- case DWC3_OTG_ROLE_IDLE:
return "idle";
- case DWC3_OTG_ROLE_DEVICE:
return "device";
- case DWC3_OTG_ROLE_HOST:
return "host";
- default:
return "invalid";
- }
+}
void dwc3_otg_update(struct dwc3 *dwc, bool ignore_idstatus) { int ret; @@ -372,6 +386,8 @@ void dwc3_otg_update(struct dwc3 *dwc, bool ignore_idstatus)
spin_lock_irqsave(&dwc->lock, flags);
dev_info(dwc->dev, "otg: %s->%s\n", otg_role_string(dwc->current_otg_role),
otg_role_string(dwc->desired_otg_role));
dwc->current_otg_role = dwc->desired_otg_role;
spin_unlock_irqrestore(&dwc->lock, flags);
-- cheers, -roger
I have added your patch and added
+&dwc3 { + dr_mode = "otg"; +}; +
to omap5-board-common.dtsi (because it already handles extcon/smps10 enable).
And it looks as if OTG just works!
a) after boot
root@letux:~# dmesg|fgrep dwc3 [ 5.733612] dwc3 4a030000.dwc3: Failed to get clk 'ref': -2 [ 5.774769] dwc3 4a030000.dwc3: otg: idle->device [ 5.785048] dwc3 4a030000.dwc3: changing max_speed on rev 5533202a root@letux:~#
b) when plugging in client cable (works the same as before)
[ 273.025757] g_ether gadget: high-speed config #1: CDC Ethernet (ECM) [ 274.367805] IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready [ 274.430674] NOHZ: local_softirq_pending 08 [ 274.733861] NOHZ: local_softirq_pending 08 [ 274.825679] NOHZ: local_softirq_pending 08 [ 275.011571] NOHZ: local_softirq_pending 08 [ 275.087843] NOHZ: local_softirq_pending 08 [ 275.217868] NOHZ: local_softirq_pending 08 [ 275.404545] NOHZ: local_softirq_pending 08 [ 275.432020] NOHZ: local_softirq_pending 08 [ 275.612179] NOHZ: local_softirq_pending 08 [ 275.721921] NOHZ: local_softirq_pending 08
c) when plugging in the OTG cable
[ 312.903775] dwc3 4a030000.dwc3: otg: device->host [ 312.916996] xhci-hcd xhci-hcd.1.auto: xHCI Host Controller [ 312.924253] xhci-hcd xhci-hcd.1.auto: new USB bus registered, assigned bus number 2 [ 312.934021] xhci-hcd xhci-hcd.1.auto: hcc params 0x0220f04c hci version 0x100 quirks 0x0000000002010010 [ 312.944522] xhci-hcd xhci-hcd.1.auto: irq 183, io mem 0x4a030000 [ 312.951418] usb usb2: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 4.18 [ 312.960256] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1 [ 312.968059] usb usb2: Product: xHCI Host Controller [ 312.973287] usb usb2: Manufacturer: Linux 4.18.0-letux+ xhci-hcd [ 312.979577] usb usb2: SerialNumber: xhci-hcd.1.auto [ 312.985199] hub 2-0:1.0: USB hub found [ 312.989255] hub 2-0:1.0: 1 port detected [ 313.003056] xhci-hcd xhci-hcd.1.auto: xHCI Host Controller [ 313.011929] xhci-hcd xhci-hcd.1.auto: new USB bus registered, assigned bus number 3 [ 313.019970] xhci-hcd xhci-hcd.1.auto: Host supports USB 3.0 SuperSpeed [ 313.027037] usb usb3: We don't know the algorithms for LPM for this host, disabling LPM. [ 313.035684] usb usb3: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 4.18 [ 313.044413] usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1 [ 313.052015] usb usb3: Product: xHCI Host Controller [ 313.057186] usb usb3: Manufacturer: Linux 4.18.0-letux+ xhci-hcd [ 313.063501] usb usb3: SerialNumber: xhci-hcd.1.auto [ 313.069163] hub 3-0:1.0: USB hub found [ 313.073157] hub 3-0:1.0: 1 port detected
d) plugging in an USB2 memory stick to the OTG port
[ 335.872164] usb 2-1: new high-speed USB device number 2 using xhci-hcd [ 336.052854] usb 2-1: New USB device found, idVendor=0204, idProduct=6025, bcdDevice= 1.00 [ 336.061427] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 336.068957] usb 2-1: Product: Flash Disk [ 336.073122] usb 2-1: Manufacturer: CBM [ 336.077060] usb 2-1: SerialNumber: 221835001DC5F204 [ 336.085548] usb-storage 2-1:1.0: USB Mass Storage device detected [ 336.092844] scsi host2: usb-storage 2-1:1.0 [ 337.138193] scsi 2:0:0:0: Direct-Access CBM Flash Disk 5.00 PQ: 0 ANSI: 2 [ 337.148804] sd 2:0:0:0: Attached scsi generic sg2 type 0 [ 337.166049] sd 2:0:0:0: [sdc] 2072064 512-byte logical blocks: (1.06 GB/1012 MiB) [ 337.174299] sd 2:0:0:0: [sdc] Write Protect is off [ 337.179326] sd 2:0:0:0: [sdc] Mode Sense: 0b 00 00 08 [ 337.184845] sd 2:0:0:0: [sdc] No Caching mode page found [ 337.190409] sd 2:0:0:0: [sdc] Assuming drive cache: write through [ 337.198545] sdc: sdc1 [ 337.205988] sd 2:0:0:0: [sdc] Attached SCSI removable disk /usr/share/usbmount/usbmount: label DOS Mountpoints /media/hns/DOS /media/usb0 /media/usb1 /media/usb2 /media/usb3 /media/usb4 /media/usb5 /media/usb6 /media/usb7 Mounting DOS rmdir /media/hns/boot rmdir: failed to remove '/media/hns/boot': Directory not empty rmdir /media/hns/rootfs rmdir: failed to remove '/media/hns/rootfs': Directory not empty [ 337.590093] FAT-fs (sdc1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck. [ 338.181832] omap_i2c 48072000.i2c: timeout waiting for bus ready [ 338.188145] bq2429x_charger 1-006b: bq24296_charger_probe(): Failed in reading register 0x0a
e) unplugging memory stick
[ 359.540212] usb 2-1: USB disconnect, device number 2
f) unplugging cable
[ 582.297499] xhci-hcd xhci-hcd.1.auto: remove, state 4 [ 582.302937] usb usb3: USB disconnect, device number 1 [ 582.309817] xhci-hcd xhci-hcd.1.auto: USB bus 3 deregistered [ 582.318382] xhci-hcd xhci-hcd.1.auto: remove, state 4 [ 582.323684] usb usb2: USB disconnect, device number 1 [ 582.331065] xhci-hcd xhci-hcd.1.auto: USB bus 2 deregistered [ 582.338002] dwc3 4a030000.dwc3: otg: host->device [ 582.343218] dwc3 4a030000.dwc3: changing max_speed on rev 5533202a [ 582.350704] using random self ethernet address [ 582.355404] using random host ethernet address [ 582.360121] using host ethernet address: 32:70:05:18:ff:78 [ 582.360125] using self ethernet address: 46:10:3a:b3:af:d9 [ 582.366515] usb0: HOST MAC 32:70:05:18:ff:78 [ 582.377671] usb0: MAC 46:10:3a:b3:af:d9 [ 582.382025] using random self ethernet address [ 582.388579] using random host ethernet address [ 582.393353] g_ether gadget: Ethernet Gadget, version: Memorial Day 2008 [ 582.400333] g_ether gadget: g_ether ready
g) plugging client cable
[ 612.975725] g_ether gadget: high-speed config #1: CDC Ethernet (ECM)
It properly switches from device -> host -> device mode and is already useable. What I have not observed is a transition to -> idle and I have not yet tested with an USB3 device.
BTW: is there a /sys node to read the OTG state?
So I'll test a little more an send a patch for review to LKML in the next days.
BR and thanks, Nikolaus