aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-11-04 12:34:11 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-11-06 16:48:51 -0500
commit1af68f75a808d02997ad0c6dde9e37f43b7dfcb4 (patch)
treed150897774159261680c6f27d0726b09d308a720
parente91fea9b38b2208113dd540f436ce2aba7ab29fd (diff)
rt2800pci: add rt2800_rfcsr_[read,write]() wrappers
Part of preparations for later code unification. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Acked-by: Ivo van Doorn <IvDoorn@gmail.com> Acked-by: Gertjan van Wingerde <gwingerde@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/rt2x00/rt2800pci.c116
1 files changed, 64 insertions, 52 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
index 12344fd02b3b..37a55527a48f 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.c
+++ b/drivers/net/wireless/rt2x00/rt2800pci.c
@@ -202,6 +202,18 @@ static void rt2800pci_rfcsr_read(struct rt2x00_dev *rt2x00dev,
202 mutex_unlock(&rt2x00dev->csr_mutex); 202 mutex_unlock(&rt2x00dev->csr_mutex);
203} 203}
204 204
205static inline void rt2800_rfcsr_write(struct rt2x00_dev *rt2x00dev,
206 const unsigned int word, const u8 value)
207{
208 rt2800pci_rfcsr_write(rt2x00dev, word, value);
209}
210
211static inline void rt2800_rfcsr_read(struct rt2x00_dev *rt2x00dev,
212 const unsigned int word, u8 *value)
213{
214 rt2800pci_rfcsr_read(rt2x00dev, word, value);
215}
216
205static void rt2800pci_rf_write(struct rt2x00_dev *rt2x00dev, 217static void rt2800pci_rf_write(struct rt2x00_dev *rt2x00dev,
206 const unsigned int word, const u32 value) 218 const unsigned int word, const u32 value)
207{ 219{
@@ -915,28 +927,28 @@ static void rt2800pci_config_channel_rt3x(struct rt2x00_dev *rt2x00dev,
915{ 927{
916 u8 rfcsr; 928 u8 rfcsr;
917 929
918 rt2800pci_rfcsr_write(rt2x00dev, 2, rf->rf1); 930 rt2800_rfcsr_write(rt2x00dev, 2, rf->rf1);
919 rt2800pci_rfcsr_write(rt2x00dev, 2, rf->rf3); 931 rt2800_rfcsr_write(rt2x00dev, 2, rf->rf3);
920 932
921 rt2800pci_rfcsr_read(rt2x00dev, 6, &rfcsr); 933 rt2800_rfcsr_read(rt2x00dev, 6, &rfcsr);
922 rt2x00_set_field8(&rfcsr, RFCSR6_R, rf->rf2); 934 rt2x00_set_field8(&rfcsr, RFCSR6_R, rf->rf2);
923 rt2800pci_rfcsr_write(rt2x00dev, 6, rfcsr); 935 rt2800_rfcsr_write(rt2x00dev, 6, rfcsr);
924 936
925 rt2800pci_rfcsr_read(rt2x00dev, 12, &rfcsr); 937 rt2800_rfcsr_read(rt2x00dev, 12, &rfcsr);
926 rt2x00_set_field8(&rfcsr, RFCSR12_TX_POWER, 938 rt2x00_set_field8(&rfcsr, RFCSR12_TX_POWER,
927 TXPOWER_G_TO_DEV(info->tx_power1)); 939 TXPOWER_G_TO_DEV(info->tx_power1));
928 rt2800pci_rfcsr_write(rt2x00dev, 12, rfcsr); 940 rt2800_rfcsr_write(rt2x00dev, 12, rfcsr);
929 941
930 rt2800pci_rfcsr_read(rt2x00dev, 23, &rfcsr); 942 rt2800_rfcsr_read(rt2x00dev, 23, &rfcsr);
931 rt2x00_set_field8(&rfcsr, RFCSR23_FREQ_OFFSET, rt2x00dev->freq_offset); 943 rt2x00_set_field8(&rfcsr, RFCSR23_FREQ_OFFSET, rt2x00dev->freq_offset);
932 rt2800pci_rfcsr_write(rt2x00dev, 23, rfcsr); 944 rt2800_rfcsr_write(rt2x00dev, 23, rfcsr);
933 945
934 rt2800pci_rfcsr_write(rt2x00dev, 24, 946 rt2800_rfcsr_write(rt2x00dev, 24,
935 rt2x00dev->calibration[conf_is_ht40(conf)]); 947 rt2x00dev->calibration[conf_is_ht40(conf)]);
936 948
937 rt2800pci_rfcsr_read(rt2x00dev, 23, &rfcsr); 949 rt2800_rfcsr_read(rt2x00dev, 23, &rfcsr);
938 rt2x00_set_field8(&rfcsr, RFCSR7_RF_TUNING, 1); 950 rt2x00_set_field8(&rfcsr, RFCSR7_RF_TUNING, 1);
939 rt2800pci_rfcsr_write(rt2x00dev, 23, rfcsr); 951 rt2800_rfcsr_write(rt2x00dev, 23, rfcsr);
940} 952}
941 953
942static void rt2800pci_config_channel(struct rt2x00_dev *rt2x00dev, 954static void rt2800pci_config_channel(struct rt2x00_dev *rt2x00dev,
@@ -1805,15 +1817,15 @@ static u8 rt2800pci_init_rx_filter(struct rt2x00_dev *rt2x00dev,
1805 u8 stopband; 1817 u8 stopband;
1806 u8 overtuned = 0; 1818 u8 overtuned = 0;
1807 1819
1808 rt2800pci_rfcsr_write(rt2x00dev, 24, rfcsr24); 1820 rt2800_rfcsr_write(rt2x00dev, 24, rfcsr24);
1809 1821
1810 rt2800_bbp_read(rt2x00dev, 4, &bbp); 1822 rt2800_bbp_read(rt2x00dev, 4, &bbp);
1811 rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 2 * bw40); 1823 rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 2 * bw40);
1812 rt2800_bbp_write(rt2x00dev, 4, bbp); 1824 rt2800_bbp_write(rt2x00dev, 4, bbp);
1813 1825
1814 rt2800pci_rfcsr_read(rt2x00dev, 22, &rfcsr); 1826 rt2800_rfcsr_read(rt2x00dev, 22, &rfcsr);
1815 rt2x00_set_field8(&rfcsr, RFCSR22_BASEBAND_LOOPBACK, 1); 1827 rt2x00_set_field8(&rfcsr, RFCSR22_BASEBAND_LOOPBACK, 1);
1816 rt2800pci_rfcsr_write(rt2x00dev, 22, rfcsr); 1828 rt2800_rfcsr_write(rt2x00dev, 22, rfcsr);
1817 1829
1818 /* 1830 /*
1819 * Set power & frequency of passband test tone 1831 * Set power & frequency of passband test tone
@@ -1846,12 +1858,12 @@ static u8 rt2800pci_init_rx_filter(struct rt2x00_dev *rt2x00dev,
1846 } else 1858 } else
1847 break; 1859 break;
1848 1860
1849 rt2800pci_rfcsr_write(rt2x00dev, 24, rfcsr24); 1861 rt2800_rfcsr_write(rt2x00dev, 24, rfcsr24);
1850 } 1862 }
1851 1863
1852 rfcsr24 -= !!overtuned; 1864 rfcsr24 -= !!overtuned;
1853 1865
1854 rt2800pci_rfcsr_write(rt2x00dev, 24, rfcsr24); 1866 rt2800_rfcsr_write(rt2x00dev, 24, rfcsr24);
1855 return rfcsr24; 1867 return rfcsr24;
1856} 1868}
1857 1869
@@ -1868,43 +1880,43 @@ static int rt2800pci_init_rfcsr(struct rt2x00_dev *rt2x00dev)
1868 /* 1880 /*
1869 * Init RF calibration. 1881 * Init RF calibration.
1870 */ 1882 */
1871 rt2800pci_rfcsr_read(rt2x00dev, 30, &rfcsr); 1883 rt2800_rfcsr_read(rt2x00dev, 30, &rfcsr);
1872 rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 1); 1884 rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 1);
1873 rt2800pci_rfcsr_write(rt2x00dev, 30, rfcsr); 1885 rt2800_rfcsr_write(rt2x00dev, 30, rfcsr);
1874 msleep(1); 1886 msleep(1);
1875 rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 0); 1887 rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 0);
1876 rt2800pci_rfcsr_write(rt2x00dev, 30, rfcsr); 1888 rt2800_rfcsr_write(rt2x00dev, 30, rfcsr);
1877 1889
1878 rt2800pci_rfcsr_write(rt2x00dev, 0, 0x50); 1890 rt2800_rfcsr_write(rt2x00dev, 0, 0x50);
1879 rt2800pci_rfcsr_write(rt2x00dev, 1, 0x01); 1891 rt2800_rfcsr_write(rt2x00dev, 1, 0x01);
1880 rt2800pci_rfcsr_write(rt2x00dev, 2, 0xf7); 1892 rt2800_rfcsr_write(rt2x00dev, 2, 0xf7);
1881 rt2800pci_rfcsr_write(rt2x00dev, 3, 0x75); 1893 rt2800_rfcsr_write(rt2x00dev, 3, 0x75);
1882 rt2800pci_rfcsr_write(rt2x00dev, 4, 0x40); 1894 rt2800_rfcsr_write(rt2x00dev, 4, 0x40);
1883 rt2800pci_rfcsr_write(rt2x00dev, 5, 0x03); 1895 rt2800_rfcsr_write(rt2x00dev, 5, 0x03);
1884 rt2800pci_rfcsr_write(rt2x00dev, 6, 0x02); 1896 rt2800_rfcsr_write(rt2x00dev, 6, 0x02);
1885 rt2800pci_rfcsr_write(rt2x00dev, 7, 0x50); 1897 rt2800_rfcsr_write(rt2x00dev, 7, 0x50);
1886 rt2800pci_rfcsr_write(rt2x00dev, 8, 0x39); 1898 rt2800_rfcsr_write(rt2x00dev, 8, 0x39);
1887 rt2800pci_rfcsr_write(rt2x00dev, 9, 0x0f); 1899 rt2800_rfcsr_write(rt2x00dev, 9, 0x0f);
1888 rt2800pci_rfcsr_write(rt2x00dev, 10, 0x60); 1900 rt2800_rfcsr_write(rt2x00dev, 10, 0x60);
1889 rt2800pci_rfcsr_write(rt2x00dev, 11, 0x21); 1901 rt2800_rfcsr_write(rt2x00dev, 11, 0x21);
1890 rt2800pci_rfcsr_write(rt2x00dev, 12, 0x75); 1902 rt2800_rfcsr_write(rt2x00dev, 12, 0x75);
1891 rt2800pci_rfcsr_write(rt2x00dev, 13, 0x75); 1903 rt2800_rfcsr_write(rt2x00dev, 13, 0x75);
1892 rt2800pci_rfcsr_write(rt2x00dev, 14, 0x90); 1904 rt2800_rfcsr_write(rt2x00dev, 14, 0x90);
1893 rt2800pci_rfcsr_write(rt2x00dev, 15, 0x58); 1905 rt2800_rfcsr_write(rt2x00dev, 15, 0x58);
1894 rt2800pci_rfcsr_write(rt2x00dev, 16, 0xb3); 1906 rt2800_rfcsr_write(rt2x00dev, 16, 0xb3);
1895 rt2800pci_rfcsr_write(rt2x00dev, 17, 0x92); 1907 rt2800_rfcsr_write(rt2x00dev, 17, 0x92);
1896 rt2800pci_rfcsr_write(rt2x00dev, 18, 0x2c); 1908 rt2800_rfcsr_write(rt2x00dev, 18, 0x2c);
1897 rt2800pci_rfcsr_write(rt2x00dev, 19, 0x02); 1909 rt2800_rfcsr_write(rt2x00dev, 19, 0x02);
1898 rt2800pci_rfcsr_write(rt2x00dev, 20, 0xba); 1910 rt2800_rfcsr_write(rt2x00dev, 20, 0xba);
1899 rt2800pci_rfcsr_write(rt2x00dev, 21, 0xdb); 1911 rt2800_rfcsr_write(rt2x00dev, 21, 0xdb);
1900 rt2800pci_rfcsr_write(rt2x00dev, 22, 0x00); 1912 rt2800_rfcsr_write(rt2x00dev, 22, 0x00);
1901 rt2800pci_rfcsr_write(rt2x00dev, 23, 0x31); 1913 rt2800_rfcsr_write(rt2x00dev, 23, 0x31);
1902 rt2800pci_rfcsr_write(rt2x00dev, 24, 0x08); 1914 rt2800_rfcsr_write(rt2x00dev, 24, 0x08);
1903 rt2800pci_rfcsr_write(rt2x00dev, 25, 0x01); 1915 rt2800_rfcsr_write(rt2x00dev, 25, 0x01);
1904 rt2800pci_rfcsr_write(rt2x00dev, 26, 0x25); 1916 rt2800_rfcsr_write(rt2x00dev, 26, 0x25);
1905 rt2800pci_rfcsr_write(rt2x00dev, 27, 0x23); 1917 rt2800_rfcsr_write(rt2x00dev, 27, 0x23);
1906 rt2800pci_rfcsr_write(rt2x00dev, 28, 0x13); 1918 rt2800_rfcsr_write(rt2x00dev, 28, 0x13);
1907 rt2800pci_rfcsr_write(rt2x00dev, 29, 0x83); 1919 rt2800_rfcsr_write(rt2x00dev, 29, 0x83);
1908 1920
1909 /* 1921 /*
1910 * Set RX Filter calibration for 20MHz and 40MHz 1922 * Set RX Filter calibration for 20MHz and 40MHz
@@ -1919,9 +1931,9 @@ static int rt2800pci_init_rfcsr(struct rt2x00_dev *rt2x00dev)
1919 */ 1931 */
1920 rt2800_bbp_write(rt2x00dev, 24, 0); 1932 rt2800_bbp_write(rt2x00dev, 24, 0);
1921 1933
1922 rt2800pci_rfcsr_read(rt2x00dev, 22, &rfcsr); 1934 rt2800_rfcsr_read(rt2x00dev, 22, &rfcsr);
1923 rt2x00_set_field8(&rfcsr, RFCSR22_BASEBAND_LOOPBACK, 0); 1935 rt2x00_set_field8(&rfcsr, RFCSR22_BASEBAND_LOOPBACK, 0);
1924 rt2800pci_rfcsr_write(rt2x00dev, 22, rfcsr); 1936 rt2800_rfcsr_write(rt2x00dev, 22, rfcsr);
1925 1937
1926 /* 1938 /*
1927 * set BBP back to BW20 1939 * set BBP back to BW20