Skip to contentSkip to conversation

Add support for usb on Hikey960

PATCH Superseded Yu Chen 7 participants 31 messages Feb 18, 2019 – Mar 2, 2019

Subsystems (7)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Yu Chen

author maintainer
#0 lore raw

v2 cover Add support for usb on Hikey960

The patchset adds support for usb functionality of Hikey960, includes:
- dwc3 driver for Hisilicon Kirin Soc hi3660
- usb driver for HiKey960 board
- some adjustment in dwc3, usb gadget and typec driver
- dts for support usb of HiKey960

---
v2:
* This patchset based on patchset https://lkml.org/lkml/2019/1/25/344
of Heikki Krogerus
---

Yu Chen (10):
dt-bindings: phy: Add support for HiSilicon's hi3660 USB PHY
dt-bindings: misc: Add bindings for HiSilicon usb hub and data role
switch functionality on HiKey960
usb: dwc3: dwc3-of-simple: Add support for dwc3 of Hisilicon Soc
Platform
usb: dwc3: Add two quirks for Hisilicon Kirin Soc Platform
phy: Add usb phy support for hi3660 Soc of Hisilicon
usb: roles: Add usb role switch notifier.
usb: dwc3: Registering a role switch in the DRD code.
hikey960: Support usb functionality of Hikey960
usb: gadget: Add configfs attribuite for controling
match_existing_only
dts: hi3660: Add support for usb on Hikey960

 .../bindings/misc/hisilicon-hikey-usb.txt          |  35 ++++
 .../devicetree/bindings/phy/phy-hi3660-usb3.txt    |  21 ++
 MAINTAINERS                                        |   8 +
 arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts  |  54 +++++
 arch/arm64/boot/dts/hisilicon/hi3660.dtsi          |  73 +++++++
 drivers/misc/Kconfig                               |   6 +
 drivers/misc/Makefile                              |   1 +
 drivers/misc/hisi_hikey_usb.c                      | 181 ++++++++++++++++
 drivers/phy/hisilicon/Kconfig                      |  10 +
 drivers/phy/hisilicon/Makefile                     |   1 +
 drivers/phy/hisilicon/phy-hi3660-usb3.c            | 232 +++++++++++++++++++++
 drivers/usb/dwc3/core.c                            |  43 ++++
 drivers/usb/dwc3/core.h                            |   9 +
 drivers/usb/dwc3/drd.c                             |  45 ++++
 drivers/usb/dwc3/dwc3-of-simple.c                  |   4 +-
 drivers/usb/dwc3/gadget.c                          |   2 +-
 drivers/usb/gadget/configfs.c                      |  32 +++
 drivers/usb/roles/class.c                          |  20 +-
 include/linux/usb/role.h                           |  46 ++++
 19 files changed, 820 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt
 create mode 100644 Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt
 create mode 100644 drivers/misc/hisi_hikey_usb.c
 create mode 100644 drivers/phy/hisilicon/phy-hi3660-usb3.c
Signature · 1 line
2.15.0-rc2
author maintainer
#1 lore raw

PATCH v2 1/10 dt-bindings: phy: Add support for HiSilicon's hi3660 USB PHY

This patch adds binding documentation for supporting the hi3660 usb phy on boards like the HiKey960.

Cc Rob Herring <[email protected]>
Cc Mark Rutland <[email protected]>
Cc John Stultz <[email protected]>
Cc Binghui Wang <[email protected]>

---
v1:
* Fix some format error as suggested by Rob.
v2:
* Change hi3660 usb PHY to hi3660 USB PHY
---

---
 .../devicetree/bindings/phy/phy-hi3660-usb3.txt     | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt
Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt new file +21 -0
new file mode 100644
index 000000000000..f9a3d56cfdd2
@@ -0,0 +1,21 @@
+Hisilicon hi3660 USB PHY
+-----------------------
+
+Required properties:
+- compatible: should be "hisilicon,hi3660-usb-phy"
+- #phy-cells: must be 0
+- hisilicon,pericrg-syscon: phandle of syscon used to control phy.
+- hisilicon,pctrl-syscon: phandle of syscon used to control phy.
+- hisilicon,usb3-otg-bc-syscon: phandle of syscon used to control phy.
+- hisilicon,eye-diagram-param: parameter set for phy
+Refer to phy/phy-bindings.txt for the generic PHY binding properties
+
+Example:
+	usb-phy {
+		compatible = "hisilicon,hi3660-usb-phy";
+		#phy-cells = <0>;
+		hisilicon,pericrg-syscon = <&crg_ctrl>;
+		hisilicon,pctrl-syscon = <&pctrl>;
+		hisilicon,usb3-otg-bc-syscon = <&usb3_otg_bc>;
+		hisilicon,eye-diagram-param = <0x22466e4>;
+	};
Signature · 1 line
2.15.0-rc2
maintainer
#2 lore raw

Re: [PATCH v2 01/10] dt-bindings: phy: Add support for HiSilicon's hi3660 USB PHY

Quoted 34 lines · Yu Chen

This patch adds binding documentation for supporting the hi3660 usb phy on boards like the HiKey960.

Cc Rob Herring <[email protected]>
Cc Mark Rutland <[email protected]>
Cc John Stultz <[email protected]>
Cc Binghui Wang <[email protected]>

---
v1:
* Fix some format error as suggested by Rob.
v2:
* Change hi3660 usb PHY to hi3660 USB PHY
---

---
 .../devicetree/bindings/phy/phy-hi3660-usb3.txt     | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt
Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt new file +9 -0
new file mode 100644
index 000000000000..f9a3d56cfdd2
@@ -0,0 +1,21 @@
+Hisilicon hi3660 USB PHY
+-----------------------
+
+Required properties:
+- compatible: should be "hisilicon,hi3660-usb-phy"
+- #phy-cells: must be 0
+- hisilicon,pericrg-syscon: phandle of syscon used to control phy.
+- hisilicon,pctrl-syscon: phandle of syscon used to control phy.
+- hisilicon,usb3-otg-bc-syscon: phandle of syscon used to control phy.

Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt line 19

Quoted 10 lines
Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt new file +10 -0
+- hisilicon,eye-diagram-param: parameter set for phy
+Refer to phy/phy-bindings.txt for the generic PHY binding properties
+
+Example:
+	usb-phy {
+		compatible = "hisilicon,hi3660-usb-phy";
+		#phy-cells = <0>;
+		hisilicon,pericrg-syscon = <&crg_ctrl>;
+		hisilicon,pctrl-syscon = <&pctrl>;
+		hisilicon,usb3-otg-bc-syscon = <&usb3_otg_bc>;

Are most of the registers within one of these blocks? If so, make this node a child of that node.

Quoted 5 lines
Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt new file +2 -0
+		hisilicon,eye-diagram-param = <0x22466e4>;
+	};
Signature · 1 line
2.15.0-rc2
author maintainer
#3 lore raw

Re: [PATCH v2 01/10] dt-bindings: phy: Add support for HiSilicon's hi3660 USB PHY

Hi,

Quoted 40 lines · Rob Herring
Quoted 39 lines · Yu Chen

This patch adds binding documentation for supporting the hi3660 usb phy on boards like the HiKey960.

Cc Rob Herring <[email protected]>
Cc Mark Rutland <[email protected]>
Cc John Stultz <[email protected]>
Cc Binghui Wang <[email protected]>

---
v1:
* Fix some format error as suggested by Rob.
v2:
* Change hi3660 usb PHY to hi3660 USB PHY
---

---
 .../devicetree/bindings/phy/phy-hi3660-usb3.txt     | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt
Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt new file +14 -0
new file mode 100644
index 000000000000..f9a3d56cfdd2
@@ -0,0 +1,21 @@
+Hisilicon hi3660 USB PHY
+-----------------------
+
+Required properties:
+- compatible: should be "hisilicon,hi3660-usb-phy"
+- #phy-cells: must be 0
+- hisilicon,pericrg-syscon: phandle of syscon used to control phy.
+- hisilicon,pctrl-syscon: phandle of syscon used to control phy.
+- hisilicon,usb3-otg-bc-syscon: phandle of syscon used to control phy.
+- hisilicon,eye-diagram-param: parameter set for phy
+Refer to phy/phy-bindings.txt for the generic PHY binding properties
+
+Example:
+	usb-phy {
Quoted 8 lines

Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt line 19

Quoted 5 lines
Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt new file +5 -0
+		compatible = "hisilicon,hi3660-usb-phy";
+		#phy-cells = <0>;
+		hisilicon,pericrg-syscon = <&crg_ctrl>;
+		hisilicon,pctrl-syscon = <&pctrl>;
+		hisilicon,usb3-otg-bc-syscon = <&usb3_otg_bc>;

Are most of the registers within one of these blocks? If so, make this node a child of that node.

I met a problem when I made this node a child of the syscon node, the driver "phy-hi3660-usb3" was not probed.
Do you have any idea about how to make it probed when it is a child node?

Quoted 9 lines
Quoted 6 lines
Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt new file +2 -0
+		hisilicon,eye-diagram-param = <0x22466e4>;
+	};
Signature · 1 line
2.15.0-rc2

.

Thanks
Yu Chen

#4 lore raw

Re: [PATCH v2 01/10] dt-bindings: phy: Add support for HiSilicon's hi3660 USB PHY

Hi,

Quoted 51 lines · Chen Yu

Hi,

Quoted 40 lines · Rob Herring
Quoted 39 lines · Yu Chen

This patch adds binding documentation for supporting the hi3660 usb phy on boards like the HiKey960.

Cc Rob Herring <[email protected]>
Cc Mark Rutland <[email protected]>
Cc John Stultz <[email protected]>
Cc Binghui Wang <[email protected]>

---
v1:
* Fix some format error as suggested by Rob.
v2:
* Change hi3660 usb PHY to hi3660 USB PHY
---

---
 .../devicetree/bindings/phy/phy-hi3660-usb3.txt     | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt
Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt new file +14 -0
new file mode 100644
index 000000000000..f9a3d56cfdd2
@@ -0,0 +1,21 @@
+Hisilicon hi3660 USB PHY
+-----------------------
+
+Required properties:
+- compatible: should be "hisilicon,hi3660-usb-phy"
+- #phy-cells: must be 0
+- hisilicon,pericrg-syscon: phandle of syscon used to control phy.
+- hisilicon,pctrl-syscon: phandle of syscon used to control phy.
+- hisilicon,usb3-otg-bc-syscon: phandle of syscon used to control phy.
+- hisilicon,eye-diagram-param: parameter set for phy
+Refer to phy/phy-bindings.txt for the generic PHY binding properties
+
+Example:
+	usb-phy {
Quoted 8 lines

Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt line 19

Quoted 5 lines
Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt new file +5 -0
+		compatible = "hisilicon,hi3660-usb-phy";
+		#phy-cells = <0>;
+		hisilicon,pericrg-syscon = <&crg_ctrl>;
+		hisilicon,pctrl-syscon = <&pctrl>;
+		hisilicon,usb3-otg-bc-syscon = <&usb3_otg_bc>;

Are most of the registers within one of these blocks? If so, make this node a child of that node.

Quoted 3 lines

I met a problem when I made this node a child of the syscon node, the driver "phy-hi3660-usb3" was not probed.
Do you have any idea about how to make it probed when it is a child node?

call of_platform_populate() in parent node's driver, but I don't know whether it's a standard way

Quoted 13 lines
Quoted 9 lines
Quoted 6 lines
Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt new file +2 -0
+		hisilicon,eye-diagram-param = <0x22466e4>;
+	};
Signature · 1 line
2.15.0-rc2

.

Thanks
Yu Chen

author maintainer
#5 lore raw

Re: [PATCH v2 01/10] dt-bindings: phy: Add support for HiSilicon's hi3660 USB PHY

Hi,

Quoted 11 lines · Chunfeng Yun
Quoted 11 lines
Quoted 11 lines

Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt line 19

Quoted 8 lines
Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt new file +8 -0
+
+Example:
+	usb-phy {
+		compatible = "hisilicon,hi3660-usb-phy";
+		#phy-cells = <0>;
+		hisilicon,pericrg-syscon = <&crg_ctrl>;
+		hisilicon,pctrl-syscon = <&pctrl>;
+		hisilicon,usb3-otg-bc-syscon = <&usb3_otg_bc>;

Are most of the registers within one of these blocks? If so, make this node a child of that node.

Quoted 5 lines
Quoted 3 lines

I met a problem when I made this node a child of the syscon node, the driver "phy-hi3660-usb3" was not probed.
Do you have any idea about how to make it probed when it is a child node?

call of_platform_populate() in parent node's driver, but I don't know whether it's a standard way

Yes, this function is used in dwc3 driver to probe the child node. But I think it is not a good way to modify the syscon driver.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt new file +2 -0
+		hisilicon,eye-diagram-param = <0x22466e4>;
+	};
Signature · 1 line
2.15.0-rc2

Thanks
Yu Chen

maintainer
#6 lore raw

Re: [PATCH v2 01/10] dt-bindings: phy: Add support for HiSilicon's hi3660 USB PHY

In reply to Chunfeng Yun
Quoted 54 lines · Chunfeng Yun

Hi,

Quoted 51 lines · Chen Yu

Hi,

Quoted 48 lines · Rob Herring
Quoted 34 lines · Yu Chen

This patch adds binding documentation for supporting the hi3660 usb phy on boards like the HiKey960.

Cc Rob Herring <[email protected]>
Cc Mark Rutland <[email protected]>
Cc John Stultz <[email protected]>
Cc Binghui Wang <[email protected]>

---
v1:
* Fix some format error as suggested by Rob.
v2:
* Change hi3660 usb PHY to hi3660 USB PHY
---

---
 .../devicetree/bindings/phy/phy-hi3660-usb3.txt     | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt
Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt new file +9 -0
new file mode 100644
index 000000000000..f9a3d56cfdd2
@@ -0,0 +1,21 @@
+Hisilicon hi3660 USB PHY
+-----------------------
+
+Required properties:
+- compatible: should be "hisilicon,hi3660-usb-phy"
+- #phy-cells: must be 0
+- hisilicon,pericrg-syscon: phandle of syscon used to control phy.
+- hisilicon,pctrl-syscon: phandle of syscon used to control phy.
+- hisilicon,usb3-otg-bc-syscon: phandle of syscon used to control phy.

Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt line 19

Quoted 10 lines
Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt new file +10 -0
+- hisilicon,eye-diagram-param: parameter set for phy
+Refer to phy/phy-bindings.txt for the generic PHY binding properties
+
+Example:
+  usb-phy {
+          compatible = "hisilicon,hi3660-usb-phy";
+          #phy-cells = <0>;
+          hisilicon,pericrg-syscon = <&crg_ctrl>;
+          hisilicon,pctrl-syscon = <&pctrl>;
+          hisilicon,usb3-otg-bc-syscon = <&usb3_otg_bc>;

Are most of the registers within one of these blocks? If so, make this node a child of that node.

Quoted 5 lines
Quoted 3 lines

I met a problem when I made this node a child of the syscon node, the driver "phy-hi3660-usb3" was not probed.
Do you have any idea about how to make it probed when it is a child node?

call of_platform_populate() in parent node's driver, but I don't know whether it's a standard way

It is. The other way is adding 'simple-mfd' compatible if there is no driver for the parent.

Rob

author maintainer
#7 lore raw

PATCH v2 2/10 dt-bindings: misc: Add bindings for HiSilicon usb hub and data role switch functionality on HiKey960

In reply to Yu Chen

This patch adds binding documentation to support usb hub and usb data role switch of Hisilicon HiKey960 Board.

Cc Sergei Shtylyov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Mark Rutland <[email protected]>
Cc John Stultz <[email protected]>
Cc Binghui Wang <[email protected]>

---
v1:
* Fix some format errors as suggested by Sergei.
* Modify gpio description to use gpiod API.
v2:
* Remove information about Hikey.
* Fix gpio description.
* Remove device_type of endpoint.
---

---
 .../bindings/misc/hisilicon-hikey-usb.txt          | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt
Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt new file +35 -0
new file mode 100644
index 000000000000..c2b789b515df
@@ -0,0 +1,35 @@
+Support usb hub and usb data role switch of Hisilicon HiKey960 Board.
+
+-----------------------------
+
+Required properties:
+- compatible: "hisilicon,gpio-hubv1","hisilicon,hikey960-usb"
+- typec-vbus-gpios: gpio to control the vbus of typeC port
+- typec-vbus-enable-val: gpio value that enable the vbus of typeC port
+- otg-switch-gpios: gpio to switch DP & DM between the hub and typeC port
+- hub-vdd33-en-gpios: gpio to enable the power of hub
+- pinctrl-0: pinctrl config
+
+Example
+-----
+
+	hisi_hikey_usb: hisi_hikey_usb {
+		compatible = "hisilicon,hikey960-usb";
+		typec-vbus-gpios = <&gpio25 2 0>;
+		typec-vbus-enable-val = <1>;
+		otg-switch-gpios = <&gpio25 6 0>;
+		hub-vdd33-en-gpios = <&gpio5 6 0>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&usbhub5734_pmx_func>;
+
+		port {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			hikey_usb_ep: endpoint@0 {
+				reg = <0>;
+				remote-endpoint = <&dwc3_role_switch_notify>;
+			};
+		};
+
+	};
Signature · 1 line
2.15.0-rc2
#8 lore raw

Re: [PATCH v2 02/10] dt-bindings: misc: Add bindings for HiSilicon usb hub and data role switch functionality on HiKey960

Hello!

Quoted 29 lines · Yu Chen

This patch adds binding documentation to support usb hub and usb data role switch of Hisilicon HiKey960 Board.

Cc Sergei Shtylyov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Mark Rutland <[email protected]>
Cc John Stultz <[email protected]>
Cc Binghui Wang <[email protected]>

---
v1:
* Fix some format errors as suggested by Sergei.
* Modify gpio description to use gpiod API.
v2:
* Remove information about Hikey.
* Fix gpio description.
* Remove device_type of endpoint.
---

---
  .../bindings/misc/hisilicon-hikey-usb.txt          | 35 ++++++++++++++++++++++
  1 file changed, 35 insertions(+)

create mode 100644 Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt

Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt new file +0 -0
new file mode 100644
index 000000000000..c2b789b515df

Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt line 6

Quoted 6 lines
Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt new file +6 -0
@@ -0,0 +1,35 @@
+Support usb hub and usb data role switch of Hisilicon HiKey960 Board.
+
+-----------------------------
+
+Required properties:
+- compatible: "hisilicon,gpio-hubv1","hisilicon,hikey960-usb"

Only one of those, looking at your example?
Need a space after comma, BTW.

Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt line 8

Quoted 2 lines
Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt new file +2 -0
+- typec-vbus-gpios: gpio to control the vbus of typeC port
+- typec-vbus-enable-val: gpio value that enable the vbus of typeC port

Hm, I thought that can be inferred from the GPIO specifier above...

Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt line 11

Quoted 3 lines
Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt new file +3 -0
+- otg-switch-gpios: gpio to switch DP & DM between the hub and typeC port
+- hub-vdd33-en-gpios: gpio to enable the power of hub
+- pinctrl-0: pinctrl config

You forgot about "pinctrl-names"...

Quoted 14 lines
Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt new file +14 -0
+
+Example
+-----
+
+	hisi_hikey_usb: hisi_hikey_usb {
+		compatible = "hisilicon,hikey960-usb";
+		typec-vbus-gpios = <&gpio25 2 0>;
+		typec-vbus-enable-val = <1>;
+		otg-switch-gpios = <&gpio25 6 0>;
+		hub-vdd33-en-gpios = <&gpio5 6 0>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&usbhub5734_pmx_func>;
+
+		port {

Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt line 35

Quoted 10 lines
Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt new file +10 -0
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			hikey_usb_ep: endpoint@0 {
+				reg = <0>;
+				remote-endpoint = <&dwc3_role_switch_notify>;
+			};
+		};
+
+	};

MBR, Sergei

author maintainer
#9 lore raw

Re: [PATCH v2 02/10] dt-bindings: misc: Add bindings for HiSilicon usb hub and data role switch functionality on HiKey960

Hi,

Quoted 27 lines · Sergei Shtylyov

Hello!

Quoted 23 lines · Yu Chen

This patch adds binding documentation to support usb hub and usb data role switch of Hisilicon HiKey960 Board.

Cc Sergei Shtylyov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Mark Rutland <[email protected]>
Cc John Stultz <[email protected]>
Cc Binghui Wang <[email protected]>

---
v1:
* Fix some format errors as suggested by Sergei.
* Modify gpio description to use gpiod API.
v2:
* Remove information about Hikey.
* Fix gpio description.
* Remove device_type of endpoint.
---
---
  .../bindings/misc/hisilicon-hikey-usb.txt          | 35 ++++++++++++++++++++++

  1 file changed, 35 insertions(+)

  create mode 100644 Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt

Quoted 14 lines

Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt line 6

Quoted 12 lines
Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt new file +6 -0
new file mode 100644
index 000000000000..c2b789b515df
@@ -0,0 +1,35 @@
+Support usb hub and usb data role switch of Hisilicon HiKey960 Board.
+
+-----------------------------
+
+Required properties:
+- compatible: "hisilicon,gpio-hubv1","hisilicon,hikey960-usb"

   Only one of those, looking at your example?

"hisilicon,gpio-hubv1" is similar as "hisilicon,hikey960-usb".

Quoted 1 line

   Need a space after comma, BTW.

OK. Thanks!

Quoted 6 lines

Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt line 8

Quoted 3 lines
Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt new file +2 -0
+- typec-vbus-gpios: gpio to control the vbus of typeC port
+- typec-vbus-enable-val: gpio value that enable the vbus of typeC port

   Hm, I thought that can be inferred from the GPIO specifier above...

OK. Thanks!

Quoted 5 lines

Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt line 11

Quoted 3 lines
Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt new file +3 -0
+- otg-switch-gpios: gpio to switch DP & DM between the hub and typeC port
+- hub-vdd33-en-gpios: gpio to enable the power of hub
+- pinctrl-0: pinctrl config

   You forgot about "pinctrl-names"...

OK. Thanks!

Quoted 28 lines
Quoted 15 lines
Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt new file +14 -0
+
+Example
+-----
+
+    hisi_hikey_usb: hisi_hikey_usb {
+        compatible = "hisilicon,hikey960-usb";
+        typec-vbus-gpios = <&gpio25 2 0>;
+        typec-vbus-enable-val = <1>;
+        otg-switch-gpios = <&gpio25 6 0>;
+        hub-vdd33-en-gpios = <&gpio5 6 0>;
+        pinctrl-names = "default";
+        pinctrl-0 = <&usbhub5734_pmx_func>;
+
+        port {

Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt line 35

Quoted 10 lines
Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt new file +10 -0
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            hikey_usb_ep: endpoint@0 {
+                reg = <0>;
+                remote-endpoint = <&dwc3_role_switch_notify>;
+            };
+        };
+
+    };

MBR, Sergei

Quoted 2 lines

.

Thanks
Yu Chen

author maintainer
#10 lore raw

PATCH v2 3/10 usb: dwc3: dwc3-of-simple: Add support for dwc3 of Hisilicon Soc Platform

In reply to Yu Chen

This patch adds support for the poweron and shutdown of dwc3 core on Hisilicon Soc Platform.

---
 drivers/usb/dwc3/dwc3-of-simple.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-of-simple.c +3 -1
index 4c2771c5e727..0ed09d876542 100644
@@ -98,7 +98,8 @@ static int dwc3_of_simple_probe(struct platform_device *pdev)
 	 * Some controllers need to toggle the usb3-otg reset before trying to
 	 * initialize the PHY, otherwise the PHY times out.
 	 */
-	if (of_device_is_compatible(np, "rockchip,rk3399-dwc3"))
+	if (of_device_is_compatible(np, "rockchip,rk3399-dwc3") ||
+			of_device_is_compatible(np, "hisilicon,hi3660-dwc3"))
 		simple->need_reset = true;
 
 	if (of_device_is_compatible(np, "amlogic,meson-axg-dwc3") ||
@@ -243,6 +244,7 @@ static const struct of_device_id of_dwc3_simple_match[] = {
 	{ .compatible = "amlogic,meson-axg-dwc3" },
 	{ .compatible = "amlogic,meson-gxl-dwc3" },
 	{ .compatible = "allwinner,sun50i-h6-dwc3" },
+	{ .compatible = "hisilicon,hi3660-dwc3" },
 	{ /* Sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, of_dwc3_simple_match);
Signature · 1 line
2.15.0-rc2
author maintainer
#11 lore raw

PATCH v2 4/10 usb: dwc3: Add two quirks for Hisilicon Kirin Soc Platform

In reply to Yu Chen

There are tow quirks for DesignWare USB3 DRD Core of Hisilicon Kirin Soc. 1)SPLIT_BOUNDARY_DISABLE should be set for Host mode
2)A GCTL soft reset should be executed when switch mode

Cc Andy Shevchenko <[email protected]>
Cc Felipe Balbi <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc John Stultz <[email protected]>
Cc Binghui Wang <[email protected]>

---
v2:
* Fix data type of reg from int to u32.
---

---
 drivers/usb/dwc3/core.c   | 43 +++++++++++++++++++++++++++++++++++++++++++
 drivers/usb/dwc3/core.h   |  7 +++++++
 drivers/usb/dwc3/gadget.c |  2 +-
 3 files changed, 51 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +43 -0
index a1b126f90261..017b0527f6ab 100644
@@ -112,11 +112,25 @@ void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode)
 	dwc->current_dr_role = mode;
 }
 
+static void dwc3_gctl_core_soft_reset(struct dwc3 *dwc)
+{
+	u32 reg;
+
+	reg = dwc3_readl(dwc->regs, DWC3_GCTL);
+	reg |= (DWC3_GCTL_CORESOFTRESET);
+	dwc3_writel(dwc->regs, DWC3_GCTL, reg);
+
+	reg = dwc3_readl(dwc->regs, DWC3_GCTL);
+	reg &= ~(DWC3_GCTL_CORESOFTRESET);
+	dwc3_writel(dwc->regs, DWC3_GCTL, reg);
+}
+
 static void __dwc3_set_mode(struct work_struct *work)
 {
 	struct dwc3 *dwc = work_to_dwc(work);
 	unsigned long flags;
 	int ret;
+	u32 reg;
 
 	if (dwc->dr_mode != USB_DR_MODE_OTG)
 		return;
@@ -156,6 +170,10 @@ static void __dwc3_set_mode(struct work_struct *work)
 
 	dwc3_set_prtcap(dwc, dwc->desired_dr_role);
 
+	/* Execute a GCTL Core Soft Reset when switch mode */
+	if (dwc->gctl_reset_quirk)
+		dwc3_gctl_core_soft_reset(dwc);
+
 	spin_unlock_irqrestore(&dwc->lock, flags);
 
 	switch (dwc->desired_dr_role) {
@@ -169,6 +187,11 @@ static void __dwc3_set_mode(struct work_struct *work)
 			phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_HOST);
 			phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_HOST);
 			phy_calibrate(dwc->usb2_generic_phy);
+			if (dwc->dis_split_quirk) {
+				reg = dwc3_readl(dwc->regs, DWC3_GUCTL3);
+				reg |= DWC3_GUCTL3_SPLITDISABLE;
+				dwc3_writel(dwc->regs, DWC3_GUCTL3, reg);
+			}
 		}
 		break;
 	case DWC3_GCTL_PRTCAP_DEVICE:
@@ -1306,6 +1329,11 @@ static void dwc3_get_properties(struct dwc3 *dwc)
 	dwc->dis_metastability_quirk = device_property_read_bool(dev,
 				"snps,dis_metastability_quirk");
 
+	dwc->dis_split_quirk = device_property_read_bool(dev,
+				"snps,dis-split-quirk");
+	dwc->gctl_reset_quirk = device_property_read_bool(dev,
+				"snps,gctl-reset-quirk");
+
 	dwc->lpm_nyet_threshold = lpm_nyet_threshold;
 	dwc->tx_de_emphasis = tx_de_emphasis;
 
@@ -1825,10 +1853,25 @@ static int dwc3_resume(struct device *dev)
 
 	return 0;
 }
+
+static void dwc3_complete(struct device *dev)
+{
+	struct dwc3	*dwc = dev_get_drvdata(dev);
+	u32		reg;
+
+	if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST &&
+			dwc->dis_split_quirk) {
+		dev_dbg(dwc->dev, "set DWC3_GUCTL3_SPLITDISABLE\n");
+		reg = dwc3_readl(dwc->regs, DWC3_GUCTL3);
+		reg |= DWC3_GUCTL3_SPLITDISABLE;
+		dwc3_writel(dwc->regs, DWC3_GUCTL3, reg);
+	}
+}
 #endif /* CONFIG_PM_SLEEP */
 
 static const struct dev_pm_ops dwc3_dev_pm_ops = {
 	SET_SYSTEM_SLEEP_PM_OPS(dwc3_suspend, dwc3_resume)
+	.complete = dwc3_complete,
 	SET_RUNTIME_PM_OPS(dwc3_runtime_suspend, dwc3_runtime_resume,
 			dwc3_runtime_idle)
 };
drivers/usb/dwc3/core.h +7 -0
index df876418cb78..402b3c29eb26 100644
@@ -136,6 +136,7 @@
 #define DWC3_GEVNTCOUNT(n)	(0xc40c + ((n) * 0x10))
 
 #define DWC3_GHWPARAMS8		0xc600
+#define DWC3_GUCTL3		0xc60c
 #define DWC3_GFLADJ		0xc630
 
 /* Device Registers */
@@ -370,6 +371,9 @@
 /* Global User Control Register 2 */
 #define DWC3_GUCTL2_RST_ACTBITLATER		BIT(14)
 
+/* Global User Control Register 3 */
+#define DWC3_GUCTL3_SPLITDISABLE		BIT(14)
+
 /* Device Configuration Register */
 #define DWC3_DCFG_DEVADDR(addr)	((addr) << 3)
 #define DWC3_DCFG_DEVADDR_MASK	DWC3_DCFG_DEVADDR(0x7f)
@@ -1210,6 +1214,9 @@ struct dwc3 {
 
 	unsigned		dis_metastability_quirk:1;
 
+	unsigned		dis_split_quirk:1;
+	unsigned		gctl_reset_quirk:1;
+
 	u16			imod_interval;
 };
 
drivers/usb/dwc3/gadget.c +1 -1
index 07bd31bb2f8a..21c0072cdf38 100644
@@ -269,7 +269,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned cmd,
 {
 	const struct usb_endpoint_descriptor *desc = dep->endpoint.desc;
 	struct dwc3		*dwc = dep->dwc;
-	u32			timeout = 1000;
+	u32			timeout = 5000;
 	u32			saved_config = 0;
 	u32			reg;
 
Signature · 1 line
2.15.0-rc2
#12 lore raw

Re: [PATCH v2 04/10] usb: dwc3: Add two quirks for Hisilicon Kirin Soc Platform

Quoted 4 lines · Yu Chen

There are tow quirks for DesignWare USB3 DRD Core of Hisilicon Kirin Soc. 1)SPLIT_BOUNDARY_DISABLE should be set for Host mode
2)A GCTL soft reset should be executed when switch mode

Thus, it must be two patches, no?

drivers/usb/dwc3/core.c void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode)

Quoted 7 lines
drivers/usb/dwc3/core.c +6 -0
+static void dwc3_gctl_core_soft_reset(struct dwc3 *dwc)
+{
+       u32 reg;
+
+       reg = dwc3_readl(dwc->regs, DWC3_GCTL);
 
+       reg |= (DWC3_GCTL_CORESOFTRESET);

Redundant parens.

drivers/usb/dwc3/core.c void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode)

Quoted 5 lines
drivers/usb/dwc3/core.c +4 -0
+       dwc3_writel(dwc->regs, DWC3_GCTL, reg);
+
+       reg = dwc3_readl(dwc->regs, DWC3_GCTL);
 
+       reg &= ~(DWC3_GCTL_CORESOFTRESET);

Ditto.

drivers/usb/dwc3/core.c static int dwc3_resume(struct device *dev)

Quoted 8 lines
drivers/usb/dwc3/core.c +6 -0
+       dwc3_writel(dwc->regs, DWC3_GCTL, reg);
+}
 
+static void dwc3_complete(struct device *dev)
+{
 
+       struct dwc3     *dwc = dev_get_drvdata(dev);
+       u32             reg;

Indentation style is different to the other functions in the same patch. Use simple space here.

Quoted 12 lines
drivers/usb/dwc3/core.c +8 -0
+       if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST &&
+                       dwc->dis_split_quirk) {
+               dev_dbg(dwc->dev, "set DWC3_GUCTL3_SPLITDISABLE\n");
+               reg = dwc3_readl(dwc->regs, DWC3_GUCTL3);
+               reg |= DWC3_GUCTL3_SPLITDISABLE;
+               dwc3_writel(dwc->regs, DWC3_GUCTL3, reg);
+       }
+}

drivers/usb/dwc3/gadget.c int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned cmd, · line 273

Quoted 6 lines
drivers/usb/dwc3/gadget.c +1 -1
@@ -269,7 +269,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned cmd,
 {
        const struct usb_endpoint_descriptor *desc = dep->endpoint.desc;
        struct dwc3             *dwc = dep->dwc;
 
-       u32                     timeout = 1000;
+       u32                     timeout = 5000;

I don't see anything about this change in commit message. Moreoever, it looks like it must be a separate logical change with its own description.

Quoted 2 lines
drivers/usb/dwc3/gadget.c +0 -0
        u32                     saved_config = 0;
        u32                     reg;
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#13 lore raw

Re: [PATCH v2 04/10] usb: dwc3: Add two quirks for Hisilicon Kirin Soc Platform

Hi,

Quoted 54 lines · Andy Shevchenko
Quoted 4 lines · Yu Chen

There are tow quirks for DesignWare USB3 DRD Core of Hisilicon Kirin Soc. 1)SPLIT_BOUNDARY_DISABLE should be set for Host mode
2)A GCTL soft reset should be executed when switch mode

