aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux
diff options
context:
space:
mode:
authorAdrian Schmutzler <freifunk@adrianschmutzler.de>2019-10-14 14:02:41 +0200
committerJohn Crispin <john@phrozen.org>2019-10-21 13:28:58 +0200
commit86a1f5261795434c0e89b3f40fe5b5bfeba50602 (patch)
tree4394c826f826c33690e7e9f250793720063556a0 /target/linux
parent8f02ab1839306ec2cacbb3b2c86e28aa019ed0ff (diff)
downloadupstream-86a1f5261795434c0e89b3f40fe5b5bfeba50602.tar.gz
upstream-86a1f5261795434c0e89b3f40fe5b5bfeba50602.tar.bz2
upstream-86a1f5261795434c0e89b3f40fe5b5bfeba50602.zip
lantiq: modify ath9k caldata extraction to reuse caldata.sh
In lantiq, ath9k caldata extraction is implemented to work in two alternate "modes", the standard one and another one with swapped byte pairs. This rearranges the functions so "standard" use is based on the caldata.sh library, while only a single local function is required for the special case. Note that while the parameter for switching between normal and swab is removed, the size of the caldata is added to the function calls to stay consistent. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Diffstat (limited to 'target/linux')
-rw-r--r--target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom62
1 files changed, 15 insertions, 47 deletions
diff --git a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom
index d0bef23045..5a6e8d360b 100644
--- a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom
+++ b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom
@@ -1,55 +1,23 @@
#!/bin/sh
-# Based on ar71xx 10-ath9k-eeprom
[ -e /lib/firmware/$FIRMWARE ] && exit 0
. /lib/functions/caldata.sh
-. /lib/upgrade/nand.sh
-ath9k_eeprom_extract_raw() {
- local source=$1
- local offset=$(($2))
- local swap=$3
- local size=4096
- local bs=1
- local conv=
-
- if [ $swap -gt 0 ]; then
- bs=2
- conv="conv=swab"
- size=$((size / bs))
- offset=$((offset / bs))
- fi
-
- dd if=$source of=/lib/firmware/$FIRMWARE bs=$bs skip=$offset count=$size $conv 2>/dev/null || \
- caldata_die "failed to extract from $mtd"
-}
-
-ath9k_eeprom_extract() {
+caldata_extract_swap() {
local part=$1
local offset=$2
- local swap=$3
+ local count=$3
local mtd
mtd=$(find_mtd_chardev $part)
- [ -n "$mtd" ] || \
- caldata_die "no mtd device found for partition $part"
-
- ath9k_eeprom_extract_raw $mtd $offset $swap
-}
-
-ath9k_ubi_eeprom_extract() {
- local part=$1
- local offset=$2
- local swap=$3
- local ubidev=$(nand_find_ubi $CI_UBIPART)
- local ubi
+ [ -n "$mtd" ] || caldata_die "no mtd device found for partition $part"
- ubi=$(nand_find_volume $ubidev $part)
- [ -n "$ubi" ] || \
- caldata_die "no UBI volume found for $part"
+ offset=$(($offset / 2))
+ count=$(($count / 2))
- ath9k_eeprom_extract_raw /dev/$ubi $offset $swap
+ dd if=$mtd of=/lib/firmware/$FIRMWARE bs=2 skip=$offset count=$count conv=swab 2>/dev/null || \
+ caldata_die "failed to extract calibration data from $mtd"
}
case "$FIRMWARE" in
@@ -60,25 +28,25 @@ case "$FIRMWARE" in
case "$board" in
arcadyan,arv7518pw)
- ath9k_eeprom_extract "boardconfig" 0x400 1
+ caldata_extract_swap "boardconfig" 0x400 0x1000
;;
arcadyan,arv8539pw22)
- ath9k_eeprom_extract "art" 0x400 1
+ caldata_extract_swap "art" 0x400 0x1000
;;
bt,homehub-v2b)
- ath9k_eeprom_extract "art" 0x0 1
+ caldata_extract_swap "art" 0x0 0x1000
ath9k_patch_mac_crc "00:00:00:00:00:00" 0x20c
;;
bt,homehub-v3a)
- ath9k_eeprom_extract "art-copy" 0x0 1
+ caldata_extract_swap "art-copy" 0x0 0x1000
ath9k_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot_env ethaddr) +2) 0x10c
;;
bt,homehub-v5a)
- ath9k_ubi_eeprom_extract "caldata" 0x1000 0
+ caldata_extract_ubi "caldata" 0x1000 0x1000
ath9k_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary_ubi caldata 0x110c) +2) 0x10c
;;
netgear,dgn3500|netgear,dgn3500b)
- ath9k_eeprom_extract "calibration" 0xf000 0
+ caldata_extract "calibration" 0xf000 0x1000
ath9k_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 0x20c
;;
avm,fritz3370-rev2-hynix|\
@@ -87,13 +55,13 @@ case "$FIRMWARE" in
caldata_extract_reverse "urlader" 0x1541 0x440
;;
avm,fritz7312|avm,fritz7320|avm,fritz7360sl)
- ath9k_eeprom_extract "urlader" 0x985 0
+ caldata_extract "urlader" 0x985 0x1000
;;
avm,fritz7412)
/usr/bin/fritz_cal_extract -i 1 -s 0x1e000 -e 0x207 -l 4096 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader")
;;
tplink,tdw8970|tplink,tdw8980)
- ath9k_eeprom_extract "boardconfig" 0x21000 0
+ caldata_extract "boardconfig" 0x21000 0x1000
;;
*)
caldata_die "board $board is not supported yet"