From nobody Fri Sep 25 07:23:46 2026 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E11253C279B; Tue, 15 Sep 2026 15:18:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789485493; cv=none; b=cQfFSyFxzMxyqnSRXWjyo6wgjuTt3jn4fx7jNpQTcCE9FCqSfYUolEaJnAd7BWL4bdonNO0kqllkKNT+5NLi+1f3tJ8UizstY+s6yo4VZ0Odg9MD137SoHMlhbeyESaa77JF8H9Q7p0w0FYe3iEkCseomLwgIs7Ul2ti8QRJ1RU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789485493; c=relaxed/simple; bh=/A6Hac4aqJzoz7kYkCtMzFY90tiyJ1AMuQj5SToK5yc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZS42QBVLgA0UK9yCNPwoLbLFxYPP3ccPf8QCZlydP20807QijR4jD/uYZj9GcfzU36C0NYB+3yu+X1FE+zApI1UlGF9gF+0PxOipH8j08Pwwv4Ukq/Q+lI1cyw50KofK/4omCvAYijFjW2eKRZIwLTEzMOmgsSP8HPShKBjBL6k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=nn84X/+b; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="nn84X/+b" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1789485488; bh=/A6Hac4aqJzoz7kYkCtMzFY90tiyJ1AMuQj5SToK5yc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=nn84X/+b/blUwrMrn/mcZGhPge1ZI+EvBMjQKuJAMIrUK1LB2hNI6EaG87JBmTOYO 9wMhVEdJBmWjJoc/O8ti7WwA/cjERX2dPO60dJi/twpd3rFn7weFMq9GaQeCS228sj 10SVD7mHf4phifAUAaoxJLC18N4pFBDbRIYYoiNOb8bt1FpgOY2zYyjqDO7aEYqIRD jKo0BezDUr1l8J2crrNVWEHgmerUjSDLlt5CwnfKZhTYIQpbOP54G5RY27cu4Rp97y eE8r9+7U2pSHI+g1jtpFz40PfkpiIq25Sxbs1WHsJefPVxZnkp94dN/hNcwivaJIxz oV2KSQ9fL3+gw== 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 0949817E00A9; Tue, 15 Sep 2026 17:18:08 +0200 (CEST) Received: by jupiter.universe (Postfix, from userid 1000) id BD411480029; Tue, 15 Sep 2026 17:18:07 +0200 (CEST) From: Sebastian Reichel Date: Tue, 15 Sep 2026 17:17:41 +0200 Subject: [PATCH 1/5] phy: core: add notifier infrastructure Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260915-b4-rockchip-dwc3-rockchip-glue-v1-1-763bb546824e@collabora.com> References: <20260915-b4-rockchip-dwc3-rockchip-glue-v1-0-763bb546824e@collabora.com> In-Reply-To: <20260915-b4-rockchip-dwc3-rockchip-glue-v1-0-763bb546824e@collabora.com> To: Thinh Nguyen , Greg Kroah-Hartman , Heiko Stuebner , Vinod Koul , Neil Armstrong , Manivannan Sadhasivam Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-phy@lists.infradead.org, kernel@collabora.com, Sebastian Reichel , Igor Paunovic X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6271; i=sebastian.reichel@collabora.com; h=from:subject:message-id; bh=/A6Hac4aqJzoz7kYkCtMzFY90tiyJ1AMuQj5SToK5yc=; b=owJ4nAFtApL9kA0DAAoB2O7X88g7+poByyZiAGqpYa//RUO96bBP1vu13dh10TjPv2zoapFEg hgYi5xqbCpUrYkCMwQAAQoAHRYhBO9mDQdGP4tyanlUE9ju1/PIO/qaBQJqqWGvAAoJENju1/PI O/qaPEkP/2kiPyBIvVpKNOZ35+7fA17PgxthnYZ1qo/gp9u3N7Rmrc3fqFbH/gQ8tCPZOzKf5eV nqOII19SbU1acLbxbzL4Sxy3McBgdhwQIwI+5+j+U5lHDRudcKWwYCqkz491z8ZUw4lPdQ0QWLk MSp5mvaK7ix4o4Sp02k/bGUtualr3Axd/FAqBbvXU++8bFcXPdPFEdyR7Brp9hJmasAed4KGDcy +2CbhVBjNSuJBN3wLMPeznc3galffx4/KMaJXKs6eIisL2Ye1Gyvch0ZbE0QqsKdbo873/TZRfi VwW0CbHc9CJ4RCJwcEHCLni524REA7Y52q0URq2hw7hVqzegYf6yi+qPA41DqANJb2yuNTiaq+k wNbSwWvfCsEL7/3bv4LAbL46IW+YTCGDO8jK17LbKBSJRsrvFv2X1/G0e26Wus/nALgYEViqm7E Od9zPnanqkDYaQwUgxIal3rCks14ofccy+y24zsKWXNF3J5ixlvafQOZHYyyB0ci/89RWP+JU2f N1DD82RoKzldeNQxa1F3RvSYNKlubDY6GGx/zGqdIfeXmRoQY1K73dfQIeEkf6nFt6u9iFhfIN+ +Cz6qjJn+dqk9FFvXl3G1nVWStAlZaxuA6iOH6y1QsRvz8wIza2qMH+lRYuNfLjZxpPf7JcDbKx 3AzOrLhNGxunmJPU9MEw/CA== X-Developer-Key: i=sebastian.reichel@collabora.com; a=openpgp; fpr=EF660D07463F8B726A795413D8EED7F3C83BFA9A Some PHY devices with multiple ports (e.g. USB3 and DP) require a reset if the configuration changes or cable orientation changes. This is a problem, as the consumer device will run into undefined behavior. With the new PHY notifier API introduced in this patch, the consumer driver can hook into reset events coming from a PHY device to handle the PHY going down gracefully. Note that this uses -ENOSYS instead of the more sensible -ENOTSUP for the stub functions when GENERIC_PHY is disabled to stay consistent with the existing ones. Tested-by: Igor Paunovic # Orange Pi 5 Plus Signed-off-by: Sebastian Reichel --- drivers/phy/phy-core.c | 65 +++++++++++++++++++++++++++++++++++++++++++++= ++++ include/linux/phy/phy.h | 40 ++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 21aaf2f76e53..51d261daae7a 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -542,6 +542,70 @@ int phy_notify_state(struct phy *phy, union phy_notify= state) } EXPORT_SYMBOL_GPL(phy_notify_state); =20 +/** + * phy_register_notifier() - register a notifier for PHY events + * @phy: the phy returned by phy_get() + * @nb: notifier block to register + * + * Allows PHY consumers to receive notifications about PHY reset events. + * PHY providers can signal these events using phy_notify_reset(). + * + * Returns: %0 if successful, a negative error code otherwise + */ +int phy_register_notifier(struct phy *phy, struct notifier_block *nb) +{ + if (!phy) + return 0; + + return blocking_notifier_chain_register(&phy->notifier, nb); +} +EXPORT_SYMBOL_GPL(phy_register_notifier); + +/** + * phy_unregister_notifier() - unregister a notifier for PHY events + * @phy: the phy returned by phy_get() + * @nb: notifier block to unregister + * + * Returns: %0 if successful, a negative error code otherwise + */ +int phy_unregister_notifier(struct phy *phy, struct notifier_block *nb) +{ + if (!phy) + return 0; + + return blocking_notifier_chain_unregister(&phy->notifier, nb); +} +EXPORT_SYMBOL_GPL(phy_unregister_notifier); + +/** + * phy_notify_reset() - notify consumers of a PHY reset event + * @phy: the phy that is being reset + * @event: the notification event (PRE_RESET or POST_RESET) + * + * Called by PHY providers to notify consumers that the PHY is about to + * be reset or has completed a reset. This allows consumers to quiesce + * hardware before the PHY becomes unavailable. + * + * This may be called from within PHY provider callbacks (e.g. set_mode, + * power_on) where phy->mutex is held. Consumer notification handlers must + * therefore NOT call back into the PHY framework (e.g. phy_power_off, + * phy_exit) on the same PHY, as this would result in a deadlock. + * + * Returns: %0 if successful or no notifiers registered, a negative error + * code if a notifier returns an error (for PRE_RESET only) + */ +int phy_notify_reset(struct phy *phy, enum phy_notification event) +{ + int ret; + + if (!phy) + return 0; + + ret =3D blocking_notifier_call_chain(&phy->notifier, event, phy); + return notifier_to_errno(ret); +} +EXPORT_SYMBOL_GPL(phy_notify_reset); + /** * phy_configure() - Changes the phy parameters * @phy: the phy returned by phy_get() @@ -1018,6 +1082,7 @@ struct phy *phy_create(struct device *dev, struct dev= ice_node *node, device_initialize(&phy->dev); lockdep_register_key(&phy->lockdep_key); mutex_init_with_key(&phy->mutex, &phy->lockdep_key); + BLOCKING_INIT_NOTIFIER_HEAD(&phy->notifier); =20 phy->dev.class =3D &phy_class; phy->dev.parent =3D dev; diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index ea47975e288a..3779a4d0a02c 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -11,6 +11,7 @@ #define __DRIVERS_PHY_H =20 #include +#include #include #include #include @@ -53,6 +54,16 @@ enum phy_media { PHY_MEDIA_DAC, }; =20 +/** + * enum phy_notification - PHY notification events + * @PHY_NOTIFY_PRE_RESET: PHY is about to be reset, consumers should quies= ce + * @PHY_NOTIFY_POST_RESET: PHY reset is complete, consumers may resume + */ +enum phy_notification { + PHY_NOTIFY_PRE_RESET, + PHY_NOTIFY_POST_RESET, +}; + enum phy_ufs_state { PHY_UFS_HIBERN8_ENTER, PHY_UFS_HIBERN8_EXIT, @@ -170,6 +181,7 @@ struct phy_attrs { * @power_count: used to protect when the PHY is used by multiple consumers * @attrs: used to specify PHY specific attributes * @pwr: power regulator associated with the phy + * @notifier: notifier head for PHY reset events * @debugfs: debugfs directory */ struct phy { @@ -182,6 +194,7 @@ struct phy { int power_count; struct phy_attrs attrs; struct regulator *pwr; + struct blocking_notifier_head notifier; struct dentry *debugfs; }; =20 @@ -267,6 +280,9 @@ int phy_calibrate(struct phy *phy); int phy_notify_connect(struct phy *phy, int port); int phy_notify_disconnect(struct phy *phy, int port); int phy_notify_state(struct phy *phy, union phy_notify state); +int phy_register_notifier(struct phy *phy, struct notifier_block *nb); +int phy_unregister_notifier(struct phy *phy, struct notifier_block *nb); +int phy_notify_reset(struct phy *phy, enum phy_notification event); static inline int phy_get_bus_width(struct phy *phy) { return phy->attrs.bus_width; @@ -428,6 +444,30 @@ static inline int phy_notify_state(struct phy *phy, un= ion phy_notify state) return -ENOSYS; } =20 +static inline int phy_register_notifier(struct phy *phy, + struct notifier_block *nb) +{ + if (!phy) + return 0; + return -ENOSYS; +} + +static inline int phy_unregister_notifier(struct phy *phy, + struct notifier_block *nb) +{ + if (!phy) + return 0; + return -ENOSYS; +} + +static inline int phy_notify_reset(struct phy *phy, + enum phy_notification event) +{ + if (!phy) + return 0; + return -ENOSYS; +} + static inline int phy_configure(struct phy *phy, union phy_configure_opts *opts) { --=20 2.53.0 From nobody Fri Sep 25 07:23:46 2026 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 011003F328A; Tue, 15 Sep 2026 15:18:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789485492; cv=none; b=GelSqaeBT/vIzZaDc3On2MUY17RA8uLlpBVLxdwEoPSoco1OkfJUHsV3kXi1D9Ti2NKhKuTk3qObDJzapy+3pCL9CHs5p9GjTRBVhrbi9D+33+PQLnXGNCiWBRk53ypK45K8qf4FbPygBFja3oV4XmA8EEkphq774fRpSHuurL4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789485492; c=relaxed/simple; bh=1qqONXOemSn7He65qwULu6DrX02TyhWC24CD6FQO7Ak=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=A2q1uBcl5U1QiB5PNRVR2Zk7E91S4Bdki+CU6WrVP9fObs6kK5c7l5G2u2rDSZzcMiseM6LzV9zEgWTNAjt+5FzfXIfhpNJaw9ReWxjy3ztvin5Ejhe56NcnAFMfCCHpgR494euZImZHqDMx/XIsbMMENrg2pKr94JQznWT2Cq8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=WXTKfdBl; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="WXTKfdBl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1789485488; bh=1qqONXOemSn7He65qwULu6DrX02TyhWC24CD6FQO7Ak=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=WXTKfdBlHKIhqHu3UrIxxwyNHKFC6LJmk0XMml5G7mRwVc2Fl2feSI5TIg27SqBEH 6gwZ6Xw8mdEGnn2qo3K86PdHcPZEJ5DWUTM/Zsdh1jsWeis3GjIYh0Gqd7vWNVxGvh hl38rNBGmyPpfs5k9jMl0aKt+279yVhvm77vR0Hz4c5wyKWYffI6wpETZ6VrFsh+o/ MP/fzinMrnaD2qTF2cKEFLGlFwjG2oq4M7qGdnKHPWo56NqPsKBjs39ofNc3qk+gaQ PTe8EFtvhvI0PC7A2mjs6onntliv05V3cSgtrCveatgLAO7cqkbIVTy/wamb1b0LEY +lJmPVhiyXJOw== 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 0C85A17E09B5; Tue, 15 Sep 2026 17:18:08 +0200 (CEST) Received: by jupiter.universe (Postfix, from userid 1000) id BE93248002F; Tue, 15 Sep 2026 17:18:07 +0200 (CEST) From: Sebastian Reichel Date: Tue, 15 Sep 2026 17:17:42 +0200 Subject: [PATCH 2/5] usb: dwc3: rockchip: introduce glue driver Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260915-b4-rockchip-dwc3-rockchip-glue-v1-2-763bb546824e@collabora.com> References: <20260915-b4-rockchip-dwc3-rockchip-glue-v1-0-763bb546824e@collabora.com> In-Reply-To: <20260915-b4-rockchip-dwc3-rockchip-glue-v1-0-763bb546824e@collabora.com> To: Thinh Nguyen , Greg Kroah-Hartman , Heiko Stuebner , Vinod Koul , Neil Armstrong , Manivannan Sadhasivam Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-phy@lists.infradead.org, kernel@collabora.com, Sebastian Reichel , Igor Paunovic X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6083; i=sebastian.reichel@collabora.com; h=from:subject:message-id; bh=1qqONXOemSn7He65qwULu6DrX02TyhWC24CD6FQO7Ak=; b=owJ4nAFtApL9kA0DAAoB2O7X88g7+poByyZiAGqpYa/JJ9w9aQnhgmVTQAuHXkZ8esQSCTokU 3ORYYK9bnWPBIkCMwQAAQoAHRYhBO9mDQdGP4tyanlUE9ju1/PIO/qaBQJqqWGvAAoJENju1/PI O/qar3UP/3EynYkLoRhGdNTU+rlVMJU/f495eMF5+uDehXkzZbBYVDtuZdV/njy7hkrSfEje4fZ eKAkdQp3XanoGcKsHIY26MJOETNXhiCXagEv8j6hnmTYTFfL3c21J0tOsJJq23+5g3EM+WZX80w XsqYxRx5rLSiOeiWt5ou/m5eWnXDfFDKMqsBItdNg1Q3ECGhyfySZ9obE+oHSd1D/c3OvYadcvB s4BNist5n3EPwMrE+IxDaH7742rlC5ytVEoXEToToDuWQR9t9zkYRC4R9XB9mOu2E1cwjlKHe4L qiVSi7q1Paf2y9ywz2zxlIUjfGVUQ9Vkx0Nrqr//YdCYG1svNrFexnAv6xsqE9cuahGN5pYKU77 S5PbUCw1uxW4aWgd5IZajlg0GmEItAobZYPl9cM9ySWm/OZ+8s1X1eRpokH+Xl5MwL8mr0ZfwrV DyWf+/0o5DmtogqkXzcq1ARCnpTRzK2xYcgPPAT0B3BGVBvXpQANx55uXKFuw08jrHFUCZmfmud XEqGRTSoAEN1+ptBYj5I2+AS29F749bfTk+Tqgte4LuI42rdimWPle+kojtNbByBUJo9WAdyM7r aAEg/f72jwR3Sryjmr8bwDi4ksW4LSclesuoenIv3gf1PlLCClbnmozr0RIkF2ScipH5VccBe0f guE9dwSTKtY0zMSbHOi4sNQ== X-Developer-Key: i=sebastian.reichel@collabora.com; a=openpgp; fpr=EF660D07463F8B726A795413D8EED7F3C83BFA9A 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 # Orange Pi 5 Plus 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 | 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. =20 +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) +=3D dwc3-imx8mp.o obj-$(CONFIG_USB_DWC3_IMX) +=3D dwc3-imx.o obj-$(CONFIG_USB_DWC3_XILINX) +=3D dwc3-xilinx.o obj-$(CONFIG_USB_DWC3_OCTEON) +=3D dwc3-octeon.o +obj-$(CONFIG_USB_DWC3_ROCKCHIP) +=3D dwc3-rockchip.o obj-$(CONFIG_USB_DWC3_RTK) +=3D dwc3-rtk.o obj-$(CONFIG_USB_DWC3_GENERIC_PLAT) +=3D dwc3-generic-plat.o obj-$(CONFIG_USB_DWC3_GOOGLE) +=3D 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 *d= ata) } EXPORT_SYMBOL_GPL(dwc3_core_probe); =20 +/* + * 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[] =3D { + "rockchip,rk3588-dwc3", + "rockchip,rk3576-dwc3", +}; + static int dwc3_probe(struct platform_device *pdev) { struct dwc3_probe_data probe_data =3D {}; struct resource *res; struct dwc3 *dwc; + int i; + + for (i =3D 0; i < ARRAY_SIZE(dwc3_compatible_blocklist); i++) + if (device_is_compatible(&pdev->dev, dwc3_compatible_blocklist[i])) + return -ENODEV; =20 res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { diff --git a/drivers/usb/dwc3/dwc3-rockchip.c b/drivers/usb/dwc3/dwc3-rockc= hip.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 +#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 =3D {}; + struct resource *res; + struct dwc3_rockchip *dwc_rk; + + res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(&pdev->dev, "missing memory resource\n"); + return -ENODEV; + } + + dwc_rk =3D devm_kzalloc(&pdev->dev, sizeof(*dwc_rk), GFP_KERNEL); + if (!dwc_rk) + return -ENOMEM; + + dwc_rk->dwc.dev =3D &pdev->dev; + dwc_rk->dwc.glue_ops =3D NULL; + + probe_data.dwc =3D &dwc_rk->dwc; + probe_data.res =3D res; + probe_data.properties =3D 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 =3D { + SET_SYSTEM_SLEEP_PM_OPS(dwc3_rockchip_suspend, dwc3_rockchip_resume) + SET_RUNTIME_PM_OPS(dwc3_rockchip_runtime_suspend, dwc3_rockchip_runtime_r= esume, + dwc3_rockchip_runtime_idle) + .complete =3D pm_sleep_ptr(dwc3_rockchip_complete), + .prepare =3D pm_sleep_ptr(dwc3_rockchip_prepare), +}; + +static const struct of_device_id dwc3_rockchip_of_match[] =3D { + { .compatible =3D "rockchip,rk3588-dwc3" }, + { .compatible =3D "rockchip,rk3576-dwc3" }, + { } +}; +MODULE_DEVICE_TABLE(of, dwc3_rockchip_of_match); + +static struct platform_driver dwc3_rockchip_driver =3D { + .probe =3D dwc3_rockchip_probe, + .remove =3D dwc3_rockchip_remove, + .driver =3D { + .name =3D "dwc3-rockchip", + .pm =3D pm_ptr(&dwc3_rockchip_dev_pm_ops), + .of_match_table =3D dwc3_rockchip_of_match, + }, +}; + +module_platform_driver(dwc3_rockchip_driver); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("DesignWare DWC3 Rockchip Glue Driver"); --=20 2.53.0 From nobody Fri Sep 25 07:23:46 2026 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0105F3E022D; Tue, 15 Sep 2026 15:18:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789485491; cv=none; b=U26AnMzMk+w2TMtAwnoQ2HibhpbB6WKsPNcIJWdPpe5yB4d5ncKCUQzQFgvfzg2EJwXczeo5outlv9AGSALFmpNlNtYT3JfmFe4hApdIkTYhDcCmZdhp7kaSm47SCoKrZEiK1TvTCYOkK2v9ZmE2q8T4cYIj/hsyXmLHZ65wJIA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789485491; c=relaxed/simple; bh=MYz6XguZYRFZ4/3nNJ/XuJ1PYCEYaFIUdFf95sJVHvM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iX80VSgnHyrdbEvnnaN4NTqPKz+9XYZK6yEwYSZJvi0Ncii0j6nAuMBgS44TxW9OYJ8Wk/k3bxHVFaoDtZ8TS4+dAcipEftCA9YwPzZk8xUGcfR+ltt/o6F8H1I89l9E21veO31jPpxKE8MxcdYzBMLuXYdRYgxAkvnhb9rsOUw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=HlffO9R0; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="HlffO9R0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1789485488; bh=MYz6XguZYRFZ4/3nNJ/XuJ1PYCEYaFIUdFf95sJVHvM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=HlffO9R0nkIt8kdPbWs85LU4bd1vKP40e/JICj4qRcGgdF5Rx4ROVk4mGXX+8HsZk JjyH3cue1+TtjQIWP8I2RgeVevfIPEDO/uuhXcd5hebdml/DogsWCXDyUCL8FFbYhf S+jWDsElqQW9llGqLYhP62MQmQoeVIHs2u7i6l17RvbONcIsNZCE0d0L2ZzcNHCewj zDGqK0iLoJPChW7QkZaVftU4P0aMLzGxidpm4Tn+tNk6Ccd70UQ3T5Ui6C/9Wp1hPE hC3nXfTvRpyt3HGAtpV+zz7H79M3udazCq7CaRNmbS8bhQZVYU00/a7Lz+PMW7Sd++ hKvS3zamxAEUw== 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 0FE1B17E0B0F; Tue, 15 Sep 2026 17:18:08 +0200 (CEST) Received: by jupiter.universe (Postfix, from userid 1000) id C0339480030; Tue, 15 Sep 2026 17:18:07 +0200 (CEST) From: Sebastian Reichel Date: Tue, 15 Sep 2026 17:17:43 +0200 Subject: [PATCH 3/5] usb: dwc3: core: add post PHY registration hook for platform glue Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260915-b4-rockchip-dwc3-rockchip-glue-v1-3-763bb546824e@collabora.com> References: <20260915-b4-rockchip-dwc3-rockchip-glue-v1-0-763bb546824e@collabora.com> In-Reply-To: <20260915-b4-rockchip-dwc3-rockchip-glue-v1-0-763bb546824e@collabora.com> To: Thinh Nguyen , Greg Kroah-Hartman , Heiko Stuebner , Vinod Koul , Neil Armstrong , Manivannan Sadhasivam Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-phy@lists.infradead.org, kernel@collabora.com, Sebastian Reichel , Igor Paunovic X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2023; i=sebastian.reichel@collabora.com; h=from:subject:message-id; bh=MYz6XguZYRFZ4/3nNJ/XuJ1PYCEYaFIUdFf95sJVHvM=; b=owJ4nAFtApL9kA0DAAoB2O7X88g7+poByyZiAGqpYa/BGNBrdPkstSJPufa+Kj1IefMXRoHk0 fWH1gVhwkYvxokCMwQAAQoAHRYhBO9mDQdGP4tyanlUE9ju1/PIO/qaBQJqqWGvAAoJENju1/PI O/qanX0P/iCmrS/h4fj6sLF5rrWdGs5mYFbqm81Q8fMVgHaz5p5xKnTP2PQl8oxyLOayEp53VDm Qf1Z4bE1xVKGhhkW5nh/CtPtnF/ZYXuF5SARN8JKafFS1T5pSKlPB5VrOXga8pyoC2JoZJIw6hi VYN5w9a5SbWl8gUCdZR3MoOERkwf9LAouV7xv0p2PuEldQRKUSxUzwZw9sjfJTEhv6iYVI7N+Ai sfy64yc8KIu5x7dLXrwu558iGQnObiVgWxXopRtf9zKFVWI7GpMux6VlCSG5x2lGaLs6nDlRRHY /KWCigOROGHVDRgy4XTiH7LnkdVqOzr1JAYVIA5xIcJmelr/cEOuX7hx0Fe55DMhp7Z42yYdBB4 Mga6h0iA6PTifQg4fPL9X2JDgHeRlKzSQNxNZMdD+U3mv4H86AdD/Q1aaJz7czxRmEP1/mrcOnj oFoOMp45FEttkvlfVZ5LtjtFNJ7ZrRzVpIQP7KPOE1fXk8E7twef2t/EIFPVkGVqQjnB3eWuhSr o/QzG9kByhcaXiTxIh3bUjGuQGKno5AdZLJzmRERBW4M9Xqyc9Z52WTCNsM15XO6LmDRO8d2tov FUOubk21rcQnYwtrqCLSJ2pagO8Nn4ankvzs/qerljBsMMvjiGC97EFZIUETW67zwBk6x5cD7xP uwbJlXkp49MZra9HC8Qkwiw== X-Developer-Key: i=sebastian.reichel@collabora.com; a=openpgp; fpr=EF660D07463F8B726A795413D8EED7F3C83BFA9A Add support for custom PHY handling steps in platform glue code by adding a post registration hook. This will be used for handling PHY reset notifications on the Rockchip platform. Tested-by: Igor Paunovic # Orange Pi 5 Plus Signed-off-by: Sebastian Reichel Reviewed-by: Krishna Kurapati --- drivers/usb/dwc3/core.c | 2 +- drivers/usb/dwc3/core.h | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 4b7132887a03..daf5aec07fbf 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1613,7 +1613,7 @@ static int dwc3_core_get_phy(struct dwc3 *dwc) } } =20 - return 0; + return dwc3_post_phy_registration(dwc); } =20 static int dwc3_core_init_mode(struct dwc3 *dwc) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 608daeb7ef10..e9d8df0a298e 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -995,10 +995,12 @@ struct dwc3_scratchpad_array { * need to be passed on to glue layer * @pre_set_role: Notify glue of role switch notifications * @pre_run_stop: Notify run stop enable/disable information to glue + * @post_phy_registration: Called directly after PHY got registered */ struct dwc3_glue_ops { void (*pre_set_role)(struct dwc3 *dwc, enum usb_role role); void (*pre_run_stop)(struct dwc3 *dwc, bool is_on); + int (*post_phy_registration)(struct dwc3 *dwc); }; =20 /** @@ -1655,6 +1657,13 @@ static inline void dwc3_pre_run_stop(struct dwc3 *dw= c, bool is_on) dwc->glue_ops->pre_run_stop(dwc, is_on); } =20 +static inline int dwc3_post_phy_registration(struct dwc3 *dwc) +{ + if (dwc->glue_ops && dwc->glue_ops->post_phy_registration) + return dwc->glue_ops->post_phy_registration(dwc); + return 0; +} + #if IS_ENABLED(CONFIG_USB_DWC3_HOST) || IS_ENABLED(CONFIG_USB_DWC3_DUAL_RO= LE) int dwc3_host_init(struct dwc3 *dwc); void dwc3_host_exit(struct dwc3 *dwc); --=20 2.53.0 From nobody Fri Sep 25 07:23:46 2026 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89AED3F44CD; Tue, 15 Sep 2026 15:18:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789485492; cv=none; b=VsKBjK4LpOoC8SEdJuw262qDibGPfGTz6XJrK5mD9tiBVDIMONh18udvUaZ+/5wgIJP3W/VUJ5DSSCdmSXDKF+BHdzsD960n0mHdmUB0H87/0e+qCBPJVjBPkN3DtMta6O8k/RXMy/xGalLPDFyDOfKZqrGnfyGp34X472XBgnw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789485492; c=relaxed/simple; bh=Qhn0zekKj4bR9GvLOaDUJOq2XlBpttbyt0gTlUC4p6o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eNNrF9BX7xrK61A+p7YpNMXScJFUZbX3SSqbraoPNfTE+makg10Lmf4AxenuTMJSGqWd3rUi9wfP9bQkVXiuUfBFd9w8CIAXYKWzzElkcxxXZ8SfhtSysSMy1YK5IenRVTaUqWmHNX37L0FnI6SHObWCs21bUMlY29qq8Add988= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=od+LUdr2; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="od+LUdr2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1789485488; bh=Qhn0zekKj4bR9GvLOaDUJOq2XlBpttbyt0gTlUC4p6o=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=od+LUdr2tlbuo2E0JPDbIvGVK7PCqBuoSWM5Rol+I2eoNWZkOCA+jXdinLh4PLm5J pwJ1gdx1Fm5m30DkRQmYotEJIpVo0uiRZjpJQ7CdSzPxATwOv4S9x4JB8IX5HnKB6g 1Hm97smjPaLZLzEeXXH0JTSghLG3XxIOrPCJcs+MHplkhfJwVX9O5N1XIydCTar0yE Br8QqnkiaLsnbGT8ZglqnmL+eu8jMCzxn9LKOtMfR2emhFjkjKY0sJhE+jOst7gwMc jzFDfBixNbJWtnZEQVGRxIbAvmE6TAF7spe7JFxclbABjiaS6nAnDIOcEcPQ+g8hof 6hgNnHBFjFBKg== 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 119FB17E0C7E; Tue, 15 Sep 2026 17:18:08 +0200 (CEST) Received: by jupiter.universe (Postfix, from userid 1000) id C1ECB480031; Tue, 15 Sep 2026 17:18:07 +0200 (CEST) From: Sebastian Reichel Date: Tue, 15 Sep 2026 17:17:44 +0200 Subject: [PATCH 4/5] usb: dwc3: rockchip: support PHY reset notifications Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260915-b4-rockchip-dwc3-rockchip-glue-v1-4-763bb546824e@collabora.com> References: <20260915-b4-rockchip-dwc3-rockchip-glue-v1-0-763bb546824e@collabora.com> In-Reply-To: <20260915-b4-rockchip-dwc3-rockchip-glue-v1-0-763bb546824e@collabora.com> To: Thinh Nguyen , Greg Kroah-Hartman , Heiko Stuebner , Vinod Koul , Neil Armstrong , Manivannan Sadhasivam Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-phy@lists.infradead.org, kernel@collabora.com, Sebastian Reichel , Igor Paunovic X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6072; i=sebastian.reichel@collabora.com; h=from:subject:message-id; bh=Qhn0zekKj4bR9GvLOaDUJOq2XlBpttbyt0gTlUC4p6o=; b=owJ4nAFtApL9kA0DAAoB2O7X88g7+poByyZiAGqpYa9EWQy52XGQUG2nVeQeoWJcilK/RTb44 /WtTntTCmHJlIkCMwQAAQoAHRYhBO9mDQdGP4tyanlUE9ju1/PIO/qaBQJqqWGvAAoJENju1/PI O/qaqs0P/3FnRSMhbAxkjmMat78LRPms7t6iFMM+SHIFaEx3ncQ6WWVSAa0iBIMBhIhNgj+94xM VFIsY4XLQWhSVtuNUqctqtbWF2Htq2xxZDzCDTt14wjtVMQaWWY6yoqzea1+OeRcHUHb2yjVpZr GGqiukcmzbpTQSnOnPMoKM7FVm28BxOLkrcX2alQKqWAnap5WFGVN4CVc6n/05R+2fY6NhbrEDJ nIkKL7lfYQJeaYklHdgtDjRIm+t5KfyI/ykIpqgOxDgA13Eip/+QV1F70p3BtwheEQynNd3bZTR hGkAfl9aKCce/H+xsuJ4gx60oQvqx5oF/aLVHr4o48OFKlWoPTta3BFOHAdT+bmwsOy8r3ixh85 6StIN1JD0n8MtCiH50XaHsxrKUtGqC4pXywbz3HlWBBnYs6DzhFUTItSF1zhQa8rcKRxeEvYeMB QDDXX3+2QK1ClwnguMtQw2DgUHYr26N7B1G0EeSMJ6NnkWVixJIhypionsGUUp8/I71WFhulkOL PtMoSRZy+lM01sdzRoAIDC2UkM/7zK4pSZLeujaZMeBDE8JZ8XNBAWSaEBMH5SqSJdWd4X5Zl0/ XR6vCPuja6aQDy6H2eoaJhCEcgTgOaypPMqsKvIvFMGX/vlbPail2PPfTrOU9Hy2zuw8+NcaqTP VQsIV8aR/srz1O3aRrIkhrg== X-Developer-Key: i=sebastian.reichel@collabora.com; a=openpgp; fpr=EF660D07463F8B726A795413D8EED7F3C83BFA9A On recent Rockchip platforms (at least RK3588 & RK3576), DWC3 IP is used with a USBDP PHY providing USB3 and DP. This PHY needs to be reset when the mode changes, which may happen when plugging in different USB-C devices. If the USBDP PHY resets with the DWC3 IP running, its internal state corrupts resulting in the USBDP PHY not being able to lock some PLL clocks, which effectively renders USB3 unusable. To fix the issue this adds handling for the new PHY framework reset notifications, which will assert PHYSOFTRST before the actual PHY is disabled and will deassert it once the PHY returns. Tested-by: Igor Paunovic # Orange Pi 5 Plus Signed-off-by: Sebastian Reichel --- drivers/usb/dwc3/dwc3-rockchip.c | 127 +++++++++++++++++++++++++++++++++++= +++- drivers/usb/dwc3/trace.c | 3 + 2 files changed, 129 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/dwc3-rockchip.c b/drivers/usb/dwc3/dwc3-rockc= hip.c index 62f2a03b08a2..7bdd6e2eb22d 100644 --- a/drivers/usb/dwc3/dwc3-rockchip.c +++ b/drivers/usb/dwc3/dwc3-rockchip.c @@ -2,11 +2,136 @@ /* Copyright (c) 2026, Collabora Ltd. */ #include #include +#include #include #include "glue.h" +#include "io.h" + +struct dwc3_rockchip; + +/** + * struct dwc3_rk_phy_nb - wrapper for PHY notifier block + * @nb: notifier block + * @dwc: back-pointer to the DWC3 controller + * @port_index: USB3 port index this notifier is registered for + */ +struct dwc3_rk_phy_nb { + struct notifier_block nb; + struct dwc3_rockchip *dwc_rk; + u8 port_index; +}; =20 struct dwc3_rockchip { struct dwc3 dwc; + struct dwc3_rk_phy_nb usb3_phy_nb[DWC3_USB3_MAX_PORTS]; + u8 phy_reset_active; +}; + +static int dwc3_usb3_phy_notify(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct dwc3_rk_phy_nb *pnb =3D container_of(nb, struct dwc3_rk_phy_nb, nb= ); + struct dwc3_rockchip *dwc_rk =3D pnb->dwc_rk; + struct dwc3 *dwc =3D &dwc_rk->dwc; + int port =3D pnb->port_index; + unsigned long flags; + u32 reg; + int ret; + + switch (action) { + case PHY_NOTIFY_PRE_RESET: + /* + * If already suspended, the resume path will reinit GUSB3PIPECTL + * via dwc3_core_init(). A forced resume is not possible as that + * would call phy_init() resulting in a deadlock. Due to the + * phy_init() in the resume path there is also no need to block + * async RPM resume on our side, since the PHY synchronizes it + * for us. + * + * pm_runtime_get_if_active() returns 0 when suspended (skip), + * 1 when active (ref held), or -EINVAL when PM is disabled + * (device always active). In the -EINVAL case PM ref counting + * is a no-op, so the unconditional put in POST_RESET is safe. + */ + ret =3D pm_runtime_get_if_active(dwc->dev); + if (!ret) + return NOTIFY_OK; + + /* + * Assert USB3 PHY soft reset within DWC3 before the external + * PHY resets. This disconnects the PIPE interface, preventing + * the DWC3 from interfering with PHY reinitialization and + * avoiding LCPLL lock failures. + */ + spin_lock_irqsave(&dwc->lock, flags); + dwc_rk->phy_reset_active |=3D BIT(port); + reg =3D dwc3_readl(dwc, DWC3_GUSB3PIPECTL(port)); + reg |=3D DWC3_GUSB3PIPECTL_PHYSOFTRST; + dwc3_writel(dwc, DWC3_GUSB3PIPECTL(port), reg); + spin_unlock_irqrestore(&dwc->lock, flags); + break; + + case PHY_NOTIFY_POST_RESET: + spin_lock_irqsave(&dwc->lock, flags); + if (!(dwc_rk->phy_reset_active & BIT(port))) { + spin_unlock_irqrestore(&dwc->lock, flags); + return NOTIFY_OK; + } + + dwc_rk->phy_reset_active &=3D ~BIT(port); + + /* + * Deassert PHY soft reset to reconnect the PIPE interface + * after PHY reinitialization. + */ + reg =3D dwc3_readl(dwc, DWC3_GUSB3PIPECTL(port)); + reg &=3D ~DWC3_GUSB3PIPECTL_PHYSOFTRST; + dwc3_writel(dwc, DWC3_GUSB3PIPECTL(port), reg); + spin_unlock_irqrestore(&dwc->lock, flags); + + pm_runtime_put_autosuspend(dwc->dev); + break; + } + + return NOTIFY_OK; +} + +static void dwc3_rk_phy_unregister_notifiers(void *data) +{ + struct dwc3_rockchip *dwc_rk =3D data; + struct dwc3 *dwc =3D &dwc_rk->dwc; + int i; + + for (i =3D 0; i < dwc->num_usb3_ports; i++) + phy_unregister_notifier(dwc->usb3_generic_phy[i], + &dwc_rk->usb3_phy_nb[i].nb); + + /* Release any PM references from in-flight resets */ + for (i =3D 0; i < dwc->num_usb3_ports; i++) { + if (dwc_rk->phy_reset_active & BIT(i)) + pm_runtime_put_autosuspend(dwc->dev); + } + dwc_rk->phy_reset_active =3D 0; +} + +static int dwc3_rk_phy_register_notifiers(struct dwc3 *dwc) +{ + struct dwc3_rockchip *dwc_rk =3D container_of(dwc, struct dwc3_rockchip, = dwc); + int i; + + for (i =3D 0; i < dwc->num_usb3_ports; i++) { + dwc_rk->usb3_phy_nb[i].nb.notifier_call =3D dwc3_usb3_phy_notify; + dwc_rk->usb3_phy_nb[i].dwc_rk =3D dwc_rk; + dwc_rk->usb3_phy_nb[i].port_index =3D i; + phy_register_notifier(dwc->usb3_generic_phy[i], + &dwc_rk->usb3_phy_nb[i].nb); + } + + return devm_add_action_or_reset(dwc->dev, dwc3_rk_phy_unregister_notifier= s, dwc_rk); +} + +static struct dwc3_glue_ops dwc3_rockchip_glue_ops =3D { + .post_phy_registration =3D dwc3_rk_phy_register_notifiers, }; =20 static int dwc3_rockchip_probe(struct platform_device *pdev) @@ -26,7 +151,7 @@ static int dwc3_rockchip_probe(struct platform_device *p= dev) return -ENOMEM; =20 dwc_rk->dwc.dev =3D &pdev->dev; - dwc_rk->dwc.glue_ops =3D NULL; + dwc_rk->dwc.glue_ops =3D &dwc3_rockchip_glue_ops; =20 probe_data.dwc =3D &dwc_rk->dwc; probe_data.res =3D res; diff --git a/drivers/usb/dwc3/trace.c b/drivers/usb/dwc3/trace.c index 088995885678..8c4e2a7b142e 100644 --- a/drivers/usb/dwc3/trace.c +++ b/drivers/usb/dwc3/trace.c @@ -9,3 +9,6 @@ =20 #define CREATE_TRACE_POINTS #include "trace.h" + +EXPORT_TRACEPOINT_SYMBOL_GPL(dwc3_readl); +EXPORT_TRACEPOINT_SYMBOL_GPL(dwc3_writel); --=20 2.53.0 From nobody Fri Sep 25 07:23:46 2026 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D61A54A8FD0; Tue, 15 Sep 2026 15:18:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789485495; cv=none; b=CcDzxSku+kruu57ExHJ5p+KGSTZTgU7oatvqipm3/xhzxW8CaMAUqCJvvdO6ovDv68uKyNJPG7a1nYzllBTqqCNW9giiDlyfKYlFUf5md1Gm3K09m+9FUfmkLyvsmAWv1tdX0chAu1NXjFp3LA3L0W9MotVV4U/99iF1j+mVLy8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789485495; c=relaxed/simple; bh=4ay9HedzmaAw9AOpIB2HEj425HBli4lesEM/GeDH6Ws=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cPzY0Fhc3RgG5rHSwkh8MyDdfTT6VbFpLzG75CFnW5u2dlidw0fvkQZ7oV9Zp2VQHSaxa/+czHIDQCoM3W1Pl8w0DxJ4GTCCN0nw9TaEaVKvttogYwEEIVBpbJQcVtRVkehE3BtJ7zKq1f4YlNxcID6InEnduXrECwPOqQDbBeE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=cg5t7IhU; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="cg5t7IhU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1789485488; bh=4ay9HedzmaAw9AOpIB2HEj425HBli4lesEM/GeDH6Ws=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=cg5t7IhUmD/nWSFCnqRs0kiBU8ihPO0fdhDugaflmmpoalPii7a0j2R089ON6QrY1 uRItSeFGKSn/JajS9cj78LiOPFFcKZc8NxQR05smag0ij9wof8oX6q4r/kHGAN3l+Z WNNEWsdu5H/P9IYlNnFEjpeyX3e6jVOoZYjC/8XOAPvmpYpfvn5APk0ulpGR+vcJUq Xt+CM3jphiWQDyEZbSvgGFyhGi6GS5QIV9pkHZniGWcG2PQcAxbOiFwnmWlWpvG8pR KqeMArgv8RTCkcUJWUhv5zJAyPT/WMNEvU5J4Rznb23bpD7QzuNufkA+q4EMmZ5oUN gdoc72h0GbWFQ== 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 5DFAF17E0D43; Tue, 15 Sep 2026 17:18:08 +0200 (CEST) Received: by jupiter.universe (Postfix, from userid 1000) id C3960480035; Tue, 15 Sep 2026 17:18:07 +0200 (CEST) From: Sebastian Reichel Date: Tue, 15 Sep 2026 17:17:45 +0200 Subject: [PATCH 5/5] usb: dwc3: rockchip: fix USB-C reconnect in gadget mode Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260915-b4-rockchip-dwc3-rockchip-glue-v1-5-763bb546824e@collabora.com> References: <20260915-b4-rockchip-dwc3-rockchip-glue-v1-0-763bb546824e@collabora.com> In-Reply-To: <20260915-b4-rockchip-dwc3-rockchip-glue-v1-0-763bb546824e@collabora.com> To: Thinh Nguyen , Greg Kroah-Hartman , Heiko Stuebner , Vinod Koul , Neil Armstrong , Manivannan Sadhasivam Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-phy@lists.infradead.org, kernel@collabora.com, Sebastian Reichel X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2823; i=sebastian.reichel@collabora.com; h=from:subject:message-id; bh=4ay9HedzmaAw9AOpIB2HEj425HBli4lesEM/GeDH6Ws=; b=owJ4nAFtApL9kA0DAAoB2O7X88g7+poByyZiAGqpYa/a9SOAir0KW4AaNxa0ywVhpg488MTBD S0OITRoVLsQzYkCMwQAAQoAHRYhBO9mDQdGP4tyanlUE9ju1/PIO/qaBQJqqWGvAAoJENju1/PI O/qa5RwQAKpvcFHb8bI5rMhfqAImvq7YJvT7RXR6ReF/8jl2T1nEvc6xW4/s2rJOnlbm8PQr6yj JesP2eExEyH6PNp1mNauTAmwALyAoeFG2iircznSMEpXFgXZjWjTzngeP2I4yW2LVfovn2oy0to UyiyGI4VTJ8YBiXTPT2QmaRzfN5IL+1+JHds6tAsnc1MvHG2Yq9Y2EzGFitweX3Q2LS4mSgMU6R fosX2KjeozFlR9Xdn9EHtmgnqjPBnkTw587QJMDeC8xXfUNXWLxgZ9eaEl3Y/IDwnCV/1jQKnQp fnSmknaz5xG0ChuKLhIOEJiazDS56oQcWXFO2hx85CXvDpr9TndZhSuZy/2y0Vb1BfUyWIzgts+ MvdjtlQPoPZiV93AEL9Ib1gSjssPuU8sEPKloDX27V8wBZqhck/9aUhMbe/ku3m+Yrq13g1/qr+ Mu8Hj2eg8whfz3OK4Ao7FZKWMTLx60UVFGrspmu6uCQDJE1vvXdMZY3nY+iGn7PjhoaZjbhAWqR 2ug3lh5K9u2/lj3gGECQDoWMWdD0ai55PyeYKM8jPQZiwap2nUkA+sX2+s3c7wYlvoo+mpEB6AZ GyBXi8HOHTGN8d9wxnNNLmCCQiYaD8T4gvoEOlIgVaLiWDCFX4yV5nehFW/clwcwYEh26hbNJRq zTBYrZVo69pN8Vyq1904r2A== X-Developer-Key: i=sebastian.reichel@collabora.com; a=openpgp; fpr=EF660D07463F8B726A795413D8EED7F3C83BFA9A When USB-C is configured in gadget mode and the cable is unplugged the USB controller is suspended. After plugging in the cable again, the USB controller stays suspended and thus the port status remains not-attached. Fix this by triggering a runtime PM resume when the role is changed. The Runtime PM reference counter is immediately decreased again - the auto-suspend time is big enough to detect the connection status, which will then keep its own reference. Signed-off-by: Sebastian Reichel --- drivers/usb/dwc3/dwc3-rockchip.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/usb/dwc3/dwc3-rockchip.c b/drivers/usb/dwc3/dwc3-rockc= hip.c index 7bdd6e2eb22d..bedec3295bb1 100644 --- a/drivers/usb/dwc3/dwc3-rockchip.c +++ b/drivers/usb/dwc3/dwc3-rockchip.c @@ -25,8 +25,17 @@ struct dwc3_rockchip { struct dwc3 dwc; struct dwc3_rk_phy_nb usb3_phy_nb[DWC3_USB3_MAX_PORTS]; u8 phy_reset_active; + enum usb_role role; }; =20 +static void dwc3_rockchip_vbus_handler(struct dwc3 *dwc, bool present) +{ + if (!dwc->gadget || !dwc->gadget_driver) + return; + + usb_udc_vbus_handler(dwc->gadget, present); +} + static int dwc3_usb3_phy_notify(struct notifier_block *nb, unsigned long action, void *data) { @@ -57,6 +66,8 @@ static int dwc3_usb3_phy_notify(struct notifier_block *nb, if (!ret) return NOTIFY_OK; =20 + dwc3_rockchip_vbus_handler(dwc, false); + /* * Assert USB3 PHY soft reset within DWC3 before the external * PHY resets. This disconnects the PIPE interface, preventing @@ -69,6 +80,7 @@ static int dwc3_usb3_phy_notify(struct notifier_block *nb, reg |=3D DWC3_GUSB3PIPECTL_PHYSOFTRST; dwc3_writel(dwc, DWC3_GUSB3PIPECTL(port), reg); spin_unlock_irqrestore(&dwc->lock, flags); + break; =20 case PHY_NOTIFY_POST_RESET: @@ -89,6 +101,8 @@ static int dwc3_usb3_phy_notify(struct notifier_block *n= b, dwc3_writel(dwc, DWC3_GUSB3PIPECTL(port), reg); spin_unlock_irqrestore(&dwc->lock, flags); =20 + dwc3_rockchip_vbus_handler(dwc, dwc_rk->role =3D=3D USB_ROLE_DEVICE); + pm_runtime_put_autosuspend(dwc->dev); break; } @@ -130,7 +144,16 @@ static int dwc3_rk_phy_register_notifiers(struct dwc3 = *dwc) return devm_add_action_or_reset(dwc->dev, dwc3_rk_phy_unregister_notifier= s, dwc_rk); } =20 +static void dwc3_rockchip_set_role(struct dwc3 *dwc, enum usb_role role) +{ + struct dwc3_rockchip *dwc_rk =3D container_of(dwc, struct dwc3_rockchip, = dwc); + + dwc_rk->role =3D role; + dwc3_rockchip_vbus_handler(dwc, role =3D=3D USB_ROLE_DEVICE); +} + static struct dwc3_glue_ops dwc3_rockchip_glue_ops =3D { + .pre_set_role =3D dwc3_rockchip_set_role, .post_phy_registration =3D dwc3_rk_phy_register_notifiers, }; =20 --=20 2.53.0