Date: Fri, 28 Nov 2008 19:58:10 +0000 (UTC) From: Sam Leffler <sam@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r185406 - in projects/ath_hal: . ar5210 ar5211 ar5212 ar5312 ar5416 Message-ID: <200811281958.mASJwAFa028208@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: sam Date: Fri Nov 28 19:58:09 2008 New Revision: 185406 URL: http://svn.freebsd.org/changeset/base/185406 Log: Replace most compile-time support options with linker sets for chip and RF backend support: o add OS_DATA_SET and OS_SET_DECLARE os requirements for setting up linker sets o add AH_CHIP macro for registering chip support (e.g. 5210) o add AH_RF macro for registering RF support (e.g. 2413); note this isn't required for single chip solutions where there's no ambiguity (e.g. 5416/9160+2133) but for 5212 class parts it's required because of the multi-chip solutions o remove all uses of AH_SUPPORT_AR5210, AH_SUPPORT_AR5211, AH_SUPPORT_5212, and AH_SUPPORT_AR9160; still need AH_SUPPORT_AR5416 to enable the 11n descriptor formats and 5312 support is presently broken o remove all uses of AH_SUPPORT_2133, AH_SUPPORT_2413, AH_SUPPORT_5111, AH_SUPPORT_5112, AH_SUPPORT_2417, AH_SUPPORT_2425, and AH_SUPPORT_5413; 5312-related support still requires fixup Remaining issues: o fixup SoC attach o ath_hal_attach uses a hack to probe w/o access to the vendorid o fallback handling of parts w/o a macrev needs to be restored Modified: projects/ath_hal/ah.c projects/ath_hal/ah_internal.h projects/ath_hal/ar5210/ar5210.h projects/ath_hal/ar5210/ar5210_attach.c projects/ath_hal/ar5210/ar5210_beacon.c projects/ath_hal/ar5210/ar5210_interrupts.c projects/ath_hal/ar5210/ar5210_keycache.c projects/ath_hal/ar5210/ar5210_misc.c projects/ath_hal/ar5210/ar5210_phy.c projects/ath_hal/ar5210/ar5210_power.c projects/ath_hal/ar5210/ar5210_recv.c projects/ath_hal/ar5210/ar5210_reset.c projects/ath_hal/ar5210/ar5210_xmit.c projects/ath_hal/ar5211/ar5211_attach.c projects/ath_hal/ar5211/ar5211_beacon.c projects/ath_hal/ar5211/ar5211_interrupts.c projects/ath_hal/ar5211/ar5211_keycache.c projects/ath_hal/ar5211/ar5211_misc.c projects/ath_hal/ar5211/ar5211_phy.c projects/ath_hal/ar5211/ar5211_power.c projects/ath_hal/ar5211/ar5211_recv.c projects/ath_hal/ar5211/ar5211_reset.c projects/ath_hal/ar5211/ar5211_xmit.c projects/ath_hal/ar5212/ar2316.c projects/ath_hal/ar5212/ar2317.c projects/ath_hal/ar5212/ar2413.c projects/ath_hal/ar5212/ar2425.c projects/ath_hal/ar5212/ar5111.c projects/ath_hal/ar5212/ar5112.c projects/ath_hal/ar5212/ar5212.h projects/ath_hal/ar5212/ar5212_ani.c projects/ath_hal/ar5212/ar5212_attach.c projects/ath_hal/ar5212/ar5212_beacon.c projects/ath_hal/ar5212/ar5212_eeprom.c projects/ath_hal/ar5212/ar5212_gpio.c projects/ath_hal/ar5212/ar5212_interrupts.c projects/ath_hal/ar5212/ar5212_keycache.c projects/ath_hal/ar5212/ar5212_misc.c projects/ath_hal/ar5212/ar5212_phy.c projects/ath_hal/ar5212/ar5212_power.c projects/ath_hal/ar5212/ar5212_recv.c projects/ath_hal/ar5212/ar5212_reset.c projects/ath_hal/ar5212/ar5212_rfgain.c projects/ath_hal/ar5212/ar5212_xmit.c projects/ath_hal/ar5212/ar5413.c projects/ath_hal/ar5312/ar5312_attach.c projects/ath_hal/ar5416/ar2133.c projects/ath_hal/ar5416/ar5416_ani.c projects/ath_hal/ar5416/ar5416_attach.c projects/ath_hal/ar5416/ar5416_beacon.c projects/ath_hal/ar5416/ar5416_cal.c projects/ath_hal/ar5416/ar5416_cal_adcdc.c projects/ath_hal/ar5416/ar5416_cal_adcgain.c projects/ath_hal/ar5416/ar5416_cal_iq.c projects/ath_hal/ar5416/ar5416_eeprom.c projects/ath_hal/ar5416/ar5416_gpio.c projects/ath_hal/ar5416/ar5416_interrupts.c projects/ath_hal/ar5416/ar5416_keycache.c projects/ath_hal/ar5416/ar5416_misc.c projects/ath_hal/ar5416/ar5416_phy.c projects/ath_hal/ar5416/ar5416_power.c projects/ath_hal/ar5416/ar5416_recv.c projects/ath_hal/ar5416/ar5416_reset.c projects/ath_hal/ar5416/ar5416_xmit.c projects/ath_hal/ar5416/ar9160_attach.c Modified: projects/ath_hal/ah.c ============================================================================== --- projects/ath_hal/ah.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ah.c Fri Nov 28 19:58:09 2008 (r185406) @@ -22,41 +22,10 @@ #include "ah_internal.h" #include "ah_devid.h" -#ifdef AH_SUPPORT_AR5210 -extern struct ath_hal *ar5210Attach(uint16_t, HAL_SOFTC, - HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*); -#endif -#ifdef AH_SUPPORT_AR5211 -extern struct ath_hal *ar5211Attach(uint16_t, HAL_SOFTC, - HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*); -#endif -#ifdef AH_SUPPORT_AR5212 -extern struct ath_hal *ar5212Attach(uint16_t, HAL_SOFTC, - HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*); -#endif -#ifdef AH_SUPPORT_AR5312 -extern struct ath_hal *ar5312Attach(uint16_t, HAL_SOFTC, - HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*); -#endif -#ifdef AH_SUPPORT_AR5416 -extern struct ath_hal *ar5416Attach(uint16_t, HAL_SOFTC, - HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*); -#endif -#ifdef AH_SUPPORT_AR9160 -extern struct ath_hal *ar9160Attach(uint16_t, HAL_SOFTC, - HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*); -#endif -#ifdef AH_SUPPORT_AR9280 -extern struct ath_hal *ar9280Attach(uint16_t, HAL_SOFTC, - HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*); -#endif -#ifdef AH_SUPPORT_AR9285 -extern struct ath_hal *ar9285Attach(uint16_t, HAL_SOFTC, - HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*); -#endif #include "version.h" char ath_hal_version[] = ATH_HAL_VERSION; +/* XXX chip+rf support no longer correct */ const char* ath_hal_buildopts[] = { #ifdef AH_SUPPORT_AR5210 "AR5210", @@ -148,66 +117,24 @@ const char* ath_hal_buildopts[] = { AH_NULL }; -static const char* -ath_hal_devname(uint16_t devid) -{ - switch (devid) { - case AR5210_PROD: - case AR5210_DEFAULT: - return "Atheros 5210"; - - case AR5211_DEVID: - case AR5311_DEVID: - case AR5211_DEFAULT: - return "Atheros 5211"; - case AR5211_FPGA11B: - return "Atheros 5211 (FPGA)"; - - case AR5212_FPGA: - return "Atheros 5212 (FPGA)"; - case AR5212_AR5312_REV2: - case AR5212_AR5312_REV7: - return "Atheros 5312 WiSoC"; - case AR5212_AR2315_REV6: - case AR5212_AR2315_REV7: - return "Atheros 2315 WiSoC"; - case AR5212_AR2317_REV1: - return "Atheros 2317 WiSoC"; - case AR5212_AR2313_REV8: - return "Atheros 2313 WiSoC"; - case AR5212_DEVID: - case AR5212_DEVID_IBM: - case AR5212_DEFAULT: - return "Atheros 5212"; - case AR5212_AR2413: - return "Atheros 2413"; - case AR5212_AR2417: - return "Atheros 2417"; - case AR5212_AR5413: - return "Atheros 5413"; - case AR5212_AR5424: - return "Atheros 5424/2424"; - case AR5416_DEVID_PCI: - case AR5416_DEVID_PCIE: - return "Atheros 5416"; - case AR9160_DEVID_PCI: - return "Atheros 9160"; - case AR9280_DEVID_PCI: - case AR9280_DEVID_PCIE: - return "Atheros 9280"; - case AR9285_DEVID_PCIE: - return "Atheros 9285"; - } - return AH_NULL; -} +/* linker set of registered chips */ +OS_SET_DECLARE(ah_chips, struct ath_hal_chip); +/* + * Check the set of registered chips to see if any recognize + * the device as one they can support. + */ const char* ath_hal_probe(uint16_t vendorid, uint16_t devid) { - return (vendorid == ATHEROS_VENDOR_ID || - vendorid == ATHEROS_3COM_VENDOR_ID || - vendorid == ATHEROS_3COM2_VENDOR_ID ? - ath_hal_devname(devid) : 0); + struct ath_hal_chip **pchip; + + SET_FOREACH(pchip, ah_chips) { + const char *name = (*pchip)->probe(vendorid, devid); + if (name != AH_NULL) + return name; + } + return AH_NULL; } /* @@ -221,87 +148,50 @@ struct ath_hal* ath_hal_attach(uint16_t devid, HAL_SOFTC sc, HAL_BUS_TAG st, HAL_BUS_HANDLE sh, HAL_STATUS *error) { - struct ath_hal *ah=AH_NULL; + struct ath_hal_chip **pchip; - switch (devid) { -#ifdef AH_SUPPORT_AR5210 - case AR5210_AP: - case AR5210_PROD: - case AR5210_DEFAULT: - ah = ar5210Attach(devid, sc, st, sh, error); - break; -#endif -#ifdef AH_SUPPORT_AR5211 - case AR5211_DEVID: - case AR5311_DEVID: - case AR5211_FPGA11B: - case AR5211_DEFAULT: - ah = ar5211Attach(devid, sc, st, sh, error); - break; -#endif -#ifdef AH_SUPPORT_AR5212 - case AR5212_DEVID_IBM: - case AR5212_AR2413: - case AR5212_AR2417: - case AR5212_AR5413: - case AR5212_AR5424: - case AR5212_DEVID_FF19: /* XXX PCI Express extra */ - devid = AR5212_DEVID; - /* fall thru... */ - case AR5212_DEVID: - case AR5212_FPGA: - case AR5212_DEFAULT: - ah = ar5212Attach(devid, sc, st, sh, error); - break; -#endif -#ifdef AH_SUPPORT_AR5312 - case AR5212_AR5312_REV2: - case AR5212_AR5312_REV7: - case AR5212_AR2313_REV8: - case AR5212_AR2315_REV6: - case AR5212_AR2315_REV7: - case AR5212_AR2317_REV1: - ah = ar5312Attach(devid, sc, st, sh, error); - break; -#endif -#ifdef AH_SUPPORT_AR5416 - case AR5416_DEVID_PCI: - case AR5416_DEVID_PCIE: - ah = ar5416Attach(devid, sc, st, sh, error); - break; -#endif -#ifdef AH_SUPPORT_AR9160 - case AR9160_DEVID_PCI: - ah = ar9160Attach(devid, sc, st, sh, error); - break; -#endif -#ifdef AH_SUPPORT_AR9280 - case AR9280_DEVID_PCI: - case AR9280_DEVID_PCIE: - ah = ar9280Attach(devid, sc, st, sh, error); - break; -#endif -#ifdef AH_SUPPORT_AR9285 - case AR9285_DEVID_PCIE: - ah = ar9285Attach(devid, sc, st, sh, error); - break; -#endif - default: - ah = AH_NULL; - *error = HAL_ENXIO; - break; + SET_FOREACH(pchip, ah_chips) { + struct ath_hal_chip *chip = *pchip; + struct ath_hal *ah; + + /* XXX don't have vendorid, assume atheros one works */ + if (chip->probe(ATHEROS_VENDOR_ID, devid) == AH_NULL) + continue; + ah = chip->attach(devid, sc, st, sh, error); + if (ah != AH_NULL) { + /* copy back private state to public area */ + ah->ah_devid = AH_PRIVATE(ah)->ah_devid; + ah->ah_subvendorid = AH_PRIVATE(ah)->ah_subvendorid; + ah->ah_macVersion = AH_PRIVATE(ah)->ah_macVersion; + ah->ah_macRev = AH_PRIVATE(ah)->ah_macRev; + ah->ah_phyRev = AH_PRIVATE(ah)->ah_phyRev; + ah->ah_analog5GhzRev = AH_PRIVATE(ah)->ah_analog5GhzRev; + ah->ah_analog2GhzRev = AH_PRIVATE(ah)->ah_analog2GhzRev; + return ah; + } } - if (ah != AH_NULL) { - /* copy back private state to public area */ - ah->ah_devid = AH_PRIVATE(ah)->ah_devid; - ah->ah_subvendorid = AH_PRIVATE(ah)->ah_subvendorid; - ah->ah_macVersion = AH_PRIVATE(ah)->ah_macVersion; - ah->ah_macRev = AH_PRIVATE(ah)->ah_macRev; - ah->ah_phyRev = AH_PRIVATE(ah)->ah_phyRev; - ah->ah_analog5GhzRev = AH_PRIVATE(ah)->ah_analog5GhzRev; - ah->ah_analog2GhzRev = AH_PRIVATE(ah)->ah_analog2GhzRev; + return AH_NULL; +} + +/* linker set of registered RF backends */ +OS_SET_DECLARE(ah_rfs, struct ath_hal_rf); + +/* + * Check the set of registered RF backends to see if + * any recognize the device as one they can support. + */ +struct ath_hal_rf * +ath_hal_rfprobe(struct ath_hal *ah, HAL_STATUS *ecode) +{ + struct ath_hal_rf **prf; + + SET_FOREACH(prf, ah_rfs) { + struct ath_hal_rf *rf = *prf; + if (rf->probe(ah)) + return rf; } - return ah; + *ecode = HAL_ENOTSUPP; + return AH_NULL; } /* Modified: projects/ath_hal/ah_internal.h ============================================================================== --- projects/ath_hal/ah_internal.h Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ah_internal.h Fri Nov 28 19:58:09 2008 (r185406) @@ -83,6 +83,42 @@ typedef enum { HAL_CAP_AR = 1, /* AR capability */ } HAL_PHYDIAG_CAPS; +/* + * Each chip or class of chips registers to offer support. + */ +struct ath_hal_chip { + const char *(*probe)(uint16_t vendorid, uint16_t devid); + struct ath_hal *(*attach)(uint16_t devid, HAL_SOFTC, + HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS *error); +}; +#ifndef AH_CHIP +#define AH_CHIP(name, _probe, _attach) \ +static struct ath_hal_chip name##_chip = { \ + .probe = _probe, \ + .attach = _attach \ +}; \ +OS_DATA_SET(ah_chips, name##_chip) +#endif + +/* + * Each RF backend registers to offer support; this is mostly + * used by multi-chip 5212 solutions. Single-chip solutions + * have a fixed idea about which RF to use. + */ +struct ath_hal_rf { + HAL_BOOL (*probe)(struct ath_hal *ah); + HAL_BOOL (*attach)(struct ath_hal *ah, HAL_STATUS *ecode); +}; +#ifndef AH_RF +#define AH_RF(name, _probe, _attach) \ +static struct ath_hal_rf name##_rf = { \ + .probe = _probe, \ + .attach = _attach \ +}; \ +OS_DATA_SET(ah_rfs, name##_rf) +#endif + +struct ath_hal_rf *ath_hal_rfprobe(struct ath_hal *ah, HAL_STATUS *ecode); /* * Internal form of a HAL_CHANNEL. Note that the structure Modified: projects/ath_hal/ar5210/ar5210.h ============================================================================== --- projects/ath_hal/ar5210/ar5210.h Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5210/ar5210.h Fri Nov 28 19:58:09 2008 (r185406) @@ -126,10 +126,7 @@ struct ath_hal_5210 { struct ath_hal; -extern struct ath_hal *ar5210Attach(uint16_t, HAL_SOFTC, - HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS *); -extern void ar5210Detach(struct ath_hal *); - +extern void ar5210Detach(struct ath_hal *ah); extern HAL_BOOL ar5210Reset(struct ath_hal *, HAL_OPMODE, HAL_CHANNEL *, HAL_BOOL bChannelChange, HAL_STATUS *); extern void ar5210SetPCUConfig(struct ath_hal *); Modified: projects/ath_hal/ar5210/ar5210_attach.c ============================================================================== --- projects/ath_hal/ar5210/ar5210_attach.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5210/ar5210_attach.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,10 +18,9 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_AR5210 - #include "ah.h" #include "ah_internal.h" +#include "ah_devid.h" #include "ar5210/ar5210.h" #include "ar5210/ar5210reg.h" @@ -170,8 +169,9 @@ static HAL_BOOL ar5210FillCapabilityInfo /* * Attach for an AR5210 part. */ -struct ath_hal * -ar5210Attach(uint16_t devid, HAL_SOFTC sc, HAL_BUS_TAG st, HAL_BUS_HANDLE sh, HAL_STATUS *status) +static struct ath_hal * +ar5210Attach(uint16_t devid, HAL_SOFTC sc, HAL_BUS_TAG st, HAL_BUS_HANDLE sh, + HAL_STATUS *status) { #define N(a) (sizeof(a)/sizeof(a[0])) struct ath_hal_5210 *ahp; @@ -371,4 +371,13 @@ ar5210FillCapabilityInfo(struct ath_hal ahpriv->ah_rxornIsFatal = AH_TRUE; return AH_TRUE; } -#endif /* AH_SUPPORT_AR5210 */ + +static const char* +ar5210Probe(uint16_t vendorid, uint16_t devid) +{ + if (vendorid == ATHEROS_VENDOR_ID && + (devid == AR5210_PROD || devid == AR5210_DEFAULT)) + return "Atheros 5210"; + return AH_NULL; +} +AH_CHIP(ar5210, ar5210Probe, ar5210Attach); Modified: projects/ath_hal/ar5210/ar5210_beacon.c ============================================================================== --- projects/ath_hal/ar5210/ar5210_beacon.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5210/ar5210_beacon.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_AR5210 - #include "ah.h" #include "ah_internal.h" #include "ah_desc.h" @@ -191,4 +189,3 @@ ar5210SetStaBeaconTimers(struct ath_hal OS_REG_WRITE(ah, AR_RSSI_THR, ahp->ah_rssiThr); #undef BMISS_MAX } -#endif /* AH_SUPPORT_AR5210 */ Modified: projects/ath_hal/ar5210/ar5210_interrupts.c ============================================================================== --- projects/ath_hal/ar5210/ar5210_interrupts.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5210/ar5210_interrupts.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_AR5210 - #include "ah.h" #include "ah_internal.h" @@ -134,4 +132,3 @@ ar5210SetInterrupts(struct ath_hal *ah, return omask; } -#endif /* AH_SUPPORT_AR5210 */ Modified: projects/ath_hal/ar5210/ar5210_keycache.c ============================================================================== --- projects/ath_hal/ar5210/ar5210_keycache.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5210/ar5210_keycache.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_AR5210 - #include "ah.h" #include "ah_internal.h" @@ -156,4 +154,3 @@ ar5210SetKeyCacheEntry(struct ath_hal *a OS_REG_WRITE(ah, AR_KEYTABLE_TYPE(entry), keyType); return ar5210SetKeyCacheEntryMac(ah, entry, mac); } -#endif /* AH_SUPPORT_AR5210 */ Modified: projects/ath_hal/ar5210/ar5210_misc.c ============================================================================== --- projects/ath_hal/ar5210/ar5210_misc.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5210/ar5210_misc.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_AR5210 - #include "ah.h" #include "ah_internal.h" @@ -642,4 +640,3 @@ ar5210GetDiagState(struct ath_hal *ah, i return ath_hal_getdiagstate(ah, request, args, argsize, result, resultsize); } -#endif /* AH_SUPPORT_AR5210 */ Modified: projects/ath_hal/ar5210/ar5210_phy.c ============================================================================== --- projects/ath_hal/ar5210/ar5210_phy.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5210/ar5210_phy.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_AR5210 - #include "ah.h" #include "ah_internal.h" @@ -85,4 +83,3 @@ ar5210GetRateTable(struct ath_hal *ah, u ath_hal_setupratetable(ah, rt); return rt; } -#endif /* AH_SUPPORT_AR5210 */ Modified: projects/ath_hal/ar5210/ar5210_power.c ============================================================================== --- projects/ath_hal/ar5210/ar5210_power.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5210/ar5210_power.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_AR5210 - #include "ah.h" #include "ah_internal.h" @@ -134,4 +132,3 @@ ar5210GetPowerMode(struct ath_hal *ah) /* Just so happens the h/w maps directly to the abstracted value */ return MS(OS_REG_READ(ah, AR_SCR), AR_SCR_SLE); } -#endif /* AH_SUPPORT_AR5210 */ Modified: projects/ath_hal/ar5210/ar5210_recv.c ============================================================================== --- projects/ath_hal/ar5210/ar5210_recv.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5210/ar5210_recv.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_AR5210 - #include "ah.h" #include "ah_internal.h" #include "ah_desc.h" @@ -266,4 +264,3 @@ ar5210ProcRxDesc(struct ath_hal *ah, str return HAL_OK; } -#endif /* AH_SUPPORT_AR5210 */ Modified: projects/ath_hal/ar5210/ar5210_reset.c ============================================================================== --- projects/ath_hal/ar5210/ar5210_reset.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5210/ar5210_reset.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_AR5210 - #include "ah.h" #include "ah_internal.h" @@ -1003,4 +1001,3 @@ ar5210GetRfgain(struct ath_hal *ah) { return HAL_RFGAIN_INACTIVE; } -#endif /* AH_SUPPORT_AR5210 */ Modified: projects/ath_hal/ar5210/ar5210_xmit.c ============================================================================== --- projects/ath_hal/ar5210/ar5210_xmit.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5210/ar5210_xmit.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_AR5210 - #include "ah.h" #include "ah_internal.h" #include "ah_desc.h" @@ -623,4 +621,3 @@ ar5210GetTxIntrQueue(struct ath_hal *ah, { return; } -#endif /* AH_SUPPORT_AR5210 */ Modified: projects/ath_hal/ar5211/ar5211_attach.c ============================================================================== --- projects/ath_hal/ar5211/ar5211_attach.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5211/ar5211_attach.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_AR5211 - #include "ah.h" #include "ah_internal.h" #include "ah_devid.h" @@ -502,4 +500,17 @@ ar5211FillCapabilityInfo(struct ath_hal ahpriv->ah_rxornIsFatal = AH_TRUE; return AH_TRUE; } -#endif /* AH_SUPPORT_AR5211 */ + +static const char* +ar5211Probe(uint16_t vendorid, uint16_t devid) +{ + if (vendorid == ATHEROS_VENDOR_ID) { + if (devid == AR5211_DEVID || devid == AR5311_DEVID || + devid == AR5211_DEFAULT) + return "Atheros 5211"; + if (devid == AR5211_FPGA11B) + return "Atheros 5211 (FPGA)"; + } + return AH_NULL; +} +AH_CHIP(ar5211, ar5211Probe, ar5211Attach); Modified: projects/ath_hal/ar5211/ar5211_beacon.c ============================================================================== --- projects/ath_hal/ar5211/ar5211_beacon.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5211/ar5211_beacon.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_AR5211 - #include "ah.h" #include "ah_internal.h" @@ -173,4 +171,3 @@ ar5211SetStaBeaconTimers(struct ath_hal (bs->bs_sleepduration - SLEEP_SLOP) << 3); #undef SLEEP_SLOP } -#endif /* AH_SUPPORT_AR5211 */ Modified: projects/ath_hal/ar5211/ar5211_interrupts.c ============================================================================== --- projects/ath_hal/ar5211/ar5211_interrupts.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5211/ar5211_interrupts.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_AR5211 - #include "ah.h" #include "ah_internal.h" @@ -160,4 +158,3 @@ ar5211SetInterrupts(struct ath_hal *ah, return omask; } -#endif /* AH_SUPPORT_AR5211 */ Modified: projects/ath_hal/ar5211/ar5211_keycache.c ============================================================================== --- projects/ath_hal/ar5211/ar5211_keycache.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5211/ar5211_keycache.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_AR5211 - #include "ah.h" #include "ah_internal.h" @@ -178,4 +176,3 @@ ar5211SetKeyCacheEntry(struct ath_hal *a OS_REG_WRITE(ah, AR_KEYTABLE_TYPE(entry), keyType); return ar5211SetKeyCacheEntryMac(ah, entry, mac); } -#endif /* AH_SUPPORT_AR5211 */ Modified: projects/ath_hal/ar5211/ar5211_misc.c ============================================================================== --- projects/ath_hal/ar5211/ar5211_misc.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5211/ar5211_misc.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_AR5211 - #include "ah.h" #include "ah_internal.h" @@ -685,4 +683,3 @@ ar5211GetDiagState(struct ath_hal *ah, i } return AH_FALSE; } -#endif /* AH_SUPPORT_AR5211 */ Modified: projects/ath_hal/ar5211/ar5211_phy.c ============================================================================== --- projects/ath_hal/ar5211/ar5211_phy.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5211/ar5211_phy.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_AR5211 - #include "ah.h" #include "ah_internal.h" @@ -104,4 +102,3 @@ ar5211GetRateTable(struct ath_hal *ah, u ath_hal_setupratetable(ah, rt); return rt; } -#endif /* AH_SUPPORT_AR5211 */ Modified: projects/ath_hal/ar5211/ar5211_power.c ============================================================================== --- projects/ath_hal/ar5211/ar5211_power.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5211/ar5211_power.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_AR5211 - #include "ah.h" #include "ah_internal.h" @@ -136,4 +134,3 @@ ar5211GetPowerMode(struct ath_hal *ah) /* Just so happens the h/w maps directly to the abstracted value */ return MS(OS_REG_READ(ah, AR_SCR), AR_SCR_SLE); } -#endif /* AH_SUPPORT_AR5211 */ Modified: projects/ath_hal/ar5211/ar5211_recv.c ============================================================================== --- projects/ath_hal/ar5211/ar5211_recv.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5211/ar5211_recv.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_AR5211 - #include "ah.h" #include "ah_internal.h" #include "ah_desc.h" @@ -245,4 +243,3 @@ ar5211ProcRxDesc(struct ath_hal *ah, str return HAL_OK; } -#endif /* AH_SUPPORT_AR5211 */ Modified: projects/ath_hal/ar5211/ar5211_reset.c ============================================================================== --- projects/ath_hal/ar5211/ar5211_reset.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5211/ar5211_reset.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,7 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_AR5211 /* * Chips specific device attachment and device info collection * Connects Init Reg Vectors, EEPROM Data, and device Functions. @@ -2137,4 +2136,3 @@ ar5211SetPCUConfig(struct ath_hal *ah) { ar5211SetOperatingMode(ah, AH_PRIVATE(ah)->ah_opmode); } -#endif /* AH_SUPPORT_AR5211 */ Modified: projects/ath_hal/ar5211/ar5211_xmit.c ============================================================================== --- projects/ath_hal/ar5211/ar5211_xmit.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5211/ar5211_xmit.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_AR5211 - #include "ah.h" #include "ah_internal.h" #include "ah_desc.h" @@ -679,4 +677,3 @@ ar5211GetTxIntrQueue(struct ath_hal *ah, { return; } -#endif /* AH_SUPPORT_AR5211 */ Modified: projects/ath_hal/ar5212/ar2316.c ============================================================================== --- projects/ath_hal/ar5212/ar2316.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5212/ar2316.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_2316 - #include "ah.h" #include "ah_internal.h" @@ -727,7 +725,7 @@ ar2316RfDetach(struct ath_hal *ah) * Allocate memory for private state. * Scratch Buffer will be reinitialized every reset so no need to zero now */ -HAL_BOOL +static HAL_BOOL ar2316RfAttach(struct ath_hal *ah, HAL_STATUS *status) { struct ath_hal_5212 *ahp = AH5212(ah); @@ -760,4 +758,10 @@ ar2316RfAttach(struct ath_hal *ah, HAL_S return AH_TRUE; } -#endif /* AH_SUPPORT_2316 */ + +static HAL_BOOL +ar2316Probe(struct ath_hal *ah) +{ + return IS_2316(ah); +} +AH_RF(ar2316, ar2316Probe, ar2316RfAttach); Modified: projects/ath_hal/ar5212/ar2317.c ============================================================================== --- projects/ath_hal/ar5212/ar2317.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5212/ar2317.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_2317 - #include "ah.h" #include "ah_internal.h" @@ -706,7 +704,7 @@ ar2317RfDetach(struct ath_hal *ah) * Allocate memory for analog bank scratch buffers * Scratch Buffer will be reinitialized every reset so no need to zero now */ -HAL_BOOL +static HAL_BOOL ar2317RfAttach(struct ath_hal *ah, HAL_STATUS *status) { struct ath_hal_5212 *ahp = AH5212(ah); @@ -737,4 +735,10 @@ ar2317RfAttach(struct ath_hal *ah, HAL_S return AH_TRUE; } -#endif /* AH_SUPPORT_2317 */ + +static HAL_BOOL +ar2317Probe(struct ath_hal *ah) +{ + return IS_2317(ah); +} +AH_RF(ar2317, ar2317Probe, ar2317RfAttach); Modified: projects/ath_hal/ar5212/ar2413.c ============================================================================== --- projects/ath_hal/ar5212/ar2413.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5212/ar2413.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_2413 - #include "ah.h" #include "ah_internal.h" @@ -721,7 +719,7 @@ ar2413RfDetach(struct ath_hal *ah) * Allocate memory for analog bank scratch buffers * Scratch Buffer will be reinitialized every reset so no need to zero now */ -HAL_BOOL +static HAL_BOOL ar2413RfAttach(struct ath_hal *ah, HAL_STATUS *status) { struct ath_hal_5212 *ahp = AH5212(ah); @@ -752,4 +750,10 @@ ar2413RfAttach(struct ath_hal *ah, HAL_S return AH_TRUE; } -#endif /* AH_SUPPORT_2413 */ + +static HAL_BOOL +ar2413Probe(struct ath_hal *ah) +{ + return IS_2413(ah); +} +AH_RF(ar2413, ar2413Probe, ar2413RfAttach); Modified: projects/ath_hal/ar5212/ar2425.c ============================================================================== --- projects/ath_hal/ar5212/ar2425.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5212/ar2425.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_2425 - #include "ah.h" #include "ah_internal.h" @@ -30,9 +28,7 @@ #include "ah_eeprom_v3.h" #define AH_5212_2425 -#ifdef AH_SUPPORT_2417 #define AH_5212_2417 -#endif #include "ar5212/ar5212.ini" #define N(a) (sizeof(a)/sizeof(a[0])) @@ -211,13 +207,11 @@ ar2425SetRfRegs(struct ath_hal *ah, HAL_ HAL_INI_WRITE_BANK(ah, ar5212Bank1_2425, priv->Bank1Data, regWrites); HAL_INI_WRITE_BANK(ah, ar5212Bank2_2425, priv->Bank2Data, regWrites); HAL_INI_WRITE_BANK(ah, ar5212Bank3_2425, priv->Bank3Data, regWrites); -#ifdef AH_SUPPORT_2417 if (IS_2417(ah)) { HALASSERT(N(ar5212Bank6_2425) == N(ar5212Bank6_2417)); HAL_INI_WRITE_BANK(ah, ar5212Bank6_2417, priv->Bank6Data, regWrites); } else -#endif /* AH_SUPPORT_2417 */ HAL_INI_WRITE_BANK(ah, ar5212Bank6_2425, priv->Bank6Data, regWrites); HAL_INI_WRITE_BANK(ah, ar5212Bank7_2425, priv->Bank7Data, regWrites); @@ -688,7 +682,7 @@ ar2425RfDetach(struct ath_hal *ah) * Allocate memory for analog bank scratch buffers * Scratch Buffer will be reinitialized every reset so no need to zero now */ -HAL_BOOL +static HAL_BOOL ar2425RfAttach(struct ath_hal *ah, HAL_STATUS *status) { struct ath_hal_5212 *ahp = AH5212(ah); @@ -719,4 +713,10 @@ ar2425RfAttach(struct ath_hal *ah, HAL_S return AH_TRUE; } -#endif /* AH_SUPPORT_2425 */ + +static HAL_BOOL +ar2425Probe(struct ath_hal *ah) +{ + return IS_2425(ah) || IS_2417(ah); +} +AH_RF(ar2425, ar2425Probe, ar2425RfAttach); Modified: projects/ath_hal/ar5212/ar5111.c ============================================================================== --- projects/ath_hal/ar5212/ar5111.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5212/ar5111.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_5111 - #include "ah.h" #include "ah_internal.h" @@ -673,7 +671,7 @@ ar5111RfDetach(struct ath_hal *ah) * Allocate memory for analog bank scratch buffers * Scratch Buffer will be reinitialized every reset so no need to zero now */ -HAL_BOOL +static HAL_BOOL ar5111RfAttach(struct ath_hal *ah, HAL_STATUS *status) { struct ath_hal_5212 *ahp = AH5212(ah); @@ -704,4 +702,10 @@ ar5111RfAttach(struct ath_hal *ah, HAL_S return AH_TRUE; } -#endif /* AH_SUPPORT_5111 */ + +static HAL_BOOL +ar5111Probe(struct ath_hal *ah) +{ + return IS_RAD5111(ah); +} +AH_RF(ar5111, ar5111Probe, ar5111RfAttach); Modified: projects/ath_hal/ar5212/ar5112.c ============================================================================== --- projects/ath_hal/ar5212/ar5112.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5212/ar5112.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_5112 - #include "ah.h" #include "ah_internal.h" @@ -843,7 +841,7 @@ ar5112RfDetach(struct ath_hal *ah) * Allocate memory for analog bank scratch buffers * Scratch Buffer will be reinitialized every reset so no need to zero now */ -HAL_BOOL +static HAL_BOOL ar5112RfAttach(struct ath_hal *ah, HAL_STATUS *status) { struct ath_hal_5212 *ahp = AH5212(ah); @@ -874,4 +872,10 @@ ar5112RfAttach(struct ath_hal *ah, HAL_S return AH_TRUE; } -#endif /* AH_SUPPORT_5112 */ + +static HAL_BOOL +ar5112Probe(struct ath_hal *ah) +{ + return IS_RAD5112(ah); +} +AH_RF(ar5112, ar5112Probe, ar5112RfAttach); Modified: projects/ath_hal/ar5212/ar5212.h ============================================================================== --- projects/ath_hal/ar5212/ar5212.h Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5212/ar5212.h Fri Nov 28 19:58:09 2008 (r185406) @@ -408,21 +408,11 @@ struct ath_hal_5212 { } \ } while (0) -extern HAL_BOOL ar5111RfAttach(struct ath_hal *, HAL_STATUS *); -extern HAL_BOOL ar5112RfAttach(struct ath_hal *, HAL_STATUS *); -extern HAL_BOOL ar2413RfAttach(struct ath_hal *, HAL_STATUS *); -extern HAL_BOOL ar5413RfAttach(struct ath_hal *, HAL_STATUS *); -extern HAL_BOOL ar2316RfAttach(struct ath_hal *, HAL_STATUS *); -extern HAL_BOOL ar2317RfAttach(struct ath_hal *, HAL_STATUS *); -extern HAL_BOOL ar2425RfAttach(struct ath_hal *, HAL_STATUS *); - struct ath_hal; extern uint32_t ar5212GetRadioRev(struct ath_hal *ah); extern void ar5212InitState(struct ath_hal_5212 *, uint16_t devid, HAL_SOFTC, HAL_BUS_TAG st, HAL_BUS_HANDLE sh, HAL_STATUS *status); -extern struct ath_hal * ar5212Attach(uint16_t devid, HAL_SOFTC sc, - HAL_BUS_TAG st, HAL_BUS_HANDLE sh, HAL_STATUS *status); extern void ar5212Detach(struct ath_hal *ah); extern HAL_BOOL ar5212ChipTest(struct ath_hal *ah); extern HAL_BOOL ar5212GetChannelEdges(struct ath_hal *ah, Modified: projects/ath_hal/ar5212/ar5212_ani.c ============================================================================== --- projects/ath_hal/ar5212/ar5212_ani.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5212/ar5212_ani.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,8 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_AR5212 - #include "ah.h" #include "ah_internal.h" #include "ah_desc.h" @@ -1016,4 +1014,3 @@ ar5212AniPoll(struct ath_hal *ah, const } } } -#endif /* AH_SUPPORT_AR5212 */ Modified: projects/ath_hal/ar5212/ar5212_attach.c ============================================================================== --- projects/ath_hal/ar5212/ar5212_attach.c Fri Nov 28 19:35:48 2008 (r185405) +++ projects/ath_hal/ar5212/ar5212_attach.c Fri Nov 28 19:58:09 2008 (r185406) @@ -18,16 +18,6 @@ */ #include "opt_ah.h" -#ifdef AH_SUPPORT_AR5212 - -#if !defined(AH_SUPPORT_5112) && \ - !defined(AH_SUPPORT_5111) && \ - !defined(AH_SUPPORT_2413) && \ - !defined(AH_SUPPORT_5413) && \ - !defined(AH_SUPPORT_AR5312) -#error "No 5212 RF support defined" -#endif - #include "ah.h" #include "ah_internal.h" #include "ah_devid.h" @@ -35,9 +25,6 @@ #include "ar5212/ar5212.h" #include "ar5212/ar5212reg.h" #include "ar5212/ar5212phy.h" -#ifdef AH_SUPPORT_AR5311 -#include "ar5212/ar5311reg.h" -#endif #define AH_5212_COMMON #include "ar5212/ar5212.ini" @@ -334,7 +321,7 @@ ar5212IsMacSupported(uint8_t macVersion, /* * Attach for an AR5212 part. */ -struct ath_hal * +static struct ath_hal * ar5212Attach(uint16_t devid, HAL_SOFTC sc, HAL_BUS_TAG st, HAL_BUS_HANDLE sh, HAL_STATUS *status) { @@ -342,10 +329,10 @@ ar5212Attach(uint16_t devid, HAL_SOFTC s (IS_PCIE(ah) ? AR_EEPROM_PROTECT_PCIE : AR_EEPROM_PROTECT) struct ath_hal_5212 *ahp; struct ath_hal *ah; + struct ath_hal_rf *rf; uint32_t val; uint16_t eeval; HAL_STATUS ecode; - HAL_BOOL rfStatus; HALDEBUG(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n", __func__, sc, (void*) st, (void*) sh); @@ -417,6 +404,11 @@ ar5212Attach(uint16_t devid, HAL_SOFTC s /* Read Radio Chip Rev Extract */ AH_PRIVATE(ah)->ah_analog5GhzRev = ar5212GetRadioRev(ah); + + rf = ath_hal_rfprobe(ah, &ecode); + if (rf == AH_NULL) + goto bad; + /* NB: silently accept anything in release code per Atheros */ switch (AH_PRIVATE(ah)->ah_analog5GhzRev & AR_RADIO_SREV_MAJOR) { case AR_RAD5111_SREV_MAJOR: @@ -554,39 +546,7 @@ ar5212Attach(uint16_t devid, HAL_SOFTC s goto bad; } - rfStatus = AH_FALSE; - if (IS_5413(ah)) { -#ifdef AH_SUPPORT_5413 - rfStatus = ar5413RfAttach(ah, &ecode); -#else - ecode = HAL_ENOTSUPP; *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811281958.mASJwAFa028208>