2
0

301-mt7622-generic-reset-button-ignore-env.patch 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. --- a/board/mediatek/mt7622/mt7622_rfb.c
  2. +++ b/board/mediatek/mt7622/mt7622_rfb.c
  3. @@ -6,9 +6,16 @@
  4. #include <common.h>
  5. #include <config.h>
  6. +#include <dm.h>
  7. +#include <button.h>
  8. #include <env.h>
  9. #include <init.h>
  10. #include <asm/global_data.h>
  11. +#include <linux/delay.h>
  12. +
  13. +#ifndef CONFIG_RESET_BUTTON_LABEL
  14. +#define CONFIG_RESET_BUTTON_LABEL "reset"
  15. +#endif
  16. #include <mtd.h>
  17. #include <linux/mtd/mtd.h>
  18. @@ -24,7 +31,22 @@ int board_init(void)
  19. int board_late_init(void)
  20. {
  21. - gd->env_valid = 1; //to load environment variable from persistent store
  22. + struct udevice *dev;
  23. +
  24. + if (!button_get_by_label(CONFIG_RESET_BUTTON_LABEL, &dev)) {
  25. + puts("reset button found\n");
  26. +#ifdef CONFIG_RESET_BUTTON_SETTLE_DELAY
  27. + if (CONFIG_RESET_BUTTON_SETTLE_DELAY > 0) {
  28. + button_get_state(dev);
  29. + mdelay(CONFIG_RESET_BUTTON_SETTLE_DELAY);
  30. + }
  31. +#endif
  32. + if (button_get_state(dev) == BUTTON_ON) {
  33. + puts("button pushed, resetting environment\n");
  34. + gd->env_valid = ENV_INVALID;
  35. + }
  36. + }
  37. +
  38. env_relocate();
  39. return 0;
  40. }
  41. --- a/arch/arm/mach-mediatek/Kconfig
  42. +++ b/arch/arm/mach-mediatek/Kconfig
  43. @@ -151,4 +151,11 @@ config MTK_BROM_HEADER_INFO
  44. source "board/mediatek/mt7629/Kconfig"
  45. +config RESET_BUTTON_LABEL
  46. + string "Button to trigger factory reset"
  47. + default "reset"
  48. +
  49. +config RESET_BUTTON_SETTLE_DELAY
  50. + int "Delay to wait for button to settle"
  51. + default 0
  52. endif