Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[201811][platform-cel]: Fix dx010 FSC error #4949

Merged
merged 5 commits into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
### END INIT INFO

function export_gpio {
label=$2
label=$3
gpio_dir=$2
gpio_num=$1
gpio_base=`( cat /sys/class/gpio/gpiochip*/base | head -1 ) 2>/dev/null`
gpio_label=`( cat /sys/class/gpio/gpiochip*/label | head -1 ) 2>/dev/null`
Expand All @@ -27,6 +28,13 @@ if [ $? -ne 0 ]; then
echo "Platform driver error: Cannot export gpio$ionum!"
exit 1;
fi
if [[ "X$gpio_dir" != "X" ]]; then
echo $gpio_dir > /sys/class/gpio/gpio${ionum}/direction
if [ $? -ne 0 ]; then
echo "Platform driver error: Cannot set direction of gpio$ionum!"
exit 1;
fi
fi
}

case "$1" in
Expand Down Expand Up @@ -95,35 +103,41 @@ start)
sleep 2

# Export platform gpio sysfs
export_gpio 10 # Fan 1 present
export_gpio 11 # Fan 2 present
export_gpio 12 # Fan 3 present
export_gpio 13 # Fan 4 present
export_gpio 14 # Fan 5 present

export_gpio 22 # PSU L PWOK
export_gpio 25 # PSU R PWOK
export_gpio 27 # PSU L ABS
export_gpio 28 # PSU R ABS

export_gpio 29 # Fan 1 LED: Red
export_gpio 30 # Fan 1 LED: Yellow
export_gpio 31 # Fan 2 LED: Red
export_gpio 32 # Fan 2 LED: Yellow
export_gpio 33 # Fan 3 LED: Red
export_gpio 34 # Fan 3 LED: Yellow
export_gpio 35 # Fan 4 LED: Red
export_gpio 36 # Fan 4 LED: Yellow
export_gpio 37 # Fan 5 LED: Red
export_gpio 38 # Fan 5 LED: Yellow
export_gpio 10 "in" # Fan 1 present
export_gpio 11 "in" # Fan 2 present
export_gpio 12 "in" # Fan 3 present
export_gpio 13 "in" # Fan 4 present
export_gpio 14 "in" # Fan 5 present

export_gpio 15 "in" # Fan 1 direction
export_gpio 16 "in" # Fan 2 direction
export_gpio 17 "in" # Fan 3 direction
export_gpio 18 "in" # Fan 4 direction
export_gpio 19 "in" # Fan 5 direction

export_gpio 22 "in" # PSU L PWOK
export_gpio 25 "in" # PSU R PWOK
export_gpio 27 "in" # PSU L ABS
export_gpio 28 "in" # PSU R ABS

export_gpio 29 "out" # Fan 1 LED: Red
export_gpio 30 "out" # Fan 1 LED: Yellow
export_gpio 31 "out" # Fan 2 LED: Red
export_gpio 32 "out" # Fan 2 LED: Yellow
export_gpio 33 "out" # Fan 3 LED: Red
export_gpio 34 "out" # Fan 3 LED: Yellow
export_gpio 35 "out" # Fan 4 LED: Red
export_gpio 36 "out" # Fan 4 LED: Yellow
export_gpio 37 "out" # Fan 5 LED: Red
export_gpio 38 "out" # Fan 5 LED: Yellow

# Turn off/down lpmod by defult (0 - Normal, 1 - Low Pow)
echo 0x00000000 > /sys/devices/platform/dx010_cpld/qsfp_lpmode

# Attach 32 instances of EEPROM driver QSFP ports
for ((n=26;n<=58;n++));
do
echo sff8436 0x50 > /sys/bus/i2c/devices/i2c-$n/new_device
echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-$n/new_device
sleep 0.1
done

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ systemctl start platform-modules-dx010.service
systemctl start fancontrol.service

/usr/local/bin/platform_api_mgnt.sh install
/etc/init.d/fancontrol.sh install
Empty file.
63 changes: 15 additions & 48 deletions platform/broadcom/sonic-platform-modules-cel/dx010/scripts/fancontrol.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,72 +7,39 @@
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: fancontrol
# Description: fan speed regulator
# Description: fancontrol configuration selector
### END INIT INFO

. /lib/lsb/init-functions

[ -f /etc/default/rcS ] && . /etc/default/rcS
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
DAEMON=/usr/local/bin/fancontrol
DESC="fan speed regulator"
NAME="fancontrol"
PIDFILE=/var/run/fancontrol.pid
MAIN_CONF=/usr/share/sonic/device/x86_64-cel_seastone-r0/fancontrol
DEVPATH=/sys/devices/pci0000:00/0000:00:13.0/i2c-*/i2c-13/13-002e
GPIO_DIR=/sys/class/gpio
BASE_GPIO=$(find $GPIO_DIR | grep gpiochip | grep -o '[[:digit:]]*')
DIRGPIO_START=15

test -x $DAEMON || exit 0

for i in 1 2 3 4 5; do
FANFAULT=$(cat ${DEVPATH}/fan${i}_fault)
[ $FANFAULT = 1 ] && continue
init() {
DIRGPIO_START=15
BASE_GPIO=$(find $GPIO_DIR | grep gpiochip | grep -o '[[:digit:]]*')
FANDIR_GPIO_NUMBER=$((DIRGPIO_START + BASE_GPIO))
FANDIR_VALUE=$(cat ${GPIO_DIR}/gpio${FANDIR_GPIO_NUMBER}/value)
DIRGPIO_START=$((DIRGPIO_START + 1))
FANDIR=$([ $FANDIR_VALUE = 1 ] && echo "B2F" || echo "F2B")
done
CONF=${MAIN_CONF}-${FANDIR}
CONF=${MAIN_CONF}-${FANDIR}
}

install() {
find /var/lib/docker/overlay*/ -path */sbin/fancontrol -exec cp /usr/local/bin/fancontrol {} \;
}

case "$1" in
start)
if [ -f $CONF ]; then
if $DAEMON --check $CONF 1>/dev/null 2>/dev/null; then
log_daemon_msg "Starting $DESC" "$NAME\n"
start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON $CONF
log_end_msg $?
else
log_failure_msg "Not starting fancontrol, broken configuration file; please re-run pwmconfig."
fi
else
if [ "$VERBOSE" != no ]; then
log_warning_msg "Not starting fancontrol; run pwmconfig first."
fi
fi
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo --startas $DAEMON $CONF
rm -f $PIDFILE
log_end_msg $?
;;
restart)
$0 stop
sleep 3
$0 start
;;
force-reload)
if start-stop-daemon --stop --test --quiet --pidfile $PIDFILE --startas $DAEMON $CONF; then
$0 restart
fi
init
cp $CONF $MAIN_CONF
;;
status)
status_of_proc $DAEMON $NAME $CONF && exit 0 || exit $?
install)
install
;;
*)
log_success_msg "Usage: /etc/init.d/fancontrol {start|stop|restart|force-reload|status}"
log_success_msg "Usage: /etc/init.d/fancontrol {start} | {install}"
exit 1
;;
esac
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ function LoadConfig
echo "Settings for ${CSMAXTEMPTYPE[$tscount]} temperature sensor:"
echo " Depends on ${CSTEMP[$tscount]}"
echo " MAXTEMPCRIT=${CSMAXTEMPCRIT[$tscount]}"
let tscount=tscount+1q
let tscount=tscount+1
done
echo

Expand Down