Skip to contentSkip to conversation

iMX51 usb fixes

PATCH New Arnaud Patard (Rtp) 4 participants 23 messages Dec 20, 2010 – Jan 11, 2011

lore
Share & tools
lore
#0 lore raw

cover iMX51 usb fixes

This patchset aims at fixing several issues I found in the usb support for iMX51 while working on the Genesis EFIKAMX/EFIKASB systems. The most "annoying" one is the usb clock patch. I found out that when the clocks are not properly enabled my system just hangs when trying to read a usb register. So far, I guess only luck (or different bootloader behaviour) may explain that nobody got hit by this.

Warning:
It has been tested on both devices against Sascha's imx-for-2.6.38 branch. It's possible that some of them apply against current mainline but I can't test such a configuration.

Arnaud

#2 lore raw

PATCH 1/5 ehci-mxc: Enable vbus later

Quoted 2 lines · Arnaud Patard

vbus should be enabled after usb_add_hcd() otherwise USB is not working on my efikamx.

There is really something wrong with the way we handle initialization of the mxc ehci controller. There are frequently patches posted trying to change this order, and I think we are at a point where we can't move anymore without possibly breaking some other board. Should this be completely board dependend in the end?

Sascha

Quoted 36 lines

Index: tst-usb/drivers/usb/host/ehci-mxc.c
===================================================================

drivers/usb/host/ehci-mxc.c +8 -5
@@ -210,11 +210,6 @@
 			ret = -ENODEV;
 			goto err_add;
 		}
-		ret = otg_set_vbus(pdata->otg, 1);
-		if (ret) {
-			dev_err(dev, "unable to enable vbus on transceiver\n");
-			goto err_add;
-		}
 	}
 
 	priv->hcd = hcd;
@@ -224,6 +219,14 @@
 	if (ret)
 		goto err_add;
 
+	if (pdata->otg) {
+		ret = otg_set_vbus(pdata->otg, 1);
+		if (ret) {
+			dev_err(dev, "unable to enable vbus on transceiver\n");
+			goto err_add;
+		}
+	}
+
 	return 0;
 
 err_add:
Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#3 lore raw

PATCH 1/5 ehci-mxc: Enable vbus later

Quoted 9 lines · Sascha Hauer
Quoted 2 lines · Arnaud Patard

vbus should be enabled after usb_add_hcd() otherwise USB is not working on my efikamx.

There is really something wrong with the way we handle initialization of the mxc ehci controller. There are frequently patches posted trying to change this order, and I think we are at a point where we can't move anymore without possibly breaking some other board. Should this be completely board dependend in the end?

I'm not aware of any other bug except the postsc setting one (which was that any code trying to read the ulpi register without making sure that portsc is configured for ulpi is buggy). Moreover, the change is following the fsl bsp. I know it's not necessary the best code of the world but I believe it has been tested on a lot of imx platforms.

Arnaud

#4 lore raw

PATCH 1/5 ehci-mxc: Enable vbus later

In reply to Arnaud Patard (Rtp)
Quoted 2 lines · Arnaud Patard

vbus should be enabled after usb_add_hcd() otherwise USB is not working on my efikamx.

I have tested this on different i.MX27/31/35 based boards, the USB is still functional, so

Quoted 36 lines

Index: tst-usb/drivers/usb/host/ehci-mxc.c
===================================================================

drivers/usb/host/ehci-mxc.c +8 -5
@@ -210,11 +210,6 @@
 			ret = -ENODEV;
 			goto err_add;
 		}
-		ret = otg_set_vbus(pdata->otg, 1);
-		if (ret) {
-			dev_err(dev, "unable to enable vbus on transceiver\n");
-			goto err_add;
-		}
 	}
 
 	priv->hcd = hcd;
@@ -224,6 +219,14 @@
 	if (ret)
 		goto err_add;
 
+	if (pdata->otg) {
+		ret = otg_set_vbus(pdata->otg, 1);
+		if (ret) {
+			dev_err(dev, "unable to enable vbus on transceiver\n");
+			goto err_add;
+		}
+	}
+
 	return 0;
 
 err_add:
Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#6 lore raw

PATCH 2/5 ulpi: handle ULPI_OTG_CTRL_CHRGVBUS

Hi Arnaud,

Quoted 21 lines · Arnaud Patard (Rtp)

Current code doesn't handle setting CHRGVBUS when enabling vbus. Add support for it

Index: tst-usb/drivers/usb/otg/ulpi.c
===================================================================

drivers/usb/otg/ulpi.c +2 -1
@@ -234,7 +234,8 @@
 {
 	unsigned int flags = otg_io_read(otg, ULPI_OTG_CTRL);
 
-	flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT);
+	flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT |
+			ULPI_OTG_CTRL_CHRGVBUS);
 
 	if (on) {
 		if (otg->flags & ULPI_OTG_DRVVBUS)

drivers/usb/otg/ulpi.c line 251

Quoted 9 lines
drivers/usb/otg/ulpi.c +3 -0
@@ -242,6 +243,9 @@
 
 		if (otg->flags & ULPI_OTG_DRVVBUS_EXT)
 			flags |= ULPI_OTG_CTRL_DRVVBUS_EXT;
+
+		if (otg->flags & ULPI_OTG_CHRGVBUS)
+			flags |= ULPI_OTG_CTRL_CHRGVBUS;
 	}
 
 	return otg_io_write(otg, flags, ULPI_OTG_CTRL);

I think this is a wrong place to set the ChrgVbus bit.
As for ULPI spec. 1.1:
"3.8.7.1 Session Request Protocol (SRP)
ULPI provides full SRP support. The Link uses the ChrgVbus and DischrgVbus bits in the OTG Control register to begin and end a session."

So it is used for SRP.
May be it is better to implement
int (*start_srp)(struct otg_transceiver *otg);
method for setting this bit?

Quoted 7 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Regards,
Igor.
#7 lore raw

PATCH 2/5 ulpi: handle ULPI_OTG_CTRL_CHRGVBUS

Quoted 40 lines · Igor Grinberg

Hi Arnaud,

Quoted 21 lines · Arnaud Patard (Rtp)

Current code doesn't handle setting CHRGVBUS when enabling vbus. Add support for it

Index: tst-usb/drivers/usb/otg/ulpi.c
===================================================================

drivers/usb/otg/ulpi.c +2 -1
@@ -234,7 +234,8 @@
 {
 	unsigned int flags = otg_io_read(otg, ULPI_OTG_CTRL);
 
-	flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT);
+	flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT |
+			ULPI_OTG_CTRL_CHRGVBUS);
 
 	if (on) {
 		if (otg->flags & ULPI_OTG_DRVVBUS)

drivers/usb/otg/ulpi.c line 251

Quoted 9 lines
drivers/usb/otg/ulpi.c +3 -0
@@ -242,6 +243,9 @@
 
 		if (otg->flags & ULPI_OTG_DRVVBUS_EXT)
 			flags |= ULPI_OTG_CTRL_DRVVBUS_EXT;
+
+		if (otg->flags & ULPI_OTG_CHRGVBUS)
+			flags |= ULPI_OTG_CTRL_CHRGVBUS;
 	}
 
 	return otg_io_write(otg, flags, ULPI_OTG_CTRL);

I think this is a wrong place to set the ChrgVbus bit.
As for ULPI spec. 1.1:
"3.8.7.1 Session Request Protocol (SRP)
ULPI provides full SRP support. The Link uses the ChrgVbus and DischrgVbus bits in the OTG Control register to begin and end a session."

Quoted 5 lines

So it is used for SRP.
May be it is better to implement
int (*start_srp)(struct otg_transceiver *otg);
method for setting this bit?

I was not sure on where to put this so I took the same approach as the fsl bsp which was to set it in this function and to call this function _after_ usb_add_hcd() [ see my previous patch ]. Indeed, it fixed my issue so I believe it not so bad given that there has already been some troubles on the ehci-mxc init.

Arnaud

#8 lore raw

PATCH 2/5 ulpi: handle ULPI_OTG_CTRL_CHRGVBUS

Quoted 46 lines · Arnaud Patard (Rtp)
Quoted 39 lines · Igor Grinberg

Hi Arnaud,

Quoted 21 lines · Arnaud Patard (Rtp)

Current code doesn't handle setting CHRGVBUS when enabling vbus. Add support for it

Index: tst-usb/drivers/usb/otg/ulpi.c
===================================================================

drivers/usb/otg/ulpi.c +2 -1
@@ -234,7 +234,8 @@
 {
 	unsigned int flags = otg_io_read(otg, ULPI_OTG_CTRL);
 
-	flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT);
+	flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT |
+			ULPI_OTG_CTRL_CHRGVBUS);
 
 	if (on) {
 		if (otg->flags & ULPI_OTG_DRVVBUS)

drivers/usb/otg/ulpi.c line 251

Quoted 9 lines
drivers/usb/otg/ulpi.c +3 -0
@@ -242,6 +243,9 @@
 
 		if (otg->flags & ULPI_OTG_DRVVBUS_EXT)
 			flags |= ULPI_OTG_CTRL_DRVVBUS_EXT;
+
+		if (otg->flags & ULPI_OTG_CHRGVBUS)
+			flags |= ULPI_OTG_CTRL_CHRGVBUS;
 	}
 
 	return otg_io_write(otg, flags, ULPI_OTG_CTRL);

I think this is a wrong place to set the ChrgVbus bit.
As for ULPI spec. 1.1:
"3.8.7.1 Session Request Protocol (SRP)
ULPI provides full SRP support. The Link uses the ChrgVbus and DischrgVbus bits in the OTG Control register to begin and end a session."

Quoted 5 lines

So it is used for SRP.
May be it is better to implement
int (*start_srp)(struct otg_transceiver *otg);
method for setting this bit?

Quoted 5 lines

I was not sure on where to put this so I took the same approach as the fsl bsp which was to set it in this function and to call this function _after_ usb_add_hcd() [ see my previous patch ]. Indeed, it fixed my issue so I believe it not so bad given that there has already been some troubles on the ehci-mxc init.

Well, the problem is that this is supposed to be a generic driver and it should somehow follow the ULPI spec.
This patch makes it more like mxc specific.

As far as I understand, Session Request Protocol (SRP) allows a B-device (Peripheral) to nudge an A-device (Host) to turn on the USB's Vbus.
This patch enables SRP along with Vbus, which seems incorrect completely. ulpi_set_vbus() should set the Vbus (as its name says) and that's it.

Have you tried without this patch or have you just applied it along with other patches from the fsl bsp?

Also, if this specific patch (2/5) makes your USB (Host as I understand) work, it makes me think that there could be some problem with your Vbus supply. Have you checked that?

Quoted 2 lines

Arnaud

Signature · 2 lines
Regards,
Igor.
#9 lore raw

PATCH 2/5 ulpi: handle ULPI_OTG_CTRL_CHRGVBUS

Igor Grinberg <[email protected]> writes:
Hi,

Quoted 53 lines · Arnaud Patard (Rtp)
Quoted 46 lines
Quoted 39 lines · Igor Grinberg

Hi Arnaud,

Quoted 21 lines · Arnaud Patard (Rtp)

Current code doesn't handle setting CHRGVBUS when enabling vbus. Add support for it

Index: tst-usb/drivers/usb/otg/ulpi.c
===================================================================

drivers/usb/otg/ulpi.c +2 -1
@@ -234,7 +234,8 @@
 {
 	unsigned int flags = otg_io_read(otg, ULPI_OTG_CTRL);
 
-	flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT);
+	flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT |
+			ULPI_OTG_CTRL_CHRGVBUS);
 
 	if (on) {
 		if (otg->flags & ULPI_OTG_DRVVBUS)

drivers/usb/otg/ulpi.c line 251

Quoted 9 lines
drivers/usb/otg/ulpi.c +3 -0
@@ -242,6 +243,9 @@
 
 		if (otg->flags & ULPI_OTG_DRVVBUS_EXT)
 			flags |= ULPI_OTG_CTRL_DRVVBUS_EXT;
+
+		if (otg->flags & ULPI_OTG_CHRGVBUS)
+			flags |= ULPI_OTG_CTRL_CHRGVBUS;
 	}
 
 	return otg_io_write(otg, flags, ULPI_OTG_CTRL);

I think this is a wrong place to set the ChrgVbus bit.
As for ULPI spec. 1.1:
"3.8.7.1 Session Request Protocol (SRP)
ULPI provides full SRP support. The Link uses the ChrgVbus and DischrgVbus bits in the OTG Control register to begin and end a session."

Quoted 5 lines

So it is used for SRP.
May be it is better to implement
int (*start_srp)(struct otg_transceiver *otg);
method for setting this bit?

Quoted 5 lines

I was not sure on where to put this so I took the same approach as the fsl bsp which was to set it in this function and to call this function _after_ usb_add_hcd() [ see my previous patch ]. Indeed, it fixed my issue so I believe it not so bad given that there has already been some troubles on the ehci-mxc init.

Quoted 8 lines

Well, the problem is that this is supposed to be a generic driver and it should somehow follow the ULPI spec.
This patch makes it more like mxc specific.

As far as I understand, Session Request Protocol (SRP) allows a B-device (Peripheral) to nudge an A-device (Host) to turn on the USB's Vbus.
This patch enables SRP along with Vbus, which seems incorrect completely. ulpi_set_vbus() should set the Vbus (as its name says) and that's it.

so, if I add a srp hook as you're suggesting, which part of the driver should call it ?

Quoted 3 lines

Have you tried without this patch or have you just applied it along with other patches from the fsl bsp?

I already tried without this patch and without it, things are not working on my systems.

Quoted 4 lines

Also, if this specific patch (2/5) makes your USB (Host as I understand) work, it makes me think that there could be some problem with your Vbus supply. Have you checked that?

I don't have any schematics and I've access only to the source code of the kernel running on the efika nettop and smartbook [1]. I've not seen anything (even remotely) related to vbus supply except in the ulpi code and from what I've heard, it's unlikely that there's something to control it on theses systems. Of course, I'll be happy to be proven wrong. Without usb theses systems are useless so anything the can reduce the number of patches needed to get the systems working with mainline is welcome.

Arnaud

[1] http://gitorious.org/efikamx/linux-kernel/

#10 lore raw

PATCH 2/5 ulpi: handle ULPI_OTG_CTRL_CHRGVBUS

Quoted 57 lines · Arnaud Patard (Rtp)

Igor Grinberg <[email protected]> writes:
Hi,

Quoted 55 lines · Arnaud Patard (Rtp)
Quoted 45 lines
Quoted 39 lines · Igor Grinberg

Hi Arnaud,

Quoted 21 lines · Arnaud Patard (Rtp)

Current code doesn't handle setting CHRGVBUS when enabling vbus. Add support for it

Index: tst-usb/drivers/usb/otg/ulpi.c
===================================================================

