Build a custom gpio-keys pinmux configuration for the kernel

Hi there,
I would like to create a custom gpio-keys configuration to enable :

  • 7 analog GPIO inputs
  • 2 PWM GPIO outputs
  • 4 analog GPIO outputs
    Is that possible with the Jetson Xavier platform ?
    Much regards, Xavier.

Yes, It’s possible.
But you need to add A/D and D/A for your analog input/output.

Dear @juns,

regarding the gpio-keys configuration, I would like to test the correct configuration with PWM outputs but so far no success to output a PWM signal. Some informations about the current set-up :

  • I want to use “pin-13 (PWM01), pin-15 (GPIO27_PWM2), pin-18 (GPIO35_PWM3) of Xavier J30 GPIO”

  • Using Jetpack 4.3 (R32.3.1) by default (not new cfg/dtsi in place)

  • Running jetson-gpio/samples/simple_pwm.py on either one of the 3 PWM pins I see the 3V3 output going down for a few ms and then up to 3V3

  • pin configuration at runtime :
    cat /sys/kernel/debug/tegra_pinctrl_reg | grep pwm Bank: 0 Reg: 0x0243d030 Val: 0x00000450 -> gp_pwm3_px3 Bank: 0 Reg: 0x0243d038 Val: 0x00000450 -> gp_pwm2_px2

  • pwm configuration from the sysfs values :
    cat /sys/kernel/debug/pwm platform/39c0000.tachometer, 1 PWM device pwm-0 (generic_pwm_tachomet): requested period: 0 ns duty: 0 ns polarity: normal platform/32f0000.pwm, 1 PWM device pwm-0 (sysfs ): requested period: 0 ns duty: 0 ns polarity: normal platform/32c0000.pwm, 1 PWM device pwm-0 (sysfs ): requested enabled period: 10000 ns duty: 5000 ns polarity: normal platform/c340000.pwm, 1 PWM device pwm-0 (pwm-fan ): requested enabled period: 45334 ns duty: 0 ns polarity: normal platform/3280000.pwm, 1 PWM device pwm-0 (sysfs ): requested enabled period: 10000 ns duty: 5000 ns polarity: normal

I have the feeling the 3 PWM pins are PWM-enabled but I may not do right control ?
Best regards,
Xavier.

HI xavier,

What is your current problem? Could you help info you pasted? It seems every line is stuck together.

BTW, I don’t see anything related to gpio-keys in your question. Such topic should call “pinmux” instead of “gpio-keys”.

Dear @WayneWWW
my current issue to validate/check that the 3 PWM pins are in PWM mode and that I can control them with a simple test code to start with. Running Jetpack 4.3 without any cfg/dtsi modification so far so the J30 pins are in the default mode of Jetpack 4.3
Cheers,
Xavier.

Hi,

How is the current status? You have to check whether current pinctrl is pwm or not. If it is not PWM, then you could use jetson-io tool to configure it to pwm. Actually, jetson-io update the DTB as well.

  • How do you check the current pinctrl is pwm or not ?
  • jetson-io tool is installed by default in Jetpack4.3 ?

BR. Xavier.

Hi Xavier,

I would suggest you to use jetson-io directly.

Please check this page.
https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide%2Fhw_setup_jetson_io.html

Hi @WayneWWW,

I have been using jetson_io to configure pin13(pwm8), pin15(pwm1), pin18(pwn5) and after reboot the tool confirmed that the 3 pins are in pwm mode.
Now I am lost about how to use this pins in shell/python script as I have the following sysfs mapping :

/sys/class/pwm$ tree . ├── pwmchip0 -> ../../devices/3280000.pwm/pwm/pwmchip0 ├── pwmchip1 -> ../../devices/c340000.pwm/pwm/pwmchip1 ├── pwmchip2 -> ../../devices/32c0000.pwm/pwm/pwmchip2 ├── pwmchip3 -> ../../devices/32f0000.pwm/pwm/pwmchip3 └── pwmchip4 -> ../../devices/39c0000.tachometer/pwm/pwmchip4

I have been trying jetson-gpio/samples/simple_pwm.py but no success and it seems this script is deconfiguring the pins ?

BR. Xavier.

Hi,

Please try the linux pwm node to see if you could see the pwm signal.

cd 32X0000.pwm/pwm/pwmchipY
echo 0 > export
cd pwm0
echo 200000 > period
echo 100000 > duty_cycle
echo 1 > enable

Hi @WayneWWW,
Thanks. Your test does work and the address/pin mapping is actually :

  • /sys/devices/32f0000.pwm/pwm/pwmchip3/pwm0 : J30/pin13
  • /sys/devices/3280000.pwm/pwm/pwmchip0/pwm0 : J30/pin15
  • /sys/devices/32c0000.pwm/pwm/pwmchip2/pwm0 : J30/pin18

Can I use a python gpio library to drive those PWM signals ?
I would like to use i2c/uart signals to talk to a 5V devices, I definitely need a level shifter to adapt the fast signals to 5V levels ?
BR. Xavier.

Actually I am wondering why simple_pwm.py is not working…
Need to investigate it on my side.

Can I use a python gpio library to drive those PWM signals ?

Is it an acceptable solution for you that we fix simple_pwm.py ?

Dear @WayneWWW,
yes if simple_pwm.py is fixed then it will a good base for me to work on the target feature. I am willing to help if needed (code/test).
BR. Xavier.

Dear @WayneWWW
may you have updates on the correction of the simple_pwm.py script ?
I would love to use the pwm pins from a python library.
Much regards, Xavier.

Hi xavier,

It seems the NX version has been updated on the github page.
Please refer to:
[0] https://github.com/NVIDIA/jetson-gpio
[1] https://github.com/NVIDIA/jetson-gpio/commit/ccaa362ad19ad174820b83d1746f79421d651457