Skip to contentSkip to conversation

Add driver for ehci in Sunplus SP7021

PATCH Superseded Vincent Shih 4 participants 6 messages Feb 27, 2022 – Feb 28, 2022

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add driver for ehci in Sunplus SP7021

This is a patch series for ehci driver for Sunplus SP7021 SoC.

Sunplus SP7021 is an ARM Coretex A7 (4 cores) based SoC. It integrates many peripherals (ex: UART, I2C, SPI, SDIO, eMMC, USB, SD Card and etc.) into a single chip. It is designed for industrial control.

Refer to:
https://sunplus-tibbo.atlassian.net/wiki/spaces/doc/overview
https://tibbo.com/store/plus1.html

Vincent Shih (2):
usb: host: ehci-sunplus: Add driver for ehci in Sunplus SP7021
dt-bindings: usb: Add bindings doc for Sunplus EHCI driver

 .../bindings/usb/sunplus,sp7021-usb-ehci.yaml      |  97 ++++
 MAINTAINERS                                        |   7 +
 drivers/usb/host/Kconfig                           |  11 +
 drivers/usb/host/Makefile                          |   1 +
 drivers/usb/host/ehci-sunplus.c                    | 495 +++++++++++++++++++++
 5 files changed, 611 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/sunplus,sp7021-usb-ehci.yaml
 create mode 100644 drivers/usb/host/ehci-sunplus.c
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/2 usb: host: ehci-sunplus: Add driver for ehci in Sunplus SP7021

Add driver for ehci in Sunplus SP7021

---
Changes in v2:
- Address the comments by Rob Herring.
- Clean up codes.

 MAINTAINERS                     |   6 +
 drivers/usb/host/Kconfig        |  11 +
 drivers/usb/host/Makefile       |   1 +
 drivers/usb/host/ehci-sunplus.c | 495 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 513 insertions(+)
 create mode 100644 drivers/usb/host/ehci-sunplus.c
MAINTAINERS +6 -0
index 80eebc1..6c2faf3 100644
@@ -17947,6 +17947,12 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/net/ethernet/dlink/sundance.c
 
+SUNPLUS USB EHCI DRIVER
+M:	Vincent Shih <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/usb/host/ehci-sunplus.c
+
 SUPERH
 M:	Yoshinori Sato <[email protected]>
 M:	Rich Felker <[email protected]>
drivers/usb/host/Kconfig +11 -0
index c4736d1..9728d3b 100644
@@ -339,6 +339,17 @@ config USB_OCTEON_EHCI
 	  USB 2.0 device support.  All CN6XXX based chips with USB are
 	  supported.
 
+config USB_EHCI_SUNPLUS
+	tristate "EHCI support for Sunplus USB controller"
+	depends on SOC_SP7021
+	select NVMEM_SUNPLUS_OCOTP
+	help
+	  Enables support for the on-chip EHCI controller in Sunplus
+	  SoCs. It supports 32-bit AHB/AXI config bus and 64-bit AXI
+	  data bus.
+	  This driver can also be built as a module. If so, the module
+	  will be called ehci-sunplus.
+
 endif # USB_EHCI_HCD
 
 config USB_OXU210HP_HCD
drivers/usb/host/Makefile +1 -0
index 171de4d..7e9b5f1 100644
@@ -46,6 +46,7 @@ obj-$(CONFIG_USB_EHCI_HCD_STI)	+= ehci-st.o
 obj-$(CONFIG_USB_EHCI_EXYNOS)	+= ehci-exynos.o
 obj-$(CONFIG_USB_EHCI_HCD_AT91) += ehci-atmel.o
 obj-$(CONFIG_USB_EHCI_BRCMSTB)	+= ehci-brcm.o
+obj-$(CONFIG_USB_EHCI_SUNPLUS)	+= ehci-sunplus.o
 
 obj-$(CONFIG_USB_OXU210HP_HCD)	+= oxu210hp-hcd.o
 obj-$(CONFIG_USB_ISP116X_HCD)	+= isp116x-hcd.o
drivers/usb/host/ehci-sunplus.c new file +495 -0

495 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer
#2 lore raw

Re: [PATCH v2 1/2] usb: host: ehci-sunplus: Add driver for ehci in Sunplus SP7021

Quoted 10 lines · Vincent Shih

Add driver for ehci in Sunplus SP7021

---

drivers/usb/host/ehci-sunplus.c new file +5 -0
+static struct usb_ehci_pdata usb_ehci_pdata = {
+};
+
+static int ehci_sunplus_probe(struct platform_device *pdev)
+{

drivers/usb/host/ehci-sunplus.c line 269

Quoted 10 lines
drivers/usb/host/ehci-sunplus.c new file +10 -0
+	struct device *dev = &pdev->dev;
+	struct sp_ehci_priv *sp_priv;
+	struct resource *res_mem;
+	struct usb_hcd *hcd;
+	int irq, ret;
+
+	if (usb_disabled())
+		return -ENODEV;
+
+	pdev->dev.platform_data = &usb_ehci_pdata;

What reason is there for doing this? I can't see any justification for storing a pointer to data that contains nothing but zeros.

Alan Stern

#3 lore raw

PATCH v2 2/2 dt-bindings: usb: Add bindings doc for Sunplus EHCI driver

In reply to Vincent Shih

Add bindings doc for Sunplus EHCI driver

---
 .../bindings/usb/sunplus,sp7021-usb-ehci.yaml      | 97 ++++++++++++++++++++++
 MAINTAINERS                                        |  1 +
 2 files changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/sunplus,sp7021-usb-ehci.yaml
Documentation/devicetree/bindings/usb/sunplus,sp7021-usb-ehci.yaml new file +97 -0
new file mode 100644
index 0000000..e492f7a
@@ -0,0 +1,97 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) Sunplus Co., Ltd. 2021
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/usb/sunplus,sp7021-usb-ehci.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sunplus SP7021 EHCI Device Tree bindings for ehci0/ehci1
+
+maintainers:
+  - Vincent Shih <[email protected]>
+
+allOf:
+  - $ref: usb-hcd.yaml#
+
+properties:
+  compatible:
+    enum:
+      - sunplus,sp7021-usb-ehci0
+      - sunplus,sp7021-usb-ehci1
+
+  clocks:
+    maxItems: 2
+
+  clock-names:
+    items:
+      - const: usbc_clk
+      - const: uphy_clk
+
+  resets:
+    maxItems: 2
+
+  reset-names:
+    items:
+      - const: usbc_rst
+      - const: uphy_rst
+
+  reg:
+    items:
+      - description: USBC register region
+      - description: UPHY register region
+      - description: MOON4 register region
+
+  reg-names:
+    items:
+      - const: usbc
+      - const: uphy
+      - const: moon4
+
+  interrupts:
+    maxItems: 1
+
+  nvmem-cell-names:
+    description: names corresponding to the nvmem cells of disconnect voltage
+    const: disc_vol
+
+  nvmem-cells:
+    description: nvmem cell address of disconnect voltage
+    maxItems: 1
+
+  port-num:
+    description:  identify ehci0 (port0) and ehci1 (port1)
+
+required:
+  - compatible
+  - clocks
+  - clock-names
+  - resets
+  - reset-names
+  - reg
+  - reg-names
+  - interrupts
+  - nvmem-cell-names
+  - nvmem-cells
+  - port-num
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    sp_ehci0: usb@9c102100 {
+      compatible = "sunplus,sp7021-usb-ehci";
+      clocks = <&clkc 0x3a>, <&clkc 0x3d>;
+      clock-names = "usbc_clk", "uphy_clk";
+      resets = <&rstc 0x2a>, <&rstc 0x2d>;
+      reset-names = "usbc_rst", "uphy_rst";
+      reg = <0x9c102100 0x68>, <0x9c004a80 0x80>, <0x9c000200 0x80>;
+      reg-names = "usbc", "uphy", "moon4";
+      interrupt-parent = <&intc>;
+      interrupts = <14 IRQ_TYPE_LEVEL_HIGH>;
+      nvmem-cell-names = "disc_vol";
+      nvmem-cells = <&disc_vol>;
+      port-num = <0>;
+    };
+...
MAINTAINERS +1 -0
index 6c2faf3..49702c4 100644
@@ -17951,6 +17951,7 @@ SUNPLUS USB EHCI DRIVER
 M:	Vincent Shih <[email protected]>
 L:	[email protected]
 S:	Maintained
