OpenBIC
OpenSource Bridge-IC
mp29816a.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <logging/log.h>
#include "libutil.h"
#include "sensor.h"
#include "hal_i2c.h"
#include "pmbus.h"
#include "mp29816a.h"
#include "util_pmbus.h"
Include dependency graph for mp29816a.c:

Classes

struct  cfg_data
 

Macros

#define READ_VOUT_MASK   GENMASK(11, 0)
 
#define MFR_VID_RES_MASK   GENMASK(12, 10)
 
#define UVP_THRESHOLD_MFR_UVP_DELTA_R1   GENMASK(12, 9)
 
#define UVP_THRESHOLD_MASK   GENMASK(8, 0)
 
#define IOUT_OCP_MASK   GENMASK(7, 0)
 
#define IOUT_SCALE_BIT_A_MASK   GENMASK(2, 0)
 
#define OVP_2_THRESHOLD_MASK   GENMASK(12, 9)
 
#define OVP_1_ABS_MASK   GENMASK(8, 0)
 
#define MFR_VOUT_SCALE_LOOP   0x29
 
#define MFR_VOUT_LOOP_CTRL   0x8D
 
#define MFR_VDIFF_GAIN_HALF_R2_BIT   BIT(10)
 
#define OVP_2_ACTION_MASK   GENMASK(7, 6)
 
#define VR_MPS_PAGE_0   0x00
 
#define VR_MPS_PAGE_1   0x01
 
#define MP29816A_VOUT_MAX_REG   0x24
 
#define MP29816A_VOUT_MIN_REG   0x2B
 
#define MP29816A_SVI3_IOUT_RPT_REG   0x67
 
#define VR_REG_EXPECTED_USER_CRC   0xED
 
#define MAX_CFG_LEN   1024
 
#define MP29816A_MAX_READ_BYTES   (6 + 1)
 

Enumerations

enum  CFG_PARAM_IDX {
  CFG_PARAM_IDX_PAGE = 1 , CFG_PARAM_IDX_REG_ADDR = 2 , CFG_PARAM_IDX_REG_NAME = 4 , CFG_PARAM_IDX_REG_VAL = 5 ,
  CFG_PARAM_IDX_REG_LEN = 7
}
 

Functions

 LOG_MODULE_REGISTER (mp29816a)
 
float mp29816a_get_resolution (sensor_cfg *cfg, bool is_vout_max_or_min)
 
uint8_t parsing_line (char *str, uint16_t len, struct cfg_data *cfg_data)
 
bool mp29816a_i2c_read (uint8_t bus, uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len)
 
bool mp29816a_i2c_write (uint8_t bus, uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len)
 
bool mp29816a_set_page (uint8_t bus, uint8_t addr, uint8_t page)
 
bool mp29816a_get_vout_max (sensor_cfg *cfg, uint8_t rail, uint16_t *millivolt)
 
bool mp29816a_get_vout_min (sensor_cfg *cfg, uint8_t rail, uint16_t *millivolt)
 
bool mp29816a_set_vout_max (sensor_cfg *cfg, uint8_t rail, uint16_t *millivolt)
 
bool mp29816a_set_vout_min (sensor_cfg *cfg, uint8_t rail, uint16_t *millivolt)
 
bool mp29816a_get_iout_oc_warn_limit (sensor_cfg *cfg, uint16_t *value)
 
bool mp29816a_set_iout_oc_warn_limit (sensor_cfg *cfg, uint16_t value)
 
bool mp29816a_fwupdate (uint8_t bus, uint8_t addr, uint8_t *img_buff, uint32_t img_size)
 
bool mp29816a_get_fw_version (uint8_t bus, uint8_t addr, uint32_t *rev)
 
bool mp29816a_get_vout_command (sensor_cfg *cfg, uint8_t rail, uint16_t *millivolt)
 
bool mp29816a_set_vout_command (sensor_cfg *cfg, uint8_t rail, uint16_t *millivolt)
 
bool mp29816a_get_vr_status (sensor_cfg *cfg, uint8_t rail, uint8_t vr_status_rail, uint16_t *vr_status)
 
bool mp29816a_clear_vr_status (sensor_cfg *cfg, uint8_t rail)
 
bool mp29816a_get_vout_offset (sensor_cfg *cfg, uint16_t *vout_offset)
 
bool mp29816a_set_vout_offset (sensor_cfg *cfg, uint16_t *write_vout_offset)
 
bool mp29816a_get_uvp (sensor_cfg *cfg, uint16_t *uvp)
 
bool mp29816a_set_uvp_threshold (sensor_cfg *cfg, uint16_t *write_uvp_threshold)
 
float get_iout_scale_bit_a (sensor_cfg *cfg)
 
bool mp29816a_get_total_ocp (sensor_cfg *cfg, uint16_t *total_ocp)
 
bool mp29816a_set_total_ocp (sensor_cfg *cfg, uint16_t *write_total_ocp)
 
bool mp29816a_get_ovp_1 (sensor_cfg *cfg, uint16_t *ovp_1)
 
bool mp29816a_set_ovp_1 (sensor_cfg *cfg, uint16_t *write_ovp_1)
 
bool mp29816a_get_ovp_2_action (sensor_cfg *cfg, uint16_t *ovp_2_action)
 
bool mp29816a_set_ovp_2_action (sensor_cfg *cfg, uint16_t *write_ovp_2_action)
 
bool mp29816a_get_ovp_2 (sensor_cfg *cfg, uint16_t *ovp_2)
 
uint8_t mp29816a_read (sensor_cfg *cfg, int *reading)
 
uint8_t mp29816a_init (sensor_cfg *cfg)
 

Macro Definition Documentation

◆ IOUT_OCP_MASK

#define IOUT_OCP_MASK   GENMASK(7, 0)

◆ IOUT_SCALE_BIT_A_MASK

#define IOUT_SCALE_BIT_A_MASK   GENMASK(2, 0)

◆ MAX_CFG_LEN

#define MAX_CFG_LEN   1024

◆ MFR_VDIFF_GAIN_HALF_R2_BIT

#define MFR_VDIFF_GAIN_HALF_R2_BIT   BIT(10)

◆ MFR_VID_RES_MASK

#define MFR_VID_RES_MASK   GENMASK(12, 10)

◆ MFR_VOUT_LOOP_CTRL

#define MFR_VOUT_LOOP_CTRL   0x8D

◆ MFR_VOUT_SCALE_LOOP

#define MFR_VOUT_SCALE_LOOP   0x29

◆ MP29816A_MAX_READ_BYTES

#define MP29816A_MAX_READ_BYTES   (6 + 1)

◆ MP29816A_SVI3_IOUT_RPT_REG

#define MP29816A_SVI3_IOUT_RPT_REG   0x67

◆ MP29816A_VOUT_MAX_REG

#define MP29816A_VOUT_MAX_REG   0x24

◆ MP29816A_VOUT_MIN_REG

#define MP29816A_VOUT_MIN_REG   0x2B

◆ OVP_1_ABS_MASK

#define OVP_1_ABS_MASK   GENMASK(8, 0)

◆ OVP_2_ACTION_MASK

#define OVP_2_ACTION_MASK   GENMASK(7, 6)

◆ OVP_2_THRESHOLD_MASK

#define OVP_2_THRESHOLD_MASK   GENMASK(12, 9)

◆ READ_VOUT_MASK

#define READ_VOUT_MASK   GENMASK(11, 0)

◆ UVP_THRESHOLD_MASK

#define UVP_THRESHOLD_MASK   GENMASK(8, 0)

◆ UVP_THRESHOLD_MFR_UVP_DELTA_R1

#define UVP_THRESHOLD_MFR_UVP_DELTA_R1   GENMASK(12, 9)

◆ VR_MPS_PAGE_0

#define VR_MPS_PAGE_0   0x00

◆ VR_MPS_PAGE_1

#define VR_MPS_PAGE_1   0x01

◆ VR_REG_EXPECTED_USER_CRC

#define VR_REG_EXPECTED_USER_CRC   0xED

Enumeration Type Documentation

◆ CFG_PARAM_IDX

Enumerator
CFG_PARAM_IDX_PAGE 
CFG_PARAM_IDX_REG_ADDR 
CFG_PARAM_IDX_REG_NAME 
CFG_PARAM_IDX_REG_VAL 
CFG_PARAM_IDX_REG_LEN 

Function Documentation

◆ get_iout_scale_bit_a()

float get_iout_scale_bit_a ( sensor_cfg cfg)
Here is the call graph for this function:

◆ LOG_MODULE_REGISTER()

LOG_MODULE_REGISTER ( mp29816a  )

◆ mp29816a_clear_vr_status()

bool mp29816a_clear_vr_status ( sensor_cfg cfg,
uint8_t  rail 
)
Here is the call graph for this function:

◆ mp29816a_fwupdate()

bool mp29816a_fwupdate ( uint8_t  bus,
uint8_t  addr,
uint8_t *  img_buff,
uint32_t  img_size 
)

◆ mp29816a_get_fw_version()

bool mp29816a_get_fw_version ( uint8_t  bus,
uint8_t  addr,
uint32_t *  rev 
)
Here is the call graph for this function:

◆ mp29816a_get_iout_oc_warn_limit()

bool mp29816a_get_iout_oc_warn_limit ( sensor_cfg cfg,
uint16_t *  value 
)
Here is the call graph for this function:

◆ mp29816a_get_ovp_1()

bool mp29816a_get_ovp_1 ( sensor_cfg cfg,
uint16_t *  ovp_1 
)
Here is the call graph for this function:

◆ mp29816a_get_ovp_2()

bool mp29816a_get_ovp_2 ( sensor_cfg cfg,
uint16_t *  ovp_2 
)
Here is the call graph for this function:

◆ mp29816a_get_ovp_2_action()

bool mp29816a_get_ovp_2_action ( sensor_cfg cfg,
uint16_t *  ovp_2_action 
)
Here is the call graph for this function:

◆ mp29816a_get_resolution()

float mp29816a_get_resolution ( sensor_cfg cfg,
bool  is_vout_max_or_min 
)
Here is the call graph for this function:

◆ mp29816a_get_total_ocp()

bool mp29816a_get_total_ocp ( sensor_cfg cfg,
uint16_t *  total_ocp 
)
Here is the call graph for this function:

◆ mp29816a_get_uvp()

bool mp29816a_get_uvp ( sensor_cfg cfg,
uint16_t *  uvp 
)
Here is the call graph for this function:

◆ mp29816a_get_vout_command()

bool mp29816a_get_vout_command ( sensor_cfg cfg,
uint8_t  rail,
uint16_t *  millivolt 
)
Here is the call graph for this function:

◆ mp29816a_get_vout_max()

bool mp29816a_get_vout_max ( sensor_cfg cfg,
uint8_t  rail,
uint16_t *  millivolt 
)
Here is the call graph for this function:

◆ mp29816a_get_vout_min()

bool mp29816a_get_vout_min ( sensor_cfg cfg,
uint8_t  rail,
uint16_t *  millivolt 
)
Here is the call graph for this function:

◆ mp29816a_get_vout_offset()

bool mp29816a_get_vout_offset ( sensor_cfg cfg,
uint16_t *  vout_offset 
)
Here is the call graph for this function:

◆ mp29816a_get_vr_status()

bool mp29816a_get_vr_status ( sensor_cfg cfg,
uint8_t  rail,
uint8_t  vr_status_rail,
uint16_t *  vr_status 
)
Here is the call graph for this function:

◆ mp29816a_i2c_read()

bool mp29816a_i2c_read ( uint8_t  bus,
uint8_t  addr,
uint8_t  reg,
uint8_t *  data,
uint8_t  len 
)
Here is the call graph for this function:

◆ mp29816a_i2c_write()

bool mp29816a_i2c_write ( uint8_t  bus,
uint8_t  addr,
uint8_t  reg,
uint8_t *  data,
uint8_t  len 
)
Here is the call graph for this function:

◆ mp29816a_init()

uint8_t mp29816a_init ( sensor_cfg cfg)
Here is the call graph for this function:

◆ mp29816a_read()

uint8_t mp29816a_read ( sensor_cfg cfg,
int *  reading 
)
Here is the call graph for this function:

◆ mp29816a_set_iout_oc_warn_limit()

bool mp29816a_set_iout_oc_warn_limit ( sensor_cfg cfg,
uint16_t  value 
)
Here is the call graph for this function:

◆ mp29816a_set_ovp_1()

bool mp29816a_set_ovp_1 ( sensor_cfg cfg,
uint16_t *  write_ovp_1 
)
Here is the call graph for this function:

◆ mp29816a_set_ovp_2_action()

bool mp29816a_set_ovp_2_action ( sensor_cfg cfg,
uint16_t *  write_ovp_2_action 
)
Here is the call graph for this function:

◆ mp29816a_set_page()

bool mp29816a_set_page ( uint8_t  bus,
uint8_t  addr,
uint8_t  page 
)
Here is the call graph for this function:

◆ mp29816a_set_total_ocp()

bool mp29816a_set_total_ocp ( sensor_cfg cfg,
uint16_t *  write_total_ocp 
)
Here is the call graph for this function:

◆ mp29816a_set_uvp_threshold()

bool mp29816a_set_uvp_threshold ( sensor_cfg cfg,
uint16_t *  write_uvp_threshold 
)
Here is the call graph for this function:

◆ mp29816a_set_vout_command()

bool mp29816a_set_vout_command ( sensor_cfg cfg,
uint8_t  rail,
uint16_t *  millivolt 
)
Here is the call graph for this function:

◆ mp29816a_set_vout_max()

bool mp29816a_set_vout_max ( sensor_cfg cfg,
uint8_t  rail,
uint16_t *  millivolt 
)
Here is the call graph for this function:

◆ mp29816a_set_vout_min()

bool mp29816a_set_vout_min ( sensor_cfg cfg,
uint8_t  rail,
uint16_t *  millivolt 
)
Here is the call graph for this function:

◆ mp29816a_set_vout_offset()

bool mp29816a_set_vout_offset ( sensor_cfg cfg,
uint16_t *  write_vout_offset 
)
Here is the call graph for this function:

◆ parsing_line()

uint8_t parsing_line ( char *  str,
uint16_t  len,
struct cfg_data cfg_data 
)