aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/lantiq/base-files
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/lantiq/base-files')
-rw-r--r--target/linux/lantiq/base-files/etc/diag.sh42
-rw-r--r--target/linux/lantiq/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom60
-rw-r--r--target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata51
-rwxr-xr-xtarget/linux/lantiq/base-files/etc/init.d/dsl_fs35
-rwxr-xr-xtarget/linux/lantiq/base-files/etc/init.d/esi7
-rw-r--r--target/linux/lantiq/base-files/etc/inittab3
-rw-r--r--target/linux/lantiq/base-files/etc/uci-defaults/01_leds77
-rw-r--r--target/linux/lantiq/base-files/etc/uci-defaults/02_network211
-rw-r--r--target/linux/lantiq/base-files/etc/uci-defaults/03_wireless-wps16
-rw-r--r--target/linux/lantiq/base-files/lib/functions/lantiq.sh29
-rwxr-xr-xtarget/linux/lantiq/base-files/lib/functions/lantiq_dsl.sh640
-rwxr-xr-xtarget/linux/lantiq/base-files/lib/preinit/03_preinit_board.sh9
-rw-r--r--target/linux/lantiq/base-files/lib/preinit/05_set_preinit_iface_lantiq18
-rwxr-xr-xtarget/linux/lantiq/base-files/lib/upgrade/platform.sh47
-rwxr-xr-xtarget/linux/lantiq/base-files/sbin/dsl_notify.sh61
15 files changed, 1306 insertions, 0 deletions
diff --git a/target/linux/lantiq/base-files/etc/diag.sh b/target/linux/lantiq/base-files/etc/diag.sh
new file mode 100644
index 0000000..26f0a3c
--- /dev/null
+++ b/target/linux/lantiq/base-files/etc/diag.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+# Copyright (C) 2012-2013 OpenWrt.org
+
+. /lib/functions/leds.sh
+
+status_led="power"
+
+set_state() {
+ [ -d /sys/class/leds/power2/ ] && {
+
+ case "$1" in
+ preinit)
+ led_set_attr "power2" "trigger" "heartbeat"
+ status_led_on
+ ;;
+ failsafe)
+ led_off "power2"
+ status_led_set_timer 100 100
+ ;;
+ done)
+ led_off "power2"
+ ;;
+ esac
+ return
+ }
+
+ case "$1" in
+ preinit)
+ status_led_set_heartbeat
+ ;;
+ failsafe)
+ [ -d /sys/class/leds/power1 ] && {
+ status_led_off
+ led_timer "power1" 100 100
+ } || status_led_set_timer 100 100
+ ;;
+ done)
+ status_led_on
+ led_off "power1"
+ ;;
+ esac
+}
diff --git a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom
new file mode 100644
index 0000000..5f1cb00
--- /dev/null
+++ b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom
@@ -0,0 +1,60 @@
+#!/bin/sh
+# based on gabors ralink wisoc implementation
+
+rt2x00_eeprom_die() {
+ echo "rt2x00 eeprom: " "$*"
+ exit 1
+}
+
+rt2x00_eeprom_extract() {
+ local part=$1
+ local offset=$2
+ local count=$3
+ local swab=$4
+ local mtd
+
+ . /lib/functions.sh
+
+ mtd=$(find_mtd_part $part)
+ [ -n "$mtd" ] || \
+ rt2x00_eeprom_die "no mtd device found for partition $part"
+
+ if [ $swab -gt 0 ]; then
+ dd if=$mtd of=/lib/firmware/$FIRMWARE bs=2 skip=$offset count=$count conv=swab || \
+ rt2x00_eeprom_die "failed to extract from $mtd"
+ else
+ dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count || \
+ rt2x00_eeprom_die "failed to extract from $mtd"
+ fi
+}
+
+[ -e /lib/firmware/$FIRMWARE ] && exit 0
+. /lib/functions/lantiq.sh
+
+case "$FIRMWARE" in
+"RT2860.eeprom" )
+ local board=$(lantiq_board_name)
+ case $board in
+ ARV7510PW22|ARV7519PW|ARV752DPW|ARV752DPW22|VGV7519)
+ rt2x00_eeprom_extract "board_config" 520 256 1
+ ;;
+ ARV7525PW)
+ rt2x00_eeprom_extract "board_config" 1040 512 0
+ ;;
+ *)
+ rt2x00_eeprom_die "board $board is not supported yet"
+ ;;
+ esac
+ ;;
+"RT3062.eeprom" )
+ local board=$(lantiq_board_name)
+ case $board in
+ VGV7510KW22)
+ rt2x00_eeprom_extract "board_config" 520 256 1
+ ;;
+ *)
+ rt2x00_eeprom_die "board $board is not supported yet"
+ ;;
+ esac
+ ;;
+esac
diff --git a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
new file mode 100644
index 0000000..0d8084f
--- /dev/null
+++ b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
@@ -0,0 +1,51 @@
+#!/bin/sh
+# Based on ar71xx 11-ath10k-caldata and 10-rt2x00-eeprom
+
+ath10k_caldata_die() {
+ echo "ath10k caldata: " "$*"
+ exit 1
+}
+
+ath10k_caldata_extract() {
+ local part=$1
+ local offset=$2
+ local mtd
+
+ . /lib/functions.sh
+
+ mtd=$(find_mtd_part $part)
+ [ -n "$mtd" ] || \
+ ath10k_caldata_die "no mtd device found for partition $part"
+
+ dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=2116 || \
+ ath10k_caldata_die "failed to extract from $mtd"
+}
+
+ath10k_caldata_set_macaddr() {
+ local macaddr=$1
+
+ macaddr_2bin $macaddr | dd of=/lib/firmware/$FIRMWARE \
+ conv=notrunc bs=1 seek=6 count=6
+}
+
+[ -e /lib/firmware/$FIRMWARE ] && exit 0
+. /lib/functions.sh
+. /lib/functions/system.sh
+. /lib/functions/lantiq.sh
+
+case "$FIRMWARE" in
+"ath10k/cal-pci-0000:02:00.0.bin")
+ local board=$(lantiq_board_name)
+ case $board in
+ BTHOMEHUBV5A)
+ local lan_mac=$(mtd_get_mac_binary caldata 4364)
+ local wifi_mac=$(macaddr_add "$lan_mac" 3)
+ ath10k_caldata_extract "caldata" 20480
+ ath10k_caldata_set_macaddr $wifi_mac
+ ;;
+ *)
+ ath10k_caldata_die "board $board is not supported yet"
+ ;;
+ esac
+ ;;
+esac
diff --git a/target/linux/lantiq/base-files/etc/init.d/dsl_fs b/target/linux/lantiq/base-files/etc/init.d/dsl_fs
new file mode 100755
index 0000000..ccba4ae
--- /dev/null
+++ b/target/linux/lantiq/base-files/etc/init.d/dsl_fs
@@ -0,0 +1,35 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2014 OpenWrt.org
+
+. $IPKG_INSTROOT/lib/functions.sh
+
+START=30
+
+boot() {
+ MTD=$(find_mtd_index dsl_fw)
+
+ grep /lib/firmware/lantiq /proc/mounts && umount /lib/firmware/lantiq
+
+ mkdir -p /lib/firmware/lantiq
+ [ "$MTD" -gt 0 ] || return 0
+
+ mount -t tmpfs none /lib/firmware/lantiq
+ case "$(dd if=/dev/mtd$MTD bs=2 count=1 2>/dev/null | hexdump -n 2 -e '1/1 "%02x"')" in
+ 1985)
+ mkdir -p /tmp/fw_mnt
+ mount -t jffs2 /dev/mtdblock$MTD /tmp/fw_mnt
+ cp -a /tmp/fw_mnt/*.bin /lib/firmware/lantiq/
+ umount /tmp/fw_mnt
+ rmdir /tmp/fw_mnt
+ ;;
+ 1f8b)
+ tar xz -C /lib/firmware/lantiq < /dev/mtd$MTD
+ ;;
+ *)
+ echo "No DSL firmware detected in /dev/mtd$MTD (dsl_fw)"
+ return 0
+ ;;
+ esac
+
+ [ -e /lib/firmware/vdsl.bin ] || ln -s /lib/firmware/lantiq/vr9_dsl_fw_annex_b.bin /lib/firmware/vdsl.bin
+}
diff --git a/target/linux/lantiq/base-files/etc/init.d/esi b/target/linux/lantiq/base-files/etc/init.d/esi
new file mode 100755
index 0000000..ca79070
--- /dev/null
+++ b/target/linux/lantiq/base-files/etc/init.d/esi
@@ -0,0 +1,7 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2013 OpenWrt.org
+
+START=19
+start() {
+ esi $(printf '%012X' $((1+0x$(tr -d : </sys/class/net/eth0/address)))) 2>/dev/console || :
+}
diff --git a/target/linux/lantiq/base-files/etc/inittab b/target/linux/lantiq/base-files/etc/inittab
new file mode 100644
index 0000000..46a1312
--- /dev/null
+++ b/target/linux/lantiq/base-files/etc/inittab
@@ -0,0 +1,3 @@
+::sysinit:/etc/init.d/rcS S boot
+::shutdown:/etc/init.d/rcS K stop
+ttyLTQ0::askfirst:/bin/ash --login
diff --git a/target/linux/lantiq/base-files/etc/uci-defaults/01_leds b/target/linux/lantiq/base-files/etc/uci-defaults/01_leds
new file mode 100644
index 0000000..b9e5420
--- /dev/null
+++ b/target/linux/lantiq/base-files/etc/uci-defaults/01_leds
@@ -0,0 +1,77 @@
+#!/bin/sh
+#
+# Copyright (C) 2011 OpenWrt.org
+# based on ar71xx
+#
+
+. /lib/functions/uci-defaults.sh
+. /lib/functions/lantiq.sh
+
+[ -e "/sys/class/leds/wifi" ] && ucidef_set_led_wlan "wifi" "wifi" "wifi" "phy0tpt"
+[ -e "/sys/class/leds/usb" ] && ucidef_set_led_usbdev "usb" "usb" "usb" "1-1"
+[ -e "/sys/class/leds/usb2" ] && ucidef_set_led_usbdev "usb2" "usb2" "usb2" "2-1"
+[ -e "/sys/class/leds/internet" ] && ucidef_set_led_netdev "internet" "internet" "internet" "pppoe-wan"
+
+board=$(lantiq_board_name)
+
+case "$board" in
+VG3503J)
+ ucidef_set_led_netdev "vdsl" "vdsl" "bt:green:dsl" "ptm0"
+ ;;
+BTHOMEHUBV2B)
+ ucidef_set_led_default "power" "power" "soc:blue:power" "1"
+# ucidef_set_led_wlan "wifi" "wifi" "soc:blue:wireless" "phy0radio"
+ ucidef_set_led_wlan "wifi" "wifi" "soc:blue:wireless" "phy0tpt"
+ ucidef_set_led_netdev "internet" "internet" "soc:blue:broadband" "pppoa-wan"
+ ucidef_set_led_usbdev "usb" "usb" "soc:blue:phone" "1-1"
+ ;;
+BTHOMEHUBV3A|BTHOMEHUBV5A)
+ ucidef_set_led_default "power" "power" "soc:blue:power" "1"
+ ucidef_set_led_wlan "wifi" "wifi" "soc:blue:wireless" "phy0tpt"
+ ucidef_set_led_netdev "internet" "internet" "soc:blue:broadband" "pppoa-wan"
+ ;;
+VGV7510KW22)
+ ucidef_set_led_default "power" "power" "power" "1"
+ ucidef_set_led_default "power2" "power2" "power2" "0"
+ ucidef_set_led_wlan "wifi" "wifi" "wifi" "phy0radio"
+ ucidef_set_led_netdev "dsl" "dsl" "dsl" "nas0"
+ ucidef_set_led_netdev "internet_green" "internet_green" "internet_green" "pppoe-wan"
+ ;;
+VGV7519)
+ ucidef_set_led_default "power" "power" "power" "0"
+ ucidef_set_led_default "power2" "power2" "power2" "1"
+ ucidef_set_led_wlan "wireless_yellow" "wireless_yellow" "wireless_yellow" "phy0radio"
+ ucidef_set_led_netdev "internet_yellow" "internet_yellow" "internet_yellow" "nas0"
+ ucidef_set_led_netdev "broadband_yellow" "broadband_yellow" "broadband_yellow" "pppoe-wan"
+ ;;
+P2812HNUF*)
+ ucidef_set_led_default "power" "power" "power" "0"
+ ucidef_set_led_default "power2" "power2" "power2" "1"
+ ucidef_set_led_wlan "wireless_green" "wireless_green" "wireless_green" "phy0radio"
+ ucidef_set_led_netdev "dsl" "dsl" "dsl" "nas0"
+ ucidef_set_led_netdev "internet_green" "internet_green" "internet_green" "pppoe-wan"
+ ;;
+ARV7519RW22)
+ ucidef_set_led_default "power" "power" "power" "1"
+ ucidef_set_led_netdev "internet_green" "internet_green" "internet_green" "pppoe-wan"
+ ucidef_set_led_netdev "lan" "lan" "lan" "eth0.1"
+ ;;
+ARV8539PW22)
+ ucidef_set_led_default "power" "power" "soc:green:power" "1"
+ ucidef_set_led_default "power2" "power2" "soc:red:power" "0"
+ ucidef_set_led_wlan "wifi" "wifi" "soc:green:wireless" "phy0tpt"
+ ucidef_set_led_netdev "dsl" "dsl" "soc:green:dsl" "nas0"
+ ucidef_set_led_netdev "online" "online" "soc:green:online" "pppoe-wan"
+ ;;
+*)
+ ;;
+esac
+
+for a in `ls /sys/class/leds/`; do
+ grep -q "\[none\]" /sys/class/leds/$a/trigger
+ [ $? -eq 0 ] && ucidef_set_led_default $a $a $a `cat /sys/class/leds/$a/brightness`
+done
+
+ucidef_commit_leds
+
+exit 0
diff --git a/target/linux/lantiq/base-files/etc/uci-defaults/02_network b/target/linux/lantiq/base-files/etc/uci-defaults/02_network
new file mode 100644
index 0000000..b22060c
--- /dev/null
+++ b/target/linux/lantiq/base-files/etc/uci-defaults/02_network
@@ -0,0 +1,211 @@
+#!/bin/sh
+#
+# Copyright (C) 2011-2012 OpenWrt.org
+#
+
+[ -e /etc/config/network ] && exit 0
+
+set_atm_wan() {
+ local vpi=$1
+ local vci=$2
+ local encaps=$3
+ local payload=$4
+ uci batch <<EOF
+set network.atm='atm-bridge'
+set network.atm.vpi='$vpi'
+set network.atm.vci='$vci'
+set network.atm.encaps='$encaps'
+set network.atm.payload='$payload'
+set network.wan='interface'
+set network.wan.ifname='nas0'
+set network.wan.proto='pppoe'
+set network.wan.username='foo'
+set network.wan.password='bar'
+set network.wan.ipv6='1'
+set network.wan6='interface'
+set network.wan6.ifname='@wan'
+set network.wan6.proto='dhcpv6'
+EOF
+}
+
+set_adsl_modem() {
+ local annex=$1
+ local firmware=$2
+ uci batch <<EOF
+set network.dsl='adsl'
+set network.dsl.annex='$annex'
+set network.dsl.firmware='$firmware'
+EOF
+}
+
+set_vdsl_modem() {
+ local annex=$1
+ local firmware=$2
+ local tone=$3
+ local xfer_mode=$4
+ uci batch <<EOF
+set network.dsl='vdsl'
+set network.dsl.annex='$annex'
+set network.dsl.firmware='$firmware'
+set network.dsl.tone='$tone'
+set network.dsl.xfer_mode='$xfer_mode'
+EOF
+}
+
+. /lib/functions/uci-defaults.sh
+. /lib/functions/lantiq.sh
+
+touch /etc/config/network
+
+ucidef_set_interface_loopback
+ucidef_set_interface_lan 'eth0'
+
+vpi=1
+vci=32
+annex="a"
+encaps="llc"
+payload="bridged"
+lan_mac=""
+wan_mac=""
+
+board=$(lantiq_board_name)
+
+case "$board" in
+# adm6996
+ARV4510PW)
+ lan_mac=$(mtd_get_mac_ascii uboot_env ethaddr)
+ wan_mac=$(macaddr_add "$lan_mac" 1)
+ ucidef_set_interface_lan "eth0.1"
+ ucidef_add_switch "switch0" "1" "1"
+ ucidef_add_switch_vlan "switch0" "1" "3 2 1 0 5t"
+ ;;
+
+ARV4520PW)
+ ucidef_set_interface_lan "eth0.1"
+ ucidef_add_switch "switch0" "1" "1"
+ ucidef_add_switch_vlan "switch0" "1" "3 2 1 0 5t"
+ ;;
+
+ACMP252|GIGASX76X)
+ ucidef_set_interface_lan "eth0.1"
+ ucidef_add_switch "switch0" "1" "1"
+ ucidef_add_switch_vlan "switch0" "1" "4 3 2 1 5t"
+ ;;
+
+# ar8316
+ARV4519PW|ARV7510PW22|ARV7518PW|ARV752DPW22|ARV8539PW22)
+ ucidef_set_interface_lan "eth0.1"
+ ucidef_add_switch "switch0" "1" "1"
+ ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
+ ;;
+
+# rtl8306g
+ARV7519PW)
+ lan_mac=$(mtd_get_mac_binary board_config 22)
+ wan_mac=$(macaddr_add "$lan_mac" 1)
+ ucidef_set_interface_lan "eth0.1"
+ ucidef_add_switch "switch0" "1" "1"
+ ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4t"
+ ;;
+
+WBMR)
+ ucidef_set_interface_lan "eth0.1"
+ ucidef_add_switch "switch0" "1" "1"
+ ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
+ ;;
+
+VG3503J)
+ ucidef_set_interface_lan 'eth0'
+ uci set network.lan.type='none'
+ ;;
+
+DGN3500*)
+ ucidef_set_interface_lan "eth0.1"
+ ucidef_add_switch "switch0" "1" "1"
+ ucidef_add_switch_vlan "switch0" "1" "3 2 1 0 5t"
+ ;;
+
+GR7000)
+ ucidef_set_interface_wan "eth0"
+ uci set network.lan.ifname=''
+ ;;
+
+H201L)
+ ucidef_set_interface_lan "eth0.1"
+ ucidef_add_switch "switch0" "1" "1"
+ ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4t"
+ ;;
+
+#rtl8306g
+P2601HNFX)
+ ucidef_set_interface_lan "eth0.1"
+ ucidef_add_switch "switch0" "1" "1"
+ ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
+ ;;
+
+P2812HNUF*)
+ lan_mac=$(mtd_get_mac_ascii uboot-env ethaddr)
+ wan_mac=$(macaddr_add "$lan_mac" 1)
+ ucidef_set_interface_lan 'eth0.1'
+ ucidef_add_switch "switch0" "1" "1"
+ ucidef_add_switch_vlan "switch0" "1" "0 1 2 4 5 6t"
+ ;;
+
+TDW8970|TDW8980)
+ lan_mac=$(mtd_get_mac_binary boardconfig 61696)
+ wan_mac=$(macaddr_add "$lan_mac" 1)
+ ucidef_set_interface_lan 'eth0.1'
+ ucidef_add_switch "switch0" "1" "1"
+ ucidef_add_switch_vlan "switch0" "1" "0 2 4 5 6t"
+ ;;
+
+ARV7519RW22)
+ lan_mac=$(mtd_get_mac_binary boardconfig 22)
+ wan_mac=$(macaddr_add "$lan_mac" 1)
+ ucidef_set_interface_lan "eth0.1"
+ ucidef_add_switch "switch0" "1" "1"
+ ucidef_add_switch_vlan "switch0" "1" "0 2 3 4 5 6t"
+ ;;
+
+BTHOMEHUBV2B|BTHOMEHUBV3A)
+ lan_mac=$(mtd_get_mac_ascii uboot_env ethaddr)
+ wan_mac=$(macaddr_add "$lan_mac" 1)
+ ;;
+
+BTHOMEHUBV5A)
+ lan_mac=$(mtd_get_mac_binary caldata 4364)
+ wan_mac=$(macaddr_add "$lan_mac" 1)
+ ucidef_set_interface_lan 'eth0.1'
+ ucidef_add_switch "switch0" "1" "1"
+ ucidef_add_switch_vlan "switch0" "1" "0 1 2 4 6t"
+ ;;
+
+VGV7519)
+ lan_mac=$(mtd_get_mac_binary board_config 22)
+ wan_mac=$(macaddr_add "$lan_mac" 1)
+ ;;
+
+VGV7510KW22)
+ lan_mac=$(mtd_get_mac_binary board_config 22)
+ wan_mac=$(macaddr_add "$lan_mac" 1)
+ ucidef_set_interface_lan 'eth0.1'
+ ucidef_add_switch "switch0" "1" "1"
+ ucidef_add_switch_vlan "switch0" "1" "2 3 4 5 6t"
+ ;;
+
+esac
+
+[ -z "$(ls /lib/modules/`uname -r`/ltq_atm*)" ] || set_atm_wan "$vpi" "$vci" "$encaps" "$payload"
+
+if [ -n "$(grep "system type.*: VR9" /proc/cpuinfo)" ]; then
+ set_vdsl_modem "$annex" "/lib/firmware/vdsl.bin" "av" "ptm"
+else
+ set_adsl_modem "$annex" "/lib/firmware/adsl.bin"
+fi
+
+[ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac
+[ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac
+
+uci commit network
+
+exit 0
diff --git a/target/linux/lantiq/base-files/etc/uci-defaults/03_wireless-wps b/target/linux/lantiq/base-files/etc/uci-defaults/03_wireless-wps
new file mode 100644
index 0000000..e75fb84
--- /dev/null
+++ b/target/linux/lantiq/base-files/etc/uci-defaults/03_wireless-wps
@@ -0,0 +1,16 @@
+. /lib/functions.sh
+. /lib/functions/lantiq.sh
+
+set_wps() {
+ uci set wireless.$1.wps_pushbutton=0
+ uci set wireless.$1.wps_device_name="OpenWrt - $(lantiq_board_model)"
+}
+
+board=$(lantiq_board_name)
+case $board in
+WBMR)
+ config_load wireless
+ config_foreach set_wps wifi-iface
+ uci commit wireless
+ ;;
+esac
diff --git a/target/linux/lantiq/base-files/lib/functions/lantiq.sh b/target/linux/lantiq/base-files/lib/functions/lantiq.sh
new file mode 100644
index 0000000..88da794
--- /dev/null
+++ b/target/linux/lantiq/base-files/lib/functions/lantiq.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+lantiq_board_detect() {
+ name=`grep "^machine" /proc/cpuinfo | sed "s/machine.*: \(.*\)/\1/g" | sed "s/\(.*\) - .*/\1/g"`
+ model=`grep "^machine" /proc/cpuinfo | sed "s/machine.*: \(.*\)/\1/g" | sed "s/.* - \(.*\)/\1/g"`
+ [ -z "$name" ] && name="unknown"
+ [ -z "$model" ] && model="unknown"
+ [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
+ echo $name > /tmp/sysinfo/board_name
+ echo $model > /tmp/sysinfo/model
+}
+
+lantiq_board_model() {
+ local model
+
+ [ -f /tmp/sysinfo/model ] && model=$(cat /tmp/sysinfo/model)
+ [ -z "$model" ] && model="unknown"
+
+ echo "$model"
+}
+
+lantiq_board_name() {
+ local name
+
+ [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
+ [ -z "$name" ] && name="unknown"
+
+ echo "$name"
+}
diff --git a/target/linux/lantiq/base-files/lib/functions/lantiq_dsl.sh b/target/linux/lantiq/base-files/lib/functions/lantiq_dsl.sh
new file mode 100755
index 0000000..22e65cb
--- /dev/null
+++ b/target/linux/lantiq/base-files/lib/functions/lantiq_dsl.sh
@@ -0,0 +1,640 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2012-2014 OpenWrt.org
+
+if [ "$( which vdsl_cpe_control )" ]; then
+ XDSL_CTRL=vdsl_cpe_control
+else
+ XDSL_CTRL=dsl_cpe_control
+fi
+
+#
+# Basic functions to send CLI commands to the vdsl_cpe_control daemon
+#
+dsl_cmd() {
+ killall -0 ${XDSL_CTRL} && (
+ lock /var/lock/dsl_pipe
+ echo "$@" > /tmp/pipe/dsl_cpe0_cmd
+ cat /tmp/pipe/dsl_cpe0_ack
+ lock -u /var/lock/dsl_pipe
+ )
+}
+dsl_val() {
+ echo $(expr "$1" : '.*'$2'=\([-\.[:alnum:]]*\).*')
+}
+dsl_string() {
+ echo $(expr "$1" : '.*'$2'=(\([A-Z0-9,]*\))')
+}
+
+#
+# Simple divide by 10 routine to cope with one decimal place
+#
+dbt() {
+ local a=$(expr $1 / 10)
+ local b=$(expr $1 % 10)
+ echo "${a}.${b}"
+}
+#
+# Take a number and convert to k or meg
+#
+scale() {
+ local val=$1
+ local a
+ local b
+
+ if [ "$val" -gt 1000000 ]; then
+ a=$(expr $val / 1000)
+ b=$(expr $a % 1000)
+ a=$(expr $a / 1000)
+ printf "%d.%03d Mb" ${a} ${b}
+ elif [ "$val" -gt 1000 ]; then
+ a=$(expr $val / 1000)
+ printf "%d Kb" ${a}
+ else
+ echo "${val} b"
+ fi
+}
+
+scale_latency() {
+ local val=$1
+ local a
+ local b
+
+ a=$(expr $val / 100)
+ b=$(expr $val % 100)
+ printf "%d.%d ms" ${a} ${b}
+}
+
+#
+# Read the data rates for both directions
+#
+data_rates() {
+ local csg
+ local dru
+ local drd
+ local sdru
+ local sdrd
+
+ csg=$(dsl_cmd g997csg 0 1)
+ drd=$(dsl_val "$csg" ActualDataRate)
+
+ csg=$(dsl_cmd g997csg 0 0)
+ dru=$(dsl_val "$csg" ActualDataRate)
+
+ [ -z "$drd" ] && drd=0
+ [ -z "$dru" ] && dru=0
+
+ sdrd=$(scale $drd)
+ sdru=$(scale $dru)
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.data_rate_down=$drd"
+ echo "dsl.data_rate_up=$dru"
+ echo "dsl.data_rate_down_s=\"$sdrd\""
+ echo "dsl.data_rate_up_s=\"$sdru\""
+ else
+ echo "Data Rate: Down: ${sdrd}/s / Up: ${sdru}/s"
+ fi
+}
+
+#
+# Chipset
+#
+chipset() {
+ local vig
+ local cs
+ local csv
+
+ vig=$(dsl_cmd vig)
+ cs=$(dsl_val "$vig" DSL_ChipSetType)
+ csv=$(dsl_val "$vig" DSL_ChipSetHWVersion)
+ csfw=$(dsl_val "$vig" DSL_ChipSetFWVersion)
+ csapi=$(dsl_val "$vig" DSL_DriverVersionApi)
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.chipset=\"${cs} ${csv}\""
+ echo "dsl.firmware_version=\"${csfw}\""
+ echo "dsl.api_version=\"${csapi}\""
+ else
+ echo "Chipset: ${cs} ${csv}"
+ echo "Firmware Version: ${csfw}"
+ echo "API Version: ${csapi}"
+ fi
+}
+
+#
+# Vendor information
+#
+vendor() {
+ local lig
+ local vid
+ local svid
+
+ lig=$(dsl_cmd g997lig 1)
+ vid=$(dsl_string "$lig" G994VendorID)
+ svid=$(dsl_string "$lig" SystemVendorID)
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.atuc_vendor_id=\"${vid}\""
+ echo "dsl.atuc_system_vendor_id=\"${svid}\""
+ else
+ echo "ATU-C Vendor ID: ${vid}"
+ echo "ATU-C System Vendor ID: ${svid}"
+ fi
+}
+
+#
+# XTSE capabilities
+#
+xtse() {
+ local xtusesg
+ local xtse1
+ local xtse2
+ local xtse3
+ local xtse4
+ local xtse5
+ local xtse6
+ local xtse7
+ local xtse8
+
+ local xtse_s=""
+
+ local annex_s=""
+ local line_mode_s=""
+ local cmd=""
+
+ xtusesg=$(dsl_cmd g997xtusesg)
+ xtse1=$(dsl_val "$xtusesg" XTSE1)
+ xtse2=$(dsl_val "$xtusesg" XTSE2)
+ xtse3=$(dsl_val "$xtusesg" XTSE3)
+ xtse4=$(dsl_val "$xtusesg" XTSE4)
+ xtse5=$(dsl_val "$xtusesg" XTSE5)
+ xtse6=$(dsl_val "$xtusesg" XTSE6)
+ xtse7=$(dsl_val "$xtusesg" XTSE7)
+ xtse8=$(dsl_val "$xtusesg" XTSE8)
+
+ # Evaluate Annex (according to G.997.1, 7.3.1.1.1)
+ if [ $((xtse1 & 13)) != 0 \
+ -o $((xtse2 & 1)) != 0 \
+ -o $((xtse3 & 12)) != 0 \
+ -o $((xtse4 & 3)) != 0 \
+ -o $((xtse6 & 3)) != 0 \
+ -o $((xtse8 & 1)) != 0 ]; then
+ annex_s=" A,"
+ fi
+
+ if [ $((xtse1 & 48)) != 0 \
+ -o $((xtse2 & 2)) != 0 \
+ -o $((xtse3 & 48)) != 0 \
+ -o $((xtse6 & 12)) != 0 \
+ -o $((xtse8 & 2)) != 0 ]; then
+ annex_s="$annex_s B,"
+ fi
+
+ if [ $((xtse1 & 194)) != 0 \
+ -o $((xtse2 & 12)) != 0 \
+ -o $((xtse8 & 4)) != 0 ]; then
+ annex_s="$annex_s C,"
+ fi
+
+ if [ $((xtse4 & 48)) != 0 \
+ -o $((xtse5 & 3)) != 0 \
+ -o $((xtse6 & 192)) != 0 ]; then
+ annex_s="$annex_s I,"
+ fi
+
+ if [ $((xtse4 & 192)) != 0 \
+ -o $((xtse7 & 3)) != 0 ]; then
+ annex_s="$annex_s J,"
+ fi
+
+ if [ $((xtse5 & 60)) != 0 ]; then
+ annex_s="$annex_s L,"
+ fi
+
+ if [ $((xtse5 & 192)) != 0 \
+ -o $((xtse7 & 12)) != 0 ]; then
+ annex_s="$annex_s M,"
+ fi
+
+ annex_s=`echo ${annex_s:1}`
+ annex_s=`echo ${annex_s%?}`
+
+ # Evaluate Line Mode (according to G.997.1, 7.3.1.1.1)
+
+ # Regional standard: ANSI T1.413
+ if [ $((xtse1 & 1)) != 0 ]; then
+ line_mode_s=" T1.413,"
+ fi
+
+ # Regional standard: TS 101 388
+ if [ $((xtse1 & 1)) != 0 ]; then
+ line_mode_s="$line_mode_s TS 101 388,"
+ fi
+
+ if [ $((xtse1 & 252)) != 0 ]; then
+ line_mode_s="$line_mode_s G.992.1 (ADSL),"
+ fi
+
+ if [ $((xtse2 & 15)) != 0 ]; then
+ line_mode_s="$line_mode_s G.992.2 (ADSL lite),"
+ fi
+
+ if [ $((xtse3 & 60)) != 0 \
+ -o $((xtse4 & 240)) != 0 \
+ -o $((xtse5 & 252)) != 0 ]; then
+ line_mode_s="$line_mode_s G.992.3 (ADSL2),"
+ fi
+
+ if [ $((xtse4 & 3)) != 0 \
+ -o $((xtse5 & 3)) != 0 ]; then
+ line_mode_s="$line_mode_s G.992.4 (ADSL2 lite),"
+ fi
+
+ if [ $((xtse6 & 199)) != 0 \
+ -o $((xtse7 & 15)) != 0 ]; then
+ line_mode_s="$line_mode_s G.992.5 (ADSL2+),"
+ fi
+
+ if [ $((xtse8 & 7)) != 0 ]; then
+ line_mode_s="$line_mode_s G.993.2 (VDSL2),"
+ fi
+
+ #!!! PROPRIETARY & INTERMEDIATE USE !!!
+ if [ $((xtse8 & 128)) != 0 ]; then
+ line_mode_s="$line_mode_s G.993.1 (VDSL),"
+ fi
+
+ line_mode_s=`echo ${line_mode_s:1}`
+ line_mode_s=`echo ${line_mode_s%?}`
+
+ xtse_s="${xtse1}, ${xtse2}, ${xtse3}, ${xtse4}, ${xtse5}, ${xtse6}, ${xtse7}, ${xtse8}"
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.xtse1=${xtse1:-nil}"
+ echo "dsl.xtse2=${xtse2:-nil}"
+ echo "dsl.xtse3=${xtse3:-nil}"
+ echo "dsl.xtse4=${xtse4:-nil}"
+ echo "dsl.xtse5=${xtse5:-nil}"
+ echo "dsl.xtse6=${xtse6:-nil}"
+ echo "dsl.xtse7=${xtse7:-nil}"
+ echo "dsl.xtse8=${xtse8:-nil}"
+ echo "dsl.xtse_s=\"$xtse_s\""
+ echo "dsl.annex_s=\"${annex_s}\""
+ echo "dsl.line_mode_s=\"${line_mode_s}\""
+ else
+ echo "XTSE Capabilities: ${xtse_s}"
+ echo "Annex: ${annex_s}"
+ echo "Line Mode: ${line_mode_s}"
+ fi
+}
+
+#
+# Power Management Mode
+#
+power_mode() {
+ local pmsg=$(dsl_cmd g997pmsg)
+ local pm=$(dsl_val "$pmsg" nPowerManagementStatus);
+ local s;
+
+ case "$pm" in
+ "-1") s="Power management state is not available" ;;
+ "0") s="L0 - Synchronized" ;;
+ "1") s="L1 - Power Down Data transmission (G.992.2)" ;;
+ "2") s="L2 - Power Down Data transmission (G.992.3 and G.992.4)" ;;
+ "3") s="L3 - No power" ;;
+ *) s="unknown" ;;
+ esac
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.power_mode_num=${pm:-nil}"
+ echo "dsl.power_mode_s=\"$s\""
+ else
+ echo "Power Management Mode: $s"
+ fi
+}
+
+#
+# Latency type (interleave delay)
+#
+latency_delay() {
+ local csg
+
+ local idu
+ local idu_s;
+ local sidu
+
+ local idd
+ local idd_s;
+ local sidd
+
+ csg=$(dsl_cmd g997csg 0 1)
+ idd=$(dsl_val "$csg" ActualInterleaveDelay)
+
+ csg=$(dsl_cmd g997csg 0 0)
+ idu=$(dsl_val "$csg" ActualInterleaveDelay)
+
+ [ -z "$idd" ] && idd=0
+ [ -z "$idu" ] && idu=0
+
+ if [ "$idd" > 100 ]; then
+ idd_s="Interleave"
+ else
+ idd_s="Fast"
+ fi
+
+ if [ "$idu" > 100 ]; then
+ idu_s="Interleave"
+ else
+ idu_s="Fast"
+ fi
+
+ sidu=$(scale_latency $idu)
+ sidd=$(scale_latency $idd)
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.latency_num_down=\"$sidu\""
+ echo "dsl.latency_num_up=\"$sidd\""
+ echo "dsl.latency_s_down=\"$idd_s\""
+ echo "dsl.latency_s_up=\"$idu_s\""
+ else
+ echo "Latency / Interleave Delay: Down: ${idd_s} (${sidd}) / Up: ${idu_s} (${sidu})"
+ fi
+}
+
+#
+# Errors
+#
+errors() {
+ local lsctg
+ local dpctg
+ local ccsg
+ local esf
+ local esn
+ local sesf
+ local sesn
+ local lossf
+ local lossn
+ local uasf
+ local uasn
+
+ local crc_pf
+ local crc_pn
+ local crcp_pf
+ local crcp_pn
+ local hecf
+ local hecn
+
+ local fecn
+ local fecf
+
+ lsctg=$(dsl_cmd pmlsctg 1)
+ esf=$(dsl_val "$lsctg" nES)
+ sesf=$(dsl_val "$lsctg" nSES)
+ lossf=$(dsl_val "$lsctg" nLOSS)
+ uasf=$(dsl_val "$lsctg" nUAS)
+
+ lsctg=$(dsl_cmd pmlsctg 0)
+ esn=$(dsl_val "$lsctg" nES)
+ sesn=$(dsl_val "$lsctg" nSES)
+ lossn=$(dsl_val "$lsctg" nLOSS)
+ uasn=$(dsl_val "$lsctg" nUAS)
+
+ dpctg=$(dsl_cmd pmdpctg 0 1)
+ hecf=$(dsl_val "$dpctg" nHEC)
+ crc_pf=$(dsl_val "$dpctg" nCRC_P)
+ crcp_pf=$(dsl_val "$dpctg" nCRCP_P)
+
+ dpctg=$(dsl_cmd pmdpctg 0 0)
+ hecn=$(dsl_val "$dpctg" nHEC)
+ crc_pn=$(dsl_val "$dpctg" nCRC_P)
+ crcp_pn=$(dsl_val "$dpctg" nCRCP_P)
+
+ ccsg=$(dsl_cmd pmccsg 0 1 0)
+ fecf=$(dsl_val "$ccsg" nFEC)
+
+ ccsg=$(dsl_cmd pmccsg 0 0 0)
+ fecn=$(dsl_val "$ccsg" nFEC)
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.errors_fec_near=${fecn:-nil}"
+ echo "dsl.errors_fec_far=${fecf:-nil}"
+ echo "dsl.errors_es_near=${esn:-nil}"
+ echo "dsl.errors_es_far=${esf:-nil}"
+ echo "dsl.errors_ses_near=${sesn:-nil}"
+ echo "dsl.errors_ses_far=${sesf:-nil}"
+ echo "dsl.errors_loss_near=${lossn:-nil}"
+ echo "dsl.errors_loss_far=${lossf:-nil}"
+ echo "dsl.errors_uas_near=${uasn:-nil}"
+ echo "dsl.errors_uas_far=${uasf:-nil}"
+ echo "dsl.errors_hec_near=${hecn:-nil}"
+ echo "dsl.errors_hec_far=${hecf:-nil}"
+ echo "dsl.errors_crc_p_near=${crc_pn:-nil}"
+ echo "dsl.errors_crc_p_far=${crc_pf:-nil}"
+ echo "dsl.errors_crcp_p_near=${crcp_pn:-nil}"
+ echo "dsl.errors_crcp_p_far=${crcp_pf:-nil}"
+ else
+ echo "Forward Error Correction Seconds (FECS): Near: ${fecn} / Far: ${fecf}"
+ echo "Errored seconds (ES): Near: ${esn} / Far: ${esf}"
+ echo "Severely Errored Seconds (SES): Near: ${sesn} / Far: ${sesf}"
+ echo "Loss of Signal Seconds (LOSS): Near: ${lossn} / Far: ${lossf}"
+ echo "Unavailable Seconds (UAS): Near: ${uasn} / Far: ${uasf}"
+ echo "Header Error Code Errors (HEC): Near: ${hecn} / Far: ${hecf}"
+ echo "Non Pre-emtive CRC errors (CRC_P): Near: ${crc_pn} / Far: ${crc_pf}"
+ echo "Pre-emtive CRC errors (CRCP_P): Near: ${crcp_pn} / Far: ${crcp_pf}"
+ fi
+}
+
+#
+# Work out how long the line has been up
+#
+line_uptime() {
+ local ccsg
+ local et
+ local etr
+ local d
+ local h
+ local m
+ local s
+ local rc=""
+
+ ccsg=$(dsl_cmd pmccsg 0 0 0)
+ et=$(dsl_val "$ccsg" nElapsedTime)
+
+ [ -z "$et" ] && et=0
+
+ d=$(expr $et / 86400)
+ etr=$(expr $et % 86400)
+ h=$(expr $etr / 3600)
+ etr=$(expr $etr % 3600)
+ m=$(expr $etr / 60)
+ s=$(expr $etr % 60)
+
+
+ [ "${d}${h}${m}${s}" -ne 0 ] && rc="${s}s"
+ [ "${d}${h}${m}" -ne 0 ] && rc="${m}m ${rc}"
+ [ "${d}${h}" -ne 0 ] && rc="${h}h ${rc}"
+ [ "${d}" -ne 0 ] && rc="${d}d ${rc}"
+
+ [ -z "$rc" ] && rc="down"
+
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.line_uptime=${et}"
+ echo "dsl.line_uptime_s=\"${rc}\""
+ else
+
+ echo "Line Uptime Seconds: ${et}"
+ echo "Line Uptime: ${rc}"
+ fi
+}
+
+#
+# Get noise and attenuation figures
+#
+line_data() {
+ local lsg
+ local latnu
+ local latnd
+ local satnu
+ local satnd
+ local snru
+ local snrd
+ local attndru
+ local attndrd
+ local sattndru
+ local sattndrd
+ local actatpu
+ local actatpd
+
+ lsg=$(dsl_cmd g997lsg 1 1)
+ latnd=$(dsl_val "$lsg" LATN)
+ satnd=$(dsl_val "$lsg" SATN)
+ snrd=$(dsl_val "$lsg" SNR)
+ attndrd=$(dsl_val "$lsg" ATTNDR)
+ actatpd=$(dsl_val "$lsg" ACTATP)
+
+ lsg=$(dsl_cmd g997lsg 0 1)
+ latnu=$(dsl_val "$lsg" LATN)
+ satnu=$(dsl_val "$lsg" SATN)
+ snru=$(dsl_val "$lsg" SNR)
+ attndru=$(dsl_val "$lsg" ATTNDR)
+ actatpu=$(dsl_val "$lsg" ACTATP)
+
+ [ -z "$latnd" ] && latnd=0
+ [ -z "$latnu" ] && latnu=0
+ [ -z "$satnd" ] && satnd=0
+ [ -z "$satnu" ] && satnu=0
+ [ -z "$snrd" ] && snrd=0
+ [ -z "$snru" ] && snru=0
+ [ -z "$actatpd" ] && actatpd=0
+ [ -z "$actatpu" ] && actatpu=0
+
+ latnd=$(dbt $latnd)
+ latnu=$(dbt $latnu)
+ satnd=$(dbt $satnd)
+ satnu=$(dbt $satnu)
+ snrd=$(dbt $snrd)
+ snru=$(dbt $snru)
+ actatpd=$(dbt $actatpd)
+ actatpu=$(dbt $actatpu)
+
+ [ -z "$attndrd" ] && attndrd=0
+ [ -z "$attndru" ] && attndru=0
+
+ sattndrd=$(scale $attndrd)
+ sattndru=$(scale $attndru)
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.line_attenuation_down=$latnd"
+ echo "dsl.line_attenuation_up=$latnu"
+ echo "dsl.noise_margin_down=$snrd"
+ echo "dsl.noise_margin_up=$snru"
+ echo "dsl.signal_attenuation_down=$satnd"
+ echo "dsl.signal_attenuation_up=$satnu"
+ echo "dsl.actatp_down=$actatpd"
+ echo "dsl.actatp_up=$actatpu"
+ echo "dsl.max_data_rate_down=$attndrd"
+ echo "dsl.max_data_rate_up=$attndru"
+ echo "dsl.max_data_rate_down_s=\"$sattndrd\""
+ echo "dsl.max_data_rate_up_s=\"$sattndru\""
+ else
+ echo "Line Attenuation (LATN): Down: ${latnd}dB / Up: ${latnu}dB"
+ echo "Signal Attenuation (SATN): Down: ${satnd}dB / Up: ${satnu}dB"
+ echo "Noise Margin (SNR): Down: ${snrd}dB / Up: ${snru}dB"
+ echo "Aggregate Transmit Power(ACTATP): Down: ${actatpd}dB / Up: ${actatpu}dB"
+ echo "Max. Attainable Data Rate (ATTNDR): Down: ${sattndrd}/s / Up: ${sattndru}/s"
+ fi
+}
+
+#
+# Is the line up? Or what state is it in?
+#
+line_state() {
+ local lsg=$(dsl_cmd lsg)
+ local ls=$(dsl_val "$lsg" nLineState);
+ local s;
+
+ case "$ls" in
+ "0x0") s="not initialized" ;;
+ "0x1") s="exception" ;;
+ "0x10") s="not updated" ;;
+ "0xff") s="idle request" ;;
+ "0x100") s="idle" ;;
+ "0x1ff") s="silent request" ;;
+ "0x200") s="silent" ;;
+ "0x300") s="handshake" ;;
+ "0x380") s="full_init" ;;
+ "0x400") s="discovery" ;;
+ "0x500") s="training" ;;
+ "0x600") s="analysis" ;;
+ "0x700") s="exchange" ;;
+ "0x800") s="showtime_no_sync" ;;
+ "0x801") s="showtime_tc_sync" ;;
+ "0x900") s="fastretrain" ;;
+ "0xa00") s="lowpower_l2" ;;
+ "0xb00") s="loopdiagnostic active" ;;
+ "0xb10") s="loopdiagnostic data exchange" ;;
+ "0xb20") s="loopdiagnostic data request" ;;
+ "0xc00") s="loopdiagnostic complete" ;;
+ "0x1000000") s="test" ;;
+ "0xd00") s="resync" ;;
+ "0x3c0") s="short init entry" ;;
+ "") s="not running daemon"; ls="0xfff" ;;
+ *) s="unknown" ;;
+ esac
+
+ if [ "$action" = "lucistat" ]; then
+ echo "dsl.line_state_num=$ls"
+ echo "dsl.line_state_detail=\"$s\""
+ if [ "$ls" = "0x801" ]; then
+ echo "dsl.line_state=\"UP\""
+ else
+ echo "dsl.line_state=\"DOWN\""
+ fi
+ else
+ if [ "$ls" = "0x801" ]; then
+ echo "Line State: UP [$ls: $s]"
+ else
+ echo "Line State: DOWN [$ls: $s]"
+ fi
+ fi
+}
+
+status() {
+ vendor
+ chipset
+ xtse
+ line_state
+ errors
+ power_mode
+ latency_delay
+ data_rates
+ line_data
+ line_uptime
+}
+
+lucistat() {
+ echo "local dsl={}"
+ status
+ echo "return dsl"
+}
diff --git a/target/linux/lantiq/base-files/lib/preinit/03_preinit_board.sh b/target/linux/lantiq/base-files/lib/preinit/03_preinit_board.sh
new file mode 100755
index 0000000..6d4bd67
--- /dev/null
+++ b/target/linux/lantiq/base-files/lib/preinit/03_preinit_board.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+do_lantiq() {
+ . /lib/functions/lantiq.sh
+
+ lantiq_board_detect
+}
+
+boot_hook_add preinit_main do_lantiq
diff --git a/target/linux/lantiq/base-files/lib/preinit/05_set_preinit_iface_lantiq b/target/linux/lantiq/base-files/lib/preinit/05_set_preinit_iface_lantiq
new file mode 100644
index 0000000..3d7fabf
--- /dev/null
+++ b/target/linux/lantiq/base-files/lib/preinit/05_set_preinit_iface_lantiq
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+. /lib/functions/lantiq.sh
+
+set_preinit_iface() {
+
+ board=$(lantiq_board_name)
+
+ case "$board" in
+ TDW8970)
+ ifname=eth0
+ ;;
+ esac
+
+}
+
+boot_hook_add preinit_main set_preinit_iface
+
diff --git a/target/linux/lantiq/base-files/lib/upgrade/platform.sh b/target/linux/lantiq/base-files/lib/upgrade/platform.sh
new file mode 100755
index 0000000..e876b11
--- /dev/null
+++ b/target/linux/lantiq/base-files/lib/upgrade/platform.sh
@@ -0,0 +1,47 @@
+. /lib/functions/lantiq.sh
+
+PART_NAME=firmware
+
+platform_check_image() {
+ [ "$#" -gt 1 ] && return 1
+ local board=$(lantiq_board_name)
+
+ case "$board" in
+ BTHOMEHUBV2B|BTHOMEHUBV3A|BTHOMEHUBV5A|P2812HNUF* )
+ nand_do_platform_check $board $1
+ return $?;
+ ;;
+ esac
+
+ case "$(get_magic_word "$1")" in
+ # uImage
+ 2705) return 0;;
+ # tplink
+ 0200) return 0;;
+ *)
+ echo "Invalid image type"
+ return 1
+ ;;
+ esac
+}
+
+platform_pre_upgrade() {
+ local board=$(lantiq_board_name)
+
+ case "$board" in
+ BTHOMEHUBV2B|BTHOMEHUBV3A|BTHOMEHUBV5A|P2812HNUF* )
+ nand_do_upgrade $1
+ ;;
+ esac
+}
+
+# use default for platform_do_upgrade()
+
+disable_watchdog() {
+ killall watchdog
+ ( ps | grep -v 'grep' | grep '/dev/watchdog' ) && {
+ echo 'Could not disable watchdog'
+ return 1
+ }
+}
+append sysupgrade_pre_upgrade disable_watchdog
diff --git a/target/linux/lantiq/base-files/sbin/dsl_notify.sh b/target/linux/lantiq/base-files/sbin/dsl_notify.sh
new file mode 100755
index 0000000..b514e25
--- /dev/null
+++ b/target/linux/lantiq/base-files/sbin/dsl_notify.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+#
+# This script is called by dsl_cpe_control whenever there is a DSL event,
+# we only actually care about the DSL_INTERFACE_STATUS events as these
+# tell us the line has either come up or gone down.
+#
+# The rest of the code is basically the same at the atm hotplug code
+#
+
+[ "$DSL_NOTIFICATION_TYPE" = "DSL_INTERFACE_STATUS" ] || exit 0
+
+. /usr/share/libubox/jshn.sh
+. /lib/functions.sh
+. /lib/functions/leds.sh
+
+include /lib/network
+scan_interfaces
+
+local default
+config_load system
+config_get default led_adsl default
+if [ "$default" != 1 ]; then
+ case "$DSL_INTERFACE_STATUS" in
+ "HANDSHAKE") led_timer dsl 500 500;;
+ "TRAINING") led_timer dsl 200 200;;
+ "UP") led_on dsl;;
+ *) led_off dsl
+ esac
+fi
+
+local interfaces=`ubus list network.interface.\* | cut -d"." -f3`
+local ifc
+for ifc in $interfaces; do
+
+ local up
+ json_load "$(ifstatus $ifc)"
+ json_get_var up up
+
+ local auto
+ config_get_bool auto "$ifc" auto 1
+
+ local proto
+ json_get_var proto proto
+
+ if [ "$DSL_INTERFACE_STATUS" = "UP" ]; then
+ if [ "$proto" = "pppoa" ] && [ "$up" != 1 ] && [ "$auto" = 1 ]; then
+ ( sleep 1; ifup "$ifc" ) &
+ fi
+ else
+ if [ "$proto" = "pppoa" ] && [ "$up" = 1 ] && [ "$auto" = 1 ]; then
+ ( sleep 1; ifdown "$ifc" ) &
+ else
+ json_get_var autostart autostart
+ if [ "$proto" = "pppoa" ] && [ "$up" != 1 ] && [ "$autostart" = 1 ]; then
+ ( sleep 1; ifdown "$ifc" ) &
+ fi
+ fi
+ fi
+done
+
+