hpm_pmon_regs.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Copyright (c) 2021-2023 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef HPM_PMON_H
  8. #define HPM_PMON_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. __R uint8_t RESERVED0[32]; /* 0x20 - 0x3F: Reserved */
  15. __RW uint32_t IRQ_FLAG; /* 0x40: */
  16. __RW uint32_t IRQ_ENABLE; /* 0x44: */
  17. } PMON_Type;
  18. /* Bitfield definition for register of struct array MONITOR: CONTROL */
  19. /*
  20. * ACTIVE (RW)
  21. *
  22. * select glitch works in active mode or passve mode.
  23. * 0: passive mode, depends on power glitch destory DFF value
  24. * 1: active mode, check glitch by DFF chain
  25. */
  26. #define PMON_MONITOR_CONTROL_ACTIVE_MASK (0x10U)
  27. #define PMON_MONITOR_CONTROL_ACTIVE_SHIFT (4U)
  28. #define PMON_MONITOR_CONTROL_ACTIVE_SET(x) (((uint32_t)(x) << PMON_MONITOR_CONTROL_ACTIVE_SHIFT) & PMON_MONITOR_CONTROL_ACTIVE_MASK)
  29. #define PMON_MONITOR_CONTROL_ACTIVE_GET(x) (((uint32_t)(x) & PMON_MONITOR_CONTROL_ACTIVE_MASK) >> PMON_MONITOR_CONTROL_ACTIVE_SHIFT)
  30. /*
  31. * ENABLE (RW)
  32. *
  33. * enable glitch detector
  34. * 0: detector disabled
  35. * 1: detector enabled
  36. */
  37. #define PMON_MONITOR_CONTROL_ENABLE_MASK (0x1U)
  38. #define PMON_MONITOR_CONTROL_ENABLE_SHIFT (0U)
  39. #define PMON_MONITOR_CONTROL_ENABLE_SET(x) (((uint32_t)(x) << PMON_MONITOR_CONTROL_ENABLE_SHIFT) & PMON_MONITOR_CONTROL_ENABLE_MASK)
  40. #define PMON_MONITOR_CONTROL_ENABLE_GET(x) (((uint32_t)(x) & PMON_MONITOR_CONTROL_ENABLE_MASK) >> PMON_MONITOR_CONTROL_ENABLE_SHIFT)
  41. /* Bitfield definition for register of struct array MONITOR: STATUS */
  42. /*
  43. * FLAG (RW)
  44. *
  45. * flag for glitch detected, write 1 to clear this flag
  46. * 0: glitch not detected
  47. * 1: glitch detected
  48. */
  49. #define PMON_MONITOR_STATUS_FLAG_MASK (0x1U)
  50. #define PMON_MONITOR_STATUS_FLAG_SHIFT (0U)
  51. #define PMON_MONITOR_STATUS_FLAG_SET(x) (((uint32_t)(x) << PMON_MONITOR_STATUS_FLAG_SHIFT) & PMON_MONITOR_STATUS_FLAG_MASK)
  52. #define PMON_MONITOR_STATUS_FLAG_GET(x) (((uint32_t)(x) & PMON_MONITOR_STATUS_FLAG_MASK) >> PMON_MONITOR_STATUS_FLAG_SHIFT)
  53. /* Bitfield definition for register: IRQ_FLAG */
  54. /*
  55. * FLAG (RW)
  56. *
  57. * interrupt flag, each bit represents for one monitor, write 1 to clear interrupt flag
  58. * 0: no monitor interrupt
  59. * 1: monitor interrupt happened
  60. */
  61. #define PMON_IRQ_FLAG_FLAG_MASK (0xFU)
  62. #define PMON_IRQ_FLAG_FLAG_SHIFT (0U)
  63. #define PMON_IRQ_FLAG_FLAG_SET(x) (((uint32_t)(x) << PMON_IRQ_FLAG_FLAG_SHIFT) & PMON_IRQ_FLAG_FLAG_MASK)
  64. #define PMON_IRQ_FLAG_FLAG_GET(x) (((uint32_t)(x) & PMON_IRQ_FLAG_FLAG_MASK) >> PMON_IRQ_FLAG_FLAG_SHIFT)
  65. /* Bitfield definition for register: IRQ_ENABLE */
  66. /*
  67. * ENABLE (RW)
  68. *
  69. * interrupt enable, each bit represents for one monitor
  70. * 0: monitor interrupt disabled
  71. * 1: monitor interrupt enabled
  72. */
  73. #define PMON_IRQ_ENABLE_ENABLE_MASK (0xFU)
  74. #define PMON_IRQ_ENABLE_ENABLE_SHIFT (0U)
  75. #define PMON_IRQ_ENABLE_ENABLE_SET(x) (((uint32_t)(x) << PMON_IRQ_ENABLE_ENABLE_SHIFT) & PMON_IRQ_ENABLE_ENABLE_MASK)
  76. #define PMON_IRQ_ENABLE_ENABLE_GET(x) (((uint32_t)(x) & PMON_IRQ_ENABLE_ENABLE_MASK) >> PMON_IRQ_ENABLE_ENABLE_SHIFT)
  77. /* MONITOR register group index macro definition */
  78. #define PMON_MONITOR_GLITCH0 (0UL)
  79. #define PMON_MONITOR_GLITCH1 (1UL)
  80. #define PMON_MONITOR_CLOCK0 (2UL)
  81. #define PMON_MONITOR_CLOCK1 (3UL)
  82. #endif /* HPM_PMON_H */