ah_eeprom_v14.c (220360) | ah_eeprom_v14.c (221163) |
---|---|
1/* 2 * Copyright (c) 2008 Sam Leffler, Errno Consulting 3 * Copyright (c) 2008 Atheros Communications, Inc. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 * | 1/* 2 * Copyright (c) 2008 Sam Leffler, Errno Consulting 3 * Copyright (c) 2008 Atheros Communications, Inc. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 * |
17 * $FreeBSD: head/sys/dev/ath/ath_hal/ah_eeprom_v14.c 220360 2011-04-05 13:14:17Z adrian $ | 17 * $FreeBSD: head/sys/dev/ath/ath_hal/ah_eeprom_v14.c 221163 2011-04-28 12:47:40Z adrian $ |
18 */ 19#include "opt_ah.h" 20 21#include "ah.h" 22#include "ah_internal.h" 23#include "ah_eeprom_v14.h" 24 25static HAL_STATUS --- 285 unchanged lines hidden (view full) --- 311 AH_PRIVATE(ah)->ah_eeprom = AH_NULL; 312} 313 314#define owl_get_eep_ver(_ee) \ 315 (((_ee)->ee_base.baseEepHeader.version >> 12) & 0xF) 316#define owl_get_eep_rev(_ee) \ 317 (((_ee)->ee_base.baseEepHeader.version) & 0xFFF) 318 | 18 */ 19#include "opt_ah.h" 20 21#include "ah.h" 22#include "ah_internal.h" 23#include "ah_eeprom_v14.h" 24 25static HAL_STATUS --- 285 unchanged lines hidden (view full) --- 311 AH_PRIVATE(ah)->ah_eeprom = AH_NULL; 312} 313 314#define owl_get_eep_ver(_ee) \ 315 (((_ee)->ee_base.baseEepHeader.version >> 12) & 0xF) 316#define owl_get_eep_rev(_ee) \ 317 (((_ee)->ee_base.baseEepHeader.version) & 0xFFF) 318 |
319/* 320 * Howl is (hopefully) a special case where the endian-ness of the EEPROM 321 * matches the native endian-ness; and that supplied EEPROMs don't have 322 * a magic value to check. 323 */ |
|
319HAL_STATUS 320ath_hal_v14EepromAttach(struct ath_hal *ah) 321{ 322#define NW(a) (sizeof(a) / sizeof(uint16_t)) 323 HAL_EEPROM_v14 *ee = AH_PRIVATE(ah)->ah_eeprom; 324 uint16_t *eep_data, magic; 325 HAL_BOOL need_swap; 326 u_int w, off, len; 327 uint32_t sum; 328 329 HALASSERT(ee == AH_NULL); 330 | 324HAL_STATUS 325ath_hal_v14EepromAttach(struct ath_hal *ah) 326{ 327#define NW(a) (sizeof(a) / sizeof(uint16_t)) 328 HAL_EEPROM_v14 *ee = AH_PRIVATE(ah)->ah_eeprom; 329 uint16_t *eep_data, magic; 330 HAL_BOOL need_swap; 331 u_int w, off, len; 332 uint32_t sum; 333 334 HALASSERT(ee == AH_NULL); 335 |
331 if (!ath_hal_eepromRead(ah, AR5416_EEPROM_MAGIC_OFFSET, &magic)) { 332 HALDEBUG(ah, HAL_DEBUG_ANY, 333 "%s Error reading Eeprom MAGIC\n", __func__); 334 return HAL_EEREAD; | 336 /* 337 * Don't check magic if we're supplied with an EEPROM block, 338 * typically this is from Howl but it may also be from later 339 * boards w/ an embedded Merlin. 340 */ 341 if (ah->ah_eepromdata == NULL) { 342 if (!ath_hal_eepromRead(ah, AR5416_EEPROM_MAGIC_OFFSET, &magic)) { 343 HALDEBUG(ah, HAL_DEBUG_ANY, 344 "%s Error reading Eeprom MAGIC\n", __func__); 345 return HAL_EEREAD; 346 } 347 HALDEBUG(ah, HAL_DEBUG_ATTACH, "%s Eeprom Magic = 0x%x\n", 348 __func__, magic); 349 if (magic != AR5416_EEPROM_MAGIC) { 350 HALDEBUG(ah, HAL_DEBUG_ANY, "Bad magic number\n"); 351 return HAL_EEMAGIC; 352 } |
335 } | 353 } |
336 HALDEBUG(ah, HAL_DEBUG_ATTACH, "%s Eeprom Magic = 0x%x\n", 337 __func__, magic); 338 if (magic != AR5416_EEPROM_MAGIC) { 339 HALDEBUG(ah, HAL_DEBUG_ANY, "Bad magic number\n"); 340 return HAL_EEMAGIC; 341 } | |
342 343 ee = ath_hal_malloc(sizeof(HAL_EEPROM_v14)); 344 if (ee == AH_NULL) { 345 /* XXX message */ 346 return HAL_ENOMEM; 347 } 348 349 eep_data = (uint16_t *)&ee->ee_base; 350 for (w = 0; w < NW(struct ar5416eeprom); w++) { 351 off = owl_eep_start_loc + w; /* NB: AP71 starts at 0 */ 352 if (!ath_hal_eepromRead(ah, off, &eep_data[w])) { 353 HALDEBUG(ah, HAL_DEBUG_ANY, 354 "%s eeprom read error at offset 0x%x\n", 355 __func__, off); 356 return HAL_EEREAD; 357 } 358 } 359 /* Convert to eeprom native eeprom endian format */ | 354 355 ee = ath_hal_malloc(sizeof(HAL_EEPROM_v14)); 356 if (ee == AH_NULL) { 357 /* XXX message */ 358 return HAL_ENOMEM; 359 } 360 361 eep_data = (uint16_t *)&ee->ee_base; 362 for (w = 0; w < NW(struct ar5416eeprom); w++) { 363 off = owl_eep_start_loc + w; /* NB: AP71 starts at 0 */ 364 if (!ath_hal_eepromRead(ah, off, &eep_data[w])) { 365 HALDEBUG(ah, HAL_DEBUG_ANY, 366 "%s eeprom read error at offset 0x%x\n", 367 __func__, off); 368 return HAL_EEREAD; 369 } 370 } 371 /* Convert to eeprom native eeprom endian format */ |
360 if (isBigEndian()) { | 372 /* XXX this is likely incorrect but will do for now to get howl/ap83 working. */ 373 if (ah->ah_eepromdata == NULL && isBigEndian()) { |
361 for (w = 0; w < NW(struct ar5416eeprom); w++) 362 eep_data[w] = __bswap16(eep_data[w]); 363 } 364 365 /* 366 * At this point, we're in the native eeprom endian format 367 * Now, determine the eeprom endian by looking at byte 26?? 368 */ --- 58 unchanged lines hidden --- | 374 for (w = 0; w < NW(struct ar5416eeprom); w++) 375 eep_data[w] = __bswap16(eep_data[w]); 376 } 377 378 /* 379 * At this point, we're in the native eeprom endian format 380 * Now, determine the eeprom endian by looking at byte 26?? 381 */ --- 58 unchanged lines hidden --- |