[PATCH 3/6] net: mdio-mux: Add MDIO mux driver for NSP SoC

Andrew Lunn andrew at lunn.ch
Wed Nov 9 06:45:15 PST 2016


> +#define NSP_MDIO_EXT_BUS_START_ADDR		16
> +#define NSP_MDIO_EXT_SELECT_BIT			BIT(9)
> +
> +static int mdio_mux_nsp_switch_fn(int current_child, int desired_child,
> +				  void *priv)
> +{
> +	struct nsp_mdiomux_desc *md = priv;
> +	u32 data, bus_id;
> +
> +	/* select internal or external bus */
> +	data = readl(md->mgmt_ctrl);
> +	if (desired_child == NSP_MDIO_EXT_BUS_START_ADDR)
> +		data |= NSP_MDIO_EXT_SELECT_BIT;
> +	else
> +		data &= ~NSP_MDIO_EXT_SELECT_BIT;
> +	writel(data, md->mgmt_ctrl);
> +
> +	/* select bus number */
> +	if (md->bus_ctrl) {
> +		bus_id = desired_child & (NSP_MDIO_EXT_BUS_START_ADDR - 1);
> +		writel(bus_id, md->bus_ctrl);
> +	}
> +
> +	return 0;

So address 16 is external. What happens which you try to access
address 16 internally? Does the chip raise an abort? Reads just give
0xffff?

I'm wondering if it would be better to implement this as two nested
muxes. One mux doing internal/external, and the other doing the bus.
If you do that, you can use the existing mdio-mux-mmioreg.c and don't
need any new code at all.

     Andrew



More information about the linux-arm-kernel mailing list