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_types.h"
31 #include "a_osapi.h"
32 #include "hif.h"
33 #include "../../../common/hif_sdio_common.h"
34 #include <linux/scatterlist.h>
35 #define HIF_LINUX_MMC_SCATTER_SUPPORT
36
37 #define BUS_REQUEST_MAX_NUM 64
38
39 #define SDIO_CLOCK_FREQUENCY_DEFAULT 25000000
40 #define SDWLAN_ENABLE_DISABLE_TIMEOUT 20
41 #define FLAGS_CARD_ENAB 0x02
42 #define FLAGS_CARD_IRQ_UNMSK 0x04
43
44 #define HIF_MBOX_BLOCK_SIZE HIF_DEFAULT_IO_BLOCK_SIZE
45 #define HIF_MBOX0_BLOCK_SIZE 1
46 #define HIF_MBOX1_BLOCK_SIZE HIF_MBOX_BLOCK_SIZE
47 #define HIF_MBOX2_BLOCK_SIZE HIF_MBOX_BLOCK_SIZE
48 #define HIF_MBOX3_BLOCK_SIZE HIF_MBOX_BLOCK_SIZE
49
50 typedef struct bus_request {
51 struct bus_request *next; /* link list of available requests */
52 struct bus_request *inusenext; /* link list of in use requests */
53 struct semaphore sem_req;
54 u32 address; /* request data */
55 u8 *buffer;
56 u32 length;
57 u32 request;
58 void *context;
59 int status;
60 struct hif_scatter_req_priv *pScatterReq; /* this request is a scatter request */
61 } BUS_REQUEST;
62
63 struct hif_device {
64 struct sdio_func *func;
65 spinlock_t asynclock;
66 struct task_struct* async_task; /* task to handle async commands */
67 struct semaphore sem_async; /* wake up for async task */
68 int async_shutdown; /* stop the async task */
69 struct completion async_completion; /* thread completion */
70 BUS_REQUEST *asyncreq; /* request for async tasklet */
71 BUS_REQUEST *taskreq; /* async tasklet data */
72 spinlock_t lock;
73 BUS_REQUEST *s_busRequestFreeQueue; /* free list */
74 BUS_REQUEST busRequest[BUS_REQUEST_MAX_NUM]; /* available bus requests */
75 void *claimedContext;
76 HTC_CALLBACKS htcCallbacks;
77 u8 *dma_buffer;
78 struct dl_list ScatterReqHead; /* scatter request list head */
79 bool scatter_enabled; /* scatter enabled flag */
80 bool is_suspend;
81 bool is_disabled;
82 atomic_t irqHandling;
83 HIF_DEVICE_POWER_CHANGE_TYPE powerConfig;
84 const struct sdio_device_id *id;
85 };
86
87 #define HIF_DMA_BUFFER_SIZE (32 * 1024)
88 #define CMD53_FIXED_ADDRESS 1
89 #define CMD53_INCR_ADDRESS 2
90
91 BUS_REQUEST *hifAllocateBusRequest(struct hif_device *device);
92 void hifFreeBusRequest(struct hif_device *device, BUS_REQUEST *busrequest);
93 void AddToAsyncList(struct hif_device *device, BUS_REQUEST *busrequest);
94
95 #ifdef HIF_LINUX_MMC_SCATTER_SUPPORT
96
97 #define MAX_SCATTER_REQUESTS 4
98 #define MAX_SCATTER_ENTRIES_PER_REQ 16
99 #define MAX_SCATTER_REQ_TRANSFER_SIZE 32*1024
100
101 struct hif_scatter_req_priv {
102 struct hif_scatter_req *pHifScatterReq; /* HIF scatter request with allocated entries */
103 struct hif_device *device; /* this device */
104 BUS_REQUEST *busrequest; /* request associated with request */
105 /* scatter list for linux */
106 struct scatterlist sgentries[MAX_SCATTER_ENTRIES_PER_REQ];
107 };
108
109 #define ATH_DEBUG_SCATTER ATH_DEBUG_MAKE_MODULE_MASK(0)
110
111 int SetupHIFScatterSupport(struct hif_device *device, struct hif_device_scatter_support_info *pInfo);
112 void CleanupHIFScatterResources(struct hif_device *device);
113 int DoHifReadWriteScatter(struct hif_device *device, BUS_REQUEST *busrequest);
114
115 #else // HIF_LINUX_MMC_SCATTER_SUPPORT
116
SetupHIFScatterSupport(struct hif_device * device,struct hif_device_scatter_support_info * pInfo)117 static inline int SetupHIFScatterSupport(struct hif_device *device, struct hif_device_scatter_support_info *pInfo)
118 {
119 return A_ENOTSUP;
120 }
121
DoHifReadWriteScatter(struct hif_device * device,BUS_REQUEST * busrequest)122 static inline int DoHifReadWriteScatter(struct hif_device *device, BUS_REQUEST *busrequest)
123 {
124 return A_ENOTSUP;
125 }
126
127 #define CleanupHIFScatterResources(d) { }
128
129 #endif // HIF_LINUX_MMC_SCATTER_SUPPORT
130
131 #endif // _HIF_INTERNAL_H_
132
133