drivers/usb/otg/ulpi.c +2 -1
@@ -234,7 +234,8 @@
 {
 	unsigned int flags = otg_io_read(otg, ULPI_OTG_CTRL);
 
-	flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT);
+	flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT |
+			ULPI_OTG_CTRL_CHRGVBUS);
 
 	if (on) {
 		if (otg->flags & ULPI_OTG_DRVVBUS)

drivers/usb/otg/ulpi.c line 251

Quoted 9 lines
drivers/usb/otg/ulpi.c +3 -0
@@ -242,6 +243,9 @@
 
 		if (otg->flags & ULPI_OTG_DRVVBUS_EXT)
 			flags |= ULPI_OTG_CTRL_DRVVBUS_EXT;
+
+		if (otg->flags & ULPI_OTG_CHRGVBUS)
+			flags |= ULPI_OTG_CTRL_CHRGVBUS;
 	}
 
 	return otg_io_write(otg, flags, ULPI_OTG_CTRL);

I think this is a wrong place to set the ChrgVbus bit.
As for ULPI spec. 1.1:
"3.8.7.1 Session Request Protocol (SRP)
ULPI provides full SRP support. The Link uses the ChrgVbus and DischrgVbus bits in the OTG Control register to begin and end a session."

Quoted 5 lines

So it is used for SRP.
May be it is better to implement
int (*start_srp)(struct otg_transceiver *otg);
method for setting this bit?

Quoted 5 lines

I was not sure on where to put this so I took the same approach as the fsl bsp which was to set it in this function and to call this function _after_ usb_add_hcd() [ see my previous patch ]. Indeed, it fixed my issue so I believe it not so bad given that there has already been some troubles on the ehci-mxc init.

Well, the problem is that this is supposed to be a generic driver and it should somehow follow the ULPI spec.
This patch makes it more like mxc specific.

Quoted 6 lines
Quoted 4 lines

As far as I understand, Session Request Protocol (SRP) allows a B-device (Peripheral) to nudge an A-device (Host) to turn on the USB's Vbus.
This patch enables SRP along with Vbus, which seems incorrect completely. ulpi_set_vbus() should set the Vbus (as its name says) and that's it.

so, if I add a srp hook as you're suggesting, which part of the driver should call it ?

It should be called from outside the ulpi driver by the OTG logic
(just like ulpi_set_vbus() is called).
But, again, SRP should be set by the B-device (peripheral) and Vbus by the A-device (Host). Usually, the A-device and B-device are on the opposite sides of the USB cable.

Quoted 7 lines
Quoted 2 lines

Have you tried without this patch or have you just applied it along with other patches from the fsl bsp?

I already tried without this patch and without it, things are not working on my systems.

Quoted 3 lines

Also, if this specific patch (2/5) makes your USB (Host as I understand) work, it makes me think that there could be some problem with your Vbus supply. Have you checked that?

Quoted 8 lines

I don't have any schematics and I've access only to the source code of the kernel running on the efika nettop and smartbook [1]. I've not seen anything (even remotely) related to vbus supply except in the ulpi code and from what I've heard, it's unlikely that there's something to control it on theses systems. Of course, I'll be happy to be proven wrong. Without usb theses systems are useless so anything the can reduce the number of patches needed to get the systems working with mainline is welcome.

Well, I was certain you are trying to use that port in Host mode (A-device), but now I'm confused...
You say "things are not working" - what are those things?
Can you, please, describe what are you trying to do?
What are you trying to connect to this USB port? What cable do you use? Also, what ulpi vendor/product id is reported in ulpi_init()?

Quoted 3 lines

Arnaud

[1] http://gitorious.org/efikamx/linux-kernel/

Signature · 2 lines
Regards,
Igor.
#11 lore raw

PATCH 2/5 ulpi: handle ULPI_OTG_CTRL_CHRGVBUS

Quoted 86 lines · Igor Grinberg
Quoted 57 lines · Arnaud Patard (Rtp)

Igor Grinberg <[email protected]> writes:
Hi,

Quoted 55 lines · Arnaud Patard (Rtp)
Quoted 45 lines
Quoted 39 lines · Igor Grinberg

Hi Arnaud,

Quoted 21 lines · Arnaud Patard (Rtp)

Current code doesn't handle setting CHRGVBUS when enabling vbus. Add support for it

Index: tst-usb/drivers/usb/otg/ulpi.c
===================================================================

drivers/usb/otg/ulpi.c +2 -1
@@ -234,7 +234,8 @@
 {
 	unsigned int flags = otg_io_read(otg, ULPI_OTG_CTRL);
 
-	flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT);
+	flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT |
+			ULPI_OTG_CTRL_CHRGVBUS);
 
 	if (on) {
 		if (otg->flags & ULPI_OTG_DRVVBUS)

drivers/usb/otg/ulpi.c line 251

Quoted 9 lines
drivers/usb/otg/ulpi.c +3 -0
@@ -242,6 +243,9 @@
 
 		if (otg->flags & ULPI_OTG_DRVVBUS_EXT)
 			flags |= ULPI_OTG_CTRL_DRVVBUS_EXT;
+
+		if (otg->flags & ULPI_OTG_CHRGVBUS)
+			flags |= ULPI_OTG_CTRL_CHRGVBUS;
 	}
 
 	return otg_io_write(otg, flags, ULPI_OTG_CTRL);

I think this is a wrong place to set the ChrgVbus bit.
As for ULPI spec. 1.1:
"3.8.7.1 Session Request Protocol (SRP)
ULPI provides full SRP support. The Link uses the ChrgVbus and DischrgVbus bits in the OTG Control register to begin and end a session."

Quoted 5 lines

So it is used for SRP.
May be it is better to implement
int (*start_srp)(struct otg_transceiver *otg);
method for setting this bit?

Quoted 5 lines

I was not sure on where to put this so I took the same approach as the fsl bsp which was to set it in this function and to call this function _after_ usb_add_hcd() [ see my previous patch ]. Indeed, it fixed my issue so I believe it not so bad given that there has already been some troubles on the ehci-mxc init.

Well, the problem is that this is supposed to be a generic driver and it should somehow follow the ULPI spec.
This patch makes it more like mxc specific.

Quoted 6 lines
Quoted 4 lines

As far as I understand, Session Request Protocol (SRP) allows a B-device (Peripheral) to nudge an A-device (Host) to turn on the USB's Vbus.
This patch enables SRP along with Vbus, which seems incorrect completely. ulpi_set_vbus() should set the Vbus (as its name says) and that's it.

so, if I add a srp hook as you're suggesting, which part of the driver should call it ?

It should be called from outside the ulpi driver by the OTG logic
(just like ulpi_set_vbus() is called).
But, again, SRP should be set by the B-device (peripheral) and Vbus by the A-device (Host). Usually, the A-device and B-device are on the opposite sides of the USB cable.

Quoted 7 lines
Quoted 2 lines

Have you tried without this patch or have you just applied it along with other patches from the fsl bsp?

I already tried without this patch and without it, things are not working on my systems.

Quoted 3 lines

Also, if this specific patch (2/5) makes your USB (Host as I understand) work, it makes me think that there could be some problem with your Vbus supply. Have you checked that?

Quoted 8 lines

I don't have any schematics and I've access only to the source code of the kernel running on the efika nettop and smartbook [1]. I've not seen anything (even remotely) related to vbus supply except in the ulpi code and from what I've heard, it's unlikely that there's something to control it on theses systems. Of course, I'll be happy to be proven wrong. Without usb theses systems are useless so anything the can reduce the number of patches needed to get the systems working with mainline is welcome.

Quoted 6 lines

Well, I was certain you are trying to use that port in Host mode (A-device), but now I'm confused...
You say "things are not working" - what are those things?
Can you, please, describe what are you trying to do?
What are you trying to connect to this USB port? What cable do you use?

I thought it was clear that "things" was everything connected on the usb ports. The problem is that this also means that the nettop/smartbook are kind of not working too as ethernet/wifi/bt/hid devs are all connected on usb [ they're all on the pcb ]. So, even if you boot on the mmc aka the only storage available which doesn't need usb, you won't be able to login.

Quoted 1 line

Also, what ulpi vendor/product id is reported in ulpi_init()?

ULPI transceiver vendor/product ID 0x0424/0x0006
Found SMSC USB3319 ULPI transceiver.

Arnaud

#12 lore raw

PATCH 2/5 ulpi: handle ULPI_OTG_CTRL_CHRGVBUS

Quoted 91 lines · Arnaud Patard (Rtp)
Quoted 84 lines · Igor Grinberg
Quoted 57 lines · Arnaud Patard (Rtp)

Igor Grinberg <[email protected]> writes:
Hi,

Quoted 55 lines · Arnaud Patard (Rtp)
Quoted 45 lines
Quoted 39 lines · Igor Grinberg

Hi Arnaud,

Quoted 21 lines · Arnaud Patard (Rtp)

Current code doesn't handle setting CHRGVBUS when enabling vbus. Add support for it

Index: tst-usb/drivers/usb/otg/ulpi.c
===================================================================

drivers/usb/otg/ulpi.c +2 -1
@@ -234,7 +234,8 @@
 {
 	unsigned int flags = otg_io_read(otg, ULPI_OTG_CTRL);
 
-	flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT);
+	flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT |
+			ULPI_OTG_CTRL_CHRGVBUS);
 
 	if (on) {
 		if (otg->flags & ULPI_OTG_DRVVBUS)

drivers/usb/otg/ulpi.c line 251

Quoted 9 lines
drivers/usb/otg/ulpi.c +3 -0
@@ -242,6 +243,9 @@
 
 		if (otg->flags & ULPI_OTG_DRVVBUS_EXT)
 			flags |= ULPI_OTG_CTRL_DRVVBUS_EXT;
+
+		if (otg->flags & ULPI_OTG_CHRGVBUS)
+			flags |= ULPI_OTG_CTRL_CHRGVBUS;
 	}
 
 	return otg_io_write(otg, flags, ULPI_OTG_CTRL);

I think this is a wrong place to set the ChrgVbus bit.
As for ULPI spec. 1.1:
"3.8.7.1 Session Request Protocol (SRP)
ULPI provides full SRP support. The Link uses the ChrgVbus and DischrgVbus bits in the OTG Control register to begin and end a session."

Quoted 5 lines

So it is used for SRP.
May be it is better to implement
int (*start_srp)(struct otg_transceiver *otg);
method for setting this bit?

Quoted 5 lines

I was not sure on where to put this so I took the same approach as the fsl bsp which was to set it in this function and to call this function _after_ usb_add_hcd() [ see my previous patch ]. Indeed, it fixed my issue so I believe it not so bad given that there has already been some troubles on the ehci-mxc init.

Well, the problem is that this is supposed to be a generic driver and it should somehow follow the ULPI spec.
This patch makes it more like mxc specific.

Quoted 6 lines
Quoted 4 lines

As far as I understand, Session Request Protocol (SRP) allows a B-device (Peripheral) to nudge an A-device (Host) to turn on the USB's Vbus.
This patch enables SRP along with Vbus, which seems incorrect completely. ulpi_set_vbus() should set the Vbus (as its name says) and that's it.

so, if I add a srp hook as you're suggesting, which part of the driver should call it ?

It should be called from outside the ulpi driver by the OTG logic
(just like ulpi_set_vbus() is called).
But, again, SRP should be set by the B-device (peripheral) and Vbus by the A-device (Host). Usually, the A-device and B-device are on the opposite sides of the USB cable.

Quoted 7 lines
Quoted 2 lines

Have you tried without this patch or have you just applied it along with other patches from the fsl bsp?

I already tried without this patch and without it, things are not working on my systems.

Quoted 3 lines

Also, if this specific patch (2/5) makes your USB (Host as I understand) work, it makes me think that there could be some problem with your Vbus supply. Have you checked that?

Quoted 8 lines

I don't have any schematics and I've access only to the source code of the kernel running on the efika nettop and smartbook [1]. I've not seen anything (even remotely) related to vbus supply except in the ulpi code and from what I've heard, it's unlikely that there's something to control it on theses systems. Of course, I'll be happy to be proven wrong. Without usb theses systems are useless so anything the can reduce the number of patches needed to get the systems working with mainline is welcome.

Quoted 6 lines

Well, I was certain you are trying to use that port in Host mode (A-device), but now I'm confused...
You say "things are not working" - what are those things?
Can you, please, describe what are you trying to do?
What are you trying to connect to this USB port? What cable do you use?

Quoted 7 lines

I thought it was clear that "things" was everything connected on the usb ports. The problem is that this also means that the nettop/smartbook are kind of not working too as ethernet/wifi/bt/hid devs are all connected on usb [ they're all on the pcb ]. So, even if you boot on the mmc aka the only storage available which doesn't need usb, you won't be able to login.

Well, "everything connected on the usb ports" can be confusing, because you can connect devices (usb disk drives, keyboards, mice, etc..) and hosts (desktop PCs, mobile computers, etc..) to the OTG port.
That's why I wanted to be sure, what devices do you connect to that port. Now it is clear, that your port should be in the Host mode and you should _not_ issue an SRP.

"ethernet/wifi/bt/hid devs are all connected on usb" - this means,
that they are either connected to several (different) usb ports or there is a usb hub connected to that port and those devices are connected to it.
Can you confirm how those devices are connected?

Quoted 3 lines
Quoted 1 line

Also, what ulpi vendor/product id is reported in ulpi_init()?

ULPI transceiver vendor/product ID 0x0424/0x0006
Found SMSC USB3319 ULPI transceiver.

SMSC USB3319 does not have either an integrated Vbus switch or Charge Pump, For the device connected to that transceiver could work properly, there is a need in _external Vbus switch_ , that should be enabled using some kind of CPEN pin (can be GPIO).
This means, that you don't even need to call ulpi_set_vbus().

Either way, this patch is NAK.
I think you need to check your hardware (in particular Vbus supply).

Signature · 2 lines
Regards,
Igor.
#13 lore raw

PATCH 2/5 ulpi: handle ULPI_OTG_CTRL_CHRGVBUS

Igor Grinberg <[email protected]> writes:

Adding Matt Sealey in CC:. he's the product development analyst so he knows the hardware (unlike me).

Quoted 124 lines · Arnaud Patard (Rtp)
Quoted 91 lines
Quoted 84 lines · Igor Grinberg
Quoted 57 lines · Arnaud Patard (Rtp)

Igor Grinberg <[email protected]> writes:
Hi,

Quoted 55 lines · Arnaud Patard (Rtp)
Quoted 45 lines
Quoted 39 lines · Igor Grinberg

Hi Arnaud,

Quoted 21 lines · Arnaud Patard (Rtp)

Current code doesn't handle setting CHRGVBUS when enabling vbus. Add support for it

Index: tst-usb/drivers/usb/otg/ulpi.c
===================================================================

drivers/usb/otg/ulpi.c +2 -1
@@ -234,7 +234,8 @@
 {
 	unsigned int flags = otg_io_read(otg, ULPI_OTG_CTRL);
 
-	flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT);
+	flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT |
+			ULPI_OTG_CTRL_CHRGVBUS);
 
 	if (on) {
 		if (otg->flags & ULPI_OTG_DRVVBUS)

drivers/usb/otg/ulpi.c line 251

Quoted 9 lines
drivers/usb/otg/ulpi.c +3 -0
@@ -242,6 +243,9 @@
 
 		if (otg->flags & ULPI_OTG_DRVVBUS_EXT)
 			flags |= ULPI_OTG_CTRL_DRVVBUS_EXT;
+
+		if (otg->flags & ULPI_OTG_CHRGVBUS)
+			flags |= ULPI_OTG_CTRL_CHRGVBUS;
 	}
 
 	return otg_io_write(otg, flags, ULPI_OTG_CTRL);

