hpm_mon_regs.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright (c) 2021 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef HPM_MON_H
  8. #define HPM_MON_H
  9. typedef struct {
  10. struct {
  11. __RW uint32_t CONTROL; /* 0x0: Glitch and clock monitor control */
  12. __RW uint32_t STATUS; /* 0x4: Glitch and clock monitor status */
  13. } MONITOR[4];
  14. __RW uint32_t TEST_MODE; /* 0x20: */
  15. __R uint8_t RESERVED0[28]; /* 0x24 - 0x3F: Reserved */
  16. __RW uint32_t IRQ_FLAG; /* 0x40: */
  17. __RW uint32_t IRQ_ENABLE; /* 0x44: */
  18. } MON_Type;
  19. /* Bitfield definition for register of struct array MONITOR: CONTROL */
  20. /*
  21. * ACTIVE (RW)
  22. *
  23. * select glitch works in active mode or passve mode.
  24. * 0: passive mode, depends on power glitch destory DFF value
  25. * 1: active mode, check glitch by DFF chain
  26. */
  27. #define MON_MONITOR_CONTROL_ACTIVE_MASK (0x10U)
  28. #define MON_MONITOR_CONTROL_ACTIVE_SHIFT (4U)
  29. #define MON_MONITOR_CONTROL_ACTIVE_SET(x) (((uint32_t)(x) << MON_MONITOR_CONTROL_ACTIVE_SHIFT) & MON_MONITOR_CONTROL_ACTIVE_MASK)
  30. #define MON_MONITOR_CONTROL_ACTIVE_GET(x) (((uint32_t)(x) & MON_MONITOR_CONTROL_ACTIVE_MASK) >> MON_MONITOR_CONTROL_ACTIVE_SHIFT)
  31. /*
  32. * ENABLE (RW)
  33. *
  34. * enable glitch detector
  35. * 0: detector disabled
  36. * 1: detector enabled
  37. */
  38. #define MON_MONITOR_CONTROL_ENABLE_MASK (0x1U)
  39. #define MON_MONITOR_CONTROL_ENABLE_SHIFT (0U)
  40. #define MON_MONITOR_CONTROL_ENABLE_SET(x) (((uint32_t)(x) << MON_MONITOR_CONTROL_ENABLE_SHIFT) & MON_MONITOR_CONTROL_ENABLE_MASK)
  41. #define MON_MONITOR_CONTROL_ENABLE_GET(x) (((uint32_t)(x) & MON_MONITOR_CONTROL_ENABLE_MASK) >> MON_MONITOR_CONTROL_ENABLE_SHIFT)
  42. /* Bitfield definition for register of struct array MONITOR: STATUS */
  43. /*
  44. * FLAG (RW)
  45. *
  46. * flag for glitch detected, write 1 to clear this flag
  47. * 0: glitch not detected
  48. * 1: glitch detected
  49. */
  50. #define MON_MONITOR_STATUS_FLAG_MASK (0x1U)
  51. #define MON_MONITOR_STATUS_FLAG_SHIFT (0U)
  52. #define MON_MONITOR_STATUS_FLAG_SET(x) (((uint32_t)(x) << MON_MONITOR_STATUS_FLAG_SHIFT) & MON_MONITOR_STATUS_FLAG_MASK)
  53. #define MON_MONITOR_STATUS_FLAG_GET(x) (((uint32_t)(x) & MON_MONITOR_STATUS_FLAG_MASK) >> MON_MONITOR_STATUS_FLAG_SHIFT)
  54. /* Bitfield definition for register: TEST_MODE */
  55. /*
  56. * DISABLE (RW)
  57. *
  58. * disable test mode entry, any non-zero value written to this register causes disable bit set
  59. * 0: test mode enabled
  60. * 1: test mode disabled
  61. * Note: This register only available in BATT domain
  62. */
  63. #define MON_TEST_MODE_DISABLE_MASK (0xFFFFFFFFUL)
  64. #define MON_TEST_MODE_DISABLE_SHIFT (0U)
  65. #define MON_TEST_MODE_DISABLE_SET(x) (((uint32_t)(x) << MON_TEST_MODE_DISABLE_SHIFT) & MON_TEST_MODE_DISABLE_MASK)
  66. #define MON_TEST_MODE_DISABLE_GET(x) (((uint32_t)(x) & MON_TEST_MODE_DISABLE_MASK) >> MON_TEST_MODE_DISABLE_SHIFT)
  67. /* Bitfield definition for register: IRQ_FLAG */
  68. /*
  69. * FLAG (RW)
  70. *
  71. * interrupt flag, each bit represents for one monitor, write 1 to clear interrupt flag
  72. * 0: no monitor interrupt
  73. * 1: monitor interrupt happened
  74. * Note: This register only available in PMIC domain
  75. */
  76. #define MON_IRQ_FLAG_FLAG_MASK (0xFU)
  77. #define MON_IRQ_FLAG_FLAG_SHIFT (0U)
  78. #define MON_IRQ_FLAG_FLAG_SET(x) (((uint32_t)(x) << MON_IRQ_FLAG_FLAG_SHIFT) & MON_IRQ_FLAG_FLAG_MASK)
  79. #define MON_IRQ_FLAG_FLAG_GET(x) (((uint32_t)(x) & MON_IRQ_FLAG_FLAG_MASK) >> MON_IRQ_FLAG_FLAG_SHIFT)
  80. /* Bitfield definition for register: IRQ_ENABLE */
  81. /*
  82. * ENABLE (RW)
  83. *
  84. * interrupt enable, each bit represents for one monitor
  85. * 0: monitor interrupt disabled
  86. * 1: monitor interrupt enabled
  87. * Note: This register only available in PMIC domain
  88. */
  89. #define MON_IRQ_ENABLE_ENABLE_MASK (0xFU)
  90. #define MON_IRQ_ENABLE_ENABLE_SHIFT (0U)
  91. #define MON_IRQ_ENABLE_ENABLE_SET(x) (((uint32_t)(x) << MON_IRQ_ENABLE_ENABLE_SHIFT) & MON_IRQ_ENABLE_ENABLE_MASK)
  92. #define MON_IRQ_ENABLE_ENABLE_GET(x) (((uint32_t)(x) & MON_IRQ_ENABLE_ENABLE_MASK) >> MON_IRQ_ENABLE_ENABLE_SHIFT)
  93. /* MONITOR register group index macro definition */
  94. #define MON_MONITOR_GLITCH0 (0UL)
  95. #define MON_MONITOR_GLITCH1 (1UL)
  96. #define MON_MONITOR_CLOCK0 (2UL)
  97. #define MON_MONITOR_CLOCK1 (3UL)
  98. #endif /* HPM_MON_H */