8b382487572e85f673de9214c3ecb44a0b398faa
[openwrt/staging/zorun.git] / package / boot / uboot-mediatek / patches / 300-mt7622-generic-reset-button-ignore-env.patch
1 --- a/board/mediatek/mt7622/mt7622_rfb.c
2 +++ b/board/mediatek/mt7622/mt7622_rfb.c
3 @@ -6,9 +6,16 @@
4
5 #include <common.h>
6 #include <config.h>
7 +#include <dm.h>
8 +#include <button.h>
9 #include <env.h>
10 #include <init.h>
11 #include <asm/global_data.h>
12 +#include <linux/delay.h>
13 +
14 +#ifndef CONFIG_RESET_BUTTON_LABEL
15 +#define CONFIG_RESET_BUTTON_LABEL "reset"
16 +#endif
17
18 DECLARE_GLOBAL_DATA_PTR;
19
20 @@ -20,7 +27,19 @@ int board_init(void)
21
22 int board_late_init(void)
23 {
24 - gd->env_valid = 1; //to load environment variable from persistent store
25 + struct udevice *dev;
26 + int ret;
27 +
28 + ret = !!button_get_by_label(CONFIG_RESET_BUTTON_LABEL, &dev);
29 +
30 + if (!ret) {
31 +#ifdef CONFIG_RESET_BUTTON_SETTLE_DELAY
32 + udelay(1000 * CONFIG_RESET_BUTTON_SETTLE_DELAY);
33 +#endif
34 + ret = !button_get_state(dev);
35 + }
36 +
37 + gd->env_valid = ret; //to load environment variable from persistent store
38 env_relocate();
39 return 0;
40 }