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

Classes

struct  mp289x_data
 
struct  mp289x_config
 

Macros

#define USR_END_KEY   "END"
 
#define CRC_CHECK_START_KEY   "CRC_CHECK_START"
 
#define CRC_CHECK_STOP_KEY   "CRC_CHECK_STOP"
 
#define CRC_USR_KEY   "CRC_P0P1"
 
#define CRC_GP12_KEY   "CRC_M1M2"
 
#define CRC_GP34_KEY   "CRC_M3M4"
 
#define CRC_GP56_KEY   "CRC_M5M6"
 
#define VR_REG_STAT_PMBUS   0x8A
 
#define VR_REG_EN_WR_PROT   0x0F
 
#define VR_REG_MTP_CTRL   0xD0
 
#define VR_REG_STAT_CML   0x7E
 
#define VR_REG_FAULT_CLR   0x03
 
#define VR_REG_MTP_FAULT_CLR   0xFF
 
#define VR_REG_CFG_REV   0x47
 
#define VR_REG_STORE_CFG_ALL   0x15
 
#define VR_REG_STORE_USR   0x17
 
#define VR_REG_CRC_USR   0xF6
 
#define VR_REG_OFFLINE_CTL   0xF3
 
#define VR_REG_STORE_STAT   0x35
 
#define VR_REG_MFR_IMON_DIGI_GAIN   0xD0
 
#define VR_REG_STORE_CFG_GP12   0xF5
 
#define VR_REG_STORE_CFG_GP34   0xF6
 
#define VR_REG_STORE_CFG_GP56   0xF7
 
#define VR_REG_CRC_GP12_HI   0xFE
 
#define VR_REG_CRC_GP12_LO   0xFF
 
#define VR_REG_CRC_GP34_HI   0x7E
 
#define VR_REG_CRC_GP34_LO   0x7F
 
#define VR_REG_CRC_GP56_HI   0xFE
 
#define VR_REG_CRC_GP56_LO   0xFF
 
#define MAX_CMD_LINE   720
 
#define VR_MPS_PAGE_0   0x00
 
#define VR_MPS_PAGE_1   0x01
 
#define VR_MPS_PAGE_3   0x03
 
#define VR_MPS_PAGE_4   0x04
 
#define VR_MPS_PAGE_14   0x14
 
#define VR_MPS_PAGE_24   0x24
 
#define VR_MPS_PAGE_34   0x34
 
#define VR_MPS_PAGE_44   0x44
 
#define VR_MPS_PAGE_54   0x54
 
#define VR_MPS_PAGE_64   0x64
 
#define VR_MPS_PAGE_9E   0x9E
 
#define VR_MPS_PAGE_9F   0x9F
 

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_COL_MAX
}
 
enum  {
  MODE_USR , MODE_MULTI_CFG_12 , MODE_MULTI_CFG_34 , MODE_MULTI_CFG_56 ,
  MODE_MULTI_CFG_ALL
}
 

Functions

 LOG_MODULE_REGISTER (mp289x)
 
bool mp289x_get_fw_version (uint8_t bus, uint8_t addr, uint16_t *rev)
 
bool mp289x_fwupdate (uint8_t bus, uint8_t addr, uint8_t *img_buff, uint32_t img_size)
 
uint8_t mp289x_read (sensor_cfg *cfg, int *reading)
 
uint8_t mp289x_init (sensor_cfg *cfg)
 

Variables

uint8_t total_current_set = 0xFF
 

Macro Definition Documentation

◆ CRC_CHECK_START_KEY

#define CRC_CHECK_START_KEY   "CRC_CHECK_START"

◆ CRC_CHECK_STOP_KEY

#define CRC_CHECK_STOP_KEY   "CRC_CHECK_STOP"

◆ CRC_GP12_KEY

#define CRC_GP12_KEY   "CRC_M1M2"

◆ CRC_GP34_KEY

#define CRC_GP34_KEY   "CRC_M3M4"

◆ CRC_GP56_KEY

#define CRC_GP56_KEY   "CRC_M5M6"

◆ CRC_USR_KEY

#define CRC_USR_KEY   "CRC_P0P1"

◆ MAX_CMD_LINE

#define MAX_CMD_LINE   720

◆ USR_END_KEY

#define USR_END_KEY   "END"

◆ VR_MPS_PAGE_0

