fsl_pmu.h 21 KB

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