summaryrefslogtreecommitdiffstats
path: root/ah.c
diff options
context:
space:
mode:
Diffstat (limited to 'ah.c')
-rw-r--r--ah.c222
1 files changed, 56 insertions, 166 deletions
diff --git a/ah.c b/ah.c
index 409259d..065c043 100644
--- a/ah.c
+++ b/ah.c
@@ -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;
}
/*
OpenPOWER on IntegriCloud