Commit e7aecd32 authored by Felix Fietkau's avatar Felix Fietkau Committed by John W. Linville

ath5k: Add a function to read chipset's MAC revision

Add bus dependent revision read function which is used to
determine chipset's MAC before hardware is initialized.
Signed-off-by: default avatarFelix Fietkau <nbd@openwrt.org>
Signed-off-by: default avatarWojciech Dubowik <Wojciech.Dubowik@neratec.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 8efa5d7d
...@@ -1046,6 +1046,7 @@ struct ath5k_hw { ...@@ -1046,6 +1046,7 @@ struct ath5k_hw {
u32 ah_phy; u32 ah_phy;
u32 ah_mac_srev; u32 ah_mac_srev;
u16 ah_mac_version; u16 ah_mac_version;
u16 ah_mac_revision;
u16 ah_phy_revision; u16 ah_phy_revision;
u16 ah_radio_5ghz_revision; u16 ah_radio_5ghz_revision;
u16 ah_radio_2ghz_revision; u16 ah_radio_2ghz_revision;
...@@ -1156,8 +1157,9 @@ void ath5k_hw_deinit(struct ath5k_hw *ah); ...@@ -1156,8 +1157,9 @@ void ath5k_hw_deinit(struct ath5k_hw *ah);
int ath5k_sysfs_register(struct ath5k_softc *sc); int ath5k_sysfs_register(struct ath5k_softc *sc);
void ath5k_sysfs_unregister(struct ath5k_softc *sc); void ath5k_sysfs_unregister(struct ath5k_softc *sc);
/*Chip id helper function */ /*Chip id helper functions */
const char *ath5k_chip_name(enum ath5k_srev_type type, u_int16_t val); const char *ath5k_chip_name(enum ath5k_srev_type type, u_int16_t val);
int ath5k_hw_read_srev(struct ath5k_hw *ah);
/* LED functions */ /* LED functions */
int ath5k_init_leds(struct ath5k_softc *sc); int ath5k_init_leds(struct ath5k_softc *sc);
......
...@@ -128,7 +128,8 @@ int ath5k_hw_init(struct ath5k_softc *sc) ...@@ -128,7 +128,8 @@ int ath5k_hw_init(struct ath5k_softc *sc)
/* /*
* Find the mac version * Find the mac version
*/ */
srev = ath5k_hw_reg_read(ah, AR5K_SREV); ath5k_hw_read_srev(ah);
srev = ah->ah_mac_srev;
if (srev < AR5K_SREV_AR5311) if (srev < AR5K_SREV_AR5311)
ah->ah_version = AR5K_AR5210; ah->ah_version = AR5K_AR5210;
else if (srev < AR5K_SREV_AR5212) else if (srev < AR5K_SREV_AR5212)
...@@ -136,6 +137,10 @@ int ath5k_hw_init(struct ath5k_softc *sc) ...@@ -136,6 +137,10 @@ int ath5k_hw_init(struct ath5k_softc *sc)
else else
ah->ah_version = AR5K_AR5212; ah->ah_version = AR5K_AR5212;
/* Get the MAC revision */
ah->ah_mac_version = AR5K_REG_MS(srev, AR5K_SREV_VER);
ah->ah_mac_revision = AR5K_REG_MS(srev, AR5K_SREV_REV);
/* Fill the ath5k_hw struct with the needed functions */ /* Fill the ath5k_hw struct with the needed functions */
ret = ath5k_hw_init_desc_functions(ah); ret = ath5k_hw_init_desc_functions(ah);
if (ret) if (ret)
...@@ -146,9 +151,7 @@ int ath5k_hw_init(struct ath5k_softc *sc) ...@@ -146,9 +151,7 @@ int ath5k_hw_init(struct ath5k_softc *sc)
if (ret) if (ret)
goto err; goto err;
/* Get MAC, PHY and RADIO revisions */ /* Get PHY and RADIO revisions */
ah->ah_mac_srev = srev;
ah->ah_mac_version = AR5K_REG_MS(srev, AR5K_SREV_VER);
ah->ah_phy_revision = ath5k_hw_reg_read(ah, AR5K_PHY_CHIP_ID) & ah->ah_phy_revision = ath5k_hw_reg_read(ah, AR5K_PHY_CHIP_ID) &
0xffffffff; 0xffffffff;
ah->ah_radio_5ghz_revision = ath5k_hw_radio_revision(ah, ah->ah_radio_5ghz_revision = ath5k_hw_radio_revision(ah,
......
...@@ -100,6 +100,12 @@ bool ath5k_pci_eeprom_read(struct ath_common *common, u32 offset, u16 *data) ...@@ -100,6 +100,12 @@ bool ath5k_pci_eeprom_read(struct ath_common *common, u32 offset, u16 *data)
return -ETIMEDOUT; return -ETIMEDOUT;
} }
int ath5k_hw_read_srev(struct ath5k_hw *ah)
{
ah->ah_mac_srev = ath5k_hw_reg_read(ah, AR5K_SREV);
return 0;
}
/* Common ath_bus_opts structure */ /* Common ath_bus_opts structure */
static const struct ath_bus_ops ath_pci_bus_ops = { static const struct ath_bus_ops ath_pci_bus_ops = {
.ath_bus_type = ATH_PCI, .ath_bus_type = ATH_PCI,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment