summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/drivers/net/phy/m88e1512/chip.h10
-rw-r--r--src/drivers/net/phy/m88e1512/m88e1512.c30
-rw-r--r--src/drivers/net/phy/m88e1512/m88e1512.h11
3 files changed, 51 insertions, 0 deletions
diff --git a/src/drivers/net/phy/m88e1512/chip.h b/src/drivers/net/phy/m88e1512/chip.h
new file mode 100644
index 0000000000..36a46e93c9
--- /dev/null
+++ b/src/drivers/net/phy/m88e1512/chip.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include "m88e1512.h"
+
+struct drivers_net_phy_m88e1512_config {
+ bool configure_leds; /* Enable LED customization */
+ unsigned char led_0_ctrl; /* LED[0] Control */
+ unsigned char led_1_ctrl; /* LED[1] Control */
+ unsigned char led_2_ctrl; /* LED[2] Control */
+};
diff --git a/src/drivers/net/phy/m88e1512/m88e1512.c b/src/drivers/net/phy/m88e1512/m88e1512.c
index 3f45a10dae..d0883bf9d6 100644
--- a/src/drivers/net/phy/m88e1512/m88e1512.c
+++ b/src/drivers/net/phy/m88e1512/m88e1512.c
@@ -1,9 +1,39 @@
/* SPDX-License-Identifier: GPL-2.0-only */
+#include <console/console.h>
#include <device/device.h>
+#include <device/mdio.h>
+#include <device/pci.h>
+#include "chip.h"
+#include "m88e1512.h"
+
+static void switch_page(struct device *dev, uint8_t page)
+{
+ mdio_write(dev, PAGE_REG, page);
+}
static void m88e1512_init(struct device *dev)
{
+ struct drivers_net_phy_m88e1512_config *config = dev->chip_info;
+ uint16_t reg;
+
+ /* Configure LEDs if requested. */
+ if (config->configure_leds) {
+ printk(BIOS_DEBUG, "%s: Set a customized LED mode for %s.\n",
+ dev_path(dev->bus->dev), dev->chip_ops->name);
+
+ /* Select page 3 to access LED function control register. */
+ switch_page(dev, 3);
+
+ /* Modify PHY LED mode. */
+ reg = mdio_read(dev, LED_FUNC_CTRL_REG);
+ clrsetbits16(&reg, LED_FUNC_CTRL_MASK, config->led_0_ctrl |
+ (config->led_1_ctrl << 4) | (config->led_2_ctrl << 8));
+ mdio_write(dev, LED_FUNC_CTRL_REG, reg);
+
+ /* Switch back to page 0. */
+ switch_page(dev, 0);
+ }
}
struct device_operations m88e1512_ops = {
diff --git a/src/drivers/net/phy/m88e1512/m88e1512.h b/src/drivers/net/phy/m88e1512/m88e1512.h
new file mode 100644
index 0000000000..36e3279689
--- /dev/null
+++ b/src/drivers/net/phy/m88e1512/m88e1512.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _PHY_M88E1512_H_
+#define _PHY_M88E1512_H_
+
+/* Register layout */
+#define PAGE_REG 0x16
+#define LED_FUNC_CTRL_REG 0x10
+#define LED_FUNC_CTRL_MASK 0x0FFF
+
+#endif /* _PHY_M88E1512_H_ */