[net-next PATCH v11 5/9] mfd: an8855: Add support for Airoha AN8855 Switch MFD
Vladimir Oltean
olteanv at gmail.com
Tue Dec 10 13:15:29 PST 2024
On Mon, Dec 09, 2024 at 02:44:22PM +0100, Christian Marangi wrote:
> +int an8855_mii_set_page(struct an8855_mfd_priv *priv, u8 phy_id,
> + u8 page) __must_hold(&priv->bus->mdio_lock)
> +{
> + struct mii_bus *bus = priv->bus;
> + int ret;
> +
> + ret = __mdiobus_write(bus, phy_id, AN8855_PHY_SELECT_PAGE, page);
> + if (ret < 0)
> + dev_err_ratelimited(&bus->dev,
> + "failed to set an8855 mii page\n");
> +
> + /* Cache current page if next mii read/write is for switch */
> + priv->current_page = page;
> + return ret < 0 ? ret : 0;
> +}
> +EXPORT_SYMBOL_GPL(an8855_mii_set_page);
You could keep the implementation more contained, and you could avoid
exporting an8855_mii_set_page() and an8855_mfd_priv to the MDIO
passthrough driver, if you implement a virtual regmap and give it to the
MDIO passthrough child MFD device.
If this bus supports only clause 22 accesses (and it looks like it does),
you could expose a 16-bit regmap with a linear address space of 32 MDIO
addresses x 65536 registers. The bus->read() of the MDIO bus passthrough
just performs regmap_read(), and bus->write() just performs regmap_write().
The MFD driver decodes the regmap address into a PHY address and a regnum,
and performs the page switching locally, if needed.
More information about the linux-arm-kernel
mailing list