Skip to contentSkip to conversation

Add USB 3 support for H6 and Orange Pi 3

PATCH Superseded Ondrej Jirman 3 participants 7 messages Oct 24, 2019 – Oct 29, 2019

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 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 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                 |  12 ++
 drivers/phy/allwinner/Makefile                |   1 +
 drivers/phy/allwinner/phy-sun50i-usb3.c       | 195 ++++++++++++++++++
 6 files changed, 295 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 v2 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
maintainer Reviewed-by on v2 1/4
#2 lore raw

Re: [PATCH v2 1/4] dt-bindings: Add bindings for USB3 phy on Allwinner H6

Quoted 12 lines · Ondrej Jirman

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
#3 lore raw

PATCH v2 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           |  12 ++
 drivers/phy/allwinner/Makefile          |   1 +
 drivers/phy/allwinner/phy-sun50i-usb3.c | 195 ++++++++++++++++++++++++
 3 files changed, 208 insertions(+)
 create mode 100644 drivers/phy/allwinner/phy-sun50i-usb3.c
drivers/phy/allwinner/Kconfig +12 -0
index 215425296c77..fcae35ddd430 100644
@@ -45,3 +45,15 @@ config PHY_SUN9I_USB
 	  sun9i SoCs.
 
 	  This driver controls each individual USB 2 host PHY.
+
+config PHY_SUN50I_USB3
+	tristate "Allwinner sun50i SoC USB3 PHY driver"
+	depends on ARCH_SUNXI && HAS_IOMEM && OF
+	depends on RESET_CONTROLLER
+	select USB_COMMON
+	select GENERIC_PHY
+	help
+	  Enable this to support the USB3.0-capable transceiver that is
+	  part of some Allwinner sun50i SoCs.
+
+	  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 +195 -0

195 lines not on this page · raw message

Signature · 1 line
2.23.0
#4 lore raw

Re: [PATCH v2 2/4] phy: allwinner: add phy driver for USB3 PHY on Allwinner H6 SoC

Hi,

Quoted 26 lines · 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           |  12 ++
 drivers/phy/allwinner/Makefile          |   1 +
 drivers/phy/allwinner/phy-sun50i-usb3.c | 195 ++++++++++++++++++++++++
 3 files changed, 208 insertions(+)
 create mode 100644 drivers/phy/allwinner/phy-sun50i-usb3.c
drivers/phy/allwinner/Kconfig +0 -0
index 215425296c77..fcae35ddd430 100644

drivers/phy/allwinner/Kconfig config PHY_SUN9I_USB · line 53

Quoted 9 lines
drivers/phy/allwinner/Kconfig +6 -0
@@ -45,3 +45,15 @@ config PHY_SUN9I_USB
 	  sun9i SoCs.
 
 	  This driver controls each individual USB 2 host PHY.
+
+config PHY_SUN50I_USB3
+	tristate "Allwinner sun50i SoC USB3 PHY driver"
+	depends on ARCH_SUNXI && HAS_IOMEM && OF
+	depends on RESET_CONTROLLER
+	select USB_COMMON

Looks like USB_COMMON is not required here.

Quoted 32 lines
drivers/phy/allwinner/Kconfig +6 -0
+	select GENERIC_PHY
+	help
+	  Enable this to support the USB3.0-capable transceiver that is
+	  part of some Allwinner sun50i SoCs.
+
+	  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 +11 -0
new file mode 100644
index 000000000000..8e170a4d0a11
@@ -0,0 +1,195 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Allwinner sun50i(H6) USB 3.0 phy driver
+ *
+ * Copyright (C) 2017 Icenowy Zheng <[email protected]>
+ *
+ * Based on phy-sun9i-usb.c, which is:
+ *
+ * Copyright (C) 2014-2015 Chen-Yu Tsai <[email protected]>
+ *
+ * Based on code from Allwinner BSP, which is:

drivers/phy/allwinner/phy-sun50i-usb3.c line 21

Quoted 10 lines
drivers/phy/allwinner/phy-sun50i-usb3.c new file +10 -0
+ *
+ * Copyright (c) 2010-2015 Allwinner Technology Co., Ltd.
+ */
+
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/phy/phy.h>
+#include <linux/usb/of.h>

this too..

Thanks
Kishon

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

#5 lore raw

PATCH v2 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 0d5ea19336a1..80233db478e6 100644
@@ -537,6 +537,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
#6 lore raw

PATCH v2 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 eb379cd402ac..259af5b0f1a7 100644
@@ -94,6 +94,10 @@
 	status = "okay";
 };
 
+&dwc3 {
+	status = "okay";
+};
+
 &ehci0 {
 	status = "okay";
 };
@@ -285,3 +289,7 @@
 	usb3_vbus-supply = <&reg_vcc5v>;
 	status = "okay";
 };
+
+&usb3phy {
+	status = "okay";
+};
Signature · 1 line
2.23.0