2 * Copyright (c) 2008-2010 Atheros Communications Inc.
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.
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.
18 #include "ar9003_mac.h"
19 #include "ar9003_2p2_initvals.h"
20 #include "ar9485_initvals.h"
22 /* General hardware code for the AR9003 hadware family */
24 static bool ar9003_hw_macversion_supported(u32 macversion)
27 case AR_SREV_VERSION_9300:
28 case AR_SREV_VERSION_9485:
37 * The AR9003 family uses a new INI format (pre, core, post
38 * arrays per subsystem). This provides support for the
39 * AR9003 2.2 chipsets.
41 static void ar9003_hw_init_mode_regs(struct ath_hw *ah)
43 if (AR_SREV_9485(ah)) {
45 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
46 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
48 ARRAY_SIZE(ar9485_1_0_mac_core), 2);
49 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
50 ar9485_1_0_mac_postamble,
51 ARRAY_SIZE(ar9485_1_0_mac_postamble), 5);
54 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], ar9485_1_0,
55 ARRAY_SIZE(ar9485_1_0), 2);
56 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
57 ar9485_1_0_baseband_core,
58 ARRAY_SIZE(ar9485_1_0_baseband_core), 2);
59 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
60 ar9485_1_0_baseband_postamble,
61 ARRAY_SIZE(ar9485_1_0_baseband_postamble), 5);
64 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
65 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
66 ar9485_1_0_radio_core,
67 ARRAY_SIZE(ar9485_1_0_radio_core), 2);
68 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
69 ar9485_1_0_radio_postamble,
70 ARRAY_SIZE(ar9485_1_0_radio_postamble), 2);
73 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
74 ar9485_1_0_soc_preamble,
75 ARRAY_SIZE(ar9485_1_0_soc_preamble), 2);
76 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
77 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST], NULL, 0, 0);
80 INIT_INI_ARRAY(&ah->iniModesRxGain,
81 ar9485Common_rx_gain_1_0,
82 ARRAY_SIZE(ar9485Common_rx_gain_1_0), 2);
83 INIT_INI_ARRAY(&ah->iniModesTxGain,
84 ar9485Modes_lowest_ob_db_tx_gain_1_0,
85 ARRAY_SIZE(ar9485Modes_lowest_ob_db_tx_gain_1_0),
88 /* Load PCIE SERDES settings from INI */
92 INIT_INI_ARRAY(&ah->iniPcieSerdes,
93 ar9485_1_0_pcie_phy_pll_on_clkreq_disable_L1,
94 ARRAY_SIZE(ar9485_1_0_pcie_phy_pll_on_clkreq_disable_L1),
99 INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
100 ar9485_1_0_pcie_phy_pll_on_clkreq_enable_L1,
101 ARRAY_SIZE(ar9485_1_0_pcie_phy_pll_on_clkreq_enable_L1),
105 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
106 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
108 ARRAY_SIZE(ar9300_2p2_mac_core), 2);
109 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
110 ar9300_2p2_mac_postamble,
111 ARRAY_SIZE(ar9300_2p2_mac_postamble), 5);
114 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0);
115 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
116 ar9300_2p2_baseband_core,
117 ARRAY_SIZE(ar9300_2p2_baseband_core), 2);
118 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
119 ar9300_2p2_baseband_postamble,
120 ARRAY_SIZE(ar9300_2p2_baseband_postamble), 5);
123 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
124 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
125 ar9300_2p2_radio_core,
126 ARRAY_SIZE(ar9300_2p2_radio_core), 2);
127 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
128 ar9300_2p2_radio_postamble,
129 ARRAY_SIZE(ar9300_2p2_radio_postamble), 5);
132 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
133 ar9300_2p2_soc_preamble,
134 ARRAY_SIZE(ar9300_2p2_soc_preamble), 2);
135 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
136 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
137 ar9300_2p2_soc_postamble,
138 ARRAY_SIZE(ar9300_2p2_soc_postamble), 5);
141 INIT_INI_ARRAY(&ah->iniModesRxGain,
142 ar9300Common_rx_gain_table_2p2,
143 ARRAY_SIZE(ar9300Common_rx_gain_table_2p2), 2);
144 INIT_INI_ARRAY(&ah->iniModesTxGain,
145 ar9300Modes_lowest_ob_db_tx_gain_table_2p2,
146 ARRAY_SIZE(ar9300Modes_lowest_ob_db_tx_gain_table_2p2),
149 /* Load PCIE SERDES settings from INI */
153 INIT_INI_ARRAY(&ah->iniPcieSerdes,
154 ar9300PciePhy_pll_on_clkreq_disable_L1_2p2,
155 ARRAY_SIZE(ar9300PciePhy_pll_on_clkreq_disable_L1_2p2),
160 INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
161 ar9300PciePhy_clkreq_enable_L1_2p2,
162 ARRAY_SIZE(ar9300PciePhy_clkreq_enable_L1_2p2),
165 /* Fast clock modal settings */
166 INIT_INI_ARRAY(&ah->iniModesAdditional,
167 ar9300Modes_fast_clock_2p2,
168 ARRAY_SIZE(ar9300Modes_fast_clock_2p2),
173 static void ar9003_tx_gain_table_apply(struct ath_hw *ah)
175 switch (ar9003_hw_get_tx_gain_idx(ah)) {
178 if (AR_SREV_9485(ah))
179 INIT_INI_ARRAY(&ah->iniModesTxGain,
180 ar9485Modes_lowest_ob_db_tx_gain_1_0,
181 ARRAY_SIZE(ar9485Modes_lowest_ob_db_tx_gain_1_0),
184 INIT_INI_ARRAY(&ah->iniModesTxGain,
185 ar9300Modes_lowest_ob_db_tx_gain_table_2p2,
186 ARRAY_SIZE(ar9300Modes_lowest_ob_db_tx_gain_table_2p2),
190 if (AR_SREV_9485(ah))
191 INIT_INI_ARRAY(&ah->iniModesTxGain,
192 ar9485Modes_high_ob_db_tx_gain_1_0,
193 ARRAY_SIZE(ar9485Modes_lowest_ob_db_tx_gain_1_0),
196 INIT_INI_ARRAY(&ah->iniModesTxGain,
197 ar9300Modes_high_ob_db_tx_gain_table_2p2,
198 ARRAY_SIZE(ar9300Modes_high_ob_db_tx_gain_table_2p2),
202 if (AR_SREV_9485(ah))
203 INIT_INI_ARRAY(&ah->iniModesTxGain,
204 ar9485Modes_low_ob_db_tx_gain_1_0,
205 ARRAY_SIZE(ar9485Modes_lowest_ob_db_tx_gain_1_0),
208 INIT_INI_ARRAY(&ah->iniModesTxGain,
209 ar9300Modes_low_ob_db_tx_gain_table_2p2,
210 ARRAY_SIZE(ar9300Modes_low_ob_db_tx_gain_table_2p2),
214 if (AR_SREV_9485(ah))
215 INIT_INI_ARRAY(&ah->iniModesTxGain,
216 ar9485Modes_high_power_tx_gain_1_0,
217 ARRAY_SIZE(ar9485Modes_high_power_tx_gain_1_0),
220 INIT_INI_ARRAY(&ah->iniModesTxGain,
221 ar9300Modes_high_power_tx_gain_table_2p2,
222 ARRAY_SIZE(ar9300Modes_high_power_tx_gain_table_2p2),
228 static void ar9003_rx_gain_table_apply(struct ath_hw *ah)
230 switch (ar9003_hw_get_rx_gain_idx(ah)) {
233 if (AR_SREV_9485(ah))
234 INIT_INI_ARRAY(&ah->iniModesRxGain,
235 ar9485Common_rx_gain_1_0,
236 ARRAY_SIZE(ar9485Common_rx_gain_1_0),
239 INIT_INI_ARRAY(&ah->iniModesRxGain,
240 ar9300Common_rx_gain_table_2p2,
241 ARRAY_SIZE(ar9300Common_rx_gain_table_2p2),
245 if (AR_SREV_9485(ah))
246 INIT_INI_ARRAY(&ah->iniModesRxGain,
247 ar9485Common_wo_xlna_rx_gain_1_0,
248 ARRAY_SIZE(ar9485Common_wo_xlna_rx_gain_1_0),
251 INIT_INI_ARRAY(&ah->iniModesRxGain,
252 ar9300Common_wo_xlna_rx_gain_table_2p2,
253 ARRAY_SIZE(ar9300Common_wo_xlna_rx_gain_table_2p2),
259 /* set gain table pointers according to values read from the eeprom */
260 static void ar9003_hw_init_mode_gain_regs(struct ath_hw *ah)
262 ar9003_tx_gain_table_apply(ah);
263 ar9003_rx_gain_table_apply(ah);
267 * Helper for ASPM support.
269 * Disable PLL when in L0s as well as receiver clock when in L1.
270 * This power saving option must be enabled through the SerDes.
272 * Programming the SerDes must go through the same 288 bit serial shift
273 * register as the other analog registers. Hence the 9 writes.
275 static void ar9003_hw_configpcipowersave(struct ath_hw *ah,
279 if (ah->is_pciexpress != true)
282 /* Do not touch SerDes registers */
283 if (ah->config.pcie_powersave_enable == 2)
286 /* Nothing to do on restore for 11N */
288 /* set bit 19 to allow forcing of pcie core into L1 state */
289 REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA);
291 /* Several PCIe massages to ensure proper behaviour */
292 if (ah->config.pcie_waen)
293 REG_WRITE(ah, AR_WA, ah->config.pcie_waen);
295 REG_WRITE(ah, AR_WA, ah->WARegVal);
299 * Configire PCIE after Ini init. SERDES values now come from ini file
300 * This enables PCIe low power mode.
302 if (ah->config.pcieSerDesWrite) {
304 struct ar5416IniArray *array;
306 array = power_off ? &ah->iniPcieSerdes :
307 &ah->iniPcieSerdesLowPower;
309 for (i = 0; i < array->ia_rows; i++) {
312 INI_RA(array, i, 1));
317 /* Sets up the AR9003 hardware familiy callbacks */
318 void ar9003_hw_attach_ops(struct ath_hw *ah)
320 struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
321 struct ath_hw_ops *ops = ath9k_hw_ops(ah);
323 priv_ops->init_mode_regs = ar9003_hw_init_mode_regs;
324 priv_ops->init_mode_gain_regs = ar9003_hw_init_mode_gain_regs;
325 priv_ops->macversion_supported = ar9003_hw_macversion_supported;
327 ops->config_pci_powersave = ar9003_hw_configpcipowersave;
329 ar9003_hw_attach_phy_ops(ah);
330 ar9003_hw_attach_calib_ops(ah);
331 ar9003_hw_attach_mac_ops(ah);