fsl_reset.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. /*
  2. * Copyright (c) 2016, Freescale Semiconductor, Inc.
  3. * Copyright (c) 2016, NXP
  4. * All rights reserved.
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. */
  8. #ifndef _FSL_RESET_H_
  9. #define _FSL_RESET_H_
  10. #include <assert.h>
  11. #include <stdbool.h>
  12. #include <stdint.h>
  13. #include <string.h>
  14. #include "fsl_device_registers.h"
  15. /*!
  16. * @addtogroup ksdk_common
  17. * @{
  18. */
  19. /*******************************************************************************
  20. * Definitions
  21. ******************************************************************************/
  22. /*! @name Driver version */
  23. /*@{*/
  24. /*! @brief reset driver version 2.0.0. */
  25. #define FSL_RESET_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
  26. /*@}*/
  27. /*!
  28. * @brief Enumeration for peripheral reset control bits
  29. *
  30. * Defines the enumeration for peripheral reset control bits in PRESETCTRL/ASYNCPRESETCTRL registers
  31. */
  32. typedef enum _SYSCON_RSTn
  33. {
  34. kROM_RST_SHIFT_RSTn = 0 | 1U, /**< ROM reset control */
  35. kSRAM1_RST_SHIFT_RSTn = 0 | 3U, /**< SRAM1 reset control */
  36. kSRAM2_RST_SHIFT_RSTn = 0 | 4U, /**< SRAM2 reset control */
  37. kSRAM3_RST_SHIFT_RSTn = 0 | 5U, /**< SRAM3 reset control */
  38. kSRAM4_RST_SHIFT_RSTn = 0 | 6U, /**< SRAM4 reset control */
  39. kFLASH_RST_SHIFT_RSTn = 0 | 7U, /**< Flash controller reset control */
  40. kFMC_RST_SHIFT_RSTn = 0 | 8U, /**< Flash accelerator reset control */
  41. kSPIFI_RST_SHIFT_RSTn = 0 | 10U, /**< SPIFI reset control */
  42. kMUX0_RST_SHIFT_RSTn = 0 | 11U, /**< Input mux0 reset control */
  43. kIOCON_RST_SHIFT_RSTn = 0 | 13U, /**< IOCON reset control */
  44. kGPIO0_RST_SHIFT_RSTn = 0 | 14U, /**< GPIO0 reset control */
  45. kGPIO1_RST_SHIFT_RSTn = 0 | 15U, /**< GPIO1 reset control */
  46. kGPIO2_RST_SHIFT_RSTn = 0 | 16U, /**< GPIO2 reset control */
  47. kGPIO3_RST_SHIFT_RSTn = 0 | 17U, /**< GPIO3 reset control */
  48. kPINT_RST_SHIFT_RSTn = 0 | 18U, /**< Pin interrupt (PINT) reset control */
  49. kGINT_RST_SHIFT_RSTn = 0 | 19U, /**< Grouped interrupt (PINT) reset control. */
  50. kDMA0_RST_SHIFT_RSTn = 0 | 20U, /**< DMA reset control */
  51. kCRC_RST_SHIFT_RSTn = 0 | 21U, /**< CRC reset control */
  52. kWWDT_RST_SHIFT_RSTn = 0 | 22U, /**< Watchdog timer reset control */
  53. kRTC_RST_SHIFT_RSTn = 0 | 23U, /**< RTC reset control */
  54. kMAILBOX_RST_SHIFT_RSTn = 0 | 26U, /**< Mailbox reset control */
  55. kADC0_RST_SHIFT_RSTn = 0 | 27U, /**< ADC0 reset control */
  56. kMRT_RST_SHIFT_RSTn = 65536 | 0U, /**< Multi-rate timer (MRT) reset control */
  57. kOSTIMER0_RST_SHIFT_RSTn = 65536 | 1U, /**< OSTimer0 reset control */
  58. kSCT0_RST_SHIFT_RSTn = 65536 | 2U, /**< SCTimer/PWM 0 (SCT0) reset control */
  59. kSCTIPU_RST_SHIFT_RSTn = 65536 | 6U, /**< SCTIPU reset control */
  60. kUTICK_RST_SHIFT_RSTn = 65536 | 10U, /**< Micro-tick timer reset control */
  61. kFC0_RST_SHIFT_RSTn = 65536 | 11U, /**< Flexcomm Interface 0 reset control */
  62. kFC1_RST_SHIFT_RSTn = 65536 | 12U, /**< Flexcomm Interface 1 reset control */
  63. kFC2_RST_SHIFT_RSTn = 65536 | 13U, /**< Flexcomm Interface 2 reset control */
  64. kFC3_RST_SHIFT_RSTn = 65536 | 14U, /**< Flexcomm Interface 3 reset control */
  65. kFC4_RST_SHIFT_RSTn = 65536 | 15U, /**< Flexcomm Interface 4 reset control */
  66. kFC5_RST_SHIFT_RSTn = 65536 | 16U, /**< Flexcomm Interface 5 reset control */
  67. kFC6_RST_SHIFT_RSTn = 65536 | 17U, /**< Flexcomm Interface 6 reset control */
  68. kFC7_RST_SHIFT_RSTn = 65536 | 18U, /**< Flexcomm Interface 7 reset control */
  69. kCTIMER2_RST_SHIFT_RSTn = 65536 | 22U, /**< CTimer 2 reset control */
  70. kUSB0D_RST_SHIFT_RSTn = 65536 | 25U, /**< USB0 Device reset control */
  71. kCTIMER0_RST_SHIFT_RSTn = 65536 | 26U, /**< CTimer 0 reset control */
  72. kCTIMER1_RST_SHIFT_RSTn = 65536 | 27U, /**< CTimer 1 reset control */
  73. kPVT_RST_SHIFT_RSTn = 65536 | 28U, /**< PVT reset control */
  74. kEZHA_RST_SHIFT_RSTn = 65536 | 30U, /**< EZHA reset control */
  75. kEZHB_RST_SHIFT_RSTn = 65536 | 31U, /**< EZHB reset control */
  76. kDMA1_RST_SHIFT_RSTn = 131072 | 1U, /**< DMA1 reset control */
  77. kCMP_RST_SHIFT_RSTn = 131072 | 2U, /**< CMP reset control */
  78. kSDIO_RST_SHIFT_RSTn = 131072 | 3U, /**< SDIO reset control */
  79. kUSB1H_RST_SHIFT_RSTn = 131072 | 4U, /**< USBHS Host reset control */
  80. kUSB1D_RST_SHIFT_RSTn = 131072 | 5U, /**< USBHS Device reset control */
  81. kUSB1RAM_RST_SHIFT_RSTn = 131072 | 6U, /**< USB RAM reset control */
  82. kUSB1_RST_SHIFT_RSTn = 131072 | 7U, /**< USBHS reset control */
  83. kFREQME_RST_SHIFT_RSTn = 131072 | 8U, /**< FREQME reset control */
  84. kGPIO4_RST_SHIFT_RSTn = 131072 | 9U, /**< GPIO4 reset control */
  85. kGPIO5_RST_SHIFT_RSTn = 131072 | 10U, /**< GPIO5 reset control */
  86. kAES_RST_SHIFT_RSTn = 131072 | 11U, /**< AES reset control */
  87. kOTP_RST_SHIFT_RSTn = 131072 | 12U, /**< OTP reset control */
  88. kRNG_RST_SHIFT_RSTn = 131072 | 13U, /**< RNG reset control */
  89. kMUX1_RST_SHIFT_RSTn = 131072 | 14U, /**< Input mux1 reset control */
  90. kUSB0HMR_RST_SHIFT_RSTn = 131072 | 16U, /**< USB0HMR reset control */
  91. kUSB0HSL_RST_SHIFT_RSTn = 131072 | 17U, /**< USB0HSL reset control */
  92. kHASHCRYPT_RST_SHIFT_RSTn = 131072 | 18U, /**< HASHCRYPT reset control */
  93. kPOWERQUAD_RST_SHIFT_RSTn = 131072 | 19U, /**< PowerQuad reset control */
  94. kPLULUT_RST_SHIFT_RSTn = 131072 | 20U, /**< PLU LUT reset control */
  95. kCTIMER3_RST_SHIFT_RSTn = 131072 | 21U, /**< CTimer 3 reset control */
  96. kCTIMER4_RST_SHIFT_RSTn = 131072 | 22U, /**< CTimer 4 reset control */
  97. kPUF_RST_SHIFT_RSTn = 131072 | 23U, /**< PUF reset control */
  98. kCASPER_RST_SHIFT_RSTn = 131072 | 24U, /**< CASPER reset control */
  99. kCAP0_RST_SHIFT_RSTn = 131072 | 25U, /**< CASPER reset control */
  100. kOSTIMER1_RST_SHIFT_RSTn = 131072 | 26U, /**< OSTIMER1 reset control */
  101. kANALOGCTL_RST_SHIFT_RSTn = 131072 | 27U, /**< ANALOG_CTL reset control */
  102. kHSLSPI_RST_SHIFT_RSTn = 131072 | 28U, /**< HS LSPI reset control */
  103. kGPIOSEC_RST_SHIFT_RSTn = 131072 | 29U, /**< GPIO Secure reset control */
  104. kGPIOSECINT_RST_SHIFT_RSTn = 131072 | 30U, /**< GPIO Secure int reset control */
  105. } SYSCON_RSTn_t;
  106. /** Array initializers with peripheral reset bits **/
  107. #define ADC_RSTS \
  108. { \
  109. kADC0_RST_SHIFT_RSTn \
  110. } /* Reset bits for ADC peripheral */
  111. #define AES_RSTS \
  112. { \
  113. kAES_RST_SHIFT_RSTn \
  114. } /* Reset bits for AES peripheral */
  115. #define CRC_RSTS \
  116. { \
  117. kCRC_RST_SHIFT_RSTn \
  118. } /* Reset bits for CRC peripheral */
  119. #define CTIMER_RSTS \
  120. { \
  121. kCTIMER0_RST_SHIFT_RSTn, kCTIMER1_RST_SHIFT_RSTn, kCTIMER2_RST_SHIFT_RSTn, kCTIMER3_RST_SHIFT_RSTn, \
  122. kCTIMER4_RST_SHIFT_RSTn \
  123. } /* Reset bits for CTIMER peripheral */
  124. #define DMA_RSTS_N \
  125. { \
  126. kDMA0_RST_SHIFT_RSTn, kDMA1_RST_SHIFT_RSTn \
  127. } /* Reset bits for DMA peripheral */
  128. #define FLEXCOMM_RSTS \
  129. { \
  130. kFC0_RST_SHIFT_RSTn, kFC1_RST_SHIFT_RSTn, kFC2_RST_SHIFT_RSTn, kFC3_RST_SHIFT_RSTn, kFC4_RST_SHIFT_RSTn, \
  131. kFC5_RST_SHIFT_RSTn, kFC6_RST_SHIFT_RSTn, kFC7_RST_SHIFT_RSTn, kHSLSPI_RST_SHIFT_RSTn \
  132. } /* Reset bits for FLEXCOMM peripheral */
  133. #define GINT_RSTS \
  134. { \
  135. kGINT_RST_SHIFT_RSTn, kGINT_RST_SHIFT_RSTn \
  136. } /* Reset bits for GINT peripheral. GINT0 & GINT1 share same slot */
  137. #define GPIO_RSTS_N \
  138. { \
  139. kGPIO0_RST_SHIFT_RSTn, kGPIO1_RST_SHIFT_RSTn, kGPIO2_RST_SHIFT_RSTn, kGPIO3_RST_SHIFT_RSTn, \
  140. kGPIO4_RST_SHIFT_RSTn, kGPIO5_RST_SHIFT_RSTn \
  141. } /* Reset bits for GPIO peripheral */
  142. #define INPUTMUX_RSTS \
  143. { \
  144. kMUX0_RST_SHIFT_RSTn, kMUX1_RST_SHIFT_RSTn \
  145. } /* Reset bits for INPUTMUX peripheral */
  146. #define IOCON_RSTS \
  147. { \
  148. kIOCON_RST_SHIFT_RSTn \
  149. } /* Reset bits for IOCON peripheral */
  150. #define FLASH_RSTS \
  151. { \
  152. kFLASH_RST_SHIFT_RSTn, kFMC_RST_SHIFT_RSTn \
  153. } /* Reset bits for Flash peripheral */
  154. #define MRT_RSTS \
  155. { \
  156. kMRT_RST_SHIFT_RSTn \
  157. } /* Reset bits for MRT peripheral */
  158. #define OTP_RSTS \
  159. { \
  160. kOTP_RST_SHIFT_RSTn \
  161. } /* Reset bits for OTP peripheral */
  162. #define PINT_RSTS \
  163. { \
  164. kPINT_RST_SHIFT_RSTn \
  165. } /* Reset bits for PINT peripheral */
  166. #define RNG_RSTS \
  167. { \
  168. kRNG_RST_SHIFT_RSTn \
  169. } /* Reset bits for RNG peripheral */
  170. #define SDIO_RST \
  171. { \
  172. kSDIO_RST_SHIFT_RSTn \
  173. } /* Reset bits for SDIO peripheral */
  174. #define SCT_RSTS \
  175. { \
  176. kSCT0_RST_SHIFT_RSTn \
  177. } /* Reset bits for SCT peripheral */
  178. #define SPIFI_RSTS \
  179. { \
  180. kSPIFI_RST_SHIFT_RSTn \
  181. } /* Reset bits for SPIFI peripheral */
  182. #define USB0D_RST \
  183. { \
  184. kUSB0D_RST_SHIFT_RSTn \
  185. } /* Reset bits for USB0D peripheral */
  186. #define USB0HMR_RST \
  187. { \
  188. kUSB0HMR_RST_SHIFT_RSTn \
  189. } /* Reset bits for USB0HMR peripheral */
  190. #define USB0HSL_RST \
  191. { \
  192. kUSB0HSL_RST_SHIFT_RSTn \
  193. } /* Reset bits for USB0HSL peripheral */
  194. #define USB1H_RST \
  195. { \
  196. kUSB1H_RST_SHIFT_RSTn \
  197. } /* Reset bits for USB1H peripheral */
  198. #define USB1D_RST \
  199. { \
  200. kUSB1D_RST_SHIFT_RSTn \
  201. } /* Reset bits for USB1D peripheral */
  202. #define USB1RAM_RST \
  203. { \
  204. kUSB1RAM_RST_SHIFT_RSTn \
  205. } /* Reset bits for USB1RAM peripheral */
  206. #define UTICK_RSTS \
  207. { \
  208. kUTICK_RST_SHIFT_RSTn \
  209. } /* Reset bits for UTICK peripheral */
  210. #define WWDT_RSTS \
  211. { \
  212. kWWDT_RST_SHIFT_RSTn \
  213. } /* Reset bits for WWDT peripheral */
  214. #define CAPT_RSTS_N \
  215. { \
  216. kCAP0_RST_SHIFT_RSTn \
  217. } /* Reset bits for CAPT peripheral */
  218. #define PLU_RSTS_N \
  219. { \
  220. kPLULUT_RST_SHIFT_RSTn \
  221. } /* Reset bits for PLU peripheral */
  222. #define OSTIMER_RSTS \
  223. { \
  224. kOSTIMER0_RST_SHIFT_RSTn \
  225. } /* Reset bits for OSTIMER peripheral */
  226. typedef SYSCON_RSTn_t reset_ip_name_t;
  227. /*******************************************************************************
  228. * API
  229. ******************************************************************************/
  230. #if defined(__cplusplus)
  231. extern "C" {
  232. #endif
  233. /*!
  234. * @brief Assert reset to peripheral.
  235. *
  236. * Asserts reset signal to specified peripheral module.
  237. *
  238. * @param peripheral Assert reset to this peripheral. The enum argument contains encoding of reset register
  239. * and reset bit position in the reset register.
  240. */
  241. void RESET_SetPeripheralReset(reset_ip_name_t peripheral);
  242. /*!
  243. * @brief Clear reset to peripheral.
  244. *
  245. * Clears reset signal to specified peripheral module, allows it to operate.
  246. *
  247. * @param peripheral Clear reset to this peripheral. The enum argument contains encoding of reset register
  248. * and reset bit position in the reset register.
  249. */
  250. void RESET_ClearPeripheralReset(reset_ip_name_t peripheral);
  251. /*!
  252. * @brief Reset peripheral module.
  253. *
  254. * Reset peripheral module.
  255. *
  256. * @param peripheral Peripheral to reset. The enum argument contains encoding of reset register
  257. * and reset bit position in the reset register.
  258. */
  259. void RESET_PeripheralReset(reset_ip_name_t peripheral);
  260. #if defined(__cplusplus)
  261. }
  262. #endif
  263. /*! @} */
  264. #endif /* _FSL_RESET_H_ */