aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorMichael Buesch <mbuesch@freenet.de>2006-03-19 18:01:04 -0500
committerJohn W. Linville <linville@tuxdriver.com>2006-03-27 11:19:42 -0500
commit6ecb26904c9db15ca964d60b9483f19dc51bda5b (patch)
tree933fd9814eac05e1975735517942dfd5c5b2e412 /drivers/net
parent0ac59daee5f7fbaab25784a643edede669b5419e (diff)
[PATCH] bcm43xx: set default attenuation values.
Signed-off-by: Michael Buesch <mbuesch@freenet.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx.h21
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_main.c9
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_phy.c30
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_radio.c131
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_radio.h5
5 files changed, 158 insertions, 38 deletions
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx.h b/drivers/net/wireless/bcm43xx/bcm43xx.h
index 8820012b4b3a..1fca1f9c48fe 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx.h
@@ -507,14 +507,23 @@ struct bcm43xx_radioinfo {
507 u16 version; 507 u16 version;
508 u8 revision; 508 u8 revision;
509 509
510 /* 0: baseband attenuation,
511 * 1: radio attenuation,
512 * 2: tx_CTL1
513 * 3: tx_CTL2
514 */
515 u16 txpower[4];
516 /* Desired TX power in dBm Q5.2 */ 510 /* Desired TX power in dBm Q5.2 */
517 u16 txpower_desired; 511 u16 txpower_desired;
512 /* TX Power control values. */
513 union {
514 /* B/G PHY */
515 struct {
516 u16 baseband_atten;
517 u16 radio_atten;
518 u16 txctl1;
519 u16 txctl2;
520 };
521 /* A PHY */
522 struct {
523 u16 txpwr_offset;
524 };
525 };
526
518 /* Current Interference Mitigation mode */ 527 /* Current Interference Mitigation mode */
519 int interfmode; 528 int interfmode;
520 /* Stack of saved values from the Interference Mitigation code */ 529 /* Stack of saved values from the Interference Mitigation code */
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
index 12c93d274ae5..e680d2acc44b 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
@@ -560,12 +560,9 @@ static int bcm43xx_read_radioinfo(struct bcm43xx_private *bcm)
560 radio->revision = revision; 560 radio->revision = revision;
561 561
562 /* Set default attenuation values. */ 562 /* Set default attenuation values. */
563 radio->txpower[0] = 2; 563 radio->baseband_atten = bcm43xx_default_baseband_attenuation(bcm);
564 radio->txpower[1] = 2; 564 radio->radio_atten = bcm43xx_default_radio_attenuation(bcm);
565 if (revision == 1) 565 radio->txctl1 = bcm43xx_default_txctl1(bcm);
566 radio->txpower[2] = 3;
567 else
568 radio->txpower[2] = 0;
569 if (phy->type == BCM43xx_PHYTYPE_A) 566 if (phy->type == BCM43xx_PHYTYPE_A)
570 radio->txpower_desired = bcm->sprom.maxpower_aphy; 567 radio->txpower_desired = bcm->sprom.maxpower_aphy;
571 else 568 else
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_phy.c b/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
index 1ce9a4599903..054c64e462fb 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
@@ -220,9 +220,9 @@ static void bcm43xx_phy_init_pctl(struct bcm43xx_private *bcm)
220 bcm43xx_radio_write16(bcm, 0x0076, 220 bcm43xx_radio_write16(bcm, 0x0076,
221 bcm43xx_radio_read16(bcm, 0x0076) | 0x0084); 221 bcm43xx_radio_read16(bcm, 0x0076) | 0x0084);
222 } else { 222 } else {
223 saved_batt = radio->txpower[0]; 223 saved_batt = radio->baseband_atten;
224 saved_ratt = radio->txpower[1]; 224 saved_ratt = radio->radio_atten;
225 saved_txctl1 = radio->txpower[2]; 225 saved_txctl1 = radio->txctl1;
226 if ((radio->revision >= 6) && (radio->revision <= 8) 226 if ((radio->revision >= 6) && (radio->revision <= 8)
227 && /*FIXME: incomplete specs for 5 < revision < 9 */ 0) 227 && /*FIXME: incomplete specs for 5 < revision < 9 */ 0)
228 bcm43xx_radio_set_txpower_bg(bcm, 0xB, 0x1F, 0); 228 bcm43xx_radio_set_txpower_bg(bcm, 0xB, 0x1F, 0);
@@ -1039,7 +1039,7 @@ static void bcm43xx_phy_initg(struct bcm43xx_private *bcm)
1039 bcm43xx_radio_write16(bcm, 0x0078, radio->initval); 1039 bcm43xx_radio_write16(bcm, 0x0078, radio->initval);
1040 bcm43xx_radio_write16(bcm, 0x0052, 1040 bcm43xx_radio_write16(bcm, 0x0052,
1041 (bcm43xx_radio_read16(bcm, 0x0052) & 0xFFF0) 1041 (bcm43xx_radio_read16(bcm, 0x0052) & 0xFFF0)
1042 | radio->txpower[3]); 1042 | radio->txctl2);
1043 } 1043 }
1044 1044
1045 if (phy->connected) { 1045 if (phy->connected) {
@@ -1259,7 +1259,6 @@ struct bcm43xx_lopair * bcm43xx_find_lopair(struct bcm43xx_private *bcm,
1259 if (baseband_attenuation > 6) 1259 if (baseband_attenuation > 6)
1260 baseband_attenuation = 6; 1260 baseband_attenuation = 6;
1261 assert(radio_attenuation < 10); 1261 assert(radio_attenuation < 10);
1262 assert(tx == 0 || tx == 3);
1263 1262
1264 if (tx == 3) { 1263 if (tx == 3) {
1265 return bcm43xx_get_lopair(phy, 1264 return bcm43xx_get_lopair(phy,
@@ -1275,9 +1274,9 @@ struct bcm43xx_lopair * bcm43xx_current_lopair(struct bcm43xx_private *bcm)
1275 struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm); 1274 struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
1276 1275
1277 return bcm43xx_find_lopair(bcm, 1276 return bcm43xx_find_lopair(bcm,
1278 radio->txpower[0], 1277 radio->baseband_atten,
1279 radio->txpower[1], 1278 radio->radio_atten,
1280 radio->txpower[2]); 1279 radio->txctl1);
1281} 1280}
1282 1281
1283/* Adjust B/G LO */ 1282/* Adjust B/G LO */
@@ -1311,7 +1310,7 @@ static void bcm43xx_phy_lo_g_measure_txctl2(struct bcm43xx_private *bcm)
1311 txctl2 = i; 1310 txctl2 = i;
1312 } 1311 }
1313 } 1312 }
1314 radio->txpower[3] = txctl2; 1313 radio->txctl2 = txctl2;
1315} 1314}
1316 1315
1317static 1316static
@@ -1530,8 +1529,7 @@ void bcm43xx_phy_lo_g_measure(struct bcm43xx_private *bcm)
1530 r31 = 0; 1529 r31 = 0;
1531 } 1530 }
1532 bcm43xx_radio_write16(bcm, 0x43, i); 1531 bcm43xx_radio_write16(bcm, 0x43, i);
1533 bcm43xx_radio_write16(bcm, 0x52, 1532 bcm43xx_radio_write16(bcm, 0x52, radio->txctl2);
1534 radio->txpower[3]);
1535 udelay(10); 1533 udelay(10);
1536 1534
1537 bcm43xx_phy_set_baseband_attenuation(bcm, j * 2); 1535 bcm43xx_phy_set_baseband_attenuation(bcm, j * 2);
@@ -1573,7 +1571,7 @@ void bcm43xx_phy_lo_g_measure(struct bcm43xx_private *bcm)
1573 } 1571 }
1574 bcm43xx_radio_write16(bcm, 0x43, i - 9); 1572 bcm43xx_radio_write16(bcm, 0x43, i - 9);
1575 bcm43xx_radio_write16(bcm, 0x52, 1573 bcm43xx_radio_write16(bcm, 0x52,
1576 radio->txpower[3] 1574 radio->txctl2
1577 | (3/*txctl1*/ << 4));//FIXME: shouldn't txctl1 be zero here and 3 in the loop above? 1575 | (3/*txctl1*/ << 4));//FIXME: shouldn't txctl1 be zero here and 3 in the loop above?
1578 udelay(10); 1576 udelay(10);
1579 1577
@@ -1780,9 +1778,9 @@ void bcm43xx_phy_xmitpower(struct bcm43xx_private *bcm)
1780 } 1778 }
1781 1779
1782 /* Calculate the new attenuation values. */ 1780 /* Calculate the new attenuation values. */
1783 baseband_attenuation = radio->txpower[0]; 1781 baseband_attenuation = radio->baseband_atten;
1784 baseband_attenuation += baseband_att_delta; 1782 baseband_attenuation += baseband_att_delta;
1785 radio_attenuation = radio->txpower[1]; 1783 radio_attenuation = radio->radio_atten;
1786 radio_attenuation += radio_att_delta; 1784 radio_attenuation += radio_att_delta;
1787 1785
1788 /* Get baseband and radio attenuation values into their permitted ranges. 1786 /* Get baseband and radio attenuation values into their permitted ranges.
@@ -1807,7 +1805,7 @@ void bcm43xx_phy_xmitpower(struct bcm43xx_private *bcm)
1807 } 1805 }
1808 baseband_attenuation = limit_value(baseband_attenuation, 0, 11); 1806 baseband_attenuation = limit_value(baseband_attenuation, 0, 11);
1809 1807
1810 txpower = radio->txpower[2]; 1808 txpower = radio->txctl1;
1811 if ((radio->version == 0x2050) && (radio->revision == 2)) { 1809 if ((radio->version == 0x2050) && (radio->revision == 2)) {
1812 if (radio_attenuation <= 1) { 1810 if (radio_attenuation <= 1) {
1813 if (txpower == 0) { 1811 if (txpower == 0) {
@@ -1829,7 +1827,7 @@ void bcm43xx_phy_xmitpower(struct bcm43xx_private *bcm)
1829 } 1827 }
1830 } 1828 }
1831 } 1829 }
1832 radio->txpower[2] = txpower; 1830 radio->txctl1 = txpower;
1833 baseband_attenuation = limit_value(baseband_attenuation, 0, 11); 1831 baseband_attenuation = limit_value(baseband_attenuation, 0, 11);
1834 radio_attenuation = limit_value(radio_attenuation, 0, 9); 1832 radio_attenuation = limit_value(radio_attenuation, 0, 9);
1835 1833
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_radio.c b/drivers/net/wireless/bcm43xx/bcm43xx_radio.c
index cac604bc0955..4e8d8c936ab4 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_radio.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_radio.c
@@ -1652,7 +1652,7 @@ void bcm43xx_radio_set_txpower_a(struct bcm43xx_private *bcm, u16 txpower)
1652 1652
1653 bcm43xx_ilt_write(bcm, 0x3001, dac); 1653 bcm43xx_ilt_write(bcm, 0x3001, dac);
1654 1654
1655 radio->txpower[0] = txpower; 1655 radio->txpwr_offset = txpower;
1656 1656
1657 TODO(); 1657 TODO();
1658 //TODO: FuncPlaceholder (Adjust BB loft cancel) 1658 //TODO: FuncPlaceholder (Adjust BB loft cancel)
@@ -1666,17 +1666,14 @@ void bcm43xx_radio_set_txpower_bg(struct bcm43xx_private *bcm,
1666 struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm); 1666 struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
1667 1667
1668 if (baseband_attenuation == 0xFFFF) 1668 if (baseband_attenuation == 0xFFFF)
1669 baseband_attenuation = radio->txpower[0]; 1669 baseband_attenuation = radio->baseband_atten;
1670 else
1671 radio->txpower[0] = baseband_attenuation;
1672 if (radio_attenuation == 0xFFFF) 1670 if (radio_attenuation == 0xFFFF)
1673 radio_attenuation = radio->txpower[1]; 1671 radio_attenuation = radio->radio_atten;
1674 else
1675 radio->txpower[1] = radio_attenuation;
1676 if (txpower == 0xFFFF) 1672 if (txpower == 0xFFFF)
1677 txpower = radio->txpower[2]; 1673 txpower = radio->txctl1;
1678 else 1674 radio->baseband_atten = baseband_attenuation;
1679 radio->txpower[2] = txpower; 1675 radio->radio_atten = radio_attenuation;
1676 radio->txctl1 = txpower;
1680 1677
1681 assert(/*baseband_attenuation >= 0 &&*/ baseband_attenuation <= 11); 1678 assert(/*baseband_attenuation >= 0 &&*/ baseband_attenuation <= 11);
1682 if (radio->revision < 6) 1679 if (radio->revision < 6)
@@ -1693,10 +1690,124 @@ void bcm43xx_radio_set_txpower_bg(struct bcm43xx_private *bcm,
1693 (bcm43xx_radio_read16(bcm, 0x0052) & ~0x0070) 1690 (bcm43xx_radio_read16(bcm, 0x0052) & ~0x0070)
1694 | ((txpower << 4) & 0x0070)); 1691 | ((txpower << 4) & 0x0070));
1695 } 1692 }
1693 //FIXME: The spec is very weird and unclear here.
1696 if (phy->type == BCM43xx_PHYTYPE_G) 1694 if (phy->type == BCM43xx_PHYTYPE_G)
1697 bcm43xx_phy_lo_adjust(bcm, 0); 1695 bcm43xx_phy_lo_adjust(bcm, 0);
1698} 1696}
1699 1697
1698u16 bcm43xx_default_baseband_attenuation(struct bcm43xx_private *bcm)
1699{
1700 struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
1701
1702 if (radio->version == 0x2050 && radio->revision < 6)
1703 return 0;
1704 return 2;
1705}
1706
1707u16 bcm43xx_default_radio_attenuation(struct bcm43xx_private *bcm)
1708{
1709 struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
1710 struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
1711 u16 att = 0xFFFF;
1712
1713 if (phy->type == BCM43xx_PHYTYPE_A)
1714 return 0x60;
1715
1716 switch (radio->version) {
1717 case 0x2053:
1718 switch (radio->revision) {
1719 case 1:
1720 att = 6;
1721 break;
1722 }
1723 break;
1724 case 0x2050:
1725 switch (radio->revision) {
1726 case 0:
1727 att = 5;
1728 break;
1729 case 1:
1730 if (phy->type == BCM43xx_PHYTYPE_G) {
1731 if (bcm->board_vendor == PCI_VENDOR_ID_BROADCOM &&
1732 bcm->board_type == 0x421 &&
1733 bcm->board_revision >= 30)
1734 att = 3;
1735 else if (bcm->board_vendor == PCI_VENDOR_ID_BROADCOM &&
1736 bcm->board_type == 0x416)
1737 att = 3;
1738 else
1739 att = 1;
1740 } else {
1741 if (bcm->board_vendor == PCI_VENDOR_ID_BROADCOM &&
1742 bcm->board_type == 0x421 &&
1743 bcm->board_revision >= 30)
1744 att = 7;
1745 else
1746 att = 6;
1747 }
1748 break;
1749 case 2:
1750 if (phy->type == BCM43xx_PHYTYPE_G) {
1751 if (bcm->board_vendor == PCI_VENDOR_ID_BROADCOM &&
1752 bcm->board_type == 0x421 &&
1753 bcm->board_revision >= 30)
1754 att = 3;
1755 else if (bcm->board_vendor == PCI_VENDOR_ID_BROADCOM &&
1756 bcm->board_type == 0x416)
1757 att = 5;
1758 else if (bcm->chip_id == 0x4320)
1759 att = 4;
1760 else
1761 att = 3;
1762 } else
1763 att = 6;
1764 break;
1765 case 3:
1766 att = 5;
1767 break;
1768 case 4:
1769 case 5:
1770 att = 1;
1771 break;
1772 case 6:
1773 case 7:
1774 att = 5;
1775 break;
1776 case 8:
1777 att = 0x1A;
1778 break;
1779 case 9:
1780 default:
1781 att = 5;
1782 }
1783 }
1784 if (bcm->board_vendor == PCI_VENDOR_ID_BROADCOM &&
1785 bcm->board_type == 0x421) {
1786 if (bcm->board_revision < 0x43)
1787 att = 2;
1788 else if (bcm->board_revision < 0x51)
1789 att = 3;
1790 }
1791 if (att == 0xFFFF)
1792 att = 5;
1793
1794 return att;
1795}
1796
1797u16 bcm43xx_default_txctl1(struct bcm43xx_private *bcm)
1798{
1799 struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
1800
1801 if (radio->version != 0x2050)
1802 return 0;
1803 if (radio->revision == 1)
1804 return 3;
1805 if (radio->revision < 6)
1806 return 2;
1807 if (radio->revision == 8)
1808 return 1;
1809 return 0;
1810}
1700 1811
1701void bcm43xx_radio_turn_on(struct bcm43xx_private *bcm) 1812void bcm43xx_radio_turn_on(struct bcm43xx_private *bcm)
1702{ 1813{
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_radio.h b/drivers/net/wireless/bcm43xx/bcm43xx_radio.h
index a5d2e10d5d98..9ed18039fa3e 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_radio.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_radio.h
@@ -72,6 +72,11 @@ void bcm43xx_radio_set_txpower_a(struct bcm43xx_private *bcm, u16 txpower);
72void bcm43xx_radio_set_txpower_bg(struct bcm43xx_private *bcm, 72void bcm43xx_radio_set_txpower_bg(struct bcm43xx_private *bcm,
73 u16 baseband_attenuation, u16 attenuation, 73 u16 baseband_attenuation, u16 attenuation,
74 u16 txpower); 74 u16 txpower);
75
76u16 bcm43xx_default_baseband_attenuation(struct bcm43xx_private *bcm);
77u16 bcm43xx_default_radio_attenuation(struct bcm43xx_private *bcm);
78u16 bcm43xx_default_txctl1(struct bcm43xx_private *bcm);
79
75void bcm43xx_radio_set_txantenna(struct bcm43xx_private *bcm, u32 val); 80void bcm43xx_radio_set_txantenna(struct bcm43xx_private *bcm, u32 val);
76 81
77void bcm43xx_radio_clear_tssi(struct bcm43xx_private *bcm); 82void bcm43xx_radio_clear_tssi(struct bcm43xx_private *bcm);