PDK API Guide for J721E
PMIC Driver API

Introduction

This is PMIC driver init, and deinit API

Files

file  pmic.h
 PMIC Driver API/interface file.
 

Data Structures

struct  Pmic_CoreCfg_t
 : PMIC configuration structure. Contains various parameters which are needed to prepare PMIC driver handle using Valid param like, PMIC device type, PMIC interface mode, Slave address, various application defined API function pointers for LLD and Critical sections Application has to set the corresponding bit in validParams structure member to update the driver with Pmic_CoreCfg_t structure fields. For Example - If the Application need to configure the PMIC driver device type as pmicDeviceType struct value then application has to set PMIC_CFG_DEVICE_TYPE_VALID bit of validParams struct and then call pmic_init() More...
 

Functions

int32_t Pmic_init (Pmic_CoreCfg_t *pPmicConfigData, Pmic_CoreHandle_t *pPmicCoreHandle)
 : Initialize pmic core haandle for PMIC LLD This function gets device configuration from pCoreCfgHandle and initializes device specific information in pPmicCoreHandle after validation of given params depends on validParams bitfileds and does some basic validation on PMIC interface I2C/SPI, confirming that PMIC is accessible for PMIC configuration and monitor features. More...
 
int32_t Pmic_deinit (Pmic_CoreHandle_t *pPmicCoreHandle)
 : DeInitilizes an existing PMIC Instance This function takes in an existing Instance pPmicCoreHandle and closes the LLD being used for this Instance. It should be called only once per instance valid pPmicCoreHandle. Should not be called if Pmic_init() is not called More...
 

PMIC Error Codes

Error codes returned by PMIC APIs

#define PMIC_ST_SUCCESS   (0)
 Error Code for SUCCESS. More...
 
#define PMIC_ST_ERR_INV_HANDLE   (-((int32_t)1))
 Error Code for Invalid input Handle. More...
 
#define PMIC_ST_ERR_INV_VOLTAGE   (-((int32_t)2))
 Error Code for Invalid Voltage Value. More...
 
#define PMIC_ST_ERR_INV_REGULATOR   (-((int32_t)3))
 Error Code for Invalid Power resource Value. More...
 
#define PMIC_ST_ERR_I2C_COMM_FAIL   (-((int32_t)4))
 Error Code for I2C Communication Fail. More...
 
#define PMIC_ST_ERR_SPI_COMM_FAIL   (-((int32_t)5))
 Error Code for SPI Communication Fail. More...
 
#define PMIC_ST_ERR_COMM_INTF_INIT_FAIL   (-((int32_t)6))
 Error Code for Interface Init Fail. More...
 
#define PMIC_ST_ERR_INV_GPIO   (-((int32_t)7))
 Error Code for Invalid input GPIO PIN. More...
 
#define PMIC_ST_ERR_INV_GPIO_FUNC   (-((int32_t)8))
 Error Code for Invalid GPIO Functionality. More...
 
#define PMIC_ST_ERR_INV_GPIO_LINE_PARAMS   (-((int32_t)9))
 Error Code for input GPIO handle is invalid. More...
 
#define PMIC_ST_ERR_NULL_PARAM   (-((int32_t)10))
 Error Code when input Param is NULL. More...
 
#define PMIC_ST_ERR_INV_PARAM   (-((int32_t)11))
 Error Code for Invalid input Param. More...
 
#define PMIC_ST_ERR_INV_ESM_TARGET   (-((int32_t)12))
 Error Code for input ESM TargetID is invalid. More...
 
#define PMIC_ST_ERR_INV_ESM_MODE   (-((int32_t)13))
 Error Code for ESM Operation Mode is invalid. More...
 
#define PMIC_ST_ERR_INTF_SETUP_FAILED   (-((int32_t)14))
 Error Code for Interface Selected is not working properly. More...
 
#define PMIC_ST_ERR_INV_DEVICE   (-((int32_t)15))
 Error Code for Invalid PMIC Device. More...
 
#define PMIC_ST_ERR_PIN_NOT_GPIO   (-((int32_t)16))
 Error Code for Invalid Pin for GPIO Configuration. More...
 
#define PMIC_ST_ERR_INV_WDG_MODE   (-((int32_t)17))
 Error Code for Invalid Watchdog Configuration Mode. More...
 
#define PMIC_ST_ERR_INV_WDG_WINDOW   (-((int32_t)18))
 Error Code for Watchdog Window 1 0r 2 duration. More...
 
#define PMIC_ST_ERR_INV_TEMP_THRESHOLD   (-((int32_t)19))
 Error Code for Invalid Temperature Threshold value. More...
 
