/* * MDIO multiplexing switch function * * This function is called by the mdio-mux layer when it thinks the mdio bus * multiplexer needs to switch. * * 'current_child' is the current value of the mux register (masked via * s->mask). * * 'desired_child' is the value of the 'reg' property of the target child MDIO * node. * * The first time this function is called, current_child == -1. * * If current_child == desired_child, then the mux is already set to the * correct bus.
*/ staticint mdio_mux_mmioreg_switch_fn(int current_child, int desired_child, void *data)
{ struct mdio_mux_mmioreg_state *s = data;
if (current_child ^ desired_child) { void __iomem *p = ioremap(s->phys, s->iosize); if (!p) return -ENOMEM;
iprop = of_get_property(np, "mux-mask", &len); if (!iprop || len != sizeof(uint32_t)) return dev_err_probe(&pdev->dev, -ENODEV, "missing or invalid mux-mask property\n"); if (be32_to_cpup(iprop) >= BIT(s->iosize * 8)) return dev_err_probe(&pdev->dev, -EINVAL, "only 8/16/32-bit registers are supported\n");
s->mask = be32_to_cpup(iprop);
/* * Verify that the 'reg' property of each child MDIO bus does not * set any bits outside of the 'mask'.
*/
for_each_available_child_of_node_scoped(np, np2) {
u64 reg;
if (of_property_read_reg(np2, 0, ®, NULL)) return dev_err_probe(&pdev->dev, -ENODEV, "mdio-mux child node %pOF is missing a 'reg' property\n",
np2); if ((u32)reg & ~s->mask) return dev_err_probe(&pdev->dev, -ENODEV, "mdio-mux child node %pOF has a 'reg' value with unmasked bits\n",
np2);
}
ret = mdio_mux_init(&pdev->dev, pdev->dev.of_node,
mdio_mux_mmioreg_switch_fn,
&s->mux_handle, s, NULL); if (ret) return dev_err_probe(&pdev->dev, ret, "failed to register mdio-mux bus %pOF\n", np);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.