diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2011-09-01 16:49:57 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-09-14 13:56:18 -0400 |
commit | c9c0d9ecdceebe51d1c4e2231f0e691556ec348f (patch) | |
tree | cab8cd290ca761ccc932a789ca8def93966a28f2 /drivers/net/wireless/b43 | |
parent | cfee66b0f9891fc2b79a238e737308a2732365d2 (diff) |
b43: N-PHY: implement enabling TX power control
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/b43')
-rw-r--r-- | drivers/net/wireless/b43/phy_n.c | 84 | ||||
-rw-r--r-- | drivers/net/wireless/b43/phy_n.h | 2 |
2 files changed, 80 insertions, 6 deletions
diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c index 2eadadf5f4fc..6e9168079b9e 100644 --- a/drivers/net/wireless/b43/phy_n.c +++ b/drivers/net/wireless/b43/phy_n.c | |||
@@ -248,15 +248,25 @@ static void b43_nphy_tx_power_ctrl(struct b43_wldev *dev, bool enable) | |||
248 | { | 248 | { |
249 | struct b43_phy_n *nphy = dev->phy.n; | 249 | struct b43_phy_n *nphy = dev->phy.n; |
250 | u8 i; | 250 | u8 i; |
251 | u16 tmp; | 251 | u16 bmask, val, tmp; |
252 | enum ieee80211_band band = b43_current_band(dev->wl); | ||
252 | 253 | ||
253 | if (nphy->hang_avoid) | 254 | if (nphy->hang_avoid) |
254 | b43_nphy_stay_in_carrier_search(dev, 1); | 255 | b43_nphy_stay_in_carrier_search(dev, 1); |
255 | 256 | ||
256 | nphy->txpwrctrl = enable; | 257 | nphy->txpwrctrl = enable; |
257 | if (!enable) { | 258 | if (!enable) { |
258 | if (dev->phy.rev >= 3) | 259 | if (dev->phy.rev >= 3 && |
259 | ; /* TODO */ | 260 | (b43_phy_read(dev, B43_NPHY_TXPCTL_CMD) & |
261 | (B43_NPHY_TXPCTL_CMD_COEFF | | ||
262 | B43_NPHY_TXPCTL_CMD_HWPCTLEN | | ||
263 | B43_NPHY_TXPCTL_CMD_PCTLEN))) { | ||
264 | /* We disable enabled TX pwr ctl, save it's state */ | ||
265 | nphy->tx_pwr_idx[0] = b43_phy_read(dev, | ||
266 | B43_NPHY_C1_TXPCTL_STAT) & 0x7f; | ||
267 | nphy->tx_pwr_idx[1] = b43_phy_read(dev, | ||
268 | B43_NPHY_C2_TXPCTL_STAT) & 0x7f; | ||
269 | } | ||
260 | 270 | ||
261 | b43_phy_write(dev, B43_NPHY_TABLE_ADDR, 0x6840); | 271 | b43_phy_write(dev, B43_NPHY_TABLE_ADDR, 0x6840); |
262 | for (i = 0; i < 84; i++) | 272 | for (i = 0; i < 84; i++) |
@@ -285,10 +295,68 @@ static void b43_nphy_tx_power_ctrl(struct b43_wldev *dev, bool enable) | |||
285 | b43_phy_maskset(dev, B43_NPHY_BPHY_CTL3, | 295 | b43_phy_maskset(dev, B43_NPHY_BPHY_CTL3, |
286 | ~B43_NPHY_BPHY_CTL3_SCALE, 0x5A); | 296 | ~B43_NPHY_BPHY_CTL3_SCALE, 0x5A); |
287 | 297 | ||
288 | if (dev->phy.rev < 2 && 0) | 298 | if (dev->phy.rev < 2 && dev->phy.is_40mhz) |
289 | ; /* TODO */ | 299 | b43_hf_write(dev, b43_hf_read(dev) | B43_HF_TSSIRPSMW); |
290 | } else { | 300 | } else { |
291 | b43err(dev->wl, "enabling tx pwr ctrl not implemented yet\n"); | 301 | b43_ntab_write_bulk(dev, B43_NTAB16(26, 64), 84, |
302 | nphy->adj_pwr_tbl); | ||
303 | b43_ntab_write_bulk(dev, B43_NTAB16(27, 64), 84, | ||
304 | nphy->adj_pwr_tbl); | ||
305 | |||
306 | bmask = B43_NPHY_TXPCTL_CMD_COEFF | | ||
307 | B43_NPHY_TXPCTL_CMD_HWPCTLEN; | ||
308 | /* wl does useless check for "enable" param here */ | ||
309 | val = B43_NPHY_TXPCTL_CMD_COEFF | B43_NPHY_TXPCTL_CMD_HWPCTLEN; | ||
310 | if (dev->phy.rev >= 3) { | ||
311 | bmask |= B43_NPHY_TXPCTL_CMD_PCTLEN; | ||
312 | if (val) | ||
313 | val |= B43_NPHY_TXPCTL_CMD_PCTLEN; | ||
314 | } | ||
315 | b43_phy_maskset(dev, B43_NPHY_TXPCTL_CMD, ~(bmask), val); | ||
316 | |||
317 | if (band == IEEE80211_BAND_5GHZ) { | ||
318 | b43_phy_maskset(dev, B43_NPHY_TXPCTL_CMD, | ||
319 | ~B43_NPHY_TXPCTL_CMD_INIT, 0x64); | ||
320 | if (dev->phy.rev > 1) | ||
321 | b43_phy_maskset(dev, B43_NPHY_TXPCTL_INIT, | ||
322 | ~B43_NPHY_TXPCTL_INIT_PIDXI1, | ||
323 | 0x64); | ||
324 | } | ||
325 | |||
326 | if (dev->phy.rev >= 3) { | ||
327 | if (nphy->tx_pwr_idx[0] != 128 && | ||
328 | nphy->tx_pwr_idx[1] != 128) { | ||
329 | /* Recover TX pwr ctl state */ | ||
330 | b43_phy_maskset(dev, B43_NPHY_TXPCTL_CMD, | ||
331 | ~B43_NPHY_TXPCTL_CMD_INIT, | ||
332 | nphy->tx_pwr_idx[0]); | ||
333 | if (dev->phy.rev > 1) | ||
334 | b43_phy_maskset(dev, | ||
335 | B43_NPHY_TXPCTL_INIT, | ||
336 | ~0xff, nphy->tx_pwr_idx[1]); | ||
337 | } | ||
338 | } | ||
339 | |||
340 | if (dev->phy.rev >= 3) { | ||
341 | b43_phy_mask(dev, B43_NPHY_AFECTL_OVER1, ~0x100); | ||
342 | b43_phy_mask(dev, B43_NPHY_AFECTL_OVER, ~0x100); | ||
343 | } else { | ||
344 | b43_phy_mask(dev, B43_NPHY_AFECTL_OVER, ~0x4000); | ||
345 | } | ||
346 | |||
347 | if (dev->phy.rev == 2) | ||
348 | b43_phy_maskset(dev, B43_NPHY_BPHY_CTL3, ~0xFF, 0x3b); | ||
349 | else if (dev->phy.rev < 2) | ||
350 | b43_phy_maskset(dev, B43_NPHY_BPHY_CTL3, ~0xFF, 0x40); | ||
351 | |||
352 | if (dev->phy.rev < 2 && dev->phy.is_40mhz) | ||
353 | b43_hf_write(dev, b43_hf_read(dev) & ~B43_HF_TSSIRPSMW); | ||
354 | |||
355 | if ((nphy->ipa2g_on && band == IEEE80211_BAND_2GHZ) || | ||
356 | (nphy->ipa5g_on && band == IEEE80211_BAND_5GHZ)) { | ||
357 | b43_phy_mask(dev, B43_NPHY_PAPD_EN0, ~0x4); | ||
358 | b43_phy_mask(dev, B43_NPHY_PAPD_EN1, ~0x4); | ||
359 | } | ||
292 | } | 360 | } |
293 | 361 | ||
294 | if (nphy->hang_avoid) | 362 | if (nphy->hang_avoid) |
@@ -3918,6 +3986,10 @@ static void b43_nphy_op_prepare_structs(struct b43_wldev *dev) | |||
3918 | nphy->txrx_chain = 2; /* sth different than 0 and 1 for now */ | 3986 | nphy->txrx_chain = 2; /* sth different than 0 and 1 for now */ |
3919 | nphy->phyrxchain = 3; /* to avoid b43_nphy_set_rx_core_state like wl */ | 3987 | nphy->phyrxchain = 3; /* to avoid b43_nphy_set_rx_core_state like wl */ |
3920 | nphy->perical = 2; /* avoid additional rssi cal on init (like wl) */ | 3988 | nphy->perical = 2; /* avoid additional rssi cal on init (like wl) */ |
3989 | /* 128 can mean disabled-by-default state of TX pwr ctl. Max value is | ||
3990 | * 0x7f == 127 and we check for 128 when restoring TX pwr ctl. */ | ||
3991 | nphy->tx_pwr_idx[0] = 128; | ||
3992 | nphy->tx_pwr_idx[1] = 128; | ||
3921 | } | 3993 | } |
3922 | 3994 | ||
3923 | static void b43_nphy_op_free(struct b43_wldev *dev) | 3995 | static void b43_nphy_op_free(struct b43_wldev *dev) |
diff --git a/drivers/net/wireless/b43/phy_n.h b/drivers/net/wireless/b43/phy_n.h index e789a89f1047..cd8498904b90 100644 --- a/drivers/net/wireless/b43/phy_n.h +++ b/drivers/net/wireless/b43/phy_n.h | |||
@@ -783,6 +783,8 @@ struct b43_phy_n { | |||
783 | u16 mphase_txcal_bestcoeffs[11]; | 783 | u16 mphase_txcal_bestcoeffs[11]; |
784 | 784 | ||
785 | bool txpwrctrl; | 785 | bool txpwrctrl; |
786 | u8 tx_pwr_idx[2]; | ||
787 | u16 adj_pwr_tbl[84]; | ||
786 | u16 txcal_bbmult; | 788 | u16 txcal_bbmult; |
787 | u16 txiqlocal_bestc[11]; | 789 | u16 txiqlocal_bestc[11]; |
788 | bool txiqlocal_coeffsvalid; | 790 | bool txiqlocal_coeffsvalid; |