aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ar71xx/base-files/etc/hotplug.d
diff options
context:
space:
mode:
authorJames <>2015-11-04 11:49:21 +0000
committerJames <>2015-11-04 11:49:21 +0000
commit716ca530e1c4515d8683c9d5be3d56b301758b66 (patch)
tree700eb5bcc1a462a5f21dcec15ce7c97ecfefa772 /target/linux/ar71xx/base-files/etc/hotplug.d
downloadtrunk-47381-master.tar.gz
trunk-47381-master.tar.bz2
trunk-47381-master.zip
trunk-47381HEADmaster
Diffstat (limited to 'target/linux/ar71xx/base-files/etc/hotplug.d')
-rw-r--r--target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom65
-rw-r--r--target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata98
-rw-r--r--target/linux/ar71xx/base-files/etc/hotplug.d/net/10-ar922x-led-fix51
3 files changed, 214 insertions, 0 deletions
diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
new file mode 100644
index 0000000..b5f0588
--- /dev/null
+++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
@@ -0,0 +1,65 @@
+#!/bin/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_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
+}
+
+[ -e /lib/firmware/$FIRMWARE ] && exit 0
+
+. /lib/ar71xx.sh
+. /lib/functions.sh
+. /lib/functions/system.sh
+
+board=$(ar71xx_board_name)
+
+case "$FIRMWARE" in
+"soc_wmac.eeprom")
+ case $board in
+ r6100 | \
+ wndr3700v4 | \
+ wndr4300)
+ ath9k_eeprom_extract "caldata" 4096 2048
+ ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 0)
+ ;;
+ *)
+ ath9k_eeprom_die "board $board is not supported yet"
+ ;;
+ esac
+ ;;
+
+"pci_wmac0.eeprom")
+ case $board in
+ wndr3700v4 | \
+ wndr4300)
+ ath9k_eeprom_extract "caldata" 20480 2048
+ ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 12)
+ ;;
+ *)
+ ath9k_eeprom_die "board $board is not supported yet"
+ ;;
+ esac
+ ;;
+esac
diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
new file mode 100644
index 0000000..f53c853
--- /dev/null
+++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
@@ -0,0 +1,98 @@
+#!/bin/sh
+
+ath10kcal_die() {
+ echo "ath10cal: " "$*"
+ exit 1
+}
+
+ath10kcal_from_file() {
+ local source=$1
+ local offset=$2
+ local count=$3
+
+ dd if=$source of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
+ ath10kcal_die "failed to extract calibration data from $source"
+}
+
+ath10kcal_extract() {
+ local part=$1
+ local offset=$2
+ local count=$3
+ local mtd
+
+ mtd=$(find_mtd_chardev $part)
+ [ -n "$mtd" ] || \
+ ath10kcal_die "no mtd device found for partition $part"
+
+ dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
+ ath10kcal_die "failed to extract calibration data from $mtd"
+}
+
+ath10kcal_patch_mac() {
+ local mac=$1
+
+ [ -z "$mac" ] && return
+
+ macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=6 count=6
+}
+
+[ -e /lib/firmware/$FIRMWARE ] && exit 0
+
+. /lib/ar71xx.sh
+. /lib/functions.sh
+. /lib/functions/system.sh
+
+board=$(ar71xx_board_name)
+
+case "$FIRMWARE" in
+"ath10k/cal-pci-0000:00:00.0.bin")
+ case $board in
+ dlan-pro-1200-ac)
+ ath10kcal_extract "art" 20480 2116
+ ;;
+ mc-mac1200r)
+ ath10kcal_extract "art" 20480 2116
+ ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -1)
+ ;;
+ tl-wdr6500-v2)
+ ath10kcal_extract "art" 20480 2116
+ ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -2)
+ ;;
+ r6100)
+ ath10kcal_extract "caldata" 20480 2116
+ ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) +2)
+ ;;
+ qihoo-c301)
+ ath10kcal_extract "radiocfg" 20480 2116
+ ath10kcal_patch_mac $(mtd_get_mac_ascii devdata wlan5mac)
+ ;;
+ esr1750 | \
+ epg5000)
+ ath10kcal_extract "caldata" 20480 2116
+ ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +1)
+ ;;
+ mr1750)
+ ath10kcal_extract "ART" 20480 2116
+ ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +16)
+ ;;
+ esac
+ ;;
+"ath10k/cal-pci-0000:01:00.0.bin")
+ case $board in
+ archer-c5 | \
+ archer-c7)
+ ath10kcal_extract "art" 20480 2116
+ ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -2)
+ ;;
+ nbg6716)
+ ath10kcal_extract "RFdata" 20480 2116
+ ;;
+ rb-911g-5hpacd)
+ ath10kcal_from_file "/sys/firmware/routerboot/ext_wlan_data" 20480 2116
+ ;;
+ esac
+ ;;
+*)
+ exit 1
+ ;;
+esac
diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/net/10-ar922x-led-fix b/target/linux/ar71xx/base-files/etc/hotplug.d/net/10-ar922x-led-fix
new file mode 100644
index 0000000..1024150
--- /dev/null
+++ b/target/linux/ar71xx/base-files/etc/hotplug.d/net/10-ar922x-led-fix
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+# For AR9220 and AR9223, GPIO JTAG must explicit be disabled
+# before LEDs start working. Do this when wifi device is
+# detected.
+
+#
+# $DEVPATH is not valid for some boards (including WZR-HP-AG300H).
+# Manipulate the $DEVPATH to reach the corresponding phyN.
+#
+
+devdir=`dirname $DEVPATH`
+devdir=`dirname $devdir`
+phydir=/sys$devdir/ieee80211
+phyname=`cat $phydir/phy*/name`
+
+if [ -z $phyname -o $ACTION != "add" ]; then exit 0; fi
+
+#
+# ar922x_disable_gpio_jtag():
+#
+# Emulate
+# REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, AR_GPIO_JTAG_DISABLE);
+# for AR9220 and AR9223.
+#
+
+ar922x_disable_gpio_jtag()
+{
+ local regidx=0x4054
+
+ [ -f /sys/kernel/debug/ieee80211/$1/ath9k/regidx ] && {
+ echo $regidx > /sys/kernel/debug/ieee80211/$1/ath9k/regidx
+ regval=`cat /sys/kernel/debug/ieee80211/$1/ath9k/regval`
+ regval=$((regval | 0x20000))
+ echo regval $regval
+ echo $regval > /sys/kernel/debug/ieee80211/$1/ath9k/regval
+ }
+}
+
+if [ $phyname -a $ACTION = "add" ]; then
+
+ . /lib/ar71xx.sh
+
+ case $(ar71xx_board_name) in
+ wzr-hp-ag300h)
+ ar922x_disable_gpio_jtag $phyname
+ ;;
+ esac;
+fi
+
+exit 0