diff options
author | Gertjan van Wingerde <gwingerde@gmail.com> | 2010-04-11 08:31:13 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-04-12 15:22:12 -0400 |
commit | d5385bfc59c737d1eae77cc48d662daf4ddddae8 (patch) | |
tree | c595e4460edd9fe4b57793b7681c1665f3ecfbd4 /drivers/net/wireless/rt2x00/rt2800lib.c | |
parent | 8cdd15e0063edbe002945ba93faf80e79c947610 (diff) |
rt2x00: Add rt3071 support in rt2800 register initialization.
Add RT3071 specific register initializations to rt2x00, based on the latest
Ralink rt3070 vendor driver.
With this patch my RT3071 based devices start showing a sign of life.
Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2800lib.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800lib.c | 102 |
1 files changed, 93 insertions, 9 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index 7d1cb7ea0952..fe7171f408ba 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c | |||
@@ -1042,7 +1042,8 @@ EXPORT_SYMBOL_GPL(rt2800_link_stats); | |||
1042 | static u8 rt2800_get_default_vgc(struct rt2x00_dev *rt2x00dev) | 1042 | static u8 rt2800_get_default_vgc(struct rt2x00_dev *rt2x00dev) |
1043 | { | 1043 | { |
1044 | if (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ) { | 1044 | if (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ) { |
1045 | if (rt2x00_rt(rt2x00dev, RT3070)) | 1045 | if (rt2x00_rt(rt2x00dev, RT3070) || |
1046 | rt2x00_rt(rt2x00dev, RT3071)) | ||
1046 | return 0x1c + (2 * rt2x00dev->lna_gain); | 1047 | return 0x1c + (2 * rt2x00dev->lna_gain); |
1047 | else | 1048 | else |
1048 | return 0x2e + rt2x00dev->lna_gain; | 1049 | return 0x2e + rt2x00dev->lna_gain; |
@@ -1091,6 +1092,7 @@ EXPORT_SYMBOL_GPL(rt2800_link_tuner); | |||
1091 | int rt2800_init_registers(struct rt2x00_dev *rt2x00dev) | 1092 | int rt2800_init_registers(struct rt2x00_dev *rt2x00dev) |
1092 | { | 1093 | { |
1093 | u32 reg; | 1094 | u32 reg; |
1095 | u16 eeprom; | ||
1094 | unsigned int i; | 1096 | unsigned int i; |
1095 | 1097 | ||
1096 | rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, ®); | 1098 | rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, ®); |
@@ -1190,7 +1192,22 @@ int rt2800_init_registers(struct rt2x00_dev *rt2x00dev) | |||
1190 | rt2x00_set_field32(®, BKOFF_SLOT_CFG_CC_DELAY_TIME, 2); | 1192 | rt2x00_set_field32(®, BKOFF_SLOT_CFG_CC_DELAY_TIME, 2); |
1191 | rt2800_register_write(rt2x00dev, BKOFF_SLOT_CFG, reg); | 1193 | rt2800_register_write(rt2x00dev, BKOFF_SLOT_CFG, reg); |
1192 | 1194 | ||
1193 | if (rt2x00_rt(rt2x00dev, RT3070)) { | 1195 | if (rt2x00_rt(rt2x00dev, RT3071)) { |
1196 | rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000400); | ||
1197 | rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00000000); | ||
1198 | if (rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E)) { | ||
1199 | rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &eeprom); | ||
1200 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_DAC_TEST)) | ||
1201 | rt2800_register_write(rt2x00dev, TX_SW_CFG2, | ||
1202 | 0x0000002c); | ||
1203 | else | ||
1204 | rt2800_register_write(rt2x00dev, TX_SW_CFG2, | ||
1205 | 0x0000000f); | ||
1206 | } else { | ||
1207 | rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000); | ||
1208 | } | ||
1209 | rt2800_register_write(rt2x00dev, TX_SW_CFG2, reg); | ||
1210 | } else if (rt2x00_rt(rt2x00dev, RT3070)) { | ||
1194 | rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000400); | 1211 | rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000400); |
1195 | 1212 | ||
1196 | if (rt2x00_rt_rev_lt(rt2x00dev, RT3070, REV_RT3070F)) { | 1213 | if (rt2x00_rt_rev_lt(rt2x00dev, RT3070, REV_RT3070F)) { |
@@ -1540,7 +1557,8 @@ int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev) | |||
1540 | 1557 | ||
1541 | rt2800_bbp_write(rt2x00dev, 70, 0x0a); | 1558 | rt2800_bbp_write(rt2x00dev, 70, 0x0a); |
1542 | 1559 | ||
1543 | if (rt2x00_rt(rt2x00dev, RT3070)) { | 1560 | if (rt2x00_rt(rt2x00dev, RT3070) || |
1561 | rt2x00_rt(rt2x00dev, RT3071)) { | ||
1544 | rt2800_bbp_write(rt2x00dev, 79, 0x13); | 1562 | rt2800_bbp_write(rt2x00dev, 79, 0x13); |
1545 | rt2800_bbp_write(rt2x00dev, 80, 0x05); | 1563 | rt2800_bbp_write(rt2x00dev, 80, 0x05); |
1546 | rt2800_bbp_write(rt2x00dev, 81, 0x33); | 1564 | rt2800_bbp_write(rt2x00dev, 81, 0x33); |
@@ -1561,7 +1579,8 @@ int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev) | |||
1561 | rt2800_bbp_write(rt2x00dev, 91, 0x04); | 1579 | rt2800_bbp_write(rt2x00dev, 91, 0x04); |
1562 | rt2800_bbp_write(rt2x00dev, 92, 0x00); | 1580 | rt2800_bbp_write(rt2x00dev, 92, 0x00); |
1563 | 1581 | ||
1564 | if (rt2x00_rt_rev_gte(rt2x00dev, RT3070, REV_RT3070F)) | 1582 | if (rt2x00_rt_rev_gte(rt2x00dev, RT3070, REV_RT3070F) || |
1583 | rt2x00_rt_rev_gte(rt2x00dev, RT3071, REV_RT3071E)) | ||
1565 | rt2800_bbp_write(rt2x00dev, 103, 0xc0); | 1584 | rt2800_bbp_write(rt2x00dev, 103, 0xc0); |
1566 | else | 1585 | else |
1567 | rt2800_bbp_write(rt2x00dev, 103, 0x00); | 1586 | rt2800_bbp_write(rt2x00dev, 103, 0x00); |
@@ -1569,6 +1588,18 @@ int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev) | |||
1569 | rt2800_bbp_write(rt2x00dev, 105, 0x05); | 1588 | rt2800_bbp_write(rt2x00dev, 105, 0x05); |
1570 | rt2800_bbp_write(rt2x00dev, 106, 0x35); | 1589 | rt2800_bbp_write(rt2x00dev, 106, 0x35); |
1571 | 1590 | ||
1591 | if (rt2x00_rt(rt2x00dev, RT3071)) { | ||
1592 | rt2800_bbp_read(rt2x00dev, 138, &value); | ||
1593 | |||
1594 | rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom); | ||
1595 | if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) == 1) | ||
1596 | value |= 0x20; | ||
1597 | if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH) == 1) | ||
1598 | value &= ~0x02; | ||
1599 | |||
1600 | rt2800_bbp_write(rt2x00dev, 138, value); | ||
1601 | } | ||
1602 | |||
1572 | if (rt2x00_rt(rt2x00dev, RT2872)) { | 1603 | if (rt2x00_rt(rt2x00dev, RT2872)) { |
1573 | rt2800_bbp_write(rt2x00dev, 31, 0x08); | 1604 | rt2800_bbp_write(rt2x00dev, 31, 0x08); |
1574 | rt2800_bbp_write(rt2x00dev, 78, 0x0e); | 1605 | rt2800_bbp_write(rt2x00dev, 78, 0x0e); |
@@ -1656,7 +1687,8 @@ int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) | |||
1656 | u32 reg; | 1687 | u32 reg; |
1657 | u16 eeprom; | 1688 | u16 eeprom; |
1658 | 1689 | ||
1659 | if (!rt2x00_rt(rt2x00dev, RT3070)) | 1690 | if (!rt2x00_rt(rt2x00dev, RT3070) && |
1691 | !rt2x00_rt(rt2x00dev, RT3071)) | ||
1660 | return 0; | 1692 | return 0; |
1661 | 1693 | ||
1662 | /* | 1694 | /* |
@@ -1669,7 +1701,8 @@ int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) | |||
1669 | rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 0); | 1701 | rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 0); |
1670 | rt2800_rfcsr_write(rt2x00dev, 30, rfcsr); | 1702 | rt2800_rfcsr_write(rt2x00dev, 30, rfcsr); |
1671 | 1703 | ||
1672 | if (rt2x00_rt(rt2x00dev, RT3070)) { | 1704 | if (rt2x00_rt(rt2x00dev, RT3070) || |
1705 | rt2x00_rt(rt2x00dev, RT3071)) { | ||
1673 | rt2800_rfcsr_write(rt2x00dev, 4, 0x40); | 1706 | rt2800_rfcsr_write(rt2x00dev, 4, 0x40); |
1674 | rt2800_rfcsr_write(rt2x00dev, 5, 0x03); | 1707 | rt2800_rfcsr_write(rt2x00dev, 5, 0x03); |
1675 | rt2800_rfcsr_write(rt2x00dev, 6, 0x02); | 1708 | rt2800_rfcsr_write(rt2x00dev, 6, 0x02); |
@@ -1696,6 +1729,23 @@ int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) | |||
1696 | rt2x00_set_field32(®, LDO_CFG0_BGSEL, 1); | 1729 | rt2x00_set_field32(®, LDO_CFG0_BGSEL, 1); |
1697 | rt2x00_set_field32(®, LDO_CFG0_LDO_CORE_VLEVEL, 3); | 1730 | rt2x00_set_field32(®, LDO_CFG0_LDO_CORE_VLEVEL, 3); |
1698 | rt2800_register_write(rt2x00dev, LDO_CFG0, reg); | 1731 | rt2800_register_write(rt2x00dev, LDO_CFG0, reg); |
1732 | } else if (rt2x00_rt(rt2x00dev, RT3071)) { | ||
1733 | rt2800_rfcsr_read(rt2x00dev, 6, &rfcsr); | ||
1734 | rt2x00_set_field8(&rfcsr, RFCSR6_R2, 1); | ||
1735 | rt2800_rfcsr_write(rt2x00dev, 6, rfcsr); | ||
1736 | |||
1737 | rt2800_rfcsr_write(rt2x00dev, 31, 0x14); | ||
1738 | |||
1739 | rt2800_register_read(rt2x00dev, LDO_CFG0, ®); | ||
1740 | rt2x00_set_field32(®, LDO_CFG0_BGSEL, 1); | ||
1741 | if (rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E)) { | ||
1742 | rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &eeprom); | ||
1743 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_DAC_TEST)) | ||
1744 | rt2x00_set_field32(®, LDO_CFG0_LDO_CORE_VLEVEL, 3); | ||
1745 | else | ||
1746 | rt2x00_set_field32(®, LDO_CFG0_LDO_CORE_VLEVEL, 0); | ||
1747 | } | ||
1748 | rt2800_register_write(rt2x00dev, LDO_CFG0, reg); | ||
1699 | } | 1749 | } |
1700 | 1750 | ||
1701 | /* | 1751 | /* |
@@ -1706,6 +1756,11 @@ int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) | |||
1706 | rt2800_init_rx_filter(rt2x00dev, false, 0x07, 0x16); | 1756 | rt2800_init_rx_filter(rt2x00dev, false, 0x07, 0x16); |
1707 | rt2x00dev->calibration[1] = | 1757 | rt2x00dev->calibration[1] = |
1708 | rt2800_init_rx_filter(rt2x00dev, true, 0x27, 0x19); | 1758 | rt2800_init_rx_filter(rt2x00dev, true, 0x27, 0x19); |
1759 | } else if (rt2x00_rt(rt2x00dev, RT3071)) { | ||
1760 | rt2x00dev->calibration[0] = | ||
1761 | rt2800_init_rx_filter(rt2x00dev, false, 0x07, 0x13); | ||
1762 | rt2x00dev->calibration[1] = | ||
1763 | rt2800_init_rx_filter(rt2x00dev, true, 0x27, 0x15); | ||
1709 | } | 1764 | } |
1710 | 1765 | ||
1711 | /* | 1766 | /* |
@@ -1724,7 +1779,8 @@ int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) | |||
1724 | rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 0); | 1779 | rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 0); |
1725 | rt2800_bbp_write(rt2x00dev, 4, bbp); | 1780 | rt2800_bbp_write(rt2x00dev, 4, bbp); |
1726 | 1781 | ||
1727 | if (rt2x00_rt_rev_lt(rt2x00dev, RT3070, REV_RT3070F)) | 1782 | if (rt2x00_rt_rev_lt(rt2x00dev, RT3070, REV_RT3070F) || |
1783 | rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E)) | ||
1728 | rt2800_rfcsr_write(rt2x00dev, 27, 0x03); | 1784 | rt2800_rfcsr_write(rt2x00dev, 27, 0x03); |
1729 | 1785 | ||
1730 | rt2800_register_read(rt2x00dev, OPT_14_CSR, ®); | 1786 | rt2800_register_read(rt2x00dev, OPT_14_CSR, ®); |
@@ -1733,6 +1789,11 @@ int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) | |||
1733 | 1789 | ||
1734 | rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr); | 1790 | rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr); |
1735 | rt2x00_set_field8(&rfcsr, RFCSR17_TX_LO1_EN, 0); | 1791 | rt2x00_set_field8(&rfcsr, RFCSR17_TX_LO1_EN, 0); |
1792 | if (rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E)) { | ||
1793 | rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &eeprom); | ||
1794 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_EXTERNAL_LNA_BG)) | ||
1795 | rt2x00_set_field8(&rfcsr, RFCSR17_R, 1); | ||
1796 | } | ||
1736 | rt2x00_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG, &eeprom); | 1797 | rt2x00_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG, &eeprom); |
1737 | if (rt2x00_get_field16(eeprom, EEPROM_TXMIXER_GAIN_BG_VAL) >= 1) | 1798 | if (rt2x00_get_field16(eeprom, EEPROM_TXMIXER_GAIN_BG_VAL) >= 1) |
1738 | rt2x00_set_field8(&rfcsr, RFCSR17_TXMIXER_GAIN, | 1799 | rt2x00_set_field8(&rfcsr, RFCSR17_TXMIXER_GAIN, |
@@ -1740,9 +1801,32 @@ int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) | |||
1740 | EEPROM_TXMIXER_GAIN_BG_VAL)); | 1801 | EEPROM_TXMIXER_GAIN_BG_VAL)); |
1741 | rt2800_rfcsr_write(rt2x00dev, 17, rfcsr); | 1802 | rt2800_rfcsr_write(rt2x00dev, 17, rfcsr); |
1742 | 1803 | ||
1743 | if (rt2x00_rt(rt2x00dev, RT3070)) { | 1804 | if (rt2x00_rt(rt2x00dev, RT3071)) { |
1805 | rt2800_rfcsr_read(rt2x00dev, 1, &rfcsr); | ||
1806 | rt2x00_set_field8(&rfcsr, RFCSR1_RF_BLOCK_EN, 1); | ||
1807 | rt2x00_set_field8(&rfcsr, RFCSR1_RX0_PD, 0); | ||
1808 | rt2x00_set_field8(&rfcsr, RFCSR1_TX0_PD, 0); | ||
1809 | rt2x00_set_field8(&rfcsr, RFCSR1_RX1_PD, 1); | ||
1810 | rt2x00_set_field8(&rfcsr, RFCSR1_TX1_PD, 1); | ||
1811 | rt2800_rfcsr_write(rt2x00dev, 1, rfcsr); | ||
1812 | |||
1813 | rt2800_rfcsr_read(rt2x00dev, 15, &rfcsr); | ||
1814 | rt2x00_set_field8(&rfcsr, RFCSR15_TX_LO2_EN, 0); | ||
1815 | rt2800_rfcsr_write(rt2x00dev, 15, rfcsr); | ||
1816 | |||
1817 | rt2800_rfcsr_read(rt2x00dev, 20, &rfcsr); | ||
1818 | rt2x00_set_field8(&rfcsr, RFCSR20_RX_LO1_EN, 0); | ||
1819 | rt2800_rfcsr_write(rt2x00dev, 20, rfcsr); | ||
1820 | |||
1821 | rt2800_rfcsr_read(rt2x00dev, 21, &rfcsr); | ||
1822 | rt2x00_set_field8(&rfcsr, RFCSR21_RX_LO2_EN, 0); | ||
1823 | rt2800_rfcsr_write(rt2x00dev, 21, rfcsr); | ||
1824 | } | ||
1825 | |||
1826 | if (rt2x00_rt(rt2x00dev, RT3070) || rt2x00_rt(rt2x00dev, RT3071)) { | ||
1744 | rt2800_rfcsr_read(rt2x00dev, 27, &rfcsr); | 1827 | rt2800_rfcsr_read(rt2x00dev, 27, &rfcsr); |
1745 | if (rt2x00_rt_rev_lt(rt2x00dev, RT3070, REV_RT3070F)) | 1828 | if (rt2x00_rt_rev_lt(rt2x00dev, RT3070, REV_RT3070F) || |
1829 | rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E)) | ||
1746 | rt2x00_set_field8(&rfcsr, RFCSR27_R1, 3); | 1830 | rt2x00_set_field8(&rfcsr, RFCSR27_R1, 3); |
1747 | else | 1831 | else |
1748 | rt2x00_set_field8(&rfcsr, RFCSR27_R1, 0); | 1832 | rt2x00_set_field8(&rfcsr, RFCSR27_R1, 0); |