I think this is a wrong place to set the ChrgVbus bit.
As for ULPI spec. 1.1:
"3.8.7.1 Session Request Protocol (SRP)
ULPI provides full SRP support. The Link uses the ChrgVbus and DischrgVbus bits in the OTG Control register to begin and end a session."

Quoted 5 lines

So it is used for SRP.
May be it is better to implement
int (*start_srp)(struct otg_transceiver *otg);
method for setting this bit?

Quoted 5 lines

I was not sure on where to put this so I took the same approach as the fsl bsp which was to set it in this function and to call this function _after_ usb_add_hcd() [ see my previous patch ]. Indeed, it fixed my issue so I believe it not so bad given that there has already been some troubles on the ehci-mxc init.

Well, the problem is that this is supposed to be a generic driver and it should somehow follow the ULPI spec.
This patch makes it more like mxc specific.

Quoted 6 lines
Quoted 4 lines

As far as I understand, Session Request Protocol (SRP) allows a B-device (Peripheral) to nudge an A-device (Host) to turn on the USB's Vbus.
This patch enables SRP along with Vbus, which seems incorrect completely. ulpi_set_vbus() should set the Vbus (as its name says) and that's it.

so, if I add a srp hook as you're suggesting, which part of the driver should call it ?

It should be called from outside the ulpi driver by the OTG logic
(just like ulpi_set_vbus() is called).
But, again, SRP should be set by the B-device (peripheral) and Vbus by the A-device (Host). Usually, the A-device and B-device are on the opposite sides of the USB cable.

Quoted 7 lines
Quoted 2 lines

Have you tried without this patch or have you just applied it along with other patches from the fsl bsp?

I already tried without this patch and without it, things are not working on my systems.

Quoted 3 lines

Also, if this specific patch (2/5) makes your USB (Host as I understand) work, it makes me think that there could be some problem with your Vbus supply. Have you checked that?

Quoted 8 lines

I don't have any schematics and I've access only to the source code of the kernel running on the efika nettop and smartbook [1]. I've not seen anything (even remotely) related to vbus supply except in the ulpi code and from what I've heard, it's unlikely that there's something to control it on theses systems. Of course, I'll be happy to be proven wrong. Without usb theses systems are useless so anything the can reduce the number of patches needed to get the systems working with mainline is welcome.

Quoted 6 lines

Well, I was certain you are trying to use that port in Host mode (A-device), but now I'm confused...
You say "things are not working" - what are those things?
Can you, please, describe what are you trying to do?
What are you trying to connect to this USB port? What cable do you use?

Quoted 7 lines

I thought it was clear that "things" was everything connected on the usb ports. The problem is that this also means that the nettop/smartbook are kind of not working too as ethernet/wifi/bt/hid devs are all connected on usb [ they're all on the pcb ]. So, even if you boot on the mmc aka the only storage available which doesn't need usb, you won't be able to login.

Well, "everything connected on the usb ports" can be confusing, because you can connect devices (usb disk drives, keyboards, mice, etc..) and hosts (desktop PCs, mobile computers, etc..) to the OTG port.
That's why I wanted to be sure, what devices do you connect to that port. Now it is clear, that your port should be in the Host mode and you should _not_ issue an SRP.

"ethernet/wifi/bt/hid devs are all connected on usb" - this means,
that they are either connected to several (different) usb ports or there is a usb hub connected to that port and those devices are connected to it.
Can you confirm how those devices are connected?

Quoted 3 lines
Quoted 1 line

Also, what ulpi vendor/product id is reported in ulpi_init()?

ULPI transceiver vendor/product ID 0x0424/0x0006
Found SMSC USB3319 ULPI transceiver.

SMSC USB3319 does not have either an integrated Vbus switch or Charge Pump, For the device connected to that transceiver could work properly, there is a need in _external Vbus switch_ , that should be enabled using some kind of CPEN pin (can be GPIO).
This means, that you don't even need to call ulpi_set_vbus().

Either way, this patch is NAK.
I think you need to check your hardware (in particular Vbus supply).

#14 lore raw

PATCH 2/5 ulpi: handle ULPI_OTG_CTRL_CHRGVBUS

Quoted 18 lines · Arnaud Patard

Igor Grinberg <[email protected]> writes:

Adding Matt Sealey in CC:. he's the product development analyst so he knows the hardware (unlike me).

Quoted 12 lines
Quoted 3 lines
Quoted 1 line

Also, what ulpi vendor/product id is reported in ulpi_init()?

ULPI transceiver vendor/product ID 0x0424/0x0006
Found SMSC USB3319 ULPI transceiver.

SMSC USB3319 does not have either an integrated Vbus switch or Charge Pump, For the device connected to that transceiver could work properly, there is a need in _external Vbus switch_ , that should be enabled using some kind of CPEN pin (can be GPIO).
This means, that you don't even need to call ulpi_set_vbus().

Either way, this patch is NAK.
I think you need to check your hardware (in particular Vbus supply).

Hey guys,

On the Smartbook at least both USB host ports (H1 and H2) on the board (one port each) are connected directly to 4-port USB hubs (SMSC2514). We don't have anything on there except that connection: the hub should handle VBUS properly. Both ports use an SMSC3317 (just a 3311 with a built in 3.3V supply so the id and behavior should be identical).

On the Smarttop H1 is connected to a 4-port USB hub (Terminus FE1.1) with the same configuration. Same PHY. The DR port is connected directly to an ASIX ethernet controller. VBUS seems routed to a test point.

I'm curious exactly what the real problem here is: that VBUS is basically not being handled correctly? It should be driven or not? I'm not entirely familiar with the specification.

Signature · 2 lines
Matt Sealey <[email protected]>
Product Development Analyst, Genesi USA, Inc.
#15 lore raw

PATCH 2/5 ulpi: handle ULPI_OTG_CTRL_CHRGVBUS

Quoted 14 lines · Matt Sealey
Quoted 13 lines · Arnaud Patard

Igor Grinberg <[email protected]> writes:

Adding Matt Sealey in CC:. he's the product development analyst so he knows the hardware (unlike me).

Quoted 9 lines
Quoted 3 lines
Quoted 1 line

Also, what ulpi vendor/product id is reported in ulpi_init()?

ULPI transceiver vendor/product ID 0x0424/0x0006
Found SMSC USB3319 ULPI transceiver.

SMSC USB3319 does not have either an integrated Vbus switch or Charge Pump, For the device connected to that transceiver could work properly, there is a need in _external Vbus switch_ , that should be enabled using some kind of CPEN pin (can be GPIO).
This means, that you don't even need to call ulpi_set_vbus().

Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

Either way, this patch is NAK.
I think you need to check your hardware (in particular Vbus supply).

Hey guys,

Hi

Thanks for the information. Now I am finally getting the picture of what's is going on there...

Quoted 5 lines

On the Smartbook at least both USB host ports (H1 and H2) on the board (one port each) are connected directly to 4-port USB hubs (SMSC2514). We don't have anything on there except that connection: the hub should handle VBUS properly. Both ports use an SMSC3317 (just a 3311 with a built in 3.3V supply so the id and behavior should be identical).

OK, so the SMSC331x ulpi transceiver is connected to the SMSC2514 usb hub, so all the peripheral devices (ethernet/wifi/bt/hid) are connected to the downstream ports of that hub and thus get their Vbus as expected. This is fine.

Quoted 8 lines

On the Smarttop H1 is connected to a 4-port USB hub (Terminus FE1.1) with the same configuration. Same PHY. The DR port is connected directly to an ASIX ethernet controller. VBUS seems routed to a test point.

I'm curious exactly what the real problem here is: that VBUS is basically not being handled correctly? It should be driven or not? I'm not entirely familiar with the specification.

SMSC2514 usb hub will not provide power to its D+ and D- pull-up resistors until it detects a Vbus enabled on the upstream port. This is totally fine.

SMSC331x ulpi transceiver does not have either an integrated Vbus switch or an integrated charge pump - this means that it cannot provide a Vbus to the hub.

The hub in its turn does not power the pull-up resistors and peripheral devices are not being connected to the usb subsystem.

With this patch applied, SMSC331x ulpi transceiver issues an SRP pulses on the Vbus and hub senses that there is something that looks like Vbus and then enables the pull-up resistors -> peripheral devices are being connected to the usb subsystem. This behavior violates the ULPI (and mostly certain OTG and may be also USB 2.0) specification and SMSC2514 usb hub datasheet.

According to the SMSC2514 usb hub datasheet, VBUS_DET pin has to be connected to a valid Vbus from the upstream port, but SMSC331x does not provide this Vbus. This means that you should have add a Vbus switch or a charge pump to the VBUS_DET pin of the usb hub and provide means (like GPIO) to enable/disable that switch or charge pump.
This is h/w design bug we are dealing with.

The best solution to this would be to add a missing h/w component. Now, I understand that it can be kind a problematic ;)
But, we cannot violate the ULPI spec and the generic driver to workaround some h/w problem that is existing in some specific configuration and hopefully will be fixed in the next h/w revisions. Therefore, as I said before, this patch is NAK.

