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)
26 * find the sandbox parent mdio and write a register on the PHY there
27 * so the mux test can verify selection.
29 err = uclass_get_device_by_name(UCLASS_MDIO, "mdio-test", &mdio);
32 return dm_mdio_write(mdio, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
33 SANDBOX_PHY_REG_CNT - 1, (u16)sel);
36 static int mdio_mux_sandbox_select(struct udevice *dev, int cur, int sel)
38 struct mdio_mux_sandbox_priv *priv = dev_get_priv(dev);
47 mdio_mux_sandbox_mark_selection(dev, priv->sel);
52 static int mdio_mux_sandbox_deselect(struct udevice *dev, int sel)
54 struct mdio_mux_sandbox_priv *priv = dev_get_priv(dev);
63 mdio_mux_sandbox_mark_selection(dev, priv->sel);
68 static const struct mdio_mux_ops mdio_mux_sandbox_ops = {
69 .select = mdio_mux_sandbox_select,
70 .deselect = mdio_mux_sandbox_deselect,
73 static int mdio_mux_sandbox_probe(struct udevice *dev)
75 struct mdio_mux_sandbox_priv *priv = dev_get_priv(dev);
83 static const struct udevice_id mdio_mux_sandbox_ids[] = {
84 { .compatible = "sandbox,mdio-mux" },
88 U_BOOT_DRIVER(mdio_mux_sandbox) = {
89 .name = "mdio_mux_sandbox",
90 .id = UCLASS_MDIO_MUX,
91 .of_match = mdio_mux_sandbox_ids,
92 .probe = mdio_mux_sandbox_probe,
93 .ops = &mdio_mux_sandbox_ops,
94 .priv_auto = sizeof(struct mdio_mux_sandbox_priv),