OpenBIC
OpenSource Bridge-IC
sensor.c File Reference
#include "sensor.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <logging/log.h>
#include "power_status.h"
#include "sdr.h"
#include "pdr.h"
#include "hal_i2c.h"
#include "plat_sensor_table.h"
#include "plat_sdr_table.h"
#include "ast_adc.h"
#include "intel_peci.h"
#include "util_sys.h"
#include "plat_def.h"
#include "libutil.h"
Include dependency graph for sensor.c:

Macros

#define SENSOR_DRIVE_INIT_DECLARE(name)   uint8_t name##_init(sensor_cfg *cfg)
 
#define SENSOR_DRIVE_TYPE_INIT_MAP(name)   { sensor_dev_##name, name##_init }
 
#define SENSOR_DRIVE_TYPE_UNUSE(name)   { sensor_dev_##name, NULL }
 
#define SENSOR_READ_RETRY_MAX   3
 

Functions

 LOG_MODULE_REGISTER (sensor)
 
 K_KERNEL_STACK_MEMBER (sensor_poll_stack, SENSOR_POLL_STACK_SIZE)
 
 SENSOR_DRIVE_INIT_DECLARE (tmp75)
 
 SENSOR_DRIVE_INIT_DECLARE (ast_adc)
 
 SENSOR_DRIVE_INIT_DECLARE (isl69259)
 
 SENSOR_DRIVE_INIT_DECLARE (nvme)
 
 SENSOR_DRIVE_INIT_DECLARE (mp5990)
 
 SENSOR_DRIVE_INIT_DECLARE (isl28022)
 
 SENSOR_DRIVE_INIT_DECLARE (pex89000)
 
 SENSOR_DRIVE_INIT_DECLARE (intel_peci)
 
 SENSOR_DRIVE_INIT_DECLARE (pch)
 
 SENSOR_DRIVE_INIT_DECLARE (adm1278)
 
 SENSOR_DRIVE_INIT_DECLARE (tps53689)
 
 SENSOR_DRIVE_INIT_DECLARE (xdpe15284)
 
 SENSOR_DRIVE_INIT_DECLARE (ltc4282)
 
 SENSOR_DRIVE_INIT_DECLARE (tmp431)
 
 SENSOR_DRIVE_INIT_DECLARE (pmic)
 
 SENSOR_DRIVE_INIT_DECLARE (ina233)
 
 SENSOR_DRIVE_INIT_DECLARE (isl69254iraz_t)
 
 SENSOR_DRIVE_INIT_DECLARE (max16550a)
 
 SENSOR_DRIVE_INIT_DECLARE (ina230)
 
 SENSOR_DRIVE_INIT_DECLARE (xdpe12284c)
 
 SENSOR_DRIVE_INIT_DECLARE (raa229621)
 
 SENSOR_DRIVE_INIT_DECLARE (nct7718w)
 
 SENSOR_DRIVE_INIT_DECLARE (ltc4286)
 
 SENSOR_DRIVE_INIT_DECLARE (xdpe19283b)
 
 SENSOR_DRIVE_INIT_DECLARE (g788p81u)
 
 SENSOR_DRIVE_INIT_DECLARE (mp2856gut)
 
 SENSOR_DRIVE_INIT_DECLARE (ddr5_power)
 
 SENSOR_DRIVE_INIT_DECLARE (ddr5_temp)
 
 SENSOR_DRIVE_INIT_DECLARE (adm1272)
 
 SENSOR_DRIVE_INIT_DECLARE (q50sn120a1)
 
 SENSOR_DRIVE_INIT_DECLARE (mp2971)
 
 SENSOR_DRIVE_INIT_DECLARE (ltc2991)
 
 SENSOR_DRIVE_INIT_DECLARE (sq52205)
 
 SENSOR_DRIVE_INIT_DECLARE (emc1412)
 
 SENSOR_DRIVE_INIT_DECLARE (i3c_dimm)
 
 SENSOR_DRIVE_INIT_DECLARE (pt5161l)
 
 SENSOR_DRIVE_INIT_DECLARE (lm75bd118)
 
 SENSOR_DRIVE_INIT_DECLARE (tmp461)
 
 SENSOR_DRIVE_INIT_DECLARE (mp2985)
 
 SENSOR_DRIVE_INIT_DECLARE (m88rt51632)
 
 SENSOR_DRIVE_INIT_DECLARE (bmr351)
 
 SENSOR_DRIVE_INIT_DECLARE (cx7)
 
 SENSOR_DRIVE_INIT_DECLARE (max11617)
 
 SENSOR_DRIVE_INIT_DECLARE (nct7363)
 
 SENSOR_DRIVE_INIT_DECLARE (ads112c)
 
 SENSOR_DRIVE_INIT_DECLARE (hdc1080)
 
 SENSOR_DRIVE_INIT_DECLARE (ina238)
 
 SENSOR_DRIVE_INIT_DECLARE (nct214)
 
 SENSOR_DRIVE_INIT_DECLARE (ast_tach)
 
 SENSOR_DRIVE_INIT_DECLARE (xdp710)
 
 SENSOR_DRIVE_INIT_DECLARE (adc128d818)
 
 SENSOR_DRIVE_INIT_DECLARE (bmr4922302_803)
 
void map_sensor_num_to_sdr_cfg (void)
 
__weak sensor_cfgget_common_sensor_cfg_info (uint8_t sensor_num)
 
sensor_cfgfind_sensor_cfg_via_sensor_num (sensor_cfg *cfg_table, uint8_t cfg_count, uint8_t sensor_num)
 
bool access_check (uint8_t sensor_num)
 
void clear_unaccessible_sensor_cache (sensor_cfg *cfg)
 
uint8_t get_sensor_reading (sensor_cfg *cfg_table, uint8_t cfg_count, uint8_t sensor_num, int *reading, uint8_t read_mode)
 
void disable_sensor_poll ()
 
void enable_sensor_poll ()
 
bool get_sensor_poll_enable_flag ()
 
__weak void plat_sensor_poll_post ()
 
void sensor_poll_handler (void *arug0, void *arug1, void *arug2)
 
__weak bool pal_is_time_to_poll (uint8_t sensor_num, int poll_time)
 
__weak void pal_set_sensor_poll_interval (int *interval_ms)
 
__weak void pal_extend_sensor_config (void)
 
__weak uint8_t pal_get_extend_sdr ()
 
__weak uint8_t pal_get_extend_sensor_config ()
 
__weak uint8_t pal_get_monitor_sensor_count ()
 
__weak void plat_fill_monitor_sensor_table ()
 
void check_init_sensor_size ()
 
bool stby_access (uint8_t sensor_num)
 
bool dc_access (uint8_t sensor_num)
 
bool e1s_pwrgd_access (uint8_t sensor_num)
 
bool post_access (uint8_t sensor_num)
 
bool me_access (uint8_t sensor_num)
 
bool vr_access (uint8_t sensor_num)
 
bool vr_stby_access (uint8_t sensor_num)
 
void sensor_poll_init ()
 
uint8_t get_sensor_config_index (uint8_t sensor_num)
 
void add_sensor_config (sensor_cfg config)
 
void init_sensor_monitor_table ()
 
uint8_t common_tbl_sen_reinit (uint8_t sen_num)
 
bool sensor_init (void)
 
bool check_is_sensor_ready ()
 
uint8_t plat_get_config_size ()
 
__weak void load_sensor_config (void)
 
void control_sensor_polling (uint8_t sensor_num, uint8_t optional, uint8_t cache_status)
 
bool check_reading_pointer_null_is_allowed (sensor_cfg *cfg)
 
bool init_drive_type_delayed (sensor_cfg *cfg)
 
bool get_sensor_init_done_flag ()
 

Variables

sensor_cfg plat_sensor_config []
 
const int SENSOR_CONFIG_SIZE
 
struct k_thread sensor_poll
 
uint8_t sensor_config_index_map [SENSOR_NUM_MAX]
 
uint8_t sdr_index_map [SENSOR_NUM_MAX]
 
bool enable_sensor_poll_thread = true
 
const int negative_ten_power [16]
 
sensor_cfgsensor_config = NULL
 
uint8_t sensor_config_count = 0
 
sensor_monitor_table_infosensor_monitor_table
 
uint16_t sensor_monitor_count = 0
 
char common_sensor_table_name [] = "common sensor table"
 
const char *const sensor_type_name []
 
sensor_drive_api sensor_drive_tbl []
 

Macro Definition Documentation

◆ SENSOR_DRIVE_INIT_DECLARE

#define SENSOR_DRIVE_INIT_DECLARE (   name)    uint8_t name##_init(sensor_cfg *cfg)

◆ SENSOR_DRIVE_TYPE_INIT_MAP

#define SENSOR_DRIVE_TYPE_INIT_MAP (   name)    { sensor_dev_##name, name##_init }

◆ SENSOR_DRIVE_TYPE_UNUSE

#define SENSOR_DRIVE_TYPE_UNUSE (   name)    { sensor_dev_##name, NULL }

◆ SENSOR_READ_RETRY_MAX

#define SENSOR_READ_RETRY_MAX   3

Function Documentation

◆ access_check()

bool access_check ( uint8_t  sensor_num)

◆ add_sensor_config()

void add_sensor_config ( sensor_cfg  config)
Here is the call graph for this function:

◆ check_init_sensor_size()

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

◆ check_is_sensor_ready()

bool check_is_sensor_ready ( )

◆ check_reading_pointer_null_is_allowed()

bool check_reading_pointer_null_is_allowed ( sensor_cfg cfg)

◆ clear_unaccessible_sensor_cache()

void clear_unaccessible_sensor_cache ( sensor_cfg cfg)

◆ common_tbl_sen_reinit()

uint8_t common_tbl_sen_reinit ( uint8_t  sen_num)
Here is the call graph for this function:

◆ control_sensor_polling()

void control_sensor_polling ( uint8_t  sensor_num,
uint8_t  optional,
uint8_t  cache_status 
)

◆ dc_access()

bool dc_access ( uint8_t  sensor_num)
Here is the call graph for this function:

◆ disable_sensor_poll()

void disable_sensor_poll ( )

◆ e1s_pwrgd_access()

bool e1s_pwrgd_access ( uint8_t  sensor_num)
Here is the call graph for this function:

◆ enable_sensor_poll()

void enable_sensor_poll ( )

◆ find_sensor_cfg_via_sensor_num()

sensor_cfg * find_sensor_cfg_via_sensor_num ( sensor_cfg cfg_table,
uint8_t  cfg_count,
uint8_t  sensor_num 
)

◆ get_common_sensor_cfg_info()

__weak sensor_cfg * get_common_sensor_cfg_info ( uint8_t  sensor_num)
Here is the call graph for this function:

◆ get_sensor_config_index()

uint8_t get_sensor_config_index ( uint8_t  sensor_num)

◆ get_sensor_init_done_flag()

bool get_sensor_init_done_flag ( )

◆ get_sensor_poll_enable_flag()

bool get_sensor_poll_enable_flag ( )

◆ get_sensor_reading()

uint8_t get_sensor_reading ( sensor_cfg cfg_table,
uint8_t  cfg_count,
uint8_t  sensor_num,
int *  reading,
uint8_t  read_mode 
)
Here is the call graph for this function:

◆ init_drive_type_delayed()

bool init_drive_type_delayed ( sensor_cfg cfg)

◆ init_sensor_monitor_table()

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

◆ K_KERNEL_STACK_MEMBER()

K_KERNEL_STACK_MEMBER ( sensor_poll_stack  ,
SENSOR_POLL_STACK_SIZE   
)

◆ load_sensor_config()

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

◆ LOG_MODULE_REGISTER()

LOG_MODULE_REGISTER ( sensor  )

◆ map_sensor_num_to_sdr_cfg()

void map_sensor_num_to_sdr_cfg ( void  )

◆ me_access()

bool me_access ( uint8_t  sensor_num)
Here is the call graph for this function:

◆ pal_extend_sensor_config()

__weak void pal_extend_sensor_config ( void  )

◆ pal_get_extend_sdr()

__weak uint8_t pal_get_extend_sdr ( )

◆ pal_get_extend_sensor_config()

__weak uint8_t pal_get_extend_sensor_config ( void  )

◆ pal_get_monitor_sensor_count()

__weak uint8_t pal_get_monitor_sensor_count ( )

◆ pal_is_time_to_poll()

__weak bool pal_is_time_to_poll ( uint8_t  sensor_num,
int  poll_time 
)

◆ pal_set_sensor_poll_interval()

__weak void pal_set_sensor_poll_interval ( int *  interval_ms)

◆ plat_fill_monitor_sensor_table()

__weak void plat_fill_monitor_sensor_table ( )

◆ plat_get_config_size()

uint8_t plat_get_config_size ( )

◆ plat_sensor_poll_post()

__weak void plat_sensor_poll_post ( )

◆ post_access()

bool post_access ( uint8_t  sensor_num)
Here is the call graph for this function:

◆ SENSOR_DRIVE_INIT_DECLARE() [1/52]

SENSOR_DRIVE_INIT_DECLARE ( adc128d818  )

◆ SENSOR_DRIVE_INIT_DECLARE() [2/52]

SENSOR_DRIVE_INIT_DECLARE ( adm1272  )

◆ SENSOR_DRIVE_INIT_DECLARE() [3/52]

SENSOR_DRIVE_INIT_DECLARE ( adm1278  )

◆ SENSOR_DRIVE_INIT_DECLARE() [4/52]

SENSOR_DRIVE_INIT_DECLARE ( ads112c  )

◆ SENSOR_DRIVE_INIT_DECLARE() [5/52]

