[PATCH 2/5] usb: dwc3: rockchip: introduce glue driver
From: Sebastian Reichel <hidden>
Date: 2026-09-15 15:18:42
Also in:
linux-phy, linux-rockchip, linux-usb, lkml
Subsystem:
arm/rockchip soc support, designware usb3 drd ip driver, the rest, usb subsystem · Maintainers:
Heiko Stuebner, Thinh Nguyen, Linus Torvalds, Greg Kroah-Hartman
Introduce Rockchip specific glue code for the Synopsys DWC3 USB driver. For now this handles things identical to the default glue. Tested-by: Igor Paunovic <redacted> # Orange Pi 5 Plus Signed-off-by: Sebastian Reichel <redacted> --- drivers/usb/dwc3/Kconfig | 11 ++++ drivers/usb/dwc3/Makefile | 1 + drivers/usb/dwc3/core.c | 15 ++++++ drivers/usb/dwc3/dwc3-rockchip.c | 106 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 133 insertions(+)
diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index 18169727a413..3c120ea9746d 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig@@ -190,6 +190,17 @@ 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_ROCKCHIP + tristate "Rockchip DWC3 Platform Driver" + depends on ARCH_ROCKCHIP || COMPILE_TEST + depends on OF + default USB_DWC3 + help + Rockchip 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. + config USB_DWC3_RTK tristate "Realtek DWC3 Platform Driver" depends on OF && ARCH_REALTEK
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
index f37971197203..444e7e7f34b2 100644
--- a/drivers/usb/dwc3/Makefile
+++ b/drivers/usb/dwc3/Makefile@@ -58,6 +58,7 @@ obj-$(CONFIG_USB_DWC3_IMX8MP) += dwc3-imx8mp.o obj-$(CONFIG_USB_DWC3_IMX) += dwc3-imx.o obj-$(CONFIG_USB_DWC3_XILINX) += dwc3-xilinx.o obj-$(CONFIG_USB_DWC3_OCTEON) += dwc3-octeon.o +obj-$(CONFIG_USB_DWC3_ROCKCHIP) += dwc3-rockchip.o obj-$(CONFIG_USB_DWC3_RTK) += dwc3-rtk.o obj-$(CONFIG_USB_DWC3_GENERIC_PLAT) += dwc3-generic-plat.o obj-$(CONFIG_USB_DWC3_GOOGLE) += dwc3-google.o
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index fd5c2cd36c59..4b7132887a03 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c@@ -2448,11 +2448,26 @@ int dwc3_core_probe(const struct dwc3_probe_data *data) } EXPORT_SYMBOL_GPL(dwc3_core_probe); +/* + * List of compatibles, which have "synopsys,dwc3" as a fallback + * compatible, but have a vendor specific glue driver that should + * be used instead of this one. + */ +static const char *const dwc3_compatible_blocklist[] = { + "rockchip,rk3588-dwc3", + "rockchip,rk3576-dwc3", +}; + static int dwc3_probe(struct platform_device *pdev) { struct dwc3_probe_data probe_data = {}; struct resource *res; struct dwc3 *dwc; + int i; + + for (i = 0; i < ARRAY_SIZE(dwc3_compatible_blocklist); i++) + if (device_is_compatible(&pdev->dev, dwc3_compatible_blocklist[i])) + return -ENODEV; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) {
diff --git a/drivers/usb/dwc3/dwc3-rockchip.c b/drivers/usb/dwc3/dwc3-rockchip.c
new file mode 100644
index 000000000000..62f2a03b08a2
--- /dev/null
+++ b/drivers/usb/dwc3/dwc3-rockchip.c@@ -0,0 +1,106 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2026, Collabora Ltd. */ +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/pm_runtime.h> +#include "glue.h" + +struct dwc3_rockchip { + struct dwc3 dwc; +}; + +static int dwc3_rockchip_probe(struct platform_device *pdev) +{ + struct dwc3_probe_data probe_data = {}; + struct resource *res; + struct dwc3_rockchip *dwc_rk; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(&pdev->dev, "missing memory resource\n"); + return -ENODEV; + } + + dwc_rk = devm_kzalloc(&pdev->dev, sizeof(*dwc_rk), GFP_KERNEL); + if (!dwc_rk) + return -ENOMEM; + + dwc_rk->dwc.dev = &pdev->dev; + dwc_rk->dwc.glue_ops = NULL; + + probe_data.dwc = &dwc_rk->dwc; + probe_data.res = res; + probe_data.properties = DWC3_DEFAULT_PROPERTIES; + + return dwc3_core_probe(&probe_data); +} + +static void dwc3_rockchip_remove(struct platform_device *pdev) +{ + dwc3_core_remove(platform_get_drvdata(pdev)); +} + +static int __maybe_unused dwc3_rockchip_runtime_suspend(struct device *dev) +{ + return dwc3_runtime_suspend(dev_get_drvdata(dev)); +} + +static int __maybe_unused dwc3_rockchip_runtime_resume(struct device *dev) +{ + return dwc3_runtime_resume(dev_get_drvdata(dev)); +} + +static int __maybe_unused dwc3_rockchip_runtime_idle(struct device *dev) +{ + return dwc3_runtime_idle(dev_get_drvdata(dev)); +} + +static int __maybe_unused dwc3_rockchip_suspend(struct device *dev) +{ + return dwc3_pm_suspend(dev_get_drvdata(dev)); +} + +static int __maybe_unused dwc3_rockchip_resume(struct device *dev) +{ + return dwc3_pm_resume(dev_get_drvdata(dev)); +} + +static void __maybe_unused dwc3_rockchip_complete(struct device *dev) +{ + dwc3_pm_complete(dev_get_drvdata(dev)); +} + +static int __maybe_unused dwc3_rockchip_prepare(struct device *dev) +{ + return dwc3_pm_prepare(dev_get_drvdata(dev)); +} + +static const struct dev_pm_ops dwc3_rockchip_dev_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(dwc3_rockchip_suspend, dwc3_rockchip_resume) + SET_RUNTIME_PM_OPS(dwc3_rockchip_runtime_suspend, dwc3_rockchip_runtime_resume, + dwc3_rockchip_runtime_idle) + .complete = pm_sleep_ptr(dwc3_rockchip_complete), + .prepare = pm_sleep_ptr(dwc3_rockchip_prepare), +}; + +static const struct of_device_id dwc3_rockchip_of_match[] = { + { .compatible = "rockchip,rk3588-dwc3" }, + { .compatible = "rockchip,rk3576-dwc3" }, + { } +}; +MODULE_DEVICE_TABLE(of, dwc3_rockchip_of_match); + +static struct platform_driver dwc3_rockchip_driver = { + .probe = dwc3_rockchip_probe, + .remove = dwc3_rockchip_remove, + .driver = { + .name = "dwc3-rockchip", + .pm = pm_ptr(&dwc3_rockchip_dev_pm_ops), + .of_match_table = dwc3_rockchip_of_match, + }, +}; + +module_platform_driver(dwc3_rockchip_driver); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("DesignWare DWC3 Rockchip Glue Driver");
--
2.53.0