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.

Linux/AM5708: Timer configuration for PWM

Part Number: AM5708


Tool/software: Linux

I'd like to use GP Timer5 (A18 on AM5708) to generate PWM signal from Linux.

Is Timer 5 part of the PWM subsystem in Linux? I am confused because technically it is a timer, not a PWM output.

Also how do I configure the device tree to enable Timer 5?

  • Ok here is an update:

    After setting "status" to "okay" for timer5 in the DTS, I can now enable "pwmchip2" in /sys/class/pwmchip2. This creates "pwm0" in /sys/class/pwmchip2/ as well.

    Is "pwm0" my timer 5?
  • Hi Adam,

    Could you describe all steps to reproduce your environment? Also could you share the device tree changes which you have made?

    BR
    Tsvetolin Shulev
  • Hi Cvetolin, 

    I haven't really changed much. Just the following:

    linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305$ git diff
    diff --git a/arch/arm/boot/dts/am5708-custom-dev.dts b/arch/arm/boot/dts/am5708-custom-dev.dts
    index 4dd1527..5d17e39 100644
    --- a/arch/arm/boot/dts/am5708-custom-dev.dts
    +++ b/arch/arm/boot/dts/am5708-custom-dev.dts
    @@ -82,6 +82,9 @@
    // power-gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>;
    //};
    };
    +&timer5 {
    + status = "okay";
    +};

    &dss {
    vdda_video-supply = <&lp8732_ldo0_reg>;

    The goal is to use Timer 5 on Am5708 to output PWM for a period of time.

  • Here is what I tried in the user space:

    root:~# cd /sys/class/pwm/
    root:/sys/class/pwm# ls
    pwmchip0 pwmchip2
    root:/sys/class/pwm# cd pwmchip2
    root:/sys/class/pwm/pwmchip2# ls
    device export npwm power subsystem uevent unexport
    root:/sys/class/pwm/pwmchip2# echo 0 > export
    root:/sys/class/pwm/pwmchip2# ls
    device npwm pwm0 uevent
    export power subsystem unexport
    root:/sys/class/pwm/pwmchip2# cd pwm0
    root:/sys/class/pwm/pwmchip2/pwm0# ls
    capture duty_cycle enable period polarity power uevent
    root:/sys/class/pwm/pwmchip2/pwm0# echo 1000 > period
    root:/sys/class/pwm/pwmchip2/pwm0# echo 50 > duty_cycle
    root:/sys/class/pwm/pwmchip2/pwm0# echo 0 > enable
    root:/sys/class/pwm/pwmchip2/pwm0# cat enable
    0

    Am I even accessing the right module?

  • Based on the sysfs operations you included, the eCAP module (configured in APWM mode) of the PWMSS is being used.  Therefore, configuring TIMER5 shouldn't have any influence on the eCAP operations.

    The devices tree should have entry

    &ecap0 {

    status = "okay";

    };

    To enable pwm0 you'll need to perform the following write:

    echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable

    Note: PWM outputs will be driven on the pins corresponding to ECAP0 configured in APWMx mode.