aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/ext/mcux-sdk/devices/LPC54606/drivers/fsl_power.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/LPC54606/drivers/fsl_power.h')
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/devices/LPC54606/drivers/fsl_power.h245
1 files changed, 245 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/LPC54606/drivers/fsl_power.h b/lib/chibios-contrib/ext/mcux-sdk/devices/LPC54606/drivers/fsl_power.h
new file mode 100644
index 000000000..03f659cfe
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/devices/LPC54606/drivers/fsl_power.h
@@ -0,0 +1,245 @@
1/*
2 * Copyright (c) 2016, Freescale Semiconductor, Inc.
3 * Copyright 2016, NXP
4 * All rights reserved.
5 *
6 *
7 * SPDX-License-Identifier: BSD-3-Clause
8 */
9#ifndef _FSL_POWER_H_
10#define _FSL_POWER_H_
11
12#include "fsl_common.h"
13
14/*******************************************************************************
15 * Definitions
16 ******************************************************************************/
17
18/*!
19 * @addtogroup power
20 * @{
21 */
22
23/*! @name Driver version */
24/*@{*/
25/*! @brief power driver version 2.0.1. */
26#define FSL_POWER_DRIVER_VERSION (MAKE_VERSION(2, 0, 1))
27/*@}*/
28
29#define MAKE_PD_BITS(reg, slot) (((reg) << 8) | (slot))
30#define PDRCFG0 0x0U
31#define PDRCFG1 0x1U
32
33typedef enum pd_bits
34{
35 kPDRUNCFG_LP_REG = MAKE_PD_BITS(PDRCFG0, 2U),
36 kPDRUNCFG_PD_FRO_EN = MAKE_PD_BITS(PDRCFG0, 4U),
37 kPDRUNCFG_PD_TS = MAKE_PD_BITS(PDRCFG0, 6U),
38 kPDRUNCFG_PD_BOD_RESET = MAKE_PD_BITS(PDRCFG0, 7U),
39 kPDRUNCFG_PD_BOD_INTR = MAKE_PD_BITS(PDRCFG0, 8U),
40 kPDRUNCFG_PD_VD2_ANA = MAKE_PD_BITS(PDRCFG0, 9U),
41 kPDRUNCFG_PD_ADC0 = MAKE_PD_BITS(PDRCFG0, 10U),
42 kPDRUNCFG_PD_RAM0 = MAKE_PD_BITS(PDRCFG0, 13U),
43 kPDRUNCFG_PD_RAM1 = MAKE_PD_BITS(PDRCFG0, 14U),
44 kPDRUNCFG_PD_RAM2 = MAKE_PD_BITS(PDRCFG0, 15U),
45 kPDRUNCFG_PD_RAM3 = MAKE_PD_BITS(PDRCFG0, 16U),
46 kPDRUNCFG_PD_ROM = MAKE_PD_BITS(PDRCFG0, 17U),
47 kPDRUNCFG_PD_VDDA = MAKE_PD_BITS(PDRCFG0, 19U),
48 kPDRUNCFG_PD_WDT_OSC = MAKE_PD_BITS(PDRCFG0, 20U),
49 kPDRUNCFG_PD_USB0_PHY = MAKE_PD_BITS(PDRCFG0, 21U),
50 kPDRUNCFG_PD_SYS_PLL0 = MAKE_PD_BITS(PDRCFG0, 22U),
51 kPDRUNCFG_PD_VREFP = MAKE_PD_BITS(PDRCFG0, 23U),
52 kPDRUNCFG_PD_FLASH_BG = MAKE_PD_BITS(PDRCFG0, 25U),
53 kPDRUNCFG_PD_VD3 = MAKE_PD_BITS(PDRCFG0, 26U),
54 kPDRUNCFG_PD_VD4 = MAKE_PD_BITS(PDRCFG0, 27U),
55 kPDRUNCFG_PD_VD5 = MAKE_PD_BITS(PDRCFG0, 28U),
56 kPDRUNCFG_PD_VD6 = MAKE_PD_BITS(PDRCFG0, 29U),
57 kPDRUNCFG_REQ_DELAY = MAKE_PD_BITS(PDRCFG0, 30U),
58 kPDRUNCFG_FORCE_RBB = MAKE_PD_BITS(PDRCFG0, 31U),
59
60 kPDRUNCFG_PD_USB1_PHY = MAKE_PD_BITS(PDRCFG1, 0U),
61 kPDRUNCFG_PD_USB_PLL = MAKE_PD_BITS(PDRCFG1, 1U),
62 kPDRUNCFG_PD_AUDIO_PLL = MAKE_PD_BITS(PDRCFG1, 2U),
63 kPDRUNCFG_PD_SYS_OSC = MAKE_PD_BITS(PDRCFG1, 3U),
64 kPDRUNCFG_PD_EEPROM = MAKE_PD_BITS(PDRCFG1, 5U),
65 kPDRUNCFG_PD_rng = MAKE_PD_BITS(PDRCFG1, 6U),
66
67 /*
68 This enum member has no practical meaning,it is used to avoid MISRA issue,
69 user should not trying to use it.
70 */
71 kPDRUNCFG_ForceUnsigned = (int)0x80000000U,
72} pd_bit_t;
73
74/* Power mode configuration API parameter */
75typedef enum _power_mode_config
76{
77 kPmu_Sleep = 0U,
78 kPmu_Deep_Sleep = 1U,
79 kPmu_Deep_PowerDown = 2U,
80} power_mode_cfg_t;
81
82/*******************************************************************************
83 * API
84 ******************************************************************************/
85
86#ifdef __cplusplus
87extern "C" {
88#endif
89
90/*!
91* @name Power Configuration
92* @{
93*/
94
95/*!
96 * @brief API to enable PDRUNCFG bit in the Syscon. Note that enabling the bit powers down the peripheral
97 *
98 * @param en peripheral for which to enable the PDRUNCFG bit
99 * @return none
100 */
101static inline void POWER_EnablePD(pd_bit_t en)
102{
103 /* PDRUNCFGSET */
104 SYSCON->PDRUNCFGSET[((uint32_t)en >> 8UL)] = (1UL << ((uint32_t)en & 0xffU));
105}
106
107/*!
108 * @brief API to disable PDRUNCFG bit in the Syscon. Note that disabling the bit powers up the peripheral
109 *
110 * @param en peripheral for which to disable the PDRUNCFG bit
111 * @return none
112 */
113static inline void POWER_DisablePD(pd_bit_t en)
114{
115 /* PDRUNCFGCLR */
116 SYSCON->PDRUNCFGCLR[((uint32_t)en >> 8UL)] = (1UL << ((uint32_t)en & 0xffU));
117}
118
119/*!
120 * @brief API to enable deep sleep bit in the ARM Core.
121 *
122 * @return none
123 */
124static inline void POWER_EnableDeepSleep(void)
125{
126 SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
127}
128
129/*!
130 * @brief API to disable deep sleep bit in the ARM Core.
131 *
132 * @return none
133 */
134static inline void POWER_DisableDeepSleep(void)
135{
136 SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk;
137}
138
139/*!
140 * @brief API to power down flash controller.
141 *
142 * @return none
143 */
144static inline void POWER_PowerDownFlash(void)
145{
146#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
147 /* TURN OFF clock ip_2113 (only needed for FLASH programming, will be turned on by ROM API) */
148 CLOCK_DisableClock(kCLOCK_Flash);
149
150 /* TURN OFF clock ip_2113 (only needed for FLASH programming, will be turned on by ROM API) */
151 CLOCK_DisableClock(kCLOCK_Fmc);
152#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
153}
154
155/*!
156 * @brief API to power up flash controller.
157 *
158 * @return none
159 */
160static inline void POWER_PowerUpFlash(void)
161{
162#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
163 /* TURN OFF clock ip_2113 (only needed for FLASH programming, will be turned on by ROM API) */
164 CLOCK_EnableClock(kCLOCK_Fmc);
165#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
166}
167
168/*!
169 * @brief Power Library API to power the PLLs.
170 *
171 * @return none
172 */
173void POWER_SetPLL(void);
174
175/*!
176 * @brief Power Library API to power the USB PHY.
177 *
178 * @return none
179 */
180void POWER_SetUsbPhy(void);
181
182/*!
183 * @brief Power Library API to enter different power mode.
184 *
185 * @param mode Power mode configuration
186 * @param exclude_from_pd Bit mask of the PDRUNCFG0(low 32bits) and PDRUNCFG1(high 32bits) that needs to be powered on
187 * during power mode selected.
188 * @return none
189 */
190void POWER_EnterPowerMode(power_mode_cfg_t mode, uint64_t exclude_from_pd);
191
192/*!
193 * @brief Power Library API to enter sleep mode.
194 *
195 * @return none
196 */
197void POWER_EnterSleep(void);
198
199/*!
200 * @brief Power Library API to enter deep sleep mode.
201 *
202 * @param exclude_from_pd Bit mask of the PDRUNCFG0(low 32bits) and PDRUNCFG1(high 32bits) bits that needs to be
203 * powered on during deep sleep
204 * @return none
205 */
206void POWER_EnterDeepSleep(uint64_t exclude_from_pd);
207
208/*!
209 * @brief Power Library API to enter deep power down mode.
210 *
211 * @param exclude_from_pd Bit mask of the PDRUNCFG0(low 32bits) and PDRUNCFG1(high 32bits) that needs to be powered on
212 during deep power
213 * down mode, but this is has no effect as the voltages are cut off.
214
215 * @return none
216 */
217void POWER_EnterDeepPowerDown(uint64_t exclude_from_pd);
218
219/*!
220 * @brief Power Library API to choose normal regulation and set the voltage for the desired operating frequency.
221 *
222 * @param freq - The desired frequency at which the part would like to operate,
223 * note that the voltage and flash wait states should be set before changing frequency
224 * @return none
225 */
226void POWER_SetVoltageForFreq(uint32_t freq);
227
228/*!
229 * @brief Power Library API to return the library version.
230 *
231 * @return version number of the power library
232 */
233uint32_t POWER_GetLibVersion(void);
234
235/* @} */
236
237#ifdef __cplusplus
238}
239#endif
240
241/*!
242 * @}
243 */
244
245#endif /* _FSL_POWER_H_ */