aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStanislaw Gruszka <stf_xl@wp.pl>2013-04-17 08:08:10 -0400
committerJohn W. Linville <linville@tuxdriver.com>2013-04-22 15:20:15 -0400
commitf7df8fe527e79fdc35defc49bc74e2ee2ff742b1 (patch)
tree874567056cc33a5d16a82a4bc6ae1ba79f04ff1c
parentab11bb28fb3b047f0e5c275d4530519cd2323c8d (diff)
rt2800: merge 5xxx normal mode setup
Merge code which program the same registes at the end of rfcsr initialization for 5592, 5392 and 5390 chips. Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl> Acked-by: Gertjan van Wingerde <gwingerde@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.c84
1 files changed, 36 insertions, 48 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 6a167a28a688..22c10e1e5ad6 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -4396,6 +4396,35 @@ static u8 rt2800_init_rx_filter(struct rt2x00_dev *rt2x00dev,
4396 return rfcsr24; 4396 return rfcsr24;
4397} 4397}
4398 4398
4399static void rt2800_normal_mode_setup_5xxx(struct rt2x00_dev *rt2x00dev)
4400{
4401 u8 reg;
4402 u16 eeprom;
4403
4404 /* Turn off unused DAC1 and ADC1 to reduce power consumption */
4405 rt2800_bbp_read(rt2x00dev, 138, &reg);
4406 rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
4407 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH) == 1)
4408 rt2x00_set_field8(&reg, BBP138_RX_ADC1, 0);
4409 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1)
4410 rt2x00_set_field8(&reg, BBP138_TX_DAC1, 1);
4411 rt2800_bbp_write(rt2x00dev, 138, reg);
4412
4413 rt2800_rfcsr_read(rt2x00dev, 38, &reg);
4414 rt2x00_set_field8(&reg, RFCSR38_RX_LO1_EN, 0);
4415 rt2800_rfcsr_write(rt2x00dev, 38, reg);
4416
4417 rt2800_rfcsr_read(rt2x00dev, 39, &reg);
4418 rt2x00_set_field8(&reg, RFCSR39_RX_LO2_EN, 0);
4419 rt2800_rfcsr_write(rt2x00dev, 39, reg);
4420
4421 rt2800_bbp4_mac_if_ctrl(rt2x00dev);
4422
4423 rt2800_rfcsr_read(rt2x00dev, 30, &reg);
4424 rt2x00_set_field8(&reg, RFCSR30_RX_VCM, 2);
4425 rt2800_rfcsr_write(rt2x00dev, 30, reg);
4426}
4427
4399static void rt2800_init_rfcsr_305x_soc(struct rt2x00_dev *rt2x00dev) 4428static void rt2800_init_rfcsr_305x_soc(struct rt2x00_dev *rt2x00dev)
4400{ 4429{
4401 rt2800_rfcsr_write(rt2x00dev, 0, 0x50); 4430 rt2800_rfcsr_write(rt2x00dev, 0, 0x50);
@@ -4725,6 +4754,8 @@ static void rt2800_init_rfcsr_5390(struct rt2x00_dev *rt2x00dev)
4725 rt2800_rfcsr_write(rt2x00dev, 61, 0xdd); 4754 rt2800_rfcsr_write(rt2x00dev, 61, 0xdd);
4726 rt2800_rfcsr_write(rt2x00dev, 62, 0x00); 4755 rt2800_rfcsr_write(rt2x00dev, 62, 0x00);
4727 rt2800_rfcsr_write(rt2x00dev, 63, 0x00); 4756 rt2800_rfcsr_write(rt2x00dev, 63, 0x00);
4757
4758 rt2800_normal_mode_setup_5xxx(rt2x00dev);
4728} 4759}
4729 4760
4730static void rt2800_init_rfcsr_5392(struct rt2x00_dev *rt2x00dev) 4761static void rt2800_init_rfcsr_5392(struct rt2x00_dev *rt2x00dev)
@@ -4788,13 +4819,12 @@ static void rt2800_init_rfcsr_5392(struct rt2x00_dev *rt2x00dev)
4788 rt2800_rfcsr_write(rt2x00dev, 61, 0x91); 4819 rt2800_rfcsr_write(rt2x00dev, 61, 0x91);
4789 rt2800_rfcsr_write(rt2x00dev, 62, 0x39); 4820 rt2800_rfcsr_write(rt2x00dev, 62, 0x39);
4790 rt2800_rfcsr_write(rt2x00dev, 63, 0x07); 4821 rt2800_rfcsr_write(rt2x00dev, 63, 0x07);
4822
4823 rt2800_normal_mode_setup_5xxx(rt2x00dev);
4791} 4824}
4792 4825
4793static void rt2800_init_rfcsr_5592(struct rt2x00_dev *rt2x00dev) 4826static void rt2800_init_rfcsr_5592(struct rt2x00_dev *rt2x00dev)
4794{ 4827{
4795 u8 reg;
4796 u16 eeprom;
4797
4798 rt2800_rfcsr_write(rt2x00dev, 1, 0x3F); 4828 rt2800_rfcsr_write(rt2x00dev, 1, 0x3F);
4799 rt2800_rfcsr_write(rt2x00dev, 3, 0x08); 4829 rt2800_rfcsr_write(rt2x00dev, 3, 0x08);
4800 rt2800_rfcsr_write(rt2x00dev, 3, 0x08); 4830 rt2800_rfcsr_write(rt2x00dev, 3, 0x08);
@@ -4823,34 +4853,11 @@ static void rt2800_init_rfcsr_5592(struct rt2x00_dev *rt2x00dev)
4823 4853
4824 rt2800_adjust_freq_offset(rt2x00dev); 4854 rt2800_adjust_freq_offset(rt2x00dev);
4825 4855
4826 rt2800_bbp_read(rt2x00dev, 138, &reg);
4827
4828 /* Turn off unused DAC1 and ADC1 to reduce power consumption */
4829 rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
4830 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH) == 1)
4831 rt2x00_set_field8(&reg, BBP138_RX_ADC1, 0);
4832 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1)
4833 rt2x00_set_field8(&reg, BBP138_TX_DAC1, 1);
4834
4835 rt2800_bbp_write(rt2x00dev, 138, reg);
4836
4837 /* Enable DC filter */ 4856 /* Enable DC filter */
4838 if (rt2x00_rt_rev_gte(rt2x00dev, RT5592, REV_RT5592C)) 4857 if (rt2x00_rt_rev_gte(rt2x00dev, RT5592, REV_RT5592C))
4839 rt2800_bbp_write(rt2x00dev, 103, 0xc0); 4858 rt2800_bbp_write(rt2x00dev, 103, 0xc0);
4840 4859
4841 rt2800_rfcsr_read(rt2x00dev, 38, &reg); 4860 rt2800_normal_mode_setup_5xxx(rt2x00dev);
4842 rt2x00_set_field8(&reg, RFCSR38_RX_LO1_EN, 0);
4843 rt2800_rfcsr_write(rt2x00dev, 38, reg);
4844
4845 rt2800_rfcsr_read(rt2x00dev, 39, &reg);
4846 rt2x00_set_field8(&reg, RFCSR39_RX_LO2_EN, 0);
4847 rt2800_rfcsr_write(rt2x00dev, 39, reg);
4848
4849 rt2800_bbp4_mac_if_ctrl(rt2x00dev);
4850
4851 rt2800_rfcsr_read(rt2x00dev, 30, &reg);
4852 rt2x00_set_field8(&reg, RFCSR30_RX_VCM, 2);
4853 rt2800_rfcsr_write(rt2x00dev, 30, reg);
4854} 4861}
4855 4862
4856static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) 4863static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
@@ -5055,17 +5062,14 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
5055 rt2800_rfcsr_write(rt2x00dev, 17, rfcsr); 5062 rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
5056 } 5063 }
5057 5064
5058 if (rt2x00_rt(rt2x00dev, RT3090) || 5065 if (rt2x00_rt(rt2x00dev, RT3090)) {
5059 rt2x00_rt(rt2x00dev, RT5592)) {
5060 rt2800_bbp_read(rt2x00dev, 138, &bbp);
5061
5062 /* Turn off unused DAC1 and ADC1 to reduce power consumption */ 5066 /* Turn off unused DAC1 and ADC1 to reduce power consumption */
5067 rt2800_bbp_read(rt2x00dev, 138, &bbp);
5063 rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom); 5068 rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
5064 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH) == 1) 5069 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH) == 1)
5065 rt2x00_set_field8(&bbp, BBP138_RX_ADC1, 0); 5070 rt2x00_set_field8(&bbp, BBP138_RX_ADC1, 0);
5066 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1) 5071 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1)
5067 rt2x00_set_field8(&bbp, BBP138_TX_DAC1, 1); 5072 rt2x00_set_field8(&bbp, BBP138_TX_DAC1, 1);
5068
5069 rt2800_bbp_write(rt2x00dev, 138, bbp); 5073 rt2800_bbp_write(rt2x00dev, 138, bbp);
5070 } 5074 }
5071 5075
@@ -5111,22 +5115,6 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
5111 rt2800_rfcsr_write(rt2x00dev, 29, rfcsr); 5115 rt2800_rfcsr_write(rt2x00dev, 29, rfcsr);
5112 } 5116 }
5113 5117
5114 if (rt2x00_rt(rt2x00dev, RT5390) ||
5115 rt2x00_rt(rt2x00dev, RT5392) ||
5116 rt2x00_rt(rt2x00dev, RT5592)) {
5117 rt2800_rfcsr_read(rt2x00dev, 38, &rfcsr);
5118 rt2x00_set_field8(&rfcsr, RFCSR38_RX_LO1_EN, 0);
5119 rt2800_rfcsr_write(rt2x00dev, 38, rfcsr);
5120
5121 rt2800_rfcsr_read(rt2x00dev, 39, &rfcsr);
5122 rt2x00_set_field8(&rfcsr, RFCSR39_RX_LO2_EN, 0);
5123 rt2800_rfcsr_write(rt2x00dev, 39, rfcsr);
5124
5125 rt2800_rfcsr_read(rt2x00dev, 30, &rfcsr);
5126 rt2x00_set_field8(&rfcsr, RFCSR30_RX_VCM, 2);
5127 rt2800_rfcsr_write(rt2x00dev, 30, rfcsr);
5128 }
5129
5130 return 0; 5118 return 0;
5131} 5119}
5132 5120