1 From 269f19c848a2380db03a3f207cafb88e28d71c53 Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Sun, 24 Mar 2013 19:26:28 +0100
4 Subject: [PATCH] rt2x00: rt2800lib: add channel configuration code for RT3883
6 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
8 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 72 +++++++++++++++++++++++++++++--
9 1 file changed, 69 insertions(+), 3 deletions(-)
11 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
12 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
13 @@ -3741,6 +3741,36 @@ static char rt2800_txpower_to_dev(struct
14 return clamp_t(char, txpower, MIN_A_TXPOWER, MAX_A_TXPOWER);
17 +static void rt3883_bbp_adjust(struct rt2x00_dev *rt2x00dev,
18 + struct rf_channel *rf)
22 + bbp = (rf->channel > 14) ? 0x48 : 0x38;
23 + rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, bbp);
25 + rt2800_bbp_write(rt2x00dev, 69, 0x12);
27 + if (rf->channel <= 14) {
28 + rt2800_bbp_write(rt2x00dev, 70, 0x0a);
30 + /* Disable CCK packet detection */
31 + rt2800_bbp_write(rt2x00dev, 70, 0x00);
34 + rt2800_bbp_write(rt2x00dev, 73, 0x10);
36 + if (rf->channel > 14) {
37 + rt2800_bbp_write(rt2x00dev, 62, 0x1d);
38 + rt2800_bbp_write(rt2x00dev, 63, 0x1d);
39 + rt2800_bbp_write(rt2x00dev, 64, 0x1d);
41 + rt2800_bbp_write(rt2x00dev, 62, 0x2d);
42 + rt2800_bbp_write(rt2x00dev, 63, 0x2d);
43 + rt2800_bbp_write(rt2x00dev, 64, 0x2d);
47 static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
48 struct ieee80211_conf *conf,
49 struct rf_channel *rf,
50 @@ -3759,6 +3789,12 @@ static void rt2800_config_channel(struct
51 rt2800_txpower_to_dev(rt2x00dev, rf->channel,
52 info->default_power3);
54 + switch (rt2x00dev->chip.rt) {
56 + rt3883_bbp_adjust(rt2x00dev, rf);
60 switch (rt2x00dev->chip.rf) {
63 @@ -3863,6 +3899,15 @@ static void rt2800_config_channel(struct
64 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
65 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain);
66 rt2800_bbp_write(rt2x00dev, 77, 0x98);
67 + } else if (rt2x00_rt(rt2x00dev, RT3883)) {
68 + rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain);
69 + rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
70 + rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain);
72 + if (rt2x00dev->default_ant.rx_chain_num > 1)
73 + rt2800_bbp_write(rt2x00dev, 86, 0x46);
75 + rt2800_bbp_write(rt2x00dev, 86, 0);
77 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain);
78 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
79 @@ -3876,6 +3921,7 @@ static void rt2800_config_channel(struct
80 !rt2x00_rt(rt2x00dev, RT6352)) {
81 if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) {
82 rt2800_bbp_write(rt2x00dev, 82, 0x62);
83 + rt2800_bbp_write(rt2x00dev, 82, 0x62);
84 rt2800_bbp_write(rt2x00dev, 75, 0x46);
86 if (rt2x00_rt(rt2x00dev, RT3593))
87 @@ -3884,19 +3930,22 @@ static void rt2800_config_channel(struct
88 rt2800_bbp_write(rt2x00dev, 82, 0x84);
89 rt2800_bbp_write(rt2x00dev, 75, 0x50);
91 - if (rt2x00_rt(rt2x00dev, RT3593))
92 + if (rt2x00_rt(rt2x00dev, RT3593) ||
93 + rt2x00_rt(rt2x00dev, RT3883))
94 rt2800_bbp_write(rt2x00dev, 83, 0x8a);
98 if (rt2x00_rt(rt2x00dev, RT3572))
99 rt2800_bbp_write(rt2x00dev, 82, 0x94);
100 - else if (rt2x00_rt(rt2x00dev, RT3593))
101 + else if (rt2x00_rt(rt2x00dev, RT3593) ||
102 + rt2x00_rt(rt2x00dev, RT3883))
103 rt2800_bbp_write(rt2x00dev, 82, 0x82);
104 else if (!rt2x00_rt(rt2x00dev, RT6352))
105 rt2800_bbp_write(rt2x00dev, 82, 0xf2);
107 - if (rt2x00_rt(rt2x00dev, RT3593))
108 + if (rt2x00_rt(rt2x00dev, RT3593) ||
109 + rt2x00_rt(rt2x00dev, RT3883))
110 rt2800_bbp_write(rt2x00dev, 83, 0x9a);
112 if (rt2x00_has_cap_external_lna_a(rt2x00dev))
113 @@ -4022,6 +4071,23 @@ static void rt2800_config_channel(struct
115 rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg);
117 + usleep_range(1000, 1500);
120 + if (rt2x00_rt(rt2x00dev, RT3883)) {
121 + if (!conf_is_ht40(conf))
122 + rt2800_bbp_write(rt2x00dev, 105, 0x34);
124 + rt2800_bbp_write(rt2x00dev, 105, 0x04);
127 + if (rf->channel <= 14)
128 + reg = 0x2e + rt2x00dev->lna_gain;
130 + reg = 0x20 + ((rt2x00dev->lna_gain * 5) / 3);
132 + rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg);
134 usleep_range(1000, 1500);