Prepare for embedded use of the AR9285/AR9287.

Calibration/PCI data that's written to flash (rather than EEPROM attached
to the NIC) is typically already in host-endian. The existing checks
end up swapping 16 bit words incorrectly - the correct solution would be
to read the magic value and determine the EEPROM endianness from that.
(This is what Linux does.)

This doesn't completely enable embedded use of the AR9285/AR9287 -
notably, the EEPROM read methods need to be made generic and available
to all EEPROM drivers. I'll worry about that later.

Approved by:	re (kib)
This commit is contained in:
Adrian Chadd 2011-07-30 13:37:38 +00:00
parent bb40c7e83f
commit b649b13f03
2 changed files with 33 additions and 12 deletions

View File

@ -298,11 +298,18 @@ ath_hal_9287EepromAttach(struct ath_hal *ah)
uint32_t sum;
HALASSERT(ee == AH_NULL);
if (!ath_hal_eepromRead(ah, AR5416_EEPROM_MAGIC_OFFSET, &magic)) {
HALDEBUG(ah, HAL_DEBUG_ANY,
"%s Error reading Eeprom MAGIC\n", __func__);
return HAL_EEREAD;
/*
* Don't check magic if we're supplied with an EEPROM block,
* typically this is from Howl but it may also be from later
* boards w/ an embedded WMAC.
*/
if (ah->ah_eepromdata == NULL) {
if (!ath_hal_eepromRead(ah, AR5416_EEPROM_MAGIC_OFFSET, &magic)) {
HALDEBUG(ah, HAL_DEBUG_ANY,
"%s Error reading Eeprom MAGIC\n", __func__);
return HAL_EEREAD;
}
}
HALDEBUG(ah, HAL_DEBUG_ATTACH, "%s Eeprom Magic = 0x%x\n",
__func__, magic);
@ -328,7 +335,11 @@ ath_hal_9287EepromAttach(struct ath_hal *ah)
}
}
/* Convert to eeprom native eeprom endian format */
if (isBigEndian()) {
/*
* XXX this is likely incorrect but will do for now
* XXX to get embedded boards working.
*/
if (ah->ah_eepromdata == NULL && isBigEndian()) {
for (w = 0; w < NW(HAL_EEPROM_9287); w++)
eep_data[w] = __bswap16(eep_data[w]);
}

View File

@ -288,11 +288,17 @@ ath_hal_v4kEepromAttach(struct ath_hal *ah)
uint32_t sum;
HALASSERT(ee == AH_NULL);
if (!ath_hal_eepromRead(ah, AR5416_EEPROM_MAGIC_OFFSET, &magic)) {
HALDEBUG(ah, HAL_DEBUG_ANY,
"%s Error reading Eeprom MAGIC\n", __func__);
return HAL_EEREAD;
/*
* Don't check magic if we're supplied with an EEPROM block,
* typically this is from Howl but it may also be from later
* boards w/ an embedded WMAC.
*/
if (ah->ah_eepromdata == NULL) {
if (!ath_hal_eepromRead(ah, AR5416_EEPROM_MAGIC_OFFSET, &magic)) {
HALDEBUG(ah, HAL_DEBUG_ANY,
"%s Error reading Eeprom MAGIC\n", __func__);
return HAL_EEREAD;
}
}
HALDEBUG(ah, HAL_DEBUG_ATTACH, "%s Eeprom Magic = 0x%x\n",
__func__, magic);
@ -318,7 +324,11 @@ ath_hal_v4kEepromAttach(struct ath_hal *ah)
}
}
/* Convert to eeprom native eeprom endian format */
if (isBigEndian()) {
/*
* XXX this is likely incorrect but will do for now
* XXX to get embedded boards working.
*/
if (ah->ah_eepromdata == NULL && isBigEndian()) {
for (w = 0; w < NW(struct ar5416eeprom_4k); w++)
eep_data[w] = __bswap16(eep_data[w]);
}