1 diff -Naur backports-3.18.1-1.org/drivers/net/wireless/Kconfig backports-3.18.1-1/drivers/net/wireless/Kconfig
2 --- backports-3.18.1-1.org/drivers/net/wireless/Kconfig 2014-12-21 22:37:15.000000000 +0100
3 +++ backports-3.18.1-1/drivers/net/wireless/Kconfig 2014-12-29 20:37:43.945764119 +0100
6 A driver for Marvell Libertas 8388 USB devices using thinfirm.
9 + tristate "Marvell 8xxx Libertas UAP"
14 + Driver for Marvell Libertas 8xxx micro AP.
18 tristate "Cisco/Aironet 34X/35X/4500/4800 ISA and PCI cards"
19 diff -Naur backports-3.18.1-1.org/drivers/net/wireless/libertas_uap/Makefile backports-3.18.1-1/drivers/net/wireless/libertas_uap/Makefile
20 --- backports-3.18.1-1.org/drivers/net/wireless/libertas_uap/Makefile 1970-01-01 01:00:00.000000000 +0100
21 +++ backports-3.18.1-1/drivers/net/wireless/libertas_uap/Makefile 2014-12-29 20:41:50.975778546 +0100
23 +obj-$(CPTCFG_LIBERTAS_UAP) += uap8xxx.o
25 +uap8xxx-y += uap_main.o uap_sdio_mmc.o
26 +uap8xxx-$(CPTCFG_PROC_FS) += uap_proc.o uap_debug.o
28 +EXTRA_CFLAGS += -DFPNUM='"52"' -DPXA3XX_DMA_ALIGN -DDEBUG_LEVEL1
29 diff -Naur backports-3.18.1-1.org/drivers/net/wireless/libertas_uap/uap_debug.c backports-3.18.1-1/drivers/net/wireless/libertas_uap/uap_debug.c
30 --- backports-3.18.1-1.org/drivers/net/wireless/libertas_uap/uap_debug.c 1970-01-01 01:00:00.000000000 +0100
31 +++ backports-3.18.1-1/drivers/net/wireless/libertas_uap/uap_debug.c 2014-12-29 20:37:43.949097590 +0100
33 +/** @file uap_debug.c
34 + * @brief This file contains functions for debug proc file.
36 + * Copyright (C) 2008-2009, Marvell International Ltd.
38 + * This software file (the "File") is distributed by Marvell International
39 + * Ltd. under the terms of the GNU General Public License Version 2, June 1991
40 + * (the "License"). You may use, redistribute and/or modify this File in
41 + * accordance with the terms and conditions of the License, a copy of which
42 + * is available along with the File in the gpl.txt file or by writing to
43 + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
44 + * 02111-1307 or on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
46 + * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
47 + * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
48 + * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
49 + * this warranty disclaimer.
52 +#ifdef CONFIG_PROC_FS
53 +#include "uap_headers.h"
55 +/********************************************************
57 +********************************************************/
59 +#define item_size(n) (sizeof ((uap_adapter *)0)->n)
60 +#define item_addr(n) ((u32) &((uap_adapter *)0)->n)
62 +#define item_dbg_size(n) (sizeof (((uap_adapter *)0)->dbg.n))
63 +#define item_dbg_addr(n) ((u32) &(((uap_adapter *)0)->dbg.n))
65 +#define item_dev_size(n) (sizeof ((uap_dev_t *)0)->n)
66 +#define item_dev_addr(n) ((u32) &((uap_dev_t *)0)->n)
68 +/** MicroAp device offset */
69 +#define OFFSET_UAP_DEV 0x01
70 +/** Bluetooth adapter offset */
71 +#define OFFSET_UAP_ADAPTER 0x02
87 +/* To debug any member of uap_adapter, simply add one line here.
89 +static struct debug_data items[] = {
90 + {"cmd_sent", item_dev_size(cmd_sent), 0, item_dev_addr(cmd_sent),
92 + {"data_sent", item_dev_size(data_sent), 0, item_dev_addr(data_sent),
94 + {"IntCounter", item_size(IntCounter), 0, item_addr(IntCounter),
95 + OFFSET_UAP_ADAPTER},
96 + {"cmd_pending", item_size(cmd_pending), 0, item_addr(cmd_pending),
97 + OFFSET_UAP_ADAPTER},
98 + {"num_cmd_h2c_fail", item_dbg_size(num_cmd_host_to_card_failure), 0,
99 + item_dbg_addr(num_cmd_host_to_card_failure), OFFSET_UAP_ADAPTER},
100 + {"num_tx_h2c_fail", item_dbg_size(num_tx_host_to_card_failure), 0,
101 + item_dbg_addr(num_tx_host_to_card_failure), OFFSET_UAP_ADAPTER},
102 + {"psmode", item_size(psmode), 0, item_addr(psmode), OFFSET_UAP_ADAPTER},
103 + {"ps_state", item_size(ps_state), 0, item_addr(ps_state),
104 + OFFSET_UAP_ADAPTER},
106 + {"drvdbg", sizeof(drvdbg), (u32) & drvdbg, 0, 0}
110 +static int num_of_items = sizeof(items) / sizeof(items[0]);
112 +/********************************************************
114 +********************************************************/
116 +/********************************************************
118 +********************************************************/
120 + * @brief proc read function
122 + * @param page pointer to buffer
123 + * @param s read data starting position
124 + * @param off offset
125 + * @param cnt counter
126 + * @param eof end of file flag
127 + * @param data data to output
128 + * @return number of output data
130 +static int uap_debug_proc_show(struct seq_file *s, void *data) {
134 + struct debug_data *d = (struct debug_data *)s->private;
136 + if (MODULE_GET == 0)
137 + return UAP_STATUS_FAILURE;
139 + for (i = 0; i < num_of_items; i++) {
140 + if (d[i].size == 1)
141 + val = *((u8 *) d[i].addr);
142 + else if (d[i].size == 2)
143 + val = *((u16 *) d[i].addr);
144 + else if (d[i].size == 4)
145 + val = *((u32 *) d[i].addr);
147 + seq_printf(s, "%s=%d\n", d[i].name, val);
153 +static int uap_debug_proc_open(struct inode* inode, struct file* file) {
154 + return single_open(file, uap_debug_proc_show, PDE_DATA(inode));
158 + * @brief proc write function
160 + * @param f file pointer
161 + * @param buf pointer to data buffer
162 + * @param cnt data number to write
163 + * @param data data to write
164 + * @return number of data
166 +static ssize_t uap_debug_proc_write(struct file *f, const char __user *buf, size_t cnt, loff_t *data) {
173 + struct debug_data *d = (struct debug_data *)PDE_DATA(file_inode(f));
175 + if (MODULE_GET == 0)
176 + return UAP_STATUS_FAILURE;
178 + pdata = (char *) kmalloc(cnt, GFP_KERNEL);
179 + if (pdata == NULL) {
184 + if (copy_from_user(pdata, buf, cnt)) {
185 + PRINTM(INFO, "Copy from user failed\n");
192 + for (i = 0; i < num_of_items; i++) {
194 + p = strstr(p0, d[i].name);
197 + p1 = strchr(p, '\n');
201 + p2 = strchr(p, '=');
205 + r = string_to_number(p2);
206 + if (d[i].size == 1)
207 + *((u8 *) d[i].addr) = (u8) r;
208 + else if (d[i].size == 2)
209 + *((u16 *) d[i].addr) = (u16) r;
210 + else if (d[i].size == 4)
211 + *((u32 *) d[i].addr) = (u32) r;
217 + printk(KERN_ALERT "drvdbg = 0x%x\n", drvdbg);
218 + printk(KERN_ALERT "INFO (%08lx) %s\n", DBG_INFO,
219 + (drvdbg & DBG_INFO) ? "X" : "");
220 + printk(KERN_ALERT "WARN (%08lx) %s\n", DBG_WARN,
221 + (drvdbg & DBG_WARN) ? "X" : "");
222 + printk(KERN_ALERT "ENTRY (%08lx) %s\n", DBG_ENTRY,
223 + (drvdbg & DBG_ENTRY) ? "X" : "");
224 + printk(KERN_ALERT "CMD_D (%08lx) %s\n", DBG_CMD_D,
225 + (drvdbg & DBG_CMD_D) ? "X" : "");
226 + printk(KERN_ALERT "DAT_D (%08lx) %s\n", DBG_DAT_D,
227 + (drvdbg & DBG_DAT_D) ? "X" : "");
228 + printk(KERN_ALERT "CMND (%08lx) %s\n", DBG_CMND,
229 + (drvdbg & DBG_CMND) ? "X" : "");
230 + printk(KERN_ALERT "DATA (%08lx) %s\n", DBG_DATA,
231 + (drvdbg & DBG_DATA) ? "X" : "");
232 + printk(KERN_ALERT "ERROR (%08lx) %s\n", DBG_ERROR,
233 + (drvdbg & DBG_ERROR) ? "X" : "");
234 + printk(KERN_ALERT "FATAL (%08lx) %s\n", DBG_FATAL,
235 + (drvdbg & DBG_FATAL) ? "X" : "");
236 + printk(KERN_ALERT "MSG (%08lx) %s\n", DBG_MSG,
237 + (drvdbg & DBG_MSG) ? "X" : "");
243 +static const struct file_operations uap_debug_proc_fops = {
244 + .owner = THIS_MODULE,
245 + .open = uap_debug_proc_open,
247 + .llseek = seq_lseek,
248 + .release = single_release,
249 + .write = uap_debug_proc_write,
252 +/********************************************************
254 +********************************************************/
256 + * @brief create debug proc file
258 + * @param priv pointer uap_private
259 + * @param dev pointer net_device
263 +uap_debug_entry(uap_private * priv, struct net_device *dev)
267 + if (priv->proc_entry == NULL)
270 + for (i = 0; i < num_of_items; i++) {
271 + if (items[i].flag & OFFSET_UAP_ADAPTER)
272 + items[i].addr = items[i].offset + (u32) priv->adapter;
273 + if (items[i].flag & OFFSET_UAP_DEV)
274 + items[i].addr = items[i].offset + (u32) & priv->uap_dev;
276 + proc_create_data("debug", 0644, priv->proc_entry, &uap_debug_proc_fops,
281 + * @brief remove proc file
283 + * @param priv pointer uap_private
287 +uap_debug_remove(uap_private * priv)
289 + remove_proc_entry("debug", priv->proc_entry);
293 diff -Naur backports-3.18.1-1.org/drivers/net/wireless/libertas_uap/uap_drv.h backports-3.18.1-1/drivers/net/wireless/libertas_uap/uap_drv.h
294 --- backports-3.18.1-1.org/drivers/net/wireless/libertas_uap/uap_drv.h 1970-01-01 01:00:00.000000000 +0100
295 +++ backports-3.18.1-1/drivers/net/wireless/libertas_uap/uap_drv.h 2014-12-29 20:37:43.949097590 +0100
298 + * @brief This file contains Linux OS related definitions and
299 + * declarations, uAP driver
301 + * Copyright (C) 2008-2009, Marvell International Ltd.
303 + * This software file (the "File") is distributed by Marvell International
304 + * Ltd. under the terms of the GNU General Public License Version 2, June 1991
305 + * (the "License"). You may use, redistribute and/or modify this File in
306 + * accordance with the terms and conditions of the License, a copy of which
307 + * is available along with the File in the gpl.txt file or by writing to
308 + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
309 + * 02111-1307 or on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
311 + * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
312 + * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
313 + * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
314 + * this warranty disclaimer.
321 +/** Driver release version */
322 +#define DRIVER_VERSION "26146"
333 +/** Bit definitions */
335 +#define BIT(x) (1UL << (x))
338 +/** Dma addresses are 32-bits wide. */
339 +#ifndef __ATTRIB_ALIGN__
340 +#define __ATTRIB_ALIGN__ __attribute__((aligned(4)))
343 +/** attribute pack */
344 +#ifndef __ATTRIB_PACK__
345 +#define __ATTRIB_PACK__ __attribute__ ((packed))
348 +/** Debug Macro definition*/
353 +/** Debug message control bit definition for drvdbg */
354 +/** Debug message */
355 +#define DBG_MSG BIT(0)
356 +/** Debug fatal message */
357 +#define DBG_FATAL BIT(1)
358 +/** Debug error message */
359 +#define DBG_ERROR BIT(2)
360 +/** Debug data message */
361 +#define DBG_DATA BIT(3)
362 +/** Debug command message */
363 +#define DBG_CMND BIT(4)
366 +#define DBG_DAT_D BIT(16)
367 +/** Debug command */
368 +#define DBG_CMD_D BIT(17)
371 +#define DBG_ENTRY BIT(28)
372 +/** Debug warning */
373 +#define DBG_WARN BIT(29)
375 +#define DBG_INFO BIT(30)
378 +#define PRINTM_INFO(msg...) {if (drvdbg & DBG_INFO) printk(KERN_DEBUG msg);}
379 +/** Print warn message */
380 +#define PRINTM_WARN(msg...) {if (drvdbg & DBG_WARN) printk(KERN_DEBUG msg);}
382 +#define PRINTM_ENTRY(msg...) {if (drvdbg & DBG_ENTRY) printk(KERN_DEBUG msg);}
384 +#define PRINTM_CMD_D(msg...) {if (drvdbg & DBG_CMD_D) printk(KERN_DEBUG msg);}
386 +#define PRINTM_DAT_D(msg...) {if (drvdbg & DBG_DAT_D) printk(KERN_DEBUG msg);}
387 +/** Print command */
388 +#define PRINTM_CMND(msg...) {if (drvdbg & DBG_CMND) printk(KERN_DEBUG msg);}
390 +#define PRINTM_DATA(msg...) {if (drvdbg & DBG_DATA) printk(KERN_DEBUG msg);}
391 +/** Print error message */
392 +#define PRINTM_ERROR(msg...) {if (drvdbg & DBG_ERROR) printk(KERN_DEBUG msg);}
393 +/** Print fatal message */
394 +#define PRINTM_FATAL(msg...) {if (drvdbg & DBG_FATAL) printk(KERN_DEBUG msg);}
395 +/** Print message */
396 +#define PRINTM_MSG(msg...) {if (drvdbg & DBG_MSG) printk(KERN_ALERT msg);}
398 +#define PRINTM(level,msg...) PRINTM_##level(msg)
402 +#define PRINTM(level,msg...) do {} while (0)
404 +#endif /* DEBUG_LEVEL1 */
406 +/** Wait until a condition becomes true */
407 +#define ASSERT(cond) \
410 + PRINTM(INFO, "ASSERT: %s, %s:%i\n", \
411 + __FUNCTION__, __FILE__, __LINE__); \
414 +/** Log enrty point for debugging */
415 +#define ENTER() PRINTM(ENTRY, "Enter: %s, %s:%i\n", __FUNCTION__, \
416 + __FILE__, __LINE__)
417 +/** Log exit point for debugging */
418 +#define LEAVE() PRINTM(ENTRY, "Leave: %s, %s:%i\n", __FUNCTION__, \
419 + __FILE__, __LINE__)
422 +/** Dump buffer length */
423 +#define DBG_DUMP_BUF_LEN 64
424 +/** Maximum dump per line */
425 +#define MAX_DUMP_PER_LINE 16
426 +/** Data dump length */
427 +#define DATA_DUMP_LEN 32
430 +hexdump(char *prompt, u8 * buf, int len)
433 + char dbgdumpbuf[DBG_DUMP_BUF_LEN];
434 + char *ptr = dbgdumpbuf;
436 + printk(KERN_DEBUG "%s:\n", prompt);
437 + for (i = 1; i <= len; i++) {
438 + ptr += sprintf(ptr, "%02x ", *buf);
440 + if (i % MAX_DUMP_PER_LINE == 0) {
442 + printk(KERN_DEBUG "%s\n", dbgdumpbuf);
446 + if (len % MAX_DUMP_PER_LINE) {
448 + printk(KERN_DEBUG "%s\n", dbgdumpbuf);
452 +/** Debug command */
453 +#define DBG_HEXDUMP_CMD_D(x,y,z) {if (drvdbg & DBG_CMD_D) hexdump(x,y,z);}
455 +#define DBG_HEXDUMP_DAT_D(x,y,z) {if (drvdbg & DBG_DAT_D) hexdump(x,y,z);}
456 +/** Debug hexdump */
457 +#define DBG_HEXDUMP(level,x,y,z) DBG_HEXDUMP_##level(x,y,z)
459 +#define HEXDUMP(x,y,z) {if (drvdbg & DBG_INFO) hexdump(x,y,z);}
461 +/** Do nothing since debugging is not turned on */
462 +#define DBG_HEXDUMP(level,x,y,z) do {} while (0)
463 +/** Do nothing since debugging is not turned on */
464 +#define HEXDUMP(x,y,z) do {} while (0)
470 +/** Unsigned char */
474 + * OS macro definitions
476 +/** OS macro to get time */
477 +#define os_time_get() jiffies
479 +/** OS macro to update transfer start time */
480 +#define UpdateTransStart(dev) { \
481 + dev->trans_start = jiffies; \
484 +/** Try to get a reference to the module */
485 +#define MODULE_GET try_module_get(THIS_MODULE)
486 +/** Decrease module reference count */
487 +#define MODULE_PUT module_put(THIS_MODULE)
489 +/** OS macro to initialize semaphore */
490 +#define OS_INIT_SEMAPHORE(x) sema_init(x,1)
491 +/** OS macro to acquire blocking semaphore */
492 +#define OS_ACQ_SEMAPHORE_BLOCK(x) down_interruptible(x)
493 +/** OS macro to acquire non-blocking semaphore */
494 +#define OS_ACQ_SEMAPHORE_NOBLOCK(x) down_trylock(x)
495 +/** OS macro to release semaphore */
496 +#define OS_REL_SEMAPHORE(x) up(x)
499 +os_sched_timeout(u32 millisec)
501 + set_current_state(TASK_INTERRUPTIBLE);
502 + schedule_timeout((millisec * HZ) / 1000);
505 +/** Maximum size of ethernet packet */
506 +#define MRVDRV_MAXIMUM_ETH_PACKET_SIZE 1514
508 +/** Maximum size of multicast list */
509 +#define MRVDRV_MAX_MULTICAST_LIST_SIZE 32
513 +#define MIN(a,b) ((a) < (b) ? (a) : (b))
518 +#define MAX(a,b) ((a) > (b) ? (a) : (b))
521 +/** Find number of elements */
523 +#define NELEMENTS(x) (sizeof(x)/sizeof(x[0]))
526 +/** Buffer Constants */
528 +/** Size of command buffer */
529 +#define MRVDRV_SIZE_OF_CMD_BUFFER (2 * 1024)
531 +/** Length of device length */
532 +#define DEV_NAME_LEN 32
534 +/** Length of ethernet address */
539 +/** Default watchdog timeout */
540 +#define MRVDRV_DEFAULT_WATCHDOG_TIMEOUT (2 * HZ)
543 +#define UAP_STATUS_SUCCESS (0)
545 +#define UAP_STATUS_FAILURE (-1)
547 +#define UAP_STATUS_NOT_ACCEPTED (-2)
549 +/** Max loop count (* 100ms) for waiting device ready at init time */
550 +#define MAX_WAIT_DEVICE_READY_COUNT 50
552 +/** Tx high watermark. Stop Tx queue after this is crossed */
553 +#define TX_HIGH_WATERMARK 4
554 +/** Tx low watermark. Restart Tx queue after this is crossed */
555 +#define TX_LOW_WATERMARK 2
557 +/** Netlink protocol number */
558 +#define NETLINK_MARVELL (MAX_LINKS - 1)
559 +/** Netlink maximum payload size */
560 +#define NL_MAX_PAYLOAD 1024
561 +/** Netlink multicast group number */
562 +#define NL_MULTICAST_GROUP 1
565 +#define MRVDRV_TIMER_20S 20000
567 +/** Host Command option for wait till Send */
568 +#define HostCmd_OPTION_WAITFORSEND 0x0001
569 +/** Host Command option for wait for RSP */
570 +#define HostCmd_OPTION_WAITFORRSP 0x0002
571 +/** Host Command option for wait for RSP or Timeout */
572 +#define HostCmd_OPTION_WAITFORRSP_TIMEOUT 0x0003
573 +/** Host Command option for wait for RSP of sleep confirm */
574 +#define HostCmd_OPTION_WAITFORRSP_SLEEPCONFIRM 0x0004
576 +/** Sleep until a condition gets true or a timeout elapses */
577 +#define os_wait_interruptible_timeout(waitq, cond, timeout) \
578 + wait_event_interruptible_timeout(waitq, cond, ((timeout) * HZ / 1000))
580 +/** Private command ID to Host command */
581 +#define UAPHOSTCMD (SIOCDEVPRIVATE + 1)
583 +/** Private command ID to Power Mode */
584 +#define UAP_POWER_MODE (SIOCDEVPRIVATE + 3)
586 +typedef struct _ps_sleep_param
588 + /** control bitmap */
590 + /** minimum sleep period (micro second) */
592 + /** maximum sleep period (micro second) */
596 +/** inactivity sleep_param */
597 +typedef struct _inact_sleep_param
599 + /** inactivity timeout (micro second) */
601 + /** miniumu awake period (micro second) */
603 + /** maximum awake period (micro second) */
605 +} inact_sleep_param;
607 +/** flag for ps mode */
608 +#define PS_FLAG_PS_MODE 1
609 +/** flag for sleep param */
610 +#define PS_FLAG_SLEEP_PARAM 2
611 +/** flag for inactivity sleep param */
612 +#define PS_FLAG_INACT_SLEEP_PARAM 4
614 +/** Disable power mode */
615 +#define PS_MODE_DISABLE 0
616 +/** Enable periodic dtim ps */
617 +#define PS_MODE_PERIODIC_DTIM 1
618 +/** Enable inactivity ps */
619 +#define PS_MODE_INACTIVITY 2
621 +/** sleep parameter */
622 +#define SLEEP_PARAMETER 1
623 +/** inactivity sleep parameter */
624 +#define INACTIVITY_SLEEP_PARAMETER 2
626 +typedef struct _ps_mgmt
628 + /** flags for valid field */
633 + ps_sleep_param sleep_param;
634 + /** inactivity sleep param */
635 + inact_sleep_param inact_param;
638 +/** Semaphore structure */
639 +typedef struct semaphore SEMAPHORE;
641 +/** Global Varibale Declaration */
642 +/** Private data structure of the device */
643 +typedef struct _uap_private uap_private;
644 +/** Adapter data structure of the device */
645 +typedef struct _uap_adapter uap_adapter;
646 +/** private structure */
647 +extern uap_private *uappriv;
649 +/** ENUM definition*/
651 +/** Hardware status codes */
652 +typedef enum _HARDWARE_STATUS
661 +/** info for debug purpose */
662 +typedef struct _uap_dbg
664 + /** Number of host to card command failures */
665 + u32 num_cmd_host_to_card_failure;
666 + /** Number of host to card Tx failures */
667 + u32 num_tx_host_to_card_failure;
670 +/** Set thread state */
671 +#define OS_SET_THREAD_STATE(x) set_current_state(x)
676 + struct task_struct *task;
678 + wait_queue_head_t waitQ;
681 + /** Private structure */
686 +uap_activate_thread(uap_thread * thr)
688 + /** Record the thread pid */
689 + thr->pid = current->pid;
691 + /** Initialize the wait queue */
692 + init_waitqueue_head(&thr->waitQ);
696 +uap_deactivate_thread(uap_thread * thr)
703 +uap_create_thread(int (*uapfunc) (void *), uap_thread * thr, char *name)
705 + thr->task = kthread_run(uapfunc, thr, "%s", name);
709 +uap_terminate_thread(uap_thread * thr)
711 + /* Check if the thread is active or not */
714 + kthread_stop(thr->task);
718 +/** Data structure for the Marvell uAP device */
719 +typedef struct _uap_dev
722 + char name[DEV_NAME_LEN];
723 + /** card pointer */
730 + TRUE - Data is sent to fw, no Tx Done received
731 + FALSE - Tx done received for previous Tx */
734 + TRUE - CMD is sent to fw, no CMD Done received
735 + FALSE - CMD done received for previous CMD */
737 + /** netdev pointer */
738 + struct net_device *netdev;
739 +} uap_dev_t, *puap_dev_t;
741 +/** Private structure for the MV device */
747 + /** Device adapter structure */
748 + uap_adapter *adapter;
749 + /** Device structure */
752 + /** Net device statistics structure */
753 + struct net_device_stats stats;
755 + /** Number of Tx timeouts */
756 + u32 num_tx_timeout;
758 + /** Media connection status */
759 + BOOLEAN MediaConnected;
761 +#ifdef CONFIG_PROC_FS
762 + struct proc_dir_entry *proc_uap;
763 + struct proc_dir_entry *proc_entry;
764 +#endif /* CONFIG_PROC_FS */
766 + /** Firmware helper */
767 + const struct firmware *fw_helper;
769 + const struct firmware *firmware;
770 + /** Hotplug device */
771 + struct device *hotplug_device;
772 + /** thread to service interrupts */
773 + uap_thread MainThread;
775 + spinlock_t driver_lock;
776 + /** Driver lock flags */
777 + ulong driver_flags;
781 +/** PS_CMD_ConfirmSleep */
782 +typedef struct _PS_CMD_ConfirmSleep
792 + /** Sequence number */
796 +} __ATTRIB_PACK__ PS_CMD_ConfirmSleep, *PPS_CMD_ConfirmSleep;
798 +/** Wlan Adapter data structure*/
801 + /** Power save confirm sleep command */
802 + PS_CMD_ConfirmSleep PSConfirmSleep;
803 + /** Device status */
804 + HARDWARE_STATUS HardwareStatus;
805 + /** Interrupt counter */
807 + /** Tx packet queue */
808 + struct sk_buff_head tx_queue;
809 + /** Cmd packet queue */
810 + struct sk_buff_head cmd_queue;
811 + /** Command sequence number */
813 + /** Command buffer */
815 + /** cmd pending flag */
817 + /** cmd wait option */
818 + u8 cmd_wait_option;
819 + /** Command buffer length */
821 + /** Command wait queue */
822 + wait_queue_head_t cmdwait_q __ATTRIB_ALIGN__;
823 + /** Command wait queue state flag */
826 + BOOLEAN SurpriseRemoved;
829 + /** Netlink kernel socket */
830 + struct sock *nl_sk;
831 + /** Semaphore for CMD */
833 + /** Power Save mode */
835 + /** Power Save state */
837 + /** Number of wakeup tries */
842 +os_upload_rx_packet(uap_private * priv, struct sk_buff *skb)
844 + skb->dev = priv->uap_dev.netdev;
845 + skb->protocol = eth_type_trans(skb, priv->uap_dev.netdev);
846 + skb->ip_summed = CHECKSUM_UNNECESSARY;
847 + if (in_interrupt())
855 + * netif carrier_on/off and start(wake)/stop_queue handling
858 +os_carrier_on(uap_private * priv)
860 + if (!netif_carrier_ok(priv->uap_dev.netdev) &&
861 + (priv->MediaConnected == TRUE)) {
862 + netif_carrier_on(priv->uap_dev.netdev);
867 +os_carrier_off(uap_private * priv)
869 + if (netif_carrier_ok(priv->uap_dev.netdev)) {
870 + netif_carrier_off(priv->uap_dev.netdev);
875 +os_start_queue(uap_private * priv)
877 + if (netif_queue_stopped(priv->uap_dev.netdev) &&
878 + (priv->MediaConnected == TRUE)) {
879 + netif_wake_queue(priv->uap_dev.netdev);
884 +os_stop_queue(uap_private * priv)
886 + if (!netif_queue_stopped(priv->uap_dev.netdev)) {
887 + netif_stop_queue(priv->uap_dev.netdev);
891 +/** Interface specific header */
892 +#define INTF_HEADER_LEN 4
894 +/** headroom alignment for tx packet */
895 +#define HEADER_ALIGNMENT 8
897 +/** The number of times to try when polling for status bits */
898 +#define MAX_POLL_TRIES 100
900 +/** Length of SNAP header */
901 +#define MRVDRV_SNAP_HEADER_LEN 8
903 +/** Extra length of Tx packet buffer */
904 +#define EXTRA_LEN 36
906 +/** Buffer size for ethernet Tx packets */
907 +#define MRVDRV_ETH_TX_PACKET_BUFFER_SIZE \
908 + (ETH_FRAME_LEN + sizeof(TxPD) + EXTRA_LEN)
910 +/** Buffer size for ethernet Rx packets */
911 +#define MRVDRV_ETH_RX_PACKET_BUFFER_SIZE \
912 + (ETH_FRAME_LEN + sizeof(RxPD) \
913 + + MRVDRV_SNAP_HEADER_LEN + EXTRA_LEN)
915 +/** Packet type: data, command & event */
916 +typedef enum _mv_type
923 +/** Disable interrupt */
924 +#define OS_INT_DISABLE spin_lock_irqsave(&priv->driver_lock, priv->driver_flags)
925 +/** Enable interrupt */
926 +#define OS_INT_RESTORE spin_unlock_irqrestore(&priv->driver_lock, priv->driver_flags)
928 +int uap_process_rx_packet(uap_private * priv, struct sk_buff *skb);
929 +void uap_interrupt(uap_private * priv);
930 +uap_private *uap_add_card(void *card);
931 +int uap_remove_card(void *card);
932 +int uap_process_event(uap_private * priv, u8 * payload, uint len);
933 +int uap_soft_reset(uap_private * priv);
934 +int uap_process_sleep_confirm_resp(uap_private * priv, u8 * resp, int resp_len);
936 +#ifdef CONFIG_PROC_FS
937 +/** The proc fs interface */
938 +void uap_proc_entry(uap_private * priv, struct net_device *dev);
939 +void uap_proc_remove(uap_private * priv);
940 +int string_to_number(char *s);
941 +void uap_debug_entry(uap_private * priv, struct net_device *dev);
942 +void uap_debug_remove(uap_private * priv);
943 +#endif /* CONFIG_PROC_FS */
945 +int sbi_register(void);
947 +void sbi_unregister(void);
948 +int sbi_register_dev(uap_private * priv);
949 +int sbi_unregister_dev(uap_private * priv);
950 +int sbi_prog_fw_w_helper(uap_private *);
952 +int sbi_host_to_card(uap_private * priv, u8 * payload, u16 nb);
953 +int sbi_enable_host_int(uap_private * priv);
954 +int sbi_disable_host_int(uap_private * priv);
956 +int sbi_get_int_status(uap_private * priv, u8 * ireg);
957 +/** Check firmware status */
958 +int sbi_check_fw_status(uap_private *, int);
959 +int sbi_prog_helper(uap_private *);
961 +int sbi_wakeup_firmware(uap_private * priv);
963 +#endif /* _UAP_DRV_H */
964 diff -Naur backports-3.18.1-1.org/drivers/net/wireless/libertas_uap/uap_fw.h backports-3.18.1-1/drivers/net/wireless/libertas_uap/uap_fw.h
965 --- backports-3.18.1-1.org/drivers/net/wireless/libertas_uap/uap_fw.h 1970-01-01 01:00:00.000000000 +0100
966 +++ backports-3.18.1-1/drivers/net/wireless/libertas_uap/uap_fw.h 2014-12-29 20:37:43.949097590 +0100
970 + * @brief This file contains firmware specific defines.
972 + * Copyright (C) 2008-2009, Marvell International Ltd.
974 + * This software file (the "File") is distributed by Marvell International
975 + * Ltd. under the terms of the GNU General Public License Version 2, June 1991
976 + * (the "License"). You may use, redistribute and/or modify this File in
977 + * accordance with the terms and conditions of the License, a copy of which
978 + * is available along with the File in the gpl.txt file or by writing to
979 + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
980 + * 02111-1307 or on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
982 + * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
983 + * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
984 + * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
985 + * this warranty disclaimer.
988 +/********************************************************
990 + 02/26/08: Initial creation
991 +********************************************************/
996 +/** uap upload size */
997 +#define UAP_UPLD_SIZE 2312
998 +/** Packet type Micro AP */
999 +#define PKT_TYPE_MICROAP 1
1000 +/** Packet type client */
1001 +#define PKT_TYPE_CLIENT 0
1003 +/** TxPD descriptor */
1004 +typedef struct _TxPD
1010 + /** Tx packet length */
1012 + /** Tx packet offset */
1014 + /** Tx packet type */
1020 +} __ATTRIB_PACK__ TxPD, *PTxPD;
1022 +/** RxPD Descriptor */
1023 +typedef struct _RxPD
1029 + /** Tx packet length */
1031 + /** Tx packet offset */
1033 +} __ATTRIB_PACK__ RxPD, *PRxPD;
1036 +/** Convert from 16 bit little endian format to CPU format */
1037 +#define uap_le16_to_cpu(x) le16_to_cpu(x)
1038 +/** Convert from 32 bit little endian format to CPU format */
1039 +#define uap_le32_to_cpu(x) le32_to_cpu(x)
1040 +/** Convert from 64 bit little endian format to CPU format */
1041 +#define uap_le64_to_cpu(x) le64_to_cpu(x)
1042 +/** Convert to 16 bit little endian format from CPU format */
1043 +#define uap_cpu_to_le16(x) cpu_to_le16(x)
1044 +/** Convert to 32 bit little endian format from CPU format */
1045 +#define uap_cpu_to_le32(x) cpu_to_le32(x)
1046 +/** Convert to 64 bit little endian format from CPU format */
1047 +#define uap_cpu_to_le64(x) cpu_to_le64(x)
1049 +/** Convert TxPD to little endian format from CPU format */
1050 +#define endian_convert_TxPD(x); \
1052 + (x)->TxPktLength = uap_cpu_to_le16((x)->TxPktLength); \
1053 + (x)->TxPktOffset = uap_cpu_to_le32((x)->TxPktOffset); \
1054 + (x)->TxControl = uap_cpu_to_le32((x)->TxControl); \
1055 + (x)->TxPktType = uap_cpu_to_le32((x)->TxPktType); \
1058 +/** Convert RxPD from little endian format to CPU format */
1059 +#define endian_convert_RxPD(x); \
1061 + (x)->RxPktLength = uap_le16_to_cpu((x)->RxPktLength); \
1062 + (x)->RxPktOffset = uap_le32_to_cpu((x)->RxPktOffset); \
1064 +#else /* BIG_ENDIAN */
1066 +#define uap_le16_to_cpu(x) x
1068 +#define uap_le32_to_cpu(x) x
1070 +#define uap_le64_to_cpu(x) x
1072 +#define uap_cpu_to_le16(x) x
1074 +#define uap_cpu_to_le32(x) x
1076 +#define uap_cpu_to_le64(x) x
1079 +#define endian_convert_TxPD(x)
1081 +#define endian_convert_RxPD(x)
1082 +#endif /* BIG_ENDIAN */
1084 +/** Host Command ID : Function initialization */
1085 +#define HostCmd_CMD_FUNC_INIT 0x00a9
1086 +/** Host Command ID : Function shutdown */
1087 +#define HostCmd_CMD_FUNC_SHUTDOWN 0x00aa
1089 +/** Host Command id: SYS_INFO */
1090 +#define HOST_CMD_APCMD_SYS_INFO 0x00ae
1091 +/** Host Command id: SYS_RESET */
1092 +#define HOST_CMD_APCMD_SYS_RESET 0x00af
1093 +/** Host Command id: SYS_CONFIGURE */
1094 +#define HOST_CMD_APCMD_SYS_CONFIGURE 0x00b0
1095 +/** Host Command id: BSS_START */
1096 +#define HOST_CMD_APCMD_BSS_START 0x00b1
1097 +/** Host Command id: SYS_STOP */
1098 +#define HOST_CMD_APCMD_BSS_STOP 0x00b2
1099 +/** Host Command id: STA_LIST */
1100 +#define HOST_CMD_APCMD_STA_LIST 0x00b3
1101 +/** Host Command id: STA_FILTER_TABLE */
1102 +#define HOST_CMD_APCMD_STA_FILTER_TABLE 0x00b4
1103 +/** Host Command id: STA_DEAUTH */
1104 +#define HOST_CMD_APCMD_STA_DEAUTH 0x00b5
1105 +/** Host Command id: SOFT_RESET */
1106 +#define HOST_CMD_APCMD_SOFT_RESET 0x00d5
1107 +/** Host Command id: POWER_MGMT_EXT */
1108 +#define HOST_CMD_POWER_MGMT_EXT 0x00ef
1109 +/** Host Command id: SLEEP_CONFIRM*/
1110 +#define HOST_CMD_SLEEP_CONFIRM 0x00d8
1112 +/** TLV type : SSID */
1113 +#define TLV_TYPE_SSID 0x0000
1114 +/** TLV type : Rates */
1115 +#define TLV_TYPE_RATES 0x0001
1116 +/** TLV type : PHY DS */
1117 +#define TLV_TYPE_PHY_DS 0x0003
1119 +/** TLV Id : Base id */
1120 +#define PROPRIETARY_TLV_BASE_ID 0x0100
1121 +/** TLV Id : AP_MAC_ADDRESS */
1122 +#define MRVL_AP_MAC_ADDRESS_TLV_ID (PROPRIETARY_TLV_BASE_ID + 43)
1123 +/** TLV Id : Beacon period */
1124 +#define MRVL_BEACON_PERIOD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 44)
1125 +/** TLV Id : Dtim period */
1126 +#define MRVL_DTIM_PERIOD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 45)
1127 +/** TLV Id : Basic rates */
1128 +#define MRVL_BASIC_RATES_TLV_ID (PROPRIETARY_TLV_BASE_ID + 46)
1129 +/** TLV Id : Tx Power */
1130 +#define MRVL_TX_POWER_TLV_ID (PROPRIETARY_TLV_BASE_ID + 47)
1131 +/** TLV Id : Broadcast SSID control */
1132 +#define MRVL_BCAST_SSID_CTL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 48)
1133 +/** TLV Id : Preamble control */
1134 +#define MRVL_PREAMBLE_CTL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 49)
1135 +/** TLV Id : Antenna control */
1136 +#define MRVL_ANTENNA_CTL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 50)
1137 +/** TLV Id : RTS threshold */
1138 +#define MRVL_RTS_THRESHOLD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 51)
1139 +/** TLV Id : Radio control */
1140 +#define MRVL_RADIO_CTL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 52)
1141 +/** TLV Id : TX data rate */
1142 +#define MRVL_TX_DATA_RATE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 53)
1143 +/** TLV Id : Packet forward control */
1144 +#define MRVL_PKT_FWD_CTL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 54)
1145 +/** TLV Id : STA info */
1146 +#define MRVL_STA_INFO_TLV_ID (PROPRIETARY_TLV_BASE_ID + 55)
1147 +/** TLV Id : STA MAC address filter */
1148 +#define MRVL_STA_MAC_ADDR_FILTER_TLV_ID (PROPRIETARY_TLV_BASE_ID + 56)
1149 +/** TLV Id : STA ageout timer */
1150 +#define MRVL_STA_AGEOUT_TIMER_TLV_ID (PROPRIETARY_TLV_BASE_ID + 57)
1151 +/** TLV Id : Security config */
1152 +#define MRVL_SECURITY_CFG_TLV_ID (PROPRIETARY_TLV_BASE_ID + 58)
1153 +/** TLV Id : WEP KEY */
1154 +#define MRVL_WEP_KEY_TLV_ID (PROPRIETARY_TLV_BASE_ID + 59)
1155 +/** TLV Id : WPA Passphrase */
1156 +#define MRVL_WPA_PASSPHRASE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 60)
1159 +#define ACTION_GET 0
1161 +#define ACTION_SET 1
1162 +/** Length of ethernet address */
1167 +/** HostCmd_DS_GEN */
1174 + /** Sequence number */
1178 +} __ATTRIB_PACK__ HostCmd_DS_GEN;
1180 +/** Size of HostCmd_DS_GEN */
1181 +#define S_DS_GEN sizeof(HostCmd_DS_GEN)
1183 +/** _HostCmd_HEADER*/
1186 + /** Command Header : Command */
1188 + /** Command Header : Size */
1190 +} __ATTRIB_PACK__ HostCmd_HEADER;
1192 +/** HostCmd_SYS_CONFIG */
1193 +typedef struct _HostCmd_SYS_CONFIG
1195 + /** CMD Action GET/SET*/
1199 +} __ATTRIB_PACK__ HostCmd_SYS_CONFIG;
1201 +/** HostCmd_DS_POWER_MGMT_EXT */
1202 +typedef struct _HostCmd_DS_POWER_MGMT_EXT
1204 + /** CMD Action Get/Set*/
1208 +} __ATTRIB_PACK__ HostCmd_DS_POWER_MGMT_EXT;
1210 +/** _HostCmd_DS_COMMAND*/
1211 +typedef struct _HostCmd_DS_COMMAND
1214 + /** Command Header : Command */
1216 + /** Command Header : Size */
1218 + /** Command Header : Sequence number */
1220 + /** Command Header : Result */
1222 + /** Command Body */
1225 + HostCmd_SYS_CONFIG sys_config;
1226 + HostCmd_DS_POWER_MGMT_EXT pm_cfg;
1229 +} __ATTRIB_PACK__ HostCmd_DS_COMMAND;
1231 +/** MrvlIEtypesHeader_*/
1232 +typedef struct _MrvlIEtypesHeader
1234 + /** Header type */
1236 + /** Header length */
1238 +} __ATTRIB_PACK__ MrvlIEtypesHeader_t;
1240 +/** MrvlIEtypes_Data_t */
1241 +typedef struct _MrvlIEtypes_Data_t
1244 + MrvlIEtypesHeader_t Header;
1247 +} __ATTRIB_PACK__ MrvlIEtypes_Data_t;
1249 +/** MrvlIEtypes_ChanListParamSet_t */
1250 +typedef struct _MrvlIEtypes_MacAddr_t
1253 + MrvlIEtypesHeader_t Header;
1254 + /** AP MAC address */
1255 + u8 ApMacAddr[ETH_ALEN];
1256 +} __ATTRIB_PACK__ MrvlIEtypes_MacAddr_t;
1258 +/** Event ID: BSS started */
1259 +#define MICRO_AP_EV_ID_BSS_START 46
1261 +/** Event ID: BSS idle event */
1262 +#define MICRO_AP_EV_BSS_IDLE 67
1264 +/** Event ID: BSS active event */
1265 +#define MICRO_AP_EV_BSS_ACTIVE 68
1267 +/** Event ID: PS_AWAKE */
1268 +#define EVENT_PS_AWAKE 0x0a
1270 +/** Event ID: PS_SLEEP */
1271 +#define EVENT_PS_SLEEP 0x0b
1274 +typedef enum _PS_STATE
1277 + PS_STATE_PRE_SLEEP,
1281 +/** TLV type: AP Sleep param */
1282 +#define TLV_TYPE_AP_SLEEP_PARAM (PROPRIETARY_TLV_BASE_ID + 106)
1283 +/** TLV type: AP Inactivity Sleep param */
1284 +#define TLV_TYPE_AP_INACT_SLEEP_PARAM (PROPRIETARY_TLV_BASE_ID + 107)
1286 +/** MrvlIEtypes_sleep_param_t */
1287 +typedef struct _MrvlIEtypes_sleep_param_t
1290 + MrvlIEtypesHeader_t header;
1291 + /** control bitmap */
1297 +} __ATTRIB_PACK__ MrvlIEtypes_sleep_param_t;
1299 +/** MrvlIEtypes_inact_sleep_param_t */
1300 +typedef struct _MrvlIEtypes_inact_sleep_param_t
1303 + MrvlIEtypesHeader_t header;
1304 + /** inactivity timeout */
1305 + u32 inactivity_to;
1310 +} __ATTRIB_PACK__ MrvlIEtypes_inact_sleep_param_t;
1313 +typedef struct _AP_Event
1318 + * Reserved for STA_ASSOCIATED event and contains
1319 + * status information for the MIC_COUNTERMEASURES event.
1321 + /** Reserved/status */
1323 + /** AP MAC address */
1324 + u8 MacAddr[ETH_ALEN];
1325 +} __ATTRIB_PACK__ AP_Event;
1326 +#endif /* _UAP_FW_H */
1327 diff -Naur backports-3.18.1-1.org/drivers/net/wireless/libertas_uap/uap_headers.h backports-3.18.1-1/drivers/net/wireless/libertas_uap/uap_headers.h
1328 --- backports-3.18.1-1.org/drivers/net/wireless/libertas_uap/uap_headers.h 1970-01-01 01:00:00.000000000 +0100
1329 +++ backports-3.18.1-1/drivers/net/wireless/libertas_uap/uap_headers.h 2014-12-29 20:37:43.949097590 +0100
1331 +/** @file uap_headers.h
1333 + * @brief This file contains all the necessary include file.
1335 + * Copyright (C) 2008-2009, Marvell International Ltd.
1337 + * This software file (the "File") is distributed by Marvell International
1338 + * Ltd. under the terms of the GNU General Public License Version 2, June 1991
1339 + * (the "License"). You may use, redistribute and/or modify this File in
1340 + * accordance with the terms and conditions of the License, a copy of which
1341 + * is available along with the File in the gpl.txt file or by writing to
1342 + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1343 + * 02111-1307 or on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
1345 + * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
1346 + * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
1347 + * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
1348 + * this warranty disclaimer.
1351 +#ifndef _UAP_HEADERS_H
1352 +#define _UAP_HEADERS_H
1354 +/* Linux header files */
1355 +#include <linux/kernel.h>
1356 +#include <linux/module.h>
1357 +#include <linux/init.h>
1358 +#include <linux/version.h>
1359 +#include <linux/param.h>
1360 +#include <linux/types.h>
1361 +#include <linux/interrupt.h>
1362 +#include <linux/proc_fs.h>
1363 +#include <linux/kthread.h>
1364 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
1365 +#include <linux/semaphore.h>
1367 +#include <asm/semaphore.h>
1370 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
1371 +#include <linux/config.h>
1374 +/* Net header files */
1375 +#include <linux/netdevice.h>
1376 +#include <linux/net.h>
1377 +#include <linux/skbuff.h>
1378 +#include <linux/if_ether.h>
1379 +#include <linux/etherdevice.h>
1380 +#include <net/sock.h>
1381 +#include <linux/netlink.h>
1382 +#include <linux/firmware.h>
1383 +#include <linux/delay.h>
1385 +#include "uap_drv.h"
1386 +#include "uap_fw.h"
1388 +#include <linux/mmc/sdio.h>
1389 +#include <linux/mmc/sdio_ids.h>
1390 +#include <linux/mmc/sdio_func.h>
1391 +#include <linux/mmc/card.h>
1392 +#include "uap_sdio_mmc.h"
1394 +#endif /* _UAP_HEADERS_H */
1395 diff -Naur backports-3.18.1-1.org/drivers/net/wireless/libertas_uap/uap_main.c backports-3.18.1-1/drivers/net/wireless/libertas_uap/uap_main.c
1396 --- backports-3.18.1-1.org/drivers/net/wireless/libertas_uap/uap_main.c 1970-01-01 01:00:00.000000000 +0100
1397 +++ backports-3.18.1-1/drivers/net/wireless/libertas_uap/uap_main.c 2014-12-29 20:37:43.952431125 +0100
1399 +/** @file uap_main.c
1400 + * @brief This file contains the major functions in uAP
1401 + * driver. It includes init, exit etc..
1402 + * This file also contains the initialization for SW,
1405 + * Copyright (C) 2008-2009, Marvell International Ltd.
1407 + * This software file (the "File") is distributed by Marvell International
1408 + * Ltd. under the terms of the GNU General Public License Version 2, June 1991
1409 + * (the "License"). You may use, redistribute and/or modify this File in
1410 + * accordance with the terms and conditions of the License, a copy of which
1411 + * is available along with the File in the gpl.txt file or by writing to
1412 + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1413 + * 02111-1307 or on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
1415 + * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
1416 + * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
1417 + * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
1418 + * this warranty disclaimer.
1422 + * @mainpage uAP Linux Driver
1424 + * @section overview_sec Overview
1426 + * This is Linux reference driver for Marvell uAP.
1428 + * @section copyright_sec Copyright
1430 + * Copyright (C) 2008, Marvell International Ltd.
1434 +#include "uap_headers.h"
1437 + * the global variable of a pointer to uap_private
1438 + * structure variable
1440 +uap_private *uappriv = NULL;
1441 +#ifdef DEBUG_LEVEL1
1442 +#define DEFAULT_DEBUG_MASK (DBG_MSG | DBG_FATAL | DBG_ERROR)
1443 +u32 drvdbg = DEFAULT_DEBUG_MASK;
1446 +char *helper_name = NULL;
1447 +/** Firmware name */
1448 +char *fw_name = NULL;
1450 +/** Semaphore for add/remove card */
1451 +SEMAPHORE AddRemoveCardSem;
1453 +/********************************************************
1455 +********************************************************/
1457 + * @brief This function send sleep confirm command to firmware
1459 + * @param priv A pointer to uap_private structure
1460 + * @return UAP_STATUS_SUCCESS for success otherwise UAP_STATUS_FAILURE
1463 +uap_dnld_sleep_confirm_cmd(uap_private * priv)
1465 + uap_adapter *Adapter = priv->adapter;
1466 + int ret = UAP_STATUS_SUCCESS;
1468 + PRINTM(CMND, "Sleep confirm\n");
1469 + Adapter->cmd_pending = TRUE;
1470 + Adapter->cmd_wait_option = HostCmd_OPTION_WAITFORRSP_SLEEPCONFIRM;
1472 + sbi_host_to_card(priv, (u8 *) & Adapter->PSConfirmSleep,
1473 + sizeof(PS_CMD_ConfirmSleep));
1474 + if (ret != UAP_STATUS_SUCCESS) {
1475 + Adapter->ps_state = PS_STATE_AWAKE;
1476 + Adapter->cmd_pending = FALSE;
1477 + Adapter->cmd_wait_option = FALSE;
1484 + * @brief This function process sleep confirm resp from firmware
1486 + * @param priv A pointer to uap_private structure
1487 + * @param resp A pointer to resp buf
1488 + * @param resp_len resp buf len
1489 + * @return UAP_STATUS_SUCCESS for success otherwise UAP_STATUS_FAILURE
1492 +uap_process_sleep_confirm_resp(uap_private * priv, u8 * resp, int resp_len)
1494 + int ret = UAP_STATUS_SUCCESS;
1495 + HostCmd_DS_COMMAND *cmd;
1496 + uap_adapter *Adapter = priv->adapter;
1498 + PRINTM(CMND, "Sleep confirm resp\n");
1500 + PRINTM(ERROR, "Cmd Size is 0\n");
1504 + cmd = (HostCmd_DS_COMMAND *) resp;
1505 + cmd->Result = uap_le16_to_cpu(cmd->Result);
1506 + if (cmd->Result != UAP_STATUS_SUCCESS) {
1507 + PRINTM(ERROR, "HOST_CMD_APCMD_PS_SLEEP_CONFIRM fail=%x\n", cmd->Result);
1511 + if (ret == UAP_STATUS_SUCCESS)
1512 + Adapter->ps_state = PS_STATE_SLEEP;
1514 + Adapter->ps_state = PS_STATE_AWAKE;
1520 + * @brief This function checks condition and prepares to
1521 + * send sleep confirm command to firmware if OK.
1523 + * @param priv A pointer to uap_private structure
1527 +uap_ps_cond_check(uap_private * priv)
1529 + uap_adapter *Adapter = priv->adapter;
1532 + if (!priv->uap_dev.cmd_sent &&
1533 + !Adapter->cmd_pending && !Adapter->IntCounter) {
1534 + uap_dnld_sleep_confirm_cmd(priv);
1536 + PRINTM(INFO, "Delay Sleep Confirm (%s%s%s)\n",
1537 + (priv->uap_dev.cmd_sent) ? "D" : "",
1538 + (Adapter->cmd_pending) ? "C" : "",
1539 + (Adapter->IntCounter) ? "I" : "");
1545 + * @brief This function add cmd to cmdQ and waiting for response
1547 + * @param priv A pointer to uap_private structure
1548 + * @param skb A pointer to the skb for process
1549 + * @param wait_option Wait option
1550 + * @return UAP_STATUS_SUCCESS for success otherwise UAP_STATUS_FAILURE
1553 +uap_process_cmd(uap_private * priv, struct sk_buff *skb, u8 wait_option)
1555 + uap_adapter *Adapter = priv->adapter;
1556 + int ret = UAP_STATUS_SUCCESS;
1557 + HostCmd_DS_COMMAND *cmd;
1560 + if (Adapter->HardwareStatus != HWReady) {
1561 + PRINTM(ERROR, "Hw not ready, uap_process_cmd\n");
1566 + skb->cb[0] = wait_option;
1567 + headptr = skb->data;
1568 + *(u16 *) & headptr[0] = uap_cpu_to_le16(skb->len);
1569 + *(u16 *) & headptr[2] = uap_cpu_to_le16(MV_TYPE_CMD);
1570 + cmd = (HostCmd_DS_COMMAND *) (skb->data + INTF_HEADER_LEN);
1571 + Adapter->SeqNum++;
1572 + cmd->SeqNum = uap_cpu_to_le16(Adapter->SeqNum);
1573 + PRINTM(CMND, "process_cmd: %x\n", cmd->Command);
1574 + DBG_HEXDUMP(CMD_D, "process_cmd", (u8 *) cmd, cmd->Size);
1575 + if (!wait_option) {
1576 + skb_queue_tail(&priv->adapter->cmd_queue, skb);
1577 + wake_up_interruptible(&priv->MainThread.waitQ);
1581 + if (OS_ACQ_SEMAPHORE_BLOCK(&Adapter->CmdSem)) {
1582 + PRINTM(ERROR, "Acquire semaphore error, uap_prepare_cmd\n");
1587 + skb_queue_tail(&priv->adapter->cmd_queue, skb);
1588 + Adapter->CmdWaitQWoken = FALSE;
1589 + wake_up_interruptible(&priv->MainThread.waitQ);
1590 + /* Sleep until response is generated by FW */
1591 + if (wait_option == HostCmd_OPTION_WAITFORRSP_TIMEOUT) {
1592 + if (!os_wait_interruptible_timeout
1593 + (Adapter->cmdwait_q, Adapter->CmdWaitQWoken, MRVDRV_TIMER_20S)) {
1594 + PRINTM(ERROR, "Cmd timeout\n");
1595 + Adapter->cmd_pending = FALSE;
1599 + wait_event_interruptible(Adapter->cmdwait_q, Adapter->CmdWaitQWoken);
1600 + OS_REL_SEMAPHORE(&Adapter->CmdSem);
1606 + * @brief Inspect the response buffer for pointers to expected TLVs
1609 + * @param pTlv Pointer to the start of the TLV buffer to parse
1610 + * @param tlvBufSize Size of the TLV buffer
1611 + * @param reqTlvType request tlv's tlvtype
1612 + * @param ppTlv Output parameter: Pointer to the request TLV if found
1617 +uap_get_tlv_ptrs(MrvlIEtypes_Data_t * pTlv, int tlvBufSize,
1618 + u16 reqTlvType, MrvlIEtypes_Data_t ** ppTlv)
1620 + MrvlIEtypes_Data_t *pCurrentTlv;
1626 + pCurrentTlv = pTlv;
1627 + tlvBufLeft = tlvBufSize;
1629 + PRINTM(INFO, "uap_get_tlv: tlvBufSize = %d, reqTlvType=%x\n", tlvBufSize,
1631 + while (tlvBufLeft >= sizeof(MrvlIEtypesHeader_t)) {
1632 + tlvType = uap_le16_to_cpu(pCurrentTlv->Header.Type);
1633 + tlvLen = uap_le16_to_cpu(pCurrentTlv->Header.Len);
1634 + if (reqTlvType == tlvType)
1635 + *ppTlv = (MrvlIEtypes_Data_t *) pCurrentTlv;
1637 + HEXDUMP("TLV Buf", (u8 *) * ppTlv, tlvLen);
1640 + tlvBufLeft -= (sizeof(pTlv->Header) + tlvLen);
1641 + pCurrentTlv = (MrvlIEtypes_Data_t *) (pCurrentTlv->Data + tlvLen);
1647 + * @brief This function get mac
1649 + * @param priv A pointer to uap_private structure
1650 + * @return UAP_STATUS_SUCCESS on success, otherwise failure code
1653 +uap_get_mac_address(uap_private * priv)
1655 + int ret = UAP_STATUS_SUCCESS;
1657 + HostCmd_DS_COMMAND *cmd;
1658 + uap_adapter *Adapter = priv->adapter;
1659 + struct sk_buff *skb;
1660 + MrvlIEtypes_MacAddr_t *pMacAddrTlv;
1661 + MrvlIEtypes_Data_t *pTlv;
1664 + skb = dev_alloc_skb(MRVDRV_SIZE_OF_CMD_BUFFER);
1666 + PRINTM(ERROR, "No free skb\n");
1671 + S_DS_GEN + sizeof(HostCmd_SYS_CONFIG) + sizeof(MrvlIEtypes_MacAddr_t);
1672 + cmd = (HostCmd_DS_COMMAND *) (skb->data + INTF_HEADER_LEN);
1673 + cmd->Command = uap_cpu_to_le16(HOST_CMD_APCMD_SYS_CONFIGURE);
1674 + cmd->Size = uap_cpu_to_le16(CmdSize);
1675 + cmd->params.sys_config.Action = uap_cpu_to_le16(ACTION_GET);
1677 + (MrvlIEtypes_MacAddr_t *) (skb->data + INTF_HEADER_LEN + S_DS_GEN +
1678 + sizeof(HostCmd_SYS_CONFIG));
1679 + pMacAddrTlv->Header.Type = uap_cpu_to_le16(MRVL_AP_MAC_ADDRESS_TLV_ID);
1680 + pMacAddrTlv->Header.Len = uap_cpu_to_le16(ETH_ALEN);
1681 + skb_put(skb, CmdSize + INTF_HEADER_LEN);
1682 + if (UAP_STATUS_SUCCESS !=
1683 + uap_process_cmd(priv, skb, HostCmd_OPTION_WAITFORRSP_TIMEOUT)) {
1684 + PRINTM(ERROR, "Fail to process cmd SYS_CONFIGURE Query\n");
1688 + if (!Adapter->CmdSize) {
1689 + PRINTM(ERROR, "Cmd Size is 0\n");
1693 + cmd = (HostCmd_DS_COMMAND *) Adapter->CmdBuf;
1694 + cmd->Result = uap_le16_to_cpu(cmd->Result);
1695 + if (cmd->Result != UAP_STATUS_SUCCESS) {
1696 + PRINTM(ERROR, "uap_get_mac_address fail=%x\n", cmd->Result);
1701 + (MrvlIEtypes_Data_t *) (Adapter->CmdBuf + S_DS_GEN +
1702 + sizeof(HostCmd_SYS_CONFIG));
1703 + tlvBufSize = Adapter->CmdSize - S_DS_GEN - sizeof(HostCmd_SYS_CONFIG);
1704 + uap_get_tlv_ptrs(pTlv, tlvBufSize, MRVL_AP_MAC_ADDRESS_TLV_ID,
1705 + (MrvlIEtypes_Data_t **) & pMacAddrTlv);
1706 + if (pMacAddrTlv) {
1707 + memcpy(priv->uap_dev.netdev->dev_addr, pMacAddrTlv->ApMacAddr,
1709 + HEXDUMP("Original MAC addr", priv->uap_dev.netdev->dev_addr, ETH_ALEN);
1717 + * @brief This function checks the conditions and sends packet to device
1719 + * @param priv A pointer to uap_private structure
1720 + * @param skb A pointer to the skb for process
1721 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
1724 +uap_process_tx(uap_private * priv, struct sk_buff *skb)
1726 + uap_adapter *Adapter = priv->adapter;
1727 + int ret = UAP_STATUS_SUCCESS;
1730 + struct sk_buff *newskb;
1736 + return UAP_STATUS_FAILURE;
1738 + if (skb_headroom(skb) < (sizeof(TxPD) + INTF_HEADER_LEN + HEADER_ALIGNMENT)) {
1739 + newheadlen = sizeof(TxPD) + INTF_HEADER_LEN + HEADER_ALIGNMENT;
1740 + PRINTM(WARN, "Tx: Insufficient skb headroom %d\n", skb_headroom(skb));
1741 + /* Insufficient skb headroom - allocate a new skb */
1742 + newskb = skb_realloc_headroom(skb, newheadlen);
1743 + if (unlikely(newskb == NULL)) {
1744 + PRINTM(ERROR, "Tx: Cannot allocate skb\n");
1745 + ret = UAP_STATUS_FAILURE;
1750 + PRINTM(INFO, "new skb headroom %d\n", skb_headroom(skb));
1752 + /* headptr should be aligned */
1753 + headptr = skb->data - sizeof(TxPD) - INTF_HEADER_LEN;
1754 + headptr = (u8 *) ((u32) headptr & ~((u32) (HEADER_ALIGNMENT - 1)));
1756 + pLocalTxPD = (TxPD *) (headptr + INTF_HEADER_LEN);
1757 + memset(pLocalTxPD, 0, sizeof(TxPD));
1758 + pLocalTxPD->BssType = PKT_TYPE_MICROAP;
1759 + pLocalTxPD->TxPktLength = skb->len;
1760 + /* offset of actual data */
1761 + pLocalTxPD->TxPktOffset = (long) skb->data - (long) pLocalTxPD;
1762 + endian_convert_TxPD(pLocalTxPD);
1763 + *(u16 *) & headptr[0] =
1764 + uap_cpu_to_le16(skb->len + ((long) skb->data - (long) headptr));
1765 + *(u16 *) & headptr[2] = uap_cpu_to_le16(MV_TYPE_DAT);
1767 + sbi_host_to_card(priv, headptr,
1768 + skb->len + ((long) skb->data - (long) headptr));
1770 + PRINTM(ERROR, "uap_process_tx Error: sbi_host_to_card failed: 0x%X\n",
1772 + Adapter->dbg.num_tx_host_to_card_failure++;
1775 + PRINTM(DATA, "Data => FW\n");
1776 + DBG_HEXDUMP(DAT_D, "Tx", headptr,
1777 + MIN(skb->len + sizeof(TxPD), DATA_DUMP_LEN));
1785 +static struct netlink_kernel_cfg cfg = {
1786 + .groups = NL_MULTICAST_GROUP,
1790 + * @brief This function initializes the adapter structure
1791 + * and set default value to the member of adapter.
1793 + * @param priv A pointer to uap_private structure
1794 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
1797 +uap_init_sw(uap_private * priv)
1799 + uap_adapter *Adapter = priv->adapter;
1803 + if (!(Adapter->CmdBuf = kmalloc(MRVDRV_SIZE_OF_CMD_BUFFER, GFP_KERNEL))) {
1804 + PRINTM(INFO, "Failed to allocate command buffer!\n");
1806 + return UAP_STATUS_FAILURE;
1809 + Adapter->cmd_pending = FALSE;
1810 + Adapter->CmdWaitQWoken = FALSE;
1811 + Adapter->ps_state = PS_STATE_AWAKE;
1812 + Adapter->WakeupTries = 0;
1814 + memset(&Adapter->PSConfirmSleep, 0, sizeof(PS_CMD_ConfirmSleep));
1815 + /** SDIO header */
1816 + Adapter->PSConfirmSleep.SDLen =
1817 + uap_cpu_to_le16(sizeof(PS_CMD_ConfirmSleep));
1818 + Adapter->PSConfirmSleep.SDType = uap_cpu_to_le16(MV_TYPE_CMD);
1819 + Adapter->PSConfirmSleep.SeqNum = 0;
1820 + Adapter->PSConfirmSleep.Command = uap_cpu_to_le16(HOST_CMD_SLEEP_CONFIRM);
1821 + Adapter->PSConfirmSleep.Size = uap_cpu_to_le16(sizeof(HostCmd_DS_GEN));
1822 + Adapter->PSConfirmSleep.Result = 0;
1824 + init_waitqueue_head(&Adapter->cmdwait_q);
1825 + OS_INIT_SEMAPHORE(&Adapter->CmdSem);
1827 + skb_queue_head_init(&Adapter->tx_queue);
1828 + skb_queue_head_init(&Adapter->cmd_queue);
1830 + /* Status variable */
1831 + Adapter->HardwareStatus = HWInitializing;
1834 + Adapter->SurpriseRemoved = FALSE;
1836 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
1837 + Adapter->nl_sk = netlink_kernel_create(NETLINK_MARVELL,
1838 + NL_MULTICAST_GROUP, NULL,
1841 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
1842 + Adapter->nl_sk = netlink_kernel_create(NETLINK_MARVELL,
1843 + NL_MULTICAST_GROUP, NULL, NULL,
1846 + Adapter->nl_sk = netlink_kernel_create(&init_net, NETLINK_MARVELL, &cfg);
1849 + if (!Adapter->nl_sk) {
1851 + "Could not initialize netlink event passing mechanism!\n");
1854 + return UAP_STATUS_SUCCESS;
1858 + * @brief This function sends FUNC_INIT command to firmware
1860 + * @param priv A pointer to uap_private structure
1861 + * @return UAP_STATUS_SUCCESS on success, otherwise failure code
1864 +uap_func_init(uap_private * priv)
1866 + int ret = UAP_STATUS_SUCCESS;
1868 + HostCmd_DS_GEN *cmd;
1869 + uap_adapter *Adapter = priv->adapter;
1870 + struct sk_buff *skb;
1872 + if (Adapter->HardwareStatus != HWReady) {
1873 + PRINTM(ERROR, "uap_func_init:Hardware is not ready!\n");
1877 + skb = dev_alloc_skb(MRVDRV_SIZE_OF_CMD_BUFFER);
1879 + PRINTM(ERROR, "No free skb\n");
1883 + CmdSize = sizeof(HostCmd_DS_GEN);
1884 + cmd = (HostCmd_DS_GEN *) (skb->data + INTF_HEADER_LEN);
1885 + cmd->Command = uap_cpu_to_le16(HostCmd_CMD_FUNC_INIT);
1886 + cmd->Size = uap_cpu_to_le16(CmdSize);
1887 + skb_put(skb, CmdSize + INTF_HEADER_LEN);
1888 + PRINTM(CMND, "HostCmd_CMD_FUNC_INIT\n");
1889 + if (UAP_STATUS_SUCCESS !=
1890 + uap_process_cmd(priv, skb, HostCmd_OPTION_WAITFORRSP_TIMEOUT)) {
1891 + PRINTM(ERROR, "Fail to process cmd HostCmd_CMD_FUNC_INIT\n");
1901 + * @brief This function sends FUNC_SHUTDOWN command to firmware
1903 + * @param priv A pointer to uap_private structure
1904 + * @return UAP_STATUS_SUCCESS on success, otherwise failure code
1907 +uap_func_shutdown(uap_private * priv)
1909 + int ret = UAP_STATUS_SUCCESS;
1911 + HostCmd_DS_GEN *cmd;
1912 + uap_adapter *Adapter = priv->adapter;
1913 + struct sk_buff *skb;
1915 + if (Adapter->HardwareStatus != HWReady) {
1916 + PRINTM(ERROR, "uap_func_shutdown:Hardware is not ready!\n");
1920 + skb = dev_alloc_skb(MRVDRV_SIZE_OF_CMD_BUFFER);
1922 + PRINTM(ERROR, "No free skb\n");
1926 + CmdSize = sizeof(HostCmd_DS_GEN);
1927 + cmd = (HostCmd_DS_GEN *) (skb->data + INTF_HEADER_LEN);
1928 + cmd->Command = uap_cpu_to_le16(HostCmd_CMD_FUNC_SHUTDOWN);
1929 + cmd->Size = uap_cpu_to_le16(CmdSize);
1930 + skb_put(skb, CmdSize + INTF_HEADER_LEN);
1931 + PRINTM(CMND, "HostCmd_CMD_FUNC_SHUTDOWN\n");
1932 + if (UAP_STATUS_SUCCESS !=
1933 + uap_process_cmd(priv, skb, HostCmd_OPTION_WAITFORRSP_TIMEOUT)) {
1934 + PRINTM(ERROR, "Fail to process cmd HostCmd_CMD_FUNC_SHUTDOWN\n");
1944 + * @brief This function initializes firmware
1946 + * @param priv A pointer to uap_private structure
1947 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
1950 +uap_init_fw(uap_private * priv)
1952 + int ret = UAP_STATUS_SUCCESS;
1954 + sbi_disable_host_int(priv);
1955 + /* Check if firmware is already running */
1956 + if (sbi_check_fw_status(priv, 1) == UAP_STATUS_SUCCESS) {
1957 + PRINTM(MSG, "UAP FW already running! Skip FW download\n");
1959 + if ((ret = request_firmware(&priv->fw_helper, helper_name,
1960 + priv->hotplug_device)) < 0) {
1962 + "request_firmware() failed (helper), error code = %#x\n",
1967 + /* Download the helper */
1968 + ret = sbi_prog_helper(priv);
1972 + "Bootloader in invalid state! Helper download failed!\n");
1973 + ret = UAP_STATUS_FAILURE;
1976 + if ((ret = request_firmware(&priv->firmware, fw_name,
1977 + priv->hotplug_device)) < 0) {
1978 + PRINTM(FATAL, "request_firmware() failed, error code = %#x\n", ret);
1982 + /* Download the main firmware via the helper firmware */
1983 + if (sbi_prog_fw_w_helper(priv)) {
1984 + PRINTM(FATAL, "UAP FW download failed!\n");
1985 + ret = UAP_STATUS_FAILURE;
1988 + /* Check if the firmware is downloaded successfully or not */
1989 + if (sbi_check_fw_status(priv, MAX_FIRMWARE_POLL_TRIES) ==
1990 + UAP_STATUS_FAILURE) {
1991 + PRINTM(FATAL, "FW failed to be active in time!\n");
1992 + ret = UAP_STATUS_FAILURE;
1995 + PRINTM(MSG, "UAP FW is active\n");
1997 + sbi_enable_host_int(priv);
1998 + priv->adapter->HardwareStatus = HWReady;
1999 + if (uap_func_init(priv) != UAP_STATUS_SUCCESS) {
2000 + ret = UAP_STATUS_FAILURE;
2004 + if (priv->fw_helper)
2005 + release_firmware(priv->fw_helper);
2006 + if (priv->firmware)
2007 + release_firmware(priv->firmware);
2014 + * @brief This function frees the structure of adapter
2016 + * @param priv A pointer to uap_private structure
2020 +uap_free_adapter(uap_private * priv)
2022 + uap_adapter *Adapter = priv->adapter;
2027 + if ((Adapter->nl_sk) && ((Adapter->nl_sk)->sk_socket)) {
2028 + sock_release((Adapter->nl_sk)->sk_socket);
2029 + Adapter->nl_sk = NULL;
2031 + if (Adapter->CmdBuf)
2032 + kfree(Adapter->CmdBuf);
2033 + skb_queue_purge(&priv->adapter->tx_queue);
2034 + skb_queue_purge(&priv->adapter->cmd_queue);
2035 + /* Free the adapter object itself */
2037 + priv->adapter = NULL;
2044 + * @brief This function handles the major job in uap driver.
2045 + * it handles the event generated by firmware, rx data received
2046 + * from firmware and tx data sent from kernel.
2048 + * @param data A pointer to uap_thread structure
2049 + * @return BT_STATUS_SUCCESS
2052 +uap_service_main_thread(void *data)
2054 + uap_thread *thread = data;
2055 + uap_private *priv = thread->priv;
2056 + uap_adapter *Adapter = priv->adapter;
2057 + wait_queue_t wait;
2059 + struct sk_buff *skb;
2061 + uap_activate_thread(thread);
2062 + init_waitqueue_entry(&wait, current);
2063 + current->flags |= PF_NOFREEZE;
2066 + add_wait_queue(&thread->waitQ, &wait);
2067 + OS_SET_THREAD_STATE(TASK_INTERRUPTIBLE);
2068 + if ((Adapter->WakeupTries) ||
2069 + (!Adapter->IntCounter && Adapter->ps_state == PS_STATE_PRE_SLEEP) ||
2070 + (!priv->adapter->IntCounter
2071 + && (priv->uap_dev.data_sent ||
2072 + skb_queue_empty(&priv->adapter->tx_queue))
2073 + && (priv->uap_dev.cmd_sent || Adapter->cmd_pending ||
2074 + skb_queue_empty(&priv->adapter->cmd_queue))
2076 + PRINTM(INFO, "Main: Thread sleeping...\n");
2079 + OS_SET_THREAD_STATE(TASK_RUNNING);
2080 + remove_wait_queue(&thread->waitQ, &wait);
2081 + if (kthread_should_stop() || Adapter->SurpriseRemoved) {
2082 + PRINTM(INFO, "main-thread: break from main thread: "
2083 + "SurpriseRemoved=0x%x\n", Adapter->SurpriseRemoved);
2084 + /* Cancel pending command */
2085 + if (Adapter->cmd_pending == TRUE) {
2086 + /* Wake up cmd Q */
2087 + Adapter->CmdWaitQWoken = TRUE;
2088 + wake_up_interruptible(&Adapter->cmdwait_q);
2093 + PRINTM(INFO, "Main: Thread waking up...\n");
2094 + if (priv->adapter->IntCounter) {
2096 + Adapter->IntCounter = 0;
2098 + sbi_get_int_status(priv, &ireg);
2099 + } else if ((priv->adapter->ps_state == PS_STATE_SLEEP) &&
2100 + (!skb_queue_empty(&priv->adapter->cmd_queue) ||
2101 + !skb_queue_empty(&priv->adapter->tx_queue))) {
2102 + priv->adapter->WakeupTries++;
2103 + PRINTM(CMND, "%lu : Wakeup device...\n", os_time_get());
2104 + sbi_wakeup_firmware(priv);
2107 + if (Adapter->ps_state == PS_STATE_PRE_SLEEP)
2108 + uap_ps_cond_check(priv);
2110 + /* The PS state is changed during processing of Sleep Request event
2112 + if ((Adapter->ps_state == PS_STATE_SLEEP) ||
2113 + (Adapter->ps_state == PS_STATE_PRE_SLEEP))
2115 + /* Execute the next command */
2116 + if (!priv->uap_dev.cmd_sent && !Adapter->cmd_pending &&
2117 + (Adapter->HardwareStatus == HWReady)) {
2118 + if (!skb_queue_empty(&priv->adapter->cmd_queue)) {
2119 + skb = skb_dequeue(&priv->adapter->cmd_queue);
2121 + Adapter->CmdSize = 0;
2122 + Adapter->cmd_pending = TRUE;
2123 + Adapter->cmd_wait_option = skb->cb[0];
2124 + if (sbi_host_to_card(priv, skb->data, skb->len)) {
2125 + PRINTM(ERROR, "Cmd:sbi_host_to_card failed!\n");
2126 + Adapter->cmd_pending = FALSE;
2127 + Adapter->dbg.num_cmd_host_to_card_failure++;
2128 + /* Wake up cmd Q */
2129 + Adapter->CmdWaitQWoken = TRUE;
2130 + wake_up_interruptible(&Adapter->cmdwait_q);
2132 + if (Adapter->cmd_wait_option ==
2133 + HostCmd_OPTION_WAITFORSEND) {
2134 + /* Wake up cmd Q */
2135 + Adapter->CmdWaitQWoken = TRUE;
2136 + wake_up_interruptible(&Adapter->cmdwait_q);
2137 + Adapter->cmd_wait_option = FALSE;
2144 + if (!priv->uap_dev.data_sent && (Adapter->HardwareStatus == HWReady)) {
2145 + if (!skb_queue_empty(&priv->adapter->tx_queue)) {
2146 + skb = skb_dequeue(&priv->adapter->tx_queue);
2148 + if (uap_process_tx(priv, skb)) {
2149 + priv->stats.tx_dropped++;
2150 + priv->stats.tx_errors++;
2151 + os_start_queue(priv);
2153 + priv->stats.tx_packets++;
2154 + priv->stats.tx_bytes += skb->len;
2161 + uap_deactivate_thread(thread);
2163 + return UAP_STATUS_SUCCESS;
2167 + * @brief uap hostcmd ioctl handler
2169 + * @param dev A pointer to net_device structure
2170 + * @param req A pointer to ifreq structure
2171 + * @return UAP_STATUS_SUCCESS --success, otherwise fail
2173 +/********* format of ifr_data *************/
2174 +/* buf_len + Hostcmd_body */
2175 +/* buf_len: 4 bytes */
2176 +/* the length of the buf which */
2177 +/* can be used to return data */
2178 +/* to application */
2180 +/*******************************************/
2182 +uap_hostcmd_ioctl(struct net_device *dev, struct ifreq *req)
2185 + HostCmd_HEADER head;
2186 + uap_private *priv = (uap_private *) netdev_priv(dev);
2187 + uap_adapter *Adapter = priv->adapter;
2188 + int ret = UAP_STATUS_SUCCESS;
2189 + struct sk_buff *skb;
2193 + /* Sanity check */
2194 + if (req->ifr_data == NULL) {
2195 + PRINTM(ERROR, "uap_hostcmd_ioctl() corrupt data\n");
2199 + if (copy_from_user(&buf_len, req->ifr_data, sizeof(buf_len))) {
2200 + PRINTM(ERROR, "Copy from user failed\n");
2204 + memset(&head, 0, sizeof(HostCmd_HEADER));
2205 + /* Get the command size from user space */
2206 + if (copy_from_user
2207 + (&head, req->ifr_data + sizeof(buf_len), sizeof(HostCmd_HEADER))) {
2208 + PRINTM(ERROR, "Copy from user failed\n");
2212 + head.Size = uap_le16_to_cpu(head.Size);
2213 + if (head.Size > MRVDRV_SIZE_OF_CMD_BUFFER) {
2214 + PRINTM(ERROR, "CmdSize too big=%d\n", head.Size);
2218 + PRINTM(CMND, "ioctl: hostcmd=%x, size=%d,buf_len=%d\n", head.Command,
2219 + head.Size, buf_len);
2220 + skb = dev_alloc_skb(head.Size + INTF_HEADER_LEN);
2222 + PRINTM(ERROR, "No free skb\n");
2227 + /* Get the command from user space */
2228 + if (copy_from_user
2229 + (skb->data + INTF_HEADER_LEN, req->ifr_data + sizeof(buf_len),
2231 + PRINTM(ERROR, "Copy from user failed\n");
2235 + skb_put(skb, head.Size + INTF_HEADER_LEN);
2236 + if (UAP_STATUS_SUCCESS !=
2237 + uap_process_cmd(priv, skb, HostCmd_OPTION_WAITFORRSP)) {
2238 + PRINTM(ERROR, "Fail to process cmd\n");
2242 + if (!Adapter->CmdSize) {
2243 + PRINTM(ERROR, "Cmd Size is 0\n");
2247 + if (Adapter->CmdSize > buf_len) {
2248 + PRINTM(ERROR, "buf_len is too small\n");
2252 + /* Copy to user */
2254 + (req->ifr_data + sizeof(buf_len), Adapter->CmdBuf, Adapter->CmdSize)) {
2255 + PRINTM(ERROR, "Copy to user failed!\n");
2264 + * @brief uap power mode ioctl handler
2266 + * @param dev A pointer to net_device structure
2267 + * @param req A pointer to ifreq structure
2268 + * @return UAP_STATUS_SUCCESS --success, otherwise fail
2271 +uap_power_mode_ioctl(struct net_device *dev, struct ifreq *req)
2274 + int ret = UAP_STATUS_SUCCESS;
2275 + uap_private *priv = (uap_private *) netdev_priv(dev);
2276 + uap_adapter *Adapter = priv->adapter;
2277 + struct sk_buff *skb = NULL;
2278 + HostCmd_DS_COMMAND *cmd;
2281 + MrvlIEtypes_sleep_param_t *sleep_tlv = NULL;
2282 + MrvlIEtypes_inact_sleep_param_t *inact_tlv = NULL;
2283 + u16 tlv_buf_left = 0;
2284 + MrvlIEtypesHeader_t *tlvbuf = NULL;
2290 + /* Sanity check */
2291 + if (req->ifr_data == NULL) {
2292 + PRINTM(ERROR, "uap_power_mode_ioctl() corrupt data\n");
2297 + memset(&pm_cfg, 0, sizeof(ps_mgmt));
2298 + if (copy_from_user(&pm_cfg, req->ifr_data, sizeof(ps_mgmt))) {
2299 + PRINTM(ERROR, "Copy from user failed\n");
2304 + "ioctl power: flag=0x%x ps_mode=%d ctrl_bitmap=%d min_sleep=%d max_sleep=%d "
2305 + "inact_to=%d min_awake=%d max_awake=%d\n", pm_cfg.flags,
2306 + (int) pm_cfg.ps_mode, (int) pm_cfg.sleep_param.ctrl_bitmap,
2307 + (int) pm_cfg.sleep_param.min_sleep,
2308 + (int) pm_cfg.sleep_param.max_sleep,
2309 + (int) pm_cfg.inact_param.inactivity_to,
2310 + (int) pm_cfg.inact_param.min_awake,
2311 + (int) pm_cfg.inact_param.max_awake);
2314 + flags & ~(PS_FLAG_PS_MODE | PS_FLAG_SLEEP_PARAM |
2315 + PS_FLAG_INACT_SLEEP_PARAM)) {
2316 + PRINTM(ERROR, "Invalid parameter: flags = 0x%x\n", pm_cfg.flags);
2320 + if (pm_cfg.ps_mode > PS_MODE_INACTIVITY) {
2321 + PRINTM(ERROR, "Invalid parameter: ps_mode = %d\n", (int) pm_cfg.flags);
2326 + skb = dev_alloc_skb(MRVDRV_SIZE_OF_CMD_BUFFER);
2328 + PRINTM(INFO, "No free skb\n");
2333 + CmdSize = S_DS_GEN + sizeof(HostCmd_DS_POWER_MGMT_EXT);
2335 + cmd = (HostCmd_DS_COMMAND *) (skb->data + INTF_HEADER_LEN);
2336 + cmd->Command = uap_cpu_to_le16(HOST_CMD_POWER_MGMT_EXT);
2337 + if (!pm_cfg.flags) {
2338 + cmd->params.pm_cfg.action = uap_cpu_to_le16(ACTION_GET);
2340 + cmd->params.pm_cfg.action = uap_cpu_to_le16(ACTION_SET);
2341 + cmd->params.pm_cfg.power_mode = uap_cpu_to_le16(pm_cfg.ps_mode);
2342 + tlv = (u8 *) & cmd->params.pm_cfg + sizeof(HostCmd_DS_POWER_MGMT_EXT);
2344 + if ((pm_cfg.ps_mode) && (pm_cfg.flags & PS_FLAG_SLEEP_PARAM)) {
2345 + sleep_tlv = (MrvlIEtypes_sleep_param_t *) tlv;
2346 + sleep_tlv->header.Type = uap_cpu_to_le16(TLV_TYPE_AP_SLEEP_PARAM);
2347 + sleep_tlv->header.Len =
2348 + uap_cpu_to_le16(sizeof(MrvlIEtypes_sleep_param_t) -
2349 + sizeof(MrvlIEtypesHeader_t));
2350 + sleep_tlv->ctrl_bitmap =
2351 + uap_cpu_to_le32(pm_cfg.sleep_param.ctrl_bitmap);
2352 + sleep_tlv->min_sleep =
2353 + uap_cpu_to_le32(pm_cfg.sleep_param.min_sleep);
2354 + sleep_tlv->max_sleep =
2355 + uap_cpu_to_le32(pm_cfg.sleep_param.max_sleep);
2356 + CmdSize += sizeof(MrvlIEtypes_sleep_param_t);
2357 + tlv += sizeof(MrvlIEtypes_sleep_param_t);
2359 + if ((pm_cfg.ps_mode == PS_MODE_INACTIVITY) &&
2360 + (pm_cfg.flags & PS_FLAG_INACT_SLEEP_PARAM)) {
2361 + inact_tlv = (MrvlIEtypes_inact_sleep_param_t *) tlv;
2362 + inact_tlv->header.Type =
2363 + uap_cpu_to_le16(TLV_TYPE_AP_INACT_SLEEP_PARAM);
2364 + inact_tlv->header.Len =
2365 + uap_cpu_to_le16(sizeof(MrvlIEtypes_inact_sleep_param_t) -
2366 + sizeof(MrvlIEtypesHeader_t));
2367 + inact_tlv->inactivity_to =
2368 + uap_cpu_to_le32(pm_cfg.inact_param.inactivity_to);
2369 + inact_tlv->min_awake =
2370 + uap_cpu_to_le32(pm_cfg.inact_param.min_awake);
2371 + inact_tlv->max_awake =
2372 + uap_cpu_to_le32(pm_cfg.inact_param.max_awake);
2373 + CmdSize += sizeof(MrvlIEtypes_inact_sleep_param_t);
2374 + tlv += sizeof(MrvlIEtypes_inact_sleep_param_t);
2377 + cmd->Size = uap_cpu_to_le16(CmdSize);
2378 + skb_put(skb, CmdSize + INTF_HEADER_LEN);
2379 + if (UAP_STATUS_SUCCESS !=
2380 + uap_process_cmd(priv, skb, HostCmd_OPTION_WAITFORRSP)) {
2381 + PRINTM(ERROR, "Fail to process cmd POWER_MODE\n");
2385 + if (!Adapter->CmdSize) {
2386 + PRINTM(ERROR, "Cmd Size is 0\n");
2390 + cmd = (HostCmd_DS_COMMAND *) Adapter->CmdBuf;
2391 + cmd->Result = uap_le16_to_cpu(cmd->Result);
2392 + if (cmd->Result != UAP_STATUS_SUCCESS) {
2393 + PRINTM(ERROR, "HOST_CMD_APCMD_POWER_MODE fail=%x\n", cmd->Result);
2397 + if (pm_cfg.flags) {
2398 + Adapter->psmode = uap_le16_to_cpu(cmd->params.pm_cfg.power_mode);
2400 + pm_cfg.flags = PS_FLAG_PS_MODE;
2401 + pm_cfg.ps_mode = uap_le16_to_cpu(cmd->params.pm_cfg.power_mode);
2403 + cmd->Size - (sizeof(HostCmd_DS_POWER_MGMT_EXT) + S_DS_GEN);
2405 + (MrvlIEtypesHeader_t *) ((u8 *) & cmd->params.pm_cfg +
2406 + sizeof(HostCmd_DS_POWER_MGMT_EXT));
2407 + while (tlv_buf_left >= sizeof(MrvlIEtypesHeader_t)) {
2408 + tlv_type = uap_le16_to_cpu(tlvbuf->Type);
2409 + tlv_len = uap_le16_to_cpu(tlvbuf->Len);
2410 + switch (tlv_type) {
2411 + case TLV_TYPE_AP_SLEEP_PARAM:
2412 + sleep_tlv = (MrvlIEtypes_sleep_param_t *) tlvbuf;
2413 + pm_cfg.flags |= PS_FLAG_SLEEP_PARAM;
2414 + pm_cfg.sleep_param.ctrl_bitmap =
2415 + uap_le32_to_cpu(sleep_tlv->ctrl_bitmap);
2416 + pm_cfg.sleep_param.min_sleep =
2417 + uap_le32_to_cpu(sleep_tlv->min_sleep);
2418 + pm_cfg.sleep_param.max_sleep =
2419 + uap_le32_to_cpu(sleep_tlv->max_sleep);
2421 + case TLV_TYPE_AP_INACT_SLEEP_PARAM:
2422 + inact_tlv = (MrvlIEtypes_inact_sleep_param_t *) tlvbuf;
2423 + pm_cfg.flags |= PS_FLAG_INACT_SLEEP_PARAM;
2424 + pm_cfg.inact_param.inactivity_to =
2425 + uap_le32_to_cpu(inact_tlv->inactivity_to);
2426 + pm_cfg.inact_param.min_awake =
2427 + uap_le32_to_cpu(inact_tlv->min_awake);
2428 + pm_cfg.inact_param.max_awake =
2429 + uap_le32_to_cpu(inact_tlv->max_awake);
2432 + tlv_buf_left -= tlv_len + sizeof(MrvlIEtypesHeader_t);
2434 + (MrvlIEtypesHeader_t *) ((u8 *) tlvbuf + tlv_len +
2435 + sizeof(MrvlIEtypesHeader_t));
2437 + /* Copy to user */
2438 + if (copy_to_user(req->ifr_data, &pm_cfg, sizeof(ps_mgmt))) {
2439 + PRINTM(ERROR, "Copy to user failed!\n");
2450 + * @brief This function send bss_stop command to firmware
2452 + * @param priv A pointer to uap_private structure
2453 + * @return UAP_STATUS_SUCCESS on success, otherwise failure code
2456 +uap_bss_stop(uap_private * priv)
2458 + int ret = UAP_STATUS_SUCCESS;
2460 + HostCmd_DS_GEN *cmd;
2461 + uap_adapter *Adapter = priv->adapter;
2462 + struct sk_buff *skb;
2464 + if (Adapter->HardwareStatus != HWReady) {
2465 + PRINTM(ERROR, "uap_bss_stop:Hardware is not ready!\n");
2469 + skb = dev_alloc_skb(MRVDRV_SIZE_OF_CMD_BUFFER);
2471 + PRINTM(ERROR, "No free skb\n");
2475 + CmdSize = sizeof(HostCmd_DS_GEN);
2476 + cmd = (HostCmd_DS_GEN *) (skb->data + INTF_HEADER_LEN);
2477 + cmd->Command = uap_cpu_to_le16(HOST_CMD_APCMD_BSS_STOP);
2478 + cmd->Size = uap_cpu_to_le16(CmdSize);
2479 + skb_put(skb, CmdSize + INTF_HEADER_LEN);
2480 + PRINTM(CMND, "APCMD_BSS_STOP\n");
2481 + if (UAP_STATUS_SUCCESS !=
2482 + uap_process_cmd(priv, skb, HostCmd_OPTION_WAITFORRSP_TIMEOUT)) {
2483 + PRINTM(ERROR, "Fail to process cmd BSS_STOP\n");
2492 +/********************************************************
2494 +********************************************************/
2496 + * @brief This function send soft_reset command to firmware
2498 + * @param priv A pointer to uap_private structure
2499 + * @return UAP_STATUS_SUCCESS on success, otherwise failure code
2502 +uap_soft_reset(uap_private * priv)
2504 + int ret = UAP_STATUS_SUCCESS;
2506 + HostCmd_DS_GEN *cmd;
2507 + uap_adapter *Adapter = priv->adapter;
2508 + struct sk_buff *skb;
2510 + ret = uap_bss_stop(priv);
2511 + if (ret != UAP_STATUS_SUCCESS)
2513 + skb = dev_alloc_skb(MRVDRV_SIZE_OF_CMD_BUFFER);
2515 + PRINTM(ERROR, "No free skb\n");
2519 + CmdSize = sizeof(HostCmd_DS_GEN);
2520 + cmd = (HostCmd_DS_GEN *) (skb->data + INTF_HEADER_LEN);
2521 + cmd->Command = uap_cpu_to_le16(HOST_CMD_APCMD_SOFT_RESET);
2522 + cmd->Size = uap_cpu_to_le16(CmdSize);
2523 + skb_put(skb, CmdSize + INTF_HEADER_LEN);
2524 + PRINTM(CMND, "APCMD_SOFT_RESET\n");
2525 + if (UAP_STATUS_SUCCESS !=
2526 + uap_process_cmd(priv, skb, HostCmd_OPTION_WAITFORSEND)) {
2527 + PRINTM(ERROR, "Fail to process cmd SOFT_RESET\n");
2531 + Adapter->SurpriseRemoved = TRUE;
2532 + /* delay to allow hardware complete reset */
2533 + os_sched_timeout(5);
2534 + if (priv->MediaConnected == TRUE) {
2535 + os_stop_queue(priv);
2536 + os_carrier_off(priv);
2537 + priv->MediaConnected = FALSE;
2539 + Adapter->CmdSize = 0;
2540 + Adapter->CmdWaitQWoken = TRUE;
2541 + wake_up_interruptible(&Adapter->cmdwait_q);
2542 + skb_queue_purge(&priv->adapter->tx_queue);
2543 + skb_queue_purge(&priv->adapter->cmd_queue);
2550 + * @brief This function processes received packet and forwards it
2551 + * to kernel/upper layer
2553 + * @param priv A pointer to uap_private
2554 + * @param skb A pointer to skb which includes the received packet
2555 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
2558 +uap_process_rx_packet(uap_private * priv, struct sk_buff *skb)
2560 + int ret = UAP_STATUS_SUCCESS;
2563 + priv->adapter->ps_state = PS_STATE_AWAKE;
2564 + pRxPD = (RxPD *) skb->data;
2565 + endian_convert_RxPD(pRxPD);
2566 + DBG_HEXDUMP(DAT_D, "Rx", skb->data, MIN(skb->len, DATA_DUMP_LEN));
2567 + skb_pull(skb, pRxPD->RxPktOffset);
2568 + priv->stats.rx_packets++;
2569 + priv->stats.rx_bytes += skb->len;
2570 + os_upload_rx_packet(priv, skb);
2576 + * @brief This function opens the network device
2578 + * @param dev A pointer to net_device structure
2579 + * @return UAP_STATUS_SUCCESS
2582 +uap_open(struct net_device *dev)
2584 + uap_private *priv = (uap_private *) (uap_private *) netdev_priv(dev);
2585 + uap_adapter *Adapter = priv->adapter;
2590 + /* On some systems the device open handler will be called before HW ready. */
2591 + /* Use the following flag check and wait function to work around the issue. */
2592 + while ((Adapter->HardwareStatus != HWReady) &&
2593 + (i < MAX_WAIT_DEVICE_READY_COUNT)) {
2595 + os_sched_timeout(100);
2597 + if (i >= MAX_WAIT_DEVICE_READY_COUNT) {
2598 + PRINTM(FATAL, "HW not ready, uap_open() return failure\n");
2600 + return UAP_STATUS_FAILURE;
2603 + if (MODULE_GET == 0)
2604 + return UAP_STATUS_FAILURE;
2606 + priv->open = TRUE;
2607 + if (priv->MediaConnected == TRUE) {
2608 + os_carrier_on(priv);
2609 + os_start_queue(priv);
2611 + os_stop_queue(priv);
2612 + os_carrier_off(priv);
2615 + return UAP_STATUS_SUCCESS;
2619 + * @brief This function closes the network device
2621 + * @param dev A pointer to net_device structure
2622 + * @return UAP_STATUS_SUCCESS
2625 +uap_close(struct net_device *dev)
2627 + uap_private *priv = (uap_private *) netdev_priv(dev);
2630 + skb_queue_purge(&priv->adapter->tx_queue);
2631 + os_stop_queue(priv);
2632 + os_carrier_off(priv);
2635 + priv->open = FALSE;
2637 + return UAP_STATUS_SUCCESS;
2641 + * @brief This function returns the network statistics
2643 + * @param dev A pointer to uap_private structure
2644 + * @return A pointer to net_device_stats structure
2646 +static struct net_device_stats *
2647 +uap_get_stats(struct net_device *dev)
2649 + uap_private *priv = (uap_private *) netdev_priv(dev);
2651 + return &priv->stats;
2655 + * @brief This function sets the MAC address to firmware.
2657 + * @param dev A pointer to uap_private structure
2658 + * @param addr MAC address to set
2659 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
2662 +uap_set_mac_address(struct net_device *dev, void *addr)
2664 + int ret = UAP_STATUS_SUCCESS;
2665 + uap_private *priv = (uap_private *) netdev_priv(dev);
2666 + struct sockaddr *pHwAddr = (struct sockaddr *) addr;
2668 + HostCmd_DS_COMMAND *cmd;
2669 + MrvlIEtypes_MacAddr_t *pMacAddrTlv;
2670 + uap_adapter *Adapter = priv->adapter;
2671 + struct sk_buff *skb;
2675 + /* Dump MAC address */
2676 + DBG_HEXDUMP(CMD_D, "Original MAC addr", dev->dev_addr, ETH_ALEN);
2677 + DBG_HEXDUMP(CMD_D, "New MAC addr", pHwAddr->sa_data, ETH_ALEN);
2678 + if (priv->open && (priv->MediaConnected == TRUE)) {
2679 + os_carrier_on(priv);
2680 + os_start_queue(priv);
2682 + skb = dev_alloc_skb(MRVDRV_SIZE_OF_CMD_BUFFER);
2684 + PRINTM(ERROR, "No free skb\n");
2689 + S_DS_GEN + sizeof(HostCmd_SYS_CONFIG) + sizeof(MrvlIEtypes_MacAddr_t);
2690 + cmd = (HostCmd_DS_COMMAND *) (skb->data + INTF_HEADER_LEN);
2691 + cmd->Command = uap_cpu_to_le16(HOST_CMD_APCMD_SYS_CONFIGURE);
2692 + cmd->Size = uap_cpu_to_le16(CmdSize);
2693 + cmd->params.sys_config.Action = uap_cpu_to_le16(ACTION_SET);
2695 + (MrvlIEtypes_MacAddr_t *) ((u8 *) cmd + S_DS_GEN +
2696 + sizeof(HostCmd_SYS_CONFIG));
2697 + pMacAddrTlv->Header.Type = uap_cpu_to_le16(MRVL_AP_MAC_ADDRESS_TLV_ID);
2698 + pMacAddrTlv->Header.Len = uap_cpu_to_le16(ETH_ALEN);
2699 + memcpy(pMacAddrTlv->ApMacAddr, pHwAddr->sa_data, ETH_ALEN);
2700 + skb_put(skb, CmdSize + INTF_HEADER_LEN);
2701 + PRINTM(CMND, "set_mac_address\n");
2702 + if (UAP_STATUS_SUCCESS !=
2703 + uap_process_cmd(priv, skb, HostCmd_OPTION_WAITFORRSP_TIMEOUT)) {
2704 + PRINTM(ERROR, "Fail to set mac address\n");
2708 + if (!Adapter->CmdSize) {
2709 + PRINTM(ERROR, "Cmd Size is 0\n");
2713 + cmd = (HostCmd_DS_COMMAND *) Adapter->CmdBuf;
2714 + cmd->Result = uap_cpu_to_le16(cmd->Result);
2715 + if (cmd->Result != UAP_STATUS_SUCCESS) {
2716 + PRINTM(ERROR, "set mac addrress fail,cmd result=%x\n", cmd->Result);
2719 + memcpy(dev->dev_addr, pHwAddr->sa_data, ETH_ALEN);
2725 + * @brief This function handles the timeout of packet
2728 + * @param dev A pointer to net_device structure
2732 +uap_tx_timeout(struct net_device *dev)
2734 + uap_private *priv = (uap_private *) netdev_priv(dev);
2738 + PRINTM(DATA, "Tx timeout\n");
2739 + UpdateTransStart(dev);
2740 + priv->num_tx_timeout++;
2741 + priv->adapter->IntCounter++;
2742 + wake_up_interruptible(&priv->MainThread.waitQ);
2748 + * @brief This function handles packet transmission
2750 + * @param skb A pointer to sk_buff structure
2751 + * @param dev A pointer to net_device structure
2752 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
2755 +uap_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
2757 + uap_private *priv = (uap_private *) netdev_priv(dev);
2758 + int ret = UAP_STATUS_SUCCESS;
2761 + PRINTM(DATA, "Data <= kernel\n");
2762 + DBG_HEXDUMP(DAT_D, "Tx", skb->data, MIN(skb->len, DATA_DUMP_LEN));
2763 + /* skb sanity check */
2764 + if (!skb->len || (skb->len > MRVDRV_MAXIMUM_ETH_PACKET_SIZE)) {
2765 + PRINTM(ERROR, "Tx Error: Bad skb length %d : %d\n", skb->len,
2766 + MRVDRV_MAXIMUM_ETH_PACKET_SIZE);
2767 + priv->stats.tx_dropped++;
2771 + skb_queue_tail(&priv->adapter->tx_queue, skb);
2772 + wake_up_interruptible(&priv->MainThread.waitQ);
2773 + if (skb_queue_len(&priv->adapter->tx_queue) > TX_HIGH_WATERMARK) {
2774 + UpdateTransStart(dev);
2775 + os_stop_queue(priv);
2783 + * @brief ioctl function - entry point
2785 + * @param dev A pointer to net_device structure
2786 + * @param req A pointer to ifreq structure
2787 + * @param cmd command
2788 + * @return UAP_STATUS_SUCCESS--success, otherwise fail
2791 +uap_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
2793 + int ret = UAP_STATUS_SUCCESS;
2797 + PRINTM(CMND, "uap_do_ioctl: ioctl cmd = 0x%x\n", cmd);
2801 + ret = uap_hostcmd_ioctl(dev, req);
2803 + case UAP_POWER_MODE:
2804 + ret = uap_power_mode_ioctl(dev, req);
2816 + * @brief This function handles events generated by firmware
2818 + * @param priv A pointer to uap_private structure
2819 + * @param payload A pointer to payload buffer
2820 + * @param len Length of the payload
2821 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
2824 +uap_process_event(uap_private * priv, u8 * payload, uint len)
2826 + int ret = UAP_STATUS_SUCCESS;
2827 + uap_adapter *Adapter = priv->adapter;
2828 + struct sk_buff *skb = NULL;
2829 + struct nlmsghdr *nlh = NULL;
2830 + struct sock *sk = Adapter->nl_sk;
2834 + Adapter->ps_state = PS_STATE_AWAKE;
2835 + if (len > NL_MAX_PAYLOAD) {
2836 + PRINTM(ERROR, "event size is too big!!! len=%d\n", len);
2837 + ret = UAP_STATUS_FAILURE;
2840 + pEvent = (AP_Event *) payload;
2841 + PRINTM(CMND, "Event: %d\n", pEvent->EventId);
2842 + switch (pEvent->EventId) {
2843 + case MICRO_AP_EV_ID_BSS_START:
2844 + memcpy(priv->uap_dev.netdev->dev_addr, pEvent->MacAddr, ETH_ALEN);
2845 + DBG_HEXDUMP(CMD_D, "BSS MAC addr", priv->uap_dev.netdev->dev_addr,
2848 + case MICRO_AP_EV_BSS_ACTIVE:
2850 + priv->MediaConnected = TRUE;
2851 + os_carrier_on(priv);
2852 + os_start_queue(priv);
2854 + case MICRO_AP_EV_BSS_IDLE:
2855 + os_stop_queue(priv);
2856 + os_carrier_off(priv);
2857 + priv->MediaConnected = FALSE;
2859 + case EVENT_PS_AWAKE:
2860 + PRINTM(CMND, "UAP: PS_AWAKE\n");
2861 + Adapter->ps_state = PS_STATE_AWAKE;
2862 + Adapter->WakeupTries = 0;
2864 + case EVENT_PS_SLEEP:
2865 + PRINTM(CMND, "UAP: PS_SLEEP\n");
2866 + Adapter->ps_state = PS_STATE_PRE_SLEEP;
2871 + if ((pEvent->EventId == EVENT_PS_AWAKE) ||
2872 + (pEvent->EventId == EVENT_PS_SLEEP))
2875 + /* Allocate skb */
2876 + if (!(skb = alloc_skb(NLMSG_SPACE(NL_MAX_PAYLOAD), GFP_ATOMIC))) {
2877 + PRINTM(ERROR, "Could not allocate skb for netlink.\n");
2878 + ret = UAP_STATUS_FAILURE;
2881 + nlh = (struct nlmsghdr *) skb->data;
2882 + nlh->nlmsg_len = NLMSG_SPACE(len);
2885 + nlh->nlmsg_pid = 0;
2886 + nlh->nlmsg_flags = 0;
2889 + skb_put(skb, nlh->nlmsg_len);
2890 + memcpy(NLMSG_DATA(nlh), payload, len);
2893 + NETLINK_CB(skb).portid = 0;
2895 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
2896 + /* Multicast message */
2897 + NETLINK_CB(skb).dst_pid = 0;
2900 + /* Multicast group number */
2901 + NETLINK_CB(skb).dst_group = NL_MULTICAST_GROUP;
2903 + /* Send message */
2904 + netlink_broadcast(sk, skb, 0, NL_MULTICAST_GROUP, GFP_KERNEL);
2906 + ret = UAP_STATUS_SUCCESS;
2908 + PRINTM(ERROR, "Could not send event through NETLINK. Link down.\n");
2909 + ret = UAP_STATUS_FAILURE;
2917 + * @brief This function handles the interrupt. it will change PS
2918 + * state if applicable. it will wake up main_thread to handle
2919 + * the interrupt event as well.
2921 + * @param priv A pointer to uap_private structure
2925 +uap_interrupt(uap_private * priv)
2928 + priv->adapter->IntCounter++;
2929 + priv->adapter->WakeupTries = 0;
2930 + PRINTM(INFO, "*\n");
2931 + wake_up_interruptible(&priv->MainThread.waitQ);
2937 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
2938 +/** Network device handlers */
2939 +static const struct net_device_ops uap_netdev_ops = {
2940 + .ndo_open = uap_open,
2941 + .ndo_start_xmit = uap_hard_start_xmit,
2942 + .ndo_stop = uap_close,
2943 + .ndo_do_ioctl = uap_do_ioctl,
2944 + .ndo_set_mac_address = uap_set_mac_address,
2945 + .ndo_tx_timeout = uap_tx_timeout,
2946 + .ndo_get_stats = uap_get_stats,
2951 + * @brief This function adds the card. it will probe the
2952 + * card, allocate the uap_priv and initialize the device.
2954 + * @param card A pointer to card
2955 + * @return A pointer to uap_private structure
2958 +uap_add_card(void *card)
2960 + struct net_device *dev = NULL;
2961 + uap_private *priv = NULL;
2965 + if (OS_ACQ_SEMAPHORE_BLOCK(&AddRemoveCardSem))
2966 + goto exit_sem_err;
2968 + /* Allocate an Ethernet device */
2969 + if (!(dev = alloc_etherdev(sizeof(uap_private)))) {
2970 + PRINTM(FATAL, "Init ethernet device failed!\n");
2973 + priv = (uap_private *) netdev_priv(dev);
2975 + /* Allocate name */
2976 + if (dev_alloc_name(dev, "uap%d") < 0) {
2977 + PRINTM(ERROR, "Could not allocate device name!\n");
2981 + /* Allocate buffer for uap_adapter */
2982 + if (!(priv->adapter = kmalloc(sizeof(uap_adapter), GFP_KERNEL))) {
2983 + PRINTM(FATAL, "Allocate buffer for uap_adapter failed!\n");
2986 + memset(priv->adapter, 0, sizeof(uap_adapter));
2988 + priv->uap_dev.netdev = dev;
2989 + priv->uap_dev.card = card;
2990 + priv->MediaConnected = FALSE;
2992 + ((struct sdio_mmc_card *) card)->priv = priv;
2994 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
2995 + SET_MODULE_OWNER(dev);
2998 + /* Setup the OS Interface to our functions */
2999 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
3000 + dev->open = uap_open;
3001 + dev->stop = uap_close;
3002 + dev->hard_start_xmit = uap_hard_start_xmit;
3003 + dev->tx_timeout = uap_tx_timeout;
3004 + dev->get_stats = uap_get_stats;
3005 + dev->do_ioctl = uap_do_ioctl;
3006 + dev->set_mac_address = uap_set_mac_address;
3007 + dev->set_multicast_list = uap_set_multicast_list;
3009 + dev->netdev_ops = &uap_netdev_ops;
3011 + dev->watchdog_timeo = MRVDRV_DEFAULT_WATCHDOG_TIMEOUT;
3012 + dev->hard_header_len += sizeof(TxPD) + INTF_HEADER_LEN;
3013 + dev->hard_header_len += HEADER_ALIGNMENT;
3014 +#define NETIF_F_DYNALLOC 16
3015 + dev->features |= NETIF_F_DYNALLOC;
3016 + dev->flags |= IFF_BROADCAST | IFF_MULTICAST;
3019 + if (uap_init_sw(priv)) {
3020 + PRINTM(FATAL, "Software Init Failed\n");
3024 + PRINTM(INFO, "Starting kthread...\n");
3025 + priv->MainThread.priv = priv;
3026 + spin_lock_init(&priv->driver_lock);
3027 + uap_create_thread(uap_service_main_thread, &priv->MainThread,
3028 + "uap_main_service");
3029 + while (priv->MainThread.pid == 0) {
3030 + os_sched_timeout(2);
3033 + /* Register the device */
3034 + if (sbi_register_dev(priv) < 0) {
3035 + PRINTM(FATAL, "Failed to register uap device!\n");
3036 + goto err_registerdev;
3038 +#ifdef FW_DNLD_NEEDED
3039 + SET_NETDEV_DEV(dev, priv->hotplug_device);
3042 + /* Init FW and HW */
3043 + if (uap_init_fw(priv)) {
3044 + PRINTM(FATAL, "Firmware Init Failed\n");
3048 + priv->uap_dev.cmd_sent = FALSE;
3049 + priv->uap_dev.data_sent = FALSE;
3051 + /* Get mac address from firmware */
3052 + if (uap_get_mac_address(priv)) {
3053 + PRINTM(FATAL, "Fail to get mac address\n");
3056 + /* Register network device */
3057 + if (register_netdev(dev)) {
3058 + printk(KERN_ERR "Cannot register network device!\n");
3061 +#ifdef CONFIG_PROC_FS
3062 + uap_proc_entry(priv, dev);
3063 + uap_debug_entry(priv, dev);
3064 +#endif /* CPNFIG_PROC_FS */
3065 + OS_REL_SEMAPHORE(&AddRemoveCardSem);
3070 + sbi_unregister_dev(priv);
3072 + ((struct sdio_mmc_card *) card)->priv = NULL;
3073 + /* Stop the thread servicing the interrupts */
3074 + priv->adapter->SurpriseRemoved = TRUE;
3075 + wake_up_interruptible(&priv->MainThread.waitQ);
3076 + while (priv->MainThread.pid) {
3077 + os_sched_timeout(1);
3081 + if (dev->reg_state == NETREG_REGISTERED)
3082 + unregister_netdev(dev);
3083 + if (priv->adapter)
3084 + uap_free_adapter(priv);
3088 + OS_REL_SEMAPHORE(&AddRemoveCardSem);
3095 + * @brief This function removes the card.
3097 + * @param card A pointer to card
3098 + * @return UAP_STATUS_SUCCESS
3101 +uap_remove_card(void *card)
3103 + uap_private *priv = uappriv;
3104 + uap_adapter *Adapter;
3105 + struct net_device *dev;
3109 + if (OS_ACQ_SEMAPHORE_BLOCK(&AddRemoveCardSem))
3110 + goto exit_sem_err;
3112 + if (!priv || !(Adapter = priv->adapter)) {
3115 + Adapter->SurpriseRemoved = TRUE;
3116 + if (Adapter->cmd_pending == TRUE) {
3117 + /* Wake up cmd Q */
3118 + Adapter->CmdWaitQWoken = TRUE;
3119 + wake_up_interruptible(&Adapter->cmdwait_q);
3121 + dev = priv->uap_dev.netdev;
3122 + if (priv->MediaConnected == TRUE) {
3123 + os_stop_queue(priv);
3124 + os_carrier_off(priv);
3125 + priv->MediaConnected = FALSE;
3127 + Adapter->CmdSize = 0;
3128 + Adapter->CmdWaitQWoken = TRUE;
3129 + wake_up_interruptible(&Adapter->cmdwait_q);
3130 + skb_queue_purge(&priv->adapter->tx_queue);
3131 + skb_queue_purge(&priv->adapter->cmd_queue);
3133 + /* Disable interrupts on the card */
3134 + sbi_disable_host_int(priv);
3135 + PRINTM(INFO, "netdev_finish_unregister: %s%s.\n", dev->name,
3136 + (dev->features & NETIF_F_DYNALLOC) ? "" : ", old style");
3137 + unregister_netdev(dev);
3138 + PRINTM(INFO, "Unregister finish\n");
3139 + wake_up_interruptible(&priv->MainThread.waitQ);
3140 + while (priv->MainThread.pid) {
3141 + os_sched_timeout(1);
3144 + if ((Adapter->nl_sk) && ((Adapter->nl_sk)->sk_socket)) {
3145 + sock_release((Adapter->nl_sk)->sk_socket);
3146 + Adapter->nl_sk = NULL;
3148 +#ifdef CONFIG_PROC_FS
3149 + uap_debug_remove(priv);
3150 + uap_proc_remove(priv);
3152 + sbi_unregister_dev(priv);
3153 + PRINTM(INFO, "Free Adapter\n");
3154 + uap_free_adapter(priv);
3155 + priv->uap_dev.netdev = NULL;
3160 + OS_REL_SEMAPHORE(&AddRemoveCardSem);
3163 + return UAP_STATUS_SUCCESS;
3167 + * @brief This function initializes module.
3169 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
3172 +uap_init_module(void)
3174 + int ret = UAP_STATUS_SUCCESS;
3177 + OS_INIT_SEMAPHORE(&AddRemoveCardSem);
3178 + ret = sbi_register();
3184 + * @brief This function cleans module
3189 +uap_cleanup_module(void)
3193 + if (OS_ACQ_SEMAPHORE_BLOCK(&AddRemoveCardSem))
3194 + goto exit_sem_err;
3196 + if ((uappriv) && (uappriv->adapter)) {
3197 + uap_func_shutdown(uappriv);
3199 + OS_REL_SEMAPHORE(&AddRemoveCardSem);
3205 +module_init(uap_init_module);
3206 +module_exit(uap_cleanup_module);
3207 +module_param(helper_name, charp, 0);
3208 +MODULE_PARM_DESC(helper_name, "Helper name");
3209 +module_param(fw_name, charp, 0);
3210 +MODULE_PARM_DESC(fw_name, "Firmware name");
3212 +MODULE_DESCRIPTION("M-UAP Driver");
3213 +MODULE_AUTHOR("Marvell International Ltd.");
3214 +MODULE_VERSION(DRIVER_VERSION);
3215 +MODULE_LICENSE("GPL");
3216 diff -Naur backports-3.18.1-1.org/drivers/net/wireless/libertas_uap/uap_proc.c backports-3.18.1-1/drivers/net/wireless/libertas_uap/uap_proc.c
3217 --- backports-3.18.1-1.org/drivers/net/wireless/libertas_uap/uap_proc.c 1970-01-01 01:00:00.000000000 +0100
3218 +++ backports-3.18.1-1/drivers/net/wireless/libertas_uap/uap_proc.c 2014-12-29 20:37:43.952431125 +0100
3220 +/** @file uap_proc.c
3221 + * @brief This file contains functions for proc file.
3223 + * Copyright (C) 2008-2009, Marvell International Ltd.
3225 + * This software file (the "File") is distributed by Marvell International
3226 + * Ltd. under the terms of the GNU General Public License Version 2, June 1991
3227 + * (the "License"). You may use, redistribute and/or modify this File in
3228 + * accordance with the terms and conditions of the License, a copy of which
3229 + * is available along with the File in the gpl.txt file or by writing to
3230 + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3231 + * 02111-1307 or on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
3233 + * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
3234 + * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
3235 + * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
3236 + * this warranty disclaimer.
3239 +#ifdef CONFIG_PROC_FS
3240 +#include <linux/proc_fs.h>
3241 +#include <linux/seq_file.h>
3242 +#include "uap_headers.h"
3244 +/** /proc directory root */
3245 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
3246 +#define PROC_DIR NULL
3247 +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
3248 +#define PROC_DIR &proc_root
3250 +#define PROC_DIR proc_net
3253 +/********************************************************
3255 +********************************************************/
3257 +/********************************************************
3259 +********************************************************/
3261 +/********************************************************
3263 +********************************************************/
3265 +static int uap_info_proc_show(struct seq_file *s, void *data) {
3267 + struct net_device *netdev = (struct net_device*)s->private;
3268 + struct netdev_hw_addr *ha;
3269 + uap_private *priv = (uap_private *) netdev_priv(netdev);
3271 + seq_printf(s, "driver_name = " "\"uap\"\n");
3272 + seq_printf(s, "driver_version = %s-(FP%s)", DRIVER_VERSION, FPNUM);
3273 + seq_printf(s, "\nInterfaceName=\"%s\"\n", netdev->name);
3275 + seq_printf(s, "State=\"%s\"\n",
3276 + ((priv->MediaConnected ==
3277 + FALSE) ? "Disconnected" : "Connected"));
3278 + seq_printf(s, "MACAddress=\"%02x:%02x:%02x:%02x:%02x:%02x\"\n",
3279 + netdev->dev_addr[0], netdev->dev_addr[1], netdev->dev_addr[2],
3280 + netdev->dev_addr[3], netdev->dev_addr[4], netdev->dev_addr[5]);
3282 + netdev_for_each_mc_addr(ha, netdev) {
3285 + seq_printf(s, "MCCount=\"%d\"\n", i);
3288 + * Put out the multicast list
3291 + netdev_for_each_mc_addr(ha, netdev) {
3293 + "MCAddr[%d]=\"%02x:%02x:%02x:%02x:%02x:%02x\"\n",
3295 + ha->addr[0], ha->addr[1],
3296 + ha->addr[2], ha->addr[3],
3297 + ha->addr[4], ha->addr[5]);
3300 + seq_printf(s, "num_tx_bytes = %lu\n", priv->stats.tx_bytes);
3301 + seq_printf(s, "num_rx_bytes = %lu\n", priv->stats.rx_bytes);
3302 + seq_printf(s, "num_tx_pkts = %lu\n", priv->stats.tx_packets);
3303 + seq_printf(s, "num_rx_pkts = %lu\n", priv->stats.rx_packets);
3304 + seq_printf(s, "num_tx_pkts_dropped = %lu\n", priv->stats.tx_dropped);
3305 + seq_printf(s, "num_rx_pkts_dropped = %lu\n", priv->stats.rx_dropped);
3306 + seq_printf(s, "num_tx_pkts_err = %lu\n", priv->stats.tx_errors);
3307 + seq_printf(s, "num_rx_pkts_err = %lu\n", priv->stats.rx_errors);
3308 + seq_printf(s, "num_tx_timeout = %u\n", priv->num_tx_timeout);
3309 + seq_printf(s, "carrier %s\n",
3310 + ((netif_carrier_ok(priv->uap_dev.netdev)) ? "on" : "off"));
3311 + seq_printf(s, "tx queue %s\n",
3312 + ((netif_queue_stopped(priv->uap_dev.netdev)) ? "stopped" :
3318 +static int uap_info_proc_open(struct inode *inode, struct file *file) {
3319 + return single_open(file, uap_info_proc_show, PDE_DATA(inode));
3322 +static int uap_hwstatus_proc_show(struct seq_file *s, void *data) {
3323 + struct net_device *netdev = (struct net_device*)s->private;
3324 + uap_private *priv = (uap_private *) netdev_priv(netdev);
3327 + seq_printf(s, "%d\n", priv->adapter->HardwareStatus);
3333 +static int uap_hwstatus_proc_open(struct inode *inode, struct file *file) {
3334 + return single_open(file, uap_hwstatus_proc_show, PDE_DATA(inode));
3337 +static ssize_t uap_hwstatus_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *data) {
3338 + struct net_device *netdev = (struct net_device *)PDE_DATA(file_inode(file));
3339 + uap_private *priv = (uap_private *) netdev_priv(netdev);
3344 + if (count > sizeof(value))
3347 + if (copy_from_user(&value, buffer, count))
3350 + hwstatus = string_to_number(value);
3351 + switch (hwstatus) {
3353 + PRINTM(MSG, "reset hw\n");
3354 + uap_soft_reset(priv);
3355 + priv->adapter->HardwareStatus = HWReset;
3365 +static const struct file_operations uap_info_proc_fops = {
3366 + .owner = THIS_MODULE,
3367 + .open = uap_info_proc_open,
3369 + .llseek = seq_lseek,
3370 + .release = single_release,
3373 +static const struct file_operations uap_hwstatus_proc_fops = {
3374 + .owner = THIS_MODULE,
3375 + .open = uap_hwstatus_proc_open,
3377 + .llseek = seq_lseek,
3378 + .release = single_release,
3379 + .write = uap_hwstatus_proc_write,
3382 +/********************************************************
3384 +********************************************************/
3386 + * @brief create uap proc file
3388 + * @param priv pointer uap_private
3389 + * @param dev pointer net_device
3393 +uap_proc_entry(uap_private * priv, struct net_device *dev)
3395 + PRINTM(INFO, "Creating Proc Interface\n");
3396 + /* Check if uap directory already exists */
3397 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
3398 + struct proc_dir_entry *r = PROC_DIR;
3400 + for (r = r->subdir; r; r = r->next) {
3401 + if (r->namelen && !strcmp("uap", r->name)) {
3402 + /* Directory exists */
3403 + PRINTM(WARN, "proc directory already exists!\n");
3404 + priv->proc_uap = r;
3409 + if (!priv->proc_uap) {
3410 + priv->proc_uap = proc_mkdir("uap", PROC_DIR);
3411 + if (!priv->proc_uap)
3414 + priv->proc_entry = proc_mkdir(dev->name, priv->proc_uap);
3416 + if (priv->proc_entry) {
3417 + proc_create_data("info", 0644, priv->proc_entry, &uap_info_proc_fops, dev);
3418 + proc_create_data("hwinfo", 0644, priv->proc_entry, &uap_hwstatus_proc_fops, dev);
3423 + * @brief remove proc file
3425 + * @param priv pointer uap_private
3429 +uap_proc_remove(uap_private * priv)
3431 + if (priv->proc_uap) {
3432 + if (priv->proc_entry) {
3433 + remove_proc_entry("info", priv->proc_entry);
3434 + remove_proc_entry("hwstatus", priv->proc_entry);
3436 + remove_proc_entry(priv->uap_dev.netdev->name, priv->proc_uap);
3441 + * @brief convert string to number
3443 + * @param s pointer to numbered string
3444 + * @return converted number from string s
3447 +string_to_number(char *s)
3453 + if (strncmp(s, "-", 1) == 0) {
3457 + if ((strncmp(s, "0x", 2) == 0) || (strncmp(s, "0X", 2) == 0)) {
3463 + for (s = s; *s != 0; s++) {
3464 + if ((*s >= '0') && (*s <= '9'))
3465 + r = (r * base) + (*s - '0');
3466 + else if ((*s >= 'A') && (*s <= 'F'))
3467 + r = (r * base) + (*s - 'A' + 10);
3468 + else if ((*s >= 'a') && (*s <= 'f'))
3469 + r = (r * base) + (*s - 'a' + 10);
3478 diff -Naur backports-3.18.1-1.org/drivers/net/wireless/libertas_uap/uap_sdio_mmc.c backports-3.18.1-1/drivers/net/wireless/libertas_uap/uap_sdio_mmc.c
3479 --- backports-3.18.1-1.org/drivers/net/wireless/libertas_uap/uap_sdio_mmc.c 1970-01-01 01:00:00.000000000 +0100
3480 +++ backports-3.18.1-1/drivers/net/wireless/libertas_uap/uap_sdio_mmc.c 2014-12-29 20:37:43.955764567 +0100
3482 +/** @file uap_sdio_mmc.c
3483 + * @brief This file contains SDIO IF (interface) module
3484 + * related functions.
3486 + * Copyright (C) 2007-2009, Marvell International Ltd.
3488 + * This software file (the "File") is distributed by Marvell International
3489 + * Ltd. under the terms of the GNU General Public License Version 2, June 1991
3490 + * (the "License"). You may use, redistribute and/or modify this File in
3491 + * accordance with the terms and conditions of the License, a copy of which
3492 + * is available along with the File in the gpl.txt file or by writing to
3493 + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3494 + * 02111-1307 or on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
3496 + * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
3497 + * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
3498 + * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
3499 + * this warranty disclaimer.
3502 +/****************************************************
3504 +****************************************************/
3506 +#include "uap_sdio_mmc.h"
3508 +#include <linux/firmware.h>
3510 +/** define SDIO block size */
3511 +/* We support up to 480-byte block size due to FW buffer limitation. */
3512 +#define SD_BLOCK_SIZE 256
3514 +/** define allocated buffer size */
3515 +#define ALLOC_BUF_SIZE (((MAX(MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, \
3516 + MRVDRV_SIZE_OF_CMD_BUFFER) + INTF_HEADER_LEN \
3517 + + SD_BLOCK_SIZE - 1) / SD_BLOCK_SIZE) * SD_BLOCK_SIZE)
3519 +/** Max retry number of CMD53 write */
3520 +#define MAX_WRITE_IOMEM_RETRY 2
3522 +/********************************************************
3524 +********************************************************/
3526 +/** SDIO Rx unit */
3527 +static u8 sdio_rx_unit = 0;
3529 +/**Interrupt status */
3530 +static u8 sd_ireg = 0;
3531 +/********************************************************
3533 +********************************************************/
3534 +extern u8 *helper_name;
3535 +extern u8 *fw_name;
3536 +/** Default helper name */
3537 +#define DEFAULT_HELPER_NAME "mrvl/helper_sd.bin"
3538 +/** Default firmware name */
3539 +#define DEFAULT_FW_NAME "mrvl/sd8688_ap.bin"
3541 +/********************************************************
3543 +********************************************************/
3545 + * @brief This function reads the IO register.
3547 + * @param priv A pointer to uap_private structure
3548 + * @param reg register to be read
3549 + * @param dat A pointer to variable that keeps returned value
3550 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
3553 +sbi_read_ioreg(uap_private * priv, u32 reg, u8 * dat)
3555 + struct sdio_mmc_card *card;
3556 + int ret = UAP_STATUS_FAILURE;
3560 + card = priv->uap_dev.card;
3561 + if (!card || !card->func) {
3562 + PRINTM(ERROR, "sbi_read_ioreg(): card or function is NULL!\n");
3566 + *dat = sdio_readb(card->func, reg, &ret);
3568 + PRINTM(ERROR, "sbi_read_ioreg(): sdio_readb failed! ret=%d\n", ret);
3572 + PRINTM(INFO, "sbi_read_ioreg() priv=%p func=%d reg=%#x dat=%#x\n", priv,
3573 + card->func->num, reg, *dat);
3581 + * @brief This function writes the IO register.
3583 + * @param priv A pointer to uap_private structure
3584 + * @param reg register to be written
3585 + * @param dat the value to be written
3586 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
3589 +sbi_write_ioreg(uap_private * priv, u32 reg, u8 dat)
3591 + struct sdio_mmc_card *card;
3592 + int ret = UAP_STATUS_FAILURE;
3596 + card = priv->uap_dev.card;
3597 + if (!card || !card->func) {
3598 + PRINTM(ERROR, "sbi_write_ioreg(): card or function is NULL!\n");
3602 + PRINTM(INFO, "sbi_write_ioreg() priv=%p func=%d reg=%#x dat=%#x\n", priv,
3603 + card->func->num, reg, dat);
3605 + sdio_writeb(card->func, dat, reg, &ret);
3607 + PRINTM(ERROR, "sbi_write_ioreg(): sdio_readb failed! ret=%d\n", ret);
3617 + * @brief This function get rx_unit value
3619 + * @param priv A pointer to uap_private structure
3620 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
3623 +sd_get_rx_unit(uap_private * priv)
3625 + int ret = UAP_STATUS_SUCCESS;
3630 + ret = sbi_read_ioreg(priv, CARD_RX_UNIT_REG, ®);
3631 + if (ret == UAP_STATUS_SUCCESS)
3632 + sdio_rx_unit = reg;
3639 + * @brief This function reads rx length
3641 + * @param priv A pointer to uap_private structure
3642 + * @param dat A pointer to keep returned data
3643 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
3646 +sd_read_rx_len(uap_private * priv, u16 * dat)
3648 + int ret = UAP_STATUS_SUCCESS;
3653 + ret = sbi_read_ioreg(priv, CARD_RX_LEN_REG, ®);
3654 + if (ret == UAP_STATUS_SUCCESS)
3655 + *dat = (u16) reg << sdio_rx_unit;
3662 + * @brief This function reads fw status registers
3664 + * @param priv A pointer to uap_private structure
3665 + * @param dat A pointer to keep returned data
3666 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
3669 +sd_read_firmware_status(uap_private * priv, u16 * dat)
3671 + int ret = UAP_STATUS_SUCCESS;
3677 + ret = sbi_read_ioreg(priv, CARD_FW_STATUS0_REG, &fws0);
3680 + return UAP_STATUS_FAILURE;
3683 + ret = sbi_read_ioreg(priv, CARD_FW_STATUS1_REG, &fws1);
3686 + return UAP_STATUS_FAILURE;
3689 + *dat = (((u16) fws1) << 8) | fws0;
3692 + return UAP_STATUS_SUCCESS;
3696 + * @brief This function polls the card status register.
3698 + * @param priv A pointer to uap_private structure
3699 + * @param bits the bit mask
3700 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
3703 +mv_sdio_poll_card_status(uap_private * priv, u8 bits)
3710 + for (tries = 0; tries < MAX_POLL_TRIES; tries++) {
3711 + if (sbi_read_ioreg(priv, CARD_STATUS_REG, &cs) < 0)
3713 + else if ((cs & bits) == bits) {
3715 + return UAP_STATUS_SUCCESS;
3720 + PRINTM(WARN, "mv_sdio_poll_card_status failed, tries = %d\n", tries);
3723 + return UAP_STATUS_FAILURE;
3727 + * @brief This function set the sdio bus width.
3729 + * @param priv A pointer to uap_private structure
3730 + * @param mode 1--1 bit mode, 4--4 bit mode
3731 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
3735 +sdio_set_bus_width(uap_private * priv, u8 mode)
3739 + return UAP_STATUS_SUCCESS;
3744 + * @brief This function reads data from the card.
3746 + * @param priv A pointer to uap_private structure
3747 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
3750 +sd_card_to_host(uap_private * priv)
3752 + int ret = UAP_STATUS_SUCCESS;
3754 + int buf_block_len;
3756 + struct sk_buff *skb = NULL;
3758 + u8 *payload = NULL;
3759 + struct sdio_mmc_card *card = priv->uap_dev.card;
3763 + if (!card || !card->func) {
3764 + PRINTM(ERROR, "card or function is NULL!\n");
3765 + ret = UAP_STATUS_FAILURE;
3769 + /* Read the length of data to be transferred */
3770 + ret = sd_read_rx_len(priv, &buf_len);
3772 + PRINTM(ERROR, "card_to_host, read scratch reg failed\n");
3773 + ret = UAP_STATUS_FAILURE;
3777 + /* Allocate buffer */
3778 + blksz = SD_BLOCK_SIZE;
3779 + buf_block_len = (buf_len + blksz - 1) / blksz;
3780 + if (buf_len <= INTF_HEADER_LEN || (buf_block_len * blksz) > ALLOC_BUF_SIZE) {
3781 + PRINTM(ERROR, "card_to_host, invalid packet length: %d\n", buf_len);
3782 + ret = UAP_STATUS_FAILURE;
3785 +#ifdef PXA3XX_DMA_ALIGN
3786 + skb = dev_alloc_skb(buf_block_len * blksz + PXA3XX_DMA_ALIGNMENT);
3788 + skb = dev_alloc_skb(buf_block_len * blksz);
3790 + if (skb == NULL) {
3791 + PRINTM(WARN, "No free skb\n");
3794 +#ifdef PXA3XX_DMA_ALIGN
3795 + if ((u32) skb->data & (PXA3XX_DMA_ALIGNMENT - 1)) {
3796 + skb_put(skb, (u32) skb->data & (PXA3XX_DMA_ALIGNMENT - 1));
3797 + skb_pull(skb, (u32) skb->data & (PXA3XX_DMA_ALIGNMENT - 1));
3799 +#endif /* PXA3XX_DMA_ALIGN */
3801 + payload = skb->tail;
3802 + ret = sdio_readsb(card->func, payload, priv->uap_dev.ioport,
3803 + buf_block_len * blksz);
3805 + PRINTM(ERROR, "card_to_host, read iomem failed: %d\n", ret);
3806 + ret = UAP_STATUS_FAILURE;
3809 + HEXDUMP("SDIO Blk Rd", payload, blksz * buf_block_len);
3811 + * This is SDIO specific header
3813 + * u16 type (MV_TYPE_DAT = 0, MV_TYPE_CMD = 1, MV_TYPE_EVENT = 3)
3815 + buf_len = uap_le16_to_cpu(*(u16 *) & payload[0]);
3816 + type = uap_le16_to_cpu(*(u16 *) & payload[2]);
3818 + case MV_TYPE_EVENT:
3819 + skb_put(skb, buf_len);
3820 + skb_pull(skb, INTF_HEADER_LEN);
3821 + uap_process_event(priv, skb->data, skb->len);
3826 + skb_put(skb, buf_len);
3827 + skb_pull(skb, INTF_HEADER_LEN);
3828 + priv->adapter->cmd_pending = FALSE;
3829 + if (priv->adapter->cmd_wait_option ==
3830 + HostCmd_OPTION_WAITFORRSP_SLEEPCONFIRM) {
3831 + priv->adapter->cmd_wait_option = FALSE;
3832 + uap_process_sleep_confirm_resp(priv, skb->data, skb->len);
3833 + } else if (priv->adapter->cmd_wait_option) {
3834 + memcpy(priv->adapter->CmdBuf, skb->data, skb->len);
3835 + priv->adapter->CmdSize = skb->len;
3836 + priv->adapter->cmd_wait_option = FALSE;
3837 + priv->adapter->CmdWaitQWoken = TRUE;
3838 + wake_up_interruptible(&priv->adapter->cmdwait_q);
3844 + skb_put(skb, buf_len);
3845 + skb_pull(skb, INTF_HEADER_LEN);
3846 + uap_process_rx_packet(priv, skb);
3849 + priv->stats.rx_errors++;
3850 + priv->stats.rx_dropped++;
3851 + /* Driver specified event and command resp should be handle here */
3852 + PRINTM(INFO, "Unknown PKT type:%d\n", type);
3868 + * @brief This function enables the host interrupts mask
3870 + * @param priv A pointer to uap_private structure
3871 + * @param mask the interrupt mask
3872 + * @return UAP_STATUS_SUCCESS
3875 +enable_host_int_mask(uap_private * priv, u8 mask)
3877 + int ret = UAP_STATUS_SUCCESS;
3881 + /* Simply write the mask to the register */
3882 + ret = sbi_write_ioreg(priv, HOST_INT_MASK_REG, mask);
3885 + PRINTM(WARN, "Unable to enable the host interrupt!\n");
3886 + ret = UAP_STATUS_FAILURE;
3893 +/** @brief This function disables the host interrupts mask.
3895 + * @param priv A pointer to uap_private structure
3896 + * @param mask the interrupt mask
3897 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
3900 +disable_host_int_mask(uap_private * priv, u8 mask)
3902 + int ret = UAP_STATUS_SUCCESS;
3907 + /* Read back the host_int_mask register */
3908 + ret = sbi_read_ioreg(priv, HOST_INT_MASK_REG, &host_int_mask);
3910 + ret = UAP_STATUS_FAILURE;
3914 + /* Update with the mask and write back to the register */
3915 + host_int_mask &= ~mask;
3916 + ret = sbi_write_ioreg(priv, HOST_INT_MASK_REG, host_int_mask);
3918 + PRINTM(WARN, "Unable to diable the host interrupt!\n");
3919 + ret = UAP_STATUS_FAILURE;
3928 +/********************************************************
3930 +********************************************************/
3933 + * @brief This function handles the interrupt.
3935 + * @param func A pointer to sdio_func structure.
3939 +sbi_interrupt(struct sdio_func *func)
3941 + struct sdio_mmc_card *card;
3942 + uap_private *priv;
3944 + int ret = UAP_STATUS_SUCCESS;
3948 + card = sdio_get_drvdata(func);
3949 + if (!card || !card->priv) {
3950 + PRINTM(MSG, "%s: sbi_interrupt(%p) card or priv is NULL, card=%p\n",
3951 + __FUNCTION__, func, card);
3955 + priv = card->priv;
3956 +#ifdef FW_WAKEUP_TIME
3957 + if ((priv->adapter->wt_pwrup_sending != 0L) &&
3958 + (priv->adapter->wt_int == 0L))
3959 + priv->adapter->wt_int = get_utimeofday();
3962 + ireg = sdio_readb(card->func, HOST_INTSTATUS_REG, &ret);
3964 + PRINTM(WARN, "sdio_read_ioreg: read int status register failed\n");
3969 + * DN_LD_HOST_INT_STATUS and/or UP_LD_HOST_INT_STATUS
3970 + * Clear the interrupt status register and re-enable the interrupt
3972 + PRINTM(INFO, "sdio_ireg = 0x%x\n", ireg);
3973 + sdio_writeb(card->func,
3974 + ~(ireg) & (DN_LD_HOST_INT_STATUS | UP_LD_HOST_INT_STATUS),
3975 + HOST_INTSTATUS_REG, &ret);
3978 + "sdio_write_ioreg: clear int status register failed\n");
3986 + uap_interrupt(priv);
3992 + * @brief This function probe the card
3994 + * @param func A pointer to sdio_func structure
3995 + * @param id A pointer to structure sd_device_id
3996 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
3999 +uap_probe(struct sdio_func *func, const struct sdio_device_id *id)
4001 + int ret = UAP_STATUS_FAILURE;
4002 + struct sdio_mmc_card *card = NULL;
4006 + PRINTM(MSG, "%s: vendor=0x%4.04X device=0x%4.04X class=%d function=%d\n",
4007 + __FUNCTION__, func->vendor, func->device, func->class, func->num);
4009 + card = kzalloc(sizeof(struct sdio_mmc_card), GFP_KERNEL);
4015 + card->func = func;
4017 + if (!uap_add_card(card)) {
4018 + PRINTM(ERROR, "%s: uap_add_callback failed\n", __FUNCTION__);
4020 + ret = UAP_STATUS_FAILURE;
4024 + ret = UAP_STATUS_SUCCESS;
4032 + * @brief This function removes the card
4034 + * @param func A pointer to sdio_func structure
4038 +uap_remove(struct sdio_func *func)
4040 + struct sdio_mmc_card *card;
4045 + card = sdio_get_drvdata(func);
4047 + uap_remove_card(card);
4057 + * @brief This function handles client driver suspend
4059 + * @param func A pointer to sdio_func structure
4060 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4063 +uap_suspend(struct sdio_func *func)
4071 + * @brief This function handles client driver resume
4073 + * @param func A pointer to sdio_func structure
4074 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4077 +uap_resume(struct sdio_func *func)
4085 +/** Device ID for SD8688 */
4086 +#define SD_DEVICE_ID_8688_UAP 0x9104
4088 +static const struct sdio_device_id uap_ids[] = {
4089 + {SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, SD_DEVICE_ID_8688_UAP)},
4093 +MODULE_DEVICE_TABLE(sdio, uap_ids);
4095 +static struct sdio_driver uap_sdio = {
4096 + .name = "uap_sdio",
4097 + .id_table = uap_ids,
4098 + .probe = uap_probe,
4099 + .remove = uap_remove,
4101 +/* .suspend = uap_suspend, */
4102 +/* .resume = uap_resume, */
4108 + * @brief This function registers the IF module in bus driver.
4110 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4115 + int ret = UAP_STATUS_SUCCESS;
4119 + /* SDIO Driver Registration */
4120 + if (sdio_register_driver(&uap_sdio) != 0) {
4121 + PRINTM(FATAL, "SDIO Driver Registration Failed \n");
4122 + ret = UAP_STATUS_FAILURE;
4130 + * @brief This function de-registers the IF module in bus driver.
4135 +sbi_unregister(void)
4139 + /* SDIO Driver Unregistration */
4140 + sdio_unregister_driver(&uap_sdio);
4146 + * @brief This function checks the interrupt status and handle it accordingly.
4148 + * @param priv A pointer to uap_private structure
4149 + * @param ireg A pointer to variable that keeps returned value
4150 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4153 +sbi_get_int_status(uap_private * priv, u8 * ireg)
4155 + int ret = UAP_STATUS_SUCCESS;
4157 + struct sdio_mmc_card *card = priv->uap_dev.card;
4163 + sdio_ireg = sd_ireg;
4167 + sdio_claim_host(card->func);
4169 + if (sdio_ireg & DN_LD_HOST_INT_STATUS) { /* tx_done INT */
4170 + if (!priv->uap_dev.cmd_sent) { /* tx_done already received */
4172 + "warning: tx_done already received: tx_dnld_rdy=0x%x int status=0x%x\n",
4173 + priv->uap_dev.cmd_sent, sdio_ireg);
4175 + priv->uap_dev.cmd_sent = FALSE;
4176 + priv->uap_dev.data_sent = FALSE;
4177 + if ( (priv->uap_dev.netdev->reg_state == NETREG_REGISTERED) && (skb_queue_len(&priv->adapter->tx_queue) < TX_LOW_WATERMARK)) {
4178 + os_start_queue(priv);
4182 + if (sdio_ireg & UP_LD_HOST_INT_STATUS) {
4183 + sd_card_to_host(priv);
4186 + *ireg = sdio_ireg;
4187 + ret = UAP_STATUS_SUCCESS;
4188 + sdio_release_host(card->func);
4195 + * @brief This function disables the host interrupts.
4197 + * @param priv A pointer to uap_private structure
4198 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4201 +sbi_disable_host_int(uap_private * priv)
4203 + struct sdio_mmc_card *card = priv->uap_dev.card;
4208 + sdio_claim_host(card->func);
4209 + ret = disable_host_int_mask(priv, HIM_DISABLE);
4210 + sdio_release_host(card->func);
4217 + * @brief This function enables the host interrupts.
4219 + * @param priv A pointer to uap_private structure
4220 + * @return UAP_STATUS_SUCCESS
4223 +sbi_enable_host_int(uap_private * priv)
4225 + struct sdio_mmc_card *card = priv->uap_dev.card;
4230 + sdio_claim_host(card->func);
4231 + ret = enable_host_int_mask(priv, HIM_ENABLE);
4232 + sdio_release_host(card->func);
4239 + * @brief This function de-registers the device.
4241 + * @param priv A pointer to uap_private structure
4242 + * @return UAP_STATUS_SUCCESS
4245 +sbi_unregister_dev(uap_private * priv)
4247 + struct sdio_mmc_card *card = priv->uap_dev.card;
4251 + if (!card || !card->func) {
4252 + PRINTM(ERROR, "Error: card or function is NULL!\n");
4256 + sdio_claim_host(card->func);
4257 + sdio_release_irq(card->func);
4258 + sdio_disable_func(card->func);
4259 + sdio_release_host(card->func);
4261 + sdio_set_drvdata(card->func, NULL);
4265 + return UAP_STATUS_SUCCESS;
4269 + * @brief This function registers the device.
4271 + * @param priv A pointer to uap_private structure
4272 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4275 +sbi_register_dev(uap_private * priv)
4277 + int ret = UAP_STATUS_FAILURE;
4279 + struct sdio_mmc_card *card = priv->uap_dev.card;
4280 + struct sdio_func *func;
4284 + if (!card || !card->func) {
4285 + PRINTM(ERROR, "Error: card or function is NULL!\n");
4289 + func = card->func;
4291 + /* Initialize the private structure */
4292 + priv->uap_dev.ioport = 0;
4294 + sdio_claim_host(func);
4296 + ret = sdio_enable_func(func);
4298 + PRINTM(FATAL, "sdio_enable_func() failed: ret=%d\n", ret);
4299 + goto release_host;
4302 + ret = sdio_claim_irq(func, sbi_interrupt);
4304 + PRINTM(FATAL, "sdio_claim_irq failed: ret=%d\n", ret);
4305 + goto disable_func;
4308 + /* Read the IO port */
4309 + ret = sbi_read_ioreg(priv, IO_PORT_0_REG, ®);
4313 + priv->uap_dev.ioport |= reg;
4315 + ret = sbi_read_ioreg(priv, IO_PORT_1_REG, ®);
4319 + priv->uap_dev.ioport |= (reg << 8);
4321 + ret = sbi_read_ioreg(priv, IO_PORT_2_REG, ®);
4325 + priv->uap_dev.ioport |= (reg << 16);
4327 + PRINTM(INFO, "SDIO FUNC #%d IO port: 0x%x\n", func->num,
4328 + priv->uap_dev.ioport);
4330 + ret = sdio_set_block_size(card->func, SD_BLOCK_SIZE);
4332 + PRINTM(ERROR, "%s: cannot set SDIO block size\n", __FUNCTION__);
4333 + ret = UAP_STATUS_FAILURE;
4336 + priv->hotplug_device = &func->dev;
4338 + if (helper_name == NULL) {
4339 + helper_name = DEFAULT_HELPER_NAME;
4341 + if (fw_name == NULL) {
4342 + fw_name = DEFAULT_FW_NAME;
4344 + sdio_release_host(func);
4346 + sdio_set_drvdata(func, card);
4348 + ret = UAP_STATUS_SUCCESS;
4352 + sdio_release_irq(func);
4354 + sdio_disable_func(func);
4356 + sdio_release_host(func);
4364 + * @brief This function sends data to the card.
4366 + * @param priv A pointer to uap_private structure
4367 + * @param payload A pointer to the data/cmd buffer
4368 + * @param nb the length of data/cmd
4369 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4372 +sbi_host_to_card(uap_private * priv, u8 * payload, u16 nb)
4374 + struct sdio_mmc_card *card = priv->uap_dev.card;
4375 + int ret = UAP_STATUS_SUCCESS;
4376 + int buf_block_len;
4380 +#ifdef PXA3XX_DMA_ALIGN
4381 + void *tmpbuf = NULL;
4387 + if (!card || !card->func) {
4388 + PRINTM(ERROR, "card or function is NULL!\n");
4390 + return UAP_STATUS_FAILURE;
4393 +#ifdef PXA3XX_DMA_ALIGN
4394 + if ((u32) payload & (PXA3XX_DMA_ALIGNMENT - 1)) {
4395 + tmpbufsz = ALIGN_SZ(nb, PXA3XX_DMA_ALIGNMENT);
4396 + tmpbuf = kmalloc(tmpbufsz, GFP_KERNEL);
4397 + memset(tmpbuf, 0, tmpbufsz);
4398 + /* Ensure 8-byte aligned CMD buffer */
4399 + buf = (u8 *) ALIGN_ADDR(tmpbuf, PXA3XX_DMA_ALIGNMENT);
4400 + memcpy(buf, payload, nb);
4403 + /* Allocate buffer and copy payload */
4404 + blksz = SD_BLOCK_SIZE;
4405 + buf_block_len = (nb + blksz - 1) / blksz;
4406 + sdio_claim_host(card->func);
4407 +#define MAX_WRITE_IOMEM_RETRY 2
4408 + priv->uap_dev.cmd_sent = TRUE;
4409 + priv->uap_dev.data_sent = TRUE;
4411 + /* Transfer data to card */
4412 + ret = sdio_writesb(card->func, priv->uap_dev.ioport, buf,
4413 + buf_block_len * blksz);
4416 + PRINTM(ERROR, "host_to_card, write iomem (%d) failed: %d\n", i,
4418 + ret = UAP_STATUS_FAILURE;
4419 + if (i > MAX_WRITE_IOMEM_RETRY)
4422 + HEXDUMP("SDIO Blk Wr", payload, nb);
4424 + } while (ret == UAP_STATUS_FAILURE);
4426 + sdio_release_host(card->func);
4427 +#ifdef PXA3XX_DMA_ALIGN
4431 + if (ret == UAP_STATUS_FAILURE) {
4432 + priv->uap_dev.cmd_sent = FALSE;
4433 + priv->uap_dev.data_sent = FALSE;
4440 + * @brief This function reads CIS information.
4442 + * @param priv A pointer to uap_private structure
4443 + * @param cisinfo A pointer to CIS information output buffer
4444 + * @param cislen A pointer to length of CIS info output buffer
4445 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4449 +sbi_get_cis_info(uap_private * priv, void *cisinfo, int *cislen)
4451 +#define CIS_PTR (0x8000)
4452 + struct sdio_mmc_card *card = priv->uap_dev.card;
4453 + unsigned int i, cis_ptr = CIS_PTR;
4454 + int ret = UAP_STATUS_FAILURE;
4458 + if (!card || !card->func) {
4459 + PRINTM(ERROR, "sbi_get_cis_info(): card or function is NULL!\n");
4462 +#define MAX_SDIO_CIS_INFO_LEN (256)
4463 + if (!cisinfo || (*cislen < MAX_SDIO_CIS_INFO_LEN)) {
4464 + PRINTM(WARN, "ERROR! get_cis_info: insufficient buffer passed\n");
4468 + *cislen = MAX_SDIO_CIS_INFO_LEN;
4470 + sdio_claim_host(card->func);
4472 + PRINTM(INFO, "cis_ptr=%#x\n", cis_ptr);
4474 + /* Read the Tuple Data */
4475 + for (i = 0; i < *cislen; i++) {
4476 + ((unsigned char *) cisinfo)[i] =
4477 + sdio_readb(card->func, cis_ptr + i, &ret);
4479 + PRINTM(WARN, "get_cis_info error: ret=%d\n", ret);
4480 + ret = UAP_STATUS_FAILURE;
4483 + PRINTM(INFO, "cisinfo[%d]=%#x\n", i, ((unsigned char *) cisinfo)[i]);
4487 + sdio_release_host(card->func);
4494 + * @brief This function downloads helper image to the card.
4496 + * @param priv A pointer to uap_private structure
4497 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4500 +sbi_prog_helper(uap_private * priv)
4502 + struct sdio_mmc_card *card = priv->uap_dev.card;
4503 + u8 *helper = NULL;
4505 + int ret = UAP_STATUS_SUCCESS;
4506 + void *tmphlprbuf = NULL;
4511 +#ifdef FW_DOWNLOAD_SPEED
4517 + if (!card || !card->func) {
4518 + PRINTM(ERROR, "sbi_prog_helper(): card or function is NULL!\n");
4522 + if (priv->fw_helper) {
4523 + helper = (u8 *) priv->fw_helper->data;
4524 + helperlen = priv->fw_helper->size;
4526 + PRINTM(MSG, "No helper image found! Terminating download.\n");
4528 + return UAP_STATUS_FAILURE;
4531 + PRINTM(INFO, "Downloading helper image (%d bytes), block size %d bytes\n",
4532 + helperlen, SD_BLOCK_SIZE);
4534 +#ifdef FW_DOWNLOAD_SPEED
4535 + tv1 = get_utimeofday();
4538 +#ifdef PXA3XX_DMA_ALIGN
4539 + tmphlprbufsz = ALIGN_SZ(UAP_UPLD_SIZE, PXA3XX_DMA_ALIGNMENT);
4540 +#else /* !PXA3XX_DMA_ALIGN */
4541 + tmphlprbufsz = UAP_UPLD_SIZE;
4542 +#endif /* !PXA3XX_DMA_ALIGN */
4543 + tmphlprbuf = kmalloc(tmphlprbufsz, GFP_KERNEL);
4544 + if (!tmphlprbuf) {
4546 + "Unable to allocate buffer for helper. Terminating download\n");
4547 + ret = UAP_STATUS_FAILURE;
4550 + memset(tmphlprbuf, 0, tmphlprbufsz);
4551 +#ifdef PXA3XX_DMA_ALIGN
4552 + hlprbuf = (u8 *) ALIGN_ADDR(tmphlprbuf, PXA3XX_DMA_ALIGNMENT);
4553 +#else /* !PXA3XX_DMA_ALIGN */
4554 + hlprbuf = (u8 *) tmphlprbuf;
4555 +#endif /* !PXA3XX_DMA_ALIGN */
4557 + sdio_claim_host(card->func);
4559 + /* Perform helper data transfer */
4560 + tx_len = (FIRMWARE_TRANSFER_NBLOCK * SD_BLOCK_SIZE) - INTF_HEADER_LEN;
4563 + /* The host polls for the DN_LD_CARD_RDY and CARD_IO_READY bits */
4564 + ret = mv_sdio_poll_card_status(priv, CARD_IO_READY | DN_LD_CARD_RDY);
4566 + PRINTM(FATAL, "Helper download poll status timeout @ %d\n",
4572 + if (hlprblknow >= helperlen)
4575 + /* Set blocksize to transfer - checking for last block */
4576 + if (helperlen - hlprblknow < tx_len)
4577 + tx_len = helperlen - hlprblknow;
4579 + /* Set length to the 4-byte header */
4580 + *(u32 *) hlprbuf = uap_cpu_to_le32(tx_len);
4582 + /* Copy payload to buffer */
4583 + memcpy(&hlprbuf[INTF_HEADER_LEN], &helper[hlprblknow], tx_len);
4585 + PRINTM(INFO, ".");
4588 + ret = sdio_writesb(card->func, priv->uap_dev.ioport,
4589 + hlprbuf, FIRMWARE_TRANSFER_NBLOCK * SD_BLOCK_SIZE);
4592 + PRINTM(FATAL, "IO error during helper download @ %d\n", hlprblknow);
4596 + hlprblknow += tx_len;
4599 +#ifdef FW_DOWNLOAD_SPEED
4600 + tv2 = get_utimeofday();
4601 + PRINTM(INFO, "helper: %ld.%03ld.%03ld ", tv1 / 1000000,
4602 + (tv1 % 1000000) / 1000, tv1 % 1000);
4603 + PRINTM(INFO, " -> %ld.%03ld.%03ld ", tv2 / 1000000, (tv2 % 1000000) / 1000,
4606 + PRINTM(INFO, " == %ld.%03ld.%03ld\n", tv2 / 1000000, (tv2 % 1000000) / 1000,
4610 + /* Write last EOF data */
4611 + PRINTM(INFO, "\nTransferring helper image EOF block\n");
4612 + memset(hlprbuf, 0x0, SD_BLOCK_SIZE);
4613 + ret = sdio_writesb(card->func, priv->uap_dev.ioport,
4614 + hlprbuf, SD_BLOCK_SIZE);
4617 + PRINTM(FATAL, "IO error in writing helper image EOF block\n");
4621 + ret = UAP_STATUS_SUCCESS;
4624 + sdio_release_host(card->func);
4626 + kfree(tmphlprbuf);
4633 + * @brief This function downloads firmware image to the card.
4635 + * @param priv A pointer to uap_private structure
4636 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4639 +sbi_prog_fw_w_helper(uap_private * priv)
4641 + struct sdio_mmc_card *card = priv->uap_dev.card;
4642 + u8 *firmware = NULL;
4646 + int ret = UAP_STATUS_SUCCESS;
4648 + void *tmpfwbuf = NULL;
4653 + int tx_blocks = 0;
4656 +#ifdef FW_DOWNLOAD_SPEED
4662 + if (!card || !card->func) {
4663 + PRINTM(ERROR, "sbi_prog_fw_w_helper(): card or function is NULL!\n");
4667 + if (priv->firmware) {
4668 + firmware = (u8 *) priv->firmware->data;
4669 + firmwarelen = priv->firmware->size;
4671 + PRINTM(MSG, "No firmware image found! Terminating download.\n");
4673 + return UAP_STATUS_FAILURE;
4676 + PRINTM(INFO, "Downloading FW image (%d bytes)\n", firmwarelen);
4678 +#ifdef FW_DOWNLOAD_SPEED
4679 + tv1 = get_utimeofday();
4682 +#ifdef PXA3XX_DMA_ALIGN
4683 + tmpfwbufsz = ALIGN_SZ(UAP_UPLD_SIZE, PXA3XX_DMA_ALIGNMENT);
4684 +#else /* PXA3XX_DMA_ALIGN */
4685 + tmpfwbufsz = UAP_UPLD_SIZE;
4686 +#endif /* PXA3XX_DMA_ALIGN */
4687 + tmpfwbuf = kmalloc(tmpfwbufsz, GFP_KERNEL);
4690 + "Unable to allocate buffer for firmware. Terminating download.\n");
4691 + ret = UAP_STATUS_FAILURE;
4694 + memset(tmpfwbuf, 0, tmpfwbufsz);
4695 +#ifdef PXA3XX_DMA_ALIGN
4696 + /* Ensure 8-byte aligned firmware buffer */
4697 + fwbuf = (u8 *) ALIGN_ADDR(tmpfwbuf, PXA3XX_DMA_ALIGNMENT);
4698 +#else /* PXA3XX_DMA_ALIGN */
4699 + fwbuf = (u8 *) tmpfwbuf;
4700 +#endif /* PXA3XX_DMA_ALIGN */
4702 + sdio_claim_host(card->func);
4704 + /* Perform firmware data transfer */
4707 + /* The host polls for the DN_LD_CARD_RDY and CARD_IO_READY bits */
4708 + ret = mv_sdio_poll_card_status(priv, CARD_IO_READY | DN_LD_CARD_RDY);
4710 + PRINTM(FATAL, "FW download with helper poll status timeout @ %d\n",
4716 + if (offset >= firmwarelen)
4719 + for (tries = 0; tries < MAX_POLL_TRIES; tries++) {
4720 + if ((ret = sbi_read_ioreg(priv, HOST_F1_RD_BASE_0, &base0)) < 0) {
4721 + PRINTM(WARN, "Dev BASE0 register read failed:"
4722 + " base0=0x%04X(%d). Terminating download.\n", base0,
4724 + ret = UAP_STATUS_FAILURE;
4727 + if ((ret = sbi_read_ioreg(priv, HOST_F1_RD_BASE_1, &base1)) < 0) {
4728 + PRINTM(WARN, "Dev BASE1 register read failed:"
4729 + " base1=0x%04X(%d). Terminating download.\n", base1,
4731 + ret = UAP_STATUS_FAILURE;
4734 + len = (((u16) base1) << 8) | base0;
4736 + /* For SD8688 wait until the length is not 0, 1 or 2 before
4737 + downloading the first FW block, since BOOT code writes the
4738 + register to indicate the helper/FW download winner, the value
4739 + could be 1 or 2 (Func1 or Func2). */
4740 + if ((len && offset) || (len > 2))
4747 + else if (len > UAP_UPLD_SIZE) {
4748 + PRINTM(FATAL, "FW download failure @ %d, invalid length %d\n",
4750 + ret = UAP_STATUS_FAILURE;
4756 + if (len & BIT(0)) {
4758 + if (i > MAX_WRITE_IOMEM_RETRY) {
4760 + "FW download failure @ %d, over max retry count\n",
4762 + ret = UAP_STATUS_FAILURE;
4765 + PRINTM(ERROR, "FW CRC error indicated by the helper:"
4766 + " len = 0x%04X, txlen = %d\n", len, txlen);
4768 + /* Setting this to 0 to resend from same offset */
4773 + /* Set blocksize to transfer - checking for last block */
4774 + if (firmwarelen - offset < txlen) {
4775 + txlen = firmwarelen - offset;
4777 + PRINTM(INFO, ".");
4779 + tx_blocks = (txlen + SD_BLOCK_SIZE - 1) / SD_BLOCK_SIZE;
4781 + /* Copy payload to buffer */
4782 + memcpy(fwbuf, &firmware[offset], txlen);
4786 + ret = sdio_writesb(card->func, priv->uap_dev.ioport,
4787 + fwbuf, tx_blocks * SD_BLOCK_SIZE);
4790 + PRINTM(ERROR, "FW download, write iomem (%d) failed @ %d\n", i,
4792 + if (sbi_write_ioreg(priv, CONFIGURATION_REG, 0x04) < 0) {
4793 + PRINTM(ERROR, "write ioreg failed (CFG)\n");
4800 + PRINTM(INFO, "\nFW download over, size %d bytes\n", offset);
4802 + ret = UAP_STATUS_SUCCESS;
4804 +#ifdef FW_DOWNLOAD_SPEED
4805 + tv2 = get_utimeofday();
4806 + PRINTM(INFO, "FW: %ld.%03ld.%03ld ", tv1 / 1000000,
4807 + (tv1 % 1000000) / 1000, tv1 % 1000);
4808 + PRINTM(INFO, " -> %ld.%03ld.%03ld ", tv2 / 1000000,
4809 + (tv2 % 1000000) / 1000, tv2 % 1000);
4811 + PRINTM(INFO, " == %ld.%03ld.%03ld\n", tv2 / 1000000,
4812 + (tv2 % 1000000) / 1000, tv2 % 1000);
4814 + sdio_release_host(card->func);
4823 + * @brief This function checks if the firmware is ready to accept
4826 + * @param priv A pointer to uap_private structure
4827 + * @param pollnum Poll number
4828 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4831 +sbi_check_fw_status(uap_private * priv, int pollnum)
4833 + struct sdio_mmc_card *card = priv->uap_dev.card;
4834 + int ret = UAP_STATUS_SUCCESS;
4840 + sdio_claim_host(card->func);
4842 + /* Wait for firmware initialization event */
4843 + for (tries = 0; tries < pollnum; tries++) {
4844 + if ((ret = sd_read_firmware_status(priv, &firmwarestat)) < 0)
4846 + if (firmwarestat == FIRMWARE_READY) {
4847 + ret = UAP_STATUS_SUCCESS;
4851 + ret = UAP_STATUS_FAILURE;
4858 + ret = UAP_STATUS_SUCCESS;
4859 + sd_get_rx_unit(priv);
4862 + sdio_release_host(card->func);
4869 + * @brief This function set bus clock on/off
4871 + * @param priv A pointer to uap_private structure
4872 + * @param option TRUE--on , FALSE--off
4873 + * @return UAP_STATUS_SUCCESS
4877 +sbi_set_bus_clock(uap_private * priv, u8 option)
4881 + return UAP_STATUS_SUCCESS;
4886 + * @brief This function wakeup firmware
4888 + * @param priv A pointer to uap_private structure
4889 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4892 +sbi_wakeup_firmware(uap_private * priv)
4894 + struct sdio_mmc_card *card = priv->uap_dev.card;
4895 + int ret = UAP_STATUS_SUCCESS;
4899 + if (!card || !card->func) {
4900 + PRINTM(ERROR, "card or function is NULL!\n");
4902 + return UAP_STATUS_FAILURE;
4904 + sdio_claim_host(card->func);
4905 + sdio_writeb(card->func, HOST_POWER_UP, CONFIGURATION_REG, &ret);
4906 + sdio_release_host(card->func);
4910 diff -Naur backports-3.18.1-1.org/drivers/net/wireless/libertas_uap/uap_sdio_mmc.h backports-3.18.1-1/drivers/net/wireless/libertas_uap/uap_sdio_mmc.h
4911 --- backports-3.18.1-1.org/drivers/net/wireless/libertas_uap/uap_sdio_mmc.h 1970-01-01 01:00:00.000000000 +0100
4912 +++ backports-3.18.1-1/drivers/net/wireless/libertas_uap/uap_sdio_mmc.h 2014-12-29 20:37:43.955764567 +0100
4914 +/** @file uap_sdio_mmc.h
4915 + * @brief This file contains SDIO IF (interface) module
4916 + * related macros, enum, and structure.
4918 + * Copyright (C) 2007-2009, Marvell International Ltd.
4920 + * This software file (the "File") is distributed by Marvell International
4921 + * Ltd. under the terms of the GNU General Public License Version 2, June 1991
4922 + * (the "License"). You may use, redistribute and/or modify this File in
4923 + * accordance with the terms and conditions of the License, a copy of which
4924 + * is available along with the File in the gpl.txt file or by writing to
4925 + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
4926 + * 02111-1307 or on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
4928 + * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
4929 + * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
4930 + * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
4931 + * this warranty disclaimer.
4934 +/****************************************************
4936 + 10/10/07: initial version
4937 +****************************************************/
4939 +#ifndef _UAP_SDIO_MMC_H
4940 +#define _UAP_SDIO_MMC_H
4942 +#include <linux/mmc/sdio.h>
4943 +#include <linux/mmc/sdio_ids.h>
4944 +#include <linux/mmc/sdio_func.h>
4945 +#include <linux/mmc/card.h>
4947 +#include "uap_headers.h"
4949 +/** The number of times to try when waiting for downloaded firmware to
4950 + become active. (polling the scratch register). */
4951 +#define MAX_FIRMWARE_POLL_TRIES 100
4953 +/** Firmware ready */
4954 +#define FIRMWARE_READY 0xfedc
4956 +/** Number of firmware blocks to transfer */
4957 +#define FIRMWARE_TRANSFER_NBLOCK 2
4959 +/* Host Control Registers */
4960 +/** Host Control Registers : I/O port 0 */
4961 +#define IO_PORT_0_REG 0x00
4962 +/** Host Control Registers : I/O port 1 */
4963 +#define IO_PORT_1_REG 0x01
4964 +/** Host Control Registers : I/O port 2 */
4965 +#define IO_PORT_2_REG 0x02
4967 +/** Host Control Registers : Configuration */
4968 +#define CONFIGURATION_REG 0x03
4969 +/** Host Control Registers : Host without Command 53 finish host */
4970 +#define HOST_WO_CMD53_FINISH_HOST (0x1U << 2)
4971 +/** Host Control Registers : Host power up */
4972 +#define HOST_POWER_UP (0x1U << 1)
4973 +/** Host Control Registers : Host power down */
4974 +#define HOST_POWER_DOWN (0x1U << 0)
4976 +/** Host Control Registers : Host interrupt mask */
4977 +#define HOST_INT_MASK_REG 0x04
4978 +/** Host Control Registers : Upload host interrupt mask */
4979 +#define UP_LD_HOST_INT_MASK (0x1U)
4980 +/** Host Control Registers : Download host interrupt mask */
4981 +#define DN_LD_HOST_INT_MASK (0x2U)
4982 +/** Enable Host interrupt mask */
4983 +#define HIM_ENABLE (UP_LD_HOST_INT_MASK | DN_LD_HOST_INT_MASK)
4984 +/** Disable Host interrupt mask */
4985 +#define HIM_DISABLE 0xff
4987 +/** Host Control Registers : Host interrupt status */
4988 +#define HOST_INTSTATUS_REG 0x05
4989 +/** Host Control Registers : Upload host interrupt status */
4990 +#define UP_LD_HOST_INT_STATUS (0x1U)
4991 +/** Host Control Registers : Download host interrupt status */
4992 +#define DN_LD_HOST_INT_STATUS (0x2U)
4994 +/** Host F1 read base 0 */
4995 +#define HOST_F1_RD_BASE_0 0x10
4996 +/** Host F1 read base 1 */
4997 +#define HOST_F1_RD_BASE_1 0x11
4999 +/** Card Control Registers : Card status register */
5000 +#define CARD_STATUS_REG 0x20
5001 +/** Card Control Registers : Card I/O ready */
5002 +#define CARD_IO_READY (0x1U << 3)
5003 +/** Card Control Registers : CIS card ready */
5004 +#define CIS_CARD_RDY (0x1U << 2)
5005 +/** Card Control Registers : Upload card ready */
5006 +#define UP_LD_CARD_RDY (0x1U << 1)
5007 +/** Card Control Registers : Download card ready */
5008 +#define DN_LD_CARD_RDY (0x1U << 0)
5010 +/** Card Control Registers : Card OCR 0 register */
5011 +#define CARD_OCR_0_REG 0x34
5012 +/** Card Control Registers : Card OCR 1 register */
5013 +#define CARD_OCR_1_REG 0x35
5015 +/** Firmware status 0 register */
5016 +#define CARD_FW_STATUS0_REG 0x40
5017 +/** Firmware status 1 register */
5018 +#define CARD_FW_STATUS1_REG 0x41
5019 +/** Rx length register */
5020 +#define CARD_RX_LEN_REG 0x42
5021 +/** Rx unit register */
5022 +#define CARD_RX_UNIT_REG 0x43
5024 +/** Chip Id Register 0 */
5025 +#define CARD_CHIP_ID_0_REG 0x801c
5026 +/** Chip Id Register 1 */
5027 +#define CARD_CHIP_ID_1_REG 0x801d
5029 +#ifdef PXA3XX_DMA_ALIGN
5030 +/** DMA alignment value for PXA3XX platforms */
5031 +#define PXA3XX_DMA_ALIGNMENT 8
5032 +/** Macros for Data Alignment : size */
5033 +#define ALIGN_SZ(p, a) \
5034 + (((p) + ((a) - 1)) & ~((a) - 1))
5036 +/** Macros for Data Alignment : address */
5037 +#define ALIGN_ADDR(p, a) \
5038 + ((((u32)(p)) + (((u32)(a)) - 1)) & ~(((u32)(a)) - 1))
5039 +#endif /* PXA3XX_DMA_ALIGN */
5041 +struct sdio_mmc_card
5043 + /** sdio_func structure pointer */
5044 + struct sdio_func *func;
5045 + /** uap_private structure pointer */
5046 + uap_private *priv;
5049 +#endif /* _UAP_SDIO_MMC_H */
5050 diff -Naur backports-3.18.1-1.org/drivers/net/wireless/Makefile backports-3.18.1-1/drivers/net/wireless/Makefile
5051 --- backports-3.18.1-1.org/drivers/net/wireless/Makefile 2014-12-21 22:37:15.000000000 +0100
5052 +++ backports-3.18.1-1/drivers/net/wireless/Makefile 2014-12-29 20:40:33.632440784 +0100
5055 obj-$(CPTCFG_CW1200) += cw1200/
5056 obj-$(CPTCFG_RSI_91X) += rsi/
5058 +obj-$(CPTCFG_LIBERTAS_UAP) += libertas_uap/