.../bindings/phy/realtek,usb2phy.yaml | 25 ++- drivers/phy/realtek/Kconfig | 4 +- drivers/phy/realtek/phy-rtk-usb2.c | 191 ++++++++++++++++-- 3 files changed, 195 insertions(+), 25 deletions(-)
This patch series for Realtek USB2 PHY driver adds support for RTL9607C
USB2 PHY.
RTL9607C is a big endian MIPS CPU which is quite far from RTD series SoCs
supported by realtek usb2 phy driver, but the phy initilization is found
to be very indentical in most areas.
Most of the code was based on the Realtek's usb driver from the GPL tarball
in [1] and adjusted to fit into the realtek usb2 phy driver code format.
The patch series was split into smaller patches that add/change something
in the driver that are not exactly related to RTL9607C and that also
helps for easier review. That also means, patch 5 depends on all the prior
patches that come before it.
USB2 PHY on RTL9607C is primarly used for its internal OHCI/EHCI controllers.
[1] - https://github.com/jameywine/GPL-for-GP3000/blob/main/linux-5.10.x/arch/mips/rtl9607c/usb.c
---
Changelog in v5:
Mostly addressing LLM review
- Patch 1
- changed int to u32 type for new_reg_req and vstatus_busy data fields.
- changed comments in rtk_phy_read/write from PHY_NEW_REG_REQ to phy_reg->new_reg_req.
- Patch 2
- explained readl/writel native endianess issue in more detail.
- explained why vstatus register doesn't need byte swapping.
- Patch 4
- moved reset_control_deassert to rtk_phy_init function to keep it outside of for loop.
- changed msleep(5) to usleep_range(5000, 6000).
- explained why reset_control_assert is not needed.
- Patch 5
- explained readl/writel native endianess issue here as well.
- explained why FORCE_DISCONNECT_REG doesn't need byte swapping.
- Link to v4: https://lore.kernel.org/linux-phy/20260406181228.25892-1-adilov@disroot.org/
Changelog in v4:
- Patch 2
- moved the le variations of read/write functions to Patch 5 where it is actually used because
otherwise, it results in unused errors when only Patch 2 is applied.
- updated the commit message to to point the reason for le32 wrappers around readl/writel.
- Patch 3
- added "Reviewed by Krzysztof Kozlowski"
- Patch 5
- updated the commit message to include the addition of little endian read/write functions from
Patch 2.
- Link to v3: https://lore.kernel.org/linux-phy/20260402154414.196012-1-adilov@disroot.org/
Changelog in v3:
- Patch 2
- renamed phy read and functions to "rtk_usb2phy" to not collide with networking API functions
- fixed the sparse warnings by creating intermidiate "tmp" variable and then pass it to writel
- sligtly adjusted commit message to instead use "default read" not "default phy_read"
- Patch 4
- added the check for reset_control_deassert() just in case
- changed mdelay(5) to msleep(5)
- changed dev_err and return combo with one dev_err_probe for phy_rst
- Patch 5
- changed mdelay(10) under force_host_disconnect to msleep(10)
- removed struct fields with false like force_host_disconnect and more in rtl9607_phy_cfg
- Patch 6
- updated the #endif commend to now include MACH_REALTEK_RTL to reflect if on top
- Link to v2: https://lore.kernel.org/linux-phy/20260327160638.15134-1-adilov@disroot.org/
Changelog in v2:
- Patch 3
- removed the line about OHCI/EHCI controllers from description.
- set the resets to false for RTD SoC devices and changed the
commit message to reflect that.
- Link to v1: https://lore.kernel.org/linux-phy/20260326193419.48419-1-adilov@disroot.org/
Rustam Adilov (6):
phy: realtek: usb2: introduce vstatus/new_reg_req variables to driver
data
phy: realtek: usb2: introduce read and write functions to driver data
dt-bindings: phy: realtek,usb2phy.yaml: extend for resets and RTL9607C
support
phy: realtek: usb2: introduce reset controller struct
phy: realtek: usb2: add support for RTL9607C USB2 PHY
phy: realtek: Make configs available for MACH_REALTEK_RTL
.../bindings/phy/realtek,usb2phy.yaml | 25 ++-
drivers/phy/realtek/Kconfig | 4 +-
drivers/phy/realtek/phy-rtk-usb2.c | 191 ++++++++++++++++--
3 files changed, 195 insertions(+), 25 deletions(-)
--
2.53.0
On Tue, Apr 21, 2026 at 12:19:35AM +0500, Rustam Adilov wrote: > This patch series for Realtek USB2 PHY driver adds support for RTL9607C > USB2 PHY. > > RTL9607C is a big endian MIPS CPU which is quite far from RTD series SoCs > supported by realtek usb2 phy driver, but the phy initilization is found > to be very indentical in most areas. > > Most of the code was based on the Realtek's usb driver from the GPL tarball > in [1] and adjusted to fit into the realtek usb2 phy driver code format. > > The patch series was split into smaller patches that add/change something > in the driver that are not exactly related to RTL9607C and that also > helps for easier review. That also means, patch 5 depends on all the prior > patches that come before it. > > USB2 PHY on RTL9607C is primarly used for its internal OHCI/EHCI controllers. > > [1] - https://github.com/jameywine/GPL-for-GP3000/blob/main/linux-5.10.x/arch/mips/rtl9607c/usb.c > > --- Could you go through Patchwork and reply inline to the issues found, stating whether you are or are not going to resolve them? https://patchwork.kernel.org/project/linux-phy/list/?series=1083475
On 2026-05-05 11:37, Vladimir Oltean wrote: > On Tue, Apr 21, 2026 at 12:19:35AM +0500, Rustam Adilov wrote: >> This patch series for Realtek USB2 PHY driver adds support for RTL9607C >> USB2 PHY. >> >> RTL9607C is a big endian MIPS CPU which is quite far from RTD series SoCs >> supported by realtek usb2 phy driver, but the phy initilization is found >> to be very indentical in most areas. >> >> Most of the code was based on the Realtek's usb driver from the GPL tarball >> in [1] and adjusted to fit into the realtek usb2 phy driver code format. >> >> The patch series was split into smaller patches that add/change something >> in the driver that are not exactly related to RTL9607C and that also >> helps for easier review. That also means, patch 5 depends on all the prior >> patches that come before it. >> >> USB2 PHY on RTL9607C is primarly used for its internal OHCI/EHCI controllers. >> >> [1] - https://github.com/jameywine/GPL-for-GP3000/blob/main/linux-5.10.x/arch/mips/rtl9607c/usb.c >> >> --- > > Could you go through Patchwork and reply inline to the issues found, > stating whether you are or are not going to resolve them? > https://patchwork.kernel.org/project/linux-phy/list/?series=1083475 Yeah, sure thing. However i do expect a good bit of refactoring of this patch series once we get SWAP_IO_SPACE working. It just turned out that some of the realtek drivers from various subsystems use readl/ioread32 for native endian (which is big endian for rtl9607c and others under MACH_REALTEK_RTL) and enabling SWAP_IO_SPACE makes them function in little endian which breaks those things. So that's what we are dealing with at this moment. > All of the WARNING: line length of XX exceeds 80 columns I can resolve them just fine. > WARNING: msleep < 20ms can sleep for up to 20ms; see function description of msleep(). > #88: FILE: drivers/phy/realtek/phy-rtk-usb2.c:629: > + msleep(10); I can resolve it by changing it to usleep_range like i did with reset controller one. > ../drivers/phy/realtek/phy-rtk-usb2.c:158:16: warning: cast to restricted __le32 > ../drivers/phy/realtek/phy-rtk-usb2.c:163:19: warning: incorrect type in initializer (different base types) > ../drivers/phy/realtek/phy-rtk-usb2.c:163:19: expected unsigned int [usertype] tmp > ../drivers/phy/realtek/phy-rtk-usb2.c:163:19: got restricted __le32 [usertype] That should be fixed by using ioread32be. > 1 maintainers not CCed: p.zabel@pengutronix.de When i run scripts/get_maintainer.pl, it doesn't print it out at all but I can include it. > Detected inline keyword in C files > +static inline int utmi_wait_register(u32 (*read)(void __iomem *reg), void __iomem *reg, u32 mask, Even though it was not introduced by this patch series, i think it is relevant as i am directly modifying its property to include read function to it. Something along like "While we are here, remove inline from utmi_wait_register" I believe that is every issue from Checks list apart from Sashiko reviews. Best, Rustam
On Tue, Apr 21, 2026 at 12:19:35AM +0500, Rustam Adilov wrote: > This patch series for Realtek USB2 PHY driver adds support for RTL9607C > USB2 PHY. > > RTL9607C is a big endian MIPS CPU which is quite far from RTD series SoCs > supported by realtek usb2 phy driver, but the phy initilization is found > to be very indentical in most areas. > > Most of the code was based on the Realtek's usb driver from the GPL tarball > in [1] and adjusted to fit into the realtek usb2 phy driver code format. > > The patch series was split into smaller patches that add/change something > in the driver that are not exactly related to RTL9607C and that also > helps for easier review. That also means, patch 5 depends on all the prior > patches that come before it. > > USB2 PHY on RTL9607C is primarly used for its internal OHCI/EHCI controllers. > > [1] - https://github.com/jameywine/GPL-for-GP3000/blob/main/linux-5.10.x/arch/mips/rtl9607c/usb.c > > --- > Changelog in v5: > Mostly addressing LLM review > - Patch 1 > - changed int to u32 type for new_reg_req and vstatus_busy data fields. > - changed comments in rtk_phy_read/write from PHY_NEW_REG_REQ to phy_reg->new_reg_req. > - Patch 2 > - explained readl/writel native endianess issue in more detail. > - explained why vstatus register doesn't need byte swapping. > - Patch 4 > - moved reset_control_deassert to rtk_phy_init function to keep it outside of for loop. > - changed msleep(5) to usleep_range(5000, 6000). > - explained why reset_control_assert is not needed. > - Patch 5 > - explained readl/writel native endianess issue here as well. > - explained why FORCE_DISCONNECT_REG doesn't need byte swapping. > - Link to v4: https://lore.kernel.org/linux-phy/20260406181228.25892-1-adilov@disroot.org/ > > Changelog in v4: > - Patch 2 > - moved the le variations of read/write functions to Patch 5 where it is actually used because > otherwise, it results in unused errors when only Patch 2 is applied. > - updated the commit message to to point the reason for le32 wrappers around readl/writel. > - Patch 3 > - added "Reviewed by Krzysztof Kozlowski" Where? Best regards, Krzysztof
On 2026-04-21 07:09, Krzysztof Kozlowski wrote: > On Tue, Apr 21, 2026 at 12:19:35AM +0500, Rustam Adilov wrote: >> This patch series for Realtek USB2 PHY driver adds support for RTL9607C >> USB2 PHY. >> >> RTL9607C is a big endian MIPS CPU which is quite far from RTD series SoCs >> supported by realtek usb2 phy driver, but the phy initilization is found >> to be very indentical in most areas. >> >> Most of the code was based on the Realtek's usb driver from the GPL tarball >> in [1] and adjusted to fit into the realtek usb2 phy driver code format. >> >> The patch series was split into smaller patches that add/change something >> in the driver that are not exactly related to RTL9607C and that also >> helps for easier review. That also means, patch 5 depends on all the prior >> patches that come before it. >> >> USB2 PHY on RTL9607C is primarly used for its internal OHCI/EHCI controllers. >> >> [1] - https://github.com/jameywine/GPL-for-GP3000/blob/main/linux-5.10.x/arch/mips/rtl9607c/usb.c >> >> --- >> Changelog in v5: >> Mostly addressing LLM review >> - Patch 1 >> - changed int to u32 type for new_reg_req and vstatus_busy data fields. >> - changed comments in rtk_phy_read/write from PHY_NEW_REG_REQ to phy_reg->new_reg_req. >> - Patch 2 >> - explained readl/writel native endianess issue in more detail. >> - explained why vstatus register doesn't need byte swapping. >> - Patch 4 >> - moved reset_control_deassert to rtk_phy_init function to keep it outside of for loop. >> - changed msleep(5) to usleep_range(5000, 6000). >> - explained why reset_control_assert is not needed. >> - Patch 5 >> - explained readl/writel native endianess issue here as well. >> - explained why FORCE_DISCONNECT_REG doesn't need byte swapping. >> - Link to v4: https://lore.kernel.org/linux-phy/20260406181228.25892-1-adilov@disroot.org/ >> >> Changelog in v4: >> - Patch 2 >> - moved the le variations of read/write functions to Patch 5 where it is actually used because >> otherwise, it results in unused errors when only Patch 2 is applied. >> - updated the commit message to to point the reason for le32 wrappers around readl/writel. >> - Patch 3 >> - added "Reviewed by Krzysztof Kozlowski" > > Where? Oi, it must have been lost in transmission because i added the tag manually to .patch after format-patch command instead of adding it to commit message. So it disappeared in v5. Sorry about that. Unintentional blunder on my part. > Best regards, > Krzysztof Thanks, Rustam
© 2016 - 2026 Red Hat, Inc.