aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/b43
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2011-09-04 03:11:46 -0400
committerJohn W. Linville <linville@tuxdriver.com>2011-09-14 13:56:26 -0400
commit28e3181a7717b7e7934391c29e21c5302324479c (patch)
treed9560be28b026fabd7feb82bdb9669814d8c66d7 /drivers/net/wireless/b43
parent108f4f3c4afff207486f9bc0ba9af2bdd4b19793 (diff)
b43: LCN-PHY: load TX gain table on init
Signed-off-by: Rafał Miłecki <zajec5@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_phy_lcn.c195
-rw-r--r--drivers/net/wireless/b43/tables_phy_lcn.h2
2 files changed, 194 insertions, 3 deletions
diff --git a/drivers/net/wireless/b43/tables_phy_lcn.c b/drivers/net/wireless/b43/tables_phy_lcn.c
index 1682ba0a410..9d484e2f79b 100644
--- a/drivers/net/wireless/b43/tables_phy_lcn.c
+++ b/drivers/net/wireless/b43/tables_phy_lcn.c
@@ -27,6 +27,18 @@
27#include "phy_common.h" 27#include "phy_common.h"
28#include "phy_lcn.h" 28#include "phy_lcn.h"
29 29
30struct b43_lcntab_tx_gain_tbl_entry {
31 u8 gm;
32 u8 pga;
33 u8 pad;
34 u8 dac;
35 u8 bb_mult;
36};
37
38/**************************************************
39 * Static tables.
40 **************************************************/
41
30static const u16 b43_lcntab_0x02[] = { 42static const u16 b43_lcntab_0x02[] = {
31 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 43 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d,
32 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 44 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d,
@@ -297,6 +309,146 @@ static const u32 b43_lcntab_0x18[] = {
297 0x00080000, 0x00080000, 0x00080000, 0x00080000, 309 0x00080000, 0x00080000, 0x00080000, 0x00080000,
298}; 310};
299 311
312/**************************************************
313 * TX gain.
314 **************************************************/
315
316const struct b43_lcntab_tx_gain_tbl_entry
317 b43_lcntab_tx_gain_tbl_2ghz_ext_pa_rev0[B43_LCNTAB_TX_GAIN_SIZE] = {
318 { 0x03, 0x00, 0x1f, 0x0, 0x48 },
319 { 0x03, 0x00, 0x1f, 0x0, 0x46 },
320 { 0x03, 0x00, 0x1f, 0x0, 0x44 },
321 { 0x03, 0x00, 0x1e, 0x0, 0x43 },
322 { 0x03, 0x00, 0x1d, 0x0, 0x44 },
323 { 0x03, 0x00, 0x1c, 0x0, 0x44 },
324 { 0x03, 0x00, 0x1b, 0x0, 0x45 },
325 { 0x03, 0x00, 0x1a, 0x0, 0x46 },
326 { 0x03, 0x00, 0x19, 0x0, 0x46 },
327 { 0x03, 0x00, 0x18, 0x0, 0x47 },
328 { 0x03, 0x00, 0x17, 0x0, 0x48 },
329 { 0x03, 0x00, 0x17, 0x0, 0x46 },
330 { 0x03, 0x00, 0x16, 0x0, 0x47 },
331 { 0x03, 0x00, 0x15, 0x0, 0x48 },
332 { 0x03, 0x00, 0x15, 0x0, 0x46 },
333 { 0x03, 0x00, 0x15, 0x0, 0x44 },
334 { 0x03, 0x00, 0x15, 0x0, 0x42 },
335 { 0x03, 0x00, 0x15, 0x0, 0x40 },
336 { 0x03, 0x00, 0x15, 0x0, 0x3f },
337 { 0x03, 0x00, 0x14, 0x0, 0x40 },
338 { 0x03, 0x00, 0x13, 0x0, 0x41 },
339 { 0x03, 0x00, 0x13, 0x0, 0x40 },
340 { 0x03, 0x00, 0x12, 0x0, 0x41 },
341 { 0x03, 0x00, 0x12, 0x0, 0x40 },
342 { 0x03, 0x00, 0x11, 0x0, 0x41 },
343 { 0x03, 0x00, 0x11, 0x0, 0x40 },
344 { 0x03, 0x00, 0x10, 0x0, 0x41 },
345 { 0x03, 0x00, 0x10, 0x0, 0x40 },
346 { 0x03, 0x00, 0x10, 0x0, 0x3e },
347 { 0x03, 0x00, 0x10, 0x0, 0x3c },
348 { 0x03, 0x00, 0x10, 0x0, 0x3a },
349 { 0x03, 0x00, 0x0f, 0x0, 0x3d },
350 { 0x03, 0x00, 0x0f, 0x0, 0x3b },
351 { 0x03, 0x00, 0x0e, 0x0, 0x3d },
352 { 0x03, 0x00, 0x0e, 0x0, 0x3c },
353 { 0x03, 0x00, 0x0e, 0x0, 0x3a },
354 { 0x03, 0x00, 0x0d, 0x0, 0x3c },
355 { 0x03, 0x00, 0x0d, 0x0, 0x3b },
356 { 0x03, 0x00, 0x0c, 0x0, 0x3e },
357 { 0x03, 0x00, 0x0c, 0x0, 0x3c },
358 { 0x03, 0x00, 0x0c, 0x0, 0x3a },
359 { 0x03, 0x00, 0x0b, 0x0, 0x3e },
360 { 0x03, 0x00, 0x0b, 0x0, 0x3c },
361 { 0x03, 0x00, 0x0b, 0x0, 0x3b },
362 { 0x03, 0x00, 0x0b, 0x0, 0x39 },
363 { 0x03, 0x00, 0x0a, 0x0, 0x3d },
364 { 0x03, 0x00, 0x0a, 0x0, 0x3b },
365 { 0x03, 0x00, 0x0a, 0x0, 0x39 },
366 { 0x03, 0x00, 0x09, 0x0, 0x3e },
367 { 0x03, 0x00, 0x09, 0x0, 0x3c },
368 { 0x03, 0x00, 0x09, 0x0, 0x3a },
369 { 0x03, 0x00, 0x09, 0x0, 0x39 },
370 { 0x03, 0x00, 0x08, 0x0, 0x3e },
371 { 0x03, 0x00, 0x08, 0x0, 0x3c },
372 { 0x03, 0x00, 0x08, 0x0, 0x3a },
373 { 0x03, 0x00, 0x08, 0x0, 0x39 },
374 { 0x03, 0x00, 0x08, 0x0, 0x37 },
375 { 0x03, 0x00, 0x07, 0x0, 0x3d },
376 { 0x03, 0x00, 0x07, 0x0, 0x3c },
377 { 0x03, 0x00, 0x07, 0x0, 0x3a },
378 { 0x03, 0x00, 0x07, 0x0, 0x38 },
379 { 0x03, 0x00, 0x07, 0x0, 0x37 },
380 { 0x03, 0x00, 0x06, 0x0, 0x3e },
381 { 0x03, 0x00, 0x06, 0x0, 0x3c },
382 { 0x03, 0x00, 0x06, 0x0, 0x3a },
383 { 0x03, 0x00, 0x06, 0x0, 0x39 },
384 { 0x03, 0x00, 0x06, 0x0, 0x37 },
385 { 0x03, 0x00, 0x06, 0x0, 0x36 },
386 { 0x03, 0x00, 0x06, 0x0, 0x34 },
387 { 0x03, 0x00, 0x05, 0x0, 0x3d },
388 { 0x03, 0x00, 0x05, 0x0, 0x3b },
389 { 0x03, 0x00, 0x05, 0x0, 0x39 },
390 { 0x03, 0x00, 0x05, 0x0, 0x38 },
391 { 0x03, 0x00, 0x05, 0x0, 0x36 },
392 { 0x03, 0x00, 0x05, 0x0, 0x35 },
393 { 0x03, 0x00, 0x05, 0x0, 0x33 },
394 { 0x03, 0x00, 0x04, 0x0, 0x3e },
395 { 0x03, 0x00, 0x04, 0x0, 0x3c },
396 { 0x03, 0x00, 0x04, 0x0, 0x3a },
397 { 0x03, 0x00, 0x04, 0x0, 0x39 },
398 { 0x03, 0x00, 0x04, 0x0, 0x37 },
399 { 0x03, 0x00, 0x04, 0x0, 0x36 },
400 { 0x03, 0x00, 0x04, 0x0, 0x34 },
401 { 0x03, 0x00, 0x04, 0x0, 0x33 },
402 { 0x03, 0x00, 0x04, 0x0, 0x31 },
403 { 0x03, 0x00, 0x04, 0x0, 0x30 },
404 { 0x03, 0x00, 0x04, 0x0, 0x2e },
405 { 0x03, 0x00, 0x03, 0x0, 0x3c },
406 { 0x03, 0x00, 0x03, 0x0, 0x3a },
407 { 0x03, 0x00, 0x03, 0x0, 0x39 },
408 { 0x03, 0x00, 0x03, 0x0, 0x37 },
409 { 0x03, 0x00, 0x03, 0x0, 0x36 },
410 { 0x03, 0x00, 0x03, 0x0, 0x34 },
411 { 0x03, 0x00, 0x03, 0x0, 0x33 },
412 { 0x03, 0x00, 0x03, 0x0, 0x31 },
413 { 0x03, 0x00, 0x03, 0x0, 0x30 },
414 { 0x03, 0x00, 0x03, 0x0, 0x2e },
415 { 0x03, 0x00, 0x03, 0x0, 0x2d },
416 { 0x03, 0x00, 0x03, 0x0, 0x2c },
417 { 0x03, 0x00, 0x03, 0x0, 0x2b },
418 { 0x03, 0x00, 0x03, 0x0, 0x29 },
419 { 0x03, 0x00, 0x02, 0x0, 0x3d },
420 { 0x03, 0x00, 0x02, 0x0, 0x3b },
421 { 0x03, 0x00, 0x02, 0x0, 0x39 },
422 { 0x03, 0x00, 0x02, 0x0, 0x38 },
423 { 0x03, 0x00, 0x02, 0x0, 0x36 },
424 { 0x03, 0x00, 0x02, 0x0, 0x35 },
425 { 0x03, 0x00, 0x02, 0x0, 0x33 },
426 { 0x03, 0x00, 0x02, 0x0, 0x32 },
427 { 0x03, 0x00, 0x02, 0x0, 0x30 },
428 { 0x03, 0x00, 0x02, 0x0, 0x2f },
429 { 0x03, 0x00, 0x02, 0x0, 0x2e },
430 { 0x03, 0x00, 0x02, 0x0, 0x2c },
431 { 0x03, 0x00, 0x02, 0x0, 0x2b },
432 { 0x03, 0x00, 0x02, 0x0, 0x2a },
433 { 0x03, 0x00, 0x02, 0x0, 0x29 },
434 { 0x03, 0x00, 0x02, 0x0, 0x27 },
435 { 0x03, 0x00, 0x02, 0x0, 0x26 },
436 { 0x03, 0x00, 0x02, 0x0, 0x25 },
437 { 0x03, 0x00, 0x02, 0x0, 0x24 },
438 { 0x03, 0x00, 0x02, 0x0, 0x23 },
439 { 0x03, 0x00, 0x02, 0x0, 0x22 },
440 { 0x03, 0x00, 0x02, 0x0, 0x21 },
441 { 0x03, 0x00, 0x02, 0x0, 0x20 },
442 { 0x03, 0x00, 0x01, 0x0, 0x3f },
443 { 0x03, 0x00, 0x01, 0x0, 0x3d },
444 { 0x03, 0x00, 0x01, 0x0, 0x3b },
445 { 0x03, 0x00, 0x01, 0x0, 0x39 },
446};
447
448/**************************************************
449 * SW control.
450 **************************************************/
451
300const u16 b43_lcntab_sw_ctl_4313_epa_rev0[] = { 452const u16 b43_lcntab_sw_ctl_4313_epa_rev0[] = {
301 0x0002, 0x0008, 0x0004, 0x0001, 0x0002, 0x0008, 453 0x0002, 0x0008, 0x0004, 0x0001, 0x0002, 0x0008,
302 0x0004, 0x0001, 0x0002, 0x0008, 0x0004, 0x0001, 454 0x0004, 0x0001, 0x0002, 0x0008, 0x0004, 0x0001,
@@ -479,6 +631,32 @@ static void b43_phy_lcn_upload_static_tables(struct b43_wldev *dev)
479 lcntab_upload(dev, B43_LCNTAB32(0x18, 0), b43_lcntab_0x18); 631 lcntab_upload(dev, B43_LCNTAB32(0x18, 0), b43_lcntab_0x18);
480} 632}
481 633
634void b43_phy_lcn_load_tx_gain_tab(struct b43_wldev *dev,
635 const struct b43_lcntab_tx_gain_tbl_entry *gain_table)
636{
637 u32 i;
638 u32 val;
639
640 u16 pa_gain = 0x70;
641 if (dev->dev->bus_sprom->boardflags_lo & B43_BFL_FEM)
642 pa_gain = 0x10;
643
644 for (i = 0; i < B43_LCNTAB_TX_GAIN_SIZE; i++) {
645 val = ((pa_gain << 24) |
646 (gain_table[i].pad << 16) |
647 (gain_table[i].pga << 8) |
648 gain_table[i].gm);
649 b43_lcntab_write(dev, B43_LCNTAB32(0x7, 0xc0 + i), val);
650
651 /* brcmsmac doesn't maskset, we follow newer wl here */
652 val = b43_lcntab_read(dev, B43_LCNTAB32(0x7, 0x140 + i));
653 val &= 0x000fffff;
654 val |= ((gain_table[i].dac << 28) |
655 (gain_table[i].bb_mult << 20));
656 b43_lcntab_write(dev, B43_LCNTAB32(0x7, 0x140 + i), val);
657 }
658}
659
482/* Not implemented in brcmsmac, noticed in wl in MMIO dump */ 660/* Not implemented in brcmsmac, noticed in wl in MMIO dump */
483static void b43_phy_lcn_rewrite_tables(struct b43_wldev *dev) 661static void b43_phy_lcn_rewrite_tables(struct b43_wldev *dev)
484{ 662{
@@ -499,13 +677,24 @@ static void b43_phy_lcn_clean_papd_comp_table(struct b43_wldev *dev)
499 b43_lcntab_write(dev, B43_LCNTAB32(0x18, i), 0x80000); 677 b43_lcntab_write(dev, B43_LCNTAB32(0x18, i), 0x80000);
500} 678}
501 679
680/* wlc_lcnphy_tbl_init */
502void b43_phy_lcn_tables_init(struct b43_wldev *dev) 681void b43_phy_lcn_tables_init(struct b43_wldev *dev)
503{ 682{
683 struct ssb_sprom *sprom = dev->dev->bus_sprom;
684
504 b43_phy_lcn_upload_static_tables(dev); 685 b43_phy_lcn_upload_static_tables(dev);
505 /* TODO: various tables ops here */
506 686
507 if (dev->dev->bus_sprom->boardflags_lo & B43_BFL_FEM && 687 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
508 !(dev->dev->bus_sprom->boardflags_hi & B43_BFH_FEM_BT)) 688 if (sprom->boardflags_lo & B43_BFL_EXTLNA)
689 b43_phy_lcn_load_tx_gain_tab(dev,
690 b43_lcntab_tx_gain_tbl_2ghz_ext_pa_rev0);
691 else
692 b43err(dev->wl,
693 "TX gain table unknown for this card\n");
694 }
695
696 if (sprom->boardflags_lo & B43_BFL_FEM &&
697 !(sprom->boardflags_hi & B43_BFH_FEM_BT))
509 b43_lcntab_write_bulk(dev, B43_LCNTAB16(0xf, 0), 698 b43_lcntab_write_bulk(dev, B43_LCNTAB16(0xf, 0),
510 ARRAY_SIZE(b43_lcntab_sw_ctl_4313_epa_rev0), 699 ARRAY_SIZE(b43_lcntab_sw_ctl_4313_epa_rev0),
511 b43_lcntab_sw_ctl_4313_epa_rev0); 700 b43_lcntab_sw_ctl_4313_epa_rev0);
diff --git a/drivers/net/wireless/b43/tables_phy_lcn.h b/drivers/net/wireless/b43/tables_phy_lcn.h
index b6471e89c36..caff9db6831 100644
--- a/drivers/net/wireless/b43/tables_phy_lcn.h
+++ b/drivers/net/wireless/b43/tables_phy_lcn.h
@@ -10,6 +10,8 @@
10#define B43_LCNTAB16(table, offset) (((table) << 10) | (offset) | B43_LCNTAB_16BIT) 10#define B43_LCNTAB16(table, offset) (((table) << 10) | (offset) | B43_LCNTAB_16BIT)
11#define B43_LCNTAB32(table, offset) (((table) << 10) | (offset) | B43_LCNTAB_32BIT) 11#define B43_LCNTAB32(table, offset) (((table) << 10) | (offset) | B43_LCNTAB_32BIT)
12 12
13#define B43_LCNTAB_TX_GAIN_SIZE 128
14
13u32 b43_lcntab_read(struct b43_wldev *dev, u32 offset); 15u32 b43_lcntab_read(struct b43_wldev *dev, u32 offset);
14void b43_lcntab_read_bulk(struct b43_wldev *dev, u32 offset, 16void b43_lcntab_read_bulk(struct b43_wldev *dev, u32 offset,
15 unsigned int nr_elements, void *_data); 17 unsigned int nr_elements, void *_data);