Lines Matching +full:0 +full:- +full:dev
1 // SPDX-License-Identifier: GPL-2.0-or-later
6 Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
14 driver Copyright(c) 2003 - 2004 Intel Corporation.
33 0x4D, 0x4C, 0x4B, 0x4A,
34 0x4A, 0x49, 0x48, 0x47,
35 0x47, 0x46, 0x45, 0x45,
36 0x44, 0x43, 0x42, 0x42,
37 0x41, 0x40, 0x3F, 0x3E,
38 0x3D, 0x3C, 0x3B, 0x3A,
39 0x39, 0x38, 0x37, 0x36,
40 0x35, 0x34, 0x32, 0x31,
41 0x30, 0x2F, 0x2D, 0x2C,
42 0x2B, 0x29, 0x28, 0x26,
43 0x25, 0x23, 0x21, 0x1F,
44 0x1D, 0x1A, 0x17, 0x14,
45 0x10, 0x0C, 0x06, 0x00,
46 -7, -7, -7, -7,
47 -7, -7, -7, -7,
48 -7, -7, -7, -7,
65 5, -7, -20, -20,
66 -20, -20, -20, -20,
67 -20, -20, -20, -20,
70 static void b43legacy_phy_initg(struct b43legacy_wldev *dev);
74 void b43legacy_phy_lock(struct b43legacy_wldev *dev) in b43legacy_phy_lock() argument
77 B43legacy_WARN_ON(dev->phy.phy_locked); in b43legacy_phy_lock()
78 dev->phy.phy_locked = 1; in b43legacy_phy_lock()
81 if (dev->dev->id.revision < 3) { in b43legacy_phy_lock()
82 b43legacy_mac_suspend(dev); in b43legacy_phy_lock()
84 if (!b43legacy_is_mode(dev->wl, NL80211_IFTYPE_AP)) in b43legacy_phy_lock()
85 b43legacy_power_saving_ctl_bits(dev, -1, 1); in b43legacy_phy_lock()
89 void b43legacy_phy_unlock(struct b43legacy_wldev *dev) in b43legacy_phy_unlock() argument
92 B43legacy_WARN_ON(!dev->phy.phy_locked); in b43legacy_phy_unlock()
93 dev->phy.phy_locked = 0; in b43legacy_phy_unlock()
96 if (dev->dev->id.revision < 3) { in b43legacy_phy_unlock()
97 b43legacy_mac_enable(dev); in b43legacy_phy_unlock()
99 if (!b43legacy_is_mode(dev->wl, NL80211_IFTYPE_AP)) in b43legacy_phy_unlock()
100 b43legacy_power_saving_ctl_bits(dev, -1, -1); in b43legacy_phy_unlock()
104 u16 b43legacy_phy_read(struct b43legacy_wldev *dev, u16 offset) in b43legacy_phy_read() argument
106 b43legacy_write16(dev, B43legacy_MMIO_PHY_CONTROL, offset); in b43legacy_phy_read()
107 return b43legacy_read16(dev, B43legacy_MMIO_PHY_DATA); in b43legacy_phy_read()
110 void b43legacy_phy_write(struct b43legacy_wldev *dev, u16 offset, u16 val) in b43legacy_phy_write() argument
112 b43legacy_write16(dev, B43legacy_MMIO_PHY_CONTROL, offset); in b43legacy_phy_write()
113 b43legacy_write16(dev, B43legacy_MMIO_PHY_DATA, val); in b43legacy_phy_write()
116 void b43legacy_phy_calibrate(struct b43legacy_wldev *dev) in b43legacy_phy_calibrate() argument
118 struct b43legacy_phy *phy = &dev->phy; in b43legacy_phy_calibrate()
120 b43legacy_read32(dev, B43legacy_MMIO_MACCTL); /* Dummy read. */ in b43legacy_phy_calibrate()
121 if (phy->calibrated) in b43legacy_phy_calibrate()
123 if (phy->type == B43legacy_PHYTYPE_G && phy->rev == 1) { in b43legacy_phy_calibrate()
124 b43legacy_wireless_core_reset(dev, 0); in b43legacy_phy_calibrate()
125 b43legacy_phy_initg(dev); in b43legacy_phy_calibrate()
126 b43legacy_wireless_core_reset(dev, B43legacy_TMSLOW_GMODE); in b43legacy_phy_calibrate()
128 phy->calibrated = 1; in b43legacy_phy_calibrate()
132 * as described in https://bcm-specs.sipsolutions.net/InitPowerControl
134 static void b43legacy_phy_init_pctl(struct b43legacy_wldev *dev) in b43legacy_phy_init_pctl() argument
136 struct b43legacy_phy *phy = &dev->phy; in b43legacy_phy_init_pctl()
137 u16 saved_batt = 0; in b43legacy_phy_init_pctl()
138 u16 saved_ratt = 0; in b43legacy_phy_init_pctl()
139 u16 saved_txctl1 = 0; in b43legacy_phy_init_pctl()
140 int must_reset_txpower = 0; in b43legacy_phy_init_pctl()
142 B43legacy_BUG_ON(!(phy->type == B43legacy_PHYTYPE_B || in b43legacy_phy_init_pctl()
143 phy->type == B43legacy_PHYTYPE_G)); in b43legacy_phy_init_pctl()
144 if (is_bcm_board_vendor(dev) && in b43legacy_phy_init_pctl()
145 (dev->dev->bus->boardinfo.type == 0x0416)) in b43legacy_phy_init_pctl()
148 b43legacy_phy_write(dev, 0x0028, 0x8018); in b43legacy_phy_init_pctl()
149 b43legacy_write16(dev, 0x03E6, b43legacy_read16(dev, 0x03E6) & 0xFFDF); in b43legacy_phy_init_pctl()
151 if (phy->type == B43legacy_PHYTYPE_G) { in b43legacy_phy_init_pctl()
152 if (!phy->gmode) in b43legacy_phy_init_pctl()
154 b43legacy_phy_write(dev, 0x047A, 0xC111); in b43legacy_phy_init_pctl()
156 if (phy->savedpctlreg != 0xFFFF) in b43legacy_phy_init_pctl()
159 if (phy->manual_txpower_control) in b43legacy_phy_init_pctl()
163 if (phy->type == B43legacy_PHYTYPE_B && in b43legacy_phy_init_pctl()
164 phy->rev >= 2 && in b43legacy_phy_init_pctl()
165 phy->radio_ver == 0x2050) in b43legacy_phy_init_pctl()
166 b43legacy_radio_write16(dev, 0x0076, in b43legacy_phy_init_pctl()
167 b43legacy_radio_read16(dev, 0x0076) in b43legacy_phy_init_pctl()
168 | 0x0084); in b43legacy_phy_init_pctl()
170 saved_batt = phy->bbatt; in b43legacy_phy_init_pctl()
171 saved_ratt = phy->rfatt; in b43legacy_phy_init_pctl()
172 saved_txctl1 = phy->txctl1; in b43legacy_phy_init_pctl()
173 if ((phy->radio_rev >= 6) && (phy->radio_rev <= 8) in b43legacy_phy_init_pctl()
174 && /*FIXME: incomplete specs for 5 < revision < 9 */ 0) in b43legacy_phy_init_pctl()
175 b43legacy_radio_set_txpower_bg(dev, 0xB, 0x1F, 0); in b43legacy_phy_init_pctl()
177 b43legacy_radio_set_txpower_bg(dev, 0xB, 9, 0); in b43legacy_phy_init_pctl()
180 b43legacy_dummy_transmission(dev); in b43legacy_phy_init_pctl()
182 phy->savedpctlreg = b43legacy_phy_read(dev, B43legacy_PHY_G_PCTL); in b43legacy_phy_init_pctl()
185 b43legacy_radio_set_txpower_bg(dev, saved_batt, saved_ratt, in b43legacy_phy_init_pctl()
188 b43legacy_radio_write16(dev, 0x0076, b43legacy_radio_read16(dev, in b43legacy_phy_init_pctl()
189 0x0076) & 0xFF7B); in b43legacy_phy_init_pctl()
190 b43legacy_radio_clear_tssi(dev); in b43legacy_phy_init_pctl()
193 static void b43legacy_phy_agcsetup(struct b43legacy_wldev *dev) in b43legacy_phy_agcsetup() argument
195 struct b43legacy_phy *phy = &dev->phy; in b43legacy_phy_agcsetup()
196 u16 offset = 0x0000; in b43legacy_phy_agcsetup()
198 if (phy->rev == 1) in b43legacy_phy_agcsetup()
199 offset = 0x4C00; in b43legacy_phy_agcsetup()
201 b43legacy_ilt_write(dev, offset, 0x00FE); in b43legacy_phy_agcsetup()
202 b43legacy_ilt_write(dev, offset + 1, 0x000D); in b43legacy_phy_agcsetup()
203 b43legacy_ilt_write(dev, offset + 2, 0x0013); in b43legacy_phy_agcsetup()
204 b43legacy_ilt_write(dev, offset + 3, 0x0019); in b43legacy_phy_agcsetup()
206 if (phy->rev == 1) { in b43legacy_phy_agcsetup()
207 b43legacy_ilt_write(dev, 0x1800, 0x2710); in b43legacy_phy_agcsetup()
208 b43legacy_ilt_write(dev, 0x1801, 0x9B83); in b43legacy_phy_agcsetup()
209 b43legacy_ilt_write(dev, 0x1802, 0x9B83); in b43legacy_phy_agcsetup()
210 b43legacy_ilt_write(dev, 0x1803, 0x0F8D); in b43legacy_phy_agcsetup()
211 b43legacy_phy_write(dev, 0x0455, 0x0004); in b43legacy_phy_agcsetup()
214 b43legacy_phy_write(dev, 0x04A5, (b43legacy_phy_read(dev, 0x04A5) in b43legacy_phy_agcsetup()
215 & 0x00FF) | 0x5700); in b43legacy_phy_agcsetup()
216 b43legacy_phy_write(dev, 0x041A, (b43legacy_phy_read(dev, 0x041A) in b43legacy_phy_agcsetup()
217 & 0xFF80) | 0x000F); in b43legacy_phy_agcsetup()
218 b43legacy_phy_write(dev, 0x041A, (b43legacy_phy_read(dev, 0x041A) in b43legacy_phy_agcsetup()
219 & 0xC07F) | 0x2B80); in b43legacy_phy_agcsetup()
220 b43legacy_phy_write(dev, 0x048C, (b43legacy_phy_read(dev, 0x048C) in b43legacy_phy_agcsetup()
221 & 0xF0FF) | 0x0300); in b43legacy_phy_agcsetup()
223 b43legacy_radio_write16(dev, 0x007A, in b43legacy_phy_agcsetup()
224 b43legacy_radio_read16(dev, 0x007A) in b43legacy_phy_agcsetup()
225 | 0x0008); in b43legacy_phy_agcsetup()
227 b43legacy_phy_write(dev, 0x04A0, (b43legacy_phy_read(dev, 0x04A0) in b43legacy_phy_agcsetup()
228 & 0xFFF0) | 0x0008); in b43legacy_phy_agcsetup()
229 b43legacy_phy_write(dev, 0x04A1, (b43legacy_phy_read(dev, 0x04A1) in b43legacy_phy_agcsetup()
230 & 0xF0FF) | 0x0600); in b43legacy_phy_agcsetup()
231 b43legacy_phy_write(dev, 0x04A2, (b43legacy_phy_read(dev, 0x04A2) in b43legacy_phy_agcsetup()
232 & 0xF0FF) | 0x0700); in b43legacy_phy_agcsetup()
233 b43legacy_phy_write(dev, 0x04A0, (b43legacy_phy_read(dev, 0x04A0) in b43legacy_phy_agcsetup()
234 & 0xF0FF) | 0x0100); in b43legacy_phy_agcsetup()
236 if (phy->rev == 1) in b43legacy_phy_agcsetup()
237 b43legacy_phy_write(dev, 0x04A2, in b43legacy_phy_agcsetup()
238 (b43legacy_phy_read(dev, 0x04A2) in b43legacy_phy_agcsetup()
239 & 0xFFF0) | 0x0007); in b43legacy_phy_agcsetup()
241 b43legacy_phy_write(dev, 0x0488, (b43legacy_phy_read(dev, 0x0488) in b43legacy_phy_agcsetup()
242 & 0xFF00) | 0x001C); in b43legacy_phy_agcsetup()
243 b43legacy_phy_write(dev, 0x0488, (b43legacy_phy_read(dev, 0x0488) in b43legacy_phy_agcsetup()
244 & 0xC0FF) | 0x0200); in b43legacy_phy_agcsetup()
245 b43legacy_phy_write(dev, 0x0496, (b43legacy_phy_read(dev, 0x0496) in b43legacy_phy_agcsetup()
246 & 0xFF00) | 0x001C); in b43legacy_phy_agcsetup()
247 b43legacy_phy_write(dev, 0x0489, (b43legacy_phy_read(dev, 0x0489) in b43legacy_phy_agcsetup()
248 & 0xFF00) | 0x0020); in b43legacy_phy_agcsetup()
249 b43legacy_phy_write(dev, 0x0489, (b43legacy_phy_read(dev, 0x0489) in b43legacy_phy_agcsetup()
250 & 0xC0FF) | 0x0200); in b43legacy_phy_agcsetup()
251 b43legacy_phy_write(dev, 0x0482, (b43legacy_phy_read(dev, 0x0482) in b43legacy_phy_agcsetup()
252 & 0xFF00) | 0x002E); in b43legacy_phy_agcsetup()
253 b43legacy_phy_write(dev, 0x0496, (b43legacy_phy_read(dev, 0x0496) in b43legacy_phy_agcsetup()
254 & 0x00FF) | 0x1A00); in b43legacy_phy_agcsetup()
255 b43legacy_phy_write(dev, 0x0481, (b43legacy_phy_read(dev, 0x0481) in b43legacy_phy_agcsetup()
256 & 0xFF00) | 0x0028); in b43legacy_phy_agcsetup()
257 b43legacy_phy_write(dev, 0x0481, (b43legacy_phy_read(dev, 0x0481) in b43legacy_phy_agcsetup()
258 & 0x00FF) | 0x2C00); in b43legacy_phy_agcsetup()
260 if (phy->rev == 1) { in b43legacy_phy_agcsetup()
261 b43legacy_phy_write(dev, 0x0430, 0x092B); in b43legacy_phy_agcsetup()
262 b43legacy_phy_write(dev, 0x041B, in b43legacy_phy_agcsetup()
263 (b43legacy_phy_read(dev, 0x041B) in b43legacy_phy_agcsetup()
264 & 0xFFE1) | 0x0002); in b43legacy_phy_agcsetup()
266 b43legacy_phy_write(dev, 0x041B, in b43legacy_phy_agcsetup()
267 b43legacy_phy_read(dev, 0x041B) & 0xFFE1); in b43legacy_phy_agcsetup()
268 b43legacy_phy_write(dev, 0x041F, 0x287A); in b43legacy_phy_agcsetup()
269 b43legacy_phy_write(dev, 0x0420, in b43legacy_phy_agcsetup()
270 (b43legacy_phy_read(dev, 0x0420) in b43legacy_phy_agcsetup()
271 & 0xFFF0) | 0x0004); in b43legacy_phy_agcsetup()
274 if (phy->rev > 2) { in b43legacy_phy_agcsetup()
275 b43legacy_phy_write(dev, 0x0422, 0x287A); in b43legacy_phy_agcsetup()
276 b43legacy_phy_write(dev, 0x0420, in b43legacy_phy_agcsetup()
277 (b43legacy_phy_read(dev, 0x0420) in b43legacy_phy_agcsetup()
278 & 0x0FFF) | 0x3000); in b43legacy_phy_agcsetup()
281 b43legacy_phy_write(dev, 0x04A8, (b43legacy_phy_read(dev, 0x04A8) in b43legacy_phy_agcsetup()
282 & 0x8080) | 0x7874); in b43legacy_phy_agcsetup()
283 b43legacy_phy_write(dev, 0x048E, 0x1C00); in b43legacy_phy_agcsetup()
285 if (phy->rev == 1) { in b43legacy_phy_agcsetup()
286 b43legacy_phy_write(dev, 0x04AB, in b43legacy_phy_agcsetup()
287 (b43legacy_phy_read(dev, 0x04AB) in b43legacy_phy_agcsetup()
288 & 0xF0FF) | 0x0600); in b43legacy_phy_agcsetup()
289 b43legacy_phy_write(dev, 0x048B, 0x005E); in b43legacy_phy_agcsetup()
290 b43legacy_phy_write(dev, 0x048C, in b43legacy_phy_agcsetup()
291 (b43legacy_phy_read(dev, 0x048C) & 0xFF00) in b43legacy_phy_agcsetup()
292 | 0x001E); in b43legacy_phy_agcsetup()
293 b43legacy_phy_write(dev, 0x048D, 0x0002); in b43legacy_phy_agcsetup()
296 b43legacy_ilt_write(dev, offset + 0x0800, 0); in b43legacy_phy_agcsetup()
297 b43legacy_ilt_write(dev, offset + 0x0801, 7); in b43legacy_phy_agcsetup()
298 b43legacy_ilt_write(dev, offset + 0x0802, 16); in b43legacy_phy_agcsetup()
299 b43legacy_ilt_write(dev, offset + 0x0803, 28); in b43legacy_phy_agcsetup()
301 if (phy->rev >= 6) { in b43legacy_phy_agcsetup()
302 b43legacy_phy_write(dev, 0x0426, in b43legacy_phy_agcsetup()
303 (b43legacy_phy_read(dev, 0x0426) & 0xFFFC)); in b43legacy_phy_agcsetup()
304 b43legacy_phy_write(dev, 0x0426, in b43legacy_phy_agcsetup()
305 (b43legacy_phy_read(dev, 0x0426) & 0xEFFF)); in b43legacy_phy_agcsetup()
309 static void b43legacy_phy_setupg(struct b43legacy_wldev *dev) in b43legacy_phy_setupg() argument
311 struct b43legacy_phy *phy = &dev->phy; in b43legacy_phy_setupg()
314 B43legacy_BUG_ON(phy->type != B43legacy_PHYTYPE_G); in b43legacy_phy_setupg()
315 if (phy->rev == 1) { in b43legacy_phy_setupg()
316 b43legacy_phy_write(dev, 0x0406, 0x4F19); in b43legacy_phy_setupg()
317 b43legacy_phy_write(dev, B43legacy_PHY_G_CRS, in b43legacy_phy_setupg()
318 (b43legacy_phy_read(dev, in b43legacy_phy_setupg()
319 B43legacy_PHY_G_CRS) & 0xFC3F) | 0x0340); in b43legacy_phy_setupg()
320 b43legacy_phy_write(dev, 0x042C, 0x005A); in b43legacy_phy_setupg()
321 b43legacy_phy_write(dev, 0x0427, 0x001A); in b43legacy_phy_setupg()
323 for (i = 0; i < B43legacy_ILT_FINEFREQG_SIZE; i++) in b43legacy_phy_setupg()
324 b43legacy_ilt_write(dev, 0x5800 + i, in b43legacy_phy_setupg()
326 for (i = 0; i < B43legacy_ILT_NOISEG1_SIZE; i++) in b43legacy_phy_setupg()
327 b43legacy_ilt_write(dev, 0x1800 + i, in b43legacy_phy_setupg()
329 for (i = 0; i < B43legacy_ILT_ROTOR_SIZE; i++) in b43legacy_phy_setupg()
330 b43legacy_ilt_write32(dev, 0x2000 + i, in b43legacy_phy_setupg()
333 /* nrssi values are signed 6-bit values. Why 0x7654 here? */ in b43legacy_phy_setupg()
334 b43legacy_nrssi_hw_write(dev, 0xBA98, (s16)0x7654); in b43legacy_phy_setupg()
336 if (phy->rev == 2) { in b43legacy_phy_setupg()
337 b43legacy_phy_write(dev, 0x04C0, 0x1861); in b43legacy_phy_setupg()
338 b43legacy_phy_write(dev, 0x04C1, 0x0271); in b43legacy_phy_setupg()
339 } else if (phy->rev > 2) { in b43legacy_phy_setupg()
340 b43legacy_phy_write(dev, 0x04C0, 0x0098); in b43legacy_phy_setupg()
341 b43legacy_phy_write(dev, 0x04C1, 0x0070); in b43legacy_phy_setupg()
342 b43legacy_phy_write(dev, 0x04C9, 0x0080); in b43legacy_phy_setupg()
344 b43legacy_phy_write(dev, 0x042B, b43legacy_phy_read(dev, in b43legacy_phy_setupg()
345 0x042B) | 0x800); in b43legacy_phy_setupg()
347 for (i = 0; i < 64; i++) in b43legacy_phy_setupg()
348 b43legacy_ilt_write(dev, 0x4000 + i, i); in b43legacy_phy_setupg()
349 for (i = 0; i < B43legacy_ILT_NOISEG2_SIZE; i++) in b43legacy_phy_setupg()
350 b43legacy_ilt_write(dev, 0x1800 + i, in b43legacy_phy_setupg()
354 if (phy->rev <= 2) in b43legacy_phy_setupg()
355 for (i = 0; i < B43legacy_ILT_NOISESCALEG_SIZE; i++) in b43legacy_phy_setupg()
356 b43legacy_ilt_write(dev, 0x1400 + i, in b43legacy_phy_setupg()
358 else if ((phy->rev >= 7) && (b43legacy_phy_read(dev, 0x0449) & 0x0200)) in b43legacy_phy_setupg()
359 for (i = 0; i < B43legacy_ILT_NOISESCALEG_SIZE; i++) in b43legacy_phy_setupg()
360 b43legacy_ilt_write(dev, 0x1400 + i, in b43legacy_phy_setupg()
363 for (i = 0; i < B43legacy_ILT_NOISESCALEG_SIZE; i++) in b43legacy_phy_setupg()
364 b43legacy_ilt_write(dev, 0x1400 + i, in b43legacy_phy_setupg()
367 if (phy->rev == 2) in b43legacy_phy_setupg()
368 for (i = 0; i < B43legacy_ILT_SIGMASQR_SIZE; i++) in b43legacy_phy_setupg()
369 b43legacy_ilt_write(dev, 0x5000 + i, in b43legacy_phy_setupg()
371 else if ((phy->rev > 2) && (phy->rev <= 8)) in b43legacy_phy_setupg()
372 for (i = 0; i < B43legacy_ILT_SIGMASQR_SIZE; i++) in b43legacy_phy_setupg()
373 b43legacy_ilt_write(dev, 0x5000 + i, in b43legacy_phy_setupg()
376 if (phy->rev == 1) { in b43legacy_phy_setupg()
377 for (i = 0; i < B43legacy_ILT_RETARD_SIZE; i++) in b43legacy_phy_setupg()
378 b43legacy_ilt_write32(dev, 0x2400 + i, in b43legacy_phy_setupg()
381 b43legacy_ilt_write(dev, 0x5400 + i, 0x0020); in b43legacy_phy_setupg()
382 b43legacy_phy_agcsetup(dev); in b43legacy_phy_setupg()
384 if (is_bcm_board_vendor(dev) && in b43legacy_phy_setupg()
385 (dev->dev->bus->boardinfo.type == 0x0416) && in b43legacy_phy_setupg()
386 (dev->dev->bus->sprom.board_rev == 0x0017)) in b43legacy_phy_setupg()
389 b43legacy_ilt_write(dev, 0x5001, 0x0002); in b43legacy_phy_setupg()
390 b43legacy_ilt_write(dev, 0x5002, 0x0001); in b43legacy_phy_setupg()
392 for (i = 0; i <= 0x20; i++) in b43legacy_phy_setupg()
393 b43legacy_ilt_write(dev, 0x1000 + i, 0x0820); in b43legacy_phy_setupg()
394 b43legacy_phy_agcsetup(dev); in b43legacy_phy_setupg()
395 b43legacy_phy_read(dev, 0x0400); /* dummy read */ in b43legacy_phy_setupg()
396 b43legacy_phy_write(dev, 0x0403, 0x1000); in b43legacy_phy_setupg()
397 b43legacy_ilt_write(dev, 0x3C02, 0x000F); in b43legacy_phy_setupg()
398 b43legacy_ilt_write(dev, 0x3C03, 0x0014); in b43legacy_phy_setupg()
400 if (is_bcm_board_vendor(dev) && in b43legacy_phy_setupg()
401 (dev->dev->bus->boardinfo.type == 0x0416) && in b43legacy_phy_setupg()
402 (dev->dev->bus->sprom.board_rev == 0x0017)) in b43legacy_phy_setupg()
405 b43legacy_ilt_write(dev, 0x0401, 0x0002); in b43legacy_phy_setupg()
406 b43legacy_ilt_write(dev, 0x0402, 0x0001); in b43legacy_phy_setupg()
411 static void b43legacy_phy_inita(struct b43legacy_wldev *dev) in b43legacy_phy_inita() argument
416 b43legacy_phy_setupg(dev); in b43legacy_phy_inita()
417 if (dev->dev->bus->sprom.boardflags_lo & B43legacy_BFL_PACTRL) in b43legacy_phy_inita()
418 b43legacy_phy_write(dev, 0x046E, 0x03CF); in b43legacy_phy_inita()
421 static void b43legacy_phy_initb2(struct b43legacy_wldev *dev) in b43legacy_phy_initb2() argument
423 struct b43legacy_phy *phy = &dev->phy; in b43legacy_phy_initb2()
427 b43legacy_write16(dev, 0x03EC, 0x3F22); in b43legacy_phy_initb2()
428 b43legacy_phy_write(dev, 0x0020, 0x301C); in b43legacy_phy_initb2()
429 b43legacy_phy_write(dev, 0x0026, 0x0000); in b43legacy_phy_initb2()
430 b43legacy_phy_write(dev, 0x0030, 0x00C6); in b43legacy_phy_initb2()
431 b43legacy_phy_write(dev, 0x0088, 0x3E00); in b43legacy_phy_initb2()
432 val = 0x3C3D; in b43legacy_phy_initb2()
433 for (offset = 0x0089; offset < 0x00A7; offset++) { in b43legacy_phy_initb2()
434 b43legacy_phy_write(dev, offset, val); in b43legacy_phy_initb2()
435 val -= 0x0202; in b43legacy_phy_initb2()
437 b43legacy_phy_write(dev, 0x03E4, 0x3000); in b43legacy_phy_initb2()
438 b43legacy_radio_selectchannel(dev, phy->channel, 0); in b43legacy_phy_initb2()
439 if (phy->radio_ver != 0x2050) { in b43legacy_phy_initb2()
440 b43legacy_radio_write16(dev, 0x0075, 0x0080); in b43legacy_phy_initb2()
441 b43legacy_radio_write16(dev, 0x0079, 0x0081); in b43legacy_phy_initb2()
443 b43legacy_radio_write16(dev, 0x0050, 0x0020); in b43legacy_phy_initb2()
444 b43legacy_radio_write16(dev, 0x0050, 0x0023); in b43legacy_phy_initb2()
445 if (phy->radio_ver == 0x2050) { in b43legacy_phy_initb2()
446 b43legacy_radio_write16(dev, 0x0050, 0x0020); in b43legacy_phy_initb2()
447 b43legacy_radio_write16(dev, 0x005A, 0x0070); in b43legacy_phy_initb2()
448 b43legacy_radio_write16(dev, 0x005B, 0x007B); in b43legacy_phy_initb2()
449 b43legacy_radio_write16(dev, 0x005C, 0x00B0); in b43legacy_phy_initb2()
450 b43legacy_radio_write16(dev, 0x007A, 0x000F); in b43legacy_phy_initb2()
451 b43legacy_phy_write(dev, 0x0038, 0x0677); in b43legacy_phy_initb2()
452 b43legacy_radio_init2050(dev); in b43legacy_phy_initb2()
454 b43legacy_phy_write(dev, 0x0014, 0x0080); in b43legacy_phy_initb2()
455 b43legacy_phy_write(dev, 0x0032, 0x00CA); in b43legacy_phy_initb2()
456 b43legacy_phy_write(dev, 0x0032, 0x00CC); in b43legacy_phy_initb2()
457 b43legacy_phy_write(dev, 0x0035, 0x07C2); in b43legacy_phy_initb2()
458 b43legacy_phy_lo_b_measure(dev); in b43legacy_phy_initb2()
459 b43legacy_phy_write(dev, 0x0026, 0xCC00); in b43legacy_phy_initb2()
460 if (phy->radio_ver != 0x2050) in b43legacy_phy_initb2()
461 b43legacy_phy_write(dev, 0x0026, 0xCE00); in b43legacy_phy_initb2()
462 b43legacy_write16(dev, B43legacy_MMIO_CHANNEL_EXT, 0x1000); in b43legacy_phy_initb2()
463 b43legacy_phy_write(dev, 0x002A, 0x88A3); in b43legacy_phy_initb2()
464 if (phy->radio_ver != 0x2050) in b43legacy_phy_initb2()
465 b43legacy_phy_write(dev, 0x002A, 0x88C2); in b43legacy_phy_initb2()
466 b43legacy_radio_set_txpower_bg(dev, 0xFFFF, 0xFFFF, 0xFFFF); in b43legacy_phy_initb2()
467 b43legacy_phy_init_pctl(dev); in b43legacy_phy_initb2()
470 static void b43legacy_phy_initb4(struct b43legacy_wldev *dev) in b43legacy_phy_initb4() argument
472 struct b43legacy_phy *phy = &dev->phy; in b43legacy_phy_initb4()
476 b43legacy_write16(dev, 0x03EC, 0x3F22); in b43legacy_phy_initb4()
477 b43legacy_phy_write(dev, 0x0020, 0x301C); in b43legacy_phy_initb4()
478 b43legacy_phy_write(dev, 0x0026, 0x0000); in b43legacy_phy_initb4()
479 b43legacy_phy_write(dev, 0x0030, 0x00C6); in b43legacy_phy_initb4()
480 b43legacy_phy_write(dev, 0x0088, 0x3E00); in b43legacy_phy_initb4()
481 val = 0x3C3D; in b43legacy_phy_initb4()
482 for (offset = 0x0089; offset < 0x00A7; offset++) { in b43legacy_phy_initb4()
483 b43legacy_phy_write(dev, offset, val); in b43legacy_phy_initb4()
484 val -= 0x0202; in b43legacy_phy_initb4()
486 b43legacy_phy_write(dev, 0x03E4, 0x3000); in b43legacy_phy_initb4()
487 b43legacy_radio_selectchannel(dev, phy->channel, 0); in b43legacy_phy_initb4()
488 if (phy->radio_ver != 0x2050) { in b43legacy_phy_initb4()
489 b43legacy_radio_write16(dev, 0x0075, 0x0080); in b43legacy_phy_initb4()
490 b43legacy_radio_write16(dev, 0x0079, 0x0081); in b43legacy_phy_initb4()
492 b43legacy_radio_write16(dev, 0x0050, 0x0020); in b43legacy_phy_initb4()
493 b43legacy_radio_write16(dev, 0x0050, 0x0023); in b43legacy_phy_initb4()
494 if (phy->radio_ver == 0x2050) { in b43legacy_phy_initb4()
495 b43legacy_radio_write16(dev, 0x0050, 0x0020); in b43legacy_phy_initb4()
496 b43legacy_radio_write16(dev, 0x005A, 0x0070); in b43legacy_phy_initb4()
497 b43legacy_radio_write16(dev, 0x005B, 0x007B); in b43legacy_phy_initb4()
498 b43legacy_radio_write16(dev, 0x005C, 0x00B0); in b43legacy_phy_initb4()
499 b43legacy_radio_write16(dev, 0x007A, 0x000F); in b43legacy_phy_initb4()
500 b43legacy_phy_write(dev, 0x0038, 0x0677); in b43legacy_phy_initb4()
501 b43legacy_radio_init2050(dev); in b43legacy_phy_initb4()
503 b43legacy_phy_write(dev, 0x0014, 0x0080); in b43legacy_phy_initb4()
504 b43legacy_phy_write(dev, 0x0032, 0x00CA); in b43legacy_phy_initb4()
505 if (phy->radio_ver == 0x2050) in b43legacy_phy_initb4()
506 b43legacy_phy_write(dev, 0x0032, 0x00E0); in b43legacy_phy_initb4()
507 b43legacy_phy_write(dev, 0x0035, 0x07C2); in b43legacy_phy_initb4()
509 b43legacy_phy_lo_b_measure(dev); in b43legacy_phy_initb4()
511 b43legacy_phy_write(dev, 0x0026, 0xCC00); in b43legacy_phy_initb4()
512 if (phy->radio_ver == 0x2050) in b43legacy_phy_initb4()
513 b43legacy_phy_write(dev, 0x0026, 0xCE00); in b43legacy_phy_initb4()
514 b43legacy_write16(dev, B43legacy_MMIO_CHANNEL_EXT, 0x1100); in b43legacy_phy_initb4()
515 b43legacy_phy_write(dev, 0x002A, 0x88A3); in b43legacy_phy_initb4()
516 if (phy->radio_ver == 0x2050) in b43legacy_phy_initb4()
517 b43legacy_phy_write(dev, 0x002A, 0x88C2); in b43legacy_phy_initb4()
518 b43legacy_radio_set_txpower_bg(dev, 0xFFFF, 0xFFFF, 0xFFFF); in b43legacy_phy_initb4()
519 if (dev->dev->bus->sprom.boardflags_lo & B43legacy_BFL_RSSI) { in b43legacy_phy_initb4()
520 b43legacy_calc_nrssi_slope(dev); in b43legacy_phy_initb4()
521 b43legacy_calc_nrssi_threshold(dev); in b43legacy_phy_initb4()
523 b43legacy_phy_init_pctl(dev); in b43legacy_phy_initb4()
526 static void b43legacy_phy_initb5(struct b43legacy_wldev *dev) in b43legacy_phy_initb5() argument
528 struct b43legacy_phy *phy = &dev->phy; in b43legacy_phy_initb5()
533 if (phy->analog == 1) in b43legacy_phy_initb5()
534 b43legacy_radio_write16(dev, 0x007A, in b43legacy_phy_initb5()
535 b43legacy_radio_read16(dev, 0x007A) in b43legacy_phy_initb5()
536 | 0x0050); in b43legacy_phy_initb5()
537 if (!is_bcm_board_vendor(dev) && in b43legacy_phy_initb5()
538 (dev->dev->bus->boardinfo.type != 0x0416)) { in b43legacy_phy_initb5()
539 value = 0x2120; in b43legacy_phy_initb5()
540 for (offset = 0x00A8 ; offset < 0x00C7; offset++) { in b43legacy_phy_initb5()
541 b43legacy_phy_write(dev, offset, value); in b43legacy_phy_initb5()
542 value += 0x0202; in b43legacy_phy_initb5()
545 b43legacy_phy_write(dev, 0x0035, in b43legacy_phy_initb5()
546 (b43legacy_phy_read(dev, 0x0035) & 0xF0FF) in b43legacy_phy_initb5()
547 | 0x0700); in b43legacy_phy_initb5()
548 if (phy->radio_ver == 0x2050) in b43legacy_phy_initb5()
549 b43legacy_phy_write(dev, 0x0038, 0x0667); in b43legacy_phy_initb5()
551 if (phy->gmode) { in b43legacy_phy_initb5()
552 if (phy->radio_ver == 0x2050) { in b43legacy_phy_initb5()
553 b43legacy_radio_write16(dev, 0x007A, in b43legacy_phy_initb5()
554 b43legacy_radio_read16(dev, 0x007A) in b43legacy_phy_initb5()
555 | 0x0020); in b43legacy_phy_initb5()
556 b43legacy_radio_write16(dev, 0x0051, in b43legacy_phy_initb5()
557 b43legacy_radio_read16(dev, 0x0051) in b43legacy_phy_initb5()
558 | 0x0004); in b43legacy_phy_initb5()
560 b43legacy_write16(dev, B43legacy_MMIO_PHY_RADIO, 0x0000); in b43legacy_phy_initb5()
562 b43legacy_phy_write(dev, 0x0802, b43legacy_phy_read(dev, 0x0802) in b43legacy_phy_initb5()
563 | 0x0100); in b43legacy_phy_initb5()
564 b43legacy_phy_write(dev, 0x042B, b43legacy_phy_read(dev, 0x042B) in b43legacy_phy_initb5()
565 | 0x2000); in b43legacy_phy_initb5()
567 b43legacy_phy_write(dev, 0x001C, 0x186A); in b43legacy_phy_initb5()
569 b43legacy_phy_write(dev, 0x0013, (b43legacy_phy_read(dev, in b43legacy_phy_initb5()
570 0x0013) & 0x00FF) | 0x1900); in b43legacy_phy_initb5()
571 b43legacy_phy_write(dev, 0x0035, (b43legacy_phy_read(dev, in b43legacy_phy_initb5()
572 0x0035) & 0xFFC0) | 0x0064); in b43legacy_phy_initb5()
573 b43legacy_phy_write(dev, 0x005D, (b43legacy_phy_read(dev, in b43legacy_phy_initb5()
574 0x005D) & 0xFF80) | 0x000A); in b43legacy_phy_initb5()
575 b43legacy_phy_write(dev, 0x5B, 0x0000); in b43legacy_phy_initb5()
576 b43legacy_phy_write(dev, 0x5C, 0x0000); in b43legacy_phy_initb5()
579 if (dev->bad_frames_preempt) in b43legacy_phy_initb5()
580 b43legacy_phy_write(dev, B43legacy_PHY_RADIO_BITFIELD, in b43legacy_phy_initb5()
581 b43legacy_phy_read(dev, in b43legacy_phy_initb5()
584 if (phy->analog == 1) { in b43legacy_phy_initb5()
585 b43legacy_phy_write(dev, 0x0026, 0xCE00); in b43legacy_phy_initb5()
586 b43legacy_phy_write(dev, 0x0021, 0x3763); in b43legacy_phy_initb5()
587 b43legacy_phy_write(dev, 0x0022, 0x1BC3); in b43legacy_phy_initb5()
588 b43legacy_phy_write(dev, 0x0023, 0x06F9); in b43legacy_phy_initb5()
589 b43legacy_phy_write(dev, 0x0024, 0x037E); in b43legacy_phy_initb5()
591 b43legacy_phy_write(dev, 0x0026, 0xCC00); in b43legacy_phy_initb5()
592 b43legacy_phy_write(dev, 0x0030, 0x00C6); in b43legacy_phy_initb5()
593 b43legacy_write16(dev, 0x03EC, 0x3F22); in b43legacy_phy_initb5()
595 if (phy->analog == 1) in b43legacy_phy_initb5()
596 b43legacy_phy_write(dev, 0x0020, 0x3E1C); in b43legacy_phy_initb5()
598 b43legacy_phy_write(dev, 0x0020, 0x301C); in b43legacy_phy_initb5()
600 if (phy->analog == 0) in b43legacy_phy_initb5()
601 b43legacy_write16(dev, 0x03E4, 0x3000); in b43legacy_phy_initb5()
603 old_channel = (phy->channel == 0xFF) ? 1 : phy->channel; in b43legacy_phy_initb5()
605 b43legacy_radio_selectchannel(dev, 7, 0); in b43legacy_phy_initb5()
607 if (phy->radio_ver != 0x2050) { in b43legacy_phy_initb5()
608 b43legacy_radio_write16(dev, 0x0075, 0x0080); in b43legacy_phy_initb5()
609 b43legacy_radio_write16(dev, 0x0079, 0x0081); in b43legacy_phy_initb5()
612 b43legacy_radio_write16(dev, 0x0050, 0x0020); in b43legacy_phy_initb5()
613 b43legacy_radio_write16(dev, 0x0050, 0x0023); in b43legacy_phy_initb5()
615 if (phy->radio_ver == 0x2050) { in b43legacy_phy_initb5()
616 b43legacy_radio_write16(dev, 0x0050, 0x0020); in b43legacy_phy_initb5()
617 b43legacy_radio_write16(dev, 0x005A, 0x0070); in b43legacy_phy_initb5()
620 b43legacy_radio_write16(dev, 0x005B, 0x007B); in b43legacy_phy_initb5()
621 b43legacy_radio_write16(dev, 0x005C, 0x00B0); in b43legacy_phy_initb5()
623 b43legacy_radio_write16(dev, 0x007A, b43legacy_radio_read16(dev, in b43legacy_phy_initb5()
624 0x007A) | 0x0007); in b43legacy_phy_initb5()
626 b43legacy_radio_selectchannel(dev, old_channel, 0); in b43legacy_phy_initb5()
628 b43legacy_phy_write(dev, 0x0014, 0x0080); in b43legacy_phy_initb5()
629 b43legacy_phy_write(dev, 0x0032, 0x00CA); in b43legacy_phy_initb5()
630 b43legacy_phy_write(dev, 0x002A, 0x88A3); in b43legacy_phy_initb5()
632 b43legacy_radio_set_txpower_bg(dev, 0xFFFF, 0xFFFF, 0xFFFF); in b43legacy_phy_initb5()
634 if (phy->radio_ver == 0x2050) in b43legacy_phy_initb5()
635 b43legacy_radio_write16(dev, 0x005D, 0x000D); in b43legacy_phy_initb5()
637 b43legacy_write16(dev, 0x03E4, (b43legacy_read16(dev, 0x03E4) & in b43legacy_phy_initb5()
638 0xFFC0) | 0x0004); in b43legacy_phy_initb5()
641 static void b43legacy_phy_initb6(struct b43legacy_wldev *dev) in b43legacy_phy_initb6() argument
643 struct b43legacy_phy *phy = &dev->phy; in b43legacy_phy_initb6()
648 b43legacy_phy_write(dev, 0x003E, 0x817A); in b43legacy_phy_initb6()
649 b43legacy_radio_write16(dev, 0x007A, in b43legacy_phy_initb6()
650 (b43legacy_radio_read16(dev, 0x007A) | 0x0058)); in b43legacy_phy_initb6()
651 if (phy->radio_rev == 4 || in b43legacy_phy_initb6()
652 phy->radio_rev == 5) { in b43legacy_phy_initb6()
653 b43legacy_radio_write16(dev, 0x0051, 0x0037); in b43legacy_phy_initb6()
654 b43legacy_radio_write16(dev, 0x0052, 0x0070); in b43legacy_phy_initb6()
655 b43legacy_radio_write16(dev, 0x0053, 0x00B3); in b43legacy_phy_initb6()
656 b43legacy_radio_write16(dev, 0x0054, 0x009B); in b43legacy_phy_initb6()
657 b43legacy_radio_write16(dev, 0x005A, 0x0088); in b43legacy_phy_initb6()
658 b43legacy_radio_write16(dev, 0x005B, 0x0088); in b43legacy_phy_initb6()
659 b43legacy_radio_write16(dev, 0x005D, 0x0088); in b43legacy_phy_initb6()
660 b43legacy_radio_write16(dev, 0x005E, 0x0088); in b43legacy_phy_initb6()
661 b43legacy_radio_write16(dev, 0x007D, 0x0088); in b43legacy_phy_initb6()
662 b43legacy_shm_write32(dev, B43legacy_SHM_SHARED, in b43legacy_phy_initb6()
664 (b43legacy_shm_read32(dev, in b43legacy_phy_initb6()
667 | 0x00000200)); in b43legacy_phy_initb6()
669 if (phy->radio_rev == 8) { in b43legacy_phy_initb6()
670 b43legacy_radio_write16(dev, 0x0051, 0x0000); in b43legacy_phy_initb6()
671 b43legacy_radio_write16(dev, 0x0052, 0x0040); in b43legacy_phy_initb6()
672 b43legacy_radio_write16(dev, 0x0053, 0x00B7); in b43legacy_phy_initb6()
673 b43legacy_radio_write16(dev, 0x0054, 0x0098); in b43legacy_phy_initb6()
674 b43legacy_radio_write16(dev, 0x005A, 0x0088); in b43legacy_phy_initb6()
675 b43legacy_radio_write16(dev, 0x005B, 0x006B); in b43legacy_phy_initb6()
676 b43legacy_radio_write16(dev, 0x005C, 0x000F); in b43legacy_phy_initb6()
677 if (dev->dev->bus->sprom.boardflags_lo & 0x8000) { in b43legacy_phy_initb6()
678 b43legacy_radio_write16(dev, 0x005D, 0x00FA); in b43legacy_phy_initb6()
679 b43legacy_radio_write16(dev, 0x005E, 0x00D8); in b43legacy_phy_initb6()
681 b43legacy_radio_write16(dev, 0x005D, 0x00F5); in b43legacy_phy_initb6()
682 b43legacy_radio_write16(dev, 0x005E, 0x00B8); in b43legacy_phy_initb6()
684 b43legacy_radio_write16(dev, 0x0073, 0x0003); in b43legacy_phy_initb6()
685 b43legacy_radio_write16(dev, 0x007D, 0x00A8); in b43legacy_phy_initb6()
686 b43legacy_radio_write16(dev, 0x007C, 0x0001); in b43legacy_phy_initb6()
687 b43legacy_radio_write16(dev, 0x007E, 0x0008); in b43legacy_phy_initb6()
689 val = 0x1E1F; in b43legacy_phy_initb6()
690 for (offset = 0x0088; offset < 0x0098; offset++) { in b43legacy_phy_initb6()
691 b43legacy_phy_write(dev, offset, val); in b43legacy_phy_initb6()
692 val -= 0x0202; in b43legacy_phy_initb6()
694 val = 0x3E3F; in b43legacy_phy_initb6()
695 for (offset = 0x0098; offset < 0x00A8; offset++) { in b43legacy_phy_initb6()
696 b43legacy_phy_write(dev, offset, val); in b43legacy_phy_initb6()
697 val -= 0x0202; in b43legacy_phy_initb6()
699 val = 0x2120; in b43legacy_phy_initb6()
700 for (offset = 0x00A8; offset < 0x00C8; offset++) { in b43legacy_phy_initb6()
701 b43legacy_phy_write(dev, offset, (val & 0x3F3F)); in b43legacy_phy_initb6()
702 val += 0x0202; in b43legacy_phy_initb6()
704 if (phy->type == B43legacy_PHYTYPE_G) { in b43legacy_phy_initb6()
705 b43legacy_radio_write16(dev, 0x007A, in b43legacy_phy_initb6()
706 b43legacy_radio_read16(dev, 0x007A) | in b43legacy_phy_initb6()
707 0x0020); in b43legacy_phy_initb6()
708 b43legacy_radio_write16(dev, 0x0051, in b43legacy_phy_initb6()
709 b43legacy_radio_read16(dev, 0x0051) | in b43legacy_phy_initb6()
710 0x0004); in b43legacy_phy_initb6()
711 b43legacy_phy_write(dev, 0x0802, in b43legacy_phy_initb6()
712 b43legacy_phy_read(dev, 0x0802) | 0x0100); in b43legacy_phy_initb6()
713 b43legacy_phy_write(dev, 0x042B, in b43legacy_phy_initb6()
714 b43legacy_phy_read(dev, 0x042B) | 0x2000); in b43legacy_phy_initb6()
715 b43legacy_phy_write(dev, 0x5B, 0x0000); in b43legacy_phy_initb6()
716 b43legacy_phy_write(dev, 0x5C, 0x0000); in b43legacy_phy_initb6()
719 old_channel = phy->channel; in b43legacy_phy_initb6()
721 b43legacy_radio_selectchannel(dev, 1, 0); in b43legacy_phy_initb6()
723 b43legacy_radio_selectchannel(dev, 13, 0); in b43legacy_phy_initb6()
725 b43legacy_radio_write16(dev, 0x0050, 0x0020); in b43legacy_phy_initb6()
726 b43legacy_radio_write16(dev, 0x0050, 0x0023); in b43legacy_phy_initb6()
728 if (phy->radio_rev < 6 || phy->radio_rev == 8) { in b43legacy_phy_initb6()
729 b43legacy_radio_write16(dev, 0x007C, in b43legacy_phy_initb6()
730 (b43legacy_radio_read16(dev, 0x007C) in b43legacy_phy_initb6()
731 | 0x0002)); in b43legacy_phy_initb6()
732 b43legacy_radio_write16(dev, 0x0050, 0x0020); in b43legacy_phy_initb6()
734 if (phy->radio_rev <= 2) { in b43legacy_phy_initb6()
735 b43legacy_radio_write16(dev, 0x0050, 0x0020); in b43legacy_phy_initb6()
736 b43legacy_radio_write16(dev, 0x005A, 0x0070); in b43legacy_phy_initb6()
737 b43legacy_radio_write16(dev, 0x005B, 0x007B); in b43legacy_phy_initb6()
738 b43legacy_radio_write16(dev, 0x005C, 0x00B0); in b43legacy_phy_initb6()
740 b43legacy_radio_write16(dev, 0x007A, in b43legacy_phy_initb6()
741 (b43legacy_radio_read16(dev, in b43legacy_phy_initb6()
742 0x007A) & 0x00F8) | 0x0007); in b43legacy_phy_initb6()
744 b43legacy_radio_selectchannel(dev, old_channel, 0); in b43legacy_phy_initb6()
746 b43legacy_phy_write(dev, 0x0014, 0x0200); in b43legacy_phy_initb6()
747 if (phy->radio_rev >= 6) in b43legacy_phy_initb6()
748 b43legacy_phy_write(dev, 0x002A, 0x88C2); in b43legacy_phy_initb6()
750 b43legacy_phy_write(dev, 0x002A, 0x8AC0); in b43legacy_phy_initb6()
751 b43legacy_phy_write(dev, 0x0038, 0x0668); in b43legacy_phy_initb6()
752 b43legacy_radio_set_txpower_bg(dev, 0xFFFF, 0xFFFF, 0xFFFF); in b43legacy_phy_initb6()
753 if (phy->radio_rev == 4 || phy->radio_rev == 5) in b43legacy_phy_initb6()
754 b43legacy_phy_write(dev, 0x005D, (b43legacy_phy_read(dev, in b43legacy_phy_initb6()
755 0x005D) & 0xFF80) | 0x0003); in b43legacy_phy_initb6()
756 if (phy->radio_rev <= 2) in b43legacy_phy_initb6()
757 b43legacy_radio_write16(dev, 0x005D, 0x000D); in b43legacy_phy_initb6()
759 if (phy->analog == 4) { in b43legacy_phy_initb6()
760 b43legacy_write16(dev, 0x03E4, 0x0009); in b43legacy_phy_initb6()
761 b43legacy_phy_write(dev, 0x61, b43legacy_phy_read(dev, 0x61) in b43legacy_phy_initb6()
762 & 0xFFF); in b43legacy_phy_initb6()
764 b43legacy_phy_write(dev, 0x0002, (b43legacy_phy_read(dev, in b43legacy_phy_initb6()
765 0x0002) & 0xFFC0) | 0x0004); in b43legacy_phy_initb6()
766 if (phy->type == B43legacy_PHYTYPE_G) in b43legacy_phy_initb6()
767 b43legacy_write16(dev, 0x03E6, 0x0); in b43legacy_phy_initb6()
768 if (phy->type == B43legacy_PHYTYPE_B) { in b43legacy_phy_initb6()
769 b43legacy_write16(dev, 0x03E6, 0x8140); in b43legacy_phy_initb6()
770 b43legacy_phy_write(dev, 0x0016, 0x0410); in b43legacy_phy_initb6()
771 b43legacy_phy_write(dev, 0x0017, 0x0820); in b43legacy_phy_initb6()
772 b43legacy_phy_write(dev, 0x0062, 0x0007); in b43legacy_phy_initb6()
773 b43legacy_radio_init2050(dev); in b43legacy_phy_initb6()
774 b43legacy_phy_lo_g_measure(dev); in b43legacy_phy_initb6()
775 if (dev->dev->bus->sprom.boardflags_lo & in b43legacy_phy_initb6()
777 b43legacy_calc_nrssi_slope(dev); in b43legacy_phy_initb6()
778 b43legacy_calc_nrssi_threshold(dev); in b43legacy_phy_initb6()
780 b43legacy_phy_init_pctl(dev); in b43legacy_phy_initb6()
784 static void b43legacy_calc_loopback_gain(struct b43legacy_wldev *dev) in b43legacy_calc_loopback_gain() argument
786 struct b43legacy_phy *phy = &dev->phy; in b43legacy_calc_loopback_gain()
787 u16 backup_phy[15] = {0}; in b43legacy_calc_loopback_gain()
796 backup_phy[0] = b43legacy_phy_read(dev, 0x0429); in b43legacy_calc_loopback_gain()
797 backup_phy[1] = b43legacy_phy_read(dev, 0x0001); in b43legacy_calc_loopback_gain()
798 backup_phy[2] = b43legacy_phy_read(dev, 0x0811); in b43legacy_calc_loopback_gain()
799 backup_phy[3] = b43legacy_phy_read(dev, 0x0812); in b43legacy_calc_loopback_gain()
800 if (phy->rev != 1) { in b43legacy_calc_loopback_gain()
801 backup_phy[4] = b43legacy_phy_read(dev, 0x0814); in b43legacy_calc_loopback_gain()
802 backup_phy[5] = b43legacy_phy_read(dev, 0x0815); in b43legacy_calc_loopback_gain()
804 backup_phy[6] = b43legacy_phy_read(dev, 0x005A); in b43legacy_calc_loopback_gain()
805 backup_phy[7] = b43legacy_phy_read(dev, 0x0059); in b43legacy_calc_loopback_gain()
806 backup_phy[8] = b43legacy_phy_read(dev, 0x0058); in b43legacy_calc_loopback_gain()
807 backup_phy[9] = b43legacy_phy_read(dev, 0x000A); in b43legacy_calc_loopback_gain()
808 backup_phy[10] = b43legacy_phy_read(dev, 0x0003); in b43legacy_calc_loopback_gain()
809 backup_phy[11] = b43legacy_phy_read(dev, 0x080F); in b43legacy_calc_loopback_gain()
810 backup_phy[12] = b43legacy_phy_read(dev, 0x0810); in b43legacy_calc_loopback_gain()
811 backup_phy[13] = b43legacy_phy_read(dev, 0x002B); in b43legacy_calc_loopback_gain()
812 backup_phy[14] = b43legacy_phy_read(dev, 0x0015); in b43legacy_calc_loopback_gain()
813 b43legacy_phy_read(dev, 0x002D); /* dummy read */ in b43legacy_calc_loopback_gain()
814 backup_bband = phy->bbatt; in b43legacy_calc_loopback_gain()
815 backup_radio[0] = b43legacy_radio_read16(dev, 0x0052); in b43legacy_calc_loopback_gain()
816 backup_radio[1] = b43legacy_radio_read16(dev, 0x0043); in b43legacy_calc_loopback_gain()
817 backup_radio[2] = b43legacy_radio_read16(dev, 0x007A); in b43legacy_calc_loopback_gain()
819 b43legacy_phy_write(dev, 0x0429, in b43legacy_calc_loopback_gain()
820 b43legacy_phy_read(dev, 0x0429) & 0x3FFF); in b43legacy_calc_loopback_gain()
821 b43legacy_phy_write(dev, 0x0001, in b43legacy_calc_loopback_gain()
822 b43legacy_phy_read(dev, 0x0001) & 0x8000); in b43legacy_calc_loopback_gain()
823 b43legacy_phy_write(dev, 0x0811, in b43legacy_calc_loopback_gain()
824 b43legacy_phy_read(dev, 0x0811) | 0x0002); in b43legacy_calc_loopback_gain()
825 b43legacy_phy_write(dev, 0x0812, in b43legacy_calc_loopback_gain()
826 b43legacy_phy_read(dev, 0x0812) & 0xFFFD); in b43legacy_calc_loopback_gain()
827 b43legacy_phy_write(dev, 0x0811, in b43legacy_calc_loopback_gain()
828 b43legacy_phy_read(dev, 0x0811) | 0x0001); in b43legacy_calc_loopback_gain()
829 b43legacy_phy_write(dev, 0x0812, in b43legacy_calc_loopback_gain()
830 b43legacy_phy_read(dev, 0x0812) & 0xFFFE); in b43legacy_calc_loopback_gain()
831 if (phy->rev != 1) { in b43legacy_calc_loopback_gain()
832 b43legacy_phy_write(dev, 0x0814, in b43legacy_calc_loopback_gain()
833 b43legacy_phy_read(dev, 0x0814) | 0x0001); in b43legacy_calc_loopback_gain()
834 b43legacy_phy_write(dev, 0x0815, in b43legacy_calc_loopback_gain()
835 b43legacy_phy_read(dev, 0x0815) & 0xFFFE); in b43legacy_calc_loopback_gain()
836 b43legacy_phy_write(dev, 0x0814, in b43legacy_calc_loopback_gain()
837 b43legacy_phy_read(dev, 0x0814) | 0x0002); in b43legacy_calc_loopback_gain()
838 b43legacy_phy_write(dev, 0x0815, in b43legacy_calc_loopback_gain()
839 b43legacy_phy_read(dev, 0x0815) & 0xFFFD); in b43legacy_calc_loopback_gain()
841 b43legacy_phy_write(dev, 0x0811, b43legacy_phy_read(dev, 0x0811) | in b43legacy_calc_loopback_gain()
842 0x000C); in b43legacy_calc_loopback_gain()
843 b43legacy_phy_write(dev, 0x0812, b43legacy_phy_read(dev, 0x0812) | in b43legacy_calc_loopback_gain()
844 0x000C); in b43legacy_calc_loopback_gain()
846 b43legacy_phy_write(dev, 0x0811, (b43legacy_phy_read(dev, 0x0811) in b43legacy_calc_loopback_gain()
847 & 0xFFCF) | 0x0030); in b43legacy_calc_loopback_gain()
848 b43legacy_phy_write(dev, 0x0812, (b43legacy_phy_read(dev, 0x0812) in b43legacy_calc_loopback_gain()
849 & 0xFFCF) | 0x0010); in b43legacy_calc_loopback_gain()
851 b43legacy_phy_write(dev, 0x005A, 0x0780); in b43legacy_calc_loopback_gain()
852 b43legacy_phy_write(dev, 0x0059, 0xC810); in b43legacy_calc_loopback_gain()
853 b43legacy_phy_write(dev, 0x0058, 0x000D); in b43legacy_calc_loopback_gain()
854 if (phy->analog == 0) in b43legacy_calc_loopback_gain()
855 b43legacy_phy_write(dev, 0x0003, 0x0122); in b43legacy_calc_loopback_gain()
857 b43legacy_phy_write(dev, 0x000A, in b43legacy_calc_loopback_gain()
858 b43legacy_phy_read(dev, 0x000A) in b43legacy_calc_loopback_gain()
859 | 0x2000); in b43legacy_calc_loopback_gain()
860 if (phy->rev != 1) { in b43legacy_calc_loopback_gain()
861 b43legacy_phy_write(dev, 0x0814, in b43legacy_calc_loopback_gain()
862 b43legacy_phy_read(dev, 0x0814) | 0x0004); in b43legacy_calc_loopback_gain()
863 b43legacy_phy_write(dev, 0x0815, in b43legacy_calc_loopback_gain()
864 b43legacy_phy_read(dev, 0x0815) & 0xFFFB); in b43legacy_calc_loopback_gain()
866 b43legacy_phy_write(dev, 0x0003, in b43legacy_calc_loopback_gain()
867 (b43legacy_phy_read(dev, 0x0003) in b43legacy_calc_loopback_gain()
868 & 0xFF9F) | 0x0040); in b43legacy_calc_loopback_gain()
869 if (phy->radio_ver == 0x2050 && phy->radio_rev == 2) { in b43legacy_calc_loopback_gain()
870 b43legacy_radio_write16(dev, 0x0052, 0x0000); in b43legacy_calc_loopback_gain()
871 b43legacy_radio_write16(dev, 0x0043, in b43legacy_calc_loopback_gain()
872 (b43legacy_radio_read16(dev, 0x0043) in b43legacy_calc_loopback_gain()
873 & 0xFFF0) | 0x0009); in b43legacy_calc_loopback_gain()
875 } else if (phy->radio_rev == 8) { in b43legacy_calc_loopback_gain()
876 b43legacy_radio_write16(dev, 0x0043, 0x000F); in b43legacy_calc_loopback_gain()
879 loop1_cnt = 0; in b43legacy_calc_loopback_gain()
881 b43legacy_phy_set_baseband_attenuation(dev, 11); in b43legacy_calc_loopback_gain()
883 if (phy->rev >= 3) in b43legacy_calc_loopback_gain()
884 b43legacy_phy_write(dev, 0x080F, 0xC020); in b43legacy_calc_loopback_gain()
886 b43legacy_phy_write(dev, 0x080F, 0x8020); in b43legacy_calc_loopback_gain()
887 b43legacy_phy_write(dev, 0x0810, 0x0000); in b43legacy_calc_loopback_gain()
889 b43legacy_phy_write(dev, 0x002B, in b43legacy_calc_loopback_gain()
890 (b43legacy_phy_read(dev, 0x002B) in b43legacy_calc_loopback_gain()
891 & 0xFFC0) | 0x0001); in b43legacy_calc_loopback_gain()
892 b43legacy_phy_write(dev, 0x002B, in b43legacy_calc_loopback_gain()
893 (b43legacy_phy_read(dev, 0x002B) in b43legacy_calc_loopback_gain()
894 & 0xC0FF) | 0x0800); in b43legacy_calc_loopback_gain()
895 b43legacy_phy_write(dev, 0x0811, in b43legacy_calc_loopback_gain()
896 b43legacy_phy_read(dev, 0x0811) | 0x0100); in b43legacy_calc_loopback_gain()
897 b43legacy_phy_write(dev, 0x0812, in b43legacy_calc_loopback_gain()
898 b43legacy_phy_read(dev, 0x0812) & 0xCFFF); in b43legacy_calc_loopback_gain()
899 if (dev->dev->bus->sprom.boardflags_lo & B43legacy_BFL_EXTLNA) { in b43legacy_calc_loopback_gain()
900 if (phy->rev >= 7) { in b43legacy_calc_loopback_gain()
901 b43legacy_phy_write(dev, 0x0811, in b43legacy_calc_loopback_gain()
902 b43legacy_phy_read(dev, 0x0811) in b43legacy_calc_loopback_gain()
903 | 0x0800); in b43legacy_calc_loopback_gain()
904 b43legacy_phy_write(dev, 0x0812, in b43legacy_calc_loopback_gain()
905 b43legacy_phy_read(dev, 0x0812) in b43legacy_calc_loopback_gain()
906 | 0x8000); in b43legacy_calc_loopback_gain()
909 b43legacy_radio_write16(dev, 0x007A, in b43legacy_calc_loopback_gain()
910 b43legacy_radio_read16(dev, 0x007A) in b43legacy_calc_loopback_gain()
911 & 0x00F7); in b43legacy_calc_loopback_gain()
913 for (i = 0; i < loop1_cnt; i++) { in b43legacy_calc_loopback_gain()
914 b43legacy_radio_write16(dev, 0x0043, loop1_cnt); in b43legacy_calc_loopback_gain()
915 b43legacy_phy_write(dev, 0x0812, in b43legacy_calc_loopback_gain()
916 (b43legacy_phy_read(dev, 0x0812) in b43legacy_calc_loopback_gain()
917 & 0xF0FF) | (i << 8)); in b43legacy_calc_loopback_gain()
918 b43legacy_phy_write(dev, 0x0015, in b43legacy_calc_loopback_gain()
919 (b43legacy_phy_read(dev, 0x0015) in b43legacy_calc_loopback_gain()
920 & 0x0FFF) | 0xA000); in b43legacy_calc_loopback_gain()
921 b43legacy_phy_write(dev, 0x0015, in b43legacy_calc_loopback_gain()
922 (b43legacy_phy_read(dev, 0x0015) in b43legacy_calc_loopback_gain()
923 & 0x0FFF) | 0xF000); in b43legacy_calc_loopback_gain()
925 if (b43legacy_phy_read(dev, 0x002D) >= 0x0DFC) in b43legacy_calc_loopback_gain()
929 loop1_omitted = loop1_cnt - loop1_done; in b43legacy_calc_loopback_gain()
931 loop2_done = 0; in b43legacy_calc_loopback_gain()
933 b43legacy_phy_write(dev, 0x0812, in b43legacy_calc_loopback_gain()
934 b43legacy_phy_read(dev, 0x0812) in b43legacy_calc_loopback_gain()
935 | 0x0030); in b43legacy_calc_loopback_gain()
936 for (i = loop1_done - 8; i < 16; i++) { in b43legacy_calc_loopback_gain()
937 b43legacy_phy_write(dev, 0x0812, in b43legacy_calc_loopback_gain()
938 (b43legacy_phy_read(dev, 0x0812) in b43legacy_calc_loopback_gain()
939 & 0xF0FF) | (i << 8)); in b43legacy_calc_loopback_gain()
940 b43legacy_phy_write(dev, 0x0015, in b43legacy_calc_loopback_gain()
941 (b43legacy_phy_read(dev, 0x0015) in b43legacy_calc_loopback_gain()
942 & 0x0FFF) | 0xA000); in b43legacy_calc_loopback_gain()
943 b43legacy_phy_write(dev, 0x0015, in b43legacy_calc_loopback_gain()
944 (b43legacy_phy_read(dev, 0x0015) in b43legacy_calc_loopback_gain()
945 & 0x0FFF) | 0xF000); in b43legacy_calc_loopback_gain()
947 if (b43legacy_phy_read(dev, 0x002D) >= 0x0DFC) in b43legacy_calc_loopback_gain()
952 if (phy->rev != 1) { in b43legacy_calc_loopback_gain()
953 b43legacy_phy_write(dev, 0x0814, backup_phy[4]); in b43legacy_calc_loopback_gain()
954 b43legacy_phy_write(dev, 0x0815, backup_phy[5]); in b43legacy_calc_loopback_gain()
956 b43legacy_phy_write(dev, 0x005A, backup_phy[6]); in b43legacy_calc_loopback_gain()
957 b43legacy_phy_write(dev, 0x0059, backup_phy[7]); in b43legacy_calc_loopback_gain()
958 b43legacy_phy_write(dev, 0x0058, backup_phy[8]); in b43legacy_calc_loopback_gain()
959 b43legacy_phy_write(dev, 0x000A, backup_phy[9]); in b43legacy_calc_loopback_gain()
960 b43legacy_phy_write(dev, 0x0003, backup_phy[10]); in b43legacy_calc_loopback_gain()
961 b43legacy_phy_write(dev, 0x080F, backup_phy[11]); in b43legacy_calc_loopback_gain()
962 b43legacy_phy_write(dev, 0x0810, backup_phy[12]); in b43legacy_calc_loopback_gain()
963 b43legacy_phy_write(dev, 0x002B, backup_phy[13]); in b43legacy_calc_loopback_gain()
964 b43legacy_phy_write(dev, 0x0015, backup_phy[14]); in b43legacy_calc_loopback_gain()
966 b43legacy_phy_set_baseband_attenuation(dev, backup_bband); in b43legacy_calc_loopback_gain()
968 b43legacy_radio_write16(dev, 0x0052, backup_radio[0]); in b43legacy_calc_loopback_gain()
969 b43legacy_radio_write16(dev, 0x0043, backup_radio[1]); in b43legacy_calc_loopback_gain()
970 b43legacy_radio_write16(dev, 0x007A, backup_radio[2]); in b43legacy_calc_loopback_gain()
972 b43legacy_phy_write(dev, 0x0811, backup_phy[2] | 0x0003); in b43legacy_calc_loopback_gain()
974 b43legacy_phy_write(dev, 0x0811, backup_phy[2]); in b43legacy_calc_loopback_gain()
975 b43legacy_phy_write(dev, 0x0812, backup_phy[3]); in b43legacy_calc_loopback_gain()
976 b43legacy_phy_write(dev, 0x0429, backup_phy[0]); in b43legacy_calc_loopback_gain()
977 b43legacy_phy_write(dev, 0x0001, backup_phy[1]); in b43legacy_calc_loopback_gain()
979 phy->loopback_gain[0] = ((loop1_done * 6) - (loop1_omitted * 4)) - 11; in b43legacy_calc_loopback_gain()
980 phy->loopback_gain[1] = (24 - (3 * loop2_done)) * 2; in b43legacy_calc_loopback_gain()
983 static void b43legacy_phy_initg(struct b43legacy_wldev *dev) in b43legacy_phy_initg() argument
985 struct b43legacy_phy *phy = &dev->phy; in b43legacy_phy_initg()
988 if (phy->rev == 1) in b43legacy_phy_initg()
989 b43legacy_phy_initb5(dev); in b43legacy_phy_initg()
991 b43legacy_phy_initb6(dev); in b43legacy_phy_initg()
992 if (phy->rev >= 2 && phy->gmode) in b43legacy_phy_initg()
993 b43legacy_phy_inita(dev); in b43legacy_phy_initg()
995 if (phy->rev >= 2) { in b43legacy_phy_initg()
996 b43legacy_phy_write(dev, 0x0814, 0x0000); in b43legacy_phy_initg()
997 b43legacy_phy_write(dev, 0x0815, 0x0000); in b43legacy_phy_initg()
999 if (phy->rev == 2) { in b43legacy_phy_initg()
1000 b43legacy_phy_write(dev, 0x0811, 0x0000); in b43legacy_phy_initg()
1001 b43legacy_phy_write(dev, 0x0015, 0x00C0); in b43legacy_phy_initg()
1003 if (phy->rev > 5) { in b43legacy_phy_initg()
1004 b43legacy_phy_write(dev, 0x0811, 0x0400); in b43legacy_phy_initg()
1005 b43legacy_phy_write(dev, 0x0015, 0x00C0); in b43legacy_phy_initg()
1007 if (phy->gmode) { in b43legacy_phy_initg()
1008 tmp = b43legacy_phy_read(dev, 0x0400) & 0xFF; in b43legacy_phy_initg()
1010 b43legacy_phy_write(dev, 0x04C2, 0x1816); in b43legacy_phy_initg()
1011 b43legacy_phy_write(dev, 0x04C3, 0x8606); in b43legacy_phy_initg()
1014 b43legacy_phy_write(dev, 0x04C2, 0x1816); in b43legacy_phy_initg()
1015 b43legacy_phy_write(dev, 0x04C3, 0x8006); in b43legacy_phy_initg()
1016 b43legacy_phy_write(dev, 0x04CC, in b43legacy_phy_initg()
1017 (b43legacy_phy_read(dev, in b43legacy_phy_initg()
1018 0x04CC) & 0x00FF) | in b43legacy_phy_initg()
1019 0x1F00); in b43legacy_phy_initg()
1021 if (phy->rev >= 2) in b43legacy_phy_initg()
1022 b43legacy_phy_write(dev, 0x047E, 0x0078); in b43legacy_phy_initg()
1024 if (phy->radio_rev == 8) { in b43legacy_phy_initg()
1025 b43legacy_phy_write(dev, 0x0801, b43legacy_phy_read(dev, 0x0801) in b43legacy_phy_initg()
1026 | 0x0080); in b43legacy_phy_initg()
1027 b43legacy_phy_write(dev, 0x043E, b43legacy_phy_read(dev, 0x043E) in b43legacy_phy_initg()
1028 | 0x0004); in b43legacy_phy_initg()
1030 if (phy->rev >= 2 && phy->gmode) in b43legacy_phy_initg()
1031 b43legacy_calc_loopback_gain(dev); in b43legacy_phy_initg()
1032 if (phy->radio_rev != 8) { in b43legacy_phy_initg()
1033 if (phy->initval == 0xFFFF) in b43legacy_phy_initg()
1034 phy->initval = b43legacy_radio_init2050(dev); in b43legacy_phy_initg()
1036 b43legacy_radio_write16(dev, 0x0078, phy->initval); in b43legacy_phy_initg()
1038 if (phy->txctl2 == 0xFFFF) in b43legacy_phy_initg()
1039 b43legacy_phy_lo_g_measure(dev); in b43legacy_phy_initg()
1041 if (phy->radio_ver == 0x2050 && phy->radio_rev == 8) in b43legacy_phy_initg()
1042 b43legacy_radio_write16(dev, 0x0052, in b43legacy_phy_initg()
1043 (phy->txctl1 << 4) | in b43legacy_phy_initg()
1044 phy->txctl2); in b43legacy_phy_initg()
1046 b43legacy_radio_write16(dev, 0x0052, in b43legacy_phy_initg()
1047 (b43legacy_radio_read16(dev, in b43legacy_phy_initg()
1048 0x0052) & 0xFFF0) | in b43legacy_phy_initg()
1049 phy->txctl1); in b43legacy_phy_initg()
1050 if (phy->rev >= 6) in b43legacy_phy_initg()
1051 b43legacy_phy_write(dev, 0x0036, in b43legacy_phy_initg()
1052 (b43legacy_phy_read(dev, 0x0036) in b43legacy_phy_initg()
1053 & 0x0FFF) | (phy->txctl2 << 12)); in b43legacy_phy_initg()
1054 if (dev->dev->bus->sprom.boardflags_lo & in b43legacy_phy_initg()
1056 b43legacy_phy_write(dev, 0x002E, 0x8075); in b43legacy_phy_initg()
1058 b43legacy_phy_write(dev, 0x002E, 0x807F); in b43legacy_phy_initg()
1059 if (phy->rev < 2) in b43legacy_phy_initg()
1060 b43legacy_phy_write(dev, 0x002F, 0x0101); in b43legacy_phy_initg()
1062 b43legacy_phy_write(dev, 0x002F, 0x0202); in b43legacy_phy_initg()
1064 if (phy->gmode) { in b43legacy_phy_initg()
1065 b43legacy_phy_lo_adjust(dev, 0); in b43legacy_phy_initg()
1066 b43legacy_phy_write(dev, 0x080F, 0x8078); in b43legacy_phy_initg()
1069 if (!(dev->dev->bus->sprom.boardflags_lo & B43legacy_BFL_RSSI)) { in b43legacy_phy_initg()
1071 * the value 0x7FFFFFFF here. I think that is some weird in b43legacy_phy_initg()
1074 * entries to -32 (see the clamp_val() in nrssi_hw_update()) in b43legacy_phy_initg()
1076 b43legacy_nrssi_hw_update(dev, 0xFFFF); in b43legacy_phy_initg()
1077 b43legacy_calc_nrssi_threshold(dev); in b43legacy_phy_initg()
1078 } else if (phy->gmode || phy->rev >= 2) { in b43legacy_phy_initg()
1079 if (phy->nrssi[0] == -1000) { in b43legacy_phy_initg()
1080 B43legacy_WARN_ON(phy->nrssi[1] != -1000); in b43legacy_phy_initg()
1081 b43legacy_calc_nrssi_slope(dev); in b43legacy_phy_initg()
1083 B43legacy_WARN_ON(phy->nrssi[1] == -1000); in b43legacy_phy_initg()
1084 b43legacy_calc_nrssi_threshold(dev); in b43legacy_phy_initg()
1087 if (phy->radio_rev == 8) in b43legacy_phy_initg()
1088 b43legacy_phy_write(dev, 0x0805, 0x3230); in b43legacy_phy_initg()
1089 b43legacy_phy_init_pctl(dev); in b43legacy_phy_initg()
1090 if (dev->dev->bus->chip_id == 0x4306 in b43legacy_phy_initg()
1091 && dev->dev->bus->chip_package == 2) { in b43legacy_phy_initg()
1092 b43legacy_phy_write(dev, 0x0429, in b43legacy_phy_initg()
1093 b43legacy_phy_read(dev, 0x0429) & 0xBFFF); in b43legacy_phy_initg()
1094 b43legacy_phy_write(dev, 0x04C3, in b43legacy_phy_initg()
1095 b43legacy_phy_read(dev, 0x04C3) & 0x7FFF); in b43legacy_phy_initg()
1099 static u16 b43legacy_phy_lo_b_r15_loop(struct b43legacy_wldev *dev) in b43legacy_phy_lo_b_r15_loop() argument
1102 u16 ret = 0; in b43legacy_phy_lo_b_r15_loop()
1106 for (i = 0; i < 10; i++) { in b43legacy_phy_lo_b_r15_loop()
1107 b43legacy_phy_write(dev, 0x0015, 0xAFA0); in b43legacy_phy_lo_b_r15_loop()
1109 b43legacy_phy_write(dev, 0x0015, 0xEFA0); in b43legacy_phy_lo_b_r15_loop()
1111 b43legacy_phy_write(dev, 0x0015, 0xFFA0); in b43legacy_phy_lo_b_r15_loop()
1113 ret += b43legacy_phy_read(dev, 0x002C); in b43legacy_phy_lo_b_r15_loop()
1121 void b43legacy_phy_lo_b_measure(struct b43legacy_wldev *dev) in b43legacy_phy_lo_b_measure() argument
1123 struct b43legacy_phy *phy = &dev->phy; in b43legacy_phy_lo_b_measure()
1124 u16 regstack[12] = { 0 }; in b43legacy_phy_lo_b_measure()
1130 regstack[0] = b43legacy_phy_read(dev, 0x0015); in b43legacy_phy_lo_b_measure()
1131 regstack[1] = b43legacy_radio_read16(dev, 0x0052) & 0xFFF0; in b43legacy_phy_lo_b_measure()
1133 if (phy->radio_ver == 0x2053) { in b43legacy_phy_lo_b_measure()
1134 regstack[2] = b43legacy_phy_read(dev, 0x000A); in b43legacy_phy_lo_b_measure()
1135 regstack[3] = b43legacy_phy_read(dev, 0x002A); in b43legacy_phy_lo_b_measure()
1136 regstack[4] = b43legacy_phy_read(dev, 0x0035); in b43legacy_phy_lo_b_measure()
1137 regstack[5] = b43legacy_phy_read(dev, 0x0003); in b43legacy_phy_lo_b_measure()
1138 regstack[6] = b43legacy_phy_read(dev, 0x0001); in b43legacy_phy_lo_b_measure()
1139 regstack[7] = b43legacy_phy_read(dev, 0x0030); in b43legacy_phy_lo_b_measure()
1141 regstack[8] = b43legacy_radio_read16(dev, 0x0043); in b43legacy_phy_lo_b_measure()
1142 regstack[9] = b43legacy_radio_read16(dev, 0x007A); in b43legacy_phy_lo_b_measure()
1143 regstack[10] = b43legacy_read16(dev, 0x03EC); in b43legacy_phy_lo_b_measure()
1144 regstack[11] = b43legacy_radio_read16(dev, 0x0052) & 0x00F0; in b43legacy_phy_lo_b_measure()
1146 b43legacy_phy_write(dev, 0x0030, 0x00FF); in b43legacy_phy_lo_b_measure()
1147 b43legacy_write16(dev, 0x03EC, 0x3F3F); in b43legacy_phy_lo_b_measure()
1148 b43legacy_phy_write(dev, 0x0035, regstack[4] & 0xFF7F); in b43legacy_phy_lo_b_measure()
1149 b43legacy_radio_write16(dev, 0x007A, regstack[9] & 0xFFF0); in b43legacy_phy_lo_b_measure()
1151 b43legacy_phy_write(dev, 0x0015, 0xB000); in b43legacy_phy_lo_b_measure()
1152 b43legacy_phy_write(dev, 0x002B, 0x0004); in b43legacy_phy_lo_b_measure()
1154 if (phy->radio_ver == 0x2053) { in b43legacy_phy_lo_b_measure()
1155 b43legacy_phy_write(dev, 0x002B, 0x0203); in b43legacy_phy_lo_b_measure()
1156 b43legacy_phy_write(dev, 0x002A, 0x08A3); in b43legacy_phy_lo_b_measure()
1159 phy->minlowsig[0] = 0xFFFF; in b43legacy_phy_lo_b_measure()
1161 for (i = 0; i < 4; i++) { in b43legacy_phy_lo_b_measure()
1162 b43legacy_radio_write16(dev, 0x0052, regstack[1] | i); in b43legacy_phy_lo_b_measure()
1163 b43legacy_phy_lo_b_r15_loop(dev); in b43legacy_phy_lo_b_measure()
1165 for (i = 0; i < 10; i++) { in b43legacy_phy_lo_b_measure()
1166 b43legacy_radio_write16(dev, 0x0052, regstack[1] | i); in b43legacy_phy_lo_b_measure()
1167 mls = b43legacy_phy_lo_b_r15_loop(dev) / 10; in b43legacy_phy_lo_b_measure()
1168 if (mls < phy->minlowsig[0]) { in b43legacy_phy_lo_b_measure()
1169 phy->minlowsig[0] = mls; in b43legacy_phy_lo_b_measure()
1170 phy->minlowsigpos[0] = i; in b43legacy_phy_lo_b_measure()
1173 b43legacy_radio_write16(dev, 0x0052, regstack[1] in b43legacy_phy_lo_b_measure()
1174 | phy->minlowsigpos[0]); in b43legacy_phy_lo_b_measure()
1176 phy->minlowsig[1] = 0xFFFF; in b43legacy_phy_lo_b_measure()
1178 for (i = -4; i < 5; i += 2) { in b43legacy_phy_lo_b_measure()
1179 for (j = -4; j < 5; j += 2) { in b43legacy_phy_lo_b_measure()
1180 if (j < 0) in b43legacy_phy_lo_b_measure()
1181 fval = (0x0100 * i) + j + 0x0100; in b43legacy_phy_lo_b_measure()
1183 fval = (0x0100 * i) + j; in b43legacy_phy_lo_b_measure()
1184 b43legacy_phy_write(dev, 0x002F, fval); in b43legacy_phy_lo_b_measure()
1185 mls = b43legacy_phy_lo_b_r15_loop(dev) / 10; in b43legacy_phy_lo_b_measure()
1186 if (mls < phy->minlowsig[1]) { in b43legacy_phy_lo_b_measure()
1187 phy->minlowsig[1] = mls; in b43legacy_phy_lo_b_measure()
1188 phy->minlowsigpos[1] = fval; in b43legacy_phy_lo_b_measure()
1192 phy->minlowsigpos[1] += 0x0101; in b43legacy_phy_lo_b_measure()
1194 b43legacy_phy_write(dev, 0x002F, phy->minlowsigpos[1]); in b43legacy_phy_lo_b_measure()
1195 if (phy->radio_ver == 0x2053) { in b43legacy_phy_lo_b_measure()
1196 b43legacy_phy_write(dev, 0x000A, regstack[2]); in b43legacy_phy_lo_b_measure()
1197 b43legacy_phy_write(dev, 0x002A, regstack[3]); in b43legacy_phy_lo_b_measure()
1198 b43legacy_phy_write(dev, 0x0035, regstack[4]); in b43legacy_phy_lo_b_measure()
1199 b43legacy_phy_write(dev, 0x0003, regstack[5]); in b43legacy_phy_lo_b_measure()
1200 b43legacy_phy_write(dev, 0x0001, regstack[6]); in b43legacy_phy_lo_b_measure()
1201 b43legacy_phy_write(dev, 0x0030, regstack[7]); in b43legacy_phy_lo_b_measure()
1203 b43legacy_radio_write16(dev, 0x0043, regstack[8]); in b43legacy_phy_lo_b_measure()
1204 b43legacy_radio_write16(dev, 0x007A, regstack[9]); in b43legacy_phy_lo_b_measure()
1206 b43legacy_radio_write16(dev, 0x0052, in b43legacy_phy_lo_b_measure()
1207 (b43legacy_radio_read16(dev, 0x0052) in b43legacy_phy_lo_b_measure()
1208 & 0x000F) | regstack[11]); in b43legacy_phy_lo_b_measure()
1210 b43legacy_write16(dev, 0x03EC, regstack[10]); in b43legacy_phy_lo_b_measure()
1212 b43legacy_phy_write(dev, 0x0015, regstack[0]); in b43legacy_phy_lo_b_measure()
1216 u16 b43legacy_phy_lo_g_deviation_subval(struct b43legacy_wldev *dev, in b43legacy_phy_lo_g_deviation_subval() argument
1219 struct b43legacy_phy *phy = &dev->phy; in b43legacy_phy_lo_g_deviation_subval()
1224 if (phy->gmode) { in b43legacy_phy_lo_g_deviation_subval()
1225 b43legacy_phy_write(dev, 0x15, 0xE300); in b43legacy_phy_lo_g_deviation_subval()
1227 b43legacy_phy_write(dev, 0x0812, control | 0x00B0); in b43legacy_phy_lo_g_deviation_subval()
1229 b43legacy_phy_write(dev, 0x0812, control | 0x00B2); in b43legacy_phy_lo_g_deviation_subval()
1231 b43legacy_phy_write(dev, 0x0812, control | 0x00B3); in b43legacy_phy_lo_g_deviation_subval()
1233 b43legacy_phy_write(dev, 0x0015, 0xF300); in b43legacy_phy_lo_g_deviation_subval()
1236 b43legacy_phy_write(dev, 0x0015, control | 0xEFA0); in b43legacy_phy_lo_g_deviation_subval()
1238 b43legacy_phy_write(dev, 0x0015, control | 0xEFE0); in b43legacy_phy_lo_g_deviation_subval()
1240 b43legacy_phy_write(dev, 0x0015, control | 0xFFE0); in b43legacy_phy_lo_g_deviation_subval()
1243 ret = b43legacy_phy_read(dev, 0x002D); in b43legacy_phy_lo_g_deviation_subval()
1250 static u32 b43legacy_phy_lo_g_singledeviation(struct b43legacy_wldev *dev, in b43legacy_phy_lo_g_singledeviation() argument
1254 u32 ret = 0; in b43legacy_phy_lo_g_singledeviation()
1256 for (i = 0; i < 8; i++) in b43legacy_phy_lo_g_singledeviation()
1257 ret += b43legacy_phy_lo_g_deviation_subval(dev, control); in b43legacy_phy_lo_g_singledeviation()
1264 void b43legacy_lo_write(struct b43legacy_wldev *dev, in b43legacy_lo_write() argument
1269 value = (u8)(pair->low); in b43legacy_lo_write()
1270 value |= ((u8)(pair->high)) << 8; in b43legacy_lo_write()
1274 if (pair->low < -8 || pair->low > 8 || in b43legacy_lo_write()
1275 pair->high < -8 || pair->high > 8) { in b43legacy_lo_write()
1276 b43legacydbg(dev->wl, in b43legacy_lo_write()
1279 pair->low, pair->high); in b43legacy_lo_write()
1284 b43legacy_phy_write(dev, B43legacy_PHY_G_LO_CONTROL, value); in b43legacy_lo_write()
1288 struct b43legacy_lopair *b43legacy_find_lopair(struct b43legacy_wldev *dev, in b43legacy_find_lopair() argument
1294 struct b43legacy_phy *phy = &dev->phy; in b43legacy_find_lopair()
1306 struct b43legacy_lopair *b43legacy_current_lopair(struct b43legacy_wldev *dev) in b43legacy_current_lopair() argument
1308 struct b43legacy_phy *phy = &dev->phy; in b43legacy_current_lopair()
1310 return b43legacy_find_lopair(dev, phy->bbatt, in b43legacy_current_lopair()
1311 phy->rfatt, phy->txctl1); in b43legacy_current_lopair()
1315 void b43legacy_phy_lo_adjust(struct b43legacy_wldev *dev, int fixed) in b43legacy_phy_lo_adjust() argument
1321 pair = b43legacy_find_lopair(dev, 2, 3, 0); in b43legacy_phy_lo_adjust()
1323 pair = b43legacy_current_lopair(dev); in b43legacy_phy_lo_adjust()
1324 b43legacy_lo_write(dev, pair); in b43legacy_phy_lo_adjust()
1327 static void b43legacy_phy_lo_g_measure_txctl2(struct b43legacy_wldev *dev) in b43legacy_phy_lo_g_measure_txctl2() argument
1329 struct b43legacy_phy *phy = &dev->phy; in b43legacy_phy_lo_g_measure_txctl2()
1330 u16 txctl2 = 0; in b43legacy_phy_lo_g_measure_txctl2()
1335 b43legacy_radio_write16(dev, 0x0052, 0x0000); in b43legacy_phy_lo_g_measure_txctl2()
1337 smallest = b43legacy_phy_lo_g_singledeviation(dev, 0); in b43legacy_phy_lo_g_measure_txctl2()
1338 for (i = 0; i < 16; i++) { in b43legacy_phy_lo_g_measure_txctl2()
1339 b43legacy_radio_write16(dev, 0x0052, i); in b43legacy_phy_lo_g_measure_txctl2()
1341 tmp = b43legacy_phy_lo_g_singledeviation(dev, 0); in b43legacy_phy_lo_g_measure_txctl2()
1347 phy->txctl2 = txctl2; in b43legacy_phy_lo_g_measure_txctl2()
1351 void b43legacy_phy_lo_g_state(struct b43legacy_wldev *dev, in b43legacy_phy_lo_g_state() argument
1358 { .high = 1, .low = 0, }, in b43legacy_phy_lo_g_state()
1359 { .high = 1, .low = -1, }, in b43legacy_phy_lo_g_state()
1360 { .high = 0, .low = -1, }, in b43legacy_phy_lo_g_state()
1361 { .high = -1, .low = -1, }, in b43legacy_phy_lo_g_state()
1362 { .high = -1, .low = 0, }, in b43legacy_phy_lo_g_state()
1363 { .high = -1, .low = 1, }, in b43legacy_phy_lo_g_state()
1364 { .high = 0, .low = 1, }, in b43legacy_phy_lo_g_state()
1367 .high = in_pair->high, in b43legacy_phy_lo_g_state()
1368 .low = in_pair->low, in b43legacy_phy_lo_g_state()
1373 int state = 0; in b43legacy_phy_lo_g_state()
1384 b43legacy_lo_write(dev, &lowest_transition); in b43legacy_phy_lo_g_state()
1385 lowest_deviation = b43legacy_phy_lo_g_singledeviation(dev, r27); in b43legacy_phy_lo_g_state()
1387 found_lower = 0; in b43legacy_phy_lo_g_state()
1388 B43legacy_WARN_ON(!(state >= 0 && state <= 8)); in b43legacy_phy_lo_g_state()
1389 if (state == 0) { in b43legacy_phy_lo_g_state()
1392 } else if (state % 2 == 0) { in b43legacy_phy_lo_g_state()
1393 begin = state - 1; in b43legacy_phy_lo_g_state()
1396 begin = state - 2; in b43legacy_phy_lo_g_state()
1402 end -= 8; in b43legacy_phy_lo_g_state()
1410 transitions[j - 1].high; in b43legacy_phy_lo_g_state()
1411 transition.low = tmp_pair.low + transitions[j - 1].low; in b43legacy_phy_lo_g_state()
1414 b43legacy_lo_write(dev, &transition); in b43legacy_phy_lo_g_state()
1415 tmp = b43legacy_phy_lo_g_singledeviation(dev, in b43legacy_phy_lo_g_state()
1434 } while (i-- && found_lower); in b43legacy_phy_lo_g_state()
1436 out_pair->high = lowest_transition.high; in b43legacy_phy_lo_g_state()
1437 out_pair->low = lowest_transition.low; in b43legacy_phy_lo_g_state()
1441 void b43legacy_phy_set_baseband_attenuation(struct b43legacy_wldev *dev, in b43legacy_phy_set_baseband_attenuation() argument
1444 struct b43legacy_phy *phy = &dev->phy; in b43legacy_phy_set_baseband_attenuation()
1447 if (phy->analog == 0) { in b43legacy_phy_set_baseband_attenuation()
1448 value = (b43legacy_read16(dev, 0x03E6) & 0xFFF0); in b43legacy_phy_set_baseband_attenuation()
1449 value |= (bbatt & 0x000F); in b43legacy_phy_set_baseband_attenuation()
1450 b43legacy_write16(dev, 0x03E6, value); in b43legacy_phy_set_baseband_attenuation()
1454 if (phy->analog > 1) { in b43legacy_phy_set_baseband_attenuation()
1455 value = b43legacy_phy_read(dev, 0x0060) & 0xFFC3; in b43legacy_phy_set_baseband_attenuation()
1456 value |= (bbatt << 2) & 0x003C; in b43legacy_phy_set_baseband_attenuation()
1458 value = b43legacy_phy_read(dev, 0x0060) & 0xFF87; in b43legacy_phy_set_baseband_attenuation()
1459 value |= (bbatt << 3) & 0x0078; in b43legacy_phy_set_baseband_attenuation()
1461 b43legacy_phy_write(dev, 0x0060, value); in b43legacy_phy_set_baseband_attenuation()
1464 /* https://bcm-specs.sipsolutions.net/LocalOscillator/Measure */
1465 void b43legacy_phy_lo_g_measure(struct b43legacy_wldev *dev) in b43legacy_phy_lo_g_measure() argument
1467 static const u8 pairorder[10] = { 3, 1, 5, 7, 9, 2, 0, 4, 6, 8 }; in b43legacy_phy_lo_g_measure()
1468 const int is_initializing = (b43legacy_status(dev) in b43legacy_phy_lo_g_measure()
1470 struct b43legacy_phy *phy = &dev->phy; in b43legacy_phy_lo_g_measure()
1473 u16 oldi = 0; in b43legacy_phy_lo_g_measure()
1478 u16 regstack[16] = { 0 }; in b43legacy_phy_lo_g_measure()
1482 u8 r27 = 0; in b43legacy_phy_lo_g_measure()
1485 oldchannel = phy->channel; in b43legacy_phy_lo_g_measure()
1487 if (phy->gmode) { in b43legacy_phy_lo_g_measure()
1488 regstack[0] = b43legacy_phy_read(dev, B43legacy_PHY_G_CRS); in b43legacy_phy_lo_g_measure()
1489 regstack[1] = b43legacy_phy_read(dev, 0x0802); in b43legacy_phy_lo_g_measure()
1490 b43legacy_phy_write(dev, B43legacy_PHY_G_CRS, regstack[0] in b43legacy_phy_lo_g_measure()
1491 & 0x7FFF); in b43legacy_phy_lo_g_measure()
1492 b43legacy_phy_write(dev, 0x0802, regstack[1] & 0xFFFC); in b43legacy_phy_lo_g_measure()
1494 regstack[3] = b43legacy_read16(dev, 0x03E2); in b43legacy_phy_lo_g_measure()
1495 b43legacy_write16(dev, 0x03E2, regstack[3] | 0x8000); in b43legacy_phy_lo_g_measure()
1496 regstack[4] = b43legacy_read16(dev, B43legacy_MMIO_CHANNEL_EXT); in b43legacy_phy_lo_g_measure()
1497 regstack[5] = b43legacy_phy_read(dev, 0x15); in b43legacy_phy_lo_g_measure()
1498 regstack[6] = b43legacy_phy_read(dev, 0x2A); in b43legacy_phy_lo_g_measure()
1499 regstack[7] = b43legacy_phy_read(dev, 0x35); in b43legacy_phy_lo_g_measure()
1500 regstack[8] = b43legacy_phy_read(dev, 0x60); in b43legacy_phy_lo_g_measure()
1501 regstack[9] = b43legacy_radio_read16(dev, 0x43); in b43legacy_phy_lo_g_measure()
1502 regstack[10] = b43legacy_radio_read16(dev, 0x7A); in b43legacy_phy_lo_g_measure()
1503 regstack[11] = b43legacy_radio_read16(dev, 0x52); in b43legacy_phy_lo_g_measure()
1504 if (phy->gmode) { in b43legacy_phy_lo_g_measure()
1505 regstack[12] = b43legacy_phy_read(dev, 0x0811); in b43legacy_phy_lo_g_measure()
1506 regstack[13] = b43legacy_phy_read(dev, 0x0812); in b43legacy_phy_lo_g_measure()
1507 regstack[14] = b43legacy_phy_read(dev, 0x0814); in b43legacy_phy_lo_g_measure()
1508 regstack[15] = b43legacy_phy_read(dev, 0x0815); in b43legacy_phy_lo_g_measure()
1510 b43legacy_radio_selectchannel(dev, 6, 0); in b43legacy_phy_lo_g_measure()
1511 if (phy->gmode) { in b43legacy_phy_lo_g_measure()
1512 b43legacy_phy_write(dev, B43legacy_PHY_G_CRS, regstack[0] in b43legacy_phy_lo_g_measure()
1513 & 0x7FFF); in b43legacy_phy_lo_g_measure()
1514 b43legacy_phy_write(dev, 0x0802, regstack[1] & 0xFFFC); in b43legacy_phy_lo_g_measure()
1515 b43legacy_dummy_transmission(dev); in b43legacy_phy_lo_g_measure()
1517 b43legacy_radio_write16(dev, 0x0043, 0x0006); in b43legacy_phy_lo_g_measure()
1519 b43legacy_phy_set_baseband_attenuation(dev, 2); in b43legacy_phy_lo_g_measure()
1521 b43legacy_write16(dev, B43legacy_MMIO_CHANNEL_EXT, 0x0000); in b43legacy_phy_lo_g_measure()
1522 b43legacy_phy_write(dev, 0x002E, 0x007F); in b43legacy_phy_lo_g_measure()
1523 b43legacy_phy_write(dev, 0x080F, 0x0078); in b43legacy_phy_lo_g_measure()
1524 b43legacy_phy_write(dev, 0x0035, regstack[7] & ~(1 << 7)); in b43legacy_phy_lo_g_measure()
1525 b43legacy_radio_write16(dev, 0x007A, regstack[10] & 0xFFF0); in b43legacy_phy_lo_g_measure()
1526 b43legacy_phy_write(dev, 0x002B, 0x0203); in b43legacy_phy_lo_g_measure()
1527 b43legacy_phy_write(dev, 0x002A, 0x08A3); in b43legacy_phy_lo_g_measure()
1528 if (phy->gmode) { in b43legacy_phy_lo_g_measure()
1529 b43legacy_phy_write(dev, 0x0814, regstack[14] | 0x0003); in b43legacy_phy_lo_g_measure()
1530 b43legacy_phy_write(dev, 0x0815, regstack[15] & 0xFFFC); in b43legacy_phy_lo_g_measure()
1531 b43legacy_phy_write(dev, 0x0811, 0x01B3); in b43legacy_phy_lo_g_measure()
1532 b43legacy_phy_write(dev, 0x0812, 0x00B2); in b43legacy_phy_lo_g_measure()
1535 b43legacy_phy_lo_g_measure_txctl2(dev); in b43legacy_phy_lo_g_measure()
1536 b43legacy_phy_write(dev, 0x080F, 0x8078); in b43legacy_phy_lo_g_measure()
1539 control.low = 0; in b43legacy_phy_lo_g_measure()
1540 control.high = 0; in b43legacy_phy_lo_g_measure()
1541 for (h = 0; h < 10; h++) { in b43legacy_phy_lo_g_measure()
1542 /* Loop over each possible RadioAttenuation (0-9) */ in b43legacy_phy_lo_g_measure()
1546 control.low = 0; in b43legacy_phy_lo_g_measure()
1547 control.high = 0; in b43legacy_phy_lo_g_measure()
1549 ((i % 2 == 0) && (oldi % 2 == 0))) { in b43legacy_phy_lo_g_measure()
1551 0); in b43legacy_phy_lo_g_measure()
1554 tmp_control = b43legacy_get_lopair(phy, 3, 0); in b43legacy_phy_lo_g_measure()
1559 for (j = 0; j < 4; j++) { in b43legacy_phy_lo_g_measure()
1562 r27 = 0; in b43legacy_phy_lo_g_measure()
1563 r31 = 0; in b43legacy_phy_lo_g_measure()
1574 if (!tmp_control->used) in b43legacy_phy_lo_g_measure()
1578 r31 = 0; in b43legacy_phy_lo_g_measure()
1580 b43legacy_radio_write16(dev, 0x43, i); in b43legacy_phy_lo_g_measure()
1581 b43legacy_radio_write16(dev, 0x52, phy->txctl2); in b43legacy_phy_lo_g_measure()
1585 b43legacy_phy_set_baseband_attenuation(dev, j * 2); in b43legacy_phy_lo_g_measure()
1587 tmp = (regstack[10] & 0xFFF0); in b43legacy_phy_lo_g_measure()
1589 tmp |= 0x0008; in b43legacy_phy_lo_g_measure()
1590 b43legacy_radio_write16(dev, 0x007A, tmp); in b43legacy_phy_lo_g_measure()
1593 b43legacy_phy_lo_g_state(dev, &control, tmp_control, in b43legacy_phy_lo_g_measure()
1598 /* Loop over each possible RadioAttenuation (10-13) */ in b43legacy_phy_lo_g_measure()
1601 for (j = 0; j < 4; j++) { in b43legacy_phy_lo_g_measure()
1603 tmp_control = b43legacy_get_lopair(phy, i - 9, in b43legacy_phy_lo_g_measure()
1608 tmp = (i - 9) * 2 + j - 5; in b43legacy_phy_lo_g_measure()
1609 r27 = 0; in b43legacy_phy_lo_g_measure()
1610 r31 = 0; in b43legacy_phy_lo_g_measure()
1619 tmp_control = b43legacy_get_lopair(phy, i - 9, in b43legacy_phy_lo_g_measure()
1621 if (!tmp_control->used) in b43legacy_phy_lo_g_measure()
1625 r31 = 0; in b43legacy_phy_lo_g_measure()
1627 b43legacy_radio_write16(dev, 0x43, i - 9); in b43legacy_phy_lo_g_measure()
1630 b43legacy_radio_write16(dev, 0x52, in b43legacy_phy_lo_g_measure()
1631 phy->txctl2 in b43legacy_phy_lo_g_measure()
1636 b43legacy_phy_set_baseband_attenuation(dev, j * 2); in b43legacy_phy_lo_g_measure()
1638 tmp = (regstack[10] & 0xFFF0); in b43legacy_phy_lo_g_measure()
1640 tmp |= 0x0008; in b43legacy_phy_lo_g_measure()
1641 b43legacy_radio_write16(dev, 0x7A, tmp); in b43legacy_phy_lo_g_measure()
1644 b43legacy_phy_lo_g_state(dev, &control, tmp_control, in b43legacy_phy_lo_g_measure()
1650 if (phy->gmode) { in b43legacy_phy_lo_g_measure()
1651 b43legacy_phy_write(dev, 0x0015, 0xE300); in b43legacy_phy_lo_g_measure()
1652 b43legacy_phy_write(dev, 0x0812, (r27 << 8) | 0xA0); in b43legacy_phy_lo_g_measure()
1654 b43legacy_phy_write(dev, 0x0812, (r27 << 8) | 0xA2); in b43legacy_phy_lo_g_measure()
1656 b43legacy_phy_write(dev, 0x0812, (r27 << 8) | 0xA3); in b43legacy_phy_lo_g_measure()
1659 b43legacy_phy_write(dev, 0x0015, r27 | 0xEFA0); in b43legacy_phy_lo_g_measure()
1660 b43legacy_phy_lo_adjust(dev, is_initializing); in b43legacy_phy_lo_g_measure()
1661 b43legacy_phy_write(dev, 0x002E, 0x807F); in b43legacy_phy_lo_g_measure()
1662 if (phy->gmode) in b43legacy_phy_lo_g_measure()
1663 b43legacy_phy_write(dev, 0x002F, 0x0202); in b43legacy_phy_lo_g_measure()
1665 b43legacy_phy_write(dev, 0x002F, 0x0101); in b43legacy_phy_lo_g_measure()
1666 b43legacy_write16(dev, B43legacy_MMIO_CHANNEL_EXT, regstack[4]); in b43legacy_phy_lo_g_measure()
1667 b43legacy_phy_write(dev, 0x0015, regstack[5]); in b43legacy_phy_lo_g_measure()
1668 b43legacy_phy_write(dev, 0x002A, regstack[6]); in b43legacy_phy_lo_g_measure()
1669 b43legacy_phy_write(dev, 0x0035, regstack[7]); in b43legacy_phy_lo_g_measure()
1670 b43legacy_phy_write(dev, 0x0060, regstack[8]); in b43legacy_phy_lo_g_measure()
1671 b43legacy_radio_write16(dev, 0x0043, regstack[9]); in b43legacy_phy_lo_g_measure()
1672 b43legacy_radio_write16(dev, 0x007A, regstack[10]); in b43legacy_phy_lo_g_measure()
1673 regstack[11] &= 0x00F0; in b43legacy_phy_lo_g_measure()
1674 regstack[11] |= (b43legacy_radio_read16(dev, 0x52) & 0x000F); in b43legacy_phy_lo_g_measure()
1675 b43legacy_radio_write16(dev, 0x52, regstack[11]); in b43legacy_phy_lo_g_measure()
1676 b43legacy_write16(dev, 0x03E2, regstack[3]); in b43legacy_phy_lo_g_measure()
1677 if (phy->gmode) { in b43legacy_phy_lo_g_measure()
1678 b43legacy_phy_write(dev, 0x0811, regstack[12]); in b43legacy_phy_lo_g_measure()
1679 b43legacy_phy_write(dev, 0x0812, regstack[13]); in b43legacy_phy_lo_g_measure()
1680 b43legacy_phy_write(dev, 0x0814, regstack[14]); in b43legacy_phy_lo_g_measure()
1681 b43legacy_phy_write(dev, 0x0815, regstack[15]); in b43legacy_phy_lo_g_measure()
1682 b43legacy_phy_write(dev, B43legacy_PHY_G_CRS, regstack[0]); in b43legacy_phy_lo_g_measure()
1683 b43legacy_phy_write(dev, 0x0802, regstack[1]); in b43legacy_phy_lo_g_measure()
1685 b43legacy_radio_selectchannel(dev, oldchannel, 1); in b43legacy_phy_lo_g_measure()
1690 for (i = 0; i < B43legacy_LO_COUNT; i++) { in b43legacy_phy_lo_g_measure()
1691 tmp_control = phy->_lo_pairs + i; in b43legacy_phy_lo_g_measure()
1692 if (tmp_control->low < -8 || tmp_control->low > 8 || in b43legacy_phy_lo_g_measure()
1693 tmp_control->high < -8 || tmp_control->high > 8) in b43legacy_phy_lo_g_measure()
1694 b43legacywarn(dev->wl, in b43legacy_phy_lo_g_measure()
1697 tmp_control->low, tmp_control->high, i); in b43legacy_phy_lo_g_measure()
1704 void b43legacy_phy_lo_mark_current_used(struct b43legacy_wldev *dev) in b43legacy_phy_lo_mark_current_used() argument
1708 pair = b43legacy_current_lopair(dev); in b43legacy_phy_lo_mark_current_used()
1709 pair->used = 1; in b43legacy_phy_lo_mark_current_used()
1712 void b43legacy_phy_lo_mark_all_unused(struct b43legacy_wldev *dev) in b43legacy_phy_lo_mark_all_unused() argument
1714 struct b43legacy_phy *phy = &dev->phy; in b43legacy_phy_lo_mark_all_unused()
1718 for (i = 0; i < B43legacy_LO_COUNT; i++) { in b43legacy_phy_lo_mark_all_unused()
1719 pair = phy->_lo_pairs + i; in b43legacy_phy_lo_mark_all_unused()
1720 pair->used = 0; in b43legacy_phy_lo_mark_all_unused()
1724 /* https://bcm-specs.sipsolutions.net/EstimatePowerOut
1727 static s8 b43legacy_phy_estimate_power_out(struct b43legacy_wldev *dev, s8 tssi) in b43legacy_phy_estimate_power_out() argument
1729 struct b43legacy_phy *phy = &dev->phy; in b43legacy_phy_estimate_power_out()
1730 s8 dbm = 0; in b43legacy_phy_estimate_power_out()
1733 tmp = phy->idle_tssi; in b43legacy_phy_estimate_power_out()
1735 tmp -= phy->savedpctlreg; in b43legacy_phy_estimate_power_out()
1737 switch (phy->type) { in b43legacy_phy_estimate_power_out()
1740 tmp = clamp_val(tmp, 0x00, 0x3F); in b43legacy_phy_estimate_power_out()
1741 dbm = phy->tssi2dbm[tmp]; in b43legacy_phy_estimate_power_out()
1750 /* https://bcm-specs.sipsolutions.net/RecalculateTransmissionPower */
1751 void b43legacy_phy_xmitpower(struct b43legacy_wldev *dev) in b43legacy_phy_xmitpower() argument
1753 struct b43legacy_phy *phy = &dev->phy; in b43legacy_phy_xmitpower()
1770 if (phy->savedpctlreg == 0xFFFF) in b43legacy_phy_xmitpower()
1772 if ((dev->dev->bus->boardinfo.type == 0x0416) && in b43legacy_phy_xmitpower()
1773 is_bcm_board_vendor(dev)) in b43legacy_phy_xmitpower()
1776 if (phy->manual_txpower_control) in b43legacy_phy_xmitpower()
1780 B43legacy_BUG_ON(!(phy->type == B43legacy_PHYTYPE_B || in b43legacy_phy_xmitpower()
1781 phy->type == B43legacy_PHYTYPE_G)); in b43legacy_phy_xmitpower()
1782 tmp = b43legacy_shm_read16(dev, B43legacy_SHM_SHARED, 0x0058); in b43legacy_phy_xmitpower()
1783 v0 = (s8)(tmp & 0x00FF); in b43legacy_phy_xmitpower()
1784 v1 = (s8)((tmp & 0xFF00) >> 8); in b43legacy_phy_xmitpower()
1785 tmp = b43legacy_shm_read16(dev, B43legacy_SHM_SHARED, 0x005A); in b43legacy_phy_xmitpower()
1786 v2 = (s8)(tmp & 0x00FF); in b43legacy_phy_xmitpower()
1787 v3 = (s8)((tmp & 0xFF00) >> 8); in b43legacy_phy_xmitpower()
1788 tmp = 0; in b43legacy_phy_xmitpower()
1790 if (v0 == 0x7F || v1 == 0x7F || v2 == 0x7F || v3 == 0x7F) { in b43legacy_phy_xmitpower()
1791 tmp = b43legacy_shm_read16(dev, B43legacy_SHM_SHARED, in b43legacy_phy_xmitpower()
1792 0x0070); in b43legacy_phy_xmitpower()
1793 v0 = (s8)(tmp & 0x00FF); in b43legacy_phy_xmitpower()
1794 v1 = (s8)((tmp & 0xFF00) >> 8); in b43legacy_phy_xmitpower()
1795 tmp = b43legacy_shm_read16(dev, B43legacy_SHM_SHARED, in b43legacy_phy_xmitpower()
1796 0x0072); in b43legacy_phy_xmitpower()
1797 v2 = (s8)(tmp & 0x00FF); in b43legacy_phy_xmitpower()
1798 v3 = (s8)((tmp & 0xFF00) >> 8); in b43legacy_phy_xmitpower()
1799 if (v0 == 0x7F || v1 == 0x7F || v2 == 0x7F || v3 == 0x7F) in b43legacy_phy_xmitpower()
1801 v0 = (v0 + 0x20) & 0x3F; in b43legacy_phy_xmitpower()
1802 v1 = (v1 + 0x20) & 0x3F; in b43legacy_phy_xmitpower()
1803 v2 = (v2 + 0x20) & 0x3F; in b43legacy_phy_xmitpower()
1804 v3 = (v3 + 0x20) & 0x3F; in b43legacy_phy_xmitpower()
1807 b43legacy_radio_clear_tssi(dev); in b43legacy_phy_xmitpower()
1811 if (tmp && (b43legacy_shm_read16(dev, B43legacy_SHM_SHARED, 0x005E) in b43legacy_phy_xmitpower()
1812 & 0x8)) in b43legacy_phy_xmitpower()
1813 average -= 13; in b43legacy_phy_xmitpower()
1815 estimated_pwr = b43legacy_phy_estimate_power_out(dev, average); in b43legacy_phy_xmitpower()
1817 max_pwr = dev->dev->bus->sprom.maxpwr_bg; in b43legacy_phy_xmitpower()
1819 if ((dev->dev->bus->sprom.boardflags_lo in b43legacy_phy_xmitpower()
1821 (phy->type == B43legacy_PHYTYPE_G)) in b43legacy_phy_xmitpower()
1822 max_pwr -= 0x3; in b43legacy_phy_xmitpower()
1823 if (unlikely(max_pwr <= 0)) { in b43legacy_phy_xmitpower()
1824 b43legacywarn(dev->wl, "Invalid max-TX-power value in SPROM." in b43legacy_phy_xmitpower()
1827 dev->dev->bus->sprom.maxpwr_bg = max_pwr; in b43legacy_phy_xmitpower()
1838 - dev->dev->bus->sprom.antenna_gain.a0 in b43legacy_phy_xmitpower()
1839 - 0x6, max_pwr); in b43legacy_phy_xmitpower()
1841 /* find the desired power in Q5.2 - power_level is in dBm in b43legacy_phy_xmitpower()
1842 * and limit it - max_pwr is already in Q5.2 */ in b43legacy_phy_xmitpower()
1843 desired_pwr = clamp_val(phy->power_level << 2, 0, max_pwr); in b43legacy_phy_xmitpower()
1844 if (b43legacy_debug(dev, B43legacy_DBG_XMITPOWER)) in b43legacy_phy_xmitpower()
1845 b43legacydbg(dev->wl, "Current TX power output: " Q52_FMT in b43legacy_phy_xmitpower()
1851 pwr_adjust = (desired_pwr - estimated_pwr) / 2; in b43legacy_phy_xmitpower()
1854 radio_att_delta = -(pwr_adjust + 7) >> 3; in b43legacy_phy_xmitpower()
1856 baseband_att_delta = -(pwr_adjust >> 1) - (4 * radio_att_delta); in b43legacy_phy_xmitpower()
1858 if ((radio_att_delta == 0) && (baseband_att_delta == 0)) { in b43legacy_phy_xmitpower()
1859 b43legacy_phy_lo_mark_current_used(dev); in b43legacy_phy_xmitpower()
1864 baseband_attenuation = phy->bbatt; in b43legacy_phy_xmitpower()
1866 radio_attenuation = phy->rfatt; in b43legacy_phy_xmitpower()
1870 * baseband 0-11, radio 0-9. in b43legacy_phy_xmitpower()
1873 if (radio_attenuation < 0) { in b43legacy_phy_xmitpower()
1874 baseband_attenuation -= (4 * -radio_attenuation); in b43legacy_phy_xmitpower()
1875 radio_attenuation = 0; in b43legacy_phy_xmitpower()
1877 baseband_attenuation += (4 * (radio_attenuation - 9)); in b43legacy_phy_xmitpower()
1880 while (baseband_attenuation < 0 && radio_attenuation > 0) { in b43legacy_phy_xmitpower()
1882 radio_attenuation--; in b43legacy_phy_xmitpower()
1885 baseband_attenuation -= 4; in b43legacy_phy_xmitpower()
1889 baseband_attenuation = clamp_val(baseband_attenuation, 0, 11); in b43legacy_phy_xmitpower()
1891 txpower = phy->txctl1; in b43legacy_phy_xmitpower()
1892 if ((phy->radio_ver == 0x2050) && (phy->radio_rev == 2)) { in b43legacy_phy_xmitpower()
1894 if (txpower == 0) { in b43legacy_phy_xmitpower()
1898 } else if (dev->dev->bus->sprom.boardflags_lo in b43legacy_phy_xmitpower()
1901 (radio_attenuation - 2); in b43legacy_phy_xmitpower()
1904 } else if (radio_attenuation > 4 && txpower != 0) { in b43legacy_phy_xmitpower()
1905 txpower = 0; in b43legacy_phy_xmitpower()
1907 radio_attenuation -= 3; in b43legacy_phy_xmitpower()
1910 radio_attenuation -= 2; in b43legacy_phy_xmitpower()
1911 baseband_attenuation -= 2; in b43legacy_phy_xmitpower()
1916 phy->txctl1 = txpower; in b43legacy_phy_xmitpower()
1917 baseband_attenuation = clamp_val(baseband_attenuation, 0, 11); in b43legacy_phy_xmitpower()
1918 radio_attenuation = clamp_val(radio_attenuation, 0, 9); in b43legacy_phy_xmitpower()
1919 phy->rfatt = radio_attenuation; in b43legacy_phy_xmitpower()
1920 phy->bbatt = baseband_attenuation; in b43legacy_phy_xmitpower()
1923 b43legacy_phy_lock(dev); in b43legacy_phy_xmitpower()
1924 b43legacy_radio_lock(dev); in b43legacy_phy_xmitpower()
1925 b43legacy_radio_set_txpower_bg(dev, baseband_attenuation, in b43legacy_phy_xmitpower()
1927 b43legacy_phy_lo_mark_current_used(dev); in b43legacy_phy_xmitpower()
1928 b43legacy_radio_unlock(dev); in b43legacy_phy_xmitpower()
1929 b43legacy_phy_unlock(dev); in b43legacy_phy_xmitpower()
1935 if (num < 0) in b43legacy_tssi2dbm_ad()
1949 s8 i = 0; in b43legacy_tssi2dbm_entry()
1955 return -EINVAL; in b43legacy_tssi2dbm_entry()
1956 q = b43legacy_tssi2dbm_ad(f * 4096 - in b43legacy_tssi2dbm_entry()
1959 delta = abs(q - f); in b43legacy_tssi2dbm_entry()
1964 -127, 128); in b43legacy_tssi2dbm_entry()
1965 return 0; in b43legacy_tssi2dbm_entry()
1968 /* http://bcm-specs.sipsolutions.net/TSSI_to_DBM_Table */
1969 int b43legacy_phy_init_tssi2dbm_table(struct b43legacy_wldev *dev) in b43legacy_phy_init_tssi2dbm_table() argument
1971 struct b43legacy_phy *phy = &dev->phy; in b43legacy_phy_init_tssi2dbm_table()
1978 B43legacy_WARN_ON(!(phy->type == B43legacy_PHYTYPE_B || in b43legacy_phy_init_tssi2dbm_table()
1979 phy->type == B43legacy_PHYTYPE_G)); in b43legacy_phy_init_tssi2dbm_table()
1980 pab0 = (s16)(dev->dev->bus->sprom.pa0b0); in b43legacy_phy_init_tssi2dbm_table()
1981 pab1 = (s16)(dev->dev->bus->sprom.pa0b1); in b43legacy_phy_init_tssi2dbm_table()
1982 pab2 = (s16)(dev->dev->bus->sprom.pa0b2); in b43legacy_phy_init_tssi2dbm_table()
1984 if ((dev->dev->bus->chip_id == 0x4301) && (phy->radio_ver != 0x2050)) { in b43legacy_phy_init_tssi2dbm_table()
1985 phy->idle_tssi = 0x34; in b43legacy_phy_init_tssi2dbm_table()
1986 phy->tssi2dbm = b43legacy_tssi2dbm_b_table; in b43legacy_phy_init_tssi2dbm_table()
1987 return 0; in b43legacy_phy_init_tssi2dbm_table()
1990 if (pab0 != 0 && pab1 != 0 && pab2 != 0 && in b43legacy_phy_init_tssi2dbm_table()
1991 pab0 != -1 && pab1 != -1 && pab2 != -1) { in b43legacy_phy_init_tssi2dbm_table()
1993 if ((s8)dev->dev->bus->sprom.itssi_bg != 0 && in b43legacy_phy_init_tssi2dbm_table()
1994 (s8)dev->dev->bus->sprom.itssi_bg != -1) in b43legacy_phy_init_tssi2dbm_table()
1995 phy->idle_tssi = (s8)(dev->dev->bus->sprom. in b43legacy_phy_init_tssi2dbm_table()
1998 phy->idle_tssi = 62; in b43legacy_phy_init_tssi2dbm_table()
2001 b43legacyerr(dev->wl, "Could not allocate memory " in b43legacy_phy_init_tssi2dbm_table()
2003 return -ENOMEM; in b43legacy_phy_init_tssi2dbm_table()
2005 for (idx = 0; idx < 64; idx++) in b43legacy_phy_init_tssi2dbm_table()
2008 phy->tssi2dbm = NULL; in b43legacy_phy_init_tssi2dbm_table()
2009 b43legacyerr(dev->wl, "Could not generate " in b43legacy_phy_init_tssi2dbm_table()
2012 return -ENODEV; in b43legacy_phy_init_tssi2dbm_table()
2014 phy->tssi2dbm = dyn_tssi2dbm; in b43legacy_phy_init_tssi2dbm_table()
2015 phy->dyn_tssi_tbl = 1; in b43legacy_phy_init_tssi2dbm_table()
2018 switch (phy->type) { in b43legacy_phy_init_tssi2dbm_table()
2020 phy->idle_tssi = 0x34; in b43legacy_phy_init_tssi2dbm_table()
2021 phy->tssi2dbm = b43legacy_tssi2dbm_b_table; in b43legacy_phy_init_tssi2dbm_table()
2024 phy->idle_tssi = 0x34; in b43legacy_phy_init_tssi2dbm_table()
2025 phy->tssi2dbm = b43legacy_tssi2dbm_g_table; in b43legacy_phy_init_tssi2dbm_table()
2030 return 0; in b43legacy_phy_init_tssi2dbm_table()
2033 int b43legacy_phy_init(struct b43legacy_wldev *dev) in b43legacy_phy_init() argument
2035 struct b43legacy_phy *phy = &dev->phy; in b43legacy_phy_init()
2036 int err = -ENODEV; in b43legacy_phy_init()
2038 switch (phy->type) { in b43legacy_phy_init()
2040 switch (phy->rev) { in b43legacy_phy_init()
2042 b43legacy_phy_initb2(dev); in b43legacy_phy_init()
2043 err = 0; in b43legacy_phy_init()
2046 b43legacy_phy_initb4(dev); in b43legacy_phy_init()
2047 err = 0; in b43legacy_phy_init()
2050 b43legacy_phy_initb5(dev); in b43legacy_phy_init()
2051 err = 0; in b43legacy_phy_init()
2054 b43legacy_phy_initb6(dev); in b43legacy_phy_init()
2055 err = 0; in b43legacy_phy_init()
2060 b43legacy_phy_initg(dev); in b43legacy_phy_init()
2061 err = 0; in b43legacy_phy_init()
2065 b43legacyerr(dev->wl, "Unknown PHYTYPE found\n"); in b43legacy_phy_init()
2070 void b43legacy_phy_set_antenna_diversity(struct b43legacy_wldev *dev) in b43legacy_phy_set_antenna_diversity() argument
2072 struct b43legacy_phy *phy = &dev->phy; in b43legacy_phy_set_antenna_diversity()
2078 antennadiv = phy->antenna_diversity; in b43legacy_phy_set_antenna_diversity()
2080 if (antennadiv == 0xFFFF) in b43legacy_phy_set_antenna_diversity()
2084 ucodeflags = b43legacy_shm_read32(dev, B43legacy_SHM_SHARED, in b43legacy_phy_set_antenna_diversity()
2086 b43legacy_shm_write32(dev, B43legacy_SHM_SHARED, in b43legacy_phy_set_antenna_diversity()
2090 switch (phy->type) { in b43legacy_phy_set_antenna_diversity()
2092 offset = 0x0400; in b43legacy_phy_set_antenna_diversity()
2098 b43legacy_phy_write(dev, offset + 1, in b43legacy_phy_set_antenna_diversity()
2099 (b43legacy_phy_read(dev, offset + 1) in b43legacy_phy_set_antenna_diversity()
2100 & 0x7E7F) | value); in b43legacy_phy_set_antenna_diversity()
2106 value = (0/*force0*/ << 7); in b43legacy_phy_set_antenna_diversity()
2107 b43legacy_phy_write(dev, offset + 0x2B, in b43legacy_phy_set_antenna_diversity()
2108 (b43legacy_phy_read(dev, in b43legacy_phy_set_antenna_diversity()
2109 offset + 0x2B) in b43legacy_phy_set_antenna_diversity()
2110 & 0xFEFF) | value); in b43legacy_phy_set_antenna_diversity()
2113 if (phy->type == B43legacy_PHYTYPE_G) { in b43legacy_phy_set_antenna_diversity()
2115 b43legacy_phy_write(dev, 0x048C, in b43legacy_phy_set_antenna_diversity()
2116 b43legacy_phy_read(dev, in b43legacy_phy_set_antenna_diversity()
2117 0x048C) | 0x2000); in b43legacy_phy_set_antenna_diversity()
2119 b43legacy_phy_write(dev, 0x048C, in b43legacy_phy_set_antenna_diversity()
2120 b43legacy_phy_read(dev, in b43legacy_phy_set_antenna_diversity()
2121 0x048C) & ~0x2000); in b43legacy_phy_set_antenna_diversity()
2122 if (phy->rev >= 2) { in b43legacy_phy_set_antenna_diversity()
2123 b43legacy_phy_write(dev, 0x0461, in b43legacy_phy_set_antenna_diversity()
2124 b43legacy_phy_read(dev, in b43legacy_phy_set_antenna_diversity()
2125 0x0461) | 0x0010); in b43legacy_phy_set_antenna_diversity()
2126 b43legacy_phy_write(dev, 0x04AD, in b43legacy_phy_set_antenna_diversity()
2127 (b43legacy_phy_read(dev, in b43legacy_phy_set_antenna_diversity()
2128 0x04AD) in b43legacy_phy_set_antenna_diversity()
2129 & 0x00FF) | 0x0015); in b43legacy_phy_set_antenna_diversity()
2130 if (phy->rev == 2) in b43legacy_phy_set_antenna_diversity()
2131 b43legacy_phy_write(dev, 0x0427, in b43legacy_phy_set_antenna_diversity()
2132 0x0008); in b43legacy_phy_set_antenna_diversity()
2134 b43legacy_phy_write(dev, 0x0427, in b43legacy_phy_set_antenna_diversity()
2135 (b43legacy_phy_read(dev, 0x0427) in b43legacy_phy_set_antenna_diversity()
2136 & 0x00FF) | 0x0008); in b43legacy_phy_set_antenna_diversity()
2137 } else if (phy->rev >= 6) in b43legacy_phy_set_antenna_diversity()
2138 b43legacy_phy_write(dev, 0x049B, 0x00DC); in b43legacy_phy_set_antenna_diversity()
2140 if (phy->rev < 3) in b43legacy_phy_set_antenna_diversity()
2141 b43legacy_phy_write(dev, 0x002B, in b43legacy_phy_set_antenna_diversity()
2142 (b43legacy_phy_read(dev, in b43legacy_phy_set_antenna_diversity()
2143 0x002B) & 0x00FF) in b43legacy_phy_set_antenna_diversity()
2144 | 0x0024); in b43legacy_phy_set_antenna_diversity()
2146 b43legacy_phy_write(dev, 0x0061, in b43legacy_phy_set_antenna_diversity()
2147 b43legacy_phy_read(dev, in b43legacy_phy_set_antenna_diversity()
2148 0x0061) | 0x0010); in b43legacy_phy_set_antenna_diversity()
2149 if (phy->rev == 3) { in b43legacy_phy_set_antenna_diversity()
2150 b43legacy_phy_write(dev, 0x0093, in b43legacy_phy_set_antenna_diversity()
2151 0x001D); in b43legacy_phy_set_antenna_diversity()
2152 b43legacy_phy_write(dev, 0x0027, in b43legacy_phy_set_antenna_diversity()
2153 0x0008); in b43legacy_phy_set_antenna_diversity()
2155 b43legacy_phy_write(dev, 0x0093, in b43legacy_phy_set_antenna_diversity()
2156 0x003A); in b43legacy_phy_set_antenna_diversity()
2157 b43legacy_phy_write(dev, 0x0027, in b43legacy_phy_set_antenna_diversity()
2158 (b43legacy_phy_read(dev, 0x0027) in b43legacy_phy_set_antenna_diversity()
2159 & 0x00FF) | 0x0008); in b43legacy_phy_set_antenna_diversity()
2165 if (dev->dev->id.revision == 2) in b43legacy_phy_set_antenna_diversity()
2169 b43legacy_phy_write(dev, 0x03E2, in b43legacy_phy_set_antenna_diversity()
2170 (b43legacy_phy_read(dev, 0x03E2) in b43legacy_phy_set_antenna_diversity()
2171 & 0xFE7F) | value); in b43legacy_phy_set_antenna_diversity()
2178 ucodeflags = b43legacy_shm_read32(dev, B43legacy_SHM_SHARED, in b43legacy_phy_set_antenna_diversity()
2180 b43legacy_shm_write32(dev, B43legacy_SHM_SHARED, in b43legacy_phy_set_antenna_diversity()
2185 phy->antenna_diversity = antennadiv; in b43legacy_phy_set_antenna_diversity()
2190 * 0 => unset the bit
2192 * -1 => calculate the bit
2194 void b43legacy_power_saving_ctl_bits(struct b43legacy_wldev *dev, in b43legacy_power_saving_ctl_bits() argument
2201 bit25 = 0; in b43legacy_power_saving_ctl_bits()
2204 if (bit25 == -1) { in b43legacy_power_saving_ctl_bits()
2209 if (bit26 == -1) { in b43legacy_power_saving_ctl_bits()
2212 * or the latest PS-Poll packet sent was successful, in b43legacy_power_saving_ctl_bits()
2215 status = b43legacy_read32(dev, B43legacy_MMIO_MACCTL); in b43legacy_power_saving_ctl_bits()
2224 b43legacy_write32(dev, B43legacy_MMIO_MACCTL, status); in b43legacy_power_saving_ctl_bits()
2225 if (bit26 && dev->dev->id.revision >= 5) { in b43legacy_power_saving_ctl_bits()
2226 for (i = 0; i < 100; i++) { in b43legacy_power_saving_ctl_bits()
2227 if (b43legacy_shm_read32(dev, B43legacy_SHM_SHARED, in b43legacy_power_saving_ctl_bits()
2228 0x0040) != 4) in b43legacy_power_saving_ctl_bits()