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 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 MFR_RESO_SET   0xC7
 
#define MP2971_VOUT_SENSE_SET   0x29
 
#define MP2971_VOUT_SCALE_MASK   GENMASK(8, 0)
 
#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 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 (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)
 
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

◆ MP2856_DISABLE_MEM_PROTECT

#define MP2856_DISABLE_MEM_PROTECT   0x00

◆ MP2856_DISABLE_WRITE_PROTECT

#define MP2856_DISABLE_WRITE_PROTECT   0x63

◆ 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

◆ 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 ( 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 
)

◆ 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_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_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_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 
)