sonic-buildimage/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-dx010.init

108 lines
3.0 KiB
Bash

#!/bin/bash
### BEGIN INIT INFO
# Provides: setup-board
# Required-Start: $portmap
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: S
# Default-Stop: 0 6
# Short-Description: Setup DX010 board.
### END INIT INFO
case "$1" in
start)
echo -n "Setting up board... "
depmod -a
modprobe i2c-dev
modprobe i2c-mux-pca954x
modprobe dx010_wdt
modprobe leds-dx010
modprobe lm75
found=0
for devnum in 0 1; do
devname=`cat /sys/bus/i2c/devices/i2c-${devnum}/name`
# iSMT adapter can be at either dffd0000 or dfff0000
if [[ $devname == 'SMBus iSMT adapter at '* ]]; then
found=1
break
fi
done
[ $found -eq 0 ] && echo "cannot find iSMT" && exit 1
i2cset -y ${devnum} 0x70 0x10 0x00 0x01 i
# Attach PCA9541 Ox70 Master Selector
chmod 755 /sys/bus/i2c/devices/i2c-${devnum}/new_device
echo pca9541 0x70 > /sys/bus/i2c/devices/i2c-${devnum}/new_device
sleep 1
# Attach PCA9548 0x71 Channel Extender for Main Board
echo pca9548 0x71 > /sys/bus/i2c/devices/i2c-${devnum}/new_device
sleep 1
# Attach PCA9548 0x73 Channel Extender for CPU Board
echo pca9548 0x73 > /sys/bus/i2c/devices/i2c-${devnum}/new_device
sleep 1
# Attach PCA9548 0x77 Channel Extender for Fan's EEPROMs
echo pca9548 0x77 > /sys/bus/i2c/devices/i2c-${devnum}/new_device
sleep 1
# Attach syseeprom
echo 24lc64t 0x50 > /sys/bus/i2c/devices/i2c-12/new_device
# Attach temperature sensors
echo lm75b 0x48 > /sys/bus/i2c/devices/i2c-5/new_device
echo lm75b 0x49 > /sys/bus/i2c/devices/i2c-6/new_device
echo lm75b 0x4a > /sys/bus/i2c/devices/i2c-7/new_device
echo lm75b 0x48 > /sys/bus/i2c/devices/i2c-14/new_device
echo lm75b 0x4e > /sys/bus/i2c/devices/i2c-15/new_device
# Attach fans
echo emc2305 0x2e > /sys/bus/i2c/devices/i2c-13/new_device
echo emc2305 0x4d > /sys/bus/i2c/devices/i2c-13/new_device
# Attach PSUs
echo dps460 0x5a > /sys/bus/i2c/devices/i2c-10/new_device
echo dps460 0x5b > /sys/bus/i2c/devices/i2c-11/new_device
# Attach PCA9506 GPIO expander for 40 pins
echo pca9505 0x20 > /sys/bus/i2c/devices/i2c-17/new_device
modprobe dx010_cpld
sleep 2
# 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
sleep 0.1
done
echo "done."
;;
stop)
echo "done."
;;
force-reload|restart)
echo "Not supported"
;;
*)
echo "Usage: /etc/init.d/platform-modules-dx010.init {start|stop}"
exit 1
;;
esac
exit 0