Lines Matching +full:lo +full:- +full:x2 +full:- +full:en
1 // SPDX-License-Identifier: GPL-2.0-or-later
6 Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>
8 Copyright (c) 2005-2009 Michael Buesch <m@bues.ch>
11 Copyright (c) 2010-2011 Rafał Miłecki <zajec5@gmail.com>
17 driver Copyright(c) 2003 - 2004 Intel Corporation.
31 #include <linux/dma-mapping.h>
45 #include "lo.h"
86 MODULE_PARM_DESC(hwpctl, "Enable hardware-side power control (default off)");
373 if (!wl || !wl->current_dev) in b43_ratelimit()
375 if (b43_status(wl->current_dev) < B43_STAT_STARTED) in b43_ratelimit()
397 printk(KERN_INFO "b43-%s: %pV", in b43info()
398 (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan", &vaf); in b43info()
418 printk(KERN_ERR "b43-%s ERROR: %pV", in b43err()
419 (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan", &vaf); in b43err()
439 printk(KERN_WARNING "b43-%s warning: %pV", in b43warn()
440 (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan", &vaf); in b43warn()
458 printk(KERN_DEBUG "b43-%s debug: %pV", in b43dbg()
459 (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan", &vaf); in b43dbg()
587 u16 lo, mi, hi; in b43_hf_write() local
589 lo = (value & 0x00000000FFFFULL); in b43_hf_write()
592 b43_shm_write16(dev, B43_SHM_SHARED, B43_SHM_SH_HOSTF1, lo); in b43_hf_write()
600 B43_WARN_ON(!dev->fw.opensource); in b43_fwcapa_read()
608 B43_WARN_ON(dev->dev->core_rev < 3); in b43_tsf_read()
638 B43_WARN_ON(dev->dev->core_rev < 3); in b43_tsf_write_locked()
686 bssid = dev->wl->bssid; in b43_write_mac_bssid_templates()
687 mac = dev->wl->mac_addr; in b43_write_mac_bssid_templates()
707 b43_macfilter_set(dev, B43_MACFILTER_SELF, dev->wl->mac_addr); in b43_upload_card_macaddress()
714 if (b43_current_band(dev->wl) == NL80211_BAND_5GHZ) in b43_set_slot_time()
737 * https://bcm-v4.sipsolutions.net/802.11/DummyTransmission
741 struct b43_phy *phy = &dev->phy; in b43_dummy_transmission()
765 if (dev->dev->core_rev < 11) in b43_dummy_transmission()
772 if (phy->type == B43_PHYTYPE_N || phy->type == B43_PHYTYPE_LP || in b43_dummy_transmission()
773 phy->type == B43_PHYTYPE_LCN) in b43_dummy_transmission()
784 if (!pa_on && phy->type == B43_PHYTYPE_N) { in b43_dummy_transmission()
788 switch (phy->type) { in b43_dummy_transmission()
801 if (phy->radio_ver == 0x2050 && phy->radio_rev <= 0x5) in b43_dummy_transmission()
821 if (phy->radio_ver == 0x2050 && phy->radio_rev <= 0x5) in b43_dummy_transmission()
840 offset = dev->ktp + (index * B43_SEC_KEYSIZE); in key_write()
862 index -= pairwise_keys_start; in keymac_write()
883 * - if it doesn't the packet is returned without modification (and software
885 * - if it does, the rc4 key is computed, and decryption is tried.
896 * (B43_SHM_SH_KEYIDXBLOCK - B43_SHM_SH_TKIPTSCTTAK)/14 = 50
917 index -= pairwise_keys_start; in rx_tkip_phase1_write()
921 b43dbg(dev->wl, "rx_tkip_phase1_write : idx 0x%x, iv32 0x%x\n", in rx_tkip_phase1_write()
942 int index = keyconf->hw_key_idx; in b43_op_update_tkip_key()
949 B43_WARN_ON(!mutex_is_locked(&wl->mutex)); in b43_op_update_tkip_key()
950 dev = wl->current_dev; in b43_op_update_tkip_key()
959 keymac_write(dev, index, sta->addr); in b43_op_update_tkip_key()
972 B43_WARN_ON(index >= ARRAY_SIZE(dev->key)); in do_key_write()
996 dev->key[index].algorithm = algorithm; in do_key_write()
1008 /* For ALG_TKIP the key is encoded as a 256-bit (32 byte) data block: in b43_key_write()
1009 * - Temporal Encryption Key (128 bits) in b43_key_write()
1010 * - Temporal Authenticator Tx MIC Key (64 bits) in b43_key_write()
1011 * - Temporal Authenticator Rx MIC Key (64 bits) in b43_key_write()
1018 return -EINVAL; in b43_key_write()
1019 for (i = 0; i < ARRAY_SIZE(dev->key); i++) { in b43_key_write()
1021 B43_WARN_ON(dev->key[i].keyconf == keyconf); in b43_key_write()
1032 B43_WARN_ON(i >= ARRAY_SIZE(dev->key)); in b43_key_write()
1033 if (!dev->key[i].keyconf) { in b43_key_write()
1040 b43warn(dev->wl, "Out of hardware key memory\n"); in b43_key_write()
1041 return -ENOSPC; in b43_key_write()
1052 keyconf->hw_key_idx = index; in b43_key_write()
1053 dev->key[index].keyconf = keyconf; in b43_key_write()
1060 if (B43_WARN_ON((index < 0) || (index >= ARRAY_SIZE(dev->key)))) in b43_key_clear()
1061 return -EINVAL; in b43_key_clear()
1068 dev->key[index].keyconf = NULL; in b43_key_clear()
1099 b43dbg(dev->wl, "Hardware key memory dump: USEDEFKEYS=%u\n", in b43_dump_keymemory()
1109 key = &(dev->key[index]); in b43_dump_keymemory()
1111 index, (key->keyconf == NULL) ? " " : "*"); in b43_dump_keymemory()
1112 offset = dev->ktp + (index * B43_SEC_KEYSIZE); in b43_dump_keymemory()
1120 printk(" Algo: %04X/%02X", algo, key->algorithm); in b43_dump_keymemory()
1123 if (key->algorithm == B43_SEC_ALGO_TKIP) { in b43_dump_keymemory()
1125 offset = B43_SHM_SH_TKIPTSCTTAK + (index - 4) * (10 + 4); in b43_dump_keymemory()
1132 ((index - pairwise_keys_start) * 2) + 0); in b43_dump_keymemory()
1134 ((index - pairwise_keys_start) * 2) + 1); in b43_dump_keymemory()
1170 // or we are associated, or FIXME, or the latest PS-Poll packet sent was in b43_power_saving_ctl_bits()
1174 /* FIXME: For now we force awake-on and hwps-off */ in b43_power_saving_ctl_bits()
1190 if (awake && dev->dev->core_rev >= 5) { in b43_power_saving_ctl_bits()
1202 /* https://bcm-v4.sipsolutions.net/802.11/PHY/BmacCorePllReset */
1208 switch (dev->dev->bus_type) { in b43_wireless_core_phy_pll_reset()
1211 bcma_cc = &dev->dev->bdev->bus->drv_cc; in b43_wireless_core_phy_pll_reset()
1221 ssb_cc = &dev->dev->sdev->bus->chipco; in b43_wireless_core_phy_pll_reset()
1238 flags = bcma_aread32(dev->dev->bdev, BCMA_IOCTL); in b43_bcma_phy_reset()
1241 bcma_awrite32(dev->dev->bdev, BCMA_IOCTL, flags); in b43_bcma_phy_reset()
1260 if (dev->phy.type == B43_PHYTYPE_AC) { in b43_bcma_wireless_core_reset()
1263 tmp = bcma_aread32(dev->dev->bdev, BCMA_IOCTL); in b43_bcma_wireless_core_reset()
1266 bcma_awrite32(dev->dev->bdev, BCMA_IOCTL, tmp); in b43_bcma_wireless_core_reset()
1268 tmp = bcma_aread32(dev->dev->bdev, BCMA_IOCTL); in b43_bcma_wireless_core_reset()
1270 bcma_awrite32(dev->dev->bdev, BCMA_IOCTL, tmp); in b43_bcma_wireless_core_reset()
1272 tmp = bcma_aread32(dev->dev->bdev, BCMA_IOCTL); in b43_bcma_wireless_core_reset()
1274 bcma_awrite32(dev->dev->bdev, BCMA_IOCTL, tmp); in b43_bcma_wireless_core_reset()
1277 bcma_core_set_clockmode(dev->dev->bdev, BCMA_CLKMODE_FAST); in b43_bcma_wireless_core_reset()
1279 bcma_core_pll_ctl(dev->dev->bdev, req, status, true); in b43_bcma_wireless_core_reset()
1292 if (dev->phy.type == B43_PHYTYPE_N) in b43_ssb_wireless_core_reset()
1305 switch (dev->dev->bus_type) { in b43_wireless_core_reset()
1318 /* Turn Analog ON, but only if we already know the PHY-type. in b43_wireless_core_reset()
1320 * PHY-type, yet. wireless_core_reset will be called once again later, in b43_wireless_core_reset()
1321 * when we know the PHY-type. */ in b43_wireless_core_reset()
1322 if (dev->phy.ops) in b43_wireless_core_reset()
1323 dev->phy.ops->switch_analog(dev, 1); in b43_wireless_core_reset()
1365 if (dev->dev->core_rev < 5) in drain_txstatus_queue()
1408 if (dev->phy.type != B43_PHYTYPE_G) in b43_calculate_link_quality()
1410 if (dev->noisecalc.calculation_running) in b43_calculate_link_quality()
1412 dev->noisecalc.calculation_running = true; in b43_calculate_link_quality()
1413 dev->noisecalc.nr_samples = 0; in b43_calculate_link_quality()
1420 struct b43_phy_g *phy = dev->phy.g; in handle_irq_noise()
1428 if (dev->phy.type != B43_PHYTYPE_G) in handle_irq_noise()
1440 B43_WARN_ON(!dev->noisecalc.calculation_running); in handle_irq_noise()
1447 B43_WARN_ON(dev->noisecalc.nr_samples >= 8); in handle_irq_noise()
1448 i = dev->noisecalc.nr_samples; in handle_irq_noise()
1449 noise[0] = clamp_val(noise[0], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); in handle_irq_noise()
1450 noise[1] = clamp_val(noise[1], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); in handle_irq_noise()
1451 noise[2] = clamp_val(noise[2], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); in handle_irq_noise()
1452 noise[3] = clamp_val(noise[3], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); in handle_irq_noise()
1453 dev->noisecalc.samples[i][0] = phy->nrssi_lt[noise[0]]; in handle_irq_noise()
1454 dev->noisecalc.samples[i][1] = phy->nrssi_lt[noise[1]]; in handle_irq_noise()
1455 dev->noisecalc.samples[i][2] = phy->nrssi_lt[noise[2]]; in handle_irq_noise()
1456 dev->noisecalc.samples[i][3] = phy->nrssi_lt[noise[3]]; in handle_irq_noise()
1457 dev->noisecalc.nr_samples++; in handle_irq_noise()
1458 if (dev->noisecalc.nr_samples == 8) { in handle_irq_noise()
1463 average += dev->noisecalc.samples[i][j]; in handle_irq_noise()
1474 average -= 25; in handle_irq_noise()
1476 average -= 72; in handle_irq_noise()
1478 average -= 48; in handle_irq_noise()
1480 dev->stats.link_noise = average; in handle_irq_noise()
1481 dev->noisecalc.calculation_running = false; in handle_irq_noise()
1490 if (b43_is_mode(dev->wl, NL80211_IFTYPE_AP)) { in handle_irq_tbtt_indication()
1496 if (b43_is_mode(dev->wl, NL80211_IFTYPE_ADHOC)) in handle_irq_tbtt_indication()
1497 dev->dfq_valid = true; in handle_irq_tbtt_indication()
1502 if (dev->dfq_valid) { in handle_irq_atim_end()
1506 dev->dfq_valid = false; in handle_irq_atim_end()
1552 b43_ram_write(dev, ram_offset + i - 2, tmp); in b43_write_template_common()
1572 if (dev->phy.gmode) in b43_ieee80211_antenna_sanitize()
1573 antenna_mask = dev->dev->bus_sprom->ant_available_bg; in b43_ieee80211_antenna_sanitize()
1575 antenna_mask = dev->dev->bus_sprom->ant_available_a; in b43_ieee80211_antenna_sanitize()
1577 if (!(antenna_mask & (1 << (antenna_nr - 1)))) { in b43_ieee80211_antenna_sanitize()
1620 spin_lock_irqsave(&dev->wl->beacon_lock, flags); in b43_write_beacon_template()
1621 info = IEEE80211_SKB_CB(dev->wl->current_beacon); in b43_write_beacon_template()
1622 rate = ieee80211_get_tx_rate(dev->wl->hw, info)->hw_value; in b43_write_beacon_template()
1624 beacon_skb = skb_clone(dev->wl->current_beacon, GFP_ATOMIC); in b43_write_beacon_template()
1625 spin_unlock_irqrestore(&dev->wl->beacon_lock, flags); in b43_write_beacon_template()
1628 b43dbg(dev->wl, "Could not upload beacon. " in b43_write_beacon_template()
1633 bcn = (const struct ieee80211_mgmt *)(beacon_skb->data); in b43_write_beacon_template()
1634 len = min_t(size_t, beacon_skb->len, in b43_write_beacon_template()
1635 0x200 - sizeof(struct b43_plcp_hdr6)); in b43_write_beacon_template()
1657 ie = bcn->u.beacon.variable; in b43_write_beacon_template()
1658 variable_len = len - offsetof(struct ieee80211_mgmt, u.beacon.variable); in b43_write_beacon_template()
1659 for (i = 0; i < variable_len - 2; ) { in b43_write_beacon_template()
1702 b43dbg(dev->wl, "Updated beacon template at 0x%x\n", ram_offset); in b43_write_beacon_template()
1709 struct b43_wl *wl = dev->wl; in b43_upload_beacon0()
1711 if (wl->beacon0_uploaded) in b43_upload_beacon0()
1714 wl->beacon0_uploaded = true; in b43_upload_beacon0()
1719 struct b43_wl *wl = dev->wl; in b43_upload_beacon1()
1721 if (wl->beacon1_uploaded) in b43_upload_beacon1()
1724 wl->beacon1_uploaded = true; in b43_upload_beacon1()
1729 struct b43_wl *wl = dev->wl; in handle_irq_beacon()
1740 dev->irq_mask &= ~B43_IRQ_BEACON; in handle_irq_beacon()
1749 dev->irq_mask |= B43_IRQ_BEACON; in handle_irq_beacon()
1753 if (unlikely(wl->beacon_templates_virgin)) { in handle_irq_beacon()
1756 wl->beacon_templates_virgin = false; in handle_irq_beacon()
1779 u32 old_irq_mask = dev->irq_mask; in b43_do_beacon_update_trigger_work()
1783 if (old_irq_mask != dev->irq_mask) { in b43_do_beacon_update_trigger_work()
1785 B43_WARN_ON(!dev->irq_mask); in b43_do_beacon_update_trigger_work()
1787 b43_write32(dev, B43_MMIO_GEN_IRQ_MASK, dev->irq_mask); in b43_do_beacon_update_trigger_work()
1793 * the mask _here_ would incorrectly re-enable IRQs. */ in b43_do_beacon_update_trigger_work()
1804 mutex_lock(&wl->mutex); in b43_beacon_update_trigger_work()
1805 dev = wl->current_dev; in b43_beacon_update_trigger_work()
1807 if (b43_bus_host_is_sdio(dev->dev)) { in b43_beacon_update_trigger_work()
1808 /* wl->mutex is enough. */ in b43_beacon_update_trigger_work()
1811 spin_lock_irq(&wl->hardirq_lock); in b43_beacon_update_trigger_work()
1813 spin_unlock_irq(&wl->hardirq_lock); in b43_beacon_update_trigger_work()
1816 mutex_unlock(&wl->mutex); in b43_beacon_update_trigger_work()
1835 beacon = ieee80211_beacon_get(wl->hw, wl->vif, 0); in b43_update_templates()
1839 spin_lock_irqsave(&wl->beacon_lock, flags); in b43_update_templates()
1840 old_beacon = wl->current_beacon; in b43_update_templates()
1841 wl->current_beacon = beacon; in b43_update_templates()
1842 wl->beacon0_uploaded = false; in b43_update_templates()
1843 wl->beacon1_uploaded = false; in b43_update_templates()
1844 spin_unlock_irqrestore(&wl->beacon_lock, flags); in b43_update_templates()
1846 ieee80211_queue_work(wl->hw, &wl->beacon_update_trigger); in b43_update_templates()
1855 if (dev->dev->core_rev >= 3) { in b43_set_beacon_int()
1863 b43dbg(dev->wl, "Set beacon interval to %u\n", beacon_int); in b43_set_beacon_int()
1872 b43err(dev->wl, "Whoopsy, firmware panic! Reason: %u\n", reason); in b43_handle_firmware_panic()
1876 b43dbg(dev->wl, "The panic reason is unknown.\n"); in b43_handle_firmware_panic()
1897 if (!dev->fw.opensource) in handle_irq_ucode_debug()
1912 b43dbg(dev->wl, "SHM-dump: Failed to allocate memory\n"); in handle_irq_ucode_debug()
1919 b43info(dev->wl, "Shared memory dump:\n"); in handle_irq_ucode_debug()
1927 b43info(dev->wl, "Microcode register dump:\n"); in handle_irq_ucode_debug()
1948 b43info(dev->wl, "The firmware just executed the MARKER(%u) " in handle_irq_ucode_debug()
1953 b43dbg(dev->wl, "Debug-IRQ triggered for unknown reason: %u\n", in handle_irq_ucode_debug()
1957 /* Acknowledge the debug-IRQ, so the firmware can continue. */ in handle_irq_ucode_debug()
1965 u32 dma_reason[ARRAY_SIZE(dev->dma_reason)]; in b43_do_interrupt_thread()
1972 reason = dev->irq_reason; in b43_do_interrupt_thread()
1974 dma_reason[i] = dev->dma_reason[i]; in b43_do_interrupt_thread()
1979 b43err(dev->wl, "MAC transmission error\n"); in b43_do_interrupt_thread()
1982 b43err(dev->wl, "PHY transmission error\n"); in b43_do_interrupt_thread()
1984 if (unlikely(atomic_dec_and_test(&dev->phy.txerr_cnt))) { in b43_do_interrupt_thread()
1985 atomic_set(&dev->phy.txerr_cnt, in b43_do_interrupt_thread()
1987 b43err(dev->wl, "Too many PHY TX errors, " in b43_do_interrupt_thread()
1994 b43err(dev->wl, in b43_do_interrupt_thread()
1999 b43err(dev->wl, "This device does not support DMA " in b43_do_interrupt_thread()
2002 dev->use_pio = true; in b43_do_interrupt_thread()
2026 b43warn(dev->wl, "RX descriptor underrun\n"); in b43_do_interrupt_thread()
2027 b43_dma_handle_rx_overflow(dev->dma.rx_ring); in b43_do_interrupt_thread()
2031 b43_pio_rx(dev->pio.rx_queue); in b43_do_interrupt_thread()
2033 b43_dma_rx(dev->dma.rx_ring); in b43_do_interrupt_thread()
2044 /* Re-enable interrupts on the device by restoring the current interrupt mask. */ in b43_do_interrupt_thread()
2045 b43_write32(dev, B43_MMIO_GEN_IRQ_MASK, dev->irq_mask); in b43_do_interrupt_thread()
2049 dev->irq_count++; in b43_do_interrupt_thread()
2050 for (i = 0; i < ARRAY_SIZE(dev->irq_bit_count); i++) { in b43_do_interrupt_thread()
2052 dev->irq_bit_count[i]++; in b43_do_interrupt_thread()
2063 mutex_lock(&dev->wl->mutex); in b43_interrupt_thread_handler()
2065 mutex_unlock(&dev->wl->mutex); in b43_interrupt_thread_handler()
2074 /* This code runs under wl->hardirq_lock, but _only_ on non-SDIO busses. in b43_do_interrupt()
2075 * On SDIO, this runs under wl->mutex. */ in b43_do_interrupt()
2080 reason &= dev->irq_mask; in b43_do_interrupt()
2084 dev->dma_reason[0] = b43_read32(dev, B43_MMIO_DMA0_REASON) in b43_do_interrupt()
2086 dev->dma_reason[1] = b43_read32(dev, B43_MMIO_DMA1_REASON) in b43_do_interrupt()
2088 dev->dma_reason[2] = b43_read32(dev, B43_MMIO_DMA2_REASON) in b43_do_interrupt()
2090 dev->dma_reason[3] = b43_read32(dev, B43_MMIO_DMA3_REASON) in b43_do_interrupt()
2092 dev->dma_reason[4] = b43_read32(dev, B43_MMIO_DMA4_REASON) in b43_do_interrupt()
2095 dev->dma_reason[5] = b43_read32(dev, B43_MMIO_DMA5_REASON) in b43_do_interrupt()
2101 b43_write32(dev, B43_MMIO_DMA0_REASON, dev->dma_reason[0]); in b43_do_interrupt()
2102 b43_write32(dev, B43_MMIO_DMA1_REASON, dev->dma_reason[1]); in b43_do_interrupt()
2103 b43_write32(dev, B43_MMIO_DMA2_REASON, dev->dma_reason[2]); in b43_do_interrupt()
2104 b43_write32(dev, B43_MMIO_DMA3_REASON, dev->dma_reason[3]); in b43_do_interrupt()
2105 b43_write32(dev, B43_MMIO_DMA4_REASON, dev->dma_reason[4]); in b43_do_interrupt()
2107 b43_write32(dev, B43_MMIO_DMA5_REASON, dev->dma_reason[5]); in b43_do_interrupt()
2110 /* Disable IRQs on the device. The IRQ thread handler will re-enable them. */ in b43_do_interrupt()
2113 dev->irq_reason = reason; in b43_do_interrupt()
2118 /* Interrupt handler top-half. This runs with interrupts disabled. */
2127 spin_lock(&dev->wl->hardirq_lock); in b43_interrupt_handler()
2129 spin_unlock(&dev->wl->hardirq_lock); in b43_interrupt_handler()
2137 struct b43_wl *wl = dev->wl; in b43_sdio_interrupt_handler()
2140 mutex_lock(&wl->mutex); in b43_sdio_interrupt_handler()
2146 mutex_unlock(&wl->mutex); in b43_sdio_interrupt_handler()
2151 release_firmware(fw->data); in b43_do_release_fw()
2152 fw->data = NULL; in b43_do_release_fw()
2153 fw->filename = NULL; in b43_do_release_fw()
2158 complete(&dev->fw_load_complete); in b43_release_firmware()
2159 b43_do_release_fw(&dev->fw.ucode); in b43_release_firmware()
2160 b43_do_release_fw(&dev->fw.pcm); in b43_release_firmware()
2161 b43_do_release_fw(&dev->fw.initvals); in b43_release_firmware()
2162 b43_do_release_fw(&dev->fw.initvals_band); in b43_release_firmware()
2169 "https://wireless.wiki.kernel.org/en/users/Drivers/b43#devicefirmware " \ in b43_print_fw_helptext()
2183 ctx->blob = firmware; in b43_fw_cb()
2184 complete(&ctx->dev->fw_load_complete); in b43_fw_cb()
2202 if (fw->filename) { in b43_do_request_fw()
2203 if ((fw->type == ctx->req_type) && in b43_do_request_fw()
2204 (strcmp(fw->filename, name) == 0)) in b43_do_request_fw()
2214 switch (ctx->req_type) { in b43_do_request_fw()
2216 snprintf(ctx->fwname, sizeof(ctx->fwname), in b43_do_request_fw()
2221 snprintf(ctx->fwname, sizeof(ctx->fwname), in b43_do_request_fw()
2222 "b43-open%s/%s.fw", in b43_do_request_fw()
2227 return -ENOSYS; in b43_do_request_fw()
2231 init_completion(&ctx->dev->fw_load_complete); in b43_do_request_fw()
2232 err = request_firmware_nowait(THIS_MODULE, 1, ctx->fwname, in b43_do_request_fw()
2233 ctx->dev->dev->dev, GFP_KERNEL, in b43_do_request_fw()
2239 wait_for_completion(&ctx->dev->fw_load_complete); in b43_do_request_fw()
2240 if (ctx->blob) in b43_do_request_fw()
2246 err = request_firmware(&ctx->blob, ctx->fwname, in b43_do_request_fw()
2247 ctx->dev->dev->dev); in b43_do_request_fw()
2248 if (err == -ENOENT) { in b43_do_request_fw()
2249 snprintf(ctx->errors[ctx->req_type], in b43_do_request_fw()
2250 sizeof(ctx->errors[ctx->req_type]), in b43_do_request_fw()
2252 ctx->fwname); in b43_do_request_fw()
2255 snprintf(ctx->errors[ctx->req_type], in b43_do_request_fw()
2256 sizeof(ctx->errors[ctx->req_type]), in b43_do_request_fw()
2258 ctx->fwname, err); in b43_do_request_fw()
2262 if (ctx->blob->size < sizeof(struct b43_fw_header)) in b43_do_request_fw()
2264 hdr = (struct b43_fw_header *)(ctx->blob->data); in b43_do_request_fw()
2265 switch (hdr->type) { in b43_do_request_fw()
2268 size = be32_to_cpu(hdr->size); in b43_do_request_fw()
2269 if (size != ctx->blob->size - sizeof(struct b43_fw_header)) in b43_do_request_fw()
2273 if (hdr->ver != 1) in b43_do_request_fw()
2280 fw->data = ctx->blob; in b43_do_request_fw()
2281 fw->filename = name; in b43_do_request_fw()
2282 fw->type = ctx->req_type; in b43_do_request_fw()
2287 snprintf(ctx->errors[ctx->req_type], in b43_do_request_fw()
2288 sizeof(ctx->errors[ctx->req_type]), in b43_do_request_fw()
2289 "Firmware file \"%s\" format error.\n", ctx->fwname); in b43_do_request_fw()
2290 release_firmware(ctx->blob); in b43_do_request_fw()
2292 return -EPROTO; in b43_do_request_fw()
2295 /* https://bcm-v4.sipsolutions.net/802.11/Init/Firmware */
2298 struct b43_wldev *dev = ctx->dev; in b43_try_request_fw()
2299 struct b43_firmware *fw = &ctx->dev->fw; in b43_try_request_fw()
2300 struct b43_phy *phy = &dev->phy; in b43_try_request_fw()
2301 const u8 rev = ctx->dev->dev->core_rev; in b43_try_request_fw()
2309 if (phy->type == B43_PHYTYPE_AC) in b43_try_request_fw()
2313 if (phy->type == B43_PHYTYPE_AC) in b43_try_request_fw()
2317 if (phy->type == B43_PHYTYPE_LCN40) in b43_try_request_fw()
2321 if (phy->type == B43_PHYTYPE_N) in b43_try_request_fw()
2325 if (phy->type == B43_PHYTYPE_HT) in b43_try_request_fw()
2329 if (phy->type == B43_PHYTYPE_HT) in b43_try_request_fw()
2334 if (phy->type == B43_PHYTYPE_N) in b43_try_request_fw()
2336 else if (phy->type == B43_PHYTYPE_LCN) in b43_try_request_fw()
2340 if (phy->type == B43_PHYTYPE_LCN) in b43_try_request_fw()
2344 if (phy->type == B43_PHYTYPE_N) in b43_try_request_fw()
2348 if (phy->type == B43_PHYTYPE_N) in b43_try_request_fw()
2350 else if (phy->type == B43_PHYTYPE_LP) in b43_try_request_fw()
2371 err = b43_do_request_fw(ctx, filename, &fw->ucode, true); in b43_try_request_fw()
2382 fw->pcm_request_failed = false; in b43_try_request_fw()
2383 err = b43_do_request_fw(ctx, filename, &fw->pcm, false); in b43_try_request_fw()
2384 if (err == -ENOENT) { in b43_try_request_fw()
2387 fw->pcm_request_failed = true; in b43_try_request_fw()
2393 switch (dev->phy.type) { in b43_try_request_fw()
2447 err = b43_do_request_fw(ctx, filename, &fw->initvals, false); in b43_try_request_fw()
2453 switch (dev->phy.type) { in b43_try_request_fw()
2507 err = b43_do_request_fw(ctx, filename, &fw->initvals_band, false); in b43_try_request_fw()
2511 fw->opensource = (ctx->req_type == B43_FWTYPE_OPENSOURCE); in b43_try_request_fw()
2516 err = ctx->fatal_failure = -EOPNOTSUPP; in b43_try_request_fw()
2517 b43err(dev->wl, "The driver does not know which firmware (ucode) " in b43_try_request_fw()
2518 "is required for your device (wl-core rev %u)\n", rev); in b43_try_request_fw()
2522 err = ctx->fatal_failure = -EOPNOTSUPP; in b43_try_request_fw()
2523 b43err(dev->wl, "The driver does not know which firmware (PCM) " in b43_try_request_fw()
2524 "is required for your device (wl-core rev %u)\n", rev); in b43_try_request_fw()
2528 err = ctx->fatal_failure = -EOPNOTSUPP; in b43_try_request_fw()
2529 b43err(dev->wl, "The driver does not know which firmware (initvals) " in b43_try_request_fw()
2530 "is required for your device (wl-core rev %u)\n", rev); in b43_try_request_fw()
2535 * already is in ctx->errors. Return and let our caller decide in b43_try_request_fw()
2552 struct b43_wldev *dev = wl->current_dev; in b43_request_firmware()
2561 ctx->dev = dev; in b43_request_firmware()
2563 ctx->req_type = B43_FWTYPE_PROPRIETARY; in b43_request_firmware()
2568 if (ctx->fatal_failure) in b43_request_firmware()
2572 ctx->req_type = B43_FWTYPE_OPENSOURCE; in b43_request_firmware()
2576 if(ctx->fatal_failure) in b43_request_firmware()
2581 errmsg = ctx->errors[i]; in b43_request_firmware()
2583 b43err(dev->wl, "%s", errmsg); in b43_request_firmware()
2585 b43_print_fw_helptext(dev->wl, 1); in b43_request_firmware()
2589 wl->hw->queues = B43_QOS_QUEUE_NUM; in b43_request_firmware()
2590 if (!modparam_qos || dev->fw.opensource) in b43_request_firmware()
2591 wl->hw->queues = 1; in b43_request_firmware()
2593 err = ieee80211_register_hw(wl->hw); in b43_request_firmware()
2596 wl->hw_registered = true; in b43_request_firmware()
2597 b43_leds_register(wl->current_dev); in b43_request_firmware()
2608 struct wiphy *wiphy = dev->wl->hw->wiphy; in b43_upload_microcode()
2628 data = (__be32 *) (dev->fw.ucode.data->data + hdr_len); in b43_upload_microcode()
2629 len = (dev->fw.ucode.data->size - hdr_len) / sizeof(__be32); in b43_upload_microcode()
2636 if (dev->fw.pcm.data) { in b43_upload_microcode()
2638 data = (__be32 *) (dev->fw.pcm.data->data + hdr_len); in b43_upload_microcode()
2639 len = (dev->fw.pcm.data->size - hdr_len) / sizeof(__be32); in b43_upload_microcode()
2664 b43err(dev->wl, "Microcode not responding\n"); in b43_upload_microcode()
2665 b43_print_fw_helptext(dev->wl, 1); in b43_upload_microcode()
2666 err = -ENODEV; in b43_upload_microcode()
2680 b43err(dev->wl, "YOUR FIRMWARE IS TOO OLD. Firmware from " in b43_upload_microcode()
2683 b43_print_fw_helptext(dev->wl, 1); in b43_upload_microcode()
2684 err = -EOPNOTSUPP; in b43_upload_microcode()
2687 dev->fw.rev = fwrev; in b43_upload_microcode()
2688 dev->fw.patch = fwpatch; in b43_upload_microcode()
2689 if (dev->fw.rev >= 598) in b43_upload_microcode()
2690 dev->fw.hdr_format = B43_FW_HDR_598; in b43_upload_microcode()
2691 else if (dev->fw.rev >= 410) in b43_upload_microcode()
2692 dev->fw.hdr_format = B43_FW_HDR_410; in b43_upload_microcode()
2694 dev->fw.hdr_format = B43_FW_HDR_351; in b43_upload_microcode()
2695 WARN_ON(dev->fw.opensource != (fwdate == 0xFFFF)); in b43_upload_microcode()
2697 dev->qos_enabled = dev->wl->hw->queues > 1; in b43_upload_microcode()
2699 dev->hwcrypto_enabled = true; in b43_upload_microcode()
2701 if (dev->fw.opensource) { in b43_upload_microcode()
2705 dev->fw.patch = fwtime; in b43_upload_microcode()
2706 b43info(dev->wl, "Loading OpenSource firmware version %u.%u\n", in b43_upload_microcode()
2707 dev->fw.rev, dev->fw.patch); in b43_upload_microcode()
2710 if (!(fwcapa & B43_FWCAPA_HWCRYPTO) || dev->fw.pcm_request_failed) { in b43_upload_microcode()
2711 b43info(dev->wl, "Hardware crypto acceleration not supported by firmware\n"); in b43_upload_microcode()
2713 dev->hwcrypto_enabled = false; in b43_upload_microcode()
2718 b43info(dev->wl, "Loading firmware version %u.%u " in b43_upload_microcode()
2719 "(20%.2i-%.2i-%.2i %.2i:%.2i:%.2i)\n", in b43_upload_microcode()
2723 if (dev->fw.pcm_request_failed) { in b43_upload_microcode()
2724 b43warn(dev->wl, "No \"pcm5.fw\" firmware file found. " in b43_upload_microcode()
2726 b43_print_fw_helptext(dev->wl, 0); in b43_upload_microcode()
2730 snprintf(wiphy->fw_version, sizeof(wiphy->fw_version), "%u.%u", in b43_upload_microcode()
2731 dev->fw.rev, dev->fw.patch); in b43_upload_microcode()
2732 wiphy->hw_version = dev->dev->core_id; in b43_upload_microcode()
2734 if (dev->fw.hdr_format == B43_FW_HDR_351) { in b43_upload_microcode()
2737 b43warn(dev->wl, "You are using an old firmware image. " in b43_upload_microcode()
2740 b43_print_fw_helptext(dev->wl, 0); in b43_upload_microcode()
2766 if (array_size < sizeof(iv->offset_size)) in b43_write_initvals()
2768 array_size -= sizeof(iv->offset_size); in b43_write_initvals()
2769 offset = be16_to_cpu(iv->offset_size); in b43_write_initvals()
2777 if (array_size < sizeof(iv->data.d32)) in b43_write_initvals()
2779 array_size -= sizeof(iv->data.d32); in b43_write_initvals()
2781 value = get_unaligned_be32(&iv->data.d32); in b43_write_initvals()
2790 if (array_size < sizeof(iv->data.d16)) in b43_write_initvals()
2792 array_size -= sizeof(iv->data.d16); in b43_write_initvals()
2794 value = be16_to_cpu(iv->data.d16); in b43_write_initvals()
2808 b43err(dev->wl, "Initial Values Firmware file-format error.\n"); in b43_write_initvals()
2809 b43_print_fw_helptext(dev->wl, 1); in b43_write_initvals()
2811 return -EPROTO; in b43_write_initvals()
2818 struct b43_firmware *fw = &dev->fw; in b43_upload_initvals()
2822 hdr = (const struct b43_fw_header *)(fw->initvals.data->data); in b43_upload_initvals()
2823 ivals = (const struct b43_iv *)(fw->initvals.data->data + hdr_len); in b43_upload_initvals()
2824 count = be32_to_cpu(hdr->size); in b43_upload_initvals()
2826 fw->initvals.data->size - hdr_len); in b43_upload_initvals()
2833 struct b43_firmware *fw = &dev->fw; in b43_upload_initvals_band()
2837 if (!fw->initvals_band.data) in b43_upload_initvals_band()
2840 hdr = (const struct b43_fw_header *)(fw->initvals_band.data->data); in b43_upload_initvals_band()
2841 ivals = (const struct b43_iv *)(fw->initvals_band.data->data + hdr_len); in b43_upload_initvals_band()
2842 count = be32_to_cpu(hdr->size); in b43_upload_initvals_band()
2844 fw->initvals_band.data->size - hdr_len); in b43_upload_initvals_band()
2848 * https://bcm-specs.sipsolutions.net/GPIO
2854 struct ssb_bus *bus = dev->dev->sdev->bus; in b43_ssb_gpio_dev()
2857 return (bus->chipco.dev ? bus->chipco.dev : bus->pcicore.dev); in b43_ssb_gpio_dev()
2859 return bus->chipco.dev; in b43_ssb_gpio_dev()
2876 if (dev->dev->chip_id == 0x4301) { in b43_gpio_init()
2879 } else if (dev->dev->chip_id == 0x5354) { in b43_gpio_init()
2881 set &= 0x2; /* 0x2 is LED GPIO on BCM5354 */ in b43_gpio_init()
2895 if (dev->dev->bus_sprom->boardflags_lo & B43_BFL_PACTRL) { in b43_gpio_init()
2904 switch (dev->dev->bus_type) { in b43_gpio_init()
2907 bcma_chipco_gpio_control(&dev->dev->bdev->bus->drv_cc, mask, set); in b43_gpio_init()
2931 switch (dev->dev->bus_type) { in b43_gpio_cleanup()
2934 bcma_chipco_gpio_control(&dev->dev->bdev->bus->drv_cc, ~0, 0); in b43_gpio_cleanup()
2947 /* http://bcm-specs.sipsolutions.net/EnableMac */
2957 b43err(dev->wl, "b43_mac_enable(): The firmware " in b43_mac_enable()
2963 dev->mac_suspended--; in b43_mac_enable()
2964 B43_WARN_ON(dev->mac_suspended < 0); in b43_mac_enable()
2965 if (dev->mac_suspended == 0) { in b43_mac_enable()
2976 /* https://bcm-specs.sipsolutions.net/SuspendMAC */
2983 B43_WARN_ON(dev->mac_suspended < 0); in b43_mac_suspend()
2985 if (dev->mac_suspended == 0) { in b43_mac_suspend()
2990 for (i = 35; i; i--) { in b43_mac_suspend()
2997 for (i = 40; i; i--) { in b43_mac_suspend()
3003 b43err(dev->wl, "MAC suspend failed\n"); in b43_mac_suspend()
3006 dev->mac_suspended++; in b43_mac_suspend()
3009 /* https://bcm-v4.sipsolutions.net/802.11/PHY/N/MacPhyClkSet */
3014 switch (dev->dev->bus_type) { in b43_mac_phy_clock_set()
3017 tmp = bcma_aread32(dev->dev->bdev, BCMA_IOCTL); in b43_mac_phy_clock_set()
3022 bcma_awrite32(dev->dev->bdev, BCMA_IOCTL, tmp); in b43_mac_phy_clock_set()
3027 tmp = ssb_read32(dev->dev->sdev, SSB_TMSLOW); in b43_mac_phy_clock_set()
3032 ssb_write32(dev->dev->sdev, SSB_TMSLOW, tmp); in b43_mac_phy_clock_set()
3041 u16 chip_id = dev->dev->chip_id; in b43_mac_switch_freq()
3079 } else if (dev->phy.type == B43_PHYTYPE_LCN) { in b43_mac_switch_freq()
3095 struct b43_wl *wl = dev->wl; in b43_adjust_opmode()
3115 if (wl->filter_flags & FIF_CONTROL) in b43_adjust_opmode()
3117 if (wl->filter_flags & FIF_FCSFAIL) in b43_adjust_opmode()
3119 if (wl->filter_flags & FIF_PLCPFAIL) in b43_adjust_opmode()
3121 if (wl->filter_flags & FIF_BCN_PRBRESP_PROMISC) in b43_adjust_opmode()
3124 /* Workaround: On old hardware the HW-MAC-address-filter in b43_adjust_opmode()
3127 if (dev->dev->core_rev <= 4) in b43_adjust_opmode()
3134 if (dev->dev->chip_id == 0x4306 && in b43_adjust_opmode()
3135 dev->dev->chip_rev == 3) in b43_adjust_opmode()
3169 switch (dev->phy.type) { in b43_rate_memory_init()
3209 /* Set the TX-Antenna for management frames sent by firmware. */
3236 * https://bcm-specs.sipsolutions.net/ChipInit
3240 struct b43_phy *phy = &dev->phy; in b43_chip_init()
3247 if (dev->phy.gmode) in b43_chip_init()
3269 phy->ops->switch_analog(dev, 1); in b43_chip_init()
3275 if (phy->ops->interf_mitigation) in b43_chip_init()
3276 phy->ops->interf_mitigation(dev, B43_INTERFMODE_NONE); in b43_chip_init()
3279 if (phy->ops->set_rx_antenna) in b43_chip_init()
3280 phy->ops->set_rx_antenna(dev, B43_ANTENNA_DEFAULT); in b43_chip_init()
3283 if (phy->type == B43_PHYTYPE_B) { in b43_chip_init()
3289 if (dev->dev->core_rev < 5) in b43_chip_init()
3296 /* FIXME: Default to 0, has to be set by ioctl probably... :-/ */ in b43_chip_init()
3302 if (dev->dev->core_rev < 3) { in b43_chip_init()
3321 switch (dev->dev->bus_type) { in b43_chip_init()
3331 dev->dev->sdev->bus->chipco.fast_pwrup_delay); in b43_chip_init()
3337 b43dbg(dev->wl, "Chip initialized\n"); in b43_chip_init()
3348 const struct b43_phy_operations *ops = dev->phy.ops; in b43_periodic_every60sec()
3350 if (ops->pwork_60sec) in b43_periodic_every60sec()
3351 ops->pwork_60sec(dev); in b43_periodic_every60sec()
3365 struct b43_phy *phy = &dev->phy; in b43_periodic_every15sec()
3368 if (dev->fw.opensource) { in b43_periodic_every15sec()
3373 b43err(dev->wl, "Firmware watchdog: The firmware died!\n"); in b43_periodic_every15sec()
3382 if (phy->ops->pwork_15sec) in b43_periodic_every15sec()
3383 phy->ops->pwork_15sec(dev); in b43_periodic_every15sec()
3385 atomic_set(&phy->txerr_cnt, B43_PHY_TX_BADNESS_LIMIT); in b43_periodic_every15sec()
3392 b43dbg(dev->wl, "Stats: %7u IRQs/sec, %7u TX/sec, %7u RX/sec\n", in b43_periodic_every15sec()
3393 dev->irq_count / 15, in b43_periodic_every15sec()
3394 dev->tx_count / 15, in b43_periodic_every15sec()
3395 dev->rx_count / 15); in b43_periodic_every15sec()
3396 dev->irq_count = 0; in b43_periodic_every15sec()
3397 dev->tx_count = 0; in b43_periodic_every15sec()
3398 dev->rx_count = 0; in b43_periodic_every15sec()
3399 for (i = 0; i < ARRAY_SIZE(dev->irq_bit_count); i++) { in b43_periodic_every15sec()
3400 if (dev->irq_bit_count[i]) { in b43_periodic_every15sec()
3401 b43dbg(dev->wl, "Stats: %7u IRQ-%02u/sec (0x%08X)\n", in b43_periodic_every15sec()
3402 dev->irq_bit_count[i] / 15, i, (1 << i)); in b43_periodic_every15sec()
3403 dev->irq_bit_count[i] = 0; in b43_periodic_every15sec()
3414 state = dev->periodic_state; in do_periodic_work()
3424 * wl->mutex. If another lock is needed somewhere in the
3425 * pwork callchain, it's acquired in-place, where it's needed.
3431 struct b43_wl *wl = dev->wl; in b43_periodic_work_handler()
3434 mutex_lock(&wl->mutex); in b43_periodic_work_handler()
3443 dev->periodic_state++; in b43_periodic_work_handler()
3449 ieee80211_queue_delayed_work(wl->hw, &dev->periodic_work, delay); in b43_periodic_work_handler()
3451 mutex_unlock(&wl->mutex); in b43_periodic_work_handler()
3456 struct delayed_work *work = &dev->periodic_work; in b43_periodic_tasks_setup()
3458 dev->periodic_state = 0; in b43_periodic_tasks_setup()
3460 ieee80211_queue_delayed_work(dev->wl->hw, work, 0); in b43_periodic_tasks_setup()
3486 b43warn(dev->wl, "Unaligned 32bit SHM read access is broken\n"); in b43_validate_chipaccess()
3492 b43warn(dev->wl, "Unaligned 32bit SHM write access is broken\n"); in b43_validate_chipaccess()
3497 if ((dev->dev->core_rev >= 3) && (dev->dev->core_rev <= 10)) { in b43_validate_chipaccess()
3516 b43err(dev->wl, "Failed to validate the chipaccess\n"); in b43_validate_chipaccess()
3517 return -ENODEV; in b43_validate_chipaccess()
3522 dev->ktp = b43_shm_read16(dev, B43_SHM_SHARED, B43_SHM_SH_KTP); in b43_security_init()
3526 dev->ktp *= 2; in b43_security_init()
3536 struct b43_wl *wl = (struct b43_wl *)rng->priv; in b43_rng_read()
3538 int count = -ENODEV; in b43_rng_read()
3540 mutex_lock(&wl->mutex); in b43_rng_read()
3541 dev = wl->current_dev; in b43_rng_read()
3546 mutex_unlock(&wl->mutex); in b43_rng_read()
3555 if (wl->rng_initialized) in b43_rng_exit()
3556 hwrng_unregister(&wl->rng); in b43_rng_exit()
3565 snprintf(wl->rng_name, ARRAY_SIZE(wl->rng_name), in b43_rng_init()
3566 "%s_%s", KBUILD_MODNAME, wiphy_name(wl->hw->wiphy)); in b43_rng_init()
3567 wl->rng.name = wl->rng_name; in b43_rng_init()
3568 wl->rng.data_read = b43_rng_read; in b43_rng_init()
3569 wl->rng.priv = (unsigned long)wl; in b43_rng_init()
3570 wl->rng_initialized = true; in b43_rng_init()
3571 err = hwrng_register(&wl->rng); in b43_rng_init()
3573 wl->rng_initialized = false; in b43_rng_init()
3590 mutex_lock(&wl->mutex); in b43_tx_work()
3591 dev = wl->current_dev; in b43_tx_work()
3593 mutex_unlock(&wl->mutex); in b43_tx_work()
3598 while (skb_queue_len(&wl->tx_queue[queue_num])) { in b43_tx_work()
3599 skb = skb_dequeue(&wl->tx_queue[queue_num]); in b43_tx_work()
3604 if (err == -ENOSPC) { in b43_tx_work()
3605 wl->tx_queue_stopped[queue_num] = true; in b43_tx_work()
3606 ieee80211_stop_queue(wl->hw, queue_num); in b43_tx_work()
3607 skb_queue_head(&wl->tx_queue[queue_num], skb); in b43_tx_work()
3611 ieee80211_free_txskb(wl->hw, skb); in b43_tx_work()
3616 wl->tx_queue_stopped[queue_num] = false; in b43_tx_work()
3620 dev->tx_count++; in b43_tx_work()
3622 mutex_unlock(&wl->mutex); in b43_tx_work()
3631 if (unlikely(skb->len < 2 + 2 + 6)) { in b43_op_tx()
3636 B43_WARN_ON(skb_shinfo(skb)->nr_frags); in b43_op_tx()
3638 skb_queue_tail(&wl->tx_queue[skb->queue_mapping], skb); in b43_op_tx()
3639 if (!wl->tx_queue_stopped[skb->queue_mapping]) { in b43_op_tx()
3640 ieee80211_queue_work(wl->hw, &wl->tx_work); in b43_op_tx()
3642 ieee80211_stop_queue(wl->hw, skb->queue_mapping); in b43_op_tx()
3654 if (!dev->qos_enabled) in b43_qos_params_upload()
3657 bslots = b43_read16(dev, B43_MMIO_RNG) & p->cw_min; in b43_qos_params_upload()
3661 params[B43_QOSPARAM_TXOP] = p->txop * 32; in b43_qos_params_upload()
3662 params[B43_QOSPARAM_CWMIN] = p->cw_min; in b43_qos_params_upload()
3663 params[B43_QOSPARAM_CWMAX] = p->cw_max; in b43_qos_params_upload()
3664 params[B43_QOSPARAM_CWCUR] = p->cw_min; in b43_qos_params_upload()
3665 params[B43_QOSPARAM_AIFS] = p->aifs; in b43_qos_params_upload()
3667 params[B43_QOSPARAM_REGGAP] = bslots + p->aifs; in b43_qos_params_upload()
3688 /* [mac80211-queue-nr] = SHM_OFFSET, */
3698 struct b43_wl *wl = dev->wl; in b43_qos_upload_all()
3702 if (!dev->qos_enabled) in b43_qos_upload_all()
3706 ARRAY_SIZE(wl->qos_params)); in b43_qos_upload_all()
3709 for (i = 0; i < ARRAY_SIZE(wl->qos_params); i++) { in b43_qos_upload_all()
3710 params = &(wl->qos_params[i]); in b43_qos_upload_all()
3711 b43_qos_params_upload(dev, &(params->p), in b43_qos_upload_all()
3725 ARRAY_SIZE(wl->qos_params)); in b43_qos_clear()
3727 for (i = 0; i < ARRAY_SIZE(wl->qos_params); i++) { in b43_qos_clear()
3728 params = &(wl->qos_params[i]); in b43_qos_clear()
3732 params->p.txop = 0; in b43_qos_clear()
3733 params->p.aifs = 2; in b43_qos_clear()
3734 params->p.cw_min = 0x0001; in b43_qos_clear()
3735 params->p.cw_max = 0x0001; in b43_qos_clear()
3738 params->p.txop = 0; in b43_qos_clear()
3739 params->p.aifs = 2; in b43_qos_clear()
3740 params->p.cw_min = 0x0001; in b43_qos_clear()
3741 params->p.cw_max = 0x0001; in b43_qos_clear()
3744 params->p.txop = 0; in b43_qos_clear()
3745 params->p.aifs = 3; in b43_qos_clear()
3746 params->p.cw_min = 0x0001; in b43_qos_clear()
3747 params->p.cw_max = 0x03FF; in b43_qos_clear()
3750 params->p.txop = 0; in b43_qos_clear()
3751 params->p.aifs = 7; in b43_qos_clear()
3752 params->p.cw_min = 0x0001; in b43_qos_clear()
3753 params->p.cw_max = 0x03FF; in b43_qos_clear()
3764 if (!dev->qos_enabled) { in b43_qos_init()
3770 b43dbg(dev->wl, "QoS disabled\n"); in b43_qos_init()
3782 b43dbg(dev->wl, "QoS enabled\n"); in b43_qos_init()
3793 int err = -ENODEV; in b43_op_conf_tx()
3795 if (queue >= ARRAY_SIZE(wl->qos_params)) { in b43_op_conf_tx()
3802 ARRAY_SIZE(wl->qos_params)); in b43_op_conf_tx()
3804 mutex_lock(&wl->mutex); in b43_op_conf_tx()
3805 dev = wl->current_dev; in b43_op_conf_tx()
3809 memcpy(&(wl->qos_params[queue].p), params, sizeof(*params)); in b43_op_conf_tx()
3811 b43_qos_params_upload(dev, &(wl->qos_params[queue].p), in b43_op_conf_tx()
3817 mutex_unlock(&wl->mutex); in b43_op_conf_tx()
3827 mutex_lock(&wl->mutex); in b43_op_get_stats()
3828 memcpy(stats, &wl->ieee_stats, sizeof(*stats)); in b43_op_get_stats()
3829 mutex_unlock(&wl->mutex); in b43_op_get_stats()
3840 mutex_lock(&wl->mutex); in b43_op_get_tsf()
3841 dev = wl->current_dev; in b43_op_get_tsf()
3848 mutex_unlock(&wl->mutex); in b43_op_get_tsf()
3859 mutex_lock(&wl->mutex); in b43_op_set_tsf()
3860 dev = wl->current_dev; in b43_op_set_tsf()
3865 mutex_unlock(&wl->mutex); in b43_op_set_tsf()
3882 /* Expects wl->mutex locked */
3886 struct b43_phy *phy = &dev->phy; in b43_switch_band()
3890 switch (chan->band) { in b43_switch_band()
3899 return -EINVAL; in b43_switch_band()
3902 if (!((gmode && phy->supports_2ghz) || in b43_switch_band()
3903 (!gmode && phy->supports_5ghz))) { in b43_switch_band()
3904 b43err(dev->wl, "This device doesn't support %s-GHz band\n", in b43_switch_band()
3905 band_to_string(chan->band)); in b43_switch_band()
3906 return -ENODEV; in b43_switch_band()
3909 if (!!phy->gmode == !!gmode) { in b43_switch_band()
3914 b43dbg(dev->wl, "Switching to %s GHz band\n", in b43_switch_band()
3915 band_to_string(chan->band)); in b43_switch_band()
3918 if (!(phy->type == B43_PHYTYPE_N && phy->rev >= 3)) in b43_switch_band()
3921 phy->gmode = gmode; in b43_switch_band()
3923 switch (dev->dev->bus_type) { in b43_switch_band()
3926 tmp = bcma_aread32(dev->dev->bdev, BCMA_IOCTL); in b43_switch_band()
3931 bcma_awrite32(dev->dev->bdev, BCMA_IOCTL, tmp); in b43_switch_band()
3936 tmp = ssb_read32(dev->dev->sdev, SSB_TMSLOW); in b43_switch_band()
3941 ssb_write32(dev->dev->sdev, SSB_TMSLOW, tmp); in b43_switch_band()
3965 /* The retry limit is a 4-bit counter. Enforce this to avoid overflowing in b43_set_retry_limits()
3966 * the chip-internal counter. */ in b43_set_retry_limits()
3979 struct b43_wldev *dev = wl->current_dev; in b43_op_config()
3980 struct b43_phy *phy = &dev->phy; in b43_op_config()
3981 struct ieee80211_conf *conf = &hw->conf; in b43_op_config()
3985 mutex_lock(&wl->mutex); in b43_op_config()
3989 b43_set_beacon_listen_interval(dev, conf->listen_interval); in b43_op_config()
3992 phy->chandef = &conf->chandef; in b43_op_config()
3993 phy->channel = conf->chandef.chan->hw_value; in b43_op_config()
3996 err = b43_switch_band(dev, conf->chandef.chan); in b43_op_config()
4003 b43_switch_channel(dev, phy->channel); in b43_op_config()
4007 b43_set_retry_limits(dev, conf->short_frame_max_tx_count, in b43_op_config()
4008 conf->long_frame_max_tx_count); in b43_op_config()
4013 dev->wl->radiotap_enabled = !!(conf->flags & IEEE80211_CONF_MONITOR); in b43_op_config()
4016 if (conf->power_level != 0) { in b43_op_config()
4017 if (conf->power_level != phy->desired_txpower) { in b43_op_config()
4018 phy->desired_txpower = conf->power_level; in b43_op_config()
4028 if (phy->ops->set_rx_antenna) in b43_op_config()
4029 phy->ops->set_rx_antenna(dev, antenna); in b43_op_config()
4031 if (wl->radio_enabled != phy->radio_on) { in b43_op_config()
4032 if (wl->radio_enabled) { in b43_op_config()
4034 b43info(dev->wl, "Radio turned on by software\n"); in b43_op_config()
4035 if (!dev->radio_hw_enable) { in b43_op_config()
4036 b43info(dev->wl, "The hardware RF-kill button " in b43_op_config()
4042 b43info(dev->wl, "Radio turned off by software\n"); in b43_op_config()
4048 mutex_unlock(&wl->mutex); in b43_op_config()
4056 dev->wl->hw->wiphy->bands[b43_current_band(dev->wl)]; in b43_update_basic_rates()
4061 for (i = 0; i < sband->n_bitrates; i++) { in b43_update_basic_rates()
4062 rate = &sband->bitrates[i]; in b43_update_basic_rates()
4064 if (b43_is_cck_rate(rate->hw_value)) { in b43_update_basic_rates()
4067 offset = b43_plcp_get_ratecode_cck(rate->hw_value); in b43_update_basic_rates()
4072 offset = b43_plcp_get_ratecode_ofdm(rate->hw_value); in b43_update_basic_rates()
4076 rate = ieee80211_get_response_rate(sband, brates, rate->bitrate); in b43_update_basic_rates()
4078 if (b43_is_cck_rate(rate->hw_value)) { in b43_update_basic_rates()
4079 basic_offset = b43_plcp_get_ratecode_cck(rate->hw_value); in b43_update_basic_rates()
4082 basic_offset = b43_plcp_get_ratecode_ofdm(rate->hw_value); in b43_update_basic_rates()
4106 mutex_lock(&wl->mutex); in b43_op_bss_info_changed()
4108 dev = wl->current_dev; in b43_op_bss_info_changed()
4112 B43_WARN_ON(wl->vif != vif); in b43_op_bss_info_changed()
4115 if (conf->bssid) in b43_op_bss_info_changed()
4116 memcpy(wl->bssid, conf->bssid, ETH_ALEN); in b43_op_bss_info_changed()
4118 eth_zero_addr(wl->bssid); in b43_op_bss_info_changed()
4139 conf->beacon_int) in b43_op_bss_info_changed()
4140 b43_set_beacon_int(dev, conf->beacon_int); in b43_op_bss_info_changed()
4143 b43_update_basic_rates(dev, conf->basic_rates); in b43_op_bss_info_changed()
4146 if (conf->use_short_slot) in b43_op_bss_info_changed()
4154 mutex_unlock(&wl->mutex); in b43_op_bss_info_changed()
4169 return -ENOSPC; /* User disabled HW-crypto */ in b43_op_set_key()
4171 if ((vif->type == NL80211_IFTYPE_ADHOC || in b43_op_set_key()
4172 vif->type == NL80211_IFTYPE_MESH_POINT) && in b43_op_set_key()
4173 (key->cipher == WLAN_CIPHER_SUITE_TKIP || in b43_op_set_key()
4174 key->cipher == WLAN_CIPHER_SUITE_CCMP) && in b43_op_set_key()
4175 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) { in b43_op_set_key()
4182 return -EOPNOTSUPP; in b43_op_set_key()
4185 mutex_lock(&wl->mutex); in b43_op_set_key()
4187 dev = wl->current_dev; in b43_op_set_key()
4188 err = -ENODEV; in b43_op_set_key()
4192 if (dev->fw.pcm_request_failed || !dev->hwcrypto_enabled) { in b43_op_set_key()
4194 * Must use software-crypto. */ in b43_op_set_key()
4195 err = -EOPNOTSUPP; in b43_op_set_key()
4199 err = -EINVAL; in b43_op_set_key()
4200 switch (key->cipher) { in b43_op_set_key()
4217 index = (u8) (key->keyidx); in b43_op_set_key()
4224 (!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE) || in b43_op_set_key()
4227 err = -EOPNOTSUPP; in b43_op_set_key()
4231 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) { in b43_op_set_key()
4233 err = -EOPNOTSUPP; in b43_op_set_key()
4237 err = b43_key_write(dev, -1, algorithm, in b43_op_set_key()
4238 key->key, key->keylen, in b43_op_set_key()
4239 sta->addr, key); in b43_op_set_key()
4243 key->key, key->keylen, NULL, key); in b43_op_set_key()
4255 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; in b43_op_set_key()
4257 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; in b43_op_set_key()
4260 err = b43_key_clear(dev, key->hw_key_idx); in b43_op_set_key()
4273 cmd == SET_KEY ? "Using" : "Disabling", key->keyidx, in b43_op_set_key()
4274 sta ? sta->addr : bcast_addr); in b43_op_set_key()
4277 mutex_unlock(&wl->mutex); in b43_op_set_key()
4289 mutex_lock(&wl->mutex); in b43_op_configure_filter()
4290 dev = wl->current_dev; in b43_op_configure_filter()
4310 wl->filter_flags = *fflags; in b43_op_configure_filter()
4316 mutex_unlock(&wl->mutex); in b43_op_configure_filter()
4319 /* Locking: wl->mutex
4331 wl = dev->wl; in b43_wireless_core_stop()
4337 mutex_unlock(&wl->mutex); in b43_wireless_core_stop()
4338 cancel_delayed_work_sync(&dev->periodic_work); in b43_wireless_core_stop()
4339 cancel_work_sync(&wl->tx_work); in b43_wireless_core_stop()
4341 mutex_lock(&wl->mutex); in b43_wireless_core_stop()
4342 dev = wl->current_dev; in b43_wireless_core_stop()
4350 if (b43_bus_host_is_sdio(dev->dev)) { in b43_wireless_core_stop()
4351 /* wl->mutex is locked. That is enough. */ in b43_wireless_core_stop()
4355 spin_lock_irq(&wl->hardirq_lock); in b43_wireless_core_stop()
4358 spin_unlock_irq(&wl->hardirq_lock); in b43_wireless_core_stop()
4362 mutex_unlock(&wl->mutex); in b43_wireless_core_stop()
4363 if (b43_bus_host_is_sdio(dev->dev)) in b43_wireless_core_stop()
4366 free_irq(dev->dev->irq, dev); in b43_wireless_core_stop()
4367 mutex_lock(&wl->mutex); in b43_wireless_core_stop()
4368 dev = wl->current_dev; in b43_wireless_core_stop()
4381 while (skb_queue_len(&wl->tx_queue[queue_num])) { in b43_wireless_core_stop()
4384 skb = skb_dequeue(&wl->tx_queue[queue_num]); in b43_wireless_core_stop()
4385 ieee80211_free_txskb(wl->hw, skb); in b43_wireless_core_stop()
4396 /* Locking: wl->mutex */
4404 if (b43_bus_host_is_sdio(dev->dev)) { in b43_wireless_core_start()
4407 b43err(dev->wl, "Cannot request SDIO IRQ\n"); in b43_wireless_core_start()
4411 err = request_threaded_irq(dev->dev->irq, b43_interrupt_handler, in b43_wireless_core_start()
4415 b43err(dev->wl, "Cannot request IRQ-%d\n", in b43_wireless_core_start()
4416 dev->dev->irq); in b43_wireless_core_start()
4422 ieee80211_wake_queues(dev->wl->hw); in b43_wireless_core_start()
4427 b43_write32(dev, B43_MMIO_GEN_IRQ_MASK, dev->irq_mask); in b43_wireless_core_start()
4434 b43dbg(dev->wl, "Wireless interface started\n"); in b43_wireless_core_start()
4471 struct b43_phy *phy = &dev->phy; in b43_phy_versioning()
4472 const u8 core_rev = dev->dev->core_rev; in b43_phy_versioning()
4536 b43err(dev->wl, "FOUND UNSUPPORTED PHY (Analog %u, Type %d (%s), Revision %u)\n", in b43_phy_versioning()
4539 return -EOPNOTSUPP; in b43_phy_versioning()
4541 b43info(dev->wl, "Found PHY: Analog %u, Type %d (%s), Revision %u\n", in b43_phy_versioning()
4568 if (dev->dev->chip_id == 0x4317) { in b43_phy_versioning()
4569 if (dev->dev->chip_rev == 0) in b43_phy_versioning()
4571 else if (dev->dev->chip_rev == 1) in b43_phy_versioning()
4628 b43err(dev->wl, in b43_phy_versioning()
4631 return -EOPNOTSUPP; in b43_phy_versioning()
4633 b43info(dev->wl, in b43_phy_versioning()
4638 phy->radio_manuf = radio_manuf; in b43_phy_versioning()
4639 phy->radio_ver = radio_id; in b43_phy_versioning()
4640 phy->radio_rev = radio_rev; in b43_phy_versioning()
4642 phy->analog = analog_type; in b43_phy_versioning()
4643 phy->type = phy_type; in b43_phy_versioning()
4644 phy->rev = phy_rev; in b43_phy_versioning()
4652 phy->hardware_power_control = !!modparam_hwpctl; in setup_struct_phy_for_init()
4653 phy->next_txpwr_check_time = jiffies; in setup_struct_phy_for_init()
4655 atomic_set(&phy->txerr_cnt, B43_PHY_TX_BADNESS_LIMIT); in setup_struct_phy_for_init()
4658 phy->phy_locked = false; in setup_struct_phy_for_init()
4659 phy->radio_locked = false; in setup_struct_phy_for_init()
4665 dev->dfq_valid = false; in setup_struct_wldev_for_init()
4669 dev->radio_hw_enable = true; in setup_struct_wldev_for_init()
4672 memset(&dev->stats, 0, sizeof(dev->stats)); in setup_struct_wldev_for_init()
4674 setup_struct_phy_for_init(dev, &dev->phy); in setup_struct_wldev_for_init()
4677 dev->irq_reason = 0; in setup_struct_wldev_for_init()
4678 memset(dev->dma_reason, 0, sizeof(dev->dma_reason)); in setup_struct_wldev_for_init()
4679 dev->irq_mask = B43_IRQ_MASKTEMPLATE; in setup_struct_wldev_for_init()
4681 dev->irq_mask &= ~B43_IRQ_PHY_TXERR; in setup_struct_wldev_for_init()
4683 dev->mac_suspended = 1; in setup_struct_wldev_for_init()
4686 memset(&dev->noisecalc, 0, sizeof(dev->noisecalc)); in setup_struct_wldev_for_init()
4691 struct ssb_sprom *sprom = dev->dev->bus_sprom; in b43_bluetooth_coext_enable()
4696 if (!(sprom->boardflags_lo & B43_BFL_BTCOEXIST)) in b43_bluetooth_coext_enable()
4698 if (dev->phy.type != B43_PHYTYPE_B && !dev->phy.gmode) in b43_bluetooth_coext_enable()
4702 if (sprom->boardflags_lo & B43_BFL_BTCMOD) in b43_bluetooth_coext_enable()
4722 if (dev->dev->bus_type != B43_BUS_SSB) in b43_imcfglo_timeouts_workaround()
4728 bus = dev->dev->sdev->bus; in b43_imcfglo_timeouts_workaround()
4730 if ((bus->chip_id == 0x4311 && bus->chip_rev == 2) || in b43_imcfglo_timeouts_workaround()
4731 (bus->chip_id == 0x4312)) { in b43_imcfglo_timeouts_workaround()
4732 tmp = ssb_read32(dev->dev->sdev, SSB_IMCFGLO); in b43_imcfglo_timeouts_workaround()
4736 ssb_write32(dev->dev->sdev, SSB_IMCFGLO, tmp); in b43_imcfglo_timeouts_workaround()
4747 if (b43_is_mode(dev->wl, NL80211_IFTYPE_ADHOC) || idle) in b43_set_synth_pu_delay()
4749 if ((dev->phy.radio_ver == 0x2050) && (dev->phy.radio_rev == 8)) in b43_set_synth_pu_delay()
4755 /* Set the TSF CFP pre-TargetBeaconTransmissionTime. */
4761 if (b43_is_mode(dev->wl, NL80211_IFTYPE_ADHOC)) in b43_set_pretbtt()
4770 /* Locking: wl->mutex */
4783 switch (dev->dev->bus_type) { in b43_wireless_core_exit()
4786 bcma_host_pci_down(dev->dev->bdev->bus); in b43_wireless_core_exit()
4799 dev->phy.ops->switch_analog(dev, 0); in b43_wireless_core_exit()
4800 if (dev->wl->current_beacon) { in b43_wireless_core_exit()
4801 dev_kfree_skb_any(dev->wl->current_beacon); in b43_wireless_core_exit()
4802 dev->wl->current_beacon = NULL; in b43_wireless_core_exit()
4812 struct ssb_sprom *sprom = dev->dev->bus_sprom; in b43_wireless_core_init()
4813 struct b43_phy *phy = &dev->phy; in b43_wireless_core_init()
4823 b43_wireless_core_reset(dev, phy->gmode); in b43_wireless_core_init()
4827 phy->ops->prepare_structs(dev); in b43_wireless_core_init()
4830 switch (dev->dev->bus_type) { in b43_wireless_core_init()
4833 bcma_host_pci_irq_ctl(dev->dev->bdev->bus, in b43_wireless_core_init()
4834 dev->dev->bdev, true); in b43_wireless_core_init()
4835 bcma_host_pci_up(dev->dev->bdev->bus); in b43_wireless_core_init()
4840 ssb_pcicore_dev_irqvecs_enable(&dev->dev->sdev->bus->pcicore, in b43_wireless_core_init()
4841 dev->dev->sdev); in b43_wireless_core_init()
4848 if (phy->ops->prepare_hardware) { in b43_wireless_core_init()
4849 err = phy->ops->prepare_hardware(dev); in b43_wireless_core_init()
4857 B43_SHM_SH_WLCOREREV, dev->dev->core_rev); in b43_wireless_core_init()
4859 if (phy->type == B43_PHYTYPE_G) { in b43_wireless_core_init()
4861 if (phy->rev == 1) in b43_wireless_core_init()
4863 if (sprom->boardflags_lo & B43_BFL_PACTRL) in b43_wireless_core_init()
4866 if (phy->radio_ver == 0x2050) { in b43_wireless_core_init()
4867 if (phy->radio_rev == 6) in b43_wireless_core_init()
4869 if (phy->radio_rev < 6) in b43_wireless_core_init()
4872 if (sprom->boardflags_lo & B43_BFL_XTAL_NOSLOW) in b43_wireless_core_init()
4875 if (dev->dev->bus_type == B43_BUS_SSB && in b43_wireless_core_init()
4876 dev->dev->sdev->bus->bustype == SSB_BUSTYPE_PCI && in b43_wireless_core_init()
4877 dev->dev->sdev->bus->pcicore.dev->id.revision <= 10) in b43_wireless_core_init()
4884 if (dev->dev->core_rev >= 13) { in b43_wireless_core_init()
4908 if (phy->type == B43_PHYTYPE_B) in b43_wireless_core_init()
4916 b43_shm_write16(dev, B43_SHM_SHARED, B43_SHM_SH_PHYTYPE, phy->type); in b43_wireless_core_init()
4917 b43_shm_write16(dev, B43_SHM_SHARED, B43_SHM_SH_PHYVER, phy->rev); in b43_wireless_core_init()
4919 if (b43_bus_host_is_pcmcia(dev->dev) || in b43_wireless_core_init()
4920 b43_bus_host_is_sdio(dev->dev)) { in b43_wireless_core_init()
4921 dev->__using_pio_transfers = true; in b43_wireless_core_init()
4923 } else if (dev->use_pio) { in b43_wireless_core_init()
4924 b43warn(dev->wl, "Forced PIO by use_pio module parameter. " in b43_wireless_core_init()
4927 dev->__using_pio_transfers = true; in b43_wireless_core_init()
4930 dev->__using_pio_transfers = false; in b43_wireless_core_init()
4939 b43_bus_powerup(dev, !(sprom->boardflags_lo & B43_BFL_XTAL_NOSLOW)); in b43_wireless_core_init()
4943 ieee80211_wake_queues(dev->wl->hw); in b43_wireless_core_init()
4963 int err = -EOPNOTSUPP; in b43_op_add_interface()
4967 if (vif->type != NL80211_IFTYPE_AP && in b43_op_add_interface()
4968 vif->type != NL80211_IFTYPE_MESH_POINT && in b43_op_add_interface()
4969 vif->type != NL80211_IFTYPE_STATION && in b43_op_add_interface()
4970 vif->type != NL80211_IFTYPE_ADHOC) in b43_op_add_interface()
4971 return -EOPNOTSUPP; in b43_op_add_interface()
4973 mutex_lock(&wl->mutex); in b43_op_add_interface()
4974 if (wl->operating) in b43_op_add_interface()
4977 b43dbg(wl, "Adding Interface type %d\n", vif->type); in b43_op_add_interface()
4979 dev = wl->current_dev; in b43_op_add_interface()
4980 wl->operating = true; in b43_op_add_interface()
4981 wl->vif = vif; in b43_op_add_interface()
4982 wl->if_type = vif->type; in b43_op_add_interface()
4983 memcpy(wl->mac_addr, vif->addr, ETH_ALEN); in b43_op_add_interface()
4992 mutex_unlock(&wl->mutex); in b43_op_add_interface()
4995 b43_op_bss_info_changed(hw, vif, &vif->bss_conf, ~0); in b43_op_add_interface()
5004 struct b43_wldev *dev = wl->current_dev; in b43_op_remove_interface()
5006 b43dbg(wl, "Removing Interface type %d\n", vif->type); in b43_op_remove_interface()
5008 mutex_lock(&wl->mutex); in b43_op_remove_interface()
5010 B43_WARN_ON(!wl->operating); in b43_op_remove_interface()
5011 B43_WARN_ON(wl->vif != vif); in b43_op_remove_interface()
5012 wl->vif = NULL; in b43_op_remove_interface()
5014 wl->operating = false; in b43_op_remove_interface()
5017 eth_zero_addr(wl->mac_addr); in b43_op_remove_interface()
5020 mutex_unlock(&wl->mutex); in b43_op_remove_interface()
5026 struct b43_wldev *dev = wl->current_dev; in b43_op_start()
5033 eth_zero_addr(wl->bssid); in b43_op_start()
5034 eth_zero_addr(wl->mac_addr); in b43_op_start()
5035 wl->filter_flags = 0; in b43_op_start()
5036 wl->radiotap_enabled = false; in b43_op_start()
5038 wl->beacon0_uploaded = false; in b43_op_start()
5039 wl->beacon1_uploaded = false; in b43_op_start()
5040 wl->beacon_templates_virgin = true; in b43_op_start()
5041 wl->radio_enabled = true; in b43_op_start()
5043 mutex_lock(&wl->mutex); in b43_op_start()
5062 wiphy_rfkill_start_polling(hw->wiphy); in b43_op_start()
5065 mutex_unlock(&wl->mutex); in b43_op_start()
5082 struct b43_wldev *dev = wl->current_dev; in b43_op_stop()
5084 cancel_work_sync(&(wl->beacon_update_trigger)); in b43_op_stop()
5089 mutex_lock(&wl->mutex); in b43_op_stop()
5096 wl->radio_enabled = false; in b43_op_stop()
5099 mutex_unlock(&wl->mutex); in b43_op_stop()
5101 cancel_work_sync(&(wl->txpower_adjust_work)); in b43_op_stop()
5121 B43_WARN_ON(!vif || wl->vif != vif); in b43_op_sta_notify()
5131 mutex_lock(&wl->mutex); in b43_op_sw_scan_start_notifier()
5132 dev = wl->current_dev; in b43_op_sw_scan_start_notifier()
5137 mutex_unlock(&wl->mutex); in b43_op_sw_scan_start_notifier()
5146 mutex_lock(&wl->mutex); in b43_op_sw_scan_complete_notifier()
5147 dev = wl->current_dev; in b43_op_sw_scan_complete_notifier()
5149 /* Re-enable CFP update. */ in b43_op_sw_scan_complete_notifier()
5152 mutex_unlock(&wl->mutex); in b43_op_sw_scan_complete_notifier()
5159 struct b43_wldev *dev = wl->current_dev; in b43_op_get_survey()
5160 struct ieee80211_conf *conf = &hw->conf; in b43_op_get_survey()
5163 return -ENOENT; in b43_op_get_survey()
5165 survey->channel = conf->chandef.chan; in b43_op_get_survey()
5166 survey->filled = SURVEY_INFO_NOISE_DBM; in b43_op_get_survey()
5167 survey->noise = dev->stats.link_noise; in b43_op_get_survey()
5195 /* Hard-reset the chip. Do not call this directly.
5202 struct b43_wl *wl = dev->wl; in b43_chip_reset()
5206 mutex_lock(&wl->mutex); in b43_chip_reset()
5213 err = -ENODEV; in b43_chip_reset()
5235 wl->current_dev = NULL; /* Failed to init the dev. */ in b43_chip_reset()
5236 mutex_unlock(&wl->mutex); in b43_chip_reset()
5244 b43_op_config(wl->hw, ~0); in b43_chip_reset()
5245 if (wl->vif) in b43_chip_reset()
5246 b43_op_bss_info_changed(wl->hw, wl->vif, &wl->vif->bss_conf, ~0); in b43_chip_reset()
5254 struct ieee80211_hw *hw = dev->wl->hw; in b43_setup_bands()
5255 struct b43_phy *phy = &dev->phy; in b43_setup_bands()
5260 limited_2g = phy->radio_ver == 0x2057 && in b43_setup_bands()
5261 (phy->radio_rev == 9 || phy->radio_rev == 14); in b43_setup_bands()
5262 limited_5g = phy->radio_ver == 0x2057 && in b43_setup_bands()
5263 phy->radio_rev == 9; in b43_setup_bands()
5266 hw->wiphy->bands[NL80211_BAND_2GHZ] = limited_2g ? in b43_setup_bands()
5268 if (dev->phy.type == B43_PHYTYPE_N) { in b43_setup_bands()
5270 hw->wiphy->bands[NL80211_BAND_5GHZ] = limited_5g ? in b43_setup_bands()
5275 hw->wiphy->bands[NL80211_BAND_5GHZ] = &b43_band_5GHz_aphy; in b43_setup_bands()
5278 dev->phy.supports_2ghz = have_2ghz_phy; in b43_setup_bands()
5279 dev->phy.supports_5ghz = have_5ghz_phy; in b43_setup_bands()
5286 /* We release firmware that late to not be required to re-request in b43_wireless_core_detach()
5298 if (dev->dev->bus_type == B43_BUS_BCMA && in b43_supported_bands()
5299 dev->dev->bdev->bus->hosttype == BCMA_HOSTTYPE_PCI) in b43_supported_bands()
5300 dev_id = dev->dev->bdev->bus->host_pci->device; in b43_supported_bands()
5303 if (dev->dev->bus_type == B43_BUS_SSB && in b43_supported_bands()
5304 dev->dev->sdev->bus->bustype == SSB_BUSTYPE_PCI) in b43_supported_bands()
5305 dev_id = dev->dev->sdev->bus->host_pci->device; in b43_supported_bands()
5308 if (dev->dev->bus_sprom->dev_id) in b43_supported_bands()
5309 dev_id = dev->dev->bus_sprom->dev_id; in b43_supported_bands()
5331 /* There are 14e4:4321 PCI devs with 2.4 GHz BCM4321 (N-PHY) */ in b43_supported_bands()
5332 if (dev->phy.type != B43_PHYTYPE_G) in b43_supported_bands()
5351 switch (dev->phy.type) { in b43_supported_bands()
5367 struct b43_wl *wl = dev->wl; in b43_wireless_core_attach()
5368 struct b43_phy *phy = &dev->phy; in b43_wireless_core_attach()
5386 phy->do_full_init = true; in b43_wireless_core_attach()
5389 switch (dev->dev->bus_type) { in b43_wireless_core_attach()
5392 tmp = bcma_aread32(dev->dev->bdev, BCMA_IOST); in b43_wireless_core_attach()
5399 if (dev->dev->core_rev >= 5) { in b43_wireless_core_attach()
5400 tmp = ssb_read32(dev->dev->sdev, SSB_TMSHIGH); in b43_wireless_core_attach()
5409 dev->phy.gmode = have_2ghz_phy; in b43_wireless_core_attach()
5410 b43_wireless_core_reset(dev, dev->phy.gmode); in b43_wireless_core_attach()
5422 switch (dev->phy.type) { in b43_wireless_core_attach()
5433 err = -EOPNOTSUPP; in b43_wireless_core_attach()
5441 dev->phy.gmode = have_2ghz_phy; in b43_wireless_core_attach()
5442 b43_wireless_core_reset(dev, dev->phy.gmode); in b43_wireless_core_attach()
5452 if (!wl->current_dev) in b43_wireless_core_attach()
5453 wl->current_dev = dev; in b43_wireless_core_attach()
5454 INIT_WORK(&dev->restart_work, b43_chip_reset); in b43_wireless_core_attach()
5456 dev->phy.ops->switch_analog(dev, 0); in b43_wireless_core_attach()
5474 /* Do not cancel ieee80211-workqueue based work here. in b43_one_core_detach()
5480 list_del(&wldev->list); in b43_one_core_detach()
5488 int err = -ENOMEM; in b43_one_core_attach()
5494 wldev->use_pio = b43_modparam_pio; in b43_one_core_attach()
5495 wldev->dev = dev; in b43_one_core_attach()
5496 wldev->wl = wl; in b43_one_core_attach()
5498 wldev->bad_frames_preempt = modparam_bad_frames_preempt; in b43_one_core_attach()
5499 INIT_LIST_HEAD(&wldev->list); in b43_one_core_attach()
5517 (pdev->vendor == PCI_VENDOR_ID_##_vendor) && \
5518 (pdev->device == _device) && \
5519 (pdev->subsystem_vendor == PCI_VENDOR_ID_##_subvendor) && \
5520 (pdev->subsystem_device == _subdevice) )
5528 if (bus->boardinfo.vendor == SSB_BOARDVENDOR_DELL && in b43_sprom_fixup()
5529 bus->chip_id == 0x4301 && bus->sprom.board_rev == 0x74) in b43_sprom_fixup()
5530 bus->sprom.boardflags_lo |= B43_BFL_BTCOEXIST; in b43_sprom_fixup()
5531 if (bus->boardinfo.vendor == PCI_VENDOR_ID_APPLE && in b43_sprom_fixup()
5532 bus->boardinfo.type == 0x4E && bus->sprom.board_rev > 0x40) in b43_sprom_fixup()
5533 bus->sprom.boardflags_lo |= B43_BFL_PACTRL; in b43_sprom_fixup()
5534 if (bus->bustype == SSB_BUSTYPE_PCI) { in b43_sprom_fixup()
5535 pdev = bus->host_pci; in b43_sprom_fixup()
5543 bus->sprom.boardflags_lo &= ~B43_BFL_BTCOEXIST; in b43_sprom_fixup()
5549 struct ieee80211_hw *hw = wl->hw; in b43_wireless_exit()
5551 ssb_set_devtypedata(dev->sdev, NULL); in b43_wireless_exit()
5558 struct ssb_sprom *sprom = dev->bus_sprom; in b43_wireless_init()
5567 return ERR_PTR(-ENOMEM); in b43_wireless_init()
5575 hw->wiphy->interface_modes = in b43_wireless_init()
5581 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; in b43_wireless_init()
5583 wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST); in b43_wireless_init()
5585 wl->hw_registered = false; in b43_wireless_init()
5586 hw->max_rates = 2; in b43_wireless_init()
5587 SET_IEEE80211_DEV(hw, dev->dev); in b43_wireless_init()
5588 if (is_valid_ether_addr(sprom->et1mac)) in b43_wireless_init()
5589 SET_IEEE80211_PERM_ADDR(hw, sprom->et1mac); in b43_wireless_init()
5591 SET_IEEE80211_PERM_ADDR(hw, sprom->il0mac); in b43_wireless_init()
5594 wl->hw = hw; in b43_wireless_init()
5595 mutex_init(&wl->mutex); in b43_wireless_init()
5596 spin_lock_init(&wl->hardirq_lock); in b43_wireless_init()
5597 spin_lock_init(&wl->beacon_lock); in b43_wireless_init()
5598 INIT_WORK(&wl->beacon_update_trigger, b43_beacon_update_trigger_work); in b43_wireless_init()
5599 INIT_WORK(&wl->txpower_adjust_work, b43_phy_txpower_adjust_work); in b43_wireless_init()
5600 INIT_WORK(&wl->tx_work, b43_tx_work); in b43_wireless_init()
5604 skb_queue_head_init(&wl->tx_queue[queue_num]); in b43_wireless_init()
5605 wl->tx_queue_stopped[queue_num] = false; in b43_wireless_init()
5609 (dev->chip_id > 0x9999) ? "%d" : "%04X", dev->chip_id); in b43_wireless_init()
5611 dev->core_rev); in b43_wireless_init()
5623 (core->id.rev == 0x17 || core->id.rev == 0x18)) { in b43_bcma_probe()
5625 return -ENOTSUPP; in b43_bcma_probe()
5630 return -ENODEV; in b43_bcma_probe()
5643 INIT_WORK(&wl->firmware_load, b43_request_firmware); in b43_bcma_probe()
5644 schedule_work(&wl->firmware_load); in b43_bcma_probe()
5649 ieee80211_free_hw(wl->hw); in b43_bcma_probe()
5658 struct b43_wl *wl = wldev->wl; in b43_bcma_remove()
5662 cancel_work_sync(&wldev->restart_work); in b43_bcma_remove()
5663 cancel_work_sync(&wl->firmware_load); in b43_bcma_remove()
5666 if (!wldev->fw.ucode.data) in b43_bcma_remove()
5668 if (wl->current_dev == wldev && wl->hw_registered) { in b43_bcma_remove()
5670 ieee80211_unregister_hw(wl->hw); in b43_bcma_remove()
5673 b43_one_core_detach(wldev->dev); in b43_bcma_remove()
5679 ieee80211_free_hw(wl->hw); in b43_bcma_remove()
5680 kfree(wldev->dev); in b43_bcma_remove()
5701 return -ENOMEM; in b43_ssb_probe()
5705 b43err(NULL, "Dual-core devices are not supported\n"); in b43_ssb_probe()
5706 err = -ENOTSUPP; in b43_ssb_probe()
5710 b43_sprom_fixup(sdev->bus); in b43_ssb_probe()
5725 INIT_WORK(&wl->firmware_load, b43_request_firmware); in b43_ssb_probe()
5726 schedule_work(&wl->firmware_load); in b43_ssb_probe()
5741 struct b43_bus_dev *dev = wldev->dev; in b43_ssb_remove()
5745 cancel_work_sync(&wldev->restart_work); in b43_ssb_remove()
5746 cancel_work_sync(&wl->firmware_load); in b43_ssb_remove()
5749 if (!wldev->fw.ucode.data) in b43_ssb_remove()
5751 if (wl->current_dev == wldev && wl->hw_registered) { in b43_ssb_remove()
5753 ieee80211_unregister_hw(wl->hw); in b43_ssb_remove()
5780 b43info(dev->wl, "Controller RESET (%s) ...\n", reason); in b43_controller_restart()
5781 ieee80211_queue_work(dev->wl->hw, &dev->restart_work); in b43_controller_restart()