[U-Boot] [PATCH 0/2] sunxi: A64: enable first USB port on Pine64 boards

Since the beginning the upper USB port on Pine64 boards (Pine64+, SoPine baseboard, Pine64-LTS, Pinebook) was not working under U-Boot. This is due to the PHY for those pins being shared with the OTG controller, which we didn't even enable for those boards. Also the PHY code was always connecting the port pins to the OTG controller.
These two patches fix this, so the upper USB port on said boards can be used within U-Boot. This allows to use an USB keyboard alongside an USB flash drive, for instance to install operating systems using UEFI.
Cheers, Andre.
Andre Przywara (2): sunxi: USB PHY: Support shared PHY 0 sunxi: Pine64: DTS: enable USB PHY 0 for HCI0
arch/arm/dts/sun50i-a64-pine64.dts | 5 ++++- arch/arm/dts/sun50i-a64-sopine-baseboard.dts | 5 ++++- drivers/phy/allwinner/phy-sun4i-usb.c | 8 +++++++- 3 files changed, 15 insertions(+), 3 deletions(-)

The Allwinner H3, H5, H6 and A64 SoCs share USB PHY 0 between the first HCI controller (OHCI0/EHCI0) and the MUSB OTG controller. Bit 0 in PHY register 0x20 selects with of the controllers is connected to the PHY. So far we were hardwiring this bit to 0, so that the OTG controller controls the pins. As the A64 has only two sets of USB pins, some boards like the Pine64 connect two USB-A sockets to them, to give more host ports. In this case we would like HCI0 to control the pins. For those boards we typically don't even enable the MUSB OTG controller in the config.
Depending on whether the OTG controller is configured or not, switch PHY0 to either EHCI0/OHCI0 or the OTG controller.
This enables the upper USB port on the Pine64 (and other) boards. This proves to be very useful when people want to connect both an USB keyboard and a flash drive, for instance to install a Linux distribution.
Signed-off-by: Andre Przywara andre.przywara@arm.com --- drivers/phy/allwinner/phy-sun4i-usb.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c index f206fa3f5d..de1065fce6 100644 --- a/drivers/phy/allwinner/phy-sun4i-usb.c +++ b/drivers/phy/allwinner/phy-sun4i-usb.c @@ -240,6 +240,11 @@ static int sun4i_usb_phy_power_off(struct phy *phy) return 0; }
+#ifdef CONFIG_USB_MUSB_SUNXI +#define REROUTE_TARGET true +#else +#define REROUTE_TARGET false +#endif static void sun4i_usb_phy0_reroute(struct sun4i_usb_phy_data *data, bool id_det) { u32 regval; @@ -304,7 +309,8 @@ static int sun4i_usb_phy_init(struct phy *phy)
sun4i_usb_phy_passby(phy, true);
- sun4i_usb_phy0_reroute(data, true); + if (data->cfg->phy0_dual_route) + sun4i_usb_phy0_reroute(data, REROUTE_TARGET);
return 0; }

