aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Drake <dsd@gentoo.org>2006-08-12 12:59:46 -0400
committerJohn W. Linville <linville@tuxdriver.com>2006-08-14 15:43:21 -0400
commitec62bd91bbb58254dfddca3d290f5fe4aa1cb769 (patch)
treeb8c77202028f1a4f2cb2f1dda36882560bc99269
parent20fe2176e5edbeb5957f113df1282a917ef87b5d (diff)
[PATCH] zd1211rw: Support AL7230B RF
This patch adds support for another Airoha RF which is present in some ZD1211 adapters. This RF supports 802.11a as well as 802.11b/g, but 802.11a connectivity is not yet supported by this driver. Signed-off-by: Daniel Drake <dsd@gentoo.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/zd1211rw/Makefile1
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.c2
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.h2
-rw-r--r--drivers/net/wireless/zd1211rw/zd_rf.c5
-rw-r--r--drivers/net/wireless/zd1211rw/zd_rf.h1
-rw-r--r--drivers/net/wireless/zd1211rw/zd_rf_al7230b.c274
6 files changed, 284 insertions, 1 deletions
diff --git a/drivers/net/wireless/zd1211rw/Makefile b/drivers/net/wireless/zd1211rw/Makefile
index 500314fc74d2..6603ad5be63d 100644
--- a/drivers/net/wireless/zd1211rw/Makefile
+++ b/drivers/net/wireless/zd1211rw/Makefile
@@ -3,6 +3,7 @@ obj-$(CONFIG_ZD1211RW) += zd1211rw.o
3zd1211rw-objs := zd_chip.o zd_ieee80211.o \ 3zd1211rw-objs := zd_chip.o zd_ieee80211.o \
4 zd_mac.o zd_netdev.o \ 4 zd_mac.o zd_netdev.o \
5 zd_rf_al2230.o zd_rf_rf2959.o \ 5 zd_rf_al2230.o zd_rf_rf2959.o \
6 zd_rf_al7230b.o \
6 zd_rf.o zd_usb.o zd_util.o 7 zd_rf.o zd_usb.o zd_util.o
7 8
8ifeq ($(CONFIG_ZD1211RW_DEBUG),y) 9ifeq ($(CONFIG_ZD1211RW_DEBUG),y)
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c
index 8cc693d80f7f..e7e92eccff5e 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.c
+++ b/drivers/net/wireless/zd1211rw/zd_chip.c
@@ -1624,7 +1624,7 @@ int zd_rfwritev_locked(struct zd_chip *chip,
1624 * We can optionally program the RF directly through CR regs, if supported by 1624 * We can optionally program the RF directly through CR regs, if supported by
1625 * the hardware. This is much faster than the older method. 1625 * the hardware. This is much faster than the older method.
1626 */ 1626 */
1627static int zd_rfwrite_cr_locked(struct zd_chip *chip, u32 value) 1627int zd_rfwrite_cr_locked(struct zd_chip *chip, u32 value)
1628{ 1628{
1629 struct zd_ioreq16 ioreqs[] = { 1629 struct zd_ioreq16 ioreqs[] = {
1630 { CR244, (value >> 16) & 0xff }, 1630 { CR244, (value >> 16) & 0xff },
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.h b/drivers/net/wireless/zd1211rw/zd_chip.h
index a7fc61ba5874..9f663f66901a 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.h
+++ b/drivers/net/wireless/zd1211rw/zd_chip.h
@@ -747,6 +747,8 @@ static inline int zd_rfwrite_locked(struct zd_chip *chip, u32 value, u8 bits)
747 return zd_usb_rfwrite(&chip->usb, value, bits); 747 return zd_usb_rfwrite(&chip->usb, value, bits);
748} 748}
749 749
750int zd_rfwrite_cr_locked(struct zd_chip *chip, u32 value);
751
750int zd_rfwritev_locked(struct zd_chip *chip, 752int zd_rfwritev_locked(struct zd_chip *chip,
751 const u32* values, unsigned int count, u8 bits); 753 const u32* values, unsigned int count, u8 bits);
752int zd_rfwritev_cr_locked(struct zd_chip *chip, 754int zd_rfwritev_cr_locked(struct zd_chip *chip,
diff --git a/drivers/net/wireless/zd1211rw/zd_rf.c b/drivers/net/wireless/zd1211rw/zd_rf.c
index d3770d2c61bc..ccf639a398b7 100644
--- a/drivers/net/wireless/zd1211rw/zd_rf.c
+++ b/drivers/net/wireless/zd1211rw/zd_rf.c
@@ -76,6 +76,11 @@ int zd_rf_init_hw(struct zd_rf *rf, u8 type)
76 if (r) 76 if (r)
77 return r; 77 return r;
78 break; 78 break;
79 case AL7230B_RF:
80 r = zd_rf_init_al7230b(rf);
81 if (r)
82 return r;
83 break;
79 default: 84 default:
80 dev_err(zd_chip_dev(chip), 85 dev_err(zd_chip_dev(chip),
81 "RF %s %#x is not supported\n", zd_rf_name(type), type); 86 "RF %s %#x is not supported\n", zd_rf_name(type), type);
diff --git a/drivers/net/wireless/zd1211rw/zd_rf.h b/drivers/net/wireless/zd1211rw/zd_rf.h
index ea30f693fcc8..676b3734f1ed 100644
--- a/drivers/net/wireless/zd1211rw/zd_rf.h
+++ b/drivers/net/wireless/zd1211rw/zd_rf.h
@@ -78,5 +78,6 @@ int zd_switch_radio_off(struct zd_rf *rf);
78 78
79int zd_rf_init_rf2959(struct zd_rf *rf); 79int zd_rf_init_rf2959(struct zd_rf *rf);
80int zd_rf_init_al2230(struct zd_rf *rf); 80int zd_rf_init_al2230(struct zd_rf *rf);
81int zd_rf_init_al7230b(struct zd_rf *rf);
81 82
82#endif /* _ZD_RF_H */ 83#endif /* _ZD_RF_H */
diff --git a/drivers/net/wireless/zd1211rw/zd_rf_al7230b.c b/drivers/net/wireless/zd1211rw/zd_rf_al7230b.c
new file mode 100644
index 000000000000..a289f95187ec
--- /dev/null
+++ b/drivers/net/wireless/zd1211rw/zd_rf_al7230b.c
@@ -0,0 +1,274 @@
1/* zd_rf_al7230b.c: Functions for the AL7230B RF controller
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18#include <linux/kernel.h>
19
20#include "zd_rf.h"
21#include "zd_usb.h"
22#include "zd_chip.h"
23
24static const u32 chan_rv[][2] = {
25 RF_CHANNEL( 1) = { 0x09ec00, 0x8cccc8 },
26 RF_CHANNEL( 2) = { 0x09ec00, 0x8cccd8 },
27 RF_CHANNEL( 3) = { 0x09ec00, 0x8cccc0 },
28 RF_CHANNEL( 4) = { 0x09ec00, 0x8cccd0 },
29 RF_CHANNEL( 5) = { 0x05ec00, 0x8cccc8 },
30 RF_CHANNEL( 6) = { 0x05ec00, 0x8cccd8 },
31 RF_CHANNEL( 7) = { 0x05ec00, 0x8cccc0 },
32 RF_CHANNEL( 8) = { 0x05ec00, 0x8cccd0 },
33 RF_CHANNEL( 9) = { 0x0dec00, 0x8cccc8 },
34 RF_CHANNEL(10) = { 0x0dec00, 0x8cccd8 },
35 RF_CHANNEL(11) = { 0x0dec00, 0x8cccc0 },
36 RF_CHANNEL(12) = { 0x0dec00, 0x8cccd0 },
37 RF_CHANNEL(13) = { 0x03ec00, 0x8cccc8 },
38 RF_CHANNEL(14) = { 0x03ec00, 0x866660 },
39};
40
41static const u32 std_rv[] = {
42 0x4ff821,
43 0xc5fbfc,
44 0x21ebfe,
45 0xafd401, /* freq shift 0xaad401 */
46 0x6cf56a,
47 0xe04073,
48 0x193d76,
49 0x9dd844,
50 0x500007,
51 0xd8c010,
52};
53
54static int al7230b_init_hw(struct zd_rf *rf)
55{
56 int i, r;
57 struct zd_chip *chip = zd_rf_to_chip(rf);
58
59 /* All of these writes are identical to AL2230 unless otherwise
60 * specified */
61 static const struct zd_ioreq16 ioreqs_1[] = {
62 /* This one is 7230-specific, and happens before the rest */
63 { CR240, 0x57 },
64 { },
65
66 { CR15, 0x20 }, { CR23, 0x40 }, { CR24, 0x20 },
67 { CR26, 0x11 }, { CR28, 0x3e }, { CR29, 0x00 },
68 { CR44, 0x33 },
69 /* This value is different for 7230 (was: 0x2a) */
70 { CR106, 0x22 },
71 { CR107, 0x1a }, { CR109, 0x09 }, { CR110, 0x27 },
72 { CR111, 0x2b }, { CR112, 0x2b }, { CR119, 0x0a },
73 /* This happened further down in AL2230,
74 * and the value changed (was: 0xe0) */
75 { CR122, 0xfc },
76 { CR10, 0x89 },
77 /* for newest (3rd cut) AL2300 */
78 { CR17, 0x28 },
79 { CR26, 0x93 }, { CR34, 0x30 },
80 /* for newest (3rd cut) AL2300 */
81 { CR35, 0x3e },
82 { CR41, 0x24 }, { CR44, 0x32 },
83 /* for newest (3rd cut) AL2300 */
84 { CR46, 0x96 },
85 { CR47, 0x1e }, { CR79, 0x58 }, { CR80, 0x30 },
86 { CR81, 0x30 }, { CR87, 0x0a }, { CR89, 0x04 },
87 { CR92, 0x0a }, { CR99, 0x28 },
88 /* This value is different for 7230 (was: 0x00) */
89 { CR100, 0x02 },
90 { CR101, 0x13 }, { CR102, 0x27 },
91 /* This value is different for 7230 (was: 0x24) */
92 { CR106, 0x22 },
93 /* This value is different for 7230 (was: 0x2a) */
94 { CR107, 0x3f },
95 { CR109, 0x09 },
96 /* This value is different for 7230 (was: 0x13) */
97 { CR110, 0x1f },
98 { CR111, 0x1f }, { CR112, 0x1f }, { CR113, 0x27 },
99 { CR114, 0x27 },
100 /* for newest (3rd cut) AL2300 */
101 { CR115, 0x24 },
102 /* This value is different for 7230 (was: 0x24) */
103 { CR116, 0x3f },
104 /* This value is different for 7230 (was: 0xf4) */
105 { CR117, 0xfa },
106 { CR118, 0xfc }, { CR119, 0x10 }, { CR120, 0x4f },
107 { CR121, 0x77 }, { CR137, 0x88 },
108 /* This one is 7230-specific */
109 { CR138, 0xa8 },
110 /* This value is different for 7230 (was: 0xff) */
111 { CR252, 0x34 },
112 /* This value is different for 7230 (was: 0xff) */
113 { CR253, 0x34 },
114
115 /* PLL_OFF */
116 { CR251, 0x2f },
117 };
118
119 static const struct zd_ioreq16 ioreqs_2[] = {
120 /* PLL_ON */
121 { CR251, 0x3f },
122 { CR128, 0x14 }, { CR129, 0x12 }, { CR130, 0x10 },
123 { CR38, 0x38 }, { CR136, 0xdf },
124 };
125
126 r = zd_iowrite16a_locked(chip, ioreqs_1, ARRAY_SIZE(ioreqs_1));
127 if (r)
128 return r;
129
130 r = zd_rfwrite_cr_locked(chip, 0x09ec04);
131 if (r)
132 return r;
133 r = zd_rfwrite_cr_locked(chip, 0x8cccc8);
134 if (r)
135 return r;
136
137 for (i = 0; i < ARRAY_SIZE(std_rv); i++) {
138 r = zd_rfwrite_cr_locked(chip, std_rv[i]);
139 if (r)
140 return r;
141 }
142
143 r = zd_rfwrite_cr_locked(chip, 0x3c9000);
144 if (r)
145 return r;
146 r = zd_rfwrite_cr_locked(chip, 0xbfffff);
147 if (r)
148 return r;
149 r = zd_rfwrite_cr_locked(chip, 0x700000);
150 if (r)
151 return r;
152 r = zd_rfwrite_cr_locked(chip, 0xf15d58);
153 if (r)
154 return r;
155
156 r = zd_iowrite16a_locked(chip, ioreqs_2, ARRAY_SIZE(ioreqs_2));
157 if (r)
158 return r;
159
160 r = zd_rfwrite_cr_locked(chip, 0xf15d59);
161 if (r)
162 return r;
163 r = zd_rfwrite_cr_locked(chip, 0xf15d5c);
164 if (r)
165 return r;
166 r = zd_rfwrite_cr_locked(chip, 0xf15d58);
167 if (r)
168 return r;
169
170 r = zd_iowrite16_locked(chip, 0x06, CR203);
171 if (r)
172 return r;
173 r = zd_iowrite16_locked(chip, 0x80, CR240);
174 if (r)
175 return r;
176
177 return 0;
178}
179
180static int al7230b_set_channel(struct zd_rf *rf, u8 channel)
181{
182 int i, r;
183 const u32 *rv = chan_rv[channel-1];
184 struct zd_chip *chip = zd_rf_to_chip(rf);
185
186 struct zd_ioreq16 ioreqs_1[] = {
187 { CR128, 0x14 }, { CR129, 0x12 }, { CR130, 0x10 },
188 { CR38, 0x38 }, { CR136, 0xdf },
189 };
190
191 struct zd_ioreq16 ioreqs_2[] = {
192 /* PLL_ON */
193 { CR251, 0x3f },
194 { CR203, 0x06 }, { CR240, 0x08 },
195 };
196
197 r = zd_iowrite16_locked(chip, 0x57, CR240);
198 if (r)
199 return r;
200
201 /* PLL_OFF */
202 r = zd_iowrite16_locked(chip, 0x2f, CR251);
203 if (r)
204 return r;
205
206 for (i = 0; i < ARRAY_SIZE(std_rv); i++) {
207 r = zd_rfwrite_cr_locked(chip, std_rv[i]);
208 if (r)
209 return r;
210 }
211
212 r = zd_rfwrite_cr_locked(chip, 0x3c9000);
213 if (r)
214 return r;
215 r = zd_rfwrite_cr_locked(chip, 0xf15d58);
216 if (r)
217 return r;
218
219 r = zd_iowrite16a_locked(chip, ioreqs_1, ARRAY_SIZE(ioreqs_1));
220 if (r)
221 return r;
222
223 for (i = 0; i < 2; i++) {
224 r = zd_rfwrite_cr_locked(chip, rv[i]);
225 if (r)
226 return r;
227 }
228
229 r = zd_rfwrite_cr_locked(chip, 0x3c9000);
230 if (r)
231 return r;
232
233 return zd_iowrite16a_locked(chip, ioreqs_2, ARRAY_SIZE(ioreqs_2));
234}
235
236static int al7230b_switch_radio_on(struct zd_rf *rf)
237{
238 struct zd_chip *chip = zd_rf_to_chip(rf);
239 static const struct zd_ioreq16 ioreqs[] = {
240 { CR11, 0x00 },
241 { CR251, 0x3f },
242 };
243
244 return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
245}
246
247static int al7230b_switch_radio_off(struct zd_rf *rf)
248{
249 struct zd_chip *chip = zd_rf_to_chip(rf);
250 static const struct zd_ioreq16 ioreqs[] = {
251 { CR11, 0x04 },
252 { CR251, 0x2f },
253 };
254
255 return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
256}
257
258int zd_rf_init_al7230b(struct zd_rf *rf)
259{
260 struct zd_chip *chip = zd_rf_to_chip(rf);
261
262 if (chip->is_zd1211b) {
263 dev_err(zd_chip_dev(chip), "AL7230B is currently not "
264 "supported for ZD1211B devices\n");
265 return -ENODEV;
266 }
267
268 rf->init_hw = al7230b_init_hw;
269 rf->set_channel = al7230b_set_channel;
270 rf->switch_radio_on = al7230b_switch_radio_on;
271 rf->switch_radio_off = al7230b_switch_radio_off;
272 rf->patch_6m_band_edge = 1;
273 return 0;
274}