summaryrefslogtreecommitdiff
path: root/src/drivers/net/phy/m88e1512
diff options
context:
space:
mode:
authorMario Scheithauer <mario.scheithauer@siemens.com>2022-11-08 13:50:06 +0100
committerMartin L Roth <gaumless@gmail.com>2022-11-24 05:59:31 +0000
commit1a97c89d7b22a92992131032b0cd587de9f33d64 (patch)
tree205cb520f8251a1c7e65193e15462fbac56f207d /src/drivers/net/phy/m88e1512
parent49ec39fa7f05c4a3d320b5a60593108e1affb19f (diff)
drivers/net/phy/m88e1512: Provide functionality to customize LED status
For Marvel PHY it could be necessary to customize the shown LED status at the connector. The LED status can be changed via Function Control Register on page 3. Link to the Marvell PHY 88E1512 datasheet: https://web.archive.org/web/20221109080111/https://www.marvell.com/content/dam/marvell/en/public-collateral/phys-transceivers/marvell-phys-transceivers-alaska-88e151x-datasheet.pdf Change-Id: Ia71c43f4286f9201f03cb759252ebb405ab81904 Signed-off-by: Mario Scheithauer <mario.scheithauer@siemens.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/69386 Reviewed-by: Arthur Heymans <arthur@aheymans.xyz> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/drivers/net/phy/m88e1512')
-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_ */