Lines Matching +full:rng +full:- +full:gpios
1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>
7 * Copyright (c) 2005-2008 Stefano Brivio <stefano.brivio@polimi.it>
14 * driver Copyright(c) 2003 - 2004 Intel Corporation.
27 #include <linux/dma-mapping.h>
157 if (!wl || !wl->current_dev) in b43legacy_ratelimit()
159 if (b43legacy_status(wl->current_dev) < B43legacy_STAT_STARTED) in b43legacy_ratelimit()
179 printk(KERN_INFO "b43legacy-%s: %pV", in b43legacyinfo()
180 (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan", &vaf); in b43legacyinfo()
198 printk(KERN_ERR "b43legacy-%s ERROR: %pV", in b43legacyerr()
199 (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan", &vaf); in b43legacyerr()
217 printk(KERN_WARNING "b43legacy-%s warning: %pV", in b43legacywarn()
218 (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan", &vaf); in b43legacywarn()
234 printk(KERN_DEBUG "b43legacy-%s debug: %pV", in b43legacydbg()
235 (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan", &vaf); in b43legacydbg()
396 if (dev->dev->id.revision >= 3) { in b43legacy_tsf_read()
466 /* Be careful with the in-progress timer. in b43legacy_tsf_write_locked()
468 * register-overflow duration to complete the operation. in b43legacy_tsf_write_locked()
470 if (dev->dev->id.revision >= 3) { in b43legacy_tsf_write_locked()
527 const u8 *mac = dev->wl->mac_addr; in b43legacy_write_mac_bssid_templates()
528 const u8 *bssid = dev->wl->bssid; in b43legacy_write_mac_bssid_templates()
559 dev->wl->mac_addr); in b43legacy_upload_card_macaddress()
566 if (dev->phy.type != B43legacy_PHYTYPE_G) in b43legacy_set_slot_time()
583 /* Synchronize IRQ top- and bottom-half.
589 synchronize_irq(dev->dev->irq); in b43legacy_synchronize_irq()
590 tasklet_kill(&dev->isr_tasklet); in b43legacy_synchronize_irq()
594 * https://bcm-specs.sipsolutions.net/DummyTransmission
598 struct b43legacy_phy *phy = &dev->phy; in b43legacy_dummy_transmission()
610 switch (phy->type) { in b43legacy_dummy_transmission()
638 if (phy->radio_ver == 0x2050 && phy->radio_rev <= 0x5) in b43legacy_dummy_transmission()
658 if (phy->radio_ver == 0x2050 && phy->radio_rev <= 0x5) in b43legacy_dummy_transmission()
675 ssb_device_enable(dev->dev, flags); in b43legacy_wireless_core_reset()
679 tmslow = ssb_read32(dev->dev, SSB_TMSLOW); in b43legacy_wireless_core_reset()
682 ssb_write32(dev->dev, SSB_TMSLOW, tmslow); in b43legacy_wireless_core_reset()
683 ssb_read32(dev->dev, SSB_TMSLOW); /* flush */ in b43legacy_wireless_core_reset()
686 ssb_write32(dev->dev, SSB_TMSLOW, tmslow); in b43legacy_wireless_core_reset()
687 ssb_read32(dev->dev, SSB_TMSLOW); /* flush */ in b43legacy_wireless_core_reset()
697 dev->phy.gmode = true; in b43legacy_wireless_core_reset()
699 dev->phy.gmode = false; in b43legacy_wireless_core_reset()
737 if (dev->dev->id.revision < 5) in drain_txstatus_queue()
775 B43legacy_WARN_ON(dev->noisecalc.channel_at_start != in b43legacy_generate_noise_sample()
776 dev->phy.channel); in b43legacy_generate_noise_sample()
783 if (dev->noisecalc.calculation_running) in b43legacy_calculate_link_quality()
785 dev->noisecalc.channel_at_start = dev->phy.channel; in b43legacy_calculate_link_quality()
786 dev->noisecalc.calculation_running = true; in b43legacy_calculate_link_quality()
787 dev->noisecalc.nr_samples = 0; in b43legacy_calculate_link_quality()
794 struct b43legacy_phy *phy = &dev->phy; in handle_irq_noise()
803 B43legacy_WARN_ON(!dev->noisecalc.calculation_running); in handle_irq_noise()
804 if (dev->noisecalc.channel_at_start != phy->channel) in handle_irq_noise()
812 B43legacy_WARN_ON(dev->noisecalc.nr_samples >= 8); in handle_irq_noise()
813 i = dev->noisecalc.nr_samples; in handle_irq_noise()
814 noise[0] = clamp_val(noise[0], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); in handle_irq_noise()
815 noise[1] = clamp_val(noise[1], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); in handle_irq_noise()
816 noise[2] = clamp_val(noise[2], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); in handle_irq_noise()
817 noise[3] = clamp_val(noise[3], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); in handle_irq_noise()
818 dev->noisecalc.samples[i][0] = phy->nrssi_lt[noise[0]]; in handle_irq_noise()
819 dev->noisecalc.samples[i][1] = phy->nrssi_lt[noise[1]]; in handle_irq_noise()
820 dev->noisecalc.samples[i][2] = phy->nrssi_lt[noise[2]]; in handle_irq_noise()
821 dev->noisecalc.samples[i][3] = phy->nrssi_lt[noise[3]]; in handle_irq_noise()
822 dev->noisecalc.nr_samples++; in handle_irq_noise()
823 if (dev->noisecalc.nr_samples == 8) { in handle_irq_noise()
828 average += dev->noisecalc.samples[i][j]; in handle_irq_noise()
840 average -= 25; in handle_irq_noise()
842 average -= 72; in handle_irq_noise()
844 average -= 48; in handle_irq_noise()
846 dev->stats.link_noise = average; in handle_irq_noise()
848 dev->noisecalc.calculation_running = false; in handle_irq_noise()
857 if (b43legacy_is_mode(dev->wl, NL80211_IFTYPE_AP)) { in handle_irq_tbtt_indication()
861 b43legacy_power_saving_ctl_bits(dev, -1, -1); in handle_irq_tbtt_indication()
863 if (b43legacy_is_mode(dev->wl, NL80211_IFTYPE_ADHOC)) in handle_irq_tbtt_indication()
864 dev->dfq_valid = true; in handle_irq_tbtt_indication()
869 if (dev->dfq_valid) { in handle_irq_atim_end()
873 dev->dfq_valid = false; in handle_irq_atim_end()
920 b43legacy_ram_write(dev, ram_offset + i - 2, tmp); in b43legacy_write_template_common()
950 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(dev->wl->current_beacon); in b43legacy_write_beacon_template()
952 bcn = (const struct ieee80211_mgmt *)(dev->wl->current_beacon->data); in b43legacy_write_beacon_template()
953 len = min_t(size_t, dev->wl->current_beacon->len, in b43legacy_write_beacon_template()
954 0x200 - sizeof(struct b43legacy_plcp_hdr6)); in b43legacy_write_beacon_template()
955 rate = ieee80211_get_tx_rate(dev->wl->hw, info)->hw_value; in b43legacy_write_beacon_template()
976 ie = bcn->u.beacon.variable; in b43legacy_write_beacon_template()
977 variable_len = len - offsetof(struct ieee80211_mgmt, u.beacon.variable); in b43legacy_write_beacon_template()
978 for (i = 0; i < variable_len - 2; ) { in b43legacy_write_beacon_template()
1012 b43legacywarn(dev->wl, "Did not find a valid TIM IE in the " in b43legacy_write_beacon_template()
1016 b43legacydbg(dev->wl, "Updated beacon template\n"); in b43legacy_write_beacon_template()
1028 b43legacy_generate_plcp_hdr(&plcp, size + FCS_LEN, rate->hw_value); in b43legacy_write_probe_resp_plcp()
1029 dur = ieee80211_generic_frame_duration(dev->wl->hw, in b43legacy_write_probe_resp_plcp()
1030 dev->wl->vif, in b43legacy_write_probe_resp_plcp()
1061 src_size = dev->wl->current_beacon->len; in b43legacy_generate_probe_resp()
1062 src_data = (const u8 *)dev->wl->current_beacon->data; in b43legacy_generate_probe_resp()
1080 for ( ; src_pos < src_size - 2; src_pos += elem_size) { in b43legacy_generate_probe_resp()
1093 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in b43legacy_generate_probe_resp()
1095 dur = ieee80211_generic_frame_duration(dev->wl->hw, in b43legacy_generate_probe_resp()
1096 dev->wl->vif, in b43legacy_generate_probe_resp()
1100 hdr->duration_id = dur; in b43legacy_generate_probe_resp()
1113 size = dev->wl->current_beacon->len; in b43legacy_write_probe_resp_template()
1131 0x200 - sizeof(struct b43legacy_plcp_hdr6)); in b43legacy_write_probe_resp_template()
1134 shm_size_offset, rate->hw_value); in b43legacy_write_probe_resp_template()
1140 struct b43legacy_wl *wl = dev->wl; in b43legacy_upload_beacon0()
1142 if (wl->beacon0_uploaded) in b43legacy_upload_beacon0()
1149 wl->beacon0_uploaded = true; in b43legacy_upload_beacon0()
1154 struct b43legacy_wl *wl = dev->wl; in b43legacy_upload_beacon1()
1156 if (wl->beacon1_uploaded) in b43legacy_upload_beacon1()
1159 wl->beacon1_uploaded = true; in b43legacy_upload_beacon1()
1164 struct b43legacy_wl *wl = dev->wl; in handle_irq_beacon()
1173 dev->irq_mask &= ~B43legacy_IRQ_BEACON; in handle_irq_beacon()
1182 dev->irq_mask |= B43legacy_IRQ_BEACON; in handle_irq_beacon()
1186 if (unlikely(wl->beacon_templates_virgin)) { in handle_irq_beacon()
1189 wl->beacon_templates_virgin = false; in handle_irq_beacon()
1216 mutex_lock(&wl->mutex); in b43legacy_beacon_update_trigger_work()
1217 dev = wl->current_dev; in b43legacy_beacon_update_trigger_work()
1219 spin_lock_irq(&wl->irq_lock); in b43legacy_beacon_update_trigger_work()
1224 dev->irq_mask); in b43legacy_beacon_update_trigger_work()
1225 spin_unlock_irq(&wl->irq_lock); in b43legacy_beacon_update_trigger_work()
1227 mutex_unlock(&wl->mutex); in b43legacy_beacon_update_trigger_work()
1231 * Locking: Requires wl->irq_lock to be locked. */
1244 beacon = ieee80211_beacon_get(wl->hw, wl->vif); in b43legacy_update_templates()
1248 if (wl->current_beacon) in b43legacy_update_templates()
1249 dev_kfree_skb_any(wl->current_beacon); in b43legacy_update_templates()
1250 wl->current_beacon = beacon; in b43legacy_update_templates()
1251 wl->beacon0_uploaded = false; in b43legacy_update_templates()
1252 wl->beacon1_uploaded = false; in b43legacy_update_templates()
1253 ieee80211_queue_work(wl->hw, &wl->beacon_update_trigger); in b43legacy_update_templates()
1260 if (dev->dev->id.revision >= 3) { in b43legacy_set_beacon_int()
1270 b43legacydbg(dev->wl, "Set beacon interval to %u\n", beacon_int); in b43legacy_set_beacon_int()
1277 /* Interrupt handler bottom-half */
1282 u32 dma_reason[ARRAY_SIZE(dev->dma_reason)]; in b43legacy_interrupt_tasklet()
1287 spin_lock_irqsave(&dev->wl->irq_lock, flags); in b43legacy_interrupt_tasklet()
1292 reason = dev->irq_reason; in b43legacy_interrupt_tasklet()
1294 dma_reason[i] = dev->dma_reason[i]; in b43legacy_interrupt_tasklet()
1299 b43legacyerr(dev->wl, "MAC transmission error\n"); in b43legacy_interrupt_tasklet()
1302 b43legacyerr(dev->wl, "PHY transmission error\n"); in b43legacy_interrupt_tasklet()
1304 if (unlikely(atomic_dec_and_test(&dev->phy.txerr_cnt))) { in b43legacy_interrupt_tasklet()
1305 b43legacyerr(dev->wl, "Too many PHY TX errors, " in b43legacy_interrupt_tasklet()
1314 b43legacyerr(dev->wl, "Fatal DMA error: " in b43legacy_interrupt_tasklet()
1321 spin_unlock_irqrestore(&dev->wl->irq_lock, flags); in b43legacy_interrupt_tasklet()
1325 b43legacyerr(dev->wl, "DMA error: " in b43legacy_interrupt_tasklet()
1352 b43legacy_pio_rx(dev->pio.queue0); in b43legacy_interrupt_tasklet()
1354 b43legacy_dma_rx(dev->dma.rx_ring0); in b43legacy_interrupt_tasklet()
1360 b43legacy_pio_rx(dev->pio.queue3); in b43legacy_interrupt_tasklet()
1362 b43legacy_dma_rx(dev->dma.rx_ring3); in b43legacy_interrupt_tasklet()
1370 b43legacy_write32(dev, B43legacy_MMIO_GEN_IRQ_MASK, dev->irq_mask); in b43legacy_interrupt_tasklet()
1371 spin_unlock_irqrestore(&dev->wl->irq_lock, flags); in b43legacy_interrupt_tasklet()
1381 dev->dma_reason[queueidx] |= B43legacy_DMAIRQ_RX_DONE; in pio_irq_workaround()
1383 dev->dma_reason[queueidx] &= ~B43legacy_DMAIRQ_RX_DONE; in pio_irq_workaround()
1389 (dev->dev->id.revision < 3) && in b43legacy_interrupt_ack()
1401 dev->dma_reason[0]); in b43legacy_interrupt_ack()
1403 dev->dma_reason[1]); in b43legacy_interrupt_ack()
1405 dev->dma_reason[2]); in b43legacy_interrupt_ack()
1407 dev->dma_reason[3]); in b43legacy_interrupt_ack()
1409 dev->dma_reason[4]); in b43legacy_interrupt_ack()
1411 dev->dma_reason[5]); in b43legacy_interrupt_ack()
1414 /* Interrupt handler top-half */
1423 spin_lock(&dev->wl->irq_lock); in b43legacy_interrupt_handler()
1432 reason &= dev->irq_mask; in b43legacy_interrupt_handler()
1436 dev->dma_reason[0] = b43legacy_read32(dev, in b43legacy_interrupt_handler()
1439 dev->dma_reason[1] = b43legacy_read32(dev, in b43legacy_interrupt_handler()
1442 dev->dma_reason[2] = b43legacy_read32(dev, in b43legacy_interrupt_handler()
1445 dev->dma_reason[3] = b43legacy_read32(dev, in b43legacy_interrupt_handler()
1448 dev->dma_reason[4] = b43legacy_read32(dev, in b43legacy_interrupt_handler()
1451 dev->dma_reason[5] = b43legacy_read32(dev, in b43legacy_interrupt_handler()
1459 dev->irq_reason = reason; in b43legacy_interrupt_handler()
1460 tasklet_schedule(&dev->isr_tasklet); in b43legacy_interrupt_handler()
1462 spin_unlock(&dev->wl->irq_lock); in b43legacy_interrupt_handler()
1469 release_firmware(dev->fw.ucode); in b43legacy_release_firmware()
1470 dev->fw.ucode = NULL; in b43legacy_release_firmware()
1471 release_firmware(dev->fw.pcm); in b43legacy_release_firmware()
1472 dev->fw.pcm = NULL; in b43legacy_release_firmware()
1473 release_firmware(dev->fw.initvals); in b43legacy_release_firmware()
1474 dev->fw.initvals = NULL; in b43legacy_release_firmware()
1475 release_firmware(dev->fw.initvals_band); in b43legacy_release_firmware()
1476 dev->fw.initvals_band = NULL; in b43legacy_release_firmware()
1490 dev->fwp = firmware; in b43legacy_fw_cb()
1491 complete(&dev->fw_load_complete); in b43legacy_fw_cb()
1509 b43legacyinfo(dev->wl, "Loading firmware %s\n", path); in do_request_fw()
1511 init_completion(&dev->fw_load_complete); in do_request_fw()
1513 dev->dev->dev, GFP_KERNEL, in do_request_fw()
1516 b43legacyerr(dev->wl, "Unable to load firmware\n"); in do_request_fw()
1520 wait_for_completion(&dev->fw_load_complete); in do_request_fw()
1521 if (!dev->fwp) in do_request_fw()
1522 err = -EINVAL; in do_request_fw()
1523 *fw = dev->fwp; in do_request_fw()
1525 err = request_firmware(fw, path, dev->dev->dev); in do_request_fw()
1528 b43legacyerr(dev->wl, "Firmware file \"%s\" not found " in do_request_fw()
1532 if ((*fw)->size < sizeof(struct b43legacy_fw_header)) in do_request_fw()
1534 hdr = (struct b43legacy_fw_header *)((*fw)->data); in do_request_fw()
1535 switch (hdr->type) { in do_request_fw()
1538 size = be32_to_cpu(hdr->size); in do_request_fw()
1539 if (size != (*fw)->size - sizeof(struct b43legacy_fw_header)) in do_request_fw()
1543 if (hdr->ver != 1) in do_request_fw()
1553 b43legacyerr(dev->wl, "Firmware file \"%s\" format error.\n", path); in do_request_fw()
1554 return -EPROTO; in do_request_fw()
1565 struct b43legacy_wldev *dev = wl->current_dev; in b43legacy_request_firmware()
1566 struct b43legacy_firmware *fw = &dev->fw; in b43legacy_request_firmware()
1567 const u8 rev = dev->dev->id.revision; in b43legacy_request_firmware()
1571 if (!fw->ucode) { in b43legacy_request_firmware()
1578 err = do_request_fw(dev, filename, &fw->ucode, true); in b43legacy_request_firmware()
1582 if (!fw->pcm) { in b43legacy_request_firmware()
1587 err = do_request_fw(dev, filename, &fw->pcm, false); in b43legacy_request_firmware()
1591 if (!fw->initvals) { in b43legacy_request_firmware()
1592 switch (dev->phy.type) { in b43legacy_request_firmware()
1605 err = do_request_fw(dev, filename, &fw->initvals, false); in b43legacy_request_firmware()
1609 if (!fw->initvals_band) { in b43legacy_request_firmware()
1610 switch (dev->phy.type) { in b43legacy_request_firmware()
1625 err = do_request_fw(dev, filename, &fw->initvals_band, false); in b43legacy_request_firmware()
1629 err = ieee80211_register_hw(wl->hw); in b43legacy_request_firmware()
1635 b43legacy_one_core_detach(dev->dev); in b43legacy_request_firmware()
1639 b43legacy_print_fw_helptext(dev->wl); in b43legacy_request_firmware()
1643 err = -ENODEV; in b43legacy_request_firmware()
1644 b43legacyerr(dev->wl, "No Initial Values firmware file for PHY %u, " in b43legacy_request_firmware()
1645 "core rev %u\n", dev->phy.type, rev); in b43legacy_request_firmware()
1655 struct wiphy *wiphy = dev->wl->hw->wiphy; in b43legacy_upload_microcode()
1679 data = (__be32 *) (dev->fw.ucode->data + hdr_len); in b43legacy_upload_microcode()
1680 len = (dev->fw.ucode->size - hdr_len) / sizeof(__be32); in b43legacy_upload_microcode()
1691 if (dev->fw.pcm) { in b43legacy_upload_microcode()
1693 data = (__be32 *) (dev->fw.pcm->data + hdr_len); in b43legacy_upload_microcode()
1694 len = (dev->fw.pcm->size - hdr_len) / sizeof(__be32); in b43legacy_upload_microcode()
1723 b43legacyerr(dev->wl, "Microcode not responding\n"); in b43legacy_upload_microcode()
1724 b43legacy_print_fw_helptext(dev->wl); in b43legacy_upload_microcode()
1725 err = -ENODEV; in b43legacy_upload_microcode()
1730 err = -EINTR; in b43legacy_upload_microcode()
1748 b43legacyerr(dev->wl, "YOU ARE TRYING TO LOAD V4 FIRMWARE." in b43legacy_upload_microcode()
1752 b43legacy_print_fw_helptext(dev->wl); in b43legacy_upload_microcode()
1753 err = -EOPNOTSUPP; in b43legacy_upload_microcode()
1756 b43legacyinfo(dev->wl, "Loading firmware version 0x%X, patch level %u " in b43legacy_upload_microcode()
1757 "(20%.2i-%.2i-%.2i %.2i:%.2i:%.2i)\n", fwrev, fwpatch, in b43legacy_upload_microcode()
1762 dev->fw.rev = fwrev; in b43legacy_upload_microcode()
1763 dev->fw.patch = fwpatch; in b43legacy_upload_microcode()
1765 snprintf(wiphy->fw_version, sizeof(wiphy->fw_version), "%u.%u", in b43legacy_upload_microcode()
1766 dev->fw.rev, dev->fw.patch); in b43legacy_upload_microcode()
1767 wiphy->hw_version = dev->dev->id.coreid; in b43legacy_upload_microcode()
1793 if (array_size < sizeof(iv->offset_size)) in b43legacy_write_initvals()
1795 array_size -= sizeof(iv->offset_size); in b43legacy_write_initvals()
1796 offset = be16_to_cpu(iv->offset_size); in b43legacy_write_initvals()
1804 if (array_size < sizeof(iv->data.d32)) in b43legacy_write_initvals()
1806 array_size -= sizeof(iv->data.d32); in b43legacy_write_initvals()
1808 value = get_unaligned_be32(&iv->data.d32); in b43legacy_write_initvals()
1817 if (array_size < sizeof(iv->data.d16)) in b43legacy_write_initvals()
1819 array_size -= sizeof(iv->data.d16); in b43legacy_write_initvals()
1821 value = be16_to_cpu(iv->data.d16); in b43legacy_write_initvals()
1835 b43legacyerr(dev->wl, "Initial Values Firmware file-format error.\n"); in b43legacy_write_initvals()
1836 b43legacy_print_fw_helptext(dev->wl); in b43legacy_write_initvals()
1838 return -EPROTO; in b43legacy_write_initvals()
1845 struct b43legacy_firmware *fw = &dev->fw; in b43legacy_upload_initvals()
1850 hdr = (const struct b43legacy_fw_header *)(fw->initvals->data); in b43legacy_upload_initvals()
1851 ivals = (const struct b43legacy_iv *)(fw->initvals->data + hdr_len); in b43legacy_upload_initvals()
1852 count = be32_to_cpu(hdr->size); in b43legacy_upload_initvals()
1854 fw->initvals->size - hdr_len); in b43legacy_upload_initvals()
1857 if (fw->initvals_band) { in b43legacy_upload_initvals()
1859 (fw->initvals_band->data); in b43legacy_upload_initvals()
1860 ivals = (const struct b43legacy_iv *)(fw->initvals_band->data in b43legacy_upload_initvals()
1862 count = be32_to_cpu(hdr->size); in b43legacy_upload_initvals()
1864 fw->initvals_band->size - hdr_len); in b43legacy_upload_initvals()
1873 /* Initialize the GPIOs
1874 * https://bcm-specs.sipsolutions.net/GPIO
1878 struct ssb_bus *bus = dev->dev->bus; in b43legacy_gpio_init()
1895 if (dev->dev->bus->chip_id == 0x4301) { in b43legacy_gpio_init()
1899 if (dev->dev->bus->sprom.boardflags_lo & B43legacy_BFL_PACTRL) { in b43legacy_gpio_init()
1907 if (dev->dev->id.revision >= 2) in b43legacy_gpio_init()
1911 pcidev = bus->pcicore.dev; in b43legacy_gpio_init()
1913 gpiodev = bus->chipco.dev ? : pcidev; in b43legacy_gpio_init()
1926 struct ssb_bus *bus = dev->dev->bus; in b43legacy_gpio_cleanup()
1930 pcidev = bus->pcicore.dev; in b43legacy_gpio_cleanup()
1932 gpiodev = bus->chipco.dev ? : pcidev; in b43legacy_gpio_cleanup()
1938 /* http://bcm-specs.sipsolutions.net/EnableMac */
1941 dev->mac_suspended--; in b43legacy_mac_enable()
1942 B43legacy_WARN_ON(dev->mac_suspended < 0); in b43legacy_mac_enable()
1944 if (dev->mac_suspended == 0) { in b43legacy_mac_enable()
1954 b43legacy_power_saving_ctl_bits(dev, -1, -1); in b43legacy_mac_enable()
1956 /* Re-enable IRQs. */ in b43legacy_mac_enable()
1957 spin_lock_irq(&dev->wl->irq_lock); in b43legacy_mac_enable()
1959 dev->irq_mask); in b43legacy_mac_enable()
1960 spin_unlock_irq(&dev->wl->irq_lock); in b43legacy_mac_enable()
1964 /* https://bcm-specs.sipsolutions.net/SuspendMAC */
1972 B43legacy_WARN_ON(dev->mac_suspended < 0); in b43legacy_mac_suspend()
1974 if (dev->mac_suspended == 0) { in b43legacy_mac_suspend()
1977 spin_lock_irq(&dev->wl->irq_lock); in b43legacy_mac_suspend()
1979 spin_unlock_irq(&dev->wl->irq_lock); in b43legacy_mac_suspend()
1982 b43legacy_power_saving_ctl_bits(dev, -1, 1); in b43legacy_mac_suspend()
1988 for (i = 40; i; i--) { in b43legacy_mac_suspend()
1995 b43legacyerr(dev->wl, "MAC suspend failed\n"); in b43legacy_mac_suspend()
1998 dev->mac_suspended++; in b43legacy_mac_suspend()
2003 struct b43legacy_wl *wl = dev->wl; in b43legacy_adjust_opmode()
2022 if (wl->filter_flags & FIF_CONTROL) in b43legacy_adjust_opmode()
2024 if (wl->filter_flags & FIF_FCSFAIL) in b43legacy_adjust_opmode()
2026 if (wl->filter_flags & FIF_PLCPFAIL) in b43legacy_adjust_opmode()
2028 if (wl->filter_flags & FIF_BCN_PRBRESP_PROMISC) in b43legacy_adjust_opmode()
2031 /* Workaround: On old hardware the HW-MAC-address-filter in b43legacy_adjust_opmode()
2034 if (dev->dev->id.revision <= 4) in b43legacy_adjust_opmode()
2042 if (dev->dev->bus->chip_id == 0x4306 && in b43legacy_adjust_opmode()
2043 dev->dev->bus->chip_rev == 3) in b43legacy_adjust_opmode()
2071 switch (dev->phy.type) { in b43legacy_rate_memory_init()
2092 /* Set the TX-Antenna for management frames sent by firmware. */
2145 * https://bcm-specs.sipsolutions.net/ChipInit
2149 struct b43legacy_phy *phy = &dev->phy; in b43legacy_chip_init()
2157 if (dev->phy.gmode) in b43legacy_chip_init()
2181 tmp = phy->interfmode; in b43legacy_chip_init()
2182 phy->interfmode = B43legacy_INTERFMODE_NONE; in b43legacy_chip_init()
2188 if (phy->type == B43legacy_PHYTYPE_B) { in b43legacy_chip_init()
2194 if (dev->dev->id.revision < 5) in b43legacy_chip_init()
2214 /* FIXME: Default to 0, has to be set by ioctl probably... :-/ */ in b43legacy_chip_init()
2220 if (dev->dev->id.revision < 3) { in b43legacy_chip_init()
2237 value32 = ssb_read32(dev->dev, SSB_TMSLOW); in b43legacy_chip_init()
2239 ssb_write32(dev->dev, SSB_TMSLOW, value32); in b43legacy_chip_init()
2242 dev->dev->bus->chipco.fast_pwrup_delay); in b43legacy_chip_init()
2245 atomic_set(&phy->txerr_cnt, B43legacy_PHY_TX_BADNESS_LIMIT); in b43legacy_chip_init()
2248 b43legacydbg(dev->wl, "Chip initialized\n"); in b43legacy_chip_init()
2261 struct b43legacy_phy *phy = &dev->phy; in b43legacy_periodic_every120sec()
2263 if (phy->type != B43legacy_PHYTYPE_G || phy->rev < 2) in b43legacy_periodic_every120sec()
2274 if (dev->dev->bus->sprom.boardflags_lo & B43legacy_BFL_RSSI) { in b43legacy_periodic_every60sec()
2291 atomic_set(&dev->phy.txerr_cnt, B43legacy_PHY_TX_BADNESS_LIMIT); in b43legacy_periodic_every15sec()
2299 state = dev->periodic_state; in do_periodic_work()
2311 * wl->mutex. If another lock is needed somewhere in the
2312 * pwork callchain, it's acquired in-place, where it's needed.
2318 struct b43legacy_wl *wl = dev->wl; in b43legacy_periodic_work_handler()
2321 mutex_lock(&wl->mutex); in b43legacy_periodic_work_handler()
2330 dev->periodic_state++; in b43legacy_periodic_work_handler()
2336 ieee80211_queue_delayed_work(wl->hw, &dev->periodic_work, delay); in b43legacy_periodic_work_handler()
2338 mutex_unlock(&wl->mutex); in b43legacy_periodic_work_handler()
2343 struct delayed_work *work = &dev->periodic_work; in b43legacy_periodic_tasks_setup()
2345 dev->periodic_state = 0; in b43legacy_periodic_tasks_setup()
2347 ieee80211_queue_delayed_work(dev->wl->hw, work, 0); in b43legacy_periodic_tasks_setup()
2378 b43legacyerr(dev->wl, "Failed to validate the chipaccess\n"); in b43legacy_validate_chipaccess()
2379 return -ENODEV; in b43legacy_validate_chipaccess()
2384 dev->max_nr_keys = (dev->dev->id.revision >= 5) ? 58 : 20; in b43legacy_security_init()
2385 B43legacy_WARN_ON(dev->max_nr_keys > ARRAY_SIZE(dev->key)); in b43legacy_security_init()
2386 dev->ktp = b43legacy_shm_read16(dev, B43legacy_SHM_SHARED, in b43legacy_security_init()
2391 dev->ktp *= 2; in b43legacy_security_init()
2392 if (dev->dev->id.revision >= 5) in b43legacy_security_init()
2395 dev->max_nr_keys - 8); in b43legacy_security_init()
2399 static int b43legacy_rng_read(struct hwrng *rng, u32 *data) in b43legacy_rng_read() argument
2401 struct b43legacy_wl *wl = (struct b43legacy_wl *)rng->priv; in b43legacy_rng_read()
2404 /* Don't take wl->mutex here, as it could deadlock with in b43legacy_rng_read()
2406 * wl->mutex here, anyway. */ in b43legacy_rng_read()
2408 spin_lock_irqsave(&wl->irq_lock, flags); in b43legacy_rng_read()
2409 *data = b43legacy_read16(wl->current_dev, B43legacy_MMIO_RNG); in b43legacy_rng_read()
2410 spin_unlock_irqrestore(&wl->irq_lock, flags); in b43legacy_rng_read()
2419 if (wl->rng_initialized) in b43legacy_rng_exit()
2420 hwrng_unregister(&wl->rng); in b43legacy_rng_exit()
2429 snprintf(wl->rng_name, ARRAY_SIZE(wl->rng_name), in b43legacy_rng_init()
2430 "%s_%s", KBUILD_MODNAME, wiphy_name(wl->hw->wiphy)); in b43legacy_rng_init()
2431 wl->rng.name = wl->rng_name; in b43legacy_rng_init()
2432 wl->rng.data_read = b43legacy_rng_read; in b43legacy_rng_init()
2433 wl->rng.priv = (unsigned long)wl; in b43legacy_rng_init()
2434 wl->rng_initialized = 1; in b43legacy_rng_init()
2435 err = hwrng_register(&wl->rng); in b43legacy_rng_init()
2437 wl->rng_initialized = 0; in b43legacy_rng_init()
2455 mutex_lock(&wl->mutex); in b43legacy_tx_work()
2456 dev = wl->current_dev; in b43legacy_tx_work()
2458 mutex_unlock(&wl->mutex); in b43legacy_tx_work()
2463 while (skb_queue_len(&wl->tx_queue[queue_num])) { in b43legacy_tx_work()
2464 skb = skb_dequeue(&wl->tx_queue[queue_num]); in b43legacy_tx_work()
2469 if (err == -ENOSPC) { in b43legacy_tx_work()
2470 wl->tx_queue_stopped[queue_num] = 1; in b43legacy_tx_work()
2471 ieee80211_stop_queue(wl->hw, queue_num); in b43legacy_tx_work()
2472 skb_queue_head(&wl->tx_queue[queue_num], skb); in b43legacy_tx_work()
2481 wl->tx_queue_stopped[queue_num] = 0; in b43legacy_tx_work()
2484 mutex_unlock(&wl->mutex); in b43legacy_tx_work()
2493 if (unlikely(skb->len < 2 + 2 + 6)) { in b43legacy_op_tx()
2498 B43legacy_WARN_ON(skb_shinfo(skb)->nr_frags); in b43legacy_op_tx()
2500 skb_queue_tail(&wl->tx_queue[skb->queue_mapping], skb); in b43legacy_op_tx()
2501 if (!wl->tx_queue_stopped[skb->queue_mapping]) in b43legacy_op_tx()
2502 ieee80211_queue_work(wl->hw, &wl->tx_work); in b43legacy_op_tx()
2504 ieee80211_stop_queue(wl->hw, skb->queue_mapping); in b43legacy_op_tx()
2520 spin_lock_irqsave(&wl->irq_lock, flags); in b43legacy_op_get_stats()
2521 memcpy(stats, &wl->ieee_stats, sizeof(*stats)); in b43legacy_op_get_stats()
2522 spin_unlock_irqrestore(&wl->irq_lock, flags); in b43legacy_op_get_stats()
2547 list_for_each_entry(d, &wl->devlist, list) { in find_wldev_for_phymode()
2548 if (d->phy.possible_phymodes & phymode) { in find_wldev_for_phymode()
2549 /* Ok, this device supports the PHY-mode. in find_wldev_for_phymode()
2558 return -ESRCH; in find_wldev_for_phymode()
2563 struct ssb_device *sdev = dev->dev; in b43legacy_put_phy_into_reset()
2580 /* Expects wl->mutex locked */
2592 b43legacyerr(wl, "Could not find a device for %s-PHY mode\n", in b43legacy_switch_phymode()
2596 if ((up_dev == wl->current_dev) && in b43legacy_switch_phymode()
2597 (!!wl->current_dev->phy.gmode == !!gmode)) in b43legacy_switch_phymode()
2600 b43legacydbg(wl, "Reconfiguring PHYmode to %s-PHY\n", in b43legacy_switch_phymode()
2602 down_dev = wl->current_dev; in b43legacy_switch_phymode()
2617 up_dev->phy.gmode = gmode; in b43legacy_switch_phymode()
2622 " for newly selected %s-PHY mode\n", in b43legacy_switch_phymode()
2631 "newly selected %s-PHY mode\n", in b43legacy_switch_phymode()
2641 wl->current_dev = up_dev; in b43legacy_switch_phymode()
2646 wl->current_dev = NULL; in b43legacy_switch_phymode()
2655 /* The retry limit is a 4-bit counter. Enforce this to avoid overflowing in b43legacy_set_retry_limits()
2656 * the chip-internal counter. */ in b43legacy_set_retry_limits()
2670 struct ieee80211_conf *conf = &hw->conf; in b43legacy_op_dev_config()
2678 mutex_lock(&wl->mutex); in b43legacy_op_dev_config()
2679 dev = wl->current_dev; in b43legacy_op_dev_config()
2680 phy = &dev->phy; in b43legacy_op_dev_config()
2684 conf->short_frame_max_tx_count, in b43legacy_op_dev_config()
2685 conf->long_frame_max_tx_count); in b43legacy_op_dev_config()
2691 switch (conf->chandef.chan->band) { in b43legacy_op_dev_config()
2693 if (phy->type == B43legacy_PHYTYPE_B) in b43legacy_op_dev_config()
2708 spin_lock_irqsave(&wl->irq_lock, flags); in b43legacy_op_dev_config()
2710 spin_unlock_irqrestore(&wl->irq_lock, flags); in b43legacy_op_dev_config()
2714 spin_unlock_irqrestore(&wl->irq_lock, flags); in b43legacy_op_dev_config()
2719 if (conf->chandef.chan->hw_value != phy->channel) in b43legacy_op_dev_config()
2720 b43legacy_radio_selectchannel(dev, conf->chandef.chan->hw_value, in b43legacy_op_dev_config()
2723 dev->wl->radiotap_enabled = !!(conf->flags & IEEE80211_CONF_MONITOR); in b43legacy_op_dev_config()
2726 if (conf->power_level != 0) { in b43legacy_op_dev_config()
2727 if (conf->power_level != phy->power_level) { in b43legacy_op_dev_config()
2728 phy->power_level = conf->power_level; in b43legacy_op_dev_config()
2736 if (wl->radio_enabled != phy->radio_on) { in b43legacy_op_dev_config()
2737 if (wl->radio_enabled) { in b43legacy_op_dev_config()
2739 b43legacyinfo(dev->wl, "Radio turned on by software\n"); in b43legacy_op_dev_config()
2740 if (!dev->radio_hw_enable) in b43legacy_op_dev_config()
2741 b43legacyinfo(dev->wl, "The hardware RF-kill" in b43legacy_op_dev_config()
2747 b43legacyinfo(dev->wl, "Radio turned off by" in b43legacy_op_dev_config()
2752 spin_lock_irqsave(&wl->irq_lock, flags); in b43legacy_op_dev_config()
2753 b43legacy_write32(dev, B43legacy_MMIO_GEN_IRQ_MASK, dev->irq_mask); in b43legacy_op_dev_config()
2754 spin_unlock_irqrestore(&wl->irq_lock, flags); in b43legacy_op_dev_config()
2756 mutex_unlock(&wl->mutex); in b43legacy_op_dev_config()
2764 dev->wl->hw->wiphy->bands[NL80211_BAND_2GHZ]; in b43legacy_update_basic_rates()
2769 for (i = 0; i < sband->n_bitrates; i++) { in b43legacy_update_basic_rates()
2770 rate = &sband->bitrates[i]; in b43legacy_update_basic_rates()
2772 if (b43legacy_is_cck_rate(rate->hw_value)) { in b43legacy_update_basic_rates()
2775 offset = b43legacy_plcp_get_ratecode_cck(rate->hw_value); in b43legacy_update_basic_rates()
2780 offset = b43legacy_plcp_get_ratecode_ofdm(rate->hw_value); in b43legacy_update_basic_rates()
2784 rate = ieee80211_get_response_rate(sband, brates, rate->bitrate); in b43legacy_update_basic_rates()
2786 if (b43legacy_is_cck_rate(rate->hw_value)) { in b43legacy_update_basic_rates()
2787 basic_offset = b43legacy_plcp_get_ratecode_cck(rate->hw_value); in b43legacy_update_basic_rates()
2790 basic_offset = b43legacy_plcp_get_ratecode_ofdm(rate->hw_value); in b43legacy_update_basic_rates()
2815 mutex_lock(&wl->mutex); in b43legacy_op_bss_info_changed()
2816 B43legacy_WARN_ON(wl->vif != vif); in b43legacy_op_bss_info_changed()
2818 dev = wl->current_dev; in b43legacy_op_bss_info_changed()
2823 spin_lock_irqsave(&wl->irq_lock, flags); in b43legacy_op_bss_info_changed()
2825 spin_unlock_irqrestore(&wl->irq_lock, flags); in b43legacy_op_bss_info_changed()
2833 if (conf->bssid) in b43legacy_op_bss_info_changed()
2834 memcpy(wl->bssid, conf->bssid, ETH_ALEN); in b43legacy_op_bss_info_changed()
2836 eth_zero_addr(wl->bssid); in b43legacy_op_bss_info_changed()
2848 spin_unlock_irqrestore(&wl->irq_lock, flags); in b43legacy_op_bss_info_changed()
2855 b43legacy_set_beacon_int(dev, conf->beacon_int); in b43legacy_op_bss_info_changed()
2858 b43legacy_update_basic_rates(dev, conf->basic_rates); in b43legacy_op_bss_info_changed()
2861 if (conf->use_short_slot) in b43legacy_op_bss_info_changed()
2869 spin_lock_irqsave(&wl->irq_lock, flags); in b43legacy_op_bss_info_changed()
2870 b43legacy_write32(dev, B43legacy_MMIO_GEN_IRQ_MASK, dev->irq_mask); in b43legacy_op_bss_info_changed()
2872 spin_unlock_irqrestore(&wl->irq_lock, flags); in b43legacy_op_bss_info_changed()
2874 mutex_unlock(&wl->mutex); in b43legacy_op_bss_info_changed()
2882 struct b43legacy_wldev *dev = wl->current_dev; in b43legacy_op_configure_filter()
2890 spin_lock_irqsave(&wl->irq_lock, flags); in b43legacy_op_configure_filter()
2905 wl->filter_flags = *fflags; in b43legacy_op_configure_filter()
2909 spin_unlock_irqrestore(&wl->irq_lock, flags); in b43legacy_op_configure_filter()
2912 /* Locking: wl->mutex */
2915 struct b43legacy_wl *wl = dev->wl; in b43legacy_wireless_core_stop()
2925 spin_lock_irqsave(&wl->irq_lock, flags); in b43legacy_wireless_core_stop()
2928 spin_unlock_irqrestore(&wl->irq_lock, flags); in b43legacy_wireless_core_stop()
2933 mutex_unlock(&wl->mutex); in b43legacy_wireless_core_stop()
2935 * Cancel the possibly running self-rearming periodic work. */ in b43legacy_wireless_core_stop()
2936 cancel_delayed_work_sync(&dev->periodic_work); in b43legacy_wireless_core_stop()
2937 cancel_work_sync(&wl->tx_work); in b43legacy_wireless_core_stop()
2938 mutex_lock(&wl->mutex); in b43legacy_wireless_core_stop()
2942 while (skb_queue_len(&wl->tx_queue[queue_num])) in b43legacy_wireless_core_stop()
2943 dev_kfree_skb(skb_dequeue(&wl->tx_queue[queue_num])); in b43legacy_wireless_core_stop()
2947 free_irq(dev->dev->irq, dev); in b43legacy_wireless_core_stop()
2951 /* Locking: wl->mutex */
2959 err = request_irq(dev->dev->irq, b43legacy_interrupt_handler, in b43legacy_wireless_core_start()
2962 b43legacyerr(dev->wl, "Cannot request IRQ-%d\n", in b43legacy_wireless_core_start()
2963 dev->dev->irq); in b43legacy_wireless_core_start()
2967 ieee80211_wake_queues(dev->wl->hw); in b43legacy_wireless_core_start()
2972 b43legacy_write32(dev, B43legacy_MMIO_GEN_IRQ_MASK, dev->irq_mask); in b43legacy_wireless_core_start()
2977 b43legacydbg(dev->wl, "Wireless interface started\n"); in b43legacy_wireless_core_start()
2985 struct b43legacy_phy *phy = &dev->phy; in b43legacy_phy_versioning()
3015 b43legacyerr(dev->wl, "FOUND UNSUPPORTED PHY " in b43legacy_phy_versioning()
3018 return -EOPNOTSUPP; in b43legacy_phy_versioning()
3020 b43legacydbg(dev->wl, "Found PHY: Analog %u, Type %u, Revision %u\n", in b43legacy_phy_versioning()
3025 if (dev->dev->bus->chip_id == 0x4317) { in b43legacy_phy_versioning()
3026 if (dev->dev->bus->chip_rev == 0) in b43legacy_phy_versioning()
3028 else if (dev->dev->bus->chip_rev == 1) in b43legacy_phy_versioning()
3057 b43legacyerr(dev->wl, "FOUND UNSUPPORTED RADIO " in b43legacy_phy_versioning()
3060 return -EOPNOTSUPP; in b43legacy_phy_versioning()
3062 b43legacydbg(dev->wl, "Found Radio: Manuf 0x%X, Version 0x%X," in b43legacy_phy_versioning()
3066 phy->radio_manuf = radio_manuf; in b43legacy_phy_versioning()
3067 phy->radio_ver = radio_ver; in b43legacy_phy_versioning()
3068 phy->radio_rev = radio_rev; in b43legacy_phy_versioning()
3070 phy->analog = analog_type; in b43legacy_phy_versioning()
3071 phy->type = phy_type; in b43legacy_phy_versioning()
3072 phy->rev = phy_rev; in b43legacy_phy_versioning()
3083 memset(phy->minlowsig, 0xFF, sizeof(phy->minlowsig)); in setup_struct_phy_for_init()
3084 memset(phy->minlowsigpos, 0, sizeof(phy->minlowsigpos)); in setup_struct_phy_for_init()
3088 dev->radio_hw_enable = true; in setup_struct_phy_for_init()
3090 phy->savedpctlreg = 0xFFFF; in setup_struct_phy_for_init()
3091 phy->aci_enable = false; in setup_struct_phy_for_init()
3092 phy->aci_wlan_automatic = false; in setup_struct_phy_for_init()
3093 phy->aci_hw_rssi = false; in setup_struct_phy_for_init()
3095 lo = phy->_lo_pairs; in setup_struct_phy_for_init()
3099 phy->max_lb_gain = 0; in setup_struct_phy_for_init()
3100 phy->trsw_rx_gain = 0; in setup_struct_phy_for_init()
3103 phy->bbatt = b43legacy_default_baseband_attenuation(dev); in setup_struct_phy_for_init()
3104 phy->rfatt = b43legacy_default_radio_attenuation(dev); in setup_struct_phy_for_init()
3105 phy->txctl1 = b43legacy_default_txctl1(dev); in setup_struct_phy_for_init()
3106 phy->txpwr_offset = 0; in setup_struct_phy_for_init()
3109 phy->nrssislope = 0; in setup_struct_phy_for_init()
3110 for (i = 0; i < ARRAY_SIZE(phy->nrssi); i++) in setup_struct_phy_for_init()
3111 phy->nrssi[i] = -1000; in setup_struct_phy_for_init()
3112 for (i = 0; i < ARRAY_SIZE(phy->nrssi_lt); i++) in setup_struct_phy_for_init()
3113 phy->nrssi_lt[i] = i; in setup_struct_phy_for_init()
3115 phy->lofcal = 0xFFFF; in setup_struct_phy_for_init()
3116 phy->initval = 0xFFFF; in setup_struct_phy_for_init()
3118 phy->interfmode = B43legacy_INTERFMODE_NONE; in setup_struct_phy_for_init()
3119 phy->channel = 0xFF; in setup_struct_phy_for_init()
3125 dev->dfq_valid = false; in setup_struct_wldev_for_init()
3128 memset(&dev->stats, 0, sizeof(dev->stats)); in setup_struct_wldev_for_init()
3130 setup_struct_phy_for_init(dev, &dev->phy); in setup_struct_wldev_for_init()
3133 dev->irq_reason = 0; in setup_struct_wldev_for_init()
3134 memset(dev->dma_reason, 0, sizeof(dev->dma_reason)); in setup_struct_wldev_for_init()
3135 dev->irq_mask = B43legacy_IRQ_MASKTEMPLATE; in setup_struct_wldev_for_init()
3137 dev->mac_suspended = 1; in setup_struct_wldev_for_init()
3140 memset(&dev->noisecalc, 0, sizeof(dev->noisecalc)); in setup_struct_wldev_for_init()
3147 if (b43legacy_is_mode(dev->wl, NL80211_IFTYPE_ADHOC) || idle) in b43legacy_set_synth_pu_delay()
3149 if ((dev->phy.radio_ver == 0x2050) && (dev->phy.radio_rev == 8)) in b43legacy_set_synth_pu_delay()
3156 /* Set the TSF CFP pre-TargetBeaconTransmissionTime. */
3162 if (b43legacy_is_mode(dev->wl, NL80211_IFTYPE_ADHOC)) in b43legacy_set_pretbtt()
3172 /* Locking: wl->mutex */
3175 struct b43legacy_phy *phy = &dev->phy; in b43legacy_wireless_core_exit()
3190 b43legacy_rng_exit(dev->wl); in b43legacy_wireless_core_exit()
3196 if (phy->dyn_tssi_tbl) in b43legacy_wireless_core_exit()
3197 kfree(phy->tssi2dbm); in b43legacy_wireless_core_exit()
3198 kfree(phy->lo_control); in b43legacy_wireless_core_exit()
3199 phy->lo_control = NULL; in b43legacy_wireless_core_exit()
3200 if (dev->wl->current_beacon) { in b43legacy_wireless_core_exit()
3201 dev_kfree_skb_any(dev->wl->current_beacon); in b43legacy_wireless_core_exit()
3202 dev->wl->current_beacon = NULL; in b43legacy_wireless_core_exit()
3205 ssb_device_disable(dev->dev, 0); in b43legacy_wireless_core_exit()
3206 ssb_bus_may_powerdown(dev->dev->bus); in b43legacy_wireless_core_exit()
3211 struct b43legacy_phy *phy = &dev->phy; in prepare_phy_data_for_init()
3215 phy->bbatt = b43legacy_default_baseband_attenuation(dev); in prepare_phy_data_for_init()
3216 phy->rfatt = b43legacy_default_radio_attenuation(dev); in prepare_phy_data_for_init()
3217 phy->txctl1 = b43legacy_default_txctl1(dev); in prepare_phy_data_for_init()
3218 phy->txctl2 = 0xFFFF; in prepare_phy_data_for_init()
3219 phy->txpwr_offset = 0; in prepare_phy_data_for_init()
3222 phy->nrssislope = 0; in prepare_phy_data_for_init()
3223 for (i = 0; i < ARRAY_SIZE(phy->nrssi); i++) in prepare_phy_data_for_init()
3224 phy->nrssi[i] = -1000; in prepare_phy_data_for_init()
3225 for (i = 0; i < ARRAY_SIZE(phy->nrssi_lt); i++) in prepare_phy_data_for_init()
3226 phy->nrssi_lt[i] = i; in prepare_phy_data_for_init()
3228 phy->lofcal = 0xFFFF; in prepare_phy_data_for_init()
3229 phy->initval = 0xFFFF; in prepare_phy_data_for_init()
3231 phy->aci_enable = false; in prepare_phy_data_for_init()
3232 phy->aci_wlan_automatic = false; in prepare_phy_data_for_init()
3233 phy->aci_hw_rssi = false; in prepare_phy_data_for_init()
3235 phy->antenna_diversity = 0xFFFF; in prepare_phy_data_for_init()
3236 memset(phy->minlowsig, 0xFF, sizeof(phy->minlowsig)); in prepare_phy_data_for_init()
3237 memset(phy->minlowsigpos, 0, sizeof(phy->minlowsigpos)); in prepare_phy_data_for_init()
3240 phy->calibrated = 0; in prepare_phy_data_for_init()
3242 if (phy->_lo_pairs) in prepare_phy_data_for_init()
3243 memset(phy->_lo_pairs, 0, in prepare_phy_data_for_init()
3245 memset(phy->loopback_gain, 0, sizeof(phy->loopback_gain)); in prepare_phy_data_for_init()
3251 struct b43legacy_wl *wl = dev->wl; in b43legacy_wireless_core_init()
3252 struct ssb_bus *bus = dev->dev->bus; in b43legacy_wireless_core_init()
3253 struct b43legacy_phy *phy = &dev->phy; in b43legacy_wireless_core_init()
3254 struct ssb_sprom *sprom = &dev->dev->bus->sprom; in b43legacy_wireless_core_init()
3264 if (!ssb_device_is_enabled(dev->dev)) { in b43legacy_wireless_core_init()
3265 tmp = phy->gmode ? B43legacy_TMSLOW_GMODE : 0; in b43legacy_wireless_core_init()
3269 if ((phy->type == B43legacy_PHYTYPE_B) || in b43legacy_wireless_core_init()
3270 (phy->type == B43legacy_PHYTYPE_G)) { in b43legacy_wireless_core_init()
3271 phy->_lo_pairs = kcalloc(B43legacy_LO_COUNT, in b43legacy_wireless_core_init()
3274 if (!phy->_lo_pairs) in b43legacy_wireless_core_init()
3275 return -ENOMEM; in b43legacy_wireless_core_init()
3284 ssb_pcicore_dev_irqvecs_enable(&bus->pcicore, dev->dev); in b43legacy_wireless_core_init()
3293 dev->dev->id.revision); in b43legacy_wireless_core_init()
3295 if (phy->type == B43legacy_PHYTYPE_G) { in b43legacy_wireless_core_init()
3297 if (phy->rev == 1) in b43legacy_wireless_core_init()
3299 if (sprom->boardflags_lo & B43legacy_BFL_PACTRL) in b43legacy_wireless_core_init()
3301 } else if (phy->type == B43legacy_PHYTYPE_B) { in b43legacy_wireless_core_init()
3303 if (phy->rev >= 2 && phy->radio_ver == 0x2050) in b43legacy_wireless_core_init()
3327 if (phy->type == B43legacy_PHYTYPE_B) in b43legacy_wireless_core_init()
3345 } while (err == -EAGAIN); in b43legacy_wireless_core_init()
3356 ieee80211_wake_queues(dev->wl->hw); in b43legacy_wireless_core_init()
3366 if (phy->dyn_tssi_tbl) in b43legacy_wireless_core_init()
3367 kfree(phy->tssi2dbm); in b43legacy_wireless_core_init()
3369 kfree(phy->lo_control); in b43legacy_wireless_core_init()
3370 phy->lo_control = NULL; in b43legacy_wireless_core_init()
3382 int err = -EOPNOTSUPP; in b43legacy_op_add_interface()
3386 if (vif->type != NL80211_IFTYPE_AP && in b43legacy_op_add_interface()
3387 vif->type != NL80211_IFTYPE_STATION && in b43legacy_op_add_interface()
3388 vif->type != NL80211_IFTYPE_WDS && in b43legacy_op_add_interface()
3389 vif->type != NL80211_IFTYPE_ADHOC) in b43legacy_op_add_interface()
3390 return -EOPNOTSUPP; in b43legacy_op_add_interface()
3392 mutex_lock(&wl->mutex); in b43legacy_op_add_interface()
3393 if (wl->operating) in b43legacy_op_add_interface()
3396 b43legacydbg(wl, "Adding Interface type %d\n", vif->type); in b43legacy_op_add_interface()
3398 dev = wl->current_dev; in b43legacy_op_add_interface()
3399 wl->operating = true; in b43legacy_op_add_interface()
3400 wl->vif = vif; in b43legacy_op_add_interface()
3401 wl->if_type = vif->type; in b43legacy_op_add_interface()
3402 memcpy(wl->mac_addr, vif->addr, ETH_ALEN); in b43legacy_op_add_interface()
3404 spin_lock_irqsave(&wl->irq_lock, flags); in b43legacy_op_add_interface()
3409 spin_unlock_irqrestore(&wl->irq_lock, flags); in b43legacy_op_add_interface()
3413 mutex_unlock(&wl->mutex); in b43legacy_op_add_interface()
3422 struct b43legacy_wldev *dev = wl->current_dev; in b43legacy_op_remove_interface()
3425 b43legacydbg(wl, "Removing Interface type %d\n", vif->type); in b43legacy_op_remove_interface()
3427 mutex_lock(&wl->mutex); in b43legacy_op_remove_interface()
3429 B43legacy_WARN_ON(!wl->operating); in b43legacy_op_remove_interface()
3430 B43legacy_WARN_ON(wl->vif != vif); in b43legacy_op_remove_interface()
3431 wl->vif = NULL; in b43legacy_op_remove_interface()
3433 wl->operating = false; in b43legacy_op_remove_interface()
3435 spin_lock_irqsave(&wl->irq_lock, flags); in b43legacy_op_remove_interface()
3437 eth_zero_addr(wl->mac_addr); in b43legacy_op_remove_interface()
3439 spin_unlock_irqrestore(&wl->irq_lock, flags); in b43legacy_op_remove_interface()
3441 mutex_unlock(&wl->mutex); in b43legacy_op_remove_interface()
3447 struct b43legacy_wldev *dev = wl->current_dev; in b43legacy_op_start()
3454 eth_zero_addr(wl->bssid); in b43legacy_op_start()
3455 eth_zero_addr(wl->mac_addr); in b43legacy_op_start()
3456 wl->filter_flags = 0; in b43legacy_op_start()
3457 wl->beacon0_uploaded = false; in b43legacy_op_start()
3458 wl->beacon1_uploaded = false; in b43legacy_op_start()
3459 wl->beacon_templates_virgin = true; in b43legacy_op_start()
3460 wl->radio_enabled = true; in b43legacy_op_start()
3462 mutex_lock(&wl->mutex); in b43legacy_op_start()
3480 wiphy_rfkill_start_polling(hw->wiphy); in b43legacy_op_start()
3483 mutex_unlock(&wl->mutex); in b43legacy_op_start()
3491 struct b43legacy_wldev *dev = wl->current_dev; in b43legacy_op_stop()
3493 cancel_work_sync(&(wl->beacon_update_trigger)); in b43legacy_op_stop()
3495 mutex_lock(&wl->mutex); in b43legacy_op_stop()
3499 wl->radio_enabled = false; in b43legacy_op_stop()
3500 mutex_unlock(&wl->mutex); in b43legacy_op_stop()
3509 spin_lock_irqsave(&wl->irq_lock, flags); in b43legacy_op_beacon_set_tim()
3511 spin_unlock_irqrestore(&wl->irq_lock, flags); in b43legacy_op_beacon_set_tim()
3520 struct b43legacy_wldev *dev = wl->current_dev; in b43legacy_op_get_survey()
3521 struct ieee80211_conf *conf = &hw->conf; in b43legacy_op_get_survey()
3524 return -ENOENT; in b43legacy_op_get_survey()
3526 survey->channel = conf->chandef.chan; in b43legacy_op_get_survey()
3527 survey->filled = SURVEY_INFO_NOISE_DBM; in b43legacy_op_get_survey()
3528 survey->noise = dev->stats.link_noise; in b43legacy_op_get_survey()
3549 /* Hard-reset the chip. Do not call this directly.
3556 struct b43legacy_wl *wl = dev->wl; in b43legacy_chip_reset()
3560 mutex_lock(&wl->mutex); in b43legacy_chip_reset()
3584 wl->current_dev = NULL; /* Failed to init the dev. */ in b43legacy_chip_reset()
3585 mutex_unlock(&wl->mutex); in b43legacy_chip_reset()
3596 struct ieee80211_hw *hw = dev->wl->hw; in b43legacy_setup_modes()
3597 struct b43legacy_phy *phy = &dev->phy; in b43legacy_setup_modes()
3599 phy->possible_phymodes = 0; in b43legacy_setup_modes()
3601 hw->wiphy->bands[NL80211_BAND_2GHZ] = in b43legacy_setup_modes()
3603 phy->possible_phymodes |= B43legacy_PHYMODE_B; in b43legacy_setup_modes()
3607 hw->wiphy->bands[NL80211_BAND_2GHZ] = in b43legacy_setup_modes()
3609 phy->possible_phymodes |= B43legacy_PHYMODE_G; in b43legacy_setup_modes()
3617 /* We release firmware that late to not be required to re-request in b43legacy_wireless_core_detach()
3624 struct b43legacy_wl *wl = dev->wl; in b43legacy_wireless_core_attach()
3625 struct ssb_bus *bus = dev->dev->bus; in b43legacy_wireless_core_attach()
3626 struct pci_dev *pdev = (bus->bustype == SSB_BUSTYPE_PCI) ? bus->host_pci : NULL; in b43legacy_wireless_core_attach()
3645 if (dev->dev->id.revision >= 5) { in b43legacy_wireless_core_attach()
3648 tmshigh = ssb_read32(dev->dev, SSB_TMSHIGH); in b43legacy_wireless_core_attach()
3652 } else if (dev->dev->id.revision == 4) in b43legacy_wireless_core_attach()
3657 dev->phy.gmode = (have_gphy || have_bphy); in b43legacy_wireless_core_attach()
3658 dev->phy.radio_on = true; in b43legacy_wireless_core_attach()
3659 tmp = dev->phy.gmode ? B43legacy_TMSLOW_GMODE : 0; in b43legacy_wireless_core_attach()
3667 (pdev->device != 0x4312 && in b43legacy_wireless_core_attach()
3668 pdev->device != 0x4319 && in b43legacy_wireless_core_attach()
3669 pdev->device != 0x4324)) { in b43legacy_wireless_core_attach()
3673 switch (dev->phy.type) { in b43legacy_wireless_core_attach()
3684 dev->phy.gmode = (have_gphy || have_bphy); in b43legacy_wireless_core_attach()
3685 tmp = dev->phy.gmode ? B43legacy_TMSLOW_GMODE : 0; in b43legacy_wireless_core_attach()
3696 if (!wl->current_dev) in b43legacy_wireless_core_attach()
3697 wl->current_dev = dev; in b43legacy_wireless_core_attach()
3698 INIT_WORK(&dev->restart_work, b43legacy_chip_reset); in b43legacy_wireless_core_attach()
3702 ssb_device_disable(dev->dev, 0); in b43legacy_wireless_core_attach()
3718 /* Do not cancel ieee80211-workqueue based work here. in b43legacy_one_core_detach()
3722 wl = wldev->wl; in b43legacy_one_core_detach()
3725 list_del(&wldev->list); in b43legacy_one_core_detach()
3726 wl->nr_devs--; in b43legacy_one_core_detach()
3735 int err = -ENOMEM; in b43legacy_one_core_attach()
3741 wldev->dev = dev; in b43legacy_one_core_attach()
3742 wldev->wl = wl; in b43legacy_one_core_attach()
3744 wldev->bad_frames_preempt = modparam_bad_frames_preempt; in b43legacy_one_core_attach()
3745 tasklet_setup(&wldev->isr_tasklet, b43legacy_interrupt_tasklet); in b43legacy_one_core_attach()
3747 wldev->__using_pio = true; in b43legacy_one_core_attach()
3748 INIT_LIST_HEAD(&wldev->list); in b43legacy_one_core_attach()
3754 list_add(&wldev->list, &wl->devlist); in b43legacy_one_core_attach()
3755 wl->nr_devs++; in b43legacy_one_core_attach()
3769 if (bus->boardinfo.vendor == PCI_VENDOR_ID_APPLE && in b43legacy_sprom_fixup()
3770 bus->boardinfo.type == 0x4E && in b43legacy_sprom_fixup()
3771 bus->sprom.board_rev > 0x40) in b43legacy_sprom_fixup()
3772 bus->sprom.boardflags_lo |= B43legacy_BFL_PACTRL; in b43legacy_sprom_fixup()
3778 struct ieee80211_hw *hw = wl->hw; in b43legacy_wireless_exit()
3786 struct ssb_sprom *sprom = &dev->bus->sprom; in b43legacy_wireless_init()
3789 int err = -ENOMEM; in b43legacy_wireless_init()
3792 b43legacy_sprom_fixup(dev->bus); in b43legacy_wireless_init()
3805 hw->wiphy->interface_modes = in b43legacy_wireless_init()
3812 hw->queues = 1; /* FIXME: hardware has more queues */ in b43legacy_wireless_init()
3813 hw->max_rates = 2; in b43legacy_wireless_init()
3814 SET_IEEE80211_DEV(hw, dev->dev); in b43legacy_wireless_init()
3815 if (is_valid_ether_addr(sprom->et1mac)) in b43legacy_wireless_init()
3816 SET_IEEE80211_PERM_ADDR(hw, sprom->et1mac); in b43legacy_wireless_init()
3818 SET_IEEE80211_PERM_ADDR(hw, sprom->il0mac); in b43legacy_wireless_init()
3820 wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST); in b43legacy_wireless_init()
3825 wl->hw = hw; in b43legacy_wireless_init()
3826 spin_lock_init(&wl->irq_lock); in b43legacy_wireless_init()
3827 spin_lock_init(&wl->leds_lock); in b43legacy_wireless_init()
3828 mutex_init(&wl->mutex); in b43legacy_wireless_init()
3829 INIT_LIST_HEAD(&wl->devlist); in b43legacy_wireless_init()
3830 INIT_WORK(&wl->beacon_update_trigger, b43legacy_beacon_update_trigger_work); in b43legacy_wireless_init()
3831 INIT_WORK(&wl->tx_work, b43legacy_tx_work); in b43legacy_wireless_init()
3835 skb_queue_head_init(&wl->tx_queue[queue_num]); in b43legacy_wireless_init()
3836 wl->tx_queue_stopped[queue_num] = 0; in b43legacy_wireless_init()
3841 dev->bus->chip_id, dev->id.revision); in b43legacy_wireless_init()
3856 /* Probing the first core - setup common struct b43legacy_wl */ in b43legacy_probe()
3869 INIT_WORK(&wl->firmware_load, b43legacy_request_firmware); in b43legacy_probe()
3870 schedule_work(&wl->firmware_load); in b43legacy_probe()
3888 cancel_work_sync(&wldev->restart_work); in b43legacy_remove()
3889 cancel_work_sync(&wl->firmware_load); in b43legacy_remove()
3890 complete(&wldev->fw_load_complete); in b43legacy_remove()
3893 if (!wldev->fw.ucode) in b43legacy_remove()
3895 if (wl->current_dev == wldev) in b43legacy_remove()
3896 ieee80211_unregister_hw(wl->hw); in b43legacy_remove()
3900 if (list_empty(&wl->devlist)) in b43legacy_remove()
3914 b43legacyinfo(dev->wl, "Controller RESET (%s) ...\n", reason); in b43legacy_controller_restart()
3915 ieee80211_queue_work(dev->wl->hw, &dev->restart_work); in b43legacy_controller_restart()
3923 struct b43legacy_wl *wl = wldev->wl; in b43legacy_suspend()
3927 mutex_lock(&wl->mutex); in b43legacy_suspend()
3928 wldev->suspend_init_status = b43legacy_status(wldev); in b43legacy_suspend()
3929 if (wldev->suspend_init_status >= B43legacy_STAT_STARTED) in b43legacy_suspend()
3931 if (wldev->suspend_init_status >= B43legacy_STAT_INITIALIZED) in b43legacy_suspend()
3933 mutex_unlock(&wl->mutex); in b43legacy_suspend()
3943 struct b43legacy_wl *wl = wldev->wl; in b43legacy_resume()
3948 mutex_lock(&wl->mutex); in b43legacy_resume()
3949 if (wldev->suspend_init_status >= B43legacy_STAT_INITIALIZED) { in b43legacy_resume()
3956 if (wldev->suspend_init_status >= B43legacy_STAT_STARTED) { in b43legacy_resume()
3967 mutex_unlock(&wl->mutex); in b43legacy_resume()
4002 printk(KERN_INFO "Broadcom 43xx-legacy driver loaded " in b43legacy_print_driverinfo()