What we can do is:
1) implement the int (*start_srp)(struct otg_transceiver *otg); method as defined by the ULPI spec.

2) and then add a call (along with huge comment explaining this workaround) to otg_start_srp(). I'd recommend to restrict this call to that specific board somehow, but it is up to Sascha to decide where to put it.

Signature · 2 lines
Regards,
Igor.
#16 lore raw

PATCH 2/5 ulpi: handle ULPI_OTG_CTRL_CHRGVBUS

Hi

Igor Grinberg <[email protected]> writes:
[...]

Quoted 50 lines

Thanks for the information. Now I am finally getting the picture of what's is going on there...

Quoted 5 lines

On the Smartbook at least both USB host ports (H1 and H2) on the board (one port each) are connected directly to 4-port USB hubs (SMSC2514). We don't have anything on there except that connection: the hub should handle VBUS properly. Both ports use an SMSC3317 (just a 3311 with a built in 3.3V supply so the id and behavior should be identical).

OK, so the SMSC331x ulpi transceiver is connected to the SMSC2514 usb hub, so all the peripheral devices (ethernet/wifi/bt/hid) are connected to the downstream ports of that hub and thus get their Vbus as expected. This is fine.

Quoted 8 lines

On the Smarttop H1 is connected to a 4-port USB hub (Terminus FE1.1) with the same configuration. Same PHY. The DR port is connected directly to an ASIX ethernet controller. VBUS seems routed to a test point.

I'm curious exactly what the real problem here is: that VBUS is basically not being handled correctly? It should be driven or not? I'm not entirely familiar with the specification.

SMSC2514 usb hub will not provide power to its D+ and D- pull-up resistors until it detects a Vbus enabled on the upstream port. This is totally fine.

SMSC331x ulpi transceiver does not have either an integrated Vbus switch or an integrated charge pump - this means that it cannot provide a Vbus to the hub.

The hub in its turn does not power the pull-up resistors and peripheral devices are not being connected to the usb subsystem.

With this patch applied, SMSC331x ulpi transceiver issues an SRP pulses on the Vbus and hub senses that there is something that looks like Vbus and then enables the pull-up resistors -> peripheral devices are being connected to the usb subsystem. This behavior violates the ULPI (and mostly certain OTG and may be also USB 2.0) specification and SMSC2514 usb hub datasheet.

According to the SMSC2514 usb hub datasheet, VBUS_DET pin has to be connected to a valid Vbus from the upstream port, but SMSC331x does not provide this Vbus. This means that you should have add a Vbus switch or a charge pump to the VBUS_DET pin of the usb hub and provide means (like GPIO) to enable/disable that switch or charge pump.
This is h/w design bug we are dealing with.

The best solution to this would be to add a missing h/w component. Now, I understand that it can be kind a problematic ;)
But, we cannot violate the ULPI spec and the generic driver to workaround some h/w problem that is existing in some specific configuration and hopefully will be fixed in the next h/w revisions. Therefore, as I said before, this patch is NAK.

Quoted 7 lines

What we can do is:
1) implement the int (*start_srp)(struct otg_transceiver *otg); method as defined by the ULPI spec.

2) and then add a call (along with huge comment explaining this workaround) to otg_start_srp(). I'd recommend to restrict this call to that specific board somehow, but it is up to Sascha to decide where to put it.

What about the following patch ?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ulpi_chrgvbus2.patch
Type: text/x-diff
Size: 1867 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110107/dad4f389/attachment-0001.bin>

#17 lore raw

PATCH 2/5 ulpi: handle ULPI_OTG_CTRL_CHRGVBUS

Hi Arnaud,

Can you, please, send patches inline and not as attachments next time? It is very inconvenient to review and comment on attached patches. Comments below.

Quoted 73 lines · Arnaud Patard (Rtp)

Hi

Igor Grinberg <[email protected]> writes:
[...]

Quoted 48 lines

Thanks for the information. Now I am finally getting the picture of what's is going on there...

Quoted 5 lines

On the Smartbook at least both USB host ports (H1 and H2) on the board (one port each) are connected directly to 4-port USB hubs (SMSC2514). We don't have anything on there except that connection: the hub should handle VBUS properly. Both ports use an SMSC3317 (just a 3311 with a built in 3.3V supply so the id and behavior should be identical).

OK, so the SMSC331x ulpi transceiver is connected to the SMSC2514 usb hub, so all the peripheral devices (ethernet/wifi/bt/hid) are connected to the downstream ports of that hub and thus get their Vbus as expected. This is fine.

Quoted 8 lines

On the Smarttop H1 is connected to a 4-port USB hub (Terminus FE1.1) with the same configuration. Same PHY. The DR port is connected directly to an ASIX ethernet controller. VBUS seems routed to a test point.

I'm curious exactly what the real problem here is: that VBUS is basically not being handled correctly? It should be driven or not? I'm not entirely familiar with the specification.

SMSC2514 usb hub will not provide power to its D+ and D- pull-up resistors until it detects a Vbus enabled on the upstream port. This is totally fine.

SMSC331x ulpi transceiver does not have either an integrated Vbus switch or an integrated charge pump - this means that it cannot provide a Vbus to the hub.

The hub in its turn does not power the pull-up resistors and peripheral devices are not being connected to the usb subsystem.

With this patch applied, SMSC331x ulpi transceiver issues an SRP pulses on the Vbus and hub senses that there is something that looks like Vbus and then enables the pull-up resistors -> peripheral devices are being connected to the usb subsystem. This behavior violates the ULPI (and mostly certain OTG and may be also USB 2.0) specification and SMSC2514 usb hub datasheet.

According to the SMSC2514 usb hub datasheet, VBUS_DET pin has to be connected to a valid Vbus from the upstream port, but SMSC331x does not provide this Vbus. This means that you should have add a Vbus switch or a charge pump to the VBUS_DET pin of the usb hub and provide means (like GPIO) to enable/disable that switch or charge pump.
This is h/w design bug we are dealing with.

The best solution to this would be to add a missing h/w component. Now, I understand that it can be kind a problematic ;)
But, we cannot violate the ULPI spec and the generic driver to workaround some h/w problem that is existing in some specific configuration and hopefully will be fixed in the next h/w revisions. Therefore, as I said before, this patch is NAK.

Quoted 7 lines

