iPXE
ath9k_ar9003_hw.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2011 Atheros Communications Inc.
3  *
4  * Modified for iPXE by Scott K Logan <logans@cottsay.net> July 2011
5  * Original from Linux kernel 3.0.1
6  *
7  * Permission to use, copy, modify, and/or distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 FILE_SECBOOT ( FORBIDDEN );
21 
22 #include "hw.h"
23 #include "ar9003_mac.h"
24 #include "ar9003_2p2_initvals.h"
25 #include "ar9485_initvals.h"
26 #include "ar9340_initvals.h"
27 
28 /* General hardware code for the AR9003 hadware family */
29 
30 /*
31  * The AR9003 family uses a new INI format (pre, core, post
32  * arrays per subsystem). This provides support for the
33  * AR9003 2.2 chipsets.
34  */
35 static void ar9003_hw_init_mode_regs(struct ath_hw *ah)
36 {
37  if (AR_SREV_9340(ah)) {
38  /* mac */
39  INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
40  INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
43  INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
46 
47  /* bb */
48  INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0);
55 
56  /* radio */
57  INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
58  INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
61  INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
64 
65  /* soc */
66  INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
69  INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
70  INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
73 
74  /* rx/tx gain */
75  INIT_INI_ARRAY(&ah->iniModesRxGain,
78  5);
79  INIT_INI_ARRAY(&ah->iniModesTxGain,
82  5);
83 
84  INIT_INI_ARRAY(&ah->iniModesAdditional,
87  3);
88 
89  INIT_INI_ARRAY(&ah->iniModesAdditional_40M,
92  2);
93  } else if (AR_SREV_9485_11(ah)) {
94  /* mac */
95  INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
96  INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
99  INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
102 
103  /* bb */
105  ARRAY_SIZE(ar9485_1_1), 2);
106  INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
109  INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
112 
113  /* radio */
114  INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
115  INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
118  INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
121 
122  /* soc */
123  INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
126  INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
127  INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST], NULL, 0, 0);
128 
129  /* rx/tx gain */
130  INIT_INI_ARRAY(&ah->iniModesRxGain,
133  INIT_INI_ARRAY(&ah->iniModesTxGain,
136  5);
137 
138  /* Load PCIE SERDES settings from INI */
139 
140  /* Awake Setting */
141 
142  INIT_INI_ARRAY(&ah->iniPcieSerdes,
145  2);
146 
147  /* Sleep Setting */
148 
149  INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
152  2);
153  } else {
154  /* mac */
155  INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
156  INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
159  INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
162 
163  /* bb */
164  INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0);
165  INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
168  INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
171 
172  /* radio */
173  INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
174  INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
177  INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
180 
181  /* soc */
182  INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
185  INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
186  INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
189 
190  /* rx/tx gain */
191  INIT_INI_ARRAY(&ah->iniModesRxGain,
194  INIT_INI_ARRAY(&ah->iniModesTxGain,
197  5);
198 
199  /* Load PCIE SERDES settings from INI */
200 
201  /* Awake Setting */
202 
203  INIT_INI_ARRAY(&ah->iniPcieSerdes,
206  2);
207 
208  /* Sleep Setting */
209 
210  INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
213  2);
214 
215  /* Fast clock modal settings */
216  INIT_INI_ARRAY(&ah->iniModesAdditional,
219  3);
220  }
221 }
222 
224 {
225  switch (ar9003_hw_get_tx_gain_idx(ah)) {
226  case 0:
227  default:
228  if (AR_SREV_9340(ah))
229  INIT_INI_ARRAY(&ah->iniModesTxGain,
232  5);
233  else if (AR_SREV_9485_11(ah))
234  INIT_INI_ARRAY(&ah->iniModesTxGain,
237  5);
238  else
239  INIT_INI_ARRAY(&ah->iniModesTxGain,
242  5);
243  break;
244  case 1:
245  if (AR_SREV_9340(ah))
246  INIT_INI_ARRAY(&ah->iniModesTxGain,
249  5);
250  else if (AR_SREV_9485_11(ah))
251  INIT_INI_ARRAY(&ah->iniModesTxGain,
254  5);
255  else
256  INIT_INI_ARRAY(&ah->iniModesTxGain,
259  5);
260  break;
261  case 2:
262  if (AR_SREV_9340(ah))
263  INIT_INI_ARRAY(&ah->iniModesTxGain,
266  5);
267  else if (AR_SREV_9485_11(ah))
268  INIT_INI_ARRAY(&ah->iniModesTxGain,
271  5);
272  else
273  INIT_INI_ARRAY(&ah->iniModesTxGain,
276  5);
277  break;
278  case 3:
279  if (AR_SREV_9340(ah))
280  INIT_INI_ARRAY(&ah->iniModesTxGain,
283  5);
284  else if (AR_SREV_9485_11(ah))
285  INIT_INI_ARRAY(&ah->iniModesTxGain,
288  5);
289  else
290  INIT_INI_ARRAY(&ah->iniModesTxGain,
293  5);
294  break;
295  }
296 }
297 
299 {
300  switch (ar9003_hw_get_rx_gain_idx(ah)) {
301  case 0:
302  default:
303  if (AR_SREV_9340(ah))
304  INIT_INI_ARRAY(&ah->iniModesRxGain,
307  2);
308  else if (AR_SREV_9485_11(ah))
309  INIT_INI_ARRAY(&ah->iniModesRxGain,
312  2);
313  else
314  INIT_INI_ARRAY(&ah->iniModesRxGain,
317  2);
318  break;
319  case 1:
320  if (AR_SREV_9340(ah))
321  INIT_INI_ARRAY(&ah->iniModesRxGain,
324  2);
325  else if (AR_SREV_9485_11(ah))
326  INIT_INI_ARRAY(&ah->iniModesRxGain,
329  2);
330  else
331  INIT_INI_ARRAY(&ah->iniModesRxGain,
334  2);
335  break;
336  }
337 }
338 
339 /* set gain table pointers according to values read from the eeprom */
341 {
344 }
345 
346 /*
347  * Helper for ASPM support.
348  *
349  * Disable PLL when in L0s as well as receiver clock when in L1.
350  * This power saving option must be enabled through the SerDes.
351  *
352  * Programming the SerDes must go through the same 288 bit serial shift
353  * register as the other analog registers. Hence the 9 writes.
354  */
356  int restore,
357  int power_off)
358 {
359  if (ah->is_pciexpress != 1)
360  return;
361 
362  /* Do not touch SerDes registers */
363  if (ah->config.pcie_powersave_enable == 2)
364  return;
365 
366  /* Nothing to do on restore for 11N */
367  if (!restore) {
368  /* set bit 19 to allow forcing of pcie core into L1 state */
370 
371  /* Several PCIe massages to ensure proper behaviour */
372  if (ah->config.pcie_waen)
373  REG_WRITE(ah, AR_WA, ah->config.pcie_waen);
374  else
375  REG_WRITE(ah, AR_WA, ah->WARegVal);
376  }
377 
378  /*
379  * Configire PCIE after Ini init. SERDES values now come from ini file
380  * This enables PCIe low power mode.
381  */
382  if (ah->config.pcieSerDesWrite) {
383  unsigned int i;
384  struct ar5416IniArray *array;
385 
386  array = power_off ? &ah->iniPcieSerdes :
387  &ah->iniPcieSerdesLowPower;
388 
389  for (i = 0; i < array->ia_rows; i++) {
390  REG_WRITE(ah,
391  INI_RA(array, i, 0),
392  INI_RA(array, i, 1));
393  }
394  }
395 }
396 
397 /* Sets up the AR9003 hardware familiy callbacks */
399 {
400  struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
401  struct ath_hw_ops *ops = ath9k_hw_ops(ah);
402 
405 
407 
411 }
static __unused const u32 ar9485Common_wo_xlna_rx_gain_1_1[][2]
static __unused const u32 ar9300Modes_high_ob_db_tx_gain_table_2p2[][5]
static __unused const u32 ar9340_1p0_mac_postamble[][5]
Definition: hw.h:657
FILE_SECBOOT(FORBIDDEN)
static __unused const u32 ar9485Modes_low_ob_db_tx_gain_1_1[][5]
static void ar9003_hw_init_mode_gain_regs(struct ath_hw *ah)
static __unused const u32 ar9300_2p2_mac_postamble[][5]
static __unused const u32 ar9340_1p0_soc_postamble[][5]
static __unused const u32 ar9340_1p0_radio_core[][2]
static __unused const u32 ar9300Modes_high_power_tx_gain_table_2p2[][5]
#define INI_RA(iniarray, row, column)
Definition: calib.h:46
void ar9003_hw_attach_ops(struct ath_hw *ah)
static void ar9003_hw_configpcipowersave(struct ath_hw *ah, int restore, int power_off)
s32 ar9003_hw_get_rx_gain_idx(struct ath_hw *ah)
static __unused const u32 ar9300_2p2_radio_core[][2]
void ar9003_hw_attach_phy_ops(struct ath_hw *ah)
struct ath_hw_private_ops - callbacks used internally by hardware code
Definition: hw.h:551
static __unused const u32 ar9300_2p2_radio_postamble[][5]
static __unused const u32 ar9300_2p2_baseband_core[][2]
static __unused const u32 ar9300_2p2_soc_preamble[][2]
static __unused const u32 ar9300_2p2_soc_postamble[][5]
static __unused const u32 ar9485_1_1_baseband_core[][2]
static __unused const u32 ar9340Modes_lowest_ob_db_tx_gain_table_1p0[][5]
static __unused const u32 ar9485_1_1_radio_postamble[][2]
uint32_t array
Array number.
Definition: edd.h:31
static __unused const u32 ar9340Common_rx_gain_table_1p0[][2]
static __unused const u32 ar9485_1_1_radio_core[][2]
static __unused const u32 ar9340Modes_fast_clock_1p0[][3]
static __unused const u32 ar9300Modes_lowest_ob_db_tx_gain_table_2p2[][5]
static __unused const u32 ar9340Common_wo_xlna_rx_gain_table_1p0[][2]
static __unused const u32 ar9485_1_1_pcie_phy_clkreq_disable_L1[][2]
static __unused const u32 ar9300_2p2_mac_core[][2]
#define AR_SREV_9485_11(_ah)
Definition: reg.h:873
#define AR_SREV_9340(_ah)
Definition: reg.h:879
static __unused const u32 ar9300PciePhy_pll_on_clkreq_disable_L1_2p2[][2]
static __unused const u32 ar9300Common_wo_xlna_rx_gain_table_2p2[][2]
static __unused const u32 ar9300_2p2_baseband_postamble[][5]
void(* init_mode_regs)(struct ath_hw *ah)
Definition: hw.h:556
#define AR_PCIE_PM_CTRL
Definition: reg.h:984
static __unused const u32 ar9485_1_1_mac_postamble[][5]
static void ar9003_hw_init_mode_regs(struct ath_hw *ah)
struct ath_hw_ops - callbacks used by hardware code and driver code
Definition: hw.h:604
static __unused const u32 ar9485_1_1_soc_preamble[][2]
static __unused const u32 ar9485_1_1_baseband_postamble[][5]
static __unused const u32 ar9300Common_rx_gain_table_2p2[][2]
#define ARRAY_SIZE(x)
Definition: efx_common.h:43
void(* config_pci_powersave)(struct ath_hw *ah, int restore, int power_off)
Definition: hw.h:605
void(* init_mode_gain_regs)(struct ath_hw *ah)
Definition: hw.h:557
void ar9003_hw_attach_calib_ops(struct ath_hw *ah)
s32 ar9003_hw_get_tx_gain_idx(struct ath_hw *ah)
static __unused const u32 ar9340_1p0_soc_preamble[][2]
static __unused const u32 ar9340_1p0_radio_postamble[][5]
static __unused const u32 ar9340_1p0_baseband_postamble[][5]
#define REG_SET_BIT(_a, _r, _f)
Definition: hw.h:108
static struct ath_hw_ops * ath9k_hw_ops(struct ath_hw *ah)
Definition: hw.h:885
static __unused const u32 ar9485_modes_lowest_ob_db_tx_gain_1_1[][5]
static __unused const u32 ar9485Modes_high_ob_db_tx_gain_1_1[][5]
#define INIT_INI_ARRAY(iniarray, array, rows, columns)
Definition: calib.h:40
void ar9003_hw_attach_mac_ops(struct ath_hw *hw)
static __unused const u32 ar9340_1p0_mac_core[][2]
static void ar9003_rx_gain_table_apply(struct ath_hw *ah)
static __unused const u32 ar9300Modes_fast_clock_2p2[][3]
static __unused const u32 ar9485_1_1[][2]
#define REG_WRITE(_ah, _reg, _val)
Definition: hw.h:78
static __unused const u32 ar9340Modes_high_ob_db_tx_gain_table_1p0[][5]
static __unused const u32 ar9340_1p0_radio_core_40M[][2]
static __unused const u32 ar9485_1_1_mac_core[][2]
#define AR_PCIE_PM_CTRL_ENA
Definition: reg.h:985
static __unused const u32 ar9300Modes_low_ob_db_tx_gain_table_2p2[][5]
static __unused const u32 ar9485Modes_high_power_tx_gain_1_1[][5]
#define AR_WA
Definition: reg.h:699
uint8_t ah
Definition: registers.h:85
static struct ath_hw_private_ops * ath9k_hw_private_ops(struct ath_hw *ah)
Definition: hw.h:880
static __unused const u32 ar9340_1p0_baseband_core[][2]
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
static void ar9003_tx_gain_table_apply(struct ath_hw *ah)