Gpio_keys can't working

Add below code in the dts file.

    lsm-keypad {
            compatible = "gpio-keys";
            gpio-keys,name = "lsm-keypad";
            status = "okay";
            autorepeat;
            disable-on-recovery-kernel;

            keya {
                    label = "UP";
                    gpios = <&gpio TEGRA_GPIO(V, 0) GPIO_ACTIVE_LOW>;
                    linux,code = <KEY_A>;
                    gpio-key,wakeup;
                    debounce-interval = <30>;
            };

            keyenter {
                    label = "Enter";
                    gpios = <&gpio TEGRA_GPIO(G, 3) GPIO_ACTIVE_LOW>;
                    linux,code = <KEY_ENTER>;
                    gpio-key,wakeup;
                    debounce-interval = <30>;
            };
    };

pinmux:
lcd_bl_pwm_pv0 {
nvidia,pins = “lcd_bl_pwm_pv0”;
nvidia,function = “rsvd3”;
nvidia,pull = <TEGRA_PIN_PULL_UP>;
nvidia,tristate = <TEGRA_PIN_DISABLE>;
nvidia,enable-input = <TEGRA_PIN_ENABLE>;
};
uart2_cts_pg3 {
nvidia,pins = “uart2_cts_pg3”;
nvidia,function = “rsvd2”;
nvidia,pull = <TEGRA_PIN_PULL_UP>;
nvidia,tristate = <TEGRA_PIN_DISABLE>;
nvidia,enable-input = <TEGRA_PIN_ENABLE>;
};

gpio default:
gpio_default: default {
gpio-input = <
TEGRA_GPIO(V, 0)
TEGRA_GPIO(G, 3)

After reboot, connect GPIO V0 to Gnd, Then Letter ‘a’ show in terminal.
But the V0 pin keep low level when it floating…
And G3 keep low level since booting.

cat /sys/kernel/debug/gpio result:

gpio-51 ( |Enter ) in lo IRQ
gpio-168 ( |UP ) in lo IRQ

Thank you!

hello felixch,

could you please check documentation, Configuring the 40-Pin Expansion Header to have Jetson‑IO tool for customization.
thanks

Thank you for reply.

jetson-io.py give me below message:
FATAL ERROR
“NoneType” object is not iterable

The steps of my procedure:

  1. The pinmux & default gpio dtsi created by Jetson_Nano_Module_Pinmux_Config_Template.xlsm.

  2. Replace
    #include “porg-platforms/tegra210-porg-pinmux-p3448-0000-b00.dtsi”
    #include “porg-platforms/tegra210-porg-gpio-p3448-0000-b00.dtsi”
    with the generated dtsi files in tegra210-p3448-0000-p3449-0000-b00.dts.

3.Then add gpio-keys stuff.

Is there some way to figure out where is the problem?

It seems like PULL_UP not working.

Connect V0 to 3.3V then leave, /sys/kernel/debug/gpio output keeping High.
Connect V0 to Gnd then leave, /sys/kernel/debug/gpio output keeping Low.

busybox devmem 0x700031fc
get 0x57 , It’s weird.

busybox devmem 0x700031fc w 0x4B
The value of register changed, But nothing different others.

hello felixch,

please refer to application notes for the steps to use pinmux spreadsheet for board configuration.
thanks

Hi, JerryChang

In the AP note,

$ cp /tegra-pinmux-scripts/pinmux-config-p3450-porg.h board/nvidia/p3450-porg/

But no one source file include the header file.
I got the u-boot source from l4t source.

Should I edit p3450-porg.c add the include line?

thanks

Hi,

After rel-32.3, there is no need to configure pinmux in uboot. All the pinmux is in dts files.

Thanks .

R32 (release), REVISION: 4.2, GCID: 20074772, BOARD: t210ref, EABI: aarch64, DATE: Thu Apr 9 01:22:12 UTC 2020

How to find the problem for gpio-keys?
Is there a sample for learning?

Hi, JerryChang,

Would you please make a gpio-keys demo on your dev-kit to verify it?
I have no idea to resolve the issue.

Thanks a lot!

hello felixch,

could you please export and control those GPIOs manually for verification,
you can refer to Nano J41 Header Pinout for the GPIO numbers.
for example,
GPIO3_PV.00 = LCD_BL_PWM = 168
GPIO3_PG.03 = UART_2_CTS = 53

you may generate sysnodes for controlling it,

$ echo 168 > /sys/class/gpio/export 
$ cd /sys/class/gpio/gpio168
$ echo 1 > value

Same things.

Set direction to in,
Connect 168 to gnd then disconnect, value always 0.
Connect 168 to 3.3 then disconnect, value always 1.

PULL_UP still not working.

Would you please verify the pull up internal on your board?
Thanks.

Hi,

Your case sounds similar to this post

Please use another GPIO on board as output and connect to GPIO168 (as input) and see if 168 can see the value toggle correctly.

Thank you for help.

Yes, It does toggle in such case.
Just like connect it to gnd or vcc.

In my opnion, the pull strength should enough for none loading gpio.

Please check the doc for pin design of 40-pin header: https://developer.nvidia.com/jetson-nano-developer-kit-40-pin-expansion-header-gpio-usage-considerations-applications-note

There are some requests on external circuit.

The TXB has a output buffer, That’s why PULL-UP/DOWN not working when input port floating.
For proper operation, the device driving
the data I/Os of the TXB0108 must have drive strength of at least ±2 mA.