#define VR_MPS_PAGE_0   0x00

◆ VR_MPS_PAGE_1

#define VR_MPS_PAGE_1   0x01

◆ VR_MPS_PAGE_14

#define VR_MPS_PAGE_14   0x14

◆ VR_MPS_PAGE_24

#define VR_MPS_PAGE_24   0x24

◆ VR_MPS_PAGE_3

#define VR_MPS_PAGE_3   0x03

◆ VR_MPS_PAGE_34

#define VR_MPS_PAGE_34   0x34

◆ VR_MPS_PAGE_4

#define VR_MPS_PAGE_4   0x04

◆ VR_MPS_PAGE_44

#define VR_MPS_PAGE_44   0x44

◆ VR_MPS_PAGE_54

#define VR_MPS_PAGE_54   0x54

◆ VR_MPS_PAGE_64

#define VR_MPS_PAGE_64   0x64

◆ VR_MPS_PAGE_9E

#define VR_MPS_PAGE_9E   0x9E

◆ VR_MPS_PAGE_9F

#define VR_MPS_PAGE_9F   0x9F

◆ VR_REG_CFG_REV

#define VR_REG_CFG_REV   0x47

◆ VR_REG_CRC_GP12_HI

#define VR_REG_CRC_GP12_HI   0xFE

◆ VR_REG_CRC_GP12_LO

#define VR_REG_CRC_GP12_LO   0xFF

◆ VR_REG_CRC_GP34_HI

#define VR_REG_CRC_GP34_HI   0x7E

◆ VR_REG_CRC_GP34_LO

#define VR_REG_CRC_GP34_LO   0x7F

◆ VR_REG_CRC_GP56_HI

#define VR_REG_CRC_GP56_HI   0xFE

◆ VR_REG_CRC_GP56_LO

#define VR_REG_CRC_GP56_LO   0xFF

◆ VR_REG_CRC_USR

#define VR_REG_CRC_USR   0xF6

◆ VR_REG_EN_WR_PROT

#define VR_REG_EN_WR_PROT   0x0F

◆ VR_REG_FAULT_CLR

#define VR_REG_FAULT_CLR   0x03

◆ VR_REG_MFR_IMON_DIGI_GAIN

#define VR_REG_MFR_IMON_DIGI_GAIN   0xD0

◆ VR_REG_MTP_CTRL

#define VR_REG_MTP_CTRL   0xD0

◆ VR_REG_MTP_FAULT_CLR

#define VR_REG_MTP_FAULT_CLR   0xFF

◆ VR_REG_OFFLINE_CTL

#define VR_REG_OFFLINE_CTL   0xF3

◆ VR_REG_STAT_CML

#define VR_REG_STAT_CML   0x7E

◆ VR_REG_STAT_PMBUS

#define VR_REG_STAT_PMBUS   0x8A

◆ VR_REG_STORE_CFG_ALL

#define VR_REG_STORE_CFG_ALL   0x15

◆ VR_REG_STORE_CFG_GP12

#define VR_REG_STORE_CFG_GP12   0xF5

◆ VR_REG_STORE_CFG_GP34

#define VR_REG_STORE_CFG_GP34   0xF6

◆ VR_REG_STORE_CFG_GP56

#define VR_REG_STORE_CFG_GP56   0xF7

◆ VR_REG_STORE_STAT

#define VR_REG_STORE_STAT   0x35

◆ VR_REG_STORE_USR

#define VR_REG_STORE_USR   0x17

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_COL_MAX 

◆ anonymous enum

anonymous enum
Enumerator
MODE_USR 
MODE_MULTI_CFG_12 
MODE_MULTI_CFG_34 
MODE_MULTI_CFG_56 
MODE_MULTI_CFG_ALL 

Function Documentation

◆ LOG_MODULE_REGISTER()

LOG_MODULE_REGISTER ( mp289x  )

◆ mp289x_fwupdate()

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

◆ mp289x_get_fw_version()

bool mp289x_get_fw_version ( uint8_t  bus,
uint8_t  addr,
uint16_t *  rev 
)

◆ mp289x_init()

uint8_t mp289x_init ( sensor_cfg cfg)

◆ mp289x_read()

uint8_t mp289x_read ( sensor_cfg cfg,
int *  reading 
)

Variable Documentation

◆ total_current_set

uint8_t total_current_set = 0xFF