Skip to contentSkip to conversation

usb: ehci-mx6: Fix bus enumeration for DM case

PATCH New Marek Vasut 4 participants 11 messages Jun 20, 2019 – Jun 24, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: ehci-mx6: Fix bus enumeration for DM case

It is likely that the DM conversion of EHCI iMX6 driver was a derivative of EHCI VF, however the conversion is incomplete and is missing the bind workaround, which updates dev->seq number. Without this, all controllers have dev->seq number 0 . Add this bind workaround into EHCI iMX6 driver as well.

Cc Abel Vesa <[email protected]>
Cc Adam Ford <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Ludwig Zenz <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Vagrant Cascadian <[email protected]>
---
 drivers/usb/host/ehci-mx6.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/usb/host/ehci-mx6.c +17 -0
index 33abfeada0..109ed7ed4a 100644
@@ -503,6 +503,22 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev)
 	return 0;
 }
 
+static int ehci_usb_bind(struct udevice *dev)
+{
+	static int num_controllers;
+
+	/*
+	 * Without this hack, if we return ENODEV for USB Controller 0, on
+	 * probe for the next controller, USB Controller 1 will be given a
+	 * sequence number of 0. This conflicts with our requirement of
+	 * sequence numbers while initialising the peripherals.
+	 */
+	dev->req_seq = num_controllers;
+	num_controllers++;
+
+	return 0;
+}
+
 static int ehci_usb_probe(struct udevice *dev)
 {
 	struct usb_platdata *plat = dev_get_platdata(dev);
@@ -564,6 +580,7 @@ U_BOOT_DRIVER(usb_mx6) = {
 	.id	= UCLASS_USB,
 	.of_match = mx6_usb_ids,
 	.ofdata_to_platdata = ehci_usb_ofdata_to_platdata,
+	.bind	= ehci_usb_bind,
 	.probe	= ehci_usb_probe,
 	.remove = ehci_deregister,
 	.ops	= &ehci_usb_ops,
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 usb: ehci-mx6: Fix bus enumeration for DM case

Hi Marek,

Quoted 36 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2019年6月21日 4:54
To: u-boot at lists.denx.de
Cc: Marek Vasut <[email protected]>; Abel Vesa <[email protected]>; Adam Ford <[email protected]>; Fabio Estevam <[email protected]>; Ludwig Zenz <[email protected]>; Peng Fan <[email protected]>; Stefano Babic <[email protected]>; Vagrant Cascadian <[email protected]>
Subject: [PATCH] usb: ehci-mx6: Fix bus enumeration for DM case

It is likely that the DM conversion of EHCI iMX6 driver was a derivative of EHCI VF, however the conversion is incomplete and is missing the bind workaround, which updates dev->seq number. Without this, all controllers have dev->seq number 0 . Add this bind workaround into EHCI iMX6 driver as well.

Cc Abel Vesa <[email protected]>
Cc Adam Ford <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Ludwig Zenz <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Vagrant Cascadian <[email protected]>
---
 drivers/usb/host/ehci-mx6.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/usb/host/ehci-mx6.c index renamed from drivers/usb/host/ehci-mx6.c +0 -0

33abfeada0..109ed7ed4a 100644

drivers/usb/host/ehci-mx6.c +0 -0
@@ -503,6 +503,22 @@ static int ehci_usb_ofdata_to_platdata(struct
 udevice *dev)
 	return 0;
 }
 

drivers/usb/host/ehci-mx6.c static int ehci_usb_ofdata_to_platdata(struct · line 516

Quoted 10 lines
drivers/usb/host/ehci-mx6.c +10 -0
+static int ehci_usb_bind(struct udevice *dev) {
+	static int num_controllers;
+
+	/*
+	 * Without this hack, if we return ENODEV for USB Controller 0, on
+	 * probe for the next controller, USB Controller 1 will be given a
+	 * sequence number of 0. This conflicts with our requirement of
+	 * sequence numbers while initialising the peripherals.
+	 */
+	dev->req_seq = num_controllers;

With alias in dts, no need this, right?

Regards,
Peng.

Quoted 17 lines
drivers/usb/host/ehci-mx6.c +5 -0
+	num_controllers++;
+
+	return 0;
+}
+
 static int ehci_usb_probe(struct udevice *dev)  {
 	struct usb_platdata *plat = dev_get_platdata(dev); @@ -564,6 +580,7

@@ U_BOOT_DRIVER(usb_mx6) = {

drivers/usb/host/ehci-mx6.c +1 -1
 	.id	= UCLASS_USB,
 	.of_match = mx6_usb_ids,
 	.ofdata_to_platdata = ehci_usb_ofdata_to_platdata,
+	.bind	= ehci_usb_bind,
 	.probe	= ehci_usb_probe,
 	.remove = ehci_deregister,
 	.ops	= &ehci_usb_ops,
--

2.20.1

#2 lore raw

PATCH 1/1 usb: ehci-mx6: Fix bus enumeration for DM case

Quoted 38 lines · Peng Fan

Hi Marek,

Quoted 36 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2019年6月21日 4:54
To: u-boot at lists.denx.de
Cc: Marek Vasut <[email protected]>; Abel Vesa <[email protected]>; Adam Ford <[email protected]>; Fabio Estevam <[email protected]>; Ludwig Zenz <[email protected]>; Peng Fan <[email protected]>; Stefano Babic <[email protected]>; Vagrant Cascadian <[email protected]>
Subject: [PATCH] usb: ehci-mx6: Fix bus enumeration for DM case

It is likely that the DM conversion of EHCI iMX6 driver was a derivative of EHCI VF, however the conversion is incomplete and is missing the bind workaround, which updates dev->seq number. Without this, all controllers have dev->seq number 0 . Add this bind workaround into EHCI iMX6 driver as well.

Cc Abel Vesa <[email protected]>
Cc Adam Ford <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Ludwig Zenz <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Vagrant Cascadian <[email protected]>
---
 drivers/usb/host/ehci-mx6.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/usb/host/ehci-mx6.c index renamed from drivers/usb/host/ehci-mx6.c +0 -0

33abfeada0..109ed7ed4a 100644

drivers/usb/host/ehci-mx6.c +0 -0
@@ -503,6 +503,22 @@ static int ehci_usb_ofdata_to_platdata(struct
 udevice *dev)
 	return 0;
 }
 
Quoted 12 lines

drivers/usb/host/ehci-mx6.c static int ehci_usb_ofdata_to_platdata(struct udevice *dev) · line 516

Quoted 10 lines
drivers/usb/host/ehci-mx6.c +10 -0
+static int ehci_usb_bind(struct udevice *dev) {
+	static int num_controllers;
+
+	/*
+	 * Without this hack, if we return ENODEV for USB Controller 0, on
+	 * probe for the next controller, USB Controller 1 will be given a
+	 * sequence number of 0. This conflicts with our requirement of
+	 * sequence numbers while initialising the peripherals.
+	 */
+	dev->req_seq = num_controllers;

With alias in dts, no need this, right?

There are no aliases in the DTs for the USB controllers, so that doesn't help. I think for DM, the real solution would be to parse the PHY phandle and pass around the PHY address instead of some arbitrary index, but that's something to be done for next release. For this release, it's only fixes.

Would you be interested in implementing the later for -next ? ;-)

Signature · 2 lines
Best regards,
Marek Vasut
#3 lore raw

PATCH 1/1 usb: ehci-mx6: Fix bus enumeration for DM case

Hi Marek,

Quoted 58 lines

Subject: Re: [PATCH] usb: ehci-mx6: Fix bus enumeration for DM case

Quoted 7 lines · Peng Fan

Hi Marek,

Quoted 5 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2019年6月21日 4:54
To: u-boot at lists.denx.de
Cc: Marek Vasut <[email protected]>; Abel Vesa <[email protected]>;

Adam

Quoted 1 line
Quoted 1 line

Ford <[email protected]>; Fabio Estevam <[email protected]>;

Ludwig

Quoted 1 line
Quoted 1 line

Zenz <[email protected]>; Peng Fan <[email protected]>;

Stefano

Quoted 7 lines
Quoted 7 lines

Babic <[email protected]>; Vagrant Cascadian <[email protected]>
Subject: [PATCH] usb: ehci-mx6: Fix bus enumeration for DM case

It is likely that the DM conversion of EHCI iMX6 driver was a derivative of EHCI VF, however the conversion is incomplete and is missing the bind workaround, which updates dev->seq number. Without this, all controllers have dev->seq number 0 . Add this bind workaround

into EHCI iMX6 driver as well.

Quoted 22 lines
Quoted 22 lines
Cc Abel Vesa <[email protected]>
Cc Adam Ford <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Ludwig Zenz <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Vagrant Cascadian <[email protected]>
---
 drivers/usb/host/ehci-mx6.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
(quoted diff) +0 -0

b/drivers/usb/host/ehci-mx6.c index 33abfeada0..109ed7ed4a 100644

drivers/usb/host/ehci-mx6.c +0 -0
@@ -503,6 +503,22 @@ static int ehci_usb_ofdata_to_platdata(struct
 udevice *dev)
 	return 0;
 }
 
Quoted 12 lines

drivers/usb/host/ehci-mx6.c static int ehci_usb_ofdata_to_platdata(struct udevice *dev) · line 516

Quoted 10 lines
drivers/usb/host/ehci-mx6.c +10 -0
+static int ehci_usb_bind(struct udevice *dev) {
+	static int num_controllers;
+
+	/*
+	 * Without this hack, if we return ENODEV for USB Controller 0, on
+	 * probe for the next controller, USB Controller 1 will be given a
+	 * sequence number of 0. This conflicts with our requirement of
+	 * sequence numbers while initialising the peripherals.
+	 */
+	dev->req_seq = num_controllers;

With alias in dts, no need this, right?

Quoted 4 lines

There are no aliases in the DTs for the USB controllers, so that doesn't help. I think for DM, the real solution would be to parse the PHY phandle and pass around the PHY address instead of some arbitrary index, but that's something to be done for next release. For this release, it's only fixes.

I think the better method is use alias in dts, introducing xx-u-boot.dtsi for such case.

Quoted 2 lines

Would you be interested in implementing the later for -next ? ;-)

In NXP vendor tree, we have ehci_usb_get_phy to parse phy from dtb, I could find some time send that to community.

Regards,
Peng.

Quoted 4 lines

--
Best regards,
Marek Vasut

#4 lore raw

PATCH 1/1 usb: ehci-mx6: Fix bus enumeration for DM case

Quoted 60 lines · Peng Fan

Hi Marek,

Quoted 58 lines

Subject: Re: [PATCH] usb: ehci-mx6: Fix bus enumeration for DM case

Quoted 7 lines · Peng Fan

Hi Marek,

Quoted 5 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2019年6月21日 4:54
To: u-boot at lists.denx.de
Cc: Marek Vasut <[email protected]>; Abel Vesa <[email protected]>;

Adam

Quoted 1 line
Quoted 1 line

Ford <[email protected]>; Fabio Estevam <[email protected]>;

Ludwig

Quoted 1 line
Quoted 1 line

Zenz <[email protected]>; Peng Fan <[email protected]>;

Stefano

Quoted 7 lines
Quoted 7 lines

Babic <[email protected]>; Vagrant Cascadian <[email protected]>
Subject: [PATCH] usb: ehci-mx6: Fix bus enumeration for DM case

It is likely that the DM conversion of EHCI iMX6 driver was a derivative of EHCI VF, however the conversion is incomplete and is missing the bind workaround, which updates dev->seq number. Without this, all controllers have dev->seq number 0 . Add this bind workaround

into EHCI iMX6 driver as well.

Quoted 34 lines
Quoted 22 lines
Cc Abel Vesa <[email protected]>
Cc Adam Ford <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Ludwig Zenz <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Vagrant Cascadian <[email protected]>
---
 drivers/usb/host/ehci-mx6.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
(quoted diff) +0 -0

b/drivers/usb/host/ehci-mx6.c index 33abfeada0..109ed7ed4a 100644

drivers/usb/host/ehci-mx6.c +0 -0
@@ -503,6 +503,22 @@ static int ehci_usb_ofdata_to_platdata(struct
 udevice *dev)
 	return 0;
 }
 

drivers/usb/host/ehci-mx6.c static int ehci_usb_ofdata_to_platdata(struct · line 516

Quoted 10 lines
drivers/usb/host/ehci-mx6.c +10 -0
+static int ehci_usb_bind(struct udevice *dev) {
+	static int num_controllers;
+
+	/*
+	 * Without this hack, if we return ENODEV for USB Controller 0, on
+	 * probe for the next controller, USB Controller 1 will be given a
+	 * sequence number of 0. This conflicts with our requirement of
+	 * sequence numbers while initialising the peripherals.
+	 */
+	dev->req_seq = num_controllers;

With alias in dts, no need this, right?

Quoted 7 lines
Quoted 4 lines

There are no aliases in the DTs for the USB controllers, so that doesn't help. I think for DM, the real solution would be to parse the PHY phandle and pass around the PHY address instead of some arbitrary index, but that's something to be done for next release. For this release, it's only fixes.

I think the better method is use alias in dts, introducing xx-u-boot.dtsi for such case.

What good would that make if you can obtain the PHY address from the DT, without the need for arbitrary error-prone indexes? The indexes are remnants from when there was no DM or from the DM conversion, so we should remove them altogether.

Quoted 4 lines
Quoted 1 line

Would you be interested in implementing the later for -next ? ;-)

In NXP vendor tree, we have ehci_usb_get_phy to parse phy from dtb, I could find some time send that to community.

What about implementing a proper USB PHY driver, which binds to a DT entry, and then hooking it up to the EHCI MX6 ? IIRC the infrastructure for this is already in place and that would be the right (TM) solution.

Signature · 2 lines
Best regards,
Marek Vasut
#5 lore raw

PATCH 1/1 usb: ehci-mx6: Fix bus enumeration for DM case

Quoted 79 lines · On Mon, 24 Jun 2019 12:06:28 +0200 Marek Vasut <[email protected]> wrote:
Quoted 64 lines · Peng Fan

Hi Marek,

Quoted 62 lines

Subject: Re: [PATCH] usb: ehci-mx6: Fix bus enumeration for DM case

Quoted 7 lines · Peng Fan

Hi Marek,

Quoted 5 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2019年6月21日 4:54
To: u-boot at lists.denx.de
Cc: Marek Vasut <[email protected]>; Abel Vesa <[email protected]>;

Adam

Quoted 1 line
Quoted 1 line

Ford <[email protected]>; Fabio Estevam <[email protected]>;

Ludwig

Quoted 1 line
Quoted 1 line

Zenz <[email protected]>; Peng Fan <[email protected]>;

Stefano

Quoted 8 lines
Quoted 8 lines

Babic <[email protected]>; Vagrant Cascadian <[email protected]>
Subject: [PATCH] usb: ehci-mx6: Fix bus enumeration for DM case

It is likely that the DM conversion of EHCI iMX6 driver was a derivative of EHCI VF, however the conversion is incomplete and is missing the bind workaround, which updates dev->seq number. Without this, all controllers have dev->seq number 0 . Add this bind workaround

into EHCI iMX6 driver as well.

Quoted 37 lines
Quoted 32 lines
Cc Abel Vesa <[email protected]>
Cc Adam Ford <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Ludwig Zenz <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Vagrant Cascadian <[email protected]>
---
 drivers/usb/host/ehci-mx6.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
(quoted diff) +0 -0

b/drivers/usb/host/ehci-mx6.c index 33abfeada0..109ed7ed4a 100644

drivers/usb/host/ehci-mx6.c +5 -0
@@ -503,6 +503,22 @@ static int
 ehci_usb_ofdata_to_platdata(struct udevice *dev)
 	return 0;
 }
 
+static int ehci_usb_bind(struct udevice *dev) {
+	static int num_controllers;
+
+	/*
+	 * Without this hack, if we return ENODEV for USB

Controller 0, on

drivers/usb/host/ehci-mx6.c +1 -0
+	 * probe for the next controller, USB Controller 1 will

be given a

drivers/usb/host/ehci-mx6.c +1 -0
+	 * sequence number of 0. This conflicts with our

requirement of

drivers/usb/host/ehci-mx6.c static int ehci_usb_ofdata_to_platdata(struct udevice *dev) · line 516

Quoted 3 lines
drivers/usb/host/ehci-mx6.c +3 -0
+	 * sequence numbers while initialising the peripherals.
+	 */
+	dev->req_seq = num_controllers;  

With alias in dts, no need this, right?

Quoted 8 lines
Quoted 5 lines

There are no aliases in the DTs for the USB controllers, so that doesn't help. I think for DM, the real solution would be to parse the PHY phandle and pass around the PHY address instead of some arbitrary index, but that's something to be done for next release. For this release, it's only fixes.

I think the better method is use alias in dts, introducing xx-u-boot.dtsi for such case.

What good would that make if you can obtain the PHY address from the DT, without the need for arbitrary error-prone indexes? The indexes are remnants from when there was no DM or from the DM conversion, so we should remove them altogether.

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

Would you be interested in implementing the later for -next ? ;-)

In NXP vendor tree, we have ehci_usb_get_phy to parse phy from dtb, I could find some time send that to community.

What about implementing a proper USB PHY driver, which binds to a DT entry, and then hooking it up to the EHCI MX6 ? IIRC the infrastructure for this is already in place and that would be the right (TM) solution.

Sorry, but I'm a bit confused.

The patch that you introduced above, in the commit message, states clearly that it is a hack.

Why shall we allow introducing hacks instead of implementing it in the "right way" from the outset ?

As you mentioned the infrastructure is already in place, so why not do it in the correct way?

And yes, as Peng noted up, till now many boards use aliases to fix this situation.

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190624/f1805e87/attachment.sig>

#6 lore raw

PATCH 1/1 usb: ehci-mx6: Fix bus enumeration for DM case

Quoted 92 lines · Lukasz Majewski
Quoted 79 lines · On Mon, 24 Jun 2019 12:06:28 +0200 Marek Vasut <[email protected]> wrote:
Quoted 64 lines · Peng Fan

Hi Marek,

Quoted 62 lines

Subject: Re: [PATCH] usb: ehci-mx6: Fix bus enumeration for DM case

Quoted 7 lines · Peng Fan

Hi Marek,

Quoted 5 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2019年6月21日 4:54
To: u-boot at lists.denx.de
Cc: Marek Vasut <[email protected]>; Abel Vesa <[email protected]>;

Adam

Quoted 1 line
Quoted 1 line

Ford <[email protected]>; Fabio Estevam <[email protected]>;

Ludwig

Quoted 1 line
Quoted 1 line

Zenz <[email protected]>; Peng Fan <[email protected]>;

Stefano

Quoted 8 lines
Quoted 8 lines

Babic <[email protected]>; Vagrant Cascadian <[email protected]>
Subject: [PATCH] usb: ehci-mx6: Fix bus enumeration for DM case

It is likely that the DM conversion of EHCI iMX6 driver was a derivative of EHCI VF, however the conversion is incomplete and is missing the bind workaround, which updates dev->seq number. Without this, all controllers have dev->seq number 0 . Add this bind workaround

into EHCI iMX6 driver as well.

Quoted 37 lines
Quoted 32 lines
Cc Abel Vesa <[email protected]>
Cc Adam Ford <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Ludwig Zenz <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Vagrant Cascadian <[email protected]>
---
 drivers/usb/host/ehci-mx6.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
(quoted diff) +0 -0

b/drivers/usb/host/ehci-mx6.c index 33abfeada0..109ed7ed4a 100644

drivers/usb/host/ehci-mx6.c +5 -0
@@ -503,6 +503,22 @@ static int
 ehci_usb_ofdata_to_platdata(struct udevice *dev)
 	return 0;
 }
 
