在Linux内核3.12中使用leds-pwm susbsystem控制LED

时间:2014-09-08 10:16:24

标签: linux embedded-linux beagleboneblack device-tree

我们正在使用beaglebone黑色定制板, 我们正在为我们的主板移植linux 3.12, 我们有三个LED用pwm控制。 那些LED连接到跟随球,

1. E18 --> Pinmux mode 0 --> eCAP0_in_PWM0_out
2. B19 --> Pinmux mode 3 --> eCAP1_in_PWM1_out
3. C18 --> Pinmux mode 3 --> eCAP2_in_PWM2_out

我们按如下方式修改了设备树,以启用leds-pwm支持,

 am33xx_pinmux: pinmux@44e10800 {
            pinctrl-names = "default";
            backlight_pin_0: pinmux_backlight_pin_0 {
                    pinctrl-single,pins = <
                            0x164 0x00  /* ecap0_in_pwm0_out.gpio0_7, OUTPUT | MODE0 */
                    >;
            };
            backlight_pin_1: pinmux_backlight_pin_1 {
                    pinctrl-single,pins = <
                            0x18C 0x03  /* ecap0_in_pwm0_out.gpio0_7, OUTPUT | MODE0 */
                    >;
            };
            backlight_pin_2: pinmux_backlight_pin_2 {
                    pinctrl-single,pins = <
                            0x188 0x03  /* ecap0_in_pwm0_out.gpio0_7, OUTPUT | MODE0 */
                    >;
            };
};


ocp {

                    epwmss0: epwmss@48300000 {
                    status = "okay";
                    /*ecap0: ecap@48300100 {*/
                    ehrpwm0: ehrpwm@48300200 {
                            status = "okay";
                            pinctrl-names = "default";
                            pinctrl-0 = <&backlight_pin_0>;
                    };
            };
            epwmss1: epwmss@48302000 {
                    status = "okay";
                    /*ecap0: ecap@48300100 {*/
                    ehrpwm1: ehrpwm@48302200 {
                            status = "okay";
                            pinctrl-names = "default";
                            pinctrl-0 = <&backlight_pin_1>;
                    };
            };

};


        pwm_led {
            compatible = "pwm-leds";
            led0 {
                    pwms = <&ehrpwm0 0 50 1>;
                    max-brightness = <255>;
                    linux,default-trigger = "default-on";
                    brightness = <127>;
                    status = "okay";
            };
            led1 {
                    pwms = <&ehrpwm1 1 50 1>;
                    max-brightness = <255>;
                    linux,default-trigger = "default-on";
                    brightness = <127>;
            };

    };

通过以上更改,我们在&#34; / sys / class / pwm /&#34;中看到了条目。并在&#34; / sys / class / leds /&#34;。 但问题是我们无法控制LED,LED没有开启,

# ls /sys/class/leds/
led0  led1
# ls /sys/class/leds/led0/
brightness      max_brightness  subsystem       uevent
device          power           trigger
# cat /sys/class/leds/led0/trigger
none nand-disk timer oneshot heartbeat backlight gpio cpu0 [default-on]
# cat /sys/class/leds/led0/brightness
255
# cat /sys/class/leds/led0/max_brightness
255
# ls /sys/class/pwm/
pwmchip0  pwmchip2
# ls /sys/class/pwm/pwmchip0
device     export     npwm       power      subsystem  uevent     unexport
# cat /sys/class/pwm/pwmchip0/device/modalias
platform:48300200.ehrpwm

我们尝试在LED下改变亮度和触发但它没有帮助, 有什么建议?你看到缺少什么吗?

谢谢,

此致 ANKUR

1 个答案:

答案 0 :(得分:0)

最后,我们发现我们应该使用ecap代替ehrpwm来使pwm正常工作。
详细解答请参考以下链接
http://e2e.ti.com/support/embedded/linux/f/354/t/366635.aspx