Merge branch 'sh-latest' of git://git.kernel.org/pub/scm/linux/kernel/git/lethal...
[pandora-kernel.git] / drivers / staging / ath6kl / hif / sdio / linux_sdio / include / hif_internal.h
1 //------------------------------------------------------------------------------
2 // <copyright file="hif_internal.h" company="Atheros">
3 //    Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
4 // 
5 //
6 // Permission to use, copy, modify, and/or distribute this software for any
7 // purpose with or without fee is hereby granted, provided that the above
8 // copyright notice and this permission notice appear in all copies.
9 //
10 // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 //
18 //
19 //------------------------------------------------------------------------------
20 //==============================================================================
21 // internal header file for hif layer
22 //
23 // Author(s): ="Atheros"
24 //==============================================================================
25 #ifndef _HIF_INTERNAL_H_
26 #define _HIF_INTERNAL_H_
27
28 #include "a_config.h"
29 #include "athdefs.h"
30 #include "a_osapi.h"
31 #include "hif.h"
32 #include "../../../common/hif_sdio_common.h"
33 #include <linux/scatterlist.h>
34 #define HIF_LINUX_MMC_SCATTER_SUPPORT
35
36 #define BUS_REQUEST_MAX_NUM                64
37
38 #define SDIO_CLOCK_FREQUENCY_DEFAULT       25000000
39 #define SDWLAN_ENABLE_DISABLE_TIMEOUT      20
40 #define FLAGS_CARD_ENAB                    0x02
41 #define FLAGS_CARD_IRQ_UNMSK               0x04
42
43 #define HIF_MBOX_BLOCK_SIZE                HIF_DEFAULT_IO_BLOCK_SIZE
44 #define HIF_MBOX0_BLOCK_SIZE               1
45 #define HIF_MBOX1_BLOCK_SIZE               HIF_MBOX_BLOCK_SIZE
46 #define HIF_MBOX2_BLOCK_SIZE               HIF_MBOX_BLOCK_SIZE
47 #define HIF_MBOX3_BLOCK_SIZE               HIF_MBOX_BLOCK_SIZE
48
49 typedef struct bus_request {
50     struct bus_request *next;       /* link list of available requests */
51     struct bus_request *inusenext;  /* link list of in use requests */
52     struct semaphore sem_req;
53     u32 address;               /* request data */
54     u8 *buffer;
55     u32 length;
56     u32 request;
57     void *context;
58     int status;
59     struct hif_scatter_req_priv *pScatterReq;      /* this request is a scatter request */
60 } BUS_REQUEST;
61
62 struct hif_device {
63     struct sdio_func *func;
64     spinlock_t asynclock;
65     struct task_struct* async_task;             /* task to handle async commands */
66     struct semaphore sem_async;                 /* wake up for async task */
67     int    async_shutdown;                      /* stop the async task */
68     struct completion async_completion;          /* thread completion */
69     BUS_REQUEST   *asyncreq;                    /* request for async tasklet */
70     BUS_REQUEST *taskreq;                       /*  async tasklet data */
71     spinlock_t lock;
72     BUS_REQUEST *s_busRequestFreeQueue;         /* free list */
73     BUS_REQUEST busRequest[BUS_REQUEST_MAX_NUM]; /* available bus requests */
74     void     *claimedContext;
75     HTC_CALLBACKS htcCallbacks;
76     u8 *dma_buffer;
77     struct dl_list      ScatterReqHead;                /* scatter request list head */
78     bool       scatter_enabled;               /* scatter enabled flag */
79     bool   is_suspend;
80     bool   is_disabled;
81     atomic_t   irqHandling;
82     HIF_DEVICE_POWER_CHANGE_TYPE powerConfig;
83     const struct sdio_device_id *id;
84 };
85
86 #define HIF_DMA_BUFFER_SIZE (32 * 1024)
87 #define CMD53_FIXED_ADDRESS 1
88 #define CMD53_INCR_ADDRESS  2
89
90 BUS_REQUEST *hifAllocateBusRequest(struct hif_device *device);
91 void hifFreeBusRequest(struct hif_device *device, BUS_REQUEST *busrequest);
92 void AddToAsyncList(struct hif_device *device, BUS_REQUEST *busrequest);
93
94 #ifdef HIF_LINUX_MMC_SCATTER_SUPPORT
95
96 #define MAX_SCATTER_REQUESTS             4
97 #define MAX_SCATTER_ENTRIES_PER_REQ      16
98 #define MAX_SCATTER_REQ_TRANSFER_SIZE    32*1024
99
100 struct hif_scatter_req_priv {
101     struct hif_scatter_req     *pHifScatterReq;  /* HIF scatter request with allocated entries */   
102     struct hif_device          *device;          /* this device */
103     BUS_REQUEST         *busrequest;      /* request associated with request */
104         /* scatter list for linux */    
105     struct scatterlist  sgentries[MAX_SCATTER_ENTRIES_PER_REQ];   
106 };
107
108 #define ATH_DEBUG_SCATTER  ATH_DEBUG_MAKE_MODULE_MASK(0)
109
110 int SetupHIFScatterSupport(struct hif_device *device, struct hif_device_scatter_support_info *pInfo);
111 void CleanupHIFScatterResources(struct hif_device *device);
112 int DoHifReadWriteScatter(struct hif_device *device, BUS_REQUEST *busrequest);
113
114 #else  // HIF_LINUX_MMC_SCATTER_SUPPORT
115
116 static inline int SetupHIFScatterSupport(struct hif_device *device, struct hif_device_scatter_support_info *pInfo)
117 {
118     return A_ENOTSUP;
119 }
120
121 static inline int DoHifReadWriteScatter(struct hif_device *device, BUS_REQUEST *busrequest)
122 {
123     return A_ENOTSUP;
124 }
125
126 #define CleanupHIFScatterResources(d) { }
127
128 #endif // HIF_LINUX_MMC_SCATTER_SUPPORT
129
130 #endif // _HIF_INTERNAL_H_
131