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

Classes

struct  mp2856_data
 
struct  mp2856_config
 

Macros

#define VR_MPS_PAGE_0   0x00
 
#define VR_MPS_PAGE_1   0x01
 
#define VR_MPS_PAGE_2   0x02
 
#define VR_MPS_PAGE_29   0x29
 
#define VR_MPS_PAGE_2A   0x2A
 
#define VR_MPS_CMD_STORE_NORMAL_CODE   0xF1
 
#define VR_MPS_REG_MFR_MTP_PMBUS_CTRL   0x4F
 
#define MP2971_MFR_OCP_TOTAL_SET   0x5F
 
#define MP2971_MFR_OVP_SET   0xE5
 
#define MP2971_MFR_UVP_SET   0xE6
 
#define MP2971_MFR_PROTECT_SET   0xC5
 
#define MFR_RESO_SET   0xC7
 
#define MP2971_VOUT_SENSE_SET   0x29
 
#define MP2971_VOUT_SCALE_MASK   GENMASK(8, 0)
 
#define OVP_UVP_MODE_REG   0x61
 
#define OVP2_ACTION_MODE_MASK   GENMASK(15, 14)
 
#define OVP2_ACTION_MODE_SHIFT   14
 
#define VR_MPS_REG_WRITE_PROTECT   0x10
 
#define VR_MPS_REG_MFR_VR_CONFIG2   0x35
 
#define VR_MPS_CMD_STORE_MULTI_CODE   0xF3
 
#define MP2856_DISABLE_WRITE_PROTECT   0x63
 
#define MP2856_DISABLE_MEM_PROTECT   0x00
 
#define VR_MPS_REG_MFR_VR_MULTI_CONFIG_R1   0x0D
 
#define VR_MPS_REG_MFR_VR_MULTI_CONFIG_R2   0x1D
 
#define MFR_VR_CONFIG_IMON_OFFSET_R1   0x0E
 
#define MFR_VR_CONFIG_IMON_OFFSET_R2   0x1E
 
#define MP2971_VOUT_MAX_REG   0x24
 
#define MP2971_VOUT_MIN_REG   0x2B
 
#define VR_MPS_REG_CRC_USER   0xFF
 
#define VR_MPS_REG_MULTI_CONFIG   0xBF
 
#define MASK_PWD_MATCH   0x08
 
#define MASK_WRITE_PROTECT_MODE   0x04
 
#define MASK_MTP_BYTE_RW_EN   0x20
 
#define MAX_CMD_LINE   720
 

Enumerations

enum  {
  ATE_CONF_ID = 0 , ATE_PAGE_NUM , ATE_REG_ADDR_HEX , ATE_REG_ADDR_DEC ,
  ATE_REG_NAME , ATE_REG_DATA_HEX , ATE_REG_DATA_DEC , ATE_WRITE_TYPE ,
  ATE_COL_MAX
}
 
enum  { VR_12 = 1 , VR_13 , IMPV9 }
 

Functions

 LOG_MODULE_REGISTER (mp2971)
 
bool mp2971_vid_to_direct (sensor_cfg *cfg, uint8_t rail, uint16_t *millivolt)
 
bool mp2971_direct_to_vid (sensor_cfg *cfg, uint8_t rail, uint16_t *millivolt)
 
bool mp2971_i2c_read (uint8_t bus, uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len)
 
bool mp2971_i2c_write (uint8_t bus, uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len)
 
bool mp2971_get_vout_max (sensor_cfg *cfg, uint8_t rail, uint16_t *millivolt)
 
bool mp2971_get_vout_min (sensor_cfg *cfg, uint8_t rail, uint16_t *millivolt)
 
bool mp2971_set_vout_max (sensor_cfg *cfg, uint8_t rail, uint16_t *millivolt)
 
bool mp2971_set_vout_min (sensor_cfg *cfg, uint8_t rail, uint16_t *millivolt)
 
bool mp2971_fwupdate (uint8_t bus, uint8_t addr, uint8_t *img_buff, uint32_t img_size)
 
bool mp2971_get_checksum (uint8_t bus, uint8_t addr, uint32_t *checksum)
 
bool get_vout_scale (const sensor_cfg *cfg, float *vout_scale)
 
float get_resolution (sensor_cfg *cfg)
 
bool mp2971_get_vout_command (sensor_cfg *cfg, uint8_t rail, uint16_t *millivolt)
 
bool mp2971_set_vout_command (sensor_cfg *cfg, uint8_t rail, uint16_t *millivolt)
 
bool mp2971_get_vr_status (sensor_cfg *cfg, uint8_t rail, uint8_t vr_status_rail, uint16_t *vr_status)
 
bool mp2971_clear_vr_status (sensor_cfg *cfg, uint8_t rail)
 
bool mp2971_get_vout_offset (sensor_cfg *cfg, uint8_t rail, uint16_t *vout_offset)
 
bool mp2971_get_total_ocp (sensor_cfg *cfg, uint8_t rail, uint16_t *total_ocp)
 
bool mp2971_set_total_ocp (sensor_cfg *cfg, uint8_t rail, uint16_t total_ocp)
 
bool mp2971_set_ovp_1 (sensor_cfg *cfg, uint8_t rail, uint16_t *ovp_1_mv)
 
bool mp2971_get_ovp_1 (sensor_cfg *cfg, uint8_t rail, uint16_t *ovp_1_mv)
 
bool mp2971_set_uvp_threshold (sensor_cfg *cfg, uint8_t rail, uint16_t *write_uvp_threshold)
 
bool mp2971_set_thres_div_en (sensor_cfg *cfg, uint8_t rail, const uint16_t *enable)
 
bool mp2971_get_ovp_2 (sensor_cfg *cfg, uint8_t rail, uint16_t *ovp_2_mv)
 
bool mp2971_get_uvp (sensor_cfg *cfg, uint8_t rail, uint16_t *uvp_mv)
 
bool mp2971_set_ovp2_action_mode (sensor_cfg *cfg, uint8_t rail, uint8_t *mode)
 
bool mp2971_get_ovp2_action_mode (sensor_cfg *cfg, uint8_t rail, uint8_t *mode)
 
uint8_t mp2971_read (sensor_cfg *cfg, int *reading)
 
uint8_t mp2971_init (sensor_cfg *cfg)
 

Macro Definition Documentation

◆ MASK_MTP_BYTE_RW_EN

#define MASK_MTP_BYTE_RW_EN   0x20

◆ MASK_PWD_MATCH

#define MASK_PWD_MATCH   0x08

◆ MASK_WRITE_PROTECT_MODE

#define MASK_WRITE_PROTECT_MODE   0x04

◆ MAX_CMD_LINE

#define MAX_CMD_LINE   720

◆ MFR_RESO_SET

#define MFR_RESO_SET   0xC7

◆ MFR_VR_CONFIG_IMON_OFFSET_R1

#define MFR_VR_CONFIG_IMON_OFFSET_R1   0x0E

◆ MFR_VR_CONFIG_IMON_OFFSET_R2

#define MFR_VR_CONFIG_IMON_OFFSET_R2   0x1E

◆ MP2856_DISABLE_MEM_PROTECT

#define MP2856_DISABLE_MEM_PROTECT   0x00

◆ MP2856_DISABLE_WRITE_PROTECT

#define MP2856_DISABLE_WRITE_PROTECT   0x63

◆ MP2971_MFR_OCP_TOTAL_SET

#define MP2971_MFR_OCP_TOTAL_SET   0x5F

◆ MP2971_MFR_OVP_SET

#define MP2971_MFR_OVP_SET   0xE5

◆ MP2971_MFR_PROTECT_SET

#define MP2971_MFR_PROTECT_SET   0xC5

◆ MP2971_MFR_UVP_SET

#define MP2971_MFR_UVP_SET   0xE6

◆ MP2971_VOUT_MAX_REG

#define MP2971_VOUT_MAX_REG   0x24

◆ MP2971_VOUT_MIN_REG

#define MP2971_VOUT_MIN_REG   0x2B

◆ MP2971_VOUT_SCALE_MASK

#define MP2971_VOUT_SCALE_MASK   GENMASK(8, 0)

◆ MP2971_VOUT_SENSE_SET

#define MP2971_VOUT_SENSE_SET   0x29

◆ OVP2_ACTION_MODE_MASK

#define OVP2_ACTION_MODE_MASK   GENMASK(15, 14)

◆ OVP2_ACTION_MODE_SHIFT

#define OVP2_ACTION_MODE_SHIFT   14

◆ OVP_UVP_MODE_REG

#define OVP_UVP_MODE_REG   0x61

