summaryrefslogtreecommitdiff
path: root/src/device
diff options
context:
space:
mode:
authorMario Scheithauer <mario.scheithauer@siemens.com>2022-11-02 15:57:10 +0100
committerMartin L Roth <gaumless@gmail.com>2022-11-24 05:53:55 +0000
commit67f63e768d8860ebc6bae5987e2d928efabcf7c4 (patch)
tree79b4434bbc318750dc4e3ba45436277aefb27c27 /src/device
parent66e44e325278f8a4b4227eb7d1c5d6c56e1686cd (diff)
src/device + util/sconfig: Introduce new device 'mdio'
This patch extends the available device paths with a new device 'mdio'. MDIO is the 'Management Data Input/Output' called interface which is used to access an Ethernet PHY behind a MAC to change settings. The real payload data path is not handled by this interface. To address the PHY correctly on the MDIO bus, there is a 5 bit address needed, which often can be configured via pins on the mainboard. Therefore, the new introduced device has an 'addr' field to define its address. If one wants to use a MDIO device in devicetree, the syntax is straight forward (example): device mdio 0x2 on end As the MDIO interface is driven by the MAC, most likely this MDIO device will be hooked in as a child device of the (PCI attached) MAC device. With the new introduced ops_mdio a new interface is added to provide an API for read and write access over MDIO. Change-Id: I6691f92c4233bc30afc9029840b06f74bb1eb4b2 Signed-off-by: Mario Scheithauer <mario.scheithauer@siemens.com> Signed-off-by: Werner Zeh <werner.zeh@siemens.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/69382 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Arthur Heymans <arthur@aheymans.xyz> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/device')
-rw-r--r--src/device/Makefile.inc1
-rw-r--r--src/device/device_const.c4
-rw-r--r--src/device/device_util.c6
-rw-r--r--src/device/mdio.c16
4 files changed, 27 insertions, 0 deletions
diff --git a/src/device/Makefile.inc b/src/device/Makefile.inc
index 28acd73879..3018ef9626 100644
--- a/src/device/Makefile.inc
+++ b/src/device/Makefile.inc
@@ -64,3 +64,4 @@ ramstage-y += resource_allocator_v4.c
ramstage-$(CONFIG_XHCI_UTILS) += xhci.c
ramstage-y += gpio.c
+ramstage-y += mdio.c
diff --git a/src/device/device_const.c b/src/device/device_const.c
index a40d0b05b9..a63a629344 100644
--- a/src/device/device_const.c
+++ b/src/device/device_const.c
@@ -147,6 +147,10 @@ static int path_eq(const struct device_path *path1,
case DEVICE_PATH_GPIO:
equal = (path1->gpio.id == path2->gpio.id);
break;
+ case DEVICE_PATH_MDIO:
+ equal = (path1->mdio.addr == path2->mdio.addr);
+ break;
+
default:
printk(BIOS_ERR, "Unknown device type: %d\n", path1->type);
break;
diff --git a/src/device/device_util.c b/src/device/device_util.c
index 9beb2ce8e2..c5e03f2079 100644
--- a/src/device/device_util.c
+++ b/src/device/device_util.c
@@ -135,6 +135,9 @@ u32 dev_path_encode(const struct device *dev)
case DEVICE_PATH_GPIO:
ret |= dev->path.gpio.id;
break;
+ case DEVICE_PATH_MDIO:
+ ret |= dev->path.mdio.addr;
+ break;
case DEVICE_PATH_NONE:
case DEVICE_PATH_MMIO: /* don't care */
default:
@@ -223,6 +226,9 @@ const char *dev_path(const struct device *dev)
case DEVICE_PATH_GPIO:
snprintf(buffer, sizeof(buffer), "GPIO: %d", dev->path.gpio.id);
break;
+ case DEVICE_PATH_MDIO:
+ snprintf(buffer, sizeof(buffer), "MDIO: %02x", dev->path.mdio.addr);
+ break;
default:
printk(BIOS_ERR, "Unknown device path type: %d\n",
dev->path.type);
diff --git a/src/device/mdio.c b/src/device/mdio.c
new file mode 100644
index 0000000000..9f560e6bdf
--- /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_bus_operations *dev_get_mdio_ops(struct device *dev)
+{
+ if (!dev || !dev->ops || !dev->ops->ops_mdio) {
+ printk(BIOS_ERR, "Could not get MDIO operations.\n");
+ return NULL;
+ }
+
+ return dev->ops->ops_mdio;
+}