122 lines
3.0 KiB
Bash
122 lines
3.0 KiB
Bash
#!/bin/sh
|
|
|
|
action=$1
|
|
nic_type=$2
|
|
slot_id=$3
|
|
|
|
path=`pwd`
|
|
i2c_script="${path}/i2c_m7.sh"
|
|
fmt_print="${path}/format_print.sh"
|
|
|
|
pca9548_slave=""
|
|
pca9641_slave=""
|
|
i2c_bus=""
|
|
pca9548_channel=""
|
|
|
|
is_have_pca9641=0
|
|
|
|
set_i2c_config(){
|
|
# set pca9641 address && I2C BUS
|
|
if [ "${nic_type}" = "ocp" ];then
|
|
is_have_pca9641=0
|
|
pca9548_slave="0x70"
|
|
i2c_bus=3
|
|
else
|
|
is_have_pca9641=1
|
|
if [ $slot_id -le 2 ];then
|
|
pca9641_slave="0x41"
|
|
pca9548_slave="0x72"
|
|
i2c_bus=12
|
|
else
|
|
pca9641_slave="0x42"
|
|
pca9548_slave="0x72"
|
|
i2c_bus=13
|
|
fi
|
|
fi
|
|
|
|
# set pca9548 switch channel
|
|
if [ "${nic_type}" = "ocp" ];then
|
|
if [ $slot_id -eq 0 ];then
|
|
pca9548_channel="0x01"
|
|
elif [ $slot_id -eq 1 ];then
|
|
pca9548_channel="0x02"
|
|
elif [ $slot_id -eq 2 ];then
|
|
pca9548_channel="0x04"
|
|
else
|
|
$fmt_print "console" "Warning" "Unspecified card slot!"
|
|
fi
|
|
else
|
|
if [ $slot_id -eq 0 ];then
|
|
pca9548_channel="0x02"
|
|
elif [ $slot_id -eq 1 ];then
|
|
pca9548_channel="0x04"
|
|
elif [ $slot_id -eq 2 ];then
|
|
pca9548_channel="0x08"
|
|
elif [ $slot_id -eq 3 ];then
|
|
pca9548_channel="0x02"
|
|
elif [ $slot_id -eq 4 ];then
|
|
pca9548_channel="0x04"
|
|
elif [ $slot_id -eq 5 ];then
|
|
pca9548_channel="0x08"
|
|
else
|
|
$fmt_print "console" "Warning" "Unspecified card slot!"
|
|
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(){
|
|
$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(){
|
|
$fmt_print "log" "Info" "[platform_5280m7] Start i2c detect"
|
|
}
|
|
|
|
# ---------------------------------------------------
|
|
# Start Execute Script
|
|
# ---------------------------------------------------
|
|
case "${action}" in
|
|
"connect")
|
|
build_i2c_connect
|
|
;;
|
|
"detect")
|
|
detect_on_server
|
|
;;
|
|
*)
|
|
$fmt_print "console" "Error" "[platform_5280m7] Unspecified Operation : $action"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
exit 0
|
|
|