PWM1, PWM2 and PWM3 on TK1

Hi,

I’m updating PWM developer article adding TK1 information, but I’m stuck in an error that the PWM1, PWM2 and PWM3 aren’t coming up when kernel boot.

The unique PWM available is the “/sys/class/pwm/pwmchip0”.

I take a look on Kernel and Device Tree but apparently the PWM is available, the unique think that I didn’t understand is why there is just “tegra_pwm: pwm@7000a000” on “tegra124-soc.dtsi”, because I see in others modules that is one entry per pwm.

Can you help me with this?

Best regards,
Daniel Morais

Hi Daniel

Which git branch are u using to compile?

Hi,

Firstly I used the Toradex Linux Image “Apalis-TK1_LXDE-Image_2.7b3-20170630.tar.bz2”.

After, I used “toradex_tk1_l4t_r21.5-next” git branch and “toradex_tk1_l4t_r21.6-next” git branch to compile.

Regards, Daniel Morais

I’m updating PWM developer article adding TK1 information, but I’m stuck in an error that the PWM1, PWM2 and PWM3 aren’t coming up when kernel boot.

No, you are mixing PWM instances with the PWM chip abstraction. In the Tegra case all PWM instances are really covered by one single PWM chip abstraction.

The unique PWM available is the “/sys/class/pwm/pwmchip0”.

Yes, that’s the one.

I take a look on Kernel and Device Tree but apparently the PWM is available, the unique think that I didn’t understand is why there is just “tegra_pwm: pwm@7000a000” on “tegra124-soc.dtsi”, because I see in others modules that is one entry per pwm.

Yes, that is really SoC specific and may be different on other non Tegra modules.

Can you help me with this?

Sure, it all should really just work fine out-of-the-box:

root@apalis-tk1:~# cd /sys/class/pwm/pwmchip0
root@apalis-tk1:/sys/class/pwm/pwmchip0# cat npwm 
4
root@apalis-tk1:/sys/class/pwm/pwmchip0# echo 0 > export 
root@apalis-tk1:/sys/class/pwm/pwmchip0# echo 1 > export
root@apalis-tk1:/sys/class/pwm/pwmchip0# echo 2 > export
root@apalis-tk1:/sys/class/pwm/pwmchip0# echo 3 > export
-sh: echo: write error: Device or resource busy
root@apalis-tk1:/sys/class/pwm/pwmchip0# echo 1000000 > pwm0/period
root@apalis-tk1:/sys/class/pwm/pwmchip0# echo 250000  > pwm0/duty_cycle
root@apalis-tk1:/sys/class/pwm/pwmchip0# echo 1 > pwm0/enable
root@apalis-tk1:/sys/class/pwm/pwmchip0# echo 1000000 > pwm1/period
root@apalis-tk1:/sys/class/pwm/pwmchip0# echo 250000  > pwm1/duty_cycle
root@apalis-tk1:/sys/class/pwm/pwmchip0# echo 1 > pwm1/enable
root@apalis-tk1:/sys/class/pwm/pwmchip0# echo 1000000 > pwm2/period
root@apalis-tk1:/sys/class/pwm/pwmchip0# echo 250000  > pwm2/duty_cycle
root@apalis-tk1:/sys/class/pwm/pwmchip0# echo 1 > pwm2/enable

And the last one is already used as back light PWM:

root@apalis-tk1:~# cd /sys/class/backlight/pwm-backlight
root@apalis-tk1:/sys/class/backlight/pwm-backlight# echo 0 > brightness
root@apalis-tk1:/sys/class/backlight/pwm-backlight# echo 255 > brightness
root@apalis-tk1:/sys/class/backlight/pwm-backlight# echo 127 > brightness

Hi Marcel,

Thanks for this explanation.

I think this information is really useful and can help many of our customers, can we make this question public?

Best regards,
Daniel Morais

Thanks for this explanation.

You are very welcome.

I think this information is really useful and can help many of our customers, can we make this question public?

Sure, also please update our developer website article accordingly.

Thanks again!