svn commit: r224518 - head/sys/dev/ath/ath_hal

Adrian Chadd adrian at FreeBSD.org
Sat Jul 30 13:37:39 UTC 2011


Author: adrian
Date: Sat Jul 30 13:37:38 2011
New Revision: 224518
URL: http://svn.freebsd.org/changeset/base/224518

Log:
  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)

Modified:
  head/sys/dev/ath/ath_hal/ah_eeprom_9287.c
  head/sys/dev/ath/ath_hal/ah_eeprom_v4k.c

Modified: head/sys/dev/ath/ath_hal/ah_eeprom_9287.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ah_eeprom_9287.c	Sat Jul 30 13:34:57 2011	(r224517)
+++ head/sys/dev/ath/ath_hal/ah_eeprom_9287.c	Sat Jul 30 13:37:38 2011	(r224518)
@@ -298,11 +298,18 @@ ath_hal_9287EepromAttach(struct ath_hal 
 	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 
 		}
 	}
 	/* 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]);
 	}

Modified: head/sys/dev/ath/ath_hal/ah_eeprom_v4k.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ah_eeprom_v4k.c	Sat Jul 30 13:34:57 2011	(r224517)
+++ head/sys/dev/ath/ath_hal/ah_eeprom_v4k.c	Sat Jul 30 13:37:38 2011	(r224518)
@@ -288,11 +288,17 @@ ath_hal_v4kEepromAttach(struct ath_hal *
 	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 *
 		}
 	}
 	/* 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]);
 	}


More information about the svn-src-all mailing list