Skip to contentSkip to conversation

usb: cdns3: USBSSP platform driver support

PATCH In review Peter Chen 2 participants 5 messages Apr 21

Subsystems (4)
lore
Share & tools
lore

Peter Chen

author
#0 lore raw

v3 cover usb: cdns3: USBSSP platform driver support

This series adds platform driver support for the Cadence USBSSP (CDNSP) controller, which was previously only accessible through PCI. The USBSSP controller is auto-detected at runtime by reading the DRD/OTG Device ID register; both USBSS and USBSSP use the "cdns,usb3" compatible string (binding update in patch 1).

Changes since v2 (vs the v2 series on list)

v2 split CONFIG_USB_CDNSP into its own cdnsp.ko-style path and built cdns3-plat as a standalone module next to cdns-usb-common. v3 folds the integration back into one driver module:

- Single cdns.ko (CONFIG_USB_CDNS3) bundles core, DRD, the generic cdns3-plat binding, optional host.o (CONFIG_USB_CDNS3_HOST) and optional gadget objects (CONFIG_USB_CDNS3_GADGET). SoC and PCI glue stay separate small .ko files.

- CONFIG_USB_CDNS_SUPPORT depends on USB and USB_GADGET using the usual pattern (depends on USB || USB_GADGET; depends on USB if !USB_GADGET; depends on USB_GADGET if !USB) so the umbrella tracks host or gadget when either is built as a module (Suggested-by: Arnd Bergmann).

- USB_CDNS3_HOST / USB_CDNS3_GADGET are matched to the cdns.ko tristate with USB=USB_CDNS3 and USB_GADGET=USB_CDNS3 instead of tying gadget only to CONFIG_USB_CDNS_SUPPORT, which mis-handled =y / =m splits when CONFIG_USB_CDNS_SUPPORT=y but CONFIG_USB_CDNS3=m.

- Drop CONFIG_USB_CDNS_HOST; Makefile and host-export.h use CONFIG_USB_CDNS3_HOST only.

- gadget-export.h uses IS_ENABLED(CONFIG_USB_CDNS3_GADGET) for stubs now that gadget is a bool compiled into the unified module (v2 used IS_REACHABLE on separate CONFIG_USB_CDNS3 / CONFIG_USB_CDNSP tristates).

- Patch 2 still refactors cdnsp-pci.c into a PCI-to-platform wrapper, keeps host_init / gadget_init callbacks, exports cdns_core_init_role, and limits drivers/usb/cdns3/ to CONFIG_USB_CDNS_SUPPORT.

- Add Rob Herring's ACK for Patch 1.

Build verification

Exhaustive Kconfig sweep: 79 unique resolved configurations (deduped on CONFIG_USB, CONFIG_USB_GADGET, CONFIG_USB_CDNS_SUPPORT, CONFIG_USB_CDNS3_HOST, CONFIG_USB_CDNS3, CONFIG_USB_CDNSP_PCI, CONFIG_USB_CDNS3_GADGET), arm64 cross-build, each run through make O=out/cix olddefconfig, then Image + modules, then modules_install into a clean INSTALL_MOD_PATH:

PASS 79 / 79; build failures 0; depmod / module graph failures 0.

Peter Chen (2):
dt-bindings: usb: cdns,usb3: document USBSSP controller support
usb: cdns3: Add USBSSP platform driver support

 .../devicetree/bindings/usb/cdns,usb3.yaml    |  10 +-
 drivers/usb/Makefile                          |   2 -
 drivers/usb/cdns3/Kconfig                     | 112 ++++-----
 drivers/usb/cdns3/Makefile                    |  44 ++--
 drivers/usb/cdns3/cdns3-gadget.c              |   1 +
 drivers/usb/cdns3/cdns3-plat.c                |  27 ++-
 drivers/usb/cdns3/cdnsp-gadget.c              |   1 +
 drivers/usb/cdns3/cdnsp-pci.c                 | 217 ++++++++----------
 drivers/usb/cdns3/core.c                      |  45 ++--
 drivers/usb/cdns3/core.h                      |   5 +-
 drivers/usb/cdns3/gadget-export.h             |  10 +-
 drivers/usb/cdns3/host-export.h               |   4 +-
 12 files changed, 209 insertions(+), 269 deletions(-)
Signature · 1 line
2.50.1
author
#1 lore raw

PATCH v3 1/2 dt-bindings: usb: cdns,usb3: document USBSSP controller support

Update the Cadence USBSS DRD binding to document that it also covers the USBSSP (SuperSpeed Plus, USB 3.1 gen2x1) controller. Both USBSS and USBSSP share the same DRD/OTG register interface, so the driver auto-detects the controller version at runtime: no additional compatible string is needed.

Changes to the binding:
- Update title and add description
- maximum-speed: add super-speed-plus