Thus, it must be two patches, no?

drivers/usb/dwc3/core.c void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode)

Quoted 7 lines
drivers/usb/dwc3/core.c +6 -0
+static void dwc3_gctl_core_soft_reset(struct dwc3 *dwc)
+{
+       u32 reg;
+
+       reg = dwc3_readl(dwc->regs, DWC3_GCTL);
 
+       reg |= (DWC3_GCTL_CORESOFTRESET);

Redundant parens.

drivers/usb/dwc3/core.c void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode)

Quoted 5 lines
drivers/usb/dwc3/core.c +4 -0
+       dwc3_writel(dwc->regs, DWC3_GCTL, reg);
+
+       reg = dwc3_readl(dwc->regs, DWC3_GCTL);
 
+       reg &= ~(DWC3_GCTL_CORESOFTRESET);

Ditto.

drivers/usb/dwc3/core.c static int dwc3_resume(struct device *dev)

Quoted 8 lines
drivers/usb/dwc3/core.c +6 -0
+       dwc3_writel(dwc->regs, DWC3_GCTL, reg);
+}
 
+static void dwc3_complete(struct device *dev)
+{
 
+       struct dwc3     *dwc = dev_get_drvdata(dev);
+       u32             reg;

Indentation style is different to the other functions in the same patch. Use simple space here.

Quoted 15 lines
drivers/usb/dwc3/core.c +8 -0
+       if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST &&
+                       dwc->dis_split_quirk) {
+               dev_dbg(dwc->dev, "set DWC3_GUCTL3_SPLITDISABLE\n");
+               reg = dwc3_readl(dwc->regs, DWC3_GUCTL3);
+               reg |= DWC3_GUCTL3_SPLITDISABLE;
+               dwc3_writel(dwc->regs, DWC3_GUCTL3, reg);
+       }
+}
drivers/usb/dwc3/gadget.c +0 -0
@@ -269,7 +269,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned cmd,
 {
        const struct usb_endpoint_descriptor *desc = dep->endpoint.desc;
        struct dwc3             *dwc = dep->dwc;
Quoted 11 lines

drivers/usb/dwc3/gadget.c int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned cmd, · line 272

Quoted 2 lines
drivers/usb/dwc3/gadget.c +1 -1
-       u32                     timeout = 1000;
+       u32                     timeout = 5000;

I don't see anything about this change in commit message. Moreoever, it looks like it must be a separate logical change with its own description.

Quoted 2 lines
drivers/usb/dwc3/gadget.c +0 -0
        u32                     saved_config = 0;
        u32                     reg;

I will separate these changes into different patches. Thanks!

author maintainer
#14 lore raw

PATCH v2 5/10 phy: Add usb phy support for hi3660 Soc of Hisilicon

In reply to Yu Chen

This driver handles usb phy power on and shutdown for hi3660 Soc of Hisilicon.

Cc Andy Shevchenko <[email protected]>
Cc Kishon Vijay Abraham I <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Pengcheng Li <[email protected]>
Cc Jianguo Sun <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Jiancheng Xue <[email protected]>
Cc John Stultz <[email protected]>
Cc Binghui Wang <[email protected]>

---
v1:
* Remove unused code and add comment for time delay as suggested by Kishon Vijay Abraham I.
v2:
* Fix license declaration.
* Remove redundant parens.
* Remove unused member variables in struct hi3660_priv.
---

---
 MAINTAINERS                             |   8 ++
 drivers/phy/hisilicon/Kconfig           |  10 ++
 drivers/phy/hisilicon/Makefile          |   1 +
 drivers/phy/hisilicon/phy-hi3660-usb3.c | 232 ++++++++++++++++++++++++++++++++
 4 files changed, 251 insertions(+)
 create mode 100644 drivers/phy/hisilicon/phy-hi3660-usb3.c
MAINTAINERS +8 -0
index 4d04cebb4a71..8dc289faa2c4 100644
@@ -15790,6 +15790,14 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/usb/roles/intel-xhci-usb-role-switch.c
 
+USB IP DRIVER FOR HISILICON KIRIN
+M:	Yu Chen <[email protected]>
+M:	Binghui Wang <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt
+F:	drivers/phy/hisilicon/phy-hi3660-usb3.c
+
 USB ISP116X DRIVER
 M:	Olav Kongas <[email protected]>
 L:	[email protected]
drivers/phy/hisilicon/Kconfig +10 -0
index b40ee54a1a50..3c142f08987c 100644
@@ -12,6 +12,16 @@ config PHY_HI6220_USB
 
 	  To compile this driver as a module, choose M here.
 
+config PHY_HI3660_USB
+	tristate "hi3660 USB PHY support"
+	depends on (ARCH_HISI && ARM64) || COMPILE_TEST
+	select GENERIC_PHY
+	select MFD_SYSCON
+	help
+	  Enable this to support the HISILICON HI3660 USB PHY.
+
+	  To compile this driver as a module, choose M here.
+
 config PHY_HISTB_COMBPHY
 	tristate "HiSilicon STB SoCs COMBPHY support"
 	depends on (ARCH_HISI && ARM64) || COMPILE_TEST
drivers/phy/hisilicon/Makefile +1 -0
index f662a4fe18d8..75ba64e2faf8 100644
@@ -1,4 +1,5 @@
 obj-$(CONFIG_PHY_HI6220_USB)		+= phy-hi6220-usb.o
+obj-$(CONFIG_PHY_HI3660_USB)		+= phy-hi3660-usb3.o
 obj-$(CONFIG_PHY_HISTB_COMBPHY)		+= phy-histb-combphy.o
 obj-$(CONFIG_PHY_HISI_INNO_USB2)	+= phy-hisi-inno-usb2.o
 obj-$(CONFIG_PHY_HIX5HD2_SATA)		+= phy-hix5hd2-sata.o
drivers/phy/hisilicon/phy-hi3660-usb3.c new file +232 -0

232 lines not on this page · raw message

Signature · 1 line
2.15.0-rc2
author maintainer
#15 lore raw

PATCH v2 6/10 usb: roles: Add usb role switch notifier.

In reply to Yu Chen

This patch adds notifier for drivers want to be informed of the usb role switch.

Cc Greg Kroah-Hartman <[email protected]>
Cc Heikki Krogerus <[email protected]>
Cc Hans de Goede <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc John Stultz <[email protected]>
---
 drivers/usb/roles/class.c | 20 +++++++++++++++++++-
 include/linux/usb/role.h  | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+), 1 deletion(-)
drivers/usb/roles/class.c +19 -1
index f45d8df5cfb8..e2caaa665d6e 100644
@@ -20,6 +20,7 @@ struct usb_role_switch {
 	struct device dev;
 	struct mutex lock; /* device lock*/
 	enum usb_role role;
+	struct blocking_notifier_head nh;
 
 	/* From descriptor */
 	struct device *usb2_port;
@@ -49,8 +50,10 @@ int usb_role_switch_set_role(struct usb_role_switch *sw, enum usb_role role)
 	mutex_lock(&sw->lock);
 
 	ret = sw->set(sw->dev.parent, role);
-	if (!ret)
+	if (!ret) {
 		sw->role = role;
+		blocking_notifier_call_chain(&sw->nh, role, NULL);
+	}
 
 	mutex_unlock(&sw->lock);
 
@@ -58,6 +61,20 @@ int usb_role_switch_set_role(struct usb_role_switch *sw, enum usb_role role)
 }
 EXPORT_SYMBOL_GPL(usb_role_switch_set_role);
 
