文档:
linux-imx-4.1.15\Documentation\devicetree\bindings\leds\leds-gpio.txt
。
LED
连接到 GPIO
线。
必须属性:
compatible
:必须是"gpio-leds"
。
每个 LED
表示为 gpio-leds
设备的子节点。每个节点的名称表示对应 LED
的名称。
LED
子节点属性:
gpios
:应指定LED
的GPIO
,参见Documentation/devicetree/bindings/gpio/gpio.txt
中的"gpios property"
属性。应该使用GPIO
指示符中的标志来指示活动的led
。label
(可选):看Documentation/devicetree/bindings/leds/common.txt
文档。linux,default-trigger
(可选):看Documentation/devicetree/bindings/leds/common.txt
文档。default-state
(可选):LED
的初始状态。有效值为on
、off
和keep
。如果LED
已经处于开启或关闭状态,并且默认状态属性被设置为相同的值,那么当LED
暂时关闭(或开启)时,就不会产生故障。keep
设置将使LED
保持当前状态,而不会产生故障。如果这个属性不存在,默认是关闭的。retain-state-suspended
(可选):可以保持挂起状态。
例如:
#include <dt-bindings/gpio/gpio.h>
leds {
compatible = "gpio-leds";
hdd {
label = "IDE Activity";
gpios = <&mcu_pio 0 GPIO_ACTIVE_LOW>;
linux,default-trigger = "ide-disk";
};
fault {
gpios = <&mcu_pio 1 GPIO_ACTIVE_HIGH>;
/* Keep LED on if BIOS detected hardware fault */
default-state = "keep";
};
};
run-control {
compatible = "gpio-leds";
red {
gpios = <&mpc8572 6 GPIO_ACTIVE_HIGH>;
default-state = "off";
};
green {
gpios = <&mpc8572 7 GPIO_ACTIVE_HIGH>;
default-state = "on";
};
};
leds {
compatible = "gpio-leds";
charger-led {
gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "max8903-charger-charging";
retain-state-suspended;
};
};