#define PMIC_ST_ERR_INV_PGOOD_LEVEL   (-((int32_t)20))
 Error Code for Invalid Power Good Threshold Value. More...
 
#define PMIC_ST_ERR_INV_INT   (-((int32_t)21))
 Error Code for Invalid Interrupt. More...
 
#define PMIC_ST_ERR_CLEAR_INT_FAILED   (-((int32_t)22))
 Error Code when Interrupts Clear is failed. More...
 
#define PMIC_ST_ERR_UNINIT   (-((int32_t)23))
 Error Code if Pmic_init() function called before PMIC driver is initialized. More...
 
#define PMIC_ST_ERR_DATA_IO_CRC   (-((int32_t)24))
 Error Code for IO data failure when CRC is enabled. More...
 
#define PMIC_ST_ERR_NULL_FPTR   (-((int32_t)25))
 Error Code when input Function pointer is NULL. More...
 
#define PMIC_ST_ERR_INV_TIME   (-((int32_t)26))
 Error Code for Invalid Time. More...
 
#define PMIC_ST_ERR_INV_DATE   (-((int32_t)27))
 Error Code for Invalid Date. More...
 
#define PMIC_ST_ERR_RTC_STOP_FAIL   (-((int32_t)28))
 Error Code for RTC Stop command failure. More...
 
#define PMIC_ST_ERR_INV_ANSWER_COUNT   (-((int32_t)29))
 Error Code for Invalid Watchdog Answer Count. More...
 
#define PMIC_ST_ERR_INV_SUBSYSTEM   (-((int32_t)30))
 Error Code for Invalid PMIC Subsystem. More...
 
#define PMIC_ST_ERR_INSUFFICIENT_CFG   (-((int32_t)31))
 Error Code for Insufficient input configuration params for PMIC Device Initialization. More...
 

PMIC Device type

#define PMIC_DEV_LEO_TPS6594   (0U)
 
#define PMIC_DEV_HERA_LP8764   (1U)
 

PMIC Communication Mode

#define PMIC_INTF_SINGLE_I2C   (0U)
 
#define PMIC_INTF_DUAL_I2C   (1U)
 
#define PMIC_INTF_SPI   (2U)
 

PMIC Instance Type

#define PMIC_MAIN_INST   (1U << 0U)
 
#define PMIC_QA_INST   (1U << 1U)
 

PMIC Config Structure Param Bits

#define PMIC_CFG_DEVICE_TYPE_VALID   (0U)
 
#define PMIC_CFG_COMM_MODE_VALID   (1U)
 
#define PMIC_CFG_SLAVEADDR_VALID   (2U)
 
#define PMIC_CFG_QASLAVEADDR_VALID   (3U)
 
#define PMIC_CFG_CRC_ENABLE_VALID   (4U)
 
#define PMIC_CFG_COMM_HANDLE_VALID   (5U)
 
#define PMIC_CFG_QACOMM_HANDLE_VALID   (6U)
 
#define PMIC_CFG_COMM_IO_RD_VALID   (7U)
 
#define PMIC_CFG_COMM_IO_WR_VALID   (8U)
 
#define PMIC_CFG_CRITSEC_START_VALID   (9U)
 
#define PMIC_CFG_CRITSEC_STOP_VALID   (10U)
 

PMIC Config Structure Param Bit shift values

Application can use below shifted values to set the validParam struct member defined in Pmic_CoreCfg_t structure

#define PMIC_CFG_DEVICE_TYPE_VALID_SHIFT   (1U << PMIC_CFG_DEVICE_TYPE_VALID)
 
#define PMIC_CFG_COMM_MODE_VALID_SHIFT   (1U << PMIC_CFG_COMM_MODE_VALID)
 
#define PMIC_CFG_SLAVEADDR_VALID_SHIFT   (1U << PMIC_CFG_SLAVEADDR_VALID)
 
#define PMIC_CFG_QASLAVEADDR_VALID_SHIFT   (1U << PMIC_CFG_QASLAVEADDR_VALID)
 
#define PMIC_CFG_CRC_ENABLE_VALID_SHIFT   (1U << PMIC_CFG_CRC_ENABLE_VALID)
 
#define PMIC_CFG_COMM_HANDLE_VALID_SHIFT   (1U << PMIC_CFG_COMM_HANDLE_VALID)
 
#define PMIC_CFG_QACOMM_HANDLE_VALID_SHIFT   (1U << PMIC_CFG_QACOMM_HANDLE_VALID)
 