SENSOR_DRIVE_INIT_DECLARE ( ast_adc  )

◆ SENSOR_DRIVE_INIT_DECLARE() [6/52]

SENSOR_DRIVE_INIT_DECLARE ( ast_tach  )

◆ SENSOR_DRIVE_INIT_DECLARE() [7/52]

SENSOR_DRIVE_INIT_DECLARE ( bmr351  )

◆ SENSOR_DRIVE_INIT_DECLARE() [8/52]

SENSOR_DRIVE_INIT_DECLARE ( bmr4922302_803  )

◆ SENSOR_DRIVE_INIT_DECLARE() [9/52]

SENSOR_DRIVE_INIT_DECLARE ( cx7  )

◆ SENSOR_DRIVE_INIT_DECLARE() [10/52]

SENSOR_DRIVE_INIT_DECLARE ( ddr5_power  )

◆ SENSOR_DRIVE_INIT_DECLARE() [11/52]

SENSOR_DRIVE_INIT_DECLARE ( ddr5_temp  )

◆ SENSOR_DRIVE_INIT_DECLARE() [12/52]

SENSOR_DRIVE_INIT_DECLARE ( emc1412  )

◆ SENSOR_DRIVE_INIT_DECLARE() [13/52]

SENSOR_DRIVE_INIT_DECLARE ( g788p81u  )

◆ SENSOR_DRIVE_INIT_DECLARE() [14/52]

SENSOR_DRIVE_INIT_DECLARE ( hdc1080  )

◆ SENSOR_DRIVE_INIT_DECLARE() [15/52]

SENSOR_DRIVE_INIT_DECLARE ( i3c_dimm  )

◆ SENSOR_DRIVE_INIT_DECLARE() [16/52]

SENSOR_DRIVE_INIT_DECLARE ( ina230  )

◆ SENSOR_DRIVE_INIT_DECLARE() [17/52]

SENSOR_DRIVE_INIT_DECLARE ( ina233  )

◆ SENSOR_DRIVE_INIT_DECLARE() [18/52]

SENSOR_DRIVE_INIT_DECLARE ( ina238  )

◆ SENSOR_DRIVE_INIT_DECLARE() [19/52]

SENSOR_DRIVE_INIT_DECLARE ( intel_peci  )

◆ SENSOR_DRIVE_INIT_DECLARE() [20/52]

SENSOR_DRIVE_INIT_DECLARE ( isl28022  )

◆ SENSOR_DRIVE_INIT_DECLARE() [21/52]

SENSOR_DRIVE_INIT_DECLARE ( isl69254iraz_t  )

◆ SENSOR_DRIVE_INIT_DECLARE() [22/52]

SENSOR_DRIVE_INIT_DECLARE ( isl69259  )

◆ SENSOR_DRIVE_INIT_DECLARE() [23/52]

SENSOR_DRIVE_INIT_DECLARE ( lm75bd118  )

◆ SENSOR_DRIVE_INIT_DECLARE() [24/52]

SENSOR_DRIVE_INIT_DECLARE ( ltc2991  )

◆ SENSOR_DRIVE_INIT_DECLARE() [25/52]

SENSOR_DRIVE_INIT_DECLARE ( ltc4282  )

◆ SENSOR_DRIVE_INIT_DECLARE() [26/52]

SENSOR_DRIVE_INIT_DECLARE ( ltc4286  )

◆ SENSOR_DRIVE_INIT_DECLARE() [27/52]

SENSOR_DRIVE_INIT_DECLARE ( m88rt51632  )

◆ SENSOR_DRIVE_INIT_DECLARE() [28/52]

SENSOR_DRIVE_INIT_DECLARE ( max11617  )

◆ SENSOR_DRIVE_INIT_DECLARE() [29/52]

SENSOR_DRIVE_INIT_DECLARE ( max16550a  )

◆ SENSOR_DRIVE_INIT_DECLARE() [30/52]

SENSOR_DRIVE_INIT_DECLARE ( mp2856gut  )

◆ SENSOR_DRIVE_INIT_DECLARE() [31/52]

SENSOR_DRIVE_INIT_DECLARE ( mp2971  )

◆ SENSOR_DRIVE_INIT_DECLARE() [32/52]

SENSOR_DRIVE_INIT_DECLARE ( mp2985  )

◆ SENSOR_DRIVE_INIT_DECLARE() [33/52]

SENSOR_DRIVE_INIT_DECLARE ( mp5990  )

◆ SENSOR_DRIVE_INIT_DECLARE() [34/52]

SENSOR_DRIVE_INIT_DECLARE ( nct214  )

◆ SENSOR_DRIVE_INIT_DECLARE() [35/52]

SENSOR_DRIVE_INIT_DECLARE ( nct7363  )

◆ SENSOR_DRIVE_INIT_DECLARE() [36/52]

SENSOR_DRIVE_INIT_DECLARE ( nct7718w  )

◆ SENSOR_DRIVE_INIT_DECLARE() [37/52]

SENSOR_DRIVE_INIT_DECLARE ( nvme  )

◆ SENSOR_DRIVE_INIT_DECLARE() [38/52]

SENSOR_DRIVE_INIT_DECLARE ( pch  )

◆ SENSOR_DRIVE_INIT_DECLARE() [39/52]

SENSOR_DRIVE_INIT_DECLARE ( pex89000  )

◆ SENSOR_DRIVE_INIT_DECLARE() [40/52]

SENSOR_DRIVE_INIT_DECLARE ( pmic  )

◆ SENSOR_DRIVE_INIT_DECLARE() [41/52]

SENSOR_DRIVE_INIT_DECLARE ( pt5161l  )

◆ SENSOR_DRIVE_INIT_DECLARE() [42/52]

SENSOR_DRIVE_INIT_DECLARE ( q50sn120a1  )

◆ SENSOR_DRIVE_INIT_DECLARE() [43/52]

SENSOR_DRIVE_INIT_DECLARE ( raa229621  )

◆ SENSOR_DRIVE_INIT_DECLARE() [44/52]

SENSOR_DRIVE_INIT_DECLARE ( sq52205  )

◆ SENSOR_DRIVE_INIT_DECLARE() [45/52]

SENSOR_DRIVE_INIT_DECLARE ( tmp431  )

◆ SENSOR_DRIVE_INIT_DECLARE() [46/52]

SENSOR_DRIVE_INIT_DECLARE ( tmp461  )

◆ SENSOR_DRIVE_INIT_DECLARE() [47/52]

SENSOR_DRIVE_INIT_DECLARE ( tmp75  )

◆ SENSOR_DRIVE_INIT_DECLARE() [48/52]

SENSOR_DRIVE_INIT_DECLARE ( tps53689  )

◆ SENSOR_DRIVE_INIT_DECLARE() [49/52]

SENSOR_DRIVE_INIT_DECLARE ( xdp710  )

◆ SENSOR_DRIVE_INIT_DECLARE() [50/52]

SENSOR_DRIVE_INIT_DECLARE ( xdpe12284c  )

◆ SENSOR_DRIVE_INIT_DECLARE() [51/52]

SENSOR_DRIVE_INIT_DECLARE ( xdpe15284  )

◆ SENSOR_DRIVE_INIT_DECLARE() [52/52]

SENSOR_DRIVE_INIT_DECLARE ( xdpe19283b  )

◆ sensor_init()

bool sensor_init ( void  )

◆ sensor_poll_handler()

void sensor_poll_handler ( void *  arug0,
void *  arug1,
void *  arug2 
)
Here is the call graph for this function:

◆ sensor_poll_init()

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

◆ stby_access()

bool stby_access ( uint8_t  sensor_num)

◆ vr_access()

bool vr_access ( uint8_t  sensor_num)
Here is the call graph for this function:

◆ vr_stby_access()

bool vr_stby_access ( uint8_t  sensor_num)
Here is the call graph for this function:

Variable Documentation

◆ common_sensor_table_name

char common_sensor_table_name[] = "common sensor table"

◆ enable_sensor_poll_thread

bool enable_sensor_poll_thread = true

◆ negative_ten_power

const int negative_ten_power[16]
Initial value:
= { 1, 1, 1, 1, 1, 1,
1, 1000000000, 100000000, 10000000, 1000000, 100000,
10000, 1000, 100, 10 }

◆ plat_sensor_config

sensor_cfg plat_sensor_config[]
extern

◆ sdr_index_map

uint8_t sdr_index_map[SENSOR_NUM_MAX]

◆ sensor_config

sensor_cfg* sensor_config = NULL

◆ sensor_config_count

uint8_t sensor_config_count = 0

◆ sensor_config_index_map

uint8_t sensor_config_index_map[SENSOR_NUM_MAX]

◆ SENSOR_CONFIG_SIZE

const int SENSOR_CONFIG_SIZE
extern

◆ sensor_drive_tbl

sensor_drive_api sensor_drive_tbl[]

◆ sensor_monitor_count

uint16_t sensor_monitor_count = 0

◆ sensor_monitor_table

sensor_monitor_table_info* sensor_monitor_table

◆ sensor_poll

struct k_thread sensor_poll

◆ sensor_type_name

const char* const sensor_type_name[]