diff options
Diffstat (limited to 'src/device')
-rw-r--r-- | src/device/mdio.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/device/mdio.c b/src/device/mdio.c index 9f560e6bdf..39ac40bca7 100644 --- a/src/device/mdio.c +++ b/src/device/mdio.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ +#include <assert.h> #include <console/console.h> #include <device/device.h> #include <device/mdio.h> @@ -14,3 +15,26 @@ const struct mdio_bus_operations *dev_get_mdio_ops(struct device *dev) return dev->ops->ops_mdio; } + +uint16_t mdio_read(struct device *dev, uint8_t offset) +{ + const struct mdio_bus_operations *mdio_ops; + struct device *parent = dev->bus->dev; + + assert(dev->path.type == DEVICE_PATH_MDIO); + mdio_ops = dev_get_mdio_ops(parent); + if (!mdio_ops) + return 0; + return mdio_ops->read(parent, dev->path.mdio.addr, offset); +} +void mdio_write(struct device *dev, uint8_t offset, uint16_t val) +{ + const struct mdio_bus_operations *mdio_ops; + struct device *parent = dev->bus->dev; + + assert(dev->path.type == DEVICE_PATH_MDIO); + mdio_ops = dev_get_mdio_ops(parent); + if (!mdio_ops) + return; + mdio_ops->write(parent, dev->path.mdio.addr, offset, val); +} |