ar5312_attach.c (185380) | ar5312_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: ar5312_attach.c,v 1.8 2008/11/27 22:30:03 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: ar5312_attach.c,v 1.8 2008/11/27 22:30:03 sam Exp $ 18 */ 19#include "opt_ah.h" 20 |
21#ifdef AH_SUPPORT_AR5312 22 23#if !defined(AH_SUPPORT_5112) && \ 24 !defined(AH_SUPPORT_5111) && \ 25 !defined(AH_SUPPORT_2316) && \ 26 !defined(AH_SUPPORT_2317) 27#error "No 5312 RF support defined" 28#endif 29 | |
30#include "ah.h" 31#include "ah_internal.h" 32#include "ah_devid.h" 33 34#include "ar5312/ar5312.h" 35#include "ar5312/ar5312reg.h" 36#include "ar5312/ar5312phy.h" 37 --- 23 unchanged lines hidden (view full) --- 61 .rssiThrHigh = 40, 62 .rssiThrLow = 7, 63 .period = 100, 64 }; 65 ar5212AniAttach(ah, &aniparams, &aniparams, AH_TRUE); 66} 67 68/* | 21#include "ah.h" 22#include "ah_internal.h" 23#include "ah_devid.h" 24 25#include "ar5312/ar5312.h" 26#include "ar5312/ar5312reg.h" 27#include "ar5312/ar5312phy.h" 28 --- 23 unchanged lines hidden (view full) --- 52 .rssiThrHigh = 40, 53 .rssiThrLow = 7, 54 .period = 100, 55 }; 56 ar5212AniAttach(ah, &aniparams, &aniparams, AH_TRUE); 57} 58 59/* |
69 * Attach for an AR3212 part. | 60 * Attach for an AR5312 part. |
70 */ | 61 */ |
71struct ath_hal * | 62static struct ath_hal * |
72ar5312Attach(uint16_t devid, HAL_SOFTC sc, 73 HAL_BUS_TAG st, HAL_BUS_HANDLE sh, HAL_STATUS *status) 74{ 75 struct ath_hal_5212 *ahp = AH_NULL; 76 struct ath_hal *ah; | 63ar5312Attach(uint16_t devid, HAL_SOFTC sc, 64 HAL_BUS_TAG st, HAL_BUS_HANDLE sh, HAL_STATUS *status) 65{ 66 struct ath_hal_5212 *ahp = AH_NULL; 67 struct ath_hal *ah; |
68 struct ath_hal_rf *rf; |
|
77 uint32_t val; 78 uint16_t eeval; 79 HAL_STATUS ecode; | 69 uint32_t val; 70 uint16_t eeval; 71 HAL_STATUS ecode; |
80 HAL_BOOL rfStatus; | |
81 82 HALDEBUG(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n", 83 __func__, sc, st, (void*) sh); 84 85 /* NB: memory is returned zero'd */ 86 ahp = ath_hal_malloc(sizeof (struct ath_hal_5212)); 87 if (ahp == AH_NULL) { 88 HALDEBUG(AH_NULL, HAL_DEBUG_ANY, --- 99 unchanged lines hidden (view full) --- 188 /* 189 * Set correct Baseband to analog shift 190 * setting to access analog chips. 191 */ 192 OS_REG_WRITE(ah, AR_PHY(0), 0x00000007); 193 194 /* Read Radio Chip Rev Extract */ 195 AH_PRIVATE(ah)->ah_analog5GhzRev = ar5212GetRadioRev(ah); | 72 73 HALDEBUG(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n", 74 __func__, sc, st, (void*) sh); 75 76 /* NB: memory is returned zero'd */ 77 ahp = ath_hal_malloc(sizeof (struct ath_hal_5212)); 78 if (ahp == AH_NULL) { 79 HALDEBUG(AH_NULL, HAL_DEBUG_ANY, --- 99 unchanged lines hidden (view full) --- 179 /* 180 * Set correct Baseband to analog shift 181 * setting to access analog chips. 182 */ 183 OS_REG_WRITE(ah, AR_PHY(0), 0x00000007); 184 185 /* Read Radio Chip Rev Extract */ 186 AH_PRIVATE(ah)->ah_analog5GhzRev = ar5212GetRadioRev(ah); |
196#ifdef AH_DEBUG 197 /* NB: silently accept anything in release code per Atheros */ 198 if ((AH_PRIVATE(ah)->ah_analog5GhzRev & 0xF0) != 199 AR_RAD5111_SREV_MAJOR && 200 (AH_PRIVATE(ah)->ah_analog5GhzRev & 0xF0) != 201 AR_RAD5112_SREV_MAJOR && 202 (AH_PRIVATE(ah)->ah_analog5GhzRev & 0xF0) != 203 AR_RAD2111_SREV_MAJOR && 204 (AH_PRIVATE(ah)->ah_analog5GhzRev & 0xF0) != 205 AR_RAD2112_SREV_MAJOR) { 206 ath_hal_printf(ah, "%s: 5G Radio Chip Rev 0x%02X is not supported by " 207 "this driver\n", __func__, 208 AH_PRIVATE(ah)->ah_analog5GhzRev); 209 ecode = HAL_ENOTSUPP; | 187 188 rf = ath_hal_rfprobe(ah, &ecode); 189 if (rf == AH_NULL) |
210 goto bad; | 190 goto bad; |
211 } 212#endif | |
213 if (IS_RAD5112(ah) && !IS_RADX112_REV2(ah)) { 214#ifdef AH_DEBUG 215 ath_hal_printf(ah, "%s: 5112 Rev 1 is not supported by this " 216 "driver (analog5GhzRev 0x%x)\n", __func__, 217 AH_PRIVATE(ah)->ah_analog5GhzRev); 218#endif 219 ecode = HAL_ENOTSUPP; 220 goto bad; --- 47 unchanged lines hidden (view full) --- 268 */ 269 if (!ar5212FillCapabilityInfo(ah)) { 270 HALDEBUG(ah, HAL_DEBUG_ANY, 271 "%s: failed ar5212FillCapabilityInfo\n", __func__); 272 ecode = HAL_EEREAD; 273 goto bad; 274 } 275 | 191 if (IS_RAD5112(ah) && !IS_RADX112_REV2(ah)) { 192#ifdef AH_DEBUG 193 ath_hal_printf(ah, "%s: 5112 Rev 1 is not supported by this " 194 "driver (analog5GhzRev 0x%x)\n", __func__, 195 AH_PRIVATE(ah)->ah_analog5GhzRev); 196#endif 197 ecode = HAL_ENOTSUPP; 198 goto bad; --- 47 unchanged lines hidden (view full) --- 246 */ 247 if (!ar5212FillCapabilityInfo(ah)) { 248 HALDEBUG(ah, HAL_DEBUG_ANY, 249 "%s: failed ar5212FillCapabilityInfo\n", __func__); 250 ecode = HAL_EEREAD; 251 goto bad; 252 } 253 |
276 rfStatus = AH_FALSE; 277 if (IS_2317(ah)) 278#if defined AH_SUPPORT_2317 279 rfStatus = ar2317RfAttach(ah, &ecode); 280#else 281 ecode = HAL_ENOTSUPP; 282#endif 283 else if (IS_2316(ah)) 284#if defined AH_SUPPORT_2316 285 rfStatus = ar2316RfAttach(ah, &ecode); 286#else 287 ecode = HAL_ENOTSUPP; 288#endif 289 else if (IS_RAD5112_ANY(ah)) 290#ifdef AH_SUPPORT_5112 291 rfStatus = ar5112RfAttach(ah, &ecode); 292#else 293 ecode = HAL_ENOTSUPP; 294#endif 295 else if (IS_RAD5111(ah)) 296#ifdef AH_SUPPORT_5111 297 rfStatus = ar5111RfAttach(ah, &ecode); 298#else 299 ecode = HAL_ENOTSUPP; 300#endif 301 if (!rfStatus) { | 254 if (!rf->attach(ah, &ecode)) { |
302 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: RF setup failed, status %u\n", 303 __func__, ecode); 304 goto bad; 305 } 306 /* arrange a direct call instead of thunking */ 307 AH_PRIVATE(ah)->ah_getNfAdjust = ahp->ah_rfHal->getNfAdjust; 308 309 /* Initialize gain ladder thermal calibration structure */ --- 38 unchanged lines hidden (view full) --- 348 ath_hal_printf(ah, "Invalid WLAN wmac index (%d)\n", 349 wlanNum); 350#endif 351 return AH_FALSE; 352 } 353 OS_MEMCPY(AH5212(ah)->ah_macaddr, macAddr, 6); 354 return AH_TRUE; 355} | 255 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: RF setup failed, status %u\n", 256 __func__, ecode); 257 goto bad; 258 } 259 /* arrange a direct call instead of thunking */ 260 AH_PRIVATE(ah)->ah_getNfAdjust = ahp->ah_rfHal->getNfAdjust; 261 262 /* Initialize gain ladder thermal calibration structure */ --- 38 unchanged lines hidden (view full) --- 301 ath_hal_printf(ah, "Invalid WLAN wmac index (%d)\n", 302 wlanNum); 303#endif 304 return AH_FALSE; 305 } 306 OS_MEMCPY(AH5212(ah)->ah_macaddr, macAddr, 6); 307 return AH_TRUE; 308} |
356#endif /* AH_SUPPORT_AR5312 */ | 309 310static const char* 311ar5312Probe(uint16_t vendorid, uint16_t devid) 312{ 313 if (vendorid == ATHEROS_VENDOR_ID) { 314 switch (devid) { 315 case AR5212_AR5312_REV2: 316 case AR5212_AR5312_REV7: 317 return "Atheros 5312 WiSoC"; 318 case AR5212_AR2313_REV8: 319 return "Atheros 2313 WiSoC"; 320 case AR5212_AR2315_REV6: 321 case AR5212_AR2315_REV6: 322 case AR5212_AR2315_REV7: 323 return "Atheros 2315 WiSoC"; 324 case AR5212_AR2317_REV1: 325 return "Atheros 2317 WiSoC"; 326 case AR5212_AR2413: 327 return "Atheros 2413"; 328 case AR5212_AR2417: 329 return "Atheros 2417"; 330 } 331 } 332 return AH_NULL; 333} 334AH_CHIP(ar5312, ar5312Probe, ar5312Attach); |