Assisted-by Cursor:claude-4.6-opus
---
 Documentation/devicetree/bindings/usb/cdns,usb3.yaml | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/usb/cdns,usb3.yaml +8 -2
index f454ddd9bbaa..ad5acf956edf 100644
@@ -4,11 +4,17 @@
 $id: http://devicetree.org/schemas/usb/cdns,usb3.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
-title: Cadence USBSS-DRD controller
+title: Cadence USBSS and USBSSP DRD controller
 
 maintainers:
   - Pawel Laszczak <[email protected]>
 
+description:
+  Cadence USB dual-role controller. Covers USBSS (SuperSpeed, USB 3.0) and
+  USBSSP (SuperSpeed Plus, USB 3.1 gen2x1). Both variants share the same
+  DRD/OTG register interface, so the driver auto-detects the controller
+  version at runtime.
+
 properties:
   compatible:
     const: cdns,usb3
@@ -49,7 +55,7 @@ properties:
       cdns3 to type C connector.
 
   maximum-speed:
-    enum: [super-speed, high-speed, full-speed]
+    enum: [super-speed-plus, super-speed, high-speed, full-speed]
 
   phys:
     minItems: 1
Signature · 1 line
2.50.1
author
#2 lore raw

PATCH v3 2/2 usb: cdns3: Add USBSSP platform driver support

In reply to Peter Chen

Expose Cadence USBSSP through the same platform path as USBSS, trim Kconfig and Makefile: one core loadable object plus separate glue .ko files.

Single cdns.ko bundles core, DRD, the generic "cdns,usb3" platform driver in cdns3-plat.c, optional host.o, and optional gadget objects. Use CONFIG_USB_CDNS3_GADGET as a bool to compile gadget support into that module. Remove duplicate MODULE_* declarations from cdns3-plat.c now that it links into the same module.

Kconfig: the generic platform driver is selected via CONFIG_USB_CDNS3. Move CONFIG_USB_CDNSP_PCI beside CONFIG_USB_CDNS3_PCI_WRAP under "Platform glue driver support". SoC glue entries (TI, i.MX, StarFive) depend only on CONFIG_USB_CDNS3.

Tighten CONFIG_USB_CDNS_SUPPORT dependencies so the umbrella follows host or gadget when either is built as a module. Match host and gadget bools to the cdns.ko tristate with USB=USB_CDNS3 and USB_GADGET=USB_CDNS3 instead of comparing against USB_CDNS_SUPPORT.

Link host.o when CONFIG_USB_CDNS3_HOST is enabled and use that symbol in host-export.h, removing the redundant CONFIG_USB_CDNS_HOST indirection.

Export cdns_core_init_role and reorganize the function cdns_init, and controller version could be gotten before the gadget init function is decided per controller.

Keep host_init / gadget_init callbacks in struct cdns, so core.c does not need direct linkage to host or gadget objects. Refactor cdnsp-pci.c into a thin PCI-to-platform wrapper.

drivers/usb/Makefile: descend into drivers/usb/cdns3/ only when CONFIG_USB_CDNS_SUPPORT is enabled.

Assisted-by Cursor:claude-4.6-opus
---
 drivers/usb/Makefile              |   2 -
 drivers/usb/cdns3/Kconfig         | 112 +++++++--------
 drivers/usb/cdns3/Makefile        |  44 +++---
 drivers/usb/cdns3/cdns3-gadget.c  |   1 +
 drivers/usb/cdns3/cdns3-plat.c    |  27 +++-
 drivers/usb/cdns3/cdnsp-gadget.c  |   1 +
 drivers/usb/cdns3/cdnsp-pci.c     | 217 +++++++++++++-----------------
 drivers/usb/cdns3/core.c          |  45 ++-----
 drivers/usb/cdns3/core.h          |   5 +-
 drivers/usb/cdns3/gadget-export.h |  10 +-
 drivers/usb/cdns3/host-export.h   |   4 +-
 11 files changed, 201 insertions(+), 267 deletions(-)
drivers/usb/Makefile +0 -2
index 6f3c86149887..eecbd631fdab 100644
@@ -14,8 +14,6 @@ obj-$(CONFIG_USB_DWC2)		+= dwc2/
 obj-$(CONFIG_USB_ISP1760)	+= isp1760/
 
 obj-$(CONFIG_USB_CDNS_SUPPORT)	+= cdns3/
-obj-$(CONFIG_USB_CDNS3)		+= cdns3/
-obj-$(CONFIG_USB_CDNSP_PCI)	+= cdns3/
 
 obj-$(CONFIG_USB_FOTG210)	+= fotg210/
 
drivers/usb/cdns3/Kconfig +47 -65

154 lines not on this page · raw message

drivers/usb/cdns3/Makefile +15 -29

57 lines not on this page · raw message

drivers/usb/cdns3/cdns3-gadget.c +1 -0
index d59a60a16ec7..ff422e5204e4 100644
@@ -3508,3 +3508,4 @@ int cdns3_gadget_init(struct cdns *cdns)
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(cdns3_gadget_init);
drivers/usb/cdns3/cdns3-plat.c +22 -5
index 735df88774e4..3fe3109a3688 100644
@@ -21,6 +21,7 @@
 
 #include "core.h"
 #include "gadget-export.h"
+#include "host-export.h"
 #include "drd.h"
 
 static int set_phy_power_on(struct cdns *cdns)
@@ -44,6 +45,19 @@ static void set_phy_power_off(struct cdns *cdns)
 	phy_power_off(cdns->usb2_phy);
 }
 
+static int cdns3_plat_gadget_init(struct cdns *cdns)
+{
+	if (cdns->version < CDNSP_CONTROLLER_V2)
+		return cdns3_gadget_init(cdns);
+	else
+		return cdnsp_gadget_init(cdns);
+}
+
+static int cdns3_plat_host_init(struct cdns *cdns)
+{
+	return cdns_host_init(cdns);
+}
+
 /**
  * cdns3_plat_probe - probe for cdns3 core device
  * @pdev: Pointer to cdns3 core platform device
@@ -64,6 +78,8 @@ static int cdns3_plat_probe(struct platform_device *pdev)
 
 	cdns->dev = dev;
 	cdns->pdata = dev_get_platdata(dev);
+	if (cdns->pdata && cdns->pdata->override_apb_timeout)
+		cdns->override_apb_timeout = cdns->pdata->override_apb_timeout;
 
 	platform_set_drvdata(pdev, cdns);
 
@@ -143,12 +159,16 @@ static int cdns3_plat_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_phy_power_on;
 
-	cdns->gadget_init = cdns3_gadget_init;
-
 	ret = cdns_init(cdns);
 	if (ret)
 		goto err_cdns_init;
 
+	cdns->gadget_init = cdns3_plat_gadget_init;
+	cdns->host_init = cdns3_plat_host_init;
+	ret = cdns_core_init_role(cdns);
+	if (ret)
+		goto err_cdns_init;
+
 	device_set_wakeup_capable(dev, true);
 	pm_runtime_set_active(dev);
 	pm_runtime_enable(dev);
@@ -336,6 +356,3 @@ static struct platform_driver cdns3_driver = {
 module_platform_driver(cdns3_driver);
 
 MODULE_ALIAS("platform:cdns3");
-MODULE_AUTHOR("Pawel Laszczak <[email protected]>");
-MODULE_LICENSE("GPL v2");
-MODULE_DESCRIPTION("Cadence USB3 DRD Controller Driver");
drivers/usb/cdns3/cdnsp-gadget.c +1 -0
index 6b3815f8a6e5..18e872ad29bd 100644
@@ -2075,3 +2075,4 @@ int cdnsp_gadget_init(struct cdns *cdns)
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(cdnsp_gadget_init);
drivers/usb/cdns3/cdnsp-pci.c +93 -124

296 lines not on this page · raw message

drivers/usb/cdns3/core.c +14 -31

92 lines not on this page · raw message

drivers/usb/cdns3/core.h +4 -1
index 801be9e61340..bca973b999a4 100644
@@ -45,6 +45,7 @@ struct cdns3_platform_data {
 	unsigned long quirks;
 #define CDNS3_DEFAULT_PM_RUNTIME_ALLOW	BIT(0)
 #define CDNS3_DRD_SUSPEND_RESIDENCY_ENABLE	BIT(1)
+	u32 override_apb_timeout;	/* 0 = use default (e.g. for PCI) */
 };
 
 /**
@@ -82,6 +83,7 @@ struct cdns3_platform_data {
  * @override_apb_timeout: hold value of APB timeout. For value 0 the default
  *                        value in CHICKEN_BITS_3 will be preserved.
  * @gadget_init: pointer to gadget initialization function
+ * @host_init: pointer to host initialization function
  */
 struct cdns {
 	struct device			*dev;
@@ -120,13 +122,14 @@ struct cdns {
 	spinlock_t			lock;
 	struct xhci_plat_priv		*xhci_plat_data;
 	u32                             override_apb_timeout;
-
 	int (*gadget_init)(struct cdns *cdns);
+	int (*host_init)(struct cdns *cdns);
 };
 
 int cdns_hw_role_switch(struct cdns *cdns);
 int cdns_init(struct cdns *cdns);
 int cdns_remove(struct cdns *cdns);
+int cdns_core_init_role(struct cdns *cdns);
 
 #ifdef CONFIG_PM_SLEEP
 int cdns_resume(struct cdns *cdns);
drivers/usb/cdns3/gadget-export.h +2 -8
index c37b6269b001..60c3177db62c 100644
@@ -10,9 +10,10 @@
 #ifndef __LINUX_CDNS3_GADGET_EXPORT
 #define __LINUX_CDNS3_GADGET_EXPORT
 
-#if IS_ENABLED(CONFIG_USB_CDNSP_GADGET)
+#if IS_ENABLED(CONFIG_USB_CDNS3_GADGET)
 
 int cdnsp_gadget_init(struct cdns *cdns);
+int cdns3_gadget_init(struct cdns *cdns);
 #else
 
 static inline int cdnsp_gadget_init(struct cdns *cdns)
@@ -20,13 +21,6 @@ static inline int cdnsp_gadget_init(struct cdns *cdns)
 	return -ENXIO;
 }
 
