Mario Scheithauer has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/69382 )
Change subject: src/device: Add MDIO operation ......................................................................
src/device: Add MDIO operation
The interface is necessary for SOC specific MDIO access.
Change-Id: I6691f92c4233bc30afc9029840b06f74bb1eb4b2 Signed-off-by: Mario Scheithauer mario.scheithauer@siemens.com --- M src/device/Makefile.inc A src/device/mdio.c M src/include/device/device.h A src/include/device/mdio.h 4 files changed, 46 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/82/69382/1
diff --git a/src/device/Makefile.inc b/src/device/Makefile.inc index 28acd73..3018ef9 100644 --- a/src/device/Makefile.inc +++ b/src/device/Makefile.inc @@ -64,3 +64,4 @@ ramstage-$(CONFIG_XHCI_UTILS) += xhci.c
ramstage-y += gpio.c +ramstage-y += mdio.c diff --git a/src/device/mdio.c b/src/device/mdio.c new file mode 100644 index 0000000..9b2e921 --- /dev/null +++ b/src/device/mdio.c @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <console/console.h> +#include <device/device.h> +#include <device/mdio.h> +#include <stddef.h> + +const struct mdio_operations *dev_get_mdio_ops(struct device *dev) +{ + if (!dev || !dev->ops || !dev->ops->ops_mdio) { + printk(BIOS_ERR, "Could not get mdio operations."); + return NULL; + } + + return dev->ops->ops_mdio; +} diff --git a/src/include/device/device.h b/src/include/device/device.h index 0f9c39f..3a89663 100644 --- a/src/include/device/device.h +++ b/src/include/device/device.h @@ -20,6 +20,7 @@ struct spi_bus_operations; struct usb_bus_operations; struct gpio_operations; +struct mdio_operations;
/* Chip operations */ struct chip_operations { @@ -67,6 +68,7 @@ const struct smbus_bus_operations *ops_smbus_bus; const struct pnp_mode_ops *ops_pnp_mode; const struct gpio_operations *ops_gpio; + const struct mdio_operations *ops_mdio; };
/** diff --git a/src/include/device/mdio.h b/src/include/device/mdio.h new file mode 100644 index 0000000..1688206 --- /dev/null +++ b/src/include/device/mdio.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __DEVICE_MDIO_H__ +#define __DEVICE_MDIO_H__ + +struct device; +struct mdio_operations { + uint16_t (*read)(struct device *dev, uint8_t phy_adr, uint8_t reg_adr); + void (*write)(struct device *dev, uint8_t phy_adr, uint8_t reg_adr, uint16_t data); +}; + +/* Helper for getting mdio operations from a device */ +const struct mdio_operations *dev_get_mdio_ops(struct device *dev); + +#endif /* __DEVICE_MDIO_H__ */