static int mdio_mux_sandbox_mark_selection(struct udevice *dev, int sel)
{
struct udevice *mdio;
- struct mdio_ops *ops;
int err;
/*
err = uclass_get_device_by_name(UCLASS_MDIO, "mdio-test", &mdio);
if (err)
return err;
- ops = mdio_get_ops(mdio);
- return ops->write(mdio, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
- SANDBOX_PHY_REG_CNT - 1, (u16)sel);
+ return dm_mdio_write(mdio, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
+ SANDBOX_PHY_REG_CNT - 1, (u16)sel);
}
static int mdio_mux_sandbox_select(struct udevice *dev, int cur, int sel)
return pdata->mdio_parent;
}
-static struct mdio_ops *mmux_get_mdio_parent_ops(struct udevice *mux)
-{
- return mdio_get_ops(mmux_get_parent_mdio(mux));
-}
-
/* call driver select function before performing MDIO r/w */
static int mmux_change_sel(struct udevice *ch, bool sel)
{
{
struct udevice *mux = ch->parent;
struct udevice *parent_mdio = mmux_get_parent_mdio(mux);
- struct mdio_ops *parent_ops = mmux_get_mdio_parent_ops(mux);
int err;
err = mmux_change_sel(ch, true);
if (err)
return err;
- err = parent_ops->read(parent_mdio, addr, devad, reg);
+ err = dm_mdio_read(parent_mdio, addr, devad, reg);
mmux_change_sel(ch, false);
return err;
{
struct udevice *mux = ch->parent;
struct udevice *parent_mdio = mmux_get_parent_mdio(mux);
- struct mdio_ops *parent_ops = mmux_get_mdio_parent_ops(mux);
int err;
err = mmux_change_sel(ch, true);
if (err)
return err;
- err = parent_ops->write(parent_mdio, addr, devad, reg, val);
+ err = dm_mdio_write(parent_mdio, addr, devad, reg, val);
mmux_change_sel(ch, false);
return err;
{
struct udevice *mux = ch->parent;
struct udevice *parent_mdio = mmux_get_parent_mdio(mux);
- struct mdio_ops *parent_ops = mmux_get_mdio_parent_ops(mux);
int err;
/* reset is optional, if it's not implemented just exit */
- if (!parent_ops->reset)
+ if (!mdio_get_ops(parent_mdio)->reset)
return 0;
err = mmux_change_sel(ch, true);
if (err)
return err;
- err = parent_ops->reset(parent_mdio);
+ err = dm_mdio_reset(parent_mdio);
mmux_change_sel(ch, false);
return err;
*/
static int mdio_read(struct mii_dev *mii_bus, int addr, int devad, int reg)
{
- struct udevice *dev = mii_bus->priv;
-
- return mdio_get_ops(dev)->read(dev, addr, devad, reg);
+ return dm_mdio_read(mii_bus->priv, addr, devad, reg);
}
static int mdio_write(struct mii_dev *mii_bus, int addr, int devad, int reg,
u16 val)
{
- struct udevice *dev = mii_bus->priv;
-
- return mdio_get_ops(dev)->write(dev, addr, devad, reg, val);
+ return dm_mdio_write(mii_bus->priv, addr, devad, reg, val);
}
static int mdio_reset(struct mii_dev *mii_bus)
{
- struct udevice *dev = mii_bus->priv;
-
- if (mdio_get_ops(dev)->reset)
- return mdio_get_ops(dev)->reset(dev);
- else
- return 0;
+ return dm_mdio_reset(mii_bus->priv);
}
static int dm_mdio_post_probe(struct udevice *dev)
static int dm_mdio_pre_remove(struct udevice *dev)
{
struct mdio_perdev_priv *pdata = dev_get_uclass_priv(dev);
- struct mdio_ops *ops = mdio_get_ops(dev);
- if (ops->reset)
- ops->reset(dev);
+ dm_mdio_reset(dev);
mdio_unregister(pdata->mii_bus);
mdio_free(pdata->mii_bus);
ut_assertnonnull(ops->read);
ut_assertnonnull(ops->write);
- ut_assertok(ops->write(dev, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
- SANDBOX_PHY_REG, TEST_REG_VALUE));
- reg = ops->read(dev, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
- SANDBOX_PHY_REG);
+ ut_assertok(dm_mdio_write(dev, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
+ SANDBOX_PHY_REG, TEST_REG_VALUE));
+ reg = dm_mdio_read(dev, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
+ SANDBOX_PHY_REG);
ut_asserteq(reg, TEST_REG_VALUE);
- ut_assert(ops->read(dev, SANDBOX_PHY_ADDR + 1, MDIO_DEVAD_NONE,
- SANDBOX_PHY_REG) != 0);
+ ut_assert(dm_mdio_read(dev, SANDBOX_PHY_ADDR + 1, MDIO_DEVAD_NONE,
+ SANDBOX_PHY_REG) != 0);
- ut_assertok(ops->reset(dev));
- reg = ops->read(dev, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
- SANDBOX_PHY_REG);
+ ut_assertok(dm_mdio_reset(dev));
+ reg = dm_mdio_read(dev, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
+ SANDBOX_PHY_REG);
ut_asserteq(reg, 0);
return 0;
* is selected to the selection #. Just reading that register from
* either of the child buses should return the id of the child bus
*/
- reg = ops->read(mdio_ch0, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
- SANDBOX_PHY_REG_CNT - 1);
+ reg = dm_mdio_read(mdio_ch0, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
+ SANDBOX_PHY_REG_CNT - 1);
ut_asserteq(reg, 0);
- reg = ops->read(mdio_ch1, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
- SANDBOX_PHY_REG_CNT - 1);
+ reg = dm_mdio_read(mdio_ch1, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
+ SANDBOX_PHY_REG_CNT - 1);
ut_asserteq(reg, 1);
mmops->select(mux, MDIO_MUX_SELECT_NONE, 5);
- reg = ops_parent->read(mdio, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
- SANDBOX_PHY_REG_CNT - 1);
+ reg = dm_mdio_read(mdio, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
+ SANDBOX_PHY_REG_CNT - 1);
ut_asserteq(reg, 5);
mmops->deselect(mux, 5);
- reg = ops_parent->read(mdio, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
- SANDBOX_PHY_REG_CNT - 1);
+ reg = dm_mdio_read(mdio, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
+ SANDBOX_PHY_REG_CNT - 1);
ut_asserteq(reg, (u16)MDIO_MUX_SELECT_NONE);
return 0;