mb/google/brya/var/orisa: Update Type C DisplayPort HPD Configuration
[coreboot2.git] / src / device / mdio.c
blob89da60bd6f593d14d67d0019d50fbab28dfae0e8
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <assert.h>
4 #include <console/console.h>
5 #include <device/device.h>
6 #include <device/mdio.h>
7 #include <stddef.h>
9 const struct mdio_bus_operations *dev_get_mdio_ops(struct device *dev)
11 if (!dev || !dev->ops || !dev->ops->ops_mdio) {
12 printk(BIOS_ERR, "Could not get MDIO operations.\n");
13 return NULL;
16 return dev->ops->ops_mdio;
19 uint16_t mdio_read(struct device *dev, uint8_t offset)
21 const struct mdio_bus_operations *mdio_ops;
22 struct device *parent = dev->upstream->dev;
24 assert(dev->path.type == DEVICE_PATH_MDIO);
25 mdio_ops = dev_get_mdio_ops(parent);
26 if (!mdio_ops)
27 return 0;
28 return mdio_ops->read(parent, dev->path.mdio.addr, offset);
30 void mdio_write(struct device *dev, uint8_t offset, uint16_t val)
32 const struct mdio_bus_operations *mdio_ops;
33 struct device *parent = dev->upstream->dev;
35 assert(dev->path.type == DEVICE_PATH_MDIO);
36 mdio_ops = dev_get_mdio_ops(parent);
37 if (!mdio_ops)
38 return;
39 mdio_ops->write(parent, dev->path.mdio.addr, offset, val);