From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 59B273A75B6 for ; Mon, 30 Mar 2026 21:50:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774907440; cv=none; b=ucmsoqBp13HZe5dIuzXcSiBWo3blkxTlB6l4/0ppaihxrA6+lQoIpIsL1RLcgjt3Vc3ThQ5UQMlQDaEhBiq9KPi1F540rHYlt7uFB79X2xB5z+yhuWVJYtAPx5ubhq8I6uWezqQjD3L1fsNo/UAoeP5+Gj6sBxDSzJw2A5N7Mp4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774907440; c=relaxed/simple; bh=892Dex4+6n7c+srBxz1jVKknV7GNsNEBw/hHHSzXRGQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rf++XKJPRtyJ7zryJsMnE415vOtvEKDlHKAuBIHMrJ3TGXSvhOAkfzIBDvNmW6UO43T4H7OVa9twvP4Lm31KGxIzER66u6Cx3FZPqn6fVag+40GjsBm8xN8VniRzFlPGz/v4cUyQ65d7HPXsaNJFjM+VsgcmbHTZALsHhYzAFbs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kK8iudL+; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kK8iudL+" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-485358f43e7so5525535e9.2 for ; Mon, 30 Mar 2026 14:50:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774907436; x=1775512236; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=1rvOVfipuNnH/UivVwc7De7z6zvsPeKLD3Y+JlWhA4s=; b=kK8iudL+3UtHIl2AF7CpDL3RfpN/t+vM8tWyTkiumRKtFA+FZRvznAx+TkQm6a6FOW 0dd6bnNi2WAYp0AdOx9vz2qINUrpKN8XgolTiK7o8CMMa9nWupl9uHaQm1PkRCFHLsSs CrqDg/etre7rlWh2fkDF6aOgwIlC/PzAULxcLieCSnVoBBfyg5MSRfQR3X09UJ9VWqoi Y22s5YxZFezM7jU17qC6XIY815UZaGVZGQ5nsKLLhCA5OSsfeeZI9tRINoRi0vgHUanT BObThGxNmRqim3j9e73Q1SdYyojXhFiimKxm+WxlbEjsXy3tOoFcBbwEPlbXE7AlGanx 79NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774907436; x=1775512236; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1rvOVfipuNnH/UivVwc7De7z6zvsPeKLD3Y+JlWhA4s=; b=DUzF1wWP/qbM/qK8ut5WuFYY/hSs9w0vh9ZWWNFsona+tdc+VaG6VYc+hGfZts+OlM 5w1dLoNRg0/vyyp94gl6z5gesieHkk2uBVVRB7YiJKykZGHYrCONSfBM6YN3bSzdB9vS MfmkGA6DFJxF9ixWKE3xvJDs5C75YLawdlLjNk278t4h/u5bGoqqRxHipI/HjLojHm8w vaNJcRLH7zvGTwQT8s2oRVNXEK6/wZpYgKFQe5+UoUHeK5sevyZm3f6bneHTPNoQm0Ga Y4adNeD0rebCAcY1mcqMFRHq+Y+PMnnKSkP4QTOhRnYQ0YqHTRPOwSpobRvzu6WNWHqm nwCQ== X-Forwarded-Encrypted: i=1; AJvYcCXfpTTjPfHX+skt9JdxtFF+2jJBjgoEnNWrrXU0+isuu0EpyrnEudmbIdpFjjTW6TNeMV30ZGcDt6q0LSY=@vger.kernel.org X-Gm-Message-State: AOJu0Ywwe5uz98uQdnmpR40WQNueiDxBz6oOJTbg93U7GqscGtTU+W8E +INrg17j2BNPCrPjSZODNeprCDY3D8teKw2XLmYC/CyAvCkOMvJhwnYJ X-Gm-Gg: ATEYQzyMYddeIcifoy0GYUwgTKKVpKiN0mz4oiSJ+UvhfNZwmxIvZb4WRi7azT4EDjK ugGXdo7BEn+J6C9b8hojDsRH10Sx7sD5fsWld4TDOWbSysPtLOPo5al0vuK8vtaqRfLpmXjxmlx ZjCGlvTmLmlJTdJW/a7DrSAsdo/Lj9qHb2yjYEWjlmKUknM5Hn7/q2in/ONDmsxVNg8MrxVNirF 6hwwb9fSiYGECxbZowwShmBTtJ0FOEMNjDEHpL5Wuig/MV7NP7xef2nMI94jb3QLg+3tkjJZvfE MD0SJdWxzDQL43Q7Mrf7lAHoLr6DA1IuvK51s4lCtTEjLV6PAEo/Z150sz7kjB94H0ALcesx/ix UkZcoaOpgF3JFbGalgixoOFNqtv4e8Ez8hLdJ9l5tOAAZhl3lzvgVTrWTjn2QWj/wWyARUjBxk1 j4g1Lu98zqNSmJ0AM= X-Received: by 2002:a05:600c:8b41:b0:487:17d:d0bf with SMTP id 5b1f17b1804b1-48727ee0e73mr119411695e9.6.1774907436457; Mon, 30 Mar 2026 14:50:36 -0700 (PDT) Received: from skbuf ([2a02:2f04:d50a:b400:fc92:d05b:3301:b722]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43cf24739easm22792835f8f.30.2026.03.30.14.50.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2026 14:50:35 -0700 (PDT) Date: Tue, 31 Mar 2026 00:50:33 +0300 From: Vladimir Oltean To: Rustam Adilov Cc: 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, Michael Zavertkin Subject: Re: [PATCH v2 5/6] phy: realtek: usb2: add support for RTL9607C USB2 PHY Message-ID: <20260330215033.ven3bllyw3jverfg@skbuf> References: <20260327160638.15134-1-adilov@disroot.org> <20260327160638.15134-1-adilov@disroot.org> <20260327160638.15134-6-adilov@disroot.org> <20260327160638.15134-6-adilov@disroot.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260327160638.15134-6-adilov@disroot.org> <20260327160638.15134-6-adilov@disroot.org> On Fri, Mar 27, 2026 at 09:06:37PM +0500, Rustam Adilov wrote: > 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 | 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 070cba1e0e0a..bf22d12681dc 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 { > @@ -614,6 +621,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); > + > + mdelay(10); LLM review: Could we use msleep(10) or usleep_range(10000, 11000) here instead of mdelay(10)? Since do_rtk_phy_init() executes as part of the phy_ops->init callback with a mutex held from a sleepable process context, spinning the CPU for 10ms wastes CPU resources and increases scheduling latency. > + } > + > /* Set page 0 */ > phy_data_page = phy_cfg->page0; > rtk_phy_set_page(phy_reg, 0); > @@ -1141,6 +1158,7 @@ static const struct phy_cfg rtd1295_phy_cfg = { > .new_reg_req = PHY_NEW_REG_REQ, > .read = phy_read, > .write = phy_write, > + .force_host_disconnect = false, You don't need to initialize rodata struct fields with false/0/NULL. > }; > > static const struct phy_cfg rtd1395_phy_cfg = { > @@ -1170,6 +1188,7 @@ static const struct phy_cfg rtd1395_phy_cfg = { > .new_reg_req = PHY_NEW_REG_REQ, > .read = phy_read, > .write = phy_write, > + .force_host_disconnect = false, > }; > > static const struct phy_cfg rtd1395_phy_cfg_2port = { > @@ -1199,6 +1218,7 @@ static const struct phy_cfg rtd1395_phy_cfg_2port = { > .new_reg_req = PHY_NEW_REG_REQ, > .read = phy_read, > .write = phy_write, > + .force_host_disconnect = false, > }; > > static const struct phy_cfg rtd1619_phy_cfg = { > @@ -1226,6 +1246,7 @@ static const struct phy_cfg rtd1619_phy_cfg = { > .new_reg_req = PHY_NEW_REG_REQ, > .read = phy_read, > .write = phy_write, > + .force_host_disconnect = false, > }; > > static const struct phy_cfg rtd1319_phy_cfg = { > @@ -1257,6 +1278,7 @@ static const struct phy_cfg rtd1319_phy_cfg = { > .new_reg_req = PHY_NEW_REG_REQ, > .read = phy_read, > .write = phy_write, > + .force_host_disconnect = false, > }; > > static const struct phy_cfg rtd1312c_phy_cfg = { > @@ -1287,6 +1309,7 @@ static const struct phy_cfg rtd1312c_phy_cfg = { > .new_reg_req = PHY_NEW_REG_REQ, > .read = phy_read, > .write = phy_write, > + .force_host_disconnect = false, > }; > > static const struct phy_cfg rtd1619b_phy_cfg = { > @@ -1317,6 +1340,7 @@ static const struct phy_cfg rtd1619b_phy_cfg = { > .new_reg_req = PHY_NEW_REG_REQ, > .read = phy_read, > .write = phy_write, > + .force_host_disconnect = false, > }; > > static const struct phy_cfg rtd1319d_phy_cfg = { > @@ -1347,6 +1371,7 @@ static const struct phy_cfg rtd1319d_phy_cfg = { > .new_reg_req = PHY_NEW_REG_REQ, > .read = phy_read, > .write = phy_write, > + .force_host_disconnect = false, > }; > > static const struct phy_cfg rtd1315e_phy_cfg = { > @@ -1378,6 +1403,37 @@ static const struct phy_cfg rtd1315e_phy_cfg = { > .new_reg_req = PHY_NEW_REG_REQ, > .read = phy_read, > .write = phy_write, > + .force_host_disconnect = false, > +}; > + > +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 = false, Similar for these (+do_toggle_driving, use_default_parameter). > + .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, > + .do_toggle_driving = false, > + .driving_updated_for_dev_dis = 0x8, > + .use_default_parameter = false, > + .is_double_sensitivity_mode = true, > + .vstatus_offset = 0xc, > + .vstatus_busy = PHY_9607_VSTS_BUSY, > + .new_reg_req = PHY_9607_NEW_REG_REQ, > + .read = phy_read_le, > + .write = phy_write_le, > + .force_host_disconnect = true, > }; > > static const struct of_device_id usbphy_rtk_dt_match[] = { > @@ -1390,6 +1446,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 > >