Linux驱动分析——pwm-leds

stm32mp157  盘古开发板  Linux内核版本4.19

pwm-leds就是用pwm来控制LED亮度

1、内核相关文档

linux-st\Documentation\devicetree\bindings\leds\leds-pwm.txt

LED connected to PWM

Required properties:
- compatible : should be "pwm-leds".

Each LED is represented as a sub-node of the pwm-leds device.  Each
node's name represents the name of the corresponding LED.

LED sub-node properties:
- pwms : PWM property to point to the PWM device (phandle)/port (id) and to
  specify the period time to be used: <&phandle id period_ns>;
- pwm-names : (optional) Name to be used by the PWM subsystem for the PWM device
  For the pwms and pwm-names property please refer to:
  Documentation/devicetree/bindings/pwm/pwm.txt
- max-brightness : Maximum brightness possible for the LED
- active-low : (optional) For PWMs where the LED is wired to supply
  rather than ground.
- label :  (optional)
  see Documentation/devicetree/bindings/leds/common.txt
- linux,default-trigger :  (optional)
  see Documentation/devicetree/bindings/leds/common.txt

Example:

twl_pwm: pwm {
	/* provides two PWMs (id 0, 1 for PWM1 and PWM2) */
	compatible = "ti,twl6030-pwm";
	#pwm-cells = <2>;
};

twl_pwmled: pwmled {
	/* provides one PWM (id 0 for Charing indicator LED) */
	compatible = "ti,twl6030-pwmled";
	#pwm-cells = <2>;
};

pwmleds {
	compatible = "pwm-leds";
	kpad {
		label = "omap4::keypad";
		pwms = <&twl_pwm 0 7812500>;
		max-brightness = <127>;
	};

	charging {
		label = "omap4:green:chrg";
		pwms = <&twl_pwmled 0 7812500>;
		max-brightness = <255>;
	};
};

关于pwm-leds文件系统操作相关的文档,没有在内核文档里面找到,我想可能是并入到LED的文件系统操作里面了,看下面就知道了。

2、设备树配置

&pinctrl {
	/*定时器5的pwm测试引脚,测试前需要先把摄像头相关失能,否则会存在引脚复用问题*/
	
	pwm5_pins_b: pwm5-0 {
		pins {
            pinmux = <STM32_PINMUX('I', 0, AF2)>; /* TIM5_CH4 */
            bias-pull-down;
            drive-push-pull;
            slew-rate = <0>;
        };
    };
	
    pwm5_sleep_pins_b: pwm5-sleep-0 {
        pins {
      
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值