aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/b43/phy_n.c
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2010-01-15 07:27:29 -0500
committerJohn W. Linville <linville@tuxdriver.com>2010-01-15 17:05:33 -0500
commit0988a7a1a98300e90a6613b33738e07cdf8ce786 (patch)
tree07ccaa2ec2da58ff4e777032d391865cc1620dad /drivers/net/wireless/b43/phy_n.c
parent088e56b44a52bbd58a790627148cf75ed71ae34b (diff)
b43: N-PHY: update init code to match current specs
Previous init path was based on old specs from old driver. Update it as much as possible leaving some TODOs for not implemented functions. 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/phy_n.c')
-rw-r--r--drivers/net/wireless/b43/phy_n.c201
1 files changed, 161 insertions, 40 deletions
diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index cb784a2504a6..c16c98538f65 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -419,75 +419,196 @@ static void b43_nphy_rssi_cal(struct b43_wldev *dev, u8 type)
419 //TODO 419 //TODO
420} 420}
421 421
422/*
423 * Init N-PHY
424 * http://bcm-v4.sipsolutions.net/802.11/PHY/Init/N
425 */
422int b43_phy_initn(struct b43_wldev *dev) 426int b43_phy_initn(struct b43_wldev *dev)
423{ 427{
428 struct ssb_bus *bus = dev->dev->bus;
424 struct b43_phy *phy = &dev->phy; 429 struct b43_phy *phy = &dev->phy;
430 struct b43_phy_n *nphy = phy->n;
431 u8 tx_pwr_state;
432 struct nphy_txgains target;
425 u16 tmp; 433 u16 tmp;
434 enum ieee80211_band tmp2;
435 bool do_rssi_cal;
436
437 u16 clip[2];
438 bool do_cal = false;
426 439
427 //TODO: Spectral management 440 if ((dev->phy.rev >= 3) &&
441 (bus->sprom.boardflags_lo & B43_BFL_EXTLNA) &&
442 (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)) {
443 chipco_set32(&dev->dev->bus->chipco, SSB_CHIPCO_CHIPCTL, 0x40);
444 }
445 nphy->deaf_count = 0;
428 b43_nphy_tables_init(dev); 446 b43_nphy_tables_init(dev);
447 nphy->crsminpwr_adjusted = false;
448 nphy->noisevars_adjusted = false;
429 449
430 /* Clear all overrides */ 450 /* Clear all overrides */
431 b43_phy_write(dev, B43_NPHY_RFCTL_OVER, 0); 451 if (dev->phy.rev >= 3) {
452 b43_phy_write(dev, B43_NPHY_TXF_40CO_B1S1, 0);
453 b43_phy_write(dev, B43_NPHY_RFCTL_OVER, 0);
454 b43_phy_write(dev, B43_NPHY_TXF_40CO_B1S0, 0);
455 b43_phy_write(dev, B43_NPHY_TXF_40CO_B32S1, 0);
456 } else {
457 b43_phy_write(dev, B43_NPHY_RFCTL_OVER, 0);
458 }
432 b43_phy_write(dev, B43_NPHY_RFCTL_INTC1, 0); 459 b43_phy_write(dev, B43_NPHY_RFCTL_INTC1, 0);
433 b43_phy_write(dev, B43_NPHY_RFCTL_INTC2, 0); 460 b43_phy_write(dev, B43_NPHY_RFCTL_INTC2, 0);
434 b43_phy_write(dev, B43_NPHY_RFCTL_INTC3, 0); 461 if (dev->phy.rev < 6) {
435 b43_phy_write(dev, B43_NPHY_RFCTL_INTC4, 0); 462 b43_phy_write(dev, B43_NPHY_RFCTL_INTC3, 0);
463 b43_phy_write(dev, B43_NPHY_RFCTL_INTC4, 0);
464 }
436 b43_phy_mask(dev, B43_NPHY_RFSEQMODE, 465 b43_phy_mask(dev, B43_NPHY_RFSEQMODE,
437 ~(B43_NPHY_RFSEQMODE_CAOVER | 466 ~(B43_NPHY_RFSEQMODE_CAOVER |
438 B43_NPHY_RFSEQMODE_TROVER)); 467 B43_NPHY_RFSEQMODE_TROVER));
468 if (dev->phy.rev >= 3)
469 b43_phy_write(dev, B43_NPHY_AFECTL_OVER1, 0);
439 b43_phy_write(dev, B43_NPHY_AFECTL_OVER, 0); 470 b43_phy_write(dev, B43_NPHY_AFECTL_OVER, 0);
440 471
441 tmp = (phy->rev < 2) ? 64 : 59; 472 if (dev->phy.rev <= 2) {
442 b43_phy_maskset(dev, B43_NPHY_BPHY_CTL3, 473 tmp = (dev->phy.rev == 2) ? 0x3B : 0x40;
443 ~B43_NPHY_BPHY_CTL3_SCALE, 474 b43_phy_maskset(dev, B43_NPHY_BPHY_CTL3,
444 tmp << B43_NPHY_BPHY_CTL3_SCALE_SHIFT); 475 ~B43_NPHY_BPHY_CTL3_SCALE,
445 476 tmp << B43_NPHY_BPHY_CTL3_SCALE_SHIFT);
477 }
446 b43_phy_write(dev, B43_NPHY_AFESEQ_TX2RX_PUD_20M, 0x20); 478 b43_phy_write(dev, B43_NPHY_AFESEQ_TX2RX_PUD_20M, 0x20);
447 b43_phy_write(dev, B43_NPHY_AFESEQ_TX2RX_PUD_40M, 0x20); 479 b43_phy_write(dev, B43_NPHY_AFESEQ_TX2RX_PUD_40M, 0x20);
448 480
449 b43_phy_write(dev, B43_NPHY_TXREALFD, 184); 481 if (bus->sprom.boardflags2_lo & 0x100 ||
450 b43_phy_write(dev, B43_NPHY_MIMO_CRSTXEXT, 200); 482 (bus->boardinfo.vendor == PCI_VENDOR_ID_APPLE &&
451 b43_phy_write(dev, B43_NPHY_PLOAD_CSENSE_EXTLEN, 80); 483 bus->boardinfo.type == 0x8B))
452 b43_phy_write(dev, B43_NPHY_C2_BCLIPBKOFF, 511); 484 b43_phy_write(dev, B43_NPHY_TXREALFD, 0xA0);
485 else
486 b43_phy_write(dev, B43_NPHY_TXREALFD, 0xB8);
487 b43_phy_write(dev, B43_NPHY_MIMO_CRSTXEXT, 0xC8);
488 b43_phy_write(dev, B43_NPHY_PLOAD_CSENSE_EXTLEN, 0x50);
489 b43_phy_write(dev, B43_NPHY_TXRIFS_FRDEL, 0x30);
453 490
454 //TODO MIMO-Config 491 /* TODO MIMO-Config */
455 //TODO Update TX/RX chain 492 /* TODO Update TX/RX chain */
456 493
457 if (phy->rev < 2) { 494 if (phy->rev < 2) {
458 b43_phy_write(dev, B43_NPHY_DUP40_GFBL, 0xAA8); 495 b43_phy_write(dev, B43_NPHY_DUP40_GFBL, 0xAA8);
459 b43_phy_write(dev, B43_NPHY_DUP40_BL, 0x9A4); 496 b43_phy_write(dev, B43_NPHY_DUP40_BL, 0x9A4);
460 } 497 }
498
499 tmp2 = b43_current_band(dev->wl);
500 if ((nphy->ipa2g_on && tmp2 == IEEE80211_BAND_2GHZ) ||
501 (nphy->ipa5g_on && tmp2 == IEEE80211_BAND_5GHZ)) {
502 b43_phy_set(dev, B43_NPHY_PAPD_EN0, 0x1);
503 b43_phy_maskset(dev, B43_NPHY_EPS_TABLE_ADJ0, 0x007F,
504 nphy->papd_epsilon_offset[0] << 7);
505 b43_phy_set(dev, B43_NPHY_PAPD_EN1, 0x1);
506 b43_phy_maskset(dev, B43_NPHY_EPS_TABLE_ADJ1, 0x007F,
507 nphy->papd_epsilon_offset[1] << 7);
508 /* TODO N PHY IPA Set TX Dig Filters */
509 } else if (phy->rev >= 5) {
510 /* TODO N PHY Ext PA Set TX Dig Filters */
511 }
512
461 b43_nphy_workarounds(dev); 513 b43_nphy_workarounds(dev);
462 b43_nphy_reset_cca(dev);
463 514
464 ssb_write32(dev->dev, SSB_TMSLOW, 515 /* Reset CCA, in init code it differs a little from standard way */
465 ssb_read32(dev->dev, SSB_TMSLOW) | B43_TMSLOW_MACPHYCLKEN); 516 /* b43_nphy_bmac_clock_fgc(dev, 1); */
517 tmp = b43_phy_read(dev, B43_NPHY_BBCFG);
518 b43_phy_write(dev, B43_NPHY_BBCFG, tmp | B43_NPHY_BBCFG_RSTCCA);
519 b43_phy_write(dev, B43_NPHY_BBCFG, tmp & ~B43_NPHY_BBCFG_RSTCCA);
520 /* b43_nphy_bmac_clock_fgc(dev, 0); */
521
522 /* TODO N PHY MAC PHY Clock Set with argument 1 */
523
524 /* b43_nphy_pa_override(dev, false); */
466 b43_nphy_force_rf_sequence(dev, B43_RFSEQ_RX2TX); 525 b43_nphy_force_rf_sequence(dev, B43_RFSEQ_RX2TX);
467 b43_nphy_force_rf_sequence(dev, B43_RFSEQ_RESET2RX); 526 b43_nphy_force_rf_sequence(dev, B43_RFSEQ_RESET2RX);
527 /* b43_nphy_pa_override(dev, true); */
528
529 /* b43_nphy_classifier(dev, 0, 0); */
530 /* b43_nphy_read_clip_detection(dev, clip); */
531 tx_pwr_state = nphy->txpwrctrl;
532 /* TODO N PHY TX power control with argument 0
533 (turning off power control) */
534 /* TODO Fix the TX Power Settings */
535 /* TODO N PHY TX Power Control Idle TSSI */
536 /* TODO N PHY TX Power Control Setup */
537
538 if (phy->rev >= 3) {
539 /* TODO */
540 } else {
541 /* TODO Write an N PHY table with ID 26, length 128, offset 192, width 32, and the data from Rev 2 TX Power Control Table */
542 /* TODO Write an N PHY table with ID 27, length 128, offset 192, width 32, and the data from Rev 2 TX Power Control Table */
543 }
468 544
469 b43_phy_read(dev, B43_NPHY_CLASSCTL); /* dummy read */ 545 if (nphy->phyrxchain != 3)
470 //TODO read core1/2 clip1 thres regs 546 ;/* TODO N PHY RX Core Set State with phyrxchain as argument */
471 547 if (nphy->mphase_cal_phase_id > 0)
472 if (1 /* FIXME Band is 2.4GHz */) 548 ;/* TODO PHY Periodic Calibration Multi-Phase Restart */
473 b43_nphy_bphy_init(dev); 549
474 //TODO disable TX power control 550 do_rssi_cal = false;
475 //TODO Fix the TX power settings 551 if (phy->rev >= 3) {
476 //TODO Init periodic calibration with reason 3 552 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
477 b43_nphy_rssi_cal(dev, 2); 553 do_rssi_cal = (nphy->rssical_chanspec_2G == 0);
478 b43_nphy_rssi_cal(dev, 0); 554 else
479 b43_nphy_rssi_cal(dev, 1); 555 do_rssi_cal = (nphy->rssical_chanspec_5G == 0);
480 //TODO get TX gain 556
481 //TODO init superswitch 557 if (do_rssi_cal)
482 //TODO calibrate LO 558 ;/* b43_nphy_rssi_cal(dev); */
483 //TODO idle TSSI TX pctl 559 else
484 //TODO TX power control power setup 560 ;/* b43_nphy_restore_rssi_cal(dev); */
485 //TODO table writes 561 } else {
486 //TODO TX power control coefficients 562 /* b43_nphy_rssi_cal(dev); */
487 //TODO enable TX power control 563 }
488 //TODO control antenna selection 564
489 //TODO init radar detection 565 if (!((nphy->measure_hold & 0x6) != 0)) {
490 //TODO reset channel if changed 566 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
567 do_cal = (nphy->iqcal_chanspec_2G == 0);
568 else
569 do_cal = (nphy->iqcal_chanspec_5G == 0);
570
571 if (nphy->mute)
572 do_cal = false;
573
574 if (do_cal) {
575 /* target = b43_nphy_get_tx_gains(dev); */
576
577 if (nphy->antsel_type == 2)
578 ;/*TODO NPHY Superswitch Init with argument 1*/
579 if (nphy->perical != 2) {
580 /* b43_nphy_rssi_cal(dev); */
581 if (phy->rev >= 3) {
582 nphy->cal_orig_pwr_idx[0] =
583 nphy->txpwrindex[0].index_internal;
584 nphy->cal_orig_pwr_idx[1] =
585 nphy->txpwrindex[1].index_internal;
586 /* TODO N PHY Pre Calibrate TX Gain */
587 /*target = b43_nphy_get_tx_gains(dev)*/
588 }
589 }
590 }
591 }
592
593 /*
594 if (!b43_nphy_cal_tx_iq_lo(dev, target, true, false)) {
595 if (b43_nphy_cal_rx_iq(dev, target, 2, 0) == 0)
596 Call N PHY Save Cal
597 else if (nphy->mphase_cal_phase_id == 0)
598 N PHY Periodic Calibration with argument 3
599 } else {
600 b43_nphy_restore_cal(dev);
601 }
602 */
603
604 /* b43_nphy_tx_pwr_ctrl_coef_setup(dev); */
605 /* TODO N PHY TX Power Control Enable with argument tx_pwr_state */
606 b43_phy_write(dev, B43_NPHY_TXMACIF_HOLDOFF, 0x0015);
607 b43_phy_write(dev, B43_NPHY_TXMACDELAY, 0x0320);
608 if (phy->rev >= 3 && phy->rev <= 6)
609 b43_phy_write(dev, B43_NPHY_PLOAD_CSENSE_EXTLEN, 0x0014);
610 /* b43_nphy_tx_lp_fbw(dev); */
611 /* TODO N PHY Spur Workaround */
491 612
492 b43err(dev->wl, "IEEE 802.11n devices are not supported, yet.\n"); 613 b43err(dev->wl, "IEEE 802.11n devices are not supported, yet.\n");
493 return 0; 614 return 0;