基于网口链路状态,通过设备树配置GPIO LED触发源的技术咨询
Answer
Yes, you absolutely can implement this functionality purely via Device Tree—no user-space scripts required. Let’s break down the correct configuration and your kernel community questions:
1. Correct Device Tree Configuration for Netdev-Triggered LED
Your initial DTS was missing critical properties that map the LED to the network device and link-state behavior. According to the Documentation/devicetree/bindings/leds/common.txt spec, for the netdev trigger, you need two key attributes in your LED node:
netdev-name: Explicitly names the network interface to monitor (matches youreth1interface)linux,netdev-link: Enables the LED to reflect link state (ON when up, OFF when down)
Here’s the revised, complete DTS node:
leds { compatible = "gpio-leds"; eth1_link { gpios = <&pioD 9 GPIO_ACTIVE_LOW>; default-state = "off"; linux,default-trigger = "netdev"; netdev-name = "eth1"; // Maps to your target network interface linux,netdev-link = <1>; // Toggles LED with link state }; };
Why your earlier attempts didn’t work:
trigger-sources = <&macb1>: This property is for other LED triggers (like PHY-integrated LED controls), not thenetdevtrigger. Thenetdevtrigger relies onnetdev-nameto bind to the network interface.- PHY handle/PHYLIB tweaks: These are unnecessary here—your LED is an external GPIO-connected device, not tied to the PHY’s internal LEDs. The
netdevtrigger operates at the network interface level, not the PHY level.
If this still fails, verify your kernel version—these DTS properties have been supported since at least Linux 4.19, but cross-check your kernel’s local common.txt documentation to confirm compatibility.
2. Kernel Community Feedback Channels
As a kernel newbie, here’s the most effective way to get targeted help:
- Primary mailing list: Send your question to
linux-leds@vger.kernel.org—this is the dedicated list for LED subsystem issues, including trigger configurations and Device Tree bindings. - Cc relevant lists: Copy
devicetree@vger.kernel.orgsince your question involves Device Tree binding compliance. - Include critical details: In your email, share:
- Your exact kernel version (
uname -routput) - Hardware platform details (SAMA5D3, MACB1 controller, KSZ8081 PHY)
- The full DTS snippet you tested
- Exact behavior you’re seeing (e.g., LED stays off regardless of link state)
- Your exact kernel version (
- Follow up if needed: If you don’t get a response after 3-5 business days, reach out directly to the LED subsystem maintainers listed in the kernel’s
MAINTAINERSfile:- Jacek Anaszewski (
jacek.anaszewski@gmail.com) - Bartlomiej Zolnierkiewicz (
b.zolnierkie@samsung.com)
- Jacek Anaszewski (
Avoid cross-posting to multiple lists unnecessarily—start with linux-leds since it’s the most relevant to your issue.
内容的提问来源于stack exchange,提问作者lnksz

