PMI Instrumentation Library API Reference Guide
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator
PCMI_Common.h
Go to the documentation of this file.
1 #ifndef __PMI_CMI_COMMON_H
2 #define __PMI_CMI_COMMON_H
3 /*
4  * PCMI_Common.h
5  *
6  * Common Power & Clock Management Instrumentation Common API Definitions
7  *
8  * Copyright (C) 2009, 2010 Texas Instruments Incorporated - http://www.ti.com/
9  *
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  *
15  * Redistributions of source code must retain the above copyright
16  * notice, this list of conditions and the following disclaimer.
17  *
18  * Redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the
21  * distribution.
22  *
23  * Neither the name of Texas Instruments Incorporated nor the names of
24  * its contributors may be used to endorse or promote products derived
25  * from this software without specific prior written permission.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38  *
39 */
40 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 //Using forward slashes in the relative serach path for linux compatibility
53 
54 #ifdef _OMAP4430
55 #include "../../PMICMILib/src/PCMI_Omap4430.h"
56 #endif
57 
58 #ifdef _STMLogging
59 #include "../../STMLib/include/StmLibrary.h"
60 #endif
61 
62 #ifdef __KERNEL__ /* If being used for a kernel build, C99 def's not available */
63 #include <linux/types.h>
64 #else
65 #include <stdint.h> // needed for uintN_t/intN_t (N=8,16,32,64) C99 standard types
66 #endif
67 
69 //
70 // Common Naming Conventions
71 //
72 // PCMI_ Prefix for shared macros and functions (typically private)
73 // ePCMI Prefix for shared enumerations used by both PMI and CMI Libraries.
74 //
76 
77 
78 
79 
80 
82 //
83 // Common Typedefs
84 //
86 
89 typedef enum {
107  /* ePMI_Error_STM must be the last PMI error*/
111  /* eCMI_Error_STM must be the last CMI error*/
113 }ePCMI_Error;
114 
115 
120 typedef void(*PCMI_CallBack)(const char * funcName, ePCMI_Error);
121 
122 
123 #ifndef _DOXYGEN_IGNORE
124 //
126 // Definitions
127 //
129 // Since PMI and CMI libraries share source these libraries will
130 // also share revision numbers.
131 // Note - the version definitions must have the end of line immediately after the value (packaging script requirement)
132 #define PMICMILIB_MAJOR_VERSION (0x1)
133 
135 #define PMICMILIB_MINOR_VERSION (0x2)
136 
140 #ifndef __linux__
141 #define NULL 0
142 #endif
143 
144 #define PCMI_ATTR_BUFSIZE 256 // PMI/CMI MetaData buffer size
145 
147 //
148 // Register Maps
149 //
151 
152 
153 #define PCMI_ID_RegOff 0x00
154 #define PCMI_SysConfig_RegOff 0x10
155 #define PCMI_Status_RegOff 0x14
156 #define PCMI_Configuration_RegOff 0x24
157 #define PCMI_EventClassFilter_RegOff 0x28
158 #define PCMI_TriggerControl_RegOff 0x2c
159 #define PCMI_SamplingWindow_RegOff 0x30
160 #define PCMI_RegBankSize 0x50
161 
162 typedef uint32_t REG32_TYPE;
163 typedef volatile uint32_t * pREG32_TYPE;
164 
165 // PMI ID Register - common between PMI and CMI
166 /************************************************************************************
167 | 31:30 | 29:28 | 27:16 | 15:11 | 10:8 | 7:6 | 5:0 |
168 |Scheme | reserved | Func | RTL | Major | Custom | Minor |
169 *************************************************************************************/
170 #define PCMI_ID_REG_ADDR(ba) (uint32_t *)((uint32_t)(ba) + PCMI_ID_RegOff )
171 #define PCMI_SCHEME_MASK 0xC0000000
172 #define PCMI_SCHEME_OFFSET 30
173 #define PCMI_GetSchemeValue(regData) ((regData & PCMI_SCHEME_MASK) >> PCMI_SCHEME_OFFSET )
174 
175 #define PCMI_FUNC_MASK 0x0FFF0000
176 #define PCMI_FUNC_OFFSET 16
177 #define PCMI_GetFuncValue(regData) ((regData & PCMI_FUNC_MASK) >> PCMI_FUNC_OFFSET )
178 
179 #define PCMI_RTL_MASK 0x0000F800
180 #define PCMI_RTK_OFFSET 11
181 #define PCMI_GetRTLValue(regData) ((regData & PCMI_RTL_MASK) >> PCMI_RTL_OFFSET )
182 
183 #define PCMI_MAJOR_MASK 0x00000700
184 #define PCMI_MAJOR_OFFSET 8
185 #define PCMI_GetMajorValue(regData) ((regData & PCMI_MAJOR_MASK) >> PCMI_MAJOR_OFFSET )
186 
187 #define PCMI_CUSTOM_MASK 0x000000C0
188 #define PCMI_CUSTOM_OFFSET 6
189 #define PCMI_GetCustomValue(regData) ((regData & PCMI_CUSTOM_MASK) >> PCMI_CUSTOM_OFFSET )
190 
191 #define PCMI_MINOR_MASK 0x0000003F
192 #define PCMI_MINOR_OFFSET 0
193 #define PCMI_GetMinorValue(regData) ((regData & PCMI_MINOR_MASK) >> PCMI_MINOR_OFFSET )
194 
195 // PMI System Configuration - common between PMI and CMI
196 /************************************************************************************
197 | 31:4 | 3:2 | 1 | 0 |
198 | Reserved | Idle Mode | Reserved | Soft Reset |
199 *************************************************************************************/
200 #define PCMI_SYSCNFG_REG_ADDR(ba) (uint32_t *)((uint32_t)(ba) + PCMI_SysConfig_RegOff )
201 
202 #define PCMI_SOFTRESET_MASK 0x1
203 #define PCMI_SOFTRESET_OFFSET 0
204 #define PCMI_SOFTRESET 0x1
205 #define PCMI_SOFTRESET_DONE 0
206 #define PCMI_GetSoftResetValue(regData) (regData & PCMI_SOFTRESET_MASK )
207 
208 #define PCMI_SMARTIDLE ( 0x2 << 2 )
209 #define PCMI_SMARTIDLE_WAKEUP ( 0x3 << 2 )
210 
211 // PMI Status Register - common between PMI and CMI
212 /************************************************************************************
213 | 31:9 | 8 | 7:0 |
214 | Module Status | Fifo Empty | OCP Status |
215 *************************************************************************************/
216 #define PCMI_STATUS_REG_ADDR(ba) (uint32_t *)((uint32_t)(ba) + PCMI_Status_RegOff )
217 
218 //TODO:: Need values for PMI Status Register bits
219 
220 //Configuration Register - common between PMI and CMI
221 /************************************************************************************
222 | 31:30 | 29 | 28 | 27:8 | 7 | 6:0 |
223 |Claim Field |Debug Override |Current Owner | Reserved | Event | Reserved |
224 |Read: | | Debug owns 0 | | Capture | |
225 | Avaialble 0 | | App owns 1 | | Enable | |
226 | Claimed 1 | | | | | |
227 | Enabled 2 | | | | | |
228 |Write: | | | | | |
229 | Release 0 | | | | | |
230 | Claim 1 | | | | | |
231 | Enable 2 | | | | | |
232 *************************************************************************************/
233 #define PCMI_CONFIG_REG_ADDR(ba) (uint32_t *)((uint32_t)(ba) + PCMI_Configuration_RegOff )
234 // Claim field read
235 #define PCMI_CLAIM_MASK 0xC0000000
236 #define PCMI_CLAIM_OFFSET 30
237 #define PCMI_GetClaimValue(regData) (regData & PCMI_CLAIM_MASK)
238 #define PCMI_AVAILABLE (REG32_TYPE)(0x0 << PCMI_CLAIM_OFFSET)
239 #define PCMI_CLAIMED (REG32_TYPE)(0x1 << PCMI_CLAIM_OFFSET)
240 #define PCMI_ENABLED (REG32_TYPE)(0x2 << PCMI_CLAIM_OFFSET)
241 
242 //Claim field write
243 #define PCMI_RELEASE_OWNERSHIP (REG32_TYPE)(0x0 << PCMI_CLAIM_OFFSET)
244 #define PCMI_CLAIM_OWNERSHIP (REG32_TYPE)(0x1 << PCMI_CLAIM_OFFSET)
245 #define PCMI_ENABLE_UNIT (REG32_TYPE)(0x2 << PCMI_CLAIM_OFFSET)
246 #define PCMI_NOP (REG32_TYPE)(0x3 << PCMI_CLAIM_OFFSET)
247 
248 // Current Owner field if PCMI_CLAIMED
249 #define PCMI_OWNERSHIP_MASK 0x10000000
250 #define PCMI_OWNERSHIP_OFFSET 28
251 #define PCMI_APP_OWNERSHIP (REG32_TYPE)(0x1 << PCMI_OWNERSHIP_OFFSET)
252 #define PCMI_DBG_OWNERSHIP (REG32_TYPE)(0x0 << PCMI_OWNERSHIP_OFFSET)
253 #define PCMI_GetClaimValue(regData) (regData & PCMI_CLAIM_MASK)
254 #define PCMI_GetOwnership(regData) (regData & PCMI_OWNERSHIP_MASK)
255 
256 // Event Capture Enable
257 #define PCMI_EVENTCAPTURE_ENABLE (0x80)
258 #define PCMI_EVENTCAPTURE_DISABLE (0x00)
259 #ifdef _CMI
260 #define CMI_MODULEACTVITYCOLLECTION_ENABLE (0x8000)
261 #endif
262 
263 // Trigger Control Register - common between PMI and CMI
264 /************************************************************************************
265 | 31:4 | 1 | 0 |
266 | Reserved | Stop Capture | Start Capture |
267 *************************************************************************************/
268 #define PCMI_TRIGGERCONTROL_REG_ADDR(ba) (uint32_t *)((uint32_t)(ba) + PCMI_TriggerControl_RegOff )
269 
270 #define PCMI_STARTCAPTURE_TRIGGER 0x1
271 #define PCMI_STOPCAPTURE_TRIGGER 0x2
272 
273 //Sample Window Register - common between PMI and CMI
274 /************************************************************************************
275 | 31:20 | 19:16 | 15:8 | 7:0 |
276 | Reserved | Func Divide By | Reserved | Sample Window |
277 *************************************************************************************/
278 #define PCMI_SAMPLEWINDOW_REG_ADDR(ba) (uint32_t *)((uint32_t)(ba) + PCMI_SamplingWindow_RegOff )
279 
280 #define PCMI_MAX_SAMPLEWINDOW 0xFF
281 #define PCMI_FUNCDIVIDEBY_OFFSET 16
282 #define PCMI_FUNCDIVIDEBY_MASK 0x000F0000
283 #define PCMI_SAMPLEWINDOW_MASK 0x000000FF
284 #define PCMI_MAX_DIVIDEBYFACTOR ( 0xF << PCMI_FUNCDIVIDEBY_OFFSET )
285 
286 
287 // PMI/CMI Module Clock Control - common
288 /************************************************************************************
289 | 31:18 | 17:16 | 15:2 | 1:0 |
290 | Reserved | IDLEST | Reserved | ModuleMode |
291 | | Read 0x0 - Functional | R/W 0 - Disabled by SW
292 | | Read 0x1 - Transition | R/W 1 - Doamin on
293 | | Read 0x2 - Idle | |
294 | | Read 0x3 - Disabled | |
295 *************************************************************************************/
296 #define PCMI_MODULE_CLKCTRL_FUNC ( 0x0<<16 )
297 #define PCMI_MODULE_CLKCTRL_TRAN ( 0x1<<16 )
298 #define PCMI_MODULE_CLKCTRL_IDLE ( 0x2<<16 )
299 #define PCMI_MODULE_CLKCTRL_DISABLED ( 0x3<<16 )
300 #define PCMI_MODULE_CLKCTRL_MASK ( 0x3<<16 )
301 
302 #define PCMI_MODULE_CLKCTRL_ON (0x1)
303 #define PCMI_MODULE_CLKCTRL_OFF (0x0)
304 #define PCMI_MODULE_CLKCTRL_MAXRETRY (1000)
305 #define PCMI_MODULE_CLKCTRL_SIZE (4)
306 
307 //#ifdef _PMI
308 // PMI Event Class Filter Register
309 /************************************************************************************
310 | 31:4 | 3 | 2 | 1 | 0 |
311 | Reserved | Memory Power | Logic Power | Memory Voltage | Logic Voltage |
312 | | State Change | State Change | OPP Change | OPP Change |
313 *************************************************************************************/
314 #define PMI_EVENTCLASSFILTER_REG_ADDR(ba) (uint32_t *)((uint32_t)(ba) + PCMI_EventClassFilter_RegOff )
315 
316 #define PMI_LOGICVOLTAGEOPPCHANGE 0x1
317 #define PMI_MEMORYVOLTAGEOPPCHANGE 0x2
318 #define PMI_LOGICPOWERSTATECHANGE 0x4
319 #define PMI_MEMORYPOWERSATTECHANGE 0x8
320 
321 //#endif
322 
323 //#ifdef _CMI
324 // Event Class Filter Register (CM Events Mode)
325 /***********************************************************************************
326 | 15:4 | 3 | 2 | 1 | 0 |
327 | Reserved | Clock Source | Clock Freq | Clock Freq | Clock Domain |
328 | | Selection | Divider Ratio| Divider Ratio | State |
329 | | Update | 4-bit | 8-bit | |
330 ************************************************************************************/
331 /****************************************************************************************************
332 | 31:21 | 20 | 19 | 18 | 17 | 16 |
333 | Reserved | DDRPHY DPLL-CM1 | ABE DPLL-CM1 | IVA DPLL-CM1 | MPU DPLL-CM1 | Core DPLL-CM1 |
334 | | Reserverd-CM2 | Reserved CM2 | UNIPRO DPLL-CM2| USB DPLL -CM2 | PER DPLL-CM2 |
335 | | Update | Update | Update | Update | Update |
336 | | | | | | |
337 ****************************************************************************************************/
338 #define CMI_EVENTCLASSFILTER_REG_ADDR(ba) (uint32_t *)((uint32_t)(ba) + PCMI_EventClassFilter_RegOff )
339 
340 #define CMI_EVENT_CLOCK_DOMAIN_STATE_UPDATE 0x000001
341 #define CMI_EVENT_CLOCK_FREQDIVIDER_8BIT_UPDATE 0x000002 //Not used in OMAP4
342 #define CMI_EVENT_CLOCK_FREQDIVIDER_4BIT_UPDATE 0x000004
343 #define CMI_EVENT_CLOCK_SOURCE_SELECTION_UPDATE 0x000008
344 #define CMI_EVENT_CM1_CORE_DPLL_UPDATE 0x010000
345 #define CMI_EVENT_CM1_MPU_DPLL_UPDATE 0x020000
346 #define CMI_EVENT_CM1_IVA_DPLL_UPDATE 0x040000
347 #define CMI_EVENT_CM1_ABE_DPLL_UPDATE 0x080000
348 #define CMI_EVENT_CM1_DDRPHY_DPLL_UPDATE 0x100000
349 
350 #define CMI_EVENT_CM2_PER_DPLL_UPDATE 0x010000
351 #define CMI_EVENT_CM2_USB_DPLL_UPDATE 0x020000
352 #define CMI_EVENT_CM2_UNIPRO_DPLL_UPDATE 0x040000
353 
354 // CMI Event Class Filter Register (Activity Mode)
355 /***********************************************************************************
356 | 31:4 | 3 | 2 | 1 | 0 |
357 | Reserved | Initiator | Initiator | Target | Target |
358 | | Activity | Activity | Activity | Activity |
359 | | 4-bit | 8-bit | 4-bit | 8-bit |
360 ************************************************************************************/
361 
362 // Note that the size of the sample window determines if 4-bit or 8-bit
363 // messages are generated.
364 #define CMI_TARGET_ACTVITY 0x3
365 #define CMI_INITIATOR_ACTIVITY 0xc
366 
367 //#endif
368 
369 typedef enum { ePCMI_TRIGGER_NONE = 0,
370  ePCMI_TRIGGER_START_ENABLE = 1,
371  ePCMI_TRIGGER_STOP_ENABLE = 2,
372  ePCMI_TRIGGER_START_STOP_ENABLE = 3,
373  ePCMI_TRIGGER_NOTMODIFIED = -1
374  } ePCMI_Triggers;
375 
376 /*
377  Strings and string pointers
378 */
379 
380 extern const char SWDomainStr[];
381 enum PCMI_DataType { MSG, STATE, VALUE, META};
382 extern const char * PCMI_DataTypeStr[];
383 extern const char SWMsg_WindowSizeStr[];
384 extern const char SWMsg_DivideByFactor[];
385 
386 extern const char PCMI_ErrorStr_Success[];
387 extern const char PCMI_ErrorStr_Not_Compatible[];
388 extern const char PCMI_ErrorStr_Ownership_Not_Confirmed[];
389 extern const char PCMI_ErrorStr_Ownership_Not_Granted[];
390 extern const char PCMI_ErrorStr_Ownership_Not_Released[];
391 extern const char PCMI_ErrorStr_ResetDone_Not_Detected[];
392 extern const char PCMI_ErrorStr_Memory_Allocation[];
393 extern const char PCMI_ErrorStr_Module_Enabled[];
394 extern const char PCMI_ErrorStr_Invalid_Parameter[];
395 extern const char PCMI_ErrorStr_NULL_STMHandle[];
396 extern const char PCMI_ErrorStr_AlreadyOpen[];
397 extern const char PCMI_ErrorStr_MappingError[];
398 extern const char PCMI_ErrorStr_ModuleEnableFailed[];
399 extern const char PCMI_ErrorStr_ModuleDisableFailed[];
400 extern const char PCMI_ErrorStr_InvalidHandlePointer[];
401 extern const char PCMI_ErrorStr_VerboseDisabled[];
402 extern const char PCMI_ErrorStr_ModuleClkModifyFailed[];
403 extern const char PCMI_ErrorStr_STM[];
404 
405 /*
406  Common Function prototypes
407 */
408 #ifdef _STMLogging
409 eSTM_STATUS PCMI_STMlogMsg(STMHandle * pSTMHandle, uint8_t STMLoggingCh, int32_t STMLoggingEnable, const char * logStr);
410 eSTM_STATUS PCMI_STMlogMsg1(STMHandle * pSTMHandle, uint8_t STMLoggingCh, int32_t STMLoggingEnable, const char * logStr, int value);
411 #endif
412 int32_t PCMI_HWCompatibility(void * BaseAddress, int LibFuncValue);
413 int32_t PCMI_ClaimModule(void * BaseAddress);
414 extern int32_t PCMI_SoftResetModule( void * BaseAddress );
415 extern int32_t PCMI_ReleaseModule( void * BaseAddress );
416 extern int32_t PCMI_ConfirmOwnership( void * BaseAddress );
417 extern int32_t PCMI_EnableModule(void * BaseAddress);
418 extern int32_t PCMI_DisableModule(void * BaseAddress);
419 int32_t PCMI_ModuleClockEnable(pREG32_TYPE ModuleAddress);
420 int32_t PCMI_ModuleClockDisable( pREG32_TYPE ModuleAddress);
421 extern int32_t PCMI_Open(void * vPMI_BaseAddress, pREG32_TYPE vPMI_ClkCtrlRegAddr, const uint32_t PMI_LibFuncValue);
422 extern uint32_t PCMI_SetSampleWindow(void * BaseAddress, uint32_t FuncClockDivider, uint32_t SampleWindowSize );
423 
424 #ifdef _UsingTITools
425 #ifdef _STMLogging
426 #pragma CODE_SECTION(PCMI_STMlogMsg, ".text:PCMILibrary");
427 #pragma CODE_SECTION(PCMI_STMlogMsg1, ".text:PCMILibrary");
428 #endif
429 #pragma CODE_SECTION(PCMI_HWCompatibility, ".text:PCMILibrary");
430 #pragma CODE_SECTION(PCMI_ClaimModule, ".text:PCMILibrary");
431 #pragma CODE_SECTION(PCMI_SoftResetModule, ".text:PCMILibrary");
432 #pragma CODE_SECTION(PCMI_ReleaseModule, ".text:PCMILibrary");
433 #pragma CODE_SECTION(PCMI_ConfirmOwnership, ".text:PCMILibrary");
434 #pragma CODE_SECTION(PCMI_EnableModule, ".text:PCMILibrary");
435 #pragma CODE_SECTION(PCMI_DisableModule, ".text:PCMILibrary");
436 #pragma CODE_SECTION(PCMI_ModuleClockEnable, ".text:PCMILibrary");
437 #pragma CODE_SECTION(PCMI_ModuleClockDisable, ".text:PCMILibrary");
438 #pragma CODE_SECTION(PCMI_Open, ".text:PCMILibrary");
439 #pragma CODE_SECTION(PCMI_SetSampleWindow, ".text:PCMILibrary");
440 #endif
441 
442 #endif //_DOXYGEN_IGNORE
443 
444 #ifdef __cplusplus
445 }
446 #endif
447 
448 #endif /* __PMI_CMI_COMMON__H */
449 
Definition: PCMI_Common.h:99
Definition: PCMI_Common.h:96
Definition: PCMI_Common.h:109
Definition: PCMI_Common.h:112
Definition: PCMI_Common.h:101
Definition: PCMI_Common.h:98
Definition: PCMI_Common.h:100
Definition: PCMI_Common.h:90
ePCMI_Error
Definition: PCMI_Common.h:89
Definition: PCMI_Common.h:106
Definition: PCMI_Common.h:91
Definition: PCMI_Common.h:92
void(* PCMI_CallBack)(const char *funcName, ePCMI_Error)
Definition: PCMI_Common.h:120
Definition: PCMI_Common.h:104
Definition: PCMI_Common.h:97
Definition: PCMI_Common.h:108
Definition: PCMI_Common.h:102
Definition: PCMI_Common.h:94
Definition: PCMI_Common.h:103
Definition: PCMI_Common.h:110
Definition: PCMI_Common.h:95
Definition: PCMI_Common.h:105
Definition: PCMI_Common.h:93