2024-11-07 11:04:47 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
2024-11-07 14:53:35 +08:00
|
|
|
log="/tmp/nicsensor_debug.log"
|
|
|
|
|
|
|
|
|
|
INFO="Info"
|
|
|
|
|
WARNING="Warning"
|
|
|
|
|
ERROR="Error"
|
|
|
|
|
|
2024-11-07 11:04:47 +08:00
|
|
|
# 在 5280m7 上扫描每个pcie slot下的I2C设备
|
|
|
|
|
# 详细对应关系参阅 readme.txt 第二节
|
|
|
|
|
detect_on_5280m7(){
|
|
|
|
|
# 从9641获取I2C控制权
|
|
|
|
|
i2c_bus=12
|
|
|
|
|
pca9641_slave="0x41"
|
|
|
|
|
get_pca9641_controll
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 0 : bus12 9548channel 1"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x72 0x02
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 1 : bus12 9548channel 2"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x72 0x04
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 2 : bus12 9548channel 3"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x72 0x08
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
i2c_bus=13
|
|
|
|
|
pca9641_slave="0x42"
|
|
|
|
|
get_pca9641_controll
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 3 : bus13 9548channel 1"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x72 0x02
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 4 : bus13 9548channel 2"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x72 0x04
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 5 : bus13 9548channel 3"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x72 0x08
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 在 5468m7 上扫描每个pcie slot下的I2C设备
|
|
|
|
|
# 详细对应关系参阅 readme.txt 第二节
|
|
|
|
|
detect_on_5468m7(){
|
|
|
|
|
# 从9641获取I2C控制权
|
|
|
|
|
i2c_bus=13
|
|
|
|
|
pca9641_slave="0x31"
|
|
|
|
|
get_pca9641_controll
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 0 : bus13 9548channel 0"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x70 0x01
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 1 : bus13 9548channel 1"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x70 0x02
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 2 : bus13 9548channel 2"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x70 0x04
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 3 : bus13 9548channel 3"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x70 0x08
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 4 : bus13 9548channel 4"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x70 0x10
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
i2c_bus=14
|
|
|
|
|
pca9641_slave="0x42"
|
|
|
|
|
get_pca9641_controll
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 5 : bus14 9548channel 0"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x71 0x01
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 6 : bus14 9548channel 1"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x71 0x02
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 7 : bus14 9548channel 2"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x71 0x04
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 8 : bus14 9548channel 3"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x71 0x08
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 9 : bus14 9548channel 4"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x71 0x10
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 10 : bus14 9548channel 5"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x71 0x20
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 在 donghu 上扫描每个pcie slot下的I2C设备
|
|
|
|
|
detect_on_donghu(){
|
|
|
|
|
|
|
|
|
|
i2c_bus=3
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 0 : bus3 9548channel 7"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x70 0x80
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 1 : bus3 9548channel 6"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x70 0x40
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 2 : bus3 9548channel 5"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x70 0x20
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 3 : bus3 9548channel 4"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x70 0x10
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 4 : bus3 9548channel 3"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x70 0x08
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 5 : bus3 9548channel 2"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x70 0x04
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 6 : bus3 9548channel 1"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x70 0x02
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
format_print $INFO "PCIe slot 7 : bus3 9548channel 0"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x70 0x01
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 在 yichun 上扫描每个pcie slot下的I2C设备
|
|
|
|
|
detect_on_yichun(){
|
|
|
|
|
i2c_bus=12
|
|
|
|
|
format_print $INFO "PCIe slot 0 : bus12 9546channel 2"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x74 0x02
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
i2c_bus=13
|
|
|
|
|
format_print $INFO "PCIe slot 1 : bus13 9546channel 2"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x74 0x02
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
|
|
|
|
|
i2c_bus=14
|
|
|
|
|
format_print $INFO "PCIe slot 2 : bus14 9546channel 2"
|
|
|
|
|
i2ctransfer -y $i2c_bus w1@0x74 0x02
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 搜索服务器所有PCIE插槽的I2C设备信息,当前仅支持特定Riser卡上的设备
|
|
|
|
|
# change list : 20240912-支持服务器器型号5280m7,5468m7
|
|
|
|
|
start_detect_device(){
|
|
|
|
|
|
|
|
|
|
# debug mode下进行detect操作仅对当前链路进行detect
|
|
|
|
|
if [ $DEBUG_MODE -ne 0 ];then
|
|
|
|
|
format_print $INFO "In debug mode now, only detect i2c_bus$i2c_bus:"
|
|
|
|
|
i2cdetect -y $i2c_bus
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
format_print $INFO "Detect on server : $server_type"
|
|
|
|
|
|
|
|
|
|
if [ $server_type == "5280m7" ];then
|
|
|
|
|
detect_on_5280m7
|
|
|
|
|
elif [ $server_type == "5468m7" ];then
|
|
|
|
|
detect_on_5468m7
|
|
|
|
|
elif [ $server_type == "donghu" ];then
|
|
|
|
|
detect_on_donghu
|
|
|
|
|
elif [ $server_type == "yichun" ];then
|
|
|
|
|
detect_on_yichun
|
|
|
|
|
else
|
|
|
|
|
format_print $ERROR "Unsupport Server Type !!!"
|
|
|
|
|
fi
|
|
|
|
|
}
|