4addb8e545511feeb944f67c44db7dcc47f8fa78
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / rt2x00 / 982-rt2x00-add-rf-self-txdc-calibration.patch
1 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
2 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
3 @@ -8422,6 +8422,56 @@ static void rt2800_init_rfcsr_5592(struc
4 rt2800_led_open_drain_enable(rt2x00dev);
5 }
6
7 +static void rt2800_rf_self_txdc_cal(struct rt2x00_dev *rt2x00dev)
8 +{
9 + u8 rfb5r1_org, rfb7r1_org, rfvalue;
10 + u32 mac0518, mac051c, mac0528, mac052c;
11 + u8 i;
12 +
13 + rt2x00_info(rt2x00dev, "RF Tx self calibration start\n");
14 + mac0518 = rt2800_register_read(rt2x00dev, RF_CONTROL0);
15 + mac051c = rt2800_register_read(rt2x00dev, RF_BYPASS0);
16 + mac0528 = rt2800_register_read(rt2x00dev, RF_CONTROL2);
17 + mac052c = rt2800_register_read(rt2x00dev, RF_BYPASS2);
18 +
19 + rt2800_register_write(rt2x00dev, RF_BYPASS0, 0x0);
20 + rt2800_register_write(rt2x00dev, RF_BYPASS2, 0x0);
21 +
22 + rt2800_register_write(rt2x00dev, RF_CONTROL0, 0xC);
23 + rt2800_register_write(rt2x00dev, RF_BYPASS0, 0x3306);
24 + rt2800_register_write(rt2x00dev, RF_CONTROL2, 0x3330);
25 + rt2800_register_write(rt2x00dev, RF_BYPASS2, 0xfffff);
26 + rfb5r1_org = rt2800_rfcsr_read_bank(rt2x00dev, 5, 1);
27 + rfb7r1_org = rt2800_rfcsr_read_bank(rt2x00dev, 7, 1);
28 +
29 + rt2800_rfcsr_write_bank(rt2x00dev, 5, 1, 0x4);
30 + for (i = 0; i < 100; i = i + 1) {
31 + udelay(50);
32 + rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 5, 1);
33 + if((rfvalue & 0x04) != 0x4)
34 + break;
35 + }
36 + rt2800_rfcsr_write_bank(rt2x00dev, 5, 1, rfb5r1_org);
37 +
38 + rt2800_rfcsr_write_bank(rt2x00dev, 7, 1, 0x4);
39 + for (i = 0; i < 100; i = i + 1) {
40 + udelay(50);
41 + rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 7, 1);
42 + if((rfvalue & 0x04) != 0x4)
43 + break;
44 + }
45 + rt2800_rfcsr_write_bank(rt2x00dev, 7, 1, rfb7r1_org);
46 +
47 + rt2800_register_write(rt2x00dev, RF_BYPASS0, 0x0);
48 + rt2800_register_write(rt2x00dev, RF_BYPASS2, 0x0);
49 + rt2800_register_write(rt2x00dev, RF_CONTROL0, mac0518);
50 + rt2800_register_write(rt2x00dev, RF_BYPASS0, mac051c);
51 + rt2800_register_write(rt2x00dev, RF_CONTROL2, mac0528);
52 + rt2800_register_write(rt2x00dev, RF_BYPASS2, mac052c);
53 +
54 + rt2x00_info(rt2x00dev, "RF Tx self calibration end\n");
55 +}
56 +
57 static void rt2800_bbp_core_soft_reset(struct rt2x00_dev *rt2x00dev,
58 bool set_bw, bool is_ht40)
59 {
60 @@ -9029,6 +9079,7 @@ static void rt2800_init_rfcsr_6352(struc
61 rt2800_rfcsr_write_dccal(rt2x00dev, 5, 0x00);
62 rt2800_rfcsr_write_dccal(rt2x00dev, 17, 0x7C);
63
64 + rt2800_rf_self_txdc_cal(rt2x00dev);
65 rt2800_bw_filter_calibration(rt2x00dev, true);
66 rt2800_bw_filter_calibration(rt2x00dev, false);
67 }