◆ VR_MPS_CMD_STORE_MULTI_CODE

#define VR_MPS_CMD_STORE_MULTI_CODE   0xF3

◆ VR_MPS_CMD_STORE_NORMAL_CODE

#define VR_MPS_CMD_STORE_NORMAL_CODE   0xF1

◆ VR_MPS_PAGE_0

#define VR_MPS_PAGE_0   0x00

◆ VR_MPS_PAGE_1

#define VR_MPS_PAGE_1   0x01

◆ VR_MPS_PAGE_2

#define VR_MPS_PAGE_2   0x02

◆ VR_MPS_PAGE_29

#define VR_MPS_PAGE_29   0x29

◆ VR_MPS_PAGE_2A

#define VR_MPS_PAGE_2A   0x2A

◆ VR_MPS_REG_CRC_USER

#define VR_MPS_REG_CRC_USER   0xFF

◆ VR_MPS_REG_MFR_MTP_PMBUS_CTRL

#define VR_MPS_REG_MFR_MTP_PMBUS_CTRL   0x4F

◆ VR_MPS_REG_MFR_VR_CONFIG2

#define VR_MPS_REG_MFR_VR_CONFIG2   0x35

◆ VR_MPS_REG_MFR_VR_MULTI_CONFIG_R1

#define VR_MPS_REG_MFR_VR_MULTI_CONFIG_R1   0x0D

◆ VR_MPS_REG_MFR_VR_MULTI_CONFIG_R2

#define VR_MPS_REG_MFR_VR_MULTI_CONFIG_R2   0x1D

◆ VR_MPS_REG_MULTI_CONFIG

#define VR_MPS_REG_MULTI_CONFIG   0xBF

◆ VR_MPS_REG_WRITE_PROTECT

#define VR_MPS_REG_WRITE_PROTECT   0x10

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
ATE_CONF_ID 
ATE_PAGE_NUM 
ATE_REG_ADDR_HEX 
ATE_REG_ADDR_DEC 
ATE_REG_NAME 
ATE_REG_DATA_HEX 
ATE_REG_DATA_DEC 
ATE_WRITE_TYPE 
ATE_COL_MAX 

◆ anonymous enum

anonymous enum
Enumerator
VR_12 
VR_13 
IMPV9 

Function Documentation

◆ get_resolution()

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

◆ get_vout_scale()

bool get_vout_scale ( const sensor_cfg cfg,
float *  vout_scale 
)
Here is the call graph for this function:

◆ LOG_MODULE_REGISTER()

LOG_MODULE_REGISTER ( mp2971  )

◆ mp2971_clear_vr_status()

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

◆ mp2971_direct_to_vid()

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

◆ mp2971_fwupdate()

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

◆ mp2971_get_checksum()

bool mp2971_get_checksum ( uint8_t  bus,
uint8_t  addr,
uint32_t *  checksum 
)

◆ mp2971_get_ovp2_action_mode()

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

◆ mp2971_get_ovp_1()

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

◆ mp2971_get_ovp_2()

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

◆ mp2971_get_total_ocp()

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

◆ mp2971_get_uvp()

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

◆ mp2971_get_vout_command()

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

◆ mp2971_get_vout_max()

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

◆ mp2971_get_vout_min()

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

◆ mp2971_get_vout_offset()

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

◆ mp2971_get_vr_status()

bool mp2971_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:

◆ mp2971_i2c_read()

bool mp2971_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:

◆ mp2971_i2c_write()

bool mp2971_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:

◆ mp2971_init()

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

◆ mp2971_read()

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

◆ mp2971_set_ovp2_action_mode()

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

◆ mp2971_set_ovp_1()

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

◆ mp2971_set_thres_div_en()

bool mp2971_set_thres_div_en ( sensor_cfg cfg,
uint8_t  rail,
const uint16_t *  enable 
)

◆ mp2971_set_total_ocp()

bool mp2971_set_total_ocp ( sensor_cfg cfg,
uint8_t  rail,
uint16_t  total_ocp 
)

◆ mp2971_set_uvp_threshold()

bool mp2971_set_uvp_threshold ( sensor_cfg cfg,
uint8_t  rail,
uint16_t *  write_uvp_threshold 
)

◆ mp2971_set_vout_command()

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

◆ mp2971_set_vout_max()

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

◆ mp2971_set_vout_min()

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

◆ mp2971_vid_to_direct()

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