+static int ehci_usb_bind(struct udevice *dev) {
+	static int num_controllers;
+
+	/*
+	 * Without this hack, if we return ENODEV for USB

Controller 0, on

drivers/usb/host/ehci-mx6.c +1 -0
+	 * probe for the next controller, USB Controller 1 will

be given a

drivers/usb/host/ehci-mx6.c +1 -0
+	 * sequence number of 0. This conflicts with our

requirement of

drivers/usb/host/ehci-mx6.c static int ehci_usb_ofdata_to_platdata(struct udevice *dev) · line 516

Quoted 3 lines
drivers/usb/host/ehci-mx6.c +3 -0
+	 * sequence numbers while initialising the peripherals.
+	 */
+	dev->req_seq = num_controllers;  

With alias in dts, no need this, right?

Quoted 8 lines
Quoted 5 lines

There are no aliases in the DTs for the USB controllers, so that doesn't help. I think for DM, the real solution would be to parse the PHY phandle and pass around the PHY address instead of some arbitrary index, but that's something to be done for next release. For this release, it's only fixes.

I think the better method is use alias in dts, introducing xx-u-boot.dtsi for such case.

What good would that make if you can obtain the PHY address from the DT, without the need for arbitrary error-prone indexes? The indexes are remnants from when there was no DM or from the DM conversion, so we should remove them altogether.

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

Would you be interested in implementing the later for -next ? ;-)

