Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d535a42a authored by Sujith's avatar Sujith Committed by John W. Linville
Browse files

ath9k: Store HW version information in a separate structure



This patch moves all the HW version/revision specific
information into a separate structure.

Signed-off-by: default avatarSujith <Sujith.Manoharan@atheros.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 17d7904d
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -132,10 +132,10 @@ static int ath_ahb_probe(struct platform_device *pdev)
	       "%s: Atheros AR%s MAC/BB Rev:%x, "
	       "AR%s RF Rev:%x, mem=0x%lx, irq=%d\n",
	       wiphy_name(hw->wiphy),
	       ath_mac_bb_name(ah->ah_macVersion),
	       ah->ah_macRev,
	       ath_rf_name((ah->ah_analog5GhzRev & AR_RADIO_SREV_MAJOR)),
	       ah->ah_phyRev,
	       ath_mac_bb_name(ah->hw_version.macVersion),
	       ah->hw_version.macRev,
	       ath_rf_name((ah->hw_version.analog5GhzRev & AR_RADIO_SREV_MAJOR)),
	       ah->hw_version.phyRev,
	       (unsigned long)mem, irq);

	return 0;
+2 −2
Original line number Diff line number Diff line
@@ -1989,7 +1989,7 @@ static void ath9k_hw_set_def_addac(struct ath_hal *ah,
	struct ar5416_eeprom_def *eep = &ahp->ah_eeprom.def;
	u8 biaslevel;

	if (ah->ah_macVersion != AR_SREV_VERSION_9160)
	if (ah->hw_version.macVersion != AR_SREV_VERSION_9160)
		return;

	if (ar5416_get_eep_rev(ahp) < AR5416_EEP_MINOR_VER_7)
@@ -2043,7 +2043,7 @@ static void ath9k_hw_set_4k_addac(struct ath_hal *ah,
	struct ar5416_eeprom_4k *eep = &ahp->ah_eeprom.map4k;
	u8 biaslevel;

	if (ah->ah_macVersion != AR_SREV_VERSION_9160)
	if (ah->hw_version.macVersion != AR_SREV_VERSION_9160)
		return;

	if (ar5416_get_eep_rev(ahp) < AR5416_EEP_MINOR_VER_7)
+32 −30
Original line number Diff line number Diff line
@@ -229,16 +229,17 @@ static void ath9k_hw_read_revisions(struct ath_hal *ah)

	if (val == 0xFF) {
		val = REG_READ(ah, AR_SREV);
		ah->ah_macVersion = (val & AR_SREV_VERSION2) >> AR_SREV_TYPE2_S;
		ah->ah_macRev = MS(val, AR_SREV_REVISION2);
		ah->hw_version.macVersion =
			(val & AR_SREV_VERSION2) >> AR_SREV_TYPE2_S;
		ah->hw_version.macRev = MS(val, AR_SREV_REVISION2);
		ah->ah_isPciExpress = (val & AR_SREV_TYPE2_HOST_MODE) ? 0 : 1;
	} else {
		if (!AR_SREV_9100(ah))
			ah->ah_macVersion = MS(val, AR_SREV_VERSION);
			ah->hw_version.macVersion = MS(val, AR_SREV_VERSION);

		ah->ah_macRev = val & AR_SREV_REVISION;
		ah->hw_version.macRev = val & AR_SREV_REVISION;

		if (ah->ah_macVersion == AR_SREV_VERSION_5416_PCIE)
		if (ah->hw_version.macVersion == AR_SREV_VERSION_5416_PCIE)
			ah->ah_isPciExpress = true;
	}
}
@@ -407,14 +408,14 @@ static struct ath_hal_5416 *ath9k_hw_newstate(u16 devid,
	ah = &ahp->ah;
	ah->ah_sc = sc;
	ah->ah_sh = mem;
	ah->ah_magic = AR5416_MAGIC;
	ah->hw_version.magic = AR5416_MAGIC;
	ah->ah_countryCode = CTRY_DEFAULT;
	ah->ah_devid = devid;
	ah->ah_subvendorid = 0;
	ah->hw_version.devid = devid;
	ah->hw_version.subvendorid = 0;

	ah->ah_flags = 0;
	if ((devid == AR5416_AR9100_DEVID))
		ah->ah_macVersion = AR_SREV_VERSION_9100;
		ah->hw_version.macVersion = AR_SREV_VERSION_9100;
	if (!AR_SREV_9100(ah))
		ah->ah_flags = AH_USE_EEPROM;

@@ -473,11 +474,11 @@ static int ath9k_hw_rf_claim(struct ath_hal *ah)
		DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
			"5G Radio Chip Rev 0x%02X is not "
			"supported by this driver\n",
			ah->ah_analog5GhzRev);
			ah->hw_version.analog5GhzRev);
		return -EOPNOTSUPP;
	}

	ah->ah_analog5GhzRev = val;
	ah->hw_version.analog5GhzRev = val;

	return 0;
}
@@ -615,7 +616,7 @@ static struct ath_hal *ath9k_hw_do_attach(u16 devid, struct ath_softc *sc,
	}

	if (ah->ah_config.serialize_regmode == SER_REG_MODE_AUTO) {
		if (ah->ah_macVersion == AR_SREV_VERSION_5416_PCI) {
		if (ah->hw_version.macVersion == AR_SREV_VERSION_5416_PCI) {
			ah->ah_config.serialize_regmode =
				SER_REG_MODE_ON;
		} else {
@@ -628,13 +629,14 @@ static struct ath_hal *ath9k_hw_do_attach(u16 devid, struct ath_softc *sc,
		"serialize_regmode is %d\n",
		ah->ah_config.serialize_regmode);

	if ((ah->ah_macVersion != AR_SREV_VERSION_5416_PCI) &&
	    (ah->ah_macVersion != AR_SREV_VERSION_5416_PCIE) &&
	    (ah->ah_macVersion != AR_SREV_VERSION_9160) &&
	if ((ah->hw_version.macVersion != AR_SREV_VERSION_5416_PCI) &&
	    (ah->hw_version.macVersion != AR_SREV_VERSION_5416_PCIE) &&
	    (ah->hw_version.macVersion != AR_SREV_VERSION_9160) &&
	    (!AR_SREV_9100(ah)) && (!AR_SREV_9280(ah)) && (!AR_SREV_9285(ah))) {
		DPRINTF(ah->ah_sc, ATH_DBG_RESET,
			"Mac Chip Rev 0x%02x.%x is not supported by "
			"this driver\n", ah->ah_macVersion, ah->ah_macRev);
			"this driver\n", ah->hw_version.macVersion,
			ah->hw_version.macRev);
		ecode = -EOPNOTSUPP;
		goto bad;
	}
@@ -644,7 +646,7 @@ static struct ath_hal *ath9k_hw_do_attach(u16 devid, struct ath_softc *sc,
		ahp->ah_suppCals = IQ_MISMATCH_CAL;
		ah->ah_isPciExpress = false;
	}
	ah->ah_phyRev = REG_READ(ah, AR_PHY_CHIP_ID);
	ah->hw_version.phyRev = REG_READ(ah, AR_PHY_CHIP_ID);

	if (AR_SREV_9160_10_OR_LATER(ah)) {
		if (AR_SREV_9280_10_OR_LATER(ah)) {
@@ -680,7 +682,7 @@ static struct ath_hal *ath9k_hw_do_attach(u16 devid, struct ath_softc *sc,

	DPRINTF(ah->ah_sc, ATH_DBG_RESET,
		"This Mac Chip Rev 0x%02x.%x is \n",
		ah->ah_macVersion, ah->ah_macRev);
		ah->hw_version.macVersion, ah->hw_version.macRev);

	if (AR_SREV_9285_12_OR_LATER(ah)) {
		INIT_INI_ARRAY(&ahp->ah_iniModes, ar9285Modes_9285_1_2,
@@ -830,7 +832,7 @@ static struct ath_hal *ath9k_hw_do_attach(u16 devid, struct ath_softc *sc,
	if (AR_SREV_9280_20(ah))
		ath9k_hw_init_txgain_ini(ah);

	if (ah->ah_devid == AR9280_DEVID_PCI) {
	if (ah->hw_version.devid == AR9280_DEVID_PCI) {
		for (i = 0; i < ahp->ah_iniModes.ia_rows; i++) {
			u32 reg = INI_RA(&ahp->ah_iniModes, i, 0);

@@ -990,7 +992,7 @@ static void ath9k_hw_init_chain_masks(struct ath_hal *ah)
		REG_SET_BIT(ah, AR_PHY_ANALOG_SWAP,
			    AR_PHY_SWAP_ALT_CHAIN);
	case 0x3:
		if (((ah)->ah_macVersion <= AR_SREV_VERSION_9160)) {
		if (((ah)->hw_version.macVersion <= AR_SREV_VERSION_9160)) {
			REG_WRITE(ah, AR_PHY_RX_CHAINMASK, 0x7);
			REG_WRITE(ah, AR_PHY_CAL_CHAINMASK, 0x7);
			break;
@@ -1181,7 +1183,7 @@ static u32 ath9k_hw_def_ini_fixup(struct ath_hal *ah,
{
	struct base_eep_header *pBase = &(pEepData->baseEepHeader);

	switch (ah->ah_devid) {
	switch (ah->hw_version.devid) {
	case AR9280_DEVID_PCI:
		if (reg == 0x7894) {
			DPRINTF(ah->ah_sc, ATH_DBG_ANY,
@@ -2438,7 +2440,7 @@ bool ath9k_hw_set_keycache_entry(struct ath_hal *ah, u16 entry,
		if (!(pCap->hw_caps & ATH9K_HW_CAP_CIPHER_AESCCM)) {
			DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE,
				"AES-CCM not supported by mac rev 0x%x\n",
				ah->ah_macRev);
				ah->hw_version.macRev);
			return false;
		}
		keyType = AR_KEYTABLE_TYPE_CCM;
@@ -2687,7 +2689,7 @@ void ath9k_hw_configpcipowersave(struct ath_hal *ah, int restore)
		}
		udelay(1000);
	} else if (AR_SREV_9280(ah) &&
		   (ah->ah_macRev == AR_SREV_REVISION_9280_10)) {
		   (ah->hw_version.macRev == AR_SREV_REVISION_9280_10)) {
		REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fd00);
		REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924);

@@ -3142,7 +3144,7 @@ bool ath9k_hw_fill_cap_info(struct ath_hal *ah)
	capField = ath9k_hw_get_eeprom(ah, EEP_OP_CAP);

	if (ah->ah_opmode != NL80211_IFTYPE_AP &&
	    ah->ah_subvendorid == AR_SUBVENDOR_ID_NEW_A) {
	    ah->hw_version.subvendorid == AR_SUBVENDOR_ID_NEW_A) {
		if (ah->ah_currentRD == 0x64 || ah->ah_currentRD == 0x65)
			ah->ah_currentRD += 5;
		else if (ah->ah_currentRD == 0x41)
@@ -3195,7 +3197,7 @@ bool ath9k_hw_fill_cap_info(struct ath_hal *ah)
			(ath9k_hw_gpio_get(ah, 0)) ? 0x5 : 0x7;
	}

	if (!(AR_SREV_9280(ah) && (ah->ah_macRev == 0)))
	if (!(AR_SREV_9280(ah) && (ah->hw_version.macRev == 0)))
		ahp->ah_miscMode |= AR_PCU_MIC_NEW_LOC_ENA;

	pCap->low_2ghz_chan = 2312;
@@ -3276,11 +3278,11 @@ bool ath9k_hw_fill_cap_info(struct ath_hal *ah)
	}
#endif

	if ((ah->ah_macVersion == AR_SREV_VERSION_5416_PCI) ||
	    (ah->ah_macVersion == AR_SREV_VERSION_5416_PCIE) ||
	    (ah->ah_macVersion == AR_SREV_VERSION_9160) ||
	    (ah->ah_macVersion == AR_SREV_VERSION_9100) ||
	    (ah->ah_macVersion == AR_SREV_VERSION_9280))
	if ((ah->hw_version.macVersion == AR_SREV_VERSION_5416_PCI) ||
	    (ah->hw_version.macVersion == AR_SREV_VERSION_5416_PCIE) ||
	    (ah->hw_version.macVersion == AR_SREV_VERSION_9160) ||
	    (ah->hw_version.macVersion == AR_SREV_VERSION_9100) ||
	    (ah->hw_version.macVersion == AR_SREV_VERSION_9280))
		pCap->hw_caps &= ~ATH9K_HW_CAP_AUTOSLEEP;
	else
		pCap->hw_caps |= ATH9K_HW_CAP_AUTOSLEEP;
+12 −9
Original line number Diff line number Diff line
@@ -406,16 +406,19 @@ enum {
	ATH9K_RESET_COLD,
};

struct ath_hal {
	u32 ah_magic;
	u16 ah_devid;
	u16 ah_subvendorid;
	u32 ah_macVersion;
	u16 ah_macRev;
	u16 ah_phyRev;
	u16 ah_analog5GhzRev;
	u16 ah_analog2GhzRev;
struct ath9k_hw_version {
	u32 magic;
	u16 devid;
	u16 subvendorid;
	u32 macVersion;
	u16 macRev;
	u16 phyRev;
	u16 analog5GhzRev;
	u16 analog2GhzRev;
};

struct ath_hal {
	struct ath9k_hw_version hw_version;
	void __iomem *ah_sh;
	struct ath_softc *ah_sc;

+4 −4
Original line number Diff line number Diff line
@@ -190,10 +190,10 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
	       "%s: Atheros AR%s MAC/BB Rev:%x "
	       "AR%s RF Rev:%x: mem=0x%lx, irq=%d\n",
	       wiphy_name(hw->wiphy),
	       ath_mac_bb_name(ah->ah_macVersion),
	       ah->ah_macRev,
	       ath_rf_name((ah->ah_analog5GhzRev & AR_RADIO_SREV_MAJOR)),
	       ah->ah_phyRev,
	       ath_mac_bb_name(ah->hw_version.macVersion),
	       ah->hw_version.macRev,
	       ath_rf_name((ah->hw_version.analog5GhzRev & AR_RADIO_SREV_MAJOR)),
	       ah->hw_version.phyRev,
	       (unsigned long)mem, pdev->irq);

	return 0;
Loading