sonic-buildimage/platform/broadcom/sonic-platform-modules-delta/ag5648/scripts/led_control
nealtai 830e1dd560 [device]: Add a new supported device, Delta-ag5648 (#1470)
* [platform]: Add a new supported platform, Delta-ag5648

            CPU : Intel Rangeley C2538
            Swich ASIC: Broadcom Tomahawk BCM56967
            Ports : 48x25G + 6x100G
            Switch SKU : Delta-ag5648

Signed-off-by: neal tai <neal.tai@deltaww.com>

* Delete the file

Delete the auto-generated file.

* [device]: ag5648 remove all *.cmd files.
          remove the files under ag5648/modules

Signed-off-by: neal tai <neal.tai@deltaww.com>

* [device]: ag5648 device drivers
          1. Use the common driver dni_emc2305.c

          ag9032v1 device drivers
          1. Move dni_emc2305.c to be the common driver
          2. Remove at24.c

Signed-off-by: neal tai <neal.tai@deltaww.com>
2018-03-23 15:17:41 -07:00

222 lines
7.6 KiB
Bash
Executable File

#!/bin/bash
FAN1_EEPROM="-y 3 0x51 0x0a"
FAN2_EEPROM="-y 3 0x52 0x0a"
FAN3_EEPROM="-y 3 0x53 0x0a"
FAN4_EEPROM="-y 3 0x54 0x0a"
LED_CONTROL="/sys/devices/platform/delta-ag5648-cpld.0/led_control"
FAN1_REAR_RPM="/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-3/3-004d/fan1_input"
FAN2_REAR_RPM="/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-3/3-004d/fan2_input"
FAN3_REAR_RPM="/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-3/3-004d/fan3_input"
FAN4_REAR_RPM="/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-3/3-004d/fan4_input"
FAN1_FRONT_RPM="/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-5/5-004d/fan1_input"
FAN2_FRONT_RPM="/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-5/5-004d/fan2_input"
FAN3_FRONT_RPM="/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-5/5-004d/fan3_input"
FAN4_FRONT_RPM="/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-5/5-004d/fan4_input"
PSU1_EEPROM="-y 6 0x51 0x00"
PSU2_EEPROM="-y 6 0x50 0x00"
PSU1_FAN_RPM="/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-6/6-0059/fan1_input"
PSU2_FAN_RPM="/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-6/6-0058/fan1_input"
catfaneeprom(){
fan_eeprom_num=0
fan1_eeprom_num=0
i2cget $FAN1_EEPROM > /dev/null 2>&1
if [ "`echo $?`" -eq "0" ]; then
fan1_eeprom_num=$((fan1_eeprom_num+1))
elif [ "`echo $?`" -eq "2" ]; then
fan1_eeprom_num=$((fan1_eeprom_num))
fi
fan2_eeprom_num=0
i2cget $FAN2_EEPROM > /dev/null 2>&1
if [ "`echo $?`" -eq "0" ]; then
fan2_eeprom_num=$((fan2_eeprom_num+1))
elif [ "`echo $?`" -eq "2" ]; then
fan2_eeprom_num=$((fan2_eeprom_num))
fi
fan3_eeprom_num=0
i2cget $FAN3_EEPROM > /dev/null 2>&1
if [ "`echo $?`" -eq "0" ]; then
fan3_eeprom_num=$((fan3_eeprom_num+1))
elif [ "`echo $?`" -eq "2" ]; then
fan3_eeprom_num=$((fan3_eeprom_num))
fi
fan4_eeprom_num=0
i2cget $FAN4_EEPROM > /dev/null 2>&1
if [ "`echo $?`" -eq "0" ]; then
fan4_eeprom_num=$((fan4_eeprom_num+1))
elif [ "`echo $?`" -eq "2" ]; then
fan4_eeprom_num=$((fan4_eeprom_num))
fi
fan_eeprom_num=$((fan1_eeprom_num+fan2_eeprom_num+fan3_eeprom_num+fan4_eeprom_num))
}
catfanspeed(){
fan_rpm_normal_num=0
fan1_rpm_normal_num=0
fan1_front_rpm=`cat $FAN1_FRONT_RPM`
fan1_rear_rpm=`cat $FAN1_REAR_RPM`
if [ "${fan1_front_rpm}" -ne "960" ] && [ "${fan1_rear_rpm}" -ne "960" ] && [ "${fan1_front_rpm}" -ne "0" ] && [ "${fan1_rear_rpm}" -ne "0" ]; then
fan1_rpm_normal_num=$((fan1_rpm_normal_num+1))
elif [ "${fan1_front_rpm}" -eq "960" ] || [ "${fan1_rear_rpm}" -eq "960" ] || [ "${fan1_front_rpm}" -eq "0" ] || [ "${fan1_rear_rpm}" -eq "0" ]; then
fan1_rpm_normal_num=$((fan1_rpm_normal_num))
fi
fan2_rpm_normal_num=0
fan2_front_rpm=`cat $FAN2_FRONT_RPM`
fan2_rear_rpm=`cat $FAN2_REAR_RPM`
if [ "${fan2_front_rpm}" -ne "960" ] && [ "${fan2_rear_rpm}" -ne "960" ] && [ "${fan2_front_rpm}" -ne "0" ] && [ "${fan2_rear_rpm}" -ne "0" ]; then
fan2_rpm_normal_num=$((fan2_rpm_normal_num+1))
elif [ "${fan2_front_rpm}" -eq "960" ] || [ "${fan2_rear_rpm}" -eq "960" ] || [ "${fan2_front_rpm}" -eq "0" ] || [ "${fan2_rear_rpm}" -eq "0" ]; then
fan2_rpm_normal_num=$((fan2_rpm_normal_num))
fi
fan3_rpm_normal_num=0
fan3_front_rpm=`cat $FAN3_FRONT_RPM`
fan3_rear_rpm=`cat $FAN3_REAR_RPM`
if [ "${fan3_front_rpm}" -ne "960" ] && [ "${fan3_rear_rpm}" -ne "960" ] && [ "${fan3_front_rpm}" -ne "0" ] && [ "${fan3_rear_rpm}" -ne "0" ]; then
fan3_rpm_normal_num=$((fan3_rpm_normal_num+1))
elif [ "${fan3_front_rpm}" -eq "960" ] || [ "${fan3_rear_rpm}" -eq "960" ] || [ "${fan3_front_rpm}" -eq "0" ] || [ "${fan3_rear_rpm}" -eq "0" ]; then
fan3_rpm_normal_num=$((fan3_rpm_normal_num))
fi
fan4_rpm_normal_num=0
fan4_front_rpm=`cat $FAN4_FRONT_RPM`
fan4_rear_rpm=`cat $FAN4_REAR_RPM`
if [ "${fan4_front_rpm}" -ne "960" ] && [ "${fan4_rear_rpm}" -ne "960" ] && [ "${fan4_front_rpm}" -ne "0" ] && [ "${fan4_rear_rpm}" -ne "0" ]; then
fan4_rpm_normal_num=$((fan4_rpm_normal_num+1))
elif [ "${fan4_front_rpm}" -eq "960" ] || [ "${fan4_rear_rpm}" -eq "960" ] || [ "${fan4_front_rpm}" -eq "0" ] || [ "${fan4_rear_rpm}" -eq "0" ]; then
fan4_rpm_normal_num=$((fan4_rpm_normal_num))
fi
fan_rpm_normal_num=$((fan1_rpm_normal_num+fan2_rpm_normal_num+fan3_rpm_normal_num+fan4_rpm_normal_num))
}
catpsueeprom(){
psu1_eeprom_num=0
i2cget $PSU1_EEPROM > /dev/null 2>&1
if [ "`echo $?`" -eq "0" ]; then
psu1_eeprom_num=$((psu1_eeprom_num+1))
elif [ "`echo $?`" -eq "2" ]; then
psu1_eeprom_num=$((psu1_eeprom_num))
fi
psu2_eeprom_num=0
i2cget $PSU2_EEPROM > /dev/null 2>&1
if [ "`echo $?`" -eq "0" ]; then
psu2_eeprom_num=$((psu2_eeprom_num+1))
elif [ "`echo $?`" -eq "2" ]; then
psu2_eeprom_num=$((psu2_eeprom_num))
fi
}
catpsufanspeed(){
psu1_rpm_normal_num=0
psu1_rpm=`cat $PSU1_FAN_RPM`
if [ "${psu1_rpm}" -ne "960" ] && [ "${psu1_rpm}" -ne "0" ]; then
psu1_rpm_normal_num=$((psu1_rpm_normal_num+1))
elif [ "${psu1_rpm}" -eq "960" ] || [ "${psu1_rpm}" -eq "0" ]; then
psu1_rpm_normal_num=$((psu1_rpm_normal_num))
fi
psu2_rpm_normal_num=0
psu2_rpm=`cat $PSU2_FAN_RPM`
if [ "${psu2_rpm}" -ne "960" ] && [ "${psu2_rpm}" -ne "0" ]; then
psu2_rpm_normal_num=$((psu2_rpm_normal_num+1))
elif [ "${psu2_rpm}" -eq "960" ] || [ "${psu2_rpm}" -eq "0" ]; then
psu2_rpm_normal_num=$((psu2_rpm_normal_num))
fi
}
setfanled(){
if [ "${fan_eeprom_num}" -eq "4" ] && [ "${fan_rpm_normal_num}" -eq "4" ]; then
echo "fan_green" > $LED_CONTROL
elif [ "${fan_eeprom_num}" -lt "4" ] && [ "${fan_rpm_normal_num}" -eq "4" ]; then
echo "fan_Amber" > $LED_CONTROL
elif [ "${psu1_eeprom_num}" -eq "0" ] && [ "${psu2_eeprom_num}" -eq "0" ]; then
echo "fan_off" > $LED_CONTROL
else
echo "fan_Blinking_yellow" > $LED_CONTROL
fi
}
setpsuled(){
if [ "${psu1_rpm_normal_num}" -eq "1" ] && [ "${psu2_rpm_normal_num}" -eq "1" ]; then
echo "pwr_green" > $LED_CONTROL
elif [ "${psu1_eeprom_num}" -eq "1" ] && [ "${psu2_eeprom_num}" -eq "1" ]; then
echo "pwr_Blinking_Amber" > $LED_CONTROL
elif [ "${psu1_eeprom_num}" -eq "0" ] || [ "${psu2_eeprom_num}" -eq "0" ]; then
echo "pwr_Amber" > $LED_CONTROL
else
echo "pwr_off" > $LED_CONTROL
fi
}
setfantrayled(){
if [ "${fan1_rpm_normal_num}" -eq "1" ]; then
echo "fan1_green" > $LED_CONTROL
elif [ "${fan1_eeprom_num}" -eq "1" ]; then
echo "fan1_Amber" > $LED_CONTROL
else
echo "fan1_off" > $LED_CONTROL
fi
if [ "${fan2_rpm_normal_num}" -eq "1" ]; then
echo "fan2_green" > $LED_CONTROL
elif [ "${fan2_eeprom_num}" -eq "1" ]; then
echo "fan2_Amber" > $LED_CONTROL
else
echo "fan2_off" > $LED_CONTROL
fi
if [ "${fan3_rpm_normal_num}" -eq "1" ]; then
echo "fan3_green" > $LED_CONTROL
elif [ "${fan3_eeprom_num}" -eq "1" ]; then
echo "fan3_Amber" > $LED_CONTROL
else
echo "fan3_off" > $LED_CONTROL
fi
if [ "${fan4_rpm_normal_num}" -eq "1" ]; then
echo "fan4_green" > $LED_CONTROL
elif [ "${fan4_eeprom_num}" -eq "1" ]; then
echo "fan4_Amber" > $LED_CONTROL
else
echo "fan4_off" > $LED_CONTROL
fi
}
platformstatus(){
echo "sys_green" > $LED_CONTROL
catfaneeprom
catfanspeed
setfanled
setfantrayled
catpsueeprom
catpsufanspeed
setpsuled
}
while true
do
platformstatus
sleep 5
done