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.

setup device-tree entry for ecap / pwmleds

Other Parts Discussed in Thread: TLC5940

Hi,

We have a custom am335x based design with a TLC5940 led driver. The design has the gsclk of the TLC5940 being driven by the following PWM  pin

ECAP1_IN_PWM1_OUT (C15)

In the kernel we've enabled both the eCAP and the eHRPWM modules. We choose to go with the ecap because all we required was a simple clock out device. Our device tree has been leveraged from am335x-evm.dts and the related entries we attempted are as follows:

    pwmleds {
        compatible = "pwm-leds";

        pmu_stat {
            label = "bboard::pmu_stat";
            pwms = <&ecap1 1 7812500>;
            max-brightness = <127>;
            linux,default-trigger = "default-on";
            brightness = <127>;
        };
    };

    ecap1_pins: ecap1_pins {
    pinctrl-single,pins = <
        0x160 ( PIN_OUTPUT | MUX_MODE2 ) /* (C15) spi0_cs1.eCAP1_in_PWM1_out */
    >;
    };

&ecap1 {
    status = "okay";
};

However we see the following boot notifications and we do not see an expected ecap device in /sys/class/pwm/

[    8.517983] /pwmleds/pmu_stat: arguments longer than property
[    8.524146] leds_pwm pwmleds: unable to request PWM for bboard::pmu_stat: -22
[    8.748229] leds_pwm: probe of pwmleds failed with error -22

All we really require is a simple clock out of the PWM, can someone perhaps see what I may be missing here. Thanks in advance.


Tom

  • I should add that we are using the 3.18.20 kernel.
  • progress or regression? made a few changes to the device tree entries, since it is based off of the evm, we use this include

    #include "am33xx.dtsi"

    updated DTS reads as follows:
    ----------
    pwmleds {
    compatible = "pwm-leds";

    pmu_stat {
    label = "ivee::pmu_stat";
    pwms = <&ecap1 0 50000 1>;
    max-brightness = <255>;
    linux,default-trigger = "default-on";
    brightness = <127>;
    };
    };
    --------
    ecap1_pins: ecap1_pins {
    pinctrl-single,pins = <
    0x160 ( PIN_OUTPUT | MUX_MODE2 ) /* (C15) spi0_cs1.eCAP1_in_PWM1_out */
    >;
    };
    --------
    &epwmss1 {
    status = "okay";
    ecap1: ecap@48302100 {
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&ecap1_pins>;
    };
    };

    Now we get these boot messages

    [ 13.662966] leds_pwm pwmleds: unable to request PWM for ivee::pmu_stat: -517
    [ 13.709080] platform pwmleds: Driver leds_pwm requests probe deferral

    and the /sys/class/pwm/ is still empty
  • Hi Tom,

    Have you verified the kernel configuration: processors.wiki.ti.com/.../AM335x_PWM_Driver's_Guide

    Also you can refer to am335x-evm.dts or am335x-evmsk.dts to see how ecap is set.

    Best Regards,
    Yordan
  • Hi Yordan, Thanks for responding. Yes, I have reviewed a number of related documents including the PWM drivers guide in detail, however it doesn't outline DTS examples in any detail. I also have looked at the am335x-evm*.dts files, reviewed multiple related posts and tired a number of different DTS configurations. It just appears something is not enabled properly.

    Can you please describe the configuration fields in

    pwms = <&ecap1 0 50000 1>; 

    and what function they apply to? Thanks, Tom

  • I was hoping to get some clarification on what the configuration fields mean... please advise. Thanks, Tom
  • Yordan, Yes, I've been over the documentation multiple times and have tried a number of different device tree approaches without any luck. Here is the latest of which the attempt was to create a backlight DT entry that will just output a PWM clock using ecap1. Can someone check the entry and perhaps see what I am doing wrong. BTW, both of the PWM based modules are built with the kernel config.

    We started with an EVM-SK based DTS. Includes are

    #include "am33xx.dtsi"
    #include <dt-bindings/interrupt-controller/irq.h>
    #include <dt-bindings/pwm/pwm.h>

    * define the backlight and configure for ecap1

    backlight {
    compatible = "pwm-backlight";
    pwms = <&ecap1 0 50000 1>;
    brightness-levels = <0 58 61 66 75 90 125 170 255>;
    default-brightness-level = <8>;
    power-supply = <&vaux2_reg>;
    };

    * define the pin

    ecap1_pins: ecap1_pins {
    pinctrl-single,pins = <
    0x160 ( PIN_OUTPUT | MUX_MODE2 ) /* (C15) spi0_cs1.eCAP1_in_PWM1_out */
    >;
    };

    * define ecap1

    &ecap1 {
    status = "okay";
    };

    * this is the only related boot message received

    [ 0.325186] platform backlight: Driver pwm-backlight requests probe deferral

    I can't think of a more generic DTS entry, I have tried many other configurations based off of other DTS files with varying messages but I want to fallback to a very basic implementation. Please advise, Thanks, Tom
  • Hi Tom,

    Sorry for the delayed response.

    Can you try the following :

    &epwmss1 {
    status = "okay";
    ecap1: ecap@0x48302100 {
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = "ecap1_pins";
    };
    };

    Also add some prints in the probe functions in pwmss & ecap driver, to see if they pass.

    Best Regards,
    Yordan
  • Hi Yordan,

    Thanks for responding, Here's the latest output with printfs

    [    1.735749] pwm-backlight backlight: TR_DBG: pwm_backlight_probe entering...
    [    1.743233] pwm-backlight backlight: GPIO lookup for consumer enable
    [    1.743248] pwm-backlight backlight: using device tree for GPIO lookup
    [    1.743266] of_get_named_gpiod_flags: can't parse 'enable-gpios' property of node '/backlight[0]'
    [    1.743280] of_get_named_gpiod_flags: can't parse 'enable-gpio' property of node '/backlight[0]'
    [    1.743294] pwm-backlight backlight: using lookup tables for GPIO lookup
    [    1.743308] pwm-backlight backlight: lookup for GPIO enable failed
    [    1.743321] pwm-backlight backlight: TR_DBG: pwm_backlight_probe enable_gpio...
    [    1.751043] pwm-backlight backlight: TR_DBG: pwm_backlight_probe gpio direction ...
    [    1.759124] pwm-backlight backlight: TR_DBG: pwm_backlight_probe get regulator...
    [    1.767176] pwm-backlight backlight: TR_DBG: pwm_backlight_probe pwm_get...
    [    1.774620] pwm-backlight backlight: TR_DBG: got pwm for backlight...
    [    1.781445] pwm-backlight backlight: TR_DBG: get pwm_period ...
    [    1.787699] pwm-backlight backlight: TR_DBG: lth_brightness ...
    [    1.793935] pwm-backlight backlight: TR_DBG: backlight device register ...
    [    1.801518] pwm-backlight backlight: TR_DBG: backlight device registered? 0xcdde8e00 ...
    [    1.810316] pwm-backlight backlight: TR_DBG: done should be ok? 0xcdde8e00 ...

    From what I can tell it completes the probe. I see the following in sys/class

    root@am335x-evm:~# ls -ltrh /sys/class/pwm/
    lrwxrwxrwx    1 root     root           0 Jan  1 00:00 pwmchip0 -> ../../devices/ocp/48302000.epwmss/48302100.ecap/pwm/pwmchip0
    root@am335x-evm:~# ls -ltrh /sys/class/pwm/pwmchip0/
    -rw-r--r--    1 root     root        4.0K Jan  1 00:00 uevent
    lrwxrwxrwx    1 root     root           0 Jan  1 00:00 subsystem -> ../../../../../../class/pwm
    --w-------    1 root     root        4.0K Jan  1 00:00 unexport
    drwxr-xr-x    2 root     root           0 Jan  1 00:00 power
    -r--r--r--    1 root     root        4.0K Jan  1 00:00 npwm
    --w-------    1 root     root        4.0K Jan  1 00:00 export
    lrwxrwxrwx    1 root     root           0 Jan  1 00:00 device -> ../../../48302100.ecap

    However the instructions to enable the PWM on this link

    http://processors.wiki.ti.com/index.php/AM335x_PWM_Driver%27s_Guide

    do not seem to match up with the pwmchip0 that is in the pwm dir


    Does this look correct? if so how do I enable it from user space. Thanks, Tom




    Note: updated the DTS entries as follows:

        backlight {
            compatible = "pwm-backlight";
            pwms = <&ecap1 0 50000 1>;
            brightness-levels = <0 58 61 66 75 90 125 170 255>;
            default-brightness-level = <8>;
            power-supply = <&vaux2_reg>;

        };

    &ecap1 {
        status = "okay";
    };


    &epwmss1 {
        status = "okay";
        ecap1: ecap@48302100 {
            status = "okay";
            pinctrl-names = "default";
            pinctrl-0 = <&ecap1_pins>;
        };
    };

  • Hi Yordan,

    Can you weigh in on what I',m seeing above in the sys/class. Does it make sense, if so how can I configure and test it. Thanks, Tom

  • Hi Yordan,

    Can you possibly respond to the latest output I have listed below? I do not see a specific ecap device, just pwmchip0. Is this correct?


    root@am335x-evm:~# ls -ltrh /sys/class/pwm/
    lrwxrwxrwx 1 root root 0 Jan 1 00:00 pwmchip0 -> ../../devices/ocp/48302000.epwmss/48302100.ecap/pwm/pwmchip0
    root@am335x-evm:~# ls -ltrh /sys/class/pwm/pwmchip0/
    -rw-r--r-- 1 root root 4.0K Jan 1 00:00 uevent
    lrwxrwxrwx 1 root root 0 Jan 1 00:00 subsystem -> ../../../../../../class/pwm
    --w------- 1 root root 4.0K Jan 1 00:00 unexport
    drwxr-xr-x 2 root root 0 Jan 1 00:00 power
    -r--r--r-- 1 root root 4.0K Jan 1 00:00 npwm
    --w------- 1 root root 4.0K Jan 1 00:00 export
    lrwxrwxrwx 1 root root 0 Jan 1 00:00 device -> ../../../48302100.ecap
  • Hi,

    Yes, this is correct.

    Now you can continue using he pwm0/1 as described in the user's guide: processors.wiki.ti.com/.../Linux_Core_PWM_User's_Guide

    Best Regards,
    Yordan