aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/b43
diff options
context:
space:
mode:
authorGábor Stefanik <netrolller.3d@gmail.com>2009-08-11 16:24:22 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-08-14 09:14:04 -0400
commit47583154767886a97a82452c8aca63bf0336337a (patch)
treec0eb7ad95efce634406ac333bd126ed8248aee0b /drivers/net/wireless/b43
parent7834ddbcc7a097443761b0722e8c9fb8511b95b1 (diff)
b43: LP-PHY: Refactor TX gain table I/O
Make it possible to write individual gain table entries. Allow gain table entries to be written outside gain table init. Add version-agnostic helpers for writing gain tables. Use the new TX gain table helpers during table init. Signed-off-by: Gábor Stefanik <netrolller.3d@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/b43')
-rw-r--r--drivers/net/wireless/b43/tables_lpphy.c85
-rw-r--r--drivers/net/wireless/b43/tables_lpphy.h9
2 files changed, 55 insertions, 39 deletions
diff --git a/drivers/net/wireless/b43/tables_lpphy.c b/drivers/net/wireless/b43/tables_lpphy.c
index b056811a1703..2721310acb2a 100644
--- a/drivers/net/wireless/b43/tables_lpphy.c
+++ b/drivers/net/wireless/b43/tables_lpphy.c
@@ -1058,10 +1058,6 @@ static const u32 lpphy_papd_mult_table[] = {
1058 0x00036963, 0x000339f2, 0x00030a89, 0x0002db28, 1058 0x00036963, 0x000339f2, 0x00030a89, 0x0002db28,
1059}; 1059};
1060 1060
1061struct lpphy_tx_gain_table_entry {
1062 u8 gm, pga, pad, dac, bb_mult;
1063};
1064
1065static struct lpphy_tx_gain_table_entry lpphy_rev0_nopa_tx_gain_table[] = { 1061static struct lpphy_tx_gain_table_entry lpphy_rev0_nopa_tx_gain_table[] = {
1066 { .gm = 7, .pga = 15, .pad = 14, .dac = 0, .bb_mult = 152, }, 1062 { .gm = 7, .pga = 15, .pad = 14, .dac = 0, .bb_mult = 152, },
1067 { .gm = 7, .pga = 15, .pad = 14, .dac = 0, .bb_mult = 147, }, 1063 { .gm = 7, .pga = 15, .pad = 14, .dac = 0, .bb_mult = 147, },
@@ -2345,44 +2341,55 @@ void lpphy_rev2plus_table_init(struct b43_wldev *dev)
2345 } 2341 }
2346} 2342}
2347 2343
2348 2344static void lpphy_rev0_1_write_gain_table(struct b43_wldev *dev, int offset,
2349static void lpphy_rev0_1_write_gain_table(struct b43_wldev *dev, 2345 struct lpphy_tx_gain_table_entry data)
2350 struct lpphy_tx_gain_table_entry *table)
2351{ 2346{
2352 int i;
2353 u32 tmp; 2347 u32 tmp;
2354 2348
2355 B43_WARN_ON(dev->phy.rev >= 2); 2349 B43_WARN_ON(dev->phy.rev >= 2);
2356 2350
2357 for (i = 0; i < 128; i++) { 2351 tmp = data.pad << 11;
2358 tmp = table[i].pad << 11; 2352 tmp |= data.pga << 7;
2359 tmp |= table[i].pga << 7; 2353 tmp |= data.gm << 4;
2360 tmp |= table[i].gm << 4; 2354 tmp |= data.dac;
2361 tmp |= table[i].dac; 2355 b43_lptab_write(dev, B43_LPTAB32(10, 0xC0 + offset), tmp);
2362 b43_lptab_write(dev, B43_LPTAB32(10, 0xC0 + i), tmp); 2356 tmp = data.bb_mult << 20;
2363 tmp = table[i].bb_mult << 20; 2357 b43_lptab_write(dev, B43_LPTAB32(10, 0x140 + offset), tmp);
2364 b43_lptab_write(dev, B43_LPTAB32(10, 0x140 + i), tmp);
2365 }
2366} 2358}
2367 2359
2368static void lpphy_rev2plus_write_gain_table(struct b43_wldev *dev, 2360static void lpphy_rev2plus_write_gain_table(struct b43_wldev *dev, int offset,
2369 struct lpphy_tx_gain_table_entry *table) 2361 struct lpphy_tx_gain_table_entry data)
2370{ 2362{
2371 int i;
2372 u32 tmp; 2363 u32 tmp;
2373 2364
2374 B43_WARN_ON(dev->phy.rev < 2); 2365 B43_WARN_ON(dev->phy.rev < 2);
2375 2366
2376 for (i = 0; i < 128; i++) { 2367 tmp = data.pad << 16;
2377 tmp = table[i].pad << 16; 2368 tmp |= data.pga << 8;
2378 tmp |= table[i].pga << 8; 2369 tmp |= data.gm;
2379 tmp |= table[i].gm; 2370 tmp |= 0x7f000000;
2380 tmp |= 0x7f000000; 2371 b43_lptab_write(dev, B43_LPTAB32(7, 0xC0 + offset), tmp);
2381 b43_lptab_write(dev, B43_LPTAB32(7, 0xC0 + i), tmp); 2372 tmp = data.bb_mult << 20;
2382 tmp = table[i].bb_mult << 20; 2373 tmp |= data.dac << 28;
2383 tmp |= table[i].dac << 28; 2374 b43_lptab_write(dev, B43_LPTAB32(7, 0x140 + offset), tmp);
2384 b43_lptab_write(dev, B43_LPTAB32(7, 0x140 + i), tmp); 2375}
2385 } 2376
2377void lpphy_write_gain_table(struct b43_wldev *dev, int offset,
2378 struct lpphy_tx_gain_table_entry data)
2379{
2380 if (dev->phy.rev >= 2)
2381 lpphy_rev2plus_write_gain_table(dev, offset, data);
2382 else
2383 lpphy_rev0_1_write_gain_table(dev, offset, data);
2384}
2385
2386void lpphy_write_gain_table_bulk(struct b43_wldev *dev, int offset, int count,
2387 struct lpphy_tx_gain_table_entry *table)
2388{
2389 int i;
2390
2391 for (i = offset; i < count; i++)
2392 lpphy_write_gain_table(dev, i, table[i]);
2386} 2393}
2387 2394
2388void lpphy_init_tx_gain_table(struct b43_wldev *dev) 2395void lpphy_init_tx_gain_table(struct b43_wldev *dev)
@@ -2393,36 +2400,36 @@ void lpphy_init_tx_gain_table(struct b43_wldev *dev)
2393 case 0: 2400 case 0:
2394 if ((bus->sprom.boardflags_hi & B43_BFH_NOPA) || 2401 if ((bus->sprom.boardflags_hi & B43_BFH_NOPA) ||
2395 (bus->sprom.boardflags_lo & B43_BFL_HGPA)) 2402 (bus->sprom.boardflags_lo & B43_BFL_HGPA))
2396 lpphy_rev0_1_write_gain_table(dev, 2403 lpphy_write_gain_table_bulk(dev, 0, 128,
2397 lpphy_rev0_nopa_tx_gain_table); 2404 lpphy_rev0_nopa_tx_gain_table);
2398 else if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) 2405 else if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
2399 lpphy_rev0_1_write_gain_table(dev, 2406 lpphy_write_gain_table_bulk(dev, 0, 128,
2400 lpphy_rev0_2ghz_tx_gain_table); 2407 lpphy_rev0_2ghz_tx_gain_table);
2401 else 2408 else
2402 lpphy_rev0_1_write_gain_table(dev, 2409 lpphy_write_gain_table_bulk(dev, 0, 128,
2403 lpphy_rev0_5ghz_tx_gain_table); 2410 lpphy_rev0_5ghz_tx_gain_table);
2404 break; 2411 break;
2405 case 1: 2412 case 1:
2406 if ((bus->sprom.boardflags_hi & B43_BFH_NOPA) || 2413 if ((bus->sprom.boardflags_hi & B43_BFH_NOPA) ||
2407 (bus->sprom.boardflags_lo & B43_BFL_HGPA)) 2414 (bus->sprom.boardflags_lo & B43_BFL_HGPA))
2408 lpphy_rev0_1_write_gain_table(dev, 2415 lpphy_write_gain_table_bulk(dev, 0, 128,
2409 lpphy_rev1_nopa_tx_gain_table); 2416 lpphy_rev1_nopa_tx_gain_table);
2410 else if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) 2417 else if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
2411 lpphy_rev0_1_write_gain_table(dev, 2418 lpphy_write_gain_table_bulk(dev, 0, 128,
2412 lpphy_rev1_2ghz_tx_gain_table); 2419 lpphy_rev1_2ghz_tx_gain_table);
2413 else 2420 else
2414 lpphy_rev0_1_write_gain_table(dev, 2421 lpphy_write_gain_table_bulk(dev, 0, 128,
2415 lpphy_rev1_5ghz_tx_gain_table); 2422 lpphy_rev1_5ghz_tx_gain_table);
2416 break; 2423 break;
2417 default: 2424 default:
2418 if (bus->sprom.boardflags_hi & B43_BFH_NOPA) 2425 if (bus->sprom.boardflags_hi & B43_BFH_NOPA)
2419 lpphy_rev2plus_write_gain_table(dev, 2426 lpphy_write_gain_table_bulk(dev, 0, 128,
2420 lpphy_rev2_nopa_tx_gain_table); 2427 lpphy_rev2_nopa_tx_gain_table);
2421 else if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) 2428 else if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
2422 lpphy_rev2plus_write_gain_table(dev, 2429 lpphy_write_gain_table_bulk(dev, 0, 128,
2423 lpphy_rev2_2ghz_tx_gain_table); 2430 lpphy_rev2_2ghz_tx_gain_table);
2424 else 2431 else
2425 lpphy_rev2plus_write_gain_table(dev, 2432 lpphy_write_gain_table_bulk(dev, 0, 128,
2426 lpphy_rev2_5ghz_tx_gain_table); 2433 lpphy_rev2_5ghz_tx_gain_table);
2427 } 2434 }
2428} 2435}
diff --git a/drivers/net/wireless/b43/tables_lpphy.h b/drivers/net/wireless/b43/tables_lpphy.h
index b5024b6edab3..84f1d265f657 100644
--- a/drivers/net/wireless/b43/tables_lpphy.h
+++ b/drivers/net/wireless/b43/tables_lpphy.h
@@ -28,6 +28,15 @@ void b43_lptab_write_bulk(struct b43_wldev *dev, u32 offset,
28void b2062_upload_init_table(struct b43_wldev *dev); 28void b2062_upload_init_table(struct b43_wldev *dev);
29void b2063_upload_init_table(struct b43_wldev *dev); 29void b2063_upload_init_table(struct b43_wldev *dev);
30 30
31struct lpphy_tx_gain_table_entry {
32 u8 gm, pga, pad, dac, bb_mult;
33};
34
35void lpphy_write_gain_table(struct b43_wldev *dev, int offset,
36 struct lpphy_tx_gain_table_entry data);
37void lpphy_write_gain_table_bulk(struct b43_wldev *dev, int offset, int count,
38 struct lpphy_tx_gain_table_entry *table);
39
31void lpphy_rev0_1_table_init(struct b43_wldev *dev); 40void lpphy_rev0_1_table_init(struct b43_wldev *dev);
32void lpphy_rev2plus_table_init(struct b43_wldev *dev); 41void lpphy_rev2plus_table_init(struct b43_wldev *dev);
33void lpphy_init_tx_gain_table(struct b43_wldev *dev); 42void lpphy_init_tx_gain_table(struct b43_wldev *dev);