AM261x MCU+ SDK: pmic.h Source File

| AM261x MCU+ SDK 26.00.00 |

pmic.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2023-24 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
45 #ifndef PMIC_LLD_H_
46 #define PMIC_LLD_H_
47
48 /* ========================================================================== */
49 /* Include Files */
50 /* ========================================================================== */
51
52 #include <stdint.h>
53 #include <kernel/dpl/SystemP.h>
54 #include <drivers/mcspi.h>
55 #include <drivers/edma.h>
56 #ifdef BLACKBIRD
57 #include <board/pmic/pmic_lld/blackbird/include/pmic.h>
58 #endif
59
60 #ifdef DERBY
61 #include <board/pmic/pmic_lld/derby/include/pmic.h>
62 #endif
63
64 #ifdef __cplusplus
65 extern "C" {
66 #endif
67
68 /* ========================================================================== */
69 /* Macros & Typedefs */
70 /* ========================================================================== */
71
73 typedef void *PMIC_Handle;
75 typedef struct PMIC_Config_s PMIC_Config;
77 typedef struct PMIC_Params_s PMIC_Params;
78
95 typedef int32_t (*PMIC_OpenFxn)(PMIC_Config *config, const PMIC_Params *params);
96
107 typedef int32_t (*PMIC_ConfigureFxn)(PMIC_Config *config);
108
119 typedef void (*PMIC_CloseFxn)(PMIC_Config *config);
120
123 /* ========================================================================== */
124 /* Structure Declarations */
125 /* ========================================================================== */
126
130 struct PMIC_Params_s
131 {
132 uint32_t deviceType;
134 uint32_t commMode;
136 uint32_t instType;
138 uint32_t i2cAddr;
141 uint32_t instance;
144 };
145
149 typedef struct PMIC_Fxns_s
150 {
151 PMIC_OpenFxn openFxn;
153 PMIC_ConfigureFxn configureFxn;
155 PMIC_CloseFxn closeFxn;
157 } PMIC_Fxns;
158
159
164 struct PMIC_Config_s
165 {
166 PMIC_Fxns *fxns;
168 void *object;
170 };
171
172 /* ========================================================================== */
173 /* Global Variables */
174 /* ========================================================================== */
175
176 extern PMIC_Config gPmicConfig[];
177 extern uint32_t gPmicConfigNum;
178
179 /* ========================================================================== */
180 /* Function Declarations */
181 /* ========================================================================== */
182
201 PMIC_Handle PMIC_open(uint32_t instanceId, const PMIC_Params *params);
202
208 int32_t PMIC_configure(PMIC_Handle handle);
209
218 Pmic_CoreHandle_t* PMIC_getCoreHandle(uint32_t index);
219
225 void PMIC_close(PMIC_Handle handle);
226
227
228 /* ========================================================================== */
229 /* Static Function Definitions */
230 /* ========================================================================== */
231
232 /* None */
233
234 /* ========================================================================== */
235 /* Internal/Private Structure Declarations */
236 /* ========================================================================== */
237
241 typedef struct
242 {
244 PMIC_Handle handle;
246 Pmic_CoreHandle_t *pmicCoreHandle;
248 uint32_t isOpen;
249
250 } PMIC_Object;
251
252 #ifdef __cplusplus
253 }
254 #endif
255
256 #endif /* #ifndef PMIC_LLD_H_ */
257
gPmicConfig
PMIC_Config gPmicConfig[]
PMIC_Params_s::instance
uint32_t instance
Definition: pmic.h:141
PMIC_Fxns::openFxn
PMIC_OpenFxn openFxn
Definition: pmic.h:151
PMIC_Params_s::deviceType
uint32_t deviceType
Definition: pmic.h:132
PMIC_Config_s::fxns
PMIC_Fxns * fxns
Definition: pmic.h:166
SystemP.h
PMIC_close
void PMIC_close(PMIC_Handle handle)
Close PMIC driver.
PMIC_Params_s::instType
uint32_t instType
Definition: pmic.h:136
PMIC_Config_s::object
void * object
Definition: pmic.h:168
PMIC_Object::pmicCoreHandle
Pmic_CoreHandle_t * pmicCoreHandle
Definition: pmic.h:246
PMIC_Object::isOpen
uint32_t isOpen
Definition: pmic.h:248
PMIC_Config_s
PMIC driver configuration, these are filled by SysCfg based on the device that is selected.
Definition: pmic.h:165
edma.h
PMIC_CloseFxn
void(* PMIC_CloseFxn)(PMIC_Config *config)
Driver implementation to close a specific PMIC driver.
Definition: pmic.h:119
mcspi.h
PMIC_Object::handle
PMIC_Handle handle
Definition: pmic.h:244
PMIC_Params_s::i2cAddr
uint32_t i2cAddr
Definition: pmic.h:138
PMIC_getCoreHandle
Pmic_CoreHandle_t * PMIC_getCoreHandle(uint32_t index)
Get handle to PMIC Pmic_CoreHandle_t driver.
PMIC_open
PMIC_Handle PMIC_open(uint32_t instanceId, const PMIC_Params *params)
Open PMIC driver.
PMIC_Params_s
Parameters passed during PMIC_open()
Definition: pmic.h:131
gPmicConfigNum
uint32_t gPmicConfigNum
PMIC_Fxns::closeFxn
PMIC_CloseFxn closeFxn
Definition: pmic.h:155
PMIC_ConfigureFxn
int32_t(* PMIC_ConfigureFxn)(PMIC_Config *config)
Driver implementation to configure the specific PMIC driver.
Definition: pmic.h:107
PMIC_configure
int32_t PMIC_configure(PMIC_Handle handle)
Configure PMIC driver.
PMIC_Object
PMIC driver object - not to be used by application.
Definition: pmic.h:242
PMIC_Handle
void * PMIC_Handle
Handle to the PMIC driver returned by PMIC_open()
Definition: pmic.h:73
PMIC_Fxns::configureFxn
PMIC_ConfigureFxn configureFxn
Definition: pmic.h:153
PMIC_Fxns
Driver implementation callbacks.
Definition: pmic.h:150
PMIC_OpenFxn
int32_t(* PMIC_OpenFxn)(PMIC_Config *config, const PMIC_Params *params)
Driver implementation to open a specific PMIC driver.
Definition: pmic.h:95
PMIC_Params_s::commMode
uint32_t commMode
Definition: pmic.h:134