In NXP vendor tree, we have ehci_usb_get_phy to parse phy from dtb, I could find some time send that to community.

What about implementing a proper USB PHY driver, which binds to a DT entry, and then hooking it up to the EHCI MX6 ? IIRC the infrastructure for this is already in place and that would be the right (TM) solution.

Quoted 7 lines

Sorry, but I'm a bit confused.

The patch that you introduced above, in the commit message, states clearly that it is a hack.

Why shall we allow introducing hacks instead of implementing it in the "right way" from the outset ?

Because we're in RC4 right now and this is the simplest possible fix which works and is consistent with the other NXP EHCI drivers. See the commit message -- this fills in the missing bit which ehci-vf has, but which was omitted from ehci-mx6 and ehci-mx5 during the conversion.

The PHY driver and the migration to that infrastructure can be done in the next cycle, but right now there's no time to develop a driver and thoroughly test either the PHY driver or the changes to the EHCI driver, no way.

Quoted 5 lines

As you mentioned the infrastructure is already in place, so why not do it in the correct way?

And yes, as Peng noted up, till now many boards use aliases to fix this situation.

Right, so this does not work with the USB stack, but feel free to try it yourself. That's why the ehci-vf has this hack in place.

And I am in fact fine with this, because you don't end up patching DTs with arbitrary aliases AND because this will code go away once the PHY driver is in place anyway and so would the aliases.

