1 diff -Naur compat-wireless-3.5-rc5-1-snpc.org/drivers/net/wireless/libertas_uap/Makefile compat-wireless-3.5-rc5-1-snpc/drivers/net/wireless/libertas_uap/Makefile
2 --- compat-wireless-3.5-rc5-1-snpc.org/drivers/net/wireless/libertas_uap/Makefile 1970-01-01 01:00:00.000000000 +0100
3 +++ compat-wireless-3.5-rc5-1-snpc/drivers/net/wireless/libertas_uap/Makefile 2012-07-31 14:23:04.000000000 +0200
5 +obj-$(CONFIG_LIBERTAS_UAP) += uap8xxx.o
7 +uap8xxx-y += uap_main.o uap_sdio_mmc.o
8 +uap8xxx-$(CONFIG_PROC_FS) += uap_proc.o uap_debug.o
10 +EXTRA_CFLAGS += -DFPNUM='"52"' -DPXA3XX_DMA_ALIGN -DDEBUG_LEVEL1
11 diff -Naur compat-wireless-3.5-rc5-1-snpc.org/drivers/net/wireless/libertas_uap/uap_debug.c compat-wireless-3.5-rc5-1-snpc/drivers/net/wireless/libertas_uap/uap_debug.c
12 --- compat-wireless-3.5-rc5-1-snpc.org/drivers/net/wireless/libertas_uap/uap_debug.c 1970-01-01 01:00:00.000000000 +0100
13 +++ compat-wireless-3.5-rc5-1-snpc/drivers/net/wireless/libertas_uap/uap_debug.c 2012-07-31 14:23:04.000000000 +0200
15 +/** @file uap_debug.c
16 + * @brief This file contains functions for debug proc file.
18 + * Copyright (C) 2008-2009, Marvell International Ltd.
20 + * This software file (the "File") is distributed by Marvell International
21 + * Ltd. under the terms of the GNU General Public License Version 2, June 1991
22 + * (the "License"). You may use, redistribute and/or modify this File in
23 + * accordance with the terms and conditions of the License, a copy of which
24 + * is available along with the File in the gpl.txt file or by writing to
25 + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26 + * 02111-1307 or on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
28 + * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
29 + * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
30 + * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
31 + * this warranty disclaimer.
34 +#ifdef CONFIG_PROC_FS
35 +#include "uap_headers.h"
37 +/********************************************************
39 +********************************************************/
41 +#define item_size(n) (sizeof ((uap_adapter *)0)->n)
42 +#define item_addr(n) ((u32) &((uap_adapter *)0)->n)
44 +#define item_dbg_size(n) (sizeof (((uap_adapter *)0)->dbg.n))
45 +#define item_dbg_addr(n) ((u32) &(((uap_adapter *)0)->dbg.n))
47 +#define item_dev_size(n) (sizeof ((uap_dev_t *)0)->n)
48 +#define item_dev_addr(n) ((u32) &((uap_dev_t *)0)->n)
50 +/** MicroAp device offset */
51 +#define OFFSET_UAP_DEV 0x01
52 +/** Bluetooth adapter offset */
53 +#define OFFSET_UAP_ADAPTER 0x02
69 +/* To debug any member of uap_adapter, simply add one line here.
71 +static struct debug_data items[] = {
72 + {"cmd_sent", item_dev_size(cmd_sent), 0, item_dev_addr(cmd_sent),
74 + {"data_sent", item_dev_size(data_sent), 0, item_dev_addr(data_sent),
76 + {"IntCounter", item_size(IntCounter), 0, item_addr(IntCounter),
77 + OFFSET_UAP_ADAPTER},
78 + {"cmd_pending", item_size(cmd_pending), 0, item_addr(cmd_pending),
79 + OFFSET_UAP_ADAPTER},
80 + {"num_cmd_h2c_fail", item_dbg_size(num_cmd_host_to_card_failure), 0,
81 + item_dbg_addr(num_cmd_host_to_card_failure), OFFSET_UAP_ADAPTER},
82 + {"num_tx_h2c_fail", item_dbg_size(num_tx_host_to_card_failure), 0,
83 + item_dbg_addr(num_tx_host_to_card_failure), OFFSET_UAP_ADAPTER},
84 + {"psmode", item_size(psmode), 0, item_addr(psmode), OFFSET_UAP_ADAPTER},
85 + {"ps_state", item_size(ps_state), 0, item_addr(ps_state),
86 + OFFSET_UAP_ADAPTER},
88 + {"drvdbg", sizeof(drvdbg), (u32) & drvdbg, 0, 0}
92 +static int num_of_items = sizeof(items) / sizeof(items[0]);
94 +/********************************************************
96 +********************************************************/
98 +/********************************************************
100 +********************************************************/
102 + * @brief proc read function
104 + * @param page pointer to buffer
105 + * @param s read data starting position
106 + * @param off offset
107 + * @param cnt counter
108 + * @param eof end of file flag
109 + * @param data data to output
110 + * @return number of output data
113 +uap_debug_read(char *page, char **s, off_t off, int cnt, int *eof, void *data)
119 + struct debug_data *d = (struct debug_data *) data;
121 + if (MODULE_GET == 0)
122 + return UAP_STATUS_FAILURE;
124 + for (i = 0; i < num_of_items; i++) {
125 + if (d[i].size == 1)
126 + val = *((u8 *) d[i].addr);
127 + else if (d[i].size == 2)
128 + val = *((u16 *) d[i].addr);
129 + else if (d[i].size == 4)
130 + val = *((u32 *) d[i].addr);
132 + p += sprintf(p, "%s=%d\n", d[i].name, val);
139 + * @brief proc write function
141 + * @param f file pointer
142 + * @param buf pointer to data buffer
143 + * @param cnt data number to write
144 + * @param data data to write
145 + * @return number of data
148 +uap_debug_write(struct file *f, const char *buf, unsigned long cnt, void *data)
156 + struct debug_data *d = (struct debug_data *) data;
158 + if (MODULE_GET == 0)
159 + return UAP_STATUS_FAILURE;
161 + pdata = (char *) kmalloc(cnt, GFP_KERNEL);
162 + if (pdata == NULL) {
167 + if (copy_from_user(pdata, buf, cnt)) {
168 + PRINTM(INFO, "Copy from user failed\n");
175 + for (i = 0; i < num_of_items; i++) {
177 + p = strstr(p0, d[i].name);
180 + p1 = strchr(p, '\n');
184 + p2 = strchr(p, '=');
188 + r = string_to_number(p2);
189 + if (d[i].size == 1)
190 + *((u8 *) d[i].addr) = (u8) r;
191 + else if (d[i].size == 2)
192 + *((u16 *) d[i].addr) = (u16) r;
193 + else if (d[i].size == 4)
194 + *((u32 *) d[i].addr) = (u32) r;
200 + printk(KERN_ALERT "drvdbg = 0x%x\n", drvdbg);
201 + printk(KERN_ALERT "INFO (%08lx) %s\n", DBG_INFO,
202 + (drvdbg & DBG_INFO) ? "X" : "");
203 + printk(KERN_ALERT "WARN (%08lx) %s\n", DBG_WARN,
204 + (drvdbg & DBG_WARN) ? "X" : "");
205 + printk(KERN_ALERT "ENTRY (%08lx) %s\n", DBG_ENTRY,
206 + (drvdbg & DBG_ENTRY) ? "X" : "");
207 + printk(KERN_ALERT "CMD_D (%08lx) %s\n", DBG_CMD_D,
208 + (drvdbg & DBG_CMD_D) ? "X" : "");
209 + printk(KERN_ALERT "DAT_D (%08lx) %s\n", DBG_DAT_D,
210 + (drvdbg & DBG_DAT_D) ? "X" : "");
211 + printk(KERN_ALERT "CMND (%08lx) %s\n", DBG_CMND,
212 + (drvdbg & DBG_CMND) ? "X" : "");
213 + printk(KERN_ALERT "DATA (%08lx) %s\n", DBG_DATA,
214 + (drvdbg & DBG_DATA) ? "X" : "");
215 + printk(KERN_ALERT "ERROR (%08lx) %s\n", DBG_ERROR,
216 + (drvdbg & DBG_ERROR) ? "X" : "");
217 + printk(KERN_ALERT "FATAL (%08lx) %s\n", DBG_FATAL,
218 + (drvdbg & DBG_FATAL) ? "X" : "");
219 + printk(KERN_ALERT "MSG (%08lx) %s\n", DBG_MSG,
220 + (drvdbg & DBG_MSG) ? "X" : "");
226 +/********************************************************
228 +********************************************************/
230 + * @brief create debug proc file
232 + * @param priv pointer uap_private
233 + * @param dev pointer net_device
237 +uap_debug_entry(uap_private * priv, struct net_device *dev)
240 + struct proc_dir_entry *r;
242 + if (priv->proc_entry == NULL)
245 + for (i = 0; i < num_of_items; i++) {
246 + if (items[i].flag & OFFSET_UAP_ADAPTER)
247 + items[i].addr = items[i].offset + (u32) priv->adapter;
248 + if (items[i].flag & OFFSET_UAP_DEV)
249 + items[i].addr = items[i].offset + (u32) & priv->uap_dev;
251 + r = create_proc_entry("debug", 0644, priv->proc_entry);
255 + r->data = &items[0];
256 + r->read_proc = uap_debug_read;
257 + r->write_proc = uap_debug_write;
258 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
259 + r->owner = THIS_MODULE;
264 + * @brief remove proc file
266 + * @param priv pointer uap_private
270 +uap_debug_remove(uap_private * priv)
272 + remove_proc_entry("debug", priv->proc_entry);
276 diff -Naur compat-wireless-3.5-rc5-1-snpc.org/drivers/net/wireless/libertas_uap/uap_drv.h compat-wireless-3.5-rc5-1-snpc/drivers/net/wireless/libertas_uap/uap_drv.h
277 --- compat-wireless-3.5-rc5-1-snpc.org/drivers/net/wireless/libertas_uap/uap_drv.h 1970-01-01 01:00:00.000000000 +0100
278 +++ compat-wireless-3.5-rc5-1-snpc/drivers/net/wireless/libertas_uap/uap_drv.h 2012-07-31 14:23:04.000000000 +0200
281 + * @brief This file contains Linux OS related definitions and
282 + * declarations, uAP driver
284 + * Copyright (C) 2008-2009, Marvell International Ltd.
286 + * This software file (the "File") is distributed by Marvell International
287 + * Ltd. under the terms of the GNU General Public License Version 2, June 1991
288 + * (the "License"). You may use, redistribute and/or modify this File in
289 + * accordance with the terms and conditions of the License, a copy of which
290 + * is available along with the File in the gpl.txt file or by writing to
291 + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
292 + * 02111-1307 or on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
294 + * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
295 + * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
296 + * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
297 + * this warranty disclaimer.
304 +/** Driver release version */
305 +#define DRIVER_VERSION "26146"
316 +/** Bit definitions */
318 +#define BIT(x) (1UL << (x))
321 +/** Dma addresses are 32-bits wide. */
322 +#ifndef __ATTRIB_ALIGN__
323 +#define __ATTRIB_ALIGN__ __attribute__((aligned(4)))
326 +/** attribute pack */
327 +#ifndef __ATTRIB_PACK__
328 +#define __ATTRIB_PACK__ __attribute__ ((packed))
331 +/** Debug Macro definition*/
336 +/** Debug message control bit definition for drvdbg */
337 +/** Debug message */
338 +#define DBG_MSG BIT(0)
339 +/** Debug fatal message */
340 +#define DBG_FATAL BIT(1)
341 +/** Debug error message */
342 +#define DBG_ERROR BIT(2)
343 +/** Debug data message */
344 +#define DBG_DATA BIT(3)
345 +/** Debug command message */
346 +#define DBG_CMND BIT(4)
349 +#define DBG_DAT_D BIT(16)
350 +/** Debug command */
351 +#define DBG_CMD_D BIT(17)
354 +#define DBG_ENTRY BIT(28)
355 +/** Debug warning */
356 +#define DBG_WARN BIT(29)
358 +#define DBG_INFO BIT(30)
361 +#define PRINTM_INFO(msg...) {if (drvdbg & DBG_INFO) printk(KERN_DEBUG msg);}
362 +/** Print warn message */
363 +#define PRINTM_WARN(msg...) {if (drvdbg & DBG_WARN) printk(KERN_DEBUG msg);}
365 +#define PRINTM_ENTRY(msg...) {if (drvdbg & DBG_ENTRY) printk(KERN_DEBUG msg);}
367 +#define PRINTM_CMD_D(msg...) {if (drvdbg & DBG_CMD_D) printk(KERN_DEBUG msg);}
369 +#define PRINTM_DAT_D(msg...) {if (drvdbg & DBG_DAT_D) printk(KERN_DEBUG msg);}
370 +/** Print command */
371 +#define PRINTM_CMND(msg...) {if (drvdbg & DBG_CMND) printk(KERN_DEBUG msg);}
373 +#define PRINTM_DATA(msg...) {if (drvdbg & DBG_DATA) printk(KERN_DEBUG msg);}
374 +/** Print error message */
375 +#define PRINTM_ERROR(msg...) {if (drvdbg & DBG_ERROR) printk(KERN_DEBUG msg);}
376 +/** Print fatal message */
377 +#define PRINTM_FATAL(msg...) {if (drvdbg & DBG_FATAL) printk(KERN_DEBUG msg);}
378 +/** Print message */
379 +#define PRINTM_MSG(msg...) {if (drvdbg & DBG_MSG) printk(KERN_ALERT msg);}
381 +#define PRINTM(level,msg...) PRINTM_##level(msg)
385 +#define PRINTM(level,msg...) do {} while (0)
387 +#endif /* DEBUG_LEVEL1 */
389 +/** Wait until a condition becomes true */
390 +#define ASSERT(cond) \
393 + PRINTM(INFO, "ASSERT: %s, %s:%i\n", \
394 + __FUNCTION__, __FILE__, __LINE__); \
397 +/** Log enrty point for debugging */
398 +#define ENTER() PRINTM(ENTRY, "Enter: %s, %s:%i\n", __FUNCTION__, \
399 + __FILE__, __LINE__)
400 +/** Log exit point for debugging */
401 +#define LEAVE() PRINTM(ENTRY, "Leave: %s, %s:%i\n", __FUNCTION__, \
402 + __FILE__, __LINE__)
405 +/** Dump buffer length */
406 +#define DBG_DUMP_BUF_LEN 64
407 +/** Maximum dump per line */
408 +#define MAX_DUMP_PER_LINE 16
409 +/** Data dump length */
410 +#define DATA_DUMP_LEN 32
413 +hexdump(char *prompt, u8 * buf, int len)
416 + char dbgdumpbuf[DBG_DUMP_BUF_LEN];
417 + char *ptr = dbgdumpbuf;
419 + printk(KERN_DEBUG "%s:\n", prompt);
420 + for (i = 1; i <= len; i++) {
421 + ptr += sprintf(ptr, "%02x ", *buf);
423 + if (i % MAX_DUMP_PER_LINE == 0) {
425 + printk(KERN_DEBUG "%s\n", dbgdumpbuf);
429 + if (len % MAX_DUMP_PER_LINE) {
431 + printk(KERN_DEBUG "%s\n", dbgdumpbuf);
435 +/** Debug command */
436 +#define DBG_HEXDUMP_CMD_D(x,y,z) {if (drvdbg & DBG_CMD_D) hexdump(x,y,z);}
438 +#define DBG_HEXDUMP_DAT_D(x,y,z) {if (drvdbg & DBG_DAT_D) hexdump(x,y,z);}
439 +/** Debug hexdump */
440 +#define DBG_HEXDUMP(level,x,y,z) DBG_HEXDUMP_##level(x,y,z)
442 +#define HEXDUMP(x,y,z) {if (drvdbg & DBG_INFO) hexdump(x,y,z);}
444 +/** Do nothing since debugging is not turned on */
445 +#define DBG_HEXDUMP(level,x,y,z) do {} while (0)
446 +/** Do nothing since debugging is not turned on */
447 +#define HEXDUMP(x,y,z) do {} while (0)
453 +/** Unsigned char */
457 + * OS macro definitions
459 +/** OS macro to get time */
460 +#define os_time_get() jiffies
462 +/** OS macro to update transfer start time */
463 +#define UpdateTransStart(dev) { \
464 + dev->trans_start = jiffies; \
467 +/** Try to get a reference to the module */
468 +#define MODULE_GET try_module_get(THIS_MODULE)
469 +/** Decrease module reference count */
470 +#define MODULE_PUT module_put(THIS_MODULE)
472 +/** OS macro to initialize semaphore */
473 +#define OS_INIT_SEMAPHORE(x) sema_init(x,1)
474 +/** OS macro to acquire blocking semaphore */
475 +#define OS_ACQ_SEMAPHORE_BLOCK(x) down_interruptible(x)
476 +/** OS macro to acquire non-blocking semaphore */
477 +#define OS_ACQ_SEMAPHORE_NOBLOCK(x) down_trylock(x)
478 +/** OS macro to release semaphore */
479 +#define OS_REL_SEMAPHORE(x) up(x)
482 +os_sched_timeout(u32 millisec)
484 + set_current_state(TASK_INTERRUPTIBLE);
485 + schedule_timeout((millisec * HZ) / 1000);
488 +/** Maximum size of ethernet packet */
489 +#define MRVDRV_MAXIMUM_ETH_PACKET_SIZE 1514
491 +/** Maximum size of multicast list */
492 +#define MRVDRV_MAX_MULTICAST_LIST_SIZE 32
496 +#define MIN(a,b) ((a) < (b) ? (a) : (b))
501 +#define MAX(a,b) ((a) > (b) ? (a) : (b))
504 +/** Find number of elements */
506 +#define NELEMENTS(x) (sizeof(x)/sizeof(x[0]))
509 +/** Buffer Constants */
511 +/** Size of command buffer */
512 +#define MRVDRV_SIZE_OF_CMD_BUFFER (2 * 1024)
514 +/** Length of device length */
515 +#define DEV_NAME_LEN 32
517 +/** Length of ethernet address */
522 +/** Default watchdog timeout */
523 +#define MRVDRV_DEFAULT_WATCHDOG_TIMEOUT (2 * HZ)
526 +#define UAP_STATUS_SUCCESS (0)
528 +#define UAP_STATUS_FAILURE (-1)
530 +#define UAP_STATUS_NOT_ACCEPTED (-2)
532 +/** Max loop count (* 100ms) for waiting device ready at init time */
533 +#define MAX_WAIT_DEVICE_READY_COUNT 50
535 +/** Tx high watermark. Stop Tx queue after this is crossed */
536 +#define TX_HIGH_WATERMARK 4
537 +/** Tx low watermark. Restart Tx queue after this is crossed */
538 +#define TX_LOW_WATERMARK 2
540 +/** Netlink protocol number */
541 +#define NETLINK_MARVELL (MAX_LINKS - 1)
542 +/** Netlink maximum payload size */
543 +#define NL_MAX_PAYLOAD 1024
544 +/** Netlink multicast group number */
545 +#define NL_MULTICAST_GROUP 1
548 +#define MRVDRV_TIMER_20S 20000
550 +/** Host Command option for wait till Send */
551 +#define HostCmd_OPTION_WAITFORSEND 0x0001
552 +/** Host Command option for wait for RSP */
553 +#define HostCmd_OPTION_WAITFORRSP 0x0002
554 +/** Host Command option for wait for RSP or Timeout */
555 +#define HostCmd_OPTION_WAITFORRSP_TIMEOUT 0x0003
556 +/** Host Command option for wait for RSP of sleep confirm */
557 +#define HostCmd_OPTION_WAITFORRSP_SLEEPCONFIRM 0x0004
559 +/** Sleep until a condition gets true or a timeout elapses */
560 +#define os_wait_interruptible_timeout(waitq, cond, timeout) \
561 + wait_event_interruptible_timeout(waitq, cond, ((timeout) * HZ / 1000))
563 +/** Private command ID to Host command */
564 +#define UAPHOSTCMD (SIOCDEVPRIVATE + 1)
566 +/** Private command ID to Power Mode */
567 +#define UAP_POWER_MODE (SIOCDEVPRIVATE + 3)
569 +typedef struct _ps_sleep_param
571 + /** control bitmap */
573 + /** minimum sleep period (micro second) */
575 + /** maximum sleep period (micro second) */
579 +/** inactivity sleep_param */
580 +typedef struct _inact_sleep_param
582 + /** inactivity timeout (micro second) */
584 + /** miniumu awake period (micro second) */
586 + /** maximum awake period (micro second) */
588 +} inact_sleep_param;
590 +/** flag for ps mode */
591 +#define PS_FLAG_PS_MODE 1
592 +/** flag for sleep param */
593 +#define PS_FLAG_SLEEP_PARAM 2
594 +/** flag for inactivity sleep param */
595 +#define PS_FLAG_INACT_SLEEP_PARAM 4
597 +/** Disable power mode */
598 +#define PS_MODE_DISABLE 0
599 +/** Enable periodic dtim ps */
600 +#define PS_MODE_PERIODIC_DTIM 1
601 +/** Enable inactivity ps */
602 +#define PS_MODE_INACTIVITY 2
604 +/** sleep parameter */
605 +#define SLEEP_PARAMETER 1
606 +/** inactivity sleep parameter */
607 +#define INACTIVITY_SLEEP_PARAMETER 2
609 +typedef struct _ps_mgmt
611 + /** flags for valid field */
616 + ps_sleep_param sleep_param;
617 + /** inactivity sleep param */
618 + inact_sleep_param inact_param;
621 +/** Semaphore structure */
622 +typedef struct semaphore SEMAPHORE;
624 +/** Global Varibale Declaration */
625 +/** Private data structure of the device */
626 +typedef struct _uap_private uap_private;
627 +/** Adapter data structure of the device */
628 +typedef struct _uap_adapter uap_adapter;
629 +/** private structure */
630 +extern uap_private *uappriv;
632 +/** ENUM definition*/
634 +/** Hardware status codes */
635 +typedef enum _HARDWARE_STATUS
644 +/** info for debug purpose */
645 +typedef struct _uap_dbg
647 + /** Number of host to card command failures */
648 + u32 num_cmd_host_to_card_failure;
649 + /** Number of host to card Tx failures */
650 + u32 num_tx_host_to_card_failure;
653 +/** Set thread state */
654 +#define OS_SET_THREAD_STATE(x) set_current_state(x)
659 + struct task_struct *task;
661 + wait_queue_head_t waitQ;
664 + /** Private structure */
669 +uap_activate_thread(uap_thread * thr)
671 + /** Record the thread pid */
672 + thr->pid = current->pid;
674 + /** Initialize the wait queue */
675 + init_waitqueue_head(&thr->waitQ);
679 +uap_deactivate_thread(uap_thread * thr)
686 +uap_create_thread(int (*uapfunc) (void *), uap_thread * thr, char *name)
688 + thr->task = kthread_run(uapfunc, thr, "%s", name);
692 +uap_terminate_thread(uap_thread * thr)
694 + /* Check if the thread is active or not */
697 + kthread_stop(thr->task);
701 +/** Data structure for the Marvell uAP device */
702 +typedef struct _uap_dev
705 + char name[DEV_NAME_LEN];
706 + /** card pointer */
713 + TRUE - Data is sent to fw, no Tx Done received
714 + FALSE - Tx done received for previous Tx */
717 + TRUE - CMD is sent to fw, no CMD Done received
718 + FALSE - CMD done received for previous CMD */
720 + /** netdev pointer */
721 + struct net_device *netdev;
722 +} uap_dev_t, *puap_dev_t;
724 +/** Private structure for the MV device */
730 + /** Device adapter structure */
731 + uap_adapter *adapter;
732 + /** Device structure */
735 + /** Net device statistics structure */
736 + struct net_device_stats stats;
738 + /** Number of Tx timeouts */
739 + u32 num_tx_timeout;
741 + /** Media connection status */
742 + BOOLEAN MediaConnected;
744 +#ifdef CONFIG_PROC_FS
745 + struct proc_dir_entry *proc_uap;
746 + struct proc_dir_entry *proc_entry;
747 +#endif /* CONFIG_PROC_FS */
749 + /** Firmware helper */
750 + const struct firmware *fw_helper;
752 + const struct firmware *firmware;
753 + /** Hotplug device */
754 + struct device *hotplug_device;
755 + /** thread to service interrupts */
756 + uap_thread MainThread;
758 + spinlock_t driver_lock;
759 + /** Driver lock flags */
760 + ulong driver_flags;
764 +/** PS_CMD_ConfirmSleep */
765 +typedef struct _PS_CMD_ConfirmSleep
775 + /** Sequence number */
779 +} __ATTRIB_PACK__ PS_CMD_ConfirmSleep, *PPS_CMD_ConfirmSleep;
781 +/** Wlan Adapter data structure*/
784 + /** Power save confirm sleep command */
785 + PS_CMD_ConfirmSleep PSConfirmSleep;
786 + /** Device status */
787 + HARDWARE_STATUS HardwareStatus;
788 + /** Interrupt counter */
790 + /** Tx packet queue */
791 + struct sk_buff_head tx_queue;
792 + /** Cmd packet queue */
793 + struct sk_buff_head cmd_queue;
794 + /** Command sequence number */
796 + /** Command buffer */
798 + /** cmd pending flag */
800 + /** cmd wait option */
801 + u8 cmd_wait_option;
802 + /** Command buffer length */
804 + /** Command wait queue */
805 + wait_queue_head_t cmdwait_q __ATTRIB_ALIGN__;
806 + /** Command wait queue state flag */
809 + BOOLEAN SurpriseRemoved;
812 + /** Netlink kernel socket */
813 + struct sock *nl_sk;
814 + /** Semaphore for CMD */
816 + /** Power Save mode */
818 + /** Power Save state */
820 + /** Number of wakeup tries */
825 +os_upload_rx_packet(uap_private * priv, struct sk_buff *skb)
827 + skb->dev = priv->uap_dev.netdev;
828 + skb->protocol = eth_type_trans(skb, priv->uap_dev.netdev);
829 + skb->ip_summed = CHECKSUM_UNNECESSARY;
830 + if (in_interrupt())
838 + * netif carrier_on/off and start(wake)/stop_queue handling
841 +os_carrier_on(uap_private * priv)
843 + if (!netif_carrier_ok(priv->uap_dev.netdev) &&
844 + (priv->MediaConnected == TRUE)) {
845 + netif_carrier_on(priv->uap_dev.netdev);
850 +os_carrier_off(uap_private * priv)
852 + if (netif_carrier_ok(priv->uap_dev.netdev)) {
853 + netif_carrier_off(priv->uap_dev.netdev);
858 +os_start_queue(uap_private * priv)
860 + if (netif_queue_stopped(priv->uap_dev.netdev) &&
861 + (priv->MediaConnected == TRUE)) {
862 + netif_wake_queue(priv->uap_dev.netdev);
867 +os_stop_queue(uap_private * priv)
869 + if (!netif_queue_stopped(priv->uap_dev.netdev)) {
870 + netif_stop_queue(priv->uap_dev.netdev);
874 +/** Interface specific header */
875 +#define INTF_HEADER_LEN 4
877 +/** headroom alignment for tx packet */
878 +#define HEADER_ALIGNMENT 8
880 +/** The number of times to try when polling for status bits */
881 +#define MAX_POLL_TRIES 100
883 +/** Length of SNAP header */
884 +#define MRVDRV_SNAP_HEADER_LEN 8
886 +/** Extra length of Tx packet buffer */
887 +#define EXTRA_LEN 36
889 +/** Buffer size for ethernet Tx packets */
890 +#define MRVDRV_ETH_TX_PACKET_BUFFER_SIZE \
891 + (ETH_FRAME_LEN + sizeof(TxPD) + EXTRA_LEN)
893 +/** Buffer size for ethernet Rx packets */
894 +#define MRVDRV_ETH_RX_PACKET_BUFFER_SIZE \
895 + (ETH_FRAME_LEN + sizeof(RxPD) \
896 + + MRVDRV_SNAP_HEADER_LEN + EXTRA_LEN)
898 +/** Packet type: data, command & event */
899 +typedef enum _mv_type
906 +/** Disable interrupt */
907 +#define OS_INT_DISABLE spin_lock_irqsave(&priv->driver_lock, priv->driver_flags)
908 +/** Enable interrupt */
909 +#define OS_INT_RESTORE spin_unlock_irqrestore(&priv->driver_lock, priv->driver_flags)
911 +int uap_process_rx_packet(uap_private * priv, struct sk_buff *skb);
912 +void uap_interrupt(uap_private * priv);
913 +uap_private *uap_add_card(void *card);
914 +int uap_remove_card(void *card);
915 +int uap_process_event(uap_private * priv, u8 * payload, uint len);
916 +int uap_soft_reset(uap_private * priv);
917 +int uap_process_sleep_confirm_resp(uap_private * priv, u8 * resp, int resp_len);
919 +#ifdef CONFIG_PROC_FS
920 +/** The proc fs interface */
921 +void uap_proc_entry(uap_private * priv, struct net_device *dev);
922 +void uap_proc_remove(uap_private * priv);
923 +int string_to_number(char *s);
924 +void uap_debug_entry(uap_private * priv, struct net_device *dev);
925 +void uap_debug_remove(uap_private * priv);
926 +#endif /* CONFIG_PROC_FS */
928 +int sbi_register(void);
930 +void sbi_unregister(void);
931 +int sbi_register_dev(uap_private * priv);
932 +int sbi_unregister_dev(uap_private * priv);
933 +int sbi_prog_fw_w_helper(uap_private *);
935 +int sbi_host_to_card(uap_private * priv, u8 * payload, u16 nb);
936 +int sbi_enable_host_int(uap_private * priv);
937 +int sbi_disable_host_int(uap_private * priv);
939 +int sbi_get_int_status(uap_private * priv, u8 * ireg);
940 +/** Check firmware status */
941 +int sbi_check_fw_status(uap_private *, int);
942 +int sbi_prog_helper(uap_private *);
944 +int sbi_wakeup_firmware(uap_private * priv);
946 +#endif /* _UAP_DRV_H */
947 diff -Naur compat-wireless-3.5-rc5-1-snpc.org/drivers/net/wireless/libertas_uap/uap_fw.h compat-wireless-3.5-rc5-1-snpc/drivers/net/wireless/libertas_uap/uap_fw.h
948 --- compat-wireless-3.5-rc5-1-snpc.org/drivers/net/wireless/libertas_uap/uap_fw.h 1970-01-01 01:00:00.000000000 +0100
949 +++ compat-wireless-3.5-rc5-1-snpc/drivers/net/wireless/libertas_uap/uap_fw.h 2012-07-31 14:23:04.000000000 +0200
953 + * @brief This file contains firmware specific defines.
955 + * Copyright (C) 2008-2009, Marvell International Ltd.
957 + * This software file (the "File") is distributed by Marvell International
958 + * Ltd. under the terms of the GNU General Public License Version 2, June 1991
959 + * (the "License"). You may use, redistribute and/or modify this File in
960 + * accordance with the terms and conditions of the License, a copy of which
961 + * is available along with the File in the gpl.txt file or by writing to
962 + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
963 + * 02111-1307 or on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
965 + * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
966 + * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
967 + * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
968 + * this warranty disclaimer.
971 +/********************************************************
973 + 02/26/08: Initial creation
974 +********************************************************/
979 +/** uap upload size */
980 +#define UAP_UPLD_SIZE 2312
981 +/** Packet type Micro AP */
982 +#define PKT_TYPE_MICROAP 1
983 +/** Packet type client */
984 +#define PKT_TYPE_CLIENT 0
986 +/** TxPD descriptor */
987 +typedef struct _TxPD
993 + /** Tx packet length */
995 + /** Tx packet offset */
997 + /** Tx packet type */
1003 +} __ATTRIB_PACK__ TxPD, *PTxPD;
1005 +/** RxPD Descriptor */
1006 +typedef struct _RxPD
1012 + /** Tx packet length */
1014 + /** Tx packet offset */
1016 +} __ATTRIB_PACK__ RxPD, *PRxPD;
1019 +/** Convert from 16 bit little endian format to CPU format */
1020 +#define uap_le16_to_cpu(x) le16_to_cpu(x)
1021 +/** Convert from 32 bit little endian format to CPU format */
1022 +#define uap_le32_to_cpu(x) le32_to_cpu(x)
1023 +/** Convert from 64 bit little endian format to CPU format */
1024 +#define uap_le64_to_cpu(x) le64_to_cpu(x)
1025 +/** Convert to 16 bit little endian format from CPU format */
1026 +#define uap_cpu_to_le16(x) cpu_to_le16(x)
1027 +/** Convert to 32 bit little endian format from CPU format */
1028 +#define uap_cpu_to_le32(x) cpu_to_le32(x)
1029 +/** Convert to 64 bit little endian format from CPU format */
1030 +#define uap_cpu_to_le64(x) cpu_to_le64(x)
1032 +/** Convert TxPD to little endian format from CPU format */
1033 +#define endian_convert_TxPD(x); \
1035 + (x)->TxPktLength = uap_cpu_to_le16((x)->TxPktLength); \
1036 + (x)->TxPktOffset = uap_cpu_to_le32((x)->TxPktOffset); \
1037 + (x)->TxControl = uap_cpu_to_le32((x)->TxControl); \
1038 + (x)->TxPktType = uap_cpu_to_le32((x)->TxPktType); \
1041 +/** Convert RxPD from little endian format to CPU format */
1042 +#define endian_convert_RxPD(x); \
1044 + (x)->RxPktLength = uap_le16_to_cpu((x)->RxPktLength); \
1045 + (x)->RxPktOffset = uap_le32_to_cpu((x)->RxPktOffset); \
1047 +#else /* BIG_ENDIAN */
1049 +#define uap_le16_to_cpu(x) x
1051 +#define uap_le32_to_cpu(x) x
1053 +#define uap_le64_to_cpu(x) x
1055 +#define uap_cpu_to_le16(x) x
1057 +#define uap_cpu_to_le32(x) x
1059 +#define uap_cpu_to_le64(x) x
1062 +#define endian_convert_TxPD(x)
1064 +#define endian_convert_RxPD(x)
1065 +#endif /* BIG_ENDIAN */
1067 +/** Host Command ID : Function initialization */
1068 +#define HostCmd_CMD_FUNC_INIT 0x00a9
1069 +/** Host Command ID : Function shutdown */
1070 +#define HostCmd_CMD_FUNC_SHUTDOWN 0x00aa
1072 +/** Host Command id: SYS_INFO */
1073 +#define HOST_CMD_APCMD_SYS_INFO 0x00ae
1074 +/** Host Command id: SYS_RESET */
1075 +#define HOST_CMD_APCMD_SYS_RESET 0x00af
1076 +/** Host Command id: SYS_CONFIGURE */
1077 +#define HOST_CMD_APCMD_SYS_CONFIGURE 0x00b0
1078 +/** Host Command id: BSS_START */
1079 +#define HOST_CMD_APCMD_BSS_START 0x00b1
1080 +/** Host Command id: SYS_STOP */
1081 +#define HOST_CMD_APCMD_BSS_STOP 0x00b2
1082 +/** Host Command id: STA_LIST */
1083 +#define HOST_CMD_APCMD_STA_LIST 0x00b3
1084 +/** Host Command id: STA_FILTER_TABLE */
1085 +#define HOST_CMD_APCMD_STA_FILTER_TABLE 0x00b4
1086 +/** Host Command id: STA_DEAUTH */
1087 +#define HOST_CMD_APCMD_STA_DEAUTH 0x00b5
1088 +/** Host Command id: SOFT_RESET */
1089 +#define HOST_CMD_APCMD_SOFT_RESET 0x00d5
1090 +/** Host Command id: POWER_MGMT_EXT */
1091 +#define HOST_CMD_POWER_MGMT_EXT 0x00ef
1092 +/** Host Command id: SLEEP_CONFIRM*/
1093 +#define HOST_CMD_SLEEP_CONFIRM 0x00d8
1095 +/** TLV type : SSID */
1096 +#define TLV_TYPE_SSID 0x0000
1097 +/** TLV type : Rates */
1098 +#define TLV_TYPE_RATES 0x0001
1099 +/** TLV type : PHY DS */
1100 +#define TLV_TYPE_PHY_DS 0x0003
1102 +/** TLV Id : Base id */
1103 +#define PROPRIETARY_TLV_BASE_ID 0x0100
1104 +/** TLV Id : AP_MAC_ADDRESS */
1105 +#define MRVL_AP_MAC_ADDRESS_TLV_ID (PROPRIETARY_TLV_BASE_ID + 43)
1106 +/** TLV Id : Beacon period */
1107 +#define MRVL_BEACON_PERIOD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 44)
1108 +/** TLV Id : Dtim period */
1109 +#define MRVL_DTIM_PERIOD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 45)
1110 +/** TLV Id : Basic rates */
1111 +#define MRVL_BASIC_RATES_TLV_ID (PROPRIETARY_TLV_BASE_ID + 46)
1112 +/** TLV Id : Tx Power */
1113 +#define MRVL_TX_POWER_TLV_ID (PROPRIETARY_TLV_BASE_ID + 47)
1114 +/** TLV Id : Broadcast SSID control */
1115 +#define MRVL_BCAST_SSID_CTL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 48)
1116 +/** TLV Id : Preamble control */
1117 +#define MRVL_PREAMBLE_CTL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 49)
1118 +/** TLV Id : Antenna control */
1119 +#define MRVL_ANTENNA_CTL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 50)
1120 +/** TLV Id : RTS threshold */
1121 +#define MRVL_RTS_THRESHOLD_TLV_ID (PROPRIETARY_TLV_BASE_ID + 51)
1122 +/** TLV Id : Radio control */
1123 +#define MRVL_RADIO_CTL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 52)
1124 +/** TLV Id : TX data rate */
1125 +#define MRVL_TX_DATA_RATE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 53)
1126 +/** TLV Id : Packet forward control */
1127 +#define MRVL_PKT_FWD_CTL_TLV_ID (PROPRIETARY_TLV_BASE_ID + 54)
1128 +/** TLV Id : STA info */
1129 +#define MRVL_STA_INFO_TLV_ID (PROPRIETARY_TLV_BASE_ID + 55)
1130 +/** TLV Id : STA MAC address filter */
1131 +#define MRVL_STA_MAC_ADDR_FILTER_TLV_ID (PROPRIETARY_TLV_BASE_ID + 56)
1132 +/** TLV Id : STA ageout timer */
1133 +#define MRVL_STA_AGEOUT_TIMER_TLV_ID (PROPRIETARY_TLV_BASE_ID + 57)
1134 +/** TLV Id : Security config */
1135 +#define MRVL_SECURITY_CFG_TLV_ID (PROPRIETARY_TLV_BASE_ID + 58)
1136 +/** TLV Id : WEP KEY */
1137 +#define MRVL_WEP_KEY_TLV_ID (PROPRIETARY_TLV_BASE_ID + 59)
1138 +/** TLV Id : WPA Passphrase */
1139 +#define MRVL_WPA_PASSPHRASE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 60)
1142 +#define ACTION_GET 0
1144 +#define ACTION_SET 1
1145 +/** Length of ethernet address */
1150 +/** HostCmd_DS_GEN */
1157 + /** Sequence number */
1161 +} __ATTRIB_PACK__ HostCmd_DS_GEN;
1163 +/** Size of HostCmd_DS_GEN */
1164 +#define S_DS_GEN sizeof(HostCmd_DS_GEN)
1166 +/** _HostCmd_HEADER*/
1169 + /** Command Header : Command */
1171 + /** Command Header : Size */
1173 +} __ATTRIB_PACK__ HostCmd_HEADER;
1175 +/** HostCmd_SYS_CONFIG */
1176 +typedef struct _HostCmd_SYS_CONFIG
1178 + /** CMD Action GET/SET*/
1182 +} __ATTRIB_PACK__ HostCmd_SYS_CONFIG;
1184 +/** HostCmd_DS_POWER_MGMT_EXT */
1185 +typedef struct _HostCmd_DS_POWER_MGMT_EXT
1187 + /** CMD Action Get/Set*/
1191 +} __ATTRIB_PACK__ HostCmd_DS_POWER_MGMT_EXT;
1193 +/** _HostCmd_DS_COMMAND*/
1194 +typedef struct _HostCmd_DS_COMMAND
1197 + /** Command Header : Command */
1199 + /** Command Header : Size */
1201 + /** Command Header : Sequence number */
1203 + /** Command Header : Result */
1205 + /** Command Body */
1208 + HostCmd_SYS_CONFIG sys_config;
1209 + HostCmd_DS_POWER_MGMT_EXT pm_cfg;
1212 +} __ATTRIB_PACK__ HostCmd_DS_COMMAND;
1214 +/** MrvlIEtypesHeader_*/
1215 +typedef struct _MrvlIEtypesHeader
1217 + /** Header type */
1219 + /** Header length */
1221 +} __ATTRIB_PACK__ MrvlIEtypesHeader_t;
1223 +/** MrvlIEtypes_Data_t */
1224 +typedef struct _MrvlIEtypes_Data_t
1227 + MrvlIEtypesHeader_t Header;
1230 +} __ATTRIB_PACK__ MrvlIEtypes_Data_t;
1232 +/** MrvlIEtypes_ChanListParamSet_t */
1233 +typedef struct _MrvlIEtypes_MacAddr_t
1236 + MrvlIEtypesHeader_t Header;
1237 + /** AP MAC address */
1238 + u8 ApMacAddr[ETH_ALEN];
1239 +} __ATTRIB_PACK__ MrvlIEtypes_MacAddr_t;
1241 +/** Event ID: BSS started */
1242 +#define MICRO_AP_EV_ID_BSS_START 46
1244 +/** Event ID: BSS idle event */
1245 +#define MICRO_AP_EV_BSS_IDLE 67
1247 +/** Event ID: BSS active event */
1248 +#define MICRO_AP_EV_BSS_ACTIVE 68
1250 +/** Event ID: PS_AWAKE */
1251 +#define EVENT_PS_AWAKE 0x0a
1253 +/** Event ID: PS_SLEEP */
1254 +#define EVENT_PS_SLEEP 0x0b
1257 +typedef enum _PS_STATE
1260 + PS_STATE_PRE_SLEEP,
1264 +/** TLV type: AP Sleep param */
1265 +#define TLV_TYPE_AP_SLEEP_PARAM (PROPRIETARY_TLV_BASE_ID + 106)
1266 +/** TLV type: AP Inactivity Sleep param */
1267 +#define TLV_TYPE_AP_INACT_SLEEP_PARAM (PROPRIETARY_TLV_BASE_ID + 107)
1269 +/** MrvlIEtypes_sleep_param_t */
1270 +typedef struct _MrvlIEtypes_sleep_param_t
1273 + MrvlIEtypesHeader_t header;
1274 + /** control bitmap */
1280 +} __ATTRIB_PACK__ MrvlIEtypes_sleep_param_t;
1282 +/** MrvlIEtypes_inact_sleep_param_t */
1283 +typedef struct _MrvlIEtypes_inact_sleep_param_t
1286 + MrvlIEtypesHeader_t header;
1287 + /** inactivity timeout */
1288 + u32 inactivity_to;
1293 +} __ATTRIB_PACK__ MrvlIEtypes_inact_sleep_param_t;
1296 +typedef struct _AP_Event
1301 + * Reserved for STA_ASSOCIATED event and contains
1302 + * status information for the MIC_COUNTERMEASURES event.
1304 + /** Reserved/status */
1306 + /** AP MAC address */
1307 + u8 MacAddr[ETH_ALEN];
1308 +} __ATTRIB_PACK__ AP_Event;
1309 +#endif /* _UAP_FW_H */
1310 diff -Naur compat-wireless-3.5-rc5-1-snpc.org/drivers/net/wireless/libertas_uap/uap_headers.h compat-wireless-3.5-rc5-1-snpc/drivers/net/wireless/libertas_uap/uap_headers.h
1311 --- compat-wireless-3.5-rc5-1-snpc.org/drivers/net/wireless/libertas_uap/uap_headers.h 1970-01-01 01:00:00.000000000 +0100
1312 +++ compat-wireless-3.5-rc5-1-snpc/drivers/net/wireless/libertas_uap/uap_headers.h 2012-07-31 14:23:04.000000000 +0200
1314 +/** @file uap_headers.h
1316 + * @brief This file contains all the necessary include file.
1318 + * Copyright (C) 2008-2009, Marvell International Ltd.
1320 + * This software file (the "File") is distributed by Marvell International
1321 + * Ltd. under the terms of the GNU General Public License Version 2, June 1991
1322 + * (the "License"). You may use, redistribute and/or modify this File in
1323 + * accordance with the terms and conditions of the License, a copy of which
1324 + * is available along with the File in the gpl.txt file or by writing to
1325 + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1326 + * 02111-1307 or on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
1328 + * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
1329 + * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
1330 + * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
1331 + * this warranty disclaimer.
1334 +#ifndef _UAP_HEADERS_H
1335 +#define _UAP_HEADERS_H
1337 +/* Linux header files */
1338 +#include <linux/kernel.h>
1339 +#include <linux/module.h>
1340 +#include <linux/init.h>
1341 +#include <linux/version.h>
1342 +#include <linux/param.h>
1343 +#include <linux/types.h>
1344 +#include <linux/interrupt.h>
1345 +#include <linux/proc_fs.h>
1346 +#include <linux/kthread.h>
1347 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
1348 +#include <linux/semaphore.h>
1350 +#include <asm/semaphore.h>
1353 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
1354 +#include <linux/config.h>
1357 +/* Net header files */
1358 +#include <linux/netdevice.h>
1359 +#include <linux/net.h>
1360 +#include <linux/skbuff.h>
1361 +#include <linux/if_ether.h>
1362 +#include <linux/etherdevice.h>
1363 +#include <net/sock.h>
1364 +#include <linux/netlink.h>
1365 +#include <linux/firmware.h>
1366 +#include <linux/delay.h>
1368 +#include "uap_drv.h"
1369 +#include "uap_fw.h"
1371 +#include <linux/mmc/sdio.h>
1372 +#include <linux/mmc/sdio_ids.h>
1373 +#include <linux/mmc/sdio_func.h>
1374 +#include <linux/mmc/card.h>
1375 +#include "uap_sdio_mmc.h"
1377 +#endif /* _UAP_HEADERS_H */
1378 diff -Naur compat-wireless-3.5-rc5-1-snpc.org/drivers/net/wireless/libertas_uap/uap_main.c compat-wireless-3.5-rc5-1-snpc/drivers/net/wireless/libertas_uap/uap_main.c
1379 --- compat-wireless-3.5-rc5-1-snpc.org/drivers/net/wireless/libertas_uap/uap_main.c 1970-01-01 01:00:00.000000000 +0100
1380 +++ compat-wireless-3.5-rc5-1-snpc/drivers/net/wireless/libertas_uap/uap_main.c 2012-07-31 14:25:28.473230753 +0200
1382 +/** @file uap_main.c
1383 + * @brief This file contains the major functions in uAP
1384 + * driver. It includes init, exit etc..
1385 + * This file also contains the initialization for SW,
1388 + * Copyright (C) 2008-2009, Marvell International Ltd.
1390 + * This software file (the "File") is distributed by Marvell International
1391 + * Ltd. under the terms of the GNU General Public License Version 2, June 1991
1392 + * (the "License"). You may use, redistribute and/or modify this File in
1393 + * accordance with the terms and conditions of the License, a copy of which
1394 + * is available along with the File in the gpl.txt file or by writing to
1395 + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1396 + * 02111-1307 or on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
1398 + * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
1399 + * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
1400 + * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
1401 + * this warranty disclaimer.
1405 + * @mainpage uAP Linux Driver
1407 + * @section overview_sec Overview
1409 + * This is Linux reference driver for Marvell uAP.
1411 + * @section copyright_sec Copyright
1413 + * Copyright (C) 2008, Marvell International Ltd.
1417 +#include "uap_headers.h"
1420 + * the global variable of a pointer to uap_private
1421 + * structure variable
1423 +uap_private *uappriv = NULL;
1424 +#ifdef DEBUG_LEVEL1
1425 +#define DEFAULT_DEBUG_MASK (DBG_MSG | DBG_FATAL | DBG_ERROR)
1426 +u32 drvdbg = DEFAULT_DEBUG_MASK;
1429 +char *helper_name = NULL;
1430 +/** Firmware name */
1431 +char *fw_name = NULL;
1433 +/** Semaphore for add/remove card */
1434 +SEMAPHORE AddRemoveCardSem;
1436 +/********************************************************
1438 +********************************************************/
1440 + * @brief This function send sleep confirm command to firmware
1442 + * @param priv A pointer to uap_private structure
1443 + * @return UAP_STATUS_SUCCESS for success otherwise UAP_STATUS_FAILURE
1446 +uap_dnld_sleep_confirm_cmd(uap_private * priv)
1448 + uap_adapter *Adapter = priv->adapter;
1449 + int ret = UAP_STATUS_SUCCESS;
1451 + PRINTM(CMND, "Sleep confirm\n");
1452 + Adapter->cmd_pending = TRUE;
1453 + Adapter->cmd_wait_option = HostCmd_OPTION_WAITFORRSP_SLEEPCONFIRM;
1455 + sbi_host_to_card(priv, (u8 *) & Adapter->PSConfirmSleep,
1456 + sizeof(PS_CMD_ConfirmSleep));
1457 + if (ret != UAP_STATUS_SUCCESS) {
1458 + Adapter->ps_state = PS_STATE_AWAKE;
1459 + Adapter->cmd_pending = FALSE;
1460 + Adapter->cmd_wait_option = FALSE;
1467 + * @brief This function process sleep confirm resp from firmware
1469 + * @param priv A pointer to uap_private structure
1470 + * @param resp A pointer to resp buf
1471 + * @param resp_len resp buf len
1472 + * @return UAP_STATUS_SUCCESS for success otherwise UAP_STATUS_FAILURE
1475 +uap_process_sleep_confirm_resp(uap_private * priv, u8 * resp, int resp_len)
1477 + int ret = UAP_STATUS_SUCCESS;
1478 + HostCmd_DS_COMMAND *cmd;
1479 + uap_adapter *Adapter = priv->adapter;
1481 + PRINTM(CMND, "Sleep confirm resp\n");
1483 + PRINTM(ERROR, "Cmd Size is 0\n");
1487 + cmd = (HostCmd_DS_COMMAND *) resp;
1488 + cmd->Result = uap_le16_to_cpu(cmd->Result);
1489 + if (cmd->Result != UAP_STATUS_SUCCESS) {
1490 + PRINTM(ERROR, "HOST_CMD_APCMD_PS_SLEEP_CONFIRM fail=%x\n", cmd->Result);
1494 + if (ret == UAP_STATUS_SUCCESS)
1495 + Adapter->ps_state = PS_STATE_SLEEP;
1497 + Adapter->ps_state = PS_STATE_AWAKE;
1503 + * @brief This function checks condition and prepares to
1504 + * send sleep confirm command to firmware if OK.
1506 + * @param priv A pointer to uap_private structure
1510 +uap_ps_cond_check(uap_private * priv)
1512 + uap_adapter *Adapter = priv->adapter;
1515 + if (!priv->uap_dev.cmd_sent &&
1516 + !Adapter->cmd_pending && !Adapter->IntCounter) {
1517 + uap_dnld_sleep_confirm_cmd(priv);
1519 + PRINTM(INFO, "Delay Sleep Confirm (%s%s%s)\n",
1520 + (priv->uap_dev.cmd_sent) ? "D" : "",
1521 + (Adapter->cmd_pending) ? "C" : "",
1522 + (Adapter->IntCounter) ? "I" : "");
1528 + * @brief This function add cmd to cmdQ and waiting for response
1530 + * @param priv A pointer to uap_private structure
1531 + * @param skb A pointer to the skb for process
1532 + * @param wait_option Wait option
1533 + * @return UAP_STATUS_SUCCESS for success otherwise UAP_STATUS_FAILURE
1536 +uap_process_cmd(uap_private * priv, struct sk_buff *skb, u8 wait_option)
1538 + uap_adapter *Adapter = priv->adapter;
1539 + int ret = UAP_STATUS_SUCCESS;
1540 + HostCmd_DS_COMMAND *cmd;
1543 + if (Adapter->HardwareStatus != HWReady) {
1544 + PRINTM(ERROR, "Hw not ready, uap_process_cmd\n");
1549 + skb->cb[0] = wait_option;
1550 + headptr = skb->data;
1551 + *(u16 *) & headptr[0] = uap_cpu_to_le16(skb->len);
1552 + *(u16 *) & headptr[2] = uap_cpu_to_le16(MV_TYPE_CMD);
1553 + cmd = (HostCmd_DS_COMMAND *) (skb->data + INTF_HEADER_LEN);
1554 + Adapter->SeqNum++;
1555 + cmd->SeqNum = uap_cpu_to_le16(Adapter->SeqNum);
1556 + PRINTM(CMND, "process_cmd: %x\n", cmd->Command);
1557 + DBG_HEXDUMP(CMD_D, "process_cmd", (u8 *) cmd, cmd->Size);
1558 + if (!wait_option) {
1559 + skb_queue_tail(&priv->adapter->cmd_queue, skb);
1560 + wake_up_interruptible(&priv->MainThread.waitQ);
1564 + if (OS_ACQ_SEMAPHORE_BLOCK(&Adapter->CmdSem)) {
1565 + PRINTM(ERROR, "Acquire semaphore error, uap_prepare_cmd\n");
1570 + skb_queue_tail(&priv->adapter->cmd_queue, skb);
1571 + Adapter->CmdWaitQWoken = FALSE;
1572 + wake_up_interruptible(&priv->MainThread.waitQ);
1573 + /* Sleep until response is generated by FW */
1574 + if (wait_option == HostCmd_OPTION_WAITFORRSP_TIMEOUT) {
1575 + if (!os_wait_interruptible_timeout
1576 + (Adapter->cmdwait_q, Adapter->CmdWaitQWoken, MRVDRV_TIMER_20S)) {
1577 + PRINTM(ERROR, "Cmd timeout\n");
1578 + Adapter->cmd_pending = FALSE;
1582 + wait_event_interruptible(Adapter->cmdwait_q, Adapter->CmdWaitQWoken);
1583 + OS_REL_SEMAPHORE(&Adapter->CmdSem);
1589 + * @brief Inspect the response buffer for pointers to expected TLVs
1592 + * @param pTlv Pointer to the start of the TLV buffer to parse
1593 + * @param tlvBufSize Size of the TLV buffer
1594 + * @param reqTlvType request tlv's tlvtype
1595 + * @param ppTlv Output parameter: Pointer to the request TLV if found
1600 +uap_get_tlv_ptrs(MrvlIEtypes_Data_t * pTlv, int tlvBufSize,
1601 + u16 reqTlvType, MrvlIEtypes_Data_t ** ppTlv)
1603 + MrvlIEtypes_Data_t *pCurrentTlv;
1609 + pCurrentTlv = pTlv;
1610 + tlvBufLeft = tlvBufSize;
1612 + PRINTM(INFO, "uap_get_tlv: tlvBufSize = %d, reqTlvType=%x\n", tlvBufSize,
1614 + while (tlvBufLeft >= sizeof(MrvlIEtypesHeader_t)) {
1615 + tlvType = uap_le16_to_cpu(pCurrentTlv->Header.Type);
1616 + tlvLen = uap_le16_to_cpu(pCurrentTlv->Header.Len);
1617 + if (reqTlvType == tlvType)
1618 + *ppTlv = (MrvlIEtypes_Data_t *) pCurrentTlv;
1620 + HEXDUMP("TLV Buf", (u8 *) * ppTlv, tlvLen);
1623 + tlvBufLeft -= (sizeof(pTlv->Header) + tlvLen);
1624 + pCurrentTlv = (MrvlIEtypes_Data_t *) (pCurrentTlv->Data + tlvLen);
1630 + * @brief This function get mac
1632 + * @param priv A pointer to uap_private structure
1633 + * @return UAP_STATUS_SUCCESS on success, otherwise failure code
1636 +uap_get_mac_address(uap_private * priv)
1638 + int ret = UAP_STATUS_SUCCESS;
1640 + HostCmd_DS_COMMAND *cmd;
1641 + uap_adapter *Adapter = priv->adapter;
1642 + struct sk_buff *skb;
1643 + MrvlIEtypes_MacAddr_t *pMacAddrTlv;
1644 + MrvlIEtypes_Data_t *pTlv;
1647 + skb = dev_alloc_skb(MRVDRV_SIZE_OF_CMD_BUFFER);
1649 + PRINTM(ERROR, "No free skb\n");
1654 + S_DS_GEN + sizeof(HostCmd_SYS_CONFIG) + sizeof(MrvlIEtypes_MacAddr_t);
1655 + cmd = (HostCmd_DS_COMMAND *) (skb->data + INTF_HEADER_LEN);
1656 + cmd->Command = uap_cpu_to_le16(HOST_CMD_APCMD_SYS_CONFIGURE);
1657 + cmd->Size = uap_cpu_to_le16(CmdSize);
1658 + cmd->params.sys_config.Action = uap_cpu_to_le16(ACTION_GET);
1660 + (MrvlIEtypes_MacAddr_t *) (skb->data + INTF_HEADER_LEN + S_DS_GEN +
1661 + sizeof(HostCmd_SYS_CONFIG));
1662 + pMacAddrTlv->Header.Type = uap_cpu_to_le16(MRVL_AP_MAC_ADDRESS_TLV_ID);
1663 + pMacAddrTlv->Header.Len = uap_cpu_to_le16(ETH_ALEN);
1664 + skb_put(skb, CmdSize + INTF_HEADER_LEN);
1665 + if (UAP_STATUS_SUCCESS !=
1666 + uap_process_cmd(priv, skb, HostCmd_OPTION_WAITFORRSP_TIMEOUT)) {
1667 + PRINTM(ERROR, "Fail to process cmd SYS_CONFIGURE Query\n");
1671 + if (!Adapter->CmdSize) {
1672 + PRINTM(ERROR, "Cmd Size is 0\n");
1676 + cmd = (HostCmd_DS_COMMAND *) Adapter->CmdBuf;
1677 + cmd->Result = uap_le16_to_cpu(cmd->Result);
1678 + if (cmd->Result != UAP_STATUS_SUCCESS) {
1679 + PRINTM(ERROR, "uap_get_mac_address fail=%x\n", cmd->Result);
1684 + (MrvlIEtypes_Data_t *) (Adapter->CmdBuf + S_DS_GEN +
1685 + sizeof(HostCmd_SYS_CONFIG));
1686 + tlvBufSize = Adapter->CmdSize - S_DS_GEN - sizeof(HostCmd_SYS_CONFIG);
1687 + uap_get_tlv_ptrs(pTlv, tlvBufSize, MRVL_AP_MAC_ADDRESS_TLV_ID,
1688 + (MrvlIEtypes_Data_t **) & pMacAddrTlv);
1689 + if (pMacAddrTlv) {
1690 + memcpy(priv->uap_dev.netdev->dev_addr, pMacAddrTlv->ApMacAddr,
1692 + HEXDUMP("Original MAC addr", priv->uap_dev.netdev->dev_addr, ETH_ALEN);
1700 + * @brief This function checks the conditions and sends packet to device
1702 + * @param priv A pointer to uap_private structure
1703 + * @param skb A pointer to the skb for process
1704 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
1707 +uap_process_tx(uap_private * priv, struct sk_buff *skb)
1709 + uap_adapter *Adapter = priv->adapter;
1710 + int ret = UAP_STATUS_SUCCESS;
1713 + struct sk_buff *newskb;
1719 + return UAP_STATUS_FAILURE;
1721 + if (skb_headroom(skb) < (sizeof(TxPD) + INTF_HEADER_LEN + HEADER_ALIGNMENT)) {
1722 + newheadlen = sizeof(TxPD) + INTF_HEADER_LEN + HEADER_ALIGNMENT;
1723 + PRINTM(WARN, "Tx: Insufficient skb headroom %d\n", skb_headroom(skb));
1724 + /* Insufficient skb headroom - allocate a new skb */
1725 + newskb = skb_realloc_headroom(skb, newheadlen);
1726 + if (unlikely(newskb == NULL)) {
1727 + PRINTM(ERROR, "Tx: Cannot allocate skb\n");
1728 + ret = UAP_STATUS_FAILURE;
1733 + PRINTM(INFO, "new skb headroom %d\n", skb_headroom(skb));
1735 + /* headptr should be aligned */
1736 + headptr = skb->data - sizeof(TxPD) - INTF_HEADER_LEN;
1737 + headptr = (u8 *) ((u32) headptr & ~((u32) (HEADER_ALIGNMENT - 1)));
1739 + pLocalTxPD = (TxPD *) (headptr + INTF_HEADER_LEN);
1740 + memset(pLocalTxPD, 0, sizeof(TxPD));
1741 + pLocalTxPD->BssType = PKT_TYPE_MICROAP;
1742 + pLocalTxPD->TxPktLength = skb->len;
1743 + /* offset of actual data */
1744 + pLocalTxPD->TxPktOffset = (long) skb->data - (long) pLocalTxPD;
1745 + endian_convert_TxPD(pLocalTxPD);
1746 + *(u16 *) & headptr[0] =
1747 + uap_cpu_to_le16(skb->len + ((long) skb->data - (long) headptr));
1748 + *(u16 *) & headptr[2] = uap_cpu_to_le16(MV_TYPE_DAT);
1750 + sbi_host_to_card(priv, headptr,
1751 + skb->len + ((long) skb->data - (long) headptr));
1753 + PRINTM(ERROR, "uap_process_tx Error: sbi_host_to_card failed: 0x%X\n",
1755 + Adapter->dbg.num_tx_host_to_card_failure++;
1758 + PRINTM(DATA, "Data => FW\n");
1759 + DBG_HEXDUMP(DAT_D, "Tx", headptr,
1760 + MIN(skb->len + sizeof(TxPD), DATA_DUMP_LEN));
1769 + * @brief This function initializes the adapter structure
1770 + * and set default value to the member of adapter.
1772 + * @param priv A pointer to uap_private structure
1773 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
1776 +uap_init_sw(uap_private * priv)
1778 + uap_adapter *Adapter = priv->adapter;
1782 + if (!(Adapter->CmdBuf = kmalloc(MRVDRV_SIZE_OF_CMD_BUFFER, GFP_KERNEL))) {
1783 + PRINTM(INFO, "Failed to allocate command buffer!\n");
1785 + return UAP_STATUS_FAILURE;
1788 + Adapter->cmd_pending = FALSE;
1789 + Adapter->CmdWaitQWoken = FALSE;
1790 + Adapter->ps_state = PS_STATE_AWAKE;
1791 + Adapter->WakeupTries = 0;
1793 + memset(&Adapter->PSConfirmSleep, 0, sizeof(PS_CMD_ConfirmSleep));
1794 + /** SDIO header */
1795 + Adapter->PSConfirmSleep.SDLen =
1796 + uap_cpu_to_le16(sizeof(PS_CMD_ConfirmSleep));
1797 + Adapter->PSConfirmSleep.SDType = uap_cpu_to_le16(MV_TYPE_CMD);
1798 + Adapter->PSConfirmSleep.SeqNum = 0;
1799 + Adapter->PSConfirmSleep.Command = uap_cpu_to_le16(HOST_CMD_SLEEP_CONFIRM);
1800 + Adapter->PSConfirmSleep.Size = uap_cpu_to_le16(sizeof(HostCmd_DS_GEN));
1801 + Adapter->PSConfirmSleep.Result = 0;
1803 + init_waitqueue_head(&Adapter->cmdwait_q);
1804 + OS_INIT_SEMAPHORE(&Adapter->CmdSem);
1806 + skb_queue_head_init(&Adapter->tx_queue);
1807 + skb_queue_head_init(&Adapter->cmd_queue);
1809 + /* Status variable */
1810 + Adapter->HardwareStatus = HWInitializing;
1813 + Adapter->SurpriseRemoved = FALSE;
1815 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
1816 + Adapter->nl_sk = netlink_kernel_create(NETLINK_MARVELL,
1817 + NL_MULTICAST_GROUP, NULL,
1820 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
1821 + Adapter->nl_sk = netlink_kernel_create(NETLINK_MARVELL,
1822 + NL_MULTICAST_GROUP, NULL, NULL,
1825 + Adapter->nl_sk = netlink_kernel_create(&init_net, NETLINK_MARVELL,
1826 + NL_MULTICAST_GROUP, NULL, NULL,
1830 + if (!Adapter->nl_sk) {
1832 + "Could not initialize netlink event passing mechanism!\n");
1835 + return UAP_STATUS_SUCCESS;
1839 + * @brief This function sends FUNC_INIT command to firmware
1841 + * @param priv A pointer to uap_private structure
1842 + * @return UAP_STATUS_SUCCESS on success, otherwise failure code
1845 +uap_func_init(uap_private * priv)
1847 + int ret = UAP_STATUS_SUCCESS;
1849 + HostCmd_DS_GEN *cmd;
1850 + uap_adapter *Adapter = priv->adapter;
1851 + struct sk_buff *skb;
1853 + if (Adapter->HardwareStatus != HWReady) {
1854 + PRINTM(ERROR, "uap_func_init:Hardware is not ready!\n");
1858 + skb = dev_alloc_skb(MRVDRV_SIZE_OF_CMD_BUFFER);
1860 + PRINTM(ERROR, "No free skb\n");
1864 + CmdSize = sizeof(HostCmd_DS_GEN);
1865 + cmd = (HostCmd_DS_GEN *) (skb->data + INTF_HEADER_LEN);
1866 + cmd->Command = uap_cpu_to_le16(HostCmd_CMD_FUNC_INIT);
1867 + cmd->Size = uap_cpu_to_le16(CmdSize);
1868 + skb_put(skb, CmdSize + INTF_HEADER_LEN);
1869 + PRINTM(CMND, "HostCmd_CMD_FUNC_INIT\n");
1870 + if (UAP_STATUS_SUCCESS !=
1871 + uap_process_cmd(priv, skb, HostCmd_OPTION_WAITFORRSP_TIMEOUT)) {
1872 + PRINTM(ERROR, "Fail to process cmd HostCmd_CMD_FUNC_INIT\n");
1882 + * @brief This function sends FUNC_SHUTDOWN command to firmware
1884 + * @param priv A pointer to uap_private structure
1885 + * @return UAP_STATUS_SUCCESS on success, otherwise failure code
1888 +uap_func_shutdown(uap_private * priv)
1890 + int ret = UAP_STATUS_SUCCESS;
1892 + HostCmd_DS_GEN *cmd;
1893 + uap_adapter *Adapter = priv->adapter;
1894 + struct sk_buff *skb;
1896 + if (Adapter->HardwareStatus != HWReady) {
1897 + PRINTM(ERROR, "uap_func_shutdown:Hardware is not ready!\n");
1901 + skb = dev_alloc_skb(MRVDRV_SIZE_OF_CMD_BUFFER);
1903 + PRINTM(ERROR, "No free skb\n");
1907 + CmdSize = sizeof(HostCmd_DS_GEN);
1908 + cmd = (HostCmd_DS_GEN *) (skb->data + INTF_HEADER_LEN);
1909 + cmd->Command = uap_cpu_to_le16(HostCmd_CMD_FUNC_SHUTDOWN);
1910 + cmd->Size = uap_cpu_to_le16(CmdSize);
1911 + skb_put(skb, CmdSize + INTF_HEADER_LEN);
1912 + PRINTM(CMND, "HostCmd_CMD_FUNC_SHUTDOWN\n");
1913 + if (UAP_STATUS_SUCCESS !=
1914 + uap_process_cmd(priv, skb, HostCmd_OPTION_WAITFORRSP_TIMEOUT)) {
1915 + PRINTM(ERROR, "Fail to process cmd HostCmd_CMD_FUNC_SHUTDOWN\n");
1925 + * @brief This function initializes firmware
1927 + * @param priv A pointer to uap_private structure
1928 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
1931 +uap_init_fw(uap_private * priv)
1933 + int ret = UAP_STATUS_SUCCESS;
1935 + sbi_disable_host_int(priv);
1936 + /* Check if firmware is already running */
1937 + if (sbi_check_fw_status(priv, 1) == UAP_STATUS_SUCCESS) {
1938 + PRINTM(MSG, "UAP FW already running! Skip FW download\n");
1940 + if ((ret = request_firmware(&priv->fw_helper, helper_name,
1941 + priv->hotplug_device)) < 0) {
1943 + "request_firmware() failed (helper), error code = %#x\n",
1948 + /* Download the helper */
1949 + ret = sbi_prog_helper(priv);
1953 + "Bootloader in invalid state! Helper download failed!\n");
1954 + ret = UAP_STATUS_FAILURE;
1957 + if ((ret = request_firmware(&priv->firmware, fw_name,
1958 + priv->hotplug_device)) < 0) {
1959 + PRINTM(FATAL, "request_firmware() failed, error code = %#x\n", ret);
1963 + /* Download the main firmware via the helper firmware */
1964 + if (sbi_prog_fw_w_helper(priv)) {
1965 + PRINTM(FATAL, "UAP FW download failed!\n");
1966 + ret = UAP_STATUS_FAILURE;
1969 + /* Check if the firmware is downloaded successfully or not */
1970 + if (sbi_check_fw_status(priv, MAX_FIRMWARE_POLL_TRIES) ==
1971 + UAP_STATUS_FAILURE) {
1972 + PRINTM(FATAL, "FW failed to be active in time!\n");
1973 + ret = UAP_STATUS_FAILURE;
1976 + PRINTM(MSG, "UAP FW is active\n");
1978 + sbi_enable_host_int(priv);
1979 + priv->adapter->HardwareStatus = HWReady;
1980 + if (uap_func_init(priv) != UAP_STATUS_SUCCESS) {
1981 + ret = UAP_STATUS_FAILURE;
1985 + if (priv->fw_helper)
1986 + release_firmware(priv->fw_helper);
1987 + if (priv->firmware)
1988 + release_firmware(priv->firmware);
1995 + * @brief This function frees the structure of adapter
1997 + * @param priv A pointer to uap_private structure
2001 +uap_free_adapter(uap_private * priv)
2003 + uap_adapter *Adapter = priv->adapter;
2008 + if ((Adapter->nl_sk) && ((Adapter->nl_sk)->sk_socket)) {
2009 + sock_release((Adapter->nl_sk)->sk_socket);
2010 + Adapter->nl_sk = NULL;
2012 + if (Adapter->CmdBuf)
2013 + kfree(Adapter->CmdBuf);
2014 + skb_queue_purge(&priv->adapter->tx_queue);
2015 + skb_queue_purge(&priv->adapter->cmd_queue);
2016 + /* Free the adapter object itself */
2018 + priv->adapter = NULL;
2025 + * @brief This function handles the major job in uap driver.
2026 + * it handles the event generated by firmware, rx data received
2027 + * from firmware and tx data sent from kernel.
2029 + * @param data A pointer to uap_thread structure
2030 + * @return BT_STATUS_SUCCESS
2033 +uap_service_main_thread(void *data)
2035 + uap_thread *thread = data;
2036 + uap_private *priv = thread->priv;
2037 + uap_adapter *Adapter = priv->adapter;
2038 + wait_queue_t wait;
2040 + struct sk_buff *skb;
2042 + uap_activate_thread(thread);
2043 + init_waitqueue_entry(&wait, current);
2044 + current->flags |= PF_NOFREEZE;
2047 + add_wait_queue(&thread->waitQ, &wait);
2048 + OS_SET_THREAD_STATE(TASK_INTERRUPTIBLE);
2049 + if ((Adapter->WakeupTries) ||
2050 + (!Adapter->IntCounter && Adapter->ps_state == PS_STATE_PRE_SLEEP) ||
2051 + (!priv->adapter->IntCounter
2052 + && (priv->uap_dev.data_sent ||
2053 + skb_queue_empty(&priv->adapter->tx_queue))
2054 + && (priv->uap_dev.cmd_sent || Adapter->cmd_pending ||
2055 + skb_queue_empty(&priv->adapter->cmd_queue))
2057 + PRINTM(INFO, "Main: Thread sleeping...\n");
2060 + OS_SET_THREAD_STATE(TASK_RUNNING);
2061 + remove_wait_queue(&thread->waitQ, &wait);
2062 + if (kthread_should_stop() || Adapter->SurpriseRemoved) {
2063 + PRINTM(INFO, "main-thread: break from main thread: "
2064 + "SurpriseRemoved=0x%x\n", Adapter->SurpriseRemoved);
2065 + /* Cancel pending command */
2066 + if (Adapter->cmd_pending == TRUE) {
2067 + /* Wake up cmd Q */
2068 + Adapter->CmdWaitQWoken = TRUE;
2069 + wake_up_interruptible(&Adapter->cmdwait_q);
2074 + PRINTM(INFO, "Main: Thread waking up...\n");
2075 + if (priv->adapter->IntCounter) {
2077 + Adapter->IntCounter = 0;
2079 + sbi_get_int_status(priv, &ireg);
2080 + } else if ((priv->adapter->ps_state == PS_STATE_SLEEP) &&
2081 + (!skb_queue_empty(&priv->adapter->cmd_queue) ||
2082 + !skb_queue_empty(&priv->adapter->tx_queue))) {
2083 + priv->adapter->WakeupTries++;
2084 + PRINTM(CMND, "%lu : Wakeup device...\n", os_time_get());
2085 + sbi_wakeup_firmware(priv);
2088 + if (Adapter->ps_state == PS_STATE_PRE_SLEEP)
2089 + uap_ps_cond_check(priv);
2091 + /* The PS state is changed during processing of Sleep Request event
2093 + if ((Adapter->ps_state == PS_STATE_SLEEP) ||
2094 + (Adapter->ps_state == PS_STATE_PRE_SLEEP))
2096 + /* Execute the next command */
2097 + if (!priv->uap_dev.cmd_sent && !Adapter->cmd_pending &&
2098 + (Adapter->HardwareStatus == HWReady)) {
2099 + if (!skb_queue_empty(&priv->adapter->cmd_queue)) {
2100 + skb = skb_dequeue(&priv->adapter->cmd_queue);
2102 + Adapter->CmdSize = 0;
2103 + Adapter->cmd_pending = TRUE;
2104 + Adapter->cmd_wait_option = skb->cb[0];
2105 + if (sbi_host_to_card(priv, skb->data, skb->len)) {
2106 + PRINTM(ERROR, "Cmd:sbi_host_to_card failed!\n");
2107 + Adapter->cmd_pending = FALSE;
2108 + Adapter->dbg.num_cmd_host_to_card_failure++;
2109 + /* Wake up cmd Q */
2110 + Adapter->CmdWaitQWoken = TRUE;
2111 + wake_up_interruptible(&Adapter->cmdwait_q);
2113 + if (Adapter->cmd_wait_option ==
2114 + HostCmd_OPTION_WAITFORSEND) {
2115 + /* Wake up cmd Q */
2116 + Adapter->CmdWaitQWoken = TRUE;
2117 + wake_up_interruptible(&Adapter->cmdwait_q);
2118 + Adapter->cmd_wait_option = FALSE;
2125 + if (!priv->uap_dev.data_sent && (Adapter->HardwareStatus == HWReady)) {
2126 + if (!skb_queue_empty(&priv->adapter->tx_queue)) {
2127 + skb = skb_dequeue(&priv->adapter->tx_queue);
2129 + if (uap_process_tx(priv, skb)) {
2130 + priv->stats.tx_dropped++;
2131 + priv->stats.tx_errors++;
2132 + os_start_queue(priv);
2134 + priv->stats.tx_packets++;
2135 + priv->stats.tx_bytes += skb->len;
2142 + uap_deactivate_thread(thread);
2144 + return UAP_STATUS_SUCCESS;
2148 + * @brief uap hostcmd ioctl handler
2150 + * @param dev A pointer to net_device structure
2151 + * @param req A pointer to ifreq structure
2152 + * @return UAP_STATUS_SUCCESS --success, otherwise fail
2154 +/********* format of ifr_data *************/
2155 +/* buf_len + Hostcmd_body */
2156 +/* buf_len: 4 bytes */
2157 +/* the length of the buf which */
2158 +/* can be used to return data */
2159 +/* to application */
2161 +/*******************************************/
2163 +uap_hostcmd_ioctl(struct net_device *dev, struct ifreq *req)
2166 + HostCmd_HEADER head;
2167 + uap_private *priv = (uap_private *) netdev_priv(dev);
2168 + uap_adapter *Adapter = priv->adapter;
2169 + int ret = UAP_STATUS_SUCCESS;
2170 + struct sk_buff *skb;
2174 + /* Sanity check */
2175 + if (req->ifr_data == NULL) {
2176 + PRINTM(ERROR, "uap_hostcmd_ioctl() corrupt data\n");
2180 + if (copy_from_user(&buf_len, req->ifr_data, sizeof(buf_len))) {
2181 + PRINTM(ERROR, "Copy from user failed\n");
2185 + memset(&head, 0, sizeof(HostCmd_HEADER));
2186 + /* Get the command size from user space */
2187 + if (copy_from_user
2188 + (&head, req->ifr_data + sizeof(buf_len), sizeof(HostCmd_HEADER))) {
2189 + PRINTM(ERROR, "Copy from user failed\n");
2193 + head.Size = uap_le16_to_cpu(head.Size);
2194 + if (head.Size > MRVDRV_SIZE_OF_CMD_BUFFER) {
2195 + PRINTM(ERROR, "CmdSize too big=%d\n", head.Size);
2199 + PRINTM(CMND, "ioctl: hostcmd=%x, size=%d,buf_len=%d\n", head.Command,
2200 + head.Size, buf_len);
2201 + skb = dev_alloc_skb(head.Size + INTF_HEADER_LEN);
2203 + PRINTM(ERROR, "No free skb\n");
2208 + /* Get the command from user space */
2209 + if (copy_from_user
2210 + (skb->data + INTF_HEADER_LEN, req->ifr_data + sizeof(buf_len),
2212 + PRINTM(ERROR, "Copy from user failed\n");
2216 + skb_put(skb, head.Size + INTF_HEADER_LEN);
2217 + if (UAP_STATUS_SUCCESS !=
2218 + uap_process_cmd(priv, skb, HostCmd_OPTION_WAITFORRSP)) {
2219 + PRINTM(ERROR, "Fail to process cmd\n");
2223 + if (!Adapter->CmdSize) {
2224 + PRINTM(ERROR, "Cmd Size is 0\n");
2228 + if (Adapter->CmdSize > buf_len) {
2229 + PRINTM(ERROR, "buf_len is too small\n");
2233 + /* Copy to user */
2235 + (req->ifr_data + sizeof(buf_len), Adapter->CmdBuf, Adapter->CmdSize)) {
2236 + PRINTM(ERROR, "Copy to user failed!\n");
2245 + * @brief uap power mode ioctl handler
2247 + * @param dev A pointer to net_device structure
2248 + * @param req A pointer to ifreq structure
2249 + * @return UAP_STATUS_SUCCESS --success, otherwise fail
2252 +uap_power_mode_ioctl(struct net_device *dev, struct ifreq *req)
2255 + int ret = UAP_STATUS_SUCCESS;
2256 + uap_private *priv = (uap_private *) netdev_priv(dev);
2257 + uap_adapter *Adapter = priv->adapter;
2258 + struct sk_buff *skb = NULL;
2259 + HostCmd_DS_COMMAND *cmd;
2262 + MrvlIEtypes_sleep_param_t *sleep_tlv = NULL;
2263 + MrvlIEtypes_inact_sleep_param_t *inact_tlv = NULL;
2264 + u16 tlv_buf_left = 0;
2265 + MrvlIEtypesHeader_t *tlvbuf = NULL;
2271 + /* Sanity check */
2272 + if (req->ifr_data == NULL) {
2273 + PRINTM(ERROR, "uap_power_mode_ioctl() corrupt data\n");
2278 + memset(&pm_cfg, 0, sizeof(ps_mgmt));
2279 + if (copy_from_user(&pm_cfg, req->ifr_data, sizeof(ps_mgmt))) {
2280 + PRINTM(ERROR, "Copy from user failed\n");
2285 + "ioctl power: flag=0x%x ps_mode=%d ctrl_bitmap=%d min_sleep=%d max_sleep=%d "
2286 + "inact_to=%d min_awake=%d max_awake=%d\n", pm_cfg.flags,
2287 + (int) pm_cfg.ps_mode, (int) pm_cfg.sleep_param.ctrl_bitmap,
2288 + (int) pm_cfg.sleep_param.min_sleep,
2289 + (int) pm_cfg.sleep_param.max_sleep,
2290 + (int) pm_cfg.inact_param.inactivity_to,
2291 + (int) pm_cfg.inact_param.min_awake,
2292 + (int) pm_cfg.inact_param.max_awake);
2295 + flags & ~(PS_FLAG_PS_MODE | PS_FLAG_SLEEP_PARAM |
2296 + PS_FLAG_INACT_SLEEP_PARAM)) {
2297 + PRINTM(ERROR, "Invalid parameter: flags = 0x%x\n", pm_cfg.flags);
2301 + if (pm_cfg.ps_mode > PS_MODE_INACTIVITY) {
2302 + PRINTM(ERROR, "Invalid parameter: ps_mode = %d\n", (int) pm_cfg.flags);
2307 + skb = dev_alloc_skb(MRVDRV_SIZE_OF_CMD_BUFFER);
2309 + PRINTM(INFO, "No free skb\n");
2314 + CmdSize = S_DS_GEN + sizeof(HostCmd_DS_POWER_MGMT_EXT);
2316 + cmd = (HostCmd_DS_COMMAND *) (skb->data + INTF_HEADER_LEN);
2317 + cmd->Command = uap_cpu_to_le16(HOST_CMD_POWER_MGMT_EXT);
2318 + if (!pm_cfg.flags) {
2319 + cmd->params.pm_cfg.action = uap_cpu_to_le16(ACTION_GET);
2321 + cmd->params.pm_cfg.action = uap_cpu_to_le16(ACTION_SET);
2322 + cmd->params.pm_cfg.power_mode = uap_cpu_to_le16(pm_cfg.ps_mode);
2323 + tlv = (u8 *) & cmd->params.pm_cfg + sizeof(HostCmd_DS_POWER_MGMT_EXT);
2325 + if ((pm_cfg.ps_mode) && (pm_cfg.flags & PS_FLAG_SLEEP_PARAM)) {
2326 + sleep_tlv = (MrvlIEtypes_sleep_param_t *) tlv;
2327 + sleep_tlv->header.Type = uap_cpu_to_le16(TLV_TYPE_AP_SLEEP_PARAM);
2328 + sleep_tlv->header.Len =
2329 + uap_cpu_to_le16(sizeof(MrvlIEtypes_sleep_param_t) -
2330 + sizeof(MrvlIEtypesHeader_t));
2331 + sleep_tlv->ctrl_bitmap =
2332 + uap_cpu_to_le32(pm_cfg.sleep_param.ctrl_bitmap);
2333 + sleep_tlv->min_sleep =
2334 + uap_cpu_to_le32(pm_cfg.sleep_param.min_sleep);
2335 + sleep_tlv->max_sleep =
2336 + uap_cpu_to_le32(pm_cfg.sleep_param.max_sleep);
2337 + CmdSize += sizeof(MrvlIEtypes_sleep_param_t);
2338 + tlv += sizeof(MrvlIEtypes_sleep_param_t);
2340 + if ((pm_cfg.ps_mode == PS_MODE_INACTIVITY) &&
2341 + (pm_cfg.flags & PS_FLAG_INACT_SLEEP_PARAM)) {
2342 + inact_tlv = (MrvlIEtypes_inact_sleep_param_t *) tlv;
2343 + inact_tlv->header.Type =
2344 + uap_cpu_to_le16(TLV_TYPE_AP_INACT_SLEEP_PARAM);
2345 + inact_tlv->header.Len =
2346 + uap_cpu_to_le16(sizeof(MrvlIEtypes_inact_sleep_param_t) -
2347 + sizeof(MrvlIEtypesHeader_t));
2348 + inact_tlv->inactivity_to =
2349 + uap_cpu_to_le32(pm_cfg.inact_param.inactivity_to);
2350 + inact_tlv->min_awake =
2351 + uap_cpu_to_le32(pm_cfg.inact_param.min_awake);
2352 + inact_tlv->max_awake =
2353 + uap_cpu_to_le32(pm_cfg.inact_param.max_awake);
2354 + CmdSize += sizeof(MrvlIEtypes_inact_sleep_param_t);
2355 + tlv += sizeof(MrvlIEtypes_inact_sleep_param_t);
2358 + cmd->Size = uap_cpu_to_le16(CmdSize);
2359 + skb_put(skb, CmdSize + INTF_HEADER_LEN);
2360 + if (UAP_STATUS_SUCCESS !=
2361 + uap_process_cmd(priv, skb, HostCmd_OPTION_WAITFORRSP)) {
2362 + PRINTM(ERROR, "Fail to process cmd POWER_MODE\n");
2366 + if (!Adapter->CmdSize) {
2367 + PRINTM(ERROR, "Cmd Size is 0\n");
2371 + cmd = (HostCmd_DS_COMMAND *) Adapter->CmdBuf;
2372 + cmd->Result = uap_le16_to_cpu(cmd->Result);
2373 + if (cmd->Result != UAP_STATUS_SUCCESS) {
2374 + PRINTM(ERROR, "HOST_CMD_APCMD_POWER_MODE fail=%x\n", cmd->Result);
2378 + if (pm_cfg.flags) {
2379 + Adapter->psmode = uap_le16_to_cpu(cmd->params.pm_cfg.power_mode);
2381 + pm_cfg.flags = PS_FLAG_PS_MODE;
2382 + pm_cfg.ps_mode = uap_le16_to_cpu(cmd->params.pm_cfg.power_mode);
2384 + cmd->Size - (sizeof(HostCmd_DS_POWER_MGMT_EXT) + S_DS_GEN);
2386 + (MrvlIEtypesHeader_t *) ((u8 *) & cmd->params.pm_cfg +
2387 + sizeof(HostCmd_DS_POWER_MGMT_EXT));
2388 + while (tlv_buf_left >= sizeof(MrvlIEtypesHeader_t)) {
2389 + tlv_type = uap_le16_to_cpu(tlvbuf->Type);
2390 + tlv_len = uap_le16_to_cpu(tlvbuf->Len);
2391 + switch (tlv_type) {
2392 + case TLV_TYPE_AP_SLEEP_PARAM:
2393 + sleep_tlv = (MrvlIEtypes_sleep_param_t *) tlvbuf;
2394 + pm_cfg.flags |= PS_FLAG_SLEEP_PARAM;
2395 + pm_cfg.sleep_param.ctrl_bitmap =
2396 + uap_le32_to_cpu(sleep_tlv->ctrl_bitmap);
2397 + pm_cfg.sleep_param.min_sleep =
2398 + uap_le32_to_cpu(sleep_tlv->min_sleep);
2399 + pm_cfg.sleep_param.max_sleep =
2400 + uap_le32_to_cpu(sleep_tlv->max_sleep);
2402 + case TLV_TYPE_AP_INACT_SLEEP_PARAM:
2403 + inact_tlv = (MrvlIEtypes_inact_sleep_param_t *) tlvbuf;
2404 + pm_cfg.flags |= PS_FLAG_INACT_SLEEP_PARAM;
2405 + pm_cfg.inact_param.inactivity_to =
2406 + uap_le32_to_cpu(inact_tlv->inactivity_to);
2407 + pm_cfg.inact_param.min_awake =
2408 + uap_le32_to_cpu(inact_tlv->min_awake);
2409 + pm_cfg.inact_param.max_awake =
2410 + uap_le32_to_cpu(inact_tlv->max_awake);
2413 + tlv_buf_left -= tlv_len + sizeof(MrvlIEtypesHeader_t);
2415 + (MrvlIEtypesHeader_t *) ((u8 *) tlvbuf + tlv_len +
2416 + sizeof(MrvlIEtypesHeader_t));
2418 + /* Copy to user */
2419 + if (copy_to_user(req->ifr_data, &pm_cfg, sizeof(ps_mgmt))) {
2420 + PRINTM(ERROR, "Copy to user failed!\n");
2431 + * @brief This function send bss_stop command to firmware
2433 + * @param priv A pointer to uap_private structure
2434 + * @return UAP_STATUS_SUCCESS on success, otherwise failure code
2437 +uap_bss_stop(uap_private * priv)
2439 + int ret = UAP_STATUS_SUCCESS;
2441 + HostCmd_DS_GEN *cmd;
2442 + uap_adapter *Adapter = priv->adapter;
2443 + struct sk_buff *skb;
2445 + if (Adapter->HardwareStatus != HWReady) {
2446 + PRINTM(ERROR, "uap_bss_stop:Hardware is not ready!\n");
2450 + skb = dev_alloc_skb(MRVDRV_SIZE_OF_CMD_BUFFER);
2452 + PRINTM(ERROR, "No free skb\n");
2456 + CmdSize = sizeof(HostCmd_DS_GEN);
2457 + cmd = (HostCmd_DS_GEN *) (skb->data + INTF_HEADER_LEN);
2458 + cmd->Command = uap_cpu_to_le16(HOST_CMD_APCMD_BSS_STOP);
2459 + cmd->Size = uap_cpu_to_le16(CmdSize);
2460 + skb_put(skb, CmdSize + INTF_HEADER_LEN);
2461 + PRINTM(CMND, "APCMD_BSS_STOP\n");
2462 + if (UAP_STATUS_SUCCESS !=
2463 + uap_process_cmd(priv, skb, HostCmd_OPTION_WAITFORRSP_TIMEOUT)) {
2464 + PRINTM(ERROR, "Fail to process cmd BSS_STOP\n");
2473 +/********************************************************
2475 +********************************************************/
2477 + * @brief This function send soft_reset command to firmware
2479 + * @param priv A pointer to uap_private structure
2480 + * @return UAP_STATUS_SUCCESS on success, otherwise failure code
2483 +uap_soft_reset(uap_private * priv)
2485 + int ret = UAP_STATUS_SUCCESS;
2487 + HostCmd_DS_GEN *cmd;
2488 + uap_adapter *Adapter = priv->adapter;
2489 + struct sk_buff *skb;
2491 + ret = uap_bss_stop(priv);
2492 + if (ret != UAP_STATUS_SUCCESS)
2494 + skb = dev_alloc_skb(MRVDRV_SIZE_OF_CMD_BUFFER);
2496 + PRINTM(ERROR, "No free skb\n");
2500 + CmdSize = sizeof(HostCmd_DS_GEN);
2501 + cmd = (HostCmd_DS_GEN *) (skb->data + INTF_HEADER_LEN);
2502 + cmd->Command = uap_cpu_to_le16(HOST_CMD_APCMD_SOFT_RESET);
2503 + cmd->Size = uap_cpu_to_le16(CmdSize);
2504 + skb_put(skb, CmdSize + INTF_HEADER_LEN);
2505 + PRINTM(CMND, "APCMD_SOFT_RESET\n");
2506 + if (UAP_STATUS_SUCCESS !=
2507 + uap_process_cmd(priv, skb, HostCmd_OPTION_WAITFORSEND)) {
2508 + PRINTM(ERROR, "Fail to process cmd SOFT_RESET\n");
2512 + Adapter->SurpriseRemoved = TRUE;
2513 + /* delay to allow hardware complete reset */
2514 + os_sched_timeout(5);
2515 + if (priv->MediaConnected == TRUE) {
2516 + os_stop_queue(priv);
2517 + os_carrier_off(priv);
2518 + priv->MediaConnected = FALSE;
2520 + Adapter->CmdSize = 0;
2521 + Adapter->CmdWaitQWoken = TRUE;
2522 + wake_up_interruptible(&Adapter->cmdwait_q);
2523 + skb_queue_purge(&priv->adapter->tx_queue);
2524 + skb_queue_purge(&priv->adapter->cmd_queue);
2531 + * @brief This function processes received packet and forwards it
2532 + * to kernel/upper layer
2534 + * @param priv A pointer to uap_private
2535 + * @param skb A pointer to skb which includes the received packet
2536 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
2539 +uap_process_rx_packet(uap_private * priv, struct sk_buff *skb)
2541 + int ret = UAP_STATUS_SUCCESS;
2544 + priv->adapter->ps_state = PS_STATE_AWAKE;
2545 + pRxPD = (RxPD *) skb->data;
2546 + endian_convert_RxPD(pRxPD);
2547 + DBG_HEXDUMP(DAT_D, "Rx", skb->data, MIN(skb->len, DATA_DUMP_LEN));
2548 + skb_pull(skb, pRxPD->RxPktOffset);
2549 + priv->stats.rx_packets++;
2550 + priv->stats.rx_bytes += skb->len;
2551 + os_upload_rx_packet(priv, skb);
2557 + * @brief This function opens the network device
2559 + * @param dev A pointer to net_device structure
2560 + * @return UAP_STATUS_SUCCESS
2563 +uap_open(struct net_device *dev)
2565 + uap_private *priv = (uap_private *) (uap_private *) netdev_priv(dev);
2566 + uap_adapter *Adapter = priv->adapter;
2571 + /* On some systems the device open handler will be called before HW ready. */
2572 + /* Use the following flag check and wait function to work around the issue. */
2573 + while ((Adapter->HardwareStatus != HWReady) &&
2574 + (i < MAX_WAIT_DEVICE_READY_COUNT)) {
2576 + os_sched_timeout(100);
2578 + if (i >= MAX_WAIT_DEVICE_READY_COUNT) {
2579 + PRINTM(FATAL, "HW not ready, uap_open() return failure\n");
2581 + return UAP_STATUS_FAILURE;
2584 + if (MODULE_GET == 0)
2585 + return UAP_STATUS_FAILURE;
2587 + priv->open = TRUE;
2588 + if (priv->MediaConnected == TRUE) {
2589 + os_carrier_on(priv);
2590 + os_start_queue(priv);
2592 + os_stop_queue(priv);
2593 + os_carrier_off(priv);
2596 + return UAP_STATUS_SUCCESS;
2600 + * @brief This function closes the network device
2602 + * @param dev A pointer to net_device structure
2603 + * @return UAP_STATUS_SUCCESS
2606 +uap_close(struct net_device *dev)
2608 + uap_private *priv = (uap_private *) netdev_priv(dev);
2611 + skb_queue_purge(&priv->adapter->tx_queue);
2612 + os_stop_queue(priv);
2613 + os_carrier_off(priv);
2616 + priv->open = FALSE;
2618 + return UAP_STATUS_SUCCESS;
2622 + * @brief This function returns the network statistics
2624 + * @param dev A pointer to uap_private structure
2625 + * @return A pointer to net_device_stats structure
2627 +static struct net_device_stats *
2628 +uap_get_stats(struct net_device *dev)
2630 + uap_private *priv = (uap_private *) netdev_priv(dev);
2632 + return &priv->stats;
2636 + * @brief This function sets the MAC address to firmware.
2638 + * @param dev A pointer to uap_private structure
2639 + * @param addr MAC address to set
2640 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
2643 +uap_set_mac_address(struct net_device *dev, void *addr)
2645 + int ret = UAP_STATUS_SUCCESS;
2646 + uap_private *priv = (uap_private *) netdev_priv(dev);
2647 + struct sockaddr *pHwAddr = (struct sockaddr *) addr;
2649 + HostCmd_DS_COMMAND *cmd;
2650 + MrvlIEtypes_MacAddr_t *pMacAddrTlv;
2651 + uap_adapter *Adapter = priv->adapter;
2652 + struct sk_buff *skb;
2656 + /* Dump MAC address */
2657 + DBG_HEXDUMP(CMD_D, "Original MAC addr", dev->dev_addr, ETH_ALEN);
2658 + DBG_HEXDUMP(CMD_D, "New MAC addr", pHwAddr->sa_data, ETH_ALEN);
2659 + if (priv->open && (priv->MediaConnected == TRUE)) {
2660 + os_carrier_on(priv);
2661 + os_start_queue(priv);
2663 + skb = dev_alloc_skb(MRVDRV_SIZE_OF_CMD_BUFFER);
2665 + PRINTM(ERROR, "No free skb\n");
2670 + S_DS_GEN + sizeof(HostCmd_SYS_CONFIG) + sizeof(MrvlIEtypes_MacAddr_t);
2671 + cmd = (HostCmd_DS_COMMAND *) (skb->data + INTF_HEADER_LEN);
2672 + cmd->Command = uap_cpu_to_le16(HOST_CMD_APCMD_SYS_CONFIGURE);
2673 + cmd->Size = uap_cpu_to_le16(CmdSize);
2674 + cmd->params.sys_config.Action = uap_cpu_to_le16(ACTION_SET);
2676 + (MrvlIEtypes_MacAddr_t *) ((u8 *) cmd + S_DS_GEN +
2677 + sizeof(HostCmd_SYS_CONFIG));
2678 + pMacAddrTlv->Header.Type = uap_cpu_to_le16(MRVL_AP_MAC_ADDRESS_TLV_ID);
2679 + pMacAddrTlv->Header.Len = uap_cpu_to_le16(ETH_ALEN);
2680 + memcpy(pMacAddrTlv->ApMacAddr, pHwAddr->sa_data, ETH_ALEN);
2681 + skb_put(skb, CmdSize + INTF_HEADER_LEN);
2682 + PRINTM(CMND, "set_mac_address\n");
2683 + if (UAP_STATUS_SUCCESS !=
2684 + uap_process_cmd(priv, skb, HostCmd_OPTION_WAITFORRSP_TIMEOUT)) {
2685 + PRINTM(ERROR, "Fail to set mac address\n");
2689 + if (!Adapter->CmdSize) {
2690 + PRINTM(ERROR, "Cmd Size is 0\n");
2694 + cmd = (HostCmd_DS_COMMAND *) Adapter->CmdBuf;
2695 + cmd->Result = uap_cpu_to_le16(cmd->Result);
2696 + if (cmd->Result != UAP_STATUS_SUCCESS) {
2697 + PRINTM(ERROR, "set mac addrress fail,cmd result=%x\n", cmd->Result);
2700 + memcpy(dev->dev_addr, pHwAddr->sa_data, ETH_ALEN);
2706 + * @brief This function handles the timeout of packet
2709 + * @param dev A pointer to net_device structure
2713 +uap_tx_timeout(struct net_device *dev)
2715 + uap_private *priv = (uap_private *) netdev_priv(dev);
2719 + PRINTM(DATA, "Tx timeout\n");
2720 + UpdateTransStart(dev);
2721 + priv->num_tx_timeout++;
2722 + priv->adapter->IntCounter++;
2723 + wake_up_interruptible(&priv->MainThread.waitQ);
2729 + * @brief This function handles packet transmission
2731 + * @param skb A pointer to sk_buff structure
2732 + * @param dev A pointer to net_device structure
2733 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
2736 +uap_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
2738 + uap_private *priv = (uap_private *) netdev_priv(dev);
2739 + int ret = UAP_STATUS_SUCCESS;
2742 + PRINTM(DATA, "Data <= kernel\n");
2743 + DBG_HEXDUMP(DAT_D, "Tx", skb->data, MIN(skb->len, DATA_DUMP_LEN));
2744 + /* skb sanity check */
2745 + if (!skb->len || (skb->len > MRVDRV_MAXIMUM_ETH_PACKET_SIZE)) {
2746 + PRINTM(ERROR, "Tx Error: Bad skb length %d : %d\n", skb->len,
2747 + MRVDRV_MAXIMUM_ETH_PACKET_SIZE);
2748 + priv->stats.tx_dropped++;
2752 + skb_queue_tail(&priv->adapter->tx_queue, skb);
2753 + wake_up_interruptible(&priv->MainThread.waitQ);
2754 + if (skb_queue_len(&priv->adapter->tx_queue) > TX_HIGH_WATERMARK) {
2755 + UpdateTransStart(dev);
2756 + os_stop_queue(priv);
2764 + * @brief ioctl function - entry point
2766 + * @param dev A pointer to net_device structure
2767 + * @param req A pointer to ifreq structure
2768 + * @param cmd command
2769 + * @return UAP_STATUS_SUCCESS--success, otherwise fail
2772 +uap_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
2774 + int ret = UAP_STATUS_SUCCESS;
2778 + PRINTM(CMND, "uap_do_ioctl: ioctl cmd = 0x%x\n", cmd);
2782 + ret = uap_hostcmd_ioctl(dev, req);
2784 + case UAP_POWER_MODE:
2785 + ret = uap_power_mode_ioctl(dev, req);
2797 + * @brief This function handles events generated by firmware
2799 + * @param priv A pointer to uap_private structure
2800 + * @param payload A pointer to payload buffer
2801 + * @param len Length of the payload
2802 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
2805 +uap_process_event(uap_private * priv, u8 * payload, uint len)
2807 + int ret = UAP_STATUS_SUCCESS;
2808 + uap_adapter *Adapter = priv->adapter;
2809 + struct sk_buff *skb = NULL;
2810 + struct nlmsghdr *nlh = NULL;
2811 + struct sock *sk = Adapter->nl_sk;
2815 + Adapter->ps_state = PS_STATE_AWAKE;
2816 + if (len > NL_MAX_PAYLOAD) {
2817 + PRINTM(ERROR, "event size is too big!!! len=%d\n", len);
2818 + ret = UAP_STATUS_FAILURE;
2821 + pEvent = (AP_Event *) payload;
2822 + PRINTM(CMND, "Event: %d\n", pEvent->EventId);
2823 + switch (pEvent->EventId) {
2824 + case MICRO_AP_EV_ID_BSS_START:
2825 + memcpy(priv->uap_dev.netdev->dev_addr, pEvent->MacAddr, ETH_ALEN);
2826 + DBG_HEXDUMP(CMD_D, "BSS MAC addr", priv->uap_dev.netdev->dev_addr,
2829 + case MICRO_AP_EV_BSS_ACTIVE:
2831 + priv->MediaConnected = TRUE;
2832 + os_carrier_on(priv);
2833 + os_start_queue(priv);
2835 + case MICRO_AP_EV_BSS_IDLE:
2836 + os_stop_queue(priv);
2837 + os_carrier_off(priv);
2838 + priv->MediaConnected = FALSE;
2840 + case EVENT_PS_AWAKE:
2841 + PRINTM(CMND, "UAP: PS_AWAKE\n");
2842 + Adapter->ps_state = PS_STATE_AWAKE;
2843 + Adapter->WakeupTries = 0;
2845 + case EVENT_PS_SLEEP:
2846 + PRINTM(CMND, "UAP: PS_SLEEP\n");
2847 + Adapter->ps_state = PS_STATE_PRE_SLEEP;
2852 + if ((pEvent->EventId == EVENT_PS_AWAKE) ||
2853 + (pEvent->EventId == EVENT_PS_SLEEP))
2856 + /* Allocate skb */
2857 + if (!(skb = alloc_skb(NLMSG_SPACE(NL_MAX_PAYLOAD), GFP_ATOMIC))) {
2858 + PRINTM(ERROR, "Could not allocate skb for netlink.\n");
2859 + ret = UAP_STATUS_FAILURE;
2862 + nlh = (struct nlmsghdr *) skb->data;
2863 + nlh->nlmsg_len = NLMSG_SPACE(len);
2866 + nlh->nlmsg_pid = 0;
2867 + nlh->nlmsg_flags = 0;
2870 + skb_put(skb, nlh->nlmsg_len);
2871 + memcpy(NLMSG_DATA(nlh), payload, len);
2874 + NETLINK_CB(skb).pid = 0;
2876 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
2877 + /* Multicast message */
2878 + NETLINK_CB(skb).dst_pid = 0;
2881 + /* Multicast group number */
2882 + NETLINK_CB(skb).dst_group = NL_MULTICAST_GROUP;
2884 + /* Send message */
2885 + netlink_broadcast(sk, skb, 0, NL_MULTICAST_GROUP, GFP_KERNEL);
2887 + ret = UAP_STATUS_SUCCESS;
2889 + PRINTM(ERROR, "Could not send event through NETLINK. Link down.\n");
2890 + ret = UAP_STATUS_FAILURE;
2898 + * @brief This function handles the interrupt. it will change PS
2899 + * state if applicable. it will wake up main_thread to handle
2900 + * the interrupt event as well.
2902 + * @param priv A pointer to uap_private structure
2906 +uap_interrupt(uap_private * priv)
2909 + priv->adapter->IntCounter++;
2910 + priv->adapter->WakeupTries = 0;
2911 + PRINTM(INFO, "*\n");
2912 + wake_up_interruptible(&priv->MainThread.waitQ);
2918 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
2919 +/** Network device handlers */
2920 +static const struct net_device_ops uap_netdev_ops = {
2921 + .ndo_open = uap_open,
2922 + .ndo_start_xmit = uap_hard_start_xmit,
2923 + .ndo_stop = uap_close,
2924 + .ndo_do_ioctl = uap_do_ioctl,
2925 + .ndo_set_mac_address = uap_set_mac_address,
2926 + .ndo_tx_timeout = uap_tx_timeout,
2927 + .ndo_get_stats = uap_get_stats,
2932 + * @brief This function adds the card. it will probe the
2933 + * card, allocate the uap_priv and initialize the device.
2935 + * @param card A pointer to card
2936 + * @return A pointer to uap_private structure
2939 +uap_add_card(void *card)
2941 + struct net_device *dev = NULL;
2942 + uap_private *priv = NULL;
2946 + if (OS_ACQ_SEMAPHORE_BLOCK(&AddRemoveCardSem))
2947 + goto exit_sem_err;
2949 + /* Allocate an Ethernet device */
2950 + if (!(dev = alloc_etherdev(sizeof(uap_private)))) {
2951 + PRINTM(FATAL, "Init ethernet device failed!\n");
2954 + priv = (uap_private *) netdev_priv(dev);
2956 + /* Allocate name */
2957 + if (dev_alloc_name(dev, "uap%d") < 0) {
2958 + PRINTM(ERROR, "Could not allocate device name!\n");
2962 + /* Allocate buffer for uap_adapter */
2963 + if (!(priv->adapter = kmalloc(sizeof(uap_adapter), GFP_KERNEL))) {
2964 + PRINTM(FATAL, "Allocate buffer for uap_adapter failed!\n");
2967 + memset(priv->adapter, 0, sizeof(uap_adapter));
2969 + priv->uap_dev.netdev = dev;
2970 + priv->uap_dev.card = card;
2971 + priv->MediaConnected = FALSE;
2973 + ((struct sdio_mmc_card *) card)->priv = priv;
2975 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
2976 + SET_MODULE_OWNER(dev);
2979 + /* Setup the OS Interface to our functions */
2980 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
2981 + dev->open = uap_open;
2982 + dev->stop = uap_close;
2983 + dev->hard_start_xmit = uap_hard_start_xmit;
2984 + dev->tx_timeout = uap_tx_timeout;
2985 + dev->get_stats = uap_get_stats;
2986 + dev->do_ioctl = uap_do_ioctl;
2987 + dev->set_mac_address = uap_set_mac_address;
2988 + dev->set_multicast_list = uap_set_multicast_list;
2990 + dev->netdev_ops = &uap_netdev_ops;
2992 + dev->watchdog_timeo = MRVDRV_DEFAULT_WATCHDOG_TIMEOUT;
2993 + dev->hard_header_len += sizeof(TxPD) + INTF_HEADER_LEN;
2994 + dev->hard_header_len += HEADER_ALIGNMENT;
2995 +#define NETIF_F_DYNALLOC 16
2996 + dev->features |= NETIF_F_DYNALLOC;
2997 + dev->flags |= IFF_BROADCAST | IFF_MULTICAST;
3000 + if (uap_init_sw(priv)) {
3001 + PRINTM(FATAL, "Software Init Failed\n");
3005 + PRINTM(INFO, "Starting kthread...\n");
3006 + priv->MainThread.priv = priv;
3007 + spin_lock_init(&priv->driver_lock);
3008 + uap_create_thread(uap_service_main_thread, &priv->MainThread,
3009 + "uap_main_service");
3010 + while (priv->MainThread.pid == 0) {
3011 + os_sched_timeout(2);
3014 + /* Register the device */
3015 + if (sbi_register_dev(priv) < 0) {
3016 + PRINTM(FATAL, "Failed to register uap device!\n");
3017 + goto err_registerdev;
3019 +#ifdef FW_DNLD_NEEDED
3020 + SET_NETDEV_DEV(dev, priv->hotplug_device);
3023 + /* Init FW and HW */
3024 + if (uap_init_fw(priv)) {
3025 + PRINTM(FATAL, "Firmware Init Failed\n");
3029 + priv->uap_dev.cmd_sent = FALSE;
3030 + priv->uap_dev.data_sent = FALSE;
3032 + /* Get mac address from firmware */
3033 + if (uap_get_mac_address(priv)) {
3034 + PRINTM(FATAL, "Fail to get mac address\n");
3037 + /* Register network device */
3038 + if (register_netdev(dev)) {
3039 + printk(KERN_ERR "Cannot register network device!\n");
3042 +#ifdef CONFIG_PROC_FS
3043 + uap_proc_entry(priv, dev);
3044 + uap_debug_entry(priv, dev);
3045 +#endif /* CPNFIG_PROC_FS */
3046 + OS_REL_SEMAPHORE(&AddRemoveCardSem);
3051 + sbi_unregister_dev(priv);
3053 + ((struct sdio_mmc_card *) card)->priv = NULL;
3054 + /* Stop the thread servicing the interrupts */
3055 + priv->adapter->SurpriseRemoved = TRUE;
3056 + wake_up_interruptible(&priv->MainThread.waitQ);
3057 + while (priv->MainThread.pid) {
3058 + os_sched_timeout(1);
3062 + if (dev->reg_state == NETREG_REGISTERED)
3063 + unregister_netdev(dev);
3064 + if (priv->adapter)
3065 + uap_free_adapter(priv);
3069 + OS_REL_SEMAPHORE(&AddRemoveCardSem);
3076 + * @brief This function removes the card.
3078 + * @param card A pointer to card
3079 + * @return UAP_STATUS_SUCCESS
3082 +uap_remove_card(void *card)
3084 + uap_private *priv = uappriv;
3085 + uap_adapter *Adapter;
3086 + struct net_device *dev;
3090 + if (OS_ACQ_SEMAPHORE_BLOCK(&AddRemoveCardSem))
3091 + goto exit_sem_err;
3093 + if (!priv || !(Adapter = priv->adapter)) {
3096 + Adapter->SurpriseRemoved = TRUE;
3097 + if (Adapter->cmd_pending == TRUE) {
3098 + /* Wake up cmd Q */
3099 + Adapter->CmdWaitQWoken = TRUE;
3100 + wake_up_interruptible(&Adapter->cmdwait_q);
3102 + dev = priv->uap_dev.netdev;
3103 + if (priv->MediaConnected == TRUE) {
3104 + os_stop_queue(priv);
3105 + os_carrier_off(priv);
3106 + priv->MediaConnected = FALSE;
3108 + Adapter->CmdSize = 0;
3109 + Adapter->CmdWaitQWoken = TRUE;
3110 + wake_up_interruptible(&Adapter->cmdwait_q);
3111 + skb_queue_purge(&priv->adapter->tx_queue);
3112 + skb_queue_purge(&priv->adapter->cmd_queue);
3114 + /* Disable interrupts on the card */
3115 + sbi_disable_host_int(priv);
3116 + PRINTM(INFO, "netdev_finish_unregister: %s%s.\n", dev->name,
3117 + (dev->features & NETIF_F_DYNALLOC) ? "" : ", old style");
3118 + unregister_netdev(dev);
3119 + PRINTM(INFO, "Unregister finish\n");
3120 + wake_up_interruptible(&priv->MainThread.waitQ);
3121 + while (priv->MainThread.pid) {
3122 + os_sched_timeout(1);
3125 + if ((Adapter->nl_sk) && ((Adapter->nl_sk)->sk_socket)) {
3126 + sock_release((Adapter->nl_sk)->sk_socket);
3127 + Adapter->nl_sk = NULL;
3129 +#ifdef CONFIG_PROC_FS
3130 + uap_debug_remove(priv);
3131 + uap_proc_remove(priv);
3133 + sbi_unregister_dev(priv);
3134 + PRINTM(INFO, "Free Adapter\n");
3135 + uap_free_adapter(priv);
3136 + priv->uap_dev.netdev = NULL;
3141 + OS_REL_SEMAPHORE(&AddRemoveCardSem);
3144 + return UAP_STATUS_SUCCESS;
3148 + * @brief This function initializes module.
3150 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
3153 +uap_init_module(void)
3155 + int ret = UAP_STATUS_SUCCESS;
3158 + OS_INIT_SEMAPHORE(&AddRemoveCardSem);
3159 + ret = sbi_register();
3165 + * @brief This function cleans module
3170 +uap_cleanup_module(void)
3174 + if (OS_ACQ_SEMAPHORE_BLOCK(&AddRemoveCardSem))
3175 + goto exit_sem_err;
3177 + if ((uappriv) && (uappriv->adapter)) {
3178 + uap_func_shutdown(uappriv);
3180 + OS_REL_SEMAPHORE(&AddRemoveCardSem);
3186 +module_init(uap_init_module);
3187 +module_exit(uap_cleanup_module);
3188 +module_param(helper_name, charp, 0);
3189 +MODULE_PARM_DESC(helper_name, "Helper name");
3190 +module_param(fw_name, charp, 0);
3191 +MODULE_PARM_DESC(fw_name, "Firmware name");
3193 +MODULE_DESCRIPTION("M-UAP Driver");
3194 +MODULE_AUTHOR("Marvell International Ltd.");
3195 +MODULE_VERSION(DRIVER_VERSION);
3196 +MODULE_LICENSE("GPL");
3197 diff -Naur compat-wireless-3.5-rc5-1-snpc.org/drivers/net/wireless/libertas_uap/uap_proc.c compat-wireless-3.5-rc5-1-snpc/drivers/net/wireless/libertas_uap/uap_proc.c
3198 --- compat-wireless-3.5-rc5-1-snpc.org/drivers/net/wireless/libertas_uap/uap_proc.c 1970-01-01 01:00:00.000000000 +0100
3199 +++ compat-wireless-3.5-rc5-1-snpc/drivers/net/wireless/libertas_uap/uap_proc.c 2012-07-31 14:23:04.000000000 +0200
3201 +/** @file uap_proc.c
3202 + * @brief This file contains functions for proc file.
3204 + * Copyright (C) 2008-2009, Marvell International Ltd.
3206 + * This software file (the "File") is distributed by Marvell International
3207 + * Ltd. under the terms of the GNU General Public License Version 2, June 1991
3208 + * (the "License"). You may use, redistribute and/or modify this File in
3209 + * accordance with the terms and conditions of the License, a copy of which
3210 + * is available along with the File in the gpl.txt file or by writing to
3211 + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3212 + * 02111-1307 or on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
3214 + * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
3215 + * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
3216 + * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
3217 + * this warranty disclaimer.
3220 +#ifdef CONFIG_PROC_FS
3221 +#include "uap_headers.h"
3223 +/** /proc directory root */
3224 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
3225 +#define PROC_DIR NULL
3226 +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
3227 +#define PROC_DIR &proc_root
3229 +#define PROC_DIR proc_net
3232 +/********************************************************
3234 +********************************************************/
3236 +/********************************************************
3238 +********************************************************/
3240 +/********************************************************
3242 +********************************************************/
3245 + * @brief proc read function
3247 + * @param page pointer to buffer
3248 + * @param start read data starting position
3249 + * @param offset offset
3250 + * @param count counter
3251 + * @param eof end of file flag
3252 + * @param data data to output
3253 + * @return number of output data
3256 +uap_proc_read(char *page, char **start, off_t offset,
3257 + int count, int *eof, void *data)
3261 + struct net_device *netdev = data;
3262 + struct netdev_hw_addr *ha;
3264 + uap_private *priv = (uap_private *) netdev_priv(netdev);
3266 + if (offset != 0) {
3271 + strcpy(fmt, DRIVER_VERSION);
3273 + p += sprintf(p, "driver_name = " "\"uap\"\n");
3274 + p += sprintf(p, "driver_version = %s-(FP%s)", fmt, FPNUM);
3275 + p += sprintf(p, "\nInterfaceName=\"%s\"\n", netdev->name);
3276 + p += sprintf(p, "State=\"%s\"\n",
3277 + ((priv->MediaConnected ==
3278 + FALSE) ? "Disconnected" : "Connected"));
3279 + p += sprintf(p, "MACAddress=\"%02x:%02x:%02x:%02x:%02x:%02x\"\n",
3280 + netdev->dev_addr[0], netdev->dev_addr[1], netdev->dev_addr[2],
3281 + netdev->dev_addr[3], netdev->dev_addr[4], netdev->dev_addr[5]);
3283 + netdev_for_each_mc_addr(ha, netdev) {
3286 + p += sprintf(p, "MCCount=\"%d\"\n", i);
3289 + * Put out the multicast list
3292 + netdev_for_each_mc_addr(ha, netdev) {
3294 + "MCAddr[%d]=\"%02x:%02x:%02x:%02x:%02x:%02x\"\n",
3296 + ha->addr[0], ha->addr[1],
3297 + ha->addr[2], ha->addr[3],
3298 + ha->addr[4], ha->addr[5]);
3301 + p += sprintf(p, "num_tx_bytes = %lu\n", priv->stats.tx_bytes);
3302 + p += sprintf(p, "num_rx_bytes = %lu\n", priv->stats.rx_bytes);
3303 + p += sprintf(p, "num_tx_pkts = %lu\n", priv->stats.tx_packets);
3304 + p += sprintf(p, "num_rx_pkts = %lu\n", priv->stats.rx_packets);
3305 + p += sprintf(p, "num_tx_pkts_dropped = %lu\n", priv->stats.tx_dropped);
3306 + p += sprintf(p, "num_rx_pkts_dropped = %lu\n", priv->stats.rx_dropped);
3307 + p += sprintf(p, "num_tx_pkts_err = %lu\n", priv->stats.tx_errors);
3308 + p += sprintf(p, "num_rx_pkts_err = %lu\n", priv->stats.rx_errors);
3309 + p += sprintf(p, "num_tx_timeout = %u\n", priv->num_tx_timeout);
3310 + p += sprintf(p, "carrier %s\n",
3311 + ((netif_carrier_ok(priv->uap_dev.netdev)) ? "on" : "off"));
3312 + p += sprintf(p, "tx queue %s\n",
3313 + ((netif_queue_stopped(priv->uap_dev.netdev)) ? "stopped" :
3317 + return (p - page);
3321 + * @brief hwstatus proc write function
3323 + * @param f file pointer
3324 + * @param buf pointer to data buffer
3325 + * @param cnt data number to write
3326 + * @param data data to write
3327 + * @return number of data
3330 +uap_hwstatus_write(struct file *f, const char *buf, unsigned long cnt,
3333 + struct net_device *netdev = data;
3334 + uap_private *priv = (uap_private *) netdev_priv(netdev);
3342 + if (copy_from_user(databuf, buf, cnt)) {
3346 + hwstatus = string_to_number(databuf);
3347 + switch (hwstatus) {
3349 + PRINTM(MSG, "reset hw\n");
3350 + uap_soft_reset(priv);
3351 + priv->adapter->HardwareStatus = HWReset;
3361 + * @brief hwstatus proc read function
3363 + * @param page pointer to buffer
3364 + * @param s read data starting position
3365 + * @param off offset
3366 + * @param cnt counter
3367 + * @param eof end of file flag
3368 + * @param data data to output
3369 + * @return number of output data
3372 +uap_hwstatus_read(char *page, char **s, off_t off, int cnt, int *eof,
3376 + struct net_device *netdev = data;
3377 + uap_private *priv = (uap_private *) netdev_priv(netdev);
3379 + p += sprintf(p, "%d\n", priv->adapter->HardwareStatus);
3384 +/********************************************************
3386 +********************************************************/
3388 + * @brief create uap proc file
3390 + * @param priv pointer uap_private
3391 + * @param dev pointer net_device
3395 +uap_proc_entry(uap_private * priv, struct net_device *dev)
3397 + struct proc_dir_entry *r = PROC_DIR;
3399 + PRINTM(INFO, "Creating Proc Interface\n");
3400 + /* Check if uap directory already exists */
3401 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
3402 + for (r = r->subdir; r; r = r->next) {
3403 + if (r->namelen && !strcmp("uap", r->name)) {
3404 + /* Directory exists */
3405 + PRINTM(WARN, "proc directory already exists!\n");
3406 + priv->proc_uap = r;
3411 + if (!priv->proc_uap) {
3412 + priv->proc_uap = proc_mkdir("uap", PROC_DIR);
3413 + if (!priv->proc_uap)
3416 + atomic_set(&priv->proc_uap->count, 1);
3418 + atomic_inc(&priv->proc_uap->count);
3420 + priv->proc_entry = proc_mkdir(dev->name, priv->proc_uap);
3422 + if (priv->proc_entry) {
3423 + r = create_proc_read_entry("info", 0, priv->proc_entry, uap_proc_read,
3425 + r = create_proc_entry("hwstatus", 0644, priv->proc_entry);
3428 + r->read_proc = uap_hwstatus_read;
3429 + r->write_proc = uap_hwstatus_write;
3430 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
3431 + r->owner = THIS_MODULE;
3434 + PRINTM(MSG, "Fail to create proc hwstatus\n");
3439 + * @brief remove proc file
3441 + * @param priv pointer uap_private
3445 +uap_proc_remove(uap_private * priv)
3447 + if (priv->proc_uap) {
3448 + if (priv->proc_entry) {
3449 + remove_proc_entry("info", priv->proc_entry);
3450 + remove_proc_entry("hwstatus", priv->proc_entry);
3452 + remove_proc_entry(priv->uap_dev.netdev->name, priv->proc_uap);
3453 + atomic_dec(&priv->proc_uap->count);
3454 + if (atomic_read(&(priv->proc_uap->count)) == 0)
3455 + remove_proc_entry("uap", PROC_DIR);
3460 + * @brief convert string to number
3462 + * @param s pointer to numbered string
3463 + * @return converted number from string s
3466 +string_to_number(char *s)
3472 + if (strncmp(s, "-", 1) == 0) {
3476 + if ((strncmp(s, "0x", 2) == 0) || (strncmp(s, "0X", 2) == 0)) {
3482 + for (s = s; *s != 0; s++) {
3483 + if ((*s >= '0') && (*s <= '9'))
3484 + r = (r * base) + (*s - '0');
3485 + else if ((*s >= 'A') && (*s <= 'F'))
3486 + r = (r * base) + (*s - 'A' + 10);
3487 + else if ((*s >= 'a') && (*s <= 'f'))
3488 + r = (r * base) + (*s - 'a' + 10);
3497 diff -Naur compat-wireless-3.5-rc5-1-snpc.org/drivers/net/wireless/libertas_uap/uap_sdio_mmc.c compat-wireless-3.5-rc5-1-snpc/drivers/net/wireless/libertas_uap/uap_sdio_mmc.c
3498 --- compat-wireless-3.5-rc5-1-snpc.org/drivers/net/wireless/libertas_uap/uap_sdio_mmc.c 1970-01-01 01:00:00.000000000 +0100
3499 +++ compat-wireless-3.5-rc5-1-snpc/drivers/net/wireless/libertas_uap/uap_sdio_mmc.c 2012-07-31 14:23:04.000000000 +0200
3501 +/** @file uap_sdio_mmc.c
3502 + * @brief This file contains SDIO IF (interface) module
3503 + * related functions.
3505 + * Copyright (C) 2007-2009, Marvell International Ltd.
3507 + * This software file (the "File") is distributed by Marvell International
3508 + * Ltd. under the terms of the GNU General Public License Version 2, June 1991
3509 + * (the "License"). You may use, redistribute and/or modify this File in
3510 + * accordance with the terms and conditions of the License, a copy of which
3511 + * is available along with the File in the gpl.txt file or by writing to
3512 + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3513 + * 02111-1307 or on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
3515 + * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
3516 + * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
3517 + * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
3518 + * this warranty disclaimer.
3521 +/****************************************************
3523 +****************************************************/
3525 +#include "uap_sdio_mmc.h"
3527 +#include <linux/firmware.h>
3529 +/** define SDIO block size */
3530 +/* We support up to 480-byte block size due to FW buffer limitation. */
3531 +#define SD_BLOCK_SIZE 256
3533 +/** define allocated buffer size */
3534 +#define ALLOC_BUF_SIZE (((MAX(MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, \
3535 + MRVDRV_SIZE_OF_CMD_BUFFER) + INTF_HEADER_LEN \
3536 + + SD_BLOCK_SIZE - 1) / SD_BLOCK_SIZE) * SD_BLOCK_SIZE)
3538 +/** Max retry number of CMD53 write */
3539 +#define MAX_WRITE_IOMEM_RETRY 2
3541 +/********************************************************
3543 +********************************************************/
3545 +/** SDIO Rx unit */
3546 +static u8 sdio_rx_unit = 0;
3548 +/**Interrupt status */
3549 +static u8 sd_ireg = 0;
3550 +/********************************************************
3552 +********************************************************/
3553 +extern u8 *helper_name;
3554 +extern u8 *fw_name;
3555 +/** Default helper name */
3556 +#define DEFAULT_HELPER_NAME "mrvl/helper_sd.bin"
3557 +/** Default firmware name */
3558 +#define DEFAULT_FW_NAME "mrvl/sd8688_ap.bin"
3560 +/********************************************************
3562 +********************************************************/
3564 + * @brief This function reads the IO register.
3566 + * @param priv A pointer to uap_private structure
3567 + * @param reg register to be read
3568 + * @param dat A pointer to variable that keeps returned value
3569 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
3572 +sbi_read_ioreg(uap_private * priv, u32 reg, u8 * dat)
3574 + struct sdio_mmc_card *card;
3575 + int ret = UAP_STATUS_FAILURE;
3579 + card = priv->uap_dev.card;
3580 + if (!card || !card->func) {
3581 + PRINTM(ERROR, "sbi_read_ioreg(): card or function is NULL!\n");
3585 + *dat = sdio_readb(card->func, reg, &ret);
3587 + PRINTM(ERROR, "sbi_read_ioreg(): sdio_readb failed! ret=%d\n", ret);
3591 + PRINTM(INFO, "sbi_read_ioreg() priv=%p func=%d reg=%#x dat=%#x\n", priv,
3592 + card->func->num, reg, *dat);
3600 + * @brief This function writes the IO register.
3602 + * @param priv A pointer to uap_private structure
3603 + * @param reg register to be written
3604 + * @param dat the value to be written
3605 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
3608 +sbi_write_ioreg(uap_private * priv, u32 reg, u8 dat)
3610 + struct sdio_mmc_card *card;
3611 + int ret = UAP_STATUS_FAILURE;
3615 + card = priv->uap_dev.card;
3616 + if (!card || !card->func) {
3617 + PRINTM(ERROR, "sbi_write_ioreg(): card or function is NULL!\n");
3621 + PRINTM(INFO, "sbi_write_ioreg() priv=%p func=%d reg=%#x dat=%#x\n", priv,
3622 + card->func->num, reg, dat);
3624 + sdio_writeb(card->func, dat, reg, &ret);
3626 + PRINTM(ERROR, "sbi_write_ioreg(): sdio_readb failed! ret=%d\n", ret);
3636 + * @brief This function get rx_unit value
3638 + * @param priv A pointer to uap_private structure
3639 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
3642 +sd_get_rx_unit(uap_private * priv)
3644 + int ret = UAP_STATUS_SUCCESS;
3649 + ret = sbi_read_ioreg(priv, CARD_RX_UNIT_REG, ®);
3650 + if (ret == UAP_STATUS_SUCCESS)
3651 + sdio_rx_unit = reg;
3658 + * @brief This function reads rx length
3660 + * @param priv A pointer to uap_private structure
3661 + * @param dat A pointer to keep returned data
3662 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
3665 +sd_read_rx_len(uap_private * priv, u16 * dat)
3667 + int ret = UAP_STATUS_SUCCESS;
3672 + ret = sbi_read_ioreg(priv, CARD_RX_LEN_REG, ®);
3673 + if (ret == UAP_STATUS_SUCCESS)
3674 + *dat = (u16) reg << sdio_rx_unit;
3681 + * @brief This function reads fw status registers
3683 + * @param priv A pointer to uap_private structure
3684 + * @param dat A pointer to keep returned data
3685 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
3688 +sd_read_firmware_status(uap_private * priv, u16 * dat)
3690 + int ret = UAP_STATUS_SUCCESS;
3696 + ret = sbi_read_ioreg(priv, CARD_FW_STATUS0_REG, &fws0);
3699 + return UAP_STATUS_FAILURE;
3702 + ret = sbi_read_ioreg(priv, CARD_FW_STATUS1_REG, &fws1);
3705 + return UAP_STATUS_FAILURE;
3708 + *dat = (((u16) fws1) << 8) | fws0;
3711 + return UAP_STATUS_SUCCESS;
3715 + * @brief This function polls the card status register.
3717 + * @param priv A pointer to uap_private structure
3718 + * @param bits the bit mask
3719 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
3722 +mv_sdio_poll_card_status(uap_private * priv, u8 bits)
3729 + for (tries = 0; tries < MAX_POLL_TRIES; tries++) {
3730 + if (sbi_read_ioreg(priv, CARD_STATUS_REG, &cs) < 0)
3732 + else if ((cs & bits) == bits) {
3734 + return UAP_STATUS_SUCCESS;
3739 + PRINTM(WARN, "mv_sdio_poll_card_status failed, tries = %d\n", tries);
3742 + return UAP_STATUS_FAILURE;
3746 + * @brief This function set the sdio bus width.
3748 + * @param priv A pointer to uap_private structure
3749 + * @param mode 1--1 bit mode, 4--4 bit mode
3750 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
3754 +sdio_set_bus_width(uap_private * priv, u8 mode)
3758 + return UAP_STATUS_SUCCESS;
3763 + * @brief This function reads data from the card.
3765 + * @param priv A pointer to uap_private structure
3766 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
3769 +sd_card_to_host(uap_private * priv)
3771 + int ret = UAP_STATUS_SUCCESS;
3773 + int buf_block_len;
3775 + struct sk_buff *skb = NULL;
3777 + u8 *payload = NULL;
3778 + struct sdio_mmc_card *card = priv->uap_dev.card;
3782 + if (!card || !card->func) {
3783 + PRINTM(ERROR, "card or function is NULL!\n");
3784 + ret = UAP_STATUS_FAILURE;
3788 + /* Read the length of data to be transferred */
3789 + ret = sd_read_rx_len(priv, &buf_len);
3791 + PRINTM(ERROR, "card_to_host, read scratch reg failed\n");
3792 + ret = UAP_STATUS_FAILURE;
3796 + /* Allocate buffer */
3797 + blksz = SD_BLOCK_SIZE;
3798 + buf_block_len = (buf_len + blksz - 1) / blksz;
3799 + if (buf_len <= INTF_HEADER_LEN || (buf_block_len * blksz) > ALLOC_BUF_SIZE) {
3800 + PRINTM(ERROR, "card_to_host, invalid packet length: %d\n", buf_len);
3801 + ret = UAP_STATUS_FAILURE;
3804 +#ifdef PXA3XX_DMA_ALIGN
3805 + skb = dev_alloc_skb(buf_block_len * blksz + PXA3XX_DMA_ALIGNMENT);
3807 + skb = dev_alloc_skb(buf_block_len * blksz);
3809 + if (skb == NULL) {
3810 + PRINTM(WARN, "No free skb\n");
3813 +#ifdef PXA3XX_DMA_ALIGN
3814 + if ((u32) skb->data & (PXA3XX_DMA_ALIGNMENT - 1)) {
3815 + skb_put(skb, (u32) skb->data & (PXA3XX_DMA_ALIGNMENT - 1));
3816 + skb_pull(skb, (u32) skb->data & (PXA3XX_DMA_ALIGNMENT - 1));
3818 +#endif /* PXA3XX_DMA_ALIGN */
3820 + payload = skb->tail;
3821 + ret = sdio_readsb(card->func, payload, priv->uap_dev.ioport,
3822 + buf_block_len * blksz);
3824 + PRINTM(ERROR, "card_to_host, read iomem failed: %d\n", ret);
3825 + ret = UAP_STATUS_FAILURE;
3828 + HEXDUMP("SDIO Blk Rd", payload, blksz * buf_block_len);
3830 + * This is SDIO specific header
3832 + * u16 type (MV_TYPE_DAT = 0, MV_TYPE_CMD = 1, MV_TYPE_EVENT = 3)
3834 + buf_len = uap_le16_to_cpu(*(u16 *) & payload[0]);
3835 + type = uap_le16_to_cpu(*(u16 *) & payload[2]);
3837 + case MV_TYPE_EVENT:
3838 + skb_put(skb, buf_len);
3839 + skb_pull(skb, INTF_HEADER_LEN);
3840 + uap_process_event(priv, skb->data, skb->len);
3845 + skb_put(skb, buf_len);
3846 + skb_pull(skb, INTF_HEADER_LEN);
3847 + priv->adapter->cmd_pending = FALSE;
3848 + if (priv->adapter->cmd_wait_option ==
3849 + HostCmd_OPTION_WAITFORRSP_SLEEPCONFIRM) {
3850 + priv->adapter->cmd_wait_option = FALSE;
3851 + uap_process_sleep_confirm_resp(priv, skb->data, skb->len);
3852 + } else if (priv->adapter->cmd_wait_option) {
3853 + memcpy(priv->adapter->CmdBuf, skb->data, skb->len);
3854 + priv->adapter->CmdSize = skb->len;
3855 + priv->adapter->cmd_wait_option = FALSE;
3856 + priv->adapter->CmdWaitQWoken = TRUE;
3857 + wake_up_interruptible(&priv->adapter->cmdwait_q);
3863 + skb_put(skb, buf_len);
3864 + skb_pull(skb, INTF_HEADER_LEN);
3865 + uap_process_rx_packet(priv, skb);
3868 + priv->stats.rx_errors++;
3869 + priv->stats.rx_dropped++;
3870 + /* Driver specified event and command resp should be handle here */
3871 + PRINTM(INFO, "Unknown PKT type:%d\n", type);
3887 + * @brief This function enables the host interrupts mask
3889 + * @param priv A pointer to uap_private structure
3890 + * @param mask the interrupt mask
3891 + * @return UAP_STATUS_SUCCESS
3894 +enable_host_int_mask(uap_private * priv, u8 mask)
3896 + int ret = UAP_STATUS_SUCCESS;
3900 + /* Simply write the mask to the register */
3901 + ret = sbi_write_ioreg(priv, HOST_INT_MASK_REG, mask);
3904 + PRINTM(WARN, "Unable to enable the host interrupt!\n");
3905 + ret = UAP_STATUS_FAILURE;
3912 +/** @brief This function disables the host interrupts mask.
3914 + * @param priv A pointer to uap_private structure
3915 + * @param mask the interrupt mask
3916 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
3919 +disable_host_int_mask(uap_private * priv, u8 mask)
3921 + int ret = UAP_STATUS_SUCCESS;
3926 + /* Read back the host_int_mask register */
3927 + ret = sbi_read_ioreg(priv, HOST_INT_MASK_REG, &host_int_mask);
3929 + ret = UAP_STATUS_FAILURE;
3933 + /* Update with the mask and write back to the register */
3934 + host_int_mask &= ~mask;
3935 + ret = sbi_write_ioreg(priv, HOST_INT_MASK_REG, host_int_mask);
3937 + PRINTM(WARN, "Unable to diable the host interrupt!\n");
3938 + ret = UAP_STATUS_FAILURE;
3947 +/********************************************************
3949 +********************************************************/
3952 + * @brief This function handles the interrupt.
3954 + * @param func A pointer to sdio_func structure.
3958 +sbi_interrupt(struct sdio_func *func)
3960 + struct sdio_mmc_card *card;
3961 + uap_private *priv;
3963 + int ret = UAP_STATUS_SUCCESS;
3967 + card = sdio_get_drvdata(func);
3968 + if (!card || !card->priv) {
3969 + PRINTM(MSG, "%s: sbi_interrupt(%p) card or priv is NULL, card=%p\n",
3970 + __FUNCTION__, func, card);
3974 + priv = card->priv;
3975 +#ifdef FW_WAKEUP_TIME
3976 + if ((priv->adapter->wt_pwrup_sending != 0L) &&
3977 + (priv->adapter->wt_int == 0L))
3978 + priv->adapter->wt_int = get_utimeofday();
3981 + ireg = sdio_readb(card->func, HOST_INTSTATUS_REG, &ret);
3983 + PRINTM(WARN, "sdio_read_ioreg: read int status register failed\n");
3988 + * DN_LD_HOST_INT_STATUS and/or UP_LD_HOST_INT_STATUS
3989 + * Clear the interrupt status register and re-enable the interrupt
3991 + PRINTM(INFO, "sdio_ireg = 0x%x\n", ireg);
3992 + sdio_writeb(card->func,
3993 + ~(ireg) & (DN_LD_HOST_INT_STATUS | UP_LD_HOST_INT_STATUS),
3994 + HOST_INTSTATUS_REG, &ret);
3997 + "sdio_write_ioreg: clear int status register failed\n");
4005 + uap_interrupt(priv);
4011 + * @brief This function probe the card
4013 + * @param func A pointer to sdio_func structure
4014 + * @param id A pointer to structure sd_device_id
4015 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4018 +uap_probe(struct sdio_func *func, const struct sdio_device_id *id)
4020 + int ret = UAP_STATUS_FAILURE;
4021 + struct sdio_mmc_card *card = NULL;
4025 + PRINTM(MSG, "%s: vendor=0x%4.04X device=0x%4.04X class=%d function=%d\n",
4026 + __FUNCTION__, func->vendor, func->device, func->class, func->num);
4028 + card = kzalloc(sizeof(struct sdio_mmc_card), GFP_KERNEL);
4034 + card->func = func;
4036 + if (!uap_add_card(card)) {
4037 + PRINTM(ERROR, "%s: uap_add_callback failed\n", __FUNCTION__);
4039 + ret = UAP_STATUS_FAILURE;
4043 + ret = UAP_STATUS_SUCCESS;
4051 + * @brief This function removes the card
4053 + * @param func A pointer to sdio_func structure
4057 +uap_remove(struct sdio_func *func)
4059 + struct sdio_mmc_card *card;
4064 + card = sdio_get_drvdata(func);
4066 + uap_remove_card(card);
4076 + * @brief This function handles client driver suspend
4078 + * @param func A pointer to sdio_func structure
4079 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4082 +uap_suspend(struct sdio_func *func)
4090 + * @brief This function handles client driver resume
4092 + * @param func A pointer to sdio_func structure
4093 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4096 +uap_resume(struct sdio_func *func)
4104 +/** Device ID for SD8688 */
4105 +#define SD_DEVICE_ID_8688_UAP 0x9104
4107 +static const struct sdio_device_id uap_ids[] = {
4108 + {SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, SD_DEVICE_ID_8688_UAP)},
4112 +MODULE_DEVICE_TABLE(sdio, uap_ids);
4114 +static struct sdio_driver uap_sdio = {
4115 + .name = "uap_sdio",
4116 + .id_table = uap_ids,
4117 + .probe = uap_probe,
4118 + .remove = uap_remove,
4120 +/* .suspend = uap_suspend, */
4121 +/* .resume = uap_resume, */
4127 + * @brief This function registers the IF module in bus driver.
4129 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4134 + int ret = UAP_STATUS_SUCCESS;
4138 + /* SDIO Driver Registration */
4139 + if (sdio_register_driver(&uap_sdio) != 0) {
4140 + PRINTM(FATAL, "SDIO Driver Registration Failed \n");
4141 + ret = UAP_STATUS_FAILURE;
4149 + * @brief This function de-registers the IF module in bus driver.
4154 +sbi_unregister(void)
4158 + /* SDIO Driver Unregistration */
4159 + sdio_unregister_driver(&uap_sdio);
4165 + * @brief This function checks the interrupt status and handle it accordingly.
4167 + * @param priv A pointer to uap_private structure
4168 + * @param ireg A pointer to variable that keeps returned value
4169 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4172 +sbi_get_int_status(uap_private * priv, u8 * ireg)
4174 + int ret = UAP_STATUS_SUCCESS;
4176 + struct sdio_mmc_card *card = priv->uap_dev.card;
4182 + sdio_ireg = sd_ireg;
4186 + sdio_claim_host(card->func);
4188 + if (sdio_ireg & DN_LD_HOST_INT_STATUS) { /* tx_done INT */
4189 + if (!priv->uap_dev.cmd_sent) { /* tx_done already received */
4191 + "warning: tx_done already received: tx_dnld_rdy=0x%x int status=0x%x\n",
4192 + priv->uap_dev.cmd_sent, sdio_ireg);
4194 + priv->uap_dev.cmd_sent = FALSE;
4195 + priv->uap_dev.data_sent = FALSE;
4196 + if ( (priv->uap_dev.netdev->reg_state == NETREG_REGISTERED) && (skb_queue_len(&priv->adapter->tx_queue) < TX_LOW_WATERMARK)) {
4197 + os_start_queue(priv);
4201 + if (sdio_ireg & UP_LD_HOST_INT_STATUS) {
4202 + sd_card_to_host(priv);
4205 + *ireg = sdio_ireg;
4206 + ret = UAP_STATUS_SUCCESS;
4207 + sdio_release_host(card->func);
4214 + * @brief This function disables the host interrupts.
4216 + * @param priv A pointer to uap_private structure
4217 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4220 +sbi_disable_host_int(uap_private * priv)
4222 + struct sdio_mmc_card *card = priv->uap_dev.card;
4227 + sdio_claim_host(card->func);
4228 + ret = disable_host_int_mask(priv, HIM_DISABLE);
4229 + sdio_release_host(card->func);
4236 + * @brief This function enables the host interrupts.
4238 + * @param priv A pointer to uap_private structure
4239 + * @return UAP_STATUS_SUCCESS
4242 +sbi_enable_host_int(uap_private * priv)
4244 + struct sdio_mmc_card *card = priv->uap_dev.card;
4249 + sdio_claim_host(card->func);
4250 + ret = enable_host_int_mask(priv, HIM_ENABLE);
4251 + sdio_release_host(card->func);
4258 + * @brief This function de-registers the device.
4260 + * @param priv A pointer to uap_private structure
4261 + * @return UAP_STATUS_SUCCESS
4264 +sbi_unregister_dev(uap_private * priv)
4266 + struct sdio_mmc_card *card = priv->uap_dev.card;
4270 + if (!card || !card->func) {
4271 + PRINTM(ERROR, "Error: card or function is NULL!\n");
4275 + sdio_claim_host(card->func);
4276 + sdio_release_irq(card->func);
4277 + sdio_disable_func(card->func);
4278 + sdio_release_host(card->func);
4280 + sdio_set_drvdata(card->func, NULL);
4284 + return UAP_STATUS_SUCCESS;
4288 + * @brief This function registers the device.
4290 + * @param priv A pointer to uap_private structure
4291 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4294 +sbi_register_dev(uap_private * priv)
4296 + int ret = UAP_STATUS_FAILURE;
4298 + struct sdio_mmc_card *card = priv->uap_dev.card;
4299 + struct sdio_func *func;
4303 + if (!card || !card->func) {
4304 + PRINTM(ERROR, "Error: card or function is NULL!\n");
4308 + func = card->func;
4310 + /* Initialize the private structure */
4311 + priv->uap_dev.ioport = 0;
4313 + sdio_claim_host(func);
4315 + ret = sdio_enable_func(func);
4317 + PRINTM(FATAL, "sdio_enable_func() failed: ret=%d\n", ret);
4318 + goto release_host;
4321 + ret = sdio_claim_irq(func, sbi_interrupt);
4323 + PRINTM(FATAL, "sdio_claim_irq failed: ret=%d\n", ret);
4324 + goto disable_func;
4327 + /* Read the IO port */
4328 + ret = sbi_read_ioreg(priv, IO_PORT_0_REG, ®);
4332 + priv->uap_dev.ioport |= reg;
4334 + ret = sbi_read_ioreg(priv, IO_PORT_1_REG, ®);
4338 + priv->uap_dev.ioport |= (reg << 8);
4340 + ret = sbi_read_ioreg(priv, IO_PORT_2_REG, ®);
4344 + priv->uap_dev.ioport |= (reg << 16);
4346 + PRINTM(INFO, "SDIO FUNC #%d IO port: 0x%x\n", func->num,
4347 + priv->uap_dev.ioport);
4349 + ret = sdio_set_block_size(card->func, SD_BLOCK_SIZE);
4351 + PRINTM(ERROR, "%s: cannot set SDIO block size\n", __FUNCTION__);
4352 + ret = UAP_STATUS_FAILURE;
4355 + priv->hotplug_device = &func->dev;
4357 + if (helper_name == NULL) {
4358 + helper_name = DEFAULT_HELPER_NAME;
4360 + if (fw_name == NULL) {
4361 + fw_name = DEFAULT_FW_NAME;
4363 + sdio_release_host(func);
4365 + sdio_set_drvdata(func, card);
4367 + ret = UAP_STATUS_SUCCESS;
4371 + sdio_release_irq(func);
4373 + sdio_disable_func(func);
4375 + sdio_release_host(func);
4383 + * @brief This function sends data to the card.
4385 + * @param priv A pointer to uap_private structure
4386 + * @param payload A pointer to the data/cmd buffer
4387 + * @param nb the length of data/cmd
4388 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4391 +sbi_host_to_card(uap_private * priv, u8 * payload, u16 nb)
4393 + struct sdio_mmc_card *card = priv->uap_dev.card;
4394 + int ret = UAP_STATUS_SUCCESS;
4395 + int buf_block_len;
4399 +#ifdef PXA3XX_DMA_ALIGN
4400 + void *tmpbuf = NULL;
4406 + if (!card || !card->func) {
4407 + PRINTM(ERROR, "card or function is NULL!\n");
4409 + return UAP_STATUS_FAILURE;
4412 +#ifdef PXA3XX_DMA_ALIGN
4413 + if ((u32) payload & (PXA3XX_DMA_ALIGNMENT - 1)) {
4414 + tmpbufsz = ALIGN_SZ(nb, PXA3XX_DMA_ALIGNMENT);
4415 + tmpbuf = kmalloc(tmpbufsz, GFP_KERNEL);
4416 + memset(tmpbuf, 0, tmpbufsz);
4417 + /* Ensure 8-byte aligned CMD buffer */
4418 + buf = (u8 *) ALIGN_ADDR(tmpbuf, PXA3XX_DMA_ALIGNMENT);
4419 + memcpy(buf, payload, nb);
4422 + /* Allocate buffer and copy payload */
4423 + blksz = SD_BLOCK_SIZE;
4424 + buf_block_len = (nb + blksz - 1) / blksz;
4425 + sdio_claim_host(card->func);
4426 +#define MAX_WRITE_IOMEM_RETRY 2
4427 + priv->uap_dev.cmd_sent = TRUE;
4428 + priv->uap_dev.data_sent = TRUE;
4430 + /* Transfer data to card */
4431 + ret = sdio_writesb(card->func, priv->uap_dev.ioport, buf,
4432 + buf_block_len * blksz);
4435 + PRINTM(ERROR, "host_to_card, write iomem (%d) failed: %d\n", i,
4437 + ret = UAP_STATUS_FAILURE;
4438 + if (i > MAX_WRITE_IOMEM_RETRY)
4441 + HEXDUMP("SDIO Blk Wr", payload, nb);
4443 + } while (ret == UAP_STATUS_FAILURE);
4445 + sdio_release_host(card->func);
4446 +#ifdef PXA3XX_DMA_ALIGN
4450 + if (ret == UAP_STATUS_FAILURE) {
4451 + priv->uap_dev.cmd_sent = FALSE;
4452 + priv->uap_dev.data_sent = FALSE;
4459 + * @brief This function reads CIS information.
4461 + * @param priv A pointer to uap_private structure
4462 + * @param cisinfo A pointer to CIS information output buffer
4463 + * @param cislen A pointer to length of CIS info output buffer
4464 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4468 +sbi_get_cis_info(uap_private * priv, void *cisinfo, int *cislen)
4470 +#define CIS_PTR (0x8000)
4471 + struct sdio_mmc_card *card = priv->uap_dev.card;
4472 + unsigned int i, cis_ptr = CIS_PTR;
4473 + int ret = UAP_STATUS_FAILURE;
4477 + if (!card || !card->func) {
4478 + PRINTM(ERROR, "sbi_get_cis_info(): card or function is NULL!\n");
4481 +#define MAX_SDIO_CIS_INFO_LEN (256)
4482 + if (!cisinfo || (*cislen < MAX_SDIO_CIS_INFO_LEN)) {
4483 + PRINTM(WARN, "ERROR! get_cis_info: insufficient buffer passed\n");
4487 + *cislen = MAX_SDIO_CIS_INFO_LEN;
4489 + sdio_claim_host(card->func);
4491 + PRINTM(INFO, "cis_ptr=%#x\n", cis_ptr);
4493 + /* Read the Tuple Data */
4494 + for (i = 0; i < *cislen; i++) {
4495 + ((unsigned char *) cisinfo)[i] =
4496 + sdio_readb(card->func, cis_ptr + i, &ret);
4498 + PRINTM(WARN, "get_cis_info error: ret=%d\n", ret);
4499 + ret = UAP_STATUS_FAILURE;
4502 + PRINTM(INFO, "cisinfo[%d]=%#x\n", i, ((unsigned char *) cisinfo)[i]);
4506 + sdio_release_host(card->func);
4513 + * @brief This function downloads helper image to the card.
4515 + * @param priv A pointer to uap_private structure
4516 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4519 +sbi_prog_helper(uap_private * priv)
4521 + struct sdio_mmc_card *card = priv->uap_dev.card;
4522 + u8 *helper = NULL;
4524 + int ret = UAP_STATUS_SUCCESS;
4525 + void *tmphlprbuf = NULL;
4530 +#ifdef FW_DOWNLOAD_SPEED
4536 + if (!card || !card->func) {
4537 + PRINTM(ERROR, "sbi_prog_helper(): card or function is NULL!\n");
4541 + if (priv->fw_helper) {
4542 + helper = (u8 *) priv->fw_helper->data;
4543 + helperlen = priv->fw_helper->size;
4545 + PRINTM(MSG, "No helper image found! Terminating download.\n");
4547 + return UAP_STATUS_FAILURE;
4550 + PRINTM(INFO, "Downloading helper image (%d bytes), block size %d bytes\n",
4551 + helperlen, SD_BLOCK_SIZE);
4553 +#ifdef FW_DOWNLOAD_SPEED
4554 + tv1 = get_utimeofday();
4557 +#ifdef PXA3XX_DMA_ALIGN
4558 + tmphlprbufsz = ALIGN_SZ(UAP_UPLD_SIZE, PXA3XX_DMA_ALIGNMENT);
4559 +#else /* !PXA3XX_DMA_ALIGN */
4560 + tmphlprbufsz = UAP_UPLD_SIZE;
4561 +#endif /* !PXA3XX_DMA_ALIGN */
4562 + tmphlprbuf = kmalloc(tmphlprbufsz, GFP_KERNEL);
4563 + if (!tmphlprbuf) {
4565 + "Unable to allocate buffer for helper. Terminating download\n");
4566 + ret = UAP_STATUS_FAILURE;
4569 + memset(tmphlprbuf, 0, tmphlprbufsz);
4570 +#ifdef PXA3XX_DMA_ALIGN
4571 + hlprbuf = (u8 *) ALIGN_ADDR(tmphlprbuf, PXA3XX_DMA_ALIGNMENT);
4572 +#else /* !PXA3XX_DMA_ALIGN */
4573 + hlprbuf = (u8 *) tmphlprbuf;
4574 +#endif /* !PXA3XX_DMA_ALIGN */
4576 + sdio_claim_host(card->func);
4578 + /* Perform helper data transfer */
4579 + tx_len = (FIRMWARE_TRANSFER_NBLOCK * SD_BLOCK_SIZE) - INTF_HEADER_LEN;
4582 + /* The host polls for the DN_LD_CARD_RDY and CARD_IO_READY bits */
4583 + ret = mv_sdio_poll_card_status(priv, CARD_IO_READY | DN_LD_CARD_RDY);
4585 + PRINTM(FATAL, "Helper download poll status timeout @ %d\n",
4591 + if (hlprblknow >= helperlen)
4594 + /* Set blocksize to transfer - checking for last block */
4595 + if (helperlen - hlprblknow < tx_len)
4596 + tx_len = helperlen - hlprblknow;
4598 + /* Set length to the 4-byte header */
4599 + *(u32 *) hlprbuf = uap_cpu_to_le32(tx_len);
4601 + /* Copy payload to buffer */
4602 + memcpy(&hlprbuf[INTF_HEADER_LEN], &helper[hlprblknow], tx_len);
4604 + PRINTM(INFO, ".");
4607 + ret = sdio_writesb(card->func, priv->uap_dev.ioport,
4608 + hlprbuf, FIRMWARE_TRANSFER_NBLOCK * SD_BLOCK_SIZE);
4611 + PRINTM(FATAL, "IO error during helper download @ %d\n", hlprblknow);
4615 + hlprblknow += tx_len;
4618 +#ifdef FW_DOWNLOAD_SPEED
4619 + tv2 = get_utimeofday();
4620 + PRINTM(INFO, "helper: %ld.%03ld.%03ld ", tv1 / 1000000,
4621 + (tv1 % 1000000) / 1000, tv1 % 1000);
4622 + PRINTM(INFO, " -> %ld.%03ld.%03ld ", tv2 / 1000000, (tv2 % 1000000) / 1000,
4625 + PRINTM(INFO, " == %ld.%03ld.%03ld\n", tv2 / 1000000, (tv2 % 1000000) / 1000,
4629 + /* Write last EOF data */
4630 + PRINTM(INFO, "\nTransferring helper image EOF block\n");
4631 + memset(hlprbuf, 0x0, SD_BLOCK_SIZE);
4632 + ret = sdio_writesb(card->func, priv->uap_dev.ioport,
4633 + hlprbuf, SD_BLOCK_SIZE);
4636 + PRINTM(FATAL, "IO error in writing helper image EOF block\n");
4640 + ret = UAP_STATUS_SUCCESS;
4643 + sdio_release_host(card->func);
4645 + kfree(tmphlprbuf);
4652 + * @brief This function downloads firmware image to the card.
4654 + * @param priv A pointer to uap_private structure
4655 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4658 +sbi_prog_fw_w_helper(uap_private * priv)
4660 + struct sdio_mmc_card *card = priv->uap_dev.card;
4661 + u8 *firmware = NULL;
4665 + int ret = UAP_STATUS_SUCCESS;
4667 + void *tmpfwbuf = NULL;
4672 + int tx_blocks = 0;
4675 +#ifdef FW_DOWNLOAD_SPEED
4681 + if (!card || !card->func) {
4682 + PRINTM(ERROR, "sbi_prog_fw_w_helper(): card or function is NULL!\n");
4686 + if (priv->firmware) {
4687 + firmware = (u8 *) priv->firmware->data;
4688 + firmwarelen = priv->firmware->size;
4690 + PRINTM(MSG, "No firmware image found! Terminating download.\n");
4692 + return UAP_STATUS_FAILURE;
4695 + PRINTM(INFO, "Downloading FW image (%d bytes)\n", firmwarelen);
4697 +#ifdef FW_DOWNLOAD_SPEED
4698 + tv1 = get_utimeofday();
4701 +#ifdef PXA3XX_DMA_ALIGN
4702 + tmpfwbufsz = ALIGN_SZ(UAP_UPLD_SIZE, PXA3XX_DMA_ALIGNMENT);
4703 +#else /* PXA3XX_DMA_ALIGN */
4704 + tmpfwbufsz = UAP_UPLD_SIZE;
4705 +#endif /* PXA3XX_DMA_ALIGN */
4706 + tmpfwbuf = kmalloc(tmpfwbufsz, GFP_KERNEL);
4709 + "Unable to allocate buffer for firmware. Terminating download.\n");
4710 + ret = UAP_STATUS_FAILURE;
4713 + memset(tmpfwbuf, 0, tmpfwbufsz);
4714 +#ifdef PXA3XX_DMA_ALIGN
4715 + /* Ensure 8-byte aligned firmware buffer */
4716 + fwbuf = (u8 *) ALIGN_ADDR(tmpfwbuf, PXA3XX_DMA_ALIGNMENT);
4717 +#else /* PXA3XX_DMA_ALIGN */
4718 + fwbuf = (u8 *) tmpfwbuf;
4719 +#endif /* PXA3XX_DMA_ALIGN */
4721 + sdio_claim_host(card->func);
4723 + /* Perform firmware data transfer */
4726 + /* The host polls for the DN_LD_CARD_RDY and CARD_IO_READY bits */
4727 + ret = mv_sdio_poll_card_status(priv, CARD_IO_READY | DN_LD_CARD_RDY);
4729 + PRINTM(FATAL, "FW download with helper poll status timeout @ %d\n",
4735 + if (offset >= firmwarelen)
4738 + for (tries = 0; tries < MAX_POLL_TRIES; tries++) {
4739 + if ((ret = sbi_read_ioreg(priv, HOST_F1_RD_BASE_0, &base0)) < 0) {
4740 + PRINTM(WARN, "Dev BASE0 register read failed:"
4741 + " base0=0x%04X(%d). Terminating download.\n", base0,
4743 + ret = UAP_STATUS_FAILURE;
4746 + if ((ret = sbi_read_ioreg(priv, HOST_F1_RD_BASE_1, &base1)) < 0) {
4747 + PRINTM(WARN, "Dev BASE1 register read failed:"
4748 + " base1=0x%04X(%d). Terminating download.\n", base1,
4750 + ret = UAP_STATUS_FAILURE;
4753 + len = (((u16) base1) << 8) | base0;
4755 + /* For SD8688 wait until the length is not 0, 1 or 2 before
4756 + downloading the first FW block, since BOOT code writes the
4757 + register to indicate the helper/FW download winner, the value
4758 + could be 1 or 2 (Func1 or Func2). */
4759 + if ((len && offset) || (len > 2))
4766 + else if (len > UAP_UPLD_SIZE) {
4767 + PRINTM(FATAL, "FW download failure @ %d, invalid length %d\n",
4769 + ret = UAP_STATUS_FAILURE;
4775 + if (len & BIT(0)) {
4777 + if (i > MAX_WRITE_IOMEM_RETRY) {
4779 + "FW download failure @ %d, over max retry count\n",
4781 + ret = UAP_STATUS_FAILURE;
4784 + PRINTM(ERROR, "FW CRC error indicated by the helper:"
4785 + " len = 0x%04X, txlen = %d\n", len, txlen);
4787 + /* Setting this to 0 to resend from same offset */
4792 + /* Set blocksize to transfer - checking for last block */
4793 + if (firmwarelen - offset < txlen) {
4794 + txlen = firmwarelen - offset;
4796 + PRINTM(INFO, ".");
4798 + tx_blocks = (txlen + SD_BLOCK_SIZE - 1) / SD_BLOCK_SIZE;
4800 + /* Copy payload to buffer */
4801 + memcpy(fwbuf, &firmware[offset], txlen);
4805 + ret = sdio_writesb(card->func, priv->uap_dev.ioport,
4806 + fwbuf, tx_blocks * SD_BLOCK_SIZE);
4809 + PRINTM(ERROR, "FW download, write iomem (%d) failed @ %d\n", i,
4811 + if (sbi_write_ioreg(priv, CONFIGURATION_REG, 0x04) < 0) {
4812 + PRINTM(ERROR, "write ioreg failed (CFG)\n");
4819 + PRINTM(INFO, "\nFW download over, size %d bytes\n", offset);
4821 + ret = UAP_STATUS_SUCCESS;
4823 +#ifdef FW_DOWNLOAD_SPEED
4824 + tv2 = get_utimeofday();
4825 + PRINTM(INFO, "FW: %ld.%03ld.%03ld ", tv1 / 1000000,
4826 + (tv1 % 1000000) / 1000, tv1 % 1000);
4827 + PRINTM(INFO, " -> %ld.%03ld.%03ld ", tv2 / 1000000,
4828 + (tv2 % 1000000) / 1000, tv2 % 1000);
4830 + PRINTM(INFO, " == %ld.%03ld.%03ld\n", tv2 / 1000000,
4831 + (tv2 % 1000000) / 1000, tv2 % 1000);
4833 + sdio_release_host(card->func);
4842 + * @brief This function checks if the firmware is ready to accept
4845 + * @param priv A pointer to uap_private structure
4846 + * @param pollnum Poll number
4847 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4850 +sbi_check_fw_status(uap_private * priv, int pollnum)
4852 + struct sdio_mmc_card *card = priv->uap_dev.card;
4853 + int ret = UAP_STATUS_SUCCESS;
4859 + sdio_claim_host(card->func);
4861 + /* Wait for firmware initialization event */
4862 + for (tries = 0; tries < pollnum; tries++) {
4863 + if ((ret = sd_read_firmware_status(priv, &firmwarestat)) < 0)
4865 + if (firmwarestat == FIRMWARE_READY) {
4866 + ret = UAP_STATUS_SUCCESS;
4870 + ret = UAP_STATUS_FAILURE;
4877 + ret = UAP_STATUS_SUCCESS;
4878 + sd_get_rx_unit(priv);
4881 + sdio_release_host(card->func);
4888 + * @brief This function set bus clock on/off
4890 + * @param priv A pointer to uap_private structure
4891 + * @param option TRUE--on , FALSE--off
4892 + * @return UAP_STATUS_SUCCESS
4896 +sbi_set_bus_clock(uap_private * priv, u8 option)
4900 + return UAP_STATUS_SUCCESS;
4905 + * @brief This function wakeup firmware
4907 + * @param priv A pointer to uap_private structure
4908 + * @return UAP_STATUS_SUCCESS or UAP_STATUS_FAILURE
4911 +sbi_wakeup_firmware(uap_private * priv)
4913 + struct sdio_mmc_card *card = priv->uap_dev.card;
4914 + int ret = UAP_STATUS_SUCCESS;
4918 + if (!card || !card->func) {
4919 + PRINTM(ERROR, "card or function is NULL!\n");
4921 + return UAP_STATUS_FAILURE;
4923 + sdio_claim_host(card->func);
4924 + sdio_writeb(card->func, HOST_POWER_UP, CONFIGURATION_REG, &ret);
4925 + sdio_release_host(card->func);
4929 diff -Naur compat-wireless-3.5-rc5-1-snpc.org/drivers/net/wireless/libertas_uap/uap_sdio_mmc.h compat-wireless-3.5-rc5-1-snpc/drivers/net/wireless/libertas_uap/uap_sdio_mmc.h
4930 --- compat-wireless-3.5-rc5-1-snpc.org/drivers/net/wireless/libertas_uap/uap_sdio_mmc.h 1970-01-01 01:00:00.000000000 +0100
4931 +++ compat-wireless-3.5-rc5-1-snpc/drivers/net/wireless/libertas_uap/uap_sdio_mmc.h 2012-07-31 14:23:04.000000000 +0200
4933 +/** @file uap_sdio_mmc.h
4934 + * @brief This file contains SDIO IF (interface) module
4935 + * related macros, enum, and structure.
4937 + * Copyright (C) 2007-2009, Marvell International Ltd.
4939 + * This software file (the "File") is distributed by Marvell International
4940 + * Ltd. under the terms of the GNU General Public License Version 2, June 1991
4941 + * (the "License"). You may use, redistribute and/or modify this File in
4942 + * accordance with the terms and conditions of the License, a copy of which
4943 + * is available along with the File in the gpl.txt file or by writing to
4944 + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
4945 + * 02111-1307 or on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
4947 + * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
4948 + * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
4949 + * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
4950 + * this warranty disclaimer.
4953 +/****************************************************
4955 + 10/10/07: initial version
4956 +****************************************************/
4958 +#ifndef _UAP_SDIO_MMC_H
4959 +#define _UAP_SDIO_MMC_H
4961 +#include <linux/mmc/sdio.h>
4962 +#include <linux/mmc/sdio_ids.h>
4963 +#include <linux/mmc/sdio_func.h>
4964 +#include <linux/mmc/card.h>
4966 +#include "uap_headers.h"
4968 +/** The number of times to try when waiting for downloaded firmware to
4969 + become active. (polling the scratch register). */
4970 +#define MAX_FIRMWARE_POLL_TRIES 100
4972 +/** Firmware ready */
4973 +#define FIRMWARE_READY 0xfedc
4975 +/** Number of firmware blocks to transfer */
4976 +#define FIRMWARE_TRANSFER_NBLOCK 2
4978 +/* Host Control Registers */
4979 +/** Host Control Registers : I/O port 0 */
4980 +#define IO_PORT_0_REG 0x00
4981 +/** Host Control Registers : I/O port 1 */
4982 +#define IO_PORT_1_REG 0x01
4983 +/** Host Control Registers : I/O port 2 */
4984 +#define IO_PORT_2_REG 0x02
4986 +/** Host Control Registers : Configuration */
4987 +#define CONFIGURATION_REG 0x03
4988 +/** Host Control Registers : Host without Command 53 finish host */
4989 +#define HOST_WO_CMD53_FINISH_HOST (0x1U << 2)
4990 +/** Host Control Registers : Host power up */
4991 +#define HOST_POWER_UP (0x1U << 1)
4992 +/** Host Control Registers : Host power down */
4993 +#define HOST_POWER_DOWN (0x1U << 0)
4995 +/** Host Control Registers : Host interrupt mask */
4996 +#define HOST_INT_MASK_REG 0x04
4997 +/** Host Control Registers : Upload host interrupt mask */
4998 +#define UP_LD_HOST_INT_MASK (0x1U)
4999 +/** Host Control Registers : Download host interrupt mask */
5000 +#define DN_LD_HOST_INT_MASK (0x2U)
5001 +/** Enable Host interrupt mask */
5002 +#define HIM_ENABLE (UP_LD_HOST_INT_MASK | DN_LD_HOST_INT_MASK)
5003 +/** Disable Host interrupt mask */
5004 +#define HIM_DISABLE 0xff
5006 +/** Host Control Registers : Host interrupt status */
5007 +#define HOST_INTSTATUS_REG 0x05
5008 +/** Host Control Registers : Upload host interrupt status */
5009 +#define UP_LD_HOST_INT_STATUS (0x1U)
5010 +/** Host Control Registers : Download host interrupt status */
5011 +#define DN_LD_HOST_INT_STATUS (0x2U)
5013 +/** Host F1 read base 0 */
5014 +#define HOST_F1_RD_BASE_0 0x10
5015 +/** Host F1 read base 1 */
5016 +#define HOST_F1_RD_BASE_1 0x11
5018 +/** Card Control Registers : Card status register */
5019 +#define CARD_STATUS_REG 0x20
5020 +/** Card Control Registers : Card I/O ready */
5021 +#define CARD_IO_READY (0x1U << 3)
5022 +/** Card Control Registers : CIS card ready */
5023 +#define CIS_CARD_RDY (0x1U << 2)
5024 +/** Card Control Registers : Upload card ready */
5025 +#define UP_LD_CARD_RDY (0x1U << 1)
5026 +/** Card Control Registers : Download card ready */
5027 +#define DN_LD_CARD_RDY (0x1U << 0)
5029 +/** Card Control Registers : Card OCR 0 register */
5030 +#define CARD_OCR_0_REG 0x34
5031 +/** Card Control Registers : Card OCR 1 register */
5032 +#define CARD_OCR_1_REG 0x35
5034 +/** Firmware status 0 register */
5035 +#define CARD_FW_STATUS0_REG 0x40
5036 +/** Firmware status 1 register */
5037 +#define CARD_FW_STATUS1_REG 0x41
5038 +/** Rx length register */
5039 +#define CARD_RX_LEN_REG 0x42
5040 +/** Rx unit register */
5041 +#define CARD_RX_UNIT_REG 0x43
5043 +/** Chip Id Register 0 */
5044 +#define CARD_CHIP_ID_0_REG 0x801c
5045 +/** Chip Id Register 1 */
5046 +#define CARD_CHIP_ID_1_REG 0x801d
5048 +#ifdef PXA3XX_DMA_ALIGN
5049 +/** DMA alignment value for PXA3XX platforms */
5050 +#define PXA3XX_DMA_ALIGNMENT 8
5051 +/** Macros for Data Alignment : size */
5052 +#define ALIGN_SZ(p, a) \
5053 + (((p) + ((a) - 1)) & ~((a) - 1))
5055 +/** Macros for Data Alignment : address */
5056 +#define ALIGN_ADDR(p, a) \
5057 + ((((u32)(p)) + (((u32)(a)) - 1)) & ~(((u32)(a)) - 1))
5058 +#endif /* PXA3XX_DMA_ALIGN */
5060 +struct sdio_mmc_card
5062 + /** sdio_func structure pointer */
5063 + struct sdio_func *func;
5064 + /** uap_private structure pointer */
5065 + uap_private *priv;
5068 +#endif /* _UAP_SDIO_MMC_H */
5069 diff -Naur compat-wireless-3.5-rc5-1-snpc.org/drivers/net/wireless/Makefile compat-wireless-3.5-rc5-1-snpc/drivers/net/wireless/Makefile
5070 --- compat-wireless-3.5-rc5-1-snpc.org/drivers/net/wireless/Makefile 2012-07-05 03:48:01.000000000 +0200
5071 +++ compat-wireless-3.5-rc5-1-snpc/drivers/net/wireless/Makefile 2012-07-31 14:20:01.343608619 +0200
5074 obj-$(CONFIG_LIBERTAS_THINFIRM) += libertas_tf/
5076 +obj-$(CONFIG_LIBERTAS_UAP) += libertas_uap/
5078 obj-$(CONFIG_ADM8211) += adm8211.o
5080 obj-$(CONFIG_MWL8K) += mwl8k.o