ar5212_attach.c (185380) | ar5212_attach.c (185406) |
---|---|
1/* 2 * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting 3 * Copyright (c) 2002-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 * --- 4 unchanged lines hidden (view full) --- 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 * $Id: ar5212_attach.c,v 1.18 2008/11/19 22:10:42 sam Exp $ 18 */ 19#include "opt_ah.h" 20 | 1/* 2 * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting 3 * Copyright (c) 2002-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 * --- 4 unchanged lines hidden (view full) --- 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 * $Id: ar5212_attach.c,v 1.18 2008/11/19 22:10:42 sam Exp $ 18 */ 19#include "opt_ah.h" 20 |
21#ifdef AH_SUPPORT_AR5212 22 23#if !defined(AH_SUPPORT_5112) && \ 24 !defined(AH_SUPPORT_5111) && \ 25 !defined(AH_SUPPORT_2413) && \ 26 !defined(AH_SUPPORT_5413) && \ 27 !defined(AH_SUPPORT_AR5312) 28#error "No 5212 RF support defined" 29#endif 30 | |
31#include "ah.h" 32#include "ah_internal.h" 33#include "ah_devid.h" 34 35#include "ar5212/ar5212.h" 36#include "ar5212/ar5212reg.h" 37#include "ar5212/ar5212phy.h" | 21#include "ah.h" 22#include "ah_internal.h" 23#include "ah_devid.h" 24 25#include "ar5212/ar5212.h" 26#include "ar5212/ar5212reg.h" 27#include "ar5212/ar5212phy.h" |
38#ifdef AH_SUPPORT_AR5311 39#include "ar5212/ar5311reg.h" 40#endif | |
41 42#define AH_5212_COMMON 43#include "ar5212/ar5212.ini" 44 45static const struct ath_hal_private ar5212hal = {{ 46 .ah_magic = AR5212_MAGIC, 47 .ah_abi = HAL_ABI_VERSION, 48 .ah_countryCode = CTRY_DEFAULT, --- 280 unchanged lines hidden (view full) --- 329 return AH_TRUE; 330 return AH_FALSE; 331#undef N 332} 333 334/* 335 * Attach for an AR5212 part. 336 */ | 28 29#define AH_5212_COMMON 30#include "ar5212/ar5212.ini" 31 32static const struct ath_hal_private ar5212hal = {{ 33 .ah_magic = AR5212_MAGIC, 34 .ah_abi = HAL_ABI_VERSION, 35 .ah_countryCode = CTRY_DEFAULT, --- 280 unchanged lines hidden (view full) --- 316 return AH_TRUE; 317 return AH_FALSE; 318#undef N 319} 320 321/* 322 * Attach for an AR5212 part. 323 */ |
337struct ath_hal * | 324static struct ath_hal * |
338ar5212Attach(uint16_t devid, HAL_SOFTC sc, 339 HAL_BUS_TAG st, HAL_BUS_HANDLE sh, HAL_STATUS *status) 340{ 341#define AH_EEPROM_PROTECT(ah) \ 342 (IS_PCIE(ah) ? AR_EEPROM_PROTECT_PCIE : AR_EEPROM_PROTECT) 343 struct ath_hal_5212 *ahp; 344 struct ath_hal *ah; | 325ar5212Attach(uint16_t devid, HAL_SOFTC sc, 326 HAL_BUS_TAG st, HAL_BUS_HANDLE sh, HAL_STATUS *status) 327{ 328#define AH_EEPROM_PROTECT(ah) \ 329 (IS_PCIE(ah) ? AR_EEPROM_PROTECT_PCIE : AR_EEPROM_PROTECT) 330 struct ath_hal_5212 *ahp; 331 struct ath_hal *ah; |
332 struct ath_hal_rf *rf; |
|
345 uint32_t val; 346 uint16_t eeval; 347 HAL_STATUS ecode; | 333 uint32_t val; 334 uint16_t eeval; 335 HAL_STATUS ecode; |
348 HAL_BOOL rfStatus; | |
349 350 HALDEBUG(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n", 351 __func__, sc, (void*) st, (void*) sh); 352 353 /* NB: memory is returned zero'd */ 354 ahp = ath_hal_malloc(sizeof (struct ath_hal_5212)); 355 if (ahp == AH_NULL) { 356 HALDEBUG(AH_NULL, HAL_DEBUG_ANY, --- 55 unchanged lines hidden (view full) --- 412 /* 413 * Set correct Baseband to analog shift 414 * setting to access analog chips. 415 */ 416 OS_REG_WRITE(ah, AR_PHY(0), 0x00000007); 417 418 /* Read Radio Chip Rev Extract */ 419 AH_PRIVATE(ah)->ah_analog5GhzRev = ar5212GetRadioRev(ah); | 336 337 HALDEBUG(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n", 338 __func__, sc, (void*) st, (void*) sh); 339 340 /* NB: memory is returned zero'd */ 341 ahp = ath_hal_malloc(sizeof (struct ath_hal_5212)); 342 if (ahp == AH_NULL) { 343 HALDEBUG(AH_NULL, HAL_DEBUG_ANY, --- 55 unchanged lines hidden (view full) --- 399 /* 400 * Set correct Baseband to analog shift 401 * setting to access analog chips. 402 */ 403 OS_REG_WRITE(ah, AR_PHY(0), 0x00000007); 404 405 /* Read Radio Chip Rev Extract */ 406 AH_PRIVATE(ah)->ah_analog5GhzRev = ar5212GetRadioRev(ah); |
407 408 rf = ath_hal_rfprobe(ah, &ecode); 409 if (rf == AH_NULL) 410 goto bad; 411 |
|
420 /* NB: silently accept anything in release code per Atheros */ 421 switch (AH_PRIVATE(ah)->ah_analog5GhzRev & AR_RADIO_SREV_MAJOR) { 422 case AR_RAD5111_SREV_MAJOR: 423 case AR_RAD5112_SREV_MAJOR: 424 case AR_RAD2112_SREV_MAJOR: 425 case AR_RAD2111_SREV_MAJOR: 426 case AR_RAD2413_SREV_MAJOR: 427 case AR_RAD5413_SREV_MAJOR: --- 121 unchanged lines hidden (view full) --- 549 */ 550 if (!ar5212FillCapabilityInfo(ah)) { 551 HALDEBUG(ah, HAL_DEBUG_ANY, 552 "%s: failed ar5212FillCapabilityInfo\n", __func__); 553 ecode = HAL_EEREAD; 554 goto bad; 555 } 556 | 412 /* NB: silently accept anything in release code per Atheros */ 413 switch (AH_PRIVATE(ah)->ah_analog5GhzRev & AR_RADIO_SREV_MAJOR) { 414 case AR_RAD5111_SREV_MAJOR: 415 case AR_RAD5112_SREV_MAJOR: 416 case AR_RAD2112_SREV_MAJOR: 417 case AR_RAD2111_SREV_MAJOR: 418 case AR_RAD2413_SREV_MAJOR: 419 case AR_RAD5413_SREV_MAJOR: --- 121 unchanged lines hidden (view full) --- 541 */ 542 if (!ar5212FillCapabilityInfo(ah)) { 543 HALDEBUG(ah, HAL_DEBUG_ANY, 544 "%s: failed ar5212FillCapabilityInfo\n", __func__); 545 ecode = HAL_EEREAD; 546 goto bad; 547 } 548 |
557 rfStatus = AH_FALSE; 558 if (IS_5413(ah)) { 559#ifdef AH_SUPPORT_5413 560 rfStatus = ar5413RfAttach(ah, &ecode); 561#else 562 ecode = HAL_ENOTSUPP; 563#endif 564 } 565 else if (IS_2413(ah)) 566#ifdef AH_SUPPORT_2413 567 rfStatus = ar2413RfAttach(ah, &ecode); 568#else 569 ecode = HAL_ENOTSUPP; 570#endif 571 else if (IS_RAD5112(ah)) 572#ifdef AH_SUPPORT_5112 573 rfStatus = ar5112RfAttach(ah, &ecode); 574#else 575 ecode = HAL_ENOTSUPP; 576#endif 577 else if (IS_2425(ah) || IS_2417(ah)) 578#ifdef AH_SUPPORT_2425 579 rfStatus = ar2425RfAttach(ah, &ecode); 580#else 581 ecode = HAL_ENOTSUPP; 582#endif 583 else if (IS_RAD5111(ah)) 584#ifdef AH_SUPPORT_5111 585 rfStatus = ar5111RfAttach(ah, &ecode); 586#else 587 ecode = HAL_ENOTSUPP; 588#endif 589 if (!rfStatus) { | 549 if (!rf->attach(ah, &ecode)) { |
590 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: RF setup failed, status %u\n", 591 __func__, ecode); 592 goto bad; 593 } 594 /* 595 * Set noise floor adjust method; we arrange a 596 * direct call instead of thunking. 597 */ --- 278 unchanged lines hidden (view full) --- 876 877 pCap->halTstampPrecision = 15; 878 879 return AH_TRUE; 880#undef IS_COBRA 881#undef IS_GRIFFIN_LITE 882#undef AR_KEYTABLE_SIZE 883} | 550 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: RF setup failed, status %u\n", 551 __func__, ecode); 552 goto bad; 553 } 554 /* 555 * Set noise floor adjust method; we arrange a 556 * direct call instead of thunking. 557 */ --- 278 unchanged lines hidden (view full) --- 836 837 pCap->halTstampPrecision = 15; 838 839 return AH_TRUE; 840#undef IS_COBRA 841#undef IS_GRIFFIN_LITE 842#undef AR_KEYTABLE_SIZE 843} |
884#endif /* AH_SUPPORT_AR5212 */ | 844 845static const char* 846ar5212Probe(uint16_t vendorid, uint16_t devid) 847{ 848 if (vendorid == ATHEROS_VENDOR_ID || 849 vendorid == ATHEROS_3COM_VENDOR_ID || 850 vendorid == ATHEROS_3COM2_VENDOR_ID) { 851 switch (devid) { 852 case AR5212_FPGA: 853 return "Atheros 5212 (FPGA)"; 854 case AR5212_DEVID: 855 case AR5212_DEVID_IBM: 856 case AR5212_DEFAULT: 857 return "Atheros 5212"; 858 case AR5212_AR2413: 859 return "Atheros 2413"; 860 case AR5212_AR2417: 861 return "Atheros 2417"; 862 case AR5212_AR5413: 863 return "Atheros 5413"; 864 case AR5212_AR5424: 865 return "Atheros 5424/2424"; 866 } 867 } 868 return AH_NULL; 869} 870AH_CHIP(ar5212, ar5212Probe, ar5212Attach); |