uboot-mediatek: update to 2021.04-rc3 with MediaTek's patches
[openwrt/staging/rmilecki.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,10 +6,17 @@
4
5 #include <common.h>
6 #include <config.h>
7 +#include <dm.h>
8 +#include <button.h>
9 +
10 #include <env.h>
11 #include <init.h>
12 #include <asm/global_data.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 int board_init(void)
21 @@ -20,7 +27,15 @@ int board_init(void)
22
23 int board_late_init(void)
24 {
25 - gd->env_valid = 1; //to load environment variable from persistent store
26 + struct udevice *dev;
27 + int ret;
28 +
29 + ret = !!button_get_by_label(CONFIG_RESET_BUTTON_LABEL, &dev);
30 +
31 + if (!ret)
32 + ret = !button_get_state(dev);
33 +
34 + gd->env_valid = ret; //to load environment variable from persistent store
35 env_relocate();
36 return 0;
37 }