AM273x MCU+ SDK  09.02.00
drivers/esm/v0/esm.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Texas Instruments Incorporated
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 
49 #ifndef ESM_H_
50 #define ESM_H_
51 
52 /* ========================================================================== */
53 /* Include Files */
54 /* ========================================================================== */
55 #include <stdint.h>
56 #include <kernel/dpl/HwiP.h>
57 #include <drivers/hw_include/cslr_soc.h>
58 #include <drivers/hw_include/cslr_esm.h>
59 
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63 
64 /* ========================================================================== */
65 /* Macros & Typedefs */
66 /* ========================================================================== */
67 
69 typedef void *ESM_Handle;
70 
72 #define ESM_ERRNO_BASE (-3000)
73 
80 #define ESM_EINVAL (ESM_ERRNO_BASE-1)
81 
82 #define ESM_ENOINIT (ESM_ERRNO_BASE-2)
83 
84 #define ESM_EREINIT (ESM_ERRNO_BASE-3)
85 
86 #define ESM_ENOMEM (ESM_ERRNO_BASE-4)
87 
90 #define ESM_MAX_NOTIFIERS (4U)
91 
92 #define ESM_MAX_ISR_COUNT (4U)
93 
94 /* ========================================================================== */
95 /* enums */
96 /* ========================================================================== */
97 
99 typedef enum
100 {
106 
108 typedef enum
109 {
115 
116 /* ========================================================================== */
117 /* Structure Declarations */
118 /* ========================================================================== */
119 
129 typedef void (*ESM_CallBack)(void* arg);
130 
132 typedef struct
133 {
134  uint32_t grpIntrStatus[ESM_NUM_INTR_PER_GROUP / 32U];
137 
144 typedef struct
145 {
146  uint32_t groupNumber;
148  uint32_t errorNumber;
154  void *arg;
159 
170 typedef struct
171 {
182 
192 typedef struct {
193  CSL_esmRegs *ptrESMRegs;
195  CSL_mss_ctrlRegs *ptrCtrlRegs;
197  uint32_t numGroup1Err;
199  uint32_t highPrioIntNum;
201  uint32_t lowPrioIntNum;
207 } ESM_Attrs;
208 
216 typedef struct
217 {
220  uint32_t esmBaseAddr;
224  void *hwiHandleHi;
228  void *hwiHandleLo;
234  uint32_t numGroup1Err;
236  uint32_t debugEsmISRCount[ESM_MAX_ISR_COUNT];
238 } ESM_Object;
239 
246 typedef struct {
251 } ESM_Config;
252 
254 extern ESM_Config gEsmConfig[];
256 extern uint32_t gEsmConfigNum;
257 
258 /* ========================================================================== */
259 /* Function Declarations */
260 /* ========================================================================== */
261 
266 void ESM_init(void);
267 
272 void ESM_deinit(void);
273 
287 ESM_Handle ESM_open(uint32_t index, ESM_OpenParams *params);
288 
298 void ESM_close(ESM_Handle handle);
299 
314 int32_t ESM_registerNotifier(ESM_Handle handle, ESM_NotifyParams* params, int32_t* errCode);
315 
330 int32_t ESM_deregisterNotifier(ESM_Handle handle, int32_t notifyIndex, int32_t* errCode);
331 
340 void ESM_setMode(uint32_t baseAddr, uint32_t mode);
341 
351 int32_t ESM_setErrPinLowTimePreload(uint32_t baseAddr, uint32_t lowTime);
352 
360 uint32_t ESM_getCurrErrPinLowTimeCnt(uint32_t baseAddr);
361 
369 uint32_t ESM_getErrPinStatus(uint32_t baseAddr);
370 
377 void ESM_resetErrPin(uint32_t baseAddr);
378 
388 uint32_t ESM_getIntrStatus(uint32_t baseAddr, uint32_t intrSrc);
389 
404 int32_t ESM_getGroupIntrStatus(uint32_t baseAddr,
405  uint32_t grpNum,
406  ESM_GroupIntrStatus *intrstatus);
407 
408 /* ========================================================================== */
409 /* Static Function Definitions */
410 /* ========================================================================== */
411 static inline void ESM_Params_init(ESM_OpenParams *openPrms)
412 {
413  if (openPrms != NULL)
414  {
415  openPrms->bClearErrors = FALSE;
416  }
417 }
418 
419 #ifdef __cplusplus
420 }
421 #endif
422 
423 #endif /* #ifndef ESM_H_ */
424 
ESM_NotifyParams::arg
void * arg
Definition: drivers/esm/v0/esm.h:154
ESM_getIntrStatus
uint32_t ESM_getIntrStatus(uint32_t baseAddr, uint32_t intrSrc)
This API is used to get the interrupt status.
ESM_Attrs::highPrioIntNum
uint32_t highPrioIntNum
Definition: drivers/esm/v0/esm.h:199
ESM_OperationMode
ESM_OperationMode
Enum to select the ESM Operation Mode.
Definition: drivers/esm/v0/esm.h:109
gEsmConfigNum
uint32_t gEsmConfigNum
Externally defined driver configuration array size.
ESM_Object::esmBaseAddr
uint32_t esmBaseAddr
Definition: drivers/esm/v0/esm.h:220
ESM_NotifyParams::errorNumber
uint32_t errorNumber
Definition: drivers/esm/v0/esm.h:148
ESM_Object::esmHandle
ESM_Handle esmHandle
Definition: drivers/esm/v0/esm.h:218
ESM_CallBack
void(* ESM_CallBack)(void *arg)
Callback function which is invoked by the ESM module if a notify function is registered using the ESM...
Definition: drivers/esm/v0/esm.h:129
ESM_OpenParams
ESM Open Parameters.
Definition: drivers/esm/v0/esm.h:171
ESM_NotifyParams::setIntrPriorityLvl
uint32_t setIntrPriorityLvl
Definition: drivers/esm/v0/esm.h:150
ESM_INTR_PRIORITY_LEVEL_LOW
@ ESM_INTR_PRIORITY_LEVEL_LOW
Definition: drivers/esm/v0/esm.h:101
ESM_MAX_ISR_COUNT
#define ESM_MAX_ISR_COUNT
Maximum ISR supported.
Definition: drivers/esm/v0/esm.h:92
ESM_close
void ESM_close(ESM_Handle handle)
The function closes a ESM peripheral specified by the ESM handle.
ESM_deinit
void ESM_deinit(void)
The functions de-initializes the ESM module.
ESM_NotifyParams::notify
ESM_CallBack notify
Definition: drivers/esm/v0/esm.h:156
ESM_Object::params
ESM_OpenParams params
Definition: drivers/esm/v0/esm.h:222
ESM_IntrPriorityLvl
ESM_IntrPriorityLvl
Enum to select level for interrupt.
Definition: drivers/esm/v0/esm.h:100
ESM_ESMEKR_EKEY_NORMAL_MODE
#define ESM_ESMEKR_EKEY_NORMAL_MODE
Definition: sdlr_esm.h:540
ESM_Config
ESM Instance configuration.
Definition: drivers/esm/v0/esm.h:246
ESM_setErrPinLowTimePreload
int32_t ESM_setErrPinLowTimePreload(uint32_t baseAddr, uint32_t lowTime)
This API is used to configure the low time counter pre-load value.
ESM_OPERATION_MODE_ERROR_FORCE
@ ESM_OPERATION_MODE_ERROR_FORCE
Definition: drivers/esm/v0/esm.h:112
ESM_setMode
void ESM_setMode(uint32_t baseAddr, uint32_t mode)
This API is used to configure operation mode of ESM module.
ESM_Object::numGroup1Err
uint32_t numGroup1Err
Definition: drivers/esm/v0/esm.h:234
gEsmConfig
ESM_Config gEsmConfig[]
Externally defined driver configuration array.
ESM_Attrs::intrLowPriority
uint8_t intrLowPriority
Definition: drivers/esm/v0/esm.h:205
ESM_ESMEKR_EKEY_ERROR_FORCE_MODE
#define ESM_ESMEKR_EKEY_ERROR_FORCE_MODE
Definition: sdlr_esm.h:542
ESM_Attrs::lowPrioIntNum
uint32_t lowPrioIntNum
Definition: drivers/esm/v0/esm.h:201
ESM_resetErrPin
void ESM_resetErrPin(uint32_t baseAddr)
This API is used to reset the nERROR pin. This will set the nERROR pin to high.
ESM_Attrs::ptrCtrlRegs
CSL_mss_ctrlRegs * ptrCtrlRegs
Definition: drivers/esm/v0/esm.h:195
HwiP.h
ESM_Object
ESM Driver Object.
Definition: drivers/esm/v0/esm.h:217
ESM_OPERATION_MODE_NORMAL
@ ESM_OPERATION_MODE_NORMAL
Definition: drivers/esm/v0/esm.h:110
ESM_getErrPinStatus
uint32_t ESM_getErrPinStatus(uint32_t baseAddr)
This API is used to get the current status of nERROR pin.
ESM_getCurrErrPinLowTimeCnt
uint32_t ESM_getCurrErrPinLowTimeCnt(uint32_t baseAddr)
This API is used to get the current value of low time counter.
ESM_registerNotifier
int32_t ESM_registerNotifier(ESM_Handle handle, ESM_NotifyParams *params, int32_t *errCode)
Register the notifers. The ESM module will call back if error interrupt is detected.
ESM_MAX_NOTIFIERS
#define ESM_MAX_NOTIFIERS
Maximum number of notify callbacks supported.
Definition: drivers/esm/v0/esm.h:90
ESM_NotifyParams::enableInfluenceOnErrPin
Bool enableInfluenceOnErrPin
Definition: drivers/esm/v0/esm.h:152
ESM_Object::hwiHandleLo
void * hwiHandleLo
Definition: drivers/esm/v0/esm.h:228
ESM_Attrs
ESM Hardware Atrributes.
Definition: drivers/esm/v0/esm.h:192
ESM_NotifyParams::groupNumber
uint32_t groupNumber
Definition: drivers/esm/v0/esm.h:146
ESM_getGroupIntrStatus
int32_t ESM_getGroupIntrStatus(uint32_t baseAddr, uint32_t grpNum, ESM_GroupIntrStatus *intrstatus)
This API is used to get the interrupt/error status for a group.
ESM_INTR_PRIORITY_LEVEL_HIGH
@ ESM_INTR_PRIORITY_LEVEL_HIGH
Definition: drivers/esm/v0/esm.h:103
ESM_Config::object
ESM_Object * object
Definition: drivers/esm/v0/esm.h:249
ESM_deregisterNotifier
int32_t ESM_deregisterNotifier(ESM_Handle handle, int32_t notifyIndex, int32_t *errCode)
Deregister the ESM notifers.
ESM_Attrs::numGroup1Err
uint32_t numGroup1Err
Definition: drivers/esm/v0/esm.h:197
HwiP_Object
Opaque Hwi object used with the Hwi APIs.
Definition: HwiP.h:93
ESM_NotifyParams
Parameters used to register the ESM notify function to handle Group1 and Group2 errors....
Definition: drivers/esm/v0/esm.h:145
ESM_init
void ESM_init(void)
The functions initializes the ESM module.
ESM_Attrs::ptrESMRegs
CSL_esmRegs * ptrESMRegs
Definition: drivers/esm/v0/esm.h:193
ESM_GroupIntrStatus
Structure to access the status of interrupts belonging to a group.
Definition: drivers/esm/v0/esm.h:133
ESM_NUM_INTR_PER_GROUP
#define ESM_NUM_INTR_PER_GROUP
Definition: cslr_soc_defines.h:124
ESM_Attrs::intrHighPriority
uint8_t intrHighPriority
Definition: drivers/esm/v0/esm.h:203
ESM_Object::hwiHandleHi
void * hwiHandleHi
Definition: drivers/esm/v0/esm.h:224
ESM_OpenParams::bClearErrors
Bool bClearErrors
Definition: drivers/esm/v0/esm.h:172
ESM_Config::hwAttrs
const ESM_Attrs * hwAttrs
Definition: drivers/esm/v0/esm.h:247
ESM_Params_init
static void ESM_Params_init(ESM_OpenParams *openPrms)
Definition: drivers/esm/v0/esm.h:411
ESM_Object::hwiHiObj
HwiP_Object hwiHiObj
Definition: drivers/esm/v0/esm.h:226
ESM_Object::hwiLoObj
HwiP_Object hwiLoObj
Definition: drivers/esm/v0/esm.h:230
ESM_open
ESM_Handle ESM_open(uint32_t index, ESM_OpenParams *params)
Opens a ESM object with the index and parameters specified, and returns a ESM_Handle.
ESM_Handle
void * ESM_Handle
A handle that is returned from a ESM_open() call.
Definition: drivers/esm/v0/esm.h:69