| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * |
|---|
| 3 | 4 | * Broadcom B43legacy wireless driver |
|---|
| .. | .. |
|---|
| 12 | 13 | * Some parts of the code in this file are derived from the ipw2200 |
|---|
| 13 | 14 | * driver Copyright(c) 2003 - 2004 Intel Corporation. |
|---|
| 14 | 15 | |
|---|
| 15 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 16 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 17 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 18 | | - * (at your option) any later version. |
|---|
| 19 | | - * |
|---|
| 20 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 21 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 22 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 23 | | - * GNU General Public License for more details. |
|---|
| 24 | | - * |
|---|
| 25 | | - * You should have received a copy of the GNU General Public License |
|---|
| 26 | | - * along with this program; see the file COPYING. If not, write to |
|---|
| 27 | | - * the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor, |
|---|
| 28 | | - * Boston, MA 02110-1301, USA. |
|---|
| 29 | | - * |
|---|
| 30 | 16 | */ |
|---|
| 31 | 17 | |
|---|
| 32 | 18 | #include <linux/delay.h> |
|---|
| .. | .. |
|---|
| 264 | 250 | val = swab32(val); |
|---|
| 265 | 251 | |
|---|
| 266 | 252 | b43legacy_write32(dev, B43legacy_MMIO_RAM_CONTROL, offset); |
|---|
| 267 | | - mmiowb(); |
|---|
| 268 | 253 | b43legacy_write32(dev, B43legacy_MMIO_RAM_DATA, val); |
|---|
| 269 | 254 | } |
|---|
| 270 | 255 | |
|---|
| .. | .. |
|---|
| 341 | 326 | if (offset & 0x0003) { |
|---|
| 342 | 327 | /* Unaligned access */ |
|---|
| 343 | 328 | b43legacy_shm_control_word(dev, routing, offset >> 2); |
|---|
| 344 | | - mmiowb(); |
|---|
| 345 | 329 | b43legacy_write16(dev, |
|---|
| 346 | 330 | B43legacy_MMIO_SHM_DATA_UNALIGNED, |
|---|
| 347 | 331 | (value >> 16) & 0xffff); |
|---|
| 348 | | - mmiowb(); |
|---|
| 349 | 332 | b43legacy_shm_control_word(dev, routing, |
|---|
| 350 | 333 | (offset >> 2) + 1); |
|---|
| 351 | | - mmiowb(); |
|---|
| 352 | 334 | b43legacy_write16(dev, B43legacy_MMIO_SHM_DATA, |
|---|
| 353 | 335 | value & 0xffff); |
|---|
| 354 | 336 | return; |
|---|
| .. | .. |
|---|
| 356 | 338 | offset >>= 2; |
|---|
| 357 | 339 | } |
|---|
| 358 | 340 | b43legacy_shm_control_word(dev, routing, offset); |
|---|
| 359 | | - mmiowb(); |
|---|
| 360 | 341 | b43legacy_write32(dev, B43legacy_MMIO_SHM_DATA, value); |
|---|
| 361 | 342 | } |
|---|
| 362 | 343 | |
|---|
| .. | .. |
|---|
| 368 | 349 | if (offset & 0x0003) { |
|---|
| 369 | 350 | /* Unaligned access */ |
|---|
| 370 | 351 | b43legacy_shm_control_word(dev, routing, offset >> 2); |
|---|
| 371 | | - mmiowb(); |
|---|
| 372 | 352 | b43legacy_write16(dev, |
|---|
| 373 | 353 | B43legacy_MMIO_SHM_DATA_UNALIGNED, |
|---|
| 374 | 354 | value); |
|---|
| .. | .. |
|---|
| 377 | 357 | offset >>= 2; |
|---|
| 378 | 358 | } |
|---|
| 379 | 359 | b43legacy_shm_control_word(dev, routing, offset); |
|---|
| 380 | | - mmiowb(); |
|---|
| 381 | 360 | b43legacy_write16(dev, B43legacy_MMIO_SHM_DATA, value); |
|---|
| 382 | 361 | } |
|---|
| 383 | 362 | |
|---|
| .. | .. |
|---|
| 471 | 450 | status = b43legacy_read32(dev, B43legacy_MMIO_MACCTL); |
|---|
| 472 | 451 | status |= B43legacy_MACCTL_TBTTHOLD; |
|---|
| 473 | 452 | b43legacy_write32(dev, B43legacy_MMIO_MACCTL, status); |
|---|
| 474 | | - mmiowb(); |
|---|
| 475 | 453 | } |
|---|
| 476 | 454 | |
|---|
| 477 | 455 | static void b43legacy_time_unlock(struct b43legacy_wldev *dev) |
|---|
| .. | .. |
|---|
| 494 | 472 | u32 hi = (tsf & 0xFFFFFFFF00000000ULL) >> 32; |
|---|
| 495 | 473 | |
|---|
| 496 | 474 | b43legacy_write32(dev, B43legacy_MMIO_REV3PLUS_TSF_LOW, 0); |
|---|
| 497 | | - mmiowb(); |
|---|
| 498 | 475 | b43legacy_write32(dev, B43legacy_MMIO_REV3PLUS_TSF_HIGH, |
|---|
| 499 | 476 | hi); |
|---|
| 500 | | - mmiowb(); |
|---|
| 501 | 477 | b43legacy_write32(dev, B43legacy_MMIO_REV3PLUS_TSF_LOW, |
|---|
| 502 | 478 | lo); |
|---|
| 503 | 479 | } else { |
|---|
| .. | .. |
|---|
| 507 | 483 | u16 v3 = (tsf & 0xFFFF000000000000ULL) >> 48; |
|---|
| 508 | 484 | |
|---|
| 509 | 485 | b43legacy_write16(dev, B43legacy_MMIO_TSF_0, 0); |
|---|
| 510 | | - mmiowb(); |
|---|
| 511 | 486 | b43legacy_write16(dev, B43legacy_MMIO_TSF_3, v3); |
|---|
| 512 | | - mmiowb(); |
|---|
| 513 | 487 | b43legacy_write16(dev, B43legacy_MMIO_TSF_2, v2); |
|---|
| 514 | | - mmiowb(); |
|---|
| 515 | 488 | b43legacy_write16(dev, B43legacy_MMIO_TSF_1, v1); |
|---|
| 516 | | - mmiowb(); |
|---|
| 517 | 489 | b43legacy_write16(dev, B43legacy_MMIO_TSF_0, v0); |
|---|
| 518 | 490 | } |
|---|
| 519 | 491 | } |
|---|
| .. | .. |
|---|
| 619 | 591 | } |
|---|
| 620 | 592 | |
|---|
| 621 | 593 | /* DummyTransmission function, as documented on |
|---|
| 622 | | - * http://bcm-specs.sipsolutions.net/DummyTransmission |
|---|
| 594 | + * https://bcm-specs.sipsolutions.net/DummyTransmission |
|---|
| 623 | 595 | */ |
|---|
| 624 | 596 | void b43legacy_dummy_transmission(struct b43legacy_wldev *dev) |
|---|
| 625 | 597 | { |
|---|
| .. | .. |
|---|
| 1250 | 1222 | /* The handler might have updated the IRQ mask. */ |
|---|
| 1251 | 1223 | b43legacy_write32(dev, B43legacy_MMIO_GEN_IRQ_MASK, |
|---|
| 1252 | 1224 | dev->irq_mask); |
|---|
| 1253 | | - mmiowb(); |
|---|
| 1254 | 1225 | spin_unlock_irq(&wl->irq_lock); |
|---|
| 1255 | 1226 | } |
|---|
| 1256 | 1227 | mutex_unlock(&wl->mutex); |
|---|
| .. | .. |
|---|
| 1304 | 1275 | } |
|---|
| 1305 | 1276 | |
|---|
| 1306 | 1277 | /* Interrupt handler bottom-half */ |
|---|
| 1307 | | -static void b43legacy_interrupt_tasklet(unsigned long data) |
|---|
| 1278 | +static void b43legacy_interrupt_tasklet(struct tasklet_struct *t) |
|---|
| 1308 | 1279 | { |
|---|
| 1309 | | - struct b43legacy_wldev *dev = (struct b43legacy_wldev *)data; |
|---|
| 1280 | + struct b43legacy_wldev *dev = from_tasklet(dev, t, isr_tasklet); |
|---|
| 1310 | 1281 | u32 reason; |
|---|
| 1311 | 1282 | u32 dma_reason[ARRAY_SIZE(dev->dma_reason)]; |
|---|
| 1312 | 1283 | u32 merged_dma_reason = 0; |
|---|
| .. | .. |
|---|
| 1347 | 1318 | dma_reason[2], dma_reason[3], |
|---|
| 1348 | 1319 | dma_reason[4], dma_reason[5]); |
|---|
| 1349 | 1320 | b43legacy_controller_restart(dev, "DMA error"); |
|---|
| 1350 | | - mmiowb(); |
|---|
| 1351 | 1321 | spin_unlock_irqrestore(&dev->wl->irq_lock, flags); |
|---|
| 1352 | 1322 | return; |
|---|
| 1353 | 1323 | } |
|---|
| .. | .. |
|---|
| 1370 | 1340 | handle_irq_beacon(dev); |
|---|
| 1371 | 1341 | if (reason & B43legacy_IRQ_PMQ) |
|---|
| 1372 | 1342 | handle_irq_pmq(dev); |
|---|
| 1373 | | - if (reason & B43legacy_IRQ_TXFIFO_FLUSH_OK) |
|---|
| 1343 | + if (reason & B43legacy_IRQ_TXFIFO_FLUSH_OK) { |
|---|
| 1374 | 1344 | ;/*TODO*/ |
|---|
| 1345 | + } |
|---|
| 1375 | 1346 | if (reason & B43legacy_IRQ_NOISESAMPLE_OK) |
|---|
| 1376 | 1347 | handle_irq_noise(dev); |
|---|
| 1377 | 1348 | |
|---|
| .. | .. |
|---|
| 1397 | 1368 | handle_irq_transmit_status(dev); |
|---|
| 1398 | 1369 | |
|---|
| 1399 | 1370 | b43legacy_write32(dev, B43legacy_MMIO_GEN_IRQ_MASK, dev->irq_mask); |
|---|
| 1400 | | - mmiowb(); |
|---|
| 1401 | 1371 | spin_unlock_irqrestore(&dev->wl->irq_lock, flags); |
|---|
| 1402 | 1372 | } |
|---|
| 1403 | 1373 | |
|---|
| .. | .. |
|---|
| 1489 | 1459 | dev->irq_reason = reason; |
|---|
| 1490 | 1460 | tasklet_schedule(&dev->isr_tasklet); |
|---|
| 1491 | 1461 | out: |
|---|
| 1492 | | - mmiowb(); |
|---|
| 1493 | 1462 | spin_unlock(&dev->wl->irq_lock); |
|---|
| 1494 | 1463 | |
|---|
| 1495 | 1464 | return ret; |
|---|
| .. | .. |
|---|
| 1509 | 1478 | |
|---|
| 1510 | 1479 | static void b43legacy_print_fw_helptext(struct b43legacy_wl *wl) |
|---|
| 1511 | 1480 | { |
|---|
| 1512 | | - b43legacyerr(wl, "You must go to http://wireless.kernel.org/en/users/" |
|---|
| 1513 | | - "Drivers/b43#devicefirmware " |
|---|
| 1481 | + b43legacyerr(wl, "You must go to https://wireless.wiki.kernel.org/en/" |
|---|
| 1482 | + "users/Drivers/b43#devicefirmware " |
|---|
| 1514 | 1483 | "and download the correct firmware (version 3).\n"); |
|---|
| 1515 | 1484 | } |
|---|
| 1516 | 1485 | |
|---|
| .. | .. |
|---|
| 1569 | 1538 | size = be32_to_cpu(hdr->size); |
|---|
| 1570 | 1539 | if (size != (*fw)->size - sizeof(struct b43legacy_fw_header)) |
|---|
| 1571 | 1540 | goto err_format; |
|---|
| 1572 | | - /* fallthrough */ |
|---|
| 1541 | + fallthrough; |
|---|
| 1573 | 1542 | case B43legacy_FW_TYPE_IV: |
|---|
| 1574 | 1543 | if (hdr->ver != 1) |
|---|
| 1575 | 1544 | goto err_format; |
|---|
| .. | .. |
|---|
| 1902 | 1871 | } |
|---|
| 1903 | 1872 | |
|---|
| 1904 | 1873 | /* Initialize the GPIOs |
|---|
| 1905 | | - * http://bcm-specs.sipsolutions.net/GPIO |
|---|
| 1874 | + * https://bcm-specs.sipsolutions.net/GPIO |
|---|
| 1906 | 1875 | */ |
|---|
| 1907 | 1876 | static int b43legacy_gpio_init(struct b43legacy_wldev *dev) |
|---|
| 1908 | 1877 | { |
|---|
| .. | .. |
|---|
| 1992 | 1961 | } |
|---|
| 1993 | 1962 | } |
|---|
| 1994 | 1963 | |
|---|
| 1995 | | -/* http://bcm-specs.sipsolutions.net/SuspendMAC */ |
|---|
| 1964 | +/* https://bcm-specs.sipsolutions.net/SuspendMAC */ |
|---|
| 1996 | 1965 | void b43legacy_mac_suspend(struct b43legacy_wldev *dev) |
|---|
| 1997 | 1966 | { |
|---|
| 1998 | 1967 | int i; |
|---|
| .. | .. |
|---|
| 2108 | 2077 | b43legacy_rate_memory_write(dev, B43legacy_OFDM_RATE_36MB, 1); |
|---|
| 2109 | 2078 | b43legacy_rate_memory_write(dev, B43legacy_OFDM_RATE_48MB, 1); |
|---|
| 2110 | 2079 | b43legacy_rate_memory_write(dev, B43legacy_OFDM_RATE_54MB, 1); |
|---|
| 2111 | | - /* fallthrough */ |
|---|
| 2080 | + fallthrough; |
|---|
| 2112 | 2081 | case B43legacy_PHYTYPE_B: |
|---|
| 2113 | 2082 | b43legacy_rate_memory_write(dev, B43legacy_CCK_RATE_1MB, 0); |
|---|
| 2114 | 2083 | b43legacy_rate_memory_write(dev, B43legacy_CCK_RATE_2MB, 0); |
|---|
| .. | .. |
|---|
| 2173 | 2142 | } |
|---|
| 2174 | 2143 | |
|---|
| 2175 | 2144 | /* Initialize the chip |
|---|
| 2176 | | - * http://bcm-specs.sipsolutions.net/ChipInit |
|---|
| 2145 | + * https://bcm-specs.sipsolutions.net/ChipInit |
|---|
| 2177 | 2146 | */ |
|---|
| 2178 | 2147 | static int b43legacy_chip_init(struct b43legacy_wldev *dev) |
|---|
| 2179 | 2148 | { |
|---|
| .. | .. |
|---|
| 2612 | 2581 | static int b43legacy_switch_phymode(struct b43legacy_wl *wl, |
|---|
| 2613 | 2582 | unsigned int new_mode) |
|---|
| 2614 | 2583 | { |
|---|
| 2615 | | - struct b43legacy_wldev *uninitialized_var(up_dev); |
|---|
| 2584 | + struct b43legacy_wldev *up_dev; |
|---|
| 2616 | 2585 | struct b43legacy_wldev *down_dev; |
|---|
| 2617 | 2586 | int err; |
|---|
| 2618 | 2587 | bool gmode = false; |
|---|
| .. | .. |
|---|
| 2782 | 2751 | |
|---|
| 2783 | 2752 | spin_lock_irqsave(&wl->irq_lock, flags); |
|---|
| 2784 | 2753 | b43legacy_write32(dev, B43legacy_MMIO_GEN_IRQ_MASK, dev->irq_mask); |
|---|
| 2785 | | - mmiowb(); |
|---|
| 2786 | 2754 | spin_unlock_irqrestore(&wl->irq_lock, flags); |
|---|
| 2787 | 2755 | out_unlock_mutex: |
|---|
| 2788 | 2756 | mutex_unlock(&wl->mutex); |
|---|
| .. | .. |
|---|
| 2901 | 2869 | spin_lock_irqsave(&wl->irq_lock, flags); |
|---|
| 2902 | 2870 | b43legacy_write32(dev, B43legacy_MMIO_GEN_IRQ_MASK, dev->irq_mask); |
|---|
| 2903 | 2871 | /* XXX: why? */ |
|---|
| 2904 | | - mmiowb(); |
|---|
| 2905 | 2872 | spin_unlock_irqrestore(&wl->irq_lock, flags); |
|---|
| 2906 | 2873 | out_unlock_mutex: |
|---|
| 2907 | 2874 | mutex_unlock(&wl->mutex); |
|---|
| .. | .. |
|---|
| 3775 | 3742 | wldev->wl = wl; |
|---|
| 3776 | 3743 | b43legacy_set_status(wldev, B43legacy_STAT_UNINIT); |
|---|
| 3777 | 3744 | wldev->bad_frames_preempt = modparam_bad_frames_preempt; |
|---|
| 3778 | | - tasklet_init(&wldev->isr_tasklet, |
|---|
| 3779 | | - b43legacy_interrupt_tasklet, |
|---|
| 3780 | | - (unsigned long)wldev); |
|---|
| 3745 | + tasklet_setup(&wldev->isr_tasklet, b43legacy_interrupt_tasklet); |
|---|
| 3781 | 3746 | if (modparam_pio) |
|---|
| 3782 | 3747 | wldev->__using_pio = true; |
|---|
| 3783 | 3748 | INIT_LIST_HEAD(&wldev->list); |
|---|