OpenBIC
OpenSource Bridge-IC
plat_hook.c File Reference
#include <stdio.h>
#include <string.h>
#include "libutil.h"
#include "sensor.h"
#include "plat_i2c.h"
#include "plat_gpio.h"
#include "plat_hook.h"
#include "plat_sensor_table.h"
#include "i2c-mux-tca9548.h"
#include "pex89000.h"
#include "pmbus.h"
#include "nvme.h"
#include "plat_pldm_monitor.h"
#include <logging/log.h>
Include dependency graph for plat_hook.c:

Macros

#define ADJUST_MP5990_POWER(x)   ((x * 1.0004) + 6.5116)
 
#define ADJUST_MP5990_CURRENT(x)   ((x * 0.9993) + 0.6114)
 
#define ADJUST_LTC4282_POWER(x)   ((x * 0.9722) - 16.315)
 
#define ADJUST_LTC4282_CURRENT(x)   ((x * 0.9634) - 1.0236)
 
#define ADJUST_LTC4286_POWER(x)   ((x * 0.95) - 8.6)
 
#define ADJUST_LTC4286_CURRENT(x)   ((x * 0.95) - 0.7)
 

Functions

 LOG_MODULE_REGISTER (plat_hook)
 
 K_MUTEX_DEFINE (i2c_bus6_mutex)
 
 K_MUTEX_DEFINE (i2c_bus9_mutex)
 
 K_MUTEX_DEFINE (i2c_bus10_mutex)
 
bool pre_vr_read (sensor_cfg *cfg, void *args)
 
bool pre_pex89000_read (sensor_cfg *cfg, void *args)
 
bool pre_i2c_bus_read (sensor_cfg *cfg, void *args)
 
bool post_i2c_bus_read (sensor_cfg *cfg, void *args, int *reading)
 
bool post_mp5990_read (sensor_cfg *cfg, void *args, int *reading)
 
bool post_ltc4282_read (sensor_cfg *cfg, void *args, int *reading)
 
bool post_ltc4286_read (sensor_cfg *cfg, void *args, int *reading)
 
struct k_mutex * find_bus_mutex (sensor_cfg *cfg)
 
void ssd_drive_reinit (void)
 
bool is_mb_dc_on ()
 
void set_cx7_init_arg_to_thor2 ()
 

Variables

isl28022_init_arg isl28022_nic_sensor_init_args []
 
ina230_init_arg ina230_nic_sensor_init_args []
 
mp5990_init_arg mp5990_hsc_init_args []
 
ltc4282_init_arg ltc4282_hsc_init_args []
 
ltc4286_init_arg ltc4286_hsc_init_args []
 
adc_asd_init_arg ast_adc_init_args []
 
isl28022_init_arg isl28022_pex_p1v25_sensor_init_args []
 
ina230_init_arg ina230_pex_p1v25_sensor_init_args []
 
isl28022_init_arg isl28022_pex_p1v8_sensor_init_args []
 
ina230_init_arg ina230_pex_p1v8_sensor_init_args []
 
isl28022_init_arg isl28022_ssd_sensor_init_args []
 
ina230_init_arg ina230_ssd_sensor_init_args []
 
pex89000_init_arg pex_sensor_init_args []
 
nct7718w_init_arg nct7718w_init_args []
 
cx7_init_arg cx7_init_args []
 
struct tca9548 mux_conf_addr_0xe0 []
 
struct tca9548 mux_conf_addr_0xe2 []
 
vr_pre_proc_arg vr_pre_read_args []
 
pex89000_pre_proc_arg pex89000_pre_read_args []
 

Macro Definition Documentation

◆ ADJUST_LTC4282_CURRENT

#define ADJUST_LTC4282_CURRENT (   x)    ((x * 0.9634) - 1.0236)

◆ ADJUST_LTC4282_POWER

#define ADJUST_LTC4282_POWER (   x)    ((x * 0.9722) - 16.315)

◆ ADJUST_LTC4286_CURRENT

#define ADJUST_LTC4286_CURRENT (   x)    ((x * 0.95) - 0.7)

◆ ADJUST_LTC4286_POWER

#define ADJUST_LTC4286_POWER (   x)    ((x * 0.95) - 8.6)

◆ ADJUST_MP5990_CURRENT

#define ADJUST_MP5990_CURRENT (   x)    ((x * 0.9993) + 0.6114)

◆ ADJUST_MP5990_POWER

#define ADJUST_MP5990_POWER (   x)    ((x * 1.0004) + 6.5116)

Function Documentation

◆ find_bus_mutex()

struct k_mutex * find_bus_mutex ( sensor_cfg cfg)

◆ is_mb_dc_on()

bool is_mb_dc_on ( )
Here is the call graph for this function:

◆ K_MUTEX_DEFINE() [1/3]

K_MUTEX_DEFINE ( i2c_bus10_mutex  )

◆ K_MUTEX_DEFINE() [2/3]

K_MUTEX_DEFINE ( i2c_bus6_mutex  )

◆ K_MUTEX_DEFINE() [3/3]

K_MUTEX_DEFINE ( i2c_bus9_mutex  )

◆ LOG_MODULE_REGISTER()

LOG_MODULE_REGISTER ( plat_hook  )

◆ post_i2c_bus_read()

bool post_i2c_bus_read ( sensor_cfg cfg,
void *  args,
int *  reading 
)

Because BUS9 has two mux behind 16 E1.S with the same i2c address, so close all mux channels after the sensor read to avoid conflict with other devices reading.

Here is the call graph for this function:

◆ post_ltc4282_read()

bool post_ltc4282_read ( sensor_cfg cfg,
void *  args,
int *  reading 
)
Here is the call graph for this function:

◆ post_ltc4286_read()

bool post_ltc4286_read ( sensor_cfg cfg,
void *  args,
int *  reading 
)
Here is the call graph for this function:

◆ post_mp5990_read()

bool post_mp5990_read ( sensor_cfg cfg,
void *  args,
int *  reading 
)
Here is the call graph for this function:

◆ pre_i2c_bus_read()

bool pre_i2c_bus_read ( sensor_cfg cfg,
void *  args 
)
Here is the call graph for this function:

◆ pre_pex89000_read()

bool pre_pex89000_read ( sensor_cfg cfg,
void *  args 
)
Here is the call graph for this function:

◆ pre_vr_read()

bool pre_vr_read ( sensor_cfg cfg,
void *  args 
)
Here is the call graph for this function:

◆ set_cx7_init_arg_to_thor2()

void set_cx7_init_arg_to_thor2 ( )

◆ ssd_drive_reinit()

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

Variable Documentation

◆ ast_adc_init_args

adc_asd_init_arg ast_adc_init_args[]
Initial value:
= {
[0] = { .is_init = false,
.deglitch[0] = { .deglitch_en = true, .upper_bound = 0x248 },
.deglitch[1] = { .deglitch_en = true, .upper_bound = 0x240 },
.deglitch[2] = { .deglitch_en = true, .upper_bound = 0x23E },
.deglitch[3] = { .deglitch_en = true, .upper_bound = 0x208 },
.deglitch[4] = { .deglitch_en = true, .upper_bound = 0x23E },
.deglitch[5] = { .deglitch_en = true, .upper_bound = 0x258 },
.deglitch[6] = { .deglitch_en = true, .upper_bound = 0x258 },
},
[1] = {
.is_init = false,
.deglitch[6] = { .deglitch_en = true, .upper_bound = 0x258 },
.deglitch[7] = { .deglitch_en = true, .upper_bound = 0x258 },
}
}

◆ cx7_init_args

cx7_init_arg cx7_init_args[]
Initial value:
= {
[0] = { .is_init = false, .endpoint = 0x10, .sensor_id = 0x0008 },
[1] = { .is_init = false, .endpoint = 0x11, .sensor_id = 0x0008 },
[2] = { .is_init = false, .endpoint = 0x12, .sensor_id = 0x0008 },
[3] = { .is_init = false, .endpoint = 0x13, .sensor_id = 0x0008 },
[4] = { .is_init = false, .endpoint = 0x14, .sensor_id = 0x0008 },
[5] = { .is_init = false, .endpoint = 0x15, .sensor_id = 0x0008 },
[6] = { .is_init = false, .endpoint = 0x16, .sensor_id = 0x0008 },
[7] = { .is_init = false, .endpoint = 0x17, .sensor_id = 0x0008 },
}

◆ ina230_nic_sensor_init_args

ina230_init_arg ina230_nic_sensor_init_args[]

◆ ina230_pex_p1v25_sensor_init_args

ina230_init_arg ina230_pex_p1v25_sensor_init_args[]

◆ ina230_pex_p1v8_sensor_init_args

ina230_init_arg ina230_pex_p1v8_sensor_init_args[]
Initial value:
= {
[0] = {
.is_init = false,
.config = {
.MODE = 0b111,
.VSH_CT = 0b100,
.VBUS_CT = 0b100,
.AVG = 0b000,
},
.alt_cfg = {
.LEN = 1,
.BOL = 1,
},
.r_shunt = 0.002,
.alert_value = 2.0,
.i_max = 16.384
},
}

◆ ina230_ssd_sensor_init_args

ina230_init_arg ina230_ssd_sensor_init_args[]

◆ isl28022_nic_sensor_init_args

isl28022_init_arg isl28022_nic_sensor_init_args[]

◆ isl28022_pex_p1v25_sensor_init_args

isl28022_init_arg isl28022_pex_p1v25_sensor_init_args[]

◆ isl28022_pex_p1v8_sensor_init_args

isl28022_init_arg isl28022_pex_p1v8_sensor_init_args[]
Initial value:
= {
[0] = { .config.fields.MODE = 0b111,
.config.fields.SADC = 0b1111,
.config.fields.BADC = 0b1111,
.config.fields.PG = 0b00,
.config.fields.BRNG = 0b00,
.aux_control_config.do_config = true,
.aux_control_config.config.fields.INTREN = 1,
.bus_volt_threshold_config.do_config = true,
.bus_volt_threshold_config.max_threshold_limit = 2.048,
.r_shunt = 2,
.is_init = false },
}

◆ isl28022_ssd_sensor_init_args

isl28022_init_arg isl28022_ssd_sensor_init_args[]

◆ ltc4282_hsc_init_args

ltc4282_init_arg ltc4282_hsc_init_args[]
Initial value:
= {
[0] = { .is_init = false,
.r_sense_mohm = 0.142,
.is_register_setting_needed = 0x00,
},
}

◆ ltc4286_hsc_init_args

ltc4286_init_arg ltc4286_hsc_init_args[]
Initial value:
= {
[0] = { .is_init = false, .r_sense_mohm = 0.142, .mfr_config_1 = { 0xFFFF } },
}

◆ mp5990_hsc_init_args

mp5990_init_arg mp5990_hsc_init_args[]
Initial value:
= {
[0] = { .is_init = false,
.iout_cal_gain = 0xFFFF,
.iout_oc_fault_limit = 0xFFFF,
.ocw_sc_ref = 0xFFFF,
},
}

◆ mux_conf_addr_0xe0

struct tca9548 mux_conf_addr_0xe0[]
Initial value:
= {
[0] = { .addr = 0xe0, .chan = 0 }, [1] = { .addr = 0xe0, .chan = 1 },
[2] = { .addr = 0xe0, .chan = 2 }, [3] = { .addr = 0xe0, .chan = 3 },
[4] = { .addr = 0xe0, .chan = 4 }, [5] = { .addr = 0xe0, .chan = 5 },
[6] = { .addr = 0xe0, .chan = 6 }, [7] = { .addr = 0xe0, .chan = 7 },
}

◆ mux_conf_addr_0xe2

struct tca9548 mux_conf_addr_0xe2[]
Initial value:
= {
[0] = { .addr = 0xe2, .chan = 0 }, [1] = { .addr = 0xe2, .chan = 1 },
[2] = { .addr = 0xe2, .chan = 2 }, [3] = { .addr = 0xe2, .chan = 3 },
[4] = { .addr = 0xe2, .chan = 4 }, [5] = { .addr = 0xe2, .chan = 5 },
[6] = { .addr = 0xe2, .chan = 6 }, [7] = { .addr = 0xe2, .chan = 7 },
}

◆ nct7718w_init_args

nct7718w_init_arg nct7718w_init_args[]
Initial value:
= {
[0] = { .is_init = false,
.rt1_high_alert_temp = 0x46,
.rt_filter_alert_mode = 0x00,
.alert_mask = 0x07,
.configuration = 0x85,
.rt1_critical_temperature = 0x65,
.lt_critical_temperature = 0x65 },
}

◆ pex89000_pre_read_args

pex89000_pre_proc_arg pex89000_pre_read_args[]
Initial value:
= {
[0] = { .mux_info_p = &mux_conf_addr_0xe0[0] },
[1] = { .mux_info_p = &mux_conf_addr_0xe0[1] },
[2] = { .mux_info_p = &mux_conf_addr_0xe0[2] },
[3] = { .mux_info_p = &mux_conf_addr_0xe0[3] },
}
struct tca9548 mux_conf_addr_0xe0[]
Definition: plat_hook.c:948

◆ pex_sensor_init_args

pex89000_init_arg pex_sensor_init_args[]
Initial value:
= {
[0] = { .idx = 0, .is_init = false },
[1] = { .idx = 1, .is_init = false },
[2] = { .idx = 2, .is_init = false },
[3] = { .idx = 3, .is_init = false },
}

◆ vr_pre_read_args

vr_pre_proc_arg vr_pre_read_args[]
Initial value:
= {
[0] = { .mux_info_p = &mux_conf_addr_0xe0[6], .vr_page = 0x0 },
[1] = { .mux_info_p = &mux_conf_addr_0xe0[6], .vr_page = 0x1 },
[2] = { .mux_info_p = &mux_conf_addr_0xe0[6], .vr_page = 0x0 },
[3] = { .mux_info_p = &mux_conf_addr_0xe0[6], .vr_page = 0x1 },
}