305-mt7988-generic-reset-button-ignore-env.patch 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --- a/board/mediatek/mt7988/mt7988_rfb.c
  2. +++ b/board/mediatek/mt7988/mt7988_rfb.c
  3. @@ -4,7 +4,43 @@
  4. * Author: Sam Shih <[email protected]>
  5. */
  6. +#include <common.h>
  7. +#include <config.h>
  8. +#include <dm.h>
  9. +#include <button.h>
  10. +#include <env.h>
  11. +#include <init.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. +
  19. int board_init(void)
  20. {
  21. return 0;
  22. }
  23. +
  24. +int board_late_init(void)
  25. +{
  26. + gd->env_valid = 1; //to load environment variable from persistent store
  27. + struct udevice *dev;
  28. +
  29. + gd->env_valid = ENV_VALID;
  30. + if (!button_get_by_label(CONFIG_RESET_BUTTON_LABEL, &dev)) {
  31. + puts("reset button found\n");
  32. +#ifdef CONFIG_RESET_BUTTON_SETTLE_DELAY
  33. + if (CONFIG_RESET_BUTTON_SETTLE_DELAY > 0) {
  34. + button_get_state(dev);
  35. + mdelay(CONFIG_RESET_BUTTON_SETTLE_DELAY);
  36. + }
  37. +#endif
  38. + if (button_get_state(dev) == BUTTON_ON) {
  39. + puts("button pushed, resetting environment\n");
  40. + gd->env_valid = ENV_INVALID;
  41. + }
  42. + }
  43. + env_relocate();
  44. + return 0;
  45. +}