hpm_gpiom_regs.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (c) 2021-2023 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef HPM_GPIOM_H
  8. #define HPM_GPIOM_H
  9. typedef struct {
  10. struct {
  11. __RW uint32_t PIN[32]; /* 0x0 - 0x7C: GPIO mananger */
  12. } ASSIGN[16];
  13. } GPIOM_Type;
  14. /* Bitfield definition for register of struct array ASSIGN: PIN00 */
  15. /*
  16. * LOCK (RW)
  17. *
  18. * lock fields in this register, lock can only be cleared by soc reset
  19. * 0: fields can be changed
  20. * 1: fields locked to current value, not changeable
  21. */
  22. #define GPIOM_ASSIGN_PIN_LOCK_MASK (0x80000000UL)
  23. #define GPIOM_ASSIGN_PIN_LOCK_SHIFT (31U)
  24. #define GPIOM_ASSIGN_PIN_LOCK_SET(x) (((uint32_t)(x) << GPIOM_ASSIGN_PIN_LOCK_SHIFT) & GPIOM_ASSIGN_PIN_LOCK_MASK)
  25. #define GPIOM_ASSIGN_PIN_LOCK_GET(x) (((uint32_t)(x) & GPIOM_ASSIGN_PIN_LOCK_MASK) >> GPIOM_ASSIGN_PIN_LOCK_SHIFT)
  26. /*
  27. * HIDE (RW)
  28. *
  29. * pin value visibility to gpios,
  30. * bit0: 1, invisible to soc gpio0; 0: visible to soc gpio0
  31. * bit1: 1, invisible to soc gpio1; 0: visible to soc gpio1
  32. * bit2: 1, invisible to cpu0 fast gpio; 0: visible to cpu0 fast gpio
  33. * bit3: 1, invisible to cpu1 fast gpio; 0: visible to cpu1 fast gpio
  34. */
  35. #define GPIOM_ASSIGN_PIN_HIDE_MASK (0xF00U)
  36. #define GPIOM_ASSIGN_PIN_HIDE_SHIFT (8U)
  37. #define GPIOM_ASSIGN_PIN_HIDE_SET(x) (((uint32_t)(x) << GPIOM_ASSIGN_PIN_HIDE_SHIFT) & GPIOM_ASSIGN_PIN_HIDE_MASK)
  38. #define GPIOM_ASSIGN_PIN_HIDE_GET(x) (((uint32_t)(x) & GPIOM_ASSIGN_PIN_HIDE_MASK) >> GPIOM_ASSIGN_PIN_HIDE_SHIFT)
  39. /*
  40. * SELECT (RW)
  41. *
  42. * select which gpio controls chip pin,
  43. * 0: soc gpio0;
  44. * 1: soc gpio1;
  45. * 2: cpu0 fastgpio
  46. * 3: cpu1 fast gpio
  47. */
  48. #define GPIOM_ASSIGN_PIN_SELECT_MASK (0x3U)
  49. #define GPIOM_ASSIGN_PIN_SELECT_SHIFT (0U)
  50. #define GPIOM_ASSIGN_PIN_SELECT_SET(x) (((uint32_t)(x) << GPIOM_ASSIGN_PIN_SELECT_SHIFT) & GPIOM_ASSIGN_PIN_SELECT_MASK)
  51. #define GPIOM_ASSIGN_PIN_SELECT_GET(x) (((uint32_t)(x) & GPIOM_ASSIGN_PIN_SELECT_MASK) >> GPIOM_ASSIGN_PIN_SELECT_SHIFT)
  52. /* PIN register group index macro definition */
  53. #define GPIOM_ASSIGN_PIN_PIN00 (0UL)
  54. #define GPIOM_ASSIGN_PIN_PIN01 (1UL)
  55. #define GPIOM_ASSIGN_PIN_PIN02 (2UL)
  56. #define GPIOM_ASSIGN_PIN_PIN03 (3UL)
  57. #define GPIOM_ASSIGN_PIN_PIN04 (4UL)
  58. #define GPIOM_ASSIGN_PIN_PIN05 (5UL)
  59. #define GPIOM_ASSIGN_PIN_PIN06 (6UL)
  60. #define GPIOM_ASSIGN_PIN_PIN07 (7UL)
  61. #define GPIOM_ASSIGN_PIN_PIN08 (8UL)
  62. #define GPIOM_ASSIGN_PIN_PIN09 (9UL)
  63. #define GPIOM_ASSIGN_PIN_PIN10 (10UL)
  64. #define GPIOM_ASSIGN_PIN_PIN11 (11UL)
  65. #define GPIOM_ASSIGN_PIN_PIN12 (12UL)
  66. #define GPIOM_ASSIGN_PIN_PIN13 (13UL)
  67. #define GPIOM_ASSIGN_PIN_PIN14 (14UL)
  68. #define GPIOM_ASSIGN_PIN_PIN15 (15UL)
  69. #define GPIOM_ASSIGN_PIN_PIN16 (16UL)
  70. #define GPIOM_ASSIGN_PIN_PIN17 (17UL)
  71. #define GPIOM_ASSIGN_PIN_PIN18 (18UL)
  72. #define GPIOM_ASSIGN_PIN_PIN19 (19UL)
  73. #define GPIOM_ASSIGN_PIN_PIN20 (20UL)
  74. #define GPIOM_ASSIGN_PIN_PIN21 (21UL)
  75. #define GPIOM_ASSIGN_PIN_PIN22 (22UL)
  76. #define GPIOM_ASSIGN_PIN_PIN23 (23UL)
  77. #define GPIOM_ASSIGN_PIN_PIN24 (24UL)
  78. #define GPIOM_ASSIGN_PIN_PIN25 (25UL)
  79. #define GPIOM_ASSIGN_PIN_PIN26 (26UL)
  80. #define GPIOM_ASSIGN_PIN_PIN27 (27UL)
  81. #define GPIOM_ASSIGN_PIN_PIN28 (28UL)
  82. #define GPIOM_ASSIGN_PIN_PIN29 (29UL)
  83. #define GPIOM_ASSIGN_PIN_PIN30 (30UL)
  84. #define GPIOM_ASSIGN_PIN_PIN31 (31UL)
  85. /* ASSIGN register group index macro definition */
  86. #define GPIOM_ASSIGN_GPIOA (0UL)
  87. #define GPIOM_ASSIGN_GPIOB (1UL)
  88. #define GPIOM_ASSIGN_GPIOC (2UL)
  89. #define GPIOM_ASSIGN_GPIOX (13UL)
  90. #define GPIOM_ASSIGN_GPIOY (14UL)
  91. #define GPIOM_ASSIGN_GPIOZ (15UL)
  92. #endif /* HPM_GPIOM_H */