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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. --- a/board/mediatek/mt7623/mt7623_rfb.c
  2. +++ b/board/mediatek/mt7623/mt7623_rfb.c
  3. @@ -4,9 +4,18 @@
  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 <part.h>
  12. #include <asm/global_data.h>
  13. +#include <linux/delay.h>
  14. +
  15. +#ifndef CONFIG_RESET_BUTTON_LABEL
  16. +#define CONFIG_RESET_BUTTON_LABEL "reset"
  17. +#endif
  18. DECLARE_GLOBAL_DATA_PTR;
  19. @@ -60,3 +69,25 @@ int mmc_get_env_dev(void)
  20. return dev_seq(dev);
  21. }
  22. #endif
  23. +
  24. +int board_late_init(void)
  25. +{
  26. + struct udevice *dev;
  27. +
  28. + if (!button_get_by_label(CONFIG_RESET_BUTTON_LABEL, &dev)) {
  29. + puts("reset button found\n");
  30. +#ifdef CONFIG_RESET_BUTTON_SETTLE_DELAY
  31. + if (CONFIG_RESET_BUTTON_SETTLE_DELAY > 0) {
  32. + button_get_state(dev);
  33. + mdelay(CONFIG_RESET_BUTTON_SETTLE_DELAY);
  34. + }
  35. +#endif
  36. + if (button_get_state(dev) == BUTTON_ON) {
  37. + puts("button pushed, resetting environment\n");
  38. + gd->env_valid = ENV_INVALID;
  39. + }
  40. + }
  41. +
  42. + env_relocate();
  43. + return 0;
  44. +}