All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/3] phy-sun4i-usb: Fix sun8i_r40_cfg
@ 2021-07-05  3:31 qianfanguijin
  2021-07-05  3:31 ` [PATCH v3 2/3] ARM: dts: sun8i: r40: Add usb_otg device node qianfanguijin
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: qianfanguijin @ 2021-07-05  3:31 UTC (permalink / raw)
  To: linux-sunxi; +Cc: mripard, wens, jernej.skrabec, andre.przywara, qianfan Zhao

From: qianfan Zhao <qianfanguijin@163.com>

the r40 has the same configurations with a33, disable enable_pmu_unk1 and
phy0_dual_route feature.

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
---
 drivers/phy/allwinner/phy-sun4i-usb.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c
index 788dd5cdbb7d..8c4136e72947 100644
--- a/drivers/phy/allwinner/phy-sun4i-usb.c
+++ b/drivers/phy/allwinner/phy-sun4i-usb.c
@@ -935,8 +935,6 @@ static const struct sun4i_usb_phy_cfg sun8i_r40_cfg = {
 	.disc_thresh = 3,
 	.phyctl_offset = REG_PHYCTL_A33,
 	.dedicated_clocks = true,
-	.enable_pmu_unk1 = true,
-	.phy0_dual_route = true,
 };
 
 static const struct sun4i_usb_phy_cfg sun8i_v3s_cfg = {
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v3 2/3] ARM: dts: sun8i: r40: Add usb_otg device node
  2021-07-05  3:31 [PATCH v3 1/3] phy-sun4i-usb: Fix sun8i_r40_cfg qianfanguijin
@ 2021-07-05  3:31 ` qianfanguijin
  2021-07-05  3:31 ` [PATCH v3 3/3] ARM: dts: sun8i: r40: bananapi-m2-ultra: Enable usb_otg qianfanguijin
  2021-07-10 17:06 ` [PATCH v3 1/3] phy-sun4i-usb: Fix sun8i_r40_cfg Evgeny Boger
  2 siblings, 0 replies; 4+ messages in thread
From: qianfanguijin @ 2021-07-05  3:31 UTC (permalink / raw)
  To: linux-sunxi; +Cc: mripard, wens, jernej.skrabec, andre.przywara, qianfan Zhao

From: qianfan Zhao <qianfanguijin@163.com>

R40's usb otg is compatibled with H3.

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
---
 arch/arm/boot/dts/sun8i-r40.dtsi | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-r40.dtsi b/arch/arm/boot/dts/sun8i-r40.dtsi
index d5ad3b9efd12..f30873ac3073 100644
--- a/arch/arm/boot/dts/sun8i-r40.dtsi
+++ b/arch/arm/boot/dts/sun8i-r40.dtsi
@@ -363,6 +363,21 @@
 			#size-cells = <0>;
 		};
 
+		usb_otg: usb@1c13000 {
+			compatible = "allwinner,sun8i-r40-musb",
+				     "allwinner,sun8i-h3-musb";
+			reg = <0x01c13000 0x0400>;
+			clocks = <&ccu CLK_BUS_OTG>;
+			resets = <&ccu RST_BUS_OTG>;
+			interrupts = <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "mc";
+			phys = <&usbphy 0>;
+			phy-names = "usb";
+			extcon = <&usbphy 0>;
+			dr_mode = "otg";
+			status = "disabled";
+		};
+
 		usbphy: phy@1c13400 {
 			compatible = "allwinner,sun8i-r40-usb-phy";
 			reg = <0x01c13400 0x14>,
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v3 3/3] ARM: dts: sun8i: r40: bananapi-m2-ultra: Enable usb_otg
  2021-07-05  3:31 [PATCH v3 1/3] phy-sun4i-usb: Fix sun8i_r40_cfg qianfanguijin
  2021-07-05  3:31 ` [PATCH v3 2/3] ARM: dts: sun8i: r40: Add usb_otg device node qianfanguijin
@ 2021-07-05  3:31 ` qianfanguijin
  2021-07-10 17:06 ` [PATCH v3 1/3] phy-sun4i-usb: Fix sun8i_r40_cfg Evgeny Boger
  2 siblings, 0 replies; 4+ messages in thread
From: qianfanguijin @ 2021-07-05  3:31 UTC (permalink / raw)
  To: linux-sunxi; +Cc: mripard, wens, jernej.skrabec, andre.przywara, qianfan Zhao

From: qianfan Zhao <qianfanguijin@163.com>

Enable it.

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
---
 .../boot/dts/sun8i-r40-bananapi-m2-ultra.dts  | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts b/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts
index a6a1087a0c9b..23b054665b9a 100644
--- a/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts
+++ b/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts
@@ -43,6 +43,7 @@
 
 /dts-v1/;
 #include "sun8i-r40.dtsi"
+#include "sunxi-common-regulators.dtsi"
 
 #include <dt-bindings/gpio/gpio.h>
 
@@ -159,6 +160,7 @@
 		reg = <0x34>;
 		interrupt-parent = <&nmi_intc>;
 		interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
+		x-powers,drive-vbus-en;
 	};
 };
 
@@ -293,6 +295,11 @@
 	regulator-name = "vdd2v5-sata";
 };
 
+&reg_drivevbus {
+	regulator-name = "usb0-vbus";
+	status = "okay";
+};
+
 &reg_eldo3 {
 	regulator-min-microvolt = <1200000>;
 	regulator-max-microvolt = <1200000>;
@@ -328,7 +335,20 @@
 	};
 };
 
+&usb_otg {
+	dr_mode = "otg";
+	status = "okay";
+};
+
+&usb_power_supply {
+	status = "okay";
+};
+
 &usbphy {
+	usb0_id_det-gpios = <&pio 8 4 GPIO_ACTIVE_HIGH>; /* PI4 */
+	usb0_vbus_det-gpios = <&pio 8 8 GPIO_ACTIVE_HIGH>; /* PI8 */
+	usb0_vbus_power-supply = <&usb_power_supply>;
+	usb0_vbus-supply = <&reg_drivevbus>;
 	usb1_vbus-supply = <&reg_vcc5v0>;
 	usb2_vbus-supply = <&reg_vcc5v0>;
 	status = "okay";
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 1/3] phy-sun4i-usb: Fix sun8i_r40_cfg
  2021-07-05  3:31 [PATCH v3 1/3] phy-sun4i-usb: Fix sun8i_r40_cfg qianfanguijin
  2021-07-05  3:31 ` [PATCH v3 2/3] ARM: dts: sun8i: r40: Add usb_otg device node qianfanguijin
  2021-07-05  3:31 ` [PATCH v3 3/3] ARM: dts: sun8i: r40: bananapi-m2-ultra: Enable usb_otg qianfanguijin
@ 2021-07-10 17:06 ` Evgeny Boger
  2 siblings, 0 replies; 4+ messages in thread
