blob: 55f13d1fd99fdbc6c3931ee860760c2c8b34eab3 [file] [log] [blame]
#!/bin/sh
if ! runnable glaser; then
# TODO(apenwarr): /etc should be readonly.
echo "Switching to GPON mode."
serial=$(serial)
if [ ! -z "$serial" ]; then
# simple py script to replace the placeholder serial with the real serial.
subst_script="
import sys
import re
sys.stdout.write(re.sub(r'SERIALXXYYZZ', '$serial', sys.stdin.read()))
"
# Do the replace.
cat /etc/xml_params/gpon_xml_cfg_file.xml | \
python -c "$subst_script" >/etc/xml_params/pon_xml_cfg_file.xml
else
cp -sf /etc/xml_params/gpon_xml_cfg_file.xml \
/etc/xml_params/pon_xml_cfg_file.xml
fi
cp -sf /etc/xml_params/pon_type_xml_cfg_file_gpon.xml \
/etc/xml_params/pon_type_xml_cfg_file.xml
cp -sf /etc/xml_params/tpm_xml_cfg_file_gpon.xml \
/etc/xml_params/tpm_xml_cfg_file.xml
fi
case "$1" in
start)
echo "Starting data configuration."
# Clean BM's cause register
devmem2 0xf10d0050 w 0
ipg_set=0
# Set PNC_AGING_LO_THRESH_REGISTERS to maximum value
devmem2 0xf10c802c w 0x3FFFFFF
devmem2 0xf10c8030 w 0x3FFFFFF
devmem2 0xf10c8034 w 0x3FFFFFF
devmem2 0xf10c8038 w 0x3FFFFFF
# Double PnC buffers for ports PMAC/GMAC0
devmem2 0xf10c8000 w 0x377777
if [ "$ipg_set" = 1 ]; then
cd /sys/devices/platform/neta/switch &&
echo 3 26 2 0x0834 >reg_w &&
sleep 1 &&
echo 2 26 2 0xb402 >reg_w &&
sleep 1
cd /
devmem2 0xf1072c00 w 0x8c00
devmem2 0xf1072c48 w 0x281
devmem2 0xf1072c00 w 0x8c01
fi
cd /sys/devices/platform/neta/gbe &&
echo 0 0x2F00 >mh_2B &&
echo 1 0x1F00 >mh_2B
;;
stop)
;;
restart|reload)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac