[openwrt/openwrt] uboot-mediatek: fix factory/reset button
LEDE Commits
lede-commits at lists.infradead.org
Thu Apr 20 03:41:17 PDT 2023
dangole pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/42eeb22450f2c3225fa79a75c0ba881ac6809a77
commit 42eeb22450f2c3225fa79a75c0ba881ac6809a77
Author: Daniel Golle <daniel at makrotopia.org>
AuthorDate: Thu Apr 20 11:31:49 2023 +0100
uboot-mediatek: fix factory/reset button
U-Boot commit ea6fdc13595 ("dm: button: add support for linux_code in
button-gpio.c driver") makes it mandatory to specify linux,code for all
buttons. As that broke handling of the reset button in U-Boot with the
update to U-Boot 2023.04, add linux,code for all butons.
Reported-by: @DragonBluep
Fixes: 50f7c5af4a ("uboot-mediatek: update to v2023.04")
Signed-off-by: Daniel Golle <daniel at makrotopia.org>
---
...01-mt7622-generic-reset-button-ignore-env.patch | 12 ++++--
...02-mt7623-generic-reset-button-ignore-env.patch | 7 +++-
...03-mt7986-generic-reset-button-ignore-env.patch | 7 +++-
.../patches/400-update-bpir2-defconfig.patch | 11 ++++-
.../patches/401-update-u7623-defconfig.patch | 49 ++++++++++++++++++++++
.../402-update-bananapi-bpi-r64-device-tree.patch | 20 ++++++---
.../patches/403-add-bananapi_bpi-r64-snand.patch | 4 +-
.../patches/405-dts-mt7623n-bpi-r2-fix-leds.patch | 2 +-
...-dts-mt7623n-bpi-r2-uart0-force-highspeed.patch | 2 +-
.../patches/410-add-linksys-e8450.patch | 5 ++-
.../patches/412-add-ubnt-unifi-6-lr.patch | 4 +-
.../uboot-mediatek/patches/430-add-bpi-r3.patch | 4 +-
.../patches/431-add-xiaomi_redmi-ax6000.patch | 5 ++-
13 files changed, 110 insertions(+), 22 deletions(-)
diff --git a/package/boot/uboot-mediatek/patches/301-mt7622-generic-reset-button-ignore-env.patch b/package/boot/uboot-mediatek/patches/301-mt7622-generic-reset-button-ignore-env.patch
index 63301fd535..1862a9344a 100644
--- a/package/boot/uboot-mediatek/patches/301-mt7622-generic-reset-button-ignore-env.patch
+++ b/package/boot/uboot-mediatek/patches/301-mt7622-generic-reset-button-ignore-env.patch
@@ -17,7 +17,7 @@
#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)
{
@@ -27,7 +27,10 @@
+ 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");
@@ -40,7 +43,7 @@
}
--- 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"
@@ -48,4 +51,7 @@
+ string "Button to trigger factory reset"
+ default "reset"
+
++config RESET_BUTTON_SETTLE_DELAY
++ int "Delay to wait for button to settle"
++ default 0
endif
diff --git a/package/boot/uboot-mediatek/patches/302-mt7623-generic-reset-button-ignore-env.patch b/package/boot/uboot-mediatek/patches/302-mt7623-generic-reset-button-ignore-env.patch
index e144f42c47..928dfe8428 100644
--- a/package/boot/uboot-mediatek/patches/302-mt7623-generic-reset-button-ignore-env.patch
+++ b/package/boot/uboot-mediatek/patches/302-mt7623-generic-reset-button-ignore-env.patch
@@ -18,7 +18,7 @@
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
@@ -30,7 +30,10 @@
+ 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");
diff --git a/package/boot/uboot-mediatek/patches/303-mt7986-generic-reset-button-ignore-env.patch b/package/boot/uboot-mediatek/patches/303-mt7986-generic-reset-button-ignore-env.patch
index 0af267c50d..45290149f3 100644
--- a/package/boot/uboot-mediatek/patches/303-mt7986-generic-reset-button-ignore-env.patch
+++ b/package/boot/uboot-mediatek/patches/303-mt7986-generic-reset-button-ignore-env.patch
@@ -17,7 +17,7 @@
#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)
{
@@ -28,7 +28,10 @@
+ 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");
diff --git a/package/boot/uboot-mediatek/patches/400-update-bpir2-defconfig.patch b/package/boot/uboot-mediatek/patches/400-update-bpir2-defconfig.patch
index 942f86a928..7ebe5c0fc7 100644
--- a/package/boot/uboot-mediatek/patches/400-update-bpir2-defconfig.patch
+++ b/package/boot/uboot-mediatek/patches/400-update-bpir2-defconfig.patch
@@ -213,7 +213,15 @@
+_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";
};
};
@@ -224,6 +232,7 @@
+ factory {
+ label = "factory";
+ gpios = <&gpio 256 GPIO_ACTIVE_LOW>;
++ linux,code = <KEY_RESTART>;
+ };
+ };
};
diff --git a/package/boot/uboot-mediatek/patches/401-update-u7623-defconfig.patch b/package/boot/uboot-mediatek/patches/401-update-u7623-defconfig.patch
index 5862ad7343..453456c94f 100644
--- a/package/boot/uboot-mediatek/patches/401-update-u7623-defconfig.patch
+++ b/package/boot/uboot-mediatek/patches/401-update-u7623-defconfig.patch
@@ -191,3 +191,52 @@
+_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 [33m$ver[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";
diff --git a/package/boot/uboot-mediatek/patches/402-update-bananapi-bpi-r64-device-tree.patch b/package/boot/uboot-mediatek/patches/402-update-bananapi-bpi-r64-device-tree.patch
index ca8f371d61..c8066a7e2d 100644
--- a/package/boot/uboot-mediatek/patches/402-update-bananapi-bpi-r64-device-tree.patch
+++ b/package/boot/uboot-mediatek/patches/402-update-bananapi-bpi-r64-device-tree.patch
@@ -1,6 +1,14 @@
--- 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;
@@ -8,7 +16,7 @@
};
memory at 40000000 {
-@@ -27,6 +28,42 @@
+@@ -27,6 +29,44 @@
reg = <0x40000000 0x40000000>;
};
@@ -18,11 +26,13 @@
+ 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>;
+ };
+ };
+
@@ -51,7 +61,7 @@
reg_1p8v: regulator-1p8v {
compatible = "regulator-fixed";
regulator-name = "fixed-1.8V";
-@@ -182,6 +219,7 @@
+@@ -182,6 +222,7 @@
};
&uart0 {
@@ -59,7 +69,7 @@
status = "okay";
};
-@@ -197,7 +235,7 @@
+@@ -197,7 +238,7 @@
status = "okay";
bus-width = <8>;
max-frequency = <50000000>;
@@ -68,7 +78,7 @@
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>;
diff --git a/package/boot/uboot-mediatek/patches/403-add-bananapi_bpi-r64-snand.patch b/package/boot/uboot-mediatek/patches/403-add-bananapi_bpi-r64-snand.patch
index 1dc2a84893..a414f0a8b5 100644
--- a/package/boot/uboot-mediatek/patches/403-add-bananapi_bpi-r64-snand.patch
+++ b/package/boot/uboot-mediatek/patches/403-add-bananapi_bpi-r64-snand.patch
@@ -1,6 +1,6 @@
--- 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 {
@@ -9,7 +9,7 @@
ethernet0 = ð
};
-@@ -205,17 +205,11 @@
+@@ -208,17 +208,11 @@
};
};
diff --git a/package/boot/uboot-mediatek/patches/405-dts-mt7623n-bpi-r2-fix-leds.patch b/package/boot/uboot-mediatek/patches/405-dts-mt7623n-bpi-r2-fix-leds.patch
index 8748192902..2ebbba8a85 100644
--- a/package/boot/uboot-mediatek/patches/405-dts-mt7623n-bpi-r2-fix-leds.patch
+++ b/package/boot/uboot-mediatek/patches/405-dts-mt7623n-bpi-r2-fix-leds.patch
@@ -1,6 +1,6 @@
--- 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";
diff --git a/package/boot/uboot-mediatek/patches/406-dts-mt7623n-bpi-r2-uart0-force-highspeed.patch b/package/boot/uboot-mediatek/patches/406-dts-mt7623n-bpi-r2-uart0-force-highspeed.patch
index 8e4c32697e..6710e3ea4e 100644
--- a/package/boot/uboot-mediatek/patches/406-dts-mt7623n-bpi-r2-uart0-force-highspeed.patch
+++ b/package/boot/uboot-mediatek/patches/406-dts-mt7623n-bpi-r2-uart0-force-highspeed.patch
@@ -1,6 +1,6 @@
--- 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>;
diff --git a/package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch b/package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch
index 5a419e9432..2e85e6c3ce 100644
--- a/package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch
+++ b/package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch
@@ -144,7 +144,7 @@
+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.
@@ -152,6 +152,7 @@
+ */
+
+/dts-v1/;
++#include <dt-bindings/input/linux-event-codes.h>
+#include "mt7622.dtsi"
+#include "mt7622-u-boot.dtsi"
+
@@ -175,11 +176,13 @@
+ 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>;
+ };
+ };
+
diff --git a/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch b/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch
index edeb4a6895..88e724ebb8 100644
--- a/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch
+++ b/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch
@@ -158,6 +158,7 @@
+ */
+
+/dts-v1/;
++#include <dt-bindings/input/linux-event-codes.h>
+#include "mt7622.dtsi"
+#include "mt7622-u-boot.dtsi"
+
@@ -178,12 +179,11 @@
+
+ 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>;
+ };
+ };
+
diff --git a/package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch b/package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch
index 2859ae42bf..855f39ed97 100644
--- a/package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch
+++ b/package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch
@@ -851,7 +851,7 @@
+
--- /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.
@@ -859,6 +859,7 @@
+ */
+
+/dts-v1/;
++#include <dt-bindings/input/linux-event-codes.h>
+#include "mt7986.dtsi"
+#include <dt-bindings/gpio/gpio.h>
+
@@ -893,6 +894,7 @@
+ wps {
+ label = "reset";
+ gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
++ linux,code = <KEY_RESTART>;
+ };
+ };
+
diff --git a/package/boot/uboot-mediatek/patches/431-add-xiaomi_redmi-ax6000.patch b/package/boot/uboot-mediatek/patches/431-add-xiaomi_redmi-ax6000.patch
index 56c60ff438..2d3f1aabea 100644
--- a/package/boot/uboot-mediatek/patches/431-add-xiaomi_redmi-ax6000.patch
+++ b/package/boot/uboot-mediatek/patches/431-add-xiaomi_redmi-ax6000.patch
@@ -183,7 +183,7 @@
+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.
@@ -191,6 +191,7 @@
+ */
+
+/dts-v1/;
++#include <dt-bindings/input/linux-event-codes.h>
+#include "mt7986.dtsi"
+#include <dt-bindings/gpio/gpio.h>
+
@@ -210,10 +211,12 @@
+ 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>;
+ };
+ };
+};
More information about the lede-commits
mailing list