From: Evgeny Boger @ 2021-07-10 17:06 UTC (permalink / raw)
  To: qianfanguijin
  Cc: andre.przywara, jernej.skrabec, linux-sunxi, mripard, wens,
	Icenowy Zheng

Hi,

I don't think that's the case.

According to my tests on custom Allwinner A40i board, the USB0 PHY works 
exactly as expected from its current configuration.

I.e. there are working ehci0/ohci0 at 1c14000/1c14400, which are working 
only if USB0 PHY is routed to EHCI/OHCI. In turn, musb stops working if 
we route USB0 to EHCI/OHCI.

Also, .enable_pmu_unk1 is needed as well.

So, the real issue here is that our current usb phy driver expects 
_both_ usbotg and ehci0+ohci0 nodes to be present and enabled so 
.phy0_dual_route works properly [1]. Attached please find the dtsi patch.

By the way, don't we need to improve PHY dual route handling?

I think the current behaviour is quite confusing. As one can see, USB on 
affected Allwinner SoCs doesn't work properly if only musb is enabled, 
as PHY is routed to non-initialized EHCI/OHCI. Surprisingly, USB won't 
also work if only ehci0/ohci0 are enabled, as usb phy is not referenced 
in ehci0/ohci0 nodes and thus won't be properly initialized. Musb's host 
controller is also exposed to the system, although it's never really 
used. I'm also afraid that current behaviour messes up with OTG dual 
role state machine, which is rarely used nowadays, but still.


[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3ecc25e12f0e210d56fcca110a8144e50db05905

diff --git a/arch/arm/boot/dts/sun8i-r40.dtsi 
b/arch/arm/boot/dts/sun8i-r40.dtsi
index d5ad3b9efd12..98f598805867 100644
--- a/arch/arm/boot/dts/sun8i-r40.dtsi
+++ b/arch/arm/boot/dts/sun8i-r40.dtsi
@@ -363,6 +363,20 @@ mmc3: mmc@1c12000 {
                         #size-cells = <0>;
                 };

+               usb_otg: usb@1c13000 {
+                       compatible = "allwinner,sun8i-h3-musb";
+                       reg = <0x01c13000 0x0400>;
+                       clocks = <&ccu CLK_BUS_OTG>;
+                       resets = <&ccu RST_BUS_OTG>;
+                       interrupts = <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "mc";
+                       phys = <&usbphy 0>;
+                       phy-names = "usb";
+                       extcon = <&usbphy 0>;
+                       dr_mode = "otg";
+                       status = "disabled";
+               };
+
                 usbphy: phy@1c13400 {
                         compatible = "allwinner,sun8i-r40-usb-phy";
                         reg = <0x01c13400 0x14>,
@@ -421,6 +435,25 @@ ahci: sata@1c18000 {
                         status = "disabled";
                 };

+               ehci0: usb@1c14000 {
+                       compatible = "allwinner,sun8i-r40-ehci", 
"generic-ehci";
+                       reg = <0x01c14000 0x100>;
+                       interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&ccu CLK_BUS_EHCI0>;
+                       resets = <&ccu RST_BUS_EHCI0>;
+                       status = "disabled";
+               };
+
+               ohci0: usb@1c14400 {
+                       compatible = "allwinner,sun8i-r40-ohci", 
"generic-ohci";
+                       reg = <0x01c14400 0x100>;
+                       interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&ccu CLK_BUS_OHCI0>,
+                                        <&ccu CLK_USB_OHCI0>;
+                       resets = <&ccu RST_BUS_OHCI0>;
+                       status = "disabled";
+               };
+
                 ehci1: usb@1c19000 {
                         compatible = "allwinner,sun8i-r40-ehci", 
"generic-ehci";
                         reg = <0x01c19000 0x100>;


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-10 17:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-05  3:31 [PATCH v3 1/3] phy-sun4i-usb: Fix sun8i_r40_cfg qianfanguijin
2021-07-05  3:31 ` [PATCH v3 2/3] ARM: dts: sun8i: r40: Add usb_otg device node qianfanguijin
2021-07-05  3:31 ` [PATCH v3 3/3] ARM: dts: sun8i: r40: bananapi-m2-ultra: Enable usb_otg qianfanguijin
2021-07-10 17:06 ` [PATCH v3 1/3] phy-sun4i-usb: Fix sun8i_r40_cfg Evgeny Boger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.