[PATCH v9 5/6] phy: realtek: usb2: add support for RTL9607C USB2 PHY
Manivannan Sadhasivam
mani at kernel.org
Sun Nov 1 02:38:41 PST 2026
On 2026-10-16 23:03 +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 rtl9607_phy_reg_desc struct.
>
> Co-developed-by: Michael Zavertkin <misha.zavertkin at mail.ru>
> Signed-off-by: Michael Zavertkin <misha.zavertkin at mail.ru>
> Signed-off-by: Rustam Adilov <adilov at disroot.org>
> ---
> drivers/phy/realtek/phy-rtk-usb2.c | 66 ++++++++++++++++++++++++++++++
> 1 file changed, 66 insertions(+)
>
> diff --git a/drivers/phy/realtek/phy-rtk-usb2.c b/drivers/phy/realtek/phy-rtk-usb2.c
> index 2ddad7be7353..64076938c821 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)
>
> @@ -107,6 +113,7 @@ struct phy_cfg {
> bool use_default_parameter;
> bool is_double_sensitivity_mode;
> const struct phy_reg_desc *reg_desc;
> + bool force_host_disconnect;
> };
>
> struct phy_parameter {
> @@ -144,6 +151,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,23 @@ static int do_rtk_phy_init(struct rtk_phy *rtk_phy, int index)
> goto do_toggle;
> }
>
> + if (phy_cfg->force_host_disconnect) {
> + const struct phy_reg_desc *reg_desc = phy_reg->desc;
> + void __iomem *vstatus = phy_reg->reg_wrap_vstatus;
> + u32 temp;
> +
> + temp = reg_desc->read(vstatus + PHY_9607_FORCE_DISCONNECT_REG);
> +
> + /* disable force-host-disconnect */
> + temp &= ~PHY_9607_FORCE_DISCONNECT_BIT;
> +
> + reg_desc->write(temp, vstatus + PHY_9607_FORCE_DISCONNECT_REG);
> + temp = reg_desc->read(vstatus + PHY_9607_FORCE_DISCONNECT_REG);
> +
> + /* allow IP to startup */
> + usleep_range(10000, 11000);
Same comment as previous patch. Do you really need this range or just a fixed
sleep time.
- Mani
More information about the linux-phy
mailing list