2
0

302-mt7623-generic-reset-button-ignore-env.patch 980 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --- a/board/mediatek/mt7623/mt7623_rfb.c
  2. +++ b/board/mediatek/mt7623/mt7623_rfb.c
  3. @@ -4,8 +4,17 @@
  4. */
  5. #include <common.h>
  6. +#include <dm.h>
  7. +#include <button.h>
  8. +#include <env.h>
  9. +#include <init.h>
  10. #include <mmc.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. DECLARE_GLOBAL_DATA_PTR;
  18. @@ -41,3 +50,25 @@ int mmc_get_env_dev(void)
  19. return mmc_get_boot_dev();
  20. }
  21. #endif
  22. +
  23. +int board_late_init(void)
  24. +{
  25. + struct udevice *dev;
  26. +
  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. + if (CONFIG_RESET_BUTTON_SETTLE_DELAY > 0) {
  31. + button_get_state(dev);
  32. + mdelay(CONFIG_RESET_BUTTON_SETTLE_DELAY);
  33. + }
  34. +#endif
  35. + if (button_get_state(dev) == BUTTON_ON) {
  36. + puts("button pushed, resetting environment\n");
  37. + gd->env_valid = ENV_INVALID;
  38. + }
  39. + }
  40. +
  41. + env_relocate();
  42. + return 0;
  43. +}