Re: [PATCH 10/14] drivers: net: dsa: qca8k: add support for specific QCA access function

Andrew Lunn
2021-04-23T12:47:11Z

> +static inline void qca8k_phy_mmd_prep(struct mii_bus *bus, int phy_addr, u16 addr, u16 reg)
> +{
> + bus->write(bus, phy_addr, MII_ATH_MMD_ADDR, addr);
> + bus->write(bus, phy_addr, MII_ATH_MMD_DATA, reg);
> + bus->write(bus, phy_addr, MII_ATH_MMD_ADDR, addr | 0x4000);
> +}
> +
> +void qca8k_phy_mmd_write(struct qca8k_priv *priv, int phy_addr, u16 addr, u16 reg, u16 data)
> +{
> + struct mii_bus *bus = priv->bus;
> +
> + mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
> + qca8k_phy_mmd_prep(bus, phy_addr, addr, reg);
> + bus->write(bus, phy_addr, MII_ATH_MMD_DATA, data);
> + mutex_unlock(&bus->mdio_lock);
> +}
> +
> +u16 qca8k_phy_mmd_read(struct qca8k_priv *priv, int phy_addr, u16 addr, u16 reg)
> +{
> + struct mii_bus *bus = priv->bus;
> + u16 data;
> +
> + mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
> + qca8k_phy_mmd_prep(bus, phy_addr, addr, reg);
> + data = bus->read(bus, phy_addr, MII_ATH_MMD_DATA);
> + mutex_unlock(&bus->mdio_lock);
> +
> + return data;
> +}

Can you use the PHY core MMD access functions?

Andrew