lantiq: fix ath9k EEPROM data swapping for some devices
authorMartin Blumenstingl <martin.blumenstingl@googlemail.com>
Sun, 4 Dec 2016 07:26:55 +0000 (08:26 +0100)
committerMathias Kresin <dev@kresin.me>
Thu, 8 Dec 2016 18:36:22 +0000 (19:36 +0100)
commitafa37092663d00aa0abf8c61943d9a1b5558b144
tree88a16e468ffea64130d4b408b55470ab94d6e1c1
parentee55a19a618a30182213937c8c96e056d8f9ed41
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>
target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom