From nobody Thu Apr 2 20:20:31 2026 Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 994D533A007; Thu, 2 Apr 2026 15:44:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775144692; cv=none; b=HpgtTYmtUmh2m2j3nuYtY26SgnJBCZxF6SosaELqkFfz0lyi7qNGBag7a+ndM2AKTvrDlmm2vIpX1j73sIKEaD0AvMrEy4x2RlP9ScnKwLcBXQ68c+0Xpa7lHJW9HZXRKsemFkrDqbn2w2vUcO+R3J0+EQhjL6yYFcqigBbKUks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775144692; c=relaxed/simple; bh=AsXZHe8dhzo/iV7ai1HnoAnUoNxuSgEq0RdX3yPSBFs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jk8TR1vLuYs0XDvqr7CuOOGnLBXqE5COpffKktk7HizBNYdAVbaXga2oma6wl+zqDsZg0562Htp0C9eZXwMPi/Ixo7x94ME8QJKEg9Yo5/BkfG8TaZeyrYc0sdScaSoM3Y2MEx0vAVXVFlMBmhoGnv668ik4f/vhcLeKwkDpHaw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org; spf=pass smtp.mailfrom=disroot.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b=PjfCyNXW; arc=none smtp.client-ip=178.21.23.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=disroot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b="PjfCyNXW" Received: from [127.0.0.1] (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 34B2C26561; Thu, 2 Apr 2026 17:44:49 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id XdmBa8nCOhzh; Thu, 2 Apr 2026 17:44:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1775144688; bh=AsXZHe8dhzo/iV7ai1HnoAnUoNxuSgEq0RdX3yPSBFs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PjfCyNXW1IZgKnfoJwO7l53ddi/UgOfVYRe2C+296HVjtqMFGOeP/Rd+44REvTP/k y+DMHFjshTKG1+w8G53rBwmYwd1aSYsce28zaTylfO2RFz1KWMOnbpBhHFP4QqXrC8 5Ei5nQtWISxsEgThJwZpoj1yxRThm3h3yXVhWXXHnBz4SFq4og2fCaOqKqpBoXErru ZWh5MbMIhaUyXgK/1b2RjLQHvrpMMh3GDrEVym2VGMM/3TSfMdU6QU4/RfNbhgmOau sGzyQdYUBJVYhVIgKt8Meg5l2YFBVeMKNFDOlQ6hL3POENWcdM4fQ+hDqjtgB+vcLs acprV29uiVdng== From: Rustam Adilov To: Vinod Koul , Neil Armstrong , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Stanley Chang , linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Rustam Adilov , Michael Zavertkin Subject: [PATCH v3 1/6] phy: realtek: usb2: introduce vstatus/new_reg_req variables to driver data Date: Thu, 2 Apr 2026 20:44:09 +0500 Message-ID: <20260402154414.196012-2-adilov@disroot.org> In-Reply-To: <20260402154414.196012-1-adilov@disroot.org> References: <20260402154414.196012-1-adilov@disroot.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In RTL9607C SoC, the vstatus register is located at a certain offset from the base and so introduce the vstatus_offset to handle it. Busy bit of the vstatus and new_reg_req bit are also different and so introduce these variables to the driver data as well. Add these variables to the pre-existing phy cfg structs for RTD SoCs and assign them the default values. Co-developed-by: Michael Zavertkin Signed-off-by: Michael Zavertkin Signed-off-by: Rustam Adilov --- drivers/phy/realtek/phy-rtk-usb2.c | 59 ++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 11 deletions(-) diff --git a/drivers/phy/realtek/phy-rtk-usb2.c b/drivers/phy/realtek/phy-r= tk-usb2.c index 248550ef98ca..f5d2f0c3376a 100644 --- a/drivers/phy/realtek/phy-rtk-usb2.c +++ b/drivers/phy/realtek/phy-rtk-usb2.c @@ -64,6 +64,9 @@ struct phy_reg { void __iomem *reg_wrap_vstatus; void __iomem *reg_gusb2phyacc0; int vstatus_index; + int vstatus_offset; + int vstatus_busy; + int new_reg_req; }; =20 struct phy_data { @@ -96,6 +99,9 @@ struct phy_cfg { bool do_toggle_driving; bool use_default_parameter; bool is_double_sensitivity_mode; + int vstatus_offset; + int vstatus_busy; + int new_reg_req; }; =20 struct phy_parameter { @@ -162,21 +168,21 @@ static char rtk_phy_read(struct phy_reg *phy_reg, cha= r addr) addr -=3D OFFEST_PHY_READ; =20 /* polling until VBusy =3D=3D 0 */ - ret =3D utmi_wait_register(reg_gusb2phyacc0, PHY_VSTS_BUSY, 0); + ret =3D utmi_wait_register(reg_gusb2phyacc0, phy_reg->vstatus_busy, 0); if (ret) return (char)ret; =20 /* VCtrl =3D low nibble of addr, and set PHY_NEW_REG_REQ */ - val =3D PHY_NEW_REG_REQ | (GET_LOW_NIBBLE(addr) << PHY_VCTRL_SHIFT); + val =3D phy_reg->new_reg_req | (GET_LOW_NIBBLE(addr) << PHY_VCTRL_SHIFT); writel(val, reg_gusb2phyacc0); - ret =3D utmi_wait_register(reg_gusb2phyacc0, PHY_VSTS_BUSY, 0); + ret =3D utmi_wait_register(reg_gusb2phyacc0, phy_reg->vstatus_busy, 0); if (ret) return (char)ret; =20 /* VCtrl =3D high nibble of addr, and set PHY_NEW_REG_REQ */ - val =3D PHY_NEW_REG_REQ | (GET_HIGH_NIBBLE(addr) << PHY_VCTRL_SHIFT); + val =3D phy_reg->new_reg_req | (GET_HIGH_NIBBLE(addr) << PHY_VCTRL_SHIFT); writel(val, reg_gusb2phyacc0); - ret =3D utmi_wait_register(reg_gusb2phyacc0, PHY_VSTS_BUSY, 0); + ret =3D utmi_wait_register(reg_gusb2phyacc0, phy_reg->vstatus_busy, 0); if (ret) return (char)ret; =20 @@ -194,25 +200,25 @@ static int rtk_phy_write(struct phy_reg *phy_reg, cha= r addr, char data) int ret =3D 0; =20 /* write data to VStatusOut2 (data output to phy) */ - writel((u32)data << shift_bits, reg_wrap_vstatus); + writel((u32)data << shift_bits, reg_wrap_vstatus + phy_reg->vstatus_offse= t); =20 - ret =3D utmi_wait_register(reg_gusb2phyacc0, PHY_VSTS_BUSY, 0); + ret =3D utmi_wait_register(reg_gusb2phyacc0, phy_reg->vstatus_busy, 0); if (ret) return ret; =20 /* VCtrl =3D low nibble of addr, set PHY_NEW_REG_REQ */ - val =3D PHY_NEW_REG_REQ | (GET_LOW_NIBBLE(addr) << PHY_VCTRL_SHIFT); + val =3D phy_reg->new_reg_req | (GET_LOW_NIBBLE(addr) << PHY_VCTRL_SHIFT); =20 writel(val, reg_gusb2phyacc0); - ret =3D utmi_wait_register(reg_gusb2phyacc0, PHY_VSTS_BUSY, 0); + ret =3D utmi_wait_register(reg_gusb2phyacc0, phy_reg->vstatus_busy, 0); if (ret) return ret; =20 /* VCtrl =3D high nibble of addr, set PHY_NEW_REG_REQ */ - val =3D PHY_NEW_REG_REQ | (GET_HIGH_NIBBLE(addr) << PHY_VCTRL_SHIFT); + val =3D phy_reg->new_reg_req | (GET_HIGH_NIBBLE(addr) << PHY_VCTRL_SHIFT); =20 writel(val, reg_gusb2phyacc0); - ret =3D utmi_wait_register(reg_gusb2phyacc0, PHY_VSTS_BUSY, 0); + ret =3D utmi_wait_register(reg_gusb2phyacc0, phy_reg->vstatus_busy, 0); if (ret) return ret; =20 @@ -957,6 +963,7 @@ static int get_phy_data_by_efuse(struct rtk_phy *rtk_ph= y, =20 static int parse_phy_data(struct rtk_phy *rtk_phy) { + struct phy_cfg *phy_cfg =3D rtk_phy->phy_cfg; struct device *dev =3D rtk_phy->dev; struct device_node *np =3D dev->of_node; struct phy_parameter *phy_parameter; @@ -974,6 +981,9 @@ static int parse_phy_data(struct rtk_phy *rtk_phy) phy_parameter->phy_reg.reg_wrap_vstatus =3D of_iomap(np, 0); phy_parameter->phy_reg.reg_gusb2phyacc0 =3D of_iomap(np, 1) + index; phy_parameter->phy_reg.vstatus_index =3D index; + phy_parameter->phy_reg.vstatus_offset =3D phy_cfg->vstatus_offset; + phy_parameter->phy_reg.vstatus_busy =3D phy_cfg->vstatus_busy; + phy_parameter->phy_reg.new_reg_req =3D phy_cfg->new_reg_req; =20 if (of_property_read_bool(np, "realtek,inverse-hstx-sync-clock")) phy_parameter->inverse_hstx_sync_clock =3D true; @@ -1085,6 +1095,9 @@ static const struct phy_cfg rtd1295_phy_cfg =3D { .driving_updated_for_dev_dis =3D 0xf, .use_default_parameter =3D false, .is_double_sensitivity_mode =3D false, + .vstatus_offset =3D 0, + .vstatus_busy =3D PHY_VSTS_BUSY, + .new_reg_req =3D PHY_NEW_REG_REQ, }; =20 static const struct phy_cfg rtd1395_phy_cfg =3D { @@ -1109,6 +1122,9 @@ static const struct phy_cfg rtd1395_phy_cfg =3D { .driving_updated_for_dev_dis =3D 0xf, .use_default_parameter =3D false, .is_double_sensitivity_mode =3D false, + .vstatus_offset =3D 0, + .vstatus_busy =3D PHY_VSTS_BUSY, + .new_reg_req =3D PHY_NEW_REG_REQ, }; =20 static const struct phy_cfg rtd1395_phy_cfg_2port =3D { @@ -1133,6 +1149,9 @@ static const struct phy_cfg rtd1395_phy_cfg_2port =3D= { .driving_updated_for_dev_dis =3D 0xf, .use_default_parameter =3D false, .is_double_sensitivity_mode =3D false, + .vstatus_offset =3D 0, + .vstatus_busy =3D PHY_VSTS_BUSY, + .new_reg_req =3D PHY_NEW_REG_REQ, }; =20 static const struct phy_cfg rtd1619_phy_cfg =3D { @@ -1155,6 +1174,9 @@ static const struct phy_cfg rtd1619_phy_cfg =3D { .driving_updated_for_dev_dis =3D 0xf, .use_default_parameter =3D false, .is_double_sensitivity_mode =3D false, + .vstatus_offset =3D 0, + .vstatus_busy =3D PHY_VSTS_BUSY, + .new_reg_req =3D PHY_NEW_REG_REQ, }; =20 static const struct phy_cfg rtd1319_phy_cfg =3D { @@ -1181,6 +1203,9 @@ static const struct phy_cfg rtd1319_phy_cfg =3D { .driving_updated_for_dev_dis =3D 0xf, .use_default_parameter =3D false, .is_double_sensitivity_mode =3D true, + .vstatus_offset =3D 0, + .vstatus_busy =3D PHY_VSTS_BUSY, + .new_reg_req =3D PHY_NEW_REG_REQ, }; =20 static const struct phy_cfg rtd1312c_phy_cfg =3D { @@ -1206,6 +1231,9 @@ static const struct phy_cfg rtd1312c_phy_cfg =3D { .driving_updated_for_dev_dis =3D 0xf, .use_default_parameter =3D false, .is_double_sensitivity_mode =3D true, + .vstatus_offset =3D 0, + .vstatus_busy =3D PHY_VSTS_BUSY, + .new_reg_req =3D PHY_NEW_REG_REQ, }; =20 static const struct phy_cfg rtd1619b_phy_cfg =3D { @@ -1231,6 +1259,9 @@ static const struct phy_cfg rtd1619b_phy_cfg =3D { .driving_updated_for_dev_dis =3D 0x8, .use_default_parameter =3D false, .is_double_sensitivity_mode =3D true, + .vstatus_offset =3D 0, + .vstatus_busy =3D PHY_VSTS_BUSY, + .new_reg_req =3D PHY_NEW_REG_REQ, }; =20 static const struct phy_cfg rtd1319d_phy_cfg =3D { @@ -1256,6 +1287,9 @@ static const struct phy_cfg rtd1319d_phy_cfg =3D { .driving_updated_for_dev_dis =3D 0x8, .use_default_parameter =3D false, .is_double_sensitivity_mode =3D true, + .vstatus_offset =3D 0, + .vstatus_busy =3D PHY_VSTS_BUSY, + .new_reg_req =3D PHY_NEW_REG_REQ, }; =20 static const struct phy_cfg rtd1315e_phy_cfg =3D { @@ -1282,6 +1316,9 @@ static const struct phy_cfg rtd1315e_phy_cfg =3D { .driving_updated_for_dev_dis =3D 0x8, .use_default_parameter =3D false, .is_double_sensitivity_mode =3D true, + .vstatus_offset =3D 0, + .vstatus_busy =3D PHY_VSTS_BUSY, + .new_reg_req =3D PHY_NEW_REG_REQ, }; =20 static const struct of_device_id usbphy_rtk_dt_match[] =3D { --=20 2.53.0 From nobody Thu Apr 2 20:20:31 2026 Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 662BC3E95B7; Thu, 2 Apr 2026 15:44:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775144695; cv=none; b=tn9c2fUQ4NcbbZzMyw0NymYWZtKGJb3HbBJuW8yhBZexPA28zUM4/sRhje+VzAYa7X54k75y9pcBcfd6L8c7FOW35yDrRgJORwEb0QqRJISBZNKIiVxRb6lEK+HpXVR6KSHwf7ECNnRtXnCL8uZzzzTB0SLB+QaxtPWq/vNXBDk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775144695; c=relaxed/simple; bh=7aI7KJeV4nQljLdmYcLTbPABQXse5pFfo+dK4rli7Tw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ecHSDDSu4mT1KXpYamFbaXZmLWVK9SDtsxiEQfc4kDc1L7toKG9Ic8G5w2rWk6WCoTxtONR1P1mcbXpGneGO0uRQKi8+uYj2274OQQ4jfkjOJNJLXFHmdzlZaQJT3u6p/Nsu8Cr2mcY5qT7H5egbPCEuBcU8ykU1yh8X9kbZ9Tw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org; spf=pass smtp.mailfrom=disroot.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b=K8Ybsyn3; arc=none smtp.client-ip=178.21.23.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=disroot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b="K8Ybsyn3" Received: from [127.0.0.1] (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id C96D526939; Thu, 2 Apr 2026 17:44:51 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id N5yDRO8KuNWw; Thu, 2 Apr 2026 17:44:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1775144690; bh=7aI7KJeV4nQljLdmYcLTbPABQXse5pFfo+dK4rli7Tw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=K8Ybsyn3EoaODqaBP1u6PISj0yzqezu6ZCLcVPPGm53eYCazhevInKPI73+WVlUri ChWGzMOmep/mRrazrsbgSgD/SQfK9DbgFCoUshy+CbPaUZKI0JhkA4kAtQ0I6MTn1M wHxKiJsEgAZR1sNW/G4nGWclKCajCJd3xCF3deaih4wp5uDtsMrqeaewEUfaMvDQWQ 3/SQJFD2KHDfjS8qVDAl2wWc31bYHRGxPvAnulDl/aVnfkWdKcxTn71HKcEZIsH6wx 9OT5IeAxIpDUolNB6m4p6NTJZQsV+2ULIWu0zHbWF+N7qE2jZBlXbV42NrYW+LZ741 ALEZoyfCIhsJw== From: Rustam Adilov To: Vinod Koul , Neil Armstrong , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Stanley Chang , linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Rustam Adilov , Michael Zavertkin Subject: [PATCH v3 2/6] phy: realtek: usb2: introduce read and write functions to driver data Date: Thu, 2 Apr 2026 20:44:10 +0500 Message-ID: <20260402154414.196012-3-adilov@disroot.org> In-Reply-To: <20260402154414.196012-1-adilov@disroot.org> References: <20260402154414.196012-1-adilov@disroot.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" RTL9607C is a big endian SoC but has little endian USB host controller and thus, reads and writes to the reg_gusb2phyacc0 should go through le32_to_cpu and cpu_to_le32 functions respectively. This doesn't apply to vstatus register though. To handle this situation, introduce read and write functions to the driver data and create 2 variations of reads and write function with le32 function in it and without. Adjust all instances of utmi_wait_register function to now include the read function as one of its arguments. Assign the existing phy configuration for RTD SoCs to the default read and write functions. Co-developed-by: Michael Zavertkin Signed-off-by: Michael Zavertkin Signed-off-by: Rustam Adilov --- drivers/phy/realtek/phy-rtk-usb2.c | 75 ++++++++++++++++++++++++------ 1 file changed, 62 insertions(+), 13 deletions(-) diff --git a/drivers/phy/realtek/phy-rtk-usb2.c b/drivers/phy/realtek/phy-r= tk-usb2.c index f5d2f0c3376a..f6670ac6346d 100644 --- a/drivers/phy/realtek/phy-rtk-usb2.c +++ b/drivers/phy/realtek/phy-rtk-usb2.c @@ -67,6 +67,9 @@ struct phy_reg { int vstatus_offset; int vstatus_busy; int new_reg_req; + + u32 (*read)(void __iomem *reg); + void (*write)(u32 val, void __iomem *reg); }; =20 struct phy_data { @@ -102,6 +105,9 @@ struct phy_cfg { int vstatus_offset; int vstatus_busy; int new_reg_req; + + u32 (*read)(void __iomem *reg); + void (*write)(u32 val, void __iomem *reg); }; =20 struct phy_parameter { @@ -128,6 +134,28 @@ struct rtk_phy { struct dentry *debug_dir; }; =20 +static u32 rtk_usb2phy_read(void __iomem *reg) +{ + return readl(reg); +} + +static u32 rtk_usb2phy_read_le(void __iomem *reg) +{ + return le32_to_cpu(readl(reg)); +} + +static void rtk_usb2phy_write(u32 val, void __iomem *reg) +{ + writel(val, reg); +} + +static void rtk_usb2phy_write_le(u32 val, void __iomem *reg) +{ + u32 tmp =3D cpu_to_le32(val); + + writel(tmp, reg); +} + /* mapping 0xE0 to 0 ... 0xE7 to 7, 0xF0 to 8 ,,, 0xF7 to 15 */ static inline int page_addr_to_array_index(u8 addr) { @@ -144,12 +172,13 @@ static inline u8 array_index_to_page_addr(int index) #define PHY_IO_TIMEOUT_USEC (50000) #define PHY_IO_DELAY_US (100) =20 -static inline int utmi_wait_register(void __iomem *reg, u32 mask, u32 resu= lt) +static inline int utmi_wait_register(u32 (*read)(void __iomem *reg), void = __iomem *reg, u32 mask, + u32 result) { int ret; unsigned int val; =20 - ret =3D read_poll_timeout(readl, val, ((val & mask) =3D=3D result), + ret =3D read_poll_timeout(read, val, ((val & mask) =3D=3D result), PHY_IO_DELAY_US, PHY_IO_TIMEOUT_USEC, false, reg); if (ret) { pr_err("%s can't program USB phy\n", __func__); @@ -168,25 +197,25 @@ static char rtk_phy_read(struct phy_reg *phy_reg, cha= r addr) addr -=3D OFFEST_PHY_READ; =20 /* polling until VBusy =3D=3D 0 */ - ret =3D utmi_wait_register(reg_gusb2phyacc0, phy_reg->vstatus_busy, 0); + ret =3D utmi_wait_register(phy_reg->read, reg_gusb2phyacc0, phy_reg->vsta= tus_busy, 0); if (ret) return (char)ret; =20 /* VCtrl =3D low nibble of addr, and set PHY_NEW_REG_REQ */ val =3D phy_reg->new_reg_req | (GET_LOW_NIBBLE(addr) << PHY_VCTRL_SHIFT); - writel(val, reg_gusb2phyacc0); - ret =3D utmi_wait_register(reg_gusb2phyacc0, phy_reg->vstatus_busy, 0); + phy_reg->write(val, reg_gusb2phyacc0); + ret =3D utmi_wait_register(phy_reg->read, reg_gusb2phyacc0, phy_reg->vsta= tus_busy, 0); if (ret) return (char)ret; =20 /* VCtrl =3D high nibble of addr, and set PHY_NEW_REG_REQ */ val =3D phy_reg->new_reg_req | (GET_HIGH_NIBBLE(addr) << PHY_VCTRL_SHIFT); - writel(val, reg_gusb2phyacc0); - ret =3D utmi_wait_register(reg_gusb2phyacc0, phy_reg->vstatus_busy, 0); + phy_reg->write(val, reg_gusb2phyacc0); + ret =3D utmi_wait_register(phy_reg->read, reg_gusb2phyacc0, phy_reg->vsta= tus_busy, 0); if (ret) return (char)ret; =20 - val =3D readl(reg_gusb2phyacc0); + val =3D phy_reg->read(reg_gusb2phyacc0); =20 return (char)(val & PHY_REG_DATA_MASK); } @@ -202,23 +231,23 @@ static int rtk_phy_write(struct phy_reg *phy_reg, cha= r addr, char data) /* write data to VStatusOut2 (data output to phy) */ writel((u32)data << shift_bits, reg_wrap_vstatus + phy_reg->vstatus_offse= t); =20 - ret =3D utmi_wait_register(reg_gusb2phyacc0, phy_reg->vstatus_busy, 0); + ret =3D utmi_wait_register(phy_reg->read, reg_gusb2phyacc0, phy_reg->vsta= tus_busy, 0); if (ret) return ret; =20 /* VCtrl =3D low nibble of addr, set PHY_NEW_REG_REQ */ val =3D phy_reg->new_reg_req | (GET_LOW_NIBBLE(addr) << PHY_VCTRL_SHIFT); =20 - writel(val, reg_gusb2phyacc0); - ret =3D utmi_wait_register(reg_gusb2phyacc0, phy_reg->vstatus_busy, 0); + phy_reg->write(val, reg_gusb2phyacc0); + ret =3D utmi_wait_register(phy_reg->read, reg_gusb2phyacc0, phy_reg->vsta= tus_busy, 0); if (ret) return ret; =20 /* VCtrl =3D high nibble of addr, set PHY_NEW_REG_REQ */ val =3D phy_reg->new_reg_req | (GET_HIGH_NIBBLE(addr) << PHY_VCTRL_SHIFT); =20 - writel(val, reg_gusb2phyacc0); - ret =3D utmi_wait_register(reg_gusb2phyacc0, phy_reg->vstatus_busy, 0); + phy_reg->write(val, reg_gusb2phyacc0); + ret =3D utmi_wait_register(phy_reg->read, reg_gusb2phyacc0, phy_reg->vsta= tus_busy, 0); if (ret) return ret; =20 @@ -984,6 +1013,8 @@ static int parse_phy_data(struct rtk_phy *rtk_phy) phy_parameter->phy_reg.vstatus_offset =3D phy_cfg->vstatus_offset; phy_parameter->phy_reg.vstatus_busy =3D phy_cfg->vstatus_busy; phy_parameter->phy_reg.new_reg_req =3D phy_cfg->new_reg_req; + phy_parameter->phy_reg.read =3D phy_cfg->read; + phy_parameter->phy_reg.write =3D phy_cfg->write; =20 if (of_property_read_bool(np, "realtek,inverse-hstx-sync-clock")) phy_parameter->inverse_hstx_sync_clock =3D true; @@ -1098,6 +1129,8 @@ static const struct phy_cfg rtd1295_phy_cfg =3D { .vstatus_offset =3D 0, .vstatus_busy =3D PHY_VSTS_BUSY, .new_reg_req =3D PHY_NEW_REG_REQ, + .read =3D rtk_usb2phy_read, + .write =3D rtk_usb2phy_write, }; =20 static const struct phy_cfg rtd1395_phy_cfg =3D { @@ -1125,6 +1158,8 @@ static const struct phy_cfg rtd1395_phy_cfg =3D { .vstatus_offset =3D 0, .vstatus_busy =3D PHY_VSTS_BUSY, .new_reg_req =3D PHY_NEW_REG_REQ, + .read =3D rtk_usb2phy_read, + .write =3D rtk_usb2phy_write, }; =20 static const struct phy_cfg rtd1395_phy_cfg_2port =3D { @@ -1152,6 +1187,8 @@ static const struct phy_cfg rtd1395_phy_cfg_2port =3D= { .vstatus_offset =3D 0, .vstatus_busy =3D PHY_VSTS_BUSY, .new_reg_req =3D PHY_NEW_REG_REQ, + .read =3D rtk_usb2phy_read, + .write =3D rtk_usb2phy_write, }; =20 static const struct phy_cfg rtd1619_phy_cfg =3D { @@ -1177,6 +1214,8 @@ static const struct phy_cfg rtd1619_phy_cfg =3D { .vstatus_offset =3D 0, .vstatus_busy =3D PHY_VSTS_BUSY, .new_reg_req =3D PHY_NEW_REG_REQ, + .read =3D rtk_usb2phy_read, + .write =3D rtk_usb2phy_write, }; =20 static const struct phy_cfg rtd1319_phy_cfg =3D { @@ -1206,6 +1245,8 @@ static const struct phy_cfg rtd1319_phy_cfg =3D { .vstatus_offset =3D 0, .vstatus_busy =3D PHY_VSTS_BUSY, .new_reg_req =3D PHY_NEW_REG_REQ, + .read =3D rtk_usb2phy_read, + .write =3D rtk_usb2phy_write, }; =20 static const struct phy_cfg rtd1312c_phy_cfg =3D { @@ -1234,6 +1275,8 @@ static const struct phy_cfg rtd1312c_phy_cfg =3D { .vstatus_offset =3D 0, .vstatus_busy =3D PHY_VSTS_BUSY, .new_reg_req =3D PHY_NEW_REG_REQ, + .read =3D rtk_usb2phy_read, + .write =3D rtk_usb2phy_write, }; =20 static const struct phy_cfg rtd1619b_phy_cfg =3D { @@ -1262,6 +1305,8 @@ static const struct phy_cfg rtd1619b_phy_cfg =3D { .vstatus_offset =3D 0, .vstatus_busy =3D PHY_VSTS_BUSY, .new_reg_req =3D PHY_NEW_REG_REQ, + .read =3D rtk_usb2phy_read, + .write =3D rtk_usb2phy_write, }; =20 static const struct phy_cfg rtd1319d_phy_cfg =3D { @@ -1290,6 +1335,8 @@ static const struct phy_cfg rtd1319d_phy_cfg =3D { .vstatus_offset =3D 0, .vstatus_busy =3D PHY_VSTS_BUSY, .new_reg_req =3D PHY_NEW_REG_REQ, + .read =3D rtk_usb2phy_read, + .write =3D rtk_usb2phy_write, }; =20 static const struct phy_cfg rtd1315e_phy_cfg =3D { @@ -1319,6 +1366,8 @@ static const struct phy_cfg rtd1315e_phy_cfg =3D { .vstatus_offset =3D 0, .vstatus_busy =3D PHY_VSTS_BUSY, .new_reg_req =3D PHY_NEW_REG_REQ, + .read =3D rtk_usb2phy_read, + .write =3D rtk_usb2phy_write, }; =20 static const struct of_device_id usbphy_rtk_dt_match[] =3D { --=20 2.53.0 From nobody Thu Apr 2 20:20:31 2026 Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 883B93E559F; Thu, 2 Apr 2026 15:44:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775144699; cv=none; b=rrUa2fkpS+9YAV29R1U12l3AdhAStbylOSc+Qle0TfsKPwbGF5qt5YkNyi3FFeaZiamtlRAkHKMtcM4j0sxNoUO1mbXDis7oTpNZlX3ROkApknV3prlvqgqrY7SqtrZqFb3RIXInSG+xiTMC9qAKCwBybuPh2QY2TwD7WV4nvkI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775144699; c=relaxed/simple; bh=f9s72veV302u0cDA0XC5ArjgV/PXcnfDIUMvghXl40c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ba0alqrB7mqpMAlPuDPTkSrxkL1ziUlJ9eDL4njaGEYI/2ZNptgbjtR43W+63s8MFifGCxPXDwwGfEpKCTp/0ZZjuJ9j5MUpYCncZizjiG7ZJAy3qRsa0d4X5K5tNEwuHg1EAH5iEAOumdeSri91s7qP9jxOcXLQi0fXr0rvwcM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org; spf=pass smtp.mailfrom=disroot.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b=IwRSTtX7; arc=none smtp.client-ip=178.21.23.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=disroot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b="IwRSTtX7" Received: from [127.0.0.1] (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id A68D026F12; Thu, 2 Apr 2026 17:44:53 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 1paANV6EYyM1; Thu, 2 Apr 2026 17:44:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1775144693; bh=f9s72veV302u0cDA0XC5ArjgV/PXcnfDIUMvghXl40c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IwRSTtX7vH355gY2GwSpK7zpjpUSvGjFnVcPqZwpx0y7XiuchaOgTHICR0MXRwJZS Os986JH0y4MJZj0R50/G+Fa4ilyurrRv0jL9k9YwvrRFh0mrbNmVVKtFkE/cLsPntt Kk2f2ydyA9XpYG2y2cbeia27L/oFTlbqEqgFC/in0uVyK1/BWv4lApGRylcOUsul+e sffvO7eeDBNq61atJneaB70qbJYbZmHoHH+bqGHB0XaxyD4Dg7qUCPmWT8b7qnjFgb Wqc1P6yS19mMqb25Z79ncm9g7WPBrfIi92NrkqYvQihRlldc2+Wf/QpqK2fldZqOI+ M5fq9dzs3bsoA== From: Rustam Adilov To: Vinod Koul , Neil Armstrong , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Stanley Chang , linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Rustam Adilov Subject: [PATCH v3 3/6] dt-bindings: phy: realtek,usb2phy.yaml: extend for resets and RTL9607C support Date: Thu, 2 Apr 2026 20:44:11 +0500 Message-ID: <20260402154414.196012-4-adilov@disroot.org> In-Reply-To: <20260402154414.196012-1-adilov@disroot.org> References: <20260402154414.196012-1-adilov@disroot.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add the "realtek,rtl9607-usb2phy" compatible for USB2 PHY on the RTL9607C SoC series. Add a resets property to properties to describe the usb2phy reset line. In RTL9607C, USB2 PHY reset line is from "IP Enable controller" which is multipurpose and handle activating various SoC peripherals. It is unclear whether RTD SoCs have something similar to that so set the resets to false for these devices. RTL9607C requires the "resets" to be specified so add the corresponding if check for the "realtek,rtl9607-usb2phy" compatible. Signed-off-by: Rustam Adilov --- .../bindings/phy/realtek,usb2phy.yaml | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml b/D= ocumentation/devicetree/bindings/phy/realtek,usb2phy.yaml index 9911ada39ee7..7b50833c8e19 100644 --- a/Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml +++ b/Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml @@ -11,7 +11,8 @@ maintainers: - Stanley Chang =20 description: | - Realtek USB 2.0 PHY support the digital home center (DHC) RTD series SoC= s. + Realtek USB 2.0 PHY support the digital home center (DHC) RTD and + RTL9607C series SoCs. The USB 2.0 PHY driver is designed to support the XHCI controller. The S= oCs support multiple XHCI controllers. One PHY device node maps to one XHCI controller. @@ -57,6 +58,12 @@ description: | XHCI controller#1 -- usb2phy -- phy#0 XHCI controller#2 -- usb2phy -- phy#0 =20 + RTL9607C SoCs USB + The USB architecture includes OHCI and EHCI controllers. + Both of them map to one USB2.0 PHY. + OHCI controller#0 -- usb2phy -- phy#0 + EHCI controller#0 -- usb2phy -- phy#0 + properties: compatible: enum: @@ -69,6 +76,7 @@ properties: - realtek,rtd1395-usb2phy-2port - realtek,rtd1619-usb2phy - realtek,rtd1619b-usb2phy + - realtek,rtl9607-usb2phy =20 reg: items: @@ -130,6 +138,9 @@ properties: minimum: -8 maximum: 8 =20 + resets: + maxItems: 1 + required: - compatible - reg @@ -157,6 +168,18 @@ allOf: then: properties: realtek,driving-level-compensate: false + - if: + properties: + compatible: + contains: + enum: + - realtek,rtl9607-usb2phy + then: + required: + - resets + else: + properties: + resets: false =20 additionalProperties: false =20 --=20 2.53.0 From nobody Thu Apr 2 20:20:31 2026 Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5EC572FC01B; Thu, 2 Apr 2026 15:44:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775144700; cv=none; b=C3gUhTnuDaDjOpEssWHzD+bGt4y2QHjq/i3TEY+vuX3+EnqJUKtr3T4gWa+RidbHY7quLhe2Dtaq1rzhxnsUh9gWHy35lbwojkbI5aquAOEhODIh1UVMJec7sdsHeJhQ7SPGMdXNQtVNL1FN5o394SzoBVs96wPUEJ2F6UnqA24= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775144700; c=relaxed/simple; bh=DfzP7HoXHrUJXf1Pl7aFkwOB+aCYHpLF8dMkVUpUPrE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LE8oUncGPlXvHR6HyNftOymYqtXpsmzRihdvbndwexGLcy6zxQJcMzDqJi22njdLx1ts9tHtIN/gv1NhyGk2ueGnhBJjWzguccMFlPGDOqOIfFbnWbzQr1J6wvVjfGpl9xtszbI6E2ry6BvURkler3YuHE7f+Xiv+522TDxLxWE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org; spf=pass smtp.mailfrom=disroot.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b=PItvXz5h; arc=none smtp.client-ip=178.21.23.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=disroot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b="PItvXz5h" Received: from [127.0.0.1] (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 0B88426561; Thu, 2 Apr 2026 17:44:56 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 5uK-BBoK71eu; Thu, 2 Apr 2026 17:44:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1775144695; bh=DfzP7HoXHrUJXf1Pl7aFkwOB+aCYHpLF8dMkVUpUPrE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PItvXz5hQJXMbJsaRjFNAeIK+N4VInygPYaG5UVO/yNeOS2ZliW6wnMfh1EefWuyW rGXysiygXX6qkBmGTD8e79PRqR+3M9W+OOIfGROPLZKD4zPN5VvTsKbPgY6WPNznT+ GS6Gi254dpid2QvVuHTS52EaWuSQCEJnOUt49WT1gHKMrhIRmMhbf7aOZbbHGV85IU gMLTRF18Gv0HvEXcRW4Dn8E4aBIDH6bK9vuyRyN9lrYwkmPqz5ziqhuv0WO7I26TD0 vRdOf06ggB+npZblCz8oNAg/EuaIM440bJQa7C8RaGrMBny8db80jTp3PCtdCfG5MT ZrHi2cg+tv+hw== From: Rustam Adilov To: Vinod Koul , Neil Armstrong , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Stanley Chang , linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Rustam Adilov , Michael Zavertkin Subject: [PATCH v3 4/6] phy: realtek: usb2: introduce reset controller struct Date: Thu, 2 Apr 2026 20:44:12 +0500 Message-ID: <20260402154414.196012-5-adilov@disroot.org> In-Reply-To: <20260402154414.196012-1-adilov@disroot.org> References: <20260402154414.196012-1-adilov@disroot.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In RTL9607C, there is so called "IP Enable Controller" which resemble reset controller with reset lines and is used for various things like USB, PCIE, GMAC and such. Introduce the reset_control struct to this driver to handle deasserting usb2 phy reset line. Make use of the function devm_reset_control_array_get_optional_exclusive() function to get the reset controller and since existing RTD SoCs don't specify the resets we can have a cleaner code. Co-developed-by: Michael Zavertkin Signed-off-by: Michael Zavertkin Signed-off-by: Rustam Adilov --- drivers/phy/realtek/phy-rtk-usb2.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/phy/realtek/phy-rtk-usb2.c b/drivers/phy/realtek/phy-r= tk-usb2.c index f6670ac6346d..288c8e9e1384 100644 --- a/drivers/phy/realtek/phy-rtk-usb2.c +++ b/drivers/phy/realtek/phy-rtk-usb2.c @@ -17,6 +17,7 @@ #include #include #include +#include #include =20 /* GUSB2PHYACCn register */ @@ -130,6 +131,7 @@ struct rtk_phy { struct phy_cfg *phy_cfg; int num_phy; struct phy_parameter *phy_parameter; + struct reset_control *phy_rst; =20 struct dentry *debug_dir; }; @@ -604,6 +606,15 @@ static int do_rtk_phy_init(struct rtk_phy *rtk_phy, in= t index) phy_parameter =3D &((struct phy_parameter *)rtk_phy->phy_parameter)[index= ]; phy_reg =3D &phy_parameter->phy_reg; =20 + if (rtk_phy->phy_rst) { + int ret =3D reset_control_deassert(rtk_phy->phy_rst); + + if (ret) + return ret; + + msleep(5); + } + if (phy_cfg->use_default_parameter) { dev_dbg(rtk_phy->dev, "%s phy#%d use default parameter\n", __func__, index); @@ -1071,6 +1082,11 @@ static int rtk_usb2phy_probe(struct platform_device = *pdev) =20 rtk_phy->num_phy =3D phy_cfg->num_phy; =20 + rtk_phy->phy_rst =3D devm_reset_control_array_get_optional_exclusive(dev); + if (IS_ERR(rtk_phy->phy_rst)) + return dev_err_probe(dev, PTR_ERR(rtk_phy->phy_rst), + "usb2 phy resets are not working\n"); + ret =3D parse_phy_data(rtk_phy); if (ret) goto err; --=20 2.53.0 From nobody Thu Apr 2 20:20:31 2026 Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B06583E4C76; Thu, 2 Apr 2026 15:44:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775144701; cv=none; b=j+QR3YJbFTgUY3P1VIe9LxeLhqyHUzwmnQzi0Z9PPNDBeTLpNPsMHMNz3OM7a3iDBZP3A/8RUpJL+MKkZYX5oyJm2AebFkgZk4Q0Ac00JObXLn6ybhhAGsrOOW5fypBfnUJUUtp7CzrRH/ZOymS9BWTzBzpPoYn9P/ldG9qdXGY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775144701; c=relaxed/simple; bh=U/7gqGoOOmMua4shiac1Tvm9liDcdDLmvlHK+wio3/g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=osOyaxujrcpcQ+U6rE3LiJfSFor2acix+dN+17owCJ4Is1PI1YC3nRSnHES+rAQ4R2hZqF+peRJgz6dF45fDNkzPiz0aRB0dfW+4zcx7X2MuFSG8VyEcJanbhyVbepJJtEtVP5vAPczodUK4lchPaSXqNtzlS257lu+xnNuH9K4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org; spf=pass smtp.mailfrom=disroot.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b=CKB8PAvI; arc=none smtp.client-ip=178.21.23.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=disroot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b="CKB8PAvI" Received: from [127.0.0.1] (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 794E526EC7; Thu, 2 Apr 2026 17:44:58 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id fjVukXx3MBXM; Thu, 2 Apr 2026 17:44:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1775144697; bh=U/7gqGoOOmMua4shiac1Tvm9liDcdDLmvlHK+wio3/g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CKB8PAvIVve6NA7E8UmTiMYrPs9gcvtINC0GXnKHIIsy4yb56YjoXw1+P81VRE4l0 izbZqEPfV7ymJLVDl16KLwmiReDUiC46OwLu0otqWWk/+IwayMMHWLsCb1CpORxtGI LrNhhVupCIlvEVjha8bvMh6EyDUW2DCiTB0tw5mfnIMSFjXHNKpHzKSPVxNBHMt8s6 8jCoborVl2RoDpCc7jj5ReCFXHYKlvM5D5MbpDEh/8CRJ0WBTbdRSqRqt0Wx8s/5lB i793LcVWNIFdXlmbS1NXZLHYf+94PvJxMkE6B6PHy1MTlzLgVarNl8QsyKXTypLDr5 o5zTieC+qEUwA== From: Rustam Adilov To: Vinod Koul , Neil Armstrong , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Stanley Chang , linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Rustam Adilov , Michael Zavertkin Subject: [PATCH v3 5/6] phy: realtek: usb2: add support for RTL9607C USB2 PHY Date: Thu, 2 Apr 2026 20:44:13 +0500 Message-ID: <20260402154414.196012-6-adilov@disroot.org> In-Reply-To: <20260402154414.196012-1-adilov@disroot.org> References: <20260402154414.196012-1-adilov@disroot.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support for the usb2 phy of RTL9607C series based SoCs. Add the macros and phy config struct for rtl9607. RTL9607C requires to clear a "force host disconnect" bit in the specific register (which is at an offset from reg_wrap_vstatus) before proceeding with phy parameter writes. Add the bool variable to the driver data struct and hide this whole procedure under the if statement that checks this new variable. Co-developed-by: Michael Zavertkin Signed-off-by: Michael Zavertkin Signed-off-by: Rustam Adilov --- drivers/phy/realtek/phy-rtk-usb2.c | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/phy/realtek/phy-rtk-usb2.c b/drivers/phy/realtek/phy-r= tk-usb2.c index 288c8e9e1384..4983dd604b62 100644 --- a/drivers/phy/realtek/phy-rtk-usb2.c +++ b/drivers/phy/realtek/phy-rtk-usb2.c @@ -26,6 +26,12 @@ #define PHY_VCTRL_SHIFT 8 #define PHY_REG_DATA_MASK 0xff =20 +#define PHY_9607_VSTS_BUSY BIT(17) +#define PHY_9607_NEW_REG_REQ BIT(13) + +#define PHY_9607_FORCE_DISCONNECT_REG 0x10 +#define PHY_9607_FORCE_DISCONNECT_BIT BIT(5) + #define GET_LOW_NIBBLE(addr) ((addr) & 0x0f) #define GET_HIGH_NIBBLE(addr) (((addr) & 0xf0) >> 4) =20 @@ -109,6 +115,7 @@ struct phy_cfg { =20 u32 (*read)(void __iomem *reg); void (*write)(u32 val, void __iomem *reg); + bool force_host_disconnect; }; =20 struct phy_parameter { @@ -621,6 +628,16 @@ static int do_rtk_phy_init(struct rtk_phy *rtk_phy, in= t index) goto do_toggle; } =20 + if (phy_cfg->force_host_disconnect) { + /* disable force-host-disconnect */ + u32 temp =3D readl(phy_reg->reg_wrap_vstatus + PHY_9607_FORCE_DISCONNECT= _REG); + + temp &=3D ~PHY_9607_FORCE_DISCONNECT_BIT; + writel(temp, phy_reg->reg_wrap_vstatus + PHY_9607_FORCE_DISCONNECT_REG); + + msleep(10); + } + /* Set page 0 */ phy_data_page =3D phy_cfg->page0; rtk_phy_set_page(phy_reg, 0); @@ -1386,6 +1403,33 @@ static const struct phy_cfg rtd1315e_phy_cfg =3D { .write =3D rtk_usb2phy_write, }; =20 +static const struct phy_cfg rtl9607_phy_cfg =3D { + .page0_size =3D MAX_USB_PHY_PAGE0_DATA_SIZE, + .page0 =3D { [0] =3D {0xe0, 0x95}, + [4] =3D {0xe4, 0x6a}, + [12] =3D {0xf3, 0x31}, }, + .page1_size =3D MAX_USB_PHY_PAGE1_DATA_SIZE, + .page1 =3D { [0] =3D {0xe0, 0x26}, }, + .page2_size =3D MAX_USB_PHY_PAGE2_DATA_SIZE, + .page2 =3D { [7] =3D {0xe7, 0x33}, }, + .num_phy =3D 1, + .check_efuse_version =3D CHECK_EFUSE_V2, + .efuse_dc_driving_rate =3D EFUS_USB_DC_CAL_RATE, + .dc_driving_mask =3D 0x1f, + .efuse_dc_disconnect_rate =3D EFUS_USB_DC_DIS_RATE, + .dc_disconnect_mask =3D 0xf, + .usb_dc_disconnect_at_page0 =3D true, + .do_toggle =3D true, + .driving_updated_for_dev_dis =3D 0x8, + .is_double_sensitivity_mode =3D true, + .vstatus_offset =3D 0xc, + .vstatus_busy =3D PHY_9607_VSTS_BUSY, + .new_reg_req =3D PHY_9607_NEW_REG_REQ, + .read =3D rtk_usb2phy_read_le, + .write =3D rtk_usb2phy_write_le, + .force_host_disconnect =3D true, +}; + static const struct of_device_id usbphy_rtk_dt_match[] =3D { { .compatible =3D "realtek,rtd1295-usb2phy", .data =3D &rtd1295_phy_cfg }, { .compatible =3D "realtek,rtd1312c-usb2phy", .data =3D &rtd1312c_phy_cfg= }, @@ -1396,6 +1440,7 @@ static const struct of_device_id usbphy_rtk_dt_match[= ] =3D { { .compatible =3D "realtek,rtd1395-usb2phy-2port", .data =3D &rtd1395_phy= _cfg_2port }, { .compatible =3D "realtek,rtd1619-usb2phy", .data =3D &rtd1619_phy_cfg }, { .compatible =3D "realtek,rtd1619b-usb2phy", .data =3D &rtd1619b_phy_cfg= }, + { .compatible =3D "realtek,rtl9607-usb2phy", .data =3D &rtl9607_phy_cfg }, {}, }; MODULE_DEVICE_TABLE(of, usbphy_rtk_dt_match); --=20 2.53.0 From nobody Thu Apr 2 20:20:31 2026 Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1877B3E559F; Thu, 2 Apr 2026 15:45:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775144703; cv=none; b=WQmw9UE7YCq8cp97L/1c3WW3Ek4RvhQXVVcKUDH4ZBEdzuEnlp8HXfuEAnDGivuSsGBnFFq4VbQt22bTqrX945Dob7B25gt69wfKfm6sYb0u1a77QjA/Q9JKEL3zYGxrz80tjdVdPMqUH3jPn30/PbAZllVI9WkKDQWOxnx7ex0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775144703; c=relaxed/simple; bh=Fsbxr1KoI6nvNJg1iQcsK0ER51AzQq33E2rDDFIUpTE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=izc/kmt+OhgmuSTmKSYytga78CGKzARKC+ud/iAusCtZGAWfWmxbGeCz8GD9CoRfwiT861UuYX4LT/NHvYI31KPfryCUgXsB2vekxOW4+ngUF78UZKKvJ3Z98MwP0PdwcWAV6CK0i4LXIPEBpNqrjD9kVAdRk+I/XFLDDCk0Xrg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org; spf=pass smtp.mailfrom=disroot.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b=Oaw1BJE7; arc=none smtp.client-ip=178.21.23.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=disroot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b="Oaw1BJE7" Received: from [127.0.0.1] (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id ABC6E26EBC; Thu, 2 Apr 2026 17:45:00 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 1bvd1Qxpz8Hf; Thu, 2 Apr 2026 17:45:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1775144700; bh=Fsbxr1KoI6nvNJg1iQcsK0ER51AzQq33E2rDDFIUpTE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Oaw1BJE7LnpxDGuJ1aGiJK2AufcxtklAYKsmnkIF9hc9KpHxEmIgBx2C0qaWBDfQo VxKLsdGc84osNMCEmZlj4OlRz8kBujHRKrFT/KOaH9dIuLczZQ33tzfCcF0T+tFRM8 tHuBsOlS+qOvzaNu0OcUri59TqeTS4dtpnd2a5cS+11meHehH7fxVLDsK5Kdgfhfi7 SI0sA4qn5jvzfOoGf0H07fWOf7I/7lBulnBc8cJuNrnbfmTexgEdXQVx5iMZrg6atz 38YuoO8lfyrQq+IEyVOvAz0Kb8Bvq0JKzYXZ+VcfXMjxKJ7CBkiKLf1iiZQun1pu9e dV53Tt0E8GPWg== From: Rustam Adilov To: Vinod Koul , Neil Armstrong , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Stanley Chang , linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Rustam Adilov Subject: [PATCH v3 6/6] phy: realtek: Make configs available for MACH_REALTEK_RTL Date: Thu, 2 Apr 2026 20:44:14 +0500 Message-ID: <20260402154414.196012-7-adilov@disroot.org> In-Reply-To: <20260402154414.196012-1-adilov@disroot.org> References: <20260402154414.196012-1-adilov@disroot.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add the MACH_REALTEK_RTL to the if statement to make the config options available for Realtek RTL SoCs as well. Signed-off-by: Rustam Adilov --- drivers/phy/realtek/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/phy/realtek/Kconfig b/drivers/phy/realtek/Kconfig index 75ac7e7c31ae..76f9215d8b94 100644 --- a/drivers/phy/realtek/Kconfig +++ b/drivers/phy/realtek/Kconfig @@ -3,7 +3,7 @@ # Phy drivers for Realtek platforms # =20 -if ARCH_REALTEK || COMPILE_TEST +if ARCH_REALTEK || MACH_REALTEK_RTL || COMPILE_TEST =20 config PHY_RTK_RTD_USB2PHY tristate "Realtek RTD USB2 PHY Transceiver Driver" @@ -29,4 +29,4 @@ config PHY_RTK_RTD_USB3PHY DWC3 USB IP. This driver will do the PHY initialization of the parameters. =20 -endif # ARCH_REALTEK || COMPILE_TEST +endif # ARCH_REALTEK || MACH_REALTEK_RTL || COMPILE_TEST --=20 2.53.0