]> git.karo-electronics.de Git - karo-tx-linux.git/commit
ath9k: Make the EEPROM swapping check use the eepmisc register
authorMartin Blumenstingl <martin.blumenstingl@googlemail.com>
Mon, 5 Dec 2016 11:27:36 +0000 (13:27 +0200)
committerKalle Valo <kvalo@qca.qualcomm.com>
Thu, 15 Dec 2016 08:26:37 +0000 (10:26 +0200)
commit68fbe792916cdf6c96def64c1bc50a39443a136a
tree0adfaca3f40410de5d28261e4538a48312b79e91
parent9bff7428d55a5fbc3b6e8d3ba725040cadd71a59
ath9k: Make the EEPROM swapping check use the eepmisc register

There are two ways of swapping the EEPROM data in the ath9k driver:
1) swab16 based on the first two EEPROM "magic" bytes (same for all
   EEPROM formats)
2) field and EEPROM format specific swab16/swab32 (different for
   eeprom_def, eeprom_4k and eeprom_9287)

The result of the first check was used to also enable the second swap.
This behavior seems incorrect, since the data may only be byte-swapped
(afterwards the data could be in the correct endianness).
Thus we introduce a separate check based on the "eepmisc" register
(which is part of the EEPROM data). When bit 0 is set, then the EEPROM
format specific values are in "big endian". This is also done by the
FreeBSD kernel, see [0] for example.

This allows us to parse EEPROMs with the "correct" magic bytes but
swapped EEPROM format specific values. These EEPROMs (mostly found in
lantiq and broadcom based big endian MIPS based devices) only worked
due to platform specific "hacks" which swapped the EEPROM so the
magic was inverted, which also enabled the format specific swapping.
With this patch the old behavior is still supported, but neither
recommended nor needed anymore.

[0]
https://github.com/freebsd/freebsd/blob/50719b56d9ce8d7d4beb53b16e9edb2e9a4a7a18/sys/dev/ath/ath_hal/ah_eeprom_9287.c#L351

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
drivers/net/wireless/ath/ath9k/eeprom.c