1 // SPDX-License-Identifier: GPL-2.0+
11 /* macros copied over from mdio_sandbox.c */
12 #define SANDBOX_PHY_ADDR 5
13 #define SANDBOX_PHY_REG_CNT 2
15 struct mdio_mux_sandbox_priv {
20 static int mdio_mux_sandbox_mark_selection(struct udevice *dev, int sel)
27 * find the sandbox parent mdio and write a register on the PHY there
28 * so the mux test can verify selection.
30 err = uclass_get_device_by_name(UCLASS_MDIO, "mdio-test", &mdio);
33 ops = mdio_get_ops(mdio);
34 return ops->write(mdio, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
35 SANDBOX_PHY_REG_CNT - 1, (u16)sel);
38 static int mdio_mux_sandbox_select(struct udevice *dev, int cur, int sel)
40 struct mdio_mux_sandbox_priv *priv = dev_get_priv(dev);
49 mdio_mux_sandbox_mark_selection(dev, priv->sel);
54 static int mdio_mux_sandbox_deselect(struct udevice *dev, int sel)
56 struct mdio_mux_sandbox_priv *priv = dev_get_priv(dev);
65 mdio_mux_sandbox_mark_selection(dev, priv->sel);
70 static const struct mdio_mux_ops mdio_mux_sandbox_ops = {
71 .select = mdio_mux_sandbox_select,
72 .deselect = mdio_mux_sandbox_deselect,
75 static int mdio_mux_sandbox_probe(struct udevice *dev)
77 struct mdio_mux_sandbox_priv *priv = dev_get_priv(dev);
85 static const struct udevice_id mdio_mux_sandbox_ids[] = {
86 { .compatible = "sandbox,mdio-mux" },
90 U_BOOT_DRIVER(mdio_mux_sandbox) = {
91 .name = "mdio_mux_sandbox",
92 .id = UCLASS_MDIO_MUX,
93 .of_match = mdio_mux_sandbox_ids,
94 .probe = mdio_mux_sandbox_probe,
95 .ops = &mdio_mux_sandbox_ops,
96 .priv_auto = sizeof(struct mdio_mux_sandbox_priv),