diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2010-01-15 08:38:32 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-01-15 17:05:35 -0500 |
commit | 3c95627d404e1094313f2dcb87424e2ae462e814 (patch) | |
tree | 8a3c3b37a9c87821a1e5a2cecde7b0c524659e2d | |
parent | bbec398c1b7baa1dbde1e49446d1cbf4c6c20fa1 (diff) |
b43: N-PHY: implement RSSI selection and offset scaling
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/b43/phy_n.c | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c index 72b1c410b7ff..494c95246954 100644 --- a/drivers/net/wireless/b43/phy_n.c +++ b/drivers/net/wireless/b43/phy_n.c | |||
@@ -465,6 +465,127 @@ static void b43_nphy_bphy_init(struct b43_wldev *dev) | |||
465 | b43_phy_write(dev, B43_PHY_N_BMODE(0x38), 0x668); | 465 | b43_phy_write(dev, B43_PHY_N_BMODE(0x38), 0x668); |
466 | } | 466 | } |
467 | 467 | ||
468 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/ScaleOffsetRssi */ | ||
469 | static void b43_nphy_scale_offset_rssi(struct b43_wldev *dev, u16 scale, | ||
470 | s8 offset, u8 core, u8 rail, u8 type) | ||
471 | { | ||
472 | u16 tmp; | ||
473 | bool core1or5 = (core == 1) || (core == 5); | ||
474 | bool core2or5 = (core == 2) || (core == 5); | ||
475 | |||
476 | offset = clamp_val(offset, -32, 31); | ||
477 | tmp = ((scale & 0x3F) << 8) | (offset & 0x3F); | ||
478 | |||
479 | if (core1or5 && (rail == 0) && (type == 2)) | ||
480 | b43_phy_write(dev, B43_NPHY_RSSIMC_0I_RSSI_Z, tmp); | ||
481 | if (core1or5 && (rail == 1) && (type == 2)) | ||
482 | b43_phy_write(dev, B43_NPHY_RSSIMC_0Q_RSSI_Z, tmp); | ||
483 | if (core2or5 && (rail == 0) && (type == 2)) | ||
484 | b43_phy_write(dev, B43_NPHY_RSSIMC_1I_RSSI_Z, tmp); | ||
485 | if (core2or5 && (rail == 1) && (type == 2)) | ||
486 | b43_phy_write(dev, B43_NPHY_RSSIMC_1Q_RSSI_Z, tmp); | ||
487 | if (core1or5 && (rail == 0) && (type == 0)) | ||
488 | b43_phy_write(dev, B43_NPHY_RSSIMC_0I_RSSI_X, tmp); | ||
489 | if (core1or5 && (rail == 1) && (type == 0)) | ||
490 | b43_phy_write(dev, B43_NPHY_RSSIMC_0Q_RSSI_X, tmp); | ||
491 | if (core2or5 && (rail == 0) && (type == 0)) | ||
492 | b43_phy_write(dev, B43_NPHY_RSSIMC_1I_RSSI_X, tmp); | ||
493 | if (core2or5 && (rail == 1) && (type == 0)) | ||
494 | b43_phy_write(dev, B43_NPHY_RSSIMC_1Q_RSSI_X, tmp); | ||
495 | if (core1or5 && (rail == 0) && (type == 1)) | ||
496 | b43_phy_write(dev, B43_NPHY_RSSIMC_0I_RSSI_Y, tmp); | ||
497 | if (core1or5 && (rail == 1) && (type == 1)) | ||
498 | b43_phy_write(dev, B43_NPHY_RSSIMC_0Q_RSSI_Y, tmp); | ||
499 | if (core2or5 && (rail == 0) && (type == 1)) | ||
500 | b43_phy_write(dev, B43_NPHY_RSSIMC_1I_RSSI_Y, tmp); | ||
501 | if (core2or5 && (rail == 1) && (type == 1)) | ||
502 | b43_phy_write(dev, B43_NPHY_RSSIMC_1Q_RSSI_Y, tmp); | ||
503 | if (core1or5 && (rail == 0) && (type == 6)) | ||
504 | b43_phy_write(dev, B43_NPHY_RSSIMC_0I_TBD, tmp); | ||
505 | if (core1or5 && (rail == 1) && (type == 6)) | ||
506 | b43_phy_write(dev, B43_NPHY_RSSIMC_0Q_TBD, tmp); | ||
507 | if (core2or5 && (rail == 0) && (type == 6)) | ||
508 | b43_phy_write(dev, B43_NPHY_RSSIMC_1I_TBD, tmp); | ||
509 | if (core2or5 && (rail == 1) && (type == 6)) | ||
510 | b43_phy_write(dev, B43_NPHY_RSSIMC_1Q_TBD, tmp); | ||
511 | if (core1or5 && (rail == 0) && (type == 3)) | ||
512 | b43_phy_write(dev, B43_NPHY_RSSIMC_0I_PWRDET, tmp); | ||
513 | if (core1or5 && (rail == 1) && (type == 3)) | ||
514 | b43_phy_write(dev, B43_NPHY_RSSIMC_0Q_PWRDET, tmp); | ||
515 | if (core2or5 && (rail == 0) && (type == 3)) | ||
516 | b43_phy_write(dev, B43_NPHY_RSSIMC_1I_PWRDET, tmp); | ||
517 | if (core2or5 && (rail == 1) && (type == 3)) | ||
518 | b43_phy_write(dev, B43_NPHY_RSSIMC_1Q_PWRDET, tmp); | ||
519 | if (core1or5 && (type == 4)) | ||
520 | b43_phy_write(dev, B43_NPHY_RSSIMC_0I_TSSI, tmp); | ||
521 | if (core2or5 && (type == 4)) | ||
522 | b43_phy_write(dev, B43_NPHY_RSSIMC_1I_TSSI, tmp); | ||
523 | if (core1or5 && (type == 5)) | ||
524 | b43_phy_write(dev, B43_NPHY_RSSIMC_0Q_TSSI, tmp); | ||
525 | if (core2or5 && (type == 5)) | ||
526 | b43_phy_write(dev, B43_NPHY_RSSIMC_1Q_TSSI, tmp); | ||
527 | } | ||
528 | |||
529 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSISel */ | ||
530 | static void b43_nphy_rssi_select(struct b43_wldev *dev, u8 code, u8 type) | ||
531 | { | ||
532 | u16 val; | ||
533 | |||
534 | if (dev->phy.rev >= 3) { | ||
535 | /* TODO */ | ||
536 | } else { | ||
537 | if (type < 3) | ||
538 | val = 0; | ||
539 | else if (type == 6) | ||
540 | val = 1; | ||
541 | else if (type == 3) | ||
542 | val = 2; | ||
543 | else | ||
544 | val = 3; | ||
545 | |||
546 | val = (val << 12) | (val << 14); | ||
547 | b43_phy_maskset(dev, B43_NPHY_AFECTL_C1, 0x0FFF, val); | ||
548 | b43_phy_maskset(dev, B43_NPHY_AFECTL_C2, 0x0FFF, val); | ||
549 | |||
550 | if (type < 3) { | ||
551 | b43_phy_maskset(dev, B43_NPHY_RFCTL_RSSIO1, 0xFFCF, | ||
552 | (type + 1) << 4); | ||
553 | b43_phy_maskset(dev, B43_NPHY_RFCTL_RSSIO2, 0xFFCF, | ||
554 | (type + 1) << 4); | ||
555 | } | ||
556 | |||
557 | /* TODO use some definitions */ | ||
558 | if (code == 0) { | ||
559 | b43_phy_maskset(dev, B43_NPHY_AFECTL_OVER, 0xCFFF, 0); | ||
560 | if (type < 3) { | ||
561 | b43_phy_maskset(dev, B43_NPHY_RFCTL_CMD, | ||
562 | 0xFEC7, 0); | ||
563 | b43_phy_maskset(dev, B43_NPHY_RFCTL_OVER, | ||
564 | 0xEFDC, 0); | ||
565 | b43_phy_maskset(dev, B43_NPHY_RFCTL_CMD, | ||
566 | 0xFFFE, 0); | ||
567 | udelay(20); | ||
568 | b43_phy_maskset(dev, B43_NPHY_RFCTL_OVER, | ||
569 | 0xFFFE, 0); | ||
570 | } | ||
571 | } else { | ||
572 | b43_phy_maskset(dev, B43_NPHY_AFECTL_OVER, 0xCFFF, | ||
573 | 0x3000); | ||
574 | if (type < 3) { | ||
575 | b43_phy_maskset(dev, B43_NPHY_RFCTL_CMD, | ||
576 | 0xFEC7, 0x0180); | ||
577 | b43_phy_maskset(dev, B43_NPHY_RFCTL_OVER, | ||
578 | 0xEFDC, (code << 1 | 0x1021)); | ||
579 | b43_phy_maskset(dev, B43_NPHY_RFCTL_CMD, | ||
580 | 0xFFFE, 0x0001); | ||
581 | udelay(20); | ||
582 | b43_phy_maskset(dev, B43_NPHY_RFCTL_OVER, | ||
583 | 0xFFFE, 0); | ||
584 | } | ||
585 | } | ||
586 | } | ||
587 | } | ||
588 | |||
468 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICal */ | 589 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICal */ |
469 | static void b43_nphy_rev2_rssi_cal(struct b43_wldev *dev, u8 type) | 590 | static void b43_nphy_rev2_rssi_cal(struct b43_wldev *dev, u8 type) |
470 | { | 591 | { |