1 /*
2  *  Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
3  *
4  *  Redistribution and use in source and binary forms, with or without
5  *  modification, are permitted provided that the following conditions
6  *  are met:
7  *
8  *    Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  *
11  *    Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the
14  *    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
21  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 //*****************************************************************************
34 //
35 //  prcm.h
36 //
37 //  Prototypes for the PRCM control driver.
38 //
39 //*****************************************************************************
40 
41 #ifndef __PRCM_H__
42 #define __PRCM_H__
43 
44 //*****************************************************************************
45 //
46 // If building with a C++ compiler, make all of the definitions in this header
47 // have a C binding.
48 //
49 //*****************************************************************************
50 #ifdef __cplusplus
51 extern "C"
52 {
53 #endif
54 
55 //*****************************************************************************
56 //
57 // Peripheral clock and reset control registers
58 //
59 //*****************************************************************************
60 typedef struct _PRCM_PeripheralRegs_
61 {
62 
63 unsigned long ulClkReg;
64 unsigned long ulRstReg;
65 
66 }PRCM_PeriphRegs_t;
67 
68 //*****************************************************************************
69 // Values that can be passed to PRCMPeripheralEnable() and
70 // PRCMPeripheralDisable()
71 //*****************************************************************************
72 #define PRCM_RUN_MODE_CLK         0x00000001
73 #define PRCM_SLP_MODE_CLK         0x00000100
74 
75 //*****************************************************************************
76 // Values that can be passed to PRCMSRAMRetentionEnable() and
77 // PRCMSRAMRetentionDisable() as ulSramColSel.
78 //*****************************************************************************
79 #define PRCM_SRAM_COL_1           0x00000001
80 #define PRCM_SRAM_COL_2           0x00000002
81 #define PRCM_SRAM_COL_3           0x00000004
82 #define PRCM_SRAM_COL_4           0x00000008
83 
84 //*****************************************************************************
85 // Values that can be passed to PRCMSRAMRetentionEnable() and
86 // PRCMSRAMRetentionDisable() as ulModeFlags.
87 //*****************************************************************************
88 #define PRCM_SRAM_LPDS_RET        0x00000002
89 
90 //*****************************************************************************
91 // Values that can be passed to PRCMLPDSWakeupSourceEnable(),
92 // PRCMLPDSWakeupCauseGet() and PRCMLPDSWakeupSourceDisable().
93 //*****************************************************************************
94 #define PRCM_LPDS_HOST_IRQ        0x00000080
95 #define PRCM_LPDS_GPIO            0x00000010
96 #define PRCM_LPDS_TIMER           0x00000001
97 
98 //*****************************************************************************
99 // Values that can be passed to PRCMLPDSWakeUpGPIOSelect() as Type
100 //*****************************************************************************
101 #define PRCM_LPDS_LOW_LEVEL       0x00000002
102 #define PRCM_LPDS_HIGH_LEVEL      0x00000000
103 #define PRCM_LPDS_FALL_EDGE       0x00000001
104 #define PRCM_LPDS_RISE_EDGE       0x00000003
105 
106 //*****************************************************************************
107 // Values that can be passed to PRCMLPDSWakeUpGPIOSelect()
108 //*****************************************************************************
109 #define PRCM_LPDS_GPIO2           0x00000000
110 #define PRCM_LPDS_GPIO4           0x00000001
111 #define PRCM_LPDS_GPIO13          0x00000002
112 #define PRCM_LPDS_GPIO17          0x00000003
113 #define PRCM_LPDS_GPIO11          0x00000004
114 #define PRCM_LPDS_GPIO24          0x00000005
115 #define PRCM_LPDS_GPIO26          0x00000006
116 
117 //*****************************************************************************
118 // Values that can be passed to PRCMHibernateWakeupSourceEnable(),
119 // PRCMHibernateWakeupSourceDisable().
120 //*****************************************************************************
121 #define PRCM_HIB_SLOW_CLK_CTR     0x00000001
122 
123 //*****************************************************************************
124 // Values that can be passed to PRCMHibernateWakeUpGPIOSelect() as ulType
125 //*****************************************************************************
126 #define PRCM_HIB_LOW_LEVEL        0x00000000
127 #define PRCM_HIB_HIGH_LEVEL       0x00000001
128 #define PRCM_HIB_FALL_EDGE        0x00000002
129 #define PRCM_HIB_RISE_EDGE        0x00000003
130 
131 //*****************************************************************************
132 // Values that can be passed to PRCMHibernateWakeupSourceEnable(),
133 // PRCMHibernateWakeupSourceDisable(), PRCMHibernateWakeUpGPIOSelect()
134 //*****************************************************************************
135 #define PRCM_HIB_GPIO2            0x00010000
136 #define PRCM_HIB_GPIO4            0x00020000
137 #define PRCM_HIB_GPIO13           0x00040000
138 #define PRCM_HIB_GPIO17           0x00080000
139 #define PRCM_HIB_GPIO11           0x00100000
140 #define PRCM_HIB_GPIO24           0x00200000
141 #define PRCM_HIB_GPIO26           0x00400000
142 
143 //*****************************************************************************
144 // Values that will be returned from PRCMSysResetCauseGet().
145 //*****************************************************************************
146 #define PRCM_POWER_ON             0x00000000
147 #define PRCM_LPDS_EXIT            0x00000001
148 #define PRCM_CORE_RESET           0x00000003
149 #define PRCM_MCU_RESET            0x00000004
150 #define PRCM_WDT_RESET            0x00000005
151 #define PRCM_SOC_RESET            0x00000006
152 #define PRCM_HIB_EXIT             0x00000007
153 
154 //*****************************************************************************
155 // Values that can be passed to PRCMHibernateWakeupCauseGet().
156 //*****************************************************************************
157 #define PRCM_HIB_WAKEUP_CAUSE_SLOW_CLOCK  0x00000002
158 #define PRCM_HIB_WAKEUP_CAUSE_GPIO        0x00000004
159 
160 //*****************************************************************************
161 // Values that can be passed to PRCMSEnableInterrupt
162 //*****************************************************************************
163 #define PRCM_INT_SLOW_CLK_CTR     0x00004000
164 
165 //*****************************************************************************
166 // Values that can be passed to PRCMPeripheralClkEnable(),
167 // PRCMPeripheralClkDisable(), PRCMPeripheralReset()
168 //*****************************************************************************
169 #define PRCM_CAMERA               0x00000000
170 #define PRCM_I2S                  0x00000001
171 #define PRCM_SDHOST               0x00000002
172 #define PRCM_GSPI                 0x00000003
173 #define PRCM_LSPI                 0x00000004
174 #define PRCM_UDMA                 0x00000005
175 #define PRCM_GPIOA0               0x00000006
176 #define PRCM_GPIOA1               0x00000007
177 #define PRCM_GPIOA2               0x00000008
178 #define PRCM_GPIOA3               0x00000009
179 #define PRCM_GPIOA4               0x0000000A
180 #define PRCM_WDT                  0x0000000B
181 #define PRCM_UARTA0               0x0000000C
182 #define PRCM_UARTA1               0x0000000D
183 #define PRCM_TIMERA0              0x0000000E
184 #define PRCM_TIMERA1              0x0000000F
185 #define PRCM_TIMERA2              0x00000010
186 #define PRCM_TIMERA3              0x00000011
187 #define PRCM_DTHE                 0x00000012
188 #define PRCM_SSPI                 0x00000013
189 #define PRCM_I2CA0                0x00000014
190 // Note : PRCM_ADC is a dummy define for pinmux utility code generation
191 // PRCM_ADC should never be used in any user code.
192 #define PRCM_ADC                  0x000000FF
193 
194 
195 //*****************************************************************************
196 // Values that can be passed to PRCMIORetEnable() and PRCMIORetDisable()
197 //*****************************************************************************
198 #define PRCM_IO_RET_GRP_0       0x00000001
199 #define PRCM_IO_RET_GRP_1       0x00000002
200 #define PRCM_IO_RET_GRP_2       0x00000004
201 #define PRCM_IO_RET_GRP_3       0x00000008
202 
203 //*****************************************************************************
204 // Macros definig the device type
205 //*****************************************************************************
206 #define PRCM_DEV_TYPE_FLAG_R         0x00000001
207 #define PRCM_DEV_TYPE_FLAG_F         0x00000002
208 #define PRCM_DEV_TYPE_FLAG_Z         0x00000004
209 #define PRCM_DEV_TYPE_FLAG_SECURE    0x00000008
210 #define PRCM_DEV_TYPE_FLAG_PRE_PROD  0x00000010
211 #define PRCM_DEV_TYPE_FLAG_3200      0x00000020
212 #define PRCM_DEV_TYPE_FLAG_3220      0x00000040
213 #define PRCM_DEV_TYPE_FLAG_REV1      0x00010000
214 #define PRCM_DEV_TYPE_FLAG_REV2      0x00020000
215 
216 //*****************************************************************************
217 // Pre-defined helper macros
218 //*****************************************************************************
219 #define PRCM_DEV_TYPE_PRE_CC3200R    (PRCM_DEV_TYPE_FLAG_PRE_PROD| \
220                                       PRCM_DEV_TYPE_FLAG_3200|     \
221                                       PRCM_DEV_TYPE_FLAG_R)
222 
223 #define PRCM_DEV_TYPE_PRE_CC3200F    (PRCM_DEV_TYPE_FLAG_PRE_PROD| \
224                                       PRCM_DEV_TYPE_FLAG_3200|     \
225                                       PRCM_DEV_TYPE_FLAG_F)
226 
227 #define PRCM_DEV_TYPE_PRE_CC3200Z    (PRCM_DEV_TYPE_FLAG_PRE_PROD| \
228                                       PRCM_DEV_TYPE_FLAG_3200|     \
229                                       PRCM_DEV_TYPE_FLAG_Z)
230 
231 #define PRCM_DEV_TYPE_CC3200R        (PRCM_DEV_TYPE_FLAG_PRE_PROD| \
232                                       PRCM_DEV_TYPE_FLAG_3200|     \
233                                       PRCM_DEV_TYPE_FLAG_R)
234 
235 #define PRCM_DEV_TYPE_PRE_CC3220R    (PRCM_DEV_TYPE_FLAG_PRE_PROD| \
236                                       PRCM_DEV_TYPE_FLAG_3220|     \
237                                       PRCM_DEV_TYPE_FLAG_R)
238 
239 #define PRCM_DEV_TYPE_PRE_CC3220F    (PRCM_DEV_TYPE_FLAG_PRE_PROD| \
240                                       PRCM_DEV_TYPE_FLAG_3220|     \
241                                       PRCM_DEV_TYPE_FLAG_F)
242 
243 #define PRCM_DEV_TYPE_PRE_CC3220Z    (PRCM_DEV_TYPE_FLAG_PRE_PROD| \
244                                       PRCM_DEV_TYPE_FLAG_3220|     \
245                                       PRCM_DEV_TYPE_FLAG_Z)
246 
247 #define PRCM_DEV_TYPE_CC3220R        (PRCM_DEV_TYPE_FLAG_3220|     \
248                                       PRCM_DEV_TYPE_FLAG_R)
249 
250 
251 #define PRCM_DEV_TYPE_PRE_CC3220RS   (PRCM_DEV_TYPE_FLAG_PRE_PROD| \
252                                       PRCM_DEV_TYPE_FLAG_3220|     \
253                                       PRCM_DEV_TYPE_FLAG_R|        \
254                                       PRCM_DEV_TYPE_FLAG_SECURE)
255 
256 #define PRCM_DEV_TYPE_PRE_CC3220FS   (PRCM_DEV_TYPE_FLAG_PRE_PROD| \
257                                       PRCM_DEV_TYPE_FLAG_3220|     \
258                                       PRCM_DEV_TYPE_FLAG_F|        \
259                                       PRCM_DEV_TYPE_FLAG_SECURE)
260 
261 #define PRCM_DEV_TYPE_PRE_CC3220ZS   (PRCM_DEV_TYPE_FLAG_PRE_PROD| \
262                                       PRCM_DEV_TYPE_FLAG_3220|     \
263                                       PRCM_DEV_TYPE_FLAG_Z|        \
264                                       PRCM_DEV_TYPE_FLAG_SECURE)
265 
266 #define PRCM_DEV_TYPE_CC3220RS       (PRCM_DEV_TYPE_FLAG_3220|     \
267                                       PRCM_DEV_TYPE_FLAG_R|        \
268                                       PRCM_DEV_TYPE_FLAG_SECURE)
269 
270 #define PRCM_DEV_TYPE_CC3220FS       (PRCM_DEV_TYPE_FLAG_3220|     \
271                                       PRCM_DEV_TYPE_FLAG_F|        \
272                                       PRCM_DEV_TYPE_FLAG_SECURE)
273 
274 
275 #define PRCM_DEV_TYPE_PRE_CC3220Z1   (PRCM_DEV_TYPE_FLAG_PRE_PROD| \
276                                       PRCM_DEV_TYPE_FLAG_3220|     \
277                                       PRCM_DEV_TYPE_FLAG_Z|        \
278                                       PRCM_DEV_TYPE_FLAG_REV1)
279 
280 #define PRCM_DEV_TYPE_PRE_CC3220Z2   (PRCM_DEV_TYPE_FLAG_PRE_PROD| \
281                                       PRCM_DEV_TYPE_FLAG_3220|     \
282                                       PRCM_DEV_TYPE_FLAG_Z|        \
283                                       PRCM_DEV_TYPE_FLAG_REV2)
284 
285 //*****************************************************************************
286 //
287 // API Function prototypes
288 //
289 //*****************************************************************************
290 extern void PRCMMCUReset(tBoolean bIncludeSubsystem);
291 extern unsigned long PRCMSysResetCauseGet(void);
292 
293 extern void PRCMPeripheralClkEnable(unsigned long ulPeripheral,
294                                     unsigned long ulClkFlags);
295 extern void PRCMPeripheralClkDisable(unsigned long ulPeripheral,
296                                      unsigned long ulClkFlags);
297 extern void PRCMPeripheralReset(unsigned long ulPeripheral);
298 extern tBoolean PRCMPeripheralStatusGet(unsigned long ulPeripheral);
299 
300 extern void PRCMI2SClockFreqSet(unsigned long ulI2CClkFreq);
301 extern unsigned long PRCMPeripheralClockGet(unsigned long ulPeripheral);
302 
303 extern void PRCMSleepEnter(void);
304 
305 extern void PRCMSRAMRetentionEnable(unsigned long ulSramColSel,
306                                     unsigned long ulFlags);
307 extern void PRCMSRAMRetentionDisable(unsigned long ulSramColSel,
308                                      unsigned long ulFlags);
309 extern void PRCMLPDSRestoreInfoSet(unsigned long ulRestoreSP,
310                                    unsigned long ulRestorePC);
311 extern void PRCMLPDSEnter(void);
312 extern void PRCMLPDSIntervalSet(unsigned long ulTicks);
313 extern void PRCMLPDSWakeupSourceEnable(unsigned long ulLpdsWakeupSrc);
314 extern unsigned long PRCMLPDSWakeupCauseGet(void);
315 extern void PRCMLPDSWakeUpGPIOSelect(unsigned long ulGPIOPin,
316                                      unsigned long ulType);
317 extern void PRCMLPDSWakeupSourceDisable(unsigned long ulLpdsWakeupSrc);
318 
319 extern void PRCMHibernateEnter(void);
320 extern void PRCMHibernateWakeupSourceEnable(unsigned long ulHIBWakupSrc);
321 extern unsigned long PRCMHibernateWakeupCauseGet(void);
322 extern void PRCMHibernateWakeUpGPIOSelect(unsigned long ulMultiGPIOBitMap,
323                                           unsigned long ulType);
324 extern void PRCMHibernateWakeupSourceDisable(unsigned long ulHIBWakupSrc);
325 extern void PRCMHibernateIntervalSet(unsigned long long ullTicks);
326 
327 extern unsigned long long PRCMSlowClkCtrGet(void);
328 extern unsigned long long PRCMSlowClkCtrFastGet(void);
329 extern void PRCMSlowClkCtrMatchSet(unsigned long long ullTicks);
330 extern unsigned long long PRCMSlowClkCtrMatchGet(void);
331 
332 extern void PRCMOCRRegisterWrite(unsigned char ucIndex,
333                                  unsigned long ulRegValue);
334 extern unsigned long PRCMOCRRegisterRead(unsigned char ucIndex);
335 
336 extern void PRCMIntRegister(void (*pfnHandler)(void));
337 extern void PRCMIntUnregister(void);
338 extern void PRCMIntEnable(unsigned long ulIntFlags);
339 extern void PRCMIntDisable(unsigned long ulIntFlags);
340 extern unsigned long PRCMIntStatus(void);
341 extern void PRCMRTCInUseSet(void);
342 extern tBoolean PRCMRTCInUseGet(void);
343 extern void PRCMRTCSet(unsigned long ulSecs, unsigned short usMsec);
344 extern void PRCMRTCGet(unsigned long *ulSecs, unsigned short *usMsec);
345 extern void PRCMRTCMatchSet(unsigned long ulSecs, unsigned short usMsec);
346 extern void PRCMRTCMatchGet(unsigned long *ulSecs, unsigned short *usMsec);
347 extern void PRCMCC3200MCUInit(void);
348 extern unsigned long PRCMHIBRegRead(unsigned long ulRegAddr);
349 extern void PRCMHIBRegWrite(unsigned long ulRegAddr, unsigned long ulValue);
350 extern unsigned long PRCMCameraFreqSet(unsigned char ulDivider,
351                                                 unsigned char ulWidth);
352 extern void PRCMIORetentionEnable(unsigned long ulIORetGrpFlags);
353 extern void PRCMIORetentionDisable(unsigned long ulIORetGrpFlags);
354 extern unsigned long PRCMDeviceTypeGet(void);
355 extern void PRCMLPDSEnterKeepDebugIf(void);
356 extern void PRCMHibernateCycleTrigger(void);
357 
358 
359 //*****************************************************************************
360 //
361 // Mark the end of the C bindings section for C++ compilers.
362 //
363 //*****************************************************************************
364 #ifdef __cplusplus
365 }
366 #endif
367 
368 #endif //  __PRCM_H__
369