1 --- a/board/mediatek/mt7622/mt7622_rfb.c
2 +++ b/board/mediatek/mt7622/mt7622_rfb.c
11 #include <asm/global_data.h>
12 +#include <linux/delay.h>
14 +#ifndef CONFIG_RESET_BUTTON_LABEL
15 +#define CONFIG_RESET_BUTTON_LABEL "reset"
19 #include <linux/mtd/mtd.h>
20 @@ -25,7 +32,19 @@ int board_init(void)
22 int board_late_init(void)
24 - gd->env_valid = 1; //to load environment variable from persistent store
25 + struct udevice *dev;
27 + if (!button_get_by_label(CONFIG_RESET_BUTTON_LABEL, &dev)) {
28 + puts("reset button found\n");
29 +#ifdef CONFIG_RESET_BUTTON_SETTLE_DELAY
30 + mdelay(CONFIG_RESET_BUTTON_SETTLE_DELAY);
32 + if (button_get_state(dev) == BUTTON_ON) {
33 + puts("button pushed, resetting environment\n");
34 + gd->env_valid = ENV_INVALID;
41 --- a/arch/arm/mach-mediatek/Kconfig
42 +++ b/arch/arm/mach-mediatek/Kconfig
43 @@ -138,4 +138,8 @@ config MTK_BROM_HEADER_INFO
45 source "board/mediatek/mt7629/Kconfig"
47 +config RESET_BUTTON_LABEL
48 + string "Button to trigger factory reset"