Skip to contentSkip to conversation

usb: dwc3: add Realtek DHC RTD SoC dwc3 glue layer driver

PATCH Superseded Stanley Chang 2 participants 5 messages Aug 10, 2023 – Aug 11, 2023

Subsystems (3)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 usb: dwc3: add Realtek DHC RTD SoC dwc3 glue layer driver

Realtek DHC RTD SoCs integrate dwc3 IP and has some customizations to support different generations of SoCs.

---
v2 to v3 change:
Remove the support_drd_mode of struct dwc3_rtk. Remove unlink_usb3_port and disable_usb3_phy. Disabled usb3 phy if the max speed is not super-speed.
v1 to v2 change:
Remove the the code about the property realtek,enable-l4icg. Select USB_ROLE_SWITCH in Kconfig.
Add dependency OF and ARCH_REALTEK in Kconfig.

---
 drivers/usb/dwc3/Kconfig    |  11 +
 drivers/usb/dwc3/Makefile   |   1 +
 drivers/usb/dwc3/dwc3-rtk.c | 482 ++++++++++++++++++++++++++++++++++++
 3 files changed, 494 insertions(+)
 create mode 100644 drivers/usb/dwc3/dwc3-rtk.c
drivers/usb/dwc3/Kconfig +11 -0
index 98efcbb76c88..5fc27b20df63 100644
@@ -178,4 +178,15 @@ config USB_DWC3_OCTEON
 	  Only the host mode is currently supported.
 	  Say 'Y' or 'M' here if you have one such device.
 
+config USB_DWC3_RTK
+	tristate "Realtek DWC3 Platform Driver"
+	depends on OF && ARCH_REALTEK
+	default USB_DWC3
+	select USB_ROLE_SWITCH
+	help
+	  RTK DHC RTD SoCs with DesignWare Core USB3 IP inside,
+	  and IP Core configured for USB 2.0 and USB 3.0 in host
+	  or dual-role mode.
+	  Say 'Y' or 'M' if you have such device.
+
 endif
drivers/usb/dwc3/Makefile +1 -0
index fe1493d4bbe5..124eda2522d9 100644
@@ -55,3 +55,4 @@ obj-$(CONFIG_USB_DWC3_QCOM)		+= dwc3-qcom.o
 obj-$(CONFIG_USB_DWC3_IMX8MP)		+= dwc3-imx8mp.o
 obj-$(CONFIG_USB_DWC3_XILINX)		+= dwc3-xilinx.o
 obj-$(CONFIG_USB_DWC3_OCTEON)		+= dwc3-octeon.o
+obj-$(CONFIG_USB_DWC3_RTK)		+= dwc3-rtk.o
drivers/usb/dwc3/dwc3-rtk.c new file +482 -0

482 lines not on this page · raw message

Signature · 1 line
2.34.1
#1 lore raw

PATCH v3 2/2 dt-bindings: usb: dwc3: Add Realtek DHC RTD SoC DWC3 USB

Document the DWC3 USB bindings for Realtek SoCs.

---
v2 to v3 change:
Add description for reg
Remove property for realtek,unlink-usb3-port. Remove property for realtek,disable-usb3-phy. Use the maximum-speed instead of the above two properties.
v1 to v2 change:
Revise the subject.
Rename the file.
Fix dtschema warnings.
Remove the property realtek,enable-l4icg.
Drop status.

---
 .../bindings/usb/realtek,rtd-dwc3.yaml        | 80 +++++++++++++++++++
 1 file changed, 80 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/realtek,rtd-dwc3.yaml
