Skip to contentSkip to conversation

usb: dwc-meson-g12a: Add support for USB on S400 board

PATCH Superseded Neil Armstrong 4 participants 16 messages Sep 9, 2020 – Sep 16, 2020

Subsystems (5)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#1 lore raw

PATCH 1/5 phy: amlogic: phy-meson-gxl-usb2: keep ID pull-up even in Host mode

In reply to Neil Armstrong

In order to keep OTG ID detection even when in Host mode, the ID line of the PHY (if the current phy is an OTG one) pull-up should be kept enable in both modes.

This fixes OTG switch on GXL, GXM & AXG platforms, otherwise once switched to Host, the ID detection doesn't work anymore to switch back to Device.

---
 drivers/phy/amlogic/phy-meson-gxl-usb2.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/phy/amlogic/phy-meson-gxl-usb2.c +2 -1
index 43ec9bf24abf..6e862ea60d8f 100644
@@ -158,7 +158,8 @@ static int phy_meson_gxl_usb2_set_mode(struct phy *phy,
 				   U2P_R0_DM_PULLDOWN);
 		regmap_update_bits(priv->regmap, U2P_R0, U2P_R0_DP_PULLDOWN,
 				   U2P_R0_DP_PULLDOWN);
-		regmap_update_bits(priv->regmap, U2P_R0, U2P_R0_ID_PULLUP, 0);
+		regmap_update_bits(priv->regmap, U2P_R0, U2P_R0_ID_PULLUP,
+				   U2P_R0_ID_PULLUP);
 		break;
 
 	case PHY_MODE_USB_DEVICE:
Signature · 7 lines
2.22.0


_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
#0 lore raw

cover usb: dwc-meson-g12a: Add support for USB on S400 board

The Amlogic AXG is close from the GXL Glue but with a single OTG PHY.

It needs the same init sequence as GXL & GXM, but it seems it doesn't need the host disconnect bit.

The Glue driver reuses the already implemented GXL & GXM work.

The USB2 PHY driver needs a slight tweak to keep the OTG detection working.

Neil Armstrong (5):
phy: amlogic: phy-meson-gxl-usb2: keep ID pull-up even in Host mode
dt-bindings: usb: amlogic,meson-g12a-usb-ctrl: add the Amlogic AXG
Families USB Glue Bindings
usb: dwc-meson-g12a: Add support for USB on AXG SoCs
arm64: dts: meson-axg: add USB nodes
arm64: dts: meson-axg-s400: enable USB OTG

 .../usb/amlogic,meson-g12a-usb-ctrl.yaml      | 22 +++++++-
 .../arm64/boot/dts/amlogic/meson-axg-s400.dts | 10 ++++
 arch/arm64/boot/dts/amlogic/meson-axg.dtsi    | 51 +++++++++++++++++++
 drivers/phy/amlogic/phy-meson-gxl-usb2.c      |  3 +-
 drivers/usb/dwc3/dwc3-meson-g12a.c            | 17 +++++++
 5 files changed, 101 insertions(+), 2 deletions(-)
Signature · 7 lines
2.22.0


_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
#3 lore raw

PATCH 2/5 dt-bindings: usb: amlogic,meson-g12a-usb-ctrl: add the Amlogic AXG Families USB Glue Bindings

The Amlogic AXG is close from the GXL Glue but with a single OTG PHY.

---
 .../usb/amlogic,meson-g12a-usb-ctrl.yaml      | 22 ++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/usb/amlogic,meson-g12a-usb-ctrl.yaml +21 -1
index 5b04a7dfa018..c0058332b967 100644
@@ -25,13 +25,14 @@ description: |
   The Amlogic A1 embeds a DWC3 USB IP Core configured for USB2 in
   host-only mode.
 
-  The Amlogic GXL & GXM SoCs doesn't embed an USB3 PHY.
+  The Amlogic GXL, GXM & AXG SoCs doesn't embed an USB3 PHY.
 
 properties:
   compatible:
     enum:
       - amlogic,meson-gxl-usb-ctrl
       - amlogic,meson-gxm-usb-ctrl
+      - amlogic,meson-axg-usb-ctrl
       - amlogic,meson-g12a-usb-ctrl
       - amlogic,meson-a1-usb-ctrl
 
