uboot-mediatek: fix factory/reset button
authorDaniel Golle <daniel@makrotopia.org>
Thu, 20 Apr 2023 10:31:49 +0000 (11:31 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Thu, 20 Apr 2023 10:40:24 +0000 (11:40 +0100)
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@makrotopia.org>
13 files changed:
package/boot/uboot-mediatek/patches/301-mt7622-generic-reset-button-ignore-env.patch
package/boot/uboot-mediatek/patches/302-mt7623-generic-reset-button-ignore-env.patch
package/boot/uboot-mediatek/patches/303-mt7986-generic-reset-button-ignore-env.patch
package/boot/uboot-mediatek/patches/400-update-bpir2-defconfig.patch
package/boot/uboot-mediatek/patches/401-update-u7623-defconfig.patch
package/boot/uboot-mediatek/patches/402-update-bananapi-bpi-r64-device-tree.patch
package/boot/uboot-mediatek/patches/403-add-bananapi_bpi-r64-snand.patch
package/boot/uboot-mediatek/patches/405-dts-mt7623n-bpi-r2-fix-leds.patch
package/boot/uboot-mediatek/patches/406-dts-mt7623n-bpi-r2-uart0-force-highspeed.patch
package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch
package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch
package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch
package/boot/uboot-mediatek/patches/431-add-xiaomi_redmi-ax6000.patch

index 63301fd53513173360cde0044d44115c56f8b15d..1862a9344ad631cfce033f1764b4050f2832b321 100644 (file)
@@ -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)
  {
 +      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
index e144f42c479770a0256de184f649eb6f57b7a661..928dfe8428a3de2680a60e78110d185a980d7746 100644 (file)
@@ -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
 +      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");
index 0af267c50db60cf45bb33725a03343a63b0b31a3..45290149f3f0982ae4c66a6ee1bd117c2409eae4 100644 (file)
@@ -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)
  {
 +      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");
index 942f86a9289075b5656a04655a0b2cf3df86d109..7ebe5c0fc7a6d91126606ce4582cd17e53f0ae82 100644 (file)
 +_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>;
 +              };
 +      };
  };
index 5862ad7343d0bfc4854c19d8d430fb8ffc4f6477..453456c94f92b2c8282f0360e434e46ca9739987 100644 (file)
 +_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";
index ca8f371d61d7266a76782bc910a40e4ceb207683..c8066a7e2d4eb64ad99ee7b961d693023996f0ca 100644 (file)
@@ -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@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>;
 +              };
 +      };
 +
@@ -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 = <&reg_3p3v>;
        vqmmc-supply = <&reg_3p3v>;
        non-removable;
-@@ -208,7 +246,7 @@
+@@ -208,7 +249,7 @@
        pinctrl-0 = <&mmc1_pins_default>;
        status = "okay";
        bus-width = <4>;
index 1dc2a84893ab15606e4ff64cf280937fb548933d..a414f0a8b5cbc0cd82155b37c2fcc82e4e851553 100644 (file)
@@ -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 = &eth;
        };
  
-@@ -205,17 +205,11 @@
+@@ -208,17 +208,11 @@
        };
  };
  
index 874819290266aba309442a7af2b5f1f5a975c136..2ebbba8a85445f8b4d3de5176a543193a368309a 100644 (file)
@@ -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";
index 8e4c32697e968e1bb72e39e7640770c9cb1ca57a..6710e3ea4ee2ccca0e121443094c45a87305a3ba 100644 (file)
@@ -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>;
index 5a419e94325d37e08b389dc9b3b6bb01ffbef67b..2e85e6c3ce667294d0a590fcb3656ccb52ce1294 100644 (file)
 +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>;
 +              };
 +      };
 +
index edeb4a689599e67b32defd823f16ca9d89c1bc87..88e724ebb8c2b316d810d5a21f68031673c00101 100644 (file)
 + */
 +
 +/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>;
 +              };
 +      };
 +
index 2859ae42bf9b95ed2b7f9b2ca788a41ae224900d..855f39ed972848e442d0eedc5be2a995b865dd35 100644 (file)
 +
 --- /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>;
 +              };
 +      };
 +
index 56c60ff438802f3f96dd99fea43605e414f2f5c0..2d3f1aabea0e4eb61e50dcb8bed16946f495fb68 100644 (file)
 +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>;
 +              };
 +      };
 +};