Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Gábor Stefanik and committed by
John W. Linville
47583154 7834ddbc

+55 -39
+46 -39
drivers/net/wireless/b43/tables_lpphy.c
··· 1058 1058 0x00036963, 0x000339f2, 0x00030a89, 0x0002db28, 1059 1059 }; 1060 1060 1061 - struct lpphy_tx_gain_table_entry { 1062 - u8 gm, pga, pad, dac, bb_mult; 1063 - }; 1064 - 1065 1061 static struct lpphy_tx_gain_table_entry lpphy_rev0_nopa_tx_gain_table[] = { 1066 1062 { .gm = 7, .pga = 15, .pad = 14, .dac = 0, .bb_mult = 152, }, 1067 1063 { .gm = 7, .pga = 15, .pad = 14, .dac = 0, .bb_mult = 147, }, ··· 2341 2345 } 2342 2346 } 2343 2347 2344 - 2345 - static void lpphy_rev0_1_write_gain_table(struct b43_wldev *dev, 2346 - struct lpphy_tx_gain_table_entry *table) 2348 + static void lpphy_rev0_1_write_gain_table(struct b43_wldev *dev, int offset, 2349 + struct lpphy_tx_gain_table_entry data) 2347 2350 { 2348 - int i; 2349 2351 u32 tmp; 2350 2352 2351 2353 B43_WARN_ON(dev->phy.rev >= 2); 2352 2354 2353 - for (i = 0; i < 128; i++) { 2354 - tmp = table[i].pad << 11; 2355 - tmp |= table[i].pga << 7; 2356 - tmp |= table[i].gm << 4; 2357 - tmp |= table[i].dac; 2358 - b43_lptab_write(dev, B43_LPTAB32(10, 0xC0 + i), tmp); 2359 - tmp = table[i].bb_mult << 20; 2360 - b43_lptab_write(dev, B43_LPTAB32(10, 0x140 + i), tmp); 2361 - } 2355 + tmp = data.pad << 11; 2356 + tmp |= data.pga << 7; 2357 + tmp |= data.gm << 4; 2358 + tmp |= data.dac; 2359 + b43_lptab_write(dev, B43_LPTAB32(10, 0xC0 + offset), tmp); 2360 + tmp = data.bb_mult << 20; 2361 + b43_lptab_write(dev, B43_LPTAB32(10, 0x140 + offset), tmp); 2362 2362 } 2363 2363 2364 - static void lpphy_rev2plus_write_gain_table(struct b43_wldev *dev, 2365 - struct lpphy_tx_gain_table_entry *table) 2364 + static void lpphy_rev2plus_write_gain_table(struct b43_wldev *dev, int offset, 2365 + struct lpphy_tx_gain_table_entry data) 2366 2366 { 2367 - int i; 2368 2367 u32 tmp; 2369 2368 2370 2369 B43_WARN_ON(dev->phy.rev < 2); 2371 2370 2372 - for (i = 0; i < 128; i++) { 2373 - tmp = table[i].pad << 16; 2374 - tmp |= table[i].pga << 8; 2375 - tmp |= table[i].gm; 2376 - tmp |= 0x7f000000; 2377 - b43_lptab_write(dev, B43_LPTAB32(7, 0xC0 + i), tmp); 2378 - tmp = table[i].bb_mult << 20; 2379 - tmp |= table[i].dac << 28; 2380 - b43_lptab_write(dev, B43_LPTAB32(7, 0x140 + i), tmp); 2381 - } 2371 + tmp = data.pad << 16; 2372 + tmp |= data.pga << 8; 2373 + tmp |= data.gm; 2374 + tmp |= 0x7f000000; 2375 + b43_lptab_write(dev, B43_LPTAB32(7, 0xC0 + offset), tmp); 2376 + tmp = data.bb_mult << 20; 2377 + tmp |= data.dac << 28; 2378 + b43_lptab_write(dev, B43_LPTAB32(7, 0x140 + offset), tmp); 2379 + } 2380 + 2381 + void lpphy_write_gain_table(struct b43_wldev *dev, int offset, 2382 + struct lpphy_tx_gain_table_entry data) 2383 + { 2384 + if (dev->phy.rev >= 2) 2385 + lpphy_rev2plus_write_gain_table(dev, offset, data); 2386 + else 2387 + lpphy_rev0_1_write_gain_table(dev, offset, data); 2388 + } 2389 + 2390 + void lpphy_write_gain_table_bulk(struct b43_wldev *dev, int offset, int count, 2391 + struct lpphy_tx_gain_table_entry *table) 2392 + { 2393 + int i; 2394 + 2395 + for (i = offset; i < count; i++) 2396 + lpphy_write_gain_table(dev, i, table[i]); 2382 2397 } 2383 2398 2384 2399 void lpphy_init_tx_gain_table(struct b43_wldev *dev) ··· 2400 2393 case 0: 2401 2394 if ((bus->sprom.boardflags_hi & B43_BFH_NOPA) || 2402 2395 (bus->sprom.boardflags_lo & B43_BFL_HGPA)) 2403 - lpphy_rev0_1_write_gain_table(dev, 2396 + lpphy_write_gain_table_bulk(dev, 0, 128, 2404 2397 lpphy_rev0_nopa_tx_gain_table); 2405 2398 else if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) 2406 - lpphy_rev0_1_write_gain_table(dev, 2399 + lpphy_write_gain_table_bulk(dev, 0, 128, 2407 2400 lpphy_rev0_2ghz_tx_gain_table); 2408 2401 else 2409 - lpphy_rev0_1_write_gain_table(dev, 2402 + lpphy_write_gain_table_bulk(dev, 0, 128, 2410 2403 lpphy_rev0_5ghz_tx_gain_table); 2411 2404 break; 2412 2405 case 1: 2413 2406 if ((bus->sprom.boardflags_hi & B43_BFH_NOPA) || 2414 2407 (bus->sprom.boardflags_lo & B43_BFL_HGPA)) 2415 - lpphy_rev0_1_write_gain_table(dev, 2408 + lpphy_write_gain_table_bulk(dev, 0, 128, 2416 2409 lpphy_rev1_nopa_tx_gain_table); 2417 2410 else if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) 2418 - lpphy_rev0_1_write_gain_table(dev, 2411 + lpphy_write_gain_table_bulk(dev, 0, 128, 2419 2412 lpphy_rev1_2ghz_tx_gain_table); 2420 2413 else 2421 - lpphy_rev0_1_write_gain_table(dev, 2414 + lpphy_write_gain_table_bulk(dev, 0, 128, 2422 2415 lpphy_rev1_5ghz_tx_gain_table); 2423 2416 break; 2424 2417 default: 2425 2418 if (bus->sprom.boardflags_hi & B43_BFH_NOPA) 2426 - lpphy_rev2plus_write_gain_table(dev, 2419 + lpphy_write_gain_table_bulk(dev, 0, 128, 2427 2420 lpphy_rev2_nopa_tx_gain_table); 2428 2421 else if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) 2429 - lpphy_rev2plus_write_gain_table(dev, 2422 + lpphy_write_gain_table_bulk(dev, 0, 128, 2430 2423 lpphy_rev2_2ghz_tx_gain_table); 2431 2424 else 2432 - lpphy_rev2plus_write_gain_table(dev, 2425 + lpphy_write_gain_table_bulk(dev, 0, 128, 2433 2426 lpphy_rev2_5ghz_tx_gain_table); 2434 2427 } 2435 2428 }
+9
drivers/net/wireless/b43/tables_lpphy.h
··· 28 28 void b2062_upload_init_table(struct b43_wldev *dev); 29 29 void b2063_upload_init_table(struct b43_wldev *dev); 30 30 31 + struct lpphy_tx_gain_table_entry { 32 + u8 gm, pga, pad, dac, bb_mult; 33 + }; 34 + 35 + void lpphy_write_gain_table(struct b43_wldev *dev, int offset, 36 + struct lpphy_tx_gain_table_entry data); 37 + void lpphy_write_gain_table_bulk(struct b43_wldev *dev, int offset, int count, 38 + struct lpphy_tx_gain_table_entry *table); 39 + 31 40 void lpphy_rev0_1_table_init(struct b43_wldev *dev); 32 41 void lpphy_rev2plus_table_init(struct b43_wldev *dev); 33 42 void lpphy_init_tx_gain_table(struct b43_wldev *dev);