You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于网口链路状态,通过设备树配置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 your eth1 interface)
  • 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 the netdev trigger. The netdev trigger relies on netdev-name to 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 netdev trigger 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.org since your question involves Device Tree binding compliance.
  • Include critical details: In your email, share:
    • Your exact kernel version (uname -r output)
    • 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)
  • 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 MAINTAINERS file:
    • Jacek Anaszewski (jacek.anaszewski@gmail.com)
    • Bartlomiej Zolnierkiewicz (b.zolnierkie@samsung.com)

Avoid cross-posting to multiple lists unnecessarily—start with linux-leds since it’s the most relevant to your issue.


内容的提问来源于stack exchange,提问作者lnksz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 22:12:56