fsl_gpc.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /*
  2. * Copyright (c) 2016, Freescale Semiconductor, Inc.
  3. * Copyright 2016-2019 NXP
  4. * All rights reserved.
  5. *
  6. *
  7. * SPDX-License-Identifier: BSD-3-Clause
  8. */
  9. #ifndef _FSL_GPC_H_
  10. #define _FSL_GPC_H_
  11. #include "fsl_common.h"
  12. /*!
  13. * @addtogroup gpc
  14. * @{
  15. */
  16. /*******************************************************************************
  17. * Definitions
  18. ******************************************************************************/
  19. /*! @name Driver version */
  20. /*@{*/
  21. /*! @brief GPC driver version 2.1.1. */
  22. #define FSL_GPC_DRIVER_VERSION (MAKE_VERSION(2, 1, 1))
  23. /*@}*/
  24. #if defined(__cplusplus)
  25. extern "C" {
  26. #endif
  27. /*******************************************************************************
  28. * API
  29. ******************************************************************************/
  30. #if (defined(FSL_FEATURE_GPC_HAS_CNTR_GPCIRQM) && FSL_FEATURE_GPC_HAS_CNTR_GPCIRQM)
  31. /*!
  32. * @brief Allow all the IRQ/Events within the charge of GPC.
  33. *
  34. * @param base GPC peripheral base address.
  35. */
  36. static inline void GPC_AllowIRQs(GPC_Type *base)
  37. {
  38. base->CNTR &= ~GPC_CNTR_GPCIRQM_MASK; /* Events would not be masked. */
  39. }
  40. /*!
  41. * @brief Disallow all the IRQ/Events within the charge of GPC.
  42. *
  43. * @param base GPC peripheral base address.
  44. */
  45. static inline void GPC_DisallowIRQs(GPC_Type *base)
  46. {
  47. base->CNTR |= GPC_CNTR_GPCIRQM_MASK; /* Mask all the events. */
  48. }
  49. #endif /* FSL_FEATURE_GPC_HAS_CNTR_GPCIRQM */
  50. /*!
  51. * @brief Enable the IRQ.
  52. *
  53. * @param base GPC peripheral base address.
  54. * @param irqId ID number of IRQ to be enabled, available range is 32-159. 0-31 is available in some platforms.
  55. */
  56. void GPC_EnableIRQ(GPC_Type *base, uint32_t irqId);
  57. /*!
  58. * @brief Disable the IRQ.
  59. *
  60. * @param base GPC peripheral base address.
  61. * @param irqId ID number of IRQ to be disabled, available range is 32-159. 0-31 is available in some platforms.
  62. */
  63. void GPC_DisableIRQ(GPC_Type *base, uint32_t irqId);
  64. /*!
  65. * @brief Get the IRQ/Event flag.
  66. *
  67. * @param base GPC peripheral base address.
  68. * @param irqId ID number of IRQ to be enabled, available range is 32-159. 0-31 is available in some platforms.
  69. * @return Indicated IRQ/Event is asserted or not.
  70. */
  71. bool GPC_GetIRQStatusFlag(GPC_Type *base, uint32_t irqId);
  72. #if (defined(FSL_FEATURE_GPC_HAS_CNTR_L2PGE) && FSL_FEATURE_GPC_HAS_CNTR_L2PGE)
  73. /*!
  74. * @brief L2 Cache Power Gate Enable
  75. *
  76. * This function configures the L2 cache if it will keep power when in low power mode.
  77. * When the L2 cache power is OFF, L2 cache will be power down once when CPU core is power down
  78. * and will be hardware invalidated automatically when CPU core is re-power up.
  79. * When the L2 cache power is ON, L2 cache will keep power on even if CPU core is power down and
  80. * will not be hardware invalidated.
  81. * When CPU core is re-power up, the default setting is OFF.
  82. *
  83. * @param base GPC peripheral base address.
  84. * @param enable Enable the request or not.
  85. */
  86. static inline void GPC_RequestL2CachePowerDown(GPC_Type *base, bool enable)
  87. {
  88. if (enable)
  89. {
  90. base->CNTR |= GPC_CNTR_L2_PGE_MASK; /* OFF. */
  91. }
  92. else
  93. {
  94. base->CNTR &= ~GPC_CNTR_L2_PGE_MASK; /* ON. */
  95. }
  96. }
  97. #endif /* FSL_FEATURE_GPC_HAS_CNTR_L2PGE */
  98. #if (defined(FSL_FEATURE_GPC_HAS_CNTR_PDRAM0PGE) && FSL_FEATURE_GPC_HAS_CNTR_PDRAM0PGE)
  99. /*!
  100. * @brief FLEXRAM PDRAM0 Power Gate Enable
  101. *
  102. * This function configures the FLEXRAM PDRAM0 if it will keep power when cpu core is power down.
  103. * When the PDRAM0 Power is 1, PDRAM0 will be power down once when CPU core is power down.
  104. * When the PDRAM0 Power is 0, PDRAM0 will keep power on even if CPU core is power down.
  105. * When CPU core is re-power up, the default setting is 1.
  106. *
  107. * @param base GPC peripheral base address.
  108. * @param enable Enable the request or not.
  109. */
  110. static inline void GPC_RequestPdram0PowerDown(GPC_Type *base, bool enable)
  111. {
  112. if (enable)
  113. {
  114. base->CNTR |= GPC_CNTR_PDRAM0_PGE_MASK; /* OFF. */
  115. }
  116. else
  117. {
  118. base->CNTR &= ~GPC_CNTR_PDRAM0_PGE_MASK; /* ON. */
  119. }
  120. }
  121. #endif /* FSL_FEATURE_GPC_HAS_CNTR_PDRAM0PGE */
  122. #if (defined(FSL_FEATURE_GPC_HAS_CNTR_VADC) && FSL_FEATURE_GPC_HAS_CNTR_VADC)
  123. /*!
  124. * @brief VADC power down.
  125. *
  126. * This function requests the VADC power down.
  127. *
  128. * @param base GPC peripheral base address.
  129. * @param enable Enable the request or not.
  130. */
  131. static inline void GPC_RequestVADCPowerDown(GPC_Type *base, bool enable)
  132. {
  133. if (enable)
  134. {
  135. base->CNTR &= ~GPC_CNTR_VADC_EXT_PWD_N_MASK; /* VADC power down. */
  136. }
  137. else
  138. {
  139. base->CNTR |= GPC_CNTR_VADC_EXT_PWD_N_MASK; /* VADC not power down. */
  140. }
  141. }
  142. /*!
  143. * @brief Checks if the VADC is power off.
  144. *
  145. * @param base GPC peripheral base address.
  146. * @return Whether the VADC is power off or not.
  147. */
  148. static inline bool GPC_GetVADCPowerDownFlag(GPC_Type *base)
  149. {
  150. return (GPC_CNTR_VADC_ANALOG_OFF_MASK == (GPC_CNTR_VADC_ANALOG_OFF_MASK & base->CNTR));
  151. }
  152. #endif /* FSL_FEATURE_GPC_HAS_CNTR_VADC */
  153. #if (defined(FSL_FEATURE_GPC_HAS_CNTR_DVFS0CR) && FSL_FEATURE_GPC_HAS_CNTR_DVFS0CR)
  154. /*!
  155. * @brief Checks if the DVFS0 is requesting for frequency/voltage update.
  156. *
  157. * @param base GPC peripheral base address.
  158. * @return Whether the DVFS0 is requesting for frequency/voltage update.
  159. */
  160. static inline bool GPC_HasDVFS0ChangeRequest(GPC_Type *base)
  161. {
  162. return (GPC_CNTR_DVFS0CR_MASK == (GPC_CNTR_DVFS0CR_MASK & base->CNTR));
  163. }
  164. #endif /* FSL_FEATURE_GPC_HAS_CNTR_DVFS0CR */
  165. #if (defined(FSL_FEATURE_GPC_HAS_CNTR_DISPLAY) && FSL_FEATURE_GPC_HAS_CNTR_DISPLAY)
  166. /*!
  167. * @brief Requests the display power switch sequence.
  168. *
  169. * @param base GPC peripheral base address.
  170. * @param enable Enable the power on sequence, or the power down sequence.
  171. */
  172. static inline void GPC_RequestDisplayPowerOn(GPC_Type *base, bool enable)
  173. {
  174. if (enable)
  175. {
  176. base->CNTR |= GPC_CNTR_DISPLAY_PUP_REQ_MASK; /* Power on sequence. */
  177. }
  178. else
  179. {
  180. base->CNTR |= GPC_CNTR_DISPLAY_PDN_REQ_MASK; /* Power down sequence. */
  181. }
  182. }
  183. #endif /* FSL_FEATURE_GPC_HAS_CNTR_DISPLAY */
  184. /*!
  185. * @brief Requests the MEGA power switch sequence.
  186. *
  187. * @param base GPC peripheral base address.
  188. * @param enable Enable the power on sequence, or the power down sequence.
  189. */
  190. static inline void GPC_RequestMEGAPowerOn(GPC_Type *base, bool enable)
  191. {
  192. if (enable)
  193. {
  194. base->CNTR |= GPC_CNTR_MEGA_PUP_REQ_MASK; /* Power on sequence. */
  195. }
  196. else
  197. {
  198. base->CNTR |= GPC_CNTR_MEGA_PDN_REQ_MASK; /* Power down sequence. */
  199. }
  200. }
  201. /*!
  202. * @}
  203. */
  204. #if defined(__cplusplus)
  205. }
  206. #endif
  207. /*!
  208. * @}
  209. */
  210. #endif /* _FSL_GPC_H_ */