Signature · 2 lines
Best regards,
Marek Vasut
#7 lore raw

PATCH 1/1 usb: ehci-mx6: Fix bus enumeration for DM case

Hi Marek,

Quoted 104 lines · Lukasz Majewski
Quoted 103 lines
Quoted 87 lines · On Mon, 24 Jun 2019 12:06:28 +0200 Marek Vasut <[email protected]> wrote:
Quoted 69 lines · Peng Fan

Hi Marek,

Quoted 67 lines

Subject: Re: [PATCH] usb: ehci-mx6: Fix bus enumeration for DM case

Quoted 8 lines · Peng Fan

Hi Marek,

Quoted 6 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2019年6月21日 4:54
To: u-boot at lists.denx.de
Cc: Marek Vasut <[email protected]>; Abel Vesa
<[email protected]>;

Adam

Quoted 2 lines
Quoted 2 lines

Ford <[email protected]>; Fabio Estevam
<[email protected]>;

Ludwig

Quoted 2 lines
Quoted 2 lines

Zenz <[email protected]>; Peng Fan
<[email protected]>;

Stefano

Quoted 8 lines
Quoted 8 lines

Babic <[email protected]>; Vagrant Cascadian <[email protected]>
Subject: [PATCH] usb: ehci-mx6: Fix bus enumeration for DM case