What we can do is:
1) implement the int (*start_srp)(struct otg_transceiver *otg); method as defined by the ULPI spec.

2) and then add a call (along with huge comment explaining this workaround) to otg_start_srp(). I'd recommend to restrict this call to that specific board somehow, but it is up to Sascha to decide where to put it.

What about the following patch ?
ulpi: provide start_srp

Add support for setting CHRGVBUS thanks to start_srp and use it
to workaround a hardware bug on efika mx/sb boards.
See http://lists.infradead.org/pipermail/linux-arm-kernel/2011-January/037341.html

Index: linux-2.6-submit/drivers/usb/otg/ulpi.c
===================================================================

drivers/usb/otg/ulpi.c +0 -0
@@ -247,6 +247,14 @@
 	return otg_io_write(otg, flags, ULPI_OTG_CTRL);

drivers/usb/otg/ulpi.c line 257

Quoted 10 lines
drivers/usb/otg/ulpi.c +8 -0
 }
 
+static int ulpi_start_srp(struct otg_transceiver *otg, bool on)
+{
+	unsigned int flags = otg_io_read(otg, ULPI_OTG_CTRL);
+
+	flags |= ULPI_OTG_CTRL_CHRGVBUS;
+	return otg_io_write(otg, flags, ULPI_OTG_CTRL);
+}
+

I went through the OTG spec. and found that there are much more things should be done for the start_srp() function to be implemented properly. For example, it says that we should make sure that the Vbus is discharged (means, the previous session has finished) before attempting to start a new session, but that is only a half of the problem. The real problem for you, is that the duration of the SRP should be no more then 100ms.
This means that my proposal under 1) is not good for you, sorry...

Quoted 25 lines
drivers/usb/otg/ulpi.c +1 -0
 struct otg_transceiver *
 otg_ulpi_create(struct otg_io_access_ops *ops,
 		unsigned int flags)
@@ -263,6 +271,7 @@
 	otg->init	= ulpi_init;
 	otg->set_host	= ulpi_set_host;
 	otg->set_vbus	= ulpi_set_vbus;
+	otg->start_srp	= ulpi_start_srp;
 
 	return otg;
 }

Index: linux-2.6-submit/drivers/usb/host/ehci-mxc.c
===================================================================

drivers/usb/host/ehci-mxc.c +2 -0
@@ -25,6 +25,8 @@
 
 #include <mach/mxc_ehci.h>
 
+#include <asm/mach-types.h>
+
 #define ULPI_VIEWPORT_OFFSET	0x170
 
 struct ehci_mxc_priv {

drivers/usb/host/ehci-mxc.c line 250

Quoted 10 lines
drivers/usb/host/ehci-mxc.c +7 -0
@@ -239,6 +241,13 @@
 			dev_err(dev, "unable to enable vbus on transceiver\n");
 			goto err_add;
 		}
+		if (machine_is_mx51_efikamx() || machine_is_mx51_efikasb()) {
+			ret = otg_start_srp(pdata->otg);
+			if (ret) {
+				dev_err(dev, "unable to start srp\n");
+				goto err_add;
+			}
+		}

In light of the problem described above, here you will need to write directly to the view port instead of calling the otg_start_srp() function.

I'd recommend to move this to the machine (board) specific code. May be to platform init (pdata->init) call back?

IMHO, the explanation of the h/w bug workaround in the commit message is not enough - in-code comment regarding the bug workaround should be added.

Signature · 2 lines
Regards,
Igor.
#18 lore raw

PATCH 2/5 ulpi: handle ULPI_OTG_CTRL_CHRGVBUS

Quoted 1 line · Igor Grinberg

Hi Arnaud,

Hi,

Quoted 4 lines

Can you, please, send patches inline and not as attachments next time? It is very inconvenient to review and comment on attached patches.

This patch a quick rewrite&test. It was more meant to understand if the direction was right rather than a formal submission. (I use quilt to send patches and not my mailer). There are some comment in the code needed and I've not put them.

Quoted 78 lines

Comments below.

Quoted 75 lines · Arnaud Patard (Rtp)

Hi

Igor Grinberg <[email protected]> writes:
[...]

Quoted 48 lines

Thanks for the information. Now I am finally getting the picture of what's is going on there...

Quoted 5 lines

On the Smartbook at least both USB host ports (H1 and H2) on the board (one port each) are connected directly to 4-port USB hubs (SMSC2514). We don't have anything on there except that connection: the hub should handle VBUS properly. Both ports use an SMSC3317 (just a 3311 with a built in 3.3V supply so the id and behavior should be identical).

OK, so the SMSC331x ulpi transceiver is connected to the SMSC2514 usb hub, so all the peripheral devices (ethernet/wifi/bt/hid) are connected to the downstream ports of that hub and thus get their Vbus as expected. This is fine.

Quoted 8 lines

On the Smarttop H1 is connected to a 4-port USB hub (Terminus FE1.1) with the same configuration. Same PHY. The DR port is connected directly to an ASIX ethernet controller. VBUS seems routed to a test point.

I'm curious exactly what the real problem here is: that VBUS is basically not being handled correctly? It should be driven or not? I'm not entirely familiar with the specification.

SMSC2514 usb hub will not provide power to its D+ and D- pull-up resistors until it detects a Vbus enabled on the upstream port. This is totally fine.

SMSC331x ulpi transceiver does not have either an integrated Vbus switch or an integrated charge pump - this means that it cannot provide a Vbus to the hub.

The hub in its turn does not power the pull-up resistors and peripheral devices are not being connected to the usb subsystem.

With this patch applied, SMSC331x ulpi transceiver issues an SRP pulses on the Vbus and hub senses that there is something that looks like Vbus and then enables the pull-up resistors -> peripheral devices are being connected to the usb subsystem. This behavior violates the ULPI (and mostly certain OTG and may be also USB 2.0) specification and SMSC2514 usb hub datasheet.

According to the SMSC2514 usb hub datasheet, VBUS_DET pin has to be connected to a valid Vbus from the upstream port, but SMSC331x does not provide this Vbus. This means that you should have add a Vbus switch or a charge pump to the VBUS_DET pin of the usb hub and provide means (like GPIO) to enable/disable that switch or charge pump.
This is h/w design bug we are dealing with.

The best solution to this would be to add a missing h/w component. Now, I understand that it can be kind a problematic ;)
But, we cannot violate the ULPI spec and the generic driver to workaround some h/w problem that is existing in some specific configuration and hopefully will be fixed in the next h/w revisions. Therefore, as I said before, this patch is NAK.

Quoted 7 lines

What we can do is:
1) implement the int (*start_srp)(struct otg_transceiver *otg); method as defined by the ULPI spec.

2) and then add a call (along with huge comment explaining this workaround) to otg_start_srp(). I'd recommend to restrict this call to that specific board somehow, but it is up to Sascha to decide where to put it.

What about the following patch ?
ulpi: provide start_srp

Add support for setting CHRGVBUS thanks to start_srp and use it
to workaround a hardware bug on efika mx/sb boards.
See http://lists.infradead.org/pipermail/linux-arm-kernel/2011-January/037341.html

Index: linux-2.6-submit/drivers/usb/otg/ulpi.c
===================================================================

drivers/usb/otg/ulpi.c +0 -0
@@ -247,6 +247,14 @@
 	return otg_io_write(otg, flags, ULPI_OTG_CTRL);
 }
 
Quoted 15 lines

drivers/usb/otg/ulpi.c line 257

Quoted 8 lines
drivers/usb/otg/ulpi.c +8 -0
+static int ulpi_start_srp(struct otg_transceiver *otg, bool on)
+{
+	unsigned int flags = otg_io_read(otg, ULPI_OTG_CTRL);
+
+	flags |= ULPI_OTG_CTRL_CHRGVBUS;
+	return otg_io_write(otg, flags, ULPI_OTG_CTRL);
+}
+

