fsl_gpc.h 7.7 KB

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