This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

led-pwm driver in linux kernel3.8



We have custom made board based on beaglebone black,
We are using linux kernel 3.8 in our project,
device doesnt have display, it has LEDs for different feedback/indiction.

we want to enable led-pwm driver in the kernel,
Basically our aim is to control leds through led driver with pwm binding,
But it seems that driver doesnt support configuration through device tree(and sysfs interface)

http://lxr.free-electrons.com/source/drivers/leds/?v=3.8

I tried using led-pwm driver in linux3.8 itself and thought i will add code for reading configuration from device tree,
i am able to compile it as built-in driver but probe funtion of the same is not getting called
I am sure i have not configured it properly, so one doubt is how do i configure it ?

This driver is very much present in linux3.14 kernel and
documentation gives information about how it can be configured using devicetree,

http://lxr.free-electrons.com/source/Documentation/devicetree/bindings/leds/leds-pwm.txt

But problem is we cant move to linux3.14 kernel because already much of testing has happened on linux3.8 kernel
and everything is works fine except one thing i.e. in Linux3.8 kernel we are using direct pwm interface for controlling leds. (sys/class/pwm) but we want to use (sys/class/led/). led-gpio driver works fine but we want to have pwm controlled leds.

Now only way for us to Make change in linux3.8 led-pwm driver, So
1. any suggestions for configurating led-pwm driver in linux3.8 ?
2. in driver/led/kconfig i see led-pwm is dependent on "HAVE_PWM" config, i am not able to find this configuration in kernel source ?  but if i change that config to PWM then i am able to compile the driver, is this hack correct ?

Any suggestion will be helpful,

Thank you,

Regards,
Ankur

  • Hi Ankur,

    I don't have experience/worked on this driver,

    config LEDS_PWM
        tristate "PWM driven LED Support"
        depends on LEDS_CLASS
        depends on HAVE_PWM
        help
          This option enables support for pwm driven LEDs

    Symbol: HAVE_PWM [=n]                                                                                                       
      │ Type  : boolean                                                                                                             
      │   Selected by: ARCH_VT8500 [=n] && <choice> || MXC_PWM [=n] && ARCH_MXC [=n] || SOC_IMX23 [=n] && ARCH_MXS [=n] || SOC_IMX28

    It seems to be the "HAVE_PWM" support only available for iMX & VT devices,

    2. in driver/led/kconfig i see led-pwm is dependent on "HAVE_PWM" config, i am not able to find this configuration in kernel source ?  but if i change that config to PWM then i am able to compile the driver, is this hack correct ?

    It ll visible only when you select iMX configurations, or you have to add entry for PWM in the OMAP2 arch section.

    arch/arm/mach-vt8500/Makefile & Kconfig

    1. any suggestions for configurating led-pwm driver in linux3.8 ?

    I have to download the source & ll come back soon,

  • Hi,

    I have found "leds_pwm" support in OMAP4 device called "board-4430sdp.c"

    DTS CHANGES:

        pwmleds {
            compatible = "pwm-leds";
            charging {
                label = "omap3:green:chrg";
                pwms = <&twl_pwmled 0 7812500>;
                max-brightness = <255>;
            };

        };

    BOARD FILE CHANGES


    static struct led_pwm beagle_pwm_leds[] = {
        {
            .name        = "omap3:green:chrg",
            .pwm_id        = 1,
            .max_brightness    = 255,
            .pwm_period_ns    = 7812500,
        },
    };

    static struct led_pwm_platform_data beagle_pwm_data = {
        .num_leds    = ARRAY_SIZE(beagle_pwm_leds),
        .leds        = beagle_pwm_leds,
    };

    static struct platform_device beagle_leds_pwm = {
        .name    = "leds_pwm",
        .id    = -1,
        .dev    = {
            .platform_data = &beagle_pwm_data,
        },
    };

    static struct platform_device *beagle_devices[] __initdata = {
        &beagle_leds_pwm,
    };

        platform_add_devices(beagle_devices, ARRAY_SIZE(beagle_devices));

     

    drivers/leds/Kconfig   --> Try to uncomment the "HAVE_PWM" & then it will display the "PWM driven LED Support" option in menuconfig.

    Try to build  "drivers/leds/leds-pwm.c" w/o any errors and check whether the probe fn called properly,