From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DE852C5CFDB for ; Thu, 13 Aug 2026 20:58:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=v1IKwM82/XKaV9TO+qQBNorvBsBfmHySV4Hyb2GhJEQ=; b=dE1mEP5EVeeG4tpGQHnXxCNh1A aCOAJT6TEvwjHZsJn6Rr1yX0KKoc+BI+FqUv+kOkptxgmdlt5abQezPWC1f4oFbID3glI9gcbO+be 5Z9zyQstC7uDzcPQIgqCeyh1hjAgxV+0PHyKnpqLFbHBiOGEoUiKIZ6/AuDxNVwkdc9gLFvrKzEyh 9EpBAhYvq/FDGzJNFmC5mLBk5wZ923ay4vLWdC8KTGyrJ1zGlwpPpdn0dDxvArJTqL34du3ZOrh0S ufJuZ3NXZ8J6VCeOH6VETH/Y7T2dP+WqY112y+3Oi8a9kzoPmOz4YWbzc6gUkb5bhwgttN1/xtDrx cHJCtKwA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wucV3-00000001b9D-1LbD; Thu, 13 Aug 2026 20:58:05 +0000 Received: from bali.collaboradmins.com ([2a01:4f8:201:9162::2]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wucUo-00000001axk-3wCJ; Thu, 13 Aug 2026 20:57:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1786654668; bh=kUx77njRFf04km+UfV96FzfV0osjQuXSlQrZVOobT8o=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=IznGHddQZvYq1/5RsJyC4F/8KqS0565G7/2dB5FH7WShlTx/TLPOEsZuIeRHP7hzw T2hSUCUFf8U5q/jutrrLM1rFGlQBIT/LUiWt1e2wn8llqNX/q6L8itI5fARyA+4GyE javvID9Czbx6NHSdgmUEPXPjU23N9SScKRcYO3/UKCZnMSdE6TepTYUE5ln4at24Oh RnUkoV/tL2dP9ssITCS5DqFDdva5DFSpD0DFHhkmAevK4Vxhj/mbBybqGQ1pcON+Aw HZtGWj4zBDGFCgYqpE6LB08gnzVhidQ4zh6FLOQ/ZC2sPPwbqwEv+nYDyco3Sn4sYK ougZUSCjHNu7Q== Received: from jupiter.universe (unknown [100.64.1.62]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) (Authenticated sender: sre) by bali.collaboradmins.com (Postfix) with ESMTPSA id 95D3817E0FE2; Thu, 13 Aug 2026 22:57:48 +0200 (CEST) Received: by jupiter.universe (Postfix, from userid 1000) id C1B5C480071; Thu, 13 Aug 2026 22:51:49 +0200 (CEST) From: Sebastian Reichel Date: Thu, 13 Aug 2026 22:52:12 +0200 Subject: [PATCH v14 29/38] usb: dwc3: rockchip: introduce glue driver MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260813-rockchip-usbdp-cleanup-v14-29-b5ad9c68fa11@collabora.com> References: <20260813-rockchip-usbdp-cleanup-v14-0-b5ad9c68fa11@collabora.com> In-Reply-To: <20260813-rockchip-usbdp-cleanup-v14-0-b5ad9c68fa11@collabora.com> To: Vinod Koul , Manivannan Sadhasivam , Neil Armstrong , Heiko Stuebner , Frank Wang , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Thinh Nguyen , Greg Kroah-Hartman , Philipp Zabel Cc: Andy Yan , Dmitry Baryshkov , Yubing Zhang , Alexey Charkov , Igor Paunovic , linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com, devicetree@vger.kernel.org, linux-usb@vger.kernel.org, Sebastian Reichel X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6118; i=sebastian.reichel@collabora.com; h=from:subject:message-id; bh=kUx77njRFf04km+UfV96FzfV0osjQuXSlQrZVOobT8o=; b=owJ4nAFtApL9kA0DAAoB2O7X88g7+poByyZiAGp+LmXG7xdK8wnHAh+c1gxNLgz73pVcZfgcX sXwIJCHKqhenYkCMwQAAQoAHRYhBO9mDQdGP4tyanlUE9ju1/PIO/qaBQJqfi5lAAoJENju1/PI O/qajvcP/A6nEWAhatS3RxGO9GCXWIPCAdGKuhmmSqnmmZbrvv+ZjKdFMAnVKFOIKj5qO78mg68 Te0ZRxWLpnlJTMS3BnT3M8taV2kfxewQDmcvU2lDzwA1uGEAU4GuZQc+0ILnJDYgk/QYZjHN3ze +Mbg+lArNPz3INMqZk5Zd2xuE+IBGlEmE8UEXM1BCGUX77stEIR26IlWJ44s/jfmuhqxtMz0xy4 kCsrmIbWj3bcyJgJQSQC2NMj5i9Bnt3G2roH570UxNiaYDWVWEXYGPRLo7h/wRuaj75/aCtZGKW 9tPEPOok2newDKykQCL9INpkkJemzeIdVq/+e6NAnmfZ56p4XNui/iVYLKlumfDAF1mUHBHtnJB 3niYr+S4nsBVCbMqsjHVHjgoSVaRFxWmOyYsuh8Qa6qaAmJ4CNxSWAvajUBquaP9IctmF+xLag8 I80FKZ6alHGYKYzVDJmYumzgsmO+ixjTxI+m+cb9BRTwlaxmRSZOxSEY0HMyfjqygJ3+JkoDw1X 4MUC+lWe51pVtN/KvOP01SbNFUDSgax6MlKiMI2ZieSsTV7GItWxImu+mE9IhGaR7Xj25CyYltu aDdyuTpfUxJF1MQXaJR65v+4Zj34dvwd4kSyLnXO9x8vk7WHk/5pgmTcC2Sp4ooa1BwPSo4BZLG oqKeuoZ0FNIY/08u8vCQonA== X-Developer-Key: i=sebastian.reichel@collabora.com; a=openpgp; fpr=EF660D07463F8B726A795413D8EED7F3C83BFA9A X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260813_135751_147929_DD164E9A X-CRM114-Status: GOOD ( 21.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Introduce Rockchip specific glue code for the Synopsys DWC3 USB driver. For now this handles things identical to the default glue. Signed-off-by: Sebastian Reichel --- drivers/usb/dwc3/Kconfig | 11 ++++ drivers/usb/dwc3/Makefile | 1 + drivers/usb/dwc3/core.c | 15 +++++ drivers/usb/dwc3/dwc3-rockchip.c | 115 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 142 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 517aa7f1486d..6e796489a04d 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -2380,11 +2380,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..1df33625b69f --- /dev/null +++ b/drivers/usb/dwc3/dwc3-rockchip.c @@ -0,0 +1,115 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2026, Collabora Ltd. */ +#include +#include +#include +#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)); +} + +#ifdef CONFIG_PM +static int dwc3_rockchip_runtime_suspend(struct device *dev) +{ + return dwc3_runtime_suspend(dev_get_drvdata(dev)); +} + +static int dwc3_rockchip_runtime_resume(struct device *dev) +{ + return dwc3_runtime_resume(dev_get_drvdata(dev)); +} + +static int dwc3_rockchip_runtime_idle(struct device *dev) +{ + return dwc3_runtime_idle(dev_get_drvdata(dev)); +} +#endif + +#ifdef CONFIG_PM_SLEEP +static int dwc3_rockchip_suspend(struct device *dev) +{ + return dwc3_pm_suspend(dev_get_drvdata(dev)); +} + +static int dwc3_rockchip_resume(struct device *dev) +{ + return dwc3_pm_resume(dev_get_drvdata(dev)); +} + +static void dwc3_rockchip_complete(struct device *dev) +{ + dwc3_pm_complete(dev_get_drvdata(dev)); +} + +static int dwc3_rockchip_prepare(struct device *dev) +{ + return dwc3_pm_prepare(dev_get_drvdata(dev)); +} +#endif + +static const struct dev_pm_ops dwc3_rockchip_dev_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(dwc3_rockchip_suspend, dwc3_rockchip_resume) + .complete = dwc3_rockchip_complete, + .prepare = dwc3_rockchip_prepare, + /* + * Runtime suspend halts the controller on disconnection. It relies on + * platforms with custom connection notification to start the controller + * again. + */ + SET_RUNTIME_PM_OPS(dwc3_rockchip_runtime_suspend, dwc3_rockchip_runtime_resume, + dwc3_rockchip_runtime_idle) +}; + +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