CC13xx Driver Library
pwr_ctrl.c
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: pwr_ctrl.c
3 * Revised: 2015-05-19 11:38:08 +0200 (Tue, 19 May 2015)
4 * Revision: 43528
5 *
6 * Description: Power Control driver.
7 *
8 * Copyright (c) 2015, Texas Instruments Incorporated
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * 1) Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 *
17 * 2) Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 *
21 * 3) Neither the name of the ORGANIZATION nor the names of its contributors may
22 * be used to endorse or promote products derived from this software without
23 * specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 *
37 ******************************************************************************/
38 
39 #include <driverlib/pwr_ctrl.h>
40 
41 //*****************************************************************************
42 //
43 // Handle support for DriverLib in ROM:
44 // This section will undo prototype renaming made in the header file
45 //
46 //*****************************************************************************
47 #if !defined(DOXYGEN)
48  #undef PowerCtrlStateSet
49  #define PowerCtrlStateSet NOROM_PowerCtrlStateSet
50  #undef PowerCtrlSourceSet
51  #define PowerCtrlSourceSet NOROM_PowerCtrlSourceSet
52 #endif
53 
54 //*****************************************************************************
55 //
56 // Force the system in to low power modes.
57 //
58 //*****************************************************************************
59 void
60 PowerCtrlStateSet(uint32_t ui32Powerstate)
61 {
62  //
63  // Check the arguments.
64  //
65  ASSERT((ui32Powerstate == PWRCTRL_STANDBY) ||
66  (ui32Powerstate == PWRCTRL_POWER_DOWN) ||
67  (ui32Powerstate == PWRCTRL_SHUTDOWN));
68 
69  //
70  // Configure the desired power state.
71  //
72  if(ui32Powerstate == PWRCTRL_STANDBY)
73  {
74  //
75  //
76  // Turn of all power domains in the MCU voltage domain. This is
77  // necessary to conserve power before switching to the uLDO.
78  //
82 
83  //
84  // Make sure to request power off of the JTAG domain.
85  //
87 
88  //
89  // Configuration of clock source for MCU and AUX in standby mode.
90  //
93 
94  //
95  // Configure the recharge controller and request the uLDO as power
96  // source.
97  //
98  AONWUCRechargeCtrlConfigSet(true, 34, 2500, 5000);
99 
100  //
101  // Enable AUX power down
102  // This will tell the system that no HF source is needed and will
103  // allow the system to use the low-leakage/effect power supply.
104  // NB. This does not allow co-existence of an independent
105  // Sensor Controller.
106  //
109 
110  //
111  // Request the uLDO for standby power consumption.
112  //
114 
115  //
116  // Sync the AON interface to ensure all writes have gone through
117  //
118  HWREG(AON_RTC_BASE + AON_RTC_O_SYNC);
119 
120  //
121  // Enable transition to standby.
122  //
123  PRCMDeepSleep();
124  }
125  else if(ui32Powerstate == PWRCTRL_POWER_DOWN)
126  {
127  //
128  // Latch the current IO configuration before going to sleep to ensure
129  // the IOs retain their value even after boot and reset of the
130  // configuration.
131  //
133 
134  //
135  // Make sure retention on MCU SRAM is on - on pr. default.
136  //
139 
140  //
141  // Allow power off on all domains in the MCU voltage domain.
142  // This is necessary to conserve power before switching to the uLDO.
143  //
147 
148  //
149  // Turn off the MCU voltage domain. This will not take effect until System CPU
150  // is in deep sleep.
151  //
152  PRCMMcuPowerOff();
153 
154  //
155  // Set the wake up mode - default value coming out of reset
156  //
158 
159  //
160  // VIRTUAL POWER OFF DISABLE is the default value coming out of reset
161  //
163 
164  //
165  // Configure the recharge controller and request the uLDO as power
166  // source.
167  // Recommended maximum numbers for lowest power consumption
168  // AdaptRate = 96
169  // MaxPeriod = 21440
170  // InitPeriod = 14816
171  //
172  AONWUCRechargeCtrlConfigSet(true, 75, 5000, 7500);
173 
174  //
175  // Enable AUX power down with LF clock source
176  // Turn off JTAG domain and enable powerdown - values are default.
177  //
182 
183  //
184  // Sync the AON interface to ensure all writes have gone through
185  //
186  HWREG(AON_RTC_BASE + AON_RTC_O_SYNC);
187 
188  //
189  // Enable transition to power down.
190  //
191  PRCMDeepSleep();
192  }
193  else
194  {
195  //
196  // Latch the current IO configuration before going to sleep to ensure
197  // the IOs retain their value even after boot and reset of the
198  // configuration.
199  //
201 
202  //
203  // Turn of all power domains in the MCU voltage domain.
204  //
208 
209  //
210  // Turn off the MCU voltage domain. This will not take effect until System CPU
211  // is in deep sleep.
212  //
213  PRCMMcuPowerOff();
214 
215  //
216  // Set the wake up mode of MCU to immediate
217  //
220 
221  //
222  // Turn off the AUX domain and wait for power to be off.
223  //
224  // Is this required for shutdown mode? or will AUX automatically
225  // power off.
228  { }
229 
230  //
231  // Latch the IOs in the padring before going to sleep to retain their
232  // value even after boot and reset of the configuration.
233  //
235 
236  //
237  // Enable shutdown and make sure the AON interface is in sync on the
238  // 32kHz clock.
239  //
241 
242  //
243  // Sync the AON interface to ensure all writes have gone through
244  //
245  HWREG(AON_RTC_BASE + AON_RTC_O_SYNC);
246 
247  //
248  // Enable transition to shutdown.
249  //
250  PRCMDeepSleep();
251  }
252 }
253 
254 //*****************************************************************************
255 //
257 //
258 //*****************************************************************************
259 void
260 PowerCtrlSourceSet(uint32_t ui32PowerConfig)
261 {
262  //
263  // Check the arguments.
264  //
265  ASSERT((ui32PowerConfig == PWRCTRL_PWRSRC_DCDC) ||
266  (ui32PowerConfig == PWRCTRL_PWRSRC_GLDO) ||
267  (ui32PowerConfig == PWRCTRL_PWRSRC_ULDO));
268 
269  //
270  // Configure the power.
271  //
272  if(ui32PowerConfig == PWRCTRL_PWRSRC_DCDC) {
275  }
276  else if (ui32PowerConfig == PWRCTRL_PWRSRC_GLDO)
277  {
280  }
281  else
282  {
283  PRCMMcuUldoConfigure(true);
284  }
285 }
#define MCU_IMM_WAKE_UP
Definition: aon_wuc.h:126
static uint32_t AONWUCPowerStatusGet(void)
Get the power status of the device.
Definition: aon_wuc.h:556
static void PRCMMcuPowerOff(void)
Request a power off of the MCU voltage domain.
Definition: prcm.h:306
static void AONIOCFreezeEnable(void)
Freeze the IOs.
Definition: aon_ioc.h:214
#define AUX_WUC_POWER_DOWN
Definition: aux_wuc.h:95
void PowerCtrlSourceSet(uint32_t ui32PowerConfig)
Set (Request) the main power source.
Definition: pwr_ctrl.c:260
void AUXWUCPowerCtrl(uint32_t ui32PowerMode)
Control the power to the AUX domain.
Definition: aux_wuc.c:274
#define MCU_RAM2_RETENTION
Definition: aon_wuc.h:141
#define AUX_WUC_POWER_OFF
Definition: aux_wuc.h:94
#define PRCM_DOMAIN_VIMS
Definition: prcm.h:142
static void PowerCtrlIOFreezeEnable(void)
Close the latches in the AON IOC interface and in padring.
Definition: pwr_ctrl.h:274
#define AONWUC_CLOCK_SRC_LF
Definition: aon_wuc.h:98
static void AONWUCMcuPowerDownConfig(uint32_t ui32ClkSrc)
Configure the power down clock for the MCU domain.
Definition: aon_wuc.h:226
void AONWUCRechargeCtrlConfigSet(bool bAdaptEnable, uint32_t ui32AdaptRate, uint32_t ui32Period, uint32_t ui32MaxPeriod)
Configure the recharge controller.
Definition: aon_wuc.c:86
#define AONWUC_AUX_POWER_ON
Definition: aon_wuc.h:172
#define PWRCTRL_PWRSRC_ULDO
Definition: pwr_ctrl.h:120
#define PRCM_DOMAIN_PERIPH
Definition: prcm.h:138
static void AONWUCDomainPowerDownEnable(void)
Enable power down mode on AUX and MCU domain.
Definition: aon_wuc.h:605
#define MCU_RAM3_RETENTION
Definition: aon_wuc.h:142
static void PRCMMcuUldoConfigure(uint32_t ui32Enable)
Assert or de-assert a request for the uLDO.
Definition: prcm.h:360
#define ASSERT(expr)
Definition: debug.h:74
#define PWRCTRL_PWRSRC_GLDO
Definition: pwr_ctrl.h:119
static void AONWUCShutDownEnable(void)
Enable shut-down of the device.
Definition: aon_wuc.h:581
#define PWRCTRL_STANDBY
Definition: pwr_ctrl.h:105
void PowerCtrlStateSet(uint32_t ui32Powerstate)
Force the system into low power modes.
Definition: pwr_ctrl.c:60
#define PWRCTRL_SHUTDOWN
Definition: pwr_ctrl.h:107
void PRCMDeepSleep(void)
Put the processor into deep-sleep mode.
Definition: prcm.c:656
#define MCU_RAM1_RETENTION
Definition: aon_wuc.h:140
static void AONWUCAuxPowerDownConfig(uint32_t ui32ClkSrc)
Configure the power down mode for the AUX domain.
Definition: aon_wuc.h:400
#define PRCM_DOMAIN_SERIAL
Definition: prcm.h:136
#define PRCM_DOMAIN_RFCORE
Definition: prcm.h:134
#define MCU_VIRT_PWOFF_DISABLE
Definition: aon_wuc.h:124
#define PRCM_DOMAIN_CPU
Definition: prcm.h:144
void PRCMPowerDomainOff(uint32_t ui32Domains)
Turn off a specific power domain.
Definition: prcm.c:442
#define PWRCTRL_PWRSRC_DCDC
Definition: pwr_ctrl.h:118
static void AONWUCMcuWakeUpConfig(uint32_t ui32WakeUp)
Configure the wake-up procedure for the MCU domain.
Definition: aon_wuc.h:294
static void AONWUCMcuPowerOffConfig(uint32_t ui32Mode)
Configure the power down mode for the MCU domain.
Definition: aon_wuc.h:265
#define PWRCTRL_POWER_DOWN
Definition: pwr_ctrl.h:106
#define MCU_RAM0_RETENTION
Definition: aon_wuc.h:139
static void AONWUCJtagPowerOff(void)
Request power off of the JTAG domain.
Definition: aon_wuc.h:816
static void AONWUCMcuSRamConfig(uint32_t ui32Retention)
Configure the retention on the block RAM in the MCU domain.
Definition: aon_wuc.h:331