Documentation/devicetree/bindings/usb/realtek,rtd-dwc3.yaml new file +80 -0
new file mode 100644
index 000000000000..cc66adc4b9da
@@ -0,0 +1,80 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2023 Realtek Semiconductor Corporation
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/usb/realtek,rtd-dwc3.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Realtek DWC3 USB SoC Controller Glue
+
+maintainers:
+  - Stanley Chang <[email protected]>
+
+description:
+  The Realtek DHC SoC embeds a DWC3 USB IP Core configured for USB 2.0
+  and USB 3.0 in host or dual-role mode.
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - realtek,rtd1295-dwc3
+          - realtek,rtd1315e-dwc3
+          - realtek,rtd1319-dwc3
+          - realtek,rtd1319d-dwc3
+          - realtek,rtd1395-dwc3
+          - realtek,rtd1619-dwc3
+          - realtek,rtd1619b-dwc3
+      - const: realtek,rtd-dwc3
+
+  reg:
+    description: Offset and length of register set for wrapper of dwc3 core.
+    maxItems: 1
+
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 1
+
+  ranges: true
+
+patternProperties:
+  "^usb@[0-9a-f]+$":
+    $ref: snps,dwc3.yaml#
+    description: Required child node
+
+required:
+  - compatible
+  - reg
+  - "#address-cells"
+  - "#size-cells"
+  - ranges
+
+additionalProperties: false
+
+examples:
+  - |
+    usb@98013e00 {
+        compatible = "realtek,rtd1319d-dwc3", "realtek,rtd-dwc3";
+        reg = <0x98013e00 0x200>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+        ranges;
+        maximum-speed = "high-speed";
+
+        usb@98050000 {
+            compatible = "snps,dwc3";
+            reg = <0x98050000 0x9000>;
+            interrupts = <0 94 4>;
+            phys = <&usb2phy &usb3phy>;
+            phy-names = "usb2-phy", "usb3-phy";
+            dr_mode = "otg";
+            usb-role-switch;
+            role-switch-default-mode = "host";
+            snps,dis_u2_susphy_quirk;
+            snps,parkmode-disable-ss-quirk;
+            snps,parkmode-disable-hs-quirk;
+            maximum-speed = "high-speed";
+        };
+    };
Signature · 1 line
2.34.1
maintainer
#2 lore raw

Re: [PATCH v3 2/2] dt-bindings: usb: dwc3: Add Realtek DHC RTD SoC DWC3 USB

Quoted 15 lines · Stanley Chang

Document the DWC3 USB bindings for Realtek SoCs.

---
v2 to v3 change:
Add description for reg
Remove property for realtek,unlink-usb3-port. Remove property for realtek,disable-usb3-phy. Use the maximum-speed instead of the above two properties.
v1 to v2 change:
Revise the subject.
Rename the file.
Fix dtschema warnings.
Remove the property realtek,enable-l4icg.
Drop status.

Quoted 5 lines
---
 .../bindings/usb/realtek,rtd-dwc3.yaml        | 80 +++++++++++++++++++
 1 file changed, 80 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/realtek,rtd-dwc3.yaml

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.

maintainer
#3 lore raw

Re: [PATCH v3 2/2] dt-bindings: usb: dwc3: Add Realtek DHC RTD SoC DWC3 USB

In reply to Stanley Chang
Quoted 80 lines · Stanley Chang

Document the DWC3 USB bindings for Realtek SoCs.

---
v2 to v3 change:
Add description for reg
Remove property for realtek,unlink-usb3-port. Remove property for realtek,disable-usb3-phy. Use the maximum-speed instead of the above two properties.
v1 to v2 change:
Revise the subject.
Rename the file.
Fix dtschema warnings.
Remove the property realtek,enable-l4icg.
Drop status.

---
 .../bindings/usb/realtek,rtd-dwc3.yaml        | 80 +++++++++++++++++++
 1 file changed, 80 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/realtek,rtd-dwc3.yaml
Documentation/devicetree/bindings/usb/realtek,rtd-dwc3.yaml new file +54 -0
new file mode 100644
index 000000000000..cc66adc4b9da
@@ -0,0 +1,80 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2023 Realtek Semiconductor Corporation
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/usb/realtek,rtd-dwc3.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Realtek DWC3 USB SoC Controller Glue
+
+maintainers:
+  - Stanley Chang <[email protected]>
+
+description:
+  The Realtek DHC SoC embeds a DWC3 USB IP Core configured for USB 2.0
+  and USB 3.0 in host or dual-role mode.
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - realtek,rtd1295-dwc3
+          - realtek,rtd1315e-dwc3
+          - realtek,rtd1319-dwc3
+          - realtek,rtd1319d-dwc3
+          - realtek,rtd1395-dwc3
+          - realtek,rtd1619-dwc3
+          - realtek,rtd1619b-dwc3
+      - const: realtek,rtd-dwc3
+
+  reg:
+    description: Offset and length of register set for wrapper of dwc3 core.
+    maxItems: 1
+
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 1
+
+  ranges: true
+
+patternProperties:
+  "^usb@[0-9a-f]+$":
+    $ref: snps,dwc3.yaml#
+    description: Required child node
+
+required:
+  - compatible
+  - reg
+  - "#address-cells"
+  - "#size-cells"
+  - ranges
+
+additionalProperties: false

Documentation/devicetree/bindings/usb/realtek,rtd-dwc3.yaml line 64

Quoted 10 lines
Documentation/devicetree/bindings/usb/realtek,rtd-dwc3.yaml new file +10 -0
+
+examples:
+  - |
+    usb@98013e00 {
+        compatible = "realtek,rtd1319d-dwc3", "realtek,rtd-dwc3";
+        reg = <0x98013e00 0x200>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+        ranges;
+        maximum-speed = "high-speed";

This should be a warning (the bot was having problems) as it is not defined for this node. It belongs in the child node as you also have, so drop it.

Quoted 19 lines
Documentation/devicetree/bindings/usb/realtek,rtd-dwc3.yaml new file +16 -0
+
+        usb@98050000 {
+            compatible = "snps,dwc3";
+            reg = <0x98050000 0x9000>;
+            interrupts = <0 94 4>;
+            phys = <&usb2phy &usb3phy>;
+            phy-names = "usb2-phy", "usb3-phy";
+            dr_mode = "otg";
+            usb-role-switch;
+            role-switch-default-mode = "host";
+            snps,dis_u2_susphy_quirk;
+            snps,parkmode-disable-ss-quirk;
+            snps,parkmode-disable-hs-quirk;
+            maximum-speed = "high-speed";
+        };
+    };
Signature · 1 line
2.34.1
#4 lore raw

RE: [PATCH v3 2/2] dt-bindings: usb: dwc3: Add Realtek DHC RTD SoC DWC3 USB

Hi Rob,

Quoted 5 lines
Quoted 5 lines
Documentation/devicetree/bindings/usb/realtek,rtd-dwc3.yaml new file +5 -0
+
+examples:
+  - |
+    usb@98013e00 {
+        compatible = "realtek,rtd1319d-dwc3", "realtek,rtd-dwc3";
Quoted 8 lines

Documentation/devicetree/bindings/usb/realtek,rtd-dwc3.yaml line 64

Quoted 5 lines
Documentation/devicetree/bindings/usb/realtek,rtd-dwc3.yaml new file +5 -0
+        reg = <0x98013e00 0x200>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+        ranges;
+        maximum-speed = "high-speed";

This should be a warning (the bot was having problems) as it is not defined for this node. It belongs in the child node as you also have, so drop it.

As I mentioned in the v1 patch, I have a problem.
This property maximum-speed belongs to dwc3.
When the dwc3-rtk setting disables USB 3.0 phy, dwc3 is not probed. So I can't use api usb_get_maximum_speed(dev) to get maximum-speed.

I added this property "maximum-speed" to the dwc3-rtk node, which is the same as the dwc3 core node. Is this configuration appropriate?
Or do you have any suggestion?

Quoted 11 lines
Quoted 11 lines
Documentation/devicetree/bindings/usb/realtek,rtd-dwc3.yaml new file +11 -0
+
+        usb@98050000 {
+            compatible = "snps,dwc3";
+            reg = <0x98050000 0x9000>;
+            interrupts = <0 94 4>;
+            phys = <&usb2phy &usb3phy>;
+            phy-names = "usb2-phy", "usb3-phy";
+            dr_mode = "otg";
+            usb-role-switch;
+            role-switch-default-mode = "host";
+            snps,dis_u2_susphy_quirk;
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/usb/realtek,rtd-dwc3.yaml new file +5 -1
+            snps,parkmode-disable-ss-quirk;
+            snps,parkmode-disable-hs-quirk;
+            maximum-speed = "high-speed";
+        };
+    };
--

2.34.1

Thanks,
Stanley