1 //------------------------------------------------------------------------------
2 // <copyright file="hif_internal.h" company="Atheros">
3 // Copyright (c) 2004-2010 Atheros Corporation. All rights reserved.
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.
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.
19 //------------------------------------------------------------------------------
20 //==============================================================================
21 // internal header file for hif layer
23 // Author(s): ="Atheros"
24 //==============================================================================
25 #ifndef _HIF_INTERNAL_H_
26 #define _HIF_INTERNAL_H_
32 #include "../../../common/hif_sdio_common.h"
33 #include <linux/scatterlist.h>
34 #define HIF_LINUX_MMC_SCATTER_SUPPORT
36 #define BUS_REQUEST_MAX_NUM 64
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
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
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 */
59 struct hif_scatter_req_priv *pScatterReq; /* this request is a scatter request */
63 struct sdio_func *func;
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 */
72 BUS_REQUEST *s_busRequestFreeQueue; /* free list */
73 BUS_REQUEST busRequest[BUS_REQUEST_MAX_NUM]; /* available bus requests */
75 HTC_CALLBACKS htcCallbacks;
77 struct dl_list ScatterReqHead; /* scatter request list head */
78 bool scatter_enabled; /* scatter enabled flag */
82 HIF_DEVICE_POWER_CHANGE_TYPE powerConfig;
83 const struct sdio_device_id *id;
86 #define HIF_DMA_BUFFER_SIZE (32 * 1024)
87 #define CMD53_FIXED_ADDRESS 1
88 #define CMD53_INCR_ADDRESS 2
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);
94 #ifdef HIF_LINUX_MMC_SCATTER_SUPPORT
96 #define MAX_SCATTER_REQUESTS 4
97 #define MAX_SCATTER_ENTRIES_PER_REQ 16
98 #define MAX_SCATTER_REQ_TRANSFER_SIZE 32*1024
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];
108 #define ATH_DEBUG_SCATTER ATH_DEBUG_MAKE_MODULE_MASK(0)
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);
114 #else // HIF_LINUX_MMC_SCATTER_SUPPORT
116 static inline int SetupHIFScatterSupport(struct hif_device *device, struct hif_device_scatter_support_info *pInfo)
121 static inline int DoHifReadWriteScatter(struct hif_device *device, BUS_REQUEST *busrequest)
126 #define CleanupHIFScatterResources(d) { }
128 #endif // HIF_LINUX_MMC_SCATTER_SUPPORT
130 #endif // _HIF_INTERNAL_H_