r8169: add support for LED's on RTL8168/RTL8101
Heiner Kallweit
maintainerPATCH 1/1 r8169: add support for LED's on RTL8168/RTL8101
This adds support for the LED's on most chip versions. Excluded are the old non-PCIe versions and RTL8125. RTL8125 has a different LED register layout, support for it will follow later.
LED's can be controlled from userspace using the netdev LED trigger.
Tested on RTL8168h.
Note: The driver can't know which LED's are actually physically wired. Therefore not every LED device may represent a physically available LED.
--- drivers/net/ethernet/realtek/Makefile | 3 + drivers/net/ethernet/realtek/r8169.h | 7 + drivers/net/ethernet/realtek/r8169_leds.c | 156 ++++++++++++++++++++++ drivers/net/ethernet/realtek/r8169_main.c | 51 +++++++ 4 files changed, 217 insertions(+) create mode 100644 drivers/net/ethernet/realtek/r8169_leds.c
drivers/net/ethernet/realtek/Makefile +3 -0
@@ -7,4 +7,7 @@ obj-$(CONFIG_8139CP) += 8139cp.o obj-$(CONFIG_8139TOO) += 8139too.o obj-$(CONFIG_ATP) += atp.o r8169-objs += r8169_main.o r8169_firmware.o r8169_phy_config.o +ifdef CONFIG_LEDS_TRIGGER_NETDEV +r8169-objs += r8169_leds.o +endif obj-$(CONFIG_R8169) += r8169.o
drivers/net/ethernet/realtek/r8169.h +7 -0
@@ -8,6 +8,7 @@* See MAINTAINERS file for support contact information. */ +#include <linux/netdevice.h> #include <linux/types.h> #include <linux/phy.h>
@@ -77,3 +78,9 @@ u16 rtl8168h_2_get_adc_bias_ioffset(struct rtl8169_private *tp);u8 rtl8168d_efuse_read (struct rtl8169_private *tp,int reg_addr);void r8169_hw_phy_config (struct rtl8169_private *tp,struct phy_device *phydev,enum mac_version ver); + +void r8169_get_led_name (struct rtl8169_private *tp,int idx, +char *buf,int buf_len); +int rtl8168_get_led_mode (struct rtl8169_private *tp); +int rtl8168_led_mod_ctrl (struct rtl8169_private *tp,u16 mask,u16 val); +void rtl8168_init_leds (struct net_device *ndev);
drivers/net/ethernet/realtek/r8169_leds.c new file +156 -0
156 lines not on this page · raw message
drivers/net/ethernet/realtek/r8169_main.c +51 -0
81 lines not on this page · raw message
Signature · 1 line
2.43.0
Heiner Kallweit
maintainerQuoted 6 lines · Heiner Kallweit
This adds support for the LED's on most chip versions. Excluded are the old non-PCIe versions and RTL8125. RTL8125 has a different LED register layout, support for it will follow later.
LED's can be controlled from userspace using the netdev LED trigger.
Quoted 8 lines
Tested on RTL8168h.
Note: The driver can't know which LED's are actually physically wired. Therefore not every LED device may represent a physically available LED.
Signed-off-by Heiner Kallweit <[email protected]>---
Will send a v2, setting default_trigger is missing.
Quoted 5 lines · Heiner Kallweit
This adds support for the LED's on most chip versions. Excluded are the old non-PCIe versions and RTL8125. RTL8125 has a different LED register layout, support for it will follow later.
LED's can be controlled from userspace using the netdev LED trigger.
Since you cannot implement set_brightness, the hardware only supports offload, it probably makes sense to add Kconfig to enable the building of the netdev LED trigger. It seems pointless just having plain LEDs which can then usable.
Andrew
Heiner Kallweit
maintainerQuoted 5 lines · Andrew Lunn
Quoted 4 lines · Heiner Kallweit
This adds support for the LED's on most chip versions. Excluded are the old non-PCIe versions and RTL8125. RTL8125 has a different LED register layout, support for it will follow later.
Quoted 7 lines
Quoted 1 line
LED's can be controlled from userspace using the netdev LED trigger.
Since you cannot implement
set_brightness, the hardware only supports offload, it probably makes sense to addKconfigto enable the building of the netdev LED trigger. It seems pointless just having plain LEDs which can then usable.
Right, therefore I create the LED devices only ifCONFIG_LEDS_TRIGGER_NETDEV is enabled:
#if IS_REACHABLE(CONFIG_LEDS_CLASS) && IS_ENABLED(CONFIG_LEDS_TRIGGER_NETDEV) [..] rtl8168_init_leds(dev);
#endif
Is this what you're referring to?
Using Kconfig select maybe problematic because it doesn't consider dependencies. So we may have to use:
imply LEDS_TRIGGER_NETDEV
imply LEDS_TRIGGERS
Quoted 1 line
Andrew
Heiner
Quoted 16 lines · Heiner Kallweit
Quoted 5 lines · Andrew Lunn
Quoted 4 lines · Heiner Kallweit
This adds support for the LED's on most chip versions. Excluded are the old non-PCIe versions and RTL8125. RTL8125 has a different LED register layout, support for it will follow later.
Quoted 7 lines
Quoted 1 line
LED's can be controlled from userspace using the netdev LED trigger.
Since you cannot implement
set_brightness, the hardware only supports offload, it probably makes sense to addKconfigto enable the building of the netdev LED trigger. It seems pointless just having plain LEDs which can then usable.Right, therefore I create the LED devices only if
CONFIG_LEDS_TRIGGER_NETDEVis enabled:
Quoted 6 lines
#if IS_REACHABLE(CONFIG_LEDS_CLASS) && IS_ENABLED(CONFIG_LEDS_TRIGGER_NETDEV) [..] rtl8168_init_leds(dev);#endif
Is this what you're referring to?
No, but that is a good alternative. I'm happy with this.
Andrew