OpenBIC
OpenSource Bridge-IC
plat_i2c_target.c File Reference
#include <zephyr.h>
#include <stdio.h>
#include <stdlib.h>
#include "plat_i2c_target.h"
#include <logging/log.h>
#include "libutil.h"
#include "plat_pldm_sensor.h"
#include "pldm_sensor.h"
#include "plat_version.h"
#include "plat_class.h"
#include "plat_cpld.h"
#include "plat_hook.h"
#include "plat_i2c.h"
#include "plat_ioexp.h"
Include dependency graph for plat_i2c_target.c:

Macros

#define MAX_TARGET_TABLE_NUM   12
 
#define DATA_TABLE_LENGTH_1   1
 
#define DATA_TABLE_LENGTH_2   2
 
#define DATA_TABLE_LENGTH_4   4
 
#define DEVICE_TYPE   0x01
 
#define REGISTER_LAYOUT_VERSION   0x01
 
#define SENSOR_READING_PDR_INDEX_MAX   50
 
#define SENSOR_INIT_PDR_INDEX_MAX   248
 
#define PLAT_MASTER_WRITE_STACK_SIZE   1024
 
#define AEGIS_CARRIER_BOARD_ID   0x0000
 
#define CPLD_VERSION_GET_REG   0x32
 
#define CPLD_VERSION_GET_REG_LEN   4
 
#define STRAP_SET_TYPE   0x44
 
#define VR_PWR_BUF_SIZE   38
 
#define I2C_TARGET_BUS_ASIC   I2C_BUS7
 

Functions

 LOG_MODULE_REGISTER (plat_i2c_target)
 
void set_bootstrap_element_handler ()
 
 K_WORK_DEFINE (set_bootstrap_element_work, set_bootstrap_element_handler)
 
 K_THREAD_STACK_DEFINE (plat_master_write_stack, PLAT_MASTER_WRITE_STACK_SIZE)
 
void * allocate_table (void **buffer, size_t buffer_size)
 
uint8_t get_vr_rail_by_control_vol_reg (uint8_t control_vol_reg)
 
bool initialize_sensor_data (telemetry_info *telemetry_info, uint8_t *buffer_size)
 
bool initialize_sensor_reading (telemetry_info *telemetry_info, uint8_t *buffer_size)
 
void update_sensor_reading_by_sensor_number (uint8_t sensor_number)
 
int get_cached_sensor_reading_by_sensor_number (uint8_t sensor_number)
 
float get_sensor_reading_cache_as_float (uint8_t sensor_number)
 
bool initialize_inventory_ids (telemetry_info *telemetry_info, uint8_t *buffer_size)
 
bool initialize_strap_capability (telemetry_info *telemetry_info, uint8_t *buffer_size)
 
void update_strap_capability_table ()
 
void plat_pldm_sensor_poll_post ()
 
void set_sensor_polling_handler (struct k_work *work_item)
 
void vr_power_reading (uint8_t *buffer, size_t buf_size)
 
void set_vr_pwr_alert_data (uint8_t controller_id, uint8_t alert_level, uint8_t data_type, uint8_t write_data_lsb, uint8_t write_data_msb)
 
void get_vr_pwr_alert_data (uint8_t *buffer, size_t buf_size, uint8_t data_type, uint8_t alert_level, uint8_t controller_id)
 
bool set_bootstrap_element (uint8_t bootstrap_pin, uint8_t user_setting_level)
 
void i2c_bridge_command_handler (struct k_work *work_item)
 
void set_control_voltage_handler (struct k_work *work_item)
 
void plat_master_write_thread_handler ()
 
void plat_master_write_thread_init ()
 
void plat_telemetry_table_init (void)
 

Variables

struct k_thread plat_master_write_thread
 
k_tid_t plat_master_write_tid
 
struct i2c_target_datatest_for_reading = NULL
 
const bool I2C_TARGET_ENABLE_TABLE [MAX_TARGET_NUM]
 
voltage_rail_mapping_sensor voltage_rail_mapping_table []
 
plat_sensor_init_datasensor_init_data_table [DATA_TABLE_LENGTH_2] = { NULL }
 
plat_sensor_readingsensor_reading_table [DATA_TABLE_LENGTH_4] = { NULL }
 
plat_inventory_idsinventory_ids_table [DATA_TABLE_LENGTH_1] = { NULL }
 
plat_strap_capabilitystrap_capability_table [DATA_TABLE_LENGTH_1] = { NULL }
 
plat_i2c_bridge_command_statusi2c_bridge_command_status_table [DATA_TABLE_LENGTH_1] = { NULL }
 
plat_i2c_bridge_command_response_datai2c_bridge_command_response_data_table [DATA_TABLE_LENGTH_1] = { NULL }
 
uint8_t vr_pwr_sensor_table []
 
vr_controller_t vr_alert_all [VR_PWR_CONTROLLER_MAX] = { 0 }
 
telemetry_info telemetry_info_table []
 
const struct _i2c_target_config I2C_TARGET_CONFIG_TABLE [MAX_TARGET_NUM]
 
uint8_t vr_pwr_alert_table []
 

Macro Definition Documentation

◆ AEGIS_CARRIER_BOARD_ID

#define AEGIS_CARRIER_BOARD_ID   0x0000

◆ CPLD_VERSION_GET_REG

#define CPLD_VERSION_GET_REG   0x32

◆ CPLD_VERSION_GET_REG_LEN

#define CPLD_VERSION_GET_REG_LEN   4

◆ DATA_TABLE_LENGTH_1

#define DATA_TABLE_LENGTH_1   1

◆ DATA_TABLE_LENGTH_2

#define DATA_TABLE_LENGTH_2   2

◆ DATA_TABLE_LENGTH_4

#define DATA_TABLE_LENGTH_4   4

◆ DEVICE_TYPE

#define DEVICE_TYPE   0x01

◆ I2C_TARGET_BUS_ASIC

#define I2C_TARGET_BUS_ASIC   I2C_BUS7

◆ MAX_TARGET_TABLE_NUM

#define MAX_TARGET_TABLE_NUM   12

◆ PLAT_MASTER_WRITE_STACK_SIZE

#define PLAT_MASTER_WRITE_STACK_SIZE   1024

◆ REGISTER_LAYOUT_VERSION

#define REGISTER_LAYOUT_VERSION   0x01

◆ SENSOR_INIT_PDR_INDEX_MAX

#define SENSOR_INIT_PDR_INDEX_MAX   248

◆ SENSOR_READING_PDR_INDEX_MAX

#define SENSOR_READING_PDR_INDEX_MAX   50

◆ STRAP_SET_TYPE

#define STRAP_SET_TYPE   0x44

◆ VR_PWR_BUF_SIZE

#define VR_PWR_BUF_SIZE   38

Function Documentation

◆ allocate_table()

void * allocate_table ( void **  buffer,
size_t  buffer_size 
)

◆ get_cached_sensor_reading_by_sensor_number()

int get_cached_sensor_reading_by_sensor_number ( uint8_t  sensor_number)

◆ get_sensor_reading_cache_as_float()

float get_sensor_reading_cache_as_float ( uint8_t  sensor_number)
Here is the call graph for this function:

◆ get_vr_pwr_alert_data()

void get_vr_pwr_alert_data ( uint8_t *  buffer,
size_t  buf_size,
uint8_t  data_type,
uint8_t  alert_level,
uint8_t  controller_id 
)

◆ get_vr_rail_by_control_vol_reg()

uint8_t get_vr_rail_by_control_vol_reg ( uint8_t  control_vol_reg)

◆ i2c_bridge_command_handler()

void i2c_bridge_command_handler ( struct k_work *  work_item)
Here is the call graph for this function:

◆ initialize_inventory_ids()

bool initialize_inventory_ids ( telemetry_info telemetry_info,
uint8_t *  buffer_size 
)
Here is the call graph for this function:

◆ initialize_sensor_data()

bool initialize_sensor_data ( telemetry_info telemetry_info,
uint8_t *  buffer_size 
)
Here is the call graph for this function:

◆ initialize_sensor_reading()

bool initialize_sensor_reading ( telemetry_info telemetry_info,
uint8_t *  buffer_size 
)
Here is the call graph for this function:

◆ initialize_strap_capability()

bool initialize_strap_capability ( telemetry_info telemetry_info,
uint8_t *  buffer_size 
)
Here is the call graph for this function:

◆ K_THREAD_STACK_DEFINE()

K_THREAD_STACK_DEFINE ( plat_master_write_stack  ,
PLAT_MASTER_WRITE_STACK_SIZE   
)

◆ K_WORK_DEFINE()

K_WORK_DEFINE ( set_bootstrap_element_work  ,
set_bootstrap_element_handler   
)

◆ LOG_MODULE_REGISTER()

LOG_MODULE_REGISTER ( plat_i2c_target  )

◆ plat_master_write_thread_handler()

void plat_master_write_thread_handler ( )
Here is the call graph for this function:

◆ plat_master_write_thread_init()

void plat_master_write_thread_init ( )
Here is the call graph for this function:

◆ plat_pldm_sensor_poll_post()

void plat_pldm_sensor_poll_post ( )
Here is the call graph for this function:

◆ plat_telemetry_table_init()

void plat_telemetry_table_init ( void  )
Here is the call graph for this function:

◆ set_bootstrap_element()

bool set_bootstrap_element ( uint8_t  bootstrap_pin,
uint8_t  user_setting_level 
)

◆ set_bootstrap_element_handler()

void set_bootstrap_element_handler ( )

◆ set_control_voltage_handler()

void set_control_voltage_handler ( struct k_work *  work_item)
Here is the call graph for this function:

◆ set_sensor_polling_handler()

void set_sensor_polling_handler ( struct k_work *  work_item)
Here is the call graph for this function:

◆ set_vr_pwr_alert_data()

void set_vr_pwr_alert_data ( uint8_t  controller_id,
uint8_t  alert_level,
uint8_t  data_type,
uint8_t  write_data_lsb,
uint8_t  write_data_msb 
)

◆ update_sensor_reading_by_sensor_number()

void update_sensor_reading_by_sensor_number ( uint8_t  sensor_number)
Here is the call graph for this function:

◆ update_strap_capability_table()

void update_strap_capability_table ( void  )
Here is the call graph for this function:

◆ vr_power_reading()

void vr_power_reading ( uint8_t *  buffer,
size_t  buf_size 
)
Here is the call graph for this function:

Variable Documentation

◆ i2c_bridge_command_response_data_table

plat_i2c_bridge_command_response_data* i2c_bridge_command_response_data_table[DATA_TABLE_LENGTH_1] = { NULL }

◆ i2c_bridge_command_status_table

plat_i2c_bridge_command_status* i2c_bridge_command_status_table[DATA_TABLE_LENGTH_1] = { NULL }

◆ I2C_TARGET_CONFIG_TABLE

const struct _i2c_target_config I2C_TARGET_CONFIG_TABLE[MAX_TARGET_NUM]
Initial value:
= {
{ 0xFF, 0xA },
{ 0xFF, 0xA },
{ 0xFF, 0xA },
{ 0xFF, 0xA },
{ 0xFF, 0xA },
{ 0x42, 0xA },
{ 0x40, 0xA, command_reply_data_handle },
{ 0xFF, 0xA },
{ 0xFF, 0xA },
{ 0xFF, 0xA },
{ 0xFF, 0xA },
{ 0xFF, 0xA },
}

◆ I2C_TARGET_ENABLE_TABLE

const bool I2C_TARGET_ENABLE_TABLE[MAX_TARGET_NUM]
Initial value:
= {
}
#define TARGET_DISABLE
Definition: plat_i2c_target.h:24
#define TARGET_ENABLE
Definition: plat_i2c_target.h:23

◆ inventory_ids_table

plat_inventory_ids* inventory_ids_table[DATA_TABLE_LENGTH_1] = { NULL }

◆ plat_master_write_thread

struct k_thread plat_master_write_thread

◆ plat_master_write_tid

k_tid_t plat_master_write_tid

◆ sensor_init_data_table

plat_sensor_init_data* sensor_init_data_table[DATA_TABLE_LENGTH_2] = { NULL }

◆ sensor_reading_table

plat_sensor_reading* sensor_reading_table[DATA_TABLE_LENGTH_4] = { NULL }

◆ strap_capability_table

plat_strap_capability* strap_capability_table[DATA_TABLE_LENGTH_1] = { NULL }

◆ telemetry_info_table

telemetry_info telemetry_info_table[]
Initial value:
= {
{ SENSOR_INIT_DATA_0_REG, 0x00, .telemetry_table_init = initialize_sensor_data },
{ SENSOR_INIT_DATA_1_REG, 0x00, .telemetry_table_init = initialize_sensor_data },
{ SENSOR_READING_0_REG, 0x00, .telemetry_table_init = initialize_sensor_reading },
{ SENSOR_READING_1_REG, 0x00, .telemetry_table_init = initialize_sensor_reading },
{ SENSOR_READING_2_REG, 0x00, .telemetry_table_init = initialize_sensor_reading },
{ SENSOR_READING_3_REG, 0x00, .telemetry_table_init = initialize_sensor_reading },
{ INVENTORY_IDS_REG, 0x00, .telemetry_table_init = initialize_inventory_ids },
{ STRAP_CAPABILTITY_REG, 0x00, .telemetry_table_init = initialize_strap_capability },
}
bool initialize_strap_capability(telemetry_info *telemetry_info, uint8_t *buffer_size)
Definition: plat_i2c_target.c:562
bool initialize_sensor_data(telemetry_info *telemetry_info, uint8_t *buffer_size)
Definition: plat_i2c_target.c:461
bool initialize_inventory_ids(telemetry_info *telemetry_info, uint8_t *buffer_size)
Definition: plat_i2c_target.c:529
bool initialize_sensor_reading(telemetry_info *telemetry_info, uint8_t *buffer_size)
Definition: plat_i2c_target.c:495
#define WRITE_STRAP_PIN_VALUE_REG
Definition: plat_i2c_target.h:37
#define I2C_BRIDGE_COMMAND_REG
Definition: plat_i2c_target.h:39
#define SENSOR_INIT_DATA_0_REG
Definition: plat_i2c_target.h:28
#define INVENTORY_IDS_REG
Definition: plat_i2c_target.h:34
#define STRAP_CAPABILTITY_REG
Definition: plat_i2c_target.h:36
#define SENSOR_INIT_DATA_1_REG
Definition: plat_i2c_target.h:29
#define SENSOR_READING_3_REG
Definition: plat_i2c_target.h:33
#define I2C_BRIDGE_COMMAND_STATUS_REG
Definition: plat_i2c_target.h:40
#define SENSOR_READING_1_REG
Definition: plat_i2c_target.h:31
#define I2C_BRIDGE_COMMAND_RESPONSE_REG
Definition: plat_i2c_target.h:41
#define SENSOR_READING_2_REG
Definition: plat_i2c_target.h:32
#define SENSOR_READING_0_REG
Definition: plat_i2c_target.h:30
#define LEVEL_1_2_3_PWR_ALERT_THRESHOLD_REG
Definition: plat_i2c_target.h:49
#define LEVEL_1_2_3_PWR_ALERT_TIME_WINDOW_REG
Definition: plat_i2c_target.h:50
#define VR_POWER_READING_REG
Definition: plat_i2c_target.h:51

◆ test_for_reading

struct i2c_target_data* test_for_reading = NULL

◆ voltage_rail_mapping_table

voltage_rail_mapping_sensor voltage_rail_mapping_table[]
Initial value:
= {
}
@ VR_RAIL_E_ASIC_P0V4_VDDQL_HBM0246
Definition: plat_hook.h:61
@ VR_RAIL_E_ASIC_P0V75_VDDPHY_HBM1357
Definition: plat_hook.h:50
@ VR_RAIL_E_ASIC_P1V8_VPP_HBM0246
Definition: plat_hook.h:60
@ VR_RAIL_E_ASIC_P0V4_VDDQL_HBM1357
Definition: plat_hook.h:52
@ VR_RAIL_E_ASIC_P1V8_VPP_HBM1357
Definition: plat_hook.h:54
@ VR_RAIL_E_ASIC_P0V85_MEDHA0_VDD
Definition: plat_hook.h:45
@ VR_RAIL_E_ASIC_P0V75_VDDPHY_HBM0246
Definition: plat_hook.h:62
@ VR_RAIL_E_ASIC_P1V1_VDDQC_HBM1357
Definition: plat_hook.h:53
@ VR_RAIL_E_ASIC_P0V85_MEDHA1_VDD
Definition: plat_hook.h:46
@ VR_RAIL_E_ASIC_P1V1_VDDQC_HBM0246
Definition: plat_hook.h:59
#define CONTROL_VOL_VR_ASIC_P1V8_VPP_HBM1357_REG
Definition: plat_i2c_target.h:46
#define CONTROL_VOL_VR_ASIC_P0V75_VDDPHY_HBM0246_REG
Definition: plat_i2c_target.h:39
#define CONTROL_VOL_VR_ASIC_P0V4_VDDQL_HBM0246_REG
Definition: plat_i2c_target.h:43
#define CONTROL_VOL_VR_ASIC_P1V8_VPP_HBM0246_REG
Definition: plat_i2c_target.h:45
#define CONTROL_VOL_VR_ASIC_P0V4_VDDQL_HBM1357_REG
Definition: plat_i2c_target.h:44
#define CONTROL_VOL_VR_ASIC_P1V1_VDDQC_HBM0246_REG
Definition: plat_i2c_target.h:41
#define CONTROL_VOL_VR_ASIC_P0V75_VDDPHY_HBM1357_REG
Definition: plat_i2c_target.h:40
#define CONTROL_VOL_VR_ASIC_P0V85_MEDHA0_VDD_REG
Definition: plat_i2c_target.h:47
#define CONTROL_VOL_VR_ASIC_P0V85_MEDHA1_VDD_REG
Definition: plat_i2c_target.h:48
#define CONTROL_VOL_VR_ASIC_P1V1_VDDQC_HBM1357_REG
Definition: plat_i2c_target.h:42

◆ vr_alert_all

vr_controller_t vr_alert_all[VR_PWR_CONTROLLER_MAX] = { 0 }

◆ vr_pwr_alert_table

uint8_t vr_pwr_alert_table[]
Initial value:
= {
}
#define SENSOR_NUM_ASIC_P0V85_MEDHA1_VDD_PWR_W
Definition: plat_pldm_sensor.h:164
#define SENSOR_NUM_ASIC_P0V85_MEDHA0_VDD_PWR_W
Definition: plat_pldm_sensor.h:159
#define SENSOR_NUM_ASIC_P0V75_VDDPHY_HBM1357_PWR_W
Definition: plat_pldm_sensor.h:249
#define SENSOR_NUM_ASIC_P0V75_MAX_S_VDD_PWR_W
Definition: plat_pldm_sensor.h:209
#define SENSOR_NUM_ASIC_P1V1_VDDQC_HBM0246_PWR_W
Definition: plat_pldm_sensor.h:239
#define SENSOR_NUM_ASIC_P0V75_VDDPHY_HBM0246_PWR_W
Definition: plat_pldm_sensor.h:229
#define SENSOR_NUM_ASIC_P0V75_MAX_N_VDD_PWR_W
Definition: plat_pldm_sensor.h:204
#define SENSOR_NUM_ASIC_P1V1_VDDQC_HBM1357_PWR_W
Definition: plat_pldm_sensor.h:259

◆ vr_pwr_sensor_table

uint8_t vr_pwr_sensor_table[]
Initial value:
= {
}
#define SENSOR_NUM_ASIC_P0V75_OWL_E_TRVDD_PWR_W
Definition: plat_pldm_sensor.h:174
#define SENSOR_NUM_ASIC_P1V8_VPP_HBM0246_PWR_W
Definition: plat_pldm_sensor.h:244
#define SENSOR_NUM_ASIC_P1V8_VPP_HBM1357_PWR_W
Definition: plat_pldm_sensor.h:264
#define SENSOR_NUM_P3V3_OSFP_PWR_W
Definition: plat_pldm_sensor.h:281
#define SENSOR_NUM_ASIC_P0V75_MAX_M_VDD_PWR_W
Definition: plat_pldm_sensor.h:199
#define SENSOR_NUM_ASIC_P0V8_HAMSA_AVDD_PCIE_PWR_W
Definition: plat_pldm_sensor.h:214
#define SENSOR_NUM_ASIC_P0V4_VDDQL_HBM1357_PWR_W
Definition: plat_pldm_sensor.h:254
#define SENSOR_NUM_ASIC_P0V4_VDDQL_HBM0246_PWR_W
Definition: plat_pldm_sensor.h:234
#define SENSOR_NUM_ASIC_P0V75_OWL_W_TRVDD_PWR_W
Definition: plat_pldm_sensor.h:189
#define SENSOR_NUM_ASIC_P0V75_OWL_W_VDD_PWR_W
Definition: plat_pldm_sensor.h:194
#define SENSOR_NUM_ASIC_P0V75_OWL_E_VDD_PWR_W
Definition: plat_pldm_sensor.h:179
#define SENSOR_NUM_ASIC_P0V9_OWL_W_TRVDD_PWR_W
Definition: plat_pldm_sensor.h:184
#define SENSOR_NUM_ASIC_P0V85_HAMSA_VDD_PWR_W
Definition: plat_pldm_sensor.h:224
#define SENSOR_NUM_ASIC_P0V9_OWL_E_TRVDD_PWR_W
Definition: plat_pldm_sensor.h:169
#define SENSOR_NUM_ASIC_P1V2_HAMSA_VDDHRXTX_PCIE_PWR_W
Definition: plat_pldm_sensor.h:219