It is likely that the DM conversion of EHCI iMX6 driver was a derivative of EHCI VF, however the conversion is incomplete and is missing the bind workaround, which updates dev->seq number. Without this, all controllers have dev->seq number 0 . Add this bind workaround

into EHCI iMX6 driver as well.

Quoted 38 lines
Quoted 34 lines
Cc Abel Vesa <[email protected]>
Cc Adam Ford <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Ludwig Zenz <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Vagrant Cascadian <[email protected]>
---
 drivers/usb/host/ehci-mx6.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
(quoted diff) +0 -0

b/drivers/usb/host/ehci-mx6.c index 33abfeada0..109ed7ed4a 100644 --- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c

(quoted diff) +5 -0
@@ -503,6 +503,22 @@ static int
 ehci_usb_ofdata_to_platdata(struct udevice *dev)
 	return 0;
 }
 
+static int ehci_usb_bind(struct udevice *dev) {
+	static int num_controllers;
+
+	/*
+	 * Without this hack, if we return ENODEV for USB

Controller 0, on

(quoted diff) +1 -0
+	 * probe for the next controller, USB Controller 1

will be given a

(quoted diff) +1 -0
+	 * sequence number of 0. This conflicts with our

requirement of

(quoted diff) +1 -0
+	 * sequence numbers while initialising the

peripherals.

Review

Quoted 2 lines
(quoted diff) +2 -0
+	 */
+	dev->req_seq = num_controllers;    

With alias in dts, no need this, right?

Quoted 8 lines
Quoted 5 lines

There are no aliases in the DTs for the USB controllers, so that doesn't help. I think for DM, the real solution would be to parse the PHY phandle and pass around the PHY address instead of some arbitrary index, but that's something to be done for next release. For this release, it's only fixes.

I think the better method is use alias in dts, introducing xx-u-boot.dtsi for such case.

What good would that make if you can obtain the PHY address from the DT, without the need for arbitrary error-prone indexes? The indexes are remnants from when there was no DM or from the DM conversion, so we should remove them altogether.

Quoted 3 lines
Quoted 2 lines

Would you be interested in implementing the later for -next ? ;-)

Quoted 7 lines
Quoted 2 lines

In NXP vendor tree, we have ehci_usb_get_phy to parse phy from dtb, I could find some time send that to community.

What about implementing a proper USB PHY driver, which binds to a DT entry, and then hooking it up to the EHCI MX6 ? IIRC the infrastructure for this is already in place and that would be the right (TM) solution.

Sorry, but I'm a bit confused.

The patch that you introduced above, in the commit message, states clearly that it is a hack.

Quoted 9 lines
Quoted 2 lines

Why shall we allow introducing hacks instead of implementing it in the "right way" from the outset ?

Because we're in RC4 right now and this is the simplest possible fix which works and is consistent with the other NXP EHCI drivers. See the
commit message -- this fills in the missing bit which ehci-vf has, but which was omitted from ehci-mx6 and ehci-mx5 during the conversion.

Apparently I was not causing the error which you have encountered.

Quoted 5 lines

The PHY driver and the migration to that infrastructure can be done in the next cycle, but right now there's no time to develop a driver and thoroughly test either the PHY driver or the changes to the EHCI driver, no way.

Quoted 8 lines
Quoted 5 lines

As you mentioned the infrastructure is already in place, so why not do it in the correct way?

And yes, as Peng noted up, till now many boards use aliases to fix this situation.

Right, so this does not work with the USB stack, but feel free to try it yourself. That's why the ehci-vf has this hack in place.