#define PMIC_CFG_COMM_IO_RD_VALID_SHIFT   (1U << PMIC_CFG_COMM_IO_RD_VALID)
 
#define PMIC_CFG_COMM_IO_WR_VALID_SHIFT   (1U << PMIC_CFG_COMM_IO_WR_VALID)
 
#define PMIC_CFG_CRITSEC_START_VALID_SHIFT   (1U << PMIC_CFG_CRITSEC_START_VALID)
 
#define PMIC_CFG_CRITSEC_STOP_VALID_SHIFT   (1U << PMIC_CFG_CRITSEC_STOP_VALID)
 

Macro Definition Documentation

#define PMIC_ST_SUCCESS   (0)

Error Code for SUCCESS.

#define PMIC_ST_ERR_INV_HANDLE   (-((int32_t)1))

Error Code for Invalid input Handle.

#define PMIC_ST_ERR_INV_VOLTAGE   (-((int32_t)2))

Error Code for Invalid Voltage Value.

#define PMIC_ST_ERR_INV_REGULATOR   (-((int32_t)3))

Error Code for Invalid Power resource Value.

#define PMIC_ST_ERR_I2C_COMM_FAIL   (-((int32_t)4))

Error Code for I2C Communication Fail.

#define PMIC_ST_ERR_SPI_COMM_FAIL   (-((int32_t)5))

Error Code for SPI Communication Fail.

#define PMIC_ST_ERR_COMM_INTF_INIT_FAIL   (-((int32_t)6))

Error Code for Interface Init Fail.

#define PMIC_ST_ERR_INV_GPIO   (-((int32_t)7))

Error Code for Invalid input GPIO PIN.

#define PMIC_ST_ERR_INV_GPIO_FUNC   (-((int32_t)8))

Error Code for Invalid GPIO Functionality.

#define PMIC_ST_ERR_INV_GPIO_LINE_PARAMS   (-((int32_t)9))

Error Code for input GPIO handle is invalid.

#define PMIC_ST_ERR_NULL_PARAM   (-((int32_t)10))

Error Code when input Param is NULL.

#define PMIC_ST_ERR_INV_PARAM   (-((int32_t)11))

Error Code for Invalid input Param.

#define PMIC_ST_ERR_INV_ESM_TARGET   (-((int32_t)12))

Error Code for input ESM TargetID is invalid.

#define PMIC_ST_ERR_INV_ESM_MODE   (-((int32_t)13))

Error Code for ESM Operation Mode is invalid.

#define PMIC_ST_ERR_INTF_SETUP_FAILED   (-((int32_t)14))

Error Code for Interface Selected is not working properly.

#define PMIC_ST_ERR_INV_DEVICE   (-((int32_t)15))

Error Code for Invalid PMIC Device.

#define PMIC_ST_ERR_PIN_NOT_GPIO   (-((int32_t)16))

Error Code for Invalid Pin for GPIO Configuration.

#define PMIC_ST_ERR_INV_WDG_MODE   (-((int32_t)17))

Error Code for Invalid Watchdog Configuration Mode.

#define PMIC_ST_ERR_INV_WDG_WINDOW   (-((int32_t)18))

Error Code for Watchdog Window 1 0r 2 duration.

#define PMIC_ST_ERR_INV_TEMP_THRESHOLD   (-((int32_t)19))

Error Code for Invalid Temperature Threshold value.

#define PMIC_ST_ERR_INV_PGOOD_LEVEL   (-((int32_t)20))

Error Code for Invalid Power Good Threshold Value.

#define PMIC_ST_ERR_INV_INT   (-((int32_t)21))

Error Code for Invalid Interrupt.

#define PMIC_ST_ERR_CLEAR_INT_FAILED   (-((int32_t)22))

Error Code when Interrupts Clear is failed.

#define PMIC_ST_ERR_UNINIT   (-((int32_t)23))

Error Code if Pmic_init() function called before PMIC driver is initialized.

#define PMIC_ST_ERR_DATA_IO_CRC   (-((int32_t)24))

Error Code for IO data failure when CRC is enabled.

#define PMIC_ST_ERR_NULL_FPTR   (-((int32_t)25))

Error Code when input Function pointer is NULL.

#define PMIC_ST_ERR_INV_TIME   (-((int32_t)26))

Error Code for Invalid Time.

#define PMIC_ST_ERR_INV_DATE   (-((int32_t)27))

Error Code for Invalid Date.

#define PMIC_ST_ERR_RTC_STOP_FAIL   (-((int32_t)28))

Error Code for RTC Stop command failure.

#define PMIC_ST_ERR_INV_ANSWER_COUNT   (-((int32_t)29))

