blob: a9f69fdd170b0fd0fb039ffb949a657c7dcefefd [file] [log] [blame]
Johannes Berg02a7fa02011-04-05 09:42:12 -07001/******************************************************************************
2 *
Emmanuel Grumbach51368bf2013-12-30 13:15:54 +02003 * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved.
Sara Sharonf65ebd82016-05-22 16:25:40 +03004 * Copyright(c) 2015 - 2016 Intel Deutschland GmbH
Johannes Berg02a7fa02011-04-05 09:42:12 -07005 *
6 * Portions of this file are derived from the ipw3945 project.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of version 2 of the GNU General Public License as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
20 *
21 * The full GNU General Public License is included in this distribution in the
22 * file called LICENSE.
23 *
24 * Contact Information:
Emmanuel Grumbachcb2f8272015-11-17 15:39:56 +020025 * Intel Linux Wireless <linuxwifi@intel.com>
Johannes Berg02a7fa02011-04-05 09:42:12 -070026 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *
28 *****************************************************************************/
Emmanuel Grumbach83ed9012011-08-25 23:11:14 -070029#include <linux/delay.h>
30#include <linux/device.h>
Don Frycc5f7e32012-05-16 22:54:27 +020031#include <linux/export.h>
Johannes Berg02a7fa02011-04-05 09:42:12 -070032
Johannes Berg48e29342013-03-01 00:13:33 +010033#include "iwl-drv.h"
Johannes Berg02a7fa02011-04-05 09:42:12 -070034#include "iwl-io.h"
Paul Bolle6ac7d112012-06-06 14:17:46 +020035#include "iwl-csr.h"
Emmanuel Grumbach83ed9012011-08-25 23:11:14 -070036#include "iwl-debug.h"
Liad Kaufman4c9706d2014-04-27 16:46:09 +030037#include "iwl-prph.h"
Inbal Hacohen313b0a22013-06-24 10:35:53 +030038#include "iwl-fh.h"
Johannes Berg02a7fa02011-04-05 09:42:12 -070039
Emmanuel Grumbacha73a2ce2015-08-23 13:29:36 +030040void iwl_write8(struct iwl_trans *trans, u32 ofs, u8 val)
41{
42 trace_iwlwifi_dev_iowrite8(trans->dev, ofs, val);
43 iwl_trans_write8(trans, ofs, val);
44}
45IWL_EXPORT_SYMBOL(iwl_write8);
46
47void iwl_write32(struct iwl_trans *trans, u32 ofs, u32 val)
48{
49 trace_iwlwifi_dev_iowrite32(trans->dev, ofs, val);
50 iwl_trans_write32(trans, ofs, val);
51}
52IWL_EXPORT_SYMBOL(iwl_write32);
53
Sara Sharon12a17452016-06-23 12:04:55 +030054void iwl_write64(struct iwl_trans *trans, u64 ofs, u64 val)
55{
56 trace_iwlwifi_dev_iowrite64(trans->dev, ofs, val);
57 iwl_trans_write32(trans, ofs, val & 0xffffffff);
58 iwl_trans_write32(trans, ofs + 4, val >> 32);
59}
60IWL_EXPORT_SYMBOL(iwl_write64);
61
Emmanuel Grumbacha73a2ce2015-08-23 13:29:36 +030062u32 iwl_read32(struct iwl_trans *trans, u32 ofs)
63{
64 u32 val = iwl_trans_read32(trans, ofs);
Emmanuel Grumbach89ced542015-08-26 13:50:59 +030065
Emmanuel Grumbacha73a2ce2015-08-23 13:29:36 +030066 trace_iwlwifi_dev_ioread32(trans->dev, ofs, val);
67 return val;
68}
69IWL_EXPORT_SYMBOL(iwl_read32);
70
Johannes Berg02a7fa02011-04-05 09:42:12 -070071#define IWL_POLL_INTERVAL 10 /* microseconds */
72
Emmanuel Grumbach1042db22012-01-03 16:56:15 +020073int iwl_poll_bit(struct iwl_trans *trans, u32 addr,
Johannes Berg02a7fa02011-04-05 09:42:12 -070074 u32 bits, u32 mask, int timeout)
75{
76 int t = 0;
77
78 do {
Emmanuel Grumbach1042db22012-01-03 16:56:15 +020079 if ((iwl_read32(trans, addr) & mask) == (bits & mask))
Johannes Berg02a7fa02011-04-05 09:42:12 -070080 return t;
81 udelay(IWL_POLL_INTERVAL);
82 t += IWL_POLL_INTERVAL;
83 } while (t < timeout);
84
85 return -ETIMEDOUT;
86}
Johannes Berg48e29342013-03-01 00:13:33 +010087IWL_EXPORT_SYMBOL(iwl_poll_bit);
Johannes Berg02a7fa02011-04-05 09:42:12 -070088
Emmanuel Grumbach1042db22012-01-03 16:56:15 +020089u32 iwl_read_direct32(struct iwl_trans *trans, u32 reg)
Johannes Berg02a7fa02011-04-05 09:42:12 -070090{
Emmanuel Grumbachabae2382012-12-31 13:46:42 +020091 u32 value = 0x5a5a5a5a;
Johannes Berg02a7fa02011-04-05 09:42:12 -070092 unsigned long flags;
Emmanuel Grumbach23ba9342015-12-17 11:55:13 +020093 if (iwl_trans_grab_nic_access(trans, &flags)) {
Emmanuel Grumbachabae2382012-12-31 13:46:42 +020094 value = iwl_read32(trans, reg);
Lilach Edelsteine56b04e2013-01-16 11:34:49 +020095 iwl_trans_release_nic_access(trans, &flags);
Emmanuel Grumbachabae2382012-12-31 13:46:42 +020096 }
Johannes Berg02a7fa02011-04-05 09:42:12 -070097
98 return value;
99}
Johannes Berg48e29342013-03-01 00:13:33 +0100100IWL_EXPORT_SYMBOL(iwl_read_direct32);
Johannes Berg02a7fa02011-04-05 09:42:12 -0700101
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200102void iwl_write_direct32(struct iwl_trans *trans, u32 reg, u32 value)
Johannes Berg02a7fa02011-04-05 09:42:12 -0700103{
104 unsigned long flags;
105
Emmanuel Grumbach23ba9342015-12-17 11:55:13 +0200106 if (iwl_trans_grab_nic_access(trans, &flags)) {
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200107 iwl_write32(trans, reg, value);
Lilach Edelsteine56b04e2013-01-16 11:34:49 +0200108 iwl_trans_release_nic_access(trans, &flags);
Johannes Berg02a7fa02011-04-05 09:42:12 -0700109 }
Johannes Berg02a7fa02011-04-05 09:42:12 -0700110}
Johannes Berg48e29342013-03-01 00:13:33 +0100111IWL_EXPORT_SYMBOL(iwl_write_direct32);
Johannes Berg02a7fa02011-04-05 09:42:12 -0700112
Sara Sharon12a17452016-06-23 12:04:55 +0300113void iwl_write_direct64(struct iwl_trans *trans, u64 reg, u64 value)
114{
115 unsigned long flags;
116
117 if (iwl_trans_grab_nic_access(trans, &flags)) {
118 iwl_write64(trans, reg, value);
119 iwl_trans_release_nic_access(trans, &flags);
120 }
121}
122IWL_EXPORT_SYMBOL(iwl_write_direct64);
123
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200124int iwl_poll_direct_bit(struct iwl_trans *trans, u32 addr, u32 mask,
Johannes Berg02a7fa02011-04-05 09:42:12 -0700125 int timeout)
126{
127 int t = 0;
128
129 do {
Emmanuel Grumbach1042db22012-01-03 16:56:15 +0200130 if ((iwl_read_direct32(trans, addr) & mask) == mask)
Johannes Berg02a7fa02011-04-05 09:42:12 -0700131 return t;
132 udelay(IWL_POLL_INTERVAL);
133 t += IWL_POLL_INTERVAL;
134 } while (t < timeout);
135
136 return -ETIMEDOUT;
137}
Johannes Berg48e29342013-03-01 00:13:33 +0100138IWL_EXPORT_SYMBOL(iwl_poll_direct_bit);
Johannes Berg02a7fa02011-04-05 09:42:12 -0700139
Golan Ben-Ami14ef1b42015-10-21 15:16:58 +0300140u32 iwl_read_prph_no_grab(struct iwl_trans *trans, u32 ofs)
Johannes Berg02a7fa02011-04-05 09:42:12 -0700141{
Emmanuel Grumbach6a06b6c2012-12-02 13:07:30 +0200142 u32 val = iwl_trans_read_prph(trans, ofs);
143 trace_iwlwifi_dev_ioread_prph32(trans->dev, ofs, val);
144 return val;
Johannes Berg02a7fa02011-04-05 09:42:12 -0700145}
Golan Ben-Ami14ef1b42015-10-21 15:16:58 +0300146IWL_EXPORT_SYMBOL(iwl_read_prph_no_grab);
Johannes Berg02a7fa02011-04-05 09:42:12 -0700147
Golan Ben-Ami14ef1b42015-10-21 15:16:58 +0300148void iwl_write_prph_no_grab(struct iwl_trans *trans, u32 ofs, u32 val)
Johannes Berg02a7fa02011-04-05 09:42:12 -0700149{
Emmanuel Grumbach6a06b6c2012-12-02 13:07:30 +0200150 trace_iwlwifi_dev_iowrite_prph32(trans->dev, ofs, val);
151 iwl_trans_write_prph(trans, ofs, val);
Johannes Berg02a7fa02011-04-05 09:42:12 -0700152}
Golan Ben-Ami14ef1b42015-10-21 15:16:58 +0300153IWL_EXPORT_SYMBOL(iwl_write_prph_no_grab);
Johannes Berg02a7fa02011-04-05 09:42:12 -0700154
Sara Sharon12a17452016-06-23 12:04:55 +0300155void iwl_write_prph64_no_grab(struct iwl_trans *trans, u64 ofs, u64 val)
156{
157 trace_iwlwifi_dev_iowrite_prph64(trans->dev, ofs, val);
158 iwl_write_prph_no_grab(trans, ofs, val & 0xffffffff);
159 iwl_write_prph_no_grab(trans, ofs + 4, val >> 32);
160}
161IWL_EXPORT_SYMBOL(iwl_write_prph64_no_grab);
162
Emmanuel Grumbach6a06b6c2012-12-02 13:07:30 +0200163u32 iwl_read_prph(struct iwl_trans *trans, u32 ofs)
Johannes Berg02a7fa02011-04-05 09:42:12 -0700164{
165 unsigned long flags;
Emmanuel Grumbachabae2382012-12-31 13:46:42 +0200166 u32 val = 0x5a5a5a5a;
Johannes Berg02a7fa02011-04-05 09:42:12 -0700167
Emmanuel Grumbach23ba9342015-12-17 11:55:13 +0200168 if (iwl_trans_grab_nic_access(trans, &flags)) {
Golan Ben-Ami14ef1b42015-10-21 15:16:58 +0300169 val = iwl_read_prph_no_grab(trans, ofs);
Lilach Edelsteine56b04e2013-01-16 11:34:49 +0200170 iwl_trans_release_nic_access(trans, &flags);
Emmanuel Grumbachabae2382012-12-31 13:46:42 +0200171 }
Johannes Berg02a7fa02011-04-05 09:42:12 -0700172 return val;
173}
Johannes Berg48e29342013-03-01 00:13:33 +0100174IWL_EXPORT_SYMBOL(iwl_read_prph);
Johannes Berg02a7fa02011-04-05 09:42:12 -0700175
Emmanuel Grumbach6a06b6c2012-12-02 13:07:30 +0200176void iwl_write_prph(struct iwl_trans *trans, u32 ofs, u32 val)
Johannes Berg02a7fa02011-04-05 09:42:12 -0700177{
178 unsigned long flags;
179
Emmanuel Grumbach23ba9342015-12-17 11:55:13 +0200180 if (iwl_trans_grab_nic_access(trans, &flags)) {
Golan Ben-Ami14ef1b42015-10-21 15:16:58 +0300181 iwl_write_prph_no_grab(trans, ofs, val);
Lilach Edelsteine56b04e2013-01-16 11:34:49 +0200182 iwl_trans_release_nic_access(trans, &flags);
Johannes Berg02a7fa02011-04-05 09:42:12 -0700183 }
Johannes Berg02a7fa02011-04-05 09:42:12 -0700184}
Johannes Berg48e29342013-03-01 00:13:33 +0100185IWL_EXPORT_SYMBOL(iwl_write_prph);
Johannes Berg02a7fa02011-04-05 09:42:12 -0700186
Eran Harary189fa2f2014-01-23 16:26:32 +0200187int iwl_poll_prph_bit(struct iwl_trans *trans, u32 addr,
188 u32 bits, u32 mask, int timeout)
189{
190 int t = 0;
191
192 do {
193 if ((iwl_read_prph(trans, addr) & mask) == (bits & mask))
194 return t;
195 udelay(IWL_POLL_INTERVAL);
196 t += IWL_POLL_INTERVAL;
197 } while (t < timeout);
198
199 return -ETIMEDOUT;
200}
201
Emmanuel Grumbach6a06b6c2012-12-02 13:07:30 +0200202void iwl_set_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask)
Johannes Berg02a7fa02011-04-05 09:42:12 -0700203{
204 unsigned long flags;
205
Emmanuel Grumbach23ba9342015-12-17 11:55:13 +0200206 if (iwl_trans_grab_nic_access(trans, &flags)) {
Golan Ben-Ami14ef1b42015-10-21 15:16:58 +0300207 iwl_write_prph_no_grab(trans, ofs,
208 iwl_read_prph_no_grab(trans, ofs) |
209 mask);
Lilach Edelsteine56b04e2013-01-16 11:34:49 +0200210 iwl_trans_release_nic_access(trans, &flags);
Stanislaw Gruszkabfe4b802012-03-07 09:52:24 -0800211 }
Johannes Berg02a7fa02011-04-05 09:42:12 -0700212}
Johannes Berg48e29342013-03-01 00:13:33 +0100213IWL_EXPORT_SYMBOL(iwl_set_bits_prph);
Johannes Berg02a7fa02011-04-05 09:42:12 -0700214
Emmanuel Grumbach6a06b6c2012-12-02 13:07:30 +0200215void iwl_set_bits_mask_prph(struct iwl_trans *trans, u32 ofs,
Johannes Berg02a7fa02011-04-05 09:42:12 -0700216 u32 bits, u32 mask)
217{
218 unsigned long flags;
219
Emmanuel Grumbach23ba9342015-12-17 11:55:13 +0200220 if (iwl_trans_grab_nic_access(trans, &flags)) {
Golan Ben-Ami14ef1b42015-10-21 15:16:58 +0300221 iwl_write_prph_no_grab(trans, ofs,
222 (iwl_read_prph_no_grab(trans, ofs) &
223 mask) | bits);
Lilach Edelsteine56b04e2013-01-16 11:34:49 +0200224 iwl_trans_release_nic_access(trans, &flags);
Stanislaw Gruszkabfe4b802012-03-07 09:52:24 -0800225 }
Johannes Berg02a7fa02011-04-05 09:42:12 -0700226}
Johannes Berg48e29342013-03-01 00:13:33 +0100227IWL_EXPORT_SYMBOL(iwl_set_bits_mask_prph);
Johannes Berg02a7fa02011-04-05 09:42:12 -0700228
Emmanuel Grumbach6a06b6c2012-12-02 13:07:30 +0200229void iwl_clear_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask)
Johannes Berg02a7fa02011-04-05 09:42:12 -0700230{
231 unsigned long flags;
232 u32 val;
233
Emmanuel Grumbach23ba9342015-12-17 11:55:13 +0200234 if (iwl_trans_grab_nic_access(trans, &flags)) {
Golan Ben-Ami14ef1b42015-10-21 15:16:58 +0300235 val = iwl_read_prph_no_grab(trans, ofs);
236 iwl_write_prph_no_grab(trans, ofs, (val & ~mask));
Lilach Edelsteine56b04e2013-01-16 11:34:49 +0200237 iwl_trans_release_nic_access(trans, &flags);
Stanislaw Gruszkabfe4b802012-03-07 09:52:24 -0800238 }
Johannes Berg02a7fa02011-04-05 09:42:12 -0700239}
Johannes Berg48e29342013-03-01 00:13:33 +0100240IWL_EXPORT_SYMBOL(iwl_clear_bits_prph);
Inbal Hacohen313b0a22013-06-24 10:35:53 +0300241
Liad Kaufman4c9706d2014-04-27 16:46:09 +0300242void iwl_force_nmi(struct iwl_trans *trans)
243{
Emmanuel Grumbach5dd9c682015-03-05 13:06:13 +0200244 if (trans->cfg->device_family != IWL_DEVICE_FAMILY_8000) {
Emmanuel Grumbach66396582015-01-07 16:44:06 +0200245 iwl_write_prph(trans, DEVICE_SET_NMI_REG,
246 DEVICE_SET_NMI_VAL_DRV);
247 iwl_write_prph(trans, DEVICE_SET_NMI_REG,
248 DEVICE_SET_NMI_VAL_HW);
249 } else {
Emmanuel Grumbach5dd9c682015-03-05 13:06:13 +0200250 iwl_write_prph(trans, DEVICE_SET_NMI_8000_REG,
251 DEVICE_SET_NMI_8000_VAL);
Emmanuel Grumbach9b666db2015-03-09 12:37:59 +0200252 iwl_write_prph(trans, DEVICE_SET_NMI_REG,
253 DEVICE_SET_NMI_VAL_DRV);
Emmanuel Grumbach66396582015-01-07 16:44:06 +0200254 }
Liad Kaufman4c9706d2014-04-27 16:46:09 +0300255}
256IWL_EXPORT_SYMBOL(iwl_force_nmi);
257
Sara Sharonf65ebd82016-05-22 16:25:40 +0300258static const char *get_rfh_string(int cmd)
Inbal Hacohen313b0a22013-06-24 10:35:53 +0300259{
260#define IWL_CMD(x) case x: return #x
Sara Sharonf65ebd82016-05-22 16:25:40 +0300261#define IWL_CMD_MQ(arg, reg, q) { if (arg == reg(q)) return #reg; }
262
263 int i;
264
265 for (i = 0; i < IWL_MAX_RX_HW_QUEUES; i++) {
266 IWL_CMD_MQ(cmd, RFH_Q_FRBDCB_BA_LSB, i);
267 IWL_CMD_MQ(cmd, RFH_Q_FRBDCB_WIDX, i);
268 IWL_CMD_MQ(cmd, RFH_Q_FRBDCB_RIDX, i);
269 IWL_CMD_MQ(cmd, RFH_Q_URBD_STTS_WPTR_LSB, i);
kbuild test robotc0ed8aa2016-07-11 05:01:12 +0800270 }
Sara Sharonf65ebd82016-05-22 16:25:40 +0300271
272 switch (cmd) {
273 IWL_CMD(RFH_RXF_DMA_CFG);
274 IWL_CMD(RFH_GEN_CFG);
275 IWL_CMD(RFH_GEN_STATUS);
276 IWL_CMD(FH_TSSR_TX_STATUS_REG);
277 IWL_CMD(FH_TSSR_TX_ERROR_REG);
278 default:
279 return "UNKNOWN";
280 }
281#undef IWL_CMD_MQ
282}
283
284struct reg {
285 u32 addr;
286 bool is64;
287};
288
289static int iwl_dump_rfh(struct iwl_trans *trans, char **buf)
290{
291 int i, q;
292 int num_q = trans->num_rx_queues;
293 static const u32 rfh_tbl[] = {
294 RFH_RXF_DMA_CFG,
295 RFH_GEN_CFG,
296 RFH_GEN_STATUS,
297 FH_TSSR_TX_STATUS_REG,
298 FH_TSSR_TX_ERROR_REG,
299 };
300 static const struct reg rfh_mq_tbl[] = {
301 { RFH_Q0_FRBDCB_BA_LSB, true },
302 { RFH_Q0_FRBDCB_WIDX, false },
303 { RFH_Q0_FRBDCB_RIDX, false },
304 { RFH_Q0_URBD_STTS_WPTR_LSB, true },
305 };
306
307#ifdef CONFIG_IWLWIFI_DEBUGFS
308 if (buf) {
309 int pos = 0;
310 /*
311 * Register (up to 34 for name + 8 blank/q for MQ): 40 chars
312 * Colon + space: 2 characters
313 * 0X%08x: 10 characters
314 * New line: 1 character
315 * Total of 53 characters
316 */
317 size_t bufsz = ARRAY_SIZE(rfh_tbl) * 53 +
318 ARRAY_SIZE(rfh_mq_tbl) * 53 * num_q + 40;
319
320 *buf = kmalloc(bufsz, GFP_KERNEL);
321 if (!*buf)
322 return -ENOMEM;
323
324 pos += scnprintf(*buf + pos, bufsz - pos,
325 "RFH register values:\n");
326
327 for (i = 0; i < ARRAY_SIZE(rfh_tbl); i++)
328 pos += scnprintf(*buf + pos, bufsz - pos,
329 "%40s: 0X%08x\n",
330 get_rfh_string(rfh_tbl[i]),
331 iwl_read_prph(trans, rfh_tbl[i]));
332
333 for (i = 0; i < ARRAY_SIZE(rfh_mq_tbl); i++)
334 for (q = 0; q < num_q; q++) {
335 u32 addr = rfh_mq_tbl[i].addr;
336
337 addr += q * (rfh_mq_tbl[i].is64 ? 8 : 4);
338 pos += scnprintf(*buf + pos, bufsz - pos,
339 "%34s(q %2d): 0X%08x\n",
340 get_rfh_string(addr), q,
341 iwl_read_prph(trans, addr));
342 }
343
344 return pos;
345 }
346#endif
347
348 IWL_ERR(trans, "RFH register values:\n");
349 for (i = 0; i < ARRAY_SIZE(rfh_tbl); i++)
350 IWL_ERR(trans, " %34s: 0X%08x\n",
351 get_rfh_string(rfh_tbl[i]),
352 iwl_read_prph(trans, rfh_tbl[i]));
353
354 for (i = 0; i < ARRAY_SIZE(rfh_mq_tbl); i++)
355 for (q = 0; q < num_q; q++) {
356 u32 addr = rfh_mq_tbl[i].addr;
357
358 addr += q * (rfh_mq_tbl[i].is64 ? 8 : 4);
359 IWL_ERR(trans, " %34s(q %d): 0X%08x\n",
360 get_rfh_string(addr), q,
361 iwl_read_prph(trans, addr));
362 }
363
364 return 0;
365}
366
367static const char *get_fh_string(int cmd)
368{
Inbal Hacohen313b0a22013-06-24 10:35:53 +0300369 switch (cmd) {
370 IWL_CMD(FH_RSCSR_CHNL0_STTS_WPTR_REG);
371 IWL_CMD(FH_RSCSR_CHNL0_RBDCB_BASE_REG);
372 IWL_CMD(FH_RSCSR_CHNL0_WPTR);
373 IWL_CMD(FH_MEM_RCSR_CHNL0_CONFIG_REG);
374 IWL_CMD(FH_MEM_RSSR_SHARED_CTRL_REG);
375 IWL_CMD(FH_MEM_RSSR_RX_STATUS_REG);
376 IWL_CMD(FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV);
377 IWL_CMD(FH_TSSR_TX_STATUS_REG);
378 IWL_CMD(FH_TSSR_TX_ERROR_REG);
379 default:
380 return "UNKNOWN";
381 }
382#undef IWL_CMD
383}
384
385int iwl_dump_fh(struct iwl_trans *trans, char **buf)
386{
387 int i;
388 static const u32 fh_tbl[] = {
389 FH_RSCSR_CHNL0_STTS_WPTR_REG,
390 FH_RSCSR_CHNL0_RBDCB_BASE_REG,
391 FH_RSCSR_CHNL0_WPTR,
392 FH_MEM_RCSR_CHNL0_CONFIG_REG,
393 FH_MEM_RSSR_SHARED_CTRL_REG,
394 FH_MEM_RSSR_RX_STATUS_REG,
395 FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV,
396 FH_TSSR_TX_STATUS_REG,
397 FH_TSSR_TX_ERROR_REG
398 };
399
Sara Sharonf65ebd82016-05-22 16:25:40 +0300400 if (trans->cfg->mq_rx_supported)
401 return iwl_dump_rfh(trans, buf);
402
Inbal Hacohen313b0a22013-06-24 10:35:53 +0300403#ifdef CONFIG_IWLWIFI_DEBUGFS
404 if (buf) {
405 int pos = 0;
406 size_t bufsz = ARRAY_SIZE(fh_tbl) * 48 + 40;
407
408 *buf = kmalloc(bufsz, GFP_KERNEL);
409 if (!*buf)
410 return -ENOMEM;
411
412 pos += scnprintf(*buf + pos, bufsz - pos,
413 "FH register values:\n");
414
415 for (i = 0; i < ARRAY_SIZE(fh_tbl); i++)
416 pos += scnprintf(*buf + pos, bufsz - pos,
417 " %34s: 0X%08x\n",
418 get_fh_string(fh_tbl[i]),
419 iwl_read_direct32(trans, fh_tbl[i]));
420
421 return pos;
422 }
423#endif
424
425 IWL_ERR(trans, "FH register values:\n");
426 for (i = 0; i < ARRAY_SIZE(fh_tbl); i++)
427 IWL_ERR(trans, " %34s: 0X%08x\n",
428 get_fh_string(fh_tbl[i]),
429 iwl_read_direct32(trans, fh_tbl[i]));
430
431 return 0;
432}