That is why I'm asking as I do use usb on imx53 and imx6q boards. The imx53 uses usbh1 which has alias to usb1.

Quoted 3 lines

And I am in fact fine with this, because you don't end up patching DTs with arbitrary aliases

This patch causes regression (the board hang) when tested on TPC70 i.MX6Q board.

master branch
SHA1: 77f6e2dd0551d8a825bab391a1bd6b838874bcd4

Log from u-boot (broken):

Booting update from usb ...
starting USB...
Bus usb at 2184200:

Working one:

=> usb start
starting USB...
Bus usb at 2184200: USB EHCI 1.00
scanning bus usb at 2184200 for devices... 2 USB Device(s) found
scanning usb for storage devices... 1 Storage Device(s) found

Quoted 3 lines

AND because this will code go away once the PHY driver is in place anyway and so would the aliases.

For now it causes working board to hang. Please fix the patch.

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190624/aca65b21/attachment.sig>

#8 lore raw

PATCH 1/1 usb: ehci-mx6: Fix bus enumeration for DM case

Quoted 126 lines · Lukasz Majewski

Hi Marek,

Quoted 104 lines · Lukasz Majewski
Quoted 103 lines
Quoted 87 lines · On Mon, 24 Jun 2019 12:06:28 +0200 Marek Vasut <[email protected]> wrote:
Quoted 69 lines · Peng Fan

Hi Marek,

Quoted 67 lines

Subject: Re: [PATCH] usb: ehci-mx6: Fix bus enumeration for DM case

Quoted 8 lines · Peng Fan

Hi Marek,

Quoted 6 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2019年6月21日 4:54
To: u-boot at lists.denx.de
Cc: Marek Vasut <[email protected]>; Abel Vesa
<[email protected]>;

Adam

Quoted 2 lines
Quoted 2 lines

Ford <[email protected]>; Fabio Estevam
<[email protected]>;

Ludwig

Quoted 2 lines
Quoted 2 lines

Zenz <[email protected]>; Peng Fan
<[email protected]>;

Stefano

Quoted 8 lines
Quoted 8 lines

Babic <[email protected]>; Vagrant Cascadian <[email protected]>
Subject: [PATCH] usb: ehci-mx6: Fix bus enumeration for DM case

It is likely that the DM conversion of EHCI iMX6 driver was a derivative of EHCI VF, however the conversion is incomplete and is missing the bind workaround, which updates dev->seq number. Without this, all controllers have dev->seq number 0 . Add this bind workaround

into EHCI iMX6 driver as well.

Quoted 38 lines
Quoted 34 lines
Cc Abel Vesa <[email protected]>
Cc Adam Ford <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Ludwig Zenz <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Vagrant Cascadian <[email protected]>
---
 drivers/usb/host/ehci-mx6.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
(quoted diff) +0 -0

b/drivers/usb/host/ehci-mx6.c index 33abfeada0..109ed7ed4a 100644 --- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c

(quoted diff) +5 -0
@@ -503,6 +503,22 @@ static int
 ehci_usb_ofdata_to_platdata(struct udevice *dev)
 	return 0;
 }
 
+static int ehci_usb_bind(struct udevice *dev) {
+	static int num_controllers;
+
+	/*
+	 * Without this hack, if we return ENODEV for USB

Controller 0, on

(quoted diff) +1 -0
+	 * probe for the next controller, USB Controller 1

will be given a

(quoted diff) +1 -0
+	 * sequence number of 0. This conflicts with our

requirement of

(quoted diff) +1 -0
+	 * sequence numbers while initialising the

peripherals.

Review

Quoted 2 lines
(quoted diff) +2 -0
+	 */
+	dev->req_seq = num_controllers;    

With alias in dts, no need this, right?

Quoted 8 lines
Quoted 5 lines

There are no aliases in the DTs for the USB controllers, so that doesn't help. I think for DM, the real solution would be to parse the PHY phandle and pass around the PHY address instead of some arbitrary index, but that's something to be done for next release. For this release, it's only fixes.

I think the better method is use alias in dts, introducing xx-u-boot.dtsi for such case.

What good would that make if you can obtain the PHY address from the DT, without the need for arbitrary error-prone indexes? The indexes are remnants from when there was no DM or from the DM conversion, so we should remove them altogether.

Quoted 3 lines
Quoted 2 lines

Would you be interested in implementing the later for -next ? ;-)

Quoted 7 lines
Quoted 2 lines

In NXP vendor tree, we have ehci_usb_get_phy to parse phy from dtb, I could find some time send that to community.

What about implementing a proper USB PHY driver, which binds to a DT entry, and then hooking it up to the EHCI MX6 ? IIRC the infrastructure for this is already in place and that would be the right (TM) solution.

Sorry, but I'm a bit confused.

The patch that you introduced above, in the commit message, states clearly that it is a hack.

Quoted 9 lines
Quoted 2 lines

Why shall we allow introducing hacks instead of implementing it in the "right way" from the outset ?

Because we're in RC4 right now and this is the simplest possible fix which works and is consistent with the other NXP EHCI drivers. See the
commit message -- this fills in the missing bit which ehci-vf has, but which was omitted from ehci-mx6 and ehci-mx5 during the conversion.

Apparently I was not causing the error which you have encountered.

Quoted 8 lines

The PHY driver and the migration to that infrastructure can be done in the next cycle, but right now there's no time to develop a driver and thoroughly test either the PHY driver or the changes to the EHCI driver, no way.

Quoted 3 lines

As you mentioned the infrastructure is already in place, so why not do it in the correct way?

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