@@ -151,6 +152,25 @@ allOf:
 
       required:
         - clock-names
+  - if:
+      properties:
+        compatible:
+          enum:
+            - amlogic,meson-axg-usb-ctrl
+
+    then:
+      properties:
+        phy-names:
+          items:
+            - const: usb2-phy1 # USB2 PHY1 if USBOTG_B port is used
+        clocks:
+          minItems: 2
+        clock-names:
+          items:
+            - const: usb_ctrl
+            - const: ddr
+      required:
+        - clock-names
   - if:
       properties:
         compatible:
Signature · 7 lines
2.22.0


_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
#6 lore raw

PATCH 3/5 usb: dwc-meson-g12a: Add support for USB on AXG SoCs

In reply to Neil Armstrong

The Amlogic AXG is close from the GXL Glue but with a single OTG PHY.

It needs the same init sequence as GXL & GXM, but it seems it doesn't need the host disconnect bit.

---
 drivers/usb/dwc3/dwc3-meson-g12a.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/usb/dwc3/dwc3-meson-g12a.c +17 -0
index 1f7f4d88ed9d..90275c13c224 100644
@@ -215,6 +215,19 @@ static struct dwc3_meson_g12a_drvdata gxm_drvdata = {
 	.usb_post_init = dwc3_meson_gxl_usb_post_init,
 };
 
+static struct dwc3_meson_g12a_drvdata axg_drvdata = {
+	.otg_switch_supported = true,
+	.clks = meson_gxl_clocks,
+	.num_clks = ARRAY_SIZE(meson_gxl_clocks),
+	.phy_names = meson_a1_phy_names,
+	.num_phys = ARRAY_SIZE(meson_a1_phy_names),
+	.setup_regmaps = dwc3_meson_gxl_setup_regmaps,
+	.usb2_init_phy = dwc3_meson_gxl_usb2_init_phy,
+	.set_phy_mode = dwc3_meson_gxl_set_phy_mode,
+	.usb_init = dwc3_meson_g12a_usb_init,
+	.usb_post_init = dwc3_meson_gxl_usb_post_init,
+};
+
 static struct dwc3_meson_g12a_drvdata g12a_drvdata = {
 	.otg_switch_supported = true,
 	.clks = meson_g12a_clocks,
@@ -930,6 +943,10 @@ static const struct of_device_id dwc3_meson_g12a_match[] = {
 		.compatible = "amlogic,meson-gxm-usb-ctrl",
 		.data = &gxm_drvdata,
 	},
+	{
+		.compatible = "amlogic,meson-axg-usb-ctrl",
+		.data = &axg_drvdata,
+	},
 	{
 		.compatible = "amlogic,meson-g12a-usb-ctrl",
 		.data = &g12a_drvdata,
Signature · 7 lines
2.22.0


_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
#9 lore raw

PATCH 4/5 arm64: dts: meson-axg: add USB nodes

In reply to Neil Armstrong

This adds the USB Glue node, with the USB2 & USB3 controllers along the single USB2 PHY node.

---
 arch/arm64/boot/dts/amlogic/meson-axg.dtsi | 51 ++++++++++++++++++++++
 1 file changed, 51 insertions(+)
arch/arm64/boot/dts/amlogic/meson-axg.dtsi +51 -0
index 9ae6db16b8e6..0b68a383b60f 100644
@@ -171,6 +171,46 @@
 		#size-cells = <2>;
 		ranges;
 
+		usb: usb@ffe09080 {
+			compatible = "amlogic,meson-axg-usb-ctrl";
+			reg = <0x0 0xffe09080 0x0 0x20>;
+			interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
+			#address-cells = <2>;
+			#size-cells = <2>;
+			ranges;
+
+			clocks = <&clkc CLKID_USB>, <&clkc CLKID_USB1_DDR_BRIDGE>;
+			clock-names = "usb_ctrl", "ddr";
+			resets = <&reset RESET_USB_OTG>;
+
+			dr_mode = "otg";
+
+			phys = <&usb2_phy1>;
+			phy-names = "usb2-phy1";
+
+			dwc2: usb@ff400000 {
+				compatible = "amlogic,meson-g12a-usb", "snps,dwc2";
+				reg = <0x0 0xff400000 0x0 0x40000>;
+				interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&clkc CLKID_USB1>;
+				clock-names = "otg";
+				phys = <&usb2_phy1>;
+				dr_mode = "peripheral";
+				g-rx-fifo-size = <192>;
+				g-np-tx-fifo-size = <128>;
+				g-tx-fifo-size = <128 128 16 16 16>;
+			};
+
+			dwc3: usb@ff500000 {
+				compatible = "snps,dwc3";
+				reg = <0x0 0xff500000 0x0 0x100000>;
+				interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>;
+				dr_mode = "host";
+				maximum-speed = "high-speed";
+				snps,dis_u2_susphy_quirk;
+			};
+		};
+
 		ethmac: ethernet@ff3f0000 {
 			compatible = "amlogic,meson-axg-dwmac",
 				     "snps,dwmac-3.70a",
@@ -1734,6 +1774,17 @@
 				clock-names = "core", "clkin0", "clkin1";
 				resets = <&reset RESET_SD_EMMC_C>;
 			};
+
+			usb2_phy1: phy@9020 {
+				compatible = "amlogic,meson-gxl-usb2-phy";
+				#phy-cells = <0>;
+				reg = <0x0 0x9020 0x0 0x20>;
+				clocks = <&clkc CLKID_USB>;
+				clock-names = "phy";
+				resets = <&reset RESET_USB_OTG>;
+				reset-names = "phy";
+				status = "okay";
+			};
 		};
 
 		sram: sram@fffc0000 {
Signature · 7 lines
2.22.0


_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
#12 lore raw

PATCH 5/5 arm64: dts: meson-axg-s400: enable USB OTG

In reply to Neil Armstrong

This enables USB OTG on the S400 board.

---
 arch/arm64/boot/dts/amlogic/meson-axg-s400.dts | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm64/boot/dts/amlogic/meson-axg-s400.dts +10 -0
index cb1360ae1211..5f131debcbad 100644
@@ -584,3 +584,13 @@
 	pinctrl-0 = <&uart_ao_a_pins>;
 	pinctrl-names = "default";
 };
+
+&usb {
+	status = "okay";
+	dr_mode = "otg";
+	vbus-supply = <&usb_pwr>;
+};
+
+&usb2_phy1 {
+	phy-supply = <&vcc_5v>;
+};
Signature · 7 lines
2.22.0


_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
maintainer Reviewed-by on the v1 series
#15 lore raw
In reply to Neil Armstrong
Quoted 1 line · Neil Armstrong

The Amlogic AXG is close from the GXL Glue but with a single OTG PHY.

minor grammar nit: s/close from/close to/ (also in patches 2 & 3). Otherwise..

Kevin

Quoted 24 lines

It needs the same init sequence as GXL & GXM, but it seems it doesn't need the host disconnect bit.

The Glue driver reuses the already implemented GXL & GXM work.

The USB2 PHY driver needs a slight tweak to keep the OTG detection working.

Neil Armstrong (5):
phy: amlogic: phy-meson-gxl-usb2: keep ID pull-up even in Host mode
dt-bindings: usb: amlogic,meson-g12a-usb-ctrl: add the Amlogic AXG
Families USB Glue Bindings
usb: dwc-meson-g12a: Add support for USB on AXG SoCs
arm64: dts: meson-axg: add USB nodes
arm64: dts: meson-axg-s400: enable USB OTG

 .../usb/amlogic,meson-g12a-usb-ctrl.yaml      | 22 +++++++-
 .../arm64/boot/dts/amlogic/meson-axg-s400.dts | 10 ++++
 arch/arm64/boot/dts/amlogic/meson-axg.dtsi    | 51 +++++++++++++++++++
 drivers/phy/amlogic/phy-meson-gxl-usb2.c      |  3 +-
 drivers/usb/dwc3/dwc3-meson-g12a.c            | 17 +++++++
 5 files changed, 101 insertions(+), 2 deletions(-)
Signature · 1 line
2.22.0
maintainer Reviewed-by on v1 2/5
#4 lore raw

Re: [PATCH 2/5] dt-bindings: usb: amlogic, meson-g12a-usb-ctrl: add the Amlogic AXG Families USB Glue Bindings

In reply to Neil Armstrong
Quoted 7 lines · Neil Armstrong

The Amlogic AXG is close from the GXL Glue but with a single OTG PHY.

---
 .../usb/amlogic,meson-g12a-usb-ctrl.yaml      | 22 ++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

reviewer Reviewed-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] phy: amlogic: phy-meson-gxl-usb2: keep ID pull-up even in Host mode

In reply to Neil Armstrong
Quoted 9 lines · Neil Armstrong

In order to keep OTG ID detection even when in Host mode, the ID line of the PHY (if the current phy is an OTG one) pull-up should be kept enable in both modes.

This fixes OTG switch on GXL, GXM & AXG platforms, otherwise once switched to Host, the ID detection doesn't work anymore to switch back to Device.

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

reviewer Acked-by on v1 2/5
#5 lore raw

Re: [PATCH 2/5] dt-bindings: usb: amlogic,meson-g12a-usb-ctrl: add the Amlogic AXG Families USB Glue Bindings

In reply to Neil Armstrong

Hi Neil

Quoted 2 lines · Neil Armstrong

The Amlogic AXG is close from the GXL Glue but with a single OTG PHY.

nit-pick: I think this should be "close to"

Quoted 1 line
Quoted 9 lines
---
 .../usb/amlogic,meson-g12a-usb-ctrl.yaml      | 22 ++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/usb/amlogic,meson-g12a-usb-ctrl.yaml +0 -0
index 5b04a7dfa018..c0058332b967 100644

Documentation/devicetree/bindings/usb/amlogic,meson-g12a-usb-ctrl.yaml description: | · line 28

Quoted 5 lines
Documentation/devicetree/bindings/usb/amlogic,meson-g12a-usb-ctrl.yaml +1 -1
@@ -25,13 +25,14 @@ description: |
   The Amlogic A1 embeds a DWC3 USB IP Core configured for USB2 in
   host-only mode.
 
-  The Amlogic GXL & GXM SoCs doesn't embed an USB3 PHY.
+  The Amlogic GXL, GXM & AXG SoCs doesn't embed an USB3 PHY.

nit-pick: not sure if we need to fix it here: s/doesn't/don't/ (personally I would also put AXG first - in reality it changes nothing though)

Best regards,
Martin

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

#7 lore raw

Re: [PATCH 3/5] usb: dwc-meson-g12a: Add support for USB on AXG SoCs

In reply to Neil Armstrong

Hi Neil,

Quoted 2 lines · Neil Armstrong

The Amlogic AXG is close from the GXL Glue but with a single OTG PHY.

s/close from/close to/

[...]

drivers/usb/dwc3/dwc3-meson-g12a.c static struct dwc3_meson_g12a_drvdata gxm_drvdata = { · line 223

Quoted 6 lines
drivers/usb/dwc3/dwc3-meson-g12a.c +6 -0
+static struct dwc3_meson_g12a_drvdata axg_drvdata = {
+       .otg_switch_supported = true,
+       .clks = meson_gxl_clocks,
+       .num_clks = ARRAY_SIZE(meson_gxl_clocks),
+       .phy_names = meson_a1_phy_names,
+       .num_phys = ARRAY_SIZE(meson_a1_phy_names),

I wonder if we should also update the comment for meson_a1_phy_names to understand that part I had to go back to the dt-bindings patch

Best regards,
Martin

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

reviewer Reviewed-by on v1 4/5
#10 lore raw

Re: [PATCH 4/5] arm64: dts: meson-axg: add USB nodes

In reply to Neil Armstrong

Hi Neil,

Quoted 5 lines · Neil Armstrong

This adds the USB Glue node, with the USB2 & USB3 controllers along the single USB2 PHY node.

[...]

arch/arm64/boot/dts/amlogic/meson-axg.dtsi line 1786

Quoted 9 lines
arch/arm64/boot/dts/amlogic/meson-axg.dtsi +9 -0
+                       usb2_phy1: phy@9020 {
+                               compatible = "amlogic,meson-gxl-usb2-phy";
+                               #phy-cells = <0>;
+                               reg = <0x0 0x9020 0x0 0x20>;
+                               clocks = <&clkc CLKID_USB>;
+                               clock-names = "phy";
+                               resets = <&reset RESET_USB_OTG>;
+                               reset-names = "phy";
+                               status = "okay";

if you have to re-send this for some reason: status = "okay" is the default and so I think we can omit this

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

#13 lore raw

Re: [PATCH 5/5] arm64: dts: meson-axg-s400: enable USB OTG

In reply to Neil Armstrong

Hi Neil,

On Wed, Sep 9, 2020 at 6:05 PM Neil Armstrong <[email protected]> wrote:
[...]

arch/arm64/boot/dts/amlogic/meson-axg-s400.dts line 595

Quoted 8 lines

+&usb {

arch/arm64/boot/dts/amlogic/meson-axg-s400.dts +7 -0
+       status = "okay";
+       dr_mode = "otg";
+       vbus-supply = <&usb_pwr>;
+};
+
+&usb2_phy1 {
+       phy-supply = <&vcc_5v>;

out of curiosity: why do we need this phy-supply here? isn't the usb_pwr regulator as vbus-supply above enough?

Best regards,
Martin

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

#14 lore raw

Re: [PATCH 5/5] arm64: dts: meson-axg-s400: enable USB OTG

Quoted 4 lines · Martin Blumenstingl

Hi Neil,

On Wed, Sep 9, 2020 at 6:05 PM Neil Armstrong <[email protected]> wrote:
[...]

Quoted 10 lines

arch/arm64/boot/dts/amlogic/meson-axg-s400.dts line 595

Quoted 8 lines

+&usb {

arch/arm64/boot/dts/amlogic/meson-axg-s400.dts +7 -0
+       status = "okay";
+       dr_mode = "otg";
+       vbus-supply = <&usb_pwr>;
+};
+
+&usb2_phy1 {
+       phy-supply = <&vcc_5v>;

out of curiosity: why do we need this phy-supply here? isn't the usb_pwr regulator as vbus-supply above enough?

Damn you're right !
Thanks for noticing.

Neil

Quoted 5 lines

Best regards,
Martin

#11 lore raw

Re: [PATCH 4/5] arm64: dts: meson-axg: add USB nodes

In reply to Martin Blumenstingl
Quoted 20 lines · Martin Blumenstingl

Hi Neil,

Quoted 5 lines · Neil Armstrong

This adds the USB Glue node, with the USB2 & USB3 controllers along the single USB2 PHY node.

[...]

arch/arm64/boot/dts/amlogic/meson-axg.dtsi line 1786

Quoted 9 lines
arch/arm64/boot/dts/amlogic/meson-axg.dtsi +9 -0
+                       usb2_phy1: phy@9020 {
+                               compatible = "amlogic,meson-gxl-usb2-phy";
+                               #phy-cells = <0>;
+                               reg = <0x0 0x9020 0x0 0x20>;
+                               clocks = <&clkc CLKID_USB>;
+                               clock-names = "phy";
+                               resets = <&reset RESET_USB_OTG>;
+                               reset-names = "phy";
+                               status = "okay";
Quoted 3 lines

if you have to re-send this for some reason: status = "okay" is the default and so I think we can omit this

Ok, will removed in v2

Thanks,
Neil

#8 lore raw

Re: [PATCH 3/5] usb: dwc-meson-g12a: Add support for USB on AXG SoCs

In reply to Martin Blumenstingl
Quoted 8 lines · Martin Blumenstingl

Hi Neil,

Quoted 2 lines · Neil Armstrong

The Amlogic AXG is close from the GXL Glue but with a single OTG PHY.

s/close from/close to/

[...]

Quoted 8 lines

drivers/usb/dwc3/dwc3-meson-g12a.c static struct dwc3_meson_g12a_drvdata gxm_drvdata = { · line 223

Quoted 6 lines
drivers/usb/dwc3/dwc3-meson-g12a.c +6 -0
+static struct dwc3_meson_g12a_drvdata axg_drvdata = {
+       .otg_switch_supported = true,
+       .clks = meson_gxl_clocks,
+       .num_clks = ARRAY_SIZE(meson_gxl_clocks),
+       .phy_names = meson_a1_phy_names,
+       .num_phys = ARRAY_SIZE(meson_a1_phy_names),

I wonder if we should also update the comment for meson_a1_phy_names to understand that part I had to go back to the dt-bindings patch

Sure,

Thanks,
Neil

Quoted 5 lines

Best regards,
Martin