Linux 驱动开发 五十八:《leds-gpio.txt》翻译

文档:linux-imx-4.1.15\Documentation\devicetree\bindings\leds\leds-gpio.txt

LED 连接到 GPIO 线。

必须属性:

  • compatible:必须是 "gpio-leds"

每个 LED 表示为 gpio-leds 设备的子节点。每个节点的名称表示对应 LED 的名称。

LED 子节点属性:

  • gpios:应指定 LEDGPIO,参见 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 的初始状态。有效值为 onoffkeep。如果 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;
	};
};
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值