1 /* zd_rf_al7230b.c: Functions for the AL7230B RF controller
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.
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.
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
18 #include <linux/kernel.h>
24 static 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 },
41 static const u32 std_rv
[] = {
45 0xafd401, /* freq shift 0xaad401 */
54 static int al7230b_init_hw(struct zd_rf
*rf
)
57 struct zd_chip
*chip
= zd_rf_to_chip(rf
);
59 /* All of these writes are identical to AL2230 unless otherwise
61 static const struct zd_ioreq16 ioreqs_1
[] = {
62 /* This one is 7230-specific, and happens before the rest */
66 { CR15
, 0x20 }, { CR23
, 0x40 }, { CR24
, 0x20 },
67 { CR26
, 0x11 }, { CR28
, 0x3e }, { CR29
, 0x00 },
69 /* This value is different for 7230 (was: 0x2a) */
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) */
77 /* for newest (3rd cut) AL2300 */
79 { CR26
, 0x93 }, { CR34
, 0x30 },
80 /* for newest (3rd cut) AL2300 */
82 { CR41
, 0x24 }, { CR44
, 0x32 },
83 /* for newest (3rd cut) AL2300 */
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) */
90 { CR101
, 0x13 }, { CR102
, 0x27 },
91 /* This value is different for 7230 (was: 0x24) */
93 /* This value is different for 7230 (was: 0x2a) */
96 /* This value is different for 7230 (was: 0x13) */
98 { CR111
, 0x1f }, { CR112
, 0x1f }, { CR113
, 0x27 },
100 /* for newest (3rd cut) AL2300 */
102 /* This value is different for 7230 (was: 0x24) */
104 /* This value is different for 7230 (was: 0xf4) */
106 { CR118
, 0xfc }, { CR119
, 0x10 }, { CR120
, 0x4f },
107 { CR121
, 0x77 }, { CR137
, 0x88 },
108 /* This one is 7230-specific */
110 /* This value is different for 7230 (was: 0xff) */
112 /* This value is different for 7230 (was: 0xff) */
119 static const struct zd_ioreq16 ioreqs_2
[] = {
122 { CR128
, 0x14 }, { CR129
, 0x12 }, { CR130
, 0x10 },
123 { CR38
, 0x38 }, { CR136
, 0xdf },
126 r
= zd_iowrite16a_locked(chip
, ioreqs_1
, ARRAY_SIZE(ioreqs_1
));
130 r
= zd_rfwrite_cr_locked(chip
, 0x09ec04);
133 r
= zd_rfwrite_cr_locked(chip
, 0x8cccc8);
137 for (i
= 0; i
< ARRAY_SIZE(std_rv
); i
++) {
138 r
= zd_rfwrite_cr_locked(chip
, std_rv
[i
]);
143 r
= zd_rfwrite_cr_locked(chip
, 0x3c9000);
146 r
= zd_rfwrite_cr_locked(chip
, 0xbfffff);
149 r
= zd_rfwrite_cr_locked(chip
, 0x700000);
152 r
= zd_rfwrite_cr_locked(chip
, 0xf15d58);
156 r
= zd_iowrite16a_locked(chip
, ioreqs_2
, ARRAY_SIZE(ioreqs_2
));
160 r
= zd_rfwrite_cr_locked(chip
, 0xf15d59);
163 r
= zd_rfwrite_cr_locked(chip
, 0xf15d5c);
166 r
= zd_rfwrite_cr_locked(chip
, 0xf15d58);
170 r
= zd_iowrite16_locked(chip
, 0x06, CR203
);
173 r
= zd_iowrite16_locked(chip
, 0x80, CR240
);
180 static int al7230b_set_channel(struct zd_rf
*rf
, u8 channel
)
183 const u32
*rv
= chan_rv
[channel
-1];
184 struct zd_chip
*chip
= zd_rf_to_chip(rf
);
186 struct zd_ioreq16 ioreqs_1
[] = {
187 { CR128
, 0x14 }, { CR129
, 0x12 }, { CR130
, 0x10 },
188 { CR38
, 0x38 }, { CR136
, 0xdf },
191 struct zd_ioreq16 ioreqs_2
[] = {
194 { CR203
, 0x06 }, { CR240
, 0x08 },
197 r
= zd_iowrite16_locked(chip
, 0x57, CR240
);
202 r
= zd_iowrite16_locked(chip
, 0x2f, CR251
);
206 for (i
= 0; i
< ARRAY_SIZE(std_rv
); i
++) {
207 r
= zd_rfwrite_cr_locked(chip
, std_rv
[i
]);
212 r
= zd_rfwrite_cr_locked(chip
, 0x3c9000);
215 r
= zd_rfwrite_cr_locked(chip
, 0xf15d58);
219 r
= zd_iowrite16a_locked(chip
, ioreqs_1
, ARRAY_SIZE(ioreqs_1
));
223 for (i
= 0; i
< 2; i
++) {
224 r
= zd_rfwrite_cr_locked(chip
, rv
[i
]);
229 r
= zd_rfwrite_cr_locked(chip
, 0x3c9000);
233 return zd_iowrite16a_locked(chip
, ioreqs_2
, ARRAY_SIZE(ioreqs_2
));
236 static int al7230b_switch_radio_on(struct zd_rf
*rf
)
238 struct zd_chip
*chip
= zd_rf_to_chip(rf
);
239 static const struct zd_ioreq16 ioreqs
[] = {
244 return zd_iowrite16a_locked(chip
, ioreqs
, ARRAY_SIZE(ioreqs
));
247 static int al7230b_switch_radio_off(struct zd_rf
*rf
)
249 struct zd_chip
*chip
= zd_rf_to_chip(rf
);
250 static const struct zd_ioreq16 ioreqs
[] = {
255 return zd_iowrite16a_locked(chip
, ioreqs
, ARRAY_SIZE(ioreqs
));
258 int zd_rf_init_al7230b(struct zd_rf
*rf
)
260 struct zd_chip
*chip
= zd_rf_to_chip(rf
);
262 if (chip
->is_zd1211b
) {
263 dev_err(zd_chip_dev(chip
), "AL7230B is currently not "
264 "supported for ZD1211B devices\n");
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;