+F:	Documentation/devicetree/bindings/nvmem/sunplus,sp7021-ocotp.yaml
 F:	drivers/usb/host/ehci-sunplus.c
 
 SUPERH
Signature · 1 line
2.7.4
#4 lore raw

Re: [PATCH v2 2/2] dt-bindings: usb: Add bindings doc for Sunplus EHCI driver

Quoted 25 lines · Vincent Shih

Add bindings doc for Sunplus EHCI driver

---
 .../bindings/usb/sunplus,sp7021-usb-ehci.yaml      | 97 ++++++++++++++++++++++
 MAINTAINERS                                        |  1 +
 2 files changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/sunplus,sp7021-usb-ehci.yaml
Documentation/devicetree/bindings/usb/sunplus,sp7021-usb-ehci.yaml new file +10 -0
new file mode 100644
index 0000000..e492f7a
@@ -0,0 +1,97 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) Sunplus Co., Ltd. 2021
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/usb/sunplus,sp7021-usb-ehci.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sunplus SP7021 EHCI Device Tree bindings for ehci0/ehci1
+
+maintainers:

Documentation/devicetree/bindings/usb/sunplus,sp7021-usb-ehci.yaml line 20

Quoted 10 lines
Documentation/devicetree/bindings/usb/sunplus,sp7021-usb-ehci.yaml new file +10 -0
+  - Vincent Shih <[email protected]>
+
+allOf:
+  - $ref: usb-hcd.yaml#
+
+properties:
+  compatible:
+    enum:
+      - sunplus,sp7021-usb-ehci0
+      - sunplus,sp7021-usb-ehci1

How did you address Rob's comments about using one one compatible? You still have two.

Quoted 32 lines
Documentation/devicetree/bindings/usb/sunplus,sp7021-usb-ehci.yaml new file +32 -0
+
+  clocks:
+    maxItems: 2
+
+  clock-names:
+    items:
+      - const: usbc_clk
+      - const: uphy_clk
+
+  resets:
+    maxItems: 2
+
+  reset-names:
+    items:
+      - const: usbc_rst
+      - const: uphy_rst
+
+  reg:
+    items:
+      - description: USBC register region
+      - description: UPHY register region
+      - description: MOON4 register region
+
+  reg-names:
+    items:
+      - const: usbc
+      - const: uphy
+      - const: moon4
+
+  interrupts:
+    maxItems: 1
+

Documentation/devicetree/bindings/usb/sunplus,sp7021-usb-ehci.yaml line 62

Quoted 10 lines
Documentation/devicetree/bindings/usb/sunplus,sp7021-usb-ehci.yaml new file +10 -0
+  nvmem-cell-names:
+    description: names corresponding to the nvmem cells of disconnect voltage
+    const: disc_vol
+
+  nvmem-cells:
+    description: nvmem cell address of disconnect voltage
+    maxItems: 1
+
+  port-num:
+    description:  identify ehci0 (port0) and ehci1 (port1)

This still should be a dedicated PHY driver referenced here.

Best regards,
Krzysztof

maintainer
#5 lore raw

Re: [PATCH v2 2/2] dt-bindings: usb: Add bindings doc for Sunplus EHCI driver

In reply to Vincent Shih
Quoted 9 lines · Vincent Shih

Add bindings doc for Sunplus EHCI driver

---
 .../bindings/usb/sunplus,sp7021-usb-ehci.yaml      | 97 ++++++++++++++++++++++
 MAINTAINERS                                        |  1 +
 2 files changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/sunplus,sp7021-usb-ehci.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:
./Documentation/devicetree/bindings/usb/sunplus,sp7021-usb-ehci.yaml:62:18: [warning] too many spaces after colon (colons)

dtschema/dtc warnings/errors:
Documentation/devicetree/bindings/usb/sunplus,sp7021-usb-ehci.example.dt.yaml:0:0: /example-0/usb@9c102100: failed to match any schema with compatible: ['sunplus,sp7021-usb-ehci']

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/patch/1598222

This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.

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.