The first USB controller on the A64 SoC shares a PHY with the OTG controller. Reportedly to avoid problems with the VBUS regulator under Linux, we don't link OHCI0/EHCI0 to the USB PHY in the A64 .dtsi file.
However on boards which can't use peripheral mode (because they have an always-on VBUS supply on an USB-A socket) we don't need this trick, and can properly connect host controller 0 to the PHY 0.
Amend the Pine64 and SoPine/LTS .dts to reflect this. This enables the upper USB port in U-Boot on those boards.
Signed-off-by: Andre Przywara andre.przywara@arm.com --- arch/arm/dts/sun50i-a64-pine64.dts | 5 ++++- arch/arm/dts/sun50i-a64-sopine-baseboard.dts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/arch/arm/dts/sun50i-a64-pine64.dts b/arch/arm/dts/sun50i-a64-pine64.dts index c077b6c1f4..523a4d5bff 100644 --- a/arch/arm/dts/sun50i-a64-pine64.dts +++ b/arch/arm/dts/sun50i-a64-pine64.dts @@ -80,6 +80,8 @@ };
&ehci0 { + phys = <&usbphy 0>; + phy-names = "usb"; status = "okay"; };
@@ -136,6 +138,8 @@ };
&ohci0 { + phys = <&usbphy 0>; + phy-names = "usb"; status = "okay"; };
@@ -301,7 +305,6 @@
&usb_otg { dr_mode = "host"; - status = "okay"; };
&usbphy { diff --git a/arch/arm/dts/sun50i-a64-sopine-baseboard.dts b/arch/arm/dts/sun50i-a64-sopine-baseboard.dts index 53fcc9098d..1986897177 100644 --- a/arch/arm/dts/sun50i-a64-sopine-baseboard.dts +++ b/arch/arm/dts/sun50i-a64-sopine-baseboard.dts @@ -85,6 +85,8 @@ };
&ehci0 { + phys = <&usbphy 0>; + phy-names = "usb"; status = "okay"; };
@@ -131,6 +133,8 @@ };
&ohci0 { + phys = <&usbphy 0>; + phy-names = "usb"; status = "okay"; };
@@ -172,7 +176,6 @@
&usb_otg { dr_mode = "host"; - status = "okay"; };
&usbphy {

On Thu, May 16, 2019 at 1:47 AM Andre Przywara andre.przywara@arm.com wrote:
The first USB controller on the A64 SoC shares a PHY with the OTG controller. Reportedly to avoid problems with the VBUS regulator under Linux, we don't link OHCI0/EHCI0 to the USB PHY in the A64 .dtsi file.
However on boards which can't use peripheral mode (because they have an always-on VBUS supply on an USB-A socket) we don't need this trick, and can properly connect host controller 0 to the PHY 0.
Amend the Pine64 and SoPine/LTS .dts to reflect this. This enables the upper USB port in U-Boot on those boards.
Signed-off-by: Andre Przywara andre.przywara@arm.com
arch/arm/dts/sun50i-a64-pine64.dts | 5 ++++- arch/arm/dts/sun50i-a64-sopine-baseboard.dts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-)
Are these changes going to go upstream to Linux too? If not it's probably best to add it to a u-boot.dtsi so the changes don't get lost when the DT files are re-synced from Linux. Same with the similar patches for the H6 boards.
Peter
diff --git a/arch/arm/dts/sun50i-a64-pine64.dts b/arch/arm/dts/sun50i-a64-pine64.dts index c077b6c1f4..523a4d5bff 100644 --- a/arch/arm/dts/sun50i-a64-pine64.dts +++ b/arch/arm/dts/sun50i-a64-pine64.dts @@ -80,6 +80,8 @@ };
&ehci0 {
phys = <&usbphy 0>;
phy-names = "usb"; status = "okay";
};
@@ -136,6 +138,8 @@ };
&ohci0 {
phys = <&usbphy 0>;
phy-names = "usb"; status = "okay";
};
@@ -301,7 +305,6 @@
&usb_otg { dr_mode = "host";
status = "okay";
};
&usbphy { diff --git a/arch/arm/dts/sun50i-a64-sopine-baseboard.dts b/arch/arm/dts/sun50i-a64-sopine-baseboard.dts index 53fcc9098d..1986897177 100644 --- a/arch/arm/dts/sun50i-a64-sopine-baseboard.dts +++ b/arch/arm/dts/sun50i-a64-sopine-baseboard.dts @@ -85,6 +85,8 @@ };
&ehci0 {
phys = <&usbphy 0>;
phy-names = "usb"; status = "okay";
};
@@ -131,6 +133,8 @@ };
&ohci0 {
phys = <&usbphy 0>;
phy-names = "usb"; status = "okay";
};
@@ -172,7 +176,6 @@
&usb_otg { dr_mode = "host";
status = "okay";
};
&usbphy {
2.14.5
U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot

On Thu, 16 May 2019 08:15:23 +0100 Peter Robinson pbrobinson@gmail.com wrote:
Hi Peter,
On Thu, May 16, 2019 at 1:47 AM Andre Przywara andre.przywara@arm.com wrote:
The first USB controller on the A64 SoC shares a PHY with the OTG controller. Reportedly to avoid problems with the VBUS regulator under Linux, we don't link OHCI0/EHCI0 to the USB PHY in the A64 .dtsi file.
However on boards which can't use peripheral mode (because they have an always-on VBUS supply on an USB-A socket) we don't need this trick, and can properly connect host controller 0 to the PHY 0.
Amend the Pine64 and SoPine/LTS .dts to reflect this. This enables the upper USB port in U-Boot on those boards.
Signed-off-by: Andre Przywara andre.przywara@arm.com
arch/arm/dts/sun50i-a64-pine64.dts | 5 ++++- arch/arm/dts/sun50i-a64-sopine-baseboard.dts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-)
Are these changes going to go upstream to Linux too? If not it's probably best to add it to a u-boot.dtsi so the changes don't get lost when the DT files are re-synced from Linux. Same with the similar patches for the H6 boards.
Yes, but I need to wait for the end of the merge window before I can post anything there. So I just posted this here to get some input on this. And we need to resync the DTs anyway, I will post something next week, probably syncing with 5.2-rc1.
Actually I believe the changes belong into the .dtsi, as this is how the hardware is wired. But I need to do more tests, as Chen-Yu hinted that this might break USB-OTG on boards with a proper micro-B socket (like the Banana-Pi M64), due to the HCI driver always enabling VBUS. So far I failed to use host mode on that board, but I will keep digging.
Cheers, Andre.
diff --git a/arch/arm/dts/sun50i-a64-pine64.dts b/arch/arm/dts/sun50i-a64-pine64.dts index c077b6c1f4..523a4d5bff 100644 --- a/arch/arm/dts/sun50i-a64-pine64.dts +++ b/arch/arm/dts/sun50i-a64-pine64.dts @@ -80,6 +80,8 @@ };
&ehci0 {
phys = <&usbphy 0>;
phy-names = "usb"; status = "okay";
};
@@ -136,6 +138,8 @@ };
&ohci0 {
phys = <&usbphy 0>;
phy-names = "usb"; status = "okay";
};
@@ -301,7 +305,6 @@
&usb_otg { dr_mode = "host";
status = "okay";
};
&usbphy { diff --git a/arch/arm/dts/sun50i-a64-sopine-baseboard.dts b/arch/arm/dts/sun50i-a64-sopine-baseboard.dts index 53fcc9098d..1986897177 100644 --- a/arch/arm/dts/sun50i-a64-sopine-baseboard.dts +++ b/arch/arm/dts/sun50i-a64-sopine-baseboard.dts @@ -85,6 +85,8 @@ };
&ehci0 {
phys = <&usbphy 0>;
phy-names = "usb"; status = "okay";
};
@@ -131,6 +133,8 @@ };
&ohci0 {
phys = <&usbphy 0>;
phy-names = "usb"; status = "okay";
};
@@ -172,7 +176,6 @@
&usb_otg { dr_mode = "host";
status = "okay";
};
&usbphy {
2.14.5
U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot

On Wed, May 15, 2019 at 5:46 PM Andre Przywara andre.przywara@arm.com wrote:
Since the beginning the upper USB port on Pine64 boards (Pine64+, SoPine baseboard, Pine64-LTS, Pinebook) was not working under U-Boot. This is due to the PHY for those pins being shared with the OTG controller, which we didn't even enable for those boards. Also the PHY code was always connecting the port pins to the OTG controller.
These two patches fix this, so the upper USB port on said boards can be used within U-Boot. This allows to use an USB keyboard alongside an USB flash drive, for instance to install operating systems using UEFI.
Can you also add Pinebook here? It has the same issue.
Cheers, Andre.
Andre Przywara (2): sunxi: USB PHY: Support shared PHY 0 sunxi: Pine64: DTS: enable USB PHY 0 for HCI0
arch/arm/dts/sun50i-a64-pine64.dts | 5 ++++- arch/arm/dts/sun50i-a64-sopine-baseboard.dts | 5 ++++- drivers/phy/allwinner/phy-sun4i-usb.c | 8 +++++++- 3 files changed, 15 insertions(+), 3 deletions(-)
-- 2.14.5
-- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe@googlegroups.com. To view this discussion on the web, visit https://groups.google.com/d/msgid/linux-sunxi/20190516004609.25304-1-andre.p.... For more options, visit https://groups.google.com/d/optout.

On 17/05/2019 19:15, Vasily Khoruzhick wrote:
On Wed, May 15, 2019 at 5:46 PM Andre Przywara andre.przywara@arm.com wrote:
Since the beginning the upper USB port on Pine64 boards (Pine64+, SoPine baseboard, Pine64-LTS, Pinebook) was not working under U-Boot. This is due to the PHY for those pins being shared with the OTG controller, which we didn't even enable for those boards. Also the PHY code was always connecting the port pins to the OTG controller.
These two patches fix this, so the upper USB port on said boards can be used within U-Boot. This allows to use an USB keyboard alongside an USB flash drive, for instance to install operating systems using UEFI.
Can you also add Pinebook here? It has the same issue.
Do you mean to change the -pinebook.dts in patch 2/2? Actually the Pinebook already had this change (from the very beginning), so it should work with just patch 1/2. My Pinebook is a somewhat sorry state, something seems fishy with the USB hub (keyboard doesn't work, although I have used it in U-Boot on another model). I will have a look again, but can you say whether this works for you with just patch 1?
Thanks, Andre.
Andre Przywara (2): sunxi: USB PHY: Support shared PHY 0 sunxi: Pine64: DTS: enable USB PHY 0 for HCI0
arch/arm/dts/sun50i-a64-pine64.dts | 5 ++++- arch/arm/dts/sun50i-a64-sopine-baseboard.dts | 5 ++++- drivers/phy/allwinner/phy-sun4i-usb.c | 8 +++++++- 3 files changed, 15 insertions(+), 3 deletions(-)
-- 2.14.5
-- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe@googlegroups.com. To view this discussion on the web, visit https://groups.google.com/d/msgid/linux-sunxi/20190516004609.25304-1-andre.p.... For more options, visit https://groups.google.com/d/optout.

On 17/05/2019 19:41, André Przywara wrote:
On 17/05/2019 19:15, Vasily Khoruzhick wrote:
On Wed, May 15, 2019 at 5:46 PM Andre Przywara andre.przywara@arm.com wrote:
Since the beginning the upper USB port on Pine64 boards (Pine64+, SoPine baseboard, Pine64-LTS, Pinebook) was not working under U-Boot. This is due to the PHY for those pins being shared with the OTG controller, which we didn't even enable for those boards. Also the PHY code was always connecting the port pins to the OTG controller.
These two patches fix this, so the upper USB port on said boards can be used within U-Boot. This allows to use an USB keyboard alongside an USB flash drive, for instance to install operating systems using UEFI.
Can you also add Pinebook here? It has the same issue.
Do you mean to change the -pinebook.dts in patch 2/2? Actually the Pinebook already had this change (from the very beginning), so it should work with just patch 1/2. My Pinebook is a somewhat sorry state, something seems fishy with the USB hub (keyboard doesn't work, although I have used it in U-Boot on another model). I will have a look again, but can you say whether this works for you with just patch 1?
I had a look, I guess it's the VBUS power supply missing. Can you type the following on the U-Boot prompt to enable GPIO0-LDO? => mw.l 0x1f0341c 0x01 => mw.l 0x1f03410 0x90 => mw.l 0x1f03400 0x80 => usb reset
And see if that fixes things for you? My Pinebook reboots at this point (also does in Linux when the AXP driver comes along that power rail). If that works for you, I will send an ATF patch.
Cheers, Andre.
Andre Przywara (2): sunxi: USB PHY: Support shared PHY 0 sunxi: Pine64: DTS: enable USB PHY 0 for HCI0
arch/arm/dts/sun50i-a64-pine64.dts | 5 ++++- arch/arm/dts/sun50i-a64-sopine-baseboard.dts | 5 ++++- drivers/phy/allwinner/phy-sun4i-usb.c | 8 +++++++- 3 files changed, 15 insertions(+), 3 deletions(-)
-- 2.14.5
-- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe@googlegroups.com. To view this discussion on the web, visit https://groups.google.com/d/msgid/linux-sunxi/20190516004609.25304-1-andre.p.... For more options, visit https://groups.google.com/d/optout.
participants (4)
-
Andre Przywara
-
André Przywara
-
Peter Robinson
-
Vasily Khoruzhick