fsl_pmu.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. /*
  2. * Copyright (c) 2016, Freescale Semiconductor, Inc.
  3. * Copyright 2016-2017 NXP
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * o Redistributions of source code must retain the above copyright notice, this list
  9. * of conditions and the following disclaimer.
  10. *
  11. * o Redistributions in binary form must reproduce the above copyright notice, this
  12. * list of conditions and the following disclaimer in the documentation and/or
  13. * other materials provided with the distribution.
  14. *
  15. * o Neither the name of the copyright holder nor the names of its
  16. * contributors may be used to endorse or promote products derived from this
  17. * software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  23. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  26. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef _FSL_PMU_H_
  31. #define _FSL_PMU_H_
  32. #include "fsl_common.h"
  33. /*! @addtogroup pmu */
  34. /*! @{ */
  35. /*******************************************************************************
  36. * Definitions
  37. ******************************************************************************/
  38. /*! @name Driver version */
  39. /*@{*/
  40. /*! @brief PMU driver version */
  41. #define FSL_PMU_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) /*!< Version 2.0.0. */
  42. /*@}*/
  43. /*!
  44. * @brief Status flags.
  45. */
  46. enum _pmu_status_flags
  47. {
  48. kPMU_1P1RegulatorOutputOK = (1U << 0U), /*!< Status bit that signals when the 1p1 regulator output
  49. is ok. 1 = regulator output > brownout target. */
  50. kPMU_1P1BrownoutOnOutput = (1U << 1U), /*!< Status bit that signals when a 1p1 brownout is detected
  51. on the regulator output. */
  52. kPMU_3P0RegulatorOutputOK = (1U << 2U), /*!< Status bit that signals when the 3p0 regulator output
  53. is ok. 1 = regulator output > brownout target. */
  54. kPMU_3P0BrownoutOnOutput = (1U << 3U), /*!< Status bit that signals when a 3p0 brownout is detected
  55. on the regulator output. */
  56. kPMU_2P5RegulatorOutputOK = (1U << 4U), /*!< Status bit that signals when the 2p5 regulator output
  57. is ok. 1 = regulator output > brownout target. */
  58. kPMU_2P5BrownoutOnOutput = (1U << 5U), /*!< Status bit that signals when a 2p5 brownout is detected
  59. on the regulator output. */
  60. };
  61. /*!
  62. * @brief The source for the reference voltage of the weak 1P1 regulator.
  63. */
  64. typedef enum _pmu_1p1_weak_reference_source
  65. {
  66. kPMU_1P1WeakReferenceSourceAlt0 = 0U, /*!< Weak-linreg output tracks low-power-bandgap voltage. */
  67. kPMU_1P1WeakReferenceSourceAlt1 = 1U, /*!< Weak-linreg output tracks VDD_SOC_CAP voltage. */
  68. } pmu_1p1_weak_reference_source_t;
  69. /*!
  70. * @brief Input voltage source for LDO_3P0 from USB VBus.
  71. */
  72. typedef enum _pmu_3p0_vbus_voltage_source
  73. {
  74. kPMU_3P0VBusVoltageSourceAlt0 = 0U, /*!< USB_OTG1_VBUS - Utilize VBUS OTG1 for power. */
  75. kPMU_3P0VBusVoltageSourceAlt1 = 1U, /*!< USB_OTG2_VBUS - Utilize VBUS OTG2 for power. */
  76. } pmu_3p0_vbus_voltage_source_t;
  77. /*!
  78. * @brief Regulator voltage ramp rate.
  79. */
  80. typedef enum _pmu_core_reg_voltage_ramp_rate
  81. {
  82. kPMU_CoreRegVoltageRampRateFast = 0U, /*!< Fast. */
  83. kPMU_CoreRegVoltageRampRateMediumFast = 1U, /*!< Medium Fast. */
  84. kPMU_CoreRegVoltageRampRateMediumSlow = 2U, /*!< Medium Slow. */
  85. kPMU_CoreRegVoltageRampRateSlow = 0U, /*!< Slow. */
  86. } pmu_core_reg_voltage_ramp_rate_t;
  87. #if defined(FSL_FEATURE_PMU_HAS_LOWPWR_CTRL) && FSL_FEATURE_PMU_HAS_LOWPWR_CTRL
  88. /*!
  89. * @brief Mask values of power gate.
  90. */
  91. enum _pmu_power_gate
  92. {
  93. kPMU_PowerGateDisplay = PMU_LOWPWR_CTRL_MIX_PWRGATE_MASK, /*!< Display power gate control. */
  94. kPMU_PowerGateDisplayLogic = PMU_LOWPWR_CTRL_DISPLAY_PWRGATE_MASK, /*!< Display logic power gate control. */
  95. kPMU_PowerGateL2 = PMU_LOWPWR_CTRL_L2_PWRGATE_MASK, /*!< L2 power gate control. */
  96. kPMU_PowerGateL1 = PMU_LOWPWR_CTRL_L1_PWRGATE_MASK, /*!< L1 power gate control. */
  97. kPMU_PowerGateRefTopIBias = PMU_LOWPWR_CTRL_REFTOP_IBIAS_OFF_MASK, /*!< Low power reftop ibias disable. */
  98. };
  99. #endif /* FSL_FEATURE_PMU_HAS_LOWPWR_CTRL. */
  100. /*!
  101. * @brief Bandgap select.
  102. */
  103. typedef enum _pmu_power_bandgap
  104. {
  105. kPMU_NormalPowerBandgap = 0U, /*!< Normal power bandgap. */
  106. kPMU_LowPowerBandgap = 1U, /*!< Low power bandgap. */
  107. } pmu_power_bandgap_t;
  108. /*******************************************************************************
  109. * API
  110. ******************************************************************************/
  111. #if defined(__cplusplus)
  112. extern "C" {
  113. #endif /* __cplusplus*/
  114. /*!
  115. * @name Status.
  116. * @{
  117. */
  118. uint32_t PMU_GetStatusFlags(PMU_Type *base);
  119. /*@}*/
  120. /*!
  121. * @name 1P1 Regular
  122. * @{
  123. */
  124. /*!
  125. * @brief Selects the source for the reference voltage of the weak 1P1 regulator.
  126. *
  127. * @param base PMU peripheral base address.
  128. * @param option The option for reference voltage source, see to #pmu_1p1_weak_reference_source_t.
  129. */
  130. static inline void PMU_1P1SetWeakReferenceSource(PMU_Type *base, pmu_1p1_weak_reference_source_t option)
  131. {
  132. base->REG_1P1 = (base->REG_1P1 & ~PMU_REG_1P1_SELREF_WEAK_LINREG_MASK) | PMU_REG_1P1_SELREF_WEAK_LINREG(option);
  133. }
  134. /*!
  135. * @brief Enables the weak 1P1 regulator.
  136. *
  137. * This regulator can be used when the main 1P1 regulator is disabled, under low-power conditions.
  138. *
  139. * @param base PMU peripheral base address.
  140. * @param enable Enable the feature or not.
  141. */
  142. static inline void PMU_1P1EnableWeakRegulator(PMU_Type *base, bool enable)
  143. {
  144. if (enable)
  145. {
  146. base->REG_1P1 |= PMU_REG_1P1_ENABLE_WEAK_LINREG_MASK;
  147. }
  148. else
  149. {
  150. base->REG_1P1 &= ~PMU_REG_1P1_ENABLE_WEAK_LINREG_MASK;
  151. }
  152. }
  153. /*!
  154. * @brief Adjust the 1P1 regulator output voltage.
  155. *
  156. * Each LSB is worth 25mV. Programming examples are detailed below. Other output target voltages
  157. * may be interpolated from these examples. Choices must be in this range:
  158. * - 0x1b(1.375V) >= output_trg >= 0x04(0.8V)
  159. * - 0x04 : 0.8V
  160. * - 0x10 : 1.1V (typical)
  161. * - 0x1b : 1.375V
  162. * NOTE: There may be reduced chip functionality or reliability at the extremes of the programming range.
  163. *
  164. * @param base PMU peripheral base address.
  165. * @param value Setting value for the output.
  166. */
  167. static inline void PMU_1P1SetRegulatorOutputVoltage(PMU_Type *base, uint32_t value)
  168. {
  169. base->REG_1P1 = (base->REG_1P1 & ~PMU_REG_1P1_OUTPUT_TRG_MASK) | PMU_REG_1P1_OUTPUT_TRG(value);
  170. }
  171. /*!
  172. * @brief Adjust the 1P1 regulator brownout offset voltage.
  173. *
  174. * Control bits to adjust the regulator brownout offset voltage in 25mV steps. The reset
  175. * brown-offset is 175mV below the programmed target code.
  176. * Brownout target = OUTPUT_TRG - BO_OFFSET.
  177. * Some steps may be irrelevant because of input supply limitations or load operation.
  178. *
  179. * @param base PMU peripheral base address.
  180. * @param value Setting value for the brownout offset. The available range is in 3-bit.
  181. */
  182. static inline void PMU_1P1SetBrownoutOffsetVoltage(PMU_Type *base, uint32_t value)
  183. {
  184. base->REG_1P1 = (base->REG_1P1 & ~PMU_REG_1P1_BO_OFFSET_MASK) | PMU_REG_1P1_BO_OFFSET(value);
  185. }
  186. /*!
  187. * @brief Enable the pull-down circuitry in the regulator.
  188. *
  189. * @param base PMU peripheral base address.
  190. * @param enable Enable the feature or not.
  191. */
  192. static inline void PMU_1P1EnablePullDown(PMU_Type *base, bool enable)
  193. {
  194. if (enable)
  195. {
  196. base->REG_1P1 |= PMU_REG_1P1_ENABLE_PULLDOWN_MASK;
  197. }
  198. else
  199. {
  200. base->REG_1P1 &= ~PMU_REG_1P1_ENABLE_PULLDOWN_MASK;
  201. }
  202. }
  203. /*!
  204. * @brief Enable the current-limit circuitry in the regulator.
  205. *
  206. * @param base PMU peripheral base address.
  207. * @param enable Enable the feature or not.
  208. */
  209. static inline void PMU_1P1EnableCurrentLimit(PMU_Type *base, bool enable)
  210. {
  211. if (enable)
  212. {
  213. base->REG_1P1 |= PMU_REG_1P1_ENABLE_ILIMIT_MASK;
  214. }
  215. else
  216. {
  217. base->REG_1P1 &= ~PMU_REG_1P1_ENABLE_ILIMIT_MASK;
  218. }
  219. }
  220. /*!
  221. * @brief Enable the brownout circuitry in the regulator.
  222. *
  223. * @param base PMU peripheral base address.
  224. * @param enable Enable the feature or not.
  225. */
  226. static inline void PMU_1P1EnableBrownout(PMU_Type *base, bool enable)
  227. {
  228. if (enable)
  229. {
  230. base->REG_1P1 |= PMU_REG_1P1_ENABLE_BO_MASK;
  231. }
  232. else
  233. {
  234. base->REG_1P1 &= ~PMU_REG_1P1_ENABLE_BO_MASK;
  235. }
  236. }
  237. /*!
  238. * @brief Enable the regulator output.
  239. *
  240. * @param base PMU peripheral base address.
  241. * @param enable Enable the feature or not.
  242. */
  243. static inline void PMU_1P1EnableOutput(PMU_Type *base, bool enable)
  244. {
  245. if (enable)
  246. {
  247. base->REG_1P1 |= PMU_REG_1P1_ENABLE_LINREG_MASK;
  248. }
  249. else
  250. {
  251. base->REG_1P1 &= ~PMU_REG_1P1_ENABLE_LINREG_MASK;
  252. }
  253. }
  254. /*@}*/
  255. /*!
  256. * @name 3P0 Regular
  257. * @{
  258. */
  259. /*!
  260. * @brief Adjust the 3P0 regulator output voltage.
  261. *
  262. * Each LSB is worth 25mV. Programming examples are detailed below. Other output target voltages
  263. * may be interpolated from these examples. Choices must be in this range:
  264. * - 0x00(2.625V) >= output_trg >= 0x1f(3.4V)
  265. * - 0x00 : 2.625V
  266. * - 0x0f : 3.0V (typical)
  267. * - 0x1f : 3.4V
  268. *
  269. * @param base PMU peripheral base address.
  270. * @param value Setting value for the output.
  271. */
  272. static inline void PMU_3P0SetRegulatorOutputVoltage(PMU_Type *base, uint32_t value)
  273. {
  274. base->REG_3P0 = (base->REG_3P0 & ~PMU_REG_3P0_OUTPUT_TRG_MASK) | PMU_REG_3P0_OUTPUT_TRG(value);
  275. }
  276. /*!
  277. * @brief Select input voltage source for LDO_3P0.
  278. *
  279. * Select input voltage source for LDO_3P0 from either USB_OTG1_VBUS or USB_OTG2_VBUS. If only
  280. * one of the two VBUS voltages is present, it is automatically selected.
  281. *
  282. * @param base PMU peripheral base address.
  283. * @param option User-defined input voltage source for LDO_3P0.
  284. */
  285. static inline void PMU_3P0SetVBusVoltageSource(PMU_Type *base, pmu_3p0_vbus_voltage_source_t option)
  286. {
  287. base->REG_3P0 = (base->REG_3P0 & ~PMU_REG_3P0_VBUS_SEL_MASK) | PMU_REG_3P0_VBUS_SEL(option);
  288. }
  289. /*!
  290. * @brief Adjust the 3P0 regulator brownout offset voltage.
  291. *
  292. * Control bits to adjust the 3P0 regulator brownout offset voltage in 25mV steps. The reset
  293. * brown-offset is 175mV below the programmed target code.
  294. * Brownout target = OUTPUT_TRG - BO_OFFSET.
  295. * Some steps may be irrelevant because of input supply limitations or load operation.
  296. *
  297. * @param base PMU peripheral base address.
  298. * @param value Setting value for the brownout offset. The available range is in 3-bit.
  299. */
  300. static inline void PMU_3P0SetBrownoutOffsetVoltage(PMU_Type *base, uint32_t value)
  301. {
  302. base->REG_3P0 = (base->REG_3P0 & ~PMU_REG_3P0_BO_OFFSET_MASK) | PMU_REG_3P0_BO_OFFSET(value);
  303. }
  304. /*!
  305. * @brief Enable the current-limit circuitry in the 3P0 regulator.
  306. *
  307. * @param base PMU peripheral base address.
  308. * @param enable Enable the feature or not.
  309. */
  310. static inline void PMU_3P0EnableCurrentLimit(PMU_Type *base, bool enable)
  311. {
  312. if (enable)
  313. {
  314. base->REG_3P0 |= PMU_REG_3P0_ENABLE_ILIMIT_MASK;
  315. }
  316. else
  317. {
  318. base->REG_3P0 &= ~PMU_REG_3P0_ENABLE_ILIMIT_MASK;
  319. }
  320. }
  321. /*!
  322. * @brief Enable the brownout circuitry in the 3P0 regulator.
  323. *
  324. * @param base PMU peripheral base address.
  325. * @param enable Enable the feature or not.
  326. */
  327. static inline void PMU_3P0EnableBrownout(PMU_Type *base, bool enable)
  328. {
  329. if (enable)
  330. {
  331. base->REG_3P0 |= PMU_REG_3P0_ENABLE_BO_MASK;
  332. }
  333. else
  334. {
  335. base->REG_3P0 &= ~PMU_REG_3P0_ENABLE_BO_MASK;
  336. }
  337. }
  338. /*!
  339. * @brief Enable the 3P0 regulator output.
  340. *
  341. * @param base PMU peripheral base address.
  342. * @param enable Enable the feature or not.
  343. */
  344. static inline void PMU_3P0EnableOutput(PMU_Type *base, bool enable)
  345. {
  346. if (enable)
  347. {
  348. base->REG_3P0 |= PMU_REG_3P0_ENABLE_LINREG_MASK;
  349. }
  350. else
  351. {
  352. base->REG_3P0 &= ~PMU_REG_3P0_ENABLE_LINREG_MASK;
  353. }
  354. }
  355. /* @} */
  356. /*!
  357. * @name 2P5 Regulator
  358. * @{
  359. */
  360. /*!
  361. * @brief Enables the weak 2P5 regulator.
  362. *
  363. * This low power regulator is used when the main 2P5 regulator is disabled
  364. * to keep the 2.5V output roughly at 2.5V. Scales directly with the value of VDDHIGH_IN.
  365. *
  366. * @param base PMU peripheral base address.
  367. * @param enable Enable the feature or not.
  368. */
  369. static inline void PMU_2P5EnableWeakRegulator(PMU_Type *base, bool enable)
  370. {
  371. if (enable)
  372. {
  373. base->REG_2P5 |= PMU_REG_2P5_ENABLE_WEAK_LINREG_MASK;
  374. }
  375. else
  376. {
  377. base->REG_2P5 &= ~PMU_REG_2P5_ENABLE_WEAK_LINREG_MASK;
  378. }
  379. }
  380. /*!
  381. * @brief Adjust the 1P1 regulator output voltage.
  382. *
  383. * Each LSB is worth 25mV. Programming examples are detailed below. Other output target voltages
  384. * may be interpolated from these examples. Choices must be in this range:
  385. * - 0x00(2.1V) >= output_trg >= 0x1f(2.875V)
  386. * - 0x00 : 2.1V
  387. * - 0x10 : 2.5V (typical)
  388. * - 0x1f : 2.875V
  389. * NOTE: There may be reduced chip functionality or reliability at the extremes of the programming range.
  390. *
  391. * @param base PMU peripheral base address.
  392. * @param value Setting value for the output.
  393. */
  394. static inline void PMU_2P5SetRegulatorOutputVoltage(PMU_Type *base, uint32_t value)
  395. {
  396. base->REG_2P5 = (base->REG_2P5 & ~PMU_REG_2P5_OUTPUT_TRG_MASK) | PMU_REG_2P5_OUTPUT_TRG(value);
  397. }
  398. /*!
  399. * @brief Adjust the 2P5 regulator brownout offset voltage.
  400. *
  401. * Adjust the regulator brownout offset voltage in 25mV steps. The reset
  402. * brown-offset is 175mV below the programmed target code.
  403. * Brownout target = OUTPUT_TRG - BO_OFFSET.
  404. * Some steps may be irrelevant because of input supply limitations or load operation.
  405. *
  406. * @param base PMU peripheral base address.
  407. * @param value Setting value for the brownout offset. The available range is in 3-bit.
  408. */
  409. static inline void PMU_2P5SetBrownoutOffsetVoltage(PMU_Type *base, uint32_t value)
  410. {
  411. base->REG_2P5 = (base->REG_2P5 & ~PMU_REG_2P5_BO_OFFSET_MASK) | PMU_REG_2P5_BO_OFFSET(value);
  412. }
  413. /*!
  414. * @brief Enable the pull-down circuitry in the 2P5 regulator.
  415. *
  416. * @param base PMU peripheral base address.
  417. * @param enable Enable the feature or not.
  418. */
  419. static inline void PMU_2P5EnablePullDown(PMU_Type *base, bool enable)
  420. {
  421. if (enable)
  422. {
  423. base->REG_2P5 |= PMU_REG_2P5_ENABLE_PULLDOWN_MASK;
  424. }
  425. else
  426. {
  427. base->REG_2P5 &= ~PMU_REG_2P5_ENABLE_PULLDOWN_MASK;
  428. }
  429. }
  430. /*!
  431. * @brief Enable the pull-down circuitry in the 2P5 regulator.
  432. * @deprecated Do not use this function. It has been superceded by @ref PMU_2P5EnablePullDown.
  433. */
  434. static inline void PMU_2P1EnablePullDown(PMU_Type *base, bool enable)
  435. {
  436. if (enable)
  437. {
  438. base->REG_2P5 |= PMU_REG_2P5_ENABLE_PULLDOWN_MASK;
  439. }
  440. else
  441. {
  442. base->REG_2P5 &= ~PMU_REG_2P5_ENABLE_PULLDOWN_MASK;
  443. }
  444. }
  445. /*!
  446. * @brief Enable the current-limit circuitry in the 2P5 regulator.
  447. *
  448. * @param base PMU peripheral base address.
  449. * @param enable Enable the feature or not.
  450. */
  451. static inline void PMU_2P5EnableCurrentLimit(PMU_Type *base, bool enable)
  452. {
  453. if (enable)
  454. {
  455. base->REG_2P5 |= PMU_REG_2P5_ENABLE_ILIMIT_MASK;
  456. }
  457. else
  458. {
  459. base->REG_2P5 &= ~PMU_REG_2P5_ENABLE_ILIMIT_MASK;
  460. }
  461. }
  462. /*!
  463. * @brief Enable the brownout circuitry in the 2P5 regulator.
  464. *
  465. * @param base PMU peripheral base address.
  466. * @param enable Enable the feature or not.
  467. */
  468. static inline void PMU_2P5nableBrownout(PMU_Type *base, bool enable)
  469. {
  470. if (enable)
  471. {
  472. base->REG_2P5 |= PMU_REG_2P5_ENABLE_BO_MASK;
  473. }
  474. else
  475. {
  476. base->REG_2P5 &= ~PMU_REG_2P5_ENABLE_BO_MASK;
  477. }
  478. }
  479. /*!
  480. * @brief Enable the 2P5 regulator output.
  481. *
  482. * @param base PMU peripheral base address.
  483. * @param enable Enable the feature or not.
  484. */
  485. static inline void PMU_2P5EnableOutput(PMU_Type *base, bool enable)
  486. {
  487. if (enable)
  488. {
  489. base->REG_2P5 |= PMU_REG_2P5_ENABLE_LINREG_MASK;
  490. }
  491. else
  492. {
  493. base->REG_2P5 &= ~PMU_REG_2P5_ENABLE_LINREG_MASK;
  494. }
  495. }
  496. /* @} */
  497. /*!
  498. * @name Core Regulator
  499. * @{
  500. */
  501. /*!
  502. * @brief Increase the gate drive on power gating FETs.
  503. *
  504. * If set, increases the gate drive on power gating FETs to reduce leakage in the off state.
  505. * Care must be taken to apply this bit only when the input supply voltage to the power FET
  506. * is less than 1.1V.
  507. * NOTE: This bit should only be used in low-power modes where the external input supply voltage
  508. * is nominally 0.9V.
  509. *
  510. * @param base PMU peripheral base address.
  511. * @param enable Enable the feature or not.
  512. */
  513. static inline void PMU_CoreEnableIncreaseGateDrive(PMU_Type *base, bool enable)
  514. {
  515. if (enable)
  516. {
  517. base->REG_CORE |= PMU_REG_CORE_FET_ODRIVE_MASK;
  518. }
  519. else
  520. {
  521. base->REG_CORE &= ~PMU_REG_CORE_FET_ODRIVE_MASK;
  522. }
  523. }
  524. /*!
  525. * @brief Set the CORE regulator voltage ramp rate.
  526. *
  527. * @param base PMU peripheral base address.
  528. * @param option User-defined option for voltage ramp rate, see to #pmu_core_reg_voltage_ramp_rate_t.
  529. */
  530. static inline void PMU_CoreSetRegulatorVoltageRampRate(PMU_Type *base, pmu_core_reg_voltage_ramp_rate_t option)
  531. {
  532. base->REG_CORE = (base->REG_CORE & ~PMU_REG_CORE_RAMP_RATE_MASK) | PMU_REG_CORE_RAMP_RATE(option);
  533. }
  534. /*!
  535. * @brief Define the target voltage for the SOC power domain.
  536. *
  537. * Define the target voltage for the SOC power domain. Single-bit increments reflect 25mV core
  538. * voltage steps. Some steps may not be relevant because of input supply limitations or load operation.
  539. * - 0x00 : Power gated off.
  540. * - 0x01 : Target core voltage = 0.725V
  541. * - 0x02 : Target core voltage = 0.750V
  542. * - ...
  543. * - 0x10 : Target core voltage = 1.100V
  544. * - ...
  545. * - 0x1e : Target core voltage = 1.450V
  546. * - 0x1F : Power FET switched full on. No regulation.
  547. * NOTE: This register is capable of programming an over-voltage condition on the device. Consult the
  548. * datasheet Operating Ranges table for the allowed voltages.
  549. *
  550. * @param base PMU peripheral base address.
  551. * @param value Setting value for target voltage. 5-bit available
  552. */
  553. static inline void PMU_CoreSetSOCDomainVoltage(PMU_Type *base, uint32_t value)
  554. {
  555. base->REG_CORE = (base->REG_CORE & ~PMU_REG_CORE_REG2_TARG_MASK) | PMU_REG_CORE_REG2_TARG(value);
  556. }
  557. /*!
  558. * @brief Define the target voltage for the ARM Core power domain.
  559. *
  560. * Define the target voltage for the ARM Core power domain. Single-bit increments reflect 25mV core
  561. * voltage steps. Some steps may not be relevant because of input supply limitations or load operation.
  562. * - 0x00 : Power gated off.
  563. * - 0x01 : Target core voltage = 0.725V
  564. * - 0x02 : Target core voltage = 0.750V
  565. * - ...
  566. * - 0x10 : Target core voltage = 1.100V
  567. * - ...
  568. * - 0x1e : Target core voltage = 1.450V
  569. * - 0x1F : Power FET switched full on. No regulation.
  570. * NOTE: This register is capable of programming an over-voltage condition on the device. Consult the
  571. * datasheet Operating Ranges table for the allowed voltages.
  572. *
  573. * @param base PMU peripheral base address.
  574. * @param value Setting value for target voltage. 5-bit available
  575. */
  576. static inline void PMU_CoreSetARMCoreDomainVoltage(PMU_Type *base, uint32_t value)
  577. {
  578. base->REG_CORE = (base->REG_CORE & ~PMU_REG_CORE_REG0_TARG_MASK) | PMU_REG_CORE_REG0_TARG(value);
  579. }
  580. /* @} */
  581. #if defined(FSL_FEATURE_PMU_HAS_LOWPWR_CTRL) && FSL_FEATURE_PMU_HAS_LOWPWR_CTRL
  582. /*!
  583. * @name Power Gate Controller & other
  584. * @{
  585. */
  586. /*!
  587. * @brief Gate the power to modules.
  588. *
  589. * @param base PMU peripheral base address.
  590. * @param gates Mask value for the module to be gated. See to #_pmu_power_gate.
  591. */
  592. static inline void PMU_GatePower(PMU_Type *base, uint32_t gates)
  593. {
  594. base->LOWPWR_CTRL_SET = gates;
  595. }
  596. /*!
  597. * @brief Ungate the power to modules.
  598. *
  599. * @param base PMU peripheral base address.
  600. * @param gates Mask value for the module to be gated. See to #_pmu_power_gate.
  601. */
  602. static inline void PMU_UngatePower(PMU_Type *base, uint32_t gates)
  603. {
  604. base->LOWPWR_CTRL_CLR = gates;
  605. }
  606. /*!
  607. * @brief Enable the low power bandgap.
  608. *
  609. * @param base PMU peripheral base address.
  610. * @param enable Enable the low power bandgap or use the normal power bandgap.
  611. * @
  612. */
  613. static inline void PMU_EnableLowPowerBandgap(PMU_Type *base, bool enable)
  614. {
  615. if (enable)
  616. {
  617. base->LOWPWR_CTRL_SET = PMU_LOWPWR_CTRL_LPBG_SEL_MASK; /* Use the low power bandgap. */
  618. }
  619. else
  620. {
  621. base->LOWPWR_CTRL_CLR = PMU_LOWPWR_CTRL_LPBG_SEL_MASK; /* Use the normal power bandgap. */
  622. }
  623. }
  624. #endif /* FSL_FEATURE_PMU_HAS_LOWPWR_CTRL. */
  625. /* @} */
  626. #if defined(__cplusplus)
  627. }
  628. #endif /* __cplusplus*/
  629. /*! @}*/
  630. #endif /* _FSL_PMU_H_*/