fsl_gpc.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. /*
  2. * The Clear BSD License
  3. * Copyright (c) 2016, Freescale Semiconductor, Inc.
  4. * Copyright 2016 NXP
  5. * All rights reserved.
  6. *
  7. *
  8. * Redistribution and use in source and binary forms, with or without modification,
  9. * are permitted (subject to the limitations in the disclaimer below) provided
  10. * that the following conditions are met:
  11. *
  12. * o Redistributions of source code must retain the above copyright notice, this list
  13. * of conditions and the following disclaimer.
  14. *
  15. * o Redistributions in binary form must reproduce the above copyright notice, this
  16. * list of conditions and the following disclaimer in the documentation and/or
  17. * other materials provided with the distribution.
  18. *
  19. * o Neither the name of the copyright holder nor the names of its
  20. * contributors may be used to endorse or promote products derived from this
  21. * software without specific prior written permission.
  22. *
  23. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  25. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  26. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  28. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  29. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  30. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  31. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  32. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  33. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. */
  35. #ifndef _FSL_GPC_H_
  36. #define _FSL_GPC_H_
  37. #include "fsl_common.h"
  38. /*!
  39. * @addtogroup gpc
  40. * @{
  41. */
  42. /*******************************************************************************
  43. * Definitions
  44. ******************************************************************************/
  45. /*! @name Driver version */
  46. /*@{*/
  47. /*! @brief GPC driver version 2.1.0. */
  48. #define FSL_GPC_DRIVER_VERSION (MAKE_VERSION(2, 1, 0))
  49. /*@}*/
  50. #if defined(__cplusplus)
  51. extern "C" {
  52. #endif
  53. /*******************************************************************************
  54. * API
  55. ******************************************************************************/
  56. #if (defined(FSL_FEATURE_GPC_HAS_CNTR_GPCIRQM) && FSL_FEATURE_GPC_HAS_CNTR_GPCIRQM)
  57. /*!
  58. * @brief Allow all the IRQ/Events within the charge of GPC.
  59. *
  60. * @param base GPC peripheral base address.
  61. */
  62. static inline void GPC_AllowIRQs(GPC_Type *base)
  63. {
  64. base->CNTR &= ~GPC_CNTR_GPCIRQM_MASK; /* Events would not be masked. */
  65. }
  66. /*!
  67. * @brief Disallow all the IRQ/Events within the charge of GPC.
  68. *
  69. * @param base GPC peripheral base address.
  70. */
  71. static inline void GPC_DisallowIRQs(GPC_Type *base)
  72. {
  73. base->CNTR |= GPC_CNTR_GPCIRQM_MASK; /* Mask all the events. */
  74. }
  75. #endif /* FSL_FEATURE_GPC_HAS_CNTR_GPCIRQM */
  76. /*!
  77. * @brief Enable the IRQ.
  78. *
  79. * @param base GPC peripheral base address.
  80. * @param irqId ID number of IRQ to be enabled, available range is 32-159.
  81. */
  82. void GPC_EnableIRQ(GPC_Type *base, uint32_t irqId);
  83. /*!
  84. * @brief Disable the IRQ.
  85. *
  86. * @param base GPC peripheral base address.
  87. * @param irqId ID number of IRQ to be disabled, available range is 32-159.
  88. */
  89. void GPC_DisableIRQ(GPC_Type *base, uint32_t irqId);
  90. /*!
  91. * @brief Get the IRQ/Event flag.
  92. *
  93. * @param base GPC peripheral base address.
  94. * @param irqId ID number of IRQ to be enabled, available range is 32-159.
  95. * @return Indicated IRQ/Event is asserted or not.
  96. */
  97. bool GPC_GetIRQStatusFlag(GPC_Type *base, uint32_t irqId);
  98. #if (defined(FSL_FEATURE_GPC_HAS_CNTR_L2PGE) && FSL_FEATURE_GPC_HAS_CNTR_L2PGE)
  99. /*!
  100. * @brief L2 Cache Power Gate Enable
  101. *
  102. * This function configures the L2 cache if it will keep power when in low power mode.
  103. * When the L2 cache power is OFF, L2 cache will be power down once when CPU core is power down
  104. * and will be hardware invalidated automatically when CPU core is re-power up.
  105. * When the L2 cache power is ON, L2 cache will keep power on even if CPU core is power down and
  106. * will not be hardware invalidated.
  107. * When CPU core is re-power up, the default setting is OFF.
  108. *
  109. * @param base GPC peripheral base address.
  110. * @param enable Enable the request or not.
  111. */
  112. static inline void GPC_RequestL2CachePowerDown(GPC_Type *base, bool enable)
  113. {
  114. if (enable)
  115. {
  116. base->CNTR |= GPC_CNTR_L2_PGE_MASK; /* OFF. */
  117. }
  118. else
  119. {
  120. base->CNTR &= ~GPC_CNTR_L2_PGE_MASK; /* ON. */
  121. }
  122. }
  123. #endif /* FSL_FEATURE_GPC_HAS_CNTR_L2PGE */
  124. #if (defined(FSL_FEATURE_GPC_HAS_CNTR_PDRAM0PGE) && FSL_FEATURE_GPC_HAS_CNTR_PDRAM0PGE)
  125. /*!
  126. * @brief FLEXRAM PDRAM0 Power Gate Enable
  127. *
  128. * This function configures the FLEXRAM PDRAM0 if it will keep power when cpu core is power down.
  129. * When the PDRAM0 Power is 1, PDRAM0 will be power down once when CPU core is power down.
  130. * When the PDRAM0 Power is 0, PDRAM0 will keep power on even if CPU core is power down.
  131. * When CPU core is re-power up, the default setting is 1.
  132. *
  133. * @param base GPC peripheral base address.
  134. * @param enable Enable the request or not.
  135. */
  136. static inline void GPC_RequestPdram0PowerDown(GPC_Type *base, bool enable)
  137. {
  138. if (enable)
  139. {
  140. base->CNTR |= GPC_CNTR_PDRAM0_PGE_MASK; /* OFF. */
  141. }
  142. else
  143. {
  144. base->CNTR &= ~GPC_CNTR_PDRAM0_PGE_MASK; /* ON. */
  145. }
  146. }
  147. #endif /* FSL_FEATURE_GPC_HAS_CNTR_PDRAM0PGE */
  148. #if (defined(FSL_FEATURE_GPC_HAS_CNTR_VADC) && FSL_FEATURE_GPC_HAS_CNTR_VADC)
  149. /*!
  150. * @brief VADC power down.
  151. *
  152. * This function requests the VADC power down.
  153. *
  154. * @param base GPC peripheral base address.
  155. * @param enable Enable the request or not.
  156. */
  157. static inline void GPC_RequestVADCPowerDown(GPC_Type *base, bool enable)
  158. {
  159. if (enable)
  160. {
  161. base->CNTR &= ~GPC_CNTR_VADC_EXT_PWD_N_MASK; /* VADC power down. */
  162. }
  163. else
  164. {
  165. base->CNTR |= GPC_CNTR_VADC_EXT_PWD_N_MASK; /* VADC not power down. */
  166. }
  167. }
  168. /*!
  169. * @brief Checks if the VADC is power off.
  170. *
  171. * @param base GPC peripheral base address.
  172. * @return Whether the VADC is power off or not.
  173. */
  174. static inline bool GPC_GetVADCPowerDownFlag(GPC_Type *base)
  175. {
  176. return (GPC_CNTR_VADC_ANALOG_OFF_MASK == (GPC_CNTR_VADC_ANALOG_OFF_MASK & base->CNTR));
  177. }
  178. #endif /* FSL_FEATURE_GPC_HAS_CNTR_VADC */
  179. #if (defined(FSL_FEATURE_GPC_HAS_CNTR_DVFS0CR) && FSL_FEATURE_GPC_HAS_CNTR_DVFS0CR)
  180. /*!
  181. * @brief Checks if the DVFS0 is requesting for frequency/voltage update.
  182. *
  183. * @param base GPC peripheral base address.
  184. * @return Whether the DVFS0 is requesting for frequency/voltage update.
  185. */
  186. static inline bool GPC_HasDVFS0ChangeRequest(GPC_Type *base)
  187. {
  188. return (GPC_CNTR_DVFS0CR_MASK == (GPC_CNTR_DVFS0CR_MASK & base->CNTR));
  189. }
  190. #endif /* FSL_FEATURE_GPC_HAS_CNTR_DVFS0CR */
  191. #if (defined(FSL_FEATURE_GPC_HAS_CNTR_DISPLAY) && FSL_FEATURE_GPC_HAS_CNTR_DISPLAY)
  192. /*!
  193. * @brief Requests the display power switch sequence.
  194. *
  195. * @param base GPC peripheral base address.
  196. * @param enable Enable the power on sequence, or the power down sequence.
  197. */
  198. static inline void GPC_RequestDisplayPowerOn(GPC_Type *base, bool enable)
  199. {
  200. if (enable)
  201. {
  202. base->CNTR |= GPC_CNTR_DISPLAY_PUP_REQ_MASK; /* Power on sequence. */
  203. }
  204. else
  205. {
  206. base->CNTR |= GPC_CNTR_DISPLAY_PDN_REQ_MASK; /* Power down sequence. */
  207. }
  208. }
  209. #endif /* FSL_FEATURE_GPC_HAS_CNTR_DISPLAY */
  210. /*!
  211. * @brief Requests the MEGA power switch sequence.
  212. *
  213. * @param base GPC peripheral base address.
  214. * @param enable Enable the power on sequence, or the power down sequence.
  215. */
  216. static inline void GPC_RequestMEGAPowerOn(GPC_Type *base, bool enable)
  217. {
  218. if (enable)
  219. {
  220. base->CNTR |= GPC_CNTR_MEGA_PUP_REQ_MASK; /* Power on sequence. */
  221. }
  222. else
  223. {
  224. base->CNTR |= GPC_CNTR_MEGA_PDN_REQ_MASK; /* Power down sequence. */
  225. }
  226. }
  227. /*!
  228. * @}
  229. */
  230. #if defined(__cplusplus)
  231. }
  232. #endif
  233. /*!
  234. * @}
  235. */
  236. #endif /* _FSL_GPC_H_ */