blob: 8359027502313da830a1c73e5c57a82465d51bf3 [file] [log] [blame]
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001/*
2 * Marvell Wireless LAN device driver: SDIO specific handling
3 *
4 * Copyright (C) 2011, Marvell International Ltd.
5 *
6 * This software file (the "File") is distributed by Marvell International
7 * Ltd. under the terms of the GNU General Public License Version 2, June 1991
8 * (the "License"). You may use, redistribute and/or modify this File in
9 * accordance with the terms and conditions of the License, a copy of which
10 * is available by writing to the Free Software Foundation, Inc.,
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
13 *
14 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
16 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
17 * this warranty disclaimer.
18 */
19
20#include <linux/firmware.h>
21
22#include "decl.h"
23#include "ioctl.h"
24#include "util.h"
25#include "fw.h"
26#include "main.h"
27#include "wmm.h"
28#include "11n.h"
29#include "sdio.h"
30
31
32#define SDIO_VERSION "1.0"
33
Amitkumar Karwar287546d2011-06-08 20:39:20 +053034/* The mwifiex_sdio_remove() callback function is called when
35 * user removes this module from kernel space or ejects
36 * the card from the slot. The driver handles these 2 cases
37 * differently.
38 * If the user is removing the module, the few commands (FUNC_SHUTDOWN,
39 * HS_CANCEL etc.) are sent to the firmware.
40 * If the card is removed, there is no need to send these command.
41 *
42 * The variable 'user_rmmod' is used to distinguish these two
43 * scenarios. This flag is initialized as FALSE in case the card
44 * is removed, and will be set to TRUE for module removal when
45 * module_exit function is called.
46 */
47static u8 user_rmmod;
48
Bing Zhao5e6e3a92011-03-21 18:00:50 -070049static struct mwifiex_if_ops sdio_ops;
50
51static struct semaphore add_remove_card_sem;
52
Amitkumar Karwar287546d2011-06-08 20:39:20 +053053static int mwifiex_sdio_resume(struct device *dev);
54
Bing Zhao5e6e3a92011-03-21 18:00:50 -070055/*
56 * SDIO probe.
57 *
58 * This function probes an mwifiex device and registers it. It allocates
59 * the card structure, enables SDIO function number and initiates the
60 * device registration and initialization procedure by adding a logical
61 * interface.
62 */
63static int
64mwifiex_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id)
65{
Yogesh Ashok Powar270e58e2011-05-03 20:11:46 -070066 int ret;
Bing Zhao5e6e3a92011-03-21 18:00:50 -070067 struct sdio_mmc_card *card = NULL;
68
69 pr_debug("info: vendor=0x%4.04X device=0x%4.04X class=%d function=%d\n",
70 func->vendor, func->device, func->class, func->num);
71
72 card = kzalloc(sizeof(struct sdio_mmc_card), GFP_KERNEL);
Joe Perchese404dec2012-01-29 12:56:23 +000073 if (!card)
Bing Zhao5e6e3a92011-03-21 18:00:50 -070074 return -ENOMEM;
Bing Zhao5e6e3a92011-03-21 18:00:50 -070075
76 card->func = func;
77
78 func->card->quirks |= MMC_QUIRK_BLKSZ_FOR_BYTE_MODE;
79
80 sdio_claim_host(func);
81 ret = sdio_enable_func(func);
82 sdio_release_host(func);
83
84 if (ret) {
85 pr_err("%s: failed to enable function\n", __func__);
Christoph Fritzb53575e2011-05-08 22:50:09 +020086 kfree(card);
Bing Zhao5e6e3a92011-03-21 18:00:50 -070087 return -EIO;
88 }
89
Amitkumar Karward930fae2011-10-11 17:41:21 -070090 if (mwifiex_add_card(card, &add_remove_card_sem, &sdio_ops,
91 MWIFIEX_SDIO)) {
Bing Zhao5e6e3a92011-03-21 18:00:50 -070092 pr_err("%s: add card failed\n", __func__);
93 kfree(card);
94 sdio_claim_host(func);
95 ret = sdio_disable_func(func);
96 sdio_release_host(func);
97 ret = -1;
98 }
99
100 return ret;
101}
102
103/*
104 * SDIO remove.
105 *
106 * This function removes the interface and frees up the card structure.
107 */
108static void
109mwifiex_sdio_remove(struct sdio_func *func)
110{
111 struct sdio_mmc_card *card;
Amitkumar Karwar287546d2011-06-08 20:39:20 +0530112 struct mwifiex_adapter *adapter;
113 int i;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700114
115 pr_debug("info: SDIO func num=%d\n", func->num);
116
Amitkumar Karwar287546d2011-06-08 20:39:20 +0530117 card = sdio_get_drvdata(func);
118 if (!card)
119 return;
120
121 adapter = card->adapter;
122 if (!adapter || !adapter->priv_num)
123 return;
124
125 if (user_rmmod) {
126 if (adapter->is_suspended)
127 mwifiex_sdio_resume(adapter->dev);
128
129 for (i = 0; i < adapter->priv_num; i++)
130 if ((GET_BSS_ROLE(adapter->priv[i]) ==
131 MWIFIEX_BSS_ROLE_STA) &&
132 adapter->priv[i]->media_connected)
133 mwifiex_deauthenticate(adapter->priv[i], NULL);
134
Amitkumar Karwara0490932011-07-13 20:51:59 -0700135 mwifiex_disable_auto_ds(mwifiex_get_priv(adapter,
136 MWIFIEX_BSS_ROLE_ANY));
137
Amitkumar Karwar287546d2011-06-08 20:39:20 +0530138 mwifiex_init_shutdown_fw(mwifiex_get_priv(adapter,
139 MWIFIEX_BSS_ROLE_ANY),
140 MWIFIEX_FUNC_SHUTDOWN);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700141 }
Amitkumar Karwar287546d2011-06-08 20:39:20 +0530142
143 mwifiex_remove_card(card->adapter, &add_remove_card_sem);
144 kfree(card);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700145}
146
147/*
148 * SDIO suspend.
149 *
150 * Kernel needs to suspend all functions separately. Therefore all
151 * registered functions must have drivers with suspend and resume
152 * methods. Failing that the kernel simply removes the whole card.
153 *
154 * If already not suspended, this function allocates and sends a host
155 * sleep activate request to the firmware and turns off the traffic.
156 */
157static int mwifiex_sdio_suspend(struct device *dev)
158{
159 struct sdio_func *func = dev_to_sdio_func(dev);
160 struct sdio_mmc_card *card;
Yogesh Ashok Powar270e58e2011-05-03 20:11:46 -0700161 struct mwifiex_adapter *adapter;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700162 mmc_pm_flag_t pm_flag = 0;
163 int hs_actived = 0;
164 int i;
165 int ret = 0;
166
167 if (func) {
168 pm_flag = sdio_get_host_pm_caps(func);
169 pr_debug("cmd: %s: suspend: PM flag = 0x%x\n",
170 sdio_func_id(func), pm_flag);
171 if (!(pm_flag & MMC_PM_KEEP_POWER)) {
172 pr_err("%s: cannot remain alive while host is"
173 " suspended\n", sdio_func_id(func));
174 return -ENOSYS;
175 }
176
177 card = sdio_get_drvdata(func);
178 if (!card || !card->adapter) {
179 pr_err("suspend: invalid card or adapter\n");
180 return 0;
181 }
182 } else {
183 pr_err("suspend: sdio_func is not specified\n");
184 return 0;
185 }
186
187 adapter = card->adapter;
188
189 /* Enable the Host Sleep */
190 hs_actived = mwifiex_enable_hs(adapter);
191 if (hs_actived) {
192 pr_debug("cmd: suspend with MMC_PM_KEEP_POWER\n");
193 ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER);
194 }
195
196 /* Indicate device suspended */
197 adapter->is_suspended = true;
198
199 for (i = 0; i < adapter->priv_num; i++)
200 netif_carrier_off(adapter->priv[i]->netdev);
201
202 return ret;
203}
204
205/*
206 * SDIO resume.
207 *
208 * Kernel needs to suspend all functions separately. Therefore all
209 * registered functions must have drivers with suspend and resume
210 * methods. Failing that the kernel simply removes the whole card.
211 *
212 * If already not resumed, this function turns on the traffic and
213 * sends a host sleep cancel request to the firmware.
214 */
215static int mwifiex_sdio_resume(struct device *dev)
216{
217 struct sdio_func *func = dev_to_sdio_func(dev);
218 struct sdio_mmc_card *card;
Yogesh Ashok Powar270e58e2011-05-03 20:11:46 -0700219 struct mwifiex_adapter *adapter;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700220 mmc_pm_flag_t pm_flag = 0;
221 int i;
222
223 if (func) {
224 pm_flag = sdio_get_host_pm_caps(func);
225 card = sdio_get_drvdata(func);
226 if (!card || !card->adapter) {
227 pr_err("resume: invalid card or adapter\n");
228 return 0;
229 }
230 } else {
231 pr_err("resume: sdio_func is not specified\n");
232 return 0;
233 }
234
235 adapter = card->adapter;
236
237 if (!adapter->is_suspended) {
238 dev_warn(adapter->dev, "device already resumed\n");
239 return 0;
240 }
241
242 adapter->is_suspended = false;
243
244 for (i = 0; i < adapter->priv_num; i++)
245 if (adapter->priv[i]->media_connected)
246 netif_carrier_on(adapter->priv[i]->netdev);
247
248 /* Disable Host Sleep */
249 mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA),
Amitkumar Karwar600f5d92011-04-13 17:27:06 -0700250 MWIFIEX_ASYNC_CMD);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700251
252 return 0;
253}
254
255/* Device ID for SD8787 */
256#define SDIO_DEVICE_ID_MARVELL_8787 (0x9119)
Bing Zhaoe3bea1c2011-11-16 20:40:35 -0800257/* Device ID for SD8797 */
258#define SDIO_DEVICE_ID_MARVELL_8797 (0x9129)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700259
260/* WLAN IDs */
261static const struct sdio_device_id mwifiex_ids[] = {
262 {SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8787)},
Bing Zhaoe3bea1c2011-11-16 20:40:35 -0800263 {SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8797)},
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700264 {},
265};
266
267MODULE_DEVICE_TABLE(sdio, mwifiex_ids);
268
269static const struct dev_pm_ops mwifiex_sdio_pm_ops = {
270 .suspend = mwifiex_sdio_suspend,
271 .resume = mwifiex_sdio_resume,
272};
273
274static struct sdio_driver mwifiex_sdio = {
275 .name = "mwifiex_sdio",
276 .id_table = mwifiex_ids,
277 .probe = mwifiex_sdio_probe,
278 .remove = mwifiex_sdio_remove,
279 .drv = {
280 .owner = THIS_MODULE,
281 .pm = &mwifiex_sdio_pm_ops,
282 }
283};
284
285/*
286 * This function writes data into SDIO card register.
287 */
288static int
289mwifiex_write_reg(struct mwifiex_adapter *adapter, u32 reg, u32 data)
290{
291 struct sdio_mmc_card *card = adapter->card;
292 int ret = -1;
293
294 sdio_claim_host(card->func);
295 sdio_writeb(card->func, (u8) data, reg, &ret);
296 sdio_release_host(card->func);
297
298 return ret;
299}
300
301/*
302 * This function reads data from SDIO card register.
303 */
304static int
305mwifiex_read_reg(struct mwifiex_adapter *adapter, u32 reg, u32 *data)
306{
307 struct sdio_mmc_card *card = adapter->card;
308 int ret = -1;
309 u8 val;
310
311 sdio_claim_host(card->func);
312 val = sdio_readb(card->func, reg, &ret);
313 sdio_release_host(card->func);
314
315 *data = val;
316
317 return ret;
318}
319
320/*
321 * This function writes multiple data into SDIO card memory.
322 *
323 * This does not work in suspended mode.
324 */
325static int
326mwifiex_write_data_sync(struct mwifiex_adapter *adapter,
Amitkumar Karwar572e8f32011-04-13 17:27:08 -0700327 u8 *buffer, u32 pkt_len, u32 port)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700328{
329 struct sdio_mmc_card *card = adapter->card;
330 int ret = -1;
331 u8 blk_mode =
332 (port & MWIFIEX_SDIO_BYTE_MODE_MASK) ? BYTE_MODE : BLOCK_MODE;
333 u32 blk_size = (blk_mode == BLOCK_MODE) ? MWIFIEX_SDIO_BLOCK_SIZE : 1;
334 u32 blk_cnt =
335 (blk_mode ==
336 BLOCK_MODE) ? (pkt_len /
337 MWIFIEX_SDIO_BLOCK_SIZE) : pkt_len;
338 u32 ioport = (port & MWIFIEX_SDIO_IO_PORT_MASK);
339
340 if (adapter->is_suspended) {
341 dev_err(adapter->dev,
342 "%s: not allowed while suspended\n", __func__);
343 return -1;
344 }
345
346 sdio_claim_host(card->func);
347
348 if (!sdio_writesb(card->func, ioport, buffer, blk_cnt * blk_size))
349 ret = 0;
350
351 sdio_release_host(card->func);
352
353 return ret;
354}
355
356/*
357 * This function reads multiple data from SDIO card memory.
358 */
Amitkumar Karwar572e8f32011-04-13 17:27:08 -0700359static int mwifiex_read_data_sync(struct mwifiex_adapter *adapter, u8 *buffer,
360 u32 len, u32 port, u8 claim)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700361{
362 struct sdio_mmc_card *card = adapter->card;
363 int ret = -1;
364 u8 blk_mode =
365 (port & MWIFIEX_SDIO_BYTE_MODE_MASK) ? BYTE_MODE : BLOCK_MODE;
366 u32 blk_size = (blk_mode == BLOCK_MODE) ? MWIFIEX_SDIO_BLOCK_SIZE : 1;
367 u32 blk_cnt =
368 (blk_mode ==
369 BLOCK_MODE) ? (len / MWIFIEX_SDIO_BLOCK_SIZE) : len;
370 u32 ioport = (port & MWIFIEX_SDIO_IO_PORT_MASK);
371
372 if (claim)
373 sdio_claim_host(card->func);
374
375 if (!sdio_readsb(card->func, buffer, ioport, blk_cnt * blk_size))
376 ret = 0;
377
378 if (claim)
379 sdio_release_host(card->func);
380
381 return ret;
382}
383
384/*
385 * This function wakes up the card.
386 *
387 * A host power up command is written to the card configuration
388 * register to wake up the card.
389 */
390static int mwifiex_pm_wakeup_card(struct mwifiex_adapter *adapter)
391{
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700392 dev_dbg(adapter->dev, "event: wakeup device...\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700393
Yogesh Ashok Powar636c4592011-04-15 20:50:40 -0700394 return mwifiex_write_reg(adapter, CONFIGURATION_REG, HOST_POWER_UP);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700395}
396
397/*
398 * This function is called after the card has woken up.
399 *
400 * The card configuration register is reset.
401 */
402static int mwifiex_pm_wakeup_card_complete(struct mwifiex_adapter *adapter)
403{
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700404 dev_dbg(adapter->dev, "cmd: wakeup device completed\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700405
Yogesh Ashok Powar636c4592011-04-15 20:50:40 -0700406 return mwifiex_write_reg(adapter, CONFIGURATION_REG, 0);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700407}
408
409/*
410 * This function initializes the IO ports.
411 *
412 * The following operations are performed -
413 * - Read the IO ports (0, 1 and 2)
414 * - Set host interrupt Reset-To-Read to clear
415 * - Set auto re-enable interrupt
416 */
417static int mwifiex_init_sdio_ioport(struct mwifiex_adapter *adapter)
418{
419 u32 reg;
420
421 adapter->ioport = 0;
422
423 /* Read the IO port */
424 if (!mwifiex_read_reg(adapter, IO_PORT_0_REG, &reg))
425 adapter->ioport |= (reg & 0xff);
426 else
427 return -1;
428
429 if (!mwifiex_read_reg(adapter, IO_PORT_1_REG, &reg))
430 adapter->ioport |= ((reg & 0xff) << 8);
431 else
432 return -1;
433
434 if (!mwifiex_read_reg(adapter, IO_PORT_2_REG, &reg))
435 adapter->ioport |= ((reg & 0xff) << 16);
436 else
437 return -1;
438
439 pr_debug("info: SDIO FUNC1 IO port: %#x\n", adapter->ioport);
440
441 /* Set Host interrupt reset to read to clear */
442 if (!mwifiex_read_reg(adapter, HOST_INT_RSR_REG, &reg))
443 mwifiex_write_reg(adapter, HOST_INT_RSR_REG,
444 reg | SDIO_INT_MASK);
445 else
446 return -1;
447
448 /* Dnld/Upld ready set to auto reset */
449 if (!mwifiex_read_reg(adapter, CARD_MISC_CFG_REG, &reg))
450 mwifiex_write_reg(adapter, CARD_MISC_CFG_REG,
451 reg | AUTO_RE_ENABLE_INT);
452 else
453 return -1;
454
455 return 0;
456}
457
458/*
459 * This function sends data to the card.
460 */
461static int mwifiex_write_data_to_card(struct mwifiex_adapter *adapter,
462 u8 *payload, u32 pkt_len, u32 port)
463{
464 u32 i = 0;
Yogesh Ashok Powar270e58e2011-05-03 20:11:46 -0700465 int ret;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700466
467 do {
Amitkumar Karwar572e8f32011-04-13 17:27:08 -0700468 ret = mwifiex_write_data_sync(adapter, payload, pkt_len, port);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700469 if (ret) {
470 i++;
471 dev_err(adapter->dev, "host_to_card, write iomem"
472 " (%d) failed: %d\n", i, ret);
473 if (mwifiex_write_reg(adapter,
474 CONFIGURATION_REG, 0x04))
475 dev_err(adapter->dev, "write CFG reg failed\n");
476
477 ret = -1;
478 if (i > MAX_WRITE_IOMEM_RETRY)
479 return ret;
480 }
481 } while (ret == -1);
482
483 return ret;
484}
485
486/*
487 * This function gets the read port.
488 *
489 * If control port bit is set in MP read bitmap, the control port
490 * is returned, otherwise the current read port is returned and
491 * the value is increased (provided it does not reach the maximum
492 * limit, in which case it is reset to 1)
493 */
494static int mwifiex_get_rd_port(struct mwifiex_adapter *adapter, u8 *port)
495{
496 struct sdio_mmc_card *card = adapter->card;
497 u16 rd_bitmap = card->mp_rd_bitmap;
498
499 dev_dbg(adapter->dev, "data: mp_rd_bitmap=0x%04x\n", rd_bitmap);
500
501 if (!(rd_bitmap & (CTRL_PORT_MASK | DATA_PORT_MASK)))
502 return -1;
503
504 if (card->mp_rd_bitmap & CTRL_PORT_MASK) {
505 card->mp_rd_bitmap &= (u16) (~CTRL_PORT_MASK);
506 *port = CTRL_PORT;
507 dev_dbg(adapter->dev, "data: port=%d mp_rd_bitmap=0x%04x\n",
508 *port, card->mp_rd_bitmap);
509 } else {
510 if (card->mp_rd_bitmap & (1 << card->curr_rd_port)) {
511 card->mp_rd_bitmap &=
512 (u16) (~(1 << card->curr_rd_port));
513 *port = card->curr_rd_port;
514
515 if (++card->curr_rd_port == MAX_PORT)
516 card->curr_rd_port = 1;
517 } else {
518 return -1;
519 }
520
521 dev_dbg(adapter->dev,
522 "data: port=%d mp_rd_bitmap=0x%04x -> 0x%04x\n",
523 *port, rd_bitmap, card->mp_rd_bitmap);
524 }
525 return 0;
526}
527
528/*
529 * This function gets the write port for data.
530 *
531 * The current write port is returned if available and the value is
532 * increased (provided it does not reach the maximum limit, in which
533 * case it is reset to 1)
534 */
535static int mwifiex_get_wr_port_data(struct mwifiex_adapter *adapter, u8 *port)
536{
537 struct sdio_mmc_card *card = adapter->card;
538 u16 wr_bitmap = card->mp_wr_bitmap;
539
540 dev_dbg(adapter->dev, "data: mp_wr_bitmap=0x%04x\n", wr_bitmap);
541
542 if (!(wr_bitmap & card->mp_data_port_mask))
543 return -1;
544
545 if (card->mp_wr_bitmap & (1 << card->curr_wr_port)) {
546 card->mp_wr_bitmap &= (u16) (~(1 << card->curr_wr_port));
547 *port = card->curr_wr_port;
548 if (++card->curr_wr_port == card->mp_end_port)
549 card->curr_wr_port = 1;
550 } else {
551 adapter->data_sent = true;
552 return -EBUSY;
553 }
554
555 if (*port == CTRL_PORT) {
556 dev_err(adapter->dev, "invalid data port=%d cur port=%d"
557 " mp_wr_bitmap=0x%04x -> 0x%04x\n",
558 *port, card->curr_wr_port, wr_bitmap,
559 card->mp_wr_bitmap);
560 return -1;
561 }
562
563 dev_dbg(adapter->dev, "data: port=%d mp_wr_bitmap=0x%04x -> 0x%04x\n",
564 *port, wr_bitmap, card->mp_wr_bitmap);
565
566 return 0;
567}
568
569/*
570 * This function polls the card status.
571 */
572static int
573mwifiex_sdio_poll_card_status(struct mwifiex_adapter *adapter, u8 bits)
574{
575 u32 tries;
Yogesh Ashok Powar270e58e2011-05-03 20:11:46 -0700576 u32 cs;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700577
578 for (tries = 0; tries < MAX_POLL_TRIES; tries++) {
579 if (mwifiex_read_reg(adapter, CARD_STATUS_REG, &cs))
580 break;
581 else if ((cs & bits) == bits)
582 return 0;
583
584 udelay(10);
585 }
586
587 dev_err(adapter->dev, "poll card status failed, tries = %d\n",
588 tries);
589 return -1;
590}
591
592/*
593 * This function reads the firmware status.
594 */
595static int
596mwifiex_sdio_read_fw_status(struct mwifiex_adapter *adapter, u16 *dat)
597{
Yogesh Ashok Powar270e58e2011-05-03 20:11:46 -0700598 u32 fws0, fws1;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700599
600 if (mwifiex_read_reg(adapter, CARD_FW_STATUS0_REG, &fws0))
601 return -1;
602
603 if (mwifiex_read_reg(adapter, CARD_FW_STATUS1_REG, &fws1))
604 return -1;
605
606 *dat = (u16) ((fws1 << 8) | fws0);
607
608 return 0;
609}
610
611/*
612 * This function disables the host interrupt.
613 *
614 * The host interrupt mask is read, the disable bit is reset and
615 * written back to the card host interrupt mask register.
616 */
617static int mwifiex_sdio_disable_host_int(struct mwifiex_adapter *adapter)
618{
Yogesh Ashok Powar270e58e2011-05-03 20:11:46 -0700619 u32 host_int_mask;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700620
621 /* Read back the host_int_mask register */
622 if (mwifiex_read_reg(adapter, HOST_INT_MASK_REG, &host_int_mask))
623 return -1;
624
625 /* Update with the mask and write back to the register */
626 host_int_mask &= ~HOST_INT_DISABLE;
627
628 if (mwifiex_write_reg(adapter, HOST_INT_MASK_REG, host_int_mask)) {
629 dev_err(adapter->dev, "disable host interrupt failed\n");
630 return -1;
631 }
632
633 return 0;
634}
635
636/*
637 * This function enables the host interrupt.
638 *
639 * The host interrupt enable mask is written to the card
640 * host interrupt mask register.
641 */
642static int mwifiex_sdio_enable_host_int(struct mwifiex_adapter *adapter)
643{
644 /* Simply write the mask to the register */
645 if (mwifiex_write_reg(adapter, HOST_INT_MASK_REG, HOST_INT_ENABLE)) {
646 dev_err(adapter->dev, "enable host interrupt failed\n");
647 return -1;
648 }
649 return 0;
650}
651
652/*
653 * This function sends a data buffer to the card.
654 */
655static int mwifiex_sdio_card_to_host(struct mwifiex_adapter *adapter,
656 u32 *type, u8 *buffer,
657 u32 npayload, u32 ioport)
658{
Yogesh Ashok Powar270e58e2011-05-03 20:11:46 -0700659 int ret;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700660 u32 nb;
661
662 if (!buffer) {
663 dev_err(adapter->dev, "%s: buffer is NULL\n", __func__);
664 return -1;
665 }
666
Amitkumar Karwar572e8f32011-04-13 17:27:08 -0700667 ret = mwifiex_read_data_sync(adapter, buffer, npayload, ioport, 1);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700668
669 if (ret) {
670 dev_err(adapter->dev, "%s: read iomem failed: %d\n", __func__,
671 ret);
672 return -1;
673 }
674
675 nb = le16_to_cpu(*(__le16 *) (buffer));
676 if (nb > npayload) {
677 dev_err(adapter->dev, "%s: invalid packet, nb=%d, npayload=%d\n",
678 __func__, nb, npayload);
679 return -1;
680 }
681
682 *type = le16_to_cpu(*(__le16 *) (buffer + 2));
683
684 return ret;
685}
686
687/*
688 * This function downloads the firmware to the card.
689 *
690 * Firmware is downloaded to the card in blocks. Every block download
691 * is tested for CRC errors, and retried a number of times before
692 * returning failure.
693 */
694static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter,
695 struct mwifiex_fw_image *fw)
696{
Yogesh Ashok Powar270e58e2011-05-03 20:11:46 -0700697 int ret;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700698 u8 *firmware = fw->fw_buf;
699 u32 firmware_len = fw->fw_len;
700 u32 offset = 0;
701 u32 base0, base1;
702 u8 *fwbuf;
703 u16 len = 0;
Yogesh Ashok Powar270e58e2011-05-03 20:11:46 -0700704 u32 txlen, tx_blocks = 0, tries;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700705 u32 i = 0;
706
707 if (!firmware_len) {
708 dev_err(adapter->dev, "firmware image not found!"
709 " Terminating download\n");
710 return -1;
711 }
712
713 dev_dbg(adapter->dev, "info: downloading FW image (%d bytes)\n",
714 firmware_len);
715
716 /* Assume that the allocated buffer is 8-byte aligned */
717 fwbuf = kzalloc(MWIFIEX_UPLD_SIZE, GFP_KERNEL);
718 if (!fwbuf) {
719 dev_err(adapter->dev, "unable to alloc buffer for firmware."
720 " Terminating download\n");
Christoph Fritzb53575e2011-05-08 22:50:09 +0200721 return -ENOMEM;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700722 }
723
724 /* Perform firmware data transfer */
725 do {
726 /* The host polls for the DN_LD_CARD_RDY and CARD_IO_READY
727 bits */
728 ret = mwifiex_sdio_poll_card_status(adapter, CARD_IO_READY |
729 DN_LD_CARD_RDY);
730 if (ret) {
731 dev_err(adapter->dev, "FW download with helper:"
732 " poll status timeout @ %d\n", offset);
733 goto done;
734 }
735
736 /* More data? */
737 if (offset >= firmware_len)
738 break;
739
740 for (tries = 0; tries < MAX_POLL_TRIES; tries++) {
741 ret = mwifiex_read_reg(adapter, HOST_F1_RD_BASE_0,
742 &base0);
743 if (ret) {
744 dev_err(adapter->dev, "dev BASE0 register read"
745 " failed: base0=0x%04X(%d). Terminating "
746 "download\n", base0, base0);
747 goto done;
748 }
749 ret = mwifiex_read_reg(adapter, HOST_F1_RD_BASE_1,
750 &base1);
751 if (ret) {
752 dev_err(adapter->dev, "dev BASE1 register read"
753 " failed: base1=0x%04X(%d). Terminating "
754 "download\n", base1, base1);
755 goto done;
756 }
757 len = (u16) (((base1 & 0xff) << 8) | (base0 & 0xff));
758
759 if (len)
760 break;
761
762 udelay(10);
763 }
764
765 if (!len) {
766 break;
767 } else if (len > MWIFIEX_UPLD_SIZE) {
768 dev_err(adapter->dev, "FW download failed @ %d,"
769 " invalid length %d\n", offset, len);
770 ret = -1;
771 goto done;
772 }
773
774 txlen = len;
775
776 if (len & BIT(0)) {
777 i++;
778 if (i > MAX_WRITE_IOMEM_RETRY) {
779 dev_err(adapter->dev, "FW download failed @"
780 " %d, over max retry count\n", offset);
781 ret = -1;
782 goto done;
783 }
784 dev_err(adapter->dev, "CRC indicated by the helper:"
785 " len = 0x%04X, txlen = %d\n", len, txlen);
786 len &= ~BIT(0);
787 /* Setting this to 0 to resend from same offset */
788 txlen = 0;
789 } else {
790 i = 0;
791
792 /* Set blocksize to transfer - checking for last
793 block */
794 if (firmware_len - offset < txlen)
795 txlen = firmware_len - offset;
796
797 tx_blocks = (txlen + MWIFIEX_SDIO_BLOCK_SIZE -
798 1) / MWIFIEX_SDIO_BLOCK_SIZE;
799
800 /* Copy payload to buffer */
801 memmove(fwbuf, &firmware[offset], txlen);
802 }
803
804 ret = mwifiex_write_data_sync(adapter, fwbuf, tx_blocks *
805 MWIFIEX_SDIO_BLOCK_SIZE,
Amitkumar Karwar572e8f32011-04-13 17:27:08 -0700806 adapter->ioport);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700807 if (ret) {
808 dev_err(adapter->dev, "FW download, write iomem (%d)"
809 " failed @ %d\n", i, offset);
810 if (mwifiex_write_reg(adapter, CONFIGURATION_REG, 0x04))
811 dev_err(adapter->dev, "write CFG reg failed\n");
812
813 ret = -1;
814 goto done;
815 }
816
817 offset += txlen;
818 } while (true);
819
820 dev_dbg(adapter->dev, "info: FW download over, size %d bytes\n",
821 offset);
822
823 ret = 0;
824done:
825 kfree(fwbuf);
826 return ret;
827}
828
829/*
830 * This function checks the firmware status in card.
831 *
832 * The winner interface is also determined by this function.
833 */
834static int mwifiex_check_fw_status(struct mwifiex_adapter *adapter,
Amitkumar Karward930fae2011-10-11 17:41:21 -0700835 u32 poll_num)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700836{
837 int ret = 0;
838 u16 firmware_stat;
839 u32 tries;
840 u32 winner_status;
841
842 /* Wait for firmware initialization event */
843 for (tries = 0; tries < poll_num; tries++) {
844 ret = mwifiex_sdio_read_fw_status(adapter, &firmware_stat);
845 if (ret)
846 continue;
Amitkumar Karward930fae2011-10-11 17:41:21 -0700847 if (firmware_stat == FIRMWARE_READY_SDIO) {
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700848 ret = 0;
849 break;
850 } else {
851 mdelay(100);
852 ret = -1;
853 }
854 }
855
Amitkumar Karward930fae2011-10-11 17:41:21 -0700856 if (ret) {
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700857 if (mwifiex_read_reg
858 (adapter, CARD_FW_STATUS0_REG, &winner_status))
859 winner_status = 0;
860
861 if (winner_status)
Amitkumar Karward930fae2011-10-11 17:41:21 -0700862 adapter->winner = 0;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700863 else
Amitkumar Karward930fae2011-10-11 17:41:21 -0700864 adapter->winner = 1;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700865 }
866 return ret;
867}
868
869/*
870 * This function reads the interrupt status from card.
871 */
872static void mwifiex_interrupt_status(struct mwifiex_adapter *adapter)
873{
874 struct sdio_mmc_card *card = adapter->card;
Yogesh Ashok Powar270e58e2011-05-03 20:11:46 -0700875 u32 sdio_ireg;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700876 unsigned long flags;
877
878 if (mwifiex_read_data_sync(adapter, card->mp_regs, MAX_MP_REGS,
Amitkumar Karwar572e8f32011-04-13 17:27:08 -0700879 REG_PORT | MWIFIEX_SDIO_BYTE_MODE_MASK,
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700880 0)) {
881 dev_err(adapter->dev, "read mp_regs failed\n");
882 return;
883 }
884
885 sdio_ireg = card->mp_regs[HOST_INTSTATUS_REG];
886 if (sdio_ireg) {
887 /*
888 * DN_LD_HOST_INT_STATUS and/or UP_LD_HOST_INT_STATUS
889 * Clear the interrupt status register
890 */
891 dev_dbg(adapter->dev, "int: sdio_ireg = %#x\n", sdio_ireg);
892 spin_lock_irqsave(&adapter->int_lock, flags);
893 adapter->int_status |= sdio_ireg;
894 spin_unlock_irqrestore(&adapter->int_lock, flags);
895 }
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700896}
897
898/*
899 * SDIO interrupt handler.
900 *
901 * This function reads the interrupt status from firmware and assigns
902 * the main process in workqueue which will handle the interrupt.
903 */
904static void
905mwifiex_sdio_interrupt(struct sdio_func *func)
906{
907 struct mwifiex_adapter *adapter;
908 struct sdio_mmc_card *card;
909
910 card = sdio_get_drvdata(func);
911 if (!card || !card->adapter) {
912 pr_debug("int: func=%p card=%p adapter=%p\n",
913 func, card, card ? card->adapter : NULL);
914 return;
915 }
916 adapter = card->adapter;
917
918 if (adapter->surprise_removed)
919 return;
920
921 if (!adapter->pps_uapsd_mode && adapter->ps_state == PS_STATE_SLEEP)
922 adapter->ps_state = PS_STATE_AWAKE;
923
924 mwifiex_interrupt_status(adapter);
925 queue_work(adapter->workqueue, &adapter->main_work);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700926}
927
928/*
929 * This function decodes a received packet.
930 *
931 * Based on the type, the packet is treated as either a data, or
932 * a command response, or an event, and the correct handler
933 * function is invoked.
934 */
935static int mwifiex_decode_rx_packet(struct mwifiex_adapter *adapter,
936 struct sk_buff *skb, u32 upld_typ)
937{
938 u8 *cmd_buf;
939
940 skb_pull(skb, INTF_HEADER_LEN);
941
942 switch (upld_typ) {
943 case MWIFIEX_TYPE_DATA:
944 dev_dbg(adapter->dev, "info: --- Rx: Data packet ---\n");
945 mwifiex_handle_rx_packet(adapter, skb);
946 break;
947
948 case MWIFIEX_TYPE_CMD:
949 dev_dbg(adapter->dev, "info: --- Rx: Cmd Response ---\n");
950 /* take care of curr_cmd = NULL case */
951 if (!adapter->curr_cmd) {
952 cmd_buf = adapter->upld_buf;
953
954 if (adapter->ps_state == PS_STATE_SLEEP_CFM)
955 mwifiex_process_sleep_confirm_resp(adapter,
956 skb->data, skb->len);
957
958 memcpy(cmd_buf, skb->data, min_t(u32,
959 MWIFIEX_SIZE_OF_CMD_BUFFER, skb->len));
960
961 dev_kfree_skb_any(skb);
962 } else {
963 adapter->cmd_resp_received = true;
964 adapter->curr_cmd->resp_skb = skb;
965 }
966 break;
967
968 case MWIFIEX_TYPE_EVENT:
969 dev_dbg(adapter->dev, "info: --- Rx: Event ---\n");
970 adapter->event_cause = *(u32 *) skb->data;
971
972 skb_pull(skb, MWIFIEX_EVENT_HEADER_LEN);
973
974 if ((skb->len > 0) && (skb->len < MAX_EVENT_SIZE))
975 memcpy(adapter->event_body, skb->data, skb->len);
976
977 /* event cause has been saved to adapter->event_cause */
978 adapter->event_received = true;
979 adapter->event_skb = skb;
980
981 break;
982
983 default:
984 dev_err(adapter->dev, "unknown upload type %#x\n", upld_typ);
985 dev_kfree_skb_any(skb);
986 break;
987 }
988
989 return 0;
990}
991
992/*
993 * This function transfers received packets from card to driver, performing
994 * aggregation if required.
995 *
996 * For data received on control port, or if aggregation is disabled, the
997 * received buffers are uploaded as separate packets. However, if aggregation
998 * is enabled and required, the buffers are copied onto an aggregation buffer,
999 * provided there is space left, processed and finally uploaded.
1000 */
1001static int mwifiex_sdio_card_to_host_mp_aggr(struct mwifiex_adapter *adapter,
1002 struct sk_buff *skb, u8 port)
1003{
1004 struct sdio_mmc_card *card = adapter->card;
1005 s32 f_do_rx_aggr = 0;
1006 s32 f_do_rx_cur = 0;
1007 s32 f_aggr_cur = 0;
1008 struct sk_buff *skb_deaggr;
Yogesh Ashok Powar270e58e2011-05-03 20:11:46 -07001009 u32 pind;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001010 u32 pkt_len, pkt_type = 0;
1011 u8 *curr_ptr;
1012 u32 rx_len = skb->len;
1013
1014 if (port == CTRL_PORT) {
1015 /* Read the command Resp without aggr */
1016 dev_dbg(adapter->dev, "info: %s: no aggregation for cmd "
1017 "response\n", __func__);
1018
1019 f_do_rx_cur = 1;
1020 goto rx_curr_single;
1021 }
1022
1023 if (!card->mpa_rx.enabled) {
1024 dev_dbg(adapter->dev, "info: %s: rx aggregation disabled\n",
1025 __func__);
1026
1027 f_do_rx_cur = 1;
1028 goto rx_curr_single;
1029 }
1030
1031 if (card->mp_rd_bitmap & (~((u16) CTRL_PORT_MASK))) {
1032 /* Some more data RX pending */
1033 dev_dbg(adapter->dev, "info: %s: not last packet\n", __func__);
1034
1035 if (MP_RX_AGGR_IN_PROGRESS(card)) {
1036 if (MP_RX_AGGR_BUF_HAS_ROOM(card, skb->len)) {
1037 f_aggr_cur = 1;
1038 } else {
1039 /* No room in Aggr buf, do rx aggr now */
1040 f_do_rx_aggr = 1;
1041 f_do_rx_cur = 1;
1042 }
1043 } else {
1044 /* Rx aggr not in progress */
1045 f_aggr_cur = 1;
1046 }
1047
1048 } else {
1049 /* No more data RX pending */
1050 dev_dbg(adapter->dev, "info: %s: last packet\n", __func__);
1051
1052 if (MP_RX_AGGR_IN_PROGRESS(card)) {
1053 f_do_rx_aggr = 1;
1054 if (MP_RX_AGGR_BUF_HAS_ROOM(card, skb->len))
1055 f_aggr_cur = 1;
1056 else
1057 /* No room in Aggr buf, do rx aggr now */
1058 f_do_rx_cur = 1;
1059 } else {
1060 f_do_rx_cur = 1;
1061 }
1062 }
1063
1064 if (f_aggr_cur) {
1065 dev_dbg(adapter->dev, "info: current packet aggregation\n");
1066 /* Curr pkt can be aggregated */
1067 MP_RX_AGGR_SETUP(card, skb, port);
1068
1069 if (MP_RX_AGGR_PKT_LIMIT_REACHED(card) ||
1070 MP_RX_AGGR_PORT_LIMIT_REACHED(card)) {
1071 dev_dbg(adapter->dev, "info: %s: aggregated packet "
1072 "limit reached\n", __func__);
1073 /* No more pkts allowed in Aggr buf, rx it */
1074 f_do_rx_aggr = 1;
1075 }
1076 }
1077
1078 if (f_do_rx_aggr) {
1079 /* do aggr RX now */
1080 dev_dbg(adapter->dev, "info: do_rx_aggr: num of packets: %d\n",
1081 card->mpa_rx.pkt_cnt);
1082
1083 if (mwifiex_read_data_sync(adapter, card->mpa_rx.buf,
1084 card->mpa_rx.buf_len,
1085 (adapter->ioport | 0x1000 |
1086 (card->mpa_rx.ports << 4)) +
Amitkumar Karwar572e8f32011-04-13 17:27:08 -07001087 card->mpa_rx.start_port, 1))
Avinash Patil17a60b42011-12-08 20:41:04 -08001088 goto error;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001089
1090 curr_ptr = card->mpa_rx.buf;
1091
1092 for (pind = 0; pind < card->mpa_rx.pkt_cnt; pind++) {
1093
1094 /* get curr PKT len & type */
1095 pkt_len = *(u16 *) &curr_ptr[0];
1096 pkt_type = *(u16 *) &curr_ptr[2];
1097
1098 /* copy pkt to deaggr buf */
1099 skb_deaggr = card->mpa_rx.skb_arr[pind];
1100
1101 if ((pkt_type == MWIFIEX_TYPE_DATA) && (pkt_len <=
1102 card->mpa_rx.len_arr[pind])) {
1103
1104 memcpy(skb_deaggr->data, curr_ptr, pkt_len);
1105
1106 skb_trim(skb_deaggr, pkt_len);
1107
1108 /* Process de-aggr packet */
1109 mwifiex_decode_rx_packet(adapter, skb_deaggr,
1110 pkt_type);
1111 } else {
1112 dev_err(adapter->dev, "wrong aggr pkt:"
1113 " type=%d len=%d max_len=%d\n",
1114 pkt_type, pkt_len,
1115 card->mpa_rx.len_arr[pind]);
1116 dev_kfree_skb_any(skb_deaggr);
1117 }
1118 curr_ptr += card->mpa_rx.len_arr[pind];
1119 }
1120 MP_RX_AGGR_BUF_RESET(card);
1121 }
1122
1123rx_curr_single:
1124 if (f_do_rx_cur) {
1125 dev_dbg(adapter->dev, "info: RX: port: %d, rx_len: %d\n",
1126 port, rx_len);
1127
1128 if (mwifiex_sdio_card_to_host(adapter, &pkt_type,
1129 skb->data, skb->len,
1130 adapter->ioport + port))
Avinash Patil17a60b42011-12-08 20:41:04 -08001131 goto error;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001132
1133 mwifiex_decode_rx_packet(adapter, skb, pkt_type);
1134 }
1135
1136 return 0;
Avinash Patil17a60b42011-12-08 20:41:04 -08001137
1138error:
1139 if (MP_RX_AGGR_IN_PROGRESS(card)) {
1140 /* Multiport-aggregation transfer failed - cleanup */
1141 for (pind = 0; pind < card->mpa_rx.pkt_cnt; pind++) {
1142 /* copy pkt to deaggr buf */
1143 skb_deaggr = card->mpa_rx.skb_arr[pind];
1144 dev_kfree_skb_any(skb_deaggr);
1145 }
1146 MP_RX_AGGR_BUF_RESET(card);
1147 }
1148
1149 if (f_do_rx_cur)
1150 /* Single transfer pending. Free curr buff also */
1151 dev_kfree_skb_any(skb);
1152
1153 return -1;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001154}
1155
1156/*
1157 * This function checks the current interrupt status.
1158 *
1159 * The following interrupts are checked and handled by this function -
1160 * - Data sent
1161 * - Command sent
1162 * - Packets received
1163 *
1164 * Since the firmware does not generate download ready interrupt if the
1165 * port updated is command port only, command sent interrupt checking
1166 * should be done manually, and for every SDIO interrupt.
1167 *
1168 * In case of Rx packets received, the packets are uploaded from card to
1169 * host and processed accordingly.
1170 */
1171static int mwifiex_process_int_status(struct mwifiex_adapter *adapter)
1172{
1173 struct sdio_mmc_card *card = adapter->card;
1174 int ret = 0;
1175 u8 sdio_ireg;
Yogesh Ashok Powar270e58e2011-05-03 20:11:46 -07001176 struct sk_buff *skb;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001177 u8 port = CTRL_PORT;
1178 u32 len_reg_l, len_reg_u;
1179 u32 rx_blocks;
1180 u16 rx_len;
1181 unsigned long flags;
1182
1183 spin_lock_irqsave(&adapter->int_lock, flags);
1184 sdio_ireg = adapter->int_status;
1185 adapter->int_status = 0;
1186 spin_unlock_irqrestore(&adapter->int_lock, flags);
1187
1188 if (!sdio_ireg)
1189 return ret;
1190
1191 if (sdio_ireg & DN_LD_HOST_INT_STATUS) {
1192 card->mp_wr_bitmap = ((u16) card->mp_regs[WR_BITMAP_U]) << 8;
1193 card->mp_wr_bitmap |= (u16) card->mp_regs[WR_BITMAP_L];
1194 dev_dbg(adapter->dev, "int: DNLD: wr_bitmap=0x%04x\n",
1195 card->mp_wr_bitmap);
1196 if (adapter->data_sent &&
1197 (card->mp_wr_bitmap & card->mp_data_port_mask)) {
1198 dev_dbg(adapter->dev,
1199 "info: <--- Tx DONE Interrupt --->\n");
1200 adapter->data_sent = false;
1201 }
1202 }
1203
1204 /* As firmware will not generate download ready interrupt if the port
1205 updated is command port only, cmd_sent should be done for any SDIO
1206 interrupt. */
1207 if (adapter->cmd_sent) {
1208 /* Check if firmware has attach buffer at command port and
1209 update just that in wr_bit_map. */
1210 card->mp_wr_bitmap |=
1211 (u16) card->mp_regs[WR_BITMAP_L] & CTRL_PORT_MASK;
1212 if (card->mp_wr_bitmap & CTRL_PORT_MASK)
1213 adapter->cmd_sent = false;
1214 }
1215
1216 dev_dbg(adapter->dev, "info: cmd_sent=%d data_sent=%d\n",
1217 adapter->cmd_sent, adapter->data_sent);
1218 if (sdio_ireg & UP_LD_HOST_INT_STATUS) {
1219 card->mp_rd_bitmap = ((u16) card->mp_regs[RD_BITMAP_U]) << 8;
1220 card->mp_rd_bitmap |= (u16) card->mp_regs[RD_BITMAP_L];
1221 dev_dbg(adapter->dev, "int: UPLD: rd_bitmap=0x%04x\n",
1222 card->mp_rd_bitmap);
1223
1224 while (true) {
1225 ret = mwifiex_get_rd_port(adapter, &port);
1226 if (ret) {
1227 dev_dbg(adapter->dev,
1228 "info: no more rd_port available\n");
1229 break;
1230 }
1231 len_reg_l = RD_LEN_P0_L + (port << 1);
1232 len_reg_u = RD_LEN_P0_U + (port << 1);
1233 rx_len = ((u16) card->mp_regs[len_reg_u]) << 8;
1234 rx_len |= (u16) card->mp_regs[len_reg_l];
1235 dev_dbg(adapter->dev, "info: RX: port=%d rx_len=%u\n",
1236 port, rx_len);
1237 rx_blocks =
1238 (rx_len + MWIFIEX_SDIO_BLOCK_SIZE -
1239 1) / MWIFIEX_SDIO_BLOCK_SIZE;
1240 if (rx_len <= INTF_HEADER_LEN
1241 || (rx_blocks * MWIFIEX_SDIO_BLOCK_SIZE) >
1242 MWIFIEX_RX_DATA_BUF_SIZE) {
1243 dev_err(adapter->dev, "invalid rx_len=%d\n",
1244 rx_len);
1245 return -1;
1246 }
1247 rx_len = (u16) (rx_blocks * MWIFIEX_SDIO_BLOCK_SIZE);
1248
1249 skb = dev_alloc_skb(rx_len);
1250
1251 if (!skb) {
1252 dev_err(adapter->dev, "%s: failed to alloc skb",
1253 __func__);
1254 return -1;
1255 }
1256
1257 skb_put(skb, rx_len);
1258
1259 dev_dbg(adapter->dev, "info: rx_len = %d skb->len = %d\n",
1260 rx_len, skb->len);
1261
1262 if (mwifiex_sdio_card_to_host_mp_aggr(adapter, skb,
1263 port)) {
1264 u32 cr = 0;
1265
1266 dev_err(adapter->dev, "card_to_host_mpa failed:"
1267 " int status=%#x\n", sdio_ireg);
1268 if (mwifiex_read_reg(adapter,
1269 CONFIGURATION_REG, &cr))
1270 dev_err(adapter->dev,
1271 "read CFG reg failed\n");
1272
1273 dev_dbg(adapter->dev,
1274 "info: CFG reg val = %d\n", cr);
1275 if (mwifiex_write_reg(adapter,
1276 CONFIGURATION_REG,
1277 (cr | 0x04)))
1278 dev_err(adapter->dev,
1279 "write CFG reg failed\n");
1280
1281 dev_dbg(adapter->dev, "info: write success\n");
1282 if (mwifiex_read_reg(adapter,
1283 CONFIGURATION_REG, &cr))
1284 dev_err(adapter->dev,
1285 "read CFG reg failed\n");
1286
1287 dev_dbg(adapter->dev,
1288 "info: CFG reg val =%x\n", cr);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001289 return -1;
1290 }
1291 }
1292 }
1293
1294 return 0;
1295}
1296
1297/*
1298 * This function aggregates transmission buffers in driver and downloads
1299 * the aggregated packet to card.
1300 *
1301 * The individual packets are aggregated by copying into an aggregation
1302 * buffer and then downloaded to the card. Previous unsent packets in the
1303 * aggregation buffer are pre-copied first before new packets are added.
1304 * Aggregation is done till there is space left in the aggregation buffer,
1305 * or till new packets are available.
1306 *
1307 * The function will only download the packet to the card when aggregation
1308 * stops, otherwise it will just aggregate the packet in aggregation buffer
1309 * and return.
1310 */
1311static int mwifiex_host_to_card_mp_aggr(struct mwifiex_adapter *adapter,
1312 u8 *payload, u32 pkt_len, u8 port,
1313 u32 next_pkt_len)
1314{
1315 struct sdio_mmc_card *card = adapter->card;
1316 int ret = 0;
1317 s32 f_send_aggr_buf = 0;
1318 s32 f_send_cur_buf = 0;
1319 s32 f_precopy_cur_buf = 0;
1320 s32 f_postcopy_cur_buf = 0;
1321
1322 if ((!card->mpa_tx.enabled) || (port == CTRL_PORT)) {
1323 dev_dbg(adapter->dev, "info: %s: tx aggregation disabled\n",
1324 __func__);
1325
1326 f_send_cur_buf = 1;
1327 goto tx_curr_single;
1328 }
1329
1330 if (next_pkt_len) {
1331 /* More pkt in TX queue */
1332 dev_dbg(adapter->dev, "info: %s: more packets in queue.\n",
1333 __func__);
1334
1335 if (MP_TX_AGGR_IN_PROGRESS(card)) {
1336 if (!MP_TX_AGGR_PORT_LIMIT_REACHED(card) &&
1337 MP_TX_AGGR_BUF_HAS_ROOM(card, pkt_len)) {
1338 f_precopy_cur_buf = 1;
1339
1340 if (!(card->mp_wr_bitmap &
1341 (1 << card->curr_wr_port))
1342 || !MP_TX_AGGR_BUF_HAS_ROOM(
Amitkumar Karwardf3b1242011-07-13 20:51:58 -07001343 card, pkt_len + next_pkt_len))
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001344 f_send_aggr_buf = 1;
1345 } else {
1346 /* No room in Aggr buf, send it */
1347 f_send_aggr_buf = 1;
1348
1349 if (MP_TX_AGGR_PORT_LIMIT_REACHED(card) ||
1350 !(card->mp_wr_bitmap &
1351 (1 << card->curr_wr_port)))
1352 f_send_cur_buf = 1;
1353 else
1354 f_postcopy_cur_buf = 1;
1355 }
1356 } else {
1357 if (MP_TX_AGGR_BUF_HAS_ROOM(card, pkt_len)
1358 && (card->mp_wr_bitmap & (1 << card->curr_wr_port)))
1359 f_precopy_cur_buf = 1;
1360 else
1361 f_send_cur_buf = 1;
1362 }
1363 } else {
1364 /* Last pkt in TX queue */
1365 dev_dbg(adapter->dev, "info: %s: Last packet in Tx Queue.\n",
1366 __func__);
1367
1368 if (MP_TX_AGGR_IN_PROGRESS(card)) {
1369 /* some packs in Aggr buf already */
1370 f_send_aggr_buf = 1;
1371
1372 if (MP_TX_AGGR_BUF_HAS_ROOM(card, pkt_len))
1373 f_precopy_cur_buf = 1;
1374 else
1375 /* No room in Aggr buf, send it */
1376 f_send_cur_buf = 1;
1377 } else {
1378 f_send_cur_buf = 1;
1379 }
1380 }
1381
1382 if (f_precopy_cur_buf) {
1383 dev_dbg(adapter->dev, "data: %s: precopy current buffer\n",
1384 __func__);
1385 MP_TX_AGGR_BUF_PUT(card, payload, pkt_len, port);
1386
1387 if (MP_TX_AGGR_PKT_LIMIT_REACHED(card) ||
1388 MP_TX_AGGR_PORT_LIMIT_REACHED(card))
1389 /* No more pkts allowed in Aggr buf, send it */
1390 f_send_aggr_buf = 1;
1391 }
1392
1393 if (f_send_aggr_buf) {
1394 dev_dbg(adapter->dev, "data: %s: send aggr buffer: %d %d\n",
1395 __func__,
1396 card->mpa_tx.start_port, card->mpa_tx.ports);
1397 ret = mwifiex_write_data_to_card(adapter, card->mpa_tx.buf,
1398 card->mpa_tx.buf_len,
1399 (adapter->ioport | 0x1000 |
1400 (card->mpa_tx.ports << 4)) +
1401 card->mpa_tx.start_port);
1402
1403 MP_TX_AGGR_BUF_RESET(card);
1404 }
1405
1406tx_curr_single:
1407 if (f_send_cur_buf) {
1408 dev_dbg(adapter->dev, "data: %s: send current buffer %d\n",
1409 __func__, port);
1410 ret = mwifiex_write_data_to_card(adapter, payload, pkt_len,
1411 adapter->ioport + port);
1412 }
1413
1414 if (f_postcopy_cur_buf) {
1415 dev_dbg(adapter->dev, "data: %s: postcopy current buffer\n",
1416 __func__);
1417 MP_TX_AGGR_BUF_PUT(card, payload, pkt_len, port);
1418 }
1419
1420 return ret;
1421}
1422
1423/*
1424 * This function downloads data from driver to card.
1425 *
1426 * Both commands and data packets are transferred to the card by this
1427 * function.
1428 *
1429 * This function adds the SDIO specific header to the front of the buffer
1430 * before transferring. The header contains the length of the packet and
1431 * the type. The firmware handles the packets based upon this set type.
1432 */
1433static int mwifiex_sdio_host_to_card(struct mwifiex_adapter *adapter,
Amitkumar Karward930fae2011-10-11 17:41:21 -07001434 u8 type, struct sk_buff *skb,
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001435 struct mwifiex_tx_param *tx_param)
1436{
1437 struct sdio_mmc_card *card = adapter->card;
Yogesh Ashok Powar270e58e2011-05-03 20:11:46 -07001438 int ret;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001439 u32 buf_block_len;
1440 u32 blk_size;
1441 u8 port = CTRL_PORT;
Amitkumar Karward930fae2011-10-11 17:41:21 -07001442 u8 *payload = (u8 *)skb->data;
1443 u32 pkt_len = skb->len;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001444
1445 /* Allocate buffer and copy payload */
1446 blk_size = MWIFIEX_SDIO_BLOCK_SIZE;
1447 buf_block_len = (pkt_len + blk_size - 1) / blk_size;
1448 *(u16 *) &payload[0] = (u16) pkt_len;
1449 *(u16 *) &payload[2] = type;
1450
1451 /*
1452 * This is SDIO specific header
1453 * u16 length,
1454 * u16 type (MWIFIEX_TYPE_DATA = 0, MWIFIEX_TYPE_CMD = 1,
1455 * MWIFIEX_TYPE_EVENT = 3)
1456 */
1457 if (type == MWIFIEX_TYPE_DATA) {
1458 ret = mwifiex_get_wr_port_data(adapter, &port);
1459 if (ret) {
1460 dev_err(adapter->dev, "%s: no wr_port available\n",
1461 __func__);
1462 return ret;
1463 }
1464 } else {
1465 adapter->cmd_sent = true;
1466 /* Type must be MWIFIEX_TYPE_CMD */
1467
1468 if (pkt_len <= INTF_HEADER_LEN ||
1469 pkt_len > MWIFIEX_UPLD_SIZE)
1470 dev_err(adapter->dev, "%s: payload=%p, nb=%d\n",
1471 __func__, payload, pkt_len);
1472 }
1473
1474 /* Transfer data to card */
1475 pkt_len = buf_block_len * blk_size;
1476
1477 if (tx_param)
1478 ret = mwifiex_host_to_card_mp_aggr(adapter, payload, pkt_len,
1479 port, tx_param->next_pkt_len);
1480 else
1481 ret = mwifiex_host_to_card_mp_aggr(adapter, payload, pkt_len,
1482 port, 0);
1483
1484 if (ret) {
1485 if (type == MWIFIEX_TYPE_CMD)
1486 adapter->cmd_sent = false;
1487 if (type == MWIFIEX_TYPE_DATA)
1488 adapter->data_sent = false;
1489 } else {
1490 if (type == MWIFIEX_TYPE_DATA) {
1491 if (!(card->mp_wr_bitmap & (1 << card->curr_wr_port)))
1492 adapter->data_sent = true;
1493 else
1494 adapter->data_sent = false;
1495 }
1496 }
1497
1498 return ret;
1499}
1500
1501/*
1502 * This function allocates the MPA Tx and Rx buffers.
1503 */
1504static int mwifiex_alloc_sdio_mpa_buffers(struct mwifiex_adapter *adapter,
1505 u32 mpa_tx_buf_size, u32 mpa_rx_buf_size)
1506{
1507 struct sdio_mmc_card *card = adapter->card;
1508 int ret = 0;
1509
1510 card->mpa_tx.buf = kzalloc(mpa_tx_buf_size, GFP_KERNEL);
1511 if (!card->mpa_tx.buf) {
1512 dev_err(adapter->dev, "could not alloc buffer for MP-A TX\n");
1513 ret = -1;
1514 goto error;
1515 }
1516
1517 card->mpa_tx.buf_size = mpa_tx_buf_size;
1518
1519 card->mpa_rx.buf = kzalloc(mpa_rx_buf_size, GFP_KERNEL);
1520 if (!card->mpa_rx.buf) {
1521 dev_err(adapter->dev, "could not alloc buffer for MP-A RX\n");
1522 ret = -1;
1523 goto error;
1524 }
1525
1526 card->mpa_rx.buf_size = mpa_rx_buf_size;
1527
1528error:
1529 if (ret) {
1530 kfree(card->mpa_tx.buf);
1531 kfree(card->mpa_rx.buf);
1532 }
1533
1534 return ret;
1535}
1536
1537/*
1538 * This function unregisters the SDIO device.
1539 *
1540 * The SDIO IRQ is released, the function is disabled and driver
1541 * data is set to null.
1542 */
1543static void
1544mwifiex_unregister_dev(struct mwifiex_adapter *adapter)
1545{
1546 struct sdio_mmc_card *card = adapter->card;
1547
1548 if (adapter->card) {
1549 /* Release the SDIO IRQ */
1550 sdio_claim_host(card->func);
1551 sdio_release_irq(card->func);
1552 sdio_disable_func(card->func);
1553 sdio_release_host(card->func);
1554 sdio_set_drvdata(card->func, NULL);
1555 }
1556}
1557
1558/*
1559 * This function registers the SDIO device.
1560 *
1561 * SDIO IRQ is claimed, block size is set and driver data is initialized.
1562 */
1563static int mwifiex_register_dev(struct mwifiex_adapter *adapter)
1564{
1565 int ret = 0;
1566 struct sdio_mmc_card *card = adapter->card;
1567 struct sdio_func *func = card->func;
1568
1569 /* save adapter pointer in card */
1570 card->adapter = adapter;
1571
1572 sdio_claim_host(func);
1573
1574 /* Request the SDIO IRQ */
1575 ret = sdio_claim_irq(func, mwifiex_sdio_interrupt);
1576 if (ret) {
1577 pr_err("claim irq failed: ret=%d\n", ret);
1578 goto disable_func;
1579 }
1580
1581 /* Set block size */
1582 ret = sdio_set_block_size(card->func, MWIFIEX_SDIO_BLOCK_SIZE);
1583 if (ret) {
1584 pr_err("cannot set SDIO block size\n");
1585 ret = -1;
1586 goto release_irq;
1587 }
1588
1589 sdio_release_host(func);
1590 sdio_set_drvdata(func, card);
1591
1592 adapter->dev = &func->dev;
Bing Zhaoe3bea1c2011-11-16 20:40:35 -08001593
1594 switch (func->device) {
1595 case SDIO_DEVICE_ID_MARVELL_8797:
1596 strcpy(adapter->fw_name, SD8797_DEFAULT_FW_NAME);
1597 break;
1598 case SDIO_DEVICE_ID_MARVELL_8787:
1599 default:
1600 strcpy(adapter->fw_name, SD8787_DEFAULT_FW_NAME);
1601 break;
1602 }
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001603
1604 return 0;
1605
1606release_irq:
1607 sdio_release_irq(func);
1608disable_func:
1609 sdio_disable_func(func);
1610 sdio_release_host(func);
1611 adapter->card = NULL;
1612
1613 return -1;
1614}
1615
1616/*
1617 * This function initializes the SDIO driver.
1618 *
1619 * The following initializations steps are followed -
1620 * - Read the Host interrupt status register to acknowledge
1621 * the first interrupt got from bootloader
1622 * - Disable host interrupt mask register
1623 * - Get SDIO port
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001624 * - Initialize SDIO variables in card
1625 * - Allocate MP registers
1626 * - Allocate MPA Tx and Rx buffers
1627 */
1628static int mwifiex_init_sdio(struct mwifiex_adapter *adapter)
1629{
1630 struct sdio_mmc_card *card = adapter->card;
1631 int ret;
Yogesh Ashok Powar270e58e2011-05-03 20:11:46 -07001632 u32 sdio_ireg;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001633
1634 /*
1635 * Read the HOST_INT_STATUS_REG for ACK the first interrupt got
1636 * from the bootloader. If we don't do this we get a interrupt
1637 * as soon as we register the irq.
1638 */
1639 mwifiex_read_reg(adapter, HOST_INTSTATUS_REG, &sdio_ireg);
1640
1641 /* Disable host interrupt mask register for SDIO */
1642 mwifiex_sdio_disable_host_int(adapter);
1643
1644 /* Get SDIO ioport */
1645 mwifiex_init_sdio_ioport(adapter);
1646
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001647 /* Initialize SDIO variables in card */
1648 card->mp_rd_bitmap = 0;
1649 card->mp_wr_bitmap = 0;
1650 card->curr_rd_port = 1;
1651 card->curr_wr_port = 1;
1652
1653 card->mp_data_port_mask = DATA_PORT_MASK;
1654
1655 card->mpa_tx.buf_len = 0;
1656 card->mpa_tx.pkt_cnt = 0;
1657 card->mpa_tx.start_port = 0;
1658
Amitkumar Karwar7d7ab022011-11-07 19:31:46 -08001659 card->mpa_tx.enabled = 1;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001660 card->mpa_tx.pkt_aggr_limit = SDIO_MP_AGGR_DEF_PKT_LIMIT;
1661
1662 card->mpa_rx.buf_len = 0;
1663 card->mpa_rx.pkt_cnt = 0;
1664 card->mpa_rx.start_port = 0;
1665
Amitkumar Karwar7d7ab022011-11-07 19:31:46 -08001666 card->mpa_rx.enabled = 1;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001667 card->mpa_rx.pkt_aggr_limit = SDIO_MP_AGGR_DEF_PKT_LIMIT;
1668
1669 /* Allocate buffers for SDIO MP-A */
1670 card->mp_regs = kzalloc(MAX_MP_REGS, GFP_KERNEL);
1671 if (!card->mp_regs) {
1672 dev_err(adapter->dev, "failed to alloc mp_regs\n");
Christoph Fritzb53575e2011-05-08 22:50:09 +02001673 return -ENOMEM;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001674 }
1675
1676 ret = mwifiex_alloc_sdio_mpa_buffers(adapter,
1677 SDIO_MP_TX_AGGR_DEF_BUF_SIZE,
1678 SDIO_MP_RX_AGGR_DEF_BUF_SIZE);
1679 if (ret) {
1680 dev_err(adapter->dev, "failed to alloc sdio mp-a buffers\n");
1681 kfree(card->mp_regs);
1682 return -1;
1683 }
1684
1685 return ret;
1686}
1687
1688/*
1689 * This function resets the MPA Tx and Rx buffers.
1690 */
1691static void mwifiex_cleanup_mpa_buf(struct mwifiex_adapter *adapter)
1692{
1693 struct sdio_mmc_card *card = adapter->card;
1694
1695 MP_TX_AGGR_BUF_RESET(card);
1696 MP_RX_AGGR_BUF_RESET(card);
1697}
1698
1699/*
1700 * This function cleans up the allocated card buffers.
1701 *
1702 * The following are freed by this function -
1703 * - MP registers
1704 * - MPA Tx buffer
1705 * - MPA Rx buffer
1706 */
1707static void mwifiex_cleanup_sdio(struct mwifiex_adapter *adapter)
1708{
1709 struct sdio_mmc_card *card = adapter->card;
1710
1711 kfree(card->mp_regs);
1712 kfree(card->mpa_tx.buf);
1713 kfree(card->mpa_rx.buf);
1714}
1715
1716/*
1717 * This function updates the MP end port in card.
1718 */
1719static void
1720mwifiex_update_mp_end_port(struct mwifiex_adapter *adapter, u16 port)
1721{
1722 struct sdio_mmc_card *card = adapter->card;
1723 int i;
1724
1725 card->mp_end_port = port;
1726
1727 card->mp_data_port_mask = DATA_PORT_MASK;
1728
1729 for (i = 1; i <= MAX_PORT - card->mp_end_port; i++)
1730 card->mp_data_port_mask &= ~(1 << (MAX_PORT - i));
1731
1732 card->curr_wr_port = 1;
1733
1734 dev_dbg(adapter->dev, "cmd: mp_end_port %d, data port mask 0x%x\n",
1735 port, card->mp_data_port_mask);
1736}
1737
1738static struct mwifiex_if_ops sdio_ops = {
1739 .init_if = mwifiex_init_sdio,
1740 .cleanup_if = mwifiex_cleanup_sdio,
1741 .check_fw_status = mwifiex_check_fw_status,
1742 .prog_fw = mwifiex_prog_fw_w_helper,
1743 .register_dev = mwifiex_register_dev,
1744 .unregister_dev = mwifiex_unregister_dev,
1745 .enable_int = mwifiex_sdio_enable_host_int,
1746 .process_int_status = mwifiex_process_int_status,
1747 .host_to_card = mwifiex_sdio_host_to_card,
1748 .wakeup = mwifiex_pm_wakeup_card,
1749 .wakeup_complete = mwifiex_pm_wakeup_card_complete,
1750
1751 /* SDIO specific */
1752 .update_mp_end_port = mwifiex_update_mp_end_port,
1753 .cleanup_mpa_buf = mwifiex_cleanup_mpa_buf,
Amitkumar Karward930fae2011-10-11 17:41:21 -07001754 .cmdrsp_complete = mwifiex_sdio_cmdrsp_complete,
1755 .event_complete = mwifiex_sdio_event_complete,
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001756};
1757
1758/*
1759 * This function initializes the SDIO driver.
1760 *
1761 * This initiates the semaphore and registers the device with
1762 * SDIO bus.
1763 */
1764static int
1765mwifiex_sdio_init_module(void)
1766{
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001767 sema_init(&add_remove_card_sem, 1);
1768
Amitkumar Karwar287546d2011-06-08 20:39:20 +05301769 /* Clear the flag in case user removes the card. */
1770 user_rmmod = 0;
1771
Yogesh Ashok Powar636c4592011-04-15 20:50:40 -07001772 return sdio_register_driver(&mwifiex_sdio);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001773}
1774
1775/*
1776 * This function cleans up the SDIO driver.
1777 *
1778 * The following major steps are followed for cleanup -
1779 * - Resume the device if its suspended
1780 * - Disconnect the device if connected
1781 * - Shutdown the firmware
1782 * - Unregister the device from SDIO bus.
1783 */
1784static void
1785mwifiex_sdio_cleanup_module(void)
1786{
Amitkumar Karwar287546d2011-06-08 20:39:20 +05301787 if (!down_interruptible(&add_remove_card_sem))
1788 up(&add_remove_card_sem);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001789
Amitkumar Karwar287546d2011-06-08 20:39:20 +05301790 /* Set the flag as user is removing this module. */
1791 user_rmmod = 1;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001792
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001793 sdio_unregister_driver(&mwifiex_sdio);
1794}
1795
1796module_init(mwifiex_sdio_init_module);
1797module_exit(mwifiex_sdio_cleanup_module);
1798
1799MODULE_AUTHOR("Marvell International Ltd.");
1800MODULE_DESCRIPTION("Marvell WiFi-Ex SDIO Driver version " SDIO_VERSION);
1801MODULE_VERSION(SDIO_VERSION);
1802MODULE_LICENSE("GPL v2");
Bing Zhaoe3bea1c2011-11-16 20:40:35 -08001803MODULE_FIRMWARE(SD8787_DEFAULT_FW_NAME);
1804MODULE_FIRMWARE(SD8797_DEFAULT_FW_NAME);