aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/apm821xx/base-files
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/apm821xx/base-files')
-rwxr-xr-xtarget/linux/apm821xx/base-files/etc/board.d/01_leds8
-rwxr-xr-xtarget/linux/apm821xx/base-files/etc/board.d/02_network6
-rwxr-xr-xtarget/linux/apm821xx/base-files/etc/diag.sh4
-rw-r--r--target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom89
-rwxr-xr-xtarget/linux/apm821xx/base-files/lib/apm821xx.sh4
-rwxr-xr-xtarget/linux/apm821xx/base-files/lib/upgrade/platform.sh9
6 files changed, 120 insertions, 0 deletions
diff --git a/target/linux/apm821xx/base-files/etc/board.d/01_leds b/target/linux/apm821xx/base-files/etc/board.d/01_leds
index bcc7a9f101..48fe139ce9 100755
--- a/target/linux/apm821xx/base-files/etc/board.d/01_leds
+++ b/target/linux/apm821xx/base-files/etc/board.d/01_leds
@@ -19,6 +19,14 @@ mr24)
mbl)
;;
+wndr4700)
+ ucidef_set_led_netdev "wan" "WAN (green)" "wndr4700:green:wan" "eth0.2"
+ ucidef_set_led_usbdev "usb3-1" "USB3-1" "wndr4700:blue:usb" "2-1"
+ ucidef_set_led_usbdev "usb3-2" "USB3-2" "wndr4700:blue:usb" "3-1"
+ ucidef_set_led_wlan "wlan2g" "WLAN2G" "wndr4700:blue:wlan" "phy0tpt"
+ ucidef_set_led_wlan "wlan5g" "WLAN5G" "wndr4700:blue:wlan" "phy1tpt"
+ ;;
+
*)
;;
esac
diff --git a/target/linux/apm821xx/base-files/etc/board.d/02_network b/target/linux/apm821xx/base-files/etc/board.d/02_network
index 9525d8c5f2..3a25709a2a 100755
--- a/target/linux/apm821xx/base-files/etc/board.d/02_network
+++ b/target/linux/apm821xx/base-files/etc/board.d/02_network
@@ -13,6 +13,12 @@ mbl | \
mr24)
ucidef_set_interface_lan "eth0"
;;
+
+wndr4700)
+ ucidef_add_switch "switch0" \
+ "0@eth0" "4:lan" "3:lan" "2:lan" "1:lan" "5:wan"
+ ;;
+
*)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
;;
diff --git a/target/linux/apm821xx/base-files/etc/diag.sh b/target/linux/apm821xx/base-files/etc/diag.sh
index bea66eb14d..3ddd21d844 100755
--- a/target/linux/apm821xx/base-files/etc/diag.sh
+++ b/target/linux/apm821xx/base-files/etc/diag.sh
@@ -13,6 +13,10 @@ get_status_led() {
status_led="mr24:green:power"
;;
+ wndr4700)
+ status_led="wndr4700:green:power"
+ ;;
+
*)
;;
esac
diff --git a/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
new file mode 100644
index 0000000000..dfdc548d63
--- /dev/null
+++ b/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
@@ -0,0 +1,89 @@
+#!/bin/sh
+
+[ -e /lib/firmware/$FIRMWARE ] && exit 0
+
+. /lib/apm821xx.sh
+. /lib/functions.sh
+. /lib/functions/system.sh
+
+ath9k_eeprom_die() {
+ echo "ath9k eeprom: " "$*"
+ exit 1
+}
+
+ath9k_eeprom_extract() {
+ local part=$1
+ local offset=$2
+ local count=$3
+ local mtd
+
+ mtd=$(find_mtd_chardev $part)
+ [ -n "$mtd" ] || \
+ ath9k_eeprom_die "no mtd device found for partition $part"
+
+ dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
+ ath9k_eeprom_die "failed to extract from $mtd"
+}
+
+ath9k_ubi_eeprom_extract() {
+ local part=$1
+ local offset=$2
+ local count=$3
+ local ubidev=$(nand_find_ubi $CI_UBIPART)
+ local ubi
+
+ ubi=$(nand_find_volume $ubidev $part)
+ [ -n "$ubi" ] || \
+ ath9k_eeprom_die "no UBI volume found for $part"
+
+ dd if=/dev/$ubi of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
+ ath9k_eeprom_die "failed to extract from $ubi"
+}
+
+ath9k_patch_firmware_mac() {
+ local mac=$1
+
+ [ -z "$mac" ] && return
+
+ macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=2 count=6
+}
+
+board=$(apm821xx_board_name)
+
+case "$FIRMWARE" in
+"pci_wmac0.eeprom")
+ case $board in
+ wndr4700)
+ . /lib/upgrade/nand.sh
+
+ if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
+ ath9k_ubi_eeprom_extract "caldata" 20480 4096
+ else
+ ath9k_eeprom_extract "wifi_data" 20480 4096
+ ath9k_patch_firmware_mac $(mtd_get_mac_binary wifi_data 12)
+ fi
+ ;;
+ *)
+ ath9k_eeprom_die "board $board is not supported yet"
+ ;;
+ esac
+ ;;
+
+"pci_wmac1.eeprom")
+ case $board in
+ wndr4700)
+ . /lib/upgrade/nand.sh
+
+ if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
+ ath9k_ubi_eeprom_extract "caldata" 4096 4096
+ else
+ ath9k_eeprom_extract "wifi_data" 4096 4096
+ ath9k_patch_firmware_mac $(mtd_get_mac_binary wifi_data 0)
+ fi
+ ;;
+ *)
+ ath9k_eeprom_die "board $board is not supported yet"
+ ;;
+ esac
+ ;;
+esac
diff --git a/target/linux/apm821xx/base-files/lib/apm821xx.sh b/target/linux/apm821xx/base-files/lib/apm821xx.sh
index 98e88cff6e..78fe452184 100755
--- a/target/linux/apm821xx/base-files/lib/apm821xx.sh
+++ b/target/linux/apm821xx/base-files/lib/apm821xx.sh
@@ -18,6 +18,10 @@ apm821xx_board_detect() {
name="mbl"
;;
+ *"Netgear WNDR4700/WNDR4720 Series")
+ name="wndr4700"
+ ;;
+
*)
name="unknown"
;;
diff --git a/target/linux/apm821xx/base-files/lib/upgrade/platform.sh b/target/linux/apm821xx/base-files/lib/upgrade/platform.sh
index d5b0986dd5..5559767a26 100755
--- a/target/linux/apm821xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/apm821xx/base-files/lib/upgrade/platform.sh
@@ -21,6 +21,11 @@ platform_check_image() {
return $?;
;;
+ wndr4700)
+ nand_do_platform_check $board "$1"
+ return $?;
+ ;;
+
*)
;;
esac
@@ -37,6 +42,10 @@ platform_pre_upgrade() {
merakinand_do_upgrade "$1"
;;
+ wndr4700)
+ nand_do_upgrade "$1"
+ ;;
+
*)
;;
esac