Unable to set PWM to low frequency

Hi, Nv’s experts:

I encountered some issues during PWM debugging on Jetson thor

Hardware: Custom board

Jetson linux versoin: Jetson_Linux_R38.2.1_aarch64

issue:

  • When I set the frequency to 500Hz, PWM can work normally and the oscilloscope can display waveforms normally.
  • When I set the frequency to 200Hz, the PWM seems to have been successfully set, but the oscilloscope cannot display the waveform.

I tried several different frequencies, and it doesn’t work properly below 480Hz.

Can you give some suggessions.

Some debugging information:

root@upai-pro03:/sys/kernel/debug/bpmp/debug/clk/pwm9# cat possible_parents 
pllp_out0 osc 
root@upai-pro03:/sys/kernel/debug/bpmp/debug/clk/pwm9# cat parent 
osc
root@upai-pro03:/sys/kernel/debug/bpmp/debug/clk/pwm9# cat rate 
27000000


root@upai-pro03:/home/nvidia# cd /sys/class/pwm/pwmchip3/
root@upai-pro03:/sys/class/pwm/pwmchip3# echo 0 > export
root@upai-pro03:/sys/class/pwm/pwmchip3# cd pwm0/
root@upai-pro03:/sys/class/pwm/pwmchip3/pwm0# echo 2000000 > period
root@upai-pro03:/sys/class/pwm/pwmchip3/pwm0# echo 1000000 > duty_cycle
root@upai-pro03:/sys/class/pwm/pwmchip3/pwm0# echo 1 > enable
root@upai-pro03:/sys/class/pwm/pwmchip3/pwm0# busybox devmem 0x810c610000
0x008000D2
root@upai-pro03:/sys/class/pwm/pwmchip3/pwm0# echo 0 > enable
root@upai-pro03:/sys/class/pwm/pwmchip3/pwm0# echo 5000000 > period
root@upai-pro03:/sys/class/pwm/pwmchip3/pwm0# echo 2500000 > duty_cycle
root@upai-pro03:/sys/class/pwm/pwmchip3/pwm0# echo 1 > enable
root@upai-pro03:/sys/class/pwm/pwmchip3/pwm0# busybox devmem 0x810c610000
0x0080020E

Hi WellsX,

Could you configure the rate as following to check if it could help?

# echo 10000000 > /sys/kernel/debug/bpmp/debug/clk/pwm9/rate
# cat /sys/kernel/debug/bpmp/debug/clk/pwm9/rate

# echo 0 > export
# cd /sys/class/pwm/pwmchip3/pwm0
# echo 5000000 > period
# echo 2500000 > duty_cycle
# echo 1 > enable

Hi,

I tried according to your steps, but unfortunately the result is still the same as before. , there is still no waveform on the oscilloscope when the pwm frequency is configured at 200Hz.

At the same time, I further tested that the lowest effective frequency in the current situation is 412Hz.

Log as follows:

root@upai-pro03:/sys/kernel/debug/bpmp/debug/clk/pwm9# cat /sys/kernel/debug/pwm
0: platform/c6a0000.pwm, 1 PWM device
 pwm-0   (pwm-fan             ): requested enabled period: 40000 ns duty: 20549 ns polarity: normal usage_power

1: platform/810c5e0000.pwm, 1 PWM device
 pwm-0   ((null)              ): period: 0 ns duty: 0 ns polarity: normal

2: platform/810c5f0000.pwm, 1 PWM device
 pwm-0   ((null)              ): period: 0 ns duty: 0 ns polarity: normal

3: platform/810c600000.pwm, 1 PWM device
 pwm-0   ((null)              ): period: 1000000 ns duty: 500000 ns polarity: normal

4: platform/810c610000.pwm, 1 PWM device
 pwm-0   ((null)              ): period: 1000000 ns duty: 500000 ns polarity: normal

5: platform/810c620000.pwm, 1 PWM device
 pwm-0   ((null)              ): period: 0 ns duty: 0 ns polarity: normal

6: platform/810c5c0000.tachometer, 1 PWM device
 pwm-0   ((null)              ): period: 0 ns duty: 0 ns polarity: normal
root@upai-pro03:/sys/kernel/debug/bpmp/debug/clk/pwm9# echo 10000000 > ./rate 
root@upai-pro03:/sys/kernel/debug/bpmp/debug/clk/pwm9# cat rate 
10800000
root@upai-pro03:/sys/kernel/debug/bpmp/debug/clk/pwm9# cd /sys/class/pwm/pwmchip4
root@upai-pro03:/sys/class/pwm/pwmchip4# ls
device  export  npwm  power  subsystem  uevent  unexport
root@upai-pro03:/sys/class/pwm/pwmchip4# echo 0 > export
root@upai-pro03:/sys/class/pwm/pwmchip4# ls
device  export  npwm  power  pwm0  subsystem  uevent  unexport
root@upai-pro03:/sys/class/pwm/pwmchip4# cd pwm0/
root@upai-pro03:/sys/class/pwm/pwmchip4/pwm0# echo 5000000 > period
root@upai-pro03:/sys/class/pwm/pwmchip4/pwm0# echo 2500000 > duty_cycle
root@upai-pro03:/sys/class/pwm/pwmchip4/pwm0# echo 1 > enable
root@upai-pro03:/sys/class/pwm/pwmchip4/pwm0# busybox devmem 0x810c610000
0x0080020E

Why it is pwmchip3 from original post but it is pwmchip4 in your latest reply?

May I know what’s the exact PWM interface your are verifying?
Do you want to use 0x810c610000.pwm?
Please share the result of ls -l /sys/class/pwm on your board.

Hi,

The reason why pwnchip changed from 3 to 4 is because I added a new PWM node(addr:810c600000) in dts. Now i deleted it again, it reverted to pwnchip3. I’m sure that the test steps are correct.

Yes, i want to use 810c610000.pwm, and the result of ls -l /sys/class/pwm is:

nvidia@upai-pro03:~$ ls -l /sys/class/pwm
total 0
lrwxrwxrwx 1 root root 0 Jul  2 14:04 pwmchip0 -> ../../devices/platform/bus@0/c6a0000.pwm/pwm/pwmchip0
lrwxrwxrwx 1 root root 0 Jul  2 14:04 pwmchip1 -> ../../devices/platform/bus@0/810c5e0000.pwm/pwm/pwmchip1
lrwxrwxrwx 1 root root 0 Jul  2 14:04 pwmchip2 -> ../../devices/platform/bus@0/810c5f0000.pwm/pwm/pwmchip2
lrwxrwxrwx 1 root root 0 Jul  2 14:04 pwmchip3 -> ../../devices/platform/bus@0/810c610000.pwm/pwm/pwmchip3
lrwxrwxrwx 1 root root 0 Jul  2 14:04 pwmchip4 -> ../../devices/platform/bus@0/810c620000.pwm/pwm/pwmchip4
lrwxrwxrwx 1 root root 0 Jul  2 14:04 pwmchip5 -> ../../devices/platform/bus@0/810c5c0000.tachometer/pwm/pwmchip5