Error Code for Invalid Watchdog Answer Count.

#define PMIC_ST_ERR_INV_SUBSYSTEM   (-((int32_t)30))

Error Code for Invalid PMIC Subsystem.

#define PMIC_ST_ERR_INSUFFICIENT_CFG   (-((int32_t)31))

Error Code for Insufficient input configuration params for PMIC Device Initialization.

#define PMIC_DEV_LEO_TPS6594   (0U)
#define PMIC_DEV_HERA_LP8764   (1U)
#define PMIC_INTF_SINGLE_I2C   (0U)
#define PMIC_INTF_DUAL_I2C   (1U)
#define PMIC_INTF_SPI   (2U)
#define PMIC_MAIN_INST   (1U << 0U)
#define PMIC_QA_INST   (1U << 1U)
#define PMIC_CFG_DEVICE_TYPE_VALID   (0U)
#define PMIC_CFG_COMM_MODE_VALID   (1U)
#define PMIC_CFG_SLAVEADDR_VALID   (2U)
#define PMIC_CFG_QASLAVEADDR_VALID   (3U)
#define PMIC_CFG_CRC_ENABLE_VALID   (4U)
#define PMIC_CFG_COMM_HANDLE_VALID   (5U)
#define PMIC_CFG_QACOMM_HANDLE_VALID   (6U)
#define PMIC_CFG_COMM_IO_RD_VALID   (7U)
#define PMIC_CFG_COMM_IO_WR_VALID   (8U)
#define PMIC_CFG_CRITSEC_START_VALID   (9U)
#define PMIC_CFG_CRITSEC_STOP_VALID   (10U)
#define PMIC_CFG_DEVICE_TYPE_VALID_SHIFT   (1U << PMIC_CFG_DEVICE_TYPE_VALID)
#define PMIC_CFG_COMM_MODE_VALID_SHIFT   (1U << PMIC_CFG_COMM_MODE_VALID)
#define PMIC_CFG_SLAVEADDR_VALID_SHIFT   (1U << PMIC_CFG_SLAVEADDR_VALID)
#define PMIC_CFG_QASLAVEADDR_VALID_SHIFT   (1U << PMIC_CFG_QASLAVEADDR_VALID)
#define PMIC_CFG_CRC_ENABLE_VALID_SHIFT   (1U << PMIC_CFG_CRC_ENABLE_VALID)
#define PMIC_CFG_COMM_HANDLE_VALID_SHIFT   (1U << PMIC_CFG_COMM_HANDLE_VALID)
#define PMIC_CFG_QACOMM_HANDLE_VALID_SHIFT   (1U << PMIC_CFG_QACOMM_HANDLE_VALID)
#define PMIC_CFG_COMM_IO_RD_VALID_SHIFT   (1U << PMIC_CFG_COMM_IO_RD_VALID)
#define PMIC_CFG_COMM_IO_WR_VALID_SHIFT   (1U << PMIC_CFG_COMM_IO_WR_VALID)
#define PMIC_CFG_CRITSEC_START_VALID_SHIFT   (1U << PMIC_CFG_CRITSEC_START_VALID)
#define PMIC_CFG_CRITSEC_STOP_VALID_SHIFT   (1U << PMIC_CFG_CRITSEC_STOP_VALID)

Function Documentation

int32_t Pmic_init ( Pmic_CoreCfg_t pPmicConfigData,
Pmic_CoreHandle_t pPmicCoreHandle 
)

: Initialize pmic core haandle for PMIC LLD This function gets device configuration from pCoreCfgHandle and initializes device specific information in pPmicCoreHandle after validation of given params depends on validParams bitfileds and does some basic validation on PMIC interface I2C/SPI, confirming that PMIC is accessible for PMIC configuration and monitor features.

Parameters
pPmicConfigData[IN] Handle to driver instance
pPmicCoreHandle[OUT] Pointer to hold pmic device subsystem info
Return values
PMIC_ST_SUCCESSin case of success with valid pCoreCfg parameters or appropriate error code. For valid values Pmic_ErrorCodes
int32_t Pmic_deinit ( Pmic_CoreHandle_t pPmicCoreHandle)

: DeInitilizes an existing PMIC Instance This function takes in an existing Instance pPmicCoreHandle and closes the LLD being used for this Instance. It should be called only once per instance valid pPmicCoreHandle. Should not be called if Pmic_init() is not called

Parameters
pPmicCoreHandle[IN] Handle to driver instance to be closed
Return values
PMIC_ST_SUCCESSin case of success or appropriate error code For valid values Pmic_ErrorCodes