aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/b43/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/b43/main.c')
-rw-r--r--drivers/net/wireless/b43/main.c194
1 files changed, 100 insertions, 94 deletions
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 5a43984bdcea..eb4159686985 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -548,7 +548,7 @@ void b43_tsf_read(struct b43_wldev *dev, u64 *tsf)
548{ 548{
549 u32 low, high; 549 u32 low, high;
550 550
551 B43_WARN_ON(dev->dev->id.revision < 3); 551 B43_WARN_ON(dev->sdev->id.revision < 3);
552 552
553 /* The hardware guarantees us an atomic read, if we 553 /* The hardware guarantees us an atomic read, if we
554 * read the low register first. */ 554 * read the low register first. */
@@ -586,7 +586,7 @@ static void b43_tsf_write_locked(struct b43_wldev *dev, u64 tsf)
586{ 586{
587 u32 low, high; 587 u32 low, high;
588 588
589 B43_WARN_ON(dev->dev->id.revision < 3); 589 B43_WARN_ON(dev->sdev->id.revision < 3);
590 590
591 low = tsf; 591 low = tsf;
592 high = (tsf >> 32); 592 high = (tsf >> 32);
@@ -714,7 +714,7 @@ void b43_dummy_transmission(struct b43_wldev *dev, bool ofdm, bool pa_on)
714 b43_ram_write(dev, i * 4, buffer[i]); 714 b43_ram_write(dev, i * 4, buffer[i]);
715 715
716 b43_write16(dev, 0x0568, 0x0000); 716 b43_write16(dev, 0x0568, 0x0000);
717 if (dev->dev->id.revision < 11) 717 if (dev->sdev->id.revision < 11)
718 b43_write16(dev, 0x07C0, 0x0000); 718 b43_write16(dev, 0x07C0, 0x0000);
719 else 719 else
720 b43_write16(dev, 0x07C0, 0x0100); 720 b43_write16(dev, 0x07C0, 0x0100);
@@ -1132,7 +1132,7 @@ void b43_power_saving_ctl_bits(struct b43_wldev *dev, unsigned int ps_flags)
1132 b43_write32(dev, B43_MMIO_MACCTL, macctl); 1132 b43_write32(dev, B43_MMIO_MACCTL, macctl);
1133 /* Commit write */ 1133 /* Commit write */
1134 b43_read32(dev, B43_MMIO_MACCTL); 1134 b43_read32(dev, B43_MMIO_MACCTL);
1135 if (awake && dev->dev->id.revision >= 5) { 1135 if (awake && dev->sdev->id.revision >= 5) {
1136 /* Wait for the microcode to wake up. */ 1136 /* Wait for the microcode to wake up. */
1137 for (i = 0; i < 100; i++) { 1137 for (i = 0; i < 100; i++) {
1138 ucstat = b43_shm_read16(dev, B43_SHM_SHARED, 1138 ucstat = b43_shm_read16(dev, B43_SHM_SHARED,
@@ -1144,29 +1144,35 @@ void b43_power_saving_ctl_bits(struct b43_wldev *dev, unsigned int ps_flags)
1144 } 1144 }
1145} 1145}
1146 1146
1147void b43_wireless_core_reset(struct b43_wldev *dev, u32 flags) 1147static void b43_ssb_wireless_core_reset(struct b43_wldev *dev, u32 flags)
1148{ 1148{
1149 u32 tmslow; 1149 u32 tmslow;
1150 u32 macctl;
1151 1150
1152 flags |= B43_TMSLOW_PHYCLKEN; 1151 flags |= B43_TMSLOW_PHYCLKEN;
1153 flags |= B43_TMSLOW_PHYRESET; 1152 flags |= B43_TMSLOW_PHYRESET;
1154 if (dev->phy.type == B43_PHYTYPE_N) 1153 if (dev->phy.type == B43_PHYTYPE_N)
1155 flags |= B43_TMSLOW_PHY_BANDWIDTH_20MHZ; /* Make 20 MHz def */ 1154 flags |= B43_TMSLOW_PHY_BANDWIDTH_20MHZ; /* Make 20 MHz def */
1156 ssb_device_enable(dev->dev, flags); 1155 ssb_device_enable(dev->sdev, flags);
1157 msleep(2); /* Wait for the PLL to turn on. */ 1156 msleep(2); /* Wait for the PLL to turn on. */
1158 1157
1159 /* Now take the PHY out of Reset again */ 1158 /* Now take the PHY out of Reset again */
1160 tmslow = ssb_read32(dev->dev, SSB_TMSLOW); 1159 tmslow = ssb_read32(dev->sdev, SSB_TMSLOW);
1161 tmslow |= SSB_TMSLOW_FGC; 1160 tmslow |= SSB_TMSLOW_FGC;
1162 tmslow &= ~B43_TMSLOW_PHYRESET; 1161 tmslow &= ~B43_TMSLOW_PHYRESET;
1163 ssb_write32(dev->dev, SSB_TMSLOW, tmslow); 1162 ssb_write32(dev->sdev, SSB_TMSLOW, tmslow);
1164 ssb_read32(dev->dev, SSB_TMSLOW); /* flush */ 1163 ssb_read32(dev->sdev, SSB_TMSLOW); /* flush */
1165 msleep(1); 1164 msleep(1);
1166 tmslow &= ~SSB_TMSLOW_FGC; 1165 tmslow &= ~SSB_TMSLOW_FGC;
1167 ssb_write32(dev->dev, SSB_TMSLOW, tmslow); 1166 ssb_write32(dev->sdev, SSB_TMSLOW, tmslow);
1168 ssb_read32(dev->dev, SSB_TMSLOW); /* flush */ 1167 ssb_read32(dev->sdev, SSB_TMSLOW); /* flush */
1169 msleep(1); 1168 msleep(1);
1169}
1170
1171void b43_wireless_core_reset(struct b43_wldev *dev, u32 flags)
1172{
1173 u32 macctl;
1174
1175 b43_ssb_wireless_core_reset(dev, flags);
1170 1176
1171 /* Turn Analog ON, but only if we already know the PHY-type. 1177 /* Turn Analog ON, but only if we already know the PHY-type.
1172 * This protects against very early setup where we don't know the 1178 * This protects against very early setup where we don't know the
@@ -1215,7 +1221,7 @@ static void drain_txstatus_queue(struct b43_wldev *dev)
1215{ 1221{
1216 u32 dummy; 1222 u32 dummy;
1217 1223
1218 if (dev->dev->id.revision < 5) 1224 if (dev->sdev->id.revision < 5)
1219 return; 1225 return;
1220 /* Read all entries from the microcode TXstatus FIFO 1226 /* Read all entries from the microcode TXstatus FIFO
1221 * and throw them away. 1227 * and throw them away.
@@ -1421,9 +1427,9 @@ u8 b43_ieee80211_antenna_sanitize(struct b43_wldev *dev,
1421 1427
1422 /* Get the mask of available antennas. */ 1428 /* Get the mask of available antennas. */
1423 if (dev->phy.gmode) 1429 if (dev->phy.gmode)
1424 antenna_mask = dev->dev->bus->sprom.ant_available_bg; 1430 antenna_mask = dev->sdev->bus->sprom.ant_available_bg;
1425 else 1431 else
1426 antenna_mask = dev->dev->bus->sprom.ant_available_a; 1432 antenna_mask = dev->sdev->bus->sprom.ant_available_a;
1427 1433
1428 if (!(antenna_mask & (1 << (antenna_nr - 1)))) { 1434 if (!(antenna_mask & (1 << (antenna_nr - 1)))) {
1429 /* This antenna is not available. Fall back to default. */ 1435 /* This antenna is not available. Fall back to default. */
@@ -1638,7 +1644,7 @@ static void b43_beacon_update_trigger_work(struct work_struct *work)
1638 mutex_lock(&wl->mutex); 1644 mutex_lock(&wl->mutex);
1639 dev = wl->current_dev; 1645 dev = wl->current_dev;
1640 if (likely(dev && (b43_status(dev) >= B43_STAT_INITIALIZED))) { 1646 if (likely(dev && (b43_status(dev) >= B43_STAT_INITIALIZED))) {
1641 if (dev->dev->bus->bustype == SSB_BUSTYPE_SDIO) { 1647 if (dev->sdev->bus->bustype == SSB_BUSTYPE_SDIO) {
1642 /* wl->mutex is enough. */ 1648 /* wl->mutex is enough. */
1643 b43_do_beacon_update_trigger_work(dev); 1649 b43_do_beacon_update_trigger_work(dev);
1644 mmiowb(); 1650 mmiowb();
@@ -1683,7 +1689,7 @@ static void b43_update_templates(struct b43_wl *wl)
1683static void b43_set_beacon_int(struct b43_wldev *dev, u16 beacon_int) 1689static void b43_set_beacon_int(struct b43_wldev *dev, u16 beacon_int)
1684{ 1690{
1685 b43_time_lock(dev); 1691 b43_time_lock(dev);
1686 if (dev->dev->id.revision >= 3) { 1692 if (dev->sdev->id.revision >= 3) {
1687 b43_write32(dev, B43_MMIO_TSF_CFP_REP, (beacon_int << 16)); 1693 b43_write32(dev, B43_MMIO_TSF_CFP_REP, (beacon_int << 16));
1688 b43_write32(dev, B43_MMIO_TSF_CFP_START, (beacon_int << 10)); 1694 b43_write32(dev, B43_MMIO_TSF_CFP_START, (beacon_int << 10));
1689 } else { 1695 } else {
@@ -2057,7 +2063,7 @@ int b43_do_request_fw(struct b43_request_fw_context *ctx,
2057 B43_WARN_ON(1); 2063 B43_WARN_ON(1);
2058 return -ENOSYS; 2064 return -ENOSYS;
2059 } 2065 }
2060 err = request_firmware(&blob, ctx->fwname, ctx->dev->dev->dev); 2066 err = request_firmware(&blob, ctx->fwname, ctx->dev->sdev->dev);
2061 if (err == -ENOENT) { 2067 if (err == -ENOENT) {
2062 snprintf(ctx->errors[ctx->req_type], 2068 snprintf(ctx->errors[ctx->req_type],
2063 sizeof(ctx->errors[ctx->req_type]), 2069 sizeof(ctx->errors[ctx->req_type]),
@@ -2107,13 +2113,12 @@ static int b43_try_request_fw(struct b43_request_fw_context *ctx)
2107{ 2113{
2108 struct b43_wldev *dev = ctx->dev; 2114 struct b43_wldev *dev = ctx->dev;
2109 struct b43_firmware *fw = &ctx->dev->fw; 2115 struct b43_firmware *fw = &ctx->dev->fw;
2110 const u8 rev = ctx->dev->dev->id.revision; 2116 const u8 rev = ctx->dev->sdev->id.revision;
2111 const char *filename; 2117 const char *filename;
2112 u32 tmshigh; 2118 u32 tmshigh;
2113 int err; 2119 int err;
2114 2120
2115 /* Get microcode */ 2121 /* Get microcode */
2116 tmshigh = ssb_read32(dev->dev, SSB_TMSHIGH);
2117 if ((rev >= 5) && (rev <= 10)) 2122 if ((rev >= 5) && (rev <= 10))
2118 filename = "ucode5"; 2123 filename = "ucode5";
2119 else if ((rev >= 11) && (rev <= 12)) 2124 else if ((rev >= 11) && (rev <= 12))
@@ -2152,6 +2157,7 @@ static int b43_try_request_fw(struct b43_request_fw_context *ctx)
2152 switch (dev->phy.type) { 2157 switch (dev->phy.type) {
2153 case B43_PHYTYPE_A: 2158 case B43_PHYTYPE_A:
2154 if ((rev >= 5) && (rev <= 10)) { 2159 if ((rev >= 5) && (rev <= 10)) {
2160 tmshigh = ssb_read32(dev->sdev, SSB_TMSHIGH);
2155 if (tmshigh & B43_TMSHIGH_HAVE_2GHZ_PHY) 2161 if (tmshigh & B43_TMSHIGH_HAVE_2GHZ_PHY)
2156 filename = "a0g1initvals5"; 2162 filename = "a0g1initvals5";
2157 else 2163 else
@@ -2196,6 +2202,7 @@ static int b43_try_request_fw(struct b43_request_fw_context *ctx)
2196 switch (dev->phy.type) { 2202 switch (dev->phy.type) {
2197 case B43_PHYTYPE_A: 2203 case B43_PHYTYPE_A:
2198 if ((rev >= 5) && (rev <= 10)) { 2204 if ((rev >= 5) && (rev <= 10)) {
2205 tmshigh = ssb_read32(dev->sdev, SSB_TMSHIGH);
2199 if (tmshigh & B43_TMSHIGH_HAVE_2GHZ_PHY) 2206 if (tmshigh & B43_TMSHIGH_HAVE_2GHZ_PHY)
2200 filename = "a0g1bsinitvals5"; 2207 filename = "a0g1bsinitvals5";
2201 else 2208 else
@@ -2441,7 +2448,7 @@ static int b43_upload_microcode(struct b43_wldev *dev)
2441 2448
2442 snprintf(wiphy->fw_version, sizeof(wiphy->fw_version), "%u.%u", 2449 snprintf(wiphy->fw_version, sizeof(wiphy->fw_version), "%u.%u",
2443 dev->fw.rev, dev->fw.patch); 2450 dev->fw.rev, dev->fw.patch);
2444 wiphy->hw_version = dev->dev->id.coreid; 2451 wiphy->hw_version = dev->sdev->id.coreid;
2445 2452
2446 if (b43_is_old_txhdr_format(dev)) { 2453 if (b43_is_old_txhdr_format(dev)) {
2447 /* We're over the deadline, but we keep support for old fw 2454 /* We're over the deadline, but we keep support for old fw
@@ -2557,10 +2564,20 @@ out:
2557/* Initialize the GPIOs 2564/* Initialize the GPIOs
2558 * http://bcm-specs.sipsolutions.net/GPIO 2565 * http://bcm-specs.sipsolutions.net/GPIO
2559 */ 2566 */
2567static struct ssb_device *b43_ssb_gpio_dev(struct b43_wldev *dev)
2568{
2569 struct ssb_bus *bus = dev->sdev->bus;
2570
2571#ifdef CONFIG_SSB_DRIVER_PCICORE
2572 return (bus->chipco.dev ? bus->chipco.dev : bus->pcicore.dev);
2573#else
2574 return bus->chipco.dev;
2575#endif
2576}
2577
2560static int b43_gpio_init(struct b43_wldev *dev) 2578static int b43_gpio_init(struct b43_wldev *dev)
2561{ 2579{
2562 struct ssb_bus *bus = dev->dev->bus; 2580 struct ssb_device *gpiodev;
2563 struct ssb_device *gpiodev, *pcidev = NULL;
2564 u32 mask, set; 2581 u32 mask, set;
2565 2582
2566 b43_write32(dev, B43_MMIO_MACCTL, b43_read32(dev, B43_MMIO_MACCTL) 2583 b43_write32(dev, B43_MMIO_MACCTL, b43_read32(dev, B43_MMIO_MACCTL)
@@ -2571,7 +2588,7 @@ static int b43_gpio_init(struct b43_wldev *dev)
2571 2588
2572 mask = 0x0000001F; 2589 mask = 0x0000001F;
2573 set = 0x0000000F; 2590 set = 0x0000000F;
2574 if (dev->dev->bus->chip_id == 0x4301) { 2591 if (dev->sdev->bus->chip_id == 0x4301) {
2575 mask |= 0x0060; 2592 mask |= 0x0060;
2576 set |= 0x0060; 2593 set |= 0x0060;
2577 } 2594 }
@@ -2582,25 +2599,21 @@ static int b43_gpio_init(struct b43_wldev *dev)
2582 mask |= 0x0180; 2599 mask |= 0x0180;
2583 set |= 0x0180; 2600 set |= 0x0180;
2584 } 2601 }
2585 if (dev->dev->bus->sprom.boardflags_lo & B43_BFL_PACTRL) { 2602 if (dev->sdev->bus->sprom.boardflags_lo & B43_BFL_PACTRL) {
2586 b43_write16(dev, B43_MMIO_GPIO_MASK, 2603 b43_write16(dev, B43_MMIO_GPIO_MASK,
2587 b43_read16(dev, B43_MMIO_GPIO_MASK) 2604 b43_read16(dev, B43_MMIO_GPIO_MASK)
2588 | 0x0200); 2605 | 0x0200);
2589 mask |= 0x0200; 2606 mask |= 0x0200;
2590 set |= 0x0200; 2607 set |= 0x0200;
2591 } 2608 }
2592 if (dev->dev->id.revision >= 2) 2609 if (dev->sdev->id.revision >= 2)
2593 mask |= 0x0010; /* FIXME: This is redundant. */ 2610 mask |= 0x0010; /* FIXME: This is redundant. */
2594 2611
2595#ifdef CONFIG_SSB_DRIVER_PCICORE 2612 gpiodev = b43_ssb_gpio_dev(dev);
2596 pcidev = bus->pcicore.dev; 2613 if (gpiodev)
2597#endif 2614 ssb_write32(gpiodev, B43_GPIO_CONTROL,
2598 gpiodev = bus->chipco.dev ? : pcidev; 2615 (ssb_read32(gpiodev, B43_GPIO_CONTROL)
2599 if (!gpiodev) 2616 & mask) | set);
2600 return 0;
2601 ssb_write32(gpiodev, B43_GPIO_CONTROL,
2602 (ssb_read32(gpiodev, B43_GPIO_CONTROL)
2603 & mask) | set);
2604 2617
2605 return 0; 2618 return 0;
2606} 2619}
@@ -2608,16 +2621,11 @@ static int b43_gpio_init(struct b43_wldev *dev)
2608/* Turn off all GPIO stuff. Call this on module unload, for example. */ 2621/* Turn off all GPIO stuff. Call this on module unload, for example. */
2609static void b43_gpio_cleanup(struct b43_wldev *dev) 2622static void b43_gpio_cleanup(struct b43_wldev *dev)
2610{ 2623{
2611 struct ssb_bus *bus = dev->dev->bus; 2624 struct ssb_device *gpiodev;
2612 struct ssb_device *gpiodev, *pcidev = NULL;
2613 2625
2614#ifdef CONFIG_SSB_DRIVER_PCICORE 2626 gpiodev = b43_ssb_gpio_dev(dev);
2615 pcidev = bus->pcicore.dev; 2627 if (gpiodev)
2616#endif 2628 ssb_write32(gpiodev, B43_GPIO_CONTROL, 0);
2617 gpiodev = bus->chipco.dev ? : pcidev;
2618 if (!gpiodev)
2619 return;
2620 ssb_write32(gpiodev, B43_GPIO_CONTROL, 0);
2621} 2629}
2622 2630
2623/* http://bcm-specs.sipsolutions.net/EnableMac */ 2631/* http://bcm-specs.sipsolutions.net/EnableMac */
@@ -2689,12 +2697,12 @@ out:
2689/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/MacPhyClkSet */ 2697/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/MacPhyClkSet */
2690void b43_mac_phy_clock_set(struct b43_wldev *dev, bool on) 2698void b43_mac_phy_clock_set(struct b43_wldev *dev, bool on)
2691{ 2699{
2692 u32 tmslow = ssb_read32(dev->dev, SSB_TMSLOW); 2700 u32 tmslow = ssb_read32(dev->sdev, SSB_TMSLOW);
2693 if (on) 2701 if (on)
2694 tmslow |= B43_TMSLOW_MACPHYCLKEN; 2702 tmslow |= B43_TMSLOW_MACPHYCLKEN;
2695 else 2703 else
2696 tmslow &= ~B43_TMSLOW_MACPHYCLKEN; 2704 tmslow &= ~B43_TMSLOW_MACPHYCLKEN;
2697 ssb_write32(dev->dev, SSB_TMSLOW, tmslow); 2705 ssb_write32(dev->sdev, SSB_TMSLOW, tmslow);
2698} 2706}
2699 2707
2700static void b43_adjust_opmode(struct b43_wldev *dev) 2708static void b43_adjust_opmode(struct b43_wldev *dev)
@@ -2733,15 +2741,15 @@ static void b43_adjust_opmode(struct b43_wldev *dev)
2733 /* Workaround: On old hardware the HW-MAC-address-filter 2741 /* Workaround: On old hardware the HW-MAC-address-filter
2734 * doesn't work properly, so always run promisc in filter 2742 * doesn't work properly, so always run promisc in filter
2735 * it in software. */ 2743 * it in software. */
2736 if (dev->dev->id.revision <= 4) 2744 if (dev->sdev->id.revision <= 4)
2737 ctl |= B43_MACCTL_PROMISC; 2745 ctl |= B43_MACCTL_PROMISC;
2738 2746
2739 b43_write32(dev, B43_MMIO_MACCTL, ctl); 2747 b43_write32(dev, B43_MMIO_MACCTL, ctl);
2740 2748
2741 cfp_pretbtt = 2; 2749 cfp_pretbtt = 2;
2742 if ((ctl & B43_MACCTL_INFRA) && !(ctl & B43_MACCTL_AP)) { 2750 if ((ctl & B43_MACCTL_INFRA) && !(ctl & B43_MACCTL_AP)) {
2743 if (dev->dev->bus->chip_id == 0x4306 && 2751 if (dev->sdev->bus->chip_id == 0x4306 &&
2744 dev->dev->bus->chip_rev == 3) 2752 dev->sdev->bus->chip_rev == 3)
2745 cfp_pretbtt = 100; 2753 cfp_pretbtt = 100;
2746 else 2754 else
2747 cfp_pretbtt = 50; 2755 cfp_pretbtt = 50;
@@ -2899,7 +2907,7 @@ static int b43_chip_init(struct b43_wldev *dev)
2899 b43_write16(dev, 0x005E, value16); 2907 b43_write16(dev, 0x005E, value16);
2900 } 2908 }
2901 b43_write32(dev, 0x0100, 0x01000000); 2909 b43_write32(dev, 0x0100, 0x01000000);
2902 if (dev->dev->id.revision < 5) 2910 if (dev->sdev->id.revision < 5)
2903 b43_write32(dev, 0x010C, 0x01000000); 2911 b43_write32(dev, 0x010C, 0x01000000);
2904 2912
2905 b43_write32(dev, B43_MMIO_MACCTL, b43_read32(dev, B43_MMIO_MACCTL) 2913 b43_write32(dev, B43_MMIO_MACCTL, b43_read32(dev, B43_MMIO_MACCTL)
@@ -2914,7 +2922,7 @@ static int b43_chip_init(struct b43_wldev *dev)
2914 /* Initially set the wireless operation mode. */ 2922 /* Initially set the wireless operation mode. */
2915 b43_adjust_opmode(dev); 2923 b43_adjust_opmode(dev);
2916 2924
2917 if (dev->dev->id.revision < 3) { 2925 if (dev->sdev->id.revision < 3) {
2918 b43_write16(dev, 0x060E, 0x0000); 2926 b43_write16(dev, 0x060E, 0x0000);
2919 b43_write16(dev, 0x0610, 0x8000); 2927 b43_write16(dev, 0x0610, 0x8000);
2920 b43_write16(dev, 0x0604, 0x0000); 2928 b43_write16(dev, 0x0604, 0x0000);
@@ -2934,7 +2942,7 @@ static int b43_chip_init(struct b43_wldev *dev)
2934 b43_mac_phy_clock_set(dev, true); 2942 b43_mac_phy_clock_set(dev, true);
2935 2943
2936 b43_write16(dev, B43_MMIO_POWERUP_DELAY, 2944 b43_write16(dev, B43_MMIO_POWERUP_DELAY,
2937 dev->dev->bus->chipco.fast_pwrup_delay); 2945 dev->sdev->bus->chipco.fast_pwrup_delay);
2938 2946
2939 err = 0; 2947 err = 0;
2940 b43dbg(dev->wl, "Chip initialized\n"); 2948 b43dbg(dev->wl, "Chip initialized\n");
@@ -3097,7 +3105,7 @@ static int b43_validate_chipaccess(struct b43_wldev *dev)
3097 b43_shm_write32(dev, B43_SHM_SHARED, 0, backup0); 3105 b43_shm_write32(dev, B43_SHM_SHARED, 0, backup0);
3098 b43_shm_write32(dev, B43_SHM_SHARED, 4, backup4); 3106 b43_shm_write32(dev, B43_SHM_SHARED, 4, backup4);
3099 3107
3100 if ((dev->dev->id.revision >= 3) && (dev->dev->id.revision <= 10)) { 3108 if ((dev->sdev->id.revision >= 3) && (dev->sdev->id.revision <= 10)) {
3101 /* The 32bit register shadows the two 16bit registers 3109 /* The 32bit register shadows the two 16bit registers
3102 * with update sideeffects. Validate this. */ 3110 * with update sideeffects. Validate this. */
3103 b43_write16(dev, B43_MMIO_TSF_CFP_START, 0xAAAA); 3111 b43_write16(dev, B43_MMIO_TSF_CFP_START, 0xAAAA);
@@ -3450,7 +3458,7 @@ static void b43_op_set_tsf(struct ieee80211_hw *hw, u64 tsf)
3450 3458
3451static void b43_put_phy_into_reset(struct b43_wldev *dev) 3459static void b43_put_phy_into_reset(struct b43_wldev *dev)
3452{ 3460{
3453 struct ssb_device *sdev = dev->dev; 3461 struct ssb_device *sdev = dev->sdev;
3454 u32 tmslow; 3462 u32 tmslow;
3455 3463
3456 tmslow = ssb_read32(sdev, SSB_TMSLOW); 3464 tmslow = ssb_read32(sdev, SSB_TMSLOW);
@@ -3946,7 +3954,7 @@ redo:
3946 3954
3947 /* Disable interrupts on the device. */ 3955 /* Disable interrupts on the device. */
3948 b43_set_status(dev, B43_STAT_INITIALIZED); 3956 b43_set_status(dev, B43_STAT_INITIALIZED);
3949 if (dev->dev->bus->bustype == SSB_BUSTYPE_SDIO) { 3957 if (dev->sdev->bus->bustype == SSB_BUSTYPE_SDIO) {
3950 /* wl->mutex is locked. That is enough. */ 3958 /* wl->mutex is locked. That is enough. */
3951 b43_write32(dev, B43_MMIO_GEN_IRQ_MASK, 0); 3959 b43_write32(dev, B43_MMIO_GEN_IRQ_MASK, 0);
3952 b43_read32(dev, B43_MMIO_GEN_IRQ_MASK); /* Flush */ 3960 b43_read32(dev, B43_MMIO_GEN_IRQ_MASK); /* Flush */
@@ -3959,11 +3967,11 @@ redo:
3959 /* Synchronize and free the interrupt handlers. Unlock to avoid deadlocks. */ 3967 /* Synchronize and free the interrupt handlers. Unlock to avoid deadlocks. */
3960 orig_dev = dev; 3968 orig_dev = dev;
3961 mutex_unlock(&wl->mutex); 3969 mutex_unlock(&wl->mutex);
3962 if (dev->dev->bus->bustype == SSB_BUSTYPE_SDIO) { 3970 if (dev->sdev->bus->bustype == SSB_BUSTYPE_SDIO) {
3963 b43_sdio_free_irq(dev); 3971 b43_sdio_free_irq(dev);
3964 } else { 3972 } else {
3965 synchronize_irq(dev->dev->irq); 3973 synchronize_irq(dev->sdev->irq);
3966 free_irq(dev->dev->irq, dev); 3974 free_irq(dev->sdev->irq, dev);
3967 } 3975 }
3968 mutex_lock(&wl->mutex); 3976 mutex_lock(&wl->mutex);
3969 dev = wl->current_dev; 3977 dev = wl->current_dev;
@@ -3996,18 +4004,19 @@ static int b43_wireless_core_start(struct b43_wldev *dev)
3996 B43_WARN_ON(b43_status(dev) != B43_STAT_INITIALIZED); 4004 B43_WARN_ON(b43_status(dev) != B43_STAT_INITIALIZED);
3997 4005
3998 drain_txstatus_queue(dev); 4006 drain_txstatus_queue(dev);
3999 if (dev->dev->bus->bustype == SSB_BUSTYPE_SDIO) { 4007 if (dev->sdev->bus->bustype == SSB_BUSTYPE_SDIO) {
4000 err = b43_sdio_request_irq(dev, b43_sdio_interrupt_handler); 4008 err = b43_sdio_request_irq(dev, b43_sdio_interrupt_handler);
4001 if (err) { 4009 if (err) {
4002 b43err(dev->wl, "Cannot request SDIO IRQ\n"); 4010 b43err(dev->wl, "Cannot request SDIO IRQ\n");
4003 goto out; 4011 goto out;
4004 } 4012 }
4005 } else { 4013 } else {
4006 err = request_threaded_irq(dev->dev->irq, b43_interrupt_handler, 4014 err = request_threaded_irq(dev->sdev->irq, b43_interrupt_handler,
4007 b43_interrupt_thread_handler, 4015 b43_interrupt_thread_handler,
4008 IRQF_SHARED, KBUILD_MODNAME, dev); 4016 IRQF_SHARED, KBUILD_MODNAME, dev);
4009 if (err) { 4017 if (err) {
4010 b43err(dev->wl, "Cannot request IRQ-%d\n", dev->dev->irq); 4018 b43err(dev->wl, "Cannot request IRQ-%d\n",
4019 dev->sdev->irq);
4011 goto out; 4020 goto out;
4012 } 4021 }
4013 } 4022 }
@@ -4087,10 +4096,10 @@ static int b43_phy_versioning(struct b43_wldev *dev)
4087 analog_type, phy_type, phy_rev); 4096 analog_type, phy_type, phy_rev);
4088 4097
4089 /* Get RADIO versioning */ 4098 /* Get RADIO versioning */
4090 if (dev->dev->bus->chip_id == 0x4317) { 4099 if (dev->sdev->bus->chip_id == 0x4317) {
4091 if (dev->dev->bus->chip_rev == 0) 4100 if (dev->sdev->bus->chip_rev == 0)
4092 tmp = 0x3205017F; 4101 tmp = 0x3205017F;
4093 else if (dev->dev->bus->chip_rev == 1) 4102 else if (dev->sdev->bus->chip_rev == 1)
4094 tmp = 0x4205017F; 4103 tmp = 0x4205017F;
4095 else 4104 else
4096 tmp = 0x5205017F; 4105 tmp = 0x5205017F;
@@ -4195,7 +4204,7 @@ static void setup_struct_wldev_for_init(struct b43_wldev *dev)
4195 4204
4196static void b43_bluetooth_coext_enable(struct b43_wldev *dev) 4205static void b43_bluetooth_coext_enable(struct b43_wldev *dev)
4197{ 4206{
4198 struct ssb_sprom *sprom = &dev->dev->bus->sprom; 4207 struct ssb_sprom *sprom = &dev->sdev->bus->sprom;
4199 u64 hf; 4208 u64 hf;
4200 4209
4201 if (!modparam_btcoex) 4210 if (!modparam_btcoex)
@@ -4222,16 +4231,16 @@ static void b43_bluetooth_coext_disable(struct b43_wldev *dev)
4222 4231
4223static void b43_imcfglo_timeouts_workaround(struct b43_wldev *dev) 4232static void b43_imcfglo_timeouts_workaround(struct b43_wldev *dev)
4224{ 4233{
4225 struct ssb_bus *bus = dev->dev->bus; 4234 struct ssb_bus *bus = dev->sdev->bus;
4226 u32 tmp; 4235 u32 tmp;
4227 4236
4228 if ((bus->chip_id == 0x4311 && bus->chip_rev == 2) || 4237 if ((bus->chip_id == 0x4311 && bus->chip_rev == 2) ||
4229 (bus->chip_id == 0x4312)) { 4238 (bus->chip_id == 0x4312)) {
4230 tmp = ssb_read32(dev->dev, SSB_IMCFGLO); 4239 tmp = ssb_read32(dev->sdev, SSB_IMCFGLO);
4231 tmp &= ~SSB_IMCFGLO_REQTO; 4240 tmp &= ~SSB_IMCFGLO_REQTO;
4232 tmp &= ~SSB_IMCFGLO_SERTO; 4241 tmp &= ~SSB_IMCFGLO_SERTO;
4233 tmp |= 0x3; 4242 tmp |= 0x3;
4234 ssb_write32(dev->dev, SSB_IMCFGLO, tmp); 4243 ssb_write32(dev->sdev, SSB_IMCFGLO, tmp);
4235 ssb_commit_settings(bus); 4244 ssb_commit_settings(bus);
4236 } 4245 }
4237} 4246}
@@ -4301,14 +4310,14 @@ static void b43_wireless_core_exit(struct b43_wldev *dev)
4301 dev->wl->current_beacon = NULL; 4310 dev->wl->current_beacon = NULL;
4302 } 4311 }
4303 4312
4304 ssb_device_disable(dev->dev, 0); 4313 ssb_device_disable(dev->sdev, 0);
4305 ssb_bus_may_powerdown(dev->dev->bus); 4314 ssb_bus_may_powerdown(dev->sdev->bus);
4306} 4315}
4307 4316
4308/* Initialize a wireless core */ 4317/* Initialize a wireless core */
4309static int b43_wireless_core_init(struct b43_wldev *dev) 4318static int b43_wireless_core_init(struct b43_wldev *dev)
4310{ 4319{
4311 struct ssb_bus *bus = dev->dev->bus; 4320 struct ssb_bus *bus = dev->sdev->bus;
4312 struct ssb_sprom *sprom = &bus->sprom; 4321 struct ssb_sprom *sprom = &bus->sprom;
4313 struct b43_phy *phy = &dev->phy; 4322 struct b43_phy *phy = &dev->phy;
4314 int err; 4323 int err;
@@ -4320,7 +4329,7 @@ static int b43_wireless_core_init(struct b43_wldev *dev)
4320 err = ssb_bus_powerup(bus, 0); 4329 err = ssb_bus_powerup(bus, 0);
4321 if (err) 4330 if (err)
4322 goto out; 4331 goto out;
4323 if (!ssb_device_is_enabled(dev->dev)) { 4332 if (!ssb_device_is_enabled(dev->sdev)) {
4324 tmp = phy->gmode ? B43_TMSLOW_GMODE : 0; 4333 tmp = phy->gmode ? B43_TMSLOW_GMODE : 0;
4325 b43_wireless_core_reset(dev, tmp); 4334 b43_wireless_core_reset(dev, tmp);
4326 } 4335 }
@@ -4330,7 +4339,7 @@ static int b43_wireless_core_init(struct b43_wldev *dev)
4330 phy->ops->prepare_structs(dev); 4339 phy->ops->prepare_structs(dev);
4331 4340
4332 /* Enable IRQ routing to this device. */ 4341 /* Enable IRQ routing to this device. */
4333 ssb_pcicore_dev_irqvecs_enable(&bus->pcicore, dev->dev); 4342 ssb_pcicore_dev_irqvecs_enable(&bus->pcicore, dev->sdev);
4334 4343
4335 b43_imcfglo_timeouts_workaround(dev); 4344 b43_imcfglo_timeouts_workaround(dev);
4336 b43_bluetooth_coext_disable(dev); 4345 b43_bluetooth_coext_disable(dev);
@@ -4343,7 +4352,7 @@ static int b43_wireless_core_init(struct b43_wldev *dev)
4343 if (err) 4352 if (err)
4344 goto err_busdown; 4353 goto err_busdown;
4345 b43_shm_write16(dev, B43_SHM_SHARED, 4354 b43_shm_write16(dev, B43_SHM_SHARED,
4346 B43_SHM_SH_WLCOREREV, dev->dev->id.revision); 4355 B43_SHM_SH_WLCOREREV, dev->sdev->id.revision);
4347 hf = b43_hf_read(dev); 4356 hf = b43_hf_read(dev);
4348 if (phy->type == B43_PHYTYPE_G) { 4357 if (phy->type == B43_PHYTYPE_G) {
4349 hf |= B43_HF_SYMW; 4358 hf |= B43_HF_SYMW;
@@ -4390,8 +4399,8 @@ static int b43_wireless_core_init(struct b43_wldev *dev)
4390 /* Maximum Contention Window */ 4399 /* Maximum Contention Window */
4391 b43_shm_write16(dev, B43_SHM_SCRATCH, B43_SHM_SC_MAXCONT, 0x3FF); 4400 b43_shm_write16(dev, B43_SHM_SCRATCH, B43_SHM_SC_MAXCONT, 0x3FF);
4392 4401
4393 if ((dev->dev->bus->bustype == SSB_BUSTYPE_PCMCIA) || 4402 if ((dev->sdev->bus->bustype == SSB_BUSTYPE_PCMCIA) ||
4394 (dev->dev->bus->bustype == SSB_BUSTYPE_SDIO) || 4403 (dev->sdev->bus->bustype == SSB_BUSTYPE_SDIO) ||
4395 dev->use_pio) { 4404 dev->use_pio) {
4396 dev->__using_pio_transfers = 1; 4405 dev->__using_pio_transfers = 1;
4397 err = b43_pio_init(dev); 4406 err = b43_pio_init(dev);
@@ -4728,7 +4737,7 @@ static void b43_wireless_core_detach(struct b43_wldev *dev)
4728static int b43_wireless_core_attach(struct b43_wldev *dev) 4737static int b43_wireless_core_attach(struct b43_wldev *dev)
4729{ 4738{
4730 struct b43_wl *wl = dev->wl; 4739 struct b43_wl *wl = dev->wl;
4731 struct ssb_bus *bus = dev->dev->bus; 4740 struct ssb_bus *bus = dev->sdev->bus;
4732 struct pci_dev *pdev = (bus->bustype == SSB_BUSTYPE_PCI) ? bus->host_pci : NULL; 4741 struct pci_dev *pdev = (bus->bustype == SSB_BUSTYPE_PCI) ? bus->host_pci : NULL;
4733 int err; 4742 int err;
4734 bool have_2ghz_phy = 0, have_5ghz_phy = 0; 4743 bool have_2ghz_phy = 0, have_5ghz_phy = 0;
@@ -4747,10 +4756,10 @@ static int b43_wireless_core_attach(struct b43_wldev *dev)
4747 goto out; 4756 goto out;
4748 } 4757 }
4749 /* Get the PHY type. */ 4758 /* Get the PHY type. */
4750 if (dev->dev->id.revision >= 5) { 4759 if (dev->sdev->id.revision >= 5) {
4751 u32 tmshigh; 4760 u32 tmshigh;
4752 4761
4753 tmshigh = ssb_read32(dev->dev, SSB_TMSHIGH); 4762 tmshigh = ssb_read32(dev->sdev, SSB_TMSHIGH);
4754 have_2ghz_phy = !!(tmshigh & B43_TMSHIGH_HAVE_2GHZ_PHY); 4763 have_2ghz_phy = !!(tmshigh & B43_TMSHIGH_HAVE_2GHZ_PHY);
4755 have_5ghz_phy = !!(tmshigh & B43_TMSHIGH_HAVE_5GHZ_PHY); 4764 have_5ghz_phy = !!(tmshigh & B43_TMSHIGH_HAVE_5GHZ_PHY);
4756 } else 4765 } else
@@ -4823,7 +4832,7 @@ static int b43_wireless_core_attach(struct b43_wldev *dev)
4823 INIT_WORK(&dev->restart_work, b43_chip_reset); 4832 INIT_WORK(&dev->restart_work, b43_chip_reset);
4824 4833
4825 dev->phy.ops->switch_analog(dev, 0); 4834 dev->phy.ops->switch_analog(dev, 0);
4826 ssb_device_disable(dev->dev, 0); 4835 ssb_device_disable(dev->sdev, 0);
4827 ssb_bus_may_powerdown(bus); 4836 ssb_bus_may_powerdown(bus);
4828 4837
4829out: 4838out:
@@ -4864,7 +4873,7 @@ static int b43_one_core_attach(struct ssb_device *dev, struct b43_wl *wl)
4864 goto out; 4873 goto out;
4865 4874
4866 wldev->use_pio = b43_modparam_pio; 4875 wldev->use_pio = b43_modparam_pio;
4867 wldev->dev = dev; 4876 wldev->sdev = dev;
4868 wldev->wl = wl; 4877 wldev->wl = wl;
4869 b43_set_status(wldev, B43_STAT_UNINIT); 4878 b43_set_status(wldev, B43_STAT_UNINIT);
4870 wldev->bad_frames_preempt = modparam_bad_frames_preempt; 4879 wldev->bad_frames_preempt = modparam_bad_frames_preempt;
@@ -4925,19 +4934,16 @@ static void b43_wireless_exit(struct ssb_device *dev, struct b43_wl *wl)
4925 ieee80211_free_hw(hw); 4934 ieee80211_free_hw(hw);
4926} 4935}
4927 4936
4928static int b43_wireless_init(struct ssb_device *dev) 4937static struct b43_wl *b43_wireless_init(struct ssb_device *dev)
4929{ 4938{
4930 struct ssb_sprom *sprom = &dev->bus->sprom; 4939 struct ssb_sprom *sprom = &dev->bus->sprom;
4931 struct ieee80211_hw *hw; 4940 struct ieee80211_hw *hw;
4932 struct b43_wl *wl; 4941 struct b43_wl *wl;
4933 int err = -ENOMEM;
4934
4935 b43_sprom_fixup(dev->bus);
4936 4942
4937 hw = ieee80211_alloc_hw(sizeof(*wl), &b43_hw_ops); 4943 hw = ieee80211_alloc_hw(sizeof(*wl), &b43_hw_ops);
4938 if (!hw) { 4944 if (!hw) {
4939 b43err(NULL, "Could not allocate ieee80211 device\n"); 4945 b43err(NULL, "Could not allocate ieee80211 device\n");
4940 goto out; 4946 return ERR_PTR(-ENOMEM);
4941 } 4947 }
4942 wl = hw_to_b43_wl(hw); 4948 wl = hw_to_b43_wl(hw);
4943 4949
@@ -4971,12 +4977,9 @@ static int b43_wireless_init(struct ssb_device *dev)
4971 INIT_WORK(&wl->tx_work, b43_tx_work); 4977 INIT_WORK(&wl->tx_work, b43_tx_work);
4972 skb_queue_head_init(&wl->tx_queue); 4978 skb_queue_head_init(&wl->tx_queue);
4973 4979
4974 ssb_set_devtypedata(dev, wl);
4975 b43info(wl, "Broadcom %04X WLAN found (core revision %u)\n", 4980 b43info(wl, "Broadcom %04X WLAN found (core revision %u)\n",
4976 dev->bus->chip_id, dev->id.revision); 4981 dev->bus->chip_id, dev->id.revision);
4977 err = 0; 4982 return wl;
4978out:
4979 return err;
4980} 4983}
4981 4984
4982static int b43_ssb_probe(struct ssb_device *dev, const struct ssb_device_id *id) 4985static int b43_ssb_probe(struct ssb_device *dev, const struct ssb_device_id *id)
@@ -4989,11 +4992,14 @@ static int b43_ssb_probe(struct ssb_device *dev, const struct ssb_device_id *id)
4989 if (!wl) { 4992 if (!wl) {
4990 /* Probing the first core. Must setup common struct b43_wl */ 4993 /* Probing the first core. Must setup common struct b43_wl */
4991 first = 1; 4994 first = 1;
4992 err = b43_wireless_init(dev); 4995 b43_sprom_fixup(dev->bus);
4993 if (err) 4996 wl = b43_wireless_init(dev);
4997 if (IS_ERR(wl)) {
4998 err = PTR_ERR(wl);
4994 goto out; 4999 goto out;
4995 wl = ssb_get_devtypedata(dev); 5000 }
4996 B43_WARN_ON(!wl); 5001 ssb_set_devtypedata(dev, wl);
5002 B43_WARN_ON(ssb_get_devtypedata(dev) != wl);
4997 } 5003 }
4998 err = b43_one_core_attach(dev, wl); 5004 err = b43_one_core_attach(dev, wl);
4999 if (err) 5005 if (err)