#include <mtd.h>
#include <linux/mtd/mtd.h>
-@@ -25,7 +32,19 @@ int board_init(void)
+@@ -25,7 +32,22 @@ int board_init(void)
int board_late_init(void)
{
+ if (!button_get_by_label(CONFIG_RESET_BUTTON_LABEL, &dev)) {
+ puts("reset button found\n");
+#ifdef CONFIG_RESET_BUTTON_SETTLE_DELAY
-+ mdelay(CONFIG_RESET_BUTTON_SETTLE_DELAY);
++ if (CONFIG_RESET_BUTTON_SETTLE_DELAY > 0) {
++ button_get_state(dev);
++ mdelay(CONFIG_RESET_BUTTON_SETTLE_DELAY);
++ }
+#endif
+ if (button_get_state(dev) == BUTTON_ON) {
+ puts("button pushed, resetting environment\n");
}
--- a/arch/arm/mach-mediatek/Kconfig
+++ b/arch/arm/mach-mediatek/Kconfig
-@@ -140,4 +140,8 @@ config MTK_BROM_HEADER_INFO
+@@ -140,4 +140,11 @@ config MTK_BROM_HEADER_INFO
source "board/mediatek/mt7629/Kconfig"
+ string "Button to trigger factory reset"
+ default "reset"
+
++config RESET_BUTTON_SETTLE_DELAY
++ int "Delay to wait for button to settle"
++ default 0
endif
DECLARE_GLOBAL_DATA_PTR;
-@@ -41,3 +50,22 @@ int mmc_get_env_dev(void)
+@@ -41,3 +50,25 @@ int mmc_get_env_dev(void)
return mmc_get_boot_dev();
}
#endif
+ if (!button_get_by_label(CONFIG_RESET_BUTTON_LABEL, &dev)) {
+ puts("reset button found\n");
+#ifdef CONFIG_RESET_BUTTON_SETTLE_DELAY
-+ mdelay(CONFIG_RESET_BUTTON_SETTLE_DELAY);
++ if (CONFIG_RESET_BUTTON_SETTLE_DELAY > 0) {
++ button_get_state(dev);
++ mdelay(CONFIG_RESET_BUTTON_SETTLE_DELAY);
++ }
+#endif
+ if (button_get_state(dev) == BUTTON_ON) {
+ puts("button pushed, resetting environment\n");
#include <mtd.h>
#include <linux/mtd/mtd.h>
-@@ -24,7 +31,19 @@ int board_init(void)
+@@ -24,7 +31,22 @@ int board_init(void)
int board_late_init(void)
{
+ if (!button_get_by_label(CONFIG_RESET_BUTTON_LABEL, &dev)) {
+ puts("reset button found\n");
+#ifdef CONFIG_RESET_BUTTON_SETTLE_DELAY
-+ mdelay(CONFIG_RESET_BUTTON_SETTLE_DELAY);
++ if (CONFIG_RESET_BUTTON_SETTLE_DELAY > 0) {
++ button_get_state(dev);
++ mdelay(CONFIG_RESET_BUTTON_SETTLE_DELAY);
++ }
+#endif
+ if (button_get_state(dev) == BUTTON_ON) {
+ puts("button pushed, resetting environment\n");
+_set_bmf=setenv _set_bmf ; setenv bootmenu_${_menu_next} "Reset all settings to factory defaults.=run reset_factory ; reset" ; setenv _menu_next
--- a/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
+++ b/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
-@@ -66,6 +66,15 @@
+@@ -6,6 +6,7 @@
+ */
+
+ /dts-v1/;
++#include <dt-bindings/input/linux-event-codes.h>
+ #include "mt7623.dtsi"
+ #include "mt7623-u-boot.dtsi"
+
+@@ -66,6 +67,16 @@
default-state = "off";
};
};
+ factory {
+ label = "factory";
+ gpios = <&gpio 256 GPIO_ACTIVE_LOW>;
++ linux,code = <KEY_RESTART>;
+ };
+ };
};
+_update_bootdev=setenv _update_bootdev ; setenv bootargs "$console root=/dev/mmcblk0p65"
+_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title
+_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title \e[33m$ver\e[0m"
+--- a/arch/arm/dts/mt7623a-unielec-u7623-02-emmc.dts
++++ b/arch/arm/dts/mt7623a-unielec-u7623-02-emmc.dts
+@@ -6,6 +6,7 @@
+ */
+
+ /dts-v1/;
++#include <dt-bindings/input/linux-event-codes.h>
+ #include "mt7623.dtsi"
+ #include "mt7623-u-boot.dtsi"
+
+@@ -50,6 +51,18 @@
+ regulator-always-on;
+ };
+
++ gpio-keys {
++ compatible = "gpio-keys";
++ pinctrl-names = "default";
++ pinctrl-0 = <&key_pins_a>;
++
++ factory {
++ label = "factory";
++ gpios = <&gpio 256 GPIO_ACTIVE_LOW>;
++ linux,code = <KEY_RESTART>;
++ };
++ };
++
+ leds {
+ compatible = "gpio-leds";
+
+@@ -109,6 +122,19 @@
+ };
+ };
+
++ key_pins_a: keys-alt {
++ mux {
++ function = "gpio";
++ groups = "msdc3";
++ };
++
++ conf {
++ pins = "MSDC0E_DAT0", "MSDC0E_DAT1";
++ input-enable;
++ bias-pull-up;
++ };
++ };
++
+ mmc0_pins_default: mmc0default {
+ mux {
+ function = "msdc";
--- a/arch/arm/dts/mt7622-bananapi-bpi-r64.dts
+++ b/arch/arm/dts/mt7622-bananapi-bpi-r64.dts
-@@ -20,6 +20,7 @@
+@@ -5,6 +5,7 @@
+ */
+
+ /dts-v1/;
++#include <dt-bindings/input/linux-event-codes.h>
+ #include "mt7622.dtsi"
+ #include "mt7622-u-boot.dtsi"
+
+@@ -20,6 +21,7 @@
aliases {
spi0 = &snfi;
};
memory@40000000 {
-@@ -27,6 +28,42 @@
+@@ -27,6 +29,44 @@
reg = <0x40000000 0x40000000>;
};
+ reset {
+ label = "reset";
+ gpios = <&gpio 0 GPIO_ACTIVE_LOW>;
++ linux,code = <KEY_RESTART>;
+ };
+
+ wps {
+ label = "wps";
+ gpios = <&gpio 102 GPIO_ACTIVE_LOW>;
++ linux,code = <KEY_WPS_BUTTON>;
+ };
+ };
+
reg_1p8v: regulator-1p8v {
compatible = "regulator-fixed";
regulator-name = "fixed-1.8V";
-@@ -182,6 +219,7 @@
+@@ -182,6 +222,7 @@
};
&uart0 {
status = "okay";
};
-@@ -197,7 +235,7 @@
+@@ -197,7 +238,7 @@
status = "okay";
bus-width = <8>;
max-frequency = <50000000>;
vmmc-supply = <®_3p3v>;
vqmmc-supply = <®_3p3v>;
non-removable;
-@@ -208,7 +246,7 @@
+@@ -208,7 +249,7 @@
pinctrl-0 = <&mmc1_pins_default>;
status = "okay";
bus-width = <4>;
--- a/arch/arm/dts/mt7622-bananapi-bpi-r64.dts
+++ b/arch/arm/dts/mt7622-bananapi-bpi-r64.dts
-@@ -19,7 +19,7 @@
+@@ -20,7 +20,7 @@
};
aliases {
ethernet0 = ð
};
-@@ -205,17 +205,11 @@
+@@ -208,17 +208,11 @@
};
};
--- a/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
+++ b/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
-@@ -50,19 +50,19 @@
+@@ -51,19 +51,19 @@
blue {
label = "bpi-r2:pio:blue";
--- a/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
+++ b/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
-@@ -243,6 +243,7 @@
+@@ -245,6 +245,7 @@
&uart0 {
pinctrl-names = "default";
pinctrl-0 = <&uart0_pins_a>;
+CONFIG_USB_STORAGE=y
--- /dev/null
+++ b/arch/arm/dts/mt7622-linksys-e8450-ubi.dts
-@@ -0,0 +1,194 @@
+@@ -0,0 +1,197 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2019 MediaTek Inc.
+ */
+
+/dts-v1/;
++#include <dt-bindings/input/linux-event-codes.h>
+#include "mt7622.dtsi"
+#include "mt7622-u-boot.dtsi"
+
+ factory {
+ label = "reset";
+ gpios = <&gpio 0 GPIO_ACTIVE_LOW>;
++ linux,code = <KEY_RESTART>;
+ };
+
+ wps {
+ label = "wps";
+ gpios = <&gpio 102 GPIO_ACTIVE_LOW>;
++ linux,code = <KEY_WPS_BUTTON>;
+ };
+ };
+
+ */
+
+/dts-v1/;
++#include <dt-bindings/input/linux-event-codes.h>
+#include "mt7622.dtsi"
+#include "mt7622-u-boot.dtsi"
+
+
+ gpio-keys {
+ compatible = "gpio-keys";
-+ u-boot,dm-pre-reloc;
+
+ reset {
+ label = "reset";
+ gpios = <&gpio 62 GPIO_ACTIVE_LOW>;
-+ u-boot,dm-pre-reloc;
++ linux,code = <KEY_RESTART>;
+ };
+ };
+
+
--- /dev/null
+++ b/arch/arm/dts/mt7986a-bpi-r3-sd.dts
-@@ -0,0 +1,270 @@
+@@ -0,0 +1,272 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ */
+
+/dts-v1/;
++#include <dt-bindings/input/linux-event-codes.h>
+#include "mt7986.dtsi"
+#include <dt-bindings/gpio/gpio.h>
+
+ wps {
+ label = "reset";
+ gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
++ linux,code = <KEY_RESTART>;
+ };
+ };
+
+CONFIG_SERVERIP="192.168.1.254"
--- /dev/null
+++ b/arch/arm/dts/mt7986a-xiaomi_redmi-ax6000.dts
-@@ -0,0 +1,153 @@
+@@ -0,0 +1,156 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ */
+
+/dts-v1/;
++#include <dt-bindings/input/linux-event-codes.h>
+#include "mt7986.dtsi"
+#include <dt-bindings/gpio/gpio.h>
+
+ factory {
+ label = "reset";
+ gpios = <&gpio 9 GPIO_ACTIVE_LOW>;
++ linux,code = <KEY_RESTART>;
+ };
+ mesh {
+ label = "mesh";
+ gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
++ linux,code = <KEY_WPS_BUTTON>;
+ };
+ };
+};