Skip to contentSkip to conversation

sunxi: A64: enable first USB port on Pine64 boards

PATCH New Andre Przywara 3 participants 8 messages May 16, 2019 – May 18, 2019

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

cover 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(-)
Signature · 1 line
2.14.5
#1 lore raw

PATCH 1/2 sunxi: USB PHY: Support shared PHY 0

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.

---
 drivers/phy/allwinner/phy-sun4i-usb.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/phy/allwinner/phy-sun4i-usb.c +7 -1
index f206fa3f5d..de1065fce6 100644
@@ -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;
 }
Signature · 1 line
2.14.5
#2 lore raw

PATCH 2/2 sunxi: Pine64: DTS: enable USB PHY 0 for HCI0

In reply to Andre Przywara

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.

---
 arch/arm/dts/sun50i-a64-pine64.dts           | 5 ++++-
 arch/arm/dts/sun50i-a64-sopine-baseboard.dts | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)
arch/arm/dts/sun50i-a64-pine64.dts +4 -1
index c077b6c1f4..523a4d5bff 100644
@@ -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 {
arch/arm/dts/sun50i-a64-sopine-baseboard.dts +4 -1
index 53fcc9098d..1986897177 100644
@@ -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 {
Signature · 1 line
2.14.5
#3 lore raw

PATCH 2/2 sunxi: Pine64: DTS: enable USB PHY 0 for HCI0

Quoted 9 lines · Andre Przywara

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.

Quoted 8 lines

Amend the Pine64 and SoPine/LTS .dts to reflect this. This enables the upper USB port in U-Boot on those boards.

---
 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

Quoted 67 lines
arch/arm/dts/sun50i-a64-pine64.dts +4 -1
index c077b6c1f4..523a4d5bff 100644
@@ -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 {
arch/arm/dts/sun50i-a64-sopine-baseboard.dts +4 -2
index 53fcc9098d..1986897177 100644
@@ -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 at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#4 lore raw

PATCH 2/2 sunxi: Pine64: DTS: enable USB PHY 0 for HCI0

On Thu, 16 May 2019 08:15:23 +0100
Peter Robinson <[email protected]> wrote:

Hi Peter,

Quoted 19 lines · Andre Przywara
Quoted 9 lines

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.

Quoted 8 lines

Amend the Pine64 and SoPine/LTS .dts to reflect this. This enables the upper USB port in U-Boot on those boards.

---
 arch/arm/dts/sun50i-a64-pine64.dts           | 5 ++++-
 arch/arm/dts/sun50i-a64-sopine-baseboard.dts | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)  
Quoted 4 lines

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.

Quoted 67 lines
Quoted 67 lines
arch/arm/dts/sun50i-a64-pine64.dts +4 -1
index c077b6c1f4..523a4d5bff 100644
@@ -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 {
arch/arm/dts/sun50i-a64-sopine-baseboard.dts +4 -2
index 53fcc9098d..1986897177 100644
@@ -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 at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#5 lore raw

cover sunxi: A64: enable first USB port on Pine64 boards

In reply to Andre Przywara
Quoted 11 lines · Andre Przywara

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.

Quoted 20 lines

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 at googlegroups.com. To view this discussion on the web, visit https://groups.google.com/d/msgid/linux-sunxi/20190516004609.25304-1-andre.przywara%40arm.com.
For more options, visit https://groups.google.com/d/optout.

#6 lore raw

cover sunxi: A64: enable first USB port on Pine64 boards

Quoted 8 lines · Vasily Khoruzhick
Quoted 7 lines · Andre Przywara

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.

Quoted 6 lines
Quoted 4 lines

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.

Quoted 18 lines
Quoted 18 lines

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 at googlegroups.com. To view this discussion on the web, visit https://groups.google.com/d/msgid/linux-sunxi/20190516004609.25304-1-andre.przywara%40arm.com.
For more options, visit https://groups.google.com/d/optout.

#7 lore raw

cover sunxi: A64: enable first USB port on Pine64 boards

Quoted 16 lines · André Przywara
Quoted 8 lines · Vasily Khoruzhick
Quoted 7 lines · Andre Przywara

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.

Quoted 6 lines
Quoted 4 lines

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.

Quoted 7 lines

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.

Quoted 19 lines
Quoted 18 lines
Quoted 18 lines

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 at googlegroups.com. To view this discussion on the web, visit https://groups.google.com/d/msgid/linux-sunxi/20190516004609.25304-1-andre.przywara%40arm.com.
For more options, visit https://groups.google.com/d/optout.