Commit 96c755a3 authored by Michael Buesch's avatar Michael Buesch Committed by David S. Miller

b43: Fix any N-PHY related WARN_ON() in the attach stage.

This fixes all WARN_ON()s in the attach stage.
Signed-off-by: default avatarMichael Buesch <mb@bu3sch.de>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent d5c71e46
...@@ -328,17 +328,22 @@ enum { ...@@ -328,17 +328,22 @@ enum {
#define B43_MACCMD_CCA 0x00000008 /* Clear channel assessment */ #define B43_MACCMD_CCA 0x00000008 /* Clear channel assessment */
#define B43_MACCMD_BGNOISE 0x00000010 /* Background noise */ #define B43_MACCMD_BGNOISE 0x00000010 /* Background noise */
/* 802.11 core specific TM State Low flags */ /* 802.11 core specific TM State Low (SSB_TMSLOW) flags */
#define B43_TMSLOW_GMODE 0x20000000 /* G Mode Enable */ #define B43_TMSLOW_GMODE 0x20000000 /* G Mode Enable */
#define B43_TMSLOW_PLLREFSEL 0x00200000 /* PLL Frequency Reference Select */ #define B43_TMSLOW_PHYCLKSPEED 0x00C00000 /* PHY clock speed mask (N-PHY only) */
#define B43_TMSLOW_PHYCLKSPEED_40MHZ 0x00000000 /* 40 MHz PHY */
#define B43_TMSLOW_PHYCLKSPEED_80MHZ 0x00400000 /* 80 MHz PHY */
#define B43_TMSLOW_PHYCLKSPEED_160MHZ 0x00800000 /* 160 MHz PHY */
#define B43_TMSLOW_PLLREFSEL 0x00200000 /* PLL Frequency Reference Select (rev >= 5) */
#define B43_TMSLOW_MACPHYCLKEN 0x00100000 /* MAC PHY Clock Control Enable (rev >= 5) */ #define B43_TMSLOW_MACPHYCLKEN 0x00100000 /* MAC PHY Clock Control Enable (rev >= 5) */
#define B43_TMSLOW_PHYRESET 0x00080000 /* PHY Reset */ #define B43_TMSLOW_PHYRESET 0x00080000 /* PHY Reset */
#define B43_TMSLOW_PHYCLKEN 0x00040000 /* PHY Clock Enable */ #define B43_TMSLOW_PHYCLKEN 0x00040000 /* PHY Clock Enable */
/* 802.11 core specific TM State High flags */ /* 802.11 core specific TM State High (SSB_TMSHIGH) flags */
#define B43_TMSHIGH_DUALBAND_PHY 0x00080000 /* Dualband PHY available */
#define B43_TMSHIGH_FCLOCK 0x00040000 /* Fast Clock Available (rev >= 5) */ #define B43_TMSHIGH_FCLOCK 0x00040000 /* Fast Clock Available (rev >= 5) */
#define B43_TMSHIGH_APHY 0x00020000 /* A-PHY available (rev >= 5) */ #define B43_TMSHIGH_HAVE_5GHZ_PHY 0x00020000 /* 5 GHz PHY available (rev >= 5) */
#define B43_TMSHIGH_GPHY 0x00010000 /* G-PHY available (rev >= 5) */ #define B43_TMSHIGH_HAVE_2GHZ_PHY 0x00010000 /* 2.4 GHz PHY available (rev >= 5) */
/* Generic-Interrupt reasons. */ /* Generic-Interrupt reasons. */
#define B43_IRQ_MAC_SUSPENDED 0x00000001 #define B43_IRQ_MAC_SUSPENDED 0x00000001
......
...@@ -132,7 +132,7 @@ static struct ieee80211_rate __b43_ratetable[] = { ...@@ -132,7 +132,7 @@ static struct ieee80211_rate __b43_ratetable[] = {
.power_level = 0xFF, \ .power_level = 0xFF, \
.antenna_max = 0xFF, \ .antenna_max = 0xFF, \
} }
static struct ieee80211_channel b43_bg_chantable[] = { static struct ieee80211_channel b43_2ghz_chantable[] = {
CHANTAB_ENT(1, 2412), CHANTAB_ENT(1, 2412),
CHANTAB_ENT(2, 2417), CHANTAB_ENT(2, 2417),
CHANTAB_ENT(3, 2422), CHANTAB_ENT(3, 2422),
...@@ -148,9 +148,10 @@ static struct ieee80211_channel b43_bg_chantable[] = { ...@@ -148,9 +148,10 @@ static struct ieee80211_channel b43_bg_chantable[] = {
CHANTAB_ENT(13, 2472), CHANTAB_ENT(13, 2472),
CHANTAB_ENT(14, 2484), CHANTAB_ENT(14, 2484),
}; };
#define b43_2ghz_chantable_size ARRAY_SIZE(b43_2ghz_chantable)
#define b43_bg_chantable_size ARRAY_SIZE(b43_bg_chantable) #if 0
static struct ieee80211_channel b43_a_chantable[] = { static struct ieee80211_channel b43_5ghz_chantable[] = {
CHANTAB_ENT(36, 5180), CHANTAB_ENT(36, 5180),
CHANTAB_ENT(40, 5200), CHANTAB_ENT(40, 5200),
CHANTAB_ENT(44, 5220), CHANTAB_ENT(44, 5220),
...@@ -165,8 +166,8 @@ static struct ieee80211_channel b43_a_chantable[] = { ...@@ -165,8 +166,8 @@ static struct ieee80211_channel b43_a_chantable[] = {
CHANTAB_ENT(161, 5805), CHANTAB_ENT(161, 5805),
CHANTAB_ENT(165, 5825), CHANTAB_ENT(165, 5825),
}; };
#define b43_5ghz_chantable_size ARRAY_SIZE(b43_5ghz_chantable)
#define b43_a_chantable_size ARRAY_SIZE(b43_a_chantable) #endif
static void b43_wireless_core_exit(struct b43_wldev *dev); static void b43_wireless_core_exit(struct b43_wldev *dev);
static int b43_wireless_core_init(struct b43_wldev *dev); static int b43_wireless_core_init(struct b43_wldev *dev);
...@@ -1614,7 +1615,7 @@ static int b43_request_firmware(struct b43_wldev *dev) ...@@ -1614,7 +1615,7 @@ static int b43_request_firmware(struct b43_wldev *dev)
switch (dev->phy.type) { switch (dev->phy.type) {
case B43_PHYTYPE_A: case B43_PHYTYPE_A:
if ((rev >= 5) && (rev <= 10)) { if ((rev >= 5) && (rev <= 10)) {
if (tmshigh & B43_TMSHIGH_GPHY) if (tmshigh & B43_TMSHIGH_HAVE_2GHZ_PHY)
filename = "a0g1initvals5"; filename = "a0g1initvals5";
else else
filename = "a0g0initvals5"; filename = "a0g0initvals5";
...@@ -1640,7 +1641,7 @@ static int b43_request_firmware(struct b43_wldev *dev) ...@@ -1640,7 +1641,7 @@ static int b43_request_firmware(struct b43_wldev *dev)
switch (dev->phy.type) { switch (dev->phy.type) {
case B43_PHYTYPE_A: case B43_PHYTYPE_A:
if ((rev >= 5) && (rev <= 10)) { if ((rev >= 5) && (rev <= 10)) {
if (tmshigh & B43_TMSHIGH_GPHY) if (tmshigh & B43_TMSHIGH_HAVE_2GHZ_PHY)
filename = "a0g1bsinitvals5"; filename = "a0g1bsinitvals5";
else else
filename = "a0g0bsinitvals5"; filename = "a0g0bsinitvals5";
...@@ -3090,6 +3091,8 @@ static int b43_phy_versioning(struct b43_wldev *dev) ...@@ -3090,6 +3091,8 @@ static int b43_phy_versioning(struct b43_wldev *dev)
radio_manuf = (tmp & 0x00000FFF); radio_manuf = (tmp & 0x00000FFF);
radio_ver = (tmp & 0x0FFFF000) >> 12; radio_ver = (tmp & 0x0FFFF000) >> 12;
radio_rev = (tmp & 0xF0000000) >> 28; radio_rev = (tmp & 0xF0000000) >> 28;
if (radio_manuf != 0x17F /* Broadcom */)
unsupported = 1;
switch (phy_type) { switch (phy_type) {
case B43_PHYTYPE_A: case B43_PHYTYPE_A:
if (radio_ver != 0x2060) if (radio_ver != 0x2060)
...@@ -3107,6 +3110,10 @@ static int b43_phy_versioning(struct b43_wldev *dev) ...@@ -3107,6 +3110,10 @@ static int b43_phy_versioning(struct b43_wldev *dev)
if (radio_ver != 0x2050) if (radio_ver != 0x2050)
unsupported = 1; unsupported = 1;
break; break;
case B43_PHYTYPE_N:
if (radio_ver != 5)
unsupported = 1;
break;
default: default:
B43_WARN_ON(1); B43_WARN_ON(1);
} }
...@@ -3610,72 +3617,30 @@ static void b43_chip_reset(struct work_struct *work) ...@@ -3610,72 +3617,30 @@ static void b43_chip_reset(struct work_struct *work)
} }
static int b43_setup_modes(struct b43_wldev *dev, static int b43_setup_modes(struct b43_wldev *dev,
int have_aphy, int have_bphy, int have_gphy) bool have_2ghz_phy, bool have_5ghz_phy)
{ {
struct ieee80211_hw *hw = dev->wl->hw; struct ieee80211_hw *hw = dev->wl->hw;
struct ieee80211_hw_mode *mode; struct ieee80211_hw_mode *mode;
struct b43_phy *phy = &dev->phy; struct b43_phy *phy = &dev->phy;
int cnt = 0;
int err; int err;
/*FIXME: Don't tell ieee80211 about an A-PHY, because we currently don't support A-PHY. */ /* XXX: This function will go away soon, when mac80211
have_aphy = 0; * band stuff is rewritten. So this is just a hack.
* For now we always claim GPHY mode, as there is no
phy->possible_phymodes = 0; * support for NPHY and APHY in the device, yet.
for (; 1; cnt++) { * This assumption is OK, as any B, N or A PHY will already
if (have_aphy) { * have died a horrible sanity check death earlier. */
B43_WARN_ON(cnt >= B43_MAX_PHYHWMODES);
mode = &phy->hwmodes[cnt];
mode->mode = MODE_IEEE80211A;
mode->num_channels = b43_a_chantable_size;
mode->channels = b43_a_chantable;
mode->num_rates = b43_a_ratetable_size;
mode->rates = b43_a_ratetable;
err = ieee80211_register_hwmode(hw, mode);
if (err)
return err;
phy->possible_phymodes |= B43_PHYMODE_A;
have_aphy = 0;
continue;
}
if (have_bphy) {
B43_WARN_ON(cnt >= B43_MAX_PHYHWMODES);
mode = &phy->hwmodes[cnt];
mode->mode = MODE_IEEE80211B;
mode->num_channels = b43_bg_chantable_size;
mode->channels = b43_bg_chantable;
mode->num_rates = b43_b_ratetable_size;
mode->rates = b43_b_ratetable;
err = ieee80211_register_hwmode(hw, mode);
if (err)
return err;
phy->possible_phymodes |= B43_PHYMODE_B;
have_bphy = 0;
continue;
}
if (have_gphy) {
B43_WARN_ON(cnt >= B43_MAX_PHYHWMODES);
mode = &phy->hwmodes[cnt];
mode = &phy->hwmodes[0];
mode->mode = MODE_IEEE80211G; mode->mode = MODE_IEEE80211G;
mode->num_channels = b43_bg_chantable_size; mode->num_channels = b43_2ghz_chantable_size;
mode->channels = b43_bg_chantable; mode->channels = b43_2ghz_chantable;
mode->num_rates = b43_g_ratetable_size; mode->num_rates = b43_g_ratetable_size;
mode->rates = b43_g_ratetable; mode->rates = b43_g_ratetable;
err = ieee80211_register_hwmode(hw, mode); err = ieee80211_register_hwmode(hw, mode);
if (err) if (err)
return err; return err;
phy->possible_phymodes |= B43_PHYMODE_G; phy->possible_phymodes |= B43_PHYMODE_G;
have_gphy = 0;
continue;
}
break;
}
return 0; return 0;
} }
...@@ -3693,7 +3658,7 @@ static int b43_wireless_core_attach(struct b43_wldev *dev) ...@@ -3693,7 +3658,7 @@ static int b43_wireless_core_attach(struct b43_wldev *dev)
struct ssb_bus *bus = dev->dev->bus; struct ssb_bus *bus = dev->dev->bus;
struct pci_dev *pdev = bus->host_pci; struct pci_dev *pdev = bus->host_pci;
int err; int err;
int have_aphy = 0, have_bphy = 0, have_gphy = 0; bool have_2ghz_phy = 0, have_5ghz_phy = 0;
u32 tmp; u32 tmp;
/* Do NOT do any device initialization here. /* Do NOT do any device initialization here.
...@@ -3713,17 +3678,12 @@ static int b43_wireless_core_attach(struct b43_wldev *dev) ...@@ -3713,17 +3678,12 @@ static int b43_wireless_core_attach(struct b43_wldev *dev)
u32 tmshigh; u32 tmshigh;
tmshigh = ssb_read32(dev->dev, SSB_TMSHIGH); tmshigh = ssb_read32(dev->dev, SSB_TMSHIGH);
have_aphy = !!(tmshigh & B43_TMSHIGH_APHY); have_2ghz_phy = !!(tmshigh & B43_TMSHIGH_HAVE_2GHZ_PHY);
have_gphy = !!(tmshigh & B43_TMSHIGH_GPHY); have_5ghz_phy = !!(tmshigh & B43_TMSHIGH_HAVE_5GHZ_PHY);
if (!have_aphy && !have_gphy)
have_bphy = 1;
} else if (dev->dev->id.revision == 4) {
have_gphy = 1;
have_aphy = 1;
} else } else
have_bphy = 1; B43_WARN_ON(1);
dev->phy.gmode = (have_gphy || have_bphy); dev->phy.gmode = have_2ghz_phy;
tmp = dev->phy.gmode ? B43_TMSLOW_GMODE : 0; tmp = dev->phy.gmode ? B43_TMSLOW_GMODE : 0;
b43_wireless_core_reset(dev, tmp); b43_wireless_core_reset(dev, tmp);
...@@ -3735,31 +3695,34 @@ static int b43_wireless_core_attach(struct b43_wldev *dev) ...@@ -3735,31 +3695,34 @@ static int b43_wireless_core_attach(struct b43_wldev *dev)
(pdev->device != 0x4312 && (pdev->device != 0x4312 &&
pdev->device != 0x4319 && pdev->device != 0x4324)) { pdev->device != 0x4319 && pdev->device != 0x4324)) {
/* No multiband support. */ /* No multiband support. */
have_aphy = 0; have_2ghz_phy = 0;
have_bphy = 0; have_5ghz_phy = 0;
have_gphy = 0;
switch (dev->phy.type) { switch (dev->phy.type) {
case B43_PHYTYPE_A: case B43_PHYTYPE_A:
have_aphy = 1; have_5ghz_phy = 1;
break;
case B43_PHYTYPE_B:
have_bphy = 1;
break; break;
case B43_PHYTYPE_G: case B43_PHYTYPE_G:
have_gphy = 1; case B43_PHYTYPE_N:
have_2ghz_phy = 1;
break; break;
default: default:
B43_WARN_ON(1); B43_WARN_ON(1);
} }
} }
dev->phy.gmode = (have_gphy || have_bphy); if (dev->phy.type == B43_PHYTYPE_A) {
/* FIXME */
b43err(wl, "IEEE 802.11a devices are unsupported\n");
err = -EOPNOTSUPP;
goto err_powerdown;
}
dev->phy.gmode = have_2ghz_phy;
tmp = dev->phy.gmode ? B43_TMSLOW_GMODE : 0; tmp = dev->phy.gmode ? B43_TMSLOW_GMODE : 0;
b43_wireless_core_reset(dev, tmp); b43_wireless_core_reset(dev, tmp);
err = b43_validate_chipaccess(dev); err = b43_validate_chipaccess(dev);
if (err) if (err)
goto err_powerdown; goto err_powerdown;
err = b43_setup_modes(dev, have_aphy, have_bphy, have_gphy); err = b43_setup_modes(dev, have_2ghz_phy, have_5ghz_phy);
if (err) if (err)
goto err_powerdown; goto err_powerdown;
......
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