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 7D08DF5A8B8 for ; Mon, 20 Apr 2026 19:20:29 +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=Lln85AnpB+olc7nWb/ZSxmkmpvQ5OlHmSnKqeaAAg08=; b=luqDZgishEEl4o EcN3FPPYWPALtP+epjWFnJWVwPAZJgks26Ql8WKtpfPLldaIuUOkl6iih3dW7S0nvXZPnxMQnsOL1 AVETq7CfsrnN65qsyKdMyqzCl9JXG8/qzmtZT+9qm8Wf81DK0qOVIfq3nsI+XOLYGzkHGOSIVk4q2 mNGCEGypnDC8TLKPOG5yPYFe5Wm6attH7zzUgghQN/8ruot14DFb7m4pqHAFjjqbHRfPc/RlSlcCM bY5DAa71Esge3vkvDGuRKKlzMMJ1hfwMTrX25iFUA70IwBA+mWam5KzI5aB4DDcOxQyowro0SWMzu 2JVnj/tVcR55Sw3COXsA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1wEuAW-00000007aGq-385W; Mon, 20 Apr 2026 19:20:28 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1wEuAV-00000007aGM-12Mi for linux-phy@bombadil.infradead.org; Mon, 20 Apr 2026 19:20:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=Jmw28oELzXf46gwF+7RTNK6I9cnQDquVulY0lyHRutA=; b=fbwayhLXqN1i/H1n9gJjgopY6/ 18+Ofn0d8KQFvLtllpLrlqm7XHiArOkFGXPeG4VDfJviu0+d4uHk/fcWNhRMcyhSK20dnX7t4U7pl ZELEvJAXAvSNIakvk9RMzrP5LiHSBasSfHF8fZdXmxLckp1mlez1qSKpVV5STulHGa1g+Aai91+ZM Dd2UcqomR9v7sXh12viJw+CtQ912rfZSAzyn102yfqqhsTgenZ+9fVdqtjh+pFirkke7SmTlDGSPo plgnd8BkJlZAJm3gFxG8ayKGq6C33W25CeNOYP2LqjK6nAt03B7eLQmzHVOm14c3kSGTv7kJewc/g bvuYc7gA==; Received: from layka.disroot.org ([178.21.23.139]) by casper.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1wEuAS-00000008uzW-0FtG for linux-phy@lists.infradead.org; Mon, 20 Apr 2026 19:20:26 +0000 Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id B3BDD26F19; Mon, 20 Apr 2026 21:20:20 +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 0wy79rXnQk12; Mon, 20 Apr 2026 21:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1776712820; bh=daxptYU8HlXdVQlCPKqv2iutTKO/3+o3g3ChmcjZbdM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Qp6iPuhQlcNn3ZmHa0O6KenLeV8byoVcD1/vX/NC4KCkw7Y2aE30Rdk1WLls9YHq2 6ch8lhJSGNGT+AOsQy63FUNkP4FF+/GlqSfU/x9GBxH3X8RFQ93CWAnUECPA32sWX1 QK/A8r8cUxjOEccrTEcx28XYk5R7ylMNvKHMxdbrPO0p9Jt9mEvLVoY/ea/8QyollO XP6ymdq/+Gy3duksC/cfhyi4M2Wz9zGaM6cc4izFKBAl6KVXyR7J6n0IYLkcAD74t1 HDFs9x23mtjYnSUywwuRtC6lgdcdx/zxudouWCZ5FFy0m2MadruDPFkfIS7yeWUlV2 ZkNHifJnJrSgg== 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 v5 5/6] phy: realtek: usb2: add support for RTL9607C USB2 PHY Date: Tue, 21 Apr 2026 00:19:40 +0500 Message-ID: <20260420191941.81834-6-adilov@disroot.org> In-Reply-To: <20260420191941.81834-1-adilov@disroot.org> References: <20260420191941.81834-1-adilov@disroot.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260420_202024_224676_9482656F X-CRM114-Status: GOOD ( 14.43 ) 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 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. Since it belongs into the vstatus register region, it doesn't need bytes swapping. Add the bool variable to the driver data struct and hide this whole procedure under the if statement that checks this new variable. Add the appropriate little endian read and write functions for rtl9607 and assign them to its phy config struct. As mentioned earlier, the readl/writel are native endian on MIPS arch if SWAP_IO_SPACE is not enabled. Since enabling SWAP_IO_SPACE results in boot hang on RTL9607C machine, wrapping le32 around readl/writel should be a good compromise, but swab32 could be also work. Co-developed-by: Michael Zavertkin Signed-off-by: Michael Zavertkin Signed-off-by: Rustam Adilov --- drivers/phy/realtek/phy-rtk-usb2.c | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/drivers/phy/realtek/phy-rtk-usb2.c b/drivers/phy/realtek/phy-rtk-usb2.c index aaa07a69224a..7671f8a9ff61 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 +#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) @@ -109,6 +115,7 @@ struct phy_cfg { u32 (*read)(void __iomem *reg); void (*write)(u32 val, void __iomem *reg); + bool force_host_disconnect; }; struct phy_parameter { @@ -146,6 +153,18 @@ static void rtk_usb2phy_write(u32 val, void __iomem *reg) writel(val, reg); } +static u32 rtk_usb2phy_read_le(void __iomem *reg) +{ + return le32_to_cpu(readl(reg)); +} + +static void rtk_usb2phy_write_le(u32 val, void __iomem *reg) +{ + u32 tmp = 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) { @@ -600,6 +619,16 @@ static int do_rtk_phy_init(struct rtk_phy *rtk_phy, int index) goto do_toggle; } + if (phy_cfg->force_host_disconnect) { + /* disable force-host-disconnect */ + u32 temp = readl(phy_reg->reg_wrap_vstatus + PHY_9607_FORCE_DISCONNECT_REG); + + temp &= ~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 = phy_cfg->page0; rtk_phy_set_page(phy_reg, 0); @@ -1374,6 +1403,33 @@ static const struct phy_cfg rtd1315e_phy_cfg = { .write = rtk_usb2phy_write, }; +static const struct phy_cfg rtl9607_phy_cfg = { + .page0_size = MAX_USB_PHY_PAGE0_DATA_SIZE, + .page0 = { [0] = {0xe0, 0x95}, + [4] = {0xe4, 0x6a}, + [12] = {0xf3, 0x31}, }, + .page1_size = MAX_USB_PHY_PAGE1_DATA_SIZE, + .page1 = { [0] = {0xe0, 0x26}, }, + .page2_size = MAX_USB_PHY_PAGE2_DATA_SIZE, + .page2 = { [7] = {0xe7, 0x33}, }, + .num_phy = 1, + .check_efuse_version = CHECK_EFUSE_V2, + .efuse_dc_driving_rate = EFUS_USB_DC_CAL_RATE, + .dc_driving_mask = 0x1f, + .efuse_dc_disconnect_rate = EFUS_USB_DC_DIS_RATE, + .dc_disconnect_mask = 0xf, + .usb_dc_disconnect_at_page0 = true, + .do_toggle = true, + .driving_updated_for_dev_dis = 0x8, + .is_double_sensitivity_mode = true, + .vstatus_offset = 0xc, + .vstatus_busy = PHY_9607_VSTS_BUSY, + .new_reg_req = PHY_9607_NEW_REG_REQ, + .read = rtk_usb2phy_read_le, + .write = rtk_usb2phy_write_le, + .force_host_disconnect = true, +}; + static const struct of_device_id usbphy_rtk_dt_match[] = { { .compatible = "realtek,rtd1295-usb2phy", .data = &rtd1295_phy_cfg }, { .compatible = "realtek,rtd1312c-usb2phy", .data = &rtd1312c_phy_cfg }, @@ -1384,6 +1440,7 @@ static const struct of_device_id usbphy_rtk_dt_match[] = { { .compatible = "realtek,rtd1395-usb2phy-2port", .data = &rtd1395_phy_cfg_2port }, { .compatible = "realtek,rtd1619-usb2phy", .data = &rtd1619_phy_cfg }, { .compatible = "realtek,rtd1619b-usb2phy", .data = &rtd1619b_phy_cfg }, + { .compatible = "realtek,rtl9607-usb2phy", .data = &rtl9607_phy_cfg }, {}, }; MODULE_DEVICE_TABLE(of, usbphy_rtk_dt_match); -- 2.53.0 -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy