mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-21 06:33:41 +00:00
74 lines
2.4 KiB
Diff
74 lines
2.4 KiB
Diff
|
From 4e901018432e38eab35d2a352661ce4727795be1 Mon Sep 17 00:00:00 2001
|
||
|
From: Andrew Lunn <andrew@lunn.ch>
|
||
|
Date: Mon, 17 Apr 2023 17:17:30 +0200
|
||
|
Subject: [PATCH 8/9] net: phy: phy_device: Call into the PHY driver to set LED
|
||
|
blinking
|
||
|
|
||
|
Linux LEDs can be requested to perform hardware accelerated
|
||
|
blinking. Pass this to the PHY driver, if it implements the op.
|
||
|
|
||
|
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
|
||
|
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||
|
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
|
||
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||
|
---
|
||
|
drivers/net/phy/phy_device.c | 18 ++++++++++++++++++
|
||
|
include/linux/phy.h | 12 ++++++++++++
|
||
|
2 files changed, 30 insertions(+)
|
||
|
|
||
|
--- a/drivers/net/phy/phy_device.c
|
||
|
+++ b/drivers/net/phy/phy_device.c
|
||
|
@@ -2959,6 +2959,22 @@ static int phy_led_set_brightness(struct
|
||
|
return err;
|
||
|
}
|
||
|
|
||
|
+static int phy_led_blink_set(struct led_classdev *led_cdev,
|
||
|
+ unsigned long *delay_on,
|
||
|
+ unsigned long *delay_off)
|
||
|
+{
|
||
|
+ struct phy_led *phyled = to_phy_led(led_cdev);
|
||
|
+ struct phy_device *phydev = phyled->phydev;
|
||
|
+ int err;
|
||
|
+
|
||
|
+ mutex_lock(&phydev->lock);
|
||
|
+ err = phydev->drv->led_blink_set(phydev, phyled->index,
|
||
|
+ delay_on, delay_off);
|
||
|
+ mutex_unlock(&phydev->lock);
|
||
|
+
|
||
|
+ return err;
|
||
|
+}
|
||
|
+
|
||
|
static int of_phy_led(struct phy_device *phydev,
|
||
|
struct device_node *led)
|
||
|
{
|
||
|
@@ -2981,6 +2997,8 @@ static int of_phy_led(struct phy_device
|
||
|
|
||
|
if (phydev->drv->led_brightness_set)
|
||
|
cdev->brightness_set_blocking = phy_led_set_brightness;
|
||
|
+ if (phydev->drv->led_blink_set)
|
||
|
+ cdev->blink_set = phy_led_blink_set;
|
||
|
cdev->max_brightness = 1;
|
||
|
init_data.devicename = dev_name(&phydev->mdio.dev);
|
||
|
init_data.fwnode = of_fwnode_handle(led);
|
||
|
--- a/include/linux/phy.h
|
||
|
+++ b/include/linux/phy.h
|
||
|
@@ -966,6 +966,18 @@ struct phy_driver {
|
||
|
*/
|
||
|
int (*led_brightness_set)(struct phy_device *dev,
|
||
|
u8 index, enum led_brightness value);
|
||
|
+
|
||
|
+ /**
|
||
|
+ * @led_blink_set: Set a PHY LED brightness. Index indicates
|
||
|
+ * which of the PHYs led should be configured to blink. Delays
|
||
|
+ * are in milliseconds and if both are zero then a sensible
|
||
|
+ * default should be chosen. The call should adjust the
|
||
|
+ * timings in that case and if it can't match the values
|
||
|
+ * specified exactly.
|
||
|
+ */
|
||
|
+ int (*led_blink_set)(struct phy_device *dev, u8 index,
|
||
|
+ unsigned long *delay_on,
|
||
|
+ unsigned long *delay_off);
|
||
|
};
|
||
|
#define to_phy_driver(d) container_of(to_mdio_common_driver(d), \
|
||
|
struct phy_driver, mdiodrv)
|