[PATCH v2 2/2] ath9k: of_init: add endian check

From: Álvaro Fernández Rojas
Date: Mon Apr 17 2023 - 01:36:09 EST


BCM63xx (Big Endian MIPS) devices store the calibration data in MTD
partitions but it needs to be swapped in order to work, otherwise it fails:
ath9k 0000:00:01.0: enabling device (0000 -> 0002)
ath: phy0: Ignoring endianness difference in EEPROM magic bytes.
ath: phy0: Bad EEPROM VER 0x0001 or REV 0x00e0
ath: phy0: Unable to initialize hardware; initialization status: -22
ath9k 0000:00:01.0: Failed to initialize device
ath9k: probe of 0000:00:01.0 failed with error -22

For compatibility with current devices the AH_NO_EEP_SWAP flag will be
activated only when qca,endian-check isn't present in the device tree.
This is because some devices have the magic values swapped but not the actual
EEPROM data, so activating the flag for those devices will break them.

Signed-off-by: Álvaro Fernández Rojas <noltari@xxxxxxxxx>
---
drivers/net/wireless/ath/ath9k/init.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index 4f00400c7ffb..abde953aec61 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -615,7 +615,6 @@ static int ath9k_nvmem_request_eeprom(struct ath_softc *sc)

ah->nvmem_blob_len = len;
ah->ah_flags &= ~AH_USE_EEPROM;
- ah->ah_flags |= AH_NO_EEP_SWAP;

return 0;
}
@@ -688,9 +687,11 @@ static int ath9k_of_init(struct ath_softc *sc)
return ret;

ah->ah_flags &= ~AH_USE_EEPROM;
- ah->ah_flags |= AH_NO_EEP_SWAP;
}

+ if (!of_property_read_bool(np, "qca,endian-check"))
+ ah->ah_flags |= AH_NO_EEP_SWAP;
+
of_get_mac_address(np, common->macaddr);

return 0;
--
2.30.2