From 351bfa6ebdcc454441b32976e895002a5b0523b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Beh=C3=BAn?= Date: Thu, 7 Apr 2022 00:32:58 +0200 Subject: net: mdio-uclass: add wrappers for read/write/reset operations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add wrappers dm_mdio_read(), dm_mdio_write() and dm_mdio_reset() for DM MDIO's .read(), .write() and .reset() operations. Signed-off-by: Marek BehĂșn Reviewed-by: Ramon Fried Reviewed-by: Vladimir Oltean --- net/mdio-uclass.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'net/mdio-uclass.c') diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c index 233b70171b5..887c2281674 100644 --- a/net/mdio-uclass.c +++ b/net/mdio-uclass.c @@ -57,6 +57,37 @@ static int dm_mdio_post_bind(struct udevice *dev) return 0; } +int dm_mdio_read(struct udevice *mdio_dev, int addr, int devad, int reg) +{ + struct mdio_ops *ops = mdio_get_ops(mdio_dev); + + if (!ops->read) + return -ENOSYS; + + return ops->read(mdio_dev, addr, devad, reg); +} + +int dm_mdio_write(struct udevice *mdio_dev, int addr, int devad, int reg, + u16 val) +{ + struct mdio_ops *ops = mdio_get_ops(mdio_dev); + + if (!ops->write) + return -ENOSYS; + + return ops->write(mdio_dev, addr, devad, reg, val); +} + +int dm_mdio_reset(struct udevice *mdio_dev) +{ + struct mdio_ops *ops = mdio_get_ops(mdio_dev); + + if (!ops->reset) + return 0; + + return ops->reset(mdio_dev); +} + /* * Following read/write/reset functions are registered with legacy MII code. * These are called for PHY operations by upper layers and we further call the -- cgit v1.2.3