Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ar9003_hw.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2011 Atheros Communications Inc.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #include "hw.h"
18 #include "ar9003_mac.h"
19 #include "ar9003_2p2_initvals.h"
20 #include "ar9485_initvals.h"
21 #include "ar9340_initvals.h"
22 #include "ar9330_1p1_initvals.h"
23 #include "ar9330_1p2_initvals.h"
24 #include "ar955x_1p0_initvals.h"
25 #include "ar9580_1p0_initvals.h"
26 #include "ar9462_2p0_initvals.h"
27 #include "ar9565_1p0_initvals.h"
28 
29 /* General hardware code for the AR9003 hadware family */
30 
31 /*
32  * The AR9003 family uses a new INI format (pre, core, post
33  * arrays per subsystem). This provides support for the
34  * AR9003 2.2 chipsets.
35  */
36 static void ar9003_hw_init_mode_regs(struct ath_hw *ah)
37 {
38 #define AR9462_BB_CTX_COEFJ(x) \
39  ar9462_##x##_baseband_core_txfir_coeff_japan_2484
40 
41 #define AR9462_BBC_TXIFR_COEFFJ \
42  ar9462_2p0_baseband_core_txfir_coeff_japan_2484
43 
44  if (AR_SREV_9330_11(ah)) {
45  /* mac */
47  ar9331_1p1_mac_core);
50 
51  /* bb */
53  ar9331_1p1_baseband_core);
55  ar9331_1p1_baseband_postamble);
56 
57  /* radio */
59  ar9331_1p1_radio_core);
60 
61  /* soc */
63  ar9331_1p1_soc_preamble);
65  ar9331_1p1_soc_postamble);
66 
67  /* rx/tx gain */
69  ar9331_common_rx_gain_1p1);
71  ar9331_modes_lowest_ob_db_tx_gain_1p1);
72 
73  /* additional clock settings */
74  if (ah->is_clk_25mhz)
76  ar9331_1p1_xtal_25M);
77  else
79  ar9331_1p1_xtal_40M);
80  } else if (AR_SREV_9330_12(ah)) {
81  /* mac */
86 
87  /* bb */
91  ar9331_1p2_baseband_postamble);
92 
93  /* radio */
95  ar9331_1p2_radio_core);
96 
97  /* soc */
102 
103  /* rx/tx gain */
108 
109  /* additional clock settings */
110  if (ah->is_clk_25mhz)
113  else
116  } else if (AR_SREV_9340(ah)) {
117  /* mac */
119  ar9340_1p0_mac_core);
122 
123  /* bb */
125  ar9340_1p0_baseband_core);
127  ar9340_1p0_baseband_postamble);
128 
129  /* radio */
131  ar9340_1p0_radio_core);
133  ar9340_1p0_radio_postamble);
134 
135  /* soc */
137  ar9340_1p0_soc_preamble);
140 
141  /* rx/tx gain */
145  ar9340Modes_high_ob_db_tx_gain_table_1p0);
146 
149 
150  if (!ah->is_clk_25mhz)
152  ar9340_1p0_radio_core_40M);
153  } else if (AR_SREV_9485_11(ah)) {
154  /* mac */
156  ar9485_1_1_mac_core);
159 
160  /* bb */
161  INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], ar9485_1_1);
163  ar9485_1_1_baseband_core);
165  ar9485_1_1_baseband_postamble);
166 
167  /* radio */
169  ar9485_1_1_radio_core);
171  ar9485_1_1_radio_postamble);
172 
173  /* soc */
175  ar9485_1_1_soc_preamble);
176 
177  /* rx/tx gain */
179  ar9485Common_wo_xlna_rx_gain_1_1);
182 
183  /* Load PCIE SERDES settings from INI */
184 
185  /* Awake Setting */
186 
188  ar9485_1_1_pcie_phy_clkreq_disable_L1);
189 
190  /* Sleep Setting */
191 
193  ar9485_1_1_pcie_phy_clkreq_disable_L1);
194  } else if (AR_SREV_9462_20(ah)) {
195 
196  INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], ar9462_2p0_mac_core);
198  ar9462_2p0_mac_postamble);
199 
201  ar9462_2p0_baseband_core);
203  ar9462_2p0_baseband_postamble);
204 
206  ar9462_2p0_radio_core);
208  ar9462_2p0_radio_postamble);
210  ar9462_2p0_radio_postamble_sys2ant);
211 
213  ar9462_2p0_soc_preamble);
215  ar9462_2p0_soc_postamble);
216 
218  ar9462_common_rx_gain_table_2p0);
219 
220  /* Awake -> Sleep Setting */
222  ar9462_pciephy_pll_on_clkreq_disable_L1_2p0);
223  /* Sleep -> Awake Setting */
225  ar9462_pciephy_pll_on_clkreq_disable_L1_2p0);
226 
227  /* Fast clock modal settings */
229  ar9462_modes_fast_clock_2p0);
230 
233 
234  INIT_INI_ARRAY(&ah->ini_japan2484, AR9462_BBC_TXIFR_COEFFJ);
235  } else if (AR_SREV_9550(ah)) {
236  /* mac */
238  ar955x_1p0_mac_core);
240  ar955x_1p0_mac_postamble);
241 
242  /* bb */
244  ar955x_1p0_baseband_core);
246  ar955x_1p0_baseband_postamble);
247 
248  /* radio */
250  ar955x_1p0_radio_core);
252  ar955x_1p0_radio_postamble);
253 
254  /* soc */
256  ar955x_1p0_soc_preamble);
258  ar955x_1p0_soc_postamble);
259 
260  /* rx/tx gain */
262  ar955x_1p0_common_wo_xlna_rx_gain_table);
264  ar955x_1p0_common_wo_xlna_rx_gain_bounds);
266  ar955x_1p0_modes_xpa_tx_gain_table);
267 
268  /* Fast clock modal settings */
270  ar955x_1p0_modes_fast_clock);
271  } else if (AR_SREV_9580(ah)) {
272  /* mac */
274  ar9580_1p0_mac_core);
277 
278  /* bb */
280  ar9580_1p0_baseband_core);
282  ar9580_1p0_baseband_postamble);
283 
284  /* radio */
286  ar9580_1p0_radio_core);
288  ar9580_1p0_radio_postamble);
289 
290  /* soc */
292  ar9580_1p0_soc_preamble);
295 
296  /* rx/tx gain */
300  ar9580_1p0_low_ob_db_tx_gain_table);
301 
304  } else if (AR_SREV_9565(ah)) {
306  ar9565_1p0_mac_core);
308  ar9565_1p0_mac_postamble);
309 
311  ar9565_1p0_baseband_core);
313  ar9565_1p0_baseband_postamble);
314 
316  ar9565_1p0_radio_core);
318  ar9565_1p0_radio_postamble);
319 
321  ar9565_1p0_soc_preamble);
323  ar9565_1p0_soc_postamble);
324 
326  ar9565_1p0_Common_rx_gain_table);
328  ar9565_1p0_Modes_lowest_ob_db_tx_gain_table);
329 
331  ar9565_1p0_pciephy_pll_on_clkreq_disable_L1);
333  ar9565_1p0_pciephy_pll_on_clkreq_disable_L1);
334 
336  ar9565_1p0_modes_fast_clock);
337  } else {
338  /* mac */
340  ar9300_2p2_mac_core);
342  ar9300_2p2_mac_postamble);
343 
344  /* bb */
346  ar9300_2p2_baseband_core);
348  ar9300_2p2_baseband_postamble);
349 
350  /* radio */
352  ar9300_2p2_radio_core);
354  ar9300_2p2_radio_postamble);
355 
356  /* soc */
358  ar9300_2p2_soc_preamble);
360  ar9300_2p2_soc_postamble);
361 
362  /* rx/tx gain */
364  ar9300Common_rx_gain_table_2p2);
366  ar9300Modes_lowest_ob_db_tx_gain_table_2p2);
367 
368  /* Load PCIE SERDES settings from INI */
369 
370  /* Awake Setting */
371 
373  ar9300PciePhy_pll_on_clkreq_disable_L1_2p2);
374 
375  /* Sleep Setting */
376 
378  ar9300PciePhy_pll_on_clkreq_disable_L1_2p2);
379 
380  /* Fast clock modal settings */
382  ar9300Modes_fast_clock_2p2);
383  }
384 }
385 
386 static void ar9003_tx_gain_table_mode0(struct ath_hw *ah)
387 {
388  if (AR_SREV_9330_12(ah))
391  else if (AR_SREV_9330_11(ah))
393  ar9331_modes_lowest_ob_db_tx_gain_1p1);
394  else if (AR_SREV_9340(ah))
396  ar9340Modes_lowest_ob_db_tx_gain_table_1p0);
397  else if (AR_SREV_9485_11(ah))
400  else if (AR_SREV_9550(ah))
402  ar955x_1p0_modes_xpa_tx_gain_table);
403  else if (AR_SREV_9580(ah))
405  ar9580_1p0_lowest_ob_db_tx_gain_table);
406  else if (AR_SREV_9462_20(ah))
408  ar9462_modes_low_ob_db_tx_gain_table_2p0);
409  else if (AR_SREV_9565(ah))
411  ar9565_1p0_modes_low_ob_db_tx_gain_table);
412  else
414  ar9300Modes_lowest_ob_db_tx_gain_table_2p2);
415 }
416 
417 static void ar9003_tx_gain_table_mode1(struct ath_hw *ah)
418 {
419  if (AR_SREV_9330_12(ah))
421  ar9331_modes_high_ob_db_tx_gain_1p2);
422  else if (AR_SREV_9330_11(ah))
424  ar9331_modes_high_ob_db_tx_gain_1p1);
425  else if (AR_SREV_9340(ah))
427  ar9340Modes_high_ob_db_tx_gain_table_1p0);
428  else if (AR_SREV_9485_11(ah))
431  else if (AR_SREV_9580(ah))
434  else if (AR_SREV_9550(ah))
436  ar955x_1p0_modes_no_xpa_tx_gain_table);
437  else if (AR_SREV_9462_20(ah))
439  ar9462_modes_high_ob_db_tx_gain_table_2p0);
440  else if (AR_SREV_9565(ah))
442  ar9565_1p0_modes_high_ob_db_tx_gain_table);
443  else
445  ar9300Modes_high_ob_db_tx_gain_table_2p2);
446 }
447 
448 static void ar9003_tx_gain_table_mode2(struct ath_hw *ah)
449 {
450  if (AR_SREV_9330_12(ah))
453  else if (AR_SREV_9330_11(ah))
455  ar9331_modes_low_ob_db_tx_gain_1p1);
456  else if (AR_SREV_9340(ah))
458  ar9340Modes_low_ob_db_tx_gain_table_1p0);
459  else if (AR_SREV_9485_11(ah))
462  else if (AR_SREV_9580(ah))
464  ar9580_1p0_low_ob_db_tx_gain_table);
465  else if (AR_SREV_9565(ah))
467  ar9565_1p0_modes_low_ob_db_tx_gain_table);
468  else
470  ar9300Modes_low_ob_db_tx_gain_table_2p2);
471 }
472 
473 static void ar9003_tx_gain_table_mode3(struct ath_hw *ah)
474 {
475  if (AR_SREV_9330_12(ah))
478  else if (AR_SREV_9330_11(ah))
480  ar9331_modes_high_power_tx_gain_1p1);
481  else if (AR_SREV_9340(ah))
483  ar9340Modes_high_power_tx_gain_table_1p0);
484  else if (AR_SREV_9485_11(ah))
486  ar9485Modes_high_power_tx_gain_1_1);
487  else if (AR_SREV_9580(ah))
490  else if (AR_SREV_9565(ah))
492  ar9565_1p0_modes_high_power_tx_gain_table);
493  else
495  ar9300Modes_high_power_tx_gain_table_2p2);
496 }
497 
498 static void ar9003_tx_gain_table_mode4(struct ath_hw *ah)
499 {
500  if (AR_SREV_9340(ah))
502  ar9340Modes_mixed_ob_db_tx_gain_table_1p0);
503  else if (AR_SREV_9580(ah))
505  ar9580_1p0_mixed_ob_db_tx_gain_table);
506 }
507 
508 static void ar9003_tx_gain_table_apply(struct ath_hw *ah)
509 {
510  switch (ar9003_hw_get_tx_gain_idx(ah)) {
511  case 0:
512  default:
513  ar9003_tx_gain_table_mode0(ah);
514  break;
515  case 1:
516  ar9003_tx_gain_table_mode1(ah);
517  break;
518  case 2:
519  ar9003_tx_gain_table_mode2(ah);
520  break;
521  case 3:
522  ar9003_tx_gain_table_mode3(ah);
523  break;
524  case 4:
525  ar9003_tx_gain_table_mode4(ah);
526  break;
527  }
528 }
529 
530 static void ar9003_rx_gain_table_mode0(struct ath_hw *ah)
531 {
532  if (AR_SREV_9330_12(ah))
535  else if (AR_SREV_9330_11(ah))
537  ar9331_common_rx_gain_1p1);
538  else if (AR_SREV_9340(ah))
540  ar9340Common_rx_gain_table_1p0);
541  else if (AR_SREV_9485_11(ah))
543  ar9485Common_wo_xlna_rx_gain_1_1);
544  else if (AR_SREV_9550(ah)) {
546  ar955x_1p0_common_rx_gain_table);
548  ar955x_1p0_common_rx_gain_bounds);
549  } else if (AR_SREV_9580(ah))
552  else if (AR_SREV_9462_20(ah))
554  ar9462_common_rx_gain_table_2p0);
555  else
557  ar9300Common_rx_gain_table_2p2);
558 }
559 
560 static void ar9003_rx_gain_table_mode1(struct ath_hw *ah)
561 {
562  if (AR_SREV_9330_12(ah))
565  else if (AR_SREV_9330_11(ah))
567  ar9331_common_wo_xlna_rx_gain_1p1);
568  else if (AR_SREV_9340(ah))
571  else if (AR_SREV_9485_11(ah))
573  ar9485Common_wo_xlna_rx_gain_1_1);
574  else if (AR_SREV_9462_20(ah))
576  ar9462_common_wo_xlna_rx_gain_table_2p0);
577  else if (AR_SREV_9550(ah)) {
579  ar955x_1p0_common_wo_xlna_rx_gain_table);
581  ar955x_1p0_common_wo_xlna_rx_gain_bounds);
582  } else if (AR_SREV_9580(ah))
585  else if (AR_SREV_9565(ah))
587  ar9565_1p0_common_wo_xlna_rx_gain_table);
588  else
590  ar9300Common_wo_xlna_rx_gain_table_2p2);
591 }
592 
593 static void ar9003_rx_gain_table_mode2(struct ath_hw *ah)
594 {
595  if (AR_SREV_9462_20(ah))
597  ar9462_common_mixed_rx_gain_table_2p0);
598 }
599 
600 static void ar9003_rx_gain_table_apply(struct ath_hw *ah)
601 {
602  switch (ar9003_hw_get_rx_gain_idx(ah)) {
603  case 0:
604  default:
605  ar9003_rx_gain_table_mode0(ah);
606  break;
607  case 1:
608  ar9003_rx_gain_table_mode1(ah);
609  break;
610  case 2:
611  ar9003_rx_gain_table_mode2(ah);
612  break;
613  }
614 }
615 
616 /* set gain table pointers according to values read from the eeprom */
617 static void ar9003_hw_init_mode_gain_regs(struct ath_hw *ah)
618 {
619  ar9003_tx_gain_table_apply(ah);
620  ar9003_rx_gain_table_apply(ah);
621 }
622 
623 /*
624  * Helper for ASPM support.
625  *
626  * Disable PLL when in L0s as well as receiver clock when in L1.
627  * This power saving option must be enabled through the SerDes.
628  *
629  * Programming the SerDes must go through the same 288 bit serial shift
630  * register as the other analog registers. Hence the 9 writes.
631  */
632 static void ar9003_hw_configpcipowersave(struct ath_hw *ah,
633  bool power_off)
634 {
635  /* Nothing to do on restore for 11N */
636  if (!power_off /* !restore */) {
637  /* set bit 19 to allow forcing of pcie core into L1 state */
639 
640  /* Several PCIe massages to ensure proper behaviour */
641  if (ah->config.pcie_waen)
642  REG_WRITE(ah, AR_WA, ah->config.pcie_waen);
643  else
644  REG_WRITE(ah, AR_WA, ah->WARegVal);
645  }
646 
647  /*
648  * Configire PCIE after Ini init. SERDES values now come from ini file
649  * This enables PCIe low power mode.
650  */
651  if (ah->config.pcieSerDesWrite) {
652  unsigned int i;
653  struct ar5416IniArray *array;
654 
655  array = power_off ? &ah->iniPcieSerdes :
657 
658  for (i = 0; i < array->ia_rows; i++) {
659  REG_WRITE(ah,
660  INI_RA(array, i, 0),
661  INI_RA(array, i, 1));
662  }
663  }
664 }
665 
666 /* Sets up the AR9003 hardware familiy callbacks */
667 void ar9003_hw_attach_ops(struct ath_hw *ah)
668 {
669  struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
670  struct ath_hw_ops *ops = ath9k_hw_ops(ah);
671 
672  priv_ops->init_mode_regs = ar9003_hw_init_mode_regs;
673  priv_ops->init_mode_gain_regs = ar9003_hw_init_mode_gain_regs;
674 
675  ops->config_pci_powersave = ar9003_hw_configpcipowersave;
676 
680 }