Commit e9357c05 authored by Michael Buesch's avatar Michael Buesch Committed by John W. Linville

[PATCH] bcm43xx: reduce the size of bcm43xx_private by removing unneeded members.

Signed-off-by: default avatarMichael Buesch <mbuesch@freenet.de>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent aae37781
...@@ -556,33 +556,37 @@ struct bcm43xx_pio { ...@@ -556,33 +556,37 @@ struct bcm43xx_pio {
#define BCM43xx_MAX_80211_CORES 2 #define BCM43xx_MAX_80211_CORES 2
#define BCM43xx_COREFLAG_AVAILABLE (1 << 0)
#define BCM43xx_COREFLAG_ENABLED (1 << 1)
#define BCM43xx_COREFLAG_INITIALIZED (1 << 2)
#ifdef CONFIG_BCM947XX #ifdef CONFIG_BCM947XX
#define core_offset(bcm) (bcm)->current_core_offset #define core_offset(bcm) (bcm)->current_core_offset
#else #else
#define core_offset(bcm) 0 #define core_offset(bcm) 0
#endif #endif
/* Generic information about a core. */
struct bcm43xx_coreinfo { struct bcm43xx_coreinfo {
/** Driver internal flags. See BCM43xx_COREFLAG_* */ u8 available:1,
u32 flags; enabled:1,
initialized:1;
/** core_id ID number */ /** core_id ID number */
u16 id; u16 id;
/** core_rev revision number */ /** core_rev revision number */
u8 rev; u8 rev;
/** Index number for _switch_core() */ /** Index number for _switch_core() */
u8 index; u8 index;
/* Pointer to the PHYinfo, which belongs to this core (if 80211 core) */ };
struct bcm43xx_phyinfo *phy;
/* Pointer to the RadioInfo, which belongs to this core (if 80211 core) */ /* Additional information for each 80211 core. */
struct bcm43xx_radioinfo *radio; struct bcm43xx_coreinfo_80211 {
/* Pointer to the DMA rings, which belong to this core (if 80211 core) */ /* PHY device. */
struct bcm43xx_dma *dma; struct bcm43xx_phyinfo phy;
/* Pointer to the PIO queues, which belong to this core (if 80211 core) */ /* Radio device. */
struct bcm43xx_pio *pio; struct bcm43xx_radioinfo radio;
union {
/* DMA context. */
struct bcm43xx_dma dma;
/* PIO context. */
struct bcm43xx_pio pio;
};
}; };
/* Context information for a noise calculation (Link Quality). */ /* Context information for a noise calculation (Link Quality). */
...@@ -652,7 +656,7 @@ struct bcm43xx_private { ...@@ -652,7 +656,7 @@ struct bcm43xx_private {
#define BCM43xx_NR_LEDS 4 #define BCM43xx_NR_LEDS 4
struct bcm43xx_led leds[BCM43xx_NR_LEDS]; struct bcm43xx_led leds[BCM43xx_NR_LEDS];
/* The currently active core. NULL if not initialized, yet. */ /* The currently active core. */
struct bcm43xx_coreinfo *current_core; struct bcm43xx_coreinfo *current_core;
#ifdef CONFIG_BCM947XX #ifdef CONFIG_BCM947XX
/** current core memory offset */ /** current core memory offset */
...@@ -665,18 +669,15 @@ struct bcm43xx_private { ...@@ -665,18 +669,15 @@ struct bcm43xx_private {
*/ */
struct bcm43xx_coreinfo core_chipcommon; struct bcm43xx_coreinfo core_chipcommon;
struct bcm43xx_coreinfo core_pci; struct bcm43xx_coreinfo core_pci;
struct bcm43xx_coreinfo core_v90;
struct bcm43xx_coreinfo core_pcmcia;
struct bcm43xx_coreinfo core_ethernet;
struct bcm43xx_coreinfo core_80211[ BCM43xx_MAX_80211_CORES ]; struct bcm43xx_coreinfo core_80211[ BCM43xx_MAX_80211_CORES ];
/* Info about the PHY for each 80211 core. */ /* Additional information, specific to the 80211 cores. */
struct bcm43xx_phyinfo phy[ BCM43xx_MAX_80211_CORES ]; struct bcm43xx_coreinfo_80211 core_80211_ext[ BCM43xx_MAX_80211_CORES ];
/* Info about the Radio for each 80211 core. */ /* Index of the current 80211 core. If current_core is not
struct bcm43xx_radioinfo radio[ BCM43xx_MAX_80211_CORES ]; * an 80211 core, this is -1.
/* DMA */ */
struct bcm43xx_dma dma[ BCM43xx_MAX_80211_CORES ]; int current_80211_core_idx;
/* PIO */ /* Number of available 80211 cores. */
struct bcm43xx_pio pio[ BCM43xx_MAX_80211_CORES ]; int nr_80211_available;
u32 chipcommon_capabilities; u32 chipcommon_capabilities;
...@@ -769,18 +770,39 @@ int bcm43xx_using_pio(struct bcm43xx_private *bcm) ...@@ -769,18 +770,39 @@ int bcm43xx_using_pio(struct bcm43xx_private *bcm)
# error "Using neither DMA nor PIO? Confused..." # error "Using neither DMA nor PIO? Confused..."
#endif #endif
/* Helper functions to access data structures private to the 80211 cores.
* Note that we _must_ have an 80211 core mapped when calling
* any of these functions.
*/
static inline static inline
int bcm43xx_num_80211_cores(struct bcm43xx_private *bcm) struct bcm43xx_pio * bcm43xx_current_pio(struct bcm43xx_private *bcm)
{ {
int i, cnt = 0; assert(bcm43xx_using_pio(bcm));
assert(bcm->current_80211_core_idx >= 0);
for (i = 0; i < BCM43xx_MAX_80211_CORES; i++) { assert(bcm->current_80211_core_idx < BCM43xx_MAX_80211_CORES);
if (bcm->core_80211[i].flags & BCM43xx_COREFLAG_AVAILABLE) return &(bcm->core_80211_ext[bcm->current_80211_core_idx].pio);
cnt++; }
} static inline
struct bcm43xx_dma * bcm43xx_current_dma(struct bcm43xx_private *bcm)
return cnt; {
assert(!bcm43xx_using_pio(bcm));
assert(bcm->current_80211_core_idx >= 0);
assert(bcm->current_80211_core_idx < BCM43xx_MAX_80211_CORES);
return &(bcm->core_80211_ext[bcm->current_80211_core_idx].dma);
}
static inline
struct bcm43xx_phyinfo * bcm43xx_current_phy(struct bcm43xx_private *bcm)
{
assert(bcm->current_80211_core_idx >= 0);
assert(bcm->current_80211_core_idx < BCM43xx_MAX_80211_CORES);
return &(bcm->core_80211_ext[bcm->current_80211_core_idx].phy);
}
static inline
struct bcm43xx_radioinfo * bcm43xx_current_radio(struct bcm43xx_private *bcm)
{
assert(bcm->current_80211_core_idx >= 0);
assert(bcm->current_80211_core_idx < BCM43xx_MAX_80211_CORES);
return &(bcm->core_80211_ext[bcm->current_80211_core_idx].radio);
} }
/* Are we running in init_board() context? */ /* Are we running in init_board() context? */
......
...@@ -104,16 +104,13 @@ static ssize_t devinfo_read_file(struct file *file, char __user *userbuf, ...@@ -104,16 +104,13 @@ static ssize_t devinfo_read_file(struct file *file, char __user *userbuf,
fappend("\nCores:\n"); fappend("\nCores:\n");
#define fappend_core(name, info) fappend("core \"" name "\" %s, %s, id: 0x%04x, " \ #define fappend_core(name, info) fappend("core \"" name "\" %s, %s, id: 0x%04x, " \
"rev: 0x%02x, index: 0x%02x\n", \ "rev: 0x%02x, index: 0x%02x\n", \
(info).flags & BCM43xx_COREFLAG_AVAILABLE \ (info).available \
? "available" : "nonavailable", \ ? "available" : "nonavailable", \
(info).flags & BCM43xx_COREFLAG_ENABLED \ (info).enabled \
? "enabled" : "disabled", \ ? "enabled" : "disabled", \
(info).id, (info).rev, (info).index) (info).id, (info).rev, (info).index)
fappend_core("CHIPCOMMON", bcm->core_chipcommon); fappend_core("CHIPCOMMON", bcm->core_chipcommon);
fappend_core("PCI", bcm->core_pci); fappend_core("PCI", bcm->core_pci);
fappend_core("V90", bcm->core_v90);
fappend_core("PCMCIA", bcm->core_pcmcia);
fappend_core("ETHERNET", bcm->core_ethernet);
fappend_core("first 80211", bcm->core_80211[0]); fappend_core("first 80211", bcm->core_80211[0]);
fappend_core("second 80211", bcm->core_80211[1]); fappend_core("second 80211", bcm->core_80211[1]);
#undef fappend_core #undef fappend_core
......
...@@ -531,7 +531,7 @@ static void bcm43xx_destroy_dmaring(struct bcm43xx_dmaring *ring) ...@@ -531,7 +531,7 @@ static void bcm43xx_destroy_dmaring(struct bcm43xx_dmaring *ring)
void bcm43xx_dma_free(struct bcm43xx_private *bcm) void bcm43xx_dma_free(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_dma *dma = bcm->current_core->dma; struct bcm43xx_dma *dma = bcm43xx_current_dma(bcm);
bcm43xx_destroy_dmaring(dma->rx_ring1); bcm43xx_destroy_dmaring(dma->rx_ring1);
dma->rx_ring1 = NULL; dma->rx_ring1 = NULL;
...@@ -549,7 +549,7 @@ void bcm43xx_dma_free(struct bcm43xx_private *bcm) ...@@ -549,7 +549,7 @@ void bcm43xx_dma_free(struct bcm43xx_private *bcm)
int bcm43xx_dma_init(struct bcm43xx_private *bcm) int bcm43xx_dma_init(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_dma *dma = bcm->current_core->dma; struct bcm43xx_dma *dma = bcm43xx_current_dma(bcm);
struct bcm43xx_dmaring *ring; struct bcm43xx_dmaring *ring;
int err = -ENOMEM; int err = -ENOMEM;
...@@ -652,7 +652,7 @@ static ...@@ -652,7 +652,7 @@ static
struct bcm43xx_dmaring * parse_cookie(struct bcm43xx_private *bcm, struct bcm43xx_dmaring * parse_cookie(struct bcm43xx_private *bcm,
u16 cookie, int *slot) u16 cookie, int *slot)
{ {
struct bcm43xx_dma *dma = bcm->current_core->dma; struct bcm43xx_dma *dma = bcm43xx_current_dma(bcm);
struct bcm43xx_dmaring *ring = NULL; struct bcm43xx_dmaring *ring = NULL;
switch (cookie & 0xF000) { switch (cookie & 0xF000) {
...@@ -755,7 +755,7 @@ int bcm43xx_dma_tx(struct bcm43xx_private *bcm, ...@@ -755,7 +755,7 @@ int bcm43xx_dma_tx(struct bcm43xx_private *bcm,
* the device to send the stuff. * the device to send the stuff.
* Note that this is called from atomic context. * Note that this is called from atomic context.
*/ */
struct bcm43xx_dmaring *ring = bcm->current_core->dma->tx_ring1; struct bcm43xx_dmaring *ring = bcm43xx_current_dma(bcm)->tx_ring1;
u8 i; u8 i;
struct sk_buff *skb; struct sk_buff *skb;
...@@ -784,6 +784,7 @@ int bcm43xx_dma_tx(struct bcm43xx_private *bcm, ...@@ -784,6 +784,7 @@ int bcm43xx_dma_tx(struct bcm43xx_private *bcm,
void bcm43xx_dma_handle_xmitstatus(struct bcm43xx_private *bcm, void bcm43xx_dma_handle_xmitstatus(struct bcm43xx_private *bcm,
struct bcm43xx_xmitstatus *status) struct bcm43xx_xmitstatus *status)
{ {
struct bcm43xx_dma *dma = bcm43xx_current_dma(bcm);
struct bcm43xx_dmaring *ring; struct bcm43xx_dmaring *ring;
struct bcm43xx_dmadesc *desc; struct bcm43xx_dmadesc *desc;
struct bcm43xx_dmadesc_meta *meta; struct bcm43xx_dmadesc_meta *meta;
......
...@@ -314,7 +314,7 @@ const u16 bcm43xx_ilt_sigmasqr2[BCM43xx_ILT_SIGMASQR_SIZE] = { ...@@ -314,7 +314,7 @@ const u16 bcm43xx_ilt_sigmasqr2[BCM43xx_ILT_SIGMASQR_SIZE] = {
void bcm43xx_ilt_write(struct bcm43xx_private *bcm, u16 offset, u16 val) void bcm43xx_ilt_write(struct bcm43xx_private *bcm, u16 offset, u16 val)
{ {
if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_A) { if (bcm43xx_current_phy(bcm)->type == BCM43xx_PHYTYPE_A) {
bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_A_CTRL, offset); bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_A_CTRL, offset);
mmiowb(); mmiowb();
bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_A_DATA1, val); bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_A_DATA1, val);
...@@ -327,7 +327,7 @@ void bcm43xx_ilt_write(struct bcm43xx_private *bcm, u16 offset, u16 val) ...@@ -327,7 +327,7 @@ void bcm43xx_ilt_write(struct bcm43xx_private *bcm, u16 offset, u16 val)
u16 bcm43xx_ilt_read(struct bcm43xx_private *bcm, u16 offset) u16 bcm43xx_ilt_read(struct bcm43xx_private *bcm, u16 offset)
{ {
if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_A) { if (bcm43xx_current_phy(bcm)->type == BCM43xx_PHYTYPE_A) {
bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_A_CTRL, offset); bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_A_CTRL, offset);
return bcm43xx_phy_read(bcm, BCM43xx_PHY_ILT_A_DATA1); return bcm43xx_phy_read(bcm, BCM43xx_PHY_ILT_A_DATA1);
} else { } else {
......
...@@ -171,8 +171,8 @@ void bcm43xx_leds_exit(struct bcm43xx_private *bcm) ...@@ -171,8 +171,8 @@ void bcm43xx_leds_exit(struct bcm43xx_private *bcm)
void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity) void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity)
{ {
struct bcm43xx_led *led; struct bcm43xx_led *led;
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
const int transferring = (jiffies - bcm->stats.last_tx) < BCM43xx_LED_XFER_THRES; const int transferring = (jiffies - bcm->stats.last_tx) < BCM43xx_LED_XFER_THRES;
int i, turn_on; int i, turn_on;
unsigned long interval = 0; unsigned long interval = 0;
......
...@@ -406,7 +406,7 @@ static void bcm43xx_write_mac_bssid_templates(struct bcm43xx_private *bcm) ...@@ -406,7 +406,7 @@ static void bcm43xx_write_mac_bssid_templates(struct bcm43xx_private *bcm)
static void bcm43xx_set_slot_time(struct bcm43xx_private *bcm, u16 slot_time) static void bcm43xx_set_slot_time(struct bcm43xx_private *bcm, u16 slot_time)
{ {
/* slot_time is in usec. */ /* slot_time is in usec. */
if (bcm->current_core->phy->type != BCM43xx_PHYTYPE_G) if (bcm43xx_current_phy(bcm)->type != BCM43xx_PHYTYPE_G)
return; return;
bcm43xx_write16(bcm, 0x684, 510 + slot_time); bcm43xx_write16(bcm, 0x684, 510 + slot_time);
bcm43xx_shm_write16(bcm, BCM43xx_SHM_SHARED, 0x0010, slot_time); bcm43xx_shm_write16(bcm, BCM43xx_SHM_SHARED, 0x0010, slot_time);
...@@ -443,7 +443,7 @@ static void bcm43xx_disassociate(struct bcm43xx_private *bcm) ...@@ -443,7 +443,7 @@ static void bcm43xx_disassociate(struct bcm43xx_private *bcm)
bcm43xx_shm_write32(bcm, BCM43xx_SHM_WIRELESS, 0x0004, 0x000003ff); bcm43xx_shm_write32(bcm, BCM43xx_SHM_WIRELESS, 0x0004, 0x000003ff);
if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_G && if (bcm43xx_current_phy(bcm)->type == BCM43xx_PHYTYPE_G &&
ieee80211_is_ofdm_rate(bcm->softmac->txrates.default_rate)) ieee80211_is_ofdm_rate(bcm->softmac->txrates.default_rate))
bcm43xx_short_slot_timing_enable(bcm); bcm43xx_short_slot_timing_enable(bcm);
...@@ -510,8 +510,8 @@ static int bcm43xx_disable_interrupts_sync(struct bcm43xx_private *bcm, u32 *old ...@@ -510,8 +510,8 @@ static int bcm43xx_disable_interrupts_sync(struct bcm43xx_private *bcm, u32 *old
static int bcm43xx_read_radioinfo(struct bcm43xx_private *bcm) static int bcm43xx_read_radioinfo(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
u32 radio_id; u32 radio_id;
u16 manufact; u16 manufact;
u16 version; u16 version;
...@@ -566,10 +566,10 @@ static int bcm43xx_read_radioinfo(struct bcm43xx_private *bcm) ...@@ -566,10 +566,10 @@ static int bcm43xx_read_radioinfo(struct bcm43xx_private *bcm)
radio->txpower[2] = 3; radio->txpower[2] = 3;
else else
radio->txpower[2] = 0; radio->txpower[2] = 0;
if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_A) if (phy->type == BCM43xx_PHYTYPE_A)
radio->txpower_desired = bcm->sprom.maxpower_aphy; radio->txpower_desired = bcm->sprom.maxpower_aphy;
else else
bcm->current_core->radio->txpower_desired = bcm->sprom.maxpower_bgphy; radio->txpower_desired = bcm->sprom.maxpower_bgphy;
/* Initialize the in-memory nrssi Lookup Table. */ /* Initialize the in-memory nrssi Lookup Table. */
for (i = 0; i < 64; i++) for (i = 0; i < 64; i++)
...@@ -929,15 +929,14 @@ static void bcm43xx_geo_init(struct bcm43xx_private *bcm) ...@@ -929,15 +929,14 @@ static void bcm43xx_geo_init(struct bcm43xx_private *bcm)
struct ieee80211_geo geo; struct ieee80211_geo geo;
struct ieee80211_channel *chan; struct ieee80211_channel *chan;
int have_a = 0, have_bg = 0; int have_a = 0, have_bg = 0;
int i, num80211; int i;
u8 channel; u8 channel;
struct bcm43xx_phyinfo *phy; struct bcm43xx_phyinfo *phy;
const char *iso_country; const char *iso_country;
memset(&geo, 0, sizeof(geo)); memset(&geo, 0, sizeof(geo));
num80211 = bcm43xx_num_80211_cores(bcm); for (i = 0; i < bcm->nr_80211_available; i++) {
for (i = 0; i < num80211; i++) { phy = &(bcm->core_80211_ext[i].phy);
phy = bcm->phy + i;
switch (phy->type) { switch (phy->type) {
case BCM43xx_PHYTYPE_B: case BCM43xx_PHYTYPE_B:
case BCM43xx_PHYTYPE_G: case BCM43xx_PHYTYPE_G:
...@@ -985,8 +984,8 @@ static void bcm43xx_geo_init(struct bcm43xx_private *bcm) ...@@ -985,8 +984,8 @@ static void bcm43xx_geo_init(struct bcm43xx_private *bcm)
*/ */
void bcm43xx_dummy_transmission(struct bcm43xx_private *bcm) void bcm43xx_dummy_transmission(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
unsigned int i, max_loop; unsigned int i, max_loop;
u16 value = 0; u16 value = 0;
u32 buffer[5] = { u32 buffer[5] = {
...@@ -1213,14 +1212,20 @@ int bcm43xx_switch_core(struct bcm43xx_private *bcm, struct bcm43xx_coreinfo *ne ...@@ -1213,14 +1212,20 @@ int bcm43xx_switch_core(struct bcm43xx_private *bcm, struct bcm43xx_coreinfo *ne
if (unlikely(!new_core)) if (unlikely(!new_core))
return 0; return 0;
if (!(new_core->flags & BCM43xx_COREFLAG_AVAILABLE)) if (!new_core->available)
return -ENODEV; return -ENODEV;
if (bcm->current_core == new_core) if (bcm->current_core == new_core)
return 0; return 0;
err = _switch_core(bcm, new_core->index); err = _switch_core(bcm, new_core->index);
if (likely(!err)) if (unlikely(err))
goto out;
bcm->current_core = new_core; bcm->current_core = new_core;
bcm->current_80211_core_idx = -1;
if (new_core->id == BCM43xx_COREID_80211)
bcm->current_80211_core_idx = (int)(new_core - &(bcm->core_80211[0]));
out:
return err; return err;
} }
...@@ -1295,7 +1300,8 @@ static int bcm43xx_core_disable(struct bcm43xx_private *bcm, u32 core_flags) ...@@ -1295,7 +1300,8 @@ static int bcm43xx_core_disable(struct bcm43xx_private *bcm, u32 core_flags)
bcm43xx_write32(bcm, BCM43xx_CIR_SBTMSTATELOW, sbtmstatelow); bcm43xx_write32(bcm, BCM43xx_CIR_SBTMSTATELOW, sbtmstatelow);
out: out:
bcm->current_core->flags &= ~ BCM43xx_COREFLAG_ENABLED; bcm->current_core->enabled = 0;
return 0; return 0;
} }
...@@ -1340,7 +1346,7 @@ static int bcm43xx_core_enable(struct bcm43xx_private *bcm, u32 core_flags) ...@@ -1340,7 +1346,7 @@ static int bcm43xx_core_enable(struct bcm43xx_private *bcm, u32 core_flags)
bcm43xx_write32(bcm, BCM43xx_CIR_SBTMSTATELOW, sbtmstatelow); bcm43xx_write32(bcm, BCM43xx_CIR_SBTMSTATELOW, sbtmstatelow);
udelay(1); udelay(1);
bcm->current_core->flags |= BCM43xx_COREFLAG_ENABLED; bcm->current_core->enabled = 1;
assert(err == 0); assert(err == 0);
out: out:
return err; return err;
...@@ -1411,7 +1417,7 @@ static int bcm43xx_wireless_core_mark_inactive(struct bcm43xx_private *bcm, ...@@ -1411,7 +1417,7 @@ static int bcm43xx_wireless_core_mark_inactive(struct bcm43xx_private *bcm,
bcm43xx_write32(bcm, BCM43xx_CIR_SBTMSTATELOW, sbtmstatelow); bcm43xx_write32(bcm, BCM43xx_CIR_SBTMSTATELOW, sbtmstatelow);
udelay(1); udelay(1);
if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_G) { if (bcm43xx_current_phy(bcm)->type == BCM43xx_PHYTYPE_G) {
old_core = bcm->current_core; old_core = bcm->current_core;
err = bcm43xx_switch_core(bcm, active_80211_core); err = bcm43xx_switch_core(bcm, active_80211_core);
if (err) if (err)
...@@ -1433,9 +1439,6 @@ static void handle_irq_transmit_status(struct bcm43xx_private *bcm) ...@@ -1433,9 +1439,6 @@ static void handle_irq_transmit_status(struct bcm43xx_private *bcm)
u16 tmp; u16 tmp;
struct bcm43xx_xmitstatus stat; struct bcm43xx_xmitstatus stat;
assert(bcm->current_core->id == BCM43xx_COREID_80211);
assert(bcm->current_core->rev >= 5);
while (1) { while (1) {
v0 = bcm43xx_read32(bcm, BCM43xx_MMIO_XMITSTAT_0); v0 = bcm43xx_read32(bcm, BCM43xx_MMIO_XMITSTAT_0);
if (!v0) if (!v0)
...@@ -1473,7 +1476,7 @@ static void bcm43xx_generate_noise_sample(struct bcm43xx_private *bcm) ...@@ -1473,7 +1476,7 @@ static void bcm43xx_generate_noise_sample(struct bcm43xx_private *bcm)
bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS2_BITFIELD, bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS2_BITFIELD,
bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS2_BITFIELD) | (1 << 4)); bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS2_BITFIELD) | (1 << 4));
assert(bcm->noisecalc.core_at_start == bcm->current_core); assert(bcm->noisecalc.core_at_start == bcm->current_core);
assert(bcm->noisecalc.channel_at_start == bcm->current_core->radio->channel); assert(bcm->noisecalc.channel_at_start == bcm43xx_current_radio(bcm)->channel);
} }
static void bcm43xx_calculate_link_quality(struct bcm43xx_private *bcm) static void bcm43xx_calculate_link_quality(struct bcm43xx_private *bcm)
...@@ -1483,7 +1486,7 @@ static void bcm43xx_calculate_link_quality(struct bcm43xx_private *bcm) ...@@ -1483,7 +1486,7 @@ static void bcm43xx_calculate_link_quality(struct bcm43xx_private *bcm)
if (bcm->noisecalc.calculation_running) if (bcm->noisecalc.calculation_running)
return; return;
bcm->noisecalc.core_at_start = bcm->current_core; bcm->noisecalc.core_at_start = bcm->current_core;
bcm->noisecalc.channel_at_start = bcm->current_core->radio->channel; bcm->noisecalc.channel_at_start = bcm43xx_current_radio(bcm)->channel;
bcm->noisecalc.calculation_running = 1; bcm->noisecalc.calculation_running = 1;
bcm->noisecalc.nr_samples = 0; bcm->noisecalc.nr_samples = 0;
...@@ -1492,7 +1495,7 @@ static void bcm43xx_calculate_link_quality(struct bcm43xx_private *bcm) ...@@ -1492,7 +1495,7 @@ static void bcm43xx_calculate_link_quality(struct bcm43xx_private *bcm)
static void handle_irq_noise(struct bcm43xx_private *bcm) static void handle_irq_noise(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
u16 tmp; u16 tmp;
u8 noise[4]; u8 noise[4];
u8 i, j; u8 i, j;
...@@ -1759,16 +1762,16 @@ static void bcm43xx_interrupt_tasklet(struct bcm43xx_private *bcm) ...@@ -1759,16 +1762,16 @@ static void bcm43xx_interrupt_tasklet(struct bcm43xx_private *bcm)
assert(!(dma_reason[2] & BCM43xx_DMAIRQ_RX_DONE)); assert(!(dma_reason[2] & BCM43xx_DMAIRQ_RX_DONE));
if (dma_reason[0] & BCM43xx_DMAIRQ_RX_DONE) { if (dma_reason[0] & BCM43xx_DMAIRQ_RX_DONE) {
if (bcm43xx_using_pio(bcm)) if (bcm43xx_using_pio(bcm))
bcm43xx_pio_rx(bcm->current_core->pio->queue0); bcm43xx_pio_rx(bcm43xx_current_pio(bcm)->queue0);
else else
bcm43xx_dma_rx(bcm->current_core->dma->rx_ring0); bcm43xx_dma_rx(bcm43xx_current_dma(bcm)->rx_ring0);
/* We intentionally don't set "activity" to 1, here. */ /* We intentionally don't set "activity" to 1, here. */
} }
if (dma_reason[3] & BCM43xx_DMAIRQ_RX_DONE) { if (dma_reason[3] & BCM43xx_DMAIRQ_RX_DONE) {
if (bcm43xx_using_pio(bcm)) if (bcm43xx_using_pio(bcm))
bcm43xx_pio_rx(bcm->current_core->pio->queue3); bcm43xx_pio_rx(bcm43xx_current_pio(bcm)->queue3);
else else
bcm43xx_dma_rx(bcm->current_core->dma->rx_ring1); bcm43xx_dma_rx(bcm43xx_current_dma(bcm)->rx_ring1);
activity = 1; activity = 1;
} }
bcmirq_handled(BCM43xx_IRQ_RX); bcmirq_handled(BCM43xx_IRQ_RX);
...@@ -1911,7 +1914,7 @@ static void bcm43xx_release_firmware(struct bcm43xx_private *bcm, int force) ...@@ -1911,7 +1914,7 @@ static void bcm43xx_release_firmware(struct bcm43xx_private *bcm, int force)
static int bcm43xx_request_firmware(struct bcm43xx_private *bcm) static int bcm43xx_request_firmware(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
u8 rev = bcm->current_core->rev; u8 rev = bcm->current_core->rev;
int err = 0; int err = 0;
int nr; int nr;
...@@ -2349,6 +2352,8 @@ static void bcm43xx_chip_cleanup(struct bcm43xx_private *bcm) ...@@ -2349,6 +2352,8 @@ static void bcm43xx_chip_cleanup(struct bcm43xx_private *bcm)
*/ */
static int bcm43xx_chip_init(struct bcm43xx_private *bcm) static int bcm43xx_chip_init(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
int err; int err;
int iw_mode = bcm->ieee->iw_mode; int iw_mode = bcm->ieee->iw_mode;
int tmp; int tmp;
...@@ -2388,13 +2393,13 @@ static int bcm43xx_chip_init(struct bcm43xx_private *bcm) ...@@ -2388,13 +2393,13 @@ static int bcm43xx_chip_init(struct bcm43xx_private *bcm)
goto err_radio_off; goto err_radio_off;
/* Select initial Interference Mitigation. */ /* Select initial Interference Mitigation. */
tmp = bcm->current_core->radio->interfmode; tmp = radio->interfmode;
bcm->current_core->radio->interfmode = BCM43xx_RADIO_INTERFMODE_NONE; radio->interfmode = BCM43xx_RADIO_INTERFMODE_NONE;
bcm43xx_radio_set_interference_mitigation(bcm, tmp); bcm43xx_radio_set_interference_mitigation(bcm, tmp);
bcm43xx_phy_set_antenna_diversity(bcm); bcm43xx_phy_set_antenna_diversity(bcm);
bcm43xx_radio_set_txantenna(bcm, BCM43xx_RADIO_TXANTENNA_DEFAULT); bcm43xx_radio_set_txantenna(bcm, BCM43xx_RADIO_TXANTENNA_DEFAULT);
if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_B) { if (phy->type == BCM43xx_PHYTYPE_B) {
value16 = bcm43xx_read16(bcm, 0x005E); value16 = bcm43xx_read16(bcm, 0x005E);
value16 |= 0x0004; value16 |= 0x0004;
bcm43xx_write16(bcm, 0x005E, value16); bcm43xx_write16(bcm, 0x005E, value16);
...@@ -2512,6 +2517,32 @@ static int bcm43xx_validate_chip(struct bcm43xx_private *bcm) ...@@ -2512,6 +2517,32 @@ static int bcm43xx_validate_chip(struct bcm43xx_private *bcm)
return -ENODEV; return -ENODEV;
} }
void bcm43xx_init_struct_phyinfo(struct bcm43xx_phyinfo *phy)
{
/* Initialize a "phyinfo" structure. The structure is already
* zeroed out.
*/
phy->antenna_diversity = 0xFFFF;
phy->savedpctlreg = 0xFFFF;
phy->minlowsig[0] = 0xFFFF;
phy->minlowsig[1] = 0xFFFF;
spin_lock_init(&phy->lock);
}
void bcm43xx_init_struct_radioinfo(struct bcm43xx_radioinfo *radio)
{
/* Initialize a "radioinfo" structure. The structure is already
* zeroed out.
*/
radio->interfmode = BCM43xx_RADIO_INTERFMODE_NONE;
radio->channel = 0xFF;
radio->initial_channel = 0xFF;
radio->lofcal = 0xFFFF;
radio->initval = 0xFFFF;
radio->nrssi[0] = -1000;
radio->nrssi[1] = -1000;
}
static int bcm43xx_probe_cores(struct bcm43xx_private *bcm) static int bcm43xx_probe_cores(struct bcm43xx_private *bcm)
{ {
int err, i; int err, i;
...@@ -2523,15 +2554,14 @@ static int bcm43xx_probe_cores(struct bcm43xx_private *bcm) ...@@ -2523,15 +2554,14 @@ static int bcm43xx_probe_cores(struct bcm43xx_private *bcm)
memset(&bcm->core_chipcommon, 0, sizeof(struct bcm43xx_coreinfo)); memset(&bcm->core_chipcommon, 0, sizeof(struct bcm43xx_coreinfo));
memset(&bcm->core_pci, 0, sizeof(struct bcm43xx_coreinfo)); memset(&bcm->core_pci, 0, sizeof(struct bcm43xx_coreinfo));
memset(&bcm->core_v90, 0, sizeof(struct bcm43xx_coreinfo));
memset(&bcm->core_pcmcia, 0, sizeof(struct bcm43xx_coreinfo));
memset(&bcm->core_80211, 0, sizeof(struct bcm43xx_coreinfo) memset(&bcm->core_80211, 0, sizeof(struct bcm43xx_coreinfo)
* BCM43xx_MAX_80211_CORES); * BCM43xx_MAX_80211_CORES);
memset(&bcm->core_80211_ext, 0, sizeof(struct bcm43xx_coreinfo_80211)
memset(&bcm->phy, 0, sizeof(struct bcm43xx_phyinfo)
* BCM43xx_MAX_80211_CORES);
memset(&bcm->radio, 0, sizeof(struct bcm43xx_radioinfo)
* BCM43xx_MAX_80211_CORES); * BCM43xx_MAX_80211_CORES);
bcm->current_80211_core_idx = -1;
bcm->nr_80211_available = 0;
bcm->current_core = NULL;
bcm->active_80211_core = NULL;
/* map core 0 */ /* map core 0 */
err = _switch_core(bcm, 0); err = _switch_core(bcm, 0);
...@@ -2549,7 +2579,7 @@ static int bcm43xx_probe_cores(struct bcm43xx_private *bcm) ...@@ -2549,7 +2579,7 @@ static int bcm43xx_probe_cores(struct bcm43xx_private *bcm)
if (core_id == BCM43xx_COREID_CHIPCOMMON) { if (core_id == BCM43xx_COREID_CHIPCOMMON) {
chip_id_32 = bcm43xx_read32(bcm, 0); chip_id_32 = bcm43xx_read32(bcm, 0);
chip_id_16 = chip_id_32 & 0xFFFF; chip_id_16 = chip_id_32 & 0xFFFF;
bcm->core_chipcommon.flags |= BCM43xx_COREFLAG_AVAILABLE; bcm->core_chipcommon.available = 1;
bcm->core_chipcommon.id = core_id; bcm->core_chipcommon.id = core_id;
bcm->core_chipcommon.rev = core_rev; bcm->core_chipcommon.rev = core_rev;
bcm->core_chipcommon.index = 0; bcm->core_chipcommon.index = 0;
...@@ -2618,18 +2648,19 @@ static int bcm43xx_probe_cores(struct bcm43xx_private *bcm) ...@@ -2618,18 +2648,19 @@ static int bcm43xx_probe_cores(struct bcm43xx_private *bcm)
dprintk(KERN_INFO PFX "Chip ID 0x%x, rev 0x%x\n", dprintk(KERN_INFO PFX "Chip ID 0x%x, rev 0x%x\n",
bcm->chip_id, bcm->chip_rev); bcm->chip_id, bcm->chip_rev);
dprintk(KERN_INFO PFX "Number of cores: %d\n", core_count); dprintk(KERN_INFO PFX "Number of cores: %d\n", core_count);
if (bcm->core_chipcommon.flags & BCM43xx_COREFLAG_AVAILABLE) { if (bcm->core_chipcommon.available) {
dprintk(KERN_INFO PFX "Core 0: ID 0x%x, rev 0x%x, vendor 0x%x, %s\n", dprintk(KERN_INFO PFX "Core 0: ID 0x%x, rev 0x%x, vendor 0x%x, %s\n",
core_id, core_rev, core_vendor, core_id, core_rev, core_vendor,
bcm43xx_core_enabled(bcm) ? "enabled" : "disabled"); bcm43xx_core_enabled(bcm) ? "enabled" : "disabled");
} }
if (bcm->core_chipcommon.flags & BCM43xx_COREFLAG_AVAILABLE) if (bcm->core_chipcommon.available)
current_core = 1; current_core = 1;
else else
current_core = 0; current_core = 0;
for ( ; current_core < core_count; current_core++) { for ( ; current_core < core_count; current_core++) {
struct bcm43xx_coreinfo *core; struct bcm43xx_coreinfo *core;
struct bcm43xx_coreinfo_80211 *ext_80211;
err = _switch_core(bcm, current_core); err = _switch_core(bcm, current_core);
if (err) if (err)
...@@ -2651,36 +2682,16 @@ static int bcm43xx_probe_cores(struct bcm43xx_private *bcm) ...@@ -2651,36 +2682,16 @@ static int bcm43xx_probe_cores(struct bcm43xx_private *bcm)
switch (core_id) { switch (core_id) {
case BCM43xx_COREID_PCI: case BCM43xx_COREID_PCI:
core = &bcm->core_pci; core = &bcm->core_pci;
if (core->flags & BCM43xx_COREFLAG_AVAILABLE) { if (core->available) {
printk(KERN_WARNING PFX "Multiple PCI cores found.\n"); printk(KERN_WARNING PFX "Multiple PCI cores found.\n");
continue; continue;
} }
break; break;
case BCM43xx_COREID_V90:
core = &bcm->core_v90;
if (core->flags & BCM43xx_COREFLAG_AVAILABLE) {
printk(KERN_WARNING PFX "Multiple V90 cores found.\n");
continue;
}
break;
case BCM43xx_COREID_PCMCIA:
core = &bcm->core_pcmcia;
if (core->flags & BCM43xx_COREFLAG_AVAILABLE) {
printk(KERN_WARNING PFX "Multiple PCMCIA cores found.\n");
continue;
}
break;
case BCM43xx_COREID_ETHERNET:
core = &bcm->core_ethernet;
if (core->flags & BCM43xx_COREFLAG_AVAILABLE) {
printk(KERN_WARNING PFX "Multiple Ethernet cores found.\n");
continue;
}
break;
case BCM43xx_COREID_80211: case BCM43xx_COREID_80211:
for (i = 0; i < BCM43xx_MAX_80211_CORES; i++) { for (i = 0; i < BCM43xx_MAX_80211_CORES; i++) {
core = &(bcm->core_80211[i]); core = &(bcm->core_80211[i]);
if (!(core->flags & BCM43xx_COREFLAG_AVAILABLE)) ext_80211 = &(bcm->core_80211_ext[i]);
if (!core->available)
break; break;
core = NULL; core = NULL;
} }
...@@ -2715,40 +2726,23 @@ static int bcm43xx_probe_cores(struct bcm43xx_private *bcm) ...@@ -2715,40 +2726,23 @@ static int bcm43xx_probe_cores(struct bcm43xx_private *bcm)
err = -ENODEV; err = -ENODEV;
goto out; goto out;
} }
core->phy = &bcm->phy[i]; bcm->nr_80211_available++;
core->phy->antenna_diversity = 0xffff; bcm43xx_init_struct_phyinfo(&ext_80211->phy);
core->phy->savedpctlreg = 0xFFFF; bcm43xx_init_struct_radioinfo(&ext_80211->radio);
core->phy->minlowsig[0] = 0xFFFF;
core->phy->minlowsig[1] = 0xFFFF;
core->phy->minlowsigpos[0] = 0;
core->phy->minlowsigpos[1] = 0;
spin_lock_init(&core->phy->lock);
core->radio = &bcm->radio[i];
core->radio->interfmode = BCM43xx_RADIO_INTERFMODE_NONE;
core->radio->channel = 0xFF;
core->radio->initial_channel = 0xFF;
core->radio->lofcal = 0xFFFF;
core->radio->initval = 0xFFFF;
core->radio->nrssi[0] = -1000;
core->radio->nrssi[1] = -1000;
core->dma = &bcm->dma[i];
core->pio = &bcm->pio[i];
break; break;
case BCM43xx_COREID_CHIPCOMMON: case BCM43xx_COREID_CHIPCOMMON:
printk(KERN_WARNING PFX "Multiple CHIPCOMMON cores found.\n"); printk(KERN_WARNING PFX "Multiple CHIPCOMMON cores found.\n");
break; break;
default:
printk(KERN_WARNING PFX "Unknown core found (ID 0x%x)\n", core_id);
} }
if (core) { if (core) {
core->flags |= BCM43xx_COREFLAG_AVAILABLE; core->available = 1;
core->id = core_id; core->id = core_id;
core->rev = core_rev; core->rev = core_rev;
core->index = current_core; core->index = current_core;
} }
} }
if (!(bcm->core_80211[0].flags & BCM43xx_COREFLAG_AVAILABLE)) { if (!bcm->core_80211[0].available) {
printk(KERN_ERR PFX "Error: No 80211 core found!\n"); printk(KERN_ERR PFX "Error: No 80211 core found!\n");
err = -ENODEV; err = -ENODEV;
goto out; goto out;
...@@ -2802,7 +2796,7 @@ static void bcm43xx_rate_memory_write(struct bcm43xx_private *bcm, ...@@ -2802,7 +2796,7 @@ static void bcm43xx_rate_memory_write(struct bcm43xx_private *bcm,
static void bcm43xx_rate_memory_init(struct bcm43xx_private *bcm) static void bcm43xx_rate_memory_init(struct bcm43xx_private *bcm)
{ {
switch (bcm->current_core->phy->type) { switch (bcm43xx_current_phy(bcm)->type) {
case BCM43xx_PHYTYPE_A: case BCM43xx_PHYTYPE_A:
case BCM43xx_PHYTYPE_G: case BCM43xx_PHYTYPE_G:
bcm43xx_rate_memory_write(bcm, IEEE80211_OFDM_RATE_6MB, 1); bcm43xx_rate_memory_write(bcm, IEEE80211_OFDM_RATE_6MB, 1);
...@@ -2829,12 +2823,14 @@ static void bcm43xx_wireless_core_cleanup(struct bcm43xx_private *bcm) ...@@ -2829,12 +2823,14 @@ static void bcm43xx_wireless_core_cleanup(struct bcm43xx_private *bcm)
bcm43xx_pio_free(bcm); bcm43xx_pio_free(bcm);
bcm43xx_dma_free(bcm); bcm43xx_dma_free(bcm);
bcm->current_core->flags &= ~ BCM43xx_COREFLAG_INITIALIZED; bcm->current_core->initialized = 0;
} }
/* http://bcm-specs.sipsolutions.net/80211Init */ /* http://bcm-specs.sipsolutions.net/80211Init */
static int bcm43xx_wireless_core_init(struct bcm43xx_private *bcm) static int bcm43xx_wireless_core_init(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
u32 ucodeflags; u32 ucodeflags;
int err; int err;
u32 sbimconfiglow; u32 sbimconfiglow;
...@@ -2867,16 +2863,15 @@ static int bcm43xx_wireless_core_init(struct bcm43xx_private *bcm) ...@@ -2867,16 +2863,15 @@ static int bcm43xx_wireless_core_init(struct bcm43xx_private *bcm)
/* HW decryption needs to be set now */ /* HW decryption needs to be set now */
ucodeflags |= 0x40000000; ucodeflags |= 0x40000000;
if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_G) { if (phy->type == BCM43xx_PHYTYPE_G) {
ucodeflags |= BCM43xx_UCODEFLAG_UNKBGPHY; ucodeflags |= BCM43xx_UCODEFLAG_UNKBGPHY;
if (bcm->current_core->phy->rev == 1) if (phy->rev == 1)
ucodeflags |= BCM43xx_UCODEFLAG_UNKGPHY; ucodeflags |= BCM43xx_UCODEFLAG_UNKGPHY;
if (bcm->sprom.boardflags & BCM43xx_BFL_PACTRL) if (bcm->sprom.boardflags & BCM43xx_BFL_PACTRL)
ucodeflags |= BCM43xx_UCODEFLAG_UNKPACTRL; ucodeflags |= BCM43xx_UCODEFLAG_UNKPACTRL;
} else if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_B) { } else if (phy->type == BCM43xx_PHYTYPE_B) {
ucodeflags |= BCM43xx_UCODEFLAG_UNKBGPHY; ucodeflags |= BCM43xx_UCODEFLAG_UNKBGPHY;
if ((bcm->current_core->phy->rev >= 2) && if (phy->rev >= 2 && radio->version == 0x2050)
(bcm->current_core->radio->version == 0x2050))
ucodeflags &= ~BCM43xx_UCODEFLAG_UNKGPHY; ucodeflags &= ~BCM43xx_UCODEFLAG_UNKGPHY;
} }
...@@ -2901,7 +2896,7 @@ static int bcm43xx_wireless_core_init(struct bcm43xx_private *bcm) ...@@ -2901,7 +2896,7 @@ static int bcm43xx_wireless_core_init(struct bcm43xx_private *bcm)
bcm43xx_rate_memory_init(bcm); bcm43xx_rate_memory_init(bcm);
/* Minimum Contention Window */ /* Minimum Contention Window */
if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_B) if (phy->type == BCM43xx_PHYTYPE_B)
bcm43xx_shm_write32(bcm, BCM43xx_SHM_WIRELESS, 0x0003, 0x0000001f); bcm43xx_shm_write32(bcm, BCM43xx_SHM_WIRELESS, 0x0003, 0x0000001f);
else else
bcm43xx_shm_write32(bcm, BCM43xx_SHM_WIRELESS, 0x0003, 0x0000000f); bcm43xx_shm_write32(bcm, BCM43xx_SHM_WIRELESS, 0x0003, 0x0000000f);
...@@ -2927,7 +2922,7 @@ static int bcm43xx_wireless_core_init(struct bcm43xx_private *bcm) ...@@ -2927,7 +2922,7 @@ static int bcm43xx_wireless_core_init(struct bcm43xx_private *bcm)
bcm43xx_mac_enable(bcm); bcm43xx_mac_enable(bcm);
bcm43xx_interrupt_enable(bcm, bcm->irq_savedstate); bcm43xx_interrupt_enable(bcm, bcm->irq_savedstate);
bcm->current_core->flags |= BCM43xx_COREFLAG_INITIALIZED; bcm->current_core->initialized = 1;
out: out:
return err; return err;
...@@ -3048,7 +3043,7 @@ static void bcm43xx_softmac_init(struct bcm43xx_private *bcm) ...@@ -3048,7 +3043,7 @@ static void bcm43xx_softmac_init(struct bcm43xx_private *bcm)
static void bcm43xx_periodic_every120sec(struct bcm43xx_private *bcm) static void bcm43xx_periodic_every120sec(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
if (phy->type != BCM43xx_PHYTYPE_G || phy->rev < 2) if (phy->type != BCM43xx_PHYTYPE_G || phy->rev < 2)
return; return;
...@@ -3076,8 +3071,8 @@ static void bcm43xx_periodic_every30sec(struct bcm43xx_private *bcm) ...@@ -3076,8 +3071,8 @@ static void bcm43xx_periodic_every30sec(struct bcm43xx_private *bcm)
static void bcm43xx_periodic_every15sec(struct bcm43xx_private *bcm) static void bcm43xx_periodic_every15sec(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
if (phy->type == BCM43xx_PHYTYPE_G) { if (phy->type == BCM43xx_PHYTYPE_G) {
//TODO: update_aci_moving_average //TODO: update_aci_moving_average
...@@ -3170,9 +3165,9 @@ static void bcm43xx_free_board(struct bcm43xx_private *bcm) ...@@ -3170,9 +3165,9 @@ static void bcm43xx_free_board(struct bcm43xx_private *bcm)
bcm43xx_unlock(bcm, flags); bcm43xx_unlock(bcm, flags);
for (i = 0; i < BCM43xx_MAX_80211_CORES; i++) { for (i = 0; i < BCM43xx_MAX_80211_CORES; i++) {
if (!(bcm->core_80211[i].flags & BCM43xx_COREFLAG_AVAILABLE)) if (!bcm->core_80211[i].available)
continue; continue;
if (!(bcm->core_80211[i].flags & BCM43xx_COREFLAG_INITIALIZED)) if (!bcm->core_80211[i].initialized)
continue; continue;
err = bcm43xx_switch_core(bcm, &bcm->core_80211[i]); err = bcm43xx_switch_core(bcm, &bcm->core_80211[i]);
...@@ -3190,7 +3185,6 @@ static void bcm43xx_free_board(struct bcm43xx_private *bcm) ...@@ -3190,7 +3185,6 @@ static void bcm43xx_free_board(struct bcm43xx_private *bcm)
static int bcm43xx_init_board(struct bcm43xx_private *bcm) static int bcm43xx_init_board(struct bcm43xx_private *bcm)
{ {
int i, err; int i, err;
int num_80211_cores;
int connect_phy; int connect_phy;
unsigned long flags; unsigned long flags;
...@@ -3212,8 +3206,7 @@ static int bcm43xx_init_board(struct bcm43xx_private *bcm) ...@@ -3212,8 +3206,7 @@ static int bcm43xx_init_board(struct bcm43xx_private *bcm)
goto err_crystal_off; goto err_crystal_off;
tasklet_enable(&bcm->isr_tasklet); tasklet_enable(&bcm->isr_tasklet);
num_80211_cores = bcm43xx_num_80211_cores(bcm); for (i = 0; i < bcm->nr_80211_available; i++) {
for (i = 0; i < num_80211_cores; i++) {
err = bcm43xx_switch_core(bcm, &bcm->core_80211[i]); err = bcm43xx_switch_core(bcm, &bcm->core_80211[i]);
assert(err != -ENODEV); assert(err != -ENODEV);
if (err) if (err)
...@@ -3223,8 +3216,8 @@ static int bcm43xx_init_board(struct bcm43xx_private *bcm) ...@@ -3223,8 +3216,8 @@ static int bcm43xx_init_board(struct bcm43xx_private *bcm)
* Connect PHY only on the first core. * Connect PHY only on the first core.
*/ */
if (!bcm43xx_core_enabled(bcm)) { if (!bcm43xx_core_enabled(bcm)) {
if (num_80211_cores == 1) { if (bcm->nr_80211_available == 1) {
connect_phy = bcm->current_core->phy->connected; connect_phy = bcm43xx_current_phy(bcm)->connected;
} else { } else {
if (i == 0) if (i == 0)
connect_phy = 1; connect_phy = 1;
...@@ -3248,7 +3241,7 @@ static int bcm43xx_init_board(struct bcm43xx_private *bcm) ...@@ -3248,7 +3241,7 @@ static int bcm43xx_init_board(struct bcm43xx_private *bcm)
} }
} }
bcm->active_80211_core = &bcm->core_80211[0]; bcm->active_80211_core = &bcm->core_80211[0];
if (num_80211_cores >= 2) { if (bcm->nr_80211_available >= 2) {
bcm43xx_switch_core(bcm, &bcm->core_80211[0]); bcm43xx_switch_core(bcm, &bcm->core_80211[0]);
bcm43xx_mac_enable(bcm); bcm43xx_mac_enable(bcm);
} }
...@@ -3260,9 +3253,9 @@ static int bcm43xx_init_board(struct bcm43xx_private *bcm) ...@@ -3260,9 +3253,9 @@ static int bcm43xx_init_board(struct bcm43xx_private *bcm)
bcm43xx_pctl_set_clock(bcm, BCM43xx_PCTL_CLK_DYNAMIC); bcm43xx_pctl_set_clock(bcm, BCM43xx_PCTL_CLK_DYNAMIC);
if (bcm->current_core->radio->initial_channel != 0xFF) { if (bcm43xx_current_radio(bcm)->initial_channel != 0xFF) {
bcm43xx_mac_suspend(bcm); bcm43xx_mac_suspend(bcm);
bcm43xx_radio_selectchannel(bcm, bcm->current_core->radio->initial_channel, 0); bcm43xx_radio_selectchannel(bcm, bcm43xx_current_radio(bcm)->initial_channel, 0);
bcm43xx_mac_enable(bcm); bcm43xx_mac_enable(bcm);
} }
...@@ -3282,8 +3275,8 @@ static int bcm43xx_init_board(struct bcm43xx_private *bcm) ...@@ -3282,8 +3275,8 @@ static int bcm43xx_init_board(struct bcm43xx_private *bcm)
err_80211_unwind: err_80211_unwind:
tasklet_disable(&bcm->isr_tasklet); tasklet_disable(&bcm->isr_tasklet);
/* unwind all 80211 initialization */ /* unwind all 80211 initialization */
for (i = 0; i < num_80211_cores; i++) { for (i = 0; i < bcm->nr_80211_available; i++) {
if (!(bcm->core_80211[i].flags & BCM43xx_COREFLAG_INITIALIZED)) if (!bcm->core_80211[i].initialized)
continue; continue;
bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL); bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL);
bcm43xx_wireless_core_cleanup(bcm); bcm43xx_wireless_core_cleanup(bcm);
...@@ -3307,15 +3300,15 @@ static void bcm43xx_detach_board(struct bcm43xx_private *bcm) ...@@ -3307,15 +3300,15 @@ static void bcm43xx_detach_board(struct bcm43xx_private *bcm)
/* Free allocated structures/fields */ /* Free allocated structures/fields */
for (i = 0; i < BCM43xx_MAX_80211_CORES; i++) { for (i = 0; i < BCM43xx_MAX_80211_CORES; i++) {
kfree(bcm->phy[i]._lo_pairs); kfree(bcm->core_80211_ext[i].phy._lo_pairs);
if (bcm->phy[i].dyn_tssi_tbl) if (bcm->core_80211_ext[i].phy.dyn_tssi_tbl)
kfree(bcm->phy[i].tssi2dbm); kfree(bcm->core_80211_ext[i].phy.tssi2dbm);
} }
} }
static int bcm43xx_read_phyinfo(struct bcm43xx_private *bcm) static int bcm43xx_read_phyinfo(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
u16 value; u16 value;
u8 phy_version; u8 phy_version;
u8 phy_type; u8 phy_type;
...@@ -3393,7 +3386,6 @@ static int bcm43xx_attach_board(struct bcm43xx_private *bcm) ...@@ -3393,7 +3386,6 @@ static int bcm43xx_attach_board(struct bcm43xx_private *bcm)
int i; int i;
void __iomem *ioaddr; void __iomem *ioaddr;
unsigned long mmio_start, mmio_end, mmio_flags, mmio_len; unsigned long mmio_start, mmio_end, mmio_flags, mmio_len;
int num_80211_cores;
u32 coremask; u32 coremask;
err = pci_enable_device(pci_dev); err = pci_enable_device(pci_dev);
...@@ -3467,11 +3459,9 @@ static int bcm43xx_attach_board(struct bcm43xx_private *bcm) ...@@ -3467,11 +3459,9 @@ static int bcm43xx_attach_board(struct bcm43xx_private *bcm)
if (err) if (err)
goto err_chipset_detach; goto err_chipset_detach;
num_80211_cores = bcm43xx_num_80211_cores(bcm);
/* Attach all IO cores to the backplane. */ /* Attach all IO cores to the backplane. */
coremask = 0; coremask = 0;
for (i = 0; i < num_80211_cores; i++) for (i = 0; i < bcm->nr_80211_available; i++)
coremask |= (1 << bcm->core_80211[i].index); coremask |= (1 << bcm->core_80211[i].index);
//FIXME: Also attach some non80211 cores? //FIXME: Also attach some non80211 cores?
err = bcm43xx_setup_backplane_pci_connection(bcm, coremask); err = bcm43xx_setup_backplane_pci_connection(bcm, coremask);
...@@ -3487,7 +3477,7 @@ static int bcm43xx_attach_board(struct bcm43xx_private *bcm) ...@@ -3487,7 +3477,7 @@ static int bcm43xx_attach_board(struct bcm43xx_private *bcm)
if (err) if (err)
goto err_chipset_detach; goto err_chipset_detach;
for (i = 0; i < num_80211_cores; i++) { for (i = 0; i < bcm->nr_80211_available; i++) {
err = bcm43xx_switch_core(bcm, &bcm->core_80211[i]); err = bcm43xx_switch_core(bcm, &bcm->core_80211[i]);
assert(err != -ENODEV); assert(err != -ENODEV);
if (err) if (err)
...@@ -3519,7 +3509,7 @@ static int bcm43xx_attach_board(struct bcm43xx_private *bcm) ...@@ -3519,7 +3509,7 @@ static int bcm43xx_attach_board(struct bcm43xx_private *bcm)
bcm43xx_pctl_set_crystal(bcm, 0); bcm43xx_pctl_set_crystal(bcm, 0);
/* Set the MAC address in the networking subsystem */ /* Set the MAC address in the networking subsystem */
if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_A) if (bcm43xx_current_phy(bcm)->type == BCM43xx_PHYTYPE_A)
memcpy(bcm->net_dev->dev_addr, bcm->sprom.et1macaddr, 6); memcpy(bcm->net_dev->dev_addr, bcm->sprom.et1macaddr, 6);
else else
memcpy(bcm->net_dev->dev_addr, bcm->sprom.il0macaddr, 6); memcpy(bcm->net_dev->dev_addr, bcm->sprom.il0macaddr, 6);
...@@ -3535,9 +3525,9 @@ static int bcm43xx_attach_board(struct bcm43xx_private *bcm) ...@@ -3535,9 +3525,9 @@ static int bcm43xx_attach_board(struct bcm43xx_private *bcm)
err_80211_unwind: err_80211_unwind:
for (i = 0; i < BCM43xx_MAX_80211_CORES; i++) { for (i = 0; i < BCM43xx_MAX_80211_CORES; i++) {
kfree(bcm->phy[i]._lo_pairs); kfree(bcm->core_80211_ext[i].phy._lo_pairs);
if (bcm->phy[i].dyn_tssi_tbl) if (bcm->core_80211_ext[i].phy.dyn_tssi_tbl)
kfree(bcm->phy[i].tssi2dbm); kfree(bcm->core_80211_ext[i].phy.tssi2dbm);
} }
err_chipset_detach: err_chipset_detach:
bcm43xx_chipset_detach(bcm); bcm43xx_chipset_detach(bcm);
......
...@@ -80,7 +80,7 @@ static inline ...@@ -80,7 +80,7 @@ static inline
u8 bcm43xx_freq_to_channel(struct bcm43xx_private *bcm, u8 bcm43xx_freq_to_channel(struct bcm43xx_private *bcm,
int freq) int freq)
{ {
if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_A) if (bcm43xx_current_phy(bcm)->type == BCM43xx_PHYTYPE_A)
return bcm43xx_freq_to_channel_a(freq); return bcm43xx_freq_to_channel_a(freq);
return bcm43xx_freq_to_channel_bg(freq); return bcm43xx_freq_to_channel_bg(freq);
} }
...@@ -107,7 +107,7 @@ static inline ...@@ -107,7 +107,7 @@ static inline
int bcm43xx_channel_to_freq(struct bcm43xx_private *bcm, int bcm43xx_channel_to_freq(struct bcm43xx_private *bcm,
u8 channel) u8 channel)
{ {
if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_A) if (bcm43xx_current_phy(bcm)->type == BCM43xx_PHYTYPE_A)
return bcm43xx_channel_to_freq_a(channel); return bcm43xx_channel_to_freq_a(channel);
return bcm43xx_channel_to_freq_bg(channel); return bcm43xx_channel_to_freq_bg(channel);
} }
...@@ -129,7 +129,7 @@ static inline ...@@ -129,7 +129,7 @@ static inline
int bcm43xx_is_valid_channel(struct bcm43xx_private *bcm, int bcm43xx_is_valid_channel(struct bcm43xx_private *bcm,
u8 channel) u8 channel)
{ {
if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_A) if (bcm43xx_current_phy(bcm)->type == BCM43xx_PHYTYPE_A)
return bcm43xx_is_valid_channel_a(channel); return bcm43xx_is_valid_channel_a(channel);
return bcm43xx_is_valid_channel_bg(channel); return bcm43xx_is_valid_channel_bg(channel);
} }
......
...@@ -83,7 +83,7 @@ static void bcm43xx_phy_initg(struct bcm43xx_private *bcm); ...@@ -83,7 +83,7 @@ static void bcm43xx_phy_initg(struct bcm43xx_private *bcm);
void bcm43xx_raw_phy_lock(struct bcm43xx_private *bcm) void bcm43xx_raw_phy_lock(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
assert(irqs_disabled()); assert(irqs_disabled());
if (bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS_BITFIELD) == 0x00000000) { if (bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS_BITFIELD) == 0x00000000) {
...@@ -102,7 +102,7 @@ void bcm43xx_raw_phy_lock(struct bcm43xx_private *bcm) ...@@ -102,7 +102,7 @@ void bcm43xx_raw_phy_lock(struct bcm43xx_private *bcm)
void bcm43xx_raw_phy_unlock(struct bcm43xx_private *bcm) void bcm43xx_raw_phy_unlock(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
assert(irqs_disabled()); assert(irqs_disabled());
if (bcm->current_core->rev < 3) { if (bcm->current_core->rev < 3) {
...@@ -132,7 +132,7 @@ void bcm43xx_phy_write(struct bcm43xx_private *bcm, u16 offset, u16 val) ...@@ -132,7 +132,7 @@ void bcm43xx_phy_write(struct bcm43xx_private *bcm, u16 offset, u16 val)
void bcm43xx_phy_calibrate(struct bcm43xx_private *bcm) void bcm43xx_phy_calibrate(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
unsigned long flags; unsigned long flags;
bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS_BITFIELD); /* Dummy read. */ bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS_BITFIELD); /* Dummy read. */
...@@ -158,39 +158,32 @@ void bcm43xx_phy_calibrate(struct bcm43xx_private *bcm) ...@@ -158,39 +158,32 @@ void bcm43xx_phy_calibrate(struct bcm43xx_private *bcm)
*/ */
int bcm43xx_phy_connect(struct bcm43xx_private *bcm, int connect) int bcm43xx_phy_connect(struct bcm43xx_private *bcm, int connect)
{ {
struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
u32 flags; u32 flags;
if (bcm->current_core->rev < 5) { if (bcm->current_core->rev < 5)
if (connect) { goto out;
bcm->current_core->phy->connected = 1;
dprintk(KERN_INFO PFX "PHY connected\n");
} else {
bcm->current_core->phy->connected = 0;
dprintk(KERN_INFO PFX "PHY disconnected\n");
}
return 0;
}
flags = bcm43xx_read32(bcm, BCM43xx_CIR_SBTMSTATEHIGH); flags = bcm43xx_read32(bcm, BCM43xx_CIR_SBTMSTATEHIGH);
if (connect) { if (connect) {
if (!(flags & 0x00010000)) if (!(flags & 0x00010000))
return -ENODEV; return -ENODEV;
bcm->current_core->phy->connected = 1;
flags = bcm43xx_read32(bcm, BCM43xx_CIR_SBTMSTATELOW); flags = bcm43xx_read32(bcm, BCM43xx_CIR_SBTMSTATELOW);
flags |= (0x800 << 18); flags |= (0x800 << 18);
bcm43xx_write32(bcm, BCM43xx_CIR_SBTMSTATELOW, flags); bcm43xx_write32(bcm, BCM43xx_CIR_SBTMSTATELOW, flags);
dprintk(KERN_INFO PFX "PHY connected\n");
} else { } else {
if (!(flags & 0x00020000)) if (!(flags & 0x00020000))
return -ENODEV; return -ENODEV;
bcm->current_core->phy->connected = 0;
flags = bcm43xx_read32(bcm, BCM43xx_CIR_SBTMSTATELOW); flags = bcm43xx_read32(bcm, BCM43xx_CIR_SBTMSTATELOW);
flags &= ~(0x800 << 18); flags &= ~(0x800 << 18);
bcm43xx_write32(bcm, BCM43xx_CIR_SBTMSTATELOW, flags); bcm43xx_write32(bcm, BCM43xx_CIR_SBTMSTATELOW, flags);
dprintk(KERN_INFO PFX "PHY disconnected\n");
} }
out:
phy->connected = connect;
if (connect)
dprintk(KERN_INFO PFX "PHY connected\n");
else
dprintk(KERN_INFO PFX "PHY disconnected\n");
return 0; return 0;
} }
...@@ -200,8 +193,8 @@ int bcm43xx_phy_connect(struct bcm43xx_private *bcm, int connect) ...@@ -200,8 +193,8 @@ int bcm43xx_phy_connect(struct bcm43xx_private *bcm, int connect)
*/ */
static void bcm43xx_phy_init_pctl(struct bcm43xx_private *bcm) static void bcm43xx_phy_init_pctl(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
u16 saved_batt = 0, saved_ratt = 0, saved_txctl1 = 0; u16 saved_batt = 0, saved_ratt = 0, saved_txctl1 = 0;
int must_reset_txpower = 0; int must_reset_txpower = 0;
...@@ -250,7 +243,7 @@ static void bcm43xx_phy_init_pctl(struct bcm43xx_private *bcm) ...@@ -250,7 +243,7 @@ static void bcm43xx_phy_init_pctl(struct bcm43xx_private *bcm)
static void bcm43xx_phy_agcsetup(struct bcm43xx_private *bcm) static void bcm43xx_phy_agcsetup(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
u16 offset = 0x0000; u16 offset = 0x0000;
if (phy->rev == 1) if (phy->rev == 1)
...@@ -326,7 +319,7 @@ static void bcm43xx_phy_agcsetup(struct bcm43xx_private *bcm) ...@@ -326,7 +319,7 @@ static void bcm43xx_phy_agcsetup(struct bcm43xx_private *bcm)
static void bcm43xx_phy_setupg(struct bcm43xx_private *bcm) static void bcm43xx_phy_setupg(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
u16 i; u16 i;
assert(phy->type == BCM43xx_PHYTYPE_G); assert(phy->type == BCM43xx_PHYTYPE_G);
...@@ -420,7 +413,7 @@ static void bcm43xx_phy_setupg(struct bcm43xx_private *bcm) ...@@ -420,7 +413,7 @@ static void bcm43xx_phy_setupg(struct bcm43xx_private *bcm)
/* Initialize the noisescaletable for APHY */ /* Initialize the noisescaletable for APHY */
static void bcm43xx_phy_init_noisescaletbl(struct bcm43xx_private *bcm) static void bcm43xx_phy_init_noisescaletbl(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
int i; int i;
bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_A_CTRL, 0x1400); bcm43xx_phy_write(bcm, BCM43xx_PHY_ILT_A_CTRL, 0x1400);
...@@ -448,10 +441,11 @@ static void bcm43xx_phy_init_noisescaletbl(struct bcm43xx_private *bcm) ...@@ -448,10 +441,11 @@ static void bcm43xx_phy_init_noisescaletbl(struct bcm43xx_private *bcm)
static void bcm43xx_phy_setupa(struct bcm43xx_private *bcm) static void bcm43xx_phy_setupa(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
u16 i; u16 i;
assert(bcm->current_core->phy->type == BCM43xx_PHYTYPE_A); assert(phy->type == BCM43xx_PHYTYPE_A);
switch (bcm->current_core->phy->rev) { switch (phy->rev) {
case 2: case 2:
bcm43xx_phy_write(bcm, 0x008E, 0x3800); bcm43xx_phy_write(bcm, 0x008E, 0x3800);
bcm43xx_phy_write(bcm, 0x0035, 0x03FF); bcm43xx_phy_write(bcm, 0x0035, 0x03FF);
...@@ -563,7 +557,8 @@ static void bcm43xx_phy_setupa(struct bcm43xx_private *bcm) ...@@ -563,7 +557,8 @@ static void bcm43xx_phy_setupa(struct bcm43xx_private *bcm)
/* Initialize APHY. This is also called for the GPHY in some cases. */ /* Initialize APHY. This is also called for the GPHY in some cases. */
static void bcm43xx_phy_inita(struct bcm43xx_private *bcm) static void bcm43xx_phy_inita(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
u16 tval; u16 tval;
if (phy->type == BCM43xx_PHYTYPE_A) { if (phy->type == BCM43xx_PHYTYPE_A) {
...@@ -586,11 +581,11 @@ static void bcm43xx_phy_inita(struct bcm43xx_private *bcm) ...@@ -586,11 +581,11 @@ static void bcm43xx_phy_inita(struct bcm43xx_private *bcm)
if ((bcm->board_vendor == PCI_VENDOR_ID_BROADCOM) if ((bcm->board_vendor == PCI_VENDOR_ID_BROADCOM)
&& ((bcm->board_type == 0x0416) || (bcm->board_type == 0x040A))) { && ((bcm->board_type == 0x0416) || (bcm->board_type == 0x040A))) {
if (bcm->current_core->radio->lofcal == 0xFFFF) { if (radio->lofcal == 0xFFFF) {
TODO();//TODO: LOF Cal TODO();//TODO: LOF Cal
bcm43xx_radio_set_tx_iq(bcm); bcm43xx_radio_set_tx_iq(bcm);
} else } else
bcm43xx_radio_write16(bcm, 0x001E, bcm->current_core->radio->lofcal); bcm43xx_radio_write16(bcm, 0x001E, radio->lofcal);
} }
bcm43xx_phy_write(bcm, 0x007A, 0xF111); bcm43xx_phy_write(bcm, 0x007A, 0xF111);
...@@ -620,7 +615,7 @@ static void bcm43xx_phy_inita(struct bcm43xx_private *bcm) ...@@ -620,7 +615,7 @@ static void bcm43xx_phy_inita(struct bcm43xx_private *bcm)
static void bcm43xx_phy_initb2(struct bcm43xx_private *bcm) static void bcm43xx_phy_initb2(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
u16 offset, val; u16 offset, val;
bcm43xx_write16(bcm, 0x03EC, 0x3F22); bcm43xx_write16(bcm, 0x03EC, 0x3F22);
...@@ -671,7 +666,7 @@ static void bcm43xx_phy_initb2(struct bcm43xx_private *bcm) ...@@ -671,7 +666,7 @@ static void bcm43xx_phy_initb2(struct bcm43xx_private *bcm)
static void bcm43xx_phy_initb4(struct bcm43xx_private *bcm) static void bcm43xx_phy_initb4(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
u16 offset, val; u16 offset, val;
bcm43xx_write16(bcm, 0x03EC, 0x3F22); bcm43xx_write16(bcm, 0x03EC, 0x3F22);
...@@ -729,8 +724,8 @@ static void bcm43xx_phy_initb4(struct bcm43xx_private *bcm) ...@@ -729,8 +724,8 @@ static void bcm43xx_phy_initb4(struct bcm43xx_private *bcm)
static void bcm43xx_phy_initb5(struct bcm43xx_private *bcm) static void bcm43xx_phy_initb5(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
u16 offset; u16 offset;
if (phy->version == 1 && if (phy->version == 1 &&
...@@ -835,8 +830,8 @@ static void bcm43xx_phy_initb5(struct bcm43xx_private *bcm) ...@@ -835,8 +830,8 @@ static void bcm43xx_phy_initb5(struct bcm43xx_private *bcm)
static void bcm43xx_phy_initb6(struct bcm43xx_private *bcm) static void bcm43xx_phy_initb6(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
u16 offset, val; u16 offset, val;
bcm43xx_phy_write(bcm, 0x003E, 0x817A); bcm43xx_phy_write(bcm, 0x003E, 0x817A);
...@@ -946,9 +941,9 @@ static void bcm43xx_phy_initb6(struct bcm43xx_private *bcm) ...@@ -946,9 +941,9 @@ static void bcm43xx_phy_initb6(struct bcm43xx_private *bcm)
udelay(40); udelay(40);
bcm43xx_radio_write16(bcm, 0x007C, (bcm43xx_radio_read16(bcm, 0x007C) | 0x0002)); bcm43xx_radio_write16(bcm, 0x007C, (bcm43xx_radio_read16(bcm, 0x007C) | 0x0002));
bcm43xx_radio_write16(bcm, 0x0050, 0x0020); bcm43xx_radio_write16(bcm, 0x0050, 0x0020);
if ((bcm->current_core->radio->manufact == 0x17F) && if (radio->manufact == 0x17F &&
(bcm->current_core->radio->version == 0x2050) && radio->version == 0x2050 &&
(bcm->current_core->radio->revision <= 2)) { radio->revision <= 2) {
bcm43xx_radio_write16(bcm, 0x0050, 0x0020); bcm43xx_radio_write16(bcm, 0x0050, 0x0020);
bcm43xx_radio_write16(bcm, 0x005A, 0x0070); bcm43xx_radio_write16(bcm, 0x005A, 0x0070);
bcm43xx_radio_write16(bcm, 0x005B, 0x007B); bcm43xx_radio_write16(bcm, 0x005B, 0x007B);
...@@ -1001,8 +996,8 @@ static void bcm43xx_phy_initb6(struct bcm43xx_private *bcm) ...@@ -1001,8 +996,8 @@ static void bcm43xx_phy_initb6(struct bcm43xx_private *bcm)
static void bcm43xx_phy_initg(struct bcm43xx_private *bcm) static void bcm43xx_phy_initg(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
u16 tmp; u16 tmp;
if (phy->rev == 1) if (phy->rev == 1)
...@@ -1096,8 +1091,8 @@ static u16 bcm43xx_phy_lo_b_r15_loop(struct bcm43xx_private *bcm) ...@@ -1096,8 +1091,8 @@ static u16 bcm43xx_phy_lo_b_r15_loop(struct bcm43xx_private *bcm)
void bcm43xx_phy_lo_b_measure(struct bcm43xx_private *bcm) void bcm43xx_phy_lo_b_measure(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
u16 regstack[12] = { 0 }; u16 regstack[12] = { 0 };
u16 mls; u16 mls;
u16 fval; u16 fval;
...@@ -1190,7 +1185,9 @@ void bcm43xx_phy_lo_b_measure(struct bcm43xx_private *bcm) ...@@ -1190,7 +1185,9 @@ void bcm43xx_phy_lo_b_measure(struct bcm43xx_private *bcm)
static inline static inline
u16 bcm43xx_phy_lo_g_deviation_subval(struct bcm43xx_private *bcm, u16 control) u16 bcm43xx_phy_lo_g_deviation_subval(struct bcm43xx_private *bcm, u16 control)
{ {
if (bcm->current_core->phy->connected) { struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
if (phy->connected) {
bcm43xx_phy_write(bcm, 0x15, 0xE300); bcm43xx_phy_write(bcm, 0x15, 0xE300);
control <<= 8; control <<= 8;
bcm43xx_phy_write(bcm, 0x0812, control | 0x00B0); bcm43xx_phy_write(bcm, 0x0812, control | 0x00B0);
...@@ -1242,7 +1239,7 @@ void bcm43xx_lo_write(struct bcm43xx_private *bcm, ...@@ -1242,7 +1239,7 @@ void bcm43xx_lo_write(struct bcm43xx_private *bcm,
"WARNING: Writing invalid LOpair " "WARNING: Writing invalid LOpair "
"(low: %d, high: %d, index: %lu)\n", "(low: %d, high: %d, index: %lu)\n",
pair->low, pair->high, pair->low, pair->high,
(unsigned long)(pair - bcm->current_core->phy->_lo_pairs)); (unsigned long)(pair - bcm43xx_current_phy(bcm)->_lo_pairs));
dump_stack(); dump_stack();
} }
#endif #endif
...@@ -1257,7 +1254,7 @@ struct bcm43xx_lopair * bcm43xx_find_lopair(struct bcm43xx_private *bcm, ...@@ -1257,7 +1254,7 @@ struct bcm43xx_lopair * bcm43xx_find_lopair(struct bcm43xx_private *bcm,
u16 tx) u16 tx)
{ {
static const u8 dict[10] = { 11, 10, 11, 12, 13, 12, 13, 12, 13, 12 }; static const u8 dict[10] = { 11, 10, 11, 12, 13, 12, 13, 12, 13, 12 };
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
if (baseband_attenuation > 6) if (baseband_attenuation > 6)
baseband_attenuation = 6; baseband_attenuation = 6;
...@@ -1275,10 +1272,12 @@ struct bcm43xx_lopair * bcm43xx_find_lopair(struct bcm43xx_private *bcm, ...@@ -1275,10 +1272,12 @@ struct bcm43xx_lopair * bcm43xx_find_lopair(struct bcm43xx_private *bcm,
static inline static inline
struct bcm43xx_lopair * bcm43xx_current_lopair(struct bcm43xx_private *bcm) struct bcm43xx_lopair * bcm43xx_current_lopair(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
return bcm43xx_find_lopair(bcm, return bcm43xx_find_lopair(bcm,
bcm->current_core->radio->txpower[0], radio->txpower[0],
bcm->current_core->radio->txpower[1], radio->txpower[1],
bcm->current_core->radio->txpower[2]); radio->txpower[2]);
} }
/* Adjust B/G LO */ /* Adjust B/G LO */
...@@ -1294,9 +1293,9 @@ void bcm43xx_phy_lo_adjust(struct bcm43xx_private *bcm, int fixed) ...@@ -1294,9 +1293,9 @@ void bcm43xx_phy_lo_adjust(struct bcm43xx_private *bcm, int fixed)
bcm43xx_lo_write(bcm, pair); bcm43xx_lo_write(bcm, pair);
} }
static inline static void bcm43xx_phy_lo_g_measure_txctl2(struct bcm43xx_private *bcm)
void bcm43xx_phy_lo_g_measure_txctl2(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
u16 txctl2 = 0, i; u16 txctl2 = 0, i;
u32 smallest, tmp; u32 smallest, tmp;
...@@ -1312,7 +1311,7 @@ void bcm43xx_phy_lo_g_measure_txctl2(struct bcm43xx_private *bcm) ...@@ -1312,7 +1311,7 @@ void bcm43xx_phy_lo_g_measure_txctl2(struct bcm43xx_private *bcm)
txctl2 = i; txctl2 = i;
} }
} }
bcm->current_core->radio->txpower[3] = txctl2; radio->txpower[3] = txctl2;
} }
static static
...@@ -1402,16 +1401,17 @@ void bcm43xx_phy_lo_g_state(struct bcm43xx_private *bcm, ...@@ -1402,16 +1401,17 @@ void bcm43xx_phy_lo_g_state(struct bcm43xx_private *bcm,
void bcm43xx_phy_set_baseband_attenuation(struct bcm43xx_private *bcm, void bcm43xx_phy_set_baseband_attenuation(struct bcm43xx_private *bcm,
u16 baseband_attenuation) u16 baseband_attenuation)
{ {
struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
u16 value; u16 value;
if (bcm->current_core->phy->version == 0) { if (phy->version == 0) {
value = (bcm43xx_read16(bcm, 0x03E6) & 0xFFF0); value = (bcm43xx_read16(bcm, 0x03E6) & 0xFFF0);
value |= (baseband_attenuation & 0x000F); value |= (baseband_attenuation & 0x000F);
bcm43xx_write16(bcm, 0x03E6, value); bcm43xx_write16(bcm, 0x03E6, value);
return; return;
} }
if (bcm->current_core->phy->version > 1) { if (phy->version > 1) {
value = bcm43xx_phy_read(bcm, 0x0060) & ~0x003C; value = bcm43xx_phy_read(bcm, 0x0060) & ~0x003C;
value |= (baseband_attenuation << 2) & 0x003C; value |= (baseband_attenuation << 2) & 0x003C;
} else { } else {
...@@ -1426,8 +1426,8 @@ void bcm43xx_phy_lo_g_measure(struct bcm43xx_private *bcm) ...@@ -1426,8 +1426,8 @@ void bcm43xx_phy_lo_g_measure(struct bcm43xx_private *bcm)
{ {
static const u8 pairorder[10] = { 3, 1, 5, 7, 9, 2, 0, 4, 6, 8 }; static const u8 pairorder[10] = { 3, 1, 5, 7, 9, 2, 0, 4, 6, 8 };
const int is_initializing = bcm43xx_is_initializing(bcm); const int is_initializing = bcm43xx_is_initializing(bcm);
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
u16 h, i, oldi = 0, j; u16 h, i, oldi = 0, j;
struct bcm43xx_lopair control; struct bcm43xx_lopair control;
struct bcm43xx_lopair *tmp_control; struct bcm43xx_lopair *tmp_control;
...@@ -1653,7 +1653,7 @@ void bcm43xx_phy_lo_mark_current_used(struct bcm43xx_private *bcm) ...@@ -1653,7 +1653,7 @@ void bcm43xx_phy_lo_mark_current_used(struct bcm43xx_private *bcm)
void bcm43xx_phy_lo_mark_all_unused(struct bcm43xx_private *bcm) void bcm43xx_phy_lo_mark_all_unused(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
struct bcm43xx_lopair *pair; struct bcm43xx_lopair *pair;
int i; int i;
...@@ -1668,7 +1668,7 @@ void bcm43xx_phy_lo_mark_all_unused(struct bcm43xx_private *bcm) ...@@ -1668,7 +1668,7 @@ void bcm43xx_phy_lo_mark_all_unused(struct bcm43xx_private *bcm)
*/ */
static s8 bcm43xx_phy_estimate_power_out(struct bcm43xx_private *bcm, s8 tssi) static s8 bcm43xx_phy_estimate_power_out(struct bcm43xx_private *bcm, s8 tssi)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
s8 dbm = 0; s8 dbm = 0;
s32 tmp; s32 tmp;
...@@ -1698,8 +1698,8 @@ static s8 bcm43xx_phy_estimate_power_out(struct bcm43xx_private *bcm, s8 tssi) ...@@ -1698,8 +1698,8 @@ static s8 bcm43xx_phy_estimate_power_out(struct bcm43xx_private *bcm, s8 tssi)
/* http://bcm-specs.sipsolutions.net/RecalculateTransmissionPower */ /* http://bcm-specs.sipsolutions.net/RecalculateTransmissionPower */
void bcm43xx_phy_xmitpower(struct bcm43xx_private *bcm) void bcm43xx_phy_xmitpower(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
if (phy->savedpctlreg == 0xFFFF) if (phy->savedpctlreg == 0xFFFF)
return; return;
...@@ -1880,8 +1880,8 @@ s8 bcm43xx_tssi2dbm_entry(s8 entry [], u8 index, s16 pab0, s16 pab1, s16 pab2) ...@@ -1880,8 +1880,8 @@ s8 bcm43xx_tssi2dbm_entry(s8 entry [], u8 index, s16 pab0, s16 pab1, s16 pab2)
/* http://bcm-specs.sipsolutions.net/TSSI_to_DBM_Table */ /* http://bcm-specs.sipsolutions.net/TSSI_to_DBM_Table */
int bcm43xx_phy_init_tssi2dbm_table(struct bcm43xx_private *bcm) int bcm43xx_phy_init_tssi2dbm_table(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
s16 pab0, pab1, pab2; s16 pab0, pab1, pab2;
u8 idx; u8 idx;
s8 *dyn_tssi2dbm; s8 *dyn_tssi2dbm;
...@@ -1958,7 +1958,7 @@ int bcm43xx_phy_init_tssi2dbm_table(struct bcm43xx_private *bcm) ...@@ -1958,7 +1958,7 @@ int bcm43xx_phy_init_tssi2dbm_table(struct bcm43xx_private *bcm)
int bcm43xx_phy_init(struct bcm43xx_private *bcm) int bcm43xx_phy_init(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
int err = -ENODEV; int err = -ENODEV;
unsigned long flags; unsigned long flags;
...@@ -2008,7 +2008,7 @@ int bcm43xx_phy_init(struct bcm43xx_private *bcm) ...@@ -2008,7 +2008,7 @@ int bcm43xx_phy_init(struct bcm43xx_private *bcm)
void bcm43xx_phy_set_antenna_diversity(struct bcm43xx_private *bcm) void bcm43xx_phy_set_antenna_diversity(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
u16 antennadiv; u16 antennadiv;
u16 offset; u16 offset;
u16 value; u16 value;
......
...@@ -146,7 +146,7 @@ struct bcm43xx_pioqueue * parse_cookie(struct bcm43xx_private *bcm, ...@@ -146,7 +146,7 @@ struct bcm43xx_pioqueue * parse_cookie(struct bcm43xx_private *bcm,
u16 cookie, u16 cookie,
struct bcm43xx_pio_txpacket **packet) struct bcm43xx_pio_txpacket **packet)
{ {
struct bcm43xx_pio *pio = bcm->current_core->pio; struct bcm43xx_pio *pio = bcm43xx_current_pio(bcm);
struct bcm43xx_pioqueue *queue = NULL; struct bcm43xx_pioqueue *queue = NULL;
int packetindex; int packetindex;
...@@ -377,7 +377,7 @@ static void bcm43xx_destroy_pioqueue(struct bcm43xx_pioqueue *queue) ...@@ -377,7 +377,7 @@ static void bcm43xx_destroy_pioqueue(struct bcm43xx_pioqueue *queue)
void bcm43xx_pio_free(struct bcm43xx_private *bcm) void bcm43xx_pio_free(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_pio *pio = bcm->current_core->pio; struct bcm43xx_pio *pio = bcm43xx_current_pio(bcm);
bcm43xx_destroy_pioqueue(pio->queue3); bcm43xx_destroy_pioqueue(pio->queue3);
pio->queue3 = NULL; pio->queue3 = NULL;
...@@ -391,7 +391,7 @@ void bcm43xx_pio_free(struct bcm43xx_private *bcm) ...@@ -391,7 +391,7 @@ void bcm43xx_pio_free(struct bcm43xx_private *bcm)
int bcm43xx_pio_init(struct bcm43xx_private *bcm) int bcm43xx_pio_init(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_pio *pio = bcm->current_core->pio; struct bcm43xx_pio *pio = bcm43xx_current_pio(bcm);
struct bcm43xx_pioqueue *queue; struct bcm43xx_pioqueue *queue;
int err = -ENOMEM; int err = -ENOMEM;
...@@ -438,7 +438,7 @@ int bcm43xx_pio_init(struct bcm43xx_private *bcm) ...@@ -438,7 +438,7 @@ int bcm43xx_pio_init(struct bcm43xx_private *bcm)
int bcm43xx_pio_tx(struct bcm43xx_private *bcm, int bcm43xx_pio_tx(struct bcm43xx_private *bcm,
struct ieee80211_txb *txb) struct ieee80211_txb *txb)
{ {
struct bcm43xx_pioqueue *queue = bcm->current_core->pio->queue1; struct bcm43xx_pioqueue *queue = bcm43xx_current_pio(bcm)->queue1;
struct bcm43xx_pio_txpacket *packet; struct bcm43xx_pio_txpacket *packet;
u16 tmp; u16 tmp;
......
...@@ -114,8 +114,8 @@ void bcm43xx_radio_unlock(struct bcm43xx_private *bcm) ...@@ -114,8 +114,8 @@ void bcm43xx_radio_unlock(struct bcm43xx_private *bcm)
u16 bcm43xx_radio_read16(struct bcm43xx_private *bcm, u16 offset) u16 bcm43xx_radio_read16(struct bcm43xx_private *bcm, u16 offset)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
switch (phy->type) { switch (phy->type) {
case BCM43xx_PHYTYPE_A: case BCM43xx_PHYTYPE_A:
...@@ -151,7 +151,7 @@ void bcm43xx_radio_write16(struct bcm43xx_private *bcm, u16 offset, u16 val) ...@@ -151,7 +151,7 @@ void bcm43xx_radio_write16(struct bcm43xx_private *bcm, u16 offset, u16 val)
static void bcm43xx_set_all_gains(struct bcm43xx_private *bcm, static void bcm43xx_set_all_gains(struct bcm43xx_private *bcm,
s16 first, s16 second, s16 third) s16 first, s16 second, s16 third)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
u16 i; u16 i;
u16 start = 0x08, end = 0x18; u16 start = 0x08, end = 0x18;
u16 offset = 0x0400; u16 offset = 0x0400;
...@@ -183,7 +183,7 @@ static void bcm43xx_set_all_gains(struct bcm43xx_private *bcm, ...@@ -183,7 +183,7 @@ static void bcm43xx_set_all_gains(struct bcm43xx_private *bcm,
static void bcm43xx_set_original_gains(struct bcm43xx_private *bcm) static void bcm43xx_set_original_gains(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
u16 i, tmp; u16 i, tmp;
u16 offset = 0x0400; u16 offset = 0x0400;
u16 start = 0x0008, end = 0x0018; u16 start = 0x0008, end = 0x0018;
...@@ -217,7 +217,7 @@ static void bcm43xx_set_original_gains(struct bcm43xx_private *bcm) ...@@ -217,7 +217,7 @@ static void bcm43xx_set_original_gains(struct bcm43xx_private *bcm)
/* Synthetic PU workaround */ /* Synthetic PU workaround */
static void bcm43xx_synth_pu_workaround(struct bcm43xx_private *bcm, u8 channel) static void bcm43xx_synth_pu_workaround(struct bcm43xx_private *bcm, u8 channel)
{ {
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
if (radio->version != 0x2050 || radio->revision >= 6) { if (radio->version != 0x2050 || radio->revision >= 6) {
/* We do not need the workaround. */ /* We do not need the workaround. */
...@@ -238,7 +238,7 @@ static void bcm43xx_synth_pu_workaround(struct bcm43xx_private *bcm, u8 channel) ...@@ -238,7 +238,7 @@ static void bcm43xx_synth_pu_workaround(struct bcm43xx_private *bcm, u8 channel)
u8 bcm43xx_radio_aci_detect(struct bcm43xx_private *bcm, u8 channel) u8 bcm43xx_radio_aci_detect(struct bcm43xx_private *bcm, u8 channel)
{ {
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
u8 ret = 0; u8 ret = 0;
u16 saved, rssi, temp; u16 saved, rssi, temp;
int i, j = 0; int i, j = 0;
...@@ -269,8 +269,8 @@ u8 bcm43xx_radio_aci_detect(struct bcm43xx_private *bcm, u8 channel) ...@@ -269,8 +269,8 @@ u8 bcm43xx_radio_aci_detect(struct bcm43xx_private *bcm, u8 channel)
u8 bcm43xx_radio_aci_scan(struct bcm43xx_private *bcm) u8 bcm43xx_radio_aci_scan(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
u8 ret[13]; u8 ret[13];
unsigned int channel = radio->channel; unsigned int channel = radio->channel;
unsigned int i, j, start, end; unsigned int i, j, start, end;
...@@ -351,22 +351,23 @@ void bcm43xx_nrssi_hw_update(struct bcm43xx_private *bcm, u16 val) ...@@ -351,22 +351,23 @@ void bcm43xx_nrssi_hw_update(struct bcm43xx_private *bcm, u16 val)
/* http://bcm-specs.sipsolutions.net/NRSSILookupTable */ /* http://bcm-specs.sipsolutions.net/NRSSILookupTable */
void bcm43xx_nrssi_mem_update(struct bcm43xx_private *bcm) void bcm43xx_nrssi_mem_update(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
s16 i, delta; s16 i, delta;
s32 tmp; s32 tmp;
delta = 0x1F - bcm->current_core->radio->nrssi[0]; delta = 0x1F - radio->nrssi[0];
for (i = 0; i < 64; i++) { for (i = 0; i < 64; i++) {
tmp = (i - delta) * bcm->current_core->radio->nrssislope; tmp = (i - delta) * radio->nrssislope;
tmp /= 0x10000; tmp /= 0x10000;
tmp += 0x3A; tmp += 0x3A;
tmp = limit_value(tmp, 0, 0x3F); tmp = limit_value(tmp, 0, 0x3F);
bcm->current_core->radio->nrssi_lt[i] = tmp; radio->nrssi_lt[i] = tmp;
} }
} }
static void bcm43xx_calc_nrssi_offset(struct bcm43xx_private *bcm) static void bcm43xx_calc_nrssi_offset(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
u16 backup[20] = { 0 }; u16 backup[20] = { 0 };
s16 v47F; s16 v47F;
u16 i; u16 i;
...@@ -531,8 +532,8 @@ static void bcm43xx_calc_nrssi_offset(struct bcm43xx_private *bcm) ...@@ -531,8 +532,8 @@ static void bcm43xx_calc_nrssi_offset(struct bcm43xx_private *bcm)
void bcm43xx_calc_nrssi_slope(struct bcm43xx_private *bcm) void bcm43xx_calc_nrssi_slope(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
u16 backup[18] = { 0 }; u16 backup[18] = { 0 };
u16 tmp; u16 tmp;
s16 nrssi0, nrssi1; s16 nrssi0, nrssi1;
...@@ -779,8 +780,8 @@ void bcm43xx_calc_nrssi_slope(struct bcm43xx_private *bcm) ...@@ -779,8 +780,8 @@ void bcm43xx_calc_nrssi_slope(struct bcm43xx_private *bcm)
void bcm43xx_calc_nrssi_threshold(struct bcm43xx_private *bcm) void bcm43xx_calc_nrssi_threshold(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
s16 threshold; s16 threshold;
s32 a, b; s32 a, b;
int tmp; int tmp;
...@@ -804,7 +805,7 @@ void bcm43xx_calc_nrssi_threshold(struct bcm43xx_private *bcm) ...@@ -804,7 +805,7 @@ void bcm43xx_calc_nrssi_threshold(struct bcm43xx_private *bcm)
radiotype = 1; radiotype = 1;
if (radiotype == 1) { if (radiotype == 1) {
threshold = bcm->current_core->radio->nrssi[1] - 5; threshold = radio->nrssi[1] - 5;
} else { } else {
threshold = 40 * radio->nrssi[0]; threshold = 40 * radio->nrssi[0];
threshold += 33 * (radio->nrssi[1] - radio->nrssi[0]); threshold += 33 * (radio->nrssi[1] - radio->nrssi[0]);
...@@ -901,8 +902,8 @@ static void ...@@ -901,8 +902,8 @@ static void
bcm43xx_radio_interference_mitigation_enable(struct bcm43xx_private *bcm, bcm43xx_radio_interference_mitigation_enable(struct bcm43xx_private *bcm,
int mode) int mode)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
int i = 0; int i = 0;
u16 *stack = radio->interfstack; u16 *stack = radio->interfstack;
u16 tmp, flipped; u16 tmp, flipped;
...@@ -1052,8 +1053,8 @@ static void ...@@ -1052,8 +1053,8 @@ static void
bcm43xx_radio_interference_mitigation_disable(struct bcm43xx_private *bcm, bcm43xx_radio_interference_mitigation_disable(struct bcm43xx_private *bcm,
int mode) int mode)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
int i = 0; int i = 0;
u16 *stack = radio->interfstack; u16 *stack = radio->interfstack;
u16 tmp, flipped; u16 tmp, flipped;
...@@ -1142,8 +1143,8 @@ bcm43xx_radio_interference_mitigation_disable(struct bcm43xx_private *bcm, ...@@ -1142,8 +1143,8 @@ bcm43xx_radio_interference_mitigation_disable(struct bcm43xx_private *bcm,
int bcm43xx_radio_set_interference_mitigation(struct bcm43xx_private *bcm, int bcm43xx_radio_set_interference_mitigation(struct bcm43xx_private *bcm,
int mode) int mode)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
int currentmode; int currentmode;
if ((phy->type != BCM43xx_PHYTYPE_G) || if ((phy->type != BCM43xx_PHYTYPE_G) ||
...@@ -1199,8 +1200,8 @@ u16 bcm43xx_radio_calibrationvalue(struct bcm43xx_private *bcm) ...@@ -1199,8 +1200,8 @@ u16 bcm43xx_radio_calibrationvalue(struct bcm43xx_private *bcm)
u16 bcm43xx_radio_init2050(struct bcm43xx_private *bcm) u16 bcm43xx_radio_init2050(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
u16 backup[19] = { 0 }; u16 backup[19] = { 0 };
u16 ret; u16 ret;
u16 i, j; u16 i, j;
...@@ -1444,7 +1445,7 @@ int bcm43xx_radio_selectchannel(struct bcm43xx_private *bcm, ...@@ -1444,7 +1445,7 @@ int bcm43xx_radio_selectchannel(struct bcm43xx_private *bcm,
u8 channel, u8 channel,
int synthetic_pu_workaround) int synthetic_pu_workaround)
{ {
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
u16 r8, tmp; u16 r8, tmp;
u16 freq; u16 freq;
...@@ -1628,6 +1629,7 @@ static u16 bcm43xx_get_txgain_dac(u16 txpower) ...@@ -1628,6 +1629,7 @@ static u16 bcm43xx_get_txgain_dac(u16 txpower)
void bcm43xx_radio_set_txpower_a(struct bcm43xx_private *bcm, u16 txpower) void bcm43xx_radio_set_txpower_a(struct bcm43xx_private *bcm, u16 txpower)
{ {
struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
u16 pamp, base, dac, ilt; u16 pamp, base, dac, ilt;
txpower = limit_value(txpower, 0, 63); txpower = limit_value(txpower, 0, 63);
...@@ -1650,7 +1652,7 @@ void bcm43xx_radio_set_txpower_a(struct bcm43xx_private *bcm, u16 txpower) ...@@ -1650,7 +1652,7 @@ void bcm43xx_radio_set_txpower_a(struct bcm43xx_private *bcm, u16 txpower)
bcm43xx_ilt_write(bcm, 0x3001, dac); bcm43xx_ilt_write(bcm, 0x3001, dac);
bcm->current_core->radio->txpower[0] = txpower; radio->txpower[0] = txpower;
TODO(); TODO();
//TODO: FuncPlaceholder (Adjust BB loft cancel) //TODO: FuncPlaceholder (Adjust BB loft cancel)
...@@ -1660,8 +1662,8 @@ void bcm43xx_radio_set_txpower_bg(struct bcm43xx_private *bcm, ...@@ -1660,8 +1662,8 @@ void bcm43xx_radio_set_txpower_bg(struct bcm43xx_private *bcm,
u16 baseband_attenuation, u16 radio_attenuation, u16 baseband_attenuation, u16 radio_attenuation,
u16 txpower) u16 txpower)
{ {
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
if (baseband_attenuation == 0xFFFF) if (baseband_attenuation == 0xFFFF)
baseband_attenuation = radio->txpower[0]; baseband_attenuation = radio->txpower[0];
...@@ -1698,8 +1700,8 @@ void bcm43xx_radio_set_txpower_bg(struct bcm43xx_private *bcm, ...@@ -1698,8 +1700,8 @@ void bcm43xx_radio_set_txpower_bg(struct bcm43xx_private *bcm,
void bcm43xx_radio_turn_on(struct bcm43xx_private *bcm) void bcm43xx_radio_turn_on(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
int err; int err;
if (radio->enabled) if (radio->enabled)
...@@ -1730,8 +1732,8 @@ void bcm43xx_radio_turn_on(struct bcm43xx_private *bcm) ...@@ -1730,8 +1732,8 @@ void bcm43xx_radio_turn_on(struct bcm43xx_private *bcm)
void bcm43xx_radio_turn_off(struct bcm43xx_private *bcm) void bcm43xx_radio_turn_off(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
if (phy->type == BCM43xx_PHYTYPE_A) { if (phy->type == BCM43xx_PHYTYPE_A) {
bcm43xx_radio_write16(bcm, 0x0004, 0x00FF); bcm43xx_radio_write16(bcm, 0x0004, 0x00FF);
...@@ -1750,7 +1752,9 @@ void bcm43xx_radio_turn_off(struct bcm43xx_private *bcm) ...@@ -1750,7 +1752,9 @@ void bcm43xx_radio_turn_off(struct bcm43xx_private *bcm)
void bcm43xx_radio_clear_tssi(struct bcm43xx_private *bcm) void bcm43xx_radio_clear_tssi(struct bcm43xx_private *bcm)
{ {
switch (bcm->current_core->phy->type) { struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
switch (phy->type) {
case BCM43xx_PHYTYPE_A: case BCM43xx_PHYTYPE_A:
bcm43xx_shm_write16(bcm, BCM43xx_SHM_SHARED, 0x0068, 0x7F7F); bcm43xx_shm_write16(bcm, BCM43xx_SHM_SHARED, 0x0068, 0x7F7F);
bcm43xx_shm_write16(bcm, BCM43xx_SHM_SHARED, 0x006a, 0x7F7F); bcm43xx_shm_write16(bcm, BCM43xx_SHM_SHARED, 0x006a, 0x7F7F);
......
...@@ -150,7 +150,7 @@ static ssize_t bcm43xx_attr_interfmode_show(struct device *dev, ...@@ -150,7 +150,7 @@ static ssize_t bcm43xx_attr_interfmode_show(struct device *dev,
bcm43xx_lock(bcm, flags); bcm43xx_lock(bcm, flags);
assert(bcm->initialized); assert(bcm->initialized);
switch (bcm->current_core->radio->interfmode) { switch (bcm43xx_current_radio(bcm)->interfmode) {
case BCM43xx_RADIO_INTERFMODE_NONE: case BCM43xx_RADIO_INTERFMODE_NONE:
count = snprintf(buf, PAGE_SIZE, "0 (No Interference Mitigation)\n"); count = snprintf(buf, PAGE_SIZE, "0 (No Interference Mitigation)\n");
break; break;
......
...@@ -56,15 +56,14 @@ static int bcm43xx_wx_get_name(struct net_device *net_dev, ...@@ -56,15 +56,14 @@ static int bcm43xx_wx_get_name(struct net_device *net_dev,
{ {
struct bcm43xx_private *bcm = bcm43xx_priv(net_dev); struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
unsigned long flags; unsigned long flags;
int i, nr_80211; int i;
struct bcm43xx_phyinfo *phy; struct bcm43xx_phyinfo *phy;
char suffix[7] = { 0 }; char suffix[7] = { 0 };
int have_a = 0, have_b = 0, have_g = 0; int have_a = 0, have_b = 0, have_g = 0;
bcm43xx_lock(bcm, flags); bcm43xx_lock(bcm, flags);
nr_80211 = bcm43xx_num_80211_cores(bcm); for (i = 0; i < bcm->nr_80211_available; i++) {
for (i = 0; i < nr_80211; i++) { phy = &(bcm->core_80211_ext[i].phy);
phy = bcm->phy + i;
switch (phy->type) { switch (phy->type) {
case BCM43xx_PHYTYPE_A: case BCM43xx_PHYTYPE_A:
have_a = 1; have_a = 1;
...@@ -129,7 +128,7 @@ static int bcm43xx_wx_set_channelfreq(struct net_device *net_dev, ...@@ -129,7 +128,7 @@ static int bcm43xx_wx_set_channelfreq(struct net_device *net_dev,
err = bcm43xx_radio_selectchannel(bcm, channel, 0); err = bcm43xx_radio_selectchannel(bcm, channel, 0);
bcm43xx_mac_enable(bcm); bcm43xx_mac_enable(bcm);
} else { } else {
bcm->current_core->radio->initial_channel = channel; bcm43xx_current_radio(bcm)->initial_channel = channel;
err = 0; err = 0;
} }
out_unlock: out_unlock:
...@@ -144,15 +143,17 @@ static int bcm43xx_wx_get_channelfreq(struct net_device *net_dev, ...@@ -144,15 +143,17 @@ static int bcm43xx_wx_get_channelfreq(struct net_device *net_dev,
char *extra) char *extra)
{ {
struct bcm43xx_private *bcm = bcm43xx_priv(net_dev); struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
struct bcm43xx_radioinfo *radio;
unsigned long flags; unsigned long flags;
int err = -ENODEV; int err = -ENODEV;
u16 channel; u16 channel;
bcm43xx_lock(bcm, flags); bcm43xx_lock(bcm, flags);
channel = bcm->current_core->radio->channel; radio = bcm43xx_current_radio(bcm);
channel = radio->channel;
if (channel == 0xFF) { if (channel == 0xFF) {
assert(!bcm->initialized); assert(!bcm->initialized);
channel = bcm->current_core->radio->initial_channel; channel = radio->initial_channel;
if (channel == 0xFF) if (channel == 0xFF)
goto out_unlock; goto out_unlock;
} }
...@@ -232,6 +233,7 @@ static int bcm43xx_wx_get_rangeparams(struct net_device *net_dev, ...@@ -232,6 +233,7 @@ static int bcm43xx_wx_get_rangeparams(struct net_device *net_dev,
const struct ieee80211_geo *geo; const struct ieee80211_geo *geo;
unsigned long flags; unsigned long flags;
int i, j; int i, j;
struct bcm43xx_phyinfo *phy;
data->data.length = sizeof(*range); data->data.length = sizeof(*range);
memset(range, 0, sizeof(*range)); memset(range, 0, sizeof(*range));
...@@ -270,11 +272,12 @@ static int bcm43xx_wx_get_rangeparams(struct net_device *net_dev, ...@@ -270,11 +272,12 @@ static int bcm43xx_wx_get_rangeparams(struct net_device *net_dev,
IW_ENC_CAPA_CIPHER_CCMP; IW_ENC_CAPA_CIPHER_CCMP;
bcm43xx_lock(bcm, flags); bcm43xx_lock(bcm, flags);
phy = bcm43xx_current_phy(bcm);
range->num_bitrates = 0; range->num_bitrates = 0;
i = 0; i = 0;
if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_A || if (phy->type == BCM43xx_PHYTYPE_A ||
bcm->current_core->phy->type == BCM43xx_PHYTYPE_G) { phy->type == BCM43xx_PHYTYPE_G) {
range->num_bitrates = 8; range->num_bitrates = 8;
range->bitrate[i++] = IEEE80211_OFDM_RATE_6MB; range->bitrate[i++] = IEEE80211_OFDM_RATE_6MB;
range->bitrate[i++] = IEEE80211_OFDM_RATE_9MB; range->bitrate[i++] = IEEE80211_OFDM_RATE_9MB;
...@@ -285,8 +288,8 @@ static int bcm43xx_wx_get_rangeparams(struct net_device *net_dev, ...@@ -285,8 +288,8 @@ static int bcm43xx_wx_get_rangeparams(struct net_device *net_dev,
range->bitrate[i++] = IEEE80211_OFDM_RATE_48MB; range->bitrate[i++] = IEEE80211_OFDM_RATE_48MB;
range->bitrate[i++] = IEEE80211_OFDM_RATE_54MB; range->bitrate[i++] = IEEE80211_OFDM_RATE_54MB;
} }
if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_B || if (phy->type == BCM43xx_PHYTYPE_B ||
bcm->current_core->phy->type == BCM43xx_PHYTYPE_G) { phy->type == BCM43xx_PHYTYPE_G) {
range->num_bitrates += 4; range->num_bitrates += 4;
range->bitrate[i++] = IEEE80211_CCK_RATE_1MB; range->bitrate[i++] = IEEE80211_CCK_RATE_1MB;
range->bitrate[i++] = IEEE80211_CCK_RATE_2MB; range->bitrate[i++] = IEEE80211_CCK_RATE_2MB;
...@@ -461,8 +464,8 @@ static int bcm43xx_wx_set_xmitpower(struct net_device *net_dev, ...@@ -461,8 +464,8 @@ static int bcm43xx_wx_set_xmitpower(struct net_device *net_dev,
bcm43xx_lock_mmio(bcm, flags); bcm43xx_lock_mmio(bcm, flags);
if (!bcm->initialized) if (!bcm->initialized)
goto out_unlock; goto out_unlock;
radio = bcm->current_core->radio; radio = bcm43xx_current_radio(bcm);
phy = bcm->current_core->phy; phy = bcm43xx_current_phy(bcm);
if (data->txpower.disabled != (!(radio->enabled))) { if (data->txpower.disabled != (!(radio->enabled))) {
if (data->txpower.disabled) if (data->txpower.disabled)
bcm43xx_radio_turn_off(bcm); bcm43xx_radio_turn_off(bcm);
...@@ -500,7 +503,7 @@ static int bcm43xx_wx_get_xmitpower(struct net_device *net_dev, ...@@ -500,7 +503,7 @@ static int bcm43xx_wx_get_xmitpower(struct net_device *net_dev,
bcm43xx_lock(bcm, flags); bcm43xx_lock(bcm, flags);
if (!bcm->initialized) if (!bcm->initialized)
goto out_unlock; goto out_unlock;
radio = bcm->current_core->radio; radio = bcm43xx_current_radio(bcm);
/* desired dBm value is in Q5.2 */ /* desired dBm value is in Q5.2 */
data->txpower.value = radio->txpower_desired >> 2; data->txpower.value = radio->txpower_desired >> 2;
data->txpower.fixed = 1; data->txpower.fixed = 1;
...@@ -645,7 +648,7 @@ static int bcm43xx_wx_set_interfmode(struct net_device *net_dev, ...@@ -645,7 +648,7 @@ static int bcm43xx_wx_set_interfmode(struct net_device *net_dev,
"not supported while the interface is down.\n"); "not supported while the interface is down.\n");
err = -ENODEV; err = -ENODEV;
} else } else
bcm->current_core->radio->interfmode = mode; bcm43xx_current_radio(bcm)->interfmode = mode;
} }
bcm43xx_unlock_mmio(bcm, flags); bcm43xx_unlock_mmio(bcm, flags);
...@@ -662,7 +665,7 @@ static int bcm43xx_wx_get_interfmode(struct net_device *net_dev, ...@@ -662,7 +665,7 @@ static int bcm43xx_wx_get_interfmode(struct net_device *net_dev,
int mode; int mode;
bcm43xx_lock(bcm, flags); bcm43xx_lock(bcm, flags);
mode = bcm->current_core->radio->interfmode; mode = bcm43xx_current_radio(bcm)->interfmode;
bcm43xx_unlock(bcm, flags); bcm43xx_unlock(bcm, flags);
switch (mode) { switch (mode) {
......
...@@ -284,7 +284,7 @@ void bcm43xx_generate_txhdr(struct bcm43xx_private *bcm, ...@@ -284,7 +284,7 @@ void bcm43xx_generate_txhdr(struct bcm43xx_private *bcm,
const int is_first_fragment, const int is_first_fragment,
const u16 cookie) const u16 cookie)
{ {
const struct bcm43xx_phyinfo *phy = bcm->current_core->phy; const struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
const struct ieee80211_hdr_4addr *wireless_header = (const struct ieee80211_hdr_4addr *)fragment_data; const struct ieee80211_hdr_4addr *wireless_header = (const struct ieee80211_hdr_4addr *)fragment_data;
const struct ieee80211_security *secinfo = &bcm->ieee->sec; const struct ieee80211_security *secinfo = &bcm->ieee->sec;
u8 bitrate; u8 bitrate;
...@@ -382,8 +382,8 @@ static s8 bcm43xx_rssi_postprocess(struct bcm43xx_private *bcm, ...@@ -382,8 +382,8 @@ static s8 bcm43xx_rssi_postprocess(struct bcm43xx_private *bcm,
u8 in_rssi, int ofdm, u8 in_rssi, int ofdm,
int adjust_2053, int adjust_2050) int adjust_2053, int adjust_2050)
{ {
struct bcm43xx_radioinfo *radio = bcm->current_core->radio; struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
s32 tmp; s32 tmp;
switch (radio->version) { switch (radio->version) {
...@@ -442,7 +442,7 @@ static s8 bcm43xx_rssi_postprocess(struct bcm43xx_private *bcm, ...@@ -442,7 +442,7 @@ static s8 bcm43xx_rssi_postprocess(struct bcm43xx_private *bcm,
static s8 bcm43xx_rssinoise_postprocess(struct bcm43xx_private *bcm, static s8 bcm43xx_rssinoise_postprocess(struct bcm43xx_private *bcm,
u8 in_rssi) u8 in_rssi)
{ {
struct bcm43xx_phyinfo *phy = bcm->current_core->phy; struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
s8 ret; s8 ret;
if (phy->type == BCM43xx_PHYTYPE_A) { if (phy->type == BCM43xx_PHYTYPE_A) {
...@@ -458,6 +458,8 @@ int bcm43xx_rx(struct bcm43xx_private *bcm, ...@@ -458,6 +458,8 @@ int bcm43xx_rx(struct bcm43xx_private *bcm,
struct sk_buff *skb, struct sk_buff *skb,
struct bcm43xx_rxhdr *rxhdr) struct bcm43xx_rxhdr *rxhdr)
{ {
struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
struct bcm43xx_plcp_hdr4 *plcp; struct bcm43xx_plcp_hdr4 *plcp;
struct ieee80211_rx_stats stats; struct ieee80211_rx_stats stats;
struct ieee80211_hdr_4addr *wlhdr; struct ieee80211_hdr_4addr *wlhdr;
...@@ -494,13 +496,13 @@ int bcm43xx_rx(struct bcm43xx_private *bcm, ...@@ -494,13 +496,13 @@ int bcm43xx_rx(struct bcm43xx_private *bcm,
else else
stats.rate = bcm43xx_plcp_get_bitrate_cck(plcp); stats.rate = bcm43xx_plcp_get_bitrate_cck(plcp);
//printk("RX ofdm %d, rate == %u\n", is_ofdm, stats.rate); //printk("RX ofdm %d, rate == %u\n", is_ofdm, stats.rate);
stats.received_channel = bcm->current_core->radio->channel; stats.received_channel = radio->channel;
//TODO stats.control = //TODO stats.control =
stats.mask = IEEE80211_STATMASK_SIGNAL | stats.mask = IEEE80211_STATMASK_SIGNAL |
//TODO IEEE80211_STATMASK_NOISE | //TODO IEEE80211_STATMASK_NOISE |
IEEE80211_STATMASK_RATE | IEEE80211_STATMASK_RATE |
IEEE80211_STATMASK_RSSI; IEEE80211_STATMASK_RSSI;
if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_A) if (phy->type == BCM43xx_PHYTYPE_A)
stats.freq = IEEE80211_52GHZ_BAND; stats.freq = IEEE80211_52GHZ_BAND;
else else
stats.freq = IEEE80211_24GHZ_BAND; stats.freq = IEEE80211_24GHZ_BAND;
......
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