[RFC PATCH 07/10] net: pcs: xpcs: add Rockchip RK3568 platform glue driver
Coia Prant
coiaprant at gmail.com
Wed Jul 15 00:57:47 PDT 2026
Maxime Chevallier <maxime.chevallier at bootlin.com> 于2026年7月15日周三 15:43写道:
>
> Hi,
>
> On 7/14/26 21:08, Coia Prant wrote:
> > The RK3568 SoC integrates a Synopsys DesignWare XPCS that is accessed
> > via APB3 memory-mapped registers.
> > This driver provides the glue logic to make the XPCS accessible to
> > the generic pcs-xpcs core.
> >
> > The XPCS block contains four MII ports (0..3), each of which can be
> > routed to GMAC0 or GMAC1 via the pcs-handle property in the MAC node.
> > The hardware maps these ports to different MMDs:
> > - port 0: MMD 7 (ROCKCHIP_MMD_MII)
> > - port 1: MMD 2 (ROCKCHIP_MMD_MII1)
> > - port 2: MMD 3 (ROCKCHIP_MMD_MII2)
> > - port 3: MMD 4 (ROCKCHIP_MMD_MII3)
> >
> > This driver creates a virtual MDIO bus that translates MDIO operations
> > to APB3 register accesses, with proper address remapping for each port.
> > The generic xpcs driver then creates a phylink_pcs instance on top of
> > this bus, allowing the MAC to use the PCS via the standard phylink API.
> >
> > Link: https://dl.radxa.com/rock3/docs/hw/datasheet/Rockchip%20RK3568%20TRM%20Part2%20V1.1-20210301.pdf (Page 2078)
> > Signed-off-by: Coia Prant <coiaprant at gmail.com>
>
> [...]
>
> > +static int xpcs_rk_probe(struct platform_device *pdev)
> > +{
> > + struct dw_xpcs_rk *pxpcs;
> > + int ret;
> > +
> > + pxpcs = xpcs_rk_create_data(pdev);
> > + if (IS_ERR(pxpcs))
> > + return PTR_ERR(pxpcs);
> > +
> > + /*
> > + * The XPCS may be attached to a power domain (e.g. PD_PIPE). The domain
> > + * must be powered on before any register access, otherwise the SoC will
> > + * trigger a synchronous external abort (SError).
> > + *
> > + * Accessing the XPCS registers also requires a TX clock from the SerDes,
> > + * which is needed for the soft reset.
> > + */
> > + ret = xpcs_rk_serdes_phy_init(pxpcs);
> > + if (ret)
> > + return ret;
> > +
> > + ret = xpcs_rk_serdes_phy_poweron(pxpcs);
> > + if (ret)
> > + return ret;
> >
> There are 2 unusual things here.
>
> The first one is that you manage the serdes phy from the PCS driver, usually it's
> the MAC driver doing so. In stmmac, we have the serdes_poweron and serdes_poweroff
> callbacks to hook into for Serdes control.
>
> The second thing is that you're setting the serdes ON at probe time, there's no
> dynamic control of it. Usually we try to only power this on at admin-up time.
>
> Can you explain the rationale behind controlling the serdes here directly, and not
> from the MAC driver ? I don't see any mention of that in the commit log, and I'm not
> convinced this is the correct approach.
>
> Maxime
Hi Maxime,
Thanks for the review.
This is intentional. The SerDes is attached to the XPCS node because
on RK3568, a single SerDes serves all four XPCS MII ports in QSGMII
mode. If we managed it from dwmac-rk, we would need complex
refcounting across multiple MAC instances. Keeping it at the XPCS
level simplifies the design and prepares for future QSGMII support.
The probe-time power-on is a one-time initialization (mode selection),
not a runtime power toggle. The actual power is controlled by the
PD_PIPE domain via PM runtime. Also, phy_power_on() on this PHY is
effectively a no-op; only phy_init() is required.
I considered the stmmac serdes_poweron/serdes_poweroff callbacks, but
they do not handle shared SerDes well. I am happy to rework if the
community prefers otherwise, but this approach seems cleaner for
multi-port setups.
Thanks,
Coia
More information about the Linux-rockchip
mailing list