diff mbox

[v2,0/3] USB: add generic onboard USB HUB driver

Message ID 20151215062821.GA11241@shlinux2 (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Chen Dec. 15, 2015, 6:28 a.m. UTC
On Mon, Dec 14, 2015 at 09:26:55AM -0200, Fabio Estevam wrote:
> Hi Peter,
> 
> On Mon, Dec 14, 2015 at 5:26 AM, Peter Chen <peter.chen@freescale.com> wrote:
> 
> > Hi all,
> >
> > There is a known issue that the USB code can't handle USB HUB's
> > external pins well, in that case, it may cause some onboard
> > USB HUBs can't work since their PHY's clock or reset pin needs to
> > operate.
> >
> > The user reported this issue at below:
> > http://www.spinics.net/lists/linux-usb/msg131502.html
> >
> > In this patch set, I add a generic onboard USB HUB driver to
> > handle this problem, the external signals will be configured
> > before usb controller's initialization, it much likes we did
> > it at board code before.
> >
> > The user needs to add this generic hub node at dts to support it.
> >
> > @The udoo users, help to test please.
> 
> This is what I get with your series applied:
> 
> [    2.288300] usb 1-1: device descriptor read/64, error -71
> [    2.518083] usb 1-1: new full-speed USB device number 3 using ci_hdrc
> [    2.738078] usb 1-1: device descriptor read/64, error -71
> [    3.058078] usb 1-1: device descriptor read/64, error -71
> [    3.288079] usb 1-1: new full-speed USB device number 4 using ci_hdrc
> [    3.768069] usb 1-1: device not accepting address 4, error -71
> [    3.888084] usb 1-1: new full-speed USB device number 5 using ci_hdrc
> [    4.368067] usb 1-1: device not accepting address 5, error -71
> [    4.374117] usb usb1-port1: unable to enumerate USB device

Thanks, Fabio.

I am afraid I forget to set gpio as output, would you please apply
below patch against my original ones:

Comments

Fabio Estevam Dec. 15, 2015, 11:32 a.m. UTC | #1
On Tue, Dec 15, 2015 at 4:28 AM, Peter Chen <peter.chen@freescale.com> wrote:

> Thanks, Fabio.
>
> I am afraid I forget to set gpio as output, would you please apply
> below patch against my original ones:

Same error happens with these changes applied.

Here are more details: if I run a pure 4.3.2 then I do see the USB
stick to get detected if I boot it with the USB stick connected to
Udoo board:

[    2.170178] usb 1-1.1: new high-speed USB device number 3 using ci_hdrc
[    2.305840] usb-storage 1-1.1:1.0: USB Mass Storage device detected
[    2.314803] scsi host1: usb-storage 1-1.1:1.0
[    2.400283] usb 1-1.3: new high-speed USB device number 4 using ci_hdrc
[    3.327925] scsi 1:0:0:0: Direct-Access     General  USB Flash Disk   1.0  P2
[    3.347070] sd 1:0:0:0: [sda] 7831552 512-byte logical blocks: (4.01 GB/3.73)
[    3.356181] sd 1:0:0:0: [sda] Write Protect is off
[    3.362550] sd 1:0:0:0: [sda] No Caching mode page found
[    3.367899] sd 1:0:0:0: [sda] Assuming drive cache: write through
[    3.387401]  sda: sda1
[    3.400238] sd 1:0:0:0: [sda] Attached SCSI removable disk
[    4.931847] fec 2188000.ethernet eth0: Link is Up - 100Mbps/Full - flow contx
[    4.941414] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[    4.961400] Sending DHCP requests ., OK
[    5.380247] IP-Config: Got DHCP answer from 10.29.244.251, my address is 10.1
[    5.390461] IP-Config: Complete:
[    5.393731]      device=eth0, hwaddr=00:c0:08:88:0c:b5, ipaddr=10.29.244.61,4
[    5.404074]      host=10.29.244.61, domain=am.freescale.net, nis-domain=(non)
[    5.411362]      bootserver=0.0.0.0, rootserver=10.29.244.24, rootpath=     0
[    5.423964] ALSA device list:
[    5.426969]   No soundcards found.
[    5.469374] VFS: Mounted root (nfs filesystem) readonly on device 0:14.
[    5.478119] devtmpfs: mounted
[    5.482376] Freeing unused kernel memory: 456K (c0a7e000 - c0af0000)
starting pid 160, tty '': '/etc/rc.d/rcS'
Mounting /proc and /sys
Starting the hotplug events dispatcher udevd
Synthesizing initial hotplug even[    6.085842] udevd (173): /proc/173/oom_adj .

,but the system hangs here.

If I boot it with the USB stick disconnected, then the system boots
until the prompt, but the insertion of the USB stick is never detected
afterwards.

With your patch applied, the error message (usb 1-1: device descriptor
read/64, error -7) is shown with USB stick connected or disconnected
during boot.
Peter Chen Dec. 16, 2015, 4:11 a.m. UTC | #2
On Tue, Dec 15, 2015 at 09:32:18AM -0200, Fabio Estevam wrote:
> On Tue, Dec 15, 2015 at 4:28 AM, Peter Chen <peter.chen@freescale.com> wrote:
> 
> > Thanks, Fabio.
> >
> > I am afraid I forget to set gpio as output, would you please apply
> > below patch against my original ones:
> 
> Same error happens with these changes applied.
> 
> Here are more details: if I run a pure 4.3.2 then I do see the USB
> stick to get detected if I boot it with the USB stick connected to
> Udoo board:
> 
> [    2.170178] usb 1-1.1: new high-speed USB device number 3 using ci_hdrc
> [    2.305840] usb-storage 1-1.1:1.0: USB Mass Storage device detected
> [    2.314803] scsi host1: usb-storage 1-1.1:1.0
> [    2.400283] usb 1-1.3: new high-speed USB device number 4 using ci_hdrc
> [    3.327925] scsi 1:0:0:0: Direct-Access     General  USB Flash Disk   1.0  P2
> [    3.347070] sd 1:0:0:0: [sda] 7831552 512-byte logical blocks: (4.01 GB/3.73)
> [    3.356181] sd 1:0:0:0: [sda] Write Protect is off
> [    3.362550] sd 1:0:0:0: [sda] No Caching mode page found
> [    3.367899] sd 1:0:0:0: [sda] Assuming drive cache: write through
> [    3.387401]  sda: sda1
> [    3.400238] sd 1:0:0:0: [sda] Attached SCSI removable disk
> [    4.931847] fec 2188000.ethernet eth0: Link is Up - 100Mbps/Full - flow contx
> [    4.941414] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
> [    4.961400] Sending DHCP requests ., OK
> [    5.380247] IP-Config: Got DHCP answer from 10.29.244.251, my address is 10.1
> [    5.390461] IP-Config: Complete:
> [    5.393731]      device=eth0, hwaddr=00:c0:08:88:0c:b5, ipaddr=10.29.244.61,4
> [    5.404074]      host=10.29.244.61, domain=am.freescale.net, nis-domain=(non)
> [    5.411362]      bootserver=0.0.0.0, rootserver=10.29.244.24, rootpath=     0
> [    5.423964] ALSA device list:
> [    5.426969]   No soundcards found.
> [    5.469374] VFS: Mounted root (nfs filesystem) readonly on device 0:14.
> [    5.478119] devtmpfs: mounted
> [    5.482376] Freeing unused kernel memory: 456K (c0a7e000 - c0af0000)
> starting pid 160, tty '': '/etc/rc.d/rcS'
> Mounting /proc and /sys
> Starting the hotplug events dispatcher udevd
> Synthesizing initial hotplug even[    6.085842] udevd (173): /proc/173/oom_adj .
> 
> ,but the system hangs here.
> 
> If I boot it with the USB stick disconnected, then the system boots
> until the prompt, but the insertion of the USB stick is never detected
> afterwards.
> 

Thanks, Fabio, but I am curious how things like that? The USBOH3 clock
is not opened, the usb driver will hang when it tries to access
registers. If this clock is always on, then, why the system will
hang later?

> With your patch applied, the error message (usb 1-1: device descriptor
> read/64, error -7) is shown with USB stick connected or disconnected
> during boot.

Would you help to check again the clock is IMX6QDL_CLK_CKO and the reset
pin is GPIO7 bit 12? If they are, check below two things please:
- The clock is opened (You can check if through clock tree)
- The gpio is high (phy_addr is 0x20b4000, the bit is 12)

If they are correct, try to toggle gpio manually to see if it can work.
diff mbox

Patch

diff --git a/arch/arm/boot/dts/imx6qdl-udoo.dtsi b/arch/arm/boot/dts/imx6qdl-udoo.dtsi
index 64eabe2..34b0708 100644
--- a/arch/arm/boot/dts/imx6qdl-udoo.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-udoo.dtsi
@@ -24,7 +24,7 @@ 
 		compatible = "generic-onboard-hub";
 		clocks = <&clks IMX6QDL_CLK_CKO>;
 		reset-gpios = <&gpio7 12 GPIO_ACTIVE_LOW>;
-		reset-duration-us = <2>;
+		reset-duration-us = <10>;
 	};
 };
 
diff --git a/drivers/usb/misc/generic_onboard_hub.c b/drivers/usb/misc/generic_onboard_hub.c
index 7db5b78..2f0afa7 100644
--- a/drivers/usb/misc/generic_onboard_hub.c
+++ b/drivers/usb/misc/generic_onboard_hub.c
@@ -89,6 +89,8 @@  static int usb_hub_generic_probe(struct platform_device *pdev)
 	of_property_read_u32(node, "reset-duration-us", &duration_us);
 
 	if (gpiod_reset) {
+		gpiod_direction_output(gpiod_reset, 1);
+
 		gpiod_set_value(gpiod_reset, 1);
 		usleep_range(duration_us, duration_us + 10);
 		gpiod_set_value(gpiod_reset, 0);