Devicetree
 help / color / mirror / Atom feed
From: Rustam Adilov <adilov@disroot.org>
To: Manivannan Sadhasivam <mani@kernel.org>
Cc: Vinod Koul <vkoul@kernel.org>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Stanley Chang <stanley_chang@realtek.com>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	linux-phy@lists.infradead.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Michael Zavertkin <misha.zavertkin@mail.ru>
Subject: Re: [PATCH v6 5/6] phy: realtek: usb2: add support for RTL9607C USB2 PHY
Date: Thu, 13 Aug 2026 07:43:00 +0000	[thread overview]
Message-ID: <0a4470dbaa381d068f25ebf8041b3f6f@disroot.org> (raw)
In-Reply-To: <pu3724you4tqsnuewo2uwqsubtwpf5t7kdd4of33awodjunfb4@cfzd3cmvlpjb>


On 2026-08-12 15:05, Manivannan Sadhasivam wrote:
> On Wed, May 20, 2026 at 10:57:27PM +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. Since it belongs into
>> the vstatus register region, it requires the use of added read and
>> write helper functions.
>> 
>> 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 big endian read and write functions for rtl9607
>> and assign them to its phy config struct.
>> 
>> Co-developed-by: Michael Zavertkin <misha.zavertkin@mail.ru>
>> Signed-off-by: Michael Zavertkin <misha.zavertkin@mail.ru>
>> Signed-off-by: Rustam Adilov <adilov@disroot.org>
>> ---
>>  drivers/phy/realtek/phy-rtk-usb2.c | 58 ++++++++++++++++++++++++++++++
>>  1 file changed, 58 insertions(+)
>> 
>> diff --git a/drivers/phy/realtek/phy-rtk-usb2.c b/drivers/phy/realtek/phy-rtk-usb2.c
>> index 16c5fc3191de..69f0f5279b5e 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,16 @@ static void rtk_usb2phy_write(u32 val, void __iomem *reg)
>>  	writel(val, reg);
>>  }
>>  
>> +static u32 rtk_usb2phy_read_be(void __iomem *reg)
>> +{
>> +	return ioread32be(reg);
>> +}
>> +
>> +static void rtk_usb2phy_write_be(u32 val, void __iomem *reg)
>> +{
>> +	iowrite32be(val, 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 +617,19 @@ 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 */
>> +		void __iomem *vstatus = phy_reg->reg_wrap_vstatus;
>> +		u32 temp;
>> +
>> +		temp = phy_reg->read(vstatus + PHY_9607_FORCE_DISCONNECT_REG);
>> +
>> +		temp &= ~PHY_9607_FORCE_DISCONNECT_BIT;
>> +		phy_reg->write(temp, vstatus + PHY_9607_FORCE_DISCONNECT_REG);
>> +
>> +		usleep_range(10000, 11000);
> 
> If you really want to make sure the delay gets completed within this if()
> condition, then add a read.
> 
> - Mani

Hey,

Thanks for reviews, i have already seen the other comments but i have a question
about this one. What do you mean by adding a read? As far as i know, it is just
time to "allow IP to startup" and not like a status bit i have to continuously
read if that is what you were referring to.

Best,
Rustam

  reply	other threads:[~2026-08-13  7:43 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-20 17:57 [PATCH v6 0/6] phy: realtek: usb2: support for RTL9607C USB2 PHY Rustam Adilov
2026-05-20 17:57 ` [PATCH v6 1/6] phy: realtek: usb2: introduce vstatus/new_reg_req variables to driver data Rustam Adilov
2026-05-20 18:23   ` sashiko-bot
2026-08-12 14:54   ` Manivannan Sadhasivam
2026-05-20 17:57 ` [PATCH v6 2/6] phy: realtek: usb2: introduce read and write functions " Rustam Adilov
2026-05-20 18:40   ` sashiko-bot
2026-05-20 17:57 ` [PATCH v6 3/6] dt-bindings: phy: realtek,usb2phy.yaml: extend for resets and RTL9607C support Rustam Adilov
2026-08-12 14:55   ` Manivannan Sadhasivam
2026-05-20 17:57 ` [PATCH v6 4/6] phy: realtek: usb2: introduce reset controller struct Rustam Adilov
2026-05-20 19:16   ` sashiko-bot
2026-08-12 15:00   ` Manivannan Sadhasivam
2026-05-20 17:57 ` [PATCH v6 5/6] phy: realtek: usb2: add support for RTL9607C USB2 PHY Rustam Adilov
2026-05-20 19:51   ` sashiko-bot
2026-08-12 15:05   ` Manivannan Sadhasivam
2026-08-13  7:43     ` Rustam Adilov [this message]
2026-08-13 13:25       ` Manivannan Sadhasivam
2026-05-20 17:57 ` [PATCH v6 6/6] phy: realtek: Make configs available for MACH_REALTEK_RTL Rustam Adilov
2026-08-12 15:06   ` Manivannan Sadhasivam
2026-06-20 11:49 ` [PATCH v6 0/6] phy: realtek: usb2: support for RTL9607C USB2 PHY Rustam Adilov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0a4470dbaa381d068f25ebf8041b3f6f@disroot.org \
    --to=adilov@disroot.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=mani@kernel.org \
    --cc=misha.zavertkin@mail.ru \
    --cc=neil.armstrong@linaro.org \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=stanley_chang@realtek.com \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox