code sync

This commit is contained in:
leimingsheng 2025-02-20 18:10:19 +08:00
parent 0b3f79b1af
commit f0662a752d
3 changed files with 53 additions and 15 deletions

@ -6,4 +6,8 @@ slave=$3
data=$4 data=$4
rc=$5 rc=$5
i2ctransfer - y $i2c_bus w$wc@$slave $data r$5 if [ $rc -eq 0 ];then
i2ctransfer - y $i2c_bus w$wc@$slave $data
else
i2ctransfer - y $i2c_bus w$wc@$slave $data r$5
fi

@ -10,10 +10,11 @@ chip_slave=$3
nic_type="" nic_type=""
slot_id="" slot_id=""
server_script="platform_${server_type}.sh" path=`pwd`
sensor_script="plugin_${sensor_type}.sh" server_script="${path}/platform_${server_type}.sh"
i2c_script="i2c_${server_platform}.sh" sensor_script="${path}/plugin_${sensor_type}.sh"
fmt_print="format_print.sh" i2c_script="${path}/i2c_${server_platform}.sh"
fmt_print="${path}/format_print.sh"
conf_pre_check(){ conf_pre_check(){
@ -45,20 +46,20 @@ conf_pre_check(){
parse_slot_name(){ parse_slot_name(){
# Get nic type and slot id from slot name # Get nic type and slot id from slot name
case "{$slot_name}" in case "${slot_name}" in
ocp*) ocp*)
nic_type="ocp" nic_type="ocp"
slot_id=`echo $slot_name | cut -c 4` slot_id=`echo $slot_name | cut -c 4`
;; ;;
pcie*) pcie*)
nic_type="pcie" nic_type="pcie"
slot_id=`echo $slot_name | cut -c 5-` slot_id=`echo $slot_name | cut -c 5-`
;; ;;
*) *)
$fmt_print "log" "Warning" "Undetermined nic type, default set to pcie" $fmt_print "log" "Warning" "Undetermined nic type, default set to pcie"
nic_type="pcie" nic_type="pcie"
slot_id=$slot_name slot_id=$slot_name
;; ;;
esac esac
} }
@ -72,7 +73,7 @@ connect_i2c(){
} }
start_sensor_reading(){ start_sensor_reading(){
$fmt_print "log" "Info" "start sensor reading"
} }
# --------------------------------------------------------- # ---------------------------------------------------------
# Start Execute Script # Start Execute Script

@ -4,20 +4,25 @@ action=$1
nic_type=$2 nic_type=$2
slot_id=$3 slot_id=$3
i2c_script="i2c_m7.sh" path=`pwd`
fmt_print="format_print.sh" i2c_script="${path}/i2c_m7.sh"
fmt_print="${path}/format_print.sh"
pca9548_slave="" pca9548_slave=""
pca9641_slave="" pca9641_slave=""
i2c_bus="" i2c_bus=""
pca9548_channel="" pca9548_channel=""
is_have_pca9641=0
set_i2c_config(){ set_i2c_config(){
# set pca9641 address && I2C BUS # set pca9641 address && I2C BUS
if [ $nic_type == "ocp" ];then if [ "${nic_type}" = "ocp" ];then
is_have_pca9641=0
pca9548_slave="0x70" pca9548_slave="0x70"
i2c_bus=3 i2c_bus=3
else else
is_have_pca9641=1
if [ $slot_id -le 2 ];then if [ $slot_id -le 2 ];then
pca9641_slave="0x41" pca9641_slave="0x41"
pca9548_slave="0x72" pca9548_slave="0x72"
@ -30,7 +35,7 @@ set_i2c_config(){
fi fi
# set pca9548 switch channel # set pca9548 switch channel
if [ $nic_type == "ocp" ];then if [ "${nic_type}" = "ocp" ];then
if [ $slot_id -eq 0 ];then if [ $slot_id -eq 0 ];then
pca9548_channel="0x01" pca9548_channel="0x01"
elif [ $slot_id -eq 1 ];then elif [ $slot_id -eq 1 ];then
@ -59,9 +64,37 @@ set_i2c_config(){
fi fi
} }
record_i2c_status(){
$fmt_print "log" "Info" "[platform_5280m7] Start record i2c configuration"
$fmt_print "log" "Info" "Nic Type: $nic_type"
$fmt_print "log" "Info" "Nic slot: $slot_id"
$fmt_print "log" "Info" "i2c bus: $i2c_bus"
$fmt_print "log" "Info" "is have pca9641: $is_have_pca9641"
$fmt_print "log" "Info" "pca9641 slave: $is_have_pca9641"
$fmt_print "log" "Info" "pca9548 slave: $pca9548_slave"
$fmt_print "log" "Info" "pca9548 channel: $pca9548_channel"
}
get_pca9641_control(){
$fmt_print "log" "Info" "[platform_5280m7] Start Get pca9641 control"
}
select_pca9548_channel(){
$fmt_print "log" "Info" "[platform_5280m7] Start Switch PCA9548"
# $i2c_script "$i2c_bus" 1 "$pca9548_slave" "$pca9548_channel" 0
}
build_i2c_connect(){ build_i2c_connect(){
$fmt_print "log" "Info" "[platform_5280m7] Start build i2c connect" $fmt_print "log" "Info" "[platform_5280m7] Start build i2c connect"
set_i2c_config
record_i2c_status
if [ $is_have_pca9641 -eq 1 ];then
get_pca9641_control
fi
select_pca9548_channel
echo "$i2c_bus"
} }
detect_on_server(){ detect_on_server(){