From patchwork Mon Apr 7 18:09:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Frattaroli X-Patchwork-Id: 14041645 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 C7166C36010 for ; Mon, 7 Apr 2025 19:21:44 +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=Hsk96FSguk/Ky1tsPSxd4I1gk9mUryoWRi27TGtLokQ=; b=rN0hBdAZfHGJwy9lkdmwouplB6 gGRyzeki300QUZp2eu+K0ZC1x8RB2dXfKhCu6YTKxolP/a55z1uJh9tRo0XdhftSnd8Y5agGBBvOZ i5iMUqyDEFvk3gjY0jJ0dFuvKm5K8yUbNkMeVl35VQ0bgr3OLXIQmcYB7jjvZEKEPGpZzyty2tgcz UKwkirUS1M30tO6jAtao6EnRnWSQwslli2OPUZ7U5N8KgX+xuhBDrGsUox3pKoK9LqqIpMB3Ab5U6 ffYZWVhS/Cnon2f7m7Rc+fsnA7OWVRXsopOJFb/WaGzP0PMvXUGBb2O3bjTp+99oeynklaIyinnIP sFvND8EA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1u1s2I-00000001nSM-0Y6R; Mon, 07 Apr 2025 19:21:34 +0000 Received: from sender4-pp-f112.zoho.com ([136.143.188.112]) by bombadil.infradead.org with esmtps (Exim 4.98.1 #2 (Red Hat Linux)) id 1u1quz-00000001Tga-3nZ8; Mon, 07 Apr 2025 18:09:59 +0000 ARC-Seal: i=1; a=rsa-sha256; t=1744049386; cv=none; d=zohomail.com; s=zohoarc; b=SRDEYS6j7qhew185kGpHfxeaN4cvGqAabO/XZ/1tkRb6AGo9vfk+FnKWZvX+jzWjRkYmsDv2G1Osl/9YHzsbul1rGCP1SRutcB5TkJIdJH1gto3fNjW5vWcQ7PbU0NTngFrDg7FkI2v+K4386sEAoRwEAqFKQ/y1S0bCMYarIY8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744049386; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=Hsk96FSguk/Ky1tsPSxd4I1gk9mUryoWRi27TGtLokQ=; b=ddnwQZSeCMBZzuXQSpkEIVK7rEE1SzrACFBi2Xkif1UW3cOOXt61RQBDvDyRJx+k04qI7PXVTXPRK8zw+H0NWDCJpy0IRwUCuuRFiFNWWk+w/F7aTFfz6ShkX8X7sL7BOk3GB5pUvuLGiIAAnCcYbkwu6/1yaYhMKLyZ/FKEY4U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=nicolas.frattaroli@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1744049386; s=zohomail; d=collabora.com; i=nicolas.frattaroli@collabora.com; h=From:From:Date:Date:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Message-Id:References:In-Reply-To:To:To:Cc:Cc:Reply-To; bh=Hsk96FSguk/Ky1tsPSxd4I1gk9mUryoWRi27TGtLokQ=; b=ivoK+cH/E3m7x3WDEoPCvqr/fH9WPvYqfA4ggDfOCrchVl6Wb+YFCM6VWnPIhuIY rJSmK1axaj6w6jWu+GQXPemHEka0uTYf3UhUVSNXdG230dwT5BiO8x1gpFSAiTDO8X6 p2MwAmrGGlgOnwfNwFcdGomYKDgi0Rel2Cmyhq5g= Received: by mx.zohomail.com with SMTPS id 1744049384577926.4016780097427; Mon, 7 Apr 2025 11:09:44 -0700 (PDT) From: Nicolas Frattaroli Date: Mon, 07 Apr 2025 20:09:14 +0200 Subject: [PATCH 1/4] dt-bindings: phy: rockchip,inno-usb2phy: add port property MIME-Version: 1.0 Message-Id: <20250407-rk3576-sige5-usb-v1-1-67eec166f82f@collabora.com> References: <20250407-rk3576-sige5-usb-v1-0-67eec166f82f@collabora.com> In-Reply-To: <20250407-rk3576-sige5-usb-v1-0-67eec166f82f@collabora.com> To: Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiko Stuebner , Kever Yang , Frank Wang Cc: Sebastian Reichel , kernel@collabora.com, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Nicolas Frattaroli X-Mailer: b4 0.14.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250407_110958_006090_E2BA0630 X-CRM114-Status: GOOD ( 10.54 ) 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 USB connectors like to have OF graph connections to high-speed related nodes to do various things. In the case of the RK3576, we can make use of a port in the usb2 PHY to detect whether the OTG controller is connected to a type C port and apply some special behaviour accordingly. The usefulness of having different bits of a fully functioning USB stack point to each other is more general though, and not constrained to RK3576 at all, even for this use-case. Add a port property to the binding. Signed-off-by: Nicolas Frattaroli --- Documentation/devicetree/bindings/phy/rockchip,inno-usb2phy.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/phy/rockchip,inno-usb2phy.yaml b/Documentation/devicetree/bindings/phy/rockchip,inno-usb2phy.yaml index 6a7ef556414cebad63c10de754778f84fd4486ee..3a662bfc353250a8ad9386ebb5575d1e84c1b5ba 100644 --- a/Documentation/devicetree/bindings/phy/rockchip,inno-usb2phy.yaml +++ b/Documentation/devicetree/bindings/phy/rockchip,inno-usb2phy.yaml @@ -78,6 +78,11 @@ properties: When set the driver will request its phandle as one companion-grf for some special SoCs (e.g rv1108). + port: + $ref: /schemas/graph.yaml#/properties/port + description: + A port node to link the PHY to a USB connector's "high-speed" port. + host-port: type: object additionalProperties: false From patchwork Mon Apr 7 18:09:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Frattaroli X-Patchwork-Id: 14041580 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 72EACC36018 for ; Mon, 7 Apr 2025 18:56:30 +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=Kk+sJ5uIUChiU10ulvk3xbtqOOJOIxtcCt00TnkAFo4=; b=b5UiW9GavWCdE3Fz/oRI6XaDjk ckYY6tOa3nYBpsAD57Sp8nWT/cO6XFehcuqo9enWJpymtBmEMNXFSn2joam7l0HWpHzqW6u0jJfwy KXsloZihAC9GgYW52jAAGBrituzoeU9NheGyISvj9AswYDXzbfjSI/4VyKM0EkGLmuSQK495CuDxQ HIVzoIleyLnf7HnDN9AXyeY+MEvTB32Etk71awSnPxdDzEffFwC1tL4i/mffGahjEXBLAqVQLiDP6 4PXecWvKE3XeKa6wYHpQhaErFYnK9uU/3ztk0guwGVVrd/hGuSgJ5EtWxp9Jg5cwpi+LS3hZ0arpy +49W55PA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1u1rdt-00000001iEK-3REJ; Mon, 07 Apr 2025 18:56:21 +0000 Received: from sender3-pp-f112.zoho.com ([136.143.184.112]) by bombadil.infradead.org with esmtps (Exim 4.98.1 #2 (Red Hat Linux)) id 1u1qv9-00000001Tjh-3aRq; Mon, 07 Apr 2025 18:10:09 +0000 ARC-Seal: i=1; a=rsa-sha256; t=1744049390; cv=none; d=zohomail.com; s=zohoarc; b=Necu4VPR/VUul1b+RBujP89FTiCPjqO/Si5Jh01ACaOTbHqylyWqyQ7e2hBq3Qd/kSGArFXMfuiisrC/MF/Sm/qy1JaMMdt2bg4xTeXSvyISgS1WIL1wxGqLDJRQtd9wCIMgxjKpYghvZ1RQA7HrcMf5jEASc9LQkYlQQQzCwbg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744049390; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=Kk+sJ5uIUChiU10ulvk3xbtqOOJOIxtcCt00TnkAFo4=; b=mDDmyjXxgsyT6LQl1niZKJEuYW6a4ZgAiM+PbKd3RgMSuIr+0ueD9zC7e0L/ytg4Sj1XpWg2mr9NA67NsCLrtkKvThQtknnDw9Da4ldxVyZq0Cvu7fw95EOQ3r/9kPX+9aw90oHmSE9Ba3lF0rDD65noUcJHMr/uwgURi+ncu+c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=nicolas.frattaroli@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1744049390; s=zohomail; d=collabora.com; i=nicolas.frattaroli@collabora.com; h=From:From:Date:Date:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Message-Id:References:In-Reply-To:To:To:Cc:Cc:Reply-To; bh=Kk+sJ5uIUChiU10ulvk3xbtqOOJOIxtcCt00TnkAFo4=; b=CTSUKXVCsZIacwoTbuUCDyLQX8AgWIkRchue8FyNix1y1bqePf2q7ojKJwPEz9m0 NR0tlGrOz2dHOFUyoqIZhFYUhX8m1USdh0WOtnXJZ2SWVIgUIfe2czjQnTWWpQ0HFyo bkSmjqaVadC2gUSf/QSWfoDNCdR793HPtX9mtgg8= Received: by mx.zohomail.com with SMTPS id 174404938859027.759672499582507; Mon, 7 Apr 2025 11:09:48 -0700 (PDT) From: Nicolas Frattaroli Date: Mon, 07 Apr 2025 20:09:15 +0200 Subject: [PATCH 2/4] phy: rockchip: inno-usb2: add soft vbusvalid control MIME-Version: 1.0 Message-Id: <20250407-rk3576-sige5-usb-v1-2-67eec166f82f@collabora.com> References: <20250407-rk3576-sige5-usb-v1-0-67eec166f82f@collabora.com> In-Reply-To: <20250407-rk3576-sige5-usb-v1-0-67eec166f82f@collabora.com> To: Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiko Stuebner , Kever Yang , Frank Wang Cc: Sebastian Reichel , kernel@collabora.com, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Nicolas Frattaroli X-Mailer: b4 0.14.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250407_111008_004748_18A61BB8 X-CRM114-Status: GOOD ( 19.53 ) 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 With USB type C connectors, the vbus detect pin of the OTG controller attached to it is pulled high by a USB Type C controller chip such as the fusb302. This means USB enumeration on Type-C ports never works, as the vbus is always seen as high. Rockchip added some GRF register flags to deal with this situation. The RK3576 TRM calls these "soft_vbusvalid_bvalid" (con0 bit index 15) and "soft_vbusvalid_bvalid_sel" (con0 bit index 14). Downstream introduces a new vendor property which tells the USB 2 PHY that it's connected to a type C port, but we can do better. Since in such an arrangement, we'll have an OF graph connection to the USB connector anyway, we can walk said OF graph and check the connector's compatible to determine this without adding any further vendor properties. Do keep in mind that the usbdp PHY driver seemingly fiddles with these register fields as well, but what it does doesn't appear to be enough for us to get working USB enumeration, presumably because the whole vbus_attach logic needs to be adjusted as well either way. Signed-off-by: Nicolas Frattaroli --- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 78 +++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 4 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c index b5e6a864deebbcb33375001fc6ed67b2dfee6954..7dc4f53e18fcf0c9d010dd78e5fcd089b6bae43f 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -114,6 +115,8 @@ struct rockchip_chg_det_reg { /** * struct rockchip_usb2phy_port_cfg - usb-phy port configuration. * @phy_sus: phy suspend register. + * @svbus_en: soft vbus bvalid enable register. + * @svbus_sel: soft vbus bvalid selection register. * @bvalid_det_en: vbus valid rise detection enable register. * @bvalid_det_st: vbus valid rise detection status register. * @bvalid_det_clr: vbus valid rise detection clear register. @@ -140,6 +143,8 @@ struct rockchip_chg_det_reg { */ struct rockchip_usb2phy_port_cfg { struct usb2phy_reg phy_sus; + struct usb2phy_reg svbus_en; + struct usb2phy_reg svbus_sel; struct usb2phy_reg bvalid_det_en; struct usb2phy_reg bvalid_det_st; struct usb2phy_reg bvalid_det_clr; @@ -203,6 +208,7 @@ struct rockchip_usb2phy_cfg { * @event_nb: hold event notification callback. * @state: define OTG enumeration states before device reset. * @mode: the dr_mode of the controller. + * @typec_vbus_det: whether to apply Type C logic to OTG vbus detection. */ struct rockchip_usb2phy_port { struct phy *phy; @@ -222,6 +228,7 @@ struct rockchip_usb2phy_port { struct notifier_block event_nb; enum usb_otg_state state; enum usb_dr_mode mode; + bool typec_vbus_det; }; /** @@ -495,6 +502,13 @@ static int rockchip_usb2phy_init(struct phy *phy) mutex_lock(&rport->mutex); if (rport->port_id == USB2PHY_PORT_OTG) { + if (rport->typec_vbus_det) { + if (rport->port_cfg->svbus_en.enable && + rport->port_cfg->svbus_sel.enable) { + property_enable(rphy->grf, &rport->port_cfg->svbus_en, true); + property_enable(rphy->grf, &rport->port_cfg->svbus_sel, true); + } + } if (rport->mode != USB_DR_MODE_HOST && rport->mode != USB_DR_MODE_UNKNOWN) { /* clear bvalid status and enable bvalid detect irq */ @@ -535,8 +549,7 @@ static int rockchip_usb2phy_init(struct phy *phy) if (ret) goto out; - schedule_delayed_work(&rport->otg_sm_work, - OTG_SCHEDULE_DELAY * 3); + schedule_delayed_work(&rport->otg_sm_work, 0); } else { /* If OTG works in host only mode, do nothing. */ dev_dbg(&rport->phy->dev, "mode %d\n", rport->mode); @@ -666,8 +679,17 @@ static void rockchip_usb2phy_otg_sm_work(struct work_struct *work) unsigned long delay; bool vbus_attach, sch_work, notify_charger; - vbus_attach = property_enabled(rphy->grf, - &rport->port_cfg->utmi_bvalid); + if (rport->port_cfg->svbus_en.enable && rport->typec_vbus_det) { + if (property_enabled(rphy->grf, &rport->port_cfg->svbus_en) && + property_enabled(rphy->grf, &rport->port_cfg->svbus_sel)) { + vbus_attach = true; + } else { + vbus_attach = false; + } + } else { + vbus_attach = property_enabled(rphy->grf, + &rport->port_cfg->utmi_bvalid); + } sch_work = false; notify_charger = false; @@ -1276,6 +1298,48 @@ static int rockchip_otg_event(struct notifier_block *nb, return NOTIFY_DONE; } +static const char *const rockchip_usb2phy_typec_cons[] = { + "usb-c-connector", + NULL, +}; + +static bool rockchip_usb2phy_otg_is_type_c(struct rockchip_usb2phy *rphy) +{ + struct device_node *node = rphy->dev->of_node; + struct device_node *ports; + struct device_node *ep = NULL; + struct device_node *parent; + + ports = of_get_child_by_name(node, "ports"); + if (ports) + node = ports; + + for_each_of_graph_port(node, port) { + ep = of_get_child_by_name(port, "endpoint"); + if (!ep) + continue; + + parent = of_graph_get_remote_port_parent(ep); + of_node_put(ep); + if (!parent) + continue; + + if (of_device_compatible_match(parent, rockchip_usb2phy_typec_cons)) { + of_node_put(parent); + if (ports) + of_node_put(ports); + return true; + } + + of_node_put(parent); + } + + if (ports) + of_node_put(ports); + + return false; +} + static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, struct rockchip_usb2phy_port *rport, struct device_node *child_np) @@ -1297,6 +1361,8 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, mutex_init(&rport->mutex); + rport->typec_vbus_det = rockchip_usb2phy_otg_is_type_c(rphy); + rport->mode = of_usb_get_dr_mode_by_phy(child_np, -1); if (rport->mode == USB_DR_MODE_HOST || rport->mode == USB_DR_MODE_UNKNOWN) { @@ -1971,6 +2037,8 @@ static const struct rockchip_usb2phy_cfg rk3576_phy_cfgs[] = { .port_cfgs = { [USB2PHY_PORT_OTG] = { .phy_sus = { 0x0000, 8, 0, 0, 0x1d1 }, + .svbus_en = { 0x0000, 15, 15, 0, 1 }, + .svbus_sel = { 0x0000, 14, 14, 0, 1 }, .bvalid_det_en = { 0x00c0, 1, 1, 0, 1 }, .bvalid_det_st = { 0x00c4, 1, 1, 0, 1 }, .bvalid_det_clr = { 0x00c8, 1, 1, 0, 1 }, @@ -2008,6 +2076,8 @@ static const struct rockchip_usb2phy_cfg rk3576_phy_cfgs[] = { .port_cfgs = { [USB2PHY_PORT_OTG] = { .phy_sus = { 0x2000, 8, 0, 0, 0x1d1 }, + .svbus_en = { 0x2000, 15, 15, 0, 1 }, + .svbus_sel = { 0x2000, 14, 14, 0, 1 }, .bvalid_det_en = { 0x20c0, 1, 1, 0, 1 }, .bvalid_det_st = { 0x20c4, 1, 1, 0, 1 }, .bvalid_det_clr = { 0x20c8, 1, 1, 0, 1 }, From patchwork Mon Apr 7 18:09:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Frattaroli X-Patchwork-Id: 14041857 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 4EFF4C369A1 for ; Mon, 7 Apr 2025 21:47:05 +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=znUavP/BrlHSUj49dkNncKOBHc7iyfaD5tE24M8Y1yg=; b=0+48S1GK5fIWtV9la6P//c+iIc lOMxrTRQrJEq4s3pOJ8zvvmkW6KPWvVrz49TK7tsjVvmCO812dfSi4Zr6JaxmvNtBCgdBaaieb2jr X9jt8JsyMEsC5UtRibfJsuOcBqX8HX7AsGPuM9enV3jHmdtDwghuqcAW/LF2bfCTTE3mWE/5ZJ1gW r1yJ67maZumLJ5Fjv9eimy/+yiszj2N/YdiwAgItJuBHRqvBCyTBduG/pcqB1tisMPtY1x1626rzj vB32stcxTNOyscZTXbUlwjjZ2g/aT31m5mFzc17ml9NiFSmpxiRQFTMPOAkeUp9/1Ngklj/cQokhX NeSTVX7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1u1uIj-000000023zn-3549; Mon, 07 Apr 2025 21:46:41 +0000 Received: from sender4-pp-f112.zoho.com ([136.143.188.112]) by bombadil.infradead.org with esmtps (Exim 4.98.1 #2 (Red Hat Linux)) id 1u1qv8-00000001TjQ-37fr; Mon, 07 Apr 2025 18:10:07 +0000 ARC-Seal: i=1; a=rsa-sha256; t=1744049394; cv=none; d=zohomail.com; s=zohoarc; b=K6IiAeHqBHlNrWiqQn+3MNldAf/eENA+BvXOKM7nbKf1rlWU+6fUObV15o6Rm6AzFG6GgOEtfu0XIpDc8C0GFToquzvl87oy2p6ABernLurSxNOjQglpzYwNJNglrILRb0r22iJejThpPi1wf3L6VWQrwvwgIWNorUtwpX/WALQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744049394; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=znUavP/BrlHSUj49dkNncKOBHc7iyfaD5tE24M8Y1yg=; b=NXh8bDoXXWwwOExleJ5437igv5RzEKqCGSEovzd4+KtJN2D/EGSY3B8ycbC31KnJP8R8YkF0sSnDU1LdYgNcNJ6Fvs2aqT8u/ZjryWDtOcmiIhNiT7JSoFvJ0mNtUGEg6DeI8DLfYJrFI/8fzjWmZ1zdRTAFQFdx+QFOEdz0D6k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=nicolas.frattaroli@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1744049394; s=zohomail; d=collabora.com; i=nicolas.frattaroli@collabora.com; h=From:From:Date:Date:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Message-Id:References:In-Reply-To:To:To:Cc:Cc:Reply-To; bh=znUavP/BrlHSUj49dkNncKOBHc7iyfaD5tE24M8Y1yg=; b=RwpDAbGcZNxlG/P6vQDHPFyHVr7ljwNalyK6/Nd34ZnUbpXUgs6R2H3OfuaWiSLp gnHapHdlFh770AYbaJvZTiPxdoNrvOi1rMaW5zbLWhcGZ0JkREGGZ3swN8pMQ6jUzm0 nJf56irj5oDDC5GLmNZ6ihhSktGDII90JP717cGU= Received: by mx.zohomail.com with SMTPS id 1744049392553406.29570236196037; Mon, 7 Apr 2025 11:09:52 -0700 (PDT) From: Nicolas Frattaroli Date: Mon, 07 Apr 2025 20:09:16 +0200 Subject: [PATCH 3/4] arm64: dts: rockchip: add phy suspend quirk to usb on rk3576 MIME-Version: 1.0 Message-Id: <20250407-rk3576-sige5-usb-v1-3-67eec166f82f@collabora.com> References: <20250407-rk3576-sige5-usb-v1-0-67eec166f82f@collabora.com> In-Reply-To: <20250407-rk3576-sige5-usb-v1-0-67eec166f82f@collabora.com> To: Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiko Stuebner , Kever Yang , Frank Wang Cc: Sebastian Reichel , kernel@collabora.com, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Nicolas Frattaroli X-Mailer: b4 0.14.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250407_111006_842858_ECC9EED4 X-CRM114-Status: GOOD ( 13.33 ) 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 The dwc3 controllers on RK3576 appear to have some quirky behaviour relating to runtime power suspension. Specifically, they will cause SError aborts on register reads in the xhci code when setting the device role. Downstream appears to work around this by manually checking for the rk3576 compatible in the dwc3 core driver, and then setting the autosuspend delay to 200. This appears to be smaller than what mainline uses, and I'm not quite sure how that fixes it, but I could also be reading the code wrong. The important takeaway is that the RK3399 uses the same codepath. Looking at RK3399 in mainline then, we see that it has one quirk that RK3576 doesn't have in its dwc3 controllers: snps,dis_u2_susphy_quirk. Long story short, adding the snps,dis_u2_susphy_quirk property to rk3576.dtsi's dwc3 controllers fixes the issue. Quite suspicious that this is not needed among usb controllers based on dwc3 in other Rockchip designs, especially other RK35xx ones. Fixes: 23ec57a32da4 ("arm64: dts: rockchip: add usb related nodes for rk3576") Signed-off-by: Nicolas Frattaroli --- arch/arm64/boot/dts/rockchip/rk3576.dtsi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/boot/dts/rockchip/rk3576.dtsi b/arch/arm64/boot/dts/rockchip/rk3576.dtsi index ebb5fc8bb8b1363127b9d3782801c4a79b678a92..71c71f5a2b77c52b251bea16e4deaa4b0109715a 100644 --- a/arch/arm64/boot/dts/rockchip/rk3576.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3576.dtsi @@ -470,6 +470,7 @@ usb_drd0_dwc3: usb@23000000 { snps,dis-u2-freeclk-exists-quirk; snps,dis-del-phy-power-chg-quirk; snps,dis-tx-ipgap-linecheck-quirk; + snps,dis_u2_susphy_quirk; snps,parkmode-disable-hs-quirk; snps,parkmode-disable-ss-quirk; status = "disabled"; @@ -496,6 +497,7 @@ usb_drd1_dwc3: usb@23400000 { snps,dis-del-phy-power-chg-quirk; snps,dis-tx-ipgap-linecheck-quirk; snps,dis_rxdet_inp3_quirk; + snps,dis_u2_susphy_quirk; snps,parkmode-disable-hs-quirk; snps,parkmode-disable-ss-quirk; dma-coherent; From patchwork Mon Apr 7 18:09:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Frattaroli X-Patchwork-Id: 14041603 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 222D0C36018 for ; Mon, 7 Apr 2025 18:58:19 +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=Xnv5MfaFzomawaxWyH7pWxpw5ddTb5bXnqTSVdYnSdk=; b=hoXyOjSkQo2v2vpOQRFHE+A+Xt /TWeAWVX6h5YPKC63xKQsLkS1G/qWWljcym+PuL2o9ts+TIa+zjT06CCR/DxuN0db/t4M4OyLO9nv 5v3zrCxyOaXhflz9eR+18OpOo+/IWd9UTjPPmwHdiLIbk6RrbtH/XzdJ1CiHufNDs81kVcUt0yyj6 eS6NMTTTDkkrZmaeD0/HT5W4G6lxXzxAsV9CC1RJ1H0kwFw2S7iEvNeTCeb+Hqh/42/0+P1TKvhEw 051Jc6EJ68Bivnz2tJCk95cuKh45MPSqRVfFMi0iQ7roV2lMuz1a/6Ob+oaHWbKYB07ZijFzhFE9O 2rDpUW6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1u1rfd-00000001iby-1OPD; Mon, 07 Apr 2025 18:58:09 +0000 Received: from sender4-pp-f112.zoho.com ([136.143.188.112]) by bombadil.infradead.org with esmtps (Exim 4.98.1 #2 (Red Hat Linux)) id 1u1qvC-00000001Tks-0ymT; Mon, 07 Apr 2025 18:10:11 +0000 ARC-Seal: i=1; a=rsa-sha256; t=1744049398; cv=none; d=zohomail.com; s=zohoarc; b=L7ZIIBXp64pKw0YfQAJ9eeFkBk7MKn3P4PYa0AVapVsvjZYiwVvIKuBFERU0O1JdoFzsHfhOD+jYAr3AqmA2+0DJevZRGymFAIMUzkXDTFyKnRsI6RrHPE8l126IsYGbj8E8DGb8SIZ6g5GA64hgA+hoSKUxXHkhOXn2bumAk18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744049398; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=Xnv5MfaFzomawaxWyH7pWxpw5ddTb5bXnqTSVdYnSdk=; b=c3s68I/jQrQklNJHmiEynxXfmNyb++bmmR2YyFtXhGG3VRM0Rjkmb6YWWM94u9forsAEWzzPQN9JqgMByjVf1vgk6mc+uZu4Ib9JyWv7Wcj+RfjzPo1nbMApYbo7+/OAOa+bbowKAEo7KkAT3pEJuOvoTW58AAQPLaetHve5j8w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=nicolas.frattaroli@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1744049398; s=zohomail; d=collabora.com; i=nicolas.frattaroli@collabora.com; h=From:From:Date:Date:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Message-Id:References:In-Reply-To:To:To:Cc:Cc:Reply-To; bh=Xnv5MfaFzomawaxWyH7pWxpw5ddTb5bXnqTSVdYnSdk=; b=AVHCswuj8QKflz+JtHurC86AVR5fkFb2a+xHP+VdU+cKoyStT4rU/Dad1vFZqCB0 UHhq9ZU0FerqTM2ga2bweLJe2xnV8bVQT54v5XdBQlIVfc5UEDE002shiofdDBRllIH anSpgvwL5g4gtqgn16lVKcNBrt5WOPIHfnx8Eojw= Received: by mx.zohomail.com with SMTPS id 1744049396610968.3321994444946; Mon, 7 Apr 2025 11:09:56 -0700 (PDT) From: Nicolas Frattaroli Date: Mon, 07 Apr 2025 20:09:17 +0200 Subject: [PATCH 4/4] arm64: dts: rockchip: enable USB on Sige5 MIME-Version: 1.0 Message-Id: <20250407-rk3576-sige5-usb-v1-4-67eec166f82f@collabora.com> References: <20250407-rk3576-sige5-usb-v1-0-67eec166f82f@collabora.com> In-Reply-To: <20250407-rk3576-sige5-usb-v1-0-67eec166f82f@collabora.com> To: Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiko Stuebner , Kever Yang , Frank Wang Cc: Sebastian Reichel , kernel@collabora.com, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Nicolas Frattaroli X-Mailer: b4 0.14.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250407_111010_333936_C92634A6 X-CRM114-Status: GOOD ( 11.08 ) 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 The ArmSoM Sige5 has several USB ports: a Type-A USB 3 port (USB2 lines going through a hub), a Type-A USB 2.0 port (also going through a hub), a Type-C DC input port that has absolutely no USB data connection and a Type-C port with USB3.2 Gen1x1 that's also the maskrom programming port. Enable these ports, and set the device role to be host for the host ports. The data capable Type-C USB port uses a fusb302 for data role switching. It currently does not have functioning SuperSpeed with certain Type-C cables in one of the two possible orientations. Signed-off-by: Nicolas Frattaroli --- .../boot/dts/rockchip/rk3576-armsom-sige5.dts | 153 +++++++++++++++++++++ 1 file changed, 153 insertions(+) diff --git a/arch/arm64/boot/dts/rockchip/rk3576-armsom-sige5.dts b/arch/arm64/boot/dts/rockchip/rk3576-armsom-sige5.dts index 828bde7fab68dc6bcbd13d75c8a72540b3666071..cdd8f8b2319105b1dae34395be20e50d45cd4431 100644 --- a/arch/arm64/boot/dts/rockchip/rk3576-armsom-sige5.dts +++ b/arch/arm64/boot/dts/rockchip/rk3576-armsom-sige5.dts @@ -175,6 +175,33 @@ vcc_3v3_ufs_s0: regulator-vcc-ufs-s0 { regulator-max-microvolt = <3300000>; vin-supply = <&vcc_5v0_sys>; }; + + vcc_5v0_typec0: regulator-vcc-5v0-typec0 { + compatible = "regulator-fixed"; + enable-active-high; + gpios = <&gpio4 RK_PA6 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&usb_otg0_pwren>; + regulator-name = "vcc_5v0_typec0"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + vin-supply = <&vcc_5v0_device>; + }; + vcc_5v0_usbhost: regulator-vcc-5v0-usbhost { + compatible = "regulator-fixed"; + enable-active-high; + gpios = <&gpio4 RK_PA4 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&usb_host_pwren>; + regulator-name = "vcc_5v0_usbhost"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + vin-supply = <&vcc_5v0_device>; + }; +}; + +&combphy1_psu { + status = "okay"; }; &cpu_l0 { @@ -605,6 +632,58 @@ regulator-state-mem { &i2c2 { status = "okay"; + usbc0: typec-portc@22 { + compatible = "fcs,fusb302"; + reg = <0x22>; + interrupt-parent = <&gpio0>; + interrupts = ; + pinctrl-names = "default"; + pinctrl-0 = <&usbc0_interrupt>; + vbus-supply = <&vcc_5v0_typec0>; + + connector { + compatible = "usb-c-connector"; + label = "USB-C"; + data-role = "dual"; + /* fusb302 supports PD Rev 2.0 Ver 1.2 */ + pd-revision = /bits/ 8 <0x2 0x0 0x1 0x2>; + power-role = "source"; + source-pdos = ; + + altmodes { + displayport { + svid = /bits/ 16 <0xff01>; + vdo = <0xffffffff>; + }; + }; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + usbc0_hs_ep: endpoint { + remote-endpoint = <&u2phy0_ep>; + }; + }; + port@1 { + reg = <1>; + usbc0_ss_ep: endpoint { + remote-endpoint = <&usb_drd0_ep>; + }; + }; + port@2 { + reg = <2>; + usbc0_dp_ep: endpoint { + remote-endpoint = <&usbdp_phy_ep>; + }; + }; + }; + }; + }; + hym8563: rtc@51 { compatible = "haoyu,hym8563"; reg = <0x51>; @@ -655,6 +734,24 @@ led_rgb_g: led-green-en { rockchip,pins = <4 RK_PB2 RK_FUNC_GPIO &pcfg_pull_none>; }; }; + + usb { + usb_host_pwren: usb-host-pwren { + rockchip,pins = <4 RK_PA4 RK_FUNC_GPIO &pcfg_pull_none>; + }; + usb_otg0_pwren: usb-otg0-pwren { + rockchip,pins = <4 RK_PA6 RK_FUNC_GPIO &pcfg_pull_none>; + }; + usbc0_interrupt: usbc0-interrupt { + rockchip,pins = <0 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>; + }; + usbc0_sbu1: usbc0-sbu1 { + rockchip,pins = <2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_down>; + }; + usbc0_sbu2: usbc0-sbu2 { + rockchip,pins = <2 RK_PA7 RK_FUNC_GPIO &pcfg_pull_down>; + }; + }; }; &sdhci { @@ -683,11 +780,67 @@ &sdmmc { status = "okay"; }; +&u2phy0 { + status = "okay"; + + port { + u2phy0_ep: endpoint { + remote-endpoint = <&usbc0_hs_ep>; + }; + }; +}; + +&u2phy0_otg { + status = "okay"; +}; + +&u2phy1 { + status = "okay"; +}; + +&u2phy1_otg { + phy-supply = <&vcc_5v0_usbhost>; + status = "okay"; +}; + &uart0 { pinctrl-0 = <&uart0m0_xfer>; status = "okay"; }; +&usb_drd0_dwc3 { + usb-role-switch; + dr_mode = "otg"; + status = "okay"; + + port { + usb_drd0_ep: endpoint { + remote-endpoint = <&usbc0_ss_ep>; + }; + }; +}; + +&usb_drd1_dwc3 { + dr_mode = "host"; + status = "okay"; +}; + +&usbdp_phy { + mode-switch; + orientation-switch; + pinctrl-names = "default"; + pinctrl-0 = <&usbc0_sbu1 &usbc0_sbu2>; + sbu1-dc-gpios = <&gpio2 RK_PA6 GPIO_ACTIVE_HIGH>; + sbu2-dc-gpios = <&gpio2 RK_PA7 GPIO_ACTIVE_HIGH>; + status = "okay"; + + port { + usbdp_phy_ep: endpoint { + remote-endpoint = <&usbc0_dp_ep>; + }; + }; +}; + &vop { status = "okay"; };