How to change S2 button to sleep function

On the Carrier Board the button S2 as the function Vol Down ,in the Jetson_TX2_OEM_Product_DesigndGuid,the pins is the sleep#,what should I do to change S2 button to sleep function?

Hi, it is default sleep function, no change needed.

@Trumany
Hi,when I press the button S2,the screen will appear volume down icon, instead of the system going to sleep.

@Trumany
Hi,when I press the button S2,the screen will appear volume down icon, instead of the system going to sleep.

The power button should be s4 instead of s2.

@ShaneCCC
Hi,I mean the button S2 is connect to E2(sleep#)pin,when my TX2 with Carrier Board are power-on,I press the button S2,it is the function Vol Down,why not the system to sleep?

The pin you tell is GPIO_FF2. It’s define as vol down key.

gpio-keys {
                compatible = "gpio-keys";
                gpio-keys,name = "gpio-keys";

                power {
                        label = "Power";
                        gpios = <&tegra_aon_gpio TEGRA_AON_GPIO(FF, 0) GPIO_ACTIVE_LOW>;
                        linux,code = <KEY_POWER>;
                        gpio-key,wakeup;
                };

                volume_up {
                        label = "Volume up";
                        gpios = <&tegra_aon_gpio TEGRA_AON_GPIO(FF, 1) GPIO_ACTIVE_LOW>;
                        linux,code = <KEY_VOLUMEUP>;
                };

                volume_down {
                        label = "Volume Down";
                        gpios = <&tegra_aon_gpio TEGRA_AON_GPIO(FF, 2) GPIO_ACTIVE_LOW>;
                        linux,code = <KEY_VOLUMEDOWN>;
                };
        };
};

@ShaneCCC
Hi,according to your tips, I find the defined place. I will give timely feedback on the changed results

@ShaneCCC

I changed the volum_code node’s linux,code to <KEY_SLEEP>, but the phenomenon is the same as before

How do you apply your DTB file?
Please check /proc/device-tree/gpio-keys/ is modify as you expect.

@ShaneCCC
I changed the file tegra186-cvb-prob-p2597-b00-p3310-1000-a00-00.dtsi like this:

[code][/
/volume_down {
label = “Volume Down”;
gpios = <&tegra_aon_gpio TEGRA_AON_GPIO(FF, 2) GPIO_ACTIVE_LOW>;
linux,code = <KEY_SLEEP>;
linux,code = <KEY_VOLUMEDOWN>;
};
/
sleep {
label = “Sleep”;
gpios = <&tegra_aon_gpio TEGRA_AON_GPIO(FF, 1) GPIO_ACTIVE_LOW>;
linux,code = <KEY_SLEEP>;
gpio-key,sleep;
};
]
I rebuild the dtb file and apply.
but I check /proc/device-tree/gpio-keys is same as before.

Using flash command to update the DTB instead of replace the file in /boot/

copy the dtb file to …/64_TX2/Linux_for_Tegra_tx2/kernel/dtb/tegra186-quill-p3310-1000-c03-00-base.dtb
sudo ./flash -r -k kernel-dtb jetson_tx2 mmcblk0p1

@ShaneCCC
I used the commond :
sudo dd if=/dev/mmcblk0p15 of=tegra186-quill-p3310-1000-c03-00-base.dtb

reboot

@ShaneCCC
Hi,I I operated according to what you said.the button S2 not are the VOL_DOWN function, however,it is not a sleep funtion.When I press the button ,no reaction was found on the device and the display.

Are there any other changes that need to be made?

Didn’t have this experience. Try to cat the /dev/input/event3 and press the key to check if any event trigger. If yes then that could be the SLEEP_KEY have no action for OS.

@ShaneCCC

I cat /dev/input/event3 and press the key,it is nothing to appear,but cat the event2 I will saw a lot character when I after press S2 and CTRL + C.

I also check the file /dev/input/event2 before changed , I press the key S2 ,it will appear a lot character.

Please check the event type by
sudo ll /dev/input/by-path/

@ShaneCCC
I have successfully debugged. because of my carelessness,I made a mistake about gpio number.