mirror of
https://git.openwrt.org/openwrt/openwrt.git
synced 2024-11-24 14:06:15 +00:00
5fd518b6e3
Add driver support for PHY LEDs for MaxLinear/Intel GPY Ethernet PHYs. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
75 lines
2.1 KiB
Diff
75 lines
2.1 KiB
Diff
From 94b90966095f3fa625897e8f53d215882f6e19b3 Mon Sep 17 00:00:00 2001
|
|
From: David Bauer <mail@david-bauer.net>
|
|
Date: Sat, 11 Mar 2023 17:00:01 +0100
|
|
Subject: [PATCH] mxl-gpy: control LED reg from DT
|
|
|
|
Add dynamic configuration for the LED control registers on MXL PHYs.
|
|
|
|
This patch has been tested with MaxLinear GPY211C. It is unlikely to be
|
|
accepted upstream, as upstream plans on integrating their own framework
|
|
for handling these LEDs.
|
|
|
|
For the time being, use this hack to configure PHY driven device-LEDs to
|
|
show the correct state.
|
|
|
|
A possible alternative might be to expose the LEDs using the kernel LED
|
|
framework and bind it to the netdevice. This might also be upstreamable,
|
|
although it is a considerable extra amount of work.
|
|
|
|
Signed-off-by: David Bauer <mail@david-bauer.net>
|
|
---
|
|
drivers/net/phy/mxl-gpy.c | 37 ++++++++++++++++++++++++++++++++++++-
|
|
1 file changed, 36 insertions(+), 1 deletion(-)
|
|
|
|
--- a/drivers/net/phy/mxl-gpy.c
|
|
+++ b/drivers/net/phy/mxl-gpy.c
|
|
@@ -10,6 +10,7 @@
|
|
#include <linux/bitfield.h>
|
|
#include <linux/hwmon.h>
|
|
#include <linux/mutex.h>
|
|
+#include <linux/of.h>
|
|
#include <linux/phy.h>
|
|
#include <linux/polynomial.h>
|
|
#include <linux/property.h>
|
|
@@ -293,10 +294,39 @@ out:
|
|
return ret;
|
|
}
|
|
|
|
+static int gpy_led_write(struct phy_device *phydev)
|
|
+{
|
|
+ struct device_node *node = phydev->mdio.dev.of_node;
|
|
+ u32 led_regs[GPY_MAX_LEDS];
|
|
+ int i, ret;
|
|
+ u16 val = 0xff00;
|
|
+
|
|
+ if (!IS_ENABLED(CONFIG_OF_MDIO))
|
|
+ return 0;
|
|
+
|
|
+ if (of_property_read_u32_array(node, "mxl,led-config", led_regs, GPY_MAX_LEDS))
|
|
+ return 0;
|
|
+
|
|
+ if (of_property_read_bool(node, "mxl,led-drive-vdd"))
|
|
+ val &= 0x0fff;
|
|
+
|
|
+ /* Enable LED function handling on all ports*/
|
|
+ phy_write(phydev, PHY_LED, val);
|
|
+
|
|
+ /* Write LED register values */
|
|
+ for (i = 0; i < GPY_MAX_LEDS; i++) {
|
|
+ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, VSPEC1_LED(i), (u16)led_regs[i]);
|
|
+ if (ret < 0)
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
static int gpy_config_init(struct phy_device *phydev)
|
|
{
|
|
/* Nothing to configure. Configuration Requirement Placeholder */
|
|
- return 0;
|
|
+ return gpy_led_write(phydev);
|
|
}
|
|
|
|
static int gpy_probe(struct phy_device *phydev)
|