wdt.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2016 Google, Inc
  4. */
  5. #ifndef _ASM_ARCH_WDT_H
  6. #define _ASM_ARCH_WDT_H
  7. #define WDT_BASE 0x1e785000
  8. /*
  9. * Special value that needs to be written to counter_restart register to
  10. * (re)start the timer
  11. */
  12. #define WDT_COUNTER_RESTART_VAL 0x4755
  13. /* Control register */
  14. #define WDT_CTRL_RESET_MODE_SHIFT 5
  15. #define WDT_CTRL_RESET_MODE_MASK 3
  16. #define WDT_CTRL_EN (1 << 0)
  17. #define WDT_CTRL_RESET (1 << 1)
  18. #define WDT_CTRL_CLK1MHZ (1 << 4)
  19. #define WDT_CTRL_2ND_BOOT (1 << 7)
  20. /* Values for Reset Mode */
  21. #define WDT_CTRL_RESET_SOC 0
  22. #define WDT_CTRL_RESET_CHIP 1
  23. #define WDT_CTRL_RESET_CPU 2
  24. #define WDT_CTRL_RESET_MASK 3
  25. /* Reset Mask register */
  26. #define WDT_RESET_ARM (1 << 0)
  27. #define WDT_RESET_COPROC (1 << 1)
  28. #define WDT_RESET_SDRAM (1 << 2)
  29. #define WDT_RESET_AHB (1 << 3)
  30. #define WDT_RESET_I2C (1 << 4)
  31. #define WDT_RESET_MAC1 (1 << 5)
  32. #define WDT_RESET_MAC2 (1 << 6)
  33. #define WDT_RESET_GCRT (1 << 7)
  34. #define WDT_RESET_USB20 (1 << 8)
  35. #define WDT_RESET_USB11_HOST (1 << 9)
  36. #define WDT_RESET_USB11_EHCI2 (1 << 10)
  37. #define WDT_RESET_VIDEO (1 << 11)
  38. #define WDT_RESET_HAC (1 << 12)
  39. #define WDT_RESET_LPC (1 << 13)
  40. #define WDT_RESET_SDSDIO (1 << 14)
  41. #define WDT_RESET_MIC (1 << 15)
  42. #define WDT_RESET_CRT2C (1 << 16)
  43. #define WDT_RESET_PWM (1 << 17)
  44. #define WDT_RESET_PECI (1 << 18)
  45. #define WDT_RESET_JTAG (1 << 19)
  46. #define WDT_RESET_ADC (1 << 20)
  47. #define WDT_RESET_GPIO (1 << 21)
  48. #define WDT_RESET_MCTP (1 << 22)
  49. #define WDT_RESET_XDMA (1 << 23)
  50. #define WDT_RESET_SPI (1 << 24)
  51. #define WDT_RESET_MISC (1 << 25)
  52. #ifndef __ASSEMBLY__
  53. struct ast_wdt {
  54. u32 counter_status;
  55. u32 counter_reload_val;
  56. u32 counter_restart;
  57. u32 ctrl;
  58. u32 timeout_status;
  59. u32 clr_timeout_status;
  60. u32 reset_width;
  61. /* On pre-ast2500 SoCs this register is reserved. */
  62. u32 reset_mask;
  63. };
  64. /**
  65. * Given flags parameter passed to wdt_reset or wdt_start uclass functions,
  66. * gets Reset Mode value from it.
  67. *
  68. * @flags: flags parameter passed into wdt_reset or wdt_start
  69. * @return Reset Mode value
  70. */
  71. u32 ast_reset_mode_from_flags(ulong flags);
  72. /**
  73. * Given flags parameter passed to wdt_reset or wdt_start uclass functions,
  74. * gets Reset Mask value from it. Reset Mask is only supported on ast2500
  75. *
  76. * @flags: flags parameter passed into wdt_reset or wdt_start
  77. * @return Reset Mask value
  78. */
  79. u32 ast_reset_mask_from_flags(ulong flags);
  80. /**
  81. * Given Reset Mask and Reset Mode values, converts them to flags,
  82. * suitable for passing into wdt_start or wdt_reset uclass functions.
  83. *
  84. * On ast2500 Reset Mask is 25 bits wide and Reset Mode is 2 bits wide, so they
  85. * can both be packed into single 32 bits wide value.
  86. *
  87. * @reset_mode: Reset Mode
  88. * @reset_mask: Reset Mask
  89. */
  90. ulong ast_flags_from_reset_mode_mask(u32 reset_mode, u32 reset_mask);
  91. #endif /* __ASSEMBLY__ */
  92. #endif /* _ASM_ARCH_WDT_H */