In lantiq, ath9k caldata extraction is implemented to work in two alternate "modes", the standard one and another one with conv=swab.
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 the size of the caldata needs to be included into the call for functions located in caldata.sh. Signed-off-by: Adrian Schmutzler <freif...@adrianschmutzler.de> --- This patch is a late addition to the caldata.sh patchset and has to be applied last. --- .../etc/hotplug.d/firmware/12-ath9k-eeprom | 61 +++++-------------- 1 file changed, 14 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 b5dba670b1..a4c6aa4f18 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,22 @@ #!/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=2048 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)) - 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 +27,25 @@ case "$FIRMWARE" in case "$board" in arcadyan,arv7518pw) - ath9k_eeprom_extract "boardconfig" 0x400 1 + caldata_extract_swap "boardconfig" 0x400 ;; arcadyan,arv8539pw22) - ath9k_eeprom_extract "art" 0x400 1 + caldata_extract_swap "art" 0x400 ;; bt,homehub-v2b) - ath9k_eeprom_extract "art" 0x0 1 + caldata_extract_swap "art" 0x0 caldata_patch_fw_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 caldata_patch_fw_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 caldata_patch_fw_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 caldata_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 0x20c ;; avm,fritz3370-rev2-hynix|\ @@ -87,13 +54,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" -- 2.20.1 _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel