Set gpio for reset button

i want set gpio 9 for reset button in openwrt
how set this gpio9 for reset button . The value of this gpio varies between 0 and 1 when the key is pressed and the key is released

Generally in the DTS for the device in the keys section.

As one example:

        keys {
                compatible = "gpio-keys";

                button@0 {
                        label = "reset";
                        linux,code = <KEY_RESTART>;
                        gpios = <&tlmm 50 GPIO_ACTIVE_LOW>;
                };
[...]
1 Like

@jeff i change this dts file for my modem model

	keys {
		compatible = "gpio-keys-polled";
		poll-interval = <20>;

		reset {
			label = "reset";
			gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_RESTART>;
		};

but after build not change anything

Do you see the key listed in /proc/device-tree on your running device?

root@test:~# ls /proc/device-tree/keys/
button@0    button@1    compatible  name

Is it the only key? Is the bottom bracket missing in the .dts too?

keys {
		compatible = "gpio-keys-polled";
		poll-interval = <20>;

		reset {
			label = "reset";
			gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_RESTART>;
		};
};

@jeff
@vov4ik_il
can change this gpio for reset button
and solve this problem
but i want change 0x10000060 registry value in source
how change this ?

Iā€™m sorry but I am not quite sure what are you asking.
If your button uses GPIO 9, use &gpio9 In the above section.
If you want to write to a register on a device - you are supposed to use the driver.

Forget gpio9
I want to change the registry value for mt7628
I want to change the 0x10000060 registry value

If you want someone to help, try being polite.

This register seems to be the gpio control, what exactly are you trying to achieve?
http://www.programmersought.com/article/5654387037/

I do not think my answer was rude
I just had a separate question from GPIO9 and I explained it to you

Yes, that's what I mean
But I want to know where in OPENWRT source I can change this

The device tree has generic structure, even names are same as those in this article...
If you are trying to connect I2C using GPIO there is a way of doing that without rewriting stuff...
https://openwrt.org/docs/techref/hardware/port.i2c
What is the end goal?

What are your current GPIO pins? Does pressing any button trigger action under hotplug?rc.button ? These are programmed by vendor as part of MFG. Can be changed but in GPIO driver.

root@OpenWrt:/sys/class/leds# cat /sys/kernel/debug/gpio
GPIOs 0-63, ecnt:
gpio-0   (BTN_0               ) in  hi
gpio-48  (BTN_2               ) in  lo
gpio-49  (BTN_1               ) in  lo

The device's DTS