I went through the OTG spec. and found that there are much more things should be done for the start_srp() function to be implemented properly. For example, it says that we should make sure that the Vbus is discharged (means, the previous session has finished) before attempting to start a new session, but that is only a half of the problem. The real problem for you, is that the duration of the SRP should be no more then 100ms.

oops. That's really annoying. (fwiw, I think that original code from fsl doesn't take care of that 100ms delay otherwise I guess I would have detected it too).

Quoted 25 lines

This means that my proposal under 1) is not good for you, sorry...

Quoted 23 lines
drivers/usb/otg/ulpi.c +1 -0
 struct otg_transceiver *
 otg_ulpi_create(struct otg_io_access_ops *ops,
 		unsigned int flags)
@@ -263,6 +271,7 @@
 	otg->init	= ulpi_init;
 	otg->set_host	= ulpi_set_host;
 	otg->set_vbus	= ulpi_set_vbus;
+	otg->start_srp	= ulpi_start_srp;
 
 	return otg;
 }

Index: linux-2.6-submit/drivers/usb/host/ehci-mxc.c
===================================================================

drivers/usb/host/ehci-mxc.c +2 -0
@@ -25,6 +25,8 @@
 
 #include <mach/mxc_ehci.h>
 
+#include <asm/mach-types.h>
+
 #define ULPI_VIEWPORT_OFFSET	0x170
 
Quoted 15 lines

drivers/usb/host/ehci-mxc.c line 250

Quoted 12 lines
drivers/usb/host/ehci-mxc.c +7 -0
 struct ehci_mxc_priv {
@@ -239,6 +241,13 @@
 			dev_err(dev, "unable to enable vbus on transceiver\n");
 			goto err_add;
 		}
+		if (machine_is_mx51_efikamx() || machine_is_mx51_efikasb()) {
+			ret = otg_start_srp(pdata->otg);
+			if (ret) {
+				dev_err(dev, "unable to start srp\n");
+				goto err_add;
+			}
+		}

In light of the problem described above, here you will need to write directly to the view port instead of calling the otg_start_srp() function.

ok. I don't think it's a problem. Looks otg_io_(read|write) are available here.

Quoted 3 lines

I'd recommend to move this to the machine (board) specific code. May be to platform init (pdata->init) call back?

oh, no. I've put this call in this place for some good reasons. This trick is working only if it's done _after_ add_hcd. Any other place won't work. For instance, pdata->init is meant to be called before mxc_initialise_usb_hw iirc which is _before_ add_hcd.

Quoted 3 lines

IMHO, the explanation of the h/w bug workaround in the commit message is not enough - in-code comment regarding the bug workaround should be added.

I know. As I said this patch was not the final submission. It was probably not clear enough.

Arnaud

#19 lore raw

PATCH 2/5 ulpi: handle ULPI_OTG_CTRL_CHRGVBUS

Quoted 7 lines · Arnaud Patard (Rtp)
Quoted 2 lines · Igor Grinberg

Can you, please, send patches inline and not as attachments next time? It is very inconvenient to review and comment on attached patches.

This patch a quick rewrite&test. It was more meant to understand if the direction was right rather than a formal submission. (I use quilt to send patches and not my mailer). There are some comment in the code needed and I've not put them.

Well, I also have got all other patches in the series as attachments... Why not use git send-email?

Quoted 71 lines
Quoted 17 lines · Arnaud Patard (Rtp)
Quoted 16 lines

What about the following patch ?
ulpi: provide start_srp

Add support for setting CHRGVBUS thanks to start_srp and use it
to workaround a hardware bug on efika mx/sb boards.
See http://lists.infradead.org/pipermail/linux-arm-kernel/2011-January/037341.html

Index: linux-2.6-submit/drivers/usb/otg/ulpi.c
===================================================================

drivers/usb/otg/ulpi.c +0 -0
@@ -247,6 +247,14 @@
 	return otg_io_write(otg, flags, ULPI_OTG_CTRL);
 }
 
Quoted 14 lines

drivers/usb/otg/ulpi.c line 257

Quoted 8 lines
drivers/usb/otg/ulpi.c +8 -0
+static int ulpi_start_srp(struct otg_transceiver *otg, bool on)
+{
+	unsigned int flags = otg_io_read(otg, ULPI_OTG_CTRL);
+
+	flags |= ULPI_OTG_CTRL_CHRGVBUS;
+	return otg_io_write(otg, flags, ULPI_OTG_CTRL);
+}
+

I went through the OTG spec. and found that there are much more things should be done for the start_srp() function to be implemented properly. For example, it says that we should make sure that the Vbus is discharged (means, the previous session has finished) before attempting to start a new session, but that is only a half of the problem. The real problem for you, is that the duration of the SRP should be no more then 100ms.

oops. That's really annoying. (fwiw, I think that original code from fsl doesn't take care of that 100ms delay otherwise I guess I would have detected it too).

Quoted 23 lines
Quoted 23 lines
drivers/usb/otg/ulpi.c +1 -0
 struct otg_transceiver *
 otg_ulpi_create(struct otg_io_access_ops *ops,
 		unsigned int flags)
@@ -263,6 +271,7 @@
 	otg->init	= ulpi_init;
 	otg->set_host	= ulpi_set_host;
 	otg->set_vbus	= ulpi_set_vbus;
+	otg->start_srp	= ulpi_start_srp;
 
 	return otg;
 }

Index: linux-2.6-submit/drivers/usb/host/ehci-mxc.c
===================================================================

drivers/usb/host/ehci-mxc.c +2 -0
@@ -25,6 +25,8 @@
 
 #include <mach/mxc_ehci.h>
 
+#include <asm/mach-types.h>
+
 #define ULPI_VIEWPORT_OFFSET	0x170
 
Quoted 14 lines

drivers/usb/host/ehci-mxc.c line 250

Quoted 12 lines
drivers/usb/host/ehci-mxc.c +7 -0
 struct ehci_mxc_priv {
@@ -239,6 +241,13 @@
 			dev_err(dev, "unable to enable vbus on transceiver\n");
 			goto err_add;
 		}
+		if (machine_is_mx51_efikamx() || machine_is_mx51_efikasb()) {
+			ret = otg_start_srp(pdata->otg);
+			if (ret) {
+				dev_err(dev, "unable to start srp\n");
+				goto err_add;
+			}
+		}

In light of the problem described above, here you will need to write directly to the view port instead of calling the otg_start_srp() function.

Quoted 2 lines

ok. I don't think it's a problem. Looks otg_io_(read|write) are available here.

yeah, otg_io_(read|write) should do.

Quoted 6 lines
Quoted 2 lines

I'd recommend to move this to the machine (board) specific code. May be to platform init (pdata->init) call back?

oh, no. I've put this call in this place for some good reasons. This trick is working only if it's done _after_ add_hcd. Any other place won't work. For instance, pdata->init is meant to be called before mxc_initialise_usb_hw iirc which is _before_ add_hcd.

I see. The reason, I'd like to move it to the board code is a possibility that h/w will change (hopefully even fixed) and then you will not have to violate the spec anymore, but to deal with the h/w revision checking. ehci-mxc.c doesn't look like a good place to deal with h/w revision checking of the board, so may be it is worth to introduce some kind of another platform hook, like pdata->late_init?

I don't insist, it is up to you and Sascha to decide what's the best choice here.

Quoted 6 lines
Quoted 2 lines

IMHO, the explanation of the h/w bug workaround in the commit message is not enough - in-code comment regarding the bug workaround should be added.

I know. As I said this patch was not the final submission. It was probably not clear enough.

Arnaud

Signature · 2 lines
Regards,
Igor.