37 #include <linux/module.h>
38 #include <linux/if_arp.h>
45 #include <linux/slab.h>
46 #include <asm/unaligned.h>
79 static int modparam_bad_frames_preempt;
82 "enable(1) / disable(0) Bad Frames Preemption");
84 static char modparam_fwpostfix[16];
88 static int modparam_hwpctl;
90 MODULE_PARM_DESC(hwpctl,
"Enable hardware-side power control (default off)");
92 static int modparam_nohwcrypt;
96 static int modparam_hwtkip;
100 static int modparam_qos = 1;
104 static int modparam_btcoex = 1;
112 static int b43_modparam_pio = 0;
116 #ifdef CONFIG_B43_BCMA
119 #ifdef CONFIG_B43_BCMA_EXTRA
129 #ifdef CONFIG_B43_SSB
150 #define RATETAB_ENT(_rateid, _flags) \
152 .bitrate = B43_RATE_TO_BASE100KBPS(_rateid), \
153 .hw_value = (_rateid), \
176 #define b43_a_ratetable (__b43_ratetable + 4)
177 #define b43_a_ratetable_size 8
178 #define b43_b_ratetable (__b43_ratetable + 0)
179 #define b43_b_ratetable_size 4
180 #define b43_g_ratetable (__b43_ratetable + 0)
181 #define b43_g_ratetable_size 12
183 #define CHAN4G(_channel, _freq, _flags) { \
184 .band = IEEE80211_BAND_2GHZ, \
185 .center_freq = (_freq), \
186 .hw_value = (_channel), \
188 .max_antenna_gain = 0, \
209 #define CHAN5G(_channel, _flags) { \
210 .band = IEEE80211_BAND_5GHZ, \
211 .center_freq = 5000 + (5 * (_channel)), \
212 .hw_value = (_channel), \
214 .max_antenna_gain = 0, \
300 .channels = b43_5ghz_nphy_chantable,
301 .n_channels =
ARRAY_SIZE(b43_5ghz_nphy_chantable),
308 .channels = b43_5ghz_aphy_chantable,
309 .n_channels =
ARRAY_SIZE(b43_5ghz_aphy_chantable),
316 .channels = b43_2ghz_chantable,
322 static void b43_wireless_core_exit(
struct b43_wldev *
dev);
323 static int b43_wireless_core_init(
struct b43_wldev *
dev);
325 static int b43_wireless_core_start(
struct b43_wldev *
dev);
331 static int b43_ratelimit(
struct b43_wl *
wl)
349 if (!b43_ratelimit(wl))
358 (wl && wl->
hw) ? wiphy_name(wl->
hw->wiphy) :
"wlan", &vaf);
370 if (!b43_ratelimit(wl))
379 (wl && wl->
hw) ? wiphy_name(wl->
hw->wiphy) :
"wlan", &vaf);
391 if (!b43_ratelimit(wl))
400 (wl && wl->
hw) ? wiphy_name(wl->
hw->wiphy) :
"wlan", &vaf);
419 (wl && wl->
hw) ? wiphy_name(wl->
hw->wiphy) :
"wlan", &vaf);
439 static inline void b43_shm_control_word(
struct b43_wldev *dev,
457 if (offset & 0x0003) {
459 b43_shm_control_word(dev, routing, offset >> 2);
461 b43_shm_control_word(dev, routing, (offset >> 2) + 1);
468 b43_shm_control_word(dev, routing, offset);
480 if (offset & 0x0003) {
482 b43_shm_control_word(dev, routing, offset >> 2);
489 b43_shm_control_word(dev, routing, offset);
499 if (offset & 0x0003) {
501 b43_shm_control_word(dev, routing, offset >> 2);
504 b43_shm_control_word(dev, routing, (offset >> 2) + 1);
506 (value >> 16) & 0xFFFF);
511 b43_shm_control_word(dev, routing, offset);
519 if (offset & 0x0003) {
521 b43_shm_control_word(dev, routing, offset >> 2);
527 b43_shm_control_word(dev, routing, offset);
550 lo = (value & 0x00000000FFFFULL);
551 mi = (value & 0x0000FFFF0000ULL) >> 16;
552 hi = (value & 0xFFFF00000000ULL) >> 32;
581 static void b43_time_lock(
struct b43_wldev *dev)
588 static void b43_time_unlock(
struct b43_wldev *dev)
614 b43_tsf_write_locked(dev, tsf);
615 b43_time_unlock(dev);
641 static void b43_write_mac_bssid_templates(
struct b43_wldev *dev)
649 bssid = dev->
wl->bssid;
650 mac = dev->
wl->mac_addr;
659 tmp = (
u32) (mac_bssid[i + 0]);
660 tmp |= (
u32) (mac_bssid[i + 1]) << 8;
661 tmp |= (
u32) (mac_bssid[i + 2]) << 16;
662 tmp |= (
u32) (mac_bssid[i + 3]) << 24;
663 b43_ram_write(dev, 0x20 + i, tmp);
667 static void b43_upload_card_macaddress(
struct b43_wldev *dev)
669 b43_write_mac_bssid_templates(dev);
673 static void b43_set_slot_time(
struct b43_wldev *dev,
u16 slot_time)
689 static void b43_short_slot_timing_enable(
struct b43_wldev *dev)
691 b43_set_slot_time(dev, 9);
694 static void b43_short_slot_timing_disable(
struct b43_wldev *dev)
696 b43_set_slot_time(dev, 20);
705 unsigned int i, max_loop;
717 buffer[0] = 0x000201CC;
720 buffer[0] = 0x000B846E;
723 for (i = 0; i < 5; i++)
724 b43_ram_write(dev, i * 4, buffer[i]);
728 if (dev->
dev->core_rev < 11)
733 value = (ofdm ? 0x41 : 0x40);
765 for (i = 0x00; i < max_loop; i++) {
771 for (i = 0x00; i < 0x0A; i++) {
777 for (i = 0x00; i < 0x19; i++) {
779 if (!(value & 0x0100))
787 static void key_write(
struct b43_wldev *dev,
796 kidx = b43_kidx_to_fw(dev, index);
797 value = ((kidx << 4) | algorithm);
805 value |= (
u16) (key[i + 1]) << 8;
812 u32 addrtmp[2] = { 0, 0, };
815 if (b43_new_kidx_api(dev))
824 index -= pairwise_keys_start;
828 addrtmp[0] = addr[0];
829 addrtmp[0] |= ((
u32) (addr[1]) << 8);
830 addrtmp[0] |= ((
u32) (addr[2]) << 16);
831 addrtmp[0] |= ((
u32) (addr[3]) << 24);
832 addrtmp[1] = addr[4];
833 addrtmp[1] |= ((
u32) (addr[5]) << 8);
838 (index * 2) + 0, addrtmp[0]);
840 (index * 2) + 1, addrtmp[1]);
860 static void rx_tkip_phase1_write(
struct b43_wldev *dev,
u8 index,
u32 iv32,
867 if (!modparam_hwtkip)
870 if (b43_new_kidx_api(dev))
879 index -= pairwise_keys_start;
883 b43dbg(dev->
wl,
"rx_tkip_phase1_write : idx 0x%x, iv32 0x%x\n",
888 for (i = 0; i < 10; i += 2) {
890 phase1key ? phase1key[i / 2] : 0);
902 struct b43_wl *wl = hw_to_b43_wl(hw);
915 keymac_write(dev, index,
NULL);
917 rx_tkip_phase1_write(dev, index, iv32, phase1key);
921 keymac_write(dev, index, sta->
addr);
924 static void do_key_write(
struct b43_wldev *dev,
925 u8 index,
u8 algorithm,
931 if (b43_new_kidx_api(dev))
937 if (index >= pairwise_keys_start)
938 keymac_write(dev, index,
NULL);
949 rx_tkip_phase1_write(dev, index, 0xffffffff, (
u16*)buf);
950 }
else if (index >= pairwise_keys_start)
951 rx_tkip_phase1_write(dev, index, 0,
NULL);
953 memcpy(buf, key, key_len);
954 key_write(dev, index, algorithm, buf);
955 if (index >= pairwise_keys_start)
956 keymac_write(dev, index, mac_addr);
961 static int b43_key_write(
struct b43_wldev *dev,
962 int index,
u8 algorithm,
963 const u8 *key,
size_t key_len,
968 int pairwise_keys_start;
979 if (key_len > B43_SEC_KEYSIZE)
987 if (b43_new_kidx_api(dev))
991 for (i = pairwise_keys_start;
995 if (!dev->
key[i].keyconf) {
1002 b43warn(dev->
wl,
"Out of hardware key memory\n");
1008 do_key_write(dev, index, algorithm, key, key_len, mac_addr);
1009 if ((index <= 3) && !b43_new_kidx_api(dev)) {
1012 do_key_write(dev, index + 4, algorithm, key, key_len,
NULL);
1020 static int b43_key_clear(
struct b43_wldev *dev,
int index)
1026 if ((index <= 3) && !b43_new_kidx_api(dev)) {
1035 static void b43_clear_keys(
struct b43_wldev *dev)
1039 if (b43_new_kidx_api(dev))
1043 for (i = 0; i <
count; i++)
1044 b43_key_clear(dev, i);
1047 static void b43_dump_keymemory(
struct b43_wldev *dev)
1061 b43dbg(dev->
wl,
"Hardware key memory dump: USEDEFKEYS=%u\n",
1063 if (b43_new_kidx_api(dev)) {
1070 for (index = 0; index <
count; index++) {
1077 printk(
"%02X%02X", (tmp & 0xFF), ((tmp >> 8) & 0xFF));
1084 if (index >= pairwise_keys_start) {
1088 for (i = 0; i < 14; i += 2) {
1090 printk(
"%02X%02X", (tmp & 0xFF), ((tmp >> 8) & 0xFF));
1094 ((index - pairwise_keys_start) * 2) + 0);
1096 ((index - pairwise_keys_start) * 2) + 1);
1099 printk(
" MAC: %pM", mac);
1118 if (ps_flags & B43_PS_ENABLED) {
1120 }
else if (ps_flags & B43_PS_DISABLED) {
1126 if (ps_flags & B43_PS_AWAKE) {
1128 }
else if (ps_flags & B43_PS_ASLEEP) {
1152 if (awake && dev->
dev->core_rev >= 5) {
1154 for (i = 0; i < 100; i++) {
1164 #ifdef CONFIG_B43_BCMA
1165 static void b43_bcma_phy_reset(
struct b43_wldev *dev)
1190 static void b43_bcma_wireless_core_reset(
struct b43_wldev *dev,
bool gmode)
1194 b43_bcma_phy_reset(dev);
1199 static void b43_ssb_wireless_core_reset(
struct b43_wldev *dev,
bool gmode)
1211 b43_device_enable(dev, flags);
1231 switch (dev->
dev->bus_type) {
1232 #ifdef CONFIG_B43_BCMA
1234 b43_bcma_wireless_core_reset(dev, gmode);
1237 #ifdef CONFIG_B43_SSB
1239 b43_ssb_wireless_core_reset(dev, gmode);
1249 dev->
phy.ops->switch_analog(dev, 1);
1259 static void handle_irq_transmit_status(
struct b43_wldev *dev)
1267 if (!(v0 & 0x00000001))
1271 stat.cookie = (v0 >> 16);
1272 stat.seq = (v1 & 0x0000FFFF);
1273 stat.phy_stat = ((v1 & 0x00FF0000) >> 16);
1274 tmp = (v0 & 0x0000FFFF);
1275 stat.frame_count = ((tmp & 0xF000) >> 12);
1276 stat.rts_count = ((tmp & 0x0F00) >> 8);
1277 stat.supp_reason = ((tmp & 0x001C) >> 2);
1278 stat.pm_indicated = !!(tmp & 0x0080);
1279 stat.intermediate = !!(tmp & 0x0040);
1280 stat.for_ampdu = !!(tmp & 0x0020);
1281 stat.acked = !!(tmp & 0x0002);
1287 static void drain_txstatus_queue(
struct b43_wldev *dev)
1291 if (dev->
dev->core_rev < 5)
1298 if (!(dummy & 0x00000001))
1315 static void b43_jssi_write(
struct b43_wldev *dev,
u32 jssi)
1321 static void b43_generate_noise_sample(
struct b43_wldev *dev)
1323 b43_jssi_write(dev, 0x7F7F7F7F);
1328 static void b43_calculate_link_quality(
struct b43_wldev *dev)
1336 dev->
noisecalc.calculation_running =
true;
1339 b43_generate_noise_sample(dev);
1342 static void handle_irq_noise(
struct b43_wldev *dev)
1366 if (noise[0] == 0x7F || noise[1] == 0x7F ||
1367 noise[2] == 0x7F || noise[3] == 0x7F)
1385 for (i = 0; i < 8; i++) {
1386 for (j = 0; j < 4; j++)
1387 average += dev->
noisecalc.samples[i][j];
1394 tmp = (tmp / 128) & 0x1F;
1405 dev->
noisecalc.calculation_running =
false;
1409 b43_generate_noise_sample(dev);
1412 static void handle_irq_tbtt_indication(
struct b43_wldev *dev)
1424 static void handle_irq_atim_end(
struct b43_wldev *dev)
1434 static void handle_irq_pmq(
struct b43_wldev *dev)
1442 if (!(tmp & 0x00000008))
1449 static void b43_write_template_common(
struct b43_wldev *dev,
1455 struct b43_plcp_hdr4 plcp;
1459 b43_ram_write(dev, ram_offset,
le32_to_cpu(plcp.data));
1460 ram_offset +=
sizeof(
u32);
1464 tmp = (
u32) (data[0]) << 16;
1465 tmp |= (
u32) (data[1]) << 24;
1466 b43_ram_write(dev, ram_offset, tmp);
1467 ram_offset +=
sizeof(
u32);
1468 for (i = 2; i <
size; i +=
sizeof(
u32)) {
1469 tmp = (
u32) (data[i + 0]);
1471 tmp |= (
u32) (data[i + 1]) << 8;
1473 tmp |= (
u32) (data[i + 2]) << 16;
1475 tmp |= (
u32) (data[i + 3]) << 24;
1476 b43_ram_write(dev, ram_offset + i - 2, tmp);
1479 size +
sizeof(
struct b43_plcp_hdr6));
1490 if (antenna_nr == 0) {
1497 antenna_mask = dev->
dev->bus_sprom->ant_available_bg;
1499 antenna_mask = dev->
dev->bus_sprom->ant_available_a;
1501 if (!(antenna_mask & (1 << (antenna_nr - 1)))) {
1510 static u16 b43_antenna_to_phyctl(
int antenna)
1529 static void b43_write_beacon_template(
struct b43_wldev *dev,
1531 u16 shm_size_offset)
1533 unsigned int i,
len, variable_len;
1536 bool tim_found =
false;
1543 len =
min((
size_t) dev->
wl->current_beacon->len,
1544 0x200 -
sizeof(
struct b43_plcp_hdr6));
1545 rate = ieee80211_get_tx_rate(dev->
wl->hw, info)->hw_value;
1547 b43_write_template_common(dev, (
const u8 *)bcn,
1548 len, ram_offset, shm_size_offset, rate);
1552 antenna = b43_antenna_to_phyctl(antenna);
1559 if (b43_is_cck_rate(rate))
1567 ie = bcn->
u.beacon.variable;
1569 for (i = 0; i < variable_len - 2; ) {
1580 if (variable_len < ie_len + 2 + i)
1587 tim_position =
sizeof(
struct b43_plcp_hdr6);
1591 dtim_period = ie[i + 3];
1608 len +
sizeof(
struct b43_plcp_hdr6));
1612 b43dbg(dev->
wl,
"Updated beacon template at 0x%x\n", ram_offset);
1615 static void b43_upload_beacon0(
struct b43_wldev *dev)
1621 b43_write_beacon_template(dev, 0x68, 0x18);
1625 static void b43_upload_beacon1(
struct b43_wldev *dev)
1631 b43_write_beacon_template(dev, 0x468, 0x1A);
1635 static void handle_irq_beacon(
struct b43_wldev *dev)
1638 u32 cmd, beacon0_valid, beacon1_valid;
1655 if (beacon0_valid && beacon1_valid) {
1665 b43_upload_beacon0(dev);
1666 b43_upload_beacon1(dev);
1671 if (!beacon0_valid) {
1672 b43_upload_beacon0(dev);
1676 }
else if (!beacon1_valid) {
1677 b43_upload_beacon1(dev);
1685 static void b43_do_beacon_update_trigger_work(
struct b43_wldev *dev)
1690 handle_irq_beacon(dev);
1691 if (old_irq_mask != dev->
irq_mask) {
1715 if (b43_bus_host_is_sdio(dev->
dev)) {
1717 b43_do_beacon_update_trigger_work(dev);
1721 b43_do_beacon_update_trigger_work(dev);
1731 static void b43_update_templates(
struct b43_wl *wl)
1745 beacon = ieee80211_beacon_get(wl->
hw, wl->
vif);
1760 if (dev->
dev->core_rev >= 3) {
1764 b43_write16(dev, 0x606, (beacon_int >> 6));
1765 b43_write16(dev, 0x610, beacon_int);
1767 b43_time_unlock(dev);
1768 b43dbg(dev->
wl,
"Set beacon interval to %u\n", beacon_int);
1771 static void b43_handle_firmware_panic(
struct b43_wldev *dev)
1777 b43err(dev->
wl,
"Whoopsy, firmware panic! Reason: %u\n", reason);
1781 b43dbg(dev->
wl,
"The panic reason is unknown.\n");
1795 static void handle_irq_ucode_debug(
struct b43_wldev *dev)
1797 unsigned int i,
cnt;
1802 if (!dev->
fw.opensource)
1810 b43_handle_firmware_panic(dev);
1817 b43dbg(dev->
wl,
"SHM-dump: Failed to allocate memory\n");
1820 for (i = 0; i < 4096; i += 2) {
1824 b43info(dev->
wl,
"Shared memory dump:\n");
1826 16, 2, buf, 4096, 1);
1832 b43info(dev->
wl,
"Microcode register dump:\n");
1833 for (i = 0, cnt = 0; i < 64; i++) {
1837 printk(
"r%02u: 0x%04X ", i, tmp);
1853 b43info(dev->
wl,
"The firmware just executed the MARKER(%u) "
1854 "at line number %u\n",
1855 marker_id, marker_line);
1858 b43dbg(dev->
wl,
"Debug-IRQ triggered for unknown reason: %u\n",
1867 static void b43_do_interrupt_thread(
struct b43_wldev *dev)
1871 u32 merged_dma_reason = 0;
1878 for (i = 0; i <
ARRAY_SIZE(dma_reason); i++) {
1880 merged_dma_reason |= dma_reason[
i];
1884 b43err(dev->
wl,
"MAC transmission error\n");
1887 b43err(dev->
wl,
"PHY transmission error\n");
1892 b43err(dev->
wl,
"Too many PHY TX errors, "
1893 "restarting the controller\n");
1901 b43err(dev->
wl,
"Fatal DMA error: "
1902 "0x%08X, 0x%08X, 0x%08X, "
1903 "0x%08X, 0x%08X, 0x%08X\n",
1904 dma_reason[0], dma_reason[1],
1905 dma_reason[2], dma_reason[3],
1906 dma_reason[4], dma_reason[5]);
1907 b43err(dev->
wl,
"This device does not support DMA "
1908 "on your system. It will now be switched to PIO.\n");
1916 "0x%08X, 0x%08X, 0x%08X, "
1917 "0x%08X, 0x%08X, 0x%08X\n",
1918 dma_reason[0], dma_reason[1],
1919 dma_reason[2], dma_reason[3],
1920 dma_reason[4], dma_reason[5]);
1925 handle_irq_ucode_debug(dev);
1927 handle_irq_tbtt_indication(dev);
1929 handle_irq_atim_end(dev);
1931 handle_irq_beacon(dev);
1933 handle_irq_pmq(dev);
1937 handle_irq_noise(dev);
1941 if (b43_using_pio_transfers(dev))
1953 handle_irq_transmit_status(dev);
1961 for (i = 0; i <
ARRAY_SIZE(dev->irq_bit_count); i++) {
1962 if (reason & (1 << i))
1963 dev->irq_bit_count[i]++;
1975 b43_do_interrupt_thread(dev);
1990 if (reason == 0xffffffff)
2039 spin_lock(&dev->
wl->hardirq_lock);
2040 ret = b43_do_interrupt(dev);
2042 spin_unlock(&dev->
wl->hardirq_lock);
2048 static void b43_sdio_interrupt_handler(
struct b43_wldev *dev)
2055 ret = b43_do_interrupt(dev);
2057 b43_do_interrupt_thread(dev);
2069 static void b43_release_firmware(
struct b43_wldev *dev)
2077 static void b43_print_fw_helptext(
struct b43_wl *wl,
bool error)
2081 "http://wireless.kernel.org/en/users/Drivers/b43#devicefirmware " \
2082 "and download the correct firmware for this driver version. " \
2083 "Please carefully read all instructions on this website.\n";
2123 modparam_fwpostfix, name);
2128 modparam_fwpostfix, name);
2138 "Firmware file \"%s\" not found\n", ctx->
fwname);
2143 "Firmware file \"%s\" request failed (err=%d)\n",
2150 switch (hdr->
type) {
2174 "Firmware file \"%s\" format error.\n", ctx->
fwname);
2184 const u8 rev = ctx->
dev->dev->core_rev;
2192 if ((rev >= 5) && (rev <= 10)) {
2193 filename =
"ucode5";
2194 }
else if ((rev >= 11) && (rev <= 12)) {
2195 filename =
"ucode11";
2196 }
else if (rev == 13) {
2197 filename =
"ucode13";
2198 }
else if (rev == 14) {
2199 filename =
"ucode14";
2200 }
else if (rev == 15) {
2201 filename =
"ucode15";
2203 switch (dev->
phy.type) {
2206 filename =
"ucode16_mimo";
2212 filename =
"ucode29_mimo";
2218 filename =
"ucode24_mimo";
2231 if ((rev >= 5) && (rev <= 10))
2247 switch (dev->
phy.type) {
2249 if ((rev >= 5) && (rev <= 10)) {
2252 filename =
"a0g1initvals5";
2254 filename =
"a0g0initvals5";
2256 goto err_no_initvals;
2259 if ((rev >= 5) && (rev <= 10))
2260 filename =
"b0g0initvals5";
2262 filename =
"b0g0initvals13";
2264 goto err_no_initvals;
2268 filename =
"n0initvals16";
2269 else if ((rev >= 11) && (rev <= 12))
2270 filename =
"n0initvals11";
2272 goto err_no_initvals;
2276 filename =
"lp0initvals13";
2278 filename =
"lp0initvals14";
2280 filename =
"lp0initvals15";
2282 goto err_no_initvals;
2286 filename =
"ht0initvals29";
2288 goto err_no_initvals;
2292 filename =
"lcn0initvals24";
2294 goto err_no_initvals;
2297 goto err_no_initvals;
2304 switch (dev->
phy.type) {
2306 if ((rev >= 5) && (rev <= 10)) {
2309 filename =
"a0g1bsinitvals5";
2311 filename =
"a0g0bsinitvals5";
2312 }
else if (rev >= 11)
2315 goto err_no_initvals;
2318 if ((rev >= 5) && (rev <= 10))
2319 filename =
"b0g0bsinitvals5";
2323 goto err_no_initvals;
2327 filename =
"n0bsinitvals16";
2328 else if ((rev >= 11) && (rev <= 12))
2329 filename =
"n0bsinitvals11";
2331 goto err_no_initvals;
2335 filename =
"lp0bsinitvals13";
2337 filename =
"lp0bsinitvals14";
2339 filename =
"lp0bsinitvals15";
2341 goto err_no_initvals;
2345 filename =
"ht0bsinitvals29";
2347 goto err_no_initvals;
2351 filename =
"lcn0bsinitvals24";
2353 goto err_no_initvals;
2356 goto err_no_initvals;
2368 b43err(dev->
wl,
"The driver does not know which firmware (ucode) "
2369 "is required for your device (wl-core rev %u)\n", rev);
2374 b43err(dev->
wl,
"The driver does not know which firmware (PCM) "
2375 "is required for your device (wl-core rev %u)\n", rev);
2380 b43err(dev->
wl,
"The driver does not know which firmware (initvals) "
2381 "is required for your device (wl-core rev %u)\n", rev);
2391 b43_release_firmware(dev);
2396 static void b43_one_core_detach(
struct b43_bus_dev *dev);
2398 static void b43_request_firmware(
struct work_struct *work)
2414 err = b43_try_request_fw(ctx);
2416 goto start_ieee80211;
2423 err = b43_try_request_fw(ctx);
2425 goto start_ieee80211;
2435 b43_print_fw_helptext(dev->
wl, 1);
2440 if (!modparam_qos || dev->
fw.opensource)
2445 goto err_one_core_detach;
2450 err_one_core_detach:
2451 b43_one_core_detach(dev->
dev);
2457 static int b43_upload_microcode(
struct b43_wldev *dev)
2462 unsigned int i, len;
2463 u16 fwrev, fwpatch, fwdate, fwtime;
2473 for (i = 0; i < 64; i++)
2475 for (i = 0; i < 4096; i += 2)
2479 data = (
__be32 *) (dev->
fw.ucode.data->data + hdr_len);
2482 for (i = 0; i < len; i++) {
2487 if (dev->
fw.pcm.data) {
2489 data = (
__be32 *) (dev->
fw.pcm.data->data + hdr_len);
2491 b43_shm_control_word(dev,
B43_SHM_HW, 0x01EA);
2494 b43_shm_control_word(dev,
B43_SHM_HW, 0x01EB);
2495 for (i = 0; i < len; i++) {
2515 b43err(dev->
wl,
"Microcode not responding\n");
2516 b43_print_fw_helptext(dev->
wl, 1);
2530 if (fwrev <= 0x128) {
2531 b43err(dev->
wl,
"YOUR FIRMWARE IS TOO OLD. Firmware from "
2532 "binary drivers older than version 4.x is unsupported. "
2533 "You must upgrade your firmware files.\n");
2534 b43_print_fw_helptext(dev->
wl, 1);
2538 dev->
fw.rev = fwrev;
2539 dev->
fw.patch = fwpatch;
2540 if (dev->
fw.rev >= 598)
2542 else if (dev->
fw.rev >= 410)
2546 WARN_ON(dev->
fw.opensource != (fwdate == 0xFFFF));
2552 if (dev->
fw.opensource) {
2556 dev->
fw.patch = fwtime;
2557 b43info(dev->
wl,
"Loading OpenSource firmware version %u.%u\n",
2558 dev->
fw.rev, dev->
fw.patch);
2560 fwcapa = b43_fwcapa_read(dev);
2562 b43info(dev->
wl,
"Hardware crypto acceleration not supported by firmware\n");
2569 b43info(dev->
wl,
"Loading firmware version %u.%u "
2570 "(20%.2i-%.2i-%.2i %.2i:%.2i:%.2i)\n",
2572 (fwdate >> 12) & 0xF, (fwdate >> 8) & 0xF, fwdate & 0xFF,
2573 (fwtime >> 11) & 0x1F, (fwtime >> 5) & 0x3F, fwtime & 0x1F);
2574 if (dev->
fw.pcm_request_failed) {
2575 b43warn(dev->
wl,
"No \"pcm5.fw\" firmware file found. "
2576 "Hardware accelerated cryptography is disabled.\n");
2577 b43_print_fw_helptext(dev->
wl, 0);
2582 dev->
fw.rev, dev->
fw.patch);
2588 b43warn(dev->
wl,
"You are using an old firmware image. "
2589 "Support for old firmware will be removed soon "
2590 "(official deadline was July 2008).\n");
2591 b43_print_fw_helptext(dev->
wl, 0);
2604 static int b43_write_initvals(
struct b43_wldev *dev,
2605 const struct b43_iv *ivals,
2616 for (i = 0; i <
count; i++) {
2623 if (offset >= 0x1000)
2628 if (array_size <
sizeof(iv->data.
d32))
2630 array_size -=
sizeof(iv->data.
d32);
2633 b43_write32(dev, offset, value);
2641 if (array_size <
sizeof(iv->data.
d16))
2643 array_size -=
sizeof(iv->data.
d16);
2646 b43_write16(dev, offset, value);
2659 b43err(dev->
wl,
"Initial Values Firmware file-format error.\n");
2660 b43_print_fw_helptext(dev->
wl, 1);
2665 static int b43_upload_initvals(
struct b43_wldev *dev)
2670 const struct b43_iv *ivals;
2675 ivals = (
const struct b43_iv *)(fw->
initvals.data->data + hdr_len);
2677 err = b43_write_initvals(dev, ivals, count,
2678 fw->
initvals.data->size - hdr_len);
2685 err = b43_write_initvals(dev, ivals, count,
2702 #ifdef CONFIG_SSB_DRIVER_PCICORE
2709 static int b43_gpio_init(
struct b43_wldev *dev)
2719 if (dev->
dev->chip_id == 0x4301) {
2722 }
else if (dev->
dev->chip_id == 0x5354) {
2747 switch (dev->
dev->bus_type) {
2748 #ifdef CONFIG_B43_BCMA
2755 #ifdef CONFIG_B43_SSB
2757 gpiodev = b43_ssb_gpio_dev(dev);
2770 static void b43_gpio_cleanup(
struct b43_wldev *dev)
2774 switch (dev->
dev->bus_type) {
2775 #ifdef CONFIG_B43_BCMA
2781 #ifdef CONFIG_B43_SSB
2783 gpiodev = b43_ssb_gpio_dev(dev);
2801 b43err(dev->
wl,
"b43_mac_enable(): The firmware "
2802 "should be suspended, but current state is %u\n",
2834 for (i = 35;
i; i--) {
2841 for (i = 40;
i; i--) {
2847 b43err(dev->
wl,
"MAC suspend failed\n");
2858 switch (dev->
dev->bus_type) {
2859 #ifdef CONFIG_B43_BCMA
2869 #ifdef CONFIG_B43_SSB
2882 static void b43_adjust_opmode(
struct b43_wldev *dev)
2918 if (dev->
dev->core_rev <= 4)
2925 if (dev->
dev->chip_id == 0x4306 &&
2926 dev->
dev->chip_rev == 3)
2931 b43_write16(dev, 0x612, cfp_pretbtt);
2943 static void b43_rate_memory_write(
struct b43_wldev *dev,
u16 rate,
int is_ofdm)
2958 static void b43_rate_memory_init(
struct b43_wldev *dev)
2960 switch (dev->
phy.type) {
2989 static void b43_set_phytxctl_defaults(
struct b43_wldev *dev)
3003 static void b43_mgmtframe_txantenna(
struct b43_wldev *dev,
int antenna)
3008 ant = b43_antenna_to_phyctl(antenna);
3021 static void b43_chip_exit(
struct b43_wldev *dev)
3024 b43_gpio_cleanup(dev);
3031 static int b43_chip_init(
struct b43_wldev *dev)
3045 err = b43_upload_microcode(dev);
3049 err = b43_gpio_init(dev);
3053 err = b43_upload_initvals(dev);
3055 goto err_gpio_clean;
3058 phy->
ops->switch_analog(dev, 1);
3061 goto err_gpio_clean;
3064 if (phy->
ops->interf_mitigation)
3068 if (phy->
ops->set_rx_antenna)
3073 value16 = b43_read16(dev, 0x005E);
3075 b43_write16(dev, 0x005E, value16);
3077 b43_write32(dev, 0x0100, 0x01000000);
3078 if (dev->
dev->core_rev < 5)
3079 b43_write32(dev, 0x010C, 0x01000000);
3089 b43_adjust_opmode(dev);
3091 if (dev->
dev->core_rev < 3) {
3092 b43_write16(dev, 0x060E, 0x0000);
3093 b43_write16(dev, 0x0610, 0x8000);
3094 b43_write16(dev, 0x0604, 0x0000);
3095 b43_write16(dev, 0x0606, 0x0200);
3097 b43_write32(dev, 0x0188, 0x80000000);
3098 b43_write32(dev, 0x018C, 0x02000000);
3110 switch (dev->
dev->bus_type) {
3111 #ifdef CONFIG_B43_BCMA
3117 #ifdef CONFIG_B43_SSB
3120 dev->
dev->sdev->bus->chipco.fast_pwrup_delay);
3126 b43dbg(dev->
wl,
"Chip initialized\n");
3131 b43_gpio_cleanup(dev);
3135 static void b43_periodic_every60sec(
struct b43_wldev *dev)
3146 static void b43_periodic_every30sec(
struct b43_wldev *dev)
3149 b43_calculate_link_quality(dev);
3152 static void b43_periodic_every15sec(
struct b43_wldev *dev)
3157 if (dev->
fw.opensource) {
3162 b43err(dev->
wl,
"Firmware watchdog: The firmware died!\n");
3171 if (phy->
ops->pwork_15sec)
3172 phy->
ops->pwork_15sec(dev);
3181 b43dbg(dev->
wl,
"Stats: %7u IRQs/sec, %7u TX/sec, %7u RX/sec\n",
3182 dev->irq_count / 15,
3184 dev->rx_count / 15);
3188 for (i = 0; i <
ARRAY_SIZE(dev->irq_bit_count); i++) {
3189 if (dev->irq_bit_count[i]) {
3190 b43dbg(dev->
wl,
"Stats: %7u IRQ-%02u/sec (0x%08X)\n",
3191 dev->irq_bit_count[i] / 15, i, (1 << i));
3192 dev->irq_bit_count[
i] = 0;
3199 static void do_periodic_work(
struct b43_wldev *dev)
3205 b43_periodic_every60sec(dev);
3207 b43_periodic_every30sec(dev);
3208 b43_periodic_every15sec(dev);
3216 static void b43_periodic_work_handler(
struct work_struct *work)
3221 unsigned long delay;
3230 do_periodic_work(dev);
3243 static void b43_periodic_tasks_setup(
struct b43_wldev *dev)
3253 static int b43_validate_chipaccess(
struct b43_wldev *dev)
3255 u32 v, backup0, backup4;
3275 b43warn(dev->
wl,
"Unaligned 32bit SHM read access is broken\n");
3281 b43warn(dev->
wl,
"Unaligned 32bit SHM write access is broken\n");
3286 if ((dev->
dev->core_rev >= 3) && (dev->
dev->core_rev <= 10)) {
3305 b43err(dev->
wl,
"Failed to validate the chipaccess\n");
3309 static void b43_security_init(
struct b43_wldev *dev)
3319 b43_clear_keys(dev);
3322 #ifdef CONFIG_B43_HWRNG
3323 static int b43_rng_read(
struct hwrng *rng,
u32 *data)
3333 count =
sizeof(
u16);
3341 static void b43_rng_exit(
struct b43_wl *wl)
3343 #ifdef CONFIG_B43_HWRNG
3344 if (wl->rng_initialized)
3349 static int b43_rng_init(
struct b43_wl *wl)
3353 #ifdef CONFIG_B43_HWRNG
3355 "%s_%s", KBUILD_MODNAME, wiphy_name(wl->
hw->wiphy));
3356 wl->rng.name = wl->rng_name;
3357 wl->rng.data_read = b43_rng_read;
3358 wl->rng.priv = (
unsigned long)wl;
3359 wl->rng_initialized =
true;
3362 wl->rng_initialized =
false;
3363 b43err(wl,
"Failed to register the random "
3364 "number generator (%d)\n", err);
3387 while (skb_queue_len(&wl->
tx_queue[queue_num])) {
3389 if (b43_using_pio_transfers(dev))
3418 struct b43_wl *wl = hw_to_b43_wl(hw);
3435 static void b43_qos_params_upload(
struct b43_wldev *dev,
3448 memset(¶ms, 0,
sizeof(params));
3461 shm_offset + (i * 2));
3465 shm_offset + (i * 2),
3469 shm_offset + (i * 2),
3476 static const u16 b43_qos_shm_offsets[] = {
3485 static void b43_qos_upload_all(
struct b43_wldev *dev)
3500 b43_qos_params_upload(dev, &(params->
p),
3501 b43_qos_shm_offsets[i]);
3506 static void b43_qos_clear(
struct b43_wl *wl)
3519 switch (b43_qos_shm_offsets[i]) {
3523 params->
p.cw_min = 0x0001;
3524 params->
p.cw_max = 0x0001;
3529 params->
p.cw_min = 0x0001;
3530 params->
p.cw_max = 0x0001;
3535 params->
p.cw_min = 0x0001;
3536 params->
p.cw_max = 0x03FF;
3541 params->
p.cw_min = 0x0001;
3542 params->
p.cw_max = 0x03FF;
3551 static void b43_qos_init(
struct b43_wldev *dev)
3564 b43_qos_upload_all(dev);
3578 struct b43_wl *wl = hw_to_b43_wl(hw);
3580 unsigned int queue = (
unsigned int)_queue;
3599 b43_qos_params_upload(dev, &(wl->
qos_params[queue].p),
3600 b43_qos_shm_offsets[queue]);
3613 struct b43_wl *wl = hw_to_b43_wl(hw);
3624 struct b43_wl *wl = hw_to_b43_wl(hw);
3644 struct b43_wl *wl = hw_to_b43_wl(hw);
3656 static void b43_put_phy_into_reset(
struct b43_wldev *dev)
3660 switch (dev->
dev->bus_type) {
3661 #ifdef CONFIG_B43_BCMA
3664 "Putting PHY into reset not supported on BCMA\n");
3667 #ifdef CONFIG_B43_SSB
3713 switch (chan->
band) {
3715 if (d->
phy.supports_5ghz) {
3721 if (d->
phy.supports_2ghz) {
3734 b43err(wl,
"Could not find a device for %s-GHz band operation\n",
3735 band_to_string(chan->
band));
3743 b43dbg(wl,
"Switching to %s-GHz band\n",
3744 band_to_string(chan->
band));
3750 down_dev = b43_wireless_core_stop(down_dev);
3752 b43_wireless_core_exit(down_dev);
3754 if (down_dev != up_dev) {
3757 b43_put_phy_into_reset(down_dev);
3761 up_dev->
phy.gmode = gmode;
3763 err = b43_wireless_core_init(up_dev);
3765 b43err(wl,
"Fatal: Could not initialize device for "
3766 "selected %s-GHz band\n",
3767 band_to_string(chan->
band));
3772 err = b43_wireless_core_start(up_dev);
3774 b43err(wl,
"Fatal: Could not start device for "
3775 "selected %s-GHz band\n",
3776 band_to_string(chan->
band));
3777 b43_wireless_core_exit(up_dev);
3793 static void b43_set_retry_limits(
struct b43_wldev *dev,
3794 unsigned int short_retry,
3795 unsigned int long_retry)
3799 short_retry =
min(short_retry, (
unsigned int)0xF);
3800 long_retry =
min(long_retry, (
unsigned int)0xF);
3810 struct b43_wl *wl = hw_to_b43_wl(hw);
3816 bool reload_bss =
false;
3823 err = b43_switch_band(wl, conf->
channel);
3825 goto out_unlock_mutex;
3836 if (conf_is_ht(conf))
3838 (conf_is_ht40_minus(conf) || conf_is_ht40_plus(conf));
3847 changed &= ~IEEE80211_CONF_CHANGE_RETRY_LIMITS;
3849 goto out_mac_enable;
3869 b43_mgmtframe_txantenna(dev, antenna);
3871 if (phy->
ops->set_rx_antenna)
3872 phy->
ops->set_rx_antenna(dev, antenna);
3877 b43info(dev->
wl,
"Radio turned on by software\n");
3879 b43info(dev->
wl,
"The hardware RF-kill button "
3880 "still turns the radio physically off. "
3881 "Press the button to turn it on.\n");
3885 b43info(dev->
wl,
"Radio turned off by software\n");
3894 if (wl->
vif && reload_bss)
3895 b43_op_bss_info_changed(hw, wl->
vif, &wl->
vif->bss_conf, ~0);
3900 static void b43_update_basic_rates(
struct b43_wldev *dev,
u32 brates)
3903 dev->
wl->hw->wiphy->bands[b43_current_band(dev->
wl)];
3911 if (b43_is_cck_rate(rate->
hw_value)) {
3925 if (b43_is_cck_rate(rate->
hw_value)) {
3927 basic_offset &= 0xF;
3930 basic_offset &= 0xF;
3938 direct + 2 * basic_offset);
3945 static void b43_op_bss_info_changed(
struct ieee80211_hw *hw,
3950 struct b43_wl *wl = hw_to_b43_wl(hw);
3957 goto out_unlock_mutex;
3973 b43_update_templates(wl);
3975 if (changed & BSS_CHANGED_BSSID)
3976 b43_write_mac_bssid_templates(dev);
3994 b43_short_slot_timing_enable(dev);
3996 b43_short_slot_timing_disable(dev);
4008 struct b43_wl *wl = hw_to_b43_wl(hw);
4013 static const u8 bcast_addr[
ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
4015 if (modparam_nohwcrypt)
4072 !modparam_hwtkip)) {
4084 err = b43_key_write(dev, -1, algorithm,
4089 err = b43_key_write(dev, index, algorithm,
4118 b43dbg(wl,
"%s hardware based encryption for keyidx: %d, "
4121 sta ? sta->
addr : bcast_addr);
4122 b43_dump_keymemory(dev);
4129 static void b43_op_configure_filter(
struct ieee80211_hw *hw,
4130 unsigned int changed,
unsigned int *fflags,
4133 struct b43_wl *wl = hw_to_b43_wl(hw);
4162 b43_adjust_opmode(dev);
4199 if (b43_bus_host_is_sdio(dev->
dev)) {
4212 if (b43_bus_host_is_sdio(dev->
dev)) {
4222 if (dev != orig_dev) {
4232 while (skb_queue_len(&wl->
tx_queue[queue_num]))
4238 b43dbg(wl,
"Wireless interface stopped\n");
4244 static int b43_wireless_core_start(
struct b43_wldev *dev)
4250 drain_txstatus_queue(dev);
4251 if (b43_bus_host_is_sdio(dev->
dev)) {
4254 b43err(dev->
wl,
"Cannot request SDIO IRQ\n");
4259 b43_interrupt_thread_handler,
4262 b43err(dev->
wl,
"Cannot request IRQ-%d\n",
4277 b43_periodic_tasks_setup(dev);
4281 b43dbg(dev->
wl,
"Wireless interface started\n");
4286 static char *b43_phy_name(
struct b43_wldev *dev,
u8 phy_type)
4316 static int b43_phy_versioning(
struct b43_wldev *dev)
4326 int unsupported = 0;
4339 if (phy_rev != 2 && phy_rev != 4 && phy_rev != 6
4347 #ifdef CONFIG_B43_PHY_N
4353 #ifdef CONFIG_B43_PHY_LP
4359 #ifdef CONFIG_B43_PHY_HT
4365 #ifdef CONFIG_B43_PHY_LCN
4375 b43err(dev->
wl,
"FOUND UNSUPPORTED PHY (Analog %u, Type %d (%s), Revision %u)\n",
4376 analog_type, phy_type, b43_phy_name(dev, phy_type),
4380 b43info(dev->
wl,
"Found PHY: Analog %u, Type %d (%s), Revision %u\n",
4381 analog_type, phy_type, b43_phy_name(dev, phy_type), phy_rev);
4384 if (dev->
dev->core_rev >= 24) {
4387 for (tmp = 0; tmp < 3; tmp++) {
4395 radio_manuf = 0x17F;
4396 radio_ver = (radio24[2] << 8) | radio24[1];
4397 radio_rev = (radio24[0] & 0xF);
4399 if (dev->
dev->chip_id == 0x4317) {
4400 if (dev->
dev->chip_rev == 0)
4402 else if (dev->
dev->chip_rev == 1)
4415 radio_manuf = (tmp & 0x00000FFF);
4416 radio_ver = (tmp & 0x0FFFF000) >> 12;
4417 radio_rev = (tmp & 0xF0000000) >> 28;
4420 if (radio_manuf != 0x17F )
4424 if (radio_ver != 0x2060)
4428 if (radio_manuf != 0x17F)
4432 if ((radio_ver & 0xFFF0) != 0x2050)
4436 if (radio_ver != 0x2050)
4440 if (radio_ver != 0x2055 && radio_ver != 0x2056)
4444 if (radio_ver != 0x2062 && radio_ver != 0x2063)
4448 if (radio_ver != 0x2059)
4452 if (radio_ver != 0x2064)
4459 b43err(dev->
wl,
"FOUND UNSUPPORTED RADIO "
4460 "(Manuf 0x%X, Version 0x%X, Revision %u)\n",
4461 radio_manuf, radio_ver, radio_rev);
4464 b43dbg(dev->
wl,
"Found Radio: Manuf 0x%X, Version 0x%X, Revision %u\n",
4465 radio_manuf, radio_ver, radio_rev);
4471 phy->
analog = analog_type;
4472 phy->
type = phy_type;
4478 static void setup_struct_phy_for_init(
struct b43_wldev *dev,
4487 phy->phy_locked =
false;
4488 phy->radio_locked =
false;
4492 static void setup_struct_wldev_for_init(
struct b43_wldev *dev)
4503 setup_struct_phy_for_init(dev, &dev->
phy);
4510 dev->
irq_mask &= ~B43_IRQ_PHY_TXERR;
4518 static void b43_bluetooth_coext_enable(
struct b43_wldev *dev)
4523 if (!modparam_btcoex)
4538 static void b43_bluetooth_coext_disable(
struct b43_wldev *dev)
4540 if (!modparam_btcoex)
4545 static void b43_imcfglo_timeouts_workaround(
struct b43_wldev *dev)
4553 bus = dev->
dev->sdev->bus;
4566 static void b43_set_synth_pu_delay(
struct b43_wldev *dev,
bool idle)
4577 if ((dev->
phy.radio_ver == 0x2050) && (dev->
phy.radio_rev == 8))
4578 pu_delay =
max(pu_delay, (
u16)2400);
4584 static void b43_set_pretbtt(
struct b43_wldev *dev)
4603 static void b43_wireless_core_exit(
struct b43_wldev *dev)
4610 b43_rng_exit(dev->
wl);
4621 dev->
phy.ops->switch_analog(dev, 0);
4622 if (dev->
wl->current_beacon) {
4624 dev->
wl->current_beacon =
NULL;
4627 b43_device_disable(dev, 0);
4628 b43_bus_may_powerdown(dev);
4632 static int b43_wireless_core_init(
struct b43_wldev *dev)
4641 err = b43_bus_powerup(dev, 0);
4644 if (!b43_device_is_enabled(dev))
4648 setup_struct_wldev_for_init(dev);
4649 phy->
ops->prepare_structs(dev);
4652 switch (dev->
dev->bus_type) {
4653 #ifdef CONFIG_B43_BCMA
4656 dev->
dev->bdev,
true);
4659 #ifdef CONFIG_B43_SSB
4667 b43_imcfglo_timeouts_workaround(dev);
4668 b43_bluetooth_coext_disable(dev);
4669 if (phy->
ops->prepare_hardware) {
4670 err = phy->
ops->prepare_hardware(dev);
4674 err = b43_chip_init(dev);
4695 #ifdef CONFIG_SSB_DRIVER_PCICORE
4698 dev->
dev->sdev->bus->pcicore.dev->id.revision <= 10)
4715 b43_rate_memory_init(dev);
4716 b43_set_phytxctl_defaults(dev);
4726 if (b43_bus_host_is_pcmcia(dev->
dev) ||
4727 b43_bus_host_is_sdio(dev->
dev)) {
4731 b43warn(dev->
wl,
"Forced PIO by use_pio module parameter. "
4732 "This should not be needed and will result in lower "
4743 b43_set_synth_pu_delay(dev, 1);
4744 b43_bluetooth_coext_enable(dev);
4747 b43_upload_card_macaddress(dev);
4748 b43_security_init(dev);
4755 b43_rng_init(dev->
wl);
4763 b43_bus_may_powerdown(dev);
4768 static int b43_op_add_interface(
struct ieee80211_hw *hw,
4771 struct b43_wl *wl = hw_to_b43_wl(hw);
4786 goto out_mutex_unlock;
4788 b43dbg(wl,
"Adding Interface type %d\n", vif->
type);
4796 b43_adjust_opmode(dev);
4797 b43_set_pretbtt(dev);
4798 b43_set_synth_pu_delay(dev, 0);
4799 b43_upload_card_macaddress(dev);
4806 b43_op_bss_info_changed(hw, vif, &vif->
bss_conf, ~0);
4811 static void b43_op_remove_interface(
struct ieee80211_hw *hw,
4814 struct b43_wl *wl = hw_to_b43_wl(hw);
4817 b43dbg(wl,
"Removing Interface type %d\n", vif->
type);
4827 b43_adjust_opmode(dev);
4829 b43_upload_card_macaddress(dev);
4836 struct b43_wl *wl = hw_to_b43_wl(hw);
4857 err = b43_wireless_core_init(dev);
4859 goto out_mutex_unlock;
4864 err = b43_wireless_core_start(dev);
4867 b43_wireless_core_exit(dev);
4868 goto out_mutex_unlock;
4885 b43_op_config(hw, ~0);
4892 struct b43_wl *wl = hw_to_b43_wl(hw);
4902 dev = b43_wireless_core_stop(dev);
4906 b43_wireless_core_exit(dev);
4915 static int b43_op_beacon_set_tim(
struct ieee80211_hw *hw,
4918 struct b43_wl *wl = hw_to_b43_wl(hw);
4921 b43_update_templates(wl);
4931 struct b43_wl *wl = hw_to_b43_wl(hw);
4936 static void b43_op_sw_scan_start_notifier(
struct ieee80211_hw *hw)
4938 struct b43_wl *wl = hw_to_b43_wl(hw);
4950 static void b43_op_sw_scan_complete_notifier(
struct ieee80211_hw *hw)
4952 struct b43_wl *wl = hw_to_b43_wl(hw);
4967 struct b43_wl *wl = hw_to_b43_wl(hw);
4983 .conf_tx = b43_op_conf_tx,
4984 .add_interface = b43_op_add_interface,
4985 .remove_interface = b43_op_remove_interface,
4986 .config = b43_op_config,
4987 .bss_info_changed = b43_op_bss_info_changed,
4988 .configure_filter = b43_op_configure_filter,
4989 .set_key = b43_op_set_key,
4990 .update_tkip_key = b43_op_update_tkip_key,
4991 .get_stats = b43_op_get_stats,
4992 .get_tsf = b43_op_get_tsf,
4993 .set_tsf = b43_op_set_tsf,
4994 .start = b43_op_start,
4995 .stop = b43_op_stop,
4996 .set_tim = b43_op_beacon_set_tim,
4997 .sta_notify = b43_op_sta_notify,
4998 .sw_scan_start = b43_op_sw_scan_start_notifier,
4999 .sw_scan_complete = b43_op_sw_scan_complete_notifier,
5000 .get_survey = b43_op_get_survey,
5007 static void b43_chip_reset(
struct work_struct *work)
5020 dev = b43_wireless_core_stop(dev);
5027 b43_wireless_core_exit(dev);
5031 err = b43_wireless_core_init(dev);
5036 err = b43_wireless_core_start(dev);
5038 b43_wireless_core_exit(dev);
5048 b43err(wl,
"Controller restart FAILED\n");
5053 b43_op_config(wl->
hw, ~0);
5055 b43_op_bss_info_changed(wl->
hw, wl->
vif, &wl->
vif->bss_conf, ~0);
5057 b43info(wl,
"Controller restarted\n");
5060 static int b43_setup_bands(
struct b43_wldev *dev,
5061 bool have_2ghz_phy,
bool have_5ghz_phy)
5075 dev->
phy.supports_2ghz = have_2ghz_phy;
5076 dev->
phy.supports_5ghz = have_5ghz_phy;
5081 static void b43_wireless_core_detach(
struct b43_wldev *dev)
5085 b43_release_firmware(dev);
5089 static int b43_wireless_core_attach(
struct b43_wldev *dev)
5095 bool have_2ghz_phy =
false, have_5ghz_phy =
false;
5104 #ifdef CONFIG_B43_SSB
5107 pdev = dev->
dev->sdev->bus->host_pci;
5110 err = b43_bus_powerup(dev, 0);
5112 b43err(wl,
"Bus powerup failed\n");
5117 switch (dev->
dev->bus_type) {
5118 #ifdef CONFIG_B43_BCMA
5125 #ifdef CONFIG_B43_SSB
5127 if (dev->
dev->core_rev >= 5) {
5137 dev->
phy.gmode = have_2ghz_phy;
5138 dev->
phy.radio_on =
true;
5141 err = b43_phy_versioning(dev);
5146 (pdev->
device != 0x4312 &&
5149 have_2ghz_phy =
false;
5150 have_5ghz_phy =
false;
5151 switch (dev->
phy.type) {
5153 have_5ghz_phy =
true;
5156 #if 0 //FIXME enabling 5GHz causes a NULL pointer dereference
5163 have_2ghz_phy =
true;
5171 b43err(wl,
"IEEE 802.11a devices are unsupported\n");
5179 have_2ghz_phy =
true;
5180 have_5ghz_phy =
false;
5188 dev->
phy.gmode = have_2ghz_phy;
5191 err = b43_validate_chipaccess(dev);
5194 err = b43_setup_bands(dev, have_2ghz_phy, have_5ghz_phy);
5203 dev->
phy.ops->switch_analog(dev, 0);
5204 b43_device_disable(dev, 0);
5205 b43_bus_may_powerdown(dev);
5213 b43_bus_may_powerdown(dev);
5217 static void b43_one_core_detach(
struct b43_bus_dev *dev)
5228 b43_wireless_core_detach(wldev);
5244 wldev->
use_pio = b43_modparam_pio;
5249 INIT_LIST_HEAD(&wldev->
list);
5251 err = b43_wireless_core_attach(wldev);
5253 goto err_kfree_wldev;
5268 #define IS_PDEV(pdev, _vendor, _device, _subvendor, _subdevice) ( \
5269 (pdev->vendor == PCI_VENDOR_ID_##_vendor) && \
5270 (pdev->device == _device) && \
5271 (pdev->subsystem_vendor == PCI_VENDOR_ID_##_subvendor) && \
5272 (pdev->subsystem_device == _subdevice) )
5274 static void b43_sprom_fixup(
struct ssb_bus *bus)
5280 bus->
chip_id == 0x4301 && bus->
sprom.board_rev == 0x74)
5287 if (
IS_PDEV(pdev, BROADCOM, 0x4318, ASUSTEK, 0x100F) ||
5288 IS_PDEV(pdev, BROADCOM, 0x4320, DELL, 0x0003) ||
5289 IS_PDEV(pdev, BROADCOM, 0x4320, HP, 0x12f8) ||
5290 IS_PDEV(pdev, BROADCOM, 0x4320, LINKSYS, 0x0015) ||
5291 IS_PDEV(pdev, BROADCOM, 0x4320, LINKSYS, 0x0014) ||
5292 IS_PDEV(pdev, BROADCOM, 0x4320, LINKSYS, 0x0013) ||
5316 b43err(
NULL,
"Could not allocate ieee80211 device\n");
5319 wl = hw_to_b43_wl(hw);
5325 hw->
wiphy->interface_modes =
5336 SET_IEEE80211_DEV(hw, dev->
dev);
5337 if (is_valid_ether_addr(sprom->
et1mac))
5338 SET_IEEE80211_PERM_ADDR(hw, sprom->
et1mac);
5340 SET_IEEE80211_PERM_ADDR(hw, sprom->
il0mac);
5353 skb_queue_head_init(&wl->
tx_queue[queue_num]);
5359 b43info(wl,
"Broadcom %s WLAN found (core revision %u)\n", chip_name,
5364 #ifdef CONFIG_B43_BCMA
5375 wl = b43_wireless_init(dev);
5381 err = b43_one_core_attach(dev, wl);
5383 goto bcma_err_wireless_exit;
5392 bcma_err_wireless_exit:
5397 static void b43_bcma_remove(
struct bcma_device *core)
5399 struct b43_wldev *wldev = bcma_get_drvdata(core);
5407 if (!wldev->
fw.ucode.data)
5414 b43_one_core_detach(wldev->
dev);
5422 .
name = KBUILD_MODNAME,
5423 .id_table = b43_bcma_tbl,
5424 .probe = b43_bcma_probe,
5425 .remove = b43_bcma_remove,
5429 #ifdef CONFIG_B43_SSB
5442 wl = ssb_get_devtypedata(sdev);
5446 b43_sprom_fixup(sdev->
bus);
5447 wl = b43_wireless_init(dev);
5455 err = b43_one_core_attach(dev, wl);
5457 goto err_wireless_exit;
5468 b43_wireless_exit(dev, wl);
5472 static void b43_ssb_remove(
struct ssb_device *sdev)
5474 struct b43_wl *wl = ssb_get_devtypedata(sdev);
5475 struct b43_wldev *wldev = ssb_get_drvdata(sdev);
5483 if (!wldev->
fw.ucode.data)
5490 b43_one_core_detach(dev);
5492 if (list_empty(&wl->
devlist)) {
5497 b43_wireless_exit(dev, wl);
5502 .
name = KBUILD_MODNAME,
5503 .id_table = b43_ssb_tbl,
5504 .probe = b43_ssb_probe,
5505 .remove = b43_ssb_remove,
5515 b43info(dev->
wl,
"Controller RESET (%s) ...\n", reason);
5519 static void b43_print_driverinfo(
void)
5521 const char *feat_pci =
"", *feat_pcmcia =
"", *feat_nphy =
"",
5522 *feat_leds =
"", *feat_sdio =
"";
5524 #ifdef CONFIG_B43_PCI_AUTOSELECT
5527 #ifdef CONFIG_B43_PCMCIA
5530 #ifdef CONFIG_B43_PHY_N
5533 #ifdef CONFIG_B43_LEDS
5536 #ifdef CONFIG_B43_SDIO
5540 "[ Features: %s%s%s%s%s ]\n",
5541 feat_pci, feat_pcmcia, feat_nphy,
5542 feat_leds, feat_sdio);
5545 static int __init b43_init(
void)
5555 goto err_pcmcia_exit;
5556 #ifdef CONFIG_B43_BCMA
5561 #ifdef CONFIG_B43_SSB
5564 goto err_bcma_driver_exit;
5566 b43_print_driverinfo();
5570 #ifdef CONFIG_B43_SSB
5571 err_bcma_driver_exit:
5573 #ifdef CONFIG_B43_BCMA
5585 static void __exit b43_exit(
void)
5587 #ifdef CONFIG_B43_SSB
5590 #ifdef CONFIG_B43_BCMA