Re: [PATCH] net: phy: marvell-88q2xxx: add support for Rev B1 and B2
From: Russell King (Oracle)
Date: Wed Apr 03 2024 - 10:00:08 EST
On Wed, Apr 03, 2024 at 03:45:22PM +0200, Gregor Herburger wrote:
> +static int mv88q222x_revb1_revb2_config_init(struct phy_device *phydev)
> +{
> + bool is_rev_b2 = phydev->c45_ids.device_ids[MDIO_MMD_PMAPMD] == PHY_ID_88Q2220_REVB2;
> + int ret, i;
> +
> + for (i = 0; i < ARRAY_SIZE(mv88q222x_revb1_init_seq0); i++) {
> + /* Rev B2 init sequence differs compared to Rev B1. As noted in Marvell API:
> + * Remove the instruction to enable TXDAC setting overwrite bit for Rev B2.
> + */
> + if (is_rev_b2 && mv88q222x_revb1_init_seq1[i].regnum == 0xffe3)
> + continue;
> +
> + ret = phy_write_mmd(phydev, mv88q222x_revb1_init_seq0[i].devad,
> + mv88q222x_revb1_init_seq0[i].regnum,
> + mv88q222x_revb1_init_seq0[i].val);
> + if (ret < 0)
> + return ret;
> + }
> +
> + usleep_range(3000, 5000);
> +
> + for (i = 0; i < ARRAY_SIZE(mv88q222x_revb1_init_seq1); i++) {
> + ret = phy_write_mmd(phydev, mv88q222x_revb1_init_seq1[i].devad,
> + mv88q222x_revb1_init_seq1[i].regnum,
> + mv88q222x_revb1_init_seq1[i].val);
> + if (ret < 0)
> + return ret;
> + }
I think a helper would be useful to write these sequences, rather than
writing the same code several times:
static int mv88q2xxx_write_mmd_vals(struct phy_device *phydev,
const struct mmd_val *vals, size_t len)
{
int ret;
for (; len; vals++, len--) {
ret = phy_write_mmd(phydev, vals->devad, vals->regnum,
vals->val);
if (ret < 0)
return ret;
}
return 0;
}
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!