TI-RTOS Drivers  tidrivers_full_2_20_01_10
PowerCC26XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2016, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQueueNTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
55 #ifndef ti_drivers_power_PowerCC26XX_
56 #define ti_drivers_power_PowerCC26XX_
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 #include <ti/sysbios/family/arm/m3/Hwi.h>
63 #include <ti/sysbios/knl/Clock.h>
64 #include <ti/drivers/Power.h>
65 
66 typedef uint8_t PowerCC26XX_Resource;
67 
68 /* latency to resume from STANDBY (usec) */
69 #define PowerCC26XX_RESUMETIMESTANDBY 750
70 
71 /* total latency for STANDBY (usec) */
72 #define PowerCC26XX_TOTALTIMESTANDBY 1000
73 
74 /* initial wake delay from STANDBY (usec) */
75 #define PowerCC26XX_WAKEDELAYSTANDBY 130
76 
77 /* initial wait time (usec) to see if RCOSC_LF is stable */
78 #define PowerCC26XX_INITIALWAITRCOSC_LF 1000
79 
80 /* retry wait time (usec) to see if RCOSC_LF is stable */
81 #define PowerCC26XX_RETRYWAITRCOSC_LF 1000
82 
83 /* initial wait time (usec) to see if XOSC_HF is stable */
84 #define PowerCC26XX_INITIALWAITXOSC_HF 50
85 
86 /* retry wait time (usec) to see if XOSC_HF is stabe */
87 #define PowerCC26XX_RETRYWAITXOSC_HF 50
88 
89 /* initial wait time (usec) to see if XOSC_LF is stable */
90 #define PowerCC26XX_INITIALWAITXOSC_LF 10000
91 
92 /* retry wait time (usec) to see if XOSC_LF is stable */
93 #define PowerCC26XX_RETRYWAITXOSC_LF 5000
94 
95 /* resource IDs */
96 #define PowerCC26XX_PERIPH_GPT0 0
97 #define PowerCC26XX_PERIPH_GPT1 1
98 #define PowerCC26XX_PERIPH_GPT2 2
99 #define PowerCC26XX_PERIPH_GPT3 3
100 #define PowerCC26XX_PERIPH_SSI0 4
101 #define PowerCC26XX_PERIPH_SSI1 5
102 #define PowerCC26XX_PERIPH_UART0 6
103 #define PowerCC26XX_PERIPH_I2C0 7
104 #define PowerCC26XX_PERIPH_TRNG 8
105 #define PowerCC26XX_PERIPH_GPIO 9
106 #define PowerCC26XX_PERIPH_UDMA 10
107 #define PowerCC26XX_PERIPH_CRYPTO 11
108 #define PowerCC26XX_PERIPH_I2S 12
109 #define PowerCC26XX_PERIPH_RFCORE 13
110 #define PowerCC26XX_XOSC_HF 14
111 #define PowerCC26XX_DOMAIN_PERIPH 15
112 #define PowerCC26XX_DOMAIN_SERIAL 16
113 #define PowerCC26XX_DOMAIN_RFCORE 17
114 #define PowerCC26XX_DOMAIN_SYSBUS 18
115 #define PowerCC26XX_NUMRESOURCES 19
116 
117 /* resource is a peripheral */
118 #define PowerCC26XX_PERIPH 0x80
119 
120 /* resource requires special handler */
121 #define PowerCC26XX_SPECIAL 0x40
122 
123  /* resource is a domain */
124 #define PowerCC26XX_DOMAIN 0x00
125 
126 /* parent resource mask */
127 #define PowerCC26XX_PARENTMASK 0x3F
128 
129 /* if resource has no parent */
130 #define PowerCC26XX_NOPARENT 0x3F
131 
132 /* standby power state */
133 #define PowerCC26XX_STANDBY 0x1
134 
135 #define PowerCC26XX_ENABLE 1
136 #define PowerCC26XX_DISABLE 0
137 
138 /*
139  * Constraints
140  */
141 #define PowerCC26XX_SB_VIMS_CACHE_RETAIN 0
142 #define PowerCC26XX_SD_DISALLOW 1
143 #define PowerCC26XX_SB_DISALLOW 2
144 #define PowerCC26XX_IDLE_PD_DISALLOW 3
145 #define PowerCC26XX_NEED_FLASH_IN_IDLE 4
146 #define PowerCC26XX_NUMCONSTRAINTS 5
147 
148 /*
149  * Events
150  *
151  * Each event must be a power of two and must be sequential
152  * without any gaps.
153  */
154 #define PowerCC26XX_ENTERING_STANDBY 0x1
155 #define PowerCC26XX_ENTERING_SHUTDOWN 0x2
156 #define PowerCC26XX_AWAKE_STANDBY 0x4
157 #define PowerCC26XX_AWAKE_STANDBY_LATE 0x8
158 #define PowerCC26XX_XOSC_HF_SWITCHED 0x10
159 #define PowerCC26XX_NUMEVENTS 5
160 
161 /*
162  * Calibration stages
163  */
164 #define PowerCC26XX_SETUP_CALIBRATE 1
165 #define PowerCC26XX_INITIATE_CALIBRATE 2
166 #define PowerCC26XX_DO_CALIBRATE 3
167 
170  uint8_t flags; /* resource type : first parent */
171  uint8_t flags2; /* second parent */
172  uint16_t driverlibID;
174 
175 
177 typedef struct PowerCC26XX_Config {
212  bool (*calibrateFxn)(unsigned int);
244 
246 typedef struct PowerCC26XX_ModuleState {
247  List_List notifyList; /* event notification list */
248  uint32_t constraintMask; /* constraint mask */
249  Clock_Struct clockObj; /* Clock object for scheduling wakeups */
250  Clock_Struct xoscClockObj; /* Clock object for XOSC_HF switching */
251  Clock_Struct lfClockObj; /* Clock object for LF clock check */
252  Clock_Struct calClockStruct; /* Clock object for RCOSC calibration */
253  Hwi_Struct hwiStruct; /* Hwi object for RCOSC calibration */
254  int32_t nDeltaFreqCurr; /* RCOSC calibration variable */
255  int32_t nCtrimCurr; /* RCOSC calibration variable */
256  int32_t nCtrimFractCurr; /* RCOSC calibration variable */
257  int32_t nCtrimNew; /* RCOSC calibration variable */
258  int32_t nCtrimFractNew; /* RCOSC calibration variable */
259  int32_t nRtrimNew; /* RCOSC calibration variable */
260  int32_t nRtrimCurr; /* RCOSC calibration variable */
261  int32_t nDeltaFreqNew; /* RCOSC calibration variable */
262  bool bRefine; /* RCOSC calibration variable */
263  uint32_t state; /* current transition state */
264  bool xoscPending; /* is XOSC_HF activation in progress? */
265  bool calLF; /* calibrate RCOSC_LF? */
266  uint8_t hwiState; /* calibration AUX ISR state */
267  bool busyCal; /* already busy calibrating */
268  uint8_t calStep; /* current calibration step */
269  bool firstLF; /* is this first LF calibration? */
270  bool enablePolicy; /* enable policy state */
271  bool initialized; /* TRUE if Power_init has been called */
274  unsigned int (*resourceHandlers[3])(unsigned int);
277 
288 bool PowerCC26XX_calibrate(unsigned int arg);
289 
296 void PowerCC26XX_doWFI(void);
297 
304 Clock_Handle PowerCC26XX_getClockHandle(void);
305 
315 uint32_t PowerCC26XX_getXoscStartupTime(uint32_t timeUntilWakeupInMs);
316 
323 
334 bool PowerCC26XX_noCalibrate(unsigned int arg);
335 
339 void PowerCC26XX_switchXOSC_HF(void);
340 
363 void PowerCC26XX_standbyPolicy(void);
364 
365 #ifdef __cplusplus
366 }
367 #endif
368 
369 #endif /* POWER_CC26XX_ */
Hwi_Struct hwiStruct
Definition: PowerCC26XX.h:253
bool calLF
Definition: PowerCC26XX.h:265
void PowerCC26XX_doWFI(void)
Wait for interrupt.
int32_t nDeltaFreqNew
Definition: PowerCC26XX.h:261
bool xoscPending
Definition: PowerCC26XX.h:264
struct PowerCC26XX_Config PowerCC26XX_Config
Global configuration structure.
bool bRefine
Definition: PowerCC26XX.h:262
bool PowerCC26XX_calibrate(unsigned int arg)
RCOSC calibration.
Definition: List.h:131
uint32_t constraintMask
Definition: PowerCC26XX.h:248
bool calibrateRCOSC_LF
Boolean specifying whether the low frequency RCOSC (RCOSC_LF) should be calibrated.
Definition: PowerCC26XX.h:233
Clock_Handle PowerCC26XX_getClockHandle(void)
Get the handle of a Clock object that a power policy can use to schedule wakeups. ...
struct PowerCC26XX_ResourceRecord PowerCC26XX_ResourceRecord
Power resource database record format.
struct PowerCC26XX_ModuleState PowerCC26XX_ModuleState
Internal module state.
Power_PolicyInitFxn policyInitFxn
The power policy's initialization function.
Definition: PowerCC26XX.h:184
void(* Power_PolicyInitFxn)(void)
Power policy initialization function pointer.
Definition: Power.h:91
Power manager interface.
uint8_t PowerCC26XX_Resource
Definition: PowerCC26XX.h:66
uint16_t driverlibID
Definition: PowerCC26XX.h:172
uint8_t resourceCounts[PowerCC26XX_NUMRESOURCES]
Definition: PowerCC26XX.h:273
bool enablePolicy
Boolean specifying if the power policy function is enabled.
Definition: PowerCC26XX.h:224
int32_t nCtrimFractNew
Definition: PowerCC26XX.h:258
Power_PolicyFxn policyFxn
The power policy function.
Definition: PowerCC26XX.h:200
bool initialized
Definition: PowerCC26XX.h:271
int32_t nRtrimNew
Definition: PowerCC26XX.h:259
int32_t nCtrimNew
Definition: PowerCC26XX.h:257
unsigned int(* resourceHandlers[3])(unsigned int)
Definition: PowerCC26XX.h:274
void(* Power_PolicyFxn)(void)
Power policy function pointer.
Definition: Power.h:96
uint32_t state
Definition: PowerCC26XX.h:263
uint8_t flags
Definition: PowerCC26XX.h:170
bool busyCal
Definition: PowerCC26XX.h:267
void PowerCC26XX_standbyPolicy(void)
Power standby policy function.
void PowerCC26XX_switchXOSC_HF(void)
Switch the HF clock source to XOSC_HF.
bool(* calibrateFxn)(unsigned int)
The function to be used for activating RC Oscillator (RCOSC) calibration.
Definition: PowerCC26XX.h:212
bool calibrateRCOSC_HF
Boolean specifying whether the high frequency RCOSC (RCOSC_HF) should be calibrated.
Definition: PowerCC26XX.h:242
#define PowerCC26XX_NUMRESOURCES
Definition: PowerCC26XX.h:115
Power_PolicyFxn policyFxn
Definition: PowerCC26XX.h:275
uint32_t PowerCC26XX_getXoscStartupTime(uint32_t timeUntilWakeupInMs)
Get the estimated crystal oscillator startup time in microseconds.
Clock_Struct calClockStruct
Definition: PowerCC26XX.h:252
int32_t nCtrimCurr
Definition: PowerCC26XX.h:255
Internal module state.
Definition: PowerCC26XX.h:246
uint8_t calStep
Definition: PowerCC26XX.h:268
Power resource database record format.
Definition: PowerCC26XX.h:169
Global configuration structure.
Definition: PowerCC26XX.h:177
bool PowerCC26XX_injectCalibration(void)
Explicitly trigger RCOSC calibration.
int32_t nCtrimFractCurr
Definition: PowerCC26XX.h:256
#define PowerCC26XX_NUMCONSTRAINTS
Definition: PowerCC26XX.h:146
Clock_Struct lfClockObj
Definition: PowerCC26XX.h:251
uint8_t flags2
Definition: PowerCC26XX.h:171
int32_t nDeltaFreqCurr
Definition: PowerCC26XX.h:254
bool PowerCC26XX_noCalibrate(unsigned int arg)
Do not perform calibration function.
bool firstLF
Definition: PowerCC26XX.h:269
int32_t nRtrimCurr
Definition: PowerCC26XX.h:260
Clock_Struct xoscClockObj
Definition: PowerCC26XX.h:250
bool enablePolicy
Definition: PowerCC26XX.h:270
uint8_t hwiState
Definition: PowerCC26XX.h:266
List_List notifyList
Definition: PowerCC26XX.h:247
uint8_t constraintCounts[PowerCC26XX_NUMCONSTRAINTS]
Definition: PowerCC26XX.h:272
Clock_Struct clockObj
Definition: PowerCC26XX.h:249
Copyright 2016, Texas Instruments Incorporated