b6180efa8b6931484618765679d2d0143a9727de
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / rt2x00 / 984-rt2x00-add-rxdcoc-calibration.patch
1 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
2 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
3 @@ -8628,6 +8628,71 @@ void rt2800_r_calibration(struct rt2x00_
4 }
5 EXPORT_SYMBOL_GPL(rt2800_r_calibration);
6
7 +void rt2800_rxdcoc_calibration(struct rt2x00_dev *rt2x00dev)
8 +{
9 + u8 bbpreg = 0;
10 + u32 macvalue = 0, macvalue1 = 0;
11 + u8 saverfb0r2, saverfb5r4, saverfb7r4, rfvalue;
12 + int i;
13 +
14 + saverfb0r2 = rt2800_rfcsr_read_bank(rt2x00dev, 0, 2);
15 + rfvalue = saverfb0r2;
16 + rfvalue |= 0x03;
17 + rt2800_rfcsr_write_bank(rt2x00dev, 0, 2, rfvalue);
18 +
19 + rt2800_bbp_write(rt2x00dev, 158, 141);
20 + bbpreg = rt2800_bbp_read(rt2x00dev, 159);
21 + bbpreg |= 0x10;
22 + rt2800_bbp_write(rt2x00dev, 159, bbpreg);
23 +
24 + macvalue = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL);
25 + rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0x8);
26 +
27 + for (i = 0; i < 10000; i++) {
28 + macvalue1 = rt2800_register_read(rt2x00dev, MAC_STATUS_CFG);
29 + if (macvalue1 & 0x1)
30 + udelay(50);
31 + else
32 + break;
33 + }
34 +
35 + saverfb5r4 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 0);
36 + saverfb7r4 = rt2800_rfcsr_read_bank(rt2x00dev, 7, 4);
37 + saverfb5r4 = saverfb5r4 & (~0x40);
38 + saverfb7r4 = saverfb7r4 & (~0x40);
39 + rt2800_rfcsr_write_dccal(rt2x00dev, 4, 0x64);
40 + rt2800_rfcsr_write_bank(rt2x00dev, 5, 4, saverfb5r4);
41 + rt2800_rfcsr_write_bank(rt2x00dev, 7, 4, saverfb7r4);
42 +
43 + rt2800_bbp_write(rt2x00dev, 158, 141);
44 + bbpreg = rt2800_bbp_read(rt2x00dev, 159);
45 + bbpreg = bbpreg & (~0x40);
46 + rt2800_bbp_write(rt2x00dev, 159, bbpreg);
47 + bbpreg |= 0x48;
48 + rt2800_bbp_write(rt2x00dev, 159, bbpreg);
49 +
50 + for (i = 0; i < 10000; i++) {
51 + bbpreg = rt2800_bbp_read(rt2x00dev, 159);
52 + if ((bbpreg & 0x40)==0)
53 + break;
54 + udelay(50);
55 + }
56 +
57 + bbpreg = rt2800_bbp_read(rt2x00dev, 159);
58 + bbpreg = bbpreg & (~0x40);
59 + rt2800_bbp_write(rt2x00dev, 159, bbpreg);
60 +
61 + rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, macvalue);
62 +
63 + rt2800_bbp_write(rt2x00dev, 158, 141);
64 + bbpreg = rt2800_bbp_read(rt2x00dev, 159);
65 + bbpreg &= (~0x10);
66 + rt2800_bbp_write(rt2x00dev, 159, bbpreg);
67 +
68 + rt2800_rfcsr_write_bank(rt2x00dev, 0, 2, saverfb0r2);
69 +}
70 +EXPORT_SYMBOL_GPL(rt2800_rxdcoc_calibration);
71 +
72 static void rt2800_bbp_core_soft_reset(struct rt2x00_dev *rt2x00dev,
73 bool set_bw, bool is_ht40)
74 {
75 @@ -9237,6 +9302,7 @@ static void rt2800_init_rfcsr_6352(struc
76
77 rt2800_r_calibration(rt2x00dev);
78 rt2800_rf_self_txdc_cal(rt2x00dev);
79 + rt2800_rxdcoc_calibration(rt2x00dev);
80 rt2800_bw_filter_calibration(rt2x00dev, true);
81 rt2800_bw_filter_calibration(rt2x00dev, false);
82 }
83 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
84 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
85 @@ -245,6 +245,7 @@ void rt2800_vco_calibration(struct rt2x0
86 void rt2800_rf_self_txdc_cal(struct rt2x00_dev *rt2x00dev);
87 int rt2800_calcrcalibrationcode(struct rt2x00_dev *rt2x00dev, int d1, int d2);
88 void rt2800_r_calibration(struct rt2x00_dev *rt2x00dev);
89 +void rt2800_rxdcoc_calibration(struct rt2x00_dev *rt2x00dev);
90
91 int rt2800_enable_radio(struct rt2x00_dev *rt2x00dev);
92 void rt2800_disable_radio(struct rt2x00_dev *rt2x00dev);
93 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
94 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
95 @@ -565,6 +565,7 @@ struct rt2x00lib_ops {
96 void (*rf_self_txdc_cal) (struct rt2x00_dev *rt2x00dev);
97 int (*calcrcalibrationcode) (struct rt2x00_dev *rt2x00dev, int d1, int d2);
98 void (*r_calibration) (struct rt2x00_dev *rt2x00dev);
99 + void (*rxdcoc_calibration) (struct rt2x00_dev *rt2x00dev);
100
101 /*
102 * Data queue handlers.