And yes, as Peng noted up, till now many boards use aliases to fix this situation.

Right, so this does not work with the USB stack, but feel free to try it yourself. That's why the ehci-vf has this hack in place.

That is why I'm asking as I do use usb on imx53 and imx6q boards. The imx53 uses usbh1 which has alias to usb1.

And the device sequence number is consistently 0, right ?

Quoted 25 lines
Quoted 2 lines

And I am in fact fine with this, because you don't end up patching DTs with arbitrary aliases

This patch causes regression (the board hang) when tested on TPC70 i.MX6Q board.

master branch
SHA1: 77f6e2dd0551d8a825bab391a1bd6b838874bcd4

Log from u-boot (broken):

Booting update from usb ...
starting USB...
Bus usb at 2184200:

Working one:

=> usb start
starting USB...
Bus usb at 2184200: USB EHCI 1.00
scanning bus usb at 2184200 for devices... 2 USB Device(s) found
scanning usb for storage devices... 1 Storage Device(s) found

Quoted 5 lines
Quoted 3 lines

AND because this will code go away once the PHY driver is in place anyway and so would the aliases.

For now it causes working board to hang. Please fix the patch.

I wonder how you managed to trigger this on , presumably , kp_imx6q_tpc . When I build this target on 77f6e2dd0551d8a825bab391a1bd6b838874bcd4 , I get:

===================== WARNING ====================== This board does not use CONFIG_DM_USB. Please update the board to use CONFIG_DM_USB before the v2019.07 release. Failure to update by the deadline may result in board removal. See doc/driver-model/MIGRATION.txt for more info.
====================================================

So the code in this patch doesn't even get compiled.

I presume you have some additional extra patches on top, right ?

Anyway, I cannot debug a board I don't have. Take a look at ehci_usb_probe() priv->portnr before and after this patch, does it change ? That's the value from which the PHY index is derived ; if the PHY index does not match the controller index, the probe hangs, I think that's what you're hitting.

Signature · 2 lines
Best regards,
Marek Vasut
#9 lore raw

PATCH 1/1 usb: ehci-mx6: Fix bus enumeration for DM case

Hi Marek,

Quoted 131 lines · Lukasz Majewski
Quoted 130 lines

Hi Marek,

Quoted 108 lines · Lukasz Majewski
Quoted 99 lines
Quoted 88 lines · On Mon, 24 Jun 2019 12:06:28 +0200 Marek Vasut <[email protected]> wrote:
Quoted 70 lines · Peng Fan

Hi Marek,

Quoted 68 lines

Subject: Re: [PATCH] usb: ehci-mx6: Fix bus enumeration for DM case

Quoted 8 lines · Peng Fan

Hi Marek,

Quoted 6 lines

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: 2019年6月21日 4:54
To: u-boot at lists.denx.de
Cc: Marek Vasut <[email protected]>; Abel Vesa
<[email protected]>;

Adam

Quoted 2 lines
Quoted 2 lines

Ford <[email protected]>; Fabio Estevam
<[email protected]>;

Ludwig

Quoted 2 lines
Quoted 2 lines

Zenz <[email protected]>; Peng Fan
<[email protected]>;

Stefano

Quoted 9 lines
Quoted 9 lines

Babic <[email protected]>; Vagrant Cascadian <[email protected]> Subject: [PATCH] usb: ehci-mx6: Fix bus enumeration for DM case

It is likely that the DM conversion of EHCI iMX6 driver was a derivative of EHCI VF, however the conversion is incomplete and is missing the bind workaround, which updates dev->seq number. Without this, all controllers have dev->seq number 0 . Add this bind workaround

into EHCI iMX6 driver as well.

Quoted 38 lines
Quoted 34 lines
Cc Abel Vesa <[email protected]>
Cc Adam Ford <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Ludwig Zenz <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Vagrant Cascadian <[email protected]>
---
 drivers/usb/host/ehci-mx6.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
(quoted diff) +0 -0

b/drivers/usb/host/ehci-mx6.c index 33abfeada0..109ed7ed4a 100644 --- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c

(quoted diff) +5 -0
@@ -503,6 +503,22 @@ static int
 ehci_usb_ofdata_to_platdata(struct udevice *dev)
 	return 0;
 }
 
+static int ehci_usb_bind(struct udevice *dev) {
+	static int num_controllers;
+
+	/*
+	 * Without this hack, if we return ENODEV for USB

Controller 0, on

(quoted diff) +1 -0
+	 * probe for the next controller, USB Controller 1

will be given a

(quoted diff) +1 -0
+	 * sequence number of 0. This conflicts with our

requirement of

(quoted diff) +1 -0
+	 * sequence numbers while initialising the

peripherals.

Review

Quoted 2 lines
(quoted diff) +2 -0
+	 */
+	dev->req_seq = num_controllers;      

With alias in dts, no need this, right?

Quoted 8 lines
Quoted 5 lines

There are no aliases in the DTs for the USB controllers, so that doesn't help. I think for DM, the real solution would be to parse the PHY phandle and pass around the PHY address instead of some arbitrary index, but that's something to be done for next release. For this release, it's only fixes.

I think the better method is use alias in dts, introducing xx-u-boot.dtsi for such case.

What good would that make if you can obtain the PHY address from the DT, without the need for arbitrary error-prone indexes? The indexes are remnants from when there was no DM or from the DM conversion, so we should remove them altogether.

Quoted 3 lines
Quoted 2 lines

Would you be interested in implementing the later for -next ? ;-)

Quoted 7 lines
Quoted 2 lines

