From owner-svn-src-all@FreeBSD.ORG Sat Jul 30 13:37:38 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C85CD106564A; Sat, 30 Jul 2011 13:37:38 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B73398FC0C; Sat, 30 Jul 2011 13:37:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6UDbcU6002198; Sat, 30 Jul 2011 13:37:38 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6UDbcM3002195; Sat, 30 Jul 2011 13:37:38 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201107301337.p6UDbcM3002195@svn.freebsd.org> From: Adrian Chadd Date: Sat, 30 Jul 2011 13:37:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224518 - head/sys/dev/ath/ath_hal X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jul 2011 13:37:39 -0000 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]); }