Reunify the split C22/C45 drivers for the RTL8221B-VB-CG 2.5Gbps and
RTL8221B-VM-CG 2.5Gbps PHYs back into a single driver.
This is possible now by using all the driver operations previously used
by the C45 driver, as transparent access to all MMDs including
MDIO_MMD_VEND2 is now possible also over Clause-22 MDIO.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
drivers/net/phy/realtek/realtek_main.c | 72 ++++++--------------------
1 file changed, 16 insertions(+), 56 deletions(-)
diff --git a/drivers/net/phy/realtek/realtek_main.c b/drivers/net/phy/realtek/realtek_main.c
index 886694ff995f6..d07d60bc1ce34 100644
--- a/drivers/net/phy/realtek/realtek_main.c
+++ b/drivers/net/phy/realtek/realtek_main.c
@@ -1879,28 +1879,18 @@ static int rtl8221b_match_phy_device(struct phy_device *phydev,
return phydev->phy_id == RTL_8221B && rtlgen_supports_mmd(phydev);
}
-static int rtl8221b_vb_cg_c22_match_phy_device(struct phy_device *phydev,
- const struct phy_driver *phydrv)
+static int rtl8221b_vb_cg_match_phy_device(struct phy_device *phydev,
+ const struct phy_driver *phydrv)
{
- return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, false);
+ return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, true) ||
+ rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, false);
}
-static int rtl8221b_vb_cg_c45_match_phy_device(struct phy_device *phydev,
- const struct phy_driver *phydrv)
+static int rtl8221b_vm_cg_match_phy_device(struct phy_device *phydev,
+ const struct phy_driver *phydrv)
{
- return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, true);
-}
-
-static int rtl8221b_vm_cg_c22_match_phy_device(struct phy_device *phydev,
- const struct phy_driver *phydrv)
-{
- return rtlgen_is_c45_match(phydev, RTL_8221B_VM_CG, false);
-}
-
-static int rtl8221b_vm_cg_c45_match_phy_device(struct phy_device *phydev,
- const struct phy_driver *phydrv)
-{
- return rtlgen_is_c45_match(phydev, RTL_8221B_VM_CG, true);
+ return rtlgen_is_c45_match(phydev, RTL_8221B_VM_CG, true) ||
+ rtlgen_is_c45_match(phydev, RTL_8221B_VM_CG, false);
}
static int rtl_internal_nbaset_match_phy_device(struct phy_device *phydev,
@@ -2284,27 +2274,8 @@ static struct phy_driver realtek_drvs[] = {
.read_mmd = rtl822xb_read_mmd,
.write_mmd = rtl822xb_write_mmd,
}, {
- .match_phy_device = rtl8221b_vb_cg_c22_match_phy_device,
- .name = "RTL8221B-VB-CG 2.5Gbps PHY (C22)",
- .config_intr = rtl8221b_config_intr,
- .handle_interrupt = rtl8221b_handle_interrupt,
- .probe = rtl822x_probe,
- .get_features = rtl822x_get_features,
- .config_aneg = rtl822x_config_aneg,
- .config_init = rtl822xb_config_init,
- .inband_caps = rtl822x_inband_caps,
- .config_inband = rtl822x_config_inband,
- .get_rate_matching = rtl822xb_get_rate_matching,
- .read_status = rtl822xb_read_status,
- .suspend = genphy_suspend,
- .resume = rtlgen_resume,
- .read_page = rtl821x_read_page,
- .write_page = rtl821x_write_page,
- .read_mmd = rtl822xb_read_mmd,
- .write_mmd = rtl822xb_write_mmd,
- }, {
- .match_phy_device = rtl8221b_vb_cg_c45_match_phy_device,
- .name = "RTL8221B-VB-CG 2.5Gbps PHY (C45)",
+ .match_phy_device = rtl8221b_vb_cg_match_phy_device,
+ .name = "RTL8221B-VB-CG 2.5Gbps PHY",
.config_intr = rtl8221b_config_intr,
.handle_interrupt = rtl8221b_handle_interrupt,
.probe = rtl822x_probe,
@@ -2317,28 +2288,13 @@ static struct phy_driver realtek_drvs[] = {
.read_status = rtl822xb_c45_read_status,
.suspend = genphy_c45_pma_suspend,
.resume = rtlgen_c45_resume,
- }, {
- .match_phy_device = rtl8221b_vm_cg_c22_match_phy_device,
- .name = "RTL8221B-VM-CG 2.5Gbps PHY (C22)",
- .config_intr = rtl8221b_config_intr,
- .handle_interrupt = rtl8221b_handle_interrupt,
- .probe = rtl822x_probe,
- .get_features = rtl822x_get_features,
- .config_aneg = rtl822x_config_aneg,
- .config_init = rtl822xb_config_init,
- .inband_caps = rtl822x_inband_caps,
- .config_inband = rtl822x_config_inband,
- .get_rate_matching = rtl822xb_get_rate_matching,
- .read_status = rtl822xb_read_status,
- .suspend = genphy_suspend,
- .resume = rtlgen_resume,
.read_page = rtl821x_read_page,
.write_page = rtl821x_write_page,
.read_mmd = rtl822xb_read_mmd,
.write_mmd = rtl822xb_write_mmd,
}, {
- .match_phy_device = rtl8221b_vm_cg_c45_match_phy_device,
- .name = "RTL8221B-VM-CG 2.5Gbps PHY (C45)",
+ .match_phy_device = rtl8221b_vm_cg_match_phy_device,
+ .name = "RTL8221B-VM-CG 2.5Gbps PHY",
.config_intr = rtl8221b_config_intr,
.handle_interrupt = rtl8221b_handle_interrupt,
.probe = rtl822x_probe,
@@ -2351,6 +2307,10 @@ static struct phy_driver realtek_drvs[] = {
.read_status = rtl822xb_c45_read_status,
.suspend = genphy_c45_pma_suspend,
.resume = rtlgen_c45_resume,
+ .read_page = rtl821x_read_page,
+ .write_page = rtl821x_write_page,
+ .read_mmd = rtl822xb_read_mmd,
+ .write_mmd = rtl822xb_write_mmd,
}, {
.match_phy_device = rtl8251b_c45_match_phy_device,
.name = "RTL8251B 5Gbps PHY",
--
2.52.0
On Fri, Jan 09, 2026 at 03:03:33AM +0000, Daniel Golle wrote:
> Reunify the split C22/C45 drivers for the RTL8221B-VB-CG 2.5Gbps and
> RTL8221B-VM-CG 2.5Gbps PHYs back into a single driver.
> This is possible now by using all the driver operations previously used
> by the C45 driver, as transparent access to all MMDs including
> MDIO_MMD_VEND2 is now possible also over Clause-22 MDIO.
>
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> ---
> drivers/net/phy/realtek/realtek_main.c | 72 ++++++--------------------
> 1 file changed, 16 insertions(+), 56 deletions(-)
>
> diff --git a/drivers/net/phy/realtek/realtek_main.c b/drivers/net/phy/realtek/realtek_main.c
> index 886694ff995f6..d07d60bc1ce34 100644
> --- a/drivers/net/phy/realtek/realtek_main.c
> +++ b/drivers/net/phy/realtek/realtek_main.c
> @@ -1879,28 +1879,18 @@ static int rtl8221b_match_phy_device(struct phy_device *phydev,
> return phydev->phy_id == RTL_8221B && rtlgen_supports_mmd(phydev);
> }
>
> -static int rtl8221b_vb_cg_c22_match_phy_device(struct phy_device *phydev,
> - const struct phy_driver *phydrv)
> +static int rtl8221b_vb_cg_match_phy_device(struct phy_device *phydev,
> + const struct phy_driver *phydrv)
> {
> - return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, false);
> + return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, true) ||
> + rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, false);
Are there any calls left to rtlgen_is_c45_match() which don't || true
and false? If not, maybe add another patch which removes the bool
parameter?
Andrew
On Fri, Jan 09, 2026 at 02:18:14PM +0100, Andrew Lunn wrote:
> On Fri, Jan 09, 2026 at 03:03:33AM +0000, Daniel Golle wrote:
> > Reunify the split C22/C45 drivers for the RTL8221B-VB-CG 2.5Gbps and
> > RTL8221B-VM-CG 2.5Gbps PHYs back into a single driver.
> > This is possible now by using all the driver operations previously used
> > by the C45 driver, as transparent access to all MMDs including
> > MDIO_MMD_VEND2 is now possible also over Clause-22 MDIO.
> >
> > Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> > ---
> > drivers/net/phy/realtek/realtek_main.c | 72 ++++++--------------------
> > 1 file changed, 16 insertions(+), 56 deletions(-)
> >
> > diff --git a/drivers/net/phy/realtek/realtek_main.c b/drivers/net/phy/realtek/realtek_main.c
> > index 886694ff995f6..d07d60bc1ce34 100644
> > --- a/drivers/net/phy/realtek/realtek_main.c
> > +++ b/drivers/net/phy/realtek/realtek_main.c
> > @@ -1879,28 +1879,18 @@ static int rtl8221b_match_phy_device(struct phy_device *phydev,
> > return phydev->phy_id == RTL_8221B && rtlgen_supports_mmd(phydev);
> > }
> >
> > -static int rtl8221b_vb_cg_c22_match_phy_device(struct phy_device *phydev,
> > - const struct phy_driver *phydrv)
> > +static int rtl8221b_vb_cg_match_phy_device(struct phy_device *phydev,
> > + const struct phy_driver *phydrv)
> > {
> > - return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, false);
> > + return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, true) ||
> > + rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, false);
>
> Are there any calls left to rtlgen_is_c45_match() which don't || true
> and false? If not, maybe add another patch which removes the bool
> parameter?
At this point it is still used by
---
static int rtl8251b_c45_match_phy_device(struct phy_device *phydev,
const struct phy_driver *phydrv)
{
return rtlgen_is_c45_match(phydev, RTL_8251B, true);
}
---
This 5G PHY supposedly supports only C45 mode, I don't know if it
actually needs the .match_phy_device at all or could also simply use
PHY_ID_MATCH_EXACT(RTL_8251B) instead, I don't have any device using
it so I can't test that.
On 1/9/2026 2:25 PM, Daniel Golle wrote:
> On Fri, Jan 09, 2026 at 02:18:14PM +0100, Andrew Lunn wrote:
>> On Fri, Jan 09, 2026 at 03:03:33AM +0000, Daniel Golle wrote:
>>> Reunify the split C22/C45 drivers for the RTL8221B-VB-CG 2.5Gbps and
>>> RTL8221B-VM-CG 2.5Gbps PHYs back into a single driver.
>>> This is possible now by using all the driver operations previously used
>>> by the C45 driver, as transparent access to all MMDs including
>>> MDIO_MMD_VEND2 is now possible also over Clause-22 MDIO.
>>>
>>> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
>>> ---
>>> drivers/net/phy/realtek/realtek_main.c | 72 ++++++--------------------
>>> 1 file changed, 16 insertions(+), 56 deletions(-)
>>>
>>> diff --git a/drivers/net/phy/realtek/realtek_main.c b/drivers/net/phy/realtek/realtek_main.c
>>> index 886694ff995f6..d07d60bc1ce34 100644
>>> --- a/drivers/net/phy/realtek/realtek_main.c
>>> +++ b/drivers/net/phy/realtek/realtek_main.c
>>> @@ -1879,28 +1879,18 @@ static int rtl8221b_match_phy_device(struct phy_device *phydev,
>>> return phydev->phy_id == RTL_8221B && rtlgen_supports_mmd(phydev);
>>> }
>>>
>>> -static int rtl8221b_vb_cg_c22_match_phy_device(struct phy_device *phydev,
>>> - const struct phy_driver *phydrv)
>>> +static int rtl8221b_vb_cg_match_phy_device(struct phy_device *phydev,
>>> + const struct phy_driver *phydrv)
>>> {
>>> - return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, false);
>>> + return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, true) ||
>>> + rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, false);
>>
>> Are there any calls left to rtlgen_is_c45_match() which don't || true
>> and false? If not, maybe add another patch which removes the bool
>> parameter?
>
> At this point it is still used by
> ---
> static int rtl8251b_c45_match_phy_device(struct phy_device *phydev,
> const struct phy_driver *phydrv)
> {
> return rtlgen_is_c45_match(phydev, RTL_8251B, true);
> }
> ---
>
> This 5G PHY supposedly supports only C45 mode, I don't know if it
> actually needs the .match_phy_device at all or could also simply use
> PHY_ID_MATCH_EXACT(RTL_8251B) instead, I don't have any device using
> it so I can't test that.
Yes, match_phy_device is needed. This PHY ID also matches the internal PHY
of RTL8126. And RTL8126 doesn't support speaking c45 to its internal PHY.
© 2016 - 2026 Red Hat, Inc.