reset.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * OMAP1 reset support
  4. */
  5. #include <linux/kernel.h>
  6. #include <linux/io.h>
  7. #include <linux/reboot.h>
  8. #include <mach/hardware.h>
  9. #include "iomap.h"
  10. #include "common.h"
  11. /* ARM_SYSST bit shifts related to SoC reset sources */
  12. #define ARM_SYSST_POR_SHIFT 5
  13. #define ARM_SYSST_EXT_RST_SHIFT 4
  14. #define ARM_SYSST_ARM_WDRST_SHIFT 2
  15. #define ARM_SYSST_GLOB_SWRST_SHIFT 1
  16. /* Standardized reset source bits (across all OMAP SoCs) */
  17. #define OMAP_GLOBAL_COLD_RST_SRC_ID_SHIFT 0
  18. #define OMAP_GLOBAL_WARM_RST_SRC_ID_SHIFT 1
  19. #define OMAP_MPU_WD_RST_SRC_ID_SHIFT 3
  20. #define OMAP_EXTWARM_RST_SRC_ID_SHIFT 5
  21. void omap1_restart(enum reboot_mode mode, const char *cmd)
  22. {
  23. /*
  24. * Workaround for 5912/1611b bug mentioned in sprz209d.pdf p. 28
  25. * "Global Software Reset Affects Traffic Controller Frequency".
  26. */
  27. if (cpu_is_omap5912()) {
  28. omap_writew(omap_readw(DPLL_CTL) & ~(1 << 4), DPLL_CTL);
  29. omap_writew(0x8, ARM_RSTCT1);
  30. }
  31. omap_writew(1, ARM_RSTCT1);
  32. }
  33. /**
  34. * omap1_get_reset_sources - return the source of the SoC's last reset
  35. *
  36. * Returns bits that represent the last reset source for the SoC. The
  37. * format is standardized across OMAPs for use by the OMAP watchdog.
  38. */
  39. u32 omap1_get_reset_sources(void)
  40. {
  41. u32 ret = 0;
  42. u16 rs;
  43. rs = __raw_readw(OMAP1_IO_ADDRESS(ARM_SYSST));
  44. if (rs & (1 << ARM_SYSST_POR_SHIFT))
  45. ret |= 1 << OMAP_GLOBAL_COLD_RST_SRC_ID_SHIFT;
  46. if (rs & (1 << ARM_SYSST_EXT_RST_SHIFT))
  47. ret |= 1 << OMAP_EXTWARM_RST_SRC_ID_SHIFT;
  48. if (rs & (1 << ARM_SYSST_ARM_WDRST_SHIFT))
  49. ret |= 1 << OMAP_MPU_WD_RST_SRC_ID_SHIFT;
  50. if (rs & (1 << ARM_SYSST_GLOB_SWRST_SHIFT))
  51. ret |= 1 << OMAP_GLOBAL_WARM_RST_SRC_ID_SHIFT;
  52. return ret;
  53. }