Setup PWM on a GPIO for Orin AGX

Hi,

I am attempting to setup a gpio to be a PWM. I have attached the decompiled devtree.

This is the pinmux definition:

                    soc_gpio39_pn1 {
                            nvidia,pins = "soc_gpio39_pn1";
                            nvidia,function = "pwm";
                            nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
                            nvidia,tristate = <TEGRA_PIN_DISABLE>;
                            nvidia,enable-input = <TEGRA_PIN_DISABLE>;
                            nvidia,lpdr = <TEGRA_PIN_DISABLE>;
                    };

I have tried the function as gp and pwm.

We are using PWM1 and the following is the device tree setup:

            pwm1: pwm@3280000 {
                    compatible = "nvidia,tegra234-pwm", "nvidia,tegra194-pwm";
                    reg = <0x0 0x3280000 0x0 0x10000>;
                    clocks = <&bpmp TEGRA234_CLK_PWM1>;
                    clock-parents = <&bpmp TEGRA234_CLK_CLK_32K>;
                    resets = <&bpmp TEGRA234_RESET_PWM1>;
                    reset-names = "pwm";
                    status = "disabled";
                    #pwm-cells = <2>;

The status is Okay in the decompiled device tree.

I am using the following commands to setup and enable the PWM:

echo 0 > /sys/class/pwm/pwmchip0/export
echo 10000 > /sys/class/pwm/pwmchip0/pwm/period
echo 5000 > /sys/class/pwm/pwmchip0/pwm/duty_cycle
echo 1 > /sys/class/pwm/pwmchip0/enable

The pin that has been assigned to the PWM is N1/ pin 85. I can toggle the pin using:

sudo gpioset gpiochip0 85=0/1

I have tried different periods and duty cycles, but I do not see the pin showing a PWM output.

What am I missing to see this pin act as a PWM signal?

Thanks for your input.

Malcolm

devtree_aug14.zip (39.1 KB)

Hi malcolm12,

Are you using the devkit or custom board for AGX Orin?
What’s the Jetpack version in use?

Please use pinmux spreadsheet to configure PWM in case you configure something invalid.

Please share the result of ls -l /sys/class/pwm/ on your board for further check.

Hi KevinFFF,

We are using AGX Orin with JetPack 35.6.

It is a custom carrier board. Is there a specific hardware control needed?

I am using what is generated from the spreedsheet for the pwm GPIO.

I cannot send you the actual ls -l right now, but I know I am seeing:

/sys/class/pwm/pwmchip0/

/sys/class/pwm/pwmchip2/

/sys/class/pwm/pwmchip3/

As we have 3 GPIOs we want to have as PWMs.

Is the setup and the commands I am using correct to enable the PWM?

Malcolm

PWM has been verified on the AGX Orin devkit.
It should work on your custom board with a similar design.

You can refer to the following thread for the steps to generate PWM output on AGX Orin.
How to use 40pins pwm01? - #23 by KevinFFF

devtree_aug_18.zip (39.1 KB)

I have tried the insrucions of post you provided, but I still don’t see pulses on the scope.

I can controll the state of the GPIO using:
gpioset gpiochip0 108=1

I set the rate as suggested
echo 19200000 > /sys/kernel/debug/bpmp/debug/clk/pwm8/rate

but when I read the value back its different:
root@tegra-ubuntu:# cat /sys/kernel/debug/bpmp/debug/clk/pwm8/rate
18545455

When I do the dump, as below I still see 408000000 not 19200000 as in the post
1 1 0 408000000 0 0 50000 Y
root@tegra-ubuntu:# grep -E “pwm8” /sys/kernel/debug/clk/clk_summary
pwm8 1 1 0 408000000 0 0 50000 Y

I modified the device tree source as shown:

            pwm8: pwm@32f0000 {
                    compatible = "nvidia,tegra234-pwm", "nvidia,tegra194-pwm";
                    reg = <0x0 0x32f0000 0x0 0x10000>;
                    clocks = <&bpmp TEGRA234_CLK_PWM8>;
                    clock-parents = <&bpmp TEGRA234_CLK_CLK_M>;
                    assigned-clocks = <&bpmp TEGRA234_CLK_PWM8>;
                    resets = <&bpmp TEGRA234_RESET_PWM8>;
                    reset-names = "pwm";
                    status = "disabled";
                    #pwm-cells = <2>;
            };

and I am seeing the same GPIO configuration in the decompiled device tree:

            pwm@32f0000 {
                    compatible = "nvidia,tegra234-pwm\0nvidia,tegra194-pwm";
                    reg = <0x00 0x32f0000 0x00 0x10000>;
                    clocks = <0x03 0x70>;
                    clock-parents = <0x03 0x0e>;
                    assigned-clocks = <0x03 0x70>;
                    resets = <0x03 0x4b>;
                    reset-names = "pwm";
                    status = "okay";
                    #pwm-cells = <0x02>;
                    phandle = <0x233>;
            };

I have attached an updated device tree.

I have tried to set the GPIO high and then enable the PWM, but it never toggles.

Do you have any other ideas?

Malcolm

I don’t see assigned-clock-parents = <0x03 0x0e>; in your device tree so the configuration may not be applied correctly.

It is not required to control the GPIO high before generating PWM output.

Have you configured the pinmux for PWM functionality before use?
image

Hi KevinFFF,

I have checked the configuration/clocks and the device tree matches what is in the post you referenced:

            pwm@32f0000 {
                    compatible = "nvidia,tegra234-pwm\0nvidia,tegra194-pwm";
                    reg = <0x00 0x32f0000 0x00 0x10000>;
                    clocks = <0x03 0x70>;
                    assigned-clock-parents = <0x03 0x0e>;
                    assigned-clocks = <0x03 0x70>;
                    resets = <0x03 0x4b>;
                    reset-names = "pwm";
                    status = "okay";
                    #pwm-cells = <0x02>;
                    phandle = <0x233>;
            };

The clk_summary matches:

grep -E “pwm8” /sys/kernel/debug/clk/clk_summary

devtree_aug_20.zip (39.1 KB)

pwm8 1 1 0 19200000 0 0 50000 Y

I can setup he PWM configuration:

cd /sys/devices/platform/bus@0/32f0000.pwm/pwm/pwmchip3

echo 0 > export

device export npwm power pwm0 subsystem uevent unexport

cd pwm0
echo 1000000 > period
echo 500000 > duty_cycle
echo 1 > enable

On a scope there is no PWM waveform.

The excel spreadsheet is correct and matches what you have provided.

I have had someone review the setup and they couldn’t see any issues.

The PWM is no seen.

Can you provide any other suggestions to get this working.

Malcolm

The steps shared in that thread have been verified on my local AGX Orin devkit with expected PWM output.
I am not sure about the difference between the devkit and your custom carrier board.
Do you have the devkit to reproduce the similar issue?

Hi

I tried a devkit and yes it works. I am not sure why, but the only difference is in the pinmux or gpio settings for our new carrier card.

There is no update from you for a period, assuming this is not an issue anymore.
Hence, we are closing this topic. If need further support, please open a new one.
Thanks
~0930

Could you compare the result of pinmux register for both the devkit and your custom carrier board?

$ sudo busybox devmem 0x2430080