In NXP vendor tree, we have ehci_usb_get_phy to parse phy from dtb, I could find some time send that to community.

What about implementing a proper USB PHY driver, which binds to a DT entry, and then hooking it up to the EHCI MX6 ? IIRC the infrastructure for this is already in place and that would be the right (TM) solution.

Quoted 7 lines

Sorry, but I'm a bit confused.

The patch that you introduced above, in the commit message, states clearly that it is a hack.

Why shall we allow introducing hacks instead of implementing it in the "right way" from the outset ?

Quoted 6 lines

Because we're in RC4 right now and this is the simplest possible fix which works and is consistent with the other NXP EHCI drivers. See the
commit message -- this fills in the missing bit which ehci-vf has, but which was omitted from ehci-mx6 and ehci-mx5 during the conversion.

Apparently I was not causing the error which you have encountered.

Quoted 11 lines

The PHY driver and the migration to that infrastructure can be done in the next cycle, but right now there's no time to develop a driver and thoroughly test either the PHY driver or the changes to the EHCI driver, no way.

Quoted 5 lines

As you mentioned the infrastructure is already in place, so why not do it in the correct way?

And yes, as Peng noted up, till now many boards use aliases to fix this situation.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Right, so this does not work with the USB stack, but feel free to try it yourself. That's why the ehci-vf has this hack in place.

That is why I'm asking as I do use usb on imx53 and imx6q boards. The imx53 uses usbh1 which has alias to usb1.

And the device sequence number is consistently 0, right ?

I've just tested it, without delving into details.

Quoted 36 lines
Quoted 26 lines
Quoted 3 lines

And I am in fact fine with this, because you don't end up patching DTs with arbitrary aliases

This patch causes regression (the board hang) when tested on TPC70 i.MX6Q board.

master branch
SHA1: 77f6e2dd0551d8a825bab391a1bd6b838874bcd4

Log from u-boot (broken):

Booting update from usb ...
starting USB...
Bus usb at 2184200:

Working one:

=> usb start
starting USB...
Bus usb at 2184200: USB EHCI 1.00
scanning bus usb at 2184200 for devices... 2 USB Device(s) found
scanning usb for storage devices... 1 Storage Device(s) found

Quoted 5 lines
Quoted 3 lines

AND because this will code go away once the PHY driver is in place anyway and so would the aliases.

For now it causes working board to hang. Please fix the patch.

I wonder how you managed to trigger this on , presumably , kp_imx6q_tpc . When I build this target on 77f6e2dd0551d8a825bab391a1bd6b838874bcd4 , I get:

Quoted 8 lines

===================== WARNING ====================== This board does not use CONFIG_DM_USB. Please update the board to use CONFIG_DM_USB before the v2019.07 release. Failure to update by the deadline may result in board removal. See doc/driver-model/MIGRATION.txt for more info.
====================================================

So the code in this patch doesn't even get compiled.

The board is being converted.

Quoted 2 lines

I presume you have some additional extra patches on top, right ?

Yes, the conversion patches.

Quoted 6 lines

Anyway, I cannot debug a board I don't have. Take a look at ehci_usb_probe() priv->portnr before and after this patch, does it change ? That's the value from which the PHY index is derived ; if the PHY index does not match the controller index, the probe hangs, I think that's what you're hitting.

Thanks for the suggestion.

Quoted 1 line

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190624/f3803a0d/attachment.sig>

#10 lore raw

PATCH 1/1 usb: ehci-mx6: Fix bus enumeration for DM case

In reply to Marek Vasut

Marek Vasut <[email protected]> Thursday 20th June 2019 22:55:

Quoted 58 lines

It is likely that the DM conversion of EHCI iMX6 driver was a derivative of EHCI VF, however the conversion is incomplete and is missing the bind workaround, which updates dev->seq number. Without this, all controllers have dev->seq number 0 . Add this bind workaround into EHCI iMX6 driver as well.

Cc Abel Vesa <[email protected]>
Cc Adam Ford <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Ludwig Zenz <[email protected]>
Cc Peng Fan <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Vagrant Cascadian <[email protected]>
---
 drivers/usb/host/ehci-mx6.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/usb/host/ehci-mx6.c +16 -0
index 33abfeada0..109ed7ed4a 100644
@@ -503,6 +503,22 @@ static int ehci_usb_ofdata_to_platdata(struct udevice
 *dev)
 	return 0;
 }
 
+static int ehci_usb_bind(struct udevice *dev)
+{
+	static int num_controllers;
+
+	/*
+	 * Without this hack, if we return ENODEV for USB Controller 0, on
+	 * probe for the next controller, USB Controller 1 will be given a
+	 * sequence number of 0. This conflicts with our requirement of
+	 * sequence numbers while initialising the peripherals.
+	 */
+	dev->req_seq = num_controllers;
+	num_controllers++;
+
+	return 0;
+}
+
 static int ehci_usb_probe(struct udevice *dev)
 {
drivers/usb/host/ehci-mx6.c +1 -0
 	struct usb_platdata *plat = dev_get_platdata(dev);
@@ -564,6 +580,7 @@ U_BOOT_DRIVER(usb_mx6) = {
 	.id	= UCLASS_USB,
 	.of_match = mx6_usb_ids,
 	.ofdata_to_platdata = ehci_usb_ofdata_to_platdata,
+	.bind	= ehci_usb_bind,
 	.probe	= ehci_usb_probe,
 	.remove = ehci_deregister,
 	.ops	= &ehci_usb_ops,
Signature · 1 line
2.20.1

Thanks,
Regards
Ludwig Zenz