diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/net/wireless/b43/main.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'drivers/net/wireless/b43/main.c')
-rw-r--r-- | drivers/net/wireless/b43/main.c | 364 |
1 files changed, 194 insertions, 170 deletions
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index 20631ae2ddd7..eb4159686985 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c | |||
@@ -72,6 +72,7 @@ MODULE_FIRMWARE("b43/ucode11.fw"); | |||
72 | MODULE_FIRMWARE("b43/ucode13.fw"); | 72 | MODULE_FIRMWARE("b43/ucode13.fw"); |
73 | MODULE_FIRMWARE("b43/ucode14.fw"); | 73 | MODULE_FIRMWARE("b43/ucode14.fw"); |
74 | MODULE_FIRMWARE("b43/ucode15.fw"); | 74 | MODULE_FIRMWARE("b43/ucode15.fw"); |
75 | MODULE_FIRMWARE("b43/ucode16_mimo.fw"); | ||
75 | MODULE_FIRMWARE("b43/ucode5.fw"); | 76 | MODULE_FIRMWARE("b43/ucode5.fw"); |
76 | MODULE_FIRMWARE("b43/ucode9.fw"); | 77 | MODULE_FIRMWARE("b43/ucode9.fw"); |
77 | 78 | ||
@@ -322,59 +323,83 @@ static int b43_ratelimit(struct b43_wl *wl) | |||
322 | 323 | ||
323 | void b43info(struct b43_wl *wl, const char *fmt, ...) | 324 | void b43info(struct b43_wl *wl, const char *fmt, ...) |
324 | { | 325 | { |
326 | struct va_format vaf; | ||
325 | va_list args; | 327 | va_list args; |
326 | 328 | ||
327 | if (b43_modparam_verbose < B43_VERBOSITY_INFO) | 329 | if (b43_modparam_verbose < B43_VERBOSITY_INFO) |
328 | return; | 330 | return; |
329 | if (!b43_ratelimit(wl)) | 331 | if (!b43_ratelimit(wl)) |
330 | return; | 332 | return; |
333 | |||
331 | va_start(args, fmt); | 334 | va_start(args, fmt); |
332 | printk(KERN_INFO "b43-%s: ", | 335 | |
333 | (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan"); | 336 | vaf.fmt = fmt; |
334 | vprintk(fmt, args); | 337 | vaf.va = &args; |
338 | |||
339 | printk(KERN_INFO "b43-%s: %pV", | ||
340 | (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan", &vaf); | ||
341 | |||
335 | va_end(args); | 342 | va_end(args); |
336 | } | 343 | } |
337 | 344 | ||
338 | void b43err(struct b43_wl *wl, const char *fmt, ...) | 345 | void b43err(struct b43_wl *wl, const char *fmt, ...) |
339 | { | 346 | { |
347 | struct va_format vaf; | ||
340 | va_list args; | 348 | va_list args; |
341 | 349 | ||
342 | if (b43_modparam_verbose < B43_VERBOSITY_ERROR) | 350 | if (b43_modparam_verbose < B43_VERBOSITY_ERROR) |
343 | return; | 351 | return; |
344 | if (!b43_ratelimit(wl)) | 352 | if (!b43_ratelimit(wl)) |
345 | return; | 353 | return; |
354 | |||
346 | va_start(args, fmt); | 355 | va_start(args, fmt); |
347 | printk(KERN_ERR "b43-%s ERROR: ", | 356 | |
348 | (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan"); | 357 | vaf.fmt = fmt; |
349 | vprintk(fmt, args); | 358 | vaf.va = &args; |
359 | |||
360 | printk(KERN_ERR "b43-%s ERROR: %pV", | ||
361 | (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan", &vaf); | ||
362 | |||
350 | va_end(args); | 363 | va_end(args); |
351 | } | 364 | } |
352 | 365 | ||
353 | void b43warn(struct b43_wl *wl, const char *fmt, ...) | 366 | void b43warn(struct b43_wl *wl, const char *fmt, ...) |
354 | { | 367 | { |
368 | struct va_format vaf; | ||
355 | va_list args; | 369 | va_list args; |
356 | 370 | ||
357 | if (b43_modparam_verbose < B43_VERBOSITY_WARN) | 371 | if (b43_modparam_verbose < B43_VERBOSITY_WARN) |
358 | return; | 372 | return; |
359 | if (!b43_ratelimit(wl)) | 373 | if (!b43_ratelimit(wl)) |
360 | return; | 374 | return; |
375 | |||
361 | va_start(args, fmt); | 376 | va_start(args, fmt); |
362 | printk(KERN_WARNING "b43-%s warning: ", | 377 | |
363 | (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan"); | 378 | vaf.fmt = fmt; |
364 | vprintk(fmt, args); | 379 | vaf.va = &args; |
380 | |||
381 | printk(KERN_WARNING "b43-%s warning: %pV", | ||
382 | (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan", &vaf); | ||
383 | |||
365 | va_end(args); | 384 | va_end(args); |
366 | } | 385 | } |
367 | 386 | ||
368 | void b43dbg(struct b43_wl *wl, const char *fmt, ...) | 387 | void b43dbg(struct b43_wl *wl, const char *fmt, ...) |
369 | { | 388 | { |
389 | struct va_format vaf; | ||
370 | va_list args; | 390 | va_list args; |
371 | 391 | ||
372 | if (b43_modparam_verbose < B43_VERBOSITY_DEBUG) | 392 | if (b43_modparam_verbose < B43_VERBOSITY_DEBUG) |
373 | return; | 393 | return; |
394 | |||
374 | va_start(args, fmt); | 395 | va_start(args, fmt); |
375 | printk(KERN_DEBUG "b43-%s debug: ", | 396 | |
376 | (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan"); | 397 | vaf.fmt = fmt; |
377 | vprintk(fmt, args); | 398 | vaf.va = &args; |
399 | |||
400 | printk(KERN_DEBUG "b43-%s debug: %pV", | ||
401 | (wl && wl->hw) ? wiphy_name(wl->hw->wiphy) : "wlan", &vaf); | ||
402 | |||
378 | va_end(args); | 403 | va_end(args); |
379 | } | 404 | } |
380 | 405 | ||
@@ -523,7 +548,7 @@ void b43_tsf_read(struct b43_wldev *dev, u64 *tsf) | |||
523 | { | 548 | { |
524 | u32 low, high; | 549 | u32 low, high; |
525 | 550 | ||
526 | B43_WARN_ON(dev->dev->id.revision < 3); | 551 | B43_WARN_ON(dev->sdev->id.revision < 3); |
527 | 552 | ||
528 | /* The hardware guarantees us an atomic read, if we | 553 | /* The hardware guarantees us an atomic read, if we |
529 | * read the low register first. */ | 554 | * read the low register first. */ |
@@ -561,7 +586,7 @@ static void b43_tsf_write_locked(struct b43_wldev *dev, u64 tsf) | |||
561 | { | 586 | { |
562 | u32 low, high; | 587 | u32 low, high; |
563 | 588 | ||
564 | B43_WARN_ON(dev->dev->id.revision < 3); | 589 | B43_WARN_ON(dev->sdev->id.revision < 3); |
565 | 590 | ||
566 | low = tsf; | 591 | low = tsf; |
567 | high = (tsf >> 32); | 592 | high = (tsf >> 32); |
@@ -689,7 +714,7 @@ void b43_dummy_transmission(struct b43_wldev *dev, bool ofdm, bool pa_on) | |||
689 | b43_ram_write(dev, i * 4, buffer[i]); | 714 | b43_ram_write(dev, i * 4, buffer[i]); |
690 | 715 | ||
691 | b43_write16(dev, 0x0568, 0x0000); | 716 | b43_write16(dev, 0x0568, 0x0000); |
692 | if (dev->dev->id.revision < 11) | 717 | if (dev->sdev->id.revision < 11) |
693 | b43_write16(dev, 0x07C0, 0x0000); | 718 | b43_write16(dev, 0x07C0, 0x0000); |
694 | else | 719 | else |
695 | b43_write16(dev, 0x07C0, 0x0100); | 720 | b43_write16(dev, 0x07C0, 0x0100); |
@@ -1107,7 +1132,7 @@ void b43_power_saving_ctl_bits(struct b43_wldev *dev, unsigned int ps_flags) | |||
1107 | b43_write32(dev, B43_MMIO_MACCTL, macctl); | 1132 | b43_write32(dev, B43_MMIO_MACCTL, macctl); |
1108 | /* Commit write */ | 1133 | /* Commit write */ |
1109 | b43_read32(dev, B43_MMIO_MACCTL); | 1134 | b43_read32(dev, B43_MMIO_MACCTL); |
1110 | if (awake && dev->dev->id.revision >= 5) { | 1135 | if (awake && dev->sdev->id.revision >= 5) { |
1111 | /* Wait for the microcode to wake up. */ | 1136 | /* Wait for the microcode to wake up. */ |
1112 | for (i = 0; i < 100; i++) { | 1137 | for (i = 0; i < 100; i++) { |
1113 | ucstat = b43_shm_read16(dev, B43_SHM_SHARED, | 1138 | ucstat = b43_shm_read16(dev, B43_SHM_SHARED, |
@@ -1119,27 +1144,35 @@ void b43_power_saving_ctl_bits(struct b43_wldev *dev, unsigned int ps_flags) | |||
1119 | } | 1144 | } |
1120 | } | 1145 | } |
1121 | 1146 | ||
1122 | void b43_wireless_core_reset(struct b43_wldev *dev, u32 flags) | 1147 | static void b43_ssb_wireless_core_reset(struct b43_wldev *dev, u32 flags) |
1123 | { | 1148 | { |
1124 | u32 tmslow; | 1149 | u32 tmslow; |
1125 | u32 macctl; | ||
1126 | 1150 | ||
1127 | flags |= B43_TMSLOW_PHYCLKEN; | 1151 | flags |= B43_TMSLOW_PHYCLKEN; |
1128 | flags |= B43_TMSLOW_PHYRESET; | 1152 | flags |= B43_TMSLOW_PHYRESET; |
1129 | ssb_device_enable(dev->dev, flags); | 1153 | if (dev->phy.type == B43_PHYTYPE_N) |
1154 | flags |= B43_TMSLOW_PHY_BANDWIDTH_20MHZ; /* Make 20 MHz def */ | ||
1155 | ssb_device_enable(dev->sdev, flags); | ||
1130 | msleep(2); /* Wait for the PLL to turn on. */ | 1156 | msleep(2); /* Wait for the PLL to turn on. */ |
1131 | 1157 | ||
1132 | /* Now take the PHY out of Reset again */ | 1158 | /* Now take the PHY out of Reset again */ |
1133 | tmslow = ssb_read32(dev->dev, SSB_TMSLOW); | 1159 | tmslow = ssb_read32(dev->sdev, SSB_TMSLOW); |
1134 | tmslow |= SSB_TMSLOW_FGC; | 1160 | tmslow |= SSB_TMSLOW_FGC; |
1135 | tmslow &= ~B43_TMSLOW_PHYRESET; | 1161 | tmslow &= ~B43_TMSLOW_PHYRESET; |
1136 | ssb_write32(dev->dev, SSB_TMSLOW, tmslow); | 1162 | ssb_write32(dev->sdev, SSB_TMSLOW, tmslow); |
1137 | ssb_read32(dev->dev, SSB_TMSLOW); /* flush */ | 1163 | ssb_read32(dev->sdev, SSB_TMSLOW); /* flush */ |
1138 | msleep(1); | 1164 | msleep(1); |
1139 | tmslow &= ~SSB_TMSLOW_FGC; | 1165 | tmslow &= ~SSB_TMSLOW_FGC; |
1140 | ssb_write32(dev->dev, SSB_TMSLOW, tmslow); | 1166 | ssb_write32(dev->sdev, SSB_TMSLOW, tmslow); |
1141 | ssb_read32(dev->dev, SSB_TMSLOW); /* flush */ | 1167 | ssb_read32(dev->sdev, SSB_TMSLOW); /* flush */ |
1142 | msleep(1); | 1168 | msleep(1); |
1169 | } | ||
1170 | |||
1171 | void b43_wireless_core_reset(struct b43_wldev *dev, u32 flags) | ||
1172 | { | ||
1173 | u32 macctl; | ||
1174 | |||
1175 | b43_ssb_wireless_core_reset(dev, flags); | ||
1143 | 1176 | ||
1144 | /* 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. |
1145 | * 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 |
@@ -1188,7 +1221,7 @@ static void drain_txstatus_queue(struct b43_wldev *dev) | |||
1188 | { | 1221 | { |
1189 | u32 dummy; | 1222 | u32 dummy; |
1190 | 1223 | ||
1191 | if (dev->dev->id.revision < 5) | 1224 | if (dev->sdev->id.revision < 5) |
1192 | return; | 1225 | return; |
1193 | /* Read all entries from the microcode TXstatus FIFO | 1226 | /* Read all entries from the microcode TXstatus FIFO |
1194 | * and throw them away. | 1227 | * and throw them away. |
@@ -1394,9 +1427,9 @@ u8 b43_ieee80211_antenna_sanitize(struct b43_wldev *dev, | |||
1394 | 1427 | ||
1395 | /* Get the mask of available antennas. */ | 1428 | /* Get the mask of available antennas. */ |
1396 | if (dev->phy.gmode) | 1429 | if (dev->phy.gmode) |
1397 | antenna_mask = dev->dev->bus->sprom.ant_available_bg; | 1430 | antenna_mask = dev->sdev->bus->sprom.ant_available_bg; |
1398 | else | 1431 | else |
1399 | antenna_mask = dev->dev->bus->sprom.ant_available_a; | 1432 | antenna_mask = dev->sdev->bus->sprom.ant_available_a; |
1400 | 1433 | ||
1401 | if (!(antenna_mask & (1 << (antenna_nr - 1)))) { | 1434 | if (!(antenna_mask & (1 << (antenna_nr - 1)))) { |
1402 | /* This antenna is not available. Fall back to default. */ | 1435 | /* This antenna is not available. Fall back to default. */ |
@@ -1611,7 +1644,7 @@ static void b43_beacon_update_trigger_work(struct work_struct *work) | |||
1611 | mutex_lock(&wl->mutex); | 1644 | mutex_lock(&wl->mutex); |
1612 | dev = wl->current_dev; | 1645 | dev = wl->current_dev; |
1613 | if (likely(dev && (b43_status(dev) >= B43_STAT_INITIALIZED))) { | 1646 | if (likely(dev && (b43_status(dev) >= B43_STAT_INITIALIZED))) { |
1614 | if (dev->dev->bus->bustype == SSB_BUSTYPE_SDIO) { | 1647 | if (dev->sdev->bus->bustype == SSB_BUSTYPE_SDIO) { |
1615 | /* wl->mutex is enough. */ | 1648 | /* wl->mutex is enough. */ |
1616 | b43_do_beacon_update_trigger_work(dev); | 1649 | b43_do_beacon_update_trigger_work(dev); |
1617 | mmiowb(); | 1650 | mmiowb(); |
@@ -1656,7 +1689,7 @@ static void b43_update_templates(struct b43_wl *wl) | |||
1656 | static void b43_set_beacon_int(struct b43_wldev *dev, u16 beacon_int) | 1689 | static void b43_set_beacon_int(struct b43_wldev *dev, u16 beacon_int) |
1657 | { | 1690 | { |
1658 | b43_time_lock(dev); | 1691 | b43_time_lock(dev); |
1659 | if (dev->dev->id.revision >= 3) { | 1692 | if (dev->sdev->id.revision >= 3) { |
1660 | b43_write32(dev, B43_MMIO_TSF_CFP_REP, (beacon_int << 16)); | 1693 | b43_write32(dev, B43_MMIO_TSF_CFP_REP, (beacon_int << 16)); |
1661 | b43_write32(dev, B43_MMIO_TSF_CFP_START, (beacon_int << 10)); | 1694 | b43_write32(dev, B43_MMIO_TSF_CFP_START, (beacon_int << 10)); |
1662 | } else { | 1695 | } else { |
@@ -2030,7 +2063,7 @@ int b43_do_request_fw(struct b43_request_fw_context *ctx, | |||
2030 | B43_WARN_ON(1); | 2063 | B43_WARN_ON(1); |
2031 | return -ENOSYS; | 2064 | return -ENOSYS; |
2032 | } | 2065 | } |
2033 | err = request_firmware(&blob, ctx->fwname, ctx->dev->dev->dev); | 2066 | err = request_firmware(&blob, ctx->fwname, ctx->dev->sdev->dev); |
2034 | if (err == -ENOENT) { | 2067 | if (err == -ENOENT) { |
2035 | snprintf(ctx->errors[ctx->req_type], | 2068 | snprintf(ctx->errors[ctx->req_type], |
2036 | sizeof(ctx->errors[ctx->req_type]), | 2069 | sizeof(ctx->errors[ctx->req_type]), |
@@ -2080,13 +2113,12 @@ static int b43_try_request_fw(struct b43_request_fw_context *ctx) | |||
2080 | { | 2113 | { |
2081 | struct b43_wldev *dev = ctx->dev; | 2114 | struct b43_wldev *dev = ctx->dev; |
2082 | struct b43_firmware *fw = &ctx->dev->fw; | 2115 | struct b43_firmware *fw = &ctx->dev->fw; |
2083 | const u8 rev = ctx->dev->dev->id.revision; | 2116 | const u8 rev = ctx->dev->sdev->id.revision; |
2084 | const char *filename; | 2117 | const char *filename; |
2085 | u32 tmshigh; | 2118 | u32 tmshigh; |
2086 | int err; | 2119 | int err; |
2087 | 2120 | ||
2088 | /* Get microcode */ | 2121 | /* Get microcode */ |
2089 | tmshigh = ssb_read32(dev->dev, SSB_TMSHIGH); | ||
2090 | if ((rev >= 5) && (rev <= 10)) | 2122 | if ((rev >= 5) && (rev <= 10)) |
2091 | filename = "ucode5"; | 2123 | filename = "ucode5"; |
2092 | else if ((rev >= 11) && (rev <= 12)) | 2124 | else if ((rev >= 11) && (rev <= 12)) |
@@ -2095,8 +2127,10 @@ static int b43_try_request_fw(struct b43_request_fw_context *ctx) | |||
2095 | filename = "ucode13"; | 2127 | filename = "ucode13"; |
2096 | else if (rev == 14) | 2128 | else if (rev == 14) |
2097 | filename = "ucode14"; | 2129 | filename = "ucode14"; |
2098 | else if (rev >= 15) | 2130 | else if (rev == 15) |
2099 | filename = "ucode15"; | 2131 | filename = "ucode15"; |
2132 | else if ((rev >= 16) && (rev <= 20)) | ||
2133 | filename = "ucode16_mimo"; | ||
2100 | else | 2134 | else |
2101 | goto err_no_ucode; | 2135 | goto err_no_ucode; |
2102 | err = b43_do_request_fw(ctx, filename, &fw->ucode); | 2136 | err = b43_do_request_fw(ctx, filename, &fw->ucode); |
@@ -2123,6 +2157,7 @@ static int b43_try_request_fw(struct b43_request_fw_context *ctx) | |||
2123 | switch (dev->phy.type) { | 2157 | switch (dev->phy.type) { |
2124 | case B43_PHYTYPE_A: | 2158 | case B43_PHYTYPE_A: |
2125 | if ((rev >= 5) && (rev <= 10)) { | 2159 | if ((rev >= 5) && (rev <= 10)) { |
2160 | tmshigh = ssb_read32(dev->sdev, SSB_TMSHIGH); | ||
2126 | if (tmshigh & B43_TMSHIGH_HAVE_2GHZ_PHY) | 2161 | if (tmshigh & B43_TMSHIGH_HAVE_2GHZ_PHY) |
2127 | filename = "a0g1initvals5"; | 2162 | filename = "a0g1initvals5"; |
2128 | else | 2163 | else |
@@ -2139,7 +2174,9 @@ static int b43_try_request_fw(struct b43_request_fw_context *ctx) | |||
2139 | goto err_no_initvals; | 2174 | goto err_no_initvals; |
2140 | break; | 2175 | break; |
2141 | case B43_PHYTYPE_N: | 2176 | case B43_PHYTYPE_N: |
2142 | if ((rev >= 11) && (rev <= 12)) | 2177 | if (rev >= 16) |
2178 | filename = "n0initvals16"; | ||
2179 | else if ((rev >= 11) && (rev <= 12)) | ||
2143 | filename = "n0initvals11"; | 2180 | filename = "n0initvals11"; |
2144 | else | 2181 | else |
2145 | goto err_no_initvals; | 2182 | goto err_no_initvals; |
@@ -2165,6 +2202,7 @@ static int b43_try_request_fw(struct b43_request_fw_context *ctx) | |||
2165 | switch (dev->phy.type) { | 2202 | switch (dev->phy.type) { |
2166 | case B43_PHYTYPE_A: | 2203 | case B43_PHYTYPE_A: |
2167 | if ((rev >= 5) && (rev <= 10)) { | 2204 | if ((rev >= 5) && (rev <= 10)) { |
2205 | tmshigh = ssb_read32(dev->sdev, SSB_TMSHIGH); | ||
2168 | if (tmshigh & B43_TMSHIGH_HAVE_2GHZ_PHY) | 2206 | if (tmshigh & B43_TMSHIGH_HAVE_2GHZ_PHY) |
2169 | filename = "a0g1bsinitvals5"; | 2207 | filename = "a0g1bsinitvals5"; |
2170 | else | 2208 | else |
@@ -2183,7 +2221,9 @@ static int b43_try_request_fw(struct b43_request_fw_context *ctx) | |||
2183 | goto err_no_initvals; | 2221 | goto err_no_initvals; |
2184 | break; | 2222 | break; |
2185 | case B43_PHYTYPE_N: | 2223 | case B43_PHYTYPE_N: |
2186 | if ((rev >= 11) && (rev <= 12)) | 2224 | if (rev >= 16) |
2225 | filename = "n0bsinitvals16"; | ||
2226 | else if ((rev >= 11) && (rev <= 12)) | ||
2187 | filename = "n0bsinitvals11"; | 2227 | filename = "n0bsinitvals11"; |
2188 | else | 2228 | else |
2189 | goto err_no_initvals; | 2229 | goto err_no_initvals; |
@@ -2280,6 +2320,7 @@ out: | |||
2280 | 2320 | ||
2281 | static int b43_upload_microcode(struct b43_wldev *dev) | 2321 | static int b43_upload_microcode(struct b43_wldev *dev) |
2282 | { | 2322 | { |
2323 | struct wiphy *wiphy = dev->wl->hw->wiphy; | ||
2283 | const size_t hdr_len = sizeof(struct b43_fw_header); | 2324 | const size_t hdr_len = sizeof(struct b43_fw_header); |
2284 | const __be32 *data; | 2325 | const __be32 *data; |
2285 | unsigned int i, len; | 2326 | unsigned int i, len; |
@@ -2405,6 +2446,10 @@ static int b43_upload_microcode(struct b43_wldev *dev) | |||
2405 | } | 2446 | } |
2406 | } | 2447 | } |
2407 | 2448 | ||
2449 | snprintf(wiphy->fw_version, sizeof(wiphy->fw_version), "%u.%u", | ||
2450 | dev->fw.rev, dev->fw.patch); | ||
2451 | wiphy->hw_version = dev->sdev->id.coreid; | ||
2452 | |||
2408 | if (b43_is_old_txhdr_format(dev)) { | 2453 | if (b43_is_old_txhdr_format(dev)) { |
2409 | /* 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 |
2410 | * until it turns out to be in major conflict with something new. */ | 2455 | * until it turns out to be in major conflict with something new. */ |
@@ -2519,10 +2564,20 @@ out: | |||
2519 | /* Initialize the GPIOs | 2564 | /* Initialize the GPIOs |
2520 | * http://bcm-specs.sipsolutions.net/GPIO | 2565 | * http://bcm-specs.sipsolutions.net/GPIO |
2521 | */ | 2566 | */ |
2567 | static 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 | |||
2522 | static int b43_gpio_init(struct b43_wldev *dev) | 2578 | static int b43_gpio_init(struct b43_wldev *dev) |
2523 | { | 2579 | { |
2524 | struct ssb_bus *bus = dev->dev->bus; | 2580 | struct ssb_device *gpiodev; |
2525 | struct ssb_device *gpiodev, *pcidev = NULL; | ||
2526 | u32 mask, set; | 2581 | u32 mask, set; |
2527 | 2582 | ||
2528 | 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) |
@@ -2533,7 +2588,7 @@ static int b43_gpio_init(struct b43_wldev *dev) | |||
2533 | 2588 | ||
2534 | mask = 0x0000001F; | 2589 | mask = 0x0000001F; |
2535 | set = 0x0000000F; | 2590 | set = 0x0000000F; |
2536 | if (dev->dev->bus->chip_id == 0x4301) { | 2591 | if (dev->sdev->bus->chip_id == 0x4301) { |
2537 | mask |= 0x0060; | 2592 | mask |= 0x0060; |
2538 | set |= 0x0060; | 2593 | set |= 0x0060; |
2539 | } | 2594 | } |
@@ -2544,25 +2599,21 @@ static int b43_gpio_init(struct b43_wldev *dev) | |||
2544 | mask |= 0x0180; | 2599 | mask |= 0x0180; |
2545 | set |= 0x0180; | 2600 | set |= 0x0180; |
2546 | } | 2601 | } |
2547 | if (dev->dev->bus->sprom.boardflags_lo & B43_BFL_PACTRL) { | 2602 | if (dev->sdev->bus->sprom.boardflags_lo & B43_BFL_PACTRL) { |
2548 | b43_write16(dev, B43_MMIO_GPIO_MASK, | 2603 | b43_write16(dev, B43_MMIO_GPIO_MASK, |
2549 | b43_read16(dev, B43_MMIO_GPIO_MASK) | 2604 | b43_read16(dev, B43_MMIO_GPIO_MASK) |
2550 | | 0x0200); | 2605 | | 0x0200); |
2551 | mask |= 0x0200; | 2606 | mask |= 0x0200; |
2552 | set |= 0x0200; | 2607 | set |= 0x0200; |
2553 | } | 2608 | } |
2554 | if (dev->dev->id.revision >= 2) | 2609 | if (dev->sdev->id.revision >= 2) |
2555 | mask |= 0x0010; /* FIXME: This is redundant. */ | 2610 | mask |= 0x0010; /* FIXME: This is redundant. */ |
2556 | 2611 | ||
2557 | #ifdef CONFIG_SSB_DRIVER_PCICORE | 2612 | gpiodev = b43_ssb_gpio_dev(dev); |
2558 | pcidev = bus->pcicore.dev; | 2613 | if (gpiodev) |
2559 | #endif | 2614 | ssb_write32(gpiodev, B43_GPIO_CONTROL, |
2560 | gpiodev = bus->chipco.dev ? : pcidev; | 2615 | (ssb_read32(gpiodev, B43_GPIO_CONTROL) |
2561 | if (!gpiodev) | 2616 | & mask) | set); |
2562 | return 0; | ||
2563 | ssb_write32(gpiodev, B43_GPIO_CONTROL, | ||
2564 | (ssb_read32(gpiodev, B43_GPIO_CONTROL) | ||
2565 | & mask) | set); | ||
2566 | 2617 | ||
2567 | return 0; | 2618 | return 0; |
2568 | } | 2619 | } |
@@ -2570,16 +2621,11 @@ static int b43_gpio_init(struct b43_wldev *dev) | |||
2570 | /* 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. */ |
2571 | static void b43_gpio_cleanup(struct b43_wldev *dev) | 2622 | static void b43_gpio_cleanup(struct b43_wldev *dev) |
2572 | { | 2623 | { |
2573 | struct ssb_bus *bus = dev->dev->bus; | 2624 | struct ssb_device *gpiodev; |
2574 | struct ssb_device *gpiodev, *pcidev = NULL; | ||
2575 | 2625 | ||
2576 | #ifdef CONFIG_SSB_DRIVER_PCICORE | 2626 | gpiodev = b43_ssb_gpio_dev(dev); |
2577 | pcidev = bus->pcicore.dev; | 2627 | if (gpiodev) |
2578 | #endif | 2628 | ssb_write32(gpiodev, B43_GPIO_CONTROL, 0); |
2579 | gpiodev = bus->chipco.dev ? : pcidev; | ||
2580 | if (!gpiodev) | ||
2581 | return; | ||
2582 | ssb_write32(gpiodev, B43_GPIO_CONTROL, 0); | ||
2583 | } | 2629 | } |
2584 | 2630 | ||
2585 | /* http://bcm-specs.sipsolutions.net/EnableMac */ | 2631 | /* http://bcm-specs.sipsolutions.net/EnableMac */ |
@@ -2648,6 +2694,17 @@ out: | |||
2648 | dev->mac_suspended++; | 2694 | dev->mac_suspended++; |
2649 | } | 2695 | } |
2650 | 2696 | ||
2697 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/MacPhyClkSet */ | ||
2698 | void b43_mac_phy_clock_set(struct b43_wldev *dev, bool on) | ||
2699 | { | ||
2700 | u32 tmslow = ssb_read32(dev->sdev, SSB_TMSLOW); | ||
2701 | if (on) | ||
2702 | tmslow |= B43_TMSLOW_MACPHYCLKEN; | ||
2703 | else | ||
2704 | tmslow &= ~B43_TMSLOW_MACPHYCLKEN; | ||
2705 | ssb_write32(dev->sdev, SSB_TMSLOW, tmslow); | ||
2706 | } | ||
2707 | |||
2651 | static void b43_adjust_opmode(struct b43_wldev *dev) | 2708 | static void b43_adjust_opmode(struct b43_wldev *dev) |
2652 | { | 2709 | { |
2653 | struct b43_wl *wl = dev->wl; | 2710 | struct b43_wl *wl = dev->wl; |
@@ -2684,15 +2741,15 @@ static void b43_adjust_opmode(struct b43_wldev *dev) | |||
2684 | /* Workaround: On old hardware the HW-MAC-address-filter | 2741 | /* Workaround: On old hardware the HW-MAC-address-filter |
2685 | * doesn't work properly, so always run promisc in filter | 2742 | * doesn't work properly, so always run promisc in filter |
2686 | * it in software. */ | 2743 | * it in software. */ |
2687 | if (dev->dev->id.revision <= 4) | 2744 | if (dev->sdev->id.revision <= 4) |
2688 | ctl |= B43_MACCTL_PROMISC; | 2745 | ctl |= B43_MACCTL_PROMISC; |
2689 | 2746 | ||
2690 | b43_write32(dev, B43_MMIO_MACCTL, ctl); | 2747 | b43_write32(dev, B43_MMIO_MACCTL, ctl); |
2691 | 2748 | ||
2692 | cfp_pretbtt = 2; | 2749 | cfp_pretbtt = 2; |
2693 | if ((ctl & B43_MACCTL_INFRA) && !(ctl & B43_MACCTL_AP)) { | 2750 | if ((ctl & B43_MACCTL_INFRA) && !(ctl & B43_MACCTL_AP)) { |
2694 | if (dev->dev->bus->chip_id == 0x4306 && | 2751 | if (dev->sdev->bus->chip_id == 0x4306 && |
2695 | dev->dev->bus->chip_rev == 3) | 2752 | dev->sdev->bus->chip_rev == 3) |
2696 | cfp_pretbtt = 100; | 2753 | cfp_pretbtt = 100; |
2697 | else | 2754 | else |
2698 | cfp_pretbtt = 50; | 2755 | cfp_pretbtt = 50; |
@@ -2804,7 +2861,7 @@ static int b43_chip_init(struct b43_wldev *dev) | |||
2804 | { | 2861 | { |
2805 | struct b43_phy *phy = &dev->phy; | 2862 | struct b43_phy *phy = &dev->phy; |
2806 | int err; | 2863 | int err; |
2807 | u32 value32, macctl; | 2864 | u32 macctl; |
2808 | u16 value16; | 2865 | u16 value16; |
2809 | 2866 | ||
2810 | /* Initialize the MAC control */ | 2867 | /* Initialize the MAC control */ |
@@ -2850,7 +2907,7 @@ static int b43_chip_init(struct b43_wldev *dev) | |||
2850 | b43_write16(dev, 0x005E, value16); | 2907 | b43_write16(dev, 0x005E, value16); |
2851 | } | 2908 | } |
2852 | b43_write32(dev, 0x0100, 0x01000000); | 2909 | b43_write32(dev, 0x0100, 0x01000000); |
2853 | if (dev->dev->id.revision < 5) | 2910 | if (dev->sdev->id.revision < 5) |
2854 | b43_write32(dev, 0x010C, 0x01000000); | 2911 | b43_write32(dev, 0x010C, 0x01000000); |
2855 | 2912 | ||
2856 | 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) |
@@ -2865,7 +2922,7 @@ static int b43_chip_init(struct b43_wldev *dev) | |||
2865 | /* Initially set the wireless operation mode. */ | 2922 | /* Initially set the wireless operation mode. */ |
2866 | b43_adjust_opmode(dev); | 2923 | b43_adjust_opmode(dev); |
2867 | 2924 | ||
2868 | if (dev->dev->id.revision < 3) { | 2925 | if (dev->sdev->id.revision < 3) { |
2869 | b43_write16(dev, 0x060E, 0x0000); | 2926 | b43_write16(dev, 0x060E, 0x0000); |
2870 | b43_write16(dev, 0x0610, 0x8000); | 2927 | b43_write16(dev, 0x0610, 0x8000); |
2871 | b43_write16(dev, 0x0604, 0x0000); | 2928 | b43_write16(dev, 0x0604, 0x0000); |
@@ -2882,12 +2939,10 @@ static int b43_chip_init(struct b43_wldev *dev) | |||
2882 | b43_write32(dev, B43_MMIO_DMA4_IRQ_MASK, 0x0000DC00); | 2939 | b43_write32(dev, B43_MMIO_DMA4_IRQ_MASK, 0x0000DC00); |
2883 | b43_write32(dev, B43_MMIO_DMA5_IRQ_MASK, 0x0000DC00); | 2940 | b43_write32(dev, B43_MMIO_DMA5_IRQ_MASK, 0x0000DC00); |
2884 | 2941 | ||
2885 | value32 = ssb_read32(dev->dev, SSB_TMSLOW); | 2942 | b43_mac_phy_clock_set(dev, true); |
2886 | value32 |= 0x00100000; | ||
2887 | ssb_write32(dev->dev, SSB_TMSLOW, value32); | ||
2888 | 2943 | ||
2889 | b43_write16(dev, B43_MMIO_POWERUP_DELAY, | 2944 | b43_write16(dev, B43_MMIO_POWERUP_DELAY, |
2890 | dev->dev->bus->chipco.fast_pwrup_delay); | 2945 | dev->sdev->bus->chipco.fast_pwrup_delay); |
2891 | 2946 | ||
2892 | err = 0; | 2947 | err = 0; |
2893 | b43dbg(dev->wl, "Chip initialized\n"); | 2948 | b43dbg(dev->wl, "Chip initialized\n"); |
@@ -3050,7 +3105,7 @@ static int b43_validate_chipaccess(struct b43_wldev *dev) | |||
3050 | b43_shm_write32(dev, B43_SHM_SHARED, 0, backup0); | 3105 | b43_shm_write32(dev, B43_SHM_SHARED, 0, backup0); |
3051 | b43_shm_write32(dev, B43_SHM_SHARED, 4, backup4); | 3106 | b43_shm_write32(dev, B43_SHM_SHARED, 4, backup4); |
3052 | 3107 | ||
3053 | if ((dev->dev->id.revision >= 3) && (dev->dev->id.revision <= 10)) { | 3108 | if ((dev->sdev->id.revision >= 3) && (dev->sdev->id.revision <= 10)) { |
3054 | /* The 32bit register shadows the two 16bit registers | 3109 | /* The 32bit register shadows the two 16bit registers |
3055 | * with update sideeffects. Validate this. */ | 3110 | * with update sideeffects. Validate this. */ |
3056 | b43_write16(dev, B43_MMIO_TSF_CFP_START, 0xAAAA); | 3111 | b43_write16(dev, B43_MMIO_TSF_CFP_START, 0xAAAA); |
@@ -3166,7 +3221,7 @@ static void b43_tx_work(struct work_struct *work) | |||
3166 | mutex_unlock(&wl->mutex); | 3221 | mutex_unlock(&wl->mutex); |
3167 | } | 3222 | } |
3168 | 3223 | ||
3169 | static int b43_op_tx(struct ieee80211_hw *hw, | 3224 | static void b43_op_tx(struct ieee80211_hw *hw, |
3170 | struct sk_buff *skb) | 3225 | struct sk_buff *skb) |
3171 | { | 3226 | { |
3172 | struct b43_wl *wl = hw_to_b43_wl(hw); | 3227 | struct b43_wl *wl = hw_to_b43_wl(hw); |
@@ -3174,14 +3229,12 @@ static int b43_op_tx(struct ieee80211_hw *hw, | |||
3174 | if (unlikely(skb->len < 2 + 2 + 6)) { | 3229 | if (unlikely(skb->len < 2 + 2 + 6)) { |
3175 | /* Too short, this can't be a valid frame. */ | 3230 | /* Too short, this can't be a valid frame. */ |
3176 | dev_kfree_skb_any(skb); | 3231 | dev_kfree_skb_any(skb); |
3177 | return NETDEV_TX_OK; | 3232 | return; |
3178 | } | 3233 | } |
3179 | B43_WARN_ON(skb_shinfo(skb)->nr_frags); | 3234 | B43_WARN_ON(skb_shinfo(skb)->nr_frags); |
3180 | 3235 | ||
3181 | skb_queue_tail(&wl->tx_queue, skb); | 3236 | skb_queue_tail(&wl->tx_queue, skb); |
3182 | ieee80211_queue_work(wl->hw, &wl->tx_work); | 3237 | ieee80211_queue_work(wl->hw, &wl->tx_work); |
3183 | |||
3184 | return NETDEV_TX_OK; | ||
3185 | } | 3238 | } |
3186 | 3239 | ||
3187 | static void b43_qos_params_upload(struct b43_wldev *dev, | 3240 | static void b43_qos_params_upload(struct b43_wldev *dev, |
@@ -3405,7 +3458,7 @@ static void b43_op_set_tsf(struct ieee80211_hw *hw, u64 tsf) | |||
3405 | 3458 | ||
3406 | static void b43_put_phy_into_reset(struct b43_wldev *dev) | 3459 | static void b43_put_phy_into_reset(struct b43_wldev *dev) |
3407 | { | 3460 | { |
3408 | struct ssb_device *sdev = dev->dev; | 3461 | struct ssb_device *sdev = dev->sdev; |
3409 | u32 tmslow; | 3462 | u32 tmslow; |
3410 | 3463 | ||
3411 | tmslow = ssb_read32(sdev, SSB_TMSLOW); | 3464 | tmslow = ssb_read32(sdev, SSB_TMSLOW); |
@@ -3754,17 +3807,17 @@ static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
3754 | } | 3807 | } |
3755 | 3808 | ||
3756 | err = -EINVAL; | 3809 | err = -EINVAL; |
3757 | switch (key->alg) { | 3810 | switch (key->cipher) { |
3758 | case ALG_WEP: | 3811 | case WLAN_CIPHER_SUITE_WEP40: |
3759 | if (key->keylen == WLAN_KEY_LEN_WEP40) | 3812 | algorithm = B43_SEC_ALGO_WEP40; |
3760 | algorithm = B43_SEC_ALGO_WEP40; | 3813 | break; |
3761 | else | 3814 | case WLAN_CIPHER_SUITE_WEP104: |
3762 | algorithm = B43_SEC_ALGO_WEP104; | 3815 | algorithm = B43_SEC_ALGO_WEP104; |
3763 | break; | 3816 | break; |
3764 | case ALG_TKIP: | 3817 | case WLAN_CIPHER_SUITE_TKIP: |
3765 | algorithm = B43_SEC_ALGO_TKIP; | 3818 | algorithm = B43_SEC_ALGO_TKIP; |
3766 | break; | 3819 | break; |
3767 | case ALG_CCMP: | 3820 | case WLAN_CIPHER_SUITE_CCMP: |
3768 | algorithm = B43_SEC_ALGO_AES; | 3821 | algorithm = B43_SEC_ALGO_AES; |
3769 | break; | 3822 | break; |
3770 | default: | 3823 | default: |
@@ -3901,7 +3954,7 @@ redo: | |||
3901 | 3954 | ||
3902 | /* Disable interrupts on the device. */ | 3955 | /* Disable interrupts on the device. */ |
3903 | b43_set_status(dev, B43_STAT_INITIALIZED); | 3956 | b43_set_status(dev, B43_STAT_INITIALIZED); |
3904 | if (dev->dev->bus->bustype == SSB_BUSTYPE_SDIO) { | 3957 | if (dev->sdev->bus->bustype == SSB_BUSTYPE_SDIO) { |
3905 | /* wl->mutex is locked. That is enough. */ | 3958 | /* wl->mutex is locked. That is enough. */ |
3906 | b43_write32(dev, B43_MMIO_GEN_IRQ_MASK, 0); | 3959 | b43_write32(dev, B43_MMIO_GEN_IRQ_MASK, 0); |
3907 | b43_read32(dev, B43_MMIO_GEN_IRQ_MASK); /* Flush */ | 3960 | b43_read32(dev, B43_MMIO_GEN_IRQ_MASK); /* Flush */ |
@@ -3914,11 +3967,11 @@ redo: | |||
3914 | /* Synchronize and free the interrupt handlers. Unlock to avoid deadlocks. */ | 3967 | /* Synchronize and free the interrupt handlers. Unlock to avoid deadlocks. */ |
3915 | orig_dev = dev; | 3968 | orig_dev = dev; |
3916 | mutex_unlock(&wl->mutex); | 3969 | mutex_unlock(&wl->mutex); |
3917 | if (dev->dev->bus->bustype == SSB_BUSTYPE_SDIO) { | 3970 | if (dev->sdev->bus->bustype == SSB_BUSTYPE_SDIO) { |
3918 | b43_sdio_free_irq(dev); | 3971 | b43_sdio_free_irq(dev); |
3919 | } else { | 3972 | } else { |
3920 | synchronize_irq(dev->dev->irq); | 3973 | synchronize_irq(dev->sdev->irq); |
3921 | free_irq(dev->dev->irq, dev); | 3974 | free_irq(dev->sdev->irq, dev); |
3922 | } | 3975 | } |
3923 | mutex_lock(&wl->mutex); | 3976 | mutex_lock(&wl->mutex); |
3924 | dev = wl->current_dev; | 3977 | dev = wl->current_dev; |
@@ -3951,18 +4004,19 @@ static int b43_wireless_core_start(struct b43_wldev *dev) | |||
3951 | B43_WARN_ON(b43_status(dev) != B43_STAT_INITIALIZED); | 4004 | B43_WARN_ON(b43_status(dev) != B43_STAT_INITIALIZED); |
3952 | 4005 | ||
3953 | drain_txstatus_queue(dev); | 4006 | drain_txstatus_queue(dev); |
3954 | if (dev->dev->bus->bustype == SSB_BUSTYPE_SDIO) { | 4007 | if (dev->sdev->bus->bustype == SSB_BUSTYPE_SDIO) { |
3955 | err = b43_sdio_request_irq(dev, b43_sdio_interrupt_handler); | 4008 | err = b43_sdio_request_irq(dev, b43_sdio_interrupt_handler); |
3956 | if (err) { | 4009 | if (err) { |
3957 | b43err(dev->wl, "Cannot request SDIO IRQ\n"); | 4010 | b43err(dev->wl, "Cannot request SDIO IRQ\n"); |
3958 | goto out; | 4011 | goto out; |
3959 | } | 4012 | } |
3960 | } else { | 4013 | } else { |
3961 | err = request_threaded_irq(dev->dev->irq, b43_interrupt_handler, | 4014 | err = request_threaded_irq(dev->sdev->irq, b43_interrupt_handler, |
3962 | b43_interrupt_thread_handler, | 4015 | b43_interrupt_thread_handler, |
3963 | IRQF_SHARED, KBUILD_MODNAME, dev); | 4016 | IRQF_SHARED, KBUILD_MODNAME, dev); |
3964 | if (err) { | 4017 | if (err) { |
3965 | b43err(dev->wl, "Cannot request IRQ-%d\n", dev->dev->irq); | 4018 | b43err(dev->wl, "Cannot request IRQ-%d\n", |
4019 | dev->sdev->irq); | ||
3966 | goto out; | 4020 | goto out; |
3967 | } | 4021 | } |
3968 | } | 4022 | } |
@@ -3975,7 +4029,7 @@ static int b43_wireless_core_start(struct b43_wldev *dev) | |||
3975 | b43_mac_enable(dev); | 4029 | b43_mac_enable(dev); |
3976 | b43_write32(dev, B43_MMIO_GEN_IRQ_MASK, dev->irq_mask); | 4030 | b43_write32(dev, B43_MMIO_GEN_IRQ_MASK, dev->irq_mask); |
3977 | 4031 | ||
3978 | /* Start maintainance work */ | 4032 | /* Start maintenance work */ |
3979 | b43_periodic_tasks_setup(dev); | 4033 | b43_periodic_tasks_setup(dev); |
3980 | 4034 | ||
3981 | b43_leds_init(dev); | 4035 | b43_leds_init(dev); |
@@ -4017,9 +4071,9 @@ static int b43_phy_versioning(struct b43_wldev *dev) | |||
4017 | if (phy_rev > 9) | 4071 | if (phy_rev > 9) |
4018 | unsupported = 1; | 4072 | unsupported = 1; |
4019 | break; | 4073 | break; |
4020 | #ifdef CONFIG_B43_NPHY | 4074 | #ifdef CONFIG_B43_PHY_N |
4021 | case B43_PHYTYPE_N: | 4075 | case B43_PHYTYPE_N: |
4022 | if (phy_rev > 4) | 4076 | if (phy_rev > 9) |
4023 | unsupported = 1; | 4077 | unsupported = 1; |
4024 | break; | 4078 | break; |
4025 | #endif | 4079 | #endif |
@@ -4042,10 +4096,10 @@ static int b43_phy_versioning(struct b43_wldev *dev) | |||
4042 | analog_type, phy_type, phy_rev); | 4096 | analog_type, phy_type, phy_rev); |
4043 | 4097 | ||
4044 | /* Get RADIO versioning */ | 4098 | /* Get RADIO versioning */ |
4045 | if (dev->dev->bus->chip_id == 0x4317) { | 4099 | if (dev->sdev->bus->chip_id == 0x4317) { |
4046 | if (dev->dev->bus->chip_rev == 0) | 4100 | if (dev->sdev->bus->chip_rev == 0) |
4047 | tmp = 0x3205017F; | 4101 | tmp = 0x3205017F; |
4048 | else if (dev->dev->bus->chip_rev == 1) | 4102 | else if (dev->sdev->bus->chip_rev == 1) |
4049 | tmp = 0x4205017F; | 4103 | tmp = 0x4205017F; |
4050 | else | 4104 | else |
4051 | tmp = 0x5205017F; | 4105 | tmp = 0x5205017F; |
@@ -4150,7 +4204,7 @@ static void setup_struct_wldev_for_init(struct b43_wldev *dev) | |||
4150 | 4204 | ||
4151 | static void b43_bluetooth_coext_enable(struct b43_wldev *dev) | 4205 | static void b43_bluetooth_coext_enable(struct b43_wldev *dev) |
4152 | { | 4206 | { |
4153 | struct ssb_sprom *sprom = &dev->dev->bus->sprom; | 4207 | struct ssb_sprom *sprom = &dev->sdev->bus->sprom; |
4154 | u64 hf; | 4208 | u64 hf; |
4155 | 4209 | ||
4156 | if (!modparam_btcoex) | 4210 | if (!modparam_btcoex) |
@@ -4177,33 +4231,18 @@ static void b43_bluetooth_coext_disable(struct b43_wldev *dev) | |||
4177 | 4231 | ||
4178 | static void b43_imcfglo_timeouts_workaround(struct b43_wldev *dev) | 4232 | static void b43_imcfglo_timeouts_workaround(struct b43_wldev *dev) |
4179 | { | 4233 | { |
4180 | #ifdef CONFIG_SSB_DRIVER_PCICORE | 4234 | struct ssb_bus *bus = dev->sdev->bus; |
4181 | struct ssb_bus *bus = dev->dev->bus; | ||
4182 | u32 tmp; | 4235 | u32 tmp; |
4183 | 4236 | ||
4184 | if (bus->pcicore.dev && | 4237 | if ((bus->chip_id == 0x4311 && bus->chip_rev == 2) || |
4185 | bus->pcicore.dev->id.coreid == SSB_DEV_PCI && | 4238 | (bus->chip_id == 0x4312)) { |
4186 | bus->pcicore.dev->id.revision <= 5) { | 4239 | tmp = ssb_read32(dev->sdev, SSB_IMCFGLO); |
4187 | /* IMCFGLO timeouts workaround. */ | 4240 | tmp &= ~SSB_IMCFGLO_REQTO; |
4188 | tmp = ssb_read32(dev->dev, SSB_IMCFGLO); | 4241 | tmp &= ~SSB_IMCFGLO_SERTO; |
4189 | switch (bus->bustype) { | 4242 | tmp |= 0x3; |
4190 | case SSB_BUSTYPE_PCI: | 4243 | ssb_write32(dev->sdev, SSB_IMCFGLO, tmp); |
4191 | case SSB_BUSTYPE_PCMCIA: | 4244 | ssb_commit_settings(bus); |
4192 | tmp &= ~SSB_IMCFGLO_REQTO; | ||
4193 | tmp &= ~SSB_IMCFGLO_SERTO; | ||
4194 | tmp |= 0x32; | ||
4195 | break; | ||
4196 | case SSB_BUSTYPE_SSB: | ||
4197 | tmp &= ~SSB_IMCFGLO_REQTO; | ||
4198 | tmp &= ~SSB_IMCFGLO_SERTO; | ||
4199 | tmp |= 0x53; | ||
4200 | break; | ||
4201 | default: | ||
4202 | break; | ||
4203 | } | ||
4204 | ssb_write32(dev->dev, SSB_IMCFGLO, tmp); | ||
4205 | } | 4245 | } |
4206 | #endif /* CONFIG_SSB_DRIVER_PCICORE */ | ||
4207 | } | 4246 | } |
4208 | 4247 | ||
4209 | static void b43_set_synth_pu_delay(struct b43_wldev *dev, bool idle) | 4248 | static void b43_set_synth_pu_delay(struct b43_wldev *dev, bool idle) |
@@ -4250,6 +4289,10 @@ static void b43_wireless_core_exit(struct b43_wldev *dev) | |||
4250 | B43_WARN_ON(dev && b43_status(dev) > B43_STAT_INITIALIZED); | 4289 | B43_WARN_ON(dev && b43_status(dev) > B43_STAT_INITIALIZED); |
4251 | if (!dev || b43_status(dev) != B43_STAT_INITIALIZED) | 4290 | if (!dev || b43_status(dev) != B43_STAT_INITIALIZED) |
4252 | return; | 4291 | return; |
4292 | |||
4293 | /* Unregister HW RNG driver */ | ||
4294 | b43_rng_exit(dev->wl); | ||
4295 | |||
4253 | b43_set_status(dev, B43_STAT_UNINIT); | 4296 | b43_set_status(dev, B43_STAT_UNINIT); |
4254 | 4297 | ||
4255 | /* Stop the microcode PSM. */ | 4298 | /* Stop the microcode PSM. */ |
@@ -4267,14 +4310,14 @@ static void b43_wireless_core_exit(struct b43_wldev *dev) | |||
4267 | dev->wl->current_beacon = NULL; | 4310 | dev->wl->current_beacon = NULL; |
4268 | } | 4311 | } |
4269 | 4312 | ||
4270 | ssb_device_disable(dev->dev, 0); | 4313 | ssb_device_disable(dev->sdev, 0); |
4271 | ssb_bus_may_powerdown(dev->dev->bus); | 4314 | ssb_bus_may_powerdown(dev->sdev->bus); |
4272 | } | 4315 | } |
4273 | 4316 | ||
4274 | /* Initialize a wireless core */ | 4317 | /* Initialize a wireless core */ |
4275 | static int b43_wireless_core_init(struct b43_wldev *dev) | 4318 | static int b43_wireless_core_init(struct b43_wldev *dev) |
4276 | { | 4319 | { |
4277 | struct ssb_bus *bus = dev->dev->bus; | 4320 | struct ssb_bus *bus = dev->sdev->bus; |
4278 | struct ssb_sprom *sprom = &bus->sprom; | 4321 | struct ssb_sprom *sprom = &bus->sprom; |
4279 | struct b43_phy *phy = &dev->phy; | 4322 | struct b43_phy *phy = &dev->phy; |
4280 | int err; | 4323 | int err; |
@@ -4286,7 +4329,7 @@ static int b43_wireless_core_init(struct b43_wldev *dev) | |||
4286 | err = ssb_bus_powerup(bus, 0); | 4329 | err = ssb_bus_powerup(bus, 0); |
4287 | if (err) | 4330 | if (err) |
4288 | goto out; | 4331 | goto out; |
4289 | if (!ssb_device_is_enabled(dev->dev)) { | 4332 | if (!ssb_device_is_enabled(dev->sdev)) { |
4290 | tmp = phy->gmode ? B43_TMSLOW_GMODE : 0; | 4333 | tmp = phy->gmode ? B43_TMSLOW_GMODE : 0; |
4291 | b43_wireless_core_reset(dev, tmp); | 4334 | b43_wireless_core_reset(dev, tmp); |
4292 | } | 4335 | } |
@@ -4296,7 +4339,7 @@ static int b43_wireless_core_init(struct b43_wldev *dev) | |||
4296 | phy->ops->prepare_structs(dev); | 4339 | phy->ops->prepare_structs(dev); |
4297 | 4340 | ||
4298 | /* Enable IRQ routing to this device. */ | 4341 | /* Enable IRQ routing to this device. */ |
4299 | ssb_pcicore_dev_irqvecs_enable(&bus->pcicore, dev->dev); | 4342 | ssb_pcicore_dev_irqvecs_enable(&bus->pcicore, dev->sdev); |
4300 | 4343 | ||
4301 | b43_imcfglo_timeouts_workaround(dev); | 4344 | b43_imcfglo_timeouts_workaround(dev); |
4302 | b43_bluetooth_coext_disable(dev); | 4345 | b43_bluetooth_coext_disable(dev); |
@@ -4309,7 +4352,7 @@ static int b43_wireless_core_init(struct b43_wldev *dev) | |||
4309 | if (err) | 4352 | if (err) |
4310 | goto err_busdown; | 4353 | goto err_busdown; |
4311 | b43_shm_write16(dev, B43_SHM_SHARED, | 4354 | b43_shm_write16(dev, B43_SHM_SHARED, |
4312 | B43_SHM_SH_WLCOREREV, dev->dev->id.revision); | 4355 | B43_SHM_SH_WLCOREREV, dev->sdev->id.revision); |
4313 | hf = b43_hf_read(dev); | 4356 | hf = b43_hf_read(dev); |
4314 | if (phy->type == B43_PHYTYPE_G) { | 4357 | if (phy->type == B43_PHYTYPE_G) { |
4315 | hf |= B43_HF_SYMW; | 4358 | hf |= B43_HF_SYMW; |
@@ -4356,8 +4399,8 @@ static int b43_wireless_core_init(struct b43_wldev *dev) | |||
4356 | /* Maximum Contention Window */ | 4399 | /* Maximum Contention Window */ |
4357 | 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); |
4358 | 4401 | ||
4359 | if ((dev->dev->bus->bustype == SSB_BUSTYPE_PCMCIA) || | 4402 | if ((dev->sdev->bus->bustype == SSB_BUSTYPE_PCMCIA) || |
4360 | (dev->dev->bus->bustype == SSB_BUSTYPE_SDIO) || | 4403 | (dev->sdev->bus->bustype == SSB_BUSTYPE_SDIO) || |
4361 | dev->use_pio) { | 4404 | dev->use_pio) { |
4362 | dev->__using_pio_transfers = 1; | 4405 | dev->__using_pio_transfers = 1; |
4363 | err = b43_pio_init(dev); | 4406 | err = b43_pio_init(dev); |
@@ -4379,6 +4422,9 @@ static int b43_wireless_core_init(struct b43_wldev *dev) | |||
4379 | 4422 | ||
4380 | b43_set_status(dev, B43_STAT_INITIALIZED); | 4423 | b43_set_status(dev, B43_STAT_INITIALIZED); |
4381 | 4424 | ||
4425 | /* Register HW RNG driver */ | ||
4426 | b43_rng_init(dev->wl); | ||
4427 | |||
4382 | out: | 4428 | out: |
4383 | return err; | 4429 | return err; |
4384 | 4430 | ||
@@ -4691,7 +4737,7 @@ static void b43_wireless_core_detach(struct b43_wldev *dev) | |||
4691 | static int b43_wireless_core_attach(struct b43_wldev *dev) | 4737 | static int b43_wireless_core_attach(struct b43_wldev *dev) |
4692 | { | 4738 | { |
4693 | struct b43_wl *wl = dev->wl; | 4739 | struct b43_wl *wl = dev->wl; |
4694 | struct ssb_bus *bus = dev->dev->bus; | 4740 | struct ssb_bus *bus = dev->sdev->bus; |
4695 | 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; |
4696 | int err; | 4742 | int err; |
4697 | bool have_2ghz_phy = 0, have_5ghz_phy = 0; | 4743 | bool have_2ghz_phy = 0, have_5ghz_phy = 0; |
@@ -4710,10 +4756,10 @@ static int b43_wireless_core_attach(struct b43_wldev *dev) | |||
4710 | goto out; | 4756 | goto out; |
4711 | } | 4757 | } |
4712 | /* Get the PHY type. */ | 4758 | /* Get the PHY type. */ |
4713 | if (dev->dev->id.revision >= 5) { | 4759 | if (dev->sdev->id.revision >= 5) { |
4714 | u32 tmshigh; | 4760 | u32 tmshigh; |
4715 | 4761 | ||
4716 | tmshigh = ssb_read32(dev->dev, SSB_TMSHIGH); | 4762 | tmshigh = ssb_read32(dev->sdev, SSB_TMSHIGH); |
4717 | have_2ghz_phy = !!(tmshigh & B43_TMSHIGH_HAVE_2GHZ_PHY); | 4763 | have_2ghz_phy = !!(tmshigh & B43_TMSHIGH_HAVE_2GHZ_PHY); |
4718 | have_5ghz_phy = !!(tmshigh & B43_TMSHIGH_HAVE_5GHZ_PHY); | 4764 | have_5ghz_phy = !!(tmshigh & B43_TMSHIGH_HAVE_5GHZ_PHY); |
4719 | } else | 4765 | } else |
@@ -4786,7 +4832,7 @@ static int b43_wireless_core_attach(struct b43_wldev *dev) | |||
4786 | INIT_WORK(&dev->restart_work, b43_chip_reset); | 4832 | INIT_WORK(&dev->restart_work, b43_chip_reset); |
4787 | 4833 | ||
4788 | dev->phy.ops->switch_analog(dev, 0); | 4834 | dev->phy.ops->switch_analog(dev, 0); |
4789 | ssb_device_disable(dev->dev, 0); | 4835 | ssb_device_disable(dev->sdev, 0); |
4790 | ssb_bus_may_powerdown(bus); | 4836 | ssb_bus_may_powerdown(bus); |
4791 | 4837 | ||
4792 | out: | 4838 | out: |
@@ -4820,31 +4866,14 @@ static void b43_one_core_detach(struct ssb_device *dev) | |||
4820 | static int b43_one_core_attach(struct ssb_device *dev, struct b43_wl *wl) | 4866 | static int b43_one_core_attach(struct ssb_device *dev, struct b43_wl *wl) |
4821 | { | 4867 | { |
4822 | struct b43_wldev *wldev; | 4868 | struct b43_wldev *wldev; |
4823 | struct pci_dev *pdev; | ||
4824 | int err = -ENOMEM; | 4869 | int err = -ENOMEM; |
4825 | 4870 | ||
4826 | if (!list_empty(&wl->devlist)) { | ||
4827 | /* We are not the first core on this chip. */ | ||
4828 | pdev = (dev->bus->bustype == SSB_BUSTYPE_PCI) ? dev->bus->host_pci : NULL; | ||
4829 | /* Only special chips support more than one wireless | ||
4830 | * core, although some of the other chips have more than | ||
4831 | * one wireless core as well. Check for this and | ||
4832 | * bail out early. | ||
4833 | */ | ||
4834 | if (!pdev || | ||
4835 | ((pdev->device != 0x4321) && | ||
4836 | (pdev->device != 0x4313) && (pdev->device != 0x431A))) { | ||
4837 | b43dbg(wl, "Ignoring unconnected 802.11 core\n"); | ||
4838 | return -ENODEV; | ||
4839 | } | ||
4840 | } | ||
4841 | |||
4842 | wldev = kzalloc(sizeof(*wldev), GFP_KERNEL); | 4871 | wldev = kzalloc(sizeof(*wldev), GFP_KERNEL); |
4843 | if (!wldev) | 4872 | if (!wldev) |
4844 | goto out; | 4873 | goto out; |
4845 | 4874 | ||
4846 | wldev->use_pio = b43_modparam_pio; | 4875 | wldev->use_pio = b43_modparam_pio; |
4847 | wldev->dev = dev; | 4876 | wldev->sdev = dev; |
4848 | wldev->wl = wl; | 4877 | wldev->wl = wl; |
4849 | b43_set_status(wldev, B43_STAT_UNINIT); | 4878 | b43_set_status(wldev, B43_STAT_UNINIT); |
4850 | wldev->bad_frames_preempt = modparam_bad_frames_preempt; | 4879 | wldev->bad_frames_preempt = modparam_bad_frames_preempt; |
@@ -4905,19 +4934,16 @@ static void b43_wireless_exit(struct ssb_device *dev, struct b43_wl *wl) | |||
4905 | ieee80211_free_hw(hw); | 4934 | ieee80211_free_hw(hw); |
4906 | } | 4935 | } |
4907 | 4936 | ||
4908 | static int b43_wireless_init(struct ssb_device *dev) | 4937 | static struct b43_wl *b43_wireless_init(struct ssb_device *dev) |
4909 | { | 4938 | { |
4910 | struct ssb_sprom *sprom = &dev->bus->sprom; | 4939 | struct ssb_sprom *sprom = &dev->bus->sprom; |
4911 | struct ieee80211_hw *hw; | 4940 | struct ieee80211_hw *hw; |
4912 | struct b43_wl *wl; | 4941 | struct b43_wl *wl; |
4913 | int err = -ENOMEM; | ||
4914 | |||
4915 | b43_sprom_fixup(dev->bus); | ||
4916 | 4942 | ||
4917 | hw = ieee80211_alloc_hw(sizeof(*wl), &b43_hw_ops); | 4943 | hw = ieee80211_alloc_hw(sizeof(*wl), &b43_hw_ops); |
4918 | if (!hw) { | 4944 | if (!hw) { |
4919 | b43err(NULL, "Could not allocate ieee80211 device\n"); | 4945 | b43err(NULL, "Could not allocate ieee80211 device\n"); |
4920 | goto out; | 4946 | return ERR_PTR(-ENOMEM); |
4921 | } | 4947 | } |
4922 | wl = hw_to_b43_wl(hw); | 4948 | wl = hw_to_b43_wl(hw); |
4923 | 4949 | ||
@@ -4951,15 +4977,12 @@ static int b43_wireless_init(struct ssb_device *dev) | |||
4951 | INIT_WORK(&wl->tx_work, b43_tx_work); | 4977 | INIT_WORK(&wl->tx_work, b43_tx_work); |
4952 | skb_queue_head_init(&wl->tx_queue); | 4978 | skb_queue_head_init(&wl->tx_queue); |
4953 | 4979 | ||
4954 | ssb_set_devtypedata(dev, wl); | ||
4955 | b43info(wl, "Broadcom %04X WLAN found (core revision %u)\n", | 4980 | b43info(wl, "Broadcom %04X WLAN found (core revision %u)\n", |
4956 | dev->bus->chip_id, dev->id.revision); | 4981 | dev->bus->chip_id, dev->id.revision); |
4957 | err = 0; | 4982 | return wl; |
4958 | out: | ||
4959 | return err; | ||
4960 | } | 4983 | } |
4961 | 4984 | ||
4962 | static int b43_probe(struct ssb_device *dev, const struct ssb_device_id *id) | 4985 | static int b43_ssb_probe(struct ssb_device *dev, const struct ssb_device_id *id) |
4963 | { | 4986 | { |
4964 | struct b43_wl *wl; | 4987 | struct b43_wl *wl; |
4965 | int err; | 4988 | int err; |
@@ -4969,11 +4992,14 @@ static int b43_probe(struct ssb_device *dev, const struct ssb_device_id *id) | |||
4969 | if (!wl) { | 4992 | if (!wl) { |
4970 | /* Probing the first core. Must setup common struct b43_wl */ | 4993 | /* Probing the first core. Must setup common struct b43_wl */ |
4971 | first = 1; | 4994 | first = 1; |
4972 | err = b43_wireless_init(dev); | 4995 | b43_sprom_fixup(dev->bus); |
4973 | if (err) | 4996 | wl = b43_wireless_init(dev); |
4997 | if (IS_ERR(wl)) { | ||
4998 | err = PTR_ERR(wl); | ||
4974 | goto out; | 4999 | goto out; |
4975 | wl = ssb_get_devtypedata(dev); | 5000 | } |
4976 | B43_WARN_ON(!wl); | 5001 | ssb_set_devtypedata(dev, wl); |
5002 | B43_WARN_ON(ssb_get_devtypedata(dev) != wl); | ||
4977 | } | 5003 | } |
4978 | err = b43_one_core_attach(dev, wl); | 5004 | err = b43_one_core_attach(dev, wl); |
4979 | if (err) | 5005 | if (err) |
@@ -4984,7 +5010,6 @@ static int b43_probe(struct ssb_device *dev, const struct ssb_device_id *id) | |||
4984 | if (err) | 5010 | if (err) |
4985 | goto err_one_core_detach; | 5011 | goto err_one_core_detach; |
4986 | b43_leds_register(wl->current_dev); | 5012 | b43_leds_register(wl->current_dev); |
4987 | b43_rng_init(wl); | ||
4988 | } | 5013 | } |
4989 | 5014 | ||
4990 | out: | 5015 | out: |
@@ -4998,7 +5023,7 @@ static int b43_probe(struct ssb_device *dev, const struct ssb_device_id *id) | |||
4998 | return err; | 5023 | return err; |
4999 | } | 5024 | } |
5000 | 5025 | ||
5001 | static void b43_remove(struct ssb_device *dev) | 5026 | static void b43_ssb_remove(struct ssb_device *dev) |
5002 | { | 5027 | { |
5003 | struct b43_wl *wl = ssb_get_devtypedata(dev); | 5028 | struct b43_wl *wl = ssb_get_devtypedata(dev); |
5004 | struct b43_wldev *wldev = ssb_get_drvdata(dev); | 5029 | struct b43_wldev *wldev = ssb_get_drvdata(dev); |
@@ -5020,7 +5045,6 @@ static void b43_remove(struct ssb_device *dev) | |||
5020 | b43_one_core_detach(dev); | 5045 | b43_one_core_detach(dev); |
5021 | 5046 | ||
5022 | if (list_empty(&wl->devlist)) { | 5047 | if (list_empty(&wl->devlist)) { |
5023 | b43_rng_exit(wl); | ||
5024 | b43_leds_unregister(wl); | 5048 | b43_leds_unregister(wl); |
5025 | /* Last core on the chip unregistered. | 5049 | /* Last core on the chip unregistered. |
5026 | * We can destroy common struct b43_wl. | 5050 | * We can destroy common struct b43_wl. |
@@ -5042,8 +5066,8 @@ void b43_controller_restart(struct b43_wldev *dev, const char *reason) | |||
5042 | static struct ssb_driver b43_ssb_driver = { | 5066 | static struct ssb_driver b43_ssb_driver = { |
5043 | .name = KBUILD_MODNAME, | 5067 | .name = KBUILD_MODNAME, |
5044 | .id_table = b43_ssb_tbl, | 5068 | .id_table = b43_ssb_tbl, |
5045 | .probe = b43_probe, | 5069 | .probe = b43_ssb_probe, |
5046 | .remove = b43_remove, | 5070 | .remove = b43_ssb_remove, |
5047 | }; | 5071 | }; |
5048 | 5072 | ||
5049 | static void b43_print_driverinfo(void) | 5073 | static void b43_print_driverinfo(void) |
@@ -5057,7 +5081,7 @@ static void b43_print_driverinfo(void) | |||
5057 | #ifdef CONFIG_B43_PCMCIA | 5081 | #ifdef CONFIG_B43_PCMCIA |
5058 | feat_pcmcia = "M"; | 5082 | feat_pcmcia = "M"; |
5059 | #endif | 5083 | #endif |
5060 | #ifdef CONFIG_B43_NPHY | 5084 | #ifdef CONFIG_B43_PHY_N |
5061 | feat_nphy = "N"; | 5085 | feat_nphy = "N"; |
5062 | #endif | 5086 | #endif |
5063 | #ifdef CONFIG_B43_LEDS | 5087 | #ifdef CONFIG_B43_LEDS |