diff options
author | Martin Blumenstingl <martin.blumenstingl@googlemail.com> | 2016-12-04 08:26:55 +0100 |
---|---|---|
committer | Mathias Kresin <dev@kresin.me> | 2016-12-08 19:36:22 +0100 |
commit | afa37092663d00aa0abf8c61943d9a1b5558b144 (patch) | |
tree | 88a16e468ffea64130d4b408b55470ab94d6e1c1 | |
parent | ee55a19a618a30182213937c8c96e056d8f9ed41 (diff) | |
download | mtk-20170518-afa37092663d00aa0abf8c61943d9a1b5558b144.zip mtk-20170518-afa37092663d00aa0abf8c61943d9a1b5558b144.tar.gz mtk-20170518-afa37092663d00aa0abf8c61943d9a1b5558b144.tar.bz2 |
lantiq: fix ath9k EEPROM data swapping for some devices
The EEPROM data in the flash of the ARV7518PW, ARV8539PW22,
BTHOMEHUBV2B and BTHOMEHUBV3A is stored byte-swapped (swab16), meaning
that for example the ath9k base_eep_header fields "version" (high and
low byte), "opCapFlags" and "eepMisc" are swapped (the latter ones are
just 1 byte wide, thus their position is swapped).
The old "ath,eep-endian" property enabled the corresponding swapping
logic in the ath9k driver (swab16 in ath9k_hw_nvram_swap_data, which is
based on the magic bytes in the EEPROM data which have nothing to do
with the calibration data - thus this logic should not be used
anymore).
Since we have switched to the upstream ath9k devicetree bindings there
is no binding anymore which enables swab16 in ath9k (as this logic is
not recommended anymore as explained above), leading to ath9k
initialization errors:
ath: phy0: Bad EEPROM VER 0x0001 or REV 0x00e0
(this shows that the version field is swapped, expected values are VER
0x000E and REV 0x0001)
Swapping the ath9k calibration data when extracting it from the flash
fixes the devices listed above (all other devices do not require
additional swapping, since the position of the fields is already as
expected by ath9k). This allows ath9k to read the version correctly
again, as well as the more important "eepmisc" field (which is used for
determining whether the data inside the EEPROM is Big or Little Endian
which is required to parse the EEPROM contents correctly).
Fixes: a20616863d3 ("lantiq: use ath9k device tree bindings
binding/owl-loader")
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
-rw-r--r-- | target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom | 40 |
1 files changed, 26 insertions, 14 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 2776275..28bde59 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 @@ -32,27 +32,39 @@ ath9k_eeprom_die() { 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=1 skip=$offset count=$size 2>/dev/null || \ + dd if=$source of=/lib/firmware/$FIRMWARE bs=$bs skip=$offset count=$size $conv 2>/dev/null || \ ath9k_eeprom_die "failed to extract from $mtd" } ath9k_eeprom_extract() { local part=$1 local offset=$2 + local swap=$3 local mtd mtd=$(find_mtd_chardev $part) [ -n "$mtd" ] || \ ath9k_eeprom_die "no mtd device found for partition $part" - ath9k_eeprom_extract_raw $mtd $offset + 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 @@ -60,7 +72,7 @@ ath9k_ubi_eeprom_extract() { [ -n "$ubi" ] || \ ath9k_eeprom_die "no UBI volume found for $part" - ath9k_eeprom_extract_raw /dev/$ubi $offset + ath9k_eeprom_extract_raw /dev/$ubi $offset $swap } ath9k_patch_firmware_mac() { @@ -101,37 +113,37 @@ case "$FIRMWARE" in case "$board" in ARV7518PW) - ath9k_eeprom_extract "boardconfig" 1024 + ath9k_eeprom_extract "boardconfig" 1024 1 ;; ARV8539PW22) - ath9k_eeprom_extract "art" 1024 + ath9k_eeprom_extract "art" 1024 1 ;; BTHOMEHUBV2B) - ath9k_eeprom_extract "art" 0 - ath9k_patch_firmware_mac "00:00:00:00:00:00" 524 1 514 + ath9k_eeprom_extract "art" 0 1 + ath9k_patch_firmware_mac "00:00:00:00:00:00" 524 0 514 ;; BTHOMEHUBV3A) - ath9k_eeprom_extract "art-copy" 0 - ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 268 1 258 + ath9k_eeprom_extract "art-copy" 0 1 + ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 268 0 258 ;; BTHOMEHUBV5A) - ath9k_ubi_eeprom_extract "caldata" 4096 + ath9k_ubi_eeprom_extract "caldata" 4096 0 ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi caldata 4364) +2) 268 0 258 ;; DGN3500*) - ath9k_eeprom_extract "calibration" 61440 + ath9k_eeprom_extract "calibration" 61440 0 ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 524 0 514 ;; FRITZ3370) - ath9k_eeprom_extract "urlader" 2437 + ath9k_eeprom_extract "urlader" 2437 0 ath9k_patch_firmware_mac "00:00:00:00:00:00" 2 0 ;; FRITZ7320|FRITZ7360SL) - ath9k_eeprom_extract "urlader" 2437 + ath9k_eeprom_extract "urlader" 2437 0 ath9k_patch_firmware_mac "00:00:00:00:00:00" 268 0 258 ;; TDW8970|TDW8980) - ath9k_eeprom_extract "boardconfig" 135168 + ath9k_eeprom_extract "boardconfig" 135168 0 ;; *) ath9k_eeprom_die "board $board is not supported yet" |