Skip to contentSkip to conversation

Add USB 3 support for H6 and Orange Pi 3

PATCH New Ondrej Jirman 1 participant 5 messages Oct 29, 2019

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

v3 cover Add USB 3 support for H6 and Orange Pi 3

This series implements USB 3 support for Xunlong Orange Pi 3 board.

This is a re-hash of the Icenowy's earlier USB3 work[1] without code that caused controversy previously. Orange Pi 3 board doesn't need vbus supply to be dynamically enabled, so that code is not needed to support USB3 on this board.

Most of patches are already reviewed. I've converted dt-bindings to yaml format, and added the Orange Pi 3 board modifications.

Hopefully with this series we can get USB3 support into mainline for Orange Pi 3, and build on it later to support more boards, where supporting them is more complicated.

Please take a look.

thank you and regards,
Ondrej Jirman

[1] https://lore.kernel.org/patchwork/patch/1058919/

Changes in v3:
- Added DT reviewed-by tag
- more sun50i / H6 name clarifications (Kconfig, ...)
- dropped USB_COMMON and linux/usb/of.h

Changes in v2:
- Added Maxime's Acked-By's
- Fixed title of DT bindings file

Changes since Icenowy v5 series:
- use earlier patches that did not include VBUS regulator/connector code
- converted dt bindings to yaml
- added patch to enable usb3 on Orange Pi 3

Icenowy Zheng (2):
phy: allwinner: add phy driver for USB3 PHY on Allwinner H6 SoC
arm64: dts: allwinner: h6: add USB3 device nodes

Ondrej Jirman (2):
dt-bindings: Add bindings for USB3 phy on Allwinner H6
arm64: dts: allwinner: orange-pi-3: Enable USB 3.0 host support

 .../phy/allwinner,sun50i-h6-usb3-phy.yaml     |  47 +++++
 .../dts/allwinner/sun50i-h6-orangepi-3.dts    |   8 +
 arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi  |  32 +++
 drivers/phy/allwinner/Kconfig                 |  11 +
 drivers/phy/allwinner/Makefile                |   1 +
 drivers/phy/allwinner/phy-sun50i-usb3.c       | 190 ++++++++++++++++++
 6 files changed, 289 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/allwinner,sun50i-h6-usb3-phy.yaml
 create mode 100644 drivers/phy/allwinner/phy-sun50i-usb3.c
Signature · 1 line
2.23.0
#1 lore raw

PATCH v3 1/4 dt-bindings: Add bindings for USB3 phy on Allwinner H6

The new Allwinner H6 SoC contains a USB3 PHY that is wired to the external USB3 pins of the SoC.

Add a device tree binding for the PHY.

---
 .../phy/allwinner,sun50i-h6-usb3-phy.yaml     | 47 +++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/allwinner,sun50i-h6-usb3-phy.yaml
Documentation/devicetree/bindings/phy/allwinner,sun50i-h6-usb3-phy.yaml new file +47 -0
new file mode 100644
index 000000000000..e5922b427342
@@ -0,0 +1,47 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2019 Ondrej Jirman <[email protected]>
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/phy/allwinner,sun50i-h6-usb3-phy.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Allwinner H6 USB3 PHY
+
+maintainers:
+  - Ondrej Jirman <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - allwinner,sun50i-h6-usb3-phy
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  resets:
+    maxItems: 1
+
+  "#phy-cells":
+    const: 0
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - resets
+  - "#phy-cells"
+
+examples:
+  - |
+    #include <dt-bindings/clock/sun50i-h6-ccu.h>
+    #include <dt-bindings/reset/sun50i-h6-ccu.h>
+    phy@5210000 {
+          compatible = "allwinner,sun50i-h6-usb3-phy";
+          reg = <0x5210000 0x10000>;
+          clocks = <&ccu CLK_USB_PHY1>;
+          resets = <&ccu RST_USB_PHY1>;
+          #phy-cells = <0>;
+    };
Signature · 1 line
2.23.0
#3 lore raw

PATCH v3 3/4 arm64: dts: allwinner: h6: add USB3 device nodes

In reply to Ondrej Jirman

From: Icenowy Zheng <[email protected]>

Allwinner H6 SoC features USB3 functionality, with a DWC3 controller and a custom PHY.

Add device tree nodes for them.

---
 arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 32 ++++++++++++++++++++
 1 file changed, 32 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi +32 -0
index 5d7ab540b950..9dbe63bf5a77 100644
@@ -547,6 +547,38 @@
 			status = "disabled";
 		};
 
+		dwc3: dwc3@5200000 {
+			compatible = "snps,dwc3";
+			reg = <0x05200000 0x10000>;
+			interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&ccu CLK_BUS_XHCI>,
+				 <&ccu CLK_BUS_XHCI>,
+				 <&rtc 0>;
+			clock-names = "ref", "bus_early", "suspend";
+			resets = <&ccu RST_BUS_XHCI>;
+			/*
+			 * The datasheet of the chip doesn't declare the
+			 * peripheral function, and there's no boards known
+			 * to have a USB Type-B port routed to the port.
+			 * In addition, no one has tested the peripheral
+			 * function yet.
+			 * So set the dr_mode to "host" in the DTSI file.
+			 */
+			dr_mode = "host";
+			phys = <&usb3phy>;
+			phy-names = "usb3-phy";
+			status = "disabled";
+		};
+
+		usb3phy: phy@5210000 {
+			compatible = "allwinner,sun50i-h6-usb3-phy";
+			reg = <0x5210000 0x10000>;
+			clocks = <&ccu CLK_USB_PHY1>;
+			resets = <&ccu RST_USB_PHY1>;
+			#phy-cells = <0>;
+			status = "disabled";
+		};
+
 		ehci3: usb@5311000 {
 			compatible = "allwinner,sun50i-h6-ehci", "generic-ehci";
 			reg = <0x05311000 0x100>;
Signature · 1 line
2.23.0
#4 lore raw

PATCH v3 4/4 arm64: dts: allwinner: orange-pi-3: Enable USB 3.0 host support

In reply to Ondrej Jirman

Enable Allwinner's USB 3.0 phy and the host controller. Orange Pi 3 board has GL3510 USB 3.0 4-port hub connected to the SoC's USB 3.0 port. All four ports are exposed via USB3-A connectors. VBUS is always on, since it's powered directly from DCIN (VCC-5V) and not switchable.

---
 arch/arm64/boot/dts/allwinner/sun50i-h6-orangepi-3.dts | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-h6-orangepi-3.dts +8 -0
index 2557cc6c8d50..32800204c22a 100644
@@ -95,6 +95,10 @@
 	status = "okay";
 };
 
+&dwc3 {
+	status = "okay";
+};
+
 &ehci0 {
 	status = "okay";
 };
@@ -304,3 +308,7 @@
 	usb3_vbus-supply = <&reg_vcc5v>;
 	status = "okay";
 };
+
+&usb3phy {
+	status = "okay";
+};
Signature · 1 line
2.23.0
#2 lore raw

PATCH v3 2/4 phy: allwinner: add phy driver for USB3 PHY on Allwinner H6 SoC

In reply to Ondrej Jirman

From: Icenowy Zheng <[email protected]>

Allwinner H6 SoC contains a USB3 PHY (with USB2 DP/DM lines also controlled).

Add a driver for it.

The register operations in this driver is mainly extracted from the BSP USB3 driver.

---
 drivers/phy/allwinner/Kconfig           |  11 ++
 drivers/phy/allwinner/Makefile          |   1 +
 drivers/phy/allwinner/phy-sun50i-usb3.c | 190 ++++++++++++++++++++++++
 3 files changed, 202 insertions(+)
 create mode 100644 drivers/phy/allwinner/phy-sun50i-usb3.c
drivers/phy/allwinner/Kconfig +11 -0
index 215425296c77..3dab79e9d52b 100644
@@ -45,3 +45,14 @@ config PHY_SUN9I_USB
 	  sun9i SoCs.
 
 	  This driver controls each individual USB 2 host PHY.
+
+config PHY_SUN50I_USB3
+	tristate "Allwinner H6 SoC USB3 PHY driver"
+	depends on ARCH_SUNXI && HAS_IOMEM && OF
+	depends on RESET_CONTROLLER
+	select GENERIC_PHY
+	help
+	  Enable this to support the USB3.0-capable transceiver that is
+	  part of Allwinner H6 SoC.
+
+	  This driver controls each individual USB 2+3 host PHY combo.
drivers/phy/allwinner/Makefile +1 -0
index 799a65c0b58d..bd74901a1255 100644
@@ -2,3 +2,4 @@
 obj-$(CONFIG_PHY_SUN4I_USB)		+= phy-sun4i-usb.o
 obj-$(CONFIG_PHY_SUN6I_MIPI_DPHY)	+= phy-sun6i-mipi-dphy.o
 obj-$(CONFIG_PHY_SUN9I_USB)		+= phy-sun9i-usb.o
+obj-$(CONFIG_PHY_SUN50I_USB3)		+= phy-sun50i-usb3.o
drivers/phy/allwinner/phy-sun50i-usb3.c new file +190 -0

190 lines not on this page · raw message

Signature · 1 line
2.23.0