Re: [net-next PATCH v11 5/9] mfd: an8855: Add support for Airoha AN8855 Switch MFD

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux