ah.c (185380) | ah.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 * --- 8 unchanged lines hidden (view full) --- 17 * $Id: ah.c,v 1.15 2008/11/15 22:15:44 sam Exp $ 18 */ 19#include "opt_ah.h" 20 21#include "ah.h" 22#include "ah_internal.h" 23#include "ah_devid.h" 24 | 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 * --- 8 unchanged lines hidden (view full) --- 17 * $Id: ah.c,v 1.15 2008/11/15 22:15:44 sam Exp $ 18 */ 19#include "opt_ah.h" 20 21#include "ah.h" 22#include "ah_internal.h" 23#include "ah_devid.h" 24 |
25#ifdef AH_SUPPORT_AR5210 26extern struct ath_hal *ar5210Attach(uint16_t, HAL_SOFTC, 27 HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*); 28#endif 29#ifdef AH_SUPPORT_AR5211 30extern struct ath_hal *ar5211Attach(uint16_t, HAL_SOFTC, 31 HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*); 32#endif 33#ifdef AH_SUPPORT_AR5212 34extern struct ath_hal *ar5212Attach(uint16_t, HAL_SOFTC, 35 HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*); 36#endif 37#ifdef AH_SUPPORT_AR5312 38extern struct ath_hal *ar5312Attach(uint16_t, HAL_SOFTC, 39 HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*); 40#endif 41#ifdef AH_SUPPORT_AR5416 42extern struct ath_hal *ar5416Attach(uint16_t, HAL_SOFTC, 43 HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*); 44#endif 45#ifdef AH_SUPPORT_AR9160 46extern struct ath_hal *ar9160Attach(uint16_t, HAL_SOFTC, 47 HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*); 48#endif 49#ifdef AH_SUPPORT_AR9280 50extern struct ath_hal *ar9280Attach(uint16_t, HAL_SOFTC, 51 HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*); 52#endif 53#ifdef AH_SUPPORT_AR9285 54extern struct ath_hal *ar9285Attach(uint16_t, HAL_SOFTC, 55 HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*); 56#endif | |
57 58#include "version.h" 59char ath_hal_version[] = ATH_HAL_VERSION; | 25 26#include "version.h" 27char ath_hal_version[] = ATH_HAL_VERSION; |
28/* XXX chip+rf support no longer correct */ |
|
60const char* ath_hal_buildopts[] = { 61#ifdef AH_SUPPORT_AR5210 62 "AR5210", 63#endif 64#ifdef AH_SUPPORT_AR5211 65 "AR5211", 66#endif 67#ifdef AH_SUPPORT_AR5212 --- 75 unchanged lines hidden (view full) --- 143 "DISABLE_WME", 144#endif 145#ifdef AH_SUPPORT_11D 146 "11D", 147#endif 148 AH_NULL 149}; 150 | 29const char* ath_hal_buildopts[] = { 30#ifdef AH_SUPPORT_AR5210 31 "AR5210", 32#endif 33#ifdef AH_SUPPORT_AR5211 34 "AR5211", 35#endif 36#ifdef AH_SUPPORT_AR5212 --- 75 unchanged lines hidden (view full) --- 112 "DISABLE_WME", 113#endif 114#ifdef AH_SUPPORT_11D 115 "11D", 116#endif 117 AH_NULL 118}; 119 |
151static const char* 152ath_hal_devname(uint16_t devid) | 120/* linker set of registered chips */ 121OS_SET_DECLARE(ah_chips, struct ath_hal_chip); 122 123/* 124 * Check the set of registered chips to see if any recognize 125 * the device as one they can support. 126 */ 127const char* 128ath_hal_probe(uint16_t vendorid, uint16_t devid) |
153{ | 129{ |
154 switch (devid) { 155 case AR5210_PROD: 156 case AR5210_DEFAULT: 157 return "Atheros 5210"; | 130 struct ath_hal_chip **pchip; |
158 | 131 |
159 case AR5211_DEVID: 160 case AR5311_DEVID: 161 case AR5211_DEFAULT: 162 return "Atheros 5211"; 163 case AR5211_FPGA11B: 164 return "Atheros 5211 (FPGA)"; 165 166 case AR5212_FPGA: 167 return "Atheros 5212 (FPGA)"; 168 case AR5212_AR5312_REV2: 169 case AR5212_AR5312_REV7: 170 return "Atheros 5312 WiSoC"; 171 case AR5212_AR2315_REV6: 172 case AR5212_AR2315_REV7: 173 return "Atheros 2315 WiSoC"; 174 case AR5212_AR2317_REV1: 175 return "Atheros 2317 WiSoC"; 176 case AR5212_AR2313_REV8: 177 return "Atheros 2313 WiSoC"; 178 case AR5212_DEVID: 179 case AR5212_DEVID_IBM: 180 case AR5212_DEFAULT: 181 return "Atheros 5212"; 182 case AR5212_AR2413: 183 return "Atheros 2413"; 184 case AR5212_AR2417: 185 return "Atheros 2417"; 186 case AR5212_AR5413: 187 return "Atheros 5413"; 188 case AR5212_AR5424: 189 return "Atheros 5424/2424"; 190 case AR5416_DEVID_PCI: 191 case AR5416_DEVID_PCIE: 192 return "Atheros 5416"; 193 case AR9160_DEVID_PCI: 194 return "Atheros 9160"; 195 case AR9280_DEVID_PCI: 196 case AR9280_DEVID_PCIE: 197 return "Atheros 9280"; 198 case AR9285_DEVID_PCIE: 199 return "Atheros 9285"; | 132 SET_FOREACH(pchip, ah_chips) { 133 const char *name = (*pchip)->probe(vendorid, devid); 134 if (name != AH_NULL) 135 return name; |
200 } 201 return AH_NULL; 202} 203 | 136 } 137 return AH_NULL; 138} 139 |
204const char* 205ath_hal_probe(uint16_t vendorid, uint16_t devid) 206{ 207 return (vendorid == ATHEROS_VENDOR_ID || 208 vendorid == ATHEROS_3COM_VENDOR_ID || 209 vendorid == ATHEROS_3COM2_VENDOR_ID ? 210 ath_hal_devname(devid) : 0); 211} 212 | |
213/* 214 * Attach detects device chip revisions, initializes the hwLayer 215 * function list, reads EEPROM information, 216 * selects reset vectors, and performs a short self test. 217 * Any failures will return an error that should cause a hardware 218 * disable. 219 */ 220struct ath_hal* 221ath_hal_attach(uint16_t devid, HAL_SOFTC sc, 222 HAL_BUS_TAG st, HAL_BUS_HANDLE sh, HAL_STATUS *error) 223{ | 140/* 141 * Attach detects device chip revisions, initializes the hwLayer 142 * function list, reads EEPROM information, 143 * selects reset vectors, and performs a short self test. 144 * Any failures will return an error that should cause a hardware 145 * disable. 146 */ 147struct ath_hal* 148ath_hal_attach(uint16_t devid, HAL_SOFTC sc, 149 HAL_BUS_TAG st, HAL_BUS_HANDLE sh, HAL_STATUS *error) 150{ |
224 struct ath_hal *ah=AH_NULL; | 151 struct ath_hal_chip **pchip; |
225 | 152 |
226 switch (devid) { 227#ifdef AH_SUPPORT_AR5210 228 case AR5210_AP: 229 case AR5210_PROD: 230 case AR5210_DEFAULT: 231 ah = ar5210Attach(devid, sc, st, sh, error); 232 break; 233#endif 234#ifdef AH_SUPPORT_AR5211 235 case AR5211_DEVID: 236 case AR5311_DEVID: 237 case AR5211_FPGA11B: 238 case AR5211_DEFAULT: 239 ah = ar5211Attach(devid, sc, st, sh, error); 240 break; 241#endif 242#ifdef AH_SUPPORT_AR5212 243 case AR5212_DEVID_IBM: 244 case AR5212_AR2413: 245 case AR5212_AR2417: 246 case AR5212_AR5413: 247 case AR5212_AR5424: 248 case AR5212_DEVID_FF19: /* XXX PCI Express extra */ 249 devid = AR5212_DEVID; 250 /* fall thru... */ 251 case AR5212_DEVID: 252 case AR5212_FPGA: 253 case AR5212_DEFAULT: 254 ah = ar5212Attach(devid, sc, st, sh, error); 255 break; 256#endif 257#ifdef AH_SUPPORT_AR5312 258 case AR5212_AR5312_REV2: 259 case AR5212_AR5312_REV7: 260 case AR5212_AR2313_REV8: 261 case AR5212_AR2315_REV6: 262 case AR5212_AR2315_REV7: 263 case AR5212_AR2317_REV1: 264 ah = ar5312Attach(devid, sc, st, sh, error); 265 break; 266#endif 267#ifdef AH_SUPPORT_AR5416 268 case AR5416_DEVID_PCI: 269 case AR5416_DEVID_PCIE: 270 ah = ar5416Attach(devid, sc, st, sh, error); 271 break; 272#endif 273#ifdef AH_SUPPORT_AR9160 274 case AR9160_DEVID_PCI: 275 ah = ar9160Attach(devid, sc, st, sh, error); 276 break; 277#endif 278#ifdef AH_SUPPORT_AR9280 279 case AR9280_DEVID_PCI: 280 case AR9280_DEVID_PCIE: 281 ah = ar9280Attach(devid, sc, st, sh, error); 282 break; 283#endif 284#ifdef AH_SUPPORT_AR9285 285 case AR9285_DEVID_PCIE: 286 ah = ar9285Attach(devid, sc, st, sh, error); 287 break; 288#endif 289 default: 290 ah = AH_NULL; 291 *error = HAL_ENXIO; 292 break; | 153 SET_FOREACH(pchip, ah_chips) { 154 struct ath_hal_chip *chip = *pchip; 155 struct ath_hal *ah; 156 157 /* XXX don't have vendorid, assume atheros one works */ 158 if (chip->probe(ATHEROS_VENDOR_ID, devid) == AH_NULL) 159 continue; 160 ah = chip->attach(devid, sc, st, sh, error); 161 if (ah != AH_NULL) { 162 /* copy back private state to public area */ 163 ah->ah_devid = AH_PRIVATE(ah)->ah_devid; 164 ah->ah_subvendorid = AH_PRIVATE(ah)->ah_subvendorid; 165 ah->ah_macVersion = AH_PRIVATE(ah)->ah_macVersion; 166 ah->ah_macRev = AH_PRIVATE(ah)->ah_macRev; 167 ah->ah_phyRev = AH_PRIVATE(ah)->ah_phyRev; 168 ah->ah_analog5GhzRev = AH_PRIVATE(ah)->ah_analog5GhzRev; 169 ah->ah_analog2GhzRev = AH_PRIVATE(ah)->ah_analog2GhzRev; 170 return ah; 171 } |
293 } | 172 } |
294 if (ah != AH_NULL) { 295 /* copy back private state to public area */ 296 ah->ah_devid = AH_PRIVATE(ah)->ah_devid; 297 ah->ah_subvendorid = AH_PRIVATE(ah)->ah_subvendorid; 298 ah->ah_macVersion = AH_PRIVATE(ah)->ah_macVersion; 299 ah->ah_macRev = AH_PRIVATE(ah)->ah_macRev; 300 ah->ah_phyRev = AH_PRIVATE(ah)->ah_phyRev; 301 ah->ah_analog5GhzRev = AH_PRIVATE(ah)->ah_analog5GhzRev; 302 ah->ah_analog2GhzRev = AH_PRIVATE(ah)->ah_analog2GhzRev; | 173 return AH_NULL; 174} 175 176/* linker set of registered RF backends */ 177OS_SET_DECLARE(ah_rfs, struct ath_hal_rf); 178 179/* 180 * Check the set of registered RF backends to see if 181 * any recognize the device as one they can support. 182 */ 183struct ath_hal_rf * 184ath_hal_rfprobe(struct ath_hal *ah, HAL_STATUS *ecode) 185{ 186 struct ath_hal_rf **prf; 187 188 SET_FOREACH(prf, ah_rfs) { 189 struct ath_hal_rf *rf = *prf; 190 if (rf->probe(ah)) 191 return rf; |
303 } | 192 } |
304 return ah; | 193 *ecode = HAL_ENOTSUPP; 194 return AH_NULL; |
305} 306 307/* 308 * Poll the register looking for a specific value. 309 */ 310HAL_BOOL 311ath_hal_wait(struct ath_hal *ah, u_int reg, uint32_t mask, uint32_t val) 312{ --- 778 unchanged lines hidden --- | 195} 196 197/* 198 * Poll the register looking for a specific value. 199 */ 200HAL_BOOL 201ath_hal_wait(struct ath_hal *ah, u_int reg, uint32_t mask, uint32_t val) 202{ --- 778 unchanged lines hidden --- |