-#endif /* CONFIG_USB_CDNSP_GADGET */
-
-#if IS_ENABLED(CONFIG_USB_CDNS3_GADGET)
-
-int cdns3_gadget_init(struct cdns *cdns);
-#else
-
 static inline int cdns3_gadget_init(struct cdns *cdns)
 {
 	return -ENXIO;
drivers/usb/cdns3/host-export.h +2 -2
index cf92173ecf00..34fd1f1ad59d 100644
@@ -9,7 +9,7 @@
 #ifndef __LINUX_CDNS3_HOST_EXPORT
 #define __LINUX_CDNS3_HOST_EXPORT
 
-#if IS_ENABLED(CONFIG_USB_CDNS_HOST)
+#if IS_ENABLED(CONFIG_USB_CDNS3_HOST)
 
 int cdns_host_init(struct cdns *cdns);
 
@@ -22,6 +22,6 @@ static inline int cdns_host_init(struct cdns *cdns)
 
 static inline void cdns_host_exit(struct cdns *cdns) { }
 
-#endif /* USB_CDNS_HOST */
+#endif /* CONFIG_USB_CDNS3_HOST */
 
 #endif /* __LINUX_CDNS3_HOST_EXPORT */
Signature · 1 line
2.50.1
Reviewed-by on v3 2/2
#3 lore raw

Re: [PATCH v3 2/2] usb: cdns3: Add USBSSP platform driver support

Quoted 31 lines · Peter Chen

Expose Cadence USBSSP through the same platform path as USBSS, trim Kconfig and Makefile: one core loadable object plus separate glue .ko files.

Single cdns.ko bundles core, DRD, the generic "cdns,usb3" platform driver in cdns3-plat.c, optional host.o, and optional gadget objects. Use CONFIG_USB_CDNS3_GADGET as a bool to compile gadget support into that module. Remove duplicate MODULE_* declarations from cdns3-plat.c now that it links into the same module.

Kconfig: the generic platform driver is selected via CONFIG_USB_CDNS3. Move CONFIG_USB_CDNSP_PCI beside CONFIG_USB_CDNS3_PCI_WRAP under "Platform glue driver support". SoC glue entries (TI, i.MX, StarFive) depend only on CONFIG_USB_CDNS3.

Tighten CONFIG_USB_CDNS_SUPPORT dependencies so the umbrella follows host or gadget when either is built as a module. Match host and gadget bools to the cdns.ko tristate with USB=USB_CDNS3 and USB_GADGET=USB_CDNS3 instead of comparing against USB_CDNS_SUPPORT.

Link host.o when CONFIG_USB_CDNS3_HOST is enabled and use that symbol in host-export.h, removing the redundant CONFIG_USB_CDNS_HOST indirection.

Export cdns_core_init_role and reorganize the function cdns_init, and controller version could be gotten before the gadget init function is decided per controller.

Keep host_init / gadget_init callbacks in struct cdns, so core.c does not need direct linkage to host or gadget objects. Refactor cdnsp-pci.c into a thin PCI-to-platform wrapper.

Quoted 6 lines

drivers/usb/Makefile: descend into drivers/usb/cdns3/ only when CONFIG_USB_CDNS_SUPPORT is enabled.

Assisted-by Cursor:claude-4.6-opus

This looks fine to me,

I've added the patch to my randconfig build setup now, to see if there are any corner cases left that I have missed where it may still get into a build time failure and will let you know if I find any.

Arnd

author
#4 lore raw

Re: [PATCH v3 2/2] usb: cdns3: Add USBSSP platform driver support

Quoted 7 lines · Arnd Bergmann
Quoted 6 lines

drivers/usb/Makefile: descend into drivers/usb/cdns3/ only when CONFIG_USB_CDNS_SUPPORT is enabled.

Assisted-by Cursor:claude-4.6-opus
Quoted 8 lines

This looks fine to me,

I've added the patch to my randconfig build setup now, to see if there are any corner cases left that I have missed where it may still get into a build time failure and will let you know if I find any.

Thanks, Arnd.

Signature · 2 lines
Best regards,
Peter