sysctl_rst.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /* Copyright (c) 2023, Canaan Bright Sight Co., Ltd
  2. *
  3. * Redistribution and use in source and binary forms, with or without
  4. * modification, are permitted provided that the following conditions are met:
  5. * 1. Redistributions of source code must retain the above copyright
  6. * notice, this list of conditions and the following disclaimer.
  7. * 2. Redistributions in binary form must reproduce the above copyright
  8. * notice, this list of conditions and the following disclaimer in the
  9. * documentation and/or other materials provided with the distribution.
  10. *
  11. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  12. * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  13. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  15. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  16. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  17. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  18. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  19. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  20. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  21. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  22. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  23. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #ifndef __SYSCTL_RST_H__
  26. #define __SYSCTL_RST_H__
  27. /* created by yangfan */
  28. #include <stdint.h>
  29. #include "stdbool.h"
  30. typedef enum
  31. {
  32. SYSCTL_RESET_CPU0_CORE,
  33. /* SYSCTL_RESET_CPU0_APB, */
  34. /* SYSCTL_RESET_CPU0_TDI, */
  35. SYSCTL_RESET_CPU0_FLUSH,
  36. SYSCTL_RESET_CPU1_CORE,
  37. /* SYSCTL_RESET_CPU1_APB, */
  38. SYSCTL_RESET_CPU1_FLUSH,
  39. SYSCTL_RESET_AI,
  40. SYSCTL_RESET_VPU,
  41. SYSCTL_RESET_HS,
  42. SYSCTL_RESET_HS_AHB,
  43. SYSCTL_RESET_SDIO0,
  44. SYSCTL_RESET_SDIO1,
  45. SYSCTL_RESET_SDIO_AXI,
  46. SYSCTL_RESET_USB0,
  47. SYSCTL_RESET_USB1,
  48. SYSCTL_RESET_USB0_AHB,
  49. SYSCTL_RESET_USB1_AHB,
  50. SYSCTL_RESET_SPI0,
  51. SYSCTL_RESET_SPI1,
  52. SYSCTL_RESET_SPI2,
  53. SYSCTL_RESET_SEC,
  54. SYSCTL_RESET_PDMA,
  55. SYSCTL_RESET_SDMA,
  56. SYSCTL_RESET_DECOMPRESS,
  57. SYSCTL_RESET_SRAM,
  58. SYSCTL_RESET_SHRM_AXIM,
  59. SYSCTL_RESET_SHRM_AXIS,
  60. SYSCTL_RESET_SHRM_APB,
  61. SYSCTL_RESET_NONAI2D,
  62. SYSCTL_RESET_MCTL,
  63. SYSCTL_RESET_ISP,
  64. SYSCTL_RESET_ISP_DW,
  65. SYSCTL_RESET_CSI0_APB,
  66. SYSCTL_RESET_CSI1_APB,
  67. SYSCTL_RESET_CSI2_APB,
  68. SYSCTL_RESET_CSI_DPHY_APB,
  69. SYSCTL_RESET_ISP_AHB,
  70. SYSCTL_RESET_M0,
  71. SYSCTL_RESET_M1,
  72. SYSCTL_RESET_M2,
  73. SYSCTL_RESET_DPU,
  74. SYSCTL_RESET_DISP,
  75. SYSCTL_RESET_GPU,
  76. SYSCTL_RESET_AUDIO,
  77. SYSCTL_RESET_TIMER0,
  78. SYSCTL_RESET_TIMER1,
  79. SYSCTL_RESET_TIMER2,
  80. SYSCTL_RESET_TIMER3,
  81. SYSCTL_RESET_TIMER4,
  82. SYSCTL_RESET_TIMER5,
  83. SYSCTL_RESET_TIMER_APB,
  84. SYSCTL_RESET_HDI,
  85. SYSCTL_RESET_WDT0,
  86. SYSCTL_RESET_WDT1,
  87. SYSCTL_RESET_WDT0_APB,
  88. SYSCTL_RESET_WDT1_APB,
  89. SYSCTL_RESET_TS_APB,
  90. SYSCTL_RESET_MAILBOX,
  91. SYSCTL_RESET_STC,
  92. SYSCTL_RESET_PMU,
  93. SYSCTL_RESET_LS_APB,
  94. SYSCTL_RESET_UART0,
  95. SYSCTL_RESET_UART1,
  96. SYSCTL_RESET_UART2,
  97. SYSCTL_RESET_UART3,
  98. SYSCTL_RESET_UART4,
  99. SYSCTL_RESET_I2C0,
  100. SYSCTL_RESET_I2C1,
  101. SYSCTL_RESET_I2C2,
  102. SYSCTL_RESET_I2C3,
  103. SYSCTL_RESET_I2C4,
  104. SYSCTL_RESET_JAMLINK0_APB,
  105. SYSCTL_RESET_JAMLINK1_APB,
  106. SYSCTL_RESET_JAMLINK2_APB,
  107. SYSCTL_RESET_JAMLINK3_APB,
  108. SYSCTL_RESET_CODEC_APB,
  109. SYSCTL_RESET_GPIO_DB,
  110. SYSCTL_RESET_GPIO_APB,
  111. SYSCTL_RESET_ADC,
  112. SYSCTL_RESET_ADC_APB,
  113. SYSCTL_RESET_PWM_APB,
  114. SYSCTL_RESET_SPI2AXI,
  115. } sysctl_reset_e;
  116. typedef enum
  117. {
  118. SYSCTL_RESET_TIME_CPU0,
  119. SYSCTL_RESET_TIME_CPU0_APB,
  120. SYSCTL_RESET_TIME_CPU1,
  121. SYSCTL_RESET_TIME_CPU1_APB,
  122. SYSCTL_RESET_TIME_AI,
  123. SYSCTL_RESET_TIME_VPU,
  124. SYSCTL_RESET_TIME_HS_HCLK,
  125. SYSCTL_RESET_TIME_SDCTL,
  126. SYSCTL_RESET_TIME_USB,
  127. SYSCTL_RESET_TIME_USB_AHB,
  128. SYSCTL_RESET_TIME_SPI,
  129. SYSCTL_RESET_TIME_SEC_SYS,
  130. SYSCTL_RESET_TIME_DMAC,
  131. SYSCTL_RESET_TIME_DECOMPRESS,
  132. SYSCTL_RESET_TIME_SRAM,
  133. SYSCTL_RESET_TIME_NONAI2D,
  134. SYSCTL_RESET_TIME_MCTL,
  135. SYSCTL_RESET_TIME_ISP,
  136. SYSCTL_RESET_TIME_ISP_DW,
  137. SYSCTL_RESET_TIME_DPU,
  138. SYSCTL_RESET_TIME_DISP_SYS,
  139. SYSCTL_RESET_TIME_V2P5D_SYS,
  140. SYSCTL_RESET_TIME_AUDIO,
  141. } sysctl_reset_time_e;
  142. /* See TRM 2.1.4, Table 2-1-2 */
  143. typedef struct {
  144. volatile uint32_t cpu0_rst_tim; /* 0x00 */
  145. volatile uint32_t cpu0_rst_ctl; /* 0x04 */
  146. volatile uint32_t cpu1_rst_tim; /* 0x08 */
  147. volatile uint32_t cpu1_rst_ctl; /* 0x0c */
  148. volatile uint32_t ai_rst_tim; /* 0x10 */
  149. volatile uint32_t ai_rst_ctl; /* 0x14 */
  150. volatile uint32_t vpu_rst_tim; /* 0x18 */
  151. volatile uint32_t vpu_rst_ctl; /* 0x1c */
  152. volatile uint32_t soc_ctl_rst_ctl; /* 0x20 */
  153. volatile uint32_t losys_rst_ctl; /* 0x24 */
  154. volatile uint32_t hisys_hclk_tim; /* 0x28 */
  155. volatile uint32_t hisys_rst_ctl; /* 0x2c */
  156. volatile uint32_t sdctl_rst_tim; /* 0x30 */
  157. volatile uint32_t sdc_rst_ctl; /* 0x34 */
  158. volatile uint32_t usb_rst_tim; /* 0x38 */
  159. volatile uint32_t usb_rst_ctl; /* 0x3c */
  160. volatile uint32_t spi_rst_tim; /* 0x40 */
  161. volatile uint32_t spi_rst_ctl; /* 0x44 */
  162. volatile uint32_t sec_sys_rst_tim; /* 0x48 */
  163. volatile uint32_t sec_rst_ctl; /* 0x4c */
  164. volatile uint32_t dmac_rst_tim; /* 0x50 */
  165. volatile uint32_t dma_rst_ctl; /* 0x54 */
  166. volatile uint32_t decompress_rst_tim; /* 0x58 */
  167. volatile uint32_t decompress_rst_ctl; /* 0x5c */
  168. volatile uint32_t sram_rst_tim; /* 0x60 */
  169. volatile uint32_t sram_rst_ctl; /* 0x64 */
  170. volatile uint32_t nonai2d_rst_tim; /* 0x68 */
  171. volatile uint32_t nonai2d_rst_ctl; /* 0x6c */
  172. volatile uint32_t mctl_rst_tim; /* 0x70 */
  173. volatile uint32_t mctl_rst_ctl; /* 0x74 */
  174. volatile uint32_t isp_rst_tim; /* 0x78 */
  175. volatile uint32_t isp_dw_rst_tim; /* 0x7c */
  176. volatile uint32_t isp_rst_ctl; /* 0x80 */
  177. volatile uint32_t dpu_rst_tim; /* 0x84 */
  178. volatile uint32_t dpu_rst_ctl; /* 0x88 */
  179. volatile uint32_t disp_sys_rst_tim; /* 0x8c */
  180. volatile uint32_t disp_rst_ctl; /* 0x90 */
  181. volatile uint32_t v2p5d_sys_rst_tim; /* 0x94 */
  182. volatile uint32_t v2p5d_rst_ctl; /* 0x98 */
  183. volatile uint32_t reserved; /* 0x9c */
  184. volatile uint32_t audio_rst_tim; /* 0xa0 */
  185. volatile uint32_t audio_rst_ctl; /* 0xa4 */
  186. volatile uint32_t spi2axi_rst_ctl; /* 0xa8 */
  187. } sysctl_rst_t;
  188. /* Just call this API to reset */
  189. bool sysctl_reset(sysctl_reset_e reset);
  190. bool sysctl_set_reset_time(sysctl_reset_time_e reset, uint32_t tim0, uint32_t tim1, uint32_t tim2);
  191. #endif