Commit 3a702e49 authored by Bob Copeland's avatar Bob Copeland Committed by John W. Linville

atheros: introduce ath module containing common ath5k/ath9k/ar9170 code

This change creates a new module, ath.ko, which includes code that can
be shared between ath5k, ath9k and ar9170. For now, extract most of the ath9k
regulatory code so it can also be used in ath5k.
Signed-off-by: default avatarBob Copeland <me@bobcopeland.com>
Signed-off-by: default avatarLuis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent c02cf373
...@@ -483,6 +483,7 @@ config MWL8K ...@@ -483,6 +483,7 @@ config MWL8K
will be called mwl8k. If unsure, say N. will be called mwl8k. If unsure, say N.
source "drivers/net/wireless/p54/Kconfig" source "drivers/net/wireless/p54/Kconfig"
source "drivers/net/wireless/ath/Kconfig"
source "drivers/net/wireless/ath5k/Kconfig" source "drivers/net/wireless/ath5k/Kconfig"
source "drivers/net/wireless/ath9k/Kconfig" source "drivers/net/wireless/ath9k/Kconfig"
source "drivers/net/wireless/ar9170/Kconfig" source "drivers/net/wireless/ar9170/Kconfig"
......
...@@ -55,6 +55,7 @@ obj-$(CONFIG_RT2X00) += rt2x00/ ...@@ -55,6 +55,7 @@ obj-$(CONFIG_RT2X00) += rt2x00/
obj-$(CONFIG_P54_COMMON) += p54/ obj-$(CONFIG_P54_COMMON) += p54/
obj-$(CONFIG_ATH_COMMON) += ath/
obj-$(CONFIG_ATH5K) += ath5k/ obj-$(CONFIG_ATH5K) += ath5k/
obj-$(CONFIG_ATH9K) += ath9k/ obj-$(CONFIG_ATH9K) += ath9k/
obj-$(CONFIG_AR9170_USB) += ar9170/ obj-$(CONFIG_AR9170_USB) += ar9170/
......
config ATH_COMMON
tristate "Atheros Wireless Cards Shared Support"
depends on ATH5K || ATH9K
obj-$(CONFIG_ATH_COMMON) += ath.o
ath-objs := regd.o
...@@ -19,6 +19,24 @@ ...@@ -19,6 +19,24 @@
#include <linux/nl80211.h> #include <linux/nl80211.h>
#include <net/cfg80211.h>
#include <net/wireless.h>
#define NO_CTL 0xff
#define SD_NO_CTL 0xE0
#define NO_CTL 0xff
#define CTL_MODE_M 7
#define CTL_11A 0
#define CTL_11B 1
#define CTL_11G 2
#define CTL_2GHT20 5
#define CTL_5GHT20 6
#define CTL_2GHT40 7
#define CTL_5GHT40 8
#define CTRY_DEBUG 0x1ff
#define CTRY_DEFAULT 0
#define COUNTRY_ERD_FLAG 0x8000 #define COUNTRY_ERD_FLAG 0x8000
#define WORLDWIDE_ROAMING_FLAG 0x4000 #define WORLDWIDE_ROAMING_FLAG 0x4000
...@@ -42,7 +60,7 @@ struct country_code_to_enum_rd { ...@@ -42,7 +60,7 @@ struct country_code_to_enum_rd {
const char *isoName; const char *isoName;
}; };
struct ath9k_regulatory { struct ath_regulatory {
char alpha2[2]; char alpha2[2];
u16 country_code; u16 country_code;
u16 max_power_level; u16 max_power_level;
...@@ -235,18 +253,20 @@ enum CountryCode { ...@@ -235,18 +253,20 @@ enum CountryCode {
CTRY_BELGIUM2 = 5002 CTRY_BELGIUM2 = 5002
}; };
bool ath9k_is_world_regd(struct ath9k_regulatory *reg); bool ath_is_world_regd(struct ath_regulatory *reg);
const struct ieee80211_regdomain *ath9k_world_regdomain( const
struct ath9k_regulatory *reg); struct ieee80211_regdomain *ath_world_regdomain(struct ath_regulatory *reg);
const struct ieee80211_regdomain *ath9k_default_world_regdomain(void); const struct ieee80211_regdomain *ath_default_world_regdomain(void);
void ath9k_reg_apply_world_flags(struct wiphy *wiphy, void ath_reg_apply_world_flags(struct wiphy *wiphy,
enum nl80211_reg_initiator, enum nl80211_reg_initiator,
struct ath9k_regulatory *reg); struct ath_regulatory *reg);
void ath9k_reg_apply_radar_flags(struct wiphy *wiphy); void ath_reg_apply_radar_flags(struct wiphy *wiphy);
int ath9k_regd_init(struct ath9k_regulatory *reg); int ath_regd_init(struct ath_regulatory *reg);
bool ath9k_regd_is_eeprom_valid(struct ath9k_regulatory *reg); bool ath_regd_is_eeprom_valid(struct ath_regulatory *reg);
u32 ath9k_regd_get_ctl(struct ath9k_regulatory *reg, u32 ath_regd_get_band_ctl(struct ath_regulatory *reg,
struct ath9k_channel *chan); enum ieee80211_band band);
int ath9k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request); int ath_reg_notifier_apply(struct wiphy *wiphy,
struct regulatory_request *request,
struct ath_regulatory *reg);
#endif #endif
...@@ -2,6 +2,7 @@ config ATH9K ...@@ -2,6 +2,7 @@ config ATH9K
tristate "Atheros 802.11n wireless cards support" tristate "Atheros 802.11n wireless cards support"
depends on PCI && MAC80211 && WLAN_80211 depends on PCI && MAC80211 && WLAN_80211
depends on RFKILL || RFKILL=n depends on RFKILL || RFKILL=n
select ATH_COMMON
select MAC80211_LEDS select MAC80211_LEDS
select LEDS_CLASS select LEDS_CLASS
select NEW_LEDS select NEW_LEDS
......
...@@ -4,7 +4,6 @@ ath9k-y += hw.o \ ...@@ -4,7 +4,6 @@ ath9k-y += hw.o \
calib.o \ calib.o \
ani.o \ ani.o \
phy.o \ phy.o \
regd.o \
beacon.o \ beacon.o \
main.o \ main.o \
recv.o \ recv.o \
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#ifndef EEPROM_H #ifndef EEPROM_H
#define EEPROM_H #define EEPROM_H
#include <net/wireless.h>
#define AH_USE_EEPROM 0x1 #define AH_USE_EEPROM 0x1
#ifdef __BIG_ENDIAN #ifdef __BIG_ENDIAN
......
...@@ -1220,6 +1220,21 @@ static void ath9k_olc_init(struct ath_hw *ah) ...@@ -1220,6 +1220,21 @@ static void ath9k_olc_init(struct ath_hw *ah)
ah->PDADCdelta = 0; ah->PDADCdelta = 0;
} }
static u32 ath9k_regd_get_ctl(struct ath_regulatory *reg,
struct ath9k_channel *chan)
{
u32 ctl = ath_regd_get_band_ctl(reg, chan->chan->band);
if (IS_CHAN_B(chan))
ctl |= CTL_11B;
else if (IS_CHAN_G(chan))
ctl |= CTL_11G;
else
ctl |= CTL_11A;
return ctl;
}
static int ath9k_hw_process_ini(struct ath_hw *ah, static int ath9k_hw_process_ini(struct ath_hw *ah,
struct ath9k_channel *chan, struct ath9k_channel *chan,
enum ath9k_ht_macmode macmode) enum ath9k_ht_macmode macmode)
......
...@@ -25,10 +25,11 @@ ...@@ -25,10 +25,11 @@
#include "ani.h" #include "ani.h"
#include "eeprom.h" #include "eeprom.h"
#include "calib.h" #include "calib.h"
#include "regd.h"
#include "reg.h" #include "reg.h"
#include "phy.h" #include "phy.h"
#include "../ath/regd.h"
#define ATHEROS_VENDOR_ID 0x168c #define ATHEROS_VENDOR_ID 0x168c
#define AR5416_DEVID_PCI 0x0023 #define AR5416_DEVID_PCI 0x0023
#define AR5416_DEVID_PCIE 0x0024 #define AR5416_DEVID_PCIE 0x0024
...@@ -404,7 +405,7 @@ struct ath_hw { ...@@ -404,7 +405,7 @@ struct ath_hw {
struct ath9k_hw_version hw_version; struct ath9k_hw_version hw_version;
struct ath9k_ops_config config; struct ath9k_ops_config config;
struct ath9k_hw_capabilities caps; struct ath9k_hw_capabilities caps;
struct ath9k_regulatory regulatory; struct ath_regulatory regulatory;
struct ath9k_channel channels[38]; struct ath9k_channel channels[38];
struct ath9k_channel *curchan; struct ath9k_channel *curchan;
......
...@@ -1406,7 +1406,7 @@ static int ath_init(u16 devid, struct ath_softc *sc) ...@@ -1406,7 +1406,7 @@ static int ath_init(u16 devid, struct ath_softc *sc)
for (i = 0; i < sc->keymax; i++) for (i = 0; i < sc->keymax; i++)
ath9k_hw_keyreset(ah, (u16) i); ath9k_hw_keyreset(ah, (u16) i);
if (ath9k_regd_init(&sc->sc_ah->regulatory)) if (ath_regd_init(&sc->sc_ah->regulatory))
goto bad; goto bad;
/* default to MONITOR mode */ /* default to MONITOR mode */
...@@ -1570,6 +1570,17 @@ static int ath_init(u16 devid, struct ath_softc *sc) ...@@ -1570,6 +1570,17 @@ static int ath_init(u16 devid, struct ath_softc *sc)
return error; return error;
} }
static int ath9k_reg_notifier(struct wiphy *wiphy,
struct regulatory_request *request)
{
struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
struct ath_wiphy *aphy = hw->priv;
struct ath_softc *sc = aphy->sc;
struct ath_regulatory *reg = &sc->sc_ah->regulatory;
return ath_reg_notifier_apply(wiphy, request, reg);
}
void ath_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) void ath_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
{ {
hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | hw->flags = IEEE80211_HW_RX_INCLUDES_FCS |
...@@ -1614,7 +1625,7 @@ int ath_attach(u16 devid, struct ath_softc *sc) ...@@ -1614,7 +1625,7 @@ int ath_attach(u16 devid, struct ath_softc *sc)
struct ieee80211_hw *hw = sc->hw; struct ieee80211_hw *hw = sc->hw;
const struct ieee80211_regdomain *regd; const struct ieee80211_regdomain *regd;
int error = 0, i; int error = 0, i;
struct ath9k_regulatory *reg; struct ath_regulatory *reg;
DPRINTF(sc, ATH_DBG_CONFIG, "Attach ATH hw\n"); DPRINTF(sc, ATH_DBG_CONFIG, "Attach ATH hw\n");
...@@ -1656,23 +1667,23 @@ int ath_attach(u16 devid, struct ath_softc *sc) ...@@ -1656,23 +1667,23 @@ int ath_attach(u16 devid, struct ath_softc *sc)
goto error_attach; goto error_attach;
#endif #endif
if (ath9k_is_world_regd(reg)) { if (ath_is_world_regd(reg)) {
/* Anything applied here (prior to wiphy registration) gets /* Anything applied here (prior to wiphy registration) gets
* saved on the wiphy orig_* parameters */ * saved on the wiphy orig_* parameters */
regd = ath9k_world_regdomain(reg); regd = ath_world_regdomain(reg);
hw->wiphy->custom_regulatory = true; hw->wiphy->custom_regulatory = true;
hw->wiphy->strict_regulatory = false; hw->wiphy->strict_regulatory = false;
} else { } else {
/* This gets applied in the case of the absense of CRDA, /* This gets applied in the case of the absense of CRDA,
* it's our own custom world regulatory domain, similar to * it's our own custom world regulatory domain, similar to
* cfg80211's but we enable passive scanning */ * cfg80211's but we enable passive scanning */
regd = ath9k_default_world_regdomain(); regd = ath_default_world_regdomain();
} }
wiphy_apply_custom_regulatory(hw->wiphy, regd); wiphy_apply_custom_regulatory(hw->wiphy, regd);
ath9k_reg_apply_radar_flags(hw->wiphy); ath_reg_apply_radar_flags(hw->wiphy);
ath9k_reg_apply_world_flags(hw->wiphy, ath_reg_apply_world_flags(hw->wiphy,
NL80211_REGDOM_SET_BY_DRIVER, NL80211_REGDOM_SET_BY_DRIVER,
reg); reg);
INIT_WORK(&sc->chan_work, ath9k_wiphy_chan_work); INIT_WORK(&sc->chan_work, ath9k_wiphy_chan_work);
INIT_DELAYED_WORK(&sc->wiphy_work, ath9k_wiphy_work); INIT_DELAYED_WORK(&sc->wiphy_work, ath9k_wiphy_work);
...@@ -1680,7 +1691,7 @@ int ath_attach(u16 devid, struct ath_softc *sc) ...@@ -1680,7 +1691,7 @@ int ath_attach(u16 devid, struct ath_softc *sc)
error = ieee80211_register_hw(hw); error = ieee80211_register_hw(hw);
if (!ath9k_is_world_regd(reg)) { if (!ath_is_world_regd(reg)) {
error = regulatory_hint(hw->wiphy, reg->alpha2); error = regulatory_hint(hw->wiphy, reg->alpha2);
if (error) if (error)
goto error_attach; goto error_attach;
......
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