• Martin Blumenstingl's avatar
    ath9k: Make the EEPROM swapping check use the eepmisc register · 68fbe792
    Martin Blumenstingl authored
    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#L351Signed-off-by: default avatarMartin Blumenstingl <martin.blumenstingl@googlemail.com>
    Signed-off-by: default avatarKalle Valo <kvalo@qca.qualcomm.com>
    68fbe792
eeprom.c 17.6 KB