1 // SPDX-License-Identifier: GPL-2.0+
11 #define SANDBOX_PHY_ADDR 5
12 #define SANDBOX_PHY_REG_CNT 2
14 struct mdio_sandbox_priv {
16 u16 reg[SANDBOX_PHY_REG_CNT];
19 static int mdio_sandbox_read(struct udevice *dev, int addr, int devad, int reg)
21 struct mdio_sandbox_priv *priv = dev_get_priv(dev);
26 if (addr != SANDBOX_PHY_ADDR)
28 if (devad != MDIO_DEVAD_NONE)
30 if (reg < 0 || reg >= SANDBOX_PHY_REG_CNT)
33 return priv->reg[reg];
36 static int mdio_sandbox_write(struct udevice *dev, int addr, int devad, int reg,
39 struct mdio_sandbox_priv *priv = dev_get_priv(dev);
44 if (addr != SANDBOX_PHY_ADDR)
46 if (devad != MDIO_DEVAD_NONE)
48 if (reg < 0 || reg >= SANDBOX_PHY_REG_CNT)
56 static int mdio_sandbox_reset(struct udevice *dev)
58 struct mdio_sandbox_priv *priv = dev_get_priv(dev);
61 for (i = 0; i < SANDBOX_PHY_REG_CNT; i++)
67 static const struct mdio_ops mdio_sandbox_ops = {
68 .read = mdio_sandbox_read,
69 .write = mdio_sandbox_write,
70 .reset = mdio_sandbox_reset,
73 static int mdio_sandbox_probe(struct udevice *dev)
75 struct mdio_sandbox_priv *priv = dev_get_priv(dev);
82 static const struct udevice_id mdio_sandbox_ids[] = {
83 { .compatible = "sandbox,mdio" },
87 U_BOOT_DRIVER(mdio_sandbox) = {
88 .name = "mdio_sandbox",
90 .of_match = mdio_sandbox_ids,
91 .probe = mdio_sandbox_probe,
92 .ops = &mdio_sandbox_ops,
93 .priv_auto = sizeof(struct mdio_sandbox_priv),