blob: 718241d4ec492e619bcfd5b265ce8ce0a3aa6d01 [file] [log] [blame]
Luis R. Rodriguezb3950e62010-04-15 17:39:03 -04001/*
Sujith Manoharan5b681382011-05-17 13:36:18 +05302 * Copyright (c) 2008-2011 Atheros Communications Inc.
Luis R. Rodriguezb3950e62010-04-15 17:39:03 -04003 *
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"
Luis R. Rodriguezb622a722010-04-15 17:39:28 -040018#include "ar9003_mac.h"
Luis R. Rodriguez72846352010-05-12 21:15:05 -040019#include "ar9003_2p2_initvals.h"
Vasanthakumar Thiagarajanc88457e2010-12-06 04:27:37 -080020#include "ar9485_initvals.h"
Vasanthakumar Thiagarajand89baac2011-04-19 19:29:04 +053021#include "ar9340_initvals.h"
Gabor Juhos172805a2011-06-21 11:23:26 +020022#include "ar9330_1p1_initvals.h"
23#include "ar9330_1p2_initvals.h"
Gabor Juhosa0fbb9b2012-07-03 19:13:22 +020024#include "ar955x_1p0_initvals.h"
Luis R. Rodriguez5a63ef02011-08-24 15:36:08 -070025#include "ar9580_1p0_initvals.h"
Rajkumar Manoharan76db2f82011-10-13 11:00:43 +053026#include "ar9462_2p0_initvals.h"
Luis R. Rodriguezb3950e62010-04-15 17:39:03 -040027
28/* General hardware code for the AR9003 hadware family */
29
Luis R. Rodriguez886b42b2010-10-14 11:44:27 -070030/*
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 */
35static void ar9003_hw_init_mode_regs(struct ath_hw *ah)
Luis R. Rodriguez72846352010-05-12 21:15:05 -040036{
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +053037#define PCIE_PLL_ON_CREQ_DIS_L1_2P0 \
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +053038 ar9462_pciephy_pll_on_clkreq_disable_L1_2p0
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +053039
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +053040#define AR9462_BB_CTX_COEFJ(x) \
41 ar9462_##x##_baseband_core_txfir_coeff_japan_2484
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +053042
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +053043#define AR9462_BBC_TXIFR_COEFFJ \
44 ar9462_2p0_baseband_core_txfir_coeff_japan_2484
Gabor Juhos172805a2011-06-21 11:23:26 +020045 if (AR_SREV_9330_11(ah)) {
46 /* mac */
47 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
48 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
49 ar9331_1p1_mac_core,
50 ARRAY_SIZE(ar9331_1p1_mac_core), 2);
51 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
52 ar9331_1p1_mac_postamble,
53 ARRAY_SIZE(ar9331_1p1_mac_postamble), 5);
54
55 /* bb */
56 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0);
57 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
58 ar9331_1p1_baseband_core,
59 ARRAY_SIZE(ar9331_1p1_baseband_core), 2);
60 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
61 ar9331_1p1_baseband_postamble,
62 ARRAY_SIZE(ar9331_1p1_baseband_postamble), 5);
63
64 /* radio */
65 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
66 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
67 ar9331_1p1_radio_core,
68 ARRAY_SIZE(ar9331_1p1_radio_core), 2);
69 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST], NULL, 0, 0);
70
71 /* soc */
72 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
73 ar9331_1p1_soc_preamble,
74 ARRAY_SIZE(ar9331_1p1_soc_preamble), 2);
75 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
76 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
77 ar9331_1p1_soc_postamble,
78 ARRAY_SIZE(ar9331_1p1_soc_postamble), 2);
79
80 /* rx/tx gain */
81 INIT_INI_ARRAY(&ah->iniModesRxGain,
82 ar9331_common_rx_gain_1p1,
83 ARRAY_SIZE(ar9331_common_rx_gain_1p1), 2);
84 INIT_INI_ARRAY(&ah->iniModesTxGain,
85 ar9331_modes_lowest_ob_db_tx_gain_1p1,
86 ARRAY_SIZE(ar9331_modes_lowest_ob_db_tx_gain_1p1),
87 5);
88
89 /* additional clock settings */
90 if (ah->is_clk_25mhz)
Felix Fietkauc7d36f92012-03-14 16:40:31 +010091 INIT_INI_ARRAY(&ah->iniAdditional,
Gabor Juhos172805a2011-06-21 11:23:26 +020092 ar9331_1p1_xtal_25M,
93 ARRAY_SIZE(ar9331_1p1_xtal_25M), 2);
94 else
Felix Fietkauc7d36f92012-03-14 16:40:31 +010095 INIT_INI_ARRAY(&ah->iniAdditional,
Gabor Juhos172805a2011-06-21 11:23:26 +020096 ar9331_1p1_xtal_40M,
97 ARRAY_SIZE(ar9331_1p1_xtal_40M), 2);
98 } else if (AR_SREV_9330_12(ah)) {
99 /* mac */
100 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
101 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
102 ar9331_1p2_mac_core,
103 ARRAY_SIZE(ar9331_1p2_mac_core), 2);
104 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
105 ar9331_1p2_mac_postamble,
106 ARRAY_SIZE(ar9331_1p2_mac_postamble), 5);
107
108 /* bb */
109 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0);
110 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
111 ar9331_1p2_baseband_core,
112 ARRAY_SIZE(ar9331_1p2_baseband_core), 2);
113 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
114 ar9331_1p2_baseband_postamble,
115 ARRAY_SIZE(ar9331_1p2_baseband_postamble), 5);
116
117 /* radio */
118 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
119 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
120 ar9331_1p2_radio_core,
121 ARRAY_SIZE(ar9331_1p2_radio_core), 2);
122 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST], NULL, 0, 0);
123
124 /* soc */
125 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
126 ar9331_1p2_soc_preamble,
127 ARRAY_SIZE(ar9331_1p2_soc_preamble), 2);
128 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
129 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
130 ar9331_1p2_soc_postamble,
131 ARRAY_SIZE(ar9331_1p2_soc_postamble), 2);
132
133 /* rx/tx gain */
134 INIT_INI_ARRAY(&ah->iniModesRxGain,
135 ar9331_common_rx_gain_1p2,
136 ARRAY_SIZE(ar9331_common_rx_gain_1p2), 2);
137 INIT_INI_ARRAY(&ah->iniModesTxGain,
138 ar9331_modes_lowest_ob_db_tx_gain_1p2,
139 ARRAY_SIZE(ar9331_modes_lowest_ob_db_tx_gain_1p2),
140 5);
141
142 /* additional clock settings */
143 if (ah->is_clk_25mhz)
Felix Fietkauc7d36f92012-03-14 16:40:31 +0100144 INIT_INI_ARRAY(&ah->iniAdditional,
Gabor Juhos172805a2011-06-21 11:23:26 +0200145 ar9331_1p2_xtal_25M,
146 ARRAY_SIZE(ar9331_1p2_xtal_25M), 2);
147 else
Felix Fietkauc7d36f92012-03-14 16:40:31 +0100148 INIT_INI_ARRAY(&ah->iniAdditional,
Gabor Juhos172805a2011-06-21 11:23:26 +0200149 ar9331_1p2_xtal_40M,
150 ARRAY_SIZE(ar9331_1p2_xtal_40M), 2);
151 } else if (AR_SREV_9340(ah)) {
Vasanthakumar Thiagarajand89baac2011-04-19 19:29:04 +0530152 /* mac */
153 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
154 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
155 ar9340_1p0_mac_core,
156 ARRAY_SIZE(ar9340_1p0_mac_core), 2);
157 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
158 ar9340_1p0_mac_postamble,
159 ARRAY_SIZE(ar9340_1p0_mac_postamble), 5);
160
161 /* bb */
162 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0);
163 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
164 ar9340_1p0_baseband_core,
165 ARRAY_SIZE(ar9340_1p0_baseband_core), 2);
166 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
167 ar9340_1p0_baseband_postamble,
168 ARRAY_SIZE(ar9340_1p0_baseband_postamble), 5);
169
170 /* radio */
171 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
172 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
173 ar9340_1p0_radio_core,
174 ARRAY_SIZE(ar9340_1p0_radio_core), 2);
175 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
176 ar9340_1p0_radio_postamble,
177 ARRAY_SIZE(ar9340_1p0_radio_postamble), 5);
178
179 /* soc */
180 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
181 ar9340_1p0_soc_preamble,
182 ARRAY_SIZE(ar9340_1p0_soc_preamble), 2);
183 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
184 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
185 ar9340_1p0_soc_postamble,
186 ARRAY_SIZE(ar9340_1p0_soc_postamble), 5);
187
188 /* rx/tx gain */
189 INIT_INI_ARRAY(&ah->iniModesRxGain,
190 ar9340Common_wo_xlna_rx_gain_table_1p0,
191 ARRAY_SIZE(ar9340Common_wo_xlna_rx_gain_table_1p0),
192 5);
193 INIT_INI_ARRAY(&ah->iniModesTxGain,
194 ar9340Modes_high_ob_db_tx_gain_table_1p0,
195 ARRAY_SIZE(ar9340Modes_high_ob_db_tx_gain_table_1p0),
196 5);
197
Felix Fietkauc7d36f92012-03-14 16:40:31 +0100198 INIT_INI_ARRAY(&ah->iniModesFastClock,
Vasanthakumar Thiagarajand89baac2011-04-19 19:29:04 +0530199 ar9340Modes_fast_clock_1p0,
200 ARRAY_SIZE(ar9340Modes_fast_clock_1p0),
201 3);
202
Felix Fietkauc7d36f92012-03-14 16:40:31 +0100203 if (!ah->is_clk_25mhz)
204 INIT_INI_ARRAY(&ah->iniAdditional,
205 ar9340_1p0_radio_core_40M,
206 ARRAY_SIZE(ar9340_1p0_radio_core_40M),
207 2);
Vasanthakumar Thiagarajand89baac2011-04-19 19:29:04 +0530208 } else if (AR_SREV_9485_11(ah)) {
Vivek Natarajan1a63e2c2011-02-18 16:49:47 +0530209 /* mac */
210 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
211 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
212 ar9485_1_1_mac_core,
213 ARRAY_SIZE(ar9485_1_1_mac_core), 2);
214 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
215 ar9485_1_1_mac_postamble,
216 ARRAY_SIZE(ar9485_1_1_mac_postamble), 5);
217
218 /* bb */
219 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], ar9485_1_1,
220 ARRAY_SIZE(ar9485_1_1), 2);
221 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
222 ar9485_1_1_baseband_core,
223 ARRAY_SIZE(ar9485_1_1_baseband_core), 2);
224 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
225 ar9485_1_1_baseband_postamble,
226 ARRAY_SIZE(ar9485_1_1_baseband_postamble), 5);
227
228 /* radio */
229 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
230 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
231 ar9485_1_1_radio_core,
232 ARRAY_SIZE(ar9485_1_1_radio_core), 2);
233 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
234 ar9485_1_1_radio_postamble,
235 ARRAY_SIZE(ar9485_1_1_radio_postamble), 2);
236
237 /* soc */
238 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
239 ar9485_1_1_soc_preamble,
240 ARRAY_SIZE(ar9485_1_1_soc_preamble), 2);
241 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
242 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST], NULL, 0, 0);
243
244 /* rx/tx gain */
245 INIT_INI_ARRAY(&ah->iniModesRxGain,
Vasanthakumar Thiagarajan832fd352011-04-01 15:32:16 +0530246 ar9485Common_wo_xlna_rx_gain_1_1,
247 ARRAY_SIZE(ar9485Common_wo_xlna_rx_gain_1_1), 2);
Vivek Natarajan1a63e2c2011-02-18 16:49:47 +0530248 INIT_INI_ARRAY(&ah->iniModesTxGain,
249 ar9485_modes_lowest_ob_db_tx_gain_1_1,
250 ARRAY_SIZE(ar9485_modes_lowest_ob_db_tx_gain_1_1),
251 5);
252
253 /* Load PCIE SERDES settings from INI */
254
255 /* Awake Setting */
256
257 INIT_INI_ARRAY(&ah->iniPcieSerdes,
Vivek Natarajan06fed572011-02-25 17:31:01 +0530258 ar9485_1_1_pcie_phy_clkreq_disable_L1,
259 ARRAY_SIZE(ar9485_1_1_pcie_phy_clkreq_disable_L1),
Vivek Natarajan1a63e2c2011-02-18 16:49:47 +0530260 2);
261
262 /* Sleep Setting */
263
264 INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
Vivek Natarajan06fed572011-02-25 17:31:01 +0530265 ar9485_1_1_pcie_phy_clkreq_disable_L1,
266 ARRAY_SIZE(ar9485_1_1_pcie_phy_clkreq_disable_L1),
Vivek Natarajan1a63e2c2011-02-18 16:49:47 +0530267 2);
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +0530268 } else if (AR_SREV_9462_20(ah)) {
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530269
270 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +0530271 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], ar9462_2p0_mac_core,
272 ARRAY_SIZE(ar9462_2p0_mac_core), 2);
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530273 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +0530274 ar9462_2p0_mac_postamble,
275 ARRAY_SIZE(ar9462_2p0_mac_postamble), 5);
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530276
277 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0);
278 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +0530279 ar9462_2p0_baseband_core,
280 ARRAY_SIZE(ar9462_2p0_baseband_core), 2);
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530281 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +0530282 ar9462_2p0_baseband_postamble,
283 ARRAY_SIZE(ar9462_2p0_baseband_postamble), 5);
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530284
285 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
286 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +0530287 ar9462_2p0_radio_core,
288 ARRAY_SIZE(ar9462_2p0_radio_core), 2);
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530289 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +0530290 ar9462_2p0_radio_postamble,
291 ARRAY_SIZE(ar9462_2p0_radio_postamble), 5);
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530292 INIT_INI_ARRAY(&ah->ini_radio_post_sys2ant,
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +0530293 ar9462_2p0_radio_postamble_sys2ant,
294 ARRAY_SIZE(ar9462_2p0_radio_postamble_sys2ant),
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530295 5);
296
297 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +0530298 ar9462_2p0_soc_preamble,
299 ARRAY_SIZE(ar9462_2p0_soc_preamble), 2);
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530300 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
301 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +0530302 ar9462_2p0_soc_postamble,
303 ARRAY_SIZE(ar9462_2p0_soc_postamble), 5);
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530304
305 INIT_INI_ARRAY(&ah->iniModesRxGain,
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +0530306 ar9462_common_rx_gain_table_2p0,
307 ARRAY_SIZE(ar9462_common_rx_gain_table_2p0), 2);
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530308
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530309 /* Awake -> Sleep Setting */
310 INIT_INI_ARRAY(&ah->iniPcieSerdes,
311 PCIE_PLL_ON_CREQ_DIS_L1_2P0,
312 ARRAY_SIZE(PCIE_PLL_ON_CREQ_DIS_L1_2P0),
313 2);
314 /* Sleep -> Awake Setting */
315 INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
316 PCIE_PLL_ON_CREQ_DIS_L1_2P0,
317 ARRAY_SIZE(PCIE_PLL_ON_CREQ_DIS_L1_2P0),
318 2);
319
320 /* Fast clock modal settings */
Felix Fietkauc7d36f92012-03-14 16:40:31 +0100321 INIT_INI_ARRAY(&ah->iniModesFastClock,
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +0530322 ar9462_modes_fast_clock_2p0,
323 ARRAY_SIZE(ar9462_modes_fast_clock_2p0), 3);
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530324
325 INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +0530326 AR9462_BB_CTX_COEFJ(2p0),
327 ARRAY_SIZE(AR9462_BB_CTX_COEFJ(2p0)), 2);
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530328
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +0530329 INIT_INI_ARRAY(&ah->ini_japan2484, AR9462_BBC_TXIFR_COEFFJ,
330 ARRAY_SIZE(AR9462_BBC_TXIFR_COEFFJ), 2);
Gabor Juhos8bc45c62012-07-03 19:13:23 +0200331 } else if (AR_SREV_9550(ah)) {
332 /* mac */
333 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
334 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
335 ar955x_1p0_mac_core,
336 ARRAY_SIZE(ar955x_1p0_mac_core), 2);
337 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
338 ar955x_1p0_mac_postamble,
339 ARRAY_SIZE(ar955x_1p0_mac_postamble), 5);
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530340
Gabor Juhos8bc45c62012-07-03 19:13:23 +0200341 /* bb */
342 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0);
343 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
344 ar955x_1p0_baseband_core,
345 ARRAY_SIZE(ar955x_1p0_baseband_core), 2);
346 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
347 ar955x_1p0_baseband_postamble,
348 ARRAY_SIZE(ar955x_1p0_baseband_postamble), 5);
349
350 /* radio */
351 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
352 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
353 ar955x_1p0_radio_core,
354 ARRAY_SIZE(ar955x_1p0_radio_core), 2);
355 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
356 ar955x_1p0_radio_postamble,
357 ARRAY_SIZE(ar955x_1p0_radio_postamble), 5);
358
359 /* soc */
360 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
361 ar955x_1p0_soc_preamble,
362 ARRAY_SIZE(ar955x_1p0_soc_preamble), 2);
363 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
364 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
365 ar955x_1p0_soc_postamble,
366 ARRAY_SIZE(ar955x_1p0_soc_postamble), 5);
367
368 /* rx/tx gain */
369 INIT_INI_ARRAY(&ah->iniModesRxGain,
370 ar955x_1p0_common_wo_xlna_rx_gain_table,
371 ARRAY_SIZE(ar955x_1p0_common_wo_xlna_rx_gain_table),
372 2);
373 INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
374 ar955x_1p0_common_wo_xlna_rx_gain_bounds,
375 ARRAY_SIZE(ar955x_1p0_common_wo_xlna_rx_gain_bounds),
376 5);
377 INIT_INI_ARRAY(&ah->iniModesTxGain,
378 ar955x_1p0_modes_xpa_tx_gain_table,
379 ARRAY_SIZE(ar955x_1p0_modes_xpa_tx_gain_table),
380 9);
381
382 /* Fast clock modal settings */
383 INIT_INI_ARRAY(&ah->iniModesFastClock,
384 ar955x_1p0_modes_fast_clock,
385 ARRAY_SIZE(ar955x_1p0_modes_fast_clock), 3);
Luis R. Rodriguez5a63ef02011-08-24 15:36:08 -0700386 } else if (AR_SREV_9580(ah)) {
387 /* mac */
388 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
389 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
390 ar9580_1p0_mac_core,
391 ARRAY_SIZE(ar9580_1p0_mac_core), 2);
392 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
393 ar9580_1p0_mac_postamble,
394 ARRAY_SIZE(ar9580_1p0_mac_postamble), 5);
395
396 /* bb */
397 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0);
398 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
399 ar9580_1p0_baseband_core,
400 ARRAY_SIZE(ar9580_1p0_baseband_core), 2);
401 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
402 ar9580_1p0_baseband_postamble,
403 ARRAY_SIZE(ar9580_1p0_baseband_postamble), 5);
404
405 /* radio */
406 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
407 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
408 ar9580_1p0_radio_core,
409 ARRAY_SIZE(ar9580_1p0_radio_core), 2);
410 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
411 ar9580_1p0_radio_postamble,
412 ARRAY_SIZE(ar9580_1p0_radio_postamble), 5);
413
414 /* soc */
415 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
416 ar9580_1p0_soc_preamble,
417 ARRAY_SIZE(ar9580_1p0_soc_preamble), 2);
418 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
419 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
420 ar9580_1p0_soc_postamble,
421 ARRAY_SIZE(ar9580_1p0_soc_postamble), 5);
422
423 /* rx/tx gain */
424 INIT_INI_ARRAY(&ah->iniModesRxGain,
425 ar9580_1p0_rx_gain_table,
426 ARRAY_SIZE(ar9580_1p0_rx_gain_table), 2);
427 INIT_INI_ARRAY(&ah->iniModesTxGain,
428 ar9580_1p0_low_ob_db_tx_gain_table,
429 ARRAY_SIZE(ar9580_1p0_low_ob_db_tx_gain_table),
430 5);
431
Felix Fietkauc7d36f92012-03-14 16:40:31 +0100432 INIT_INI_ARRAY(&ah->iniModesFastClock,
Luis R. Rodriguez5a63ef02011-08-24 15:36:08 -0700433 ar9580_1p0_modes_fast_clock,
434 ARRAY_SIZE(ar9580_1p0_modes_fast_clock),
435 3);
Vasanthakumar Thiagarajanc88457e2010-12-06 04:27:37 -0800436 } else {
437 /* mac */
438 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
439 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
440 ar9300_2p2_mac_core,
441 ARRAY_SIZE(ar9300_2p2_mac_core), 2);
442 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
443 ar9300_2p2_mac_postamble,
444 ARRAY_SIZE(ar9300_2p2_mac_postamble), 5);
Luis R. Rodriguez72846352010-05-12 21:15:05 -0400445
Vasanthakumar Thiagarajanc88457e2010-12-06 04:27:37 -0800446 /* bb */
447 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0);
448 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
449 ar9300_2p2_baseband_core,
450 ARRAY_SIZE(ar9300_2p2_baseband_core), 2);
451 INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
452 ar9300_2p2_baseband_postamble,
453 ARRAY_SIZE(ar9300_2p2_baseband_postamble), 5);
454
455 /* radio */
456 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
457 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
458 ar9300_2p2_radio_core,
459 ARRAY_SIZE(ar9300_2p2_radio_core), 2);
460 INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
461 ar9300_2p2_radio_postamble,
462 ARRAY_SIZE(ar9300_2p2_radio_postamble), 5);
463
464 /* soc */
465 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
466 ar9300_2p2_soc_preamble,
467 ARRAY_SIZE(ar9300_2p2_soc_preamble), 2);
468 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
469 INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
470 ar9300_2p2_soc_postamble,
471 ARRAY_SIZE(ar9300_2p2_soc_postamble), 5);
472
473 /* rx/tx gain */
474 INIT_INI_ARRAY(&ah->iniModesRxGain,
475 ar9300Common_rx_gain_table_2p2,
476 ARRAY_SIZE(ar9300Common_rx_gain_table_2p2), 2);
477 INIT_INI_ARRAY(&ah->iniModesTxGain,
478 ar9300Modes_lowest_ob_db_tx_gain_table_2p2,
479 ARRAY_SIZE(ar9300Modes_lowest_ob_db_tx_gain_table_2p2),
480 5);
481
482 /* Load PCIE SERDES settings from INI */
483
484 /* Awake Setting */
485
486 INIT_INI_ARRAY(&ah->iniPcieSerdes,
487 ar9300PciePhy_pll_on_clkreq_disable_L1_2p2,
488 ARRAY_SIZE(ar9300PciePhy_pll_on_clkreq_disable_L1_2p2),
489 2);
490
491 /* Sleep Setting */
492
493 INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
Luis R. Rodriguez58c52962011-01-13 18:19:29 -0800494 ar9300PciePhy_pll_on_clkreq_disable_L1_2p2,
495 ARRAY_SIZE(ar9300PciePhy_pll_on_clkreq_disable_L1_2p2),
Vasanthakumar Thiagarajanc88457e2010-12-06 04:27:37 -0800496 2);
497
498 /* Fast clock modal settings */
Felix Fietkauc7d36f92012-03-14 16:40:31 +0100499 INIT_INI_ARRAY(&ah->iniModesFastClock,
Vasanthakumar Thiagarajanc88457e2010-12-06 04:27:37 -0800500 ar9300Modes_fast_clock_2p2,
501 ARRAY_SIZE(ar9300Modes_fast_clock_2p2),
502 3);
503 }
Luis R. Rodriguez72846352010-05-12 21:15:05 -0400504}
505
Senthil Balasubramanian4d0707e2011-09-13 22:38:17 +0530506static void ar9003_tx_gain_table_mode0(struct ath_hw *ah)
507{
508 if (AR_SREV_9330_12(ah))
509 INIT_INI_ARRAY(&ah->iniModesTxGain,
510 ar9331_modes_lowest_ob_db_tx_gain_1p2,
511 ARRAY_SIZE(ar9331_modes_lowest_ob_db_tx_gain_1p2),
512 5);
513 else if (AR_SREV_9330_11(ah))
514 INIT_INI_ARRAY(&ah->iniModesTxGain,
515 ar9331_modes_lowest_ob_db_tx_gain_1p1,
516 ARRAY_SIZE(ar9331_modes_lowest_ob_db_tx_gain_1p1),
517 5);
518 else if (AR_SREV_9340(ah))
519 INIT_INI_ARRAY(&ah->iniModesTxGain,
520 ar9340Modes_lowest_ob_db_tx_gain_table_1p0,
521 ARRAY_SIZE(ar9340Modes_lowest_ob_db_tx_gain_table_1p0),
522 5);
523 else if (AR_SREV_9485_11(ah))
524 INIT_INI_ARRAY(&ah->iniModesTxGain,
525 ar9485_modes_lowest_ob_db_tx_gain_1_1,
526 ARRAY_SIZE(ar9485_modes_lowest_ob_db_tx_gain_1_1),
527 5);
Gabor Juhos8bc45c62012-07-03 19:13:23 +0200528 else if (AR_SREV_9550(ah))
529 INIT_INI_ARRAY(&ah->iniModesTxGain,
530 ar955x_1p0_modes_xpa_tx_gain_table,
531 ARRAY_SIZE(ar955x_1p0_modes_xpa_tx_gain_table),
532 9);
Senthil Balasubramanian4d0707e2011-09-13 22:38:17 +0530533 else if (AR_SREV_9580(ah))
534 INIT_INI_ARRAY(&ah->iniModesTxGain,
535 ar9580_1p0_lowest_ob_db_tx_gain_table,
536 ARRAY_SIZE(ar9580_1p0_lowest_ob_db_tx_gain_table),
537 5);
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +0530538 else if (AR_SREV_9462_20(ah))
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530539 INIT_INI_ARRAY(&ah->iniModesTxGain,
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +0530540 ar9462_modes_low_ob_db_tx_gain_table_2p0,
541 ARRAY_SIZE(ar9462_modes_low_ob_db_tx_gain_table_2p0),
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530542 5);
Senthil Balasubramanian4d0707e2011-09-13 22:38:17 +0530543 else
544 INIT_INI_ARRAY(&ah->iniModesTxGain,
545 ar9300Modes_lowest_ob_db_tx_gain_table_2p2,
546 ARRAY_SIZE(ar9300Modes_lowest_ob_db_tx_gain_table_2p2),
547 5);
548}
549
550static void ar9003_tx_gain_table_mode1(struct ath_hw *ah)
551{
552 if (AR_SREV_9330_12(ah))
553 INIT_INI_ARRAY(&ah->iniModesTxGain,
554 ar9331_modes_high_ob_db_tx_gain_1p2,
555 ARRAY_SIZE(ar9331_modes_high_ob_db_tx_gain_1p2),
556 5);
557 else if (AR_SREV_9330_11(ah))
558 INIT_INI_ARRAY(&ah->iniModesTxGain,
559 ar9331_modes_high_ob_db_tx_gain_1p1,
560 ARRAY_SIZE(ar9331_modes_high_ob_db_tx_gain_1p1),
561 5);
562 else if (AR_SREV_9340(ah))
563 INIT_INI_ARRAY(&ah->iniModesTxGain,
Felix Fietkaub05a0112012-07-15 19:53:32 +0200564 ar9340Modes_high_ob_db_tx_gain_table_1p0,
565 ARRAY_SIZE(ar9340Modes_high_ob_db_tx_gain_table_1p0),
Senthil Balasubramanian4d0707e2011-09-13 22:38:17 +0530566 5);
567 else if (AR_SREV_9485_11(ah))
568 INIT_INI_ARRAY(&ah->iniModesTxGain,
569 ar9485Modes_high_ob_db_tx_gain_1_1,
570 ARRAY_SIZE(ar9485Modes_high_ob_db_tx_gain_1_1),
571 5);
572 else if (AR_SREV_9580(ah))
573 INIT_INI_ARRAY(&ah->iniModesTxGain,
574 ar9580_1p0_high_ob_db_tx_gain_table,
575 ARRAY_SIZE(ar9580_1p0_high_ob_db_tx_gain_table),
576 5);
Gabor Juhos8bc45c62012-07-03 19:13:23 +0200577 else if (AR_SREV_9550(ah))
578 INIT_INI_ARRAY(&ah->iniModesTxGain,
579 ar955x_1p0_modes_no_xpa_tx_gain_table,
580 ARRAY_SIZE(ar955x_1p0_modes_no_xpa_tx_gain_table),
581 9);
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +0530582 else if (AR_SREV_9462_20(ah))
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530583 INIT_INI_ARRAY(&ah->iniModesTxGain,
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +0530584 ar9462_modes_high_ob_db_tx_gain_table_2p0,
585 ARRAY_SIZE(ar9462_modes_high_ob_db_tx_gain_table_2p0),
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530586 5);
Senthil Balasubramanian4d0707e2011-09-13 22:38:17 +0530587 else
588 INIT_INI_ARRAY(&ah->iniModesTxGain,
589 ar9300Modes_high_ob_db_tx_gain_table_2p2,
590 ARRAY_SIZE(ar9300Modes_high_ob_db_tx_gain_table_2p2),
591 5);
592}
593
594static void ar9003_tx_gain_table_mode2(struct ath_hw *ah)
595{
596 if (AR_SREV_9330_12(ah))
597 INIT_INI_ARRAY(&ah->iniModesTxGain,
598 ar9331_modes_low_ob_db_tx_gain_1p2,
599 ARRAY_SIZE(ar9331_modes_low_ob_db_tx_gain_1p2),
600 5);
601 else if (AR_SREV_9330_11(ah))
602 INIT_INI_ARRAY(&ah->iniModesTxGain,
603 ar9331_modes_low_ob_db_tx_gain_1p1,
604 ARRAY_SIZE(ar9331_modes_low_ob_db_tx_gain_1p1),
605 5);
606 else if (AR_SREV_9340(ah))
607 INIT_INI_ARRAY(&ah->iniModesTxGain,
Felix Fietkaub05a0112012-07-15 19:53:32 +0200608 ar9340Modes_low_ob_db_tx_gain_table_1p0,
609 ARRAY_SIZE(ar9340Modes_low_ob_db_tx_gain_table_1p0),
Senthil Balasubramanian4d0707e2011-09-13 22:38:17 +0530610 5);
611 else if (AR_SREV_9485_11(ah))
612 INIT_INI_ARRAY(&ah->iniModesTxGain,
613 ar9485Modes_low_ob_db_tx_gain_1_1,
614 ARRAY_SIZE(ar9485Modes_low_ob_db_tx_gain_1_1),
615 5);
616 else if (AR_SREV_9580(ah))
617 INIT_INI_ARRAY(&ah->iniModesTxGain,
618 ar9580_1p0_low_ob_db_tx_gain_table,
619 ARRAY_SIZE(ar9580_1p0_low_ob_db_tx_gain_table),
620 5);
621 else
622 INIT_INI_ARRAY(&ah->iniModesTxGain,
623 ar9300Modes_low_ob_db_tx_gain_table_2p2,
624 ARRAY_SIZE(ar9300Modes_low_ob_db_tx_gain_table_2p2),
625 5);
626}
627
628static void ar9003_tx_gain_table_mode3(struct ath_hw *ah)
629{
630 if (AR_SREV_9330_12(ah))
631 INIT_INI_ARRAY(&ah->iniModesTxGain,
632 ar9331_modes_high_power_tx_gain_1p2,
633 ARRAY_SIZE(ar9331_modes_high_power_tx_gain_1p2),
634 5);
635 else if (AR_SREV_9330_11(ah))
636 INIT_INI_ARRAY(&ah->iniModesTxGain,
637 ar9331_modes_high_power_tx_gain_1p1,
638 ARRAY_SIZE(ar9331_modes_high_power_tx_gain_1p1),
639 5);
640 else if (AR_SREV_9340(ah))
641 INIT_INI_ARRAY(&ah->iniModesTxGain,
Felix Fietkaub05a0112012-07-15 19:53:32 +0200642 ar9340Modes_high_power_tx_gain_table_1p0,
643 ARRAY_SIZE(ar9340Modes_high_power_tx_gain_table_1p0),
Senthil Balasubramanian4d0707e2011-09-13 22:38:17 +0530644 5);
645 else if (AR_SREV_9485_11(ah))
646 INIT_INI_ARRAY(&ah->iniModesTxGain,
647 ar9485Modes_high_power_tx_gain_1_1,
648 ARRAY_SIZE(ar9485Modes_high_power_tx_gain_1_1),
649 5);
650 else if (AR_SREV_9580(ah))
651 INIT_INI_ARRAY(&ah->iniModesTxGain,
652 ar9580_1p0_high_power_tx_gain_table,
653 ARRAY_SIZE(ar9580_1p0_high_power_tx_gain_table),
654 5);
655 else
656 INIT_INI_ARRAY(&ah->iniModesTxGain,
657 ar9300Modes_high_power_tx_gain_table_2p2,
658 ARRAY_SIZE(ar9300Modes_high_power_tx_gain_table_2p2),
659 5);
660}
661
Felix Fietkaub05a0112012-07-15 19:53:32 +0200662static void ar9003_tx_gain_table_mode4(struct ath_hw *ah)
663{
664 if (AR_SREV_9340(ah))
665 INIT_INI_ARRAY(&ah->iniModesTxGain,
666 ar9340Modes_mixed_ob_db_tx_gain_table_1p0,
667 ARRAY_SIZE(ar9340Modes_mixed_ob_db_tx_gain_table_1p0),
668 5);
669 else if (AR_SREV_9580(ah))
670 INIT_INI_ARRAY(&ah->iniModesTxGain,
671 ar9580_1p0_mixed_ob_db_tx_gain_table,
672 ARRAY_SIZE(ar9580_1p0_mixed_ob_db_tx_gain_table),
673 5);
674}
675
Luis R. Rodriguezc14a85d2010-04-15 17:39:21 -0400676static void ar9003_tx_gain_table_apply(struct ath_hw *ah)
677{
678 switch (ar9003_hw_get_tx_gain_idx(ah)) {
679 case 0:
680 default:
Senthil Balasubramanian4d0707e2011-09-13 22:38:17 +0530681 ar9003_tx_gain_table_mode0(ah);
Luis R. Rodriguezc14a85d2010-04-15 17:39:21 -0400682 break;
683 case 1:
Senthil Balasubramanian4d0707e2011-09-13 22:38:17 +0530684 ar9003_tx_gain_table_mode1(ah);
Luis R. Rodriguezc14a85d2010-04-15 17:39:21 -0400685 break;
686 case 2:
Senthil Balasubramanian4d0707e2011-09-13 22:38:17 +0530687 ar9003_tx_gain_table_mode2(ah);
Vasanthakumar Thiagarajanff48ba42010-12-06 04:27:38 -0800688 break;
689 case 3:
Senthil Balasubramanian4d0707e2011-09-13 22:38:17 +0530690 ar9003_tx_gain_table_mode3(ah);
Luis R. Rodriguezc14a85d2010-04-15 17:39:21 -0400691 break;
Felix Fietkaub05a0112012-07-15 19:53:32 +0200692 case 4:
693 ar9003_tx_gain_table_mode4(ah);
694 break;
Luis R. Rodriguezc14a85d2010-04-15 17:39:21 -0400695 }
696}
697
Senthil Balasubramanian4d0707e2011-09-13 22:38:17 +0530698static void ar9003_rx_gain_table_mode0(struct ath_hw *ah)
699{
700 if (AR_SREV_9330_12(ah))
701 INIT_INI_ARRAY(&ah->iniModesRxGain,
702 ar9331_common_rx_gain_1p2,
703 ARRAY_SIZE(ar9331_common_rx_gain_1p2),
704 2);
705 else if (AR_SREV_9330_11(ah))
706 INIT_INI_ARRAY(&ah->iniModesRxGain,
707 ar9331_common_rx_gain_1p1,
708 ARRAY_SIZE(ar9331_common_rx_gain_1p1),
709 2);
710 else if (AR_SREV_9340(ah))
711 INIT_INI_ARRAY(&ah->iniModesRxGain,
712 ar9340Common_rx_gain_table_1p0,
713 ARRAY_SIZE(ar9340Common_rx_gain_table_1p0),
714 2);
715 else if (AR_SREV_9485_11(ah))
716 INIT_INI_ARRAY(&ah->iniModesRxGain,
717 ar9485Common_wo_xlna_rx_gain_1_1,
718 ARRAY_SIZE(ar9485Common_wo_xlna_rx_gain_1_1),
719 2);
Gabor Juhos8bc45c62012-07-03 19:13:23 +0200720 else if (AR_SREV_9550(ah)) {
721 INIT_INI_ARRAY(&ah->iniModesRxGain,
722 ar955x_1p0_common_rx_gain_table,
723 ARRAY_SIZE(ar955x_1p0_common_rx_gain_table),
724 2);
725 INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
726 ar955x_1p0_common_rx_gain_bounds,
727 ARRAY_SIZE(ar955x_1p0_common_rx_gain_bounds),
728 5);
729 } else if (AR_SREV_9580(ah))
Senthil Balasubramanian4d0707e2011-09-13 22:38:17 +0530730 INIT_INI_ARRAY(&ah->iniModesRxGain,
731 ar9580_1p0_rx_gain_table,
732 ARRAY_SIZE(ar9580_1p0_rx_gain_table),
733 2);
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +0530734 else if (AR_SREV_9462_20(ah))
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530735 INIT_INI_ARRAY(&ah->iniModesRxGain,
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +0530736 ar9462_common_rx_gain_table_2p0,
737 ARRAY_SIZE(ar9462_common_rx_gain_table_2p0),
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530738 2);
Senthil Balasubramanian4d0707e2011-09-13 22:38:17 +0530739 else
740 INIT_INI_ARRAY(&ah->iniModesRxGain,
741 ar9300Common_rx_gain_table_2p2,
742 ARRAY_SIZE(ar9300Common_rx_gain_table_2p2),
743 2);
744}
745
746static void ar9003_rx_gain_table_mode1(struct ath_hw *ah)
747{
748 if (AR_SREV_9330_12(ah))
749 INIT_INI_ARRAY(&ah->iniModesRxGain,
750 ar9331_common_wo_xlna_rx_gain_1p2,
751 ARRAY_SIZE(ar9331_common_wo_xlna_rx_gain_1p2),
752 2);
753 else if (AR_SREV_9330_11(ah))
754 INIT_INI_ARRAY(&ah->iniModesRxGain,
755 ar9331_common_wo_xlna_rx_gain_1p1,
756 ARRAY_SIZE(ar9331_common_wo_xlna_rx_gain_1p1),
757 2);
758 else if (AR_SREV_9340(ah))
759 INIT_INI_ARRAY(&ah->iniModesRxGain,
760 ar9340Common_wo_xlna_rx_gain_table_1p0,
761 ARRAY_SIZE(ar9340Common_wo_xlna_rx_gain_table_1p0),
762 2);
763 else if (AR_SREV_9485_11(ah))
764 INIT_INI_ARRAY(&ah->iniModesRxGain,
765 ar9485Common_wo_xlna_rx_gain_1_1,
766 ARRAY_SIZE(ar9485Common_wo_xlna_rx_gain_1_1),
767 2);
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +0530768 else if (AR_SREV_9462_20(ah))
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530769 INIT_INI_ARRAY(&ah->iniModesRxGain,
Rajkumar Manoharan423e38e2011-10-13 11:00:44 +0530770 ar9462_common_wo_xlna_rx_gain_table_2p0,
771 ARRAY_SIZE(ar9462_common_wo_xlna_rx_gain_table_2p0),
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530772 2);
Gabor Juhos8bc45c62012-07-03 19:13:23 +0200773 else if (AR_SREV_9550(ah)) {
774 INIT_INI_ARRAY(&ah->iniModesRxGain,
775 ar955x_1p0_common_wo_xlna_rx_gain_table,
776 ARRAY_SIZE(ar955x_1p0_common_wo_xlna_rx_gain_table),
777 2);
778 INIT_INI_ARRAY(&ah->ini_modes_rx_gain_bounds,
779 ar955x_1p0_common_wo_xlna_rx_gain_bounds,
780 ARRAY_SIZE(ar955x_1p0_common_wo_xlna_rx_gain_bounds),
781 5);
782 } else if (AR_SREV_9580(ah))
Senthil Balasubramanian4d0707e2011-09-13 22:38:17 +0530783 INIT_INI_ARRAY(&ah->iniModesRxGain,
784 ar9580_1p0_wo_xlna_rx_gain_table,
785 ARRAY_SIZE(ar9580_1p0_wo_xlna_rx_gain_table),
786 2);
787 else
788 INIT_INI_ARRAY(&ah->iniModesRxGain,
789 ar9300Common_wo_xlna_rx_gain_table_2p2,
790 ARRAY_SIZE(ar9300Common_wo_xlna_rx_gain_table_2p2),
791 2);
792}
793
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530794static void ar9003_rx_gain_table_mode2(struct ath_hw *ah)
795{
Sujith Manoharanc91ec462012-02-22 12:40:03 +0530796 if (AR_SREV_9462_20(ah))
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530797 INIT_INI_ARRAY(&ah->iniModesRxGain,
Sujith Manoharanc91ec462012-02-22 12:40:03 +0530798 ar9462_common_mixed_rx_gain_table_2p0,
799 ARRAY_SIZE(ar9462_common_mixed_rx_gain_table_2p0), 2);
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530800}
801
Luis R. Rodriguezc14a85d2010-04-15 17:39:21 -0400802static void ar9003_rx_gain_table_apply(struct ath_hw *ah)
803{
804 switch (ar9003_hw_get_rx_gain_idx(ah)) {
805 case 0:
806 default:
Senthil Balasubramanian4d0707e2011-09-13 22:38:17 +0530807 ar9003_rx_gain_table_mode0(ah);
Luis R. Rodriguezc14a85d2010-04-15 17:39:21 -0400808 break;
809 case 1:
Senthil Balasubramanian4d0707e2011-09-13 22:38:17 +0530810 ar9003_rx_gain_table_mode1(ah);
Luis R. Rodriguezc14a85d2010-04-15 17:39:21 -0400811 break;
Senthil Balasubramanian2577c6e2011-09-13 22:38:18 +0530812 case 2:
813 ar9003_rx_gain_table_mode2(ah);
814 break;
Luis R. Rodriguezc14a85d2010-04-15 17:39:21 -0400815 }
816}
817
818/* set gain table pointers according to values read from the eeprom */
819static void ar9003_hw_init_mode_gain_regs(struct ath_hw *ah)
820{
821 ar9003_tx_gain_table_apply(ah);
822 ar9003_rx_gain_table_apply(ah);
823}
824
Luis R. Rodriguezb3950e62010-04-15 17:39:03 -0400825/*
826 * Helper for ASPM support.
827 *
828 * Disable PLL when in L0s as well as receiver clock when in L1.
829 * This power saving option must be enabled through the SerDes.
830 *
831 * Programming the SerDes must go through the same 288 bit serial shift
832 * register as the other analog registers. Hence the 9 writes.
833 */
834static void ar9003_hw_configpcipowersave(struct ath_hw *ah,
Stanislaw Gruszka84c87dc2011-08-05 13:10:32 +0200835 bool power_off)
Luis R. Rodriguezb3950e62010-04-15 17:39:03 -0400836{
Luis R. Rodriguezb3950e62010-04-15 17:39:03 -0400837 /* Nothing to do on restore for 11N */
Stanislaw Gruszka84c87dc2011-08-05 13:10:32 +0200838 if (!power_off /* !restore */) {
Luis R. Rodriguezb3950e62010-04-15 17:39:03 -0400839 /* set bit 19 to allow forcing of pcie core into L1 state */
840 REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA);
841
842 /* Several PCIe massages to ensure proper behaviour */
843 if (ah->config.pcie_waen)
844 REG_WRITE(ah, AR_WA, ah->config.pcie_waen);
Luis R. Rodriguez9a658d22010-06-21 18:38:47 -0400845 else
846 REG_WRITE(ah, AR_WA, ah->WARegVal);
Luis R. Rodriguezb3950e62010-04-15 17:39:03 -0400847 }
Luis R. Rodriguez653fe372010-06-21 18:38:48 -0400848
849 /*
850 * Configire PCIE after Ini init. SERDES values now come from ini file
851 * This enables PCIe low power mode.
852 */
Luis R. Rodriguez6a0ec302010-06-21 18:38:49 -0400853 if (ah->config.pcieSerDesWrite) {
Luis R. Rodriguez653fe372010-06-21 18:38:48 -0400854 unsigned int i;
Luis R. Rodriguezd5c4d192010-06-21 18:38:50 -0400855 struct ar5416IniArray *array;
Luis R. Rodriguez653fe372010-06-21 18:38:48 -0400856
Luis R. Rodriguezd5c4d192010-06-21 18:38:50 -0400857 array = power_off ? &ah->iniPcieSerdes :
858 &ah->iniPcieSerdesLowPower;
859
860 for (i = 0; i < array->ia_rows; i++) {
Luis R. Rodriguez653fe372010-06-21 18:38:48 -0400861 REG_WRITE(ah,
Luis R. Rodriguezd5c4d192010-06-21 18:38:50 -0400862 INI_RA(array, i, 0),
863 INI_RA(array, i, 1));
Luis R. Rodriguez653fe372010-06-21 18:38:48 -0400864 }
865 }
Luis R. Rodriguezb3950e62010-04-15 17:39:03 -0400866}
867
868/* Sets up the AR9003 hardware familiy callbacks */
869void ar9003_hw_attach_ops(struct ath_hw *ah)
870{
871 struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
872 struct ath_hw_ops *ops = ath9k_hw_ops(ah);
873
874 priv_ops->init_mode_regs = ar9003_hw_init_mode_regs;
Luis R. Rodriguezc14a85d2010-04-15 17:39:21 -0400875 priv_ops->init_mode_gain_regs = ar9003_hw_init_mode_gain_regs;
Luis R. Rodriguezb3950e62010-04-15 17:39:03 -0400876
877 ops->config_pci_powersave = ar9003_hw_configpcipowersave;
878
879 ar9003_hw_attach_phy_ops(ah);
880 ar9003_hw_attach_calib_ops(ah);
881 ar9003_hw_attach_mac_ops(ah);
Luis R. Rodriguezb3950e62010-04-15 17:39:03 -0400882}