From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 47569F46C6D for ; Mon, 6 Apr 2026 18:13:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PpI7Se+U2lIRw18THz6HqD0Msez8Eavx+dNNFi8oSbs=; b=QjzjAhyacfZgol Ot5kHsIa5xATafE37eRG5s7F7JGvf6DYS4BlRG278w6nnYdI2gMCaMMuIeQ8PCCD3GgfK+P0hCATZ o9V3+uk4GboPCq4G0+1eOL9ZGZXwJ+oT8KGKDHusVqGhA6xJ40dIutf0I94EBVGB2SVudQyEMUbRz FNoo2hACK3sq45oCYGei6INnFfi/4Jk51J5WasAvIk95/4QuGGWemHlYNukEFlOqNbhNvWXtsawQa Ppga3NwxZ2T7XdD77VCob31ypmTdcxrj0vX+liwBSUIRL6KuU6E48YrNlwnd/jaCNfTvHqEbGkgEI Mt+euQ8dBNlejGTdZm9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1w9oRo-00000005Ny1-45uA; Mon, 06 Apr 2026 18:13:16 +0000 Received: from layka.disroot.org ([178.21.23.139]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1w9oRm-00000005NxN-4Aeo for linux-phy@lists.infradead.org; Mon, 06 Apr 2026 18:13:16 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id C26D7271C5; Mon, 6 Apr 2026 20:13:12 +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 FRfC7Y_FFm5T; Mon, 6 Apr 2026 20:13:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1775499191; bh=AsXZHe8dhzo/iV7ai1HnoAnUoNxuSgEq0RdX3yPSBFs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ighzWj/kRuYvWME5OHu/g4tYQSctPfv0Uq/FHXLOzc3jRZ+lhO9dZdHoEts1RkIdJ tmctHylLf9v9ZA+akMaxMxB7ZO6y/iN15i1w8+ylr8ZA1btq5fM4NucUGu5DwCUG1T VcpG1Zs7PXPeY2cOu67uBRfRsYJ+rYr+1QWEPWssnEmE0hmO6S1m4h2h9BiqMcjO3f q74VPHq1wipCO0wMskOVK+PPqruA0rOBk7z+oaIhwYoX2kROfJVsSQ0K2qxrRBtTQS vfcxJxmkazV4b9Qsz160Pa7gxgWwqScxpxlvVpWgxFvQjK1dIBh3dBL9bJJmeTsPql QjFn3sKHZhHow== 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 v4 1/6] phy: realtek: usb2: introduce vstatus/new_reg_req variables to driver data Date: Mon, 6 Apr 2026 23:12:23 +0500 Message-ID: <20260406181228.25892-2-adilov@disroot.org> In-Reply-To: <20260406181228.25892-1-adilov@disroot.org> References: <20260406181228.25892-1-adilov@disroot.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260406_111315_356372_97A492E0 X-CRM114-Status: GOOD ( 12.48 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org 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-rtk-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; }; 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; }; struct phy_parameter { @@ -162,21 +168,21 @@ static char rtk_phy_read(struct phy_reg *phy_reg, char addr) addr -= OFFEST_PHY_READ; /* polling until VBusy == 0 */ - ret = utmi_wait_register(reg_gusb2phyacc0, PHY_VSTS_BUSY, 0); + ret = utmi_wait_register(reg_gusb2phyacc0, phy_reg->vstatus_busy, 0); if (ret) return (char)ret; /* VCtrl = low nibble of addr, and set PHY_NEW_REG_REQ */ - val = PHY_NEW_REG_REQ | (GET_LOW_NIBBLE(addr) << PHY_VCTRL_SHIFT); + val = phy_reg->new_reg_req | (GET_LOW_NIBBLE(addr) << PHY_VCTRL_SHIFT); writel(val, reg_gusb2phyacc0); - ret = utmi_wait_register(reg_gusb2phyacc0, PHY_VSTS_BUSY, 0); + ret = utmi_wait_register(reg_gusb2phyacc0, phy_reg->vstatus_busy, 0); if (ret) return (char)ret; /* VCtrl = high nibble of addr, and set PHY_NEW_REG_REQ */ - val = PHY_NEW_REG_REQ | (GET_HIGH_NIBBLE(addr) << PHY_VCTRL_SHIFT); + val = phy_reg->new_reg_req | (GET_HIGH_NIBBLE(addr) << PHY_VCTRL_SHIFT); writel(val, reg_gusb2phyacc0); - ret = utmi_wait_register(reg_gusb2phyacc0, PHY_VSTS_BUSY, 0); + ret = utmi_wait_register(reg_gusb2phyacc0, phy_reg->vstatus_busy, 0); if (ret) return (char)ret; @@ -194,25 +200,25 @@ static int rtk_phy_write(struct phy_reg *phy_reg, char addr, char data) int ret = 0; /* 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_offset); - ret = utmi_wait_register(reg_gusb2phyacc0, PHY_VSTS_BUSY, 0); + ret = utmi_wait_register(reg_gusb2phyacc0, phy_reg->vstatus_busy, 0); if (ret) return ret; /* VCtrl = low nibble of addr, set PHY_NEW_REG_REQ */ - val = PHY_NEW_REG_REQ | (GET_LOW_NIBBLE(addr) << PHY_VCTRL_SHIFT); + val = phy_reg->new_reg_req | (GET_LOW_NIBBLE(addr) << PHY_VCTRL_SHIFT); writel(val, reg_gusb2phyacc0); - ret = utmi_wait_register(reg_gusb2phyacc0, PHY_VSTS_BUSY, 0); + ret = utmi_wait_register(reg_gusb2phyacc0, phy_reg->vstatus_busy, 0); if (ret) return ret; /* VCtrl = high nibble of addr, set PHY_NEW_REG_REQ */ - val = PHY_NEW_REG_REQ | (GET_HIGH_NIBBLE(addr) << PHY_VCTRL_SHIFT); + val = phy_reg->new_reg_req | (GET_HIGH_NIBBLE(addr) << PHY_VCTRL_SHIFT); writel(val, reg_gusb2phyacc0); - ret = utmi_wait_register(reg_gusb2phyacc0, PHY_VSTS_BUSY, 0); + ret = utmi_wait_register(reg_gusb2phyacc0, phy_reg->vstatus_busy, 0); if (ret) return ret; @@ -957,6 +963,7 @@ static int get_phy_data_by_efuse(struct rtk_phy *rtk_phy, static int parse_phy_data(struct rtk_phy *rtk_phy) { + struct phy_cfg *phy_cfg = rtk_phy->phy_cfg; struct device *dev = rtk_phy->dev; struct device_node *np = 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 = of_iomap(np, 0); phy_parameter->phy_reg.reg_gusb2phyacc0 = of_iomap(np, 1) + index; phy_parameter->phy_reg.vstatus_index = index; + phy_parameter->phy_reg.vstatus_offset = phy_cfg->vstatus_offset; + phy_parameter->phy_reg.vstatus_busy = phy_cfg->vstatus_busy; + phy_parameter->phy_reg.new_reg_req = phy_cfg->new_reg_req; if (of_property_read_bool(np, "realtek,inverse-hstx-sync-clock")) phy_parameter->inverse_hstx_sync_clock = true; @@ -1085,6 +1095,9 @@ static const struct phy_cfg rtd1295_phy_cfg = { .driving_updated_for_dev_dis = 0xf, .use_default_parameter = false, .is_double_sensitivity_mode = false, + .vstatus_offset = 0, + .vstatus_busy = PHY_VSTS_BUSY, + .new_reg_req = PHY_NEW_REG_REQ, }; static const struct phy_cfg rtd1395_phy_cfg = { @@ -1109,6 +1122,9 @@ static const struct phy_cfg rtd1395_phy_cfg = { .driving_updated_for_dev_dis = 0xf, .use_default_parameter = false, .is_double_sensitivity_mode = false, + .vstatus_offset = 0, + .vstatus_busy = PHY_VSTS_BUSY, + .new_reg_req = PHY_NEW_REG_REQ, }; static const struct phy_cfg rtd1395_phy_cfg_2port = { @@ -1133,6 +1149,9 @@ static const struct phy_cfg rtd1395_phy_cfg_2port = { .driving_updated_for_dev_dis = 0xf, .use_default_parameter = false, .is_double_sensitivity_mode = false, + .vstatus_offset = 0, + .vstatus_busy = PHY_VSTS_BUSY, + .new_reg_req = PHY_NEW_REG_REQ, }; static const struct phy_cfg rtd1619_phy_cfg = { @@ -1155,6 +1174,9 @@ static const struct phy_cfg rtd1619_phy_cfg = { .driving_updated_for_dev_dis = 0xf, .use_default_parameter = false, .is_double_sensitivity_mode = false, + .vstatus_offset = 0, + .vstatus_busy = PHY_VSTS_BUSY, + .new_reg_req = PHY_NEW_REG_REQ, }; static const struct phy_cfg rtd1319_phy_cfg = { @@ -1181,6 +1203,9 @@ static const struct phy_cfg rtd1319_phy_cfg = { .driving_updated_for_dev_dis = 0xf, .use_default_parameter = false, .is_double_sensitivity_mode = true, + .vstatus_offset = 0, + .vstatus_busy = PHY_VSTS_BUSY, + .new_reg_req = PHY_NEW_REG_REQ, }; static const struct phy_cfg rtd1312c_phy_cfg = { @@ -1206,6 +1231,9 @@ static const struct phy_cfg rtd1312c_phy_cfg = { .driving_updated_for_dev_dis = 0xf, .use_default_parameter = false, .is_double_sensitivity_mode = true, + .vstatus_offset = 0, + .vstatus_busy = PHY_VSTS_BUSY, + .new_reg_req = PHY_NEW_REG_REQ, }; static const struct phy_cfg rtd1619b_phy_cfg = { @@ -1231,6 +1259,9 @@ static const struct phy_cfg rtd1619b_phy_cfg = { .driving_updated_for_dev_dis = 0x8, .use_default_parameter = false, .is_double_sensitivity_mode = true, + .vstatus_offset = 0, + .vstatus_busy = PHY_VSTS_BUSY, + .new_reg_req = PHY_NEW_REG_REQ, }; static const struct phy_cfg rtd1319d_phy_cfg = { @@ -1256,6 +1287,9 @@ static const struct phy_cfg rtd1319d_phy_cfg = { .driving_updated_for_dev_dis = 0x8, .use_default_parameter = false, .is_double_sensitivity_mode = true, + .vstatus_offset = 0, + .vstatus_busy = PHY_VSTS_BUSY, + .new_reg_req = PHY_NEW_REG_REQ, }; static const struct phy_cfg rtd1315e_phy_cfg = { @@ -1282,6 +1316,9 @@ static const struct phy_cfg rtd1315e_phy_cfg = { .driving_updated_for_dev_dis = 0x8, .use_default_parameter = false, .is_double_sensitivity_mode = true, + .vstatus_offset = 0, + .vstatus_busy = PHY_VSTS_BUSY, + .new_reg_req = PHY_NEW_REG_REQ, }; static const struct of_device_id usbphy_rtk_dt_match[] = { -- 2.53.0 -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy