diff --git a/tool/plugin/i2c_m7.sh b/tool/plugin/i2c_m7.sh index a0b269e..e12abbd 100644 --- a/tool/plugin/i2c_m7.sh +++ b/tool/plugin/i2c_m7.sh @@ -6,4 +6,8 @@ slave=$3 data=$4 rc=$5 -i2ctransfer - y $i2c_bus w$wc@$slave $data r$5 \ No newline at end of file +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 \ No newline at end of file diff --git a/tool/plugin/nicsensor.sh b/tool/plugin/nicsensor.sh index 4a66b1a..995a1e0 100644 --- a/tool/plugin/nicsensor.sh +++ b/tool/plugin/nicsensor.sh @@ -10,10 +10,11 @@ chip_slave=$3 nic_type="" slot_id="" -server_script="platform_${server_type}.sh" -sensor_script="plugin_${sensor_type}.sh" -i2c_script="i2c_${server_platform}.sh" -fmt_print="format_print.sh" +path=`pwd` +server_script="${path}/platform_${server_type}.sh" +sensor_script="${path}/plugin_${sensor_type}.sh" +i2c_script="${path}/i2c_${server_platform}.sh" +fmt_print="${path}/format_print.sh" conf_pre_check(){ @@ -45,20 +46,20 @@ conf_pre_check(){ parse_slot_name(){ # Get nic type and slot id from slot name - case "{$slot_name}" in + case "${slot_name}" in ocp*) nic_type="ocp" slot_id=`echo $slot_name | cut -c 4` - ;; + ;; pcie*) nic_type="pcie" slot_id=`echo $slot_name | cut -c 5-` - ;; + ;; *) $fmt_print "log" "Warning" "Undetermined nic type, default set to pcie" nic_type="pcie" slot_id=$slot_name - ;; + ;; esac } @@ -72,7 +73,7 @@ connect_i2c(){ } start_sensor_reading(){ - + $fmt_print "log" "Info" "start sensor reading" } # --------------------------------------------------------- # Start Execute Script diff --git a/tool/plugin/platform_5280m7.sh b/tool/plugin/platform_5280m7.sh index 40507f7..0119c90 100644 --- a/tool/plugin/platform_5280m7.sh +++ b/tool/plugin/platform_5280m7.sh @@ -4,20 +4,25 @@ action=$1 nic_type=$2 slot_id=$3 -i2c_script="i2c_m7.sh" -fmt_print="format_print.sh" +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 + 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" @@ -30,7 +35,7 @@ set_i2c_config(){ fi # set pca9548 switch channel - if [ $nic_type == "ocp" ];then + if [ "${nic_type}" = "ocp" ];then if [ $slot_id -eq 0 ];then pca9548_channel="0x01" elif [ $slot_id -eq 1 ];then @@ -59,9 +64,37 @@ set_i2c_config(){ 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(){