gpio.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _GPIO_H_
  13. #define _GPIO_H_
  14. // Auto generated by dtools(see dtools.txt for its version).
  15. // Don't edit it manually!
  16. #define IDX_GPIO_DCON (0)
  17. #define IDX_GPO_CHG (0)
  18. #define REG_GPIO1_BASE (0x51703000)
  19. #define REG_GPIO2_BASE (0x51503000)
  20. typedef volatile struct
  21. {
  22. uint32_t gpio_oen_val; // 0x00000000
  23. uint32_t gpio_oen_set_out; // 0x00000004
  24. uint32_t gpio_oen_set_in; // 0x00000008
  25. uint32_t gpio_val_reg; // 0x0000000c
  26. uint32_t gpio_set_reg; // 0x00000010
  27. uint32_t gpio_clr_reg; // 0x00000014
  28. uint32_t gpint_ctrl_r_set_reg; // 0x00000018
  29. uint32_t gpint_ctrl_r_clr_reg; // 0x0000001c
  30. uint32_t int_clr; // 0x00000020
  31. uint32_t int_status; // 0x00000024
  32. uint32_t chg_ctrl; // 0x00000028
  33. uint32_t chg_cmd; // 0x0000002c
  34. uint32_t gpo_set_reg; // 0x00000030
  35. uint32_t gpo_clr_reg; // 0x00000034
  36. uint32_t gpint_ctrl_f_set_reg; // 0x00000038
  37. uint32_t gpint_ctrl_f_clr_reg; // 0x0000003c
  38. uint32_t dbn_en_set_reg; // 0x00000040
  39. uint32_t dbn_en_clr_reg; // 0x00000044
  40. uint32_t gpint_mode_set_reg; // 0x00000048
  41. uint32_t gpint_mode_clr_reg; // 0x0000004c
  42. } HWP_GPIO_T;
  43. #define hwp_gpio1 ((HWP_GPIO_T *)REG_ACCESS_ADDRESS(REG_GPIO1_BASE))
  44. #define hwp_gpio2 ((HWP_GPIO_T *)REG_ACCESS_ADDRESS(REG_GPIO2_BASE))
  45. // chg_ctrl
  46. typedef union {
  47. uint32_t v;
  48. struct
  49. {
  50. uint32_t out_time : 4; // [3:0]
  51. uint32_t wait_time : 6; // [9:4]
  52. uint32_t __15_10 : 6; // [15:10]
  53. uint32_t int_mode : 2; // [17:16]
  54. uint32_t __31_18 : 14; // [31:18]
  55. } b;
  56. } REG_GPIO_CHG_CTRL_T;
  57. // chg_cmd
  58. typedef union {
  59. uint32_t v;
  60. struct
  61. {
  62. uint32_t dcon_mode_set : 1; // [0], write set
  63. uint32_t __3_1 : 3; // [3:1]
  64. uint32_t chg_mode_set : 1; // [4], write set
  65. uint32_t __7_5 : 3; // [7:5]
  66. uint32_t dcon_mode_clr : 1; // [8], write clear
  67. uint32_t __11_9 : 3; // [11:9]
  68. uint32_t chg_mode_clr : 1; // [12], write clear
  69. uint32_t __23_13 : 11; // [23:13]
  70. uint32_t chg_down : 1; // [24], write set
  71. uint32_t __31_25 : 7; // [31:25]
  72. } b;
  73. } REG_GPIO_CHG_CMD_T;
  74. // gpo_set_reg
  75. typedef union {
  76. uint32_t v;
  77. struct
  78. {
  79. uint32_t gpo_set : 8; // [7:0], write set
  80. uint32_t __31_8 : 24; // [31:8]
  81. } b;
  82. } REG_GPIO_GPO_SET_REG_T;
  83. // gpo_clr_reg
  84. typedef union {
  85. uint32_t v;
  86. struct
  87. {
  88. uint32_t gpo_clr : 8; // [7:0], write clear
  89. uint32_t __31_8 : 24; // [31:8]
  90. } b;
  91. } REG_GPIO_GPO_CLR_REG_T;
  92. // chg_ctrl
  93. #define GPIO_OUT_TIME(n) (((n)&0xf) << 0)
  94. #define GPIO_WAIT_TIME(n) (((n)&0x3f) << 4)
  95. #define GPIO_INT_MODE(n) (((n)&0x3) << 16)
  96. #define GPIO_INT_MODE_L2H (0 << 16)
  97. #define GPIO_INT_MODE_H2L (1 << 16)
  98. #define GPIO_INT_MODE_RR (3 << 16)
  99. #define GPIO_INT_MODE_V_L2H (0)
  100. #define GPIO_INT_MODE_V_H2L (1)
  101. #define GPIO_INT_MODE_V_RR (3)
  102. // chg_cmd
  103. #define GPIO_DCON_MODE_SET (1 << 0)
  104. #define GPIO_CHG_MODE_SET (1 << 4)
  105. #define GPIO_DCON_MODE_CLR (1 << 8)
  106. #define GPIO_CHG_MODE_CLR (1 << 12)
  107. #define GPIO_CHG_DOWN (1 << 24)
  108. // gpo_set_reg
  109. #define GPIO_GPO_SET(n) (((n)&0xff) << 0)
  110. // gpo_clr_reg
  111. #define GPIO_GPO_CLR(n) (((n)&0xff) << 0)
  112. #endif // _GPIO_H_