+int usb_role_switch_register_notifier(struct usb_role_switch *sw,
+				      struct notifier_block *nb)
+{
+	return blocking_notifier_chain_register(&sw->nh, nb);
+}
+EXPORT_SYMBOL_GPL(usb_role_switch_register_notifier);
+
+int usb_role_switch_unregister_notifier(struct usb_role_switch *sw,
+					struct notifier_block *nb)
+{
+	return blocking_notifier_chain_unregister(&sw->nh, nb);
+}
+EXPORT_SYMBOL_GPL(usb_role_switch_unregister_notifier);
+
 /**
  * usb_role_switch_get_role - Get the USB role for a switch
  * @sw: USB role switch
@@ -271,6 +288,7 @@ usb_role_switch_register(struct device *parent,
 		return ERR_PTR(-ENOMEM);
 
 	mutex_init(&sw->lock);
+	BLOCKING_INIT_NOTIFIER_HEAD(&sw->nh);
 
 	sw->allow_userspace_control = desc->allow_userspace_control;
 	sw->usb2_port = desc->usb2_port;
include/linux/usb/role.h +46 -0

57 lines not on this page · raw message

Signature · 1 line
2.15.0-rc2
author maintainer
#16 lore raw

PATCH v2 7/10 usb: dwc3: Registering a role switch in the DRD code.

In reply to Yu Chen

The Type-C drivers use USB role switch API to inform the system about the negotiated data role, so registering a role switch in the DRD code in order to support platforms with USB Type-C connectors.

Cc John Stultz <[email protected]>
Cc Felipe Balbi <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Heikki Krogerus <[email protected]>

---
v2:
* Assign fwnode in dwc3_role_switch.
---

---
 drivers/usb/dwc3/core.h |  2 ++
 drivers/usb/dwc3/drd.c  | 45 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)
drivers/usb/dwc3/core.h +2 -0
index 402b3c29eb26..7385544b9936 100644
@@ -25,6 +25,7 @@
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
 #include <linux/usb/otg.h>
+#include <linux/usb/role.h>
 #include <linux/ulpi/interface.h>
 
 #include <linux/phy/phy.h>
@@ -1083,6 +1084,7 @@ struct dwc3 {
 	struct extcon_dev	*edev;
 	struct notifier_block	edev_nb;
 	enum usb_phy_interface	hsphy_mode;
+	struct usb_role_switch	*role_sw;
 
 	u32			fladj;
 	u32			irq_gadget;
drivers/usb/dwc3/drd.c +45 -0

63 lines not on this page · raw message

Signature · 1 line
2.15.0-rc2
#17 lore raw

Re: [PATCH v2 07/10] usb: dwc3: Registering a role switch in the DRD code.

Hi,

On 18/02/2019 11:23, Yu Chen wrote:
[...]

Review int dwc3_drd_init(struct dwc3 *dwc) · line 562

Quoted 8 lines
(quoted diff) +4 -0
@@ -522,6 +556,15 @@ int dwc3_drd_init(struct dwc3 *dwc)
 		dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
 	}
 
+	dwc3_role_switch.fwnode = dev_fwnode(dwc->dev);
+	dwc3_role_switch.set = dwc3_usb_role_switch_set;
+	dwc3_role_switch.get = dwc3_usb_role_switch_get;
+	dwc->role_sw = usb_role_switch_register(dwc->dev, &dwc3_role_switch);

Building arm64 defconfig gives me this:

drivers/usb/dwc3/drd.o: In function `dwc3_drd_exit':
/home/valsch01/Work/kernel/drivers/usb/dwc3/drd.c:604: undefined reference to usb_role_switch_unregister' /home/valsch01/Work/kernel/drivers/usb/dwc3/drd.c:604:(.text+0x814): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol usb_role_switch_unregister' /home/valsch01/Work/kernel/drivers/usb/dwc3/drd.c:604: undefined reference to usb_role_switch_unregister' /home/valsch01/Work/kernel/drivers/usb/dwc3/drd.c:604:(.text+0x844): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol usb_role_switch_unregister' drivers/usb/dwc3/drd.o: In function `dwc3_drd_init':
/home/valsch01/Work/kernel/drivers/usb/dwc3/drd.c:562: undefined reference to usb_role_switch_register' /home/valsch01/Work/kernel/drivers/usb/dwc3/drd.c:562:(.text+0xa20): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol usb_role_switch_register' /home/valsch01/Work/kernel/drivers/usb/dwc3/drd.c:562: undefined reference to usb_role_switch_register' /home/valsch01/Work/kernel/drivers/usb/dwc3/drd.c:562:(.text+0xb4c): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol usb_role_switch_register' Makefile:1024: recipe for target 'vmlinux' failed
make: *** [vmlinux] Error 1

This has CONFIG_USB_ROLE_SWITCH=m, setting it as a built-in makes the thing linkable.

I suppose that's because defconfig gives us

CONFIG_USB_DWC3_DUAL_ROLE=y

but then that should probably force a CONFIG_USB_ROLE_SWITCH=y. My immediate reaction to this would be to add:

---

drivers/usb/dwc3/Kconfig +1 -0
index 2b1494460d0c..661b1d2efc8b 100644
@@ -44,6 +44,7 @@ config USB_DWC3_DUAL_ROLE
 	bool "Dual Role mode"
 	depends on ((USB=y || USB=USB_DWC3) && (USB_GADGET=y || USB_GADGET=USB_DWC3))
 	depends on (EXTCON=y || EXTCON=USB_DWC3)
+	select USB_ROLE_SWITCH
 	help
 	  This is the default mode of working of DWC3 controller where
 	  both host and gadget features are enabled.

---

Not sure how acceptable that is though.

Quoted 16 lines
(quoted diff) +7 -0
+	if (ret) {
+		dwc3_drd_exit(dwc);
+		return PTR_ERR(dwc->role_sw);
+	}
+
 	return 0;
 }
 
@@ -557,4 +600,6 @@ void dwc3_drd_exit(struct dwc3 *dwc)
 
 	if (!dwc->edev)
 		free_irq(dwc->otg_irq, dwc);
+
+	usb_role_switch_unregister(dwc->role_sw);
 }
author maintainer
#18 lore raw

Re: [PATCH v2 07/10] usb: dwc3: Registering a role switch in the DRD code.

Hi,

Quoted 53 lines · Valentin Schneider

Hi,

On 18/02/2019 11:23, Yu Chen wrote:
[...]

Review int dwc3_drd_init(struct dwc3 *dwc) · line 562

Quoted 8 lines
(quoted diff) +4 -0
@@ -522,6 +556,15 @@ int dwc3_drd_init(struct dwc3 *dwc)
 		dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
 	}
 
+	dwc3_role_switch.fwnode = dev_fwnode(dwc->dev);
+	dwc3_role_switch.set = dwc3_usb_role_switch_set;
+	dwc3_role_switch.get = dwc3_usb_role_switch_get;
+	dwc->role_sw = usb_role_switch_register(dwc->dev, &dwc3_role_switch);

Building arm64 defconfig gives me this:

drivers/usb/dwc3/drd.o: In function `dwc3_drd_exit':
/home/valsch01/Work/kernel/drivers/usb/dwc3/drd.c:604: undefined reference to usb_role_switch_unregister' /home/valsch01/Work/kernel/drivers/usb/dwc3/drd.c:604:(.text+0x814): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol usb_role_switch_unregister' /home/valsch01/Work/kernel/drivers/usb/dwc3/drd.c:604: undefined reference to usb_role_switch_unregister' /home/valsch01/Work/kernel/drivers/usb/dwc3/drd.c:604:(.text+0x844): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol usb_role_switch_unregister' drivers/usb/dwc3/drd.o: In function `dwc3_drd_init':
/home/valsch01/Work/kernel/drivers/usb/dwc3/drd.c:562: undefined reference to usb_role_switch_register' /home/valsch01/Work/kernel/drivers/usb/dwc3/drd.c:562:(.text+0xa20): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol usb_role_switch_register' /home/valsch01/Work/kernel/drivers/usb/dwc3/drd.c:562: undefined reference to usb_role_switch_register' /home/valsch01/Work/kernel/drivers/usb/dwc3/drd.c:562:(.text+0xb4c): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol usb_role_switch_register' Makefile:1024: recipe for target 'vmlinux' failed
make: *** [vmlinux] Error 1

This has CONFIG_USB_ROLE_SWITCH=m, setting it as a built-in makes the thing linkable.

I suppose that's because defconfig gives us

CONFIG_USB_DWC3_DUAL_ROLE=y

but then that should probably force a CONFIG_USB_ROLE_SWITCH=y. My immediate reaction to this would be to add:

---

drivers/usb/dwc3/Kconfig +1 -1
index 2b1494460d0c..661b1d2efc8b 100644
@@ -44,6 +44,7 @@ config USB_DWC3_DUAL_ROLE
 	bool "Dual Role mode"
 	depends on ((USB=y || USB=USB_DWC3) && (USB_GADGET=y || USB_GADGET=USB_DWC3))
 	depends on (EXTCON=y || EXTCON=USB_DWC3)
+	select USB_ROLE_SWITCH
 	help
 	  This is the default mode of working of DWC3 controller where
 	  both host and gadget features are enabled.
---
Quoted 2 lines

Not sure how acceptable that is though.

Thanks for your notice! I will add this in next version.

Quoted 11 lines
Quoted 11 lines
(quoted diff) +5 -0
+	if (ret) {
+		dwc3_drd_exit(dwc);
+		return PTR_ERR(dwc->role_sw);
+	}
+
 	return 0;
 }
 
@@ -557,4 +600,6 @@ void dwc3_drd_exit(struct dwc3 *dwc)
 
Quoted 9 lines

Review void dwc3_drd_exit(struct dwc3 *dwc) · line 605

Quoted 6 lines
(quoted diff) +2 -0
 	if (!dwc->edev)
 		free_irq(dwc->otg_irq, dwc);
+
+	usb_role_switch_unregister(dwc->role_sw);
 }

.

Thanks
Yu Chen

#19 lore raw

Re: [PATCH v2 07/10] usb: dwc3: Registering a role switch in the DRD code.

In reply to Yu Chen

Hi

Quoted 52 lines · Yu Chen <[email protected]> 于2019年2月18日周一 下午7:34写道:

The Type-C drivers use USB role switch API to inform the system about the negotiated data role, so registering a role switch in the DRD code in order to support platforms with USB Type-C connectors.

Cc John Stultz <[email protected]>
Cc Felipe Balbi <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Heikki Krogerus <[email protected]>

---
v2:
* Assign fwnode in dwc3_role_switch.
---

---
 drivers/usb/dwc3/core.h |  2 ++
 drivers/usb/dwc3/drd.c  | 45 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)
drivers/usb/dwc3/core.h +2 -0
index 402b3c29eb26..7385544b9936 100644
@@ -25,6 +25,7 @@
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
 #include <linux/usb/otg.h>
+#include <linux/usb/role.h>
 #include <linux/ulpi/interface.h>
 
 #include <linux/phy/phy.h>
@@ -1083,6 +1084,7 @@ struct dwc3 {
        struct extcon_dev       *edev;
        struct notifier_block   edev_nb;
        enum usb_phy_interface  hsphy_mode;
+       struct usb_role_switch  *role_sw;
 
        u32                     fladj;
        u32                     irq_gadget;
drivers/usb/dwc3/drd.c +3 -0
index 869725d15c74..cf977bb0d62e 100644
@@ -474,8 +474,42 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc)
        return edev;
 }
 
+static int dwc3_usb_role_switch_set(struct device *dev, enum usb_role role)
+{
+       u32 mode;

drivers/usb/dwc3/drd.c static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) · line 489

Quoted 10 lines
drivers/usb/dwc3/drd.c +10 -0
+
+       switch (role) {
+       case USB_ROLE_HOST:
+               mode = DWC3_GCTL_PRTCAP_HOST;
+               break;
+       case USB_ROLE_DEVICE:
+               mode = DWC3_GCTL_PRTCAP_DEVICE;
+               break;
+       default:
+               mode = DWC3_GCTL_PRTCAP_HOST;

I'd propose let dwc3 stay at device mode at default case.

Quoted 29 lines
drivers/usb/dwc3/drd.c +21 -0
+               break;
+       };
+
+       dwc3_set_mode(dev_get_drvdata(dev), mode);
+       return 0;
+}
+
+static enum usb_role dwc3_usb_role_switch_get(struct device *dev)
+{
+       struct dwc3 *dwc = dev_get_drvdata(dev);
+       unsigned long flags;
+       enum usb_role role;
+
+       spin_lock_irqsave(&dwc->lock, flags);
+       role = dwc->current_otg_role;
+       spin_unlock_irqrestore(&dwc->lock, flags);
+
+       return role;
+}
+
 int dwc3_drd_init(struct dwc3 *dwc)
 {
+       struct usb_role_switch_desc dwc3_role_switch = {0};
        int ret, irq;
 
        dwc->edev = dwc3_get_extcon(dwc);
@@ -522,6 +556,15 @@ int dwc3_drd_init(struct dwc3 *dwc)
                dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
        }

drivers/usb/dwc3/drd.c int dwc3_drd_init(struct dwc3 *dwc) · line 567

Quoted 10 lines
drivers/usb/dwc3/drd.c +9 -0
 
+       dwc3_role_switch.fwnode = dev_fwnode(dwc->dev);
+       dwc3_role_switch.set = dwc3_usb_role_switch_set;
+       dwc3_role_switch.get = dwc3_usb_role_switch_get;
+       dwc->role_sw = usb_role_switch_register(dwc->dev, &dwc3_role_switch);
+       if (ret) {
+               dwc3_drd_exit(dwc);
+               return PTR_ERR(dwc->role_sw);
+       }
+

My understanding is, if you use usb role switch, you don't need either edev or OTG block event, so this should be like:

if (device_property_read_bool(dwc->dev, "usb-role-switch")) {
           usb role switch register;
} else if (edev) {

...
} else {
...
}

Jun

Quoted 13 lines
drivers/usb/dwc3/drd.c +2 -1
        return 0;
 }
 
@@ -557,4 +600,6 @@ void dwc3_drd_exit(struct dwc3 *dwc)
 
        if (!dwc->edev)
                free_irq(dwc->otg_irq, dwc);
+
+       usb_role_switch_unregister(dwc->role_sw);
 }
--

2.15.0-rc2

author maintainer
#20 lore raw

Re: [PATCH v2 07/10] usb: dwc3: Registering a role switch in the DRD code.

Hi,

Quoted 17 lines · Jun Li
Quoted 4 lines
drivers/usb/dwc3/drd.c +3 -0
+static int dwc3_usb_role_switch_set(struct device *dev, enum usb_role role)
+{
+       u32 mode;

drivers/usb/dwc3/drd.c static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) · line 489

Quoted 10 lines
drivers/usb/dwc3/drd.c +10 -0
+
+       switch (role) {
+       case USB_ROLE_HOST:
+               mode = DWC3_GCTL_PRTCAP_HOST;
+               break;
+       case USB_ROLE_DEVICE:
+               mode = DWC3_GCTL_PRTCAP_DEVICE;
+               break;
+       default:
+               mode = DWC3_GCTL_PRTCAP_HOST;

I'd propose let dwc3 stay at device mode at default case.

Setting mode to DWC3_GCTL_PRTCAP_HOST at default case due to the requirement of Hikey960 board. When there is no cable connected to type-C port, dwc3 should be set to HOST mode and the hub on the Hikey960 will be power on.
Here is the details of the Hikey960:
https://www.96boards.org/documentation/consumer/hikey/hikey960/hardware-docs/hardware-user-manual.md.html

But I will check the code to see if it is possible to make dwc3 set to device mode at default case.

Quoted 43 lines
Quoted 29 lines
drivers/usb/dwc3/drd.c +21 -0
+               break;
+       };
+
+       dwc3_set_mode(dev_get_drvdata(dev), mode);
+       return 0;
+}
+
+static enum usb_role dwc3_usb_role_switch_get(struct device *dev)
+{
+       struct dwc3 *dwc = dev_get_drvdata(dev);
+       unsigned long flags;
+       enum usb_role role;
+
+       spin_lock_irqsave(&dwc->lock, flags);
+       role = dwc->current_otg_role;
+       spin_unlock_irqrestore(&dwc->lock, flags);
+
+       return role;
+}
+
 int dwc3_drd_init(struct dwc3 *dwc)
 {
+       struct usb_role_switch_desc dwc3_role_switch = {0};
        int ret, irq;
 
        dwc->edev = dwc3_get_extcon(dwc);
@@ -522,6 +556,15 @@ int dwc3_drd_init(struct dwc3 *dwc)
                dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
        }

drivers/usb/dwc3/drd.c int dwc3_drd_init(struct dwc3 *dwc) · line 567

Quoted 10 lines
drivers/usb/dwc3/drd.c +9 -0
 
+       dwc3_role_switch.fwnode = dev_fwnode(dwc->dev);
+       dwc3_role_switch.set = dwc3_usb_role_switch_set;
+       dwc3_role_switch.get = dwc3_usb_role_switch_get;
+       dwc->role_sw = usb_role_switch_register(dwc->dev, &dwc3_role_switch);
+       if (ret) {
+               dwc3_drd_exit(dwc);
+               return PTR_ERR(dwc->role_sw);
+       }
+

My understanding is, if you use usb role switch, you don't need either edev or OTG block event, so this should be like:

Quoted 7 lines
if (device_property_read_bool(dwc->dev, "usb-role-switch")) {
           usb role switch register;
} else if (edev) {

...
} else {
...
}

Yes. Thanks!

Quoted 7 lines

Jun

Quoted 5 lines
drivers/usb/dwc3/drd.c +0 -0
        return 0;
 }
 
@@ -557,4 +600,6 @@ void dwc3_drd_exit(struct dwc3 *dwc)
 
Quoted 11 lines
Quoted 8 lines
drivers/usb/dwc3/drd.c +2 -1
        if (!dwc->edev)
                free_irq(dwc->otg_irq, dwc);
+
+       usb_role_switch_unregister(dwc->role_sw);
 }
--

2.15.0-rc2

.

Thanks
Yu Chen

author maintainer
#21 lore raw

PATCH v2 8/10 hikey960: Support usb functionality of Hikey960

In reply to Yu Chen

This driver handles usb hub power on and typeC port event of HiKey960 board:
1)DP&DM switching between usb hub and typeC port base on typeC port state
2)Control power of usb hub on Hikey960
3)Control vbus of typeC port

Cc Andy Shevchenko <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc John Stultz <[email protected]>
Cc Binghui Wang <[email protected]>
Cc Heikki Krogerus <[email protected]>

---
v1:
* Using gpiod API with the gpios.
* Removing registering usb role switch.
* Registering usb role switch notifier.
v2:
* Fix license declaration.
* Add configuration of gpio direction.
* Remove some log print.
---

---
 drivers/misc/Kconfig          |   6 ++
 drivers/misc/Makefile         |   1 +
 drivers/misc/hisi_hikey_usb.c | 181 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 188 insertions(+)
 create mode 100644 drivers/misc/hisi_hikey_usb.c
drivers/misc/Kconfig +6 -0
index f417b06e11c5..8d8b717759e2 100644
@@ -521,6 +521,12 @@ config PVPANIC
 	  a paravirtualized device provided by QEMU; it lets a virtual machine
 	  (guest) communicate panic events to the host.
 
+config HISI_HIKEY_USB
+	tristate "USB functionality of HiSilicon Hikey Platform"
+	depends on OF && GPIOLIB
+	help
+	  If you say yes here you get support for usb functionality of HiSilicon Hikey Platform.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +1 -0
index e39ccbbc1b3a..dc8892b13a1a 100644
@@ -59,3 +59,4 @@ obj-$(CONFIG_PCI_ENDPOINT_TEST)	+= pci_endpoint_test.o
 obj-$(CONFIG_OCXL)		+= ocxl/
 obj-y				+= cardreader/
 obj-$(CONFIG_PVPANIC)   	+= pvpanic.o
+obj-$(CONFIG_HISI_HIKEY_USB)	+= hisi_hikey_usb.o
drivers/misc/hisi_hikey_usb.c new file +181 -0

181 lines not on this page · raw message

Signature · 1 line
2.15.0-rc2
#22 lore raw

Re: [PATCH v2 08/10] hikey960: Support usb functionality of Hikey960

Hi,

Quoted 167 lines · Yu Chen

This driver handles usb hub power on and typeC port event of HiKey960 board:
1)DP&DM switching between usb hub and typeC port base on typeC port state
2)Control power of usb hub on Hikey960
3)Control vbus of typeC port

Cc Andy Shevchenko <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc John Stultz <[email protected]>
Cc Binghui Wang <[email protected]>
Cc Heikki Krogerus <[email protected]>

---
v1:
* Using gpiod API with the gpios.
* Removing registering usb role switch.
* Registering usb role switch notifier.
v2:
* Fix license declaration.
* Add configuration of gpio direction.
* Remove some log print.
---

---
 drivers/misc/Kconfig          |   6 ++
 drivers/misc/Makefile         |   1 +
 drivers/misc/hisi_hikey_usb.c | 181 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 188 insertions(+)
 create mode 100644 drivers/misc/hisi_hikey_usb.c
drivers/misc/Kconfig +6 -0
index f417b06e11c5..8d8b717759e2 100644
@@ -521,6 +521,12 @@ config PVPANIC
 	  a paravirtualized device provided by QEMU; it lets a virtual machine
 	  (guest) communicate panic events to the host.
 
+config HISI_HIKEY_USB
+	tristate "USB functionality of HiSilicon Hikey Platform"
+	depends on OF && GPIOLIB
+	help
+	  If you say yes here you get support for usb functionality of HiSilicon Hikey Platform.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +1 -0
index e39ccbbc1b3a..dc8892b13a1a 100644
@@ -59,3 +59,4 @@ obj-$(CONFIG_PCI_ENDPOINT_TEST)	+= pci_endpoint_test.o
 obj-$(CONFIG_OCXL)		+= ocxl/
 obj-y				+= cardreader/
 obj-$(CONFIG_PVPANIC)   	+= pvpanic.o
+obj-$(CONFIG_HISI_HIKEY_USB)	+= hisi_hikey_usb.o
drivers/misc/hisi_hikey_usb.c new file +104 -0
new file mode 100644
index 000000000000..70013f8e76f0
@@ -0,0 +1,181 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Support for usb functionality of Hikey series boards
+ * based on Hisilicon Kirin Soc.
+ *
+ * Copyright (C) 2017-2018 Hilisicon Electronics Co., Ltd.
+ *		http://www.huawei.com
+ *
+ * Authors: Yu Chen <[email protected]>
+ */
+
+#include <linux/gpio/consumer.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/notifier.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/usb/role.h>
+
+#define DEVICE_DRIVER_NAME "hisi_hikey_usb"
+
+#define HUB_VBUS_POWER_ON 1
+#define HUB_VBUS_POWER_OFF 0
+#define USB_SWITCH_TO_HUB 1
+#define USB_SWITCH_TO_TYPEC 0
+
+struct hisi_hikey_usb {
+	struct gpio_desc *otg_switch;
+	struct gpio_desc *typec_vbus;
+	struct gpio_desc *hub_vbus;
+	int typec_vbus_enable_val;
+
+	struct usb_role_switch *role_sw;
+	struct notifier_block nb;
+};
+
+static void hub_power_ctrl(struct hisi_hikey_usb *hisi_hikey_usb, int value)
+{
+	gpiod_set_value_cansleep(hisi_hikey_usb->hub_vbus, value);
+}
+
+static void usb_switch_ctrl(struct hisi_hikey_usb *hisi_hikey_usb,
+		int switch_to)
+{
+	gpiod_set_value_cansleep(hisi_hikey_usb->otg_switch, switch_to);
+}
+
+static void usb_typec_power_ctrl(struct hisi_hikey_usb *hisi_hikey_usb,
+		int value)
+{
+	gpiod_set_value_cansleep(hisi_hikey_usb->typec_vbus, value);
+}
+
+static int hisi_hikey_role_switch(struct notifier_block *nb,
+			unsigned long state, void *data)
+{
+	struct hisi_hikey_usb *hisi_hikey_usb;
+
+	hisi_hikey_usb = container_of(nb, struct hisi_hikey_usb, nb);
+
+	switch (state) {
+	case USB_ROLE_NONE:
+		usb_typec_power_ctrl(hisi_hikey_usb,
+				!hisi_hikey_usb->typec_vbus_enable_val);
+		usb_switch_ctrl(hisi_hikey_usb, USB_SWITCH_TO_HUB);
+		hub_power_ctrl(hisi_hikey_usb, HUB_VBUS_POWER_ON);
+		break;
+	case USB_ROLE_HOST:
+		usb_switch_ctrl(hisi_hikey_usb, USB_SWITCH_TO_TYPEC);
+		usb_typec_power_ctrl(hisi_hikey_usb,
+				hisi_hikey_usb->typec_vbus_enable_val);
+		break;
+	case USB_ROLE_DEVICE:
+		hub_power_ctrl(hisi_hikey_usb, HUB_VBUS_POWER_OFF);
+		usb_typec_power_ctrl(hisi_hikey_usb,
+				!hisi_hikey_usb->typec_vbus_enable_val);
+		usb_switch_ctrl(hisi_hikey_usb, USB_SWITCH_TO_TYPEC);
+		break;
+	default:
+		break;
+	}
+
+	return 0;
+}
+
+static int hisi_hikey_usb_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *root = dev->of_node;
+	struct hisi_hikey_usb *hisi_hikey_usb;
+	int ret;
+
+	hisi_hikey_usb = devm_kzalloc(dev, sizeof(*hisi_hikey_usb), GFP_KERNEL);
+	if (!hisi_hikey_usb)
+		return -ENOMEM;
+
+	hisi_hikey_usb->nb.notifier_call = hisi_hikey_role_switch;
+
+	ret = of_property_read_u32(root, "typec-vbus-enable-val",
+				   &hisi_hikey_usb->typec_vbus_enable_val);
+	if (ret)
+		hisi_hikey_usb->typec_vbus_enable_val = 1;
+

drivers/misc/hisi_hikey_usb.c line 114

Quoted 10 lines
drivers/misc/hisi_hikey_usb.c new file +10 -0
+	hisi_hikey_usb->typec_vbus = devm_gpiod_get(dev, "typec-vbus",
+			hisi_hikey_usb->typec_vbus_enable_val ?
+			GPIOD_OUT_LOW : GPIOD_OUT_HIGH);
+	if (!hisi_hikey_usb->typec_vbus)
+		return -ENOENT;
+	else if (IS_ERR(hisi_hikey_usb->typec_vbus))
+		return PTR_ERR(hisi_hikey_usb->typec_vbus);
+
+	gpiod_direction_output(hisi_hikey_usb->typec_vbus,
+			!hisi_hikey_usb->typec_vbus_enable_val);

maybe a simple way if use fixed regulator?

Quoted 6 lines
drivers/misc/hisi_hikey_usb.c new file +6 -0
+
+	hisi_hikey_usb->otg_switch = devm_gpiod_get(dev, "otg-switch", GPIOD_IN);
+	if (!hisi_hikey_usb->otg_switch)
+		return -ENOENT;
+	else if (IS_ERR(hisi_hikey_usb->otg_switch))
+		return PTR_ERR(hisi_hikey_usb->otg_switch);

drivers/misc/hisi_hikey_usb.c line 130

Quoted 10 lines
drivers/misc/hisi_hikey_usb.c new file +10 -0
+
+	gpiod_direction_output(hisi_hikey_usb->otg_switch, USB_SWITCH_TO_HUB);
+
+	/* hub-vdd33-en is optional */
+	hisi_hikey_usb->hub_vbus = devm_gpiod_get(dev, "hub-vdd33-en",
+			GPIOD_OUT_LOW);
+	if (IS_ERR(hisi_hikey_usb->hub_vbus))
+		return PTR_ERR(hisi_hikey_usb->hub_vbus);
+
+	gpiod_direction_output(hisi_hikey_usb->hub_vbus, HUB_VBUS_POWER_ON);

ditto

Quoted 51 lines
drivers/misc/hisi_hikey_usb.c new file +51 -0
+
+	hisi_hikey_usb->role_sw = usb_role_switch_get(dev);
+	if (!hisi_hikey_usb->role_sw)
+		return -EPROBE_DEFER;
+	else if (IS_ERR(hisi_hikey_usb->role_sw))
+		return PTR_ERR(hisi_hikey_usb->role_sw);
+
+	ret = usb_role_switch_register_notifier(hisi_hikey_usb->role_sw,
+			&hisi_hikey_usb->nb);
+	if (ret) {
+		usb_role_switch_put(hisi_hikey_usb->role_sw);
+		return ret;
+	}
+
+	platform_set_drvdata(pdev, hisi_hikey_usb);
+
+	return 0;
+}
+
+static int  hisi_hikey_usb_remove(struct platform_device *pdev)
+{
+	struct hisi_hikey_usb *hisi_hikey_usb = platform_get_drvdata(pdev);
+
+	usb_role_switch_unregister_notifier(hisi_hikey_usb->role_sw,
+			&hisi_hikey_usb->nb);
+
+	usb_role_switch_put(hisi_hikey_usb->role_sw);
+
+	return 0;
+}
+
+static const struct of_device_id id_table_hisi_hikey_usb[] = {
+	{.compatible = "hisilicon,gpio_hubv1"},
+	{.compatible = "hisilicon,hikey960_usb"},
+	{}
+};
+
+static struct platform_driver hisi_hikey_usb_driver = {
+	.probe = hisi_hikey_usb_probe,
+	.remove = hisi_hikey_usb_remove,
+	.driver = {
+		.name = DEVICE_DRIVER_NAME,
+		.of_match_table = id_table_hisi_hikey_usb,
+	},
+};
+
+module_platform_driver(hisi_hikey_usb_driver);
+
+MODULE_AUTHOR("Yu Chen <[email protected]>");
+MODULE_DESCRIPTION("Driver Support for USB functionality of Hikey");
+MODULE_LICENSE("GPL v2");
author maintainer
#23 lore raw

Re: [PATCH v2 08/10] hikey960: Support usb functionality of Hikey960

Hi,

Quoted 6 lines · Chunfeng Yun
Quoted 6 lines
drivers/misc/hisi_hikey_usb.c new file +6 -0
+	if (ret)
+		hisi_hikey_usb->typec_vbus_enable_val = 1;
+
+	hisi_hikey_usb->typec_vbus = devm_gpiod_get(dev, "typec-vbus",
+			hisi_hikey_usb->typec_vbus_enable_val ?
+			GPIOD_OUT_LOW : GPIOD_OUT_HIGH);
Quoted 9 lines

drivers/misc/hisi_hikey_usb.c line 114

Quoted 7 lines
drivers/misc/hisi_hikey_usb.c new file +7 -0
+	if (!hisi_hikey_usb->typec_vbus)
+		return -ENOENT;
+	else if (IS_ERR(hisi_hikey_usb->typec_vbus))
+		return PTR_ERR(hisi_hikey_usb->typec_vbus);
+
+	gpiod_direction_output(hisi_hikey_usb->typec_vbus,
+			!hisi_hikey_usb->typec_vbus_enable_val);

maybe a simple way if use fixed regulator?

The hardware of the Hikey960 board has been fixed, and the type-c port can act as UFP. So it is better to close the vbus when Hikey960 connect to host(e.g PC).

Quoted 17 lines
Quoted 6 lines
drivers/misc/hisi_hikey_usb.c new file +6 -0
+
+	hisi_hikey_usb->otg_switch = devm_gpiod_get(dev, "otg-switch", GPIOD_IN);
+	if (!hisi_hikey_usb->otg_switch)
+		return -ENOENT;
+	else if (IS_ERR(hisi_hikey_usb->otg_switch))
+		return PTR_ERR(hisi_hikey_usb->otg_switch);

drivers/misc/hisi_hikey_usb.c line 130

Quoted 10 lines
drivers/misc/hisi_hikey_usb.c new file +10 -0
+
+	gpiod_direction_output(hisi_hikey_usb->otg_switch, USB_SWITCH_TO_HUB);
+
+	/* hub-vdd33-en is optional */
+	hisi_hikey_usb->hub_vbus = devm_gpiod_get(dev, "hub-vdd33-en",
+			GPIOD_OUT_LOW);
+	if (IS_ERR(hisi_hikey_usb->hub_vbus))
+		return PTR_ERR(hisi_hikey_usb->hub_vbus);
+
+	gpiod_direction_output(hisi_hikey_usb->hub_vbus, HUB_VBUS_POWER_ON);

ditto

Quoted 7 lines

drivers/misc/hisi_hikey_usb.c line 137

Quoted 7 lines
drivers/misc/hisi_hikey_usb.c new file +7 -0
+
+	hisi_hikey_usb->role_sw = usb_role_switch_get(dev);
+	if (!hisi_hikey_usb->role_sw)
+		return -EPROBE_DEFER;
+	else if (IS_ERR(hisi_hikey_usb->role_sw))
+		return PTR_ERR(hisi_hikey_usb->role_sw);
+

Thanks
Yu Chen

#24 lore raw

Re: [PATCH v2 08/10] hikey960: Support usb functionality of Hikey960

Quoted 18 lines · Chen Yu

Hi,

Quoted 6 lines · Chunfeng Yun
Quoted 6 lines
drivers/misc/hisi_hikey_usb.c new file +6 -0
+	if (ret)
+		hisi_hikey_usb->typec_vbus_enable_val = 1;
+
+	hisi_hikey_usb->typec_vbus = devm_gpiod_get(dev, "typec-vbus",
+			hisi_hikey_usb->typec_vbus_enable_val ?
+			GPIOD_OUT_LOW : GPIOD_OUT_HIGH);
Quoted 9 lines

drivers/misc/hisi_hikey_usb.c line 114

Quoted 7 lines
drivers/misc/hisi_hikey_usb.c new file +7 -0
+	if (!hisi_hikey_usb->typec_vbus)
+		return -ENOENT;
+	else if (IS_ERR(hisi_hikey_usb->typec_vbus))
+		return PTR_ERR(hisi_hikey_usb->typec_vbus);
+
+	gpiod_direction_output(hisi_hikey_usb->typec_vbus,
+			!hisi_hikey_usb->typec_vbus_enable_val);

maybe a simple way if use fixed regulator?

Quoted 3 lines

The hardware of the Hikey960 board has been fixed, and the type-c port can act as UFP. So it is better to close the vbus when Hikey960 connect to host(e.g PC).

I guess you misunderstand what I mean?
Please refer to bindings/regulator/fixed-regulator.txt
If you control vbus by gpio, you can use fixed-regulator, it will be easy to make compatible with other cases, think about using a LDO to control vbus

Quoted 28 lines
Quoted 17 lines
Quoted 6 lines
drivers/misc/hisi_hikey_usb.c new file +6 -0
+
+	hisi_hikey_usb->otg_switch = devm_gpiod_get(dev, "otg-switch", GPIOD_IN);
+	if (!hisi_hikey_usb->otg_switch)
+		return -ENOENT;
+	else if (IS_ERR(hisi_hikey_usb->otg_switch))
+		return PTR_ERR(hisi_hikey_usb->otg_switch);

drivers/misc/hisi_hikey_usb.c line 130

Quoted 10 lines
drivers/misc/hisi_hikey_usb.c new file +10 -0
+
+	gpiod_direction_output(hisi_hikey_usb->otg_switch, USB_SWITCH_TO_HUB);
+
+	/* hub-vdd33-en is optional */
+	hisi_hikey_usb->hub_vbus = devm_gpiod_get(dev, "hub-vdd33-en",
+			GPIOD_OUT_LOW);
+	if (IS_ERR(hisi_hikey_usb->hub_vbus))
+		return PTR_ERR(hisi_hikey_usb->hub_vbus);
+
+	gpiod_direction_output(hisi_hikey_usb->hub_vbus, HUB_VBUS_POWER_ON);

ditto

Quoted 7 lines

drivers/misc/hisi_hikey_usb.c line 137

Quoted 7 lines
drivers/misc/hisi_hikey_usb.c new file +7 -0
+
+	hisi_hikey_usb->role_sw = usb_role_switch_get(dev);
+	if (!hisi_hikey_usb->role_sw)
+		return -EPROBE_DEFER;
+	else if (IS_ERR(hisi_hikey_usb->role_sw))
+		return PTR_ERR(hisi_hikey_usb->role_sw);
+

Thanks
Yu Chen

author maintainer
#25 lore raw

Re: [PATCH v2 08/10] hikey960: Support usb functionality of Hikey960

Hi Chunfeng Yun,

Quoted 19 lines · Chunfeng Yun
Quoted 18 lines · Chen Yu

Hi,

Quoted 15 lines · Chunfeng Yun

drivers/misc/hisi_hikey_usb.c line 114

Quoted 13 lines
drivers/misc/hisi_hikey_usb.c new file +13 -0
+	if (ret)
+		hisi_hikey_usb->typec_vbus_enable_val = 1;
+
+	hisi_hikey_usb->typec_vbus = devm_gpiod_get(dev, "typec-vbus",
+			hisi_hikey_usb->typec_vbus_enable_val ?
+			GPIOD_OUT_LOW : GPIOD_OUT_HIGH);
+	if (!hisi_hikey_usb->typec_vbus)
+		return -ENOENT;
+	else if (IS_ERR(hisi_hikey_usb->typec_vbus))
+		return PTR_ERR(hisi_hikey_usb->typec_vbus);
+
+	gpiod_direction_output(hisi_hikey_usb->typec_vbus,
+			!hisi_hikey_usb->typec_vbus_enable_val);

maybe a simple way if use fixed regulator?

Quoted 8 lines
Quoted 3 lines

The hardware of the Hikey960 board has been fixed, and the type-c port can act as UFP. So it is better to close the vbus when Hikey960 connect to host(e.g PC).

I guess you misunderstand what I mean?
Please refer to bindings/regulator/fixed-regulator.txt
If you control vbus by gpio, you can use fixed-regulator, it will be easy to make compatible with other cases, think about using a LDO to control vbus

Sorry for misunderstanding the fixed-regulator and thanks for your advice! I have read bindings/regulator/fixed-regulator.txt and I think it is enough to use gpiod API right now.

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 6 lines
drivers/misc/hisi_hikey_usb.c new file +6 -0
+
+	hisi_hikey_usb->otg_switch = devm_gpiod_get(dev, "otg-switch", GPIOD_IN);
+	if (!hisi_hikey_usb->otg_switch)
+		return -ENOENT;
+	else if (IS_ERR(hisi_hikey_usb->otg_switch))
+		return PTR_ERR(hisi_hikey_usb->otg_switch);

drivers/misc/hisi_hikey_usb.c line 130

Quoted 10 lines
drivers/misc/hisi_hikey_usb.c new file +10 -0
+
+	gpiod_direction_output(hisi_hikey_usb->otg_switch, USB_SWITCH_TO_HUB);
+
+	/* hub-vdd33-en is optional */
+	hisi_hikey_usb->hub_vbus = devm_gpiod_get(dev, "hub-vdd33-en",
+			GPIOD_OUT_LOW);
+	if (IS_ERR(hisi_hikey_usb->hub_vbus))
+		return PTR_ERR(hisi_hikey_usb->hub_vbus);
+
+	gpiod_direction_output(hisi_hikey_usb->hub_vbus, HUB_VBUS_POWER_ON);

ditto

Quoted 12 lines
Quoted 11 lines
Quoted 7 lines

drivers/misc/hisi_hikey_usb.c line 137

Quoted 7 lines
drivers/misc/hisi_hikey_usb.c new file +7 -0
+
+	hisi_hikey_usb->role_sw = usb_role_switch_get(dev);
+	if (!hisi_hikey_usb->role_sw)
+		return -EPROBE_DEFER;
+	else if (IS_ERR(hisi_hikey_usb->role_sw))
+		return PTR_ERR(hisi_hikey_usb->role_sw);
+

Thanks
Yu Chen

Thanks
Yu Chen

author maintainer
#26 lore raw

PATCH v2 9/10 usb: gadget: Add configfs attribuite for controling match_existing_only

In reply to Yu Chen

Currently the "match_existing_only" of usb_gadget_driver in configfs is set to one which is not flexible.
Dwc3 udc will be removed when usb core switch to host mode. This causes failure of writing name of dwc3 udc to configfs's UDC attribuite. To fix this we need to add a way to change the config of "match_existing_only".
There are systems like Android do not support udev, so adding "match_existing_only" attribute to allow configuration by user is cost little. This patch adds a configfs attribuite for controling match_existing_only which allow user to config "match_existing_only".

Cc Andy Shevchenko <[email protected]>
Cc Felipe Balbi <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc John Stultz <[email protected]>
Cc Binghui Wang <[email protected]>
---
 drivers/usb/gadget/configfs.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
drivers/usb/gadget/configfs.c +32 -0
index 025129942894..be85104bfab9 100644
@@ -291,6 +291,36 @@ static ssize_t gadget_dev_desc_UDC_store(struct config_item *item,
 	return ret;
 }
 
+static ssize_t gadget_driver_match_existing_only_store(struct config_item *item,
+		const char *page, size_t len)
+{
+	struct gadget_info *gi = to_gadget_info(item);
+	struct usb_gadget_driver *gadget_driver = &(gi->composite.gadget_driver);
+	bool match_existing_only;
+	int ret;
+
+	ret = kstrtobool(page, &match_existing_only);
+	if (ret)
+		return ret;
+
+	if (match_existing_only)
+		gadget_driver->match_existing_only = 1;
+	else
+		gadget_driver->match_existing_only = 0;
+
+	return len;
+}
+
+static ssize_t gadget_driver_match_existing_only_show(struct config_item *item,
+		char *page)
+{
+	struct gadget_info *gi = to_gadget_info(item);
+	struct usb_gadget_driver *gadget_driver = &(gi->composite.gadget_driver);
+	bool match_existing_only = !!gadget_driver->match_existing_only;
+
+	return sprintf(page, "%s\n", match_existing_only ? "true" : "false");
+}
+
 CONFIGFS_ATTR(gadget_dev_desc_, bDeviceClass);
 CONFIGFS_ATTR(gadget_dev_desc_, bDeviceSubClass);
 CONFIGFS_ATTR(gadget_dev_desc_, bDeviceProtocol);
@@ -300,6 +330,7 @@ CONFIGFS_ATTR(gadget_dev_desc_, idProduct);
 CONFIGFS_ATTR(gadget_dev_desc_, bcdDevice);
 CONFIGFS_ATTR(gadget_dev_desc_, bcdUSB);
 CONFIGFS_ATTR(gadget_dev_desc_, UDC);
+CONFIGFS_ATTR(gadget_, driver_match_existing_only);
 
 static struct configfs_attribute *gadget_root_attrs[] = {
 	&gadget_dev_desc_attr_bDeviceClass,
@@ -311,6 +342,7 @@ static struct configfs_attribute *gadget_root_attrs[] = {
 	&gadget_dev_desc_attr_bcdDevice,
 	&gadget_dev_desc_attr_bcdUSB,
 	&gadget_dev_desc_attr_UDC,
+	&gadget_attr_driver_match_existing_only,
 	NULL,
 };
 
Signature · 1 line
2.15.0-rc2
author maintainer
#27 lore raw

PATCH v2 10/10 dts: hi3660: Add support for usb on Hikey960

In reply to Yu Chen

This patch adds support for usb on Hikey960.

Cc Wei Xu <[email protected]>
Cc Rob Herring <[email protected]>
Cc Mark Rutland <[email protected]>
Cc John Stultz <[email protected]>
Cc Binghui Wang <[email protected]>

---
v2:
* Remove device_type property.
* Add property "usb-role-switch".
---

---
 arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts | 54 +++++++++++++++++
 arch/arm64/boot/dts/hisilicon/hi3660.dtsi         | 73 +++++++++++++++++++++++
 2 files changed, 127 insertions(+)
arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts +54 -0
index 46435466f1ab..2cada9d44046 100644
@@ -13,6 +13,7 @@
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
 #include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/usb/pd.h>
 
 / {
 	model = "HiKey960";
@@ -196,6 +197,27 @@
 			method = "smc";
 		};
 	};
+
+	hisi_hikey_usb: hisi_hikey_usb {
+		compatible = "hisilicon,hikey960_usb";
+		typec-vbus-gpios = <&gpio25 2 0>;
+		typec-vbus-enable-val = <1>;
+		otg-switch-gpios = <&gpio25 6 0>;
+		hub-vdd33-en-gpios = <&gpio5 6 0>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&usbhub5734_pmx_func>;
+
+		port {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			hikey_usb_ep: endpoint@0 {
+				reg = <0>;
+				remote-endpoint = <&dwc3_role_switch_notify>;
+			};
+		};
+	};
+
 };
 
 /*
@@ -526,6 +548,38 @@
 &i2c1 {
 	status = "okay";
 
+	rt1711h: rt1711h@4e {
+		compatible = "richtek,rt1711h";
+		reg = <0x4e>;
+		status = "ok";
+		interrupt-parent = <&gpio27>;
+		interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&usb_cfg_func>;
+
+		usb_con: connector {
+			compatible = "usb-c-connector";
+			label = "USB-C";
+			data-role = "dual";
+			power-role = "dual";
+			try-power-role = "sink";
+			source-pdos = <PDO_FIXED(5000, 500, PDO_FIXED_USB_COMM)>;
+			sink-pdos = <PDO_FIXED(5000, 500, PDO_FIXED_USB_COMM)
+				PDO_VAR(5000, 5000, 1000)>;
+			op-sink-microwatt = <10000000>;
+		};
+
+		port {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			rt1711h_ep: endpoint@0 {
+				reg = <0>;
+				remote-endpoint = <&dwc3_role_switch>;
+			};
+		};
+	};
+
 	adv7533: adv7533@39 {
 		status = "ok";
 		compatible = "adi,adv7533";
arch/arm64/boot/dts/hisilicon/hi3660.dtsi +73 -0

84 lines not on this page · raw message

Signature · 1 line
2.15.0-rc2
#28 lore raw
In reply to Yu Chen

Hi,

Quoted 6 lines · Yu Chen

The patchset adds support for usb functionality of Hikey960, includes:
- dwc3 driver for Hisilicon Kirin Soc hi3660
- usb driver for HiKey960 board
- some adjustment in dwc3, usb gadget and typec driver
- dts for support usb of HiKey960

I want to try this out on my HiKey960, but I can't get the USB A ports working (tried USB stick and USB eth adapter).

On top of the arm64 defconfig, I've enabled (with menuconfig):

	CONFIG_PHY_HI3660_USB
	CONFIG_HISI_HIKEY_USB

Am I missing something? FYI up until now I've carried over Fan Ning's old USB patch-set and that works fine, so I think it might just be a configuration error from my end.

Thanks,
Valentin

author maintainer
#29 lore raw

Hi,

Quoted 13 lines · Valentin Schneider

Hi,

Quoted 6 lines · Yu Chen

The patchset adds support for usb functionality of Hikey960, includes:
- dwc3 driver for Hisilicon Kirin Soc hi3660
- usb driver for HiKey960 board
- some adjustment in dwc3, usb gadget and typec driver
- dts for support usb of HiKey960

I want to try this out on my HiKey960, but I can't get the USB A ports working (tried USB stick and USB eth adapter).

Quoted 8 lines

On top of the arm64 defconfig, I've enabled (with menuconfig):

	CONFIG_PHY_HI3660_USB
	CONFIG_HISI_HIKEY_USB

Am I missing something? FYI up until now I've carried over Fan Ning's old USB patch-set and that works fine, so I think it might just be a configuration error from my end.

This patch set based on Heikki Krogerus's patches.
Have you applied https://do-db2.lkml.org/lkml/2019/2/13/106 first? And these configs should be set to y:

	CONFIG_TYPEC
	CONFIG_TYPEC_TCPM
	CONFIG_TYPEC_TCPCI
	CONFIG_TYPEC_RT1711H
Quoted 8 lines

Thanks,
Valentin

.

Thanks,
Yu Chen