Commit | Line | Data |
---|---|---|
a9533e7e HP |
1 | /* |
2 | * Copyright (c) 2010 Broadcom Corporation | |
3 | * | |
4 | * Permission to use, copy, modify, and/or distribute this software for any | |
5 | * purpose with or without fee is hereby granted, provided that the above | |
6 | * copyright notice and this permission notice appear in all copies. | |
7 | * | |
8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | |
11 | * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION | |
13 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |
14 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
15 | */ | |
16 | ||
17 | #ifndef _sdio_api_h_ | |
18 | #define _sdio_api_h_ | |
19 | ||
c55a1223 RV |
20 | #include "sdio_host.h" |
21 | ||
a9533e7e HP |
22 | #define SDIOH_READ 0 /* Read request */ |
23 | #define SDIOH_WRITE 1 /* Write request */ | |
24 | ||
25 | #define SDIOH_DATA_FIX 0 /* Fixed addressing */ | |
26 | #define SDIOH_DATA_INC 1 /* Incremental addressing */ | |
27 | ||
28 | #define SDIOH_CMD_TYPE_NORMAL 0 /* Normal command */ | |
29 | #define SDIOH_CMD_TYPE_APPEND 1 /* Append command */ | |
30 | #define SDIOH_CMD_TYPE_CUTTHRU 2 /* Cut-through command */ | |
31 | ||
32 | #define SDIOH_DATA_PIO 0 /* PIO mode */ | |
33 | #define SDIOH_DATA_DMA 1 /* DMA mode */ | |
34 | ||
621beaff RV |
35 | /* internal return code */ |
36 | #define SUCCESS 0 | |
37 | #define ERROR 1 | |
38 | ||
39 | /* Common msglevel constants */ | |
40 | #define SDH_ERROR_VAL 0x0001 /* Error */ | |
41 | #define SDH_TRACE_VAL 0x0002 /* Trace */ | |
42 | #define SDH_INFO_VAL 0x0004 /* Info */ | |
43 | #define SDH_DEBUG_VAL 0x0008 /* Debug */ | |
44 | #define SDH_DATA_VAL 0x0010 /* Data */ | |
45 | #define SDH_CTRL_VAL 0x0020 /* Control Regs */ | |
46 | #define SDH_LOG_VAL 0x0040 /* Enable bcmlog */ | |
47 | #define SDH_DMA_VAL 0x0080 /* DMA */ | |
48 | ||
49 | #ifdef BCMDBG | |
50 | #define sd_err(x) \ | |
51 | do { \ | |
52 | if ((sd_msglevel & SDH_ERROR_VAL) && net_ratelimit()) \ | |
53 | printk x; \ | |
54 | } while (0) | |
55 | #define sd_trace(x) \ | |
56 | do { \ | |
57 | if ((sd_msglevel & SDH_TRACE_VAL) && net_ratelimit()) \ | |
58 | printk x; \ | |
59 | } while (0) | |
60 | #define sd_info(x) \ | |
61 | do { \ | |
62 | if ((sd_msglevel & SDH_INFO_VAL) && net_ratelimit()) \ | |
63 | printk x; \ | |
64 | } while (0) | |
65 | #define sd_debug(x) \ | |
66 | do { \ | |
67 | if ((sd_msglevel & SDH_DEBUG_VAL) && net_ratelimit()) \ | |
68 | printk x; \ | |
69 | } while (0) | |
70 | #define sd_data(x) \ | |
71 | do { \ | |
72 | if ((sd_msglevel & SDH_DATA_VAL) && net_ratelimit()) \ | |
73 | printk x; \ | |
74 | } while (0) | |
75 | #define sd_ctrl(x) \ | |
76 | do { \ | |
77 | if ((sd_msglevel & SDH_CTRL_VAL) && net_ratelimit()) \ | |
78 | printk x; \ | |
79 | } while (0) | |
80 | #else | |
81 | #define sd_err(x) | |
82 | #define sd_trace(x) | |
83 | #define sd_info(x) | |
84 | #define sd_debug(x) | |
85 | #define sd_data(x) | |
86 | #define sd_ctrl(x) | |
87 | #endif | |
88 | ||
5def3b95 RV |
89 | struct brcmf_sdreg { |
90 | int func; | |
91 | int offset; | |
92 | int value; | |
93 | }; | |
94 | ||
621beaff RV |
95 | struct sdioh_info { |
96 | struct osl_info *osh; /* osh handler */ | |
97 | bool client_intr_enabled; /* interrupt connnected flag */ | |
98 | bool intr_handler_valid; /* client driver interrupt handler valid */ | |
63bec49e | 99 | void (*intr_handler)(void *); /* registered interrupt handler */ |
621beaff RV |
100 | void *intr_handler_arg; /* argument to call interrupt handler */ |
101 | u16 intmask; /* Current active interrupts */ | |
102 | void *sdos_info; /* Pointer to per-OS private data */ | |
103 | ||
104 | uint irq; /* Client irq */ | |
105 | int intrcount; /* Client interrupts */ | |
106 | bool sd_blockmode; /* sd_blockmode == false => 64 Byte Cmd 53s. */ | |
107 | /* Must be on for sd_multiblock to be effective */ | |
108 | bool use_client_ints; /* If this is false, make sure to restore */ | |
109 | int client_block_size[SDIOD_MAX_IOFUNCS]; /* Blocksize */ | |
110 | u8 num_funcs; /* Supported funcs on client */ | |
111 | u32 com_cis_ptr; | |
112 | u32 func_cis_ptr[SDIOD_MAX_IOFUNCS]; | |
113 | uint max_dma_len; | |
114 | uint max_dma_descriptors; /* DMA Descriptors supported by this controller. */ | |
115 | /* SDDMA_DESCRIPTOR SGList[32]; *//* Scatter/Gather DMA List */ | |
116 | }; | |
117 | ||
118 | struct brcmf_sdmmc_instance { | |
119 | struct sdioh_info *sd; | |
120 | struct sdio_func *func[SDIOD_MAX_IOFUNCS]; | |
121 | u32 host_claimed; | |
122 | }; | |
123 | ||
124 | /* Allocate/init/free per-OS private data */ | |
125 | extern int brcmf_sdioh_osinit(struct sdioh_info *sd); | |
126 | extern void brcmf_sdioh_osfree(struct sdioh_info *sd); | |
127 | ||
621beaff RV |
128 | /* Core interrupt enable/disable of device interrupts */ |
129 | extern void brcmf_sdioh_dev_intr_on(struct sdioh_info *sd); | |
130 | extern void brcmf_sdioh_dev_intr_off(struct sdioh_info *sd); | |
131 | ||
a9533e7e HP |
132 | /* attach, return handler on success, NULL if failed. |
133 | * The handler shall be provided by all subsequent calls. No local cache | |
134 | * cfghdl points to the starting address of pci device mapped memory | |
135 | */ | |
294f2439 | 136 | extern struct sdioh_info *brcmf_sdioh_attach(void *cfghdl, uint irq); |
3c793822 | 137 | extern int brcmf_sdioh_detach(struct sdioh_info *si); |
63bec49e RV |
138 | |
139 | extern int | |
140 | brcmf_sdioh_interrupt_register(struct sdioh_info *si, | |
141 | void (*sdioh_cb_fn)(void *), void *argh); | |
142 | ||
3c793822 | 143 | extern int brcmf_sdioh_interrupt_deregister(struct sdioh_info *si); |
a9533e7e | 144 | |
a9533e7e | 145 | /* enable or disable SD interrupt */ |
3c793822 | 146 | extern int |
294f2439 | 147 | brcmf_sdioh_interrupt_set(struct sdioh_info *si, bool enable_disable); |
a9533e7e | 148 | |
a9533e7e | 149 | /* read or write one byte using cmd52 */ |
3c793822 | 150 | extern int |
294f2439 | 151 | brcmf_sdioh_request_byte(struct sdioh_info *si, uint rw, uint fnc, uint addr, |
54ca2969 | 152 | u8 *byte); |
a9533e7e HP |
153 | |
154 | /* read or write 2/4 bytes using cmd53 */ | |
3c793822 | 155 | extern int |
294f2439 RV |
156 | brcmf_sdioh_request_word(struct sdioh_info *si, uint cmd_type, |
157 | uint rw, uint fnc, uint addr, | |
158 | u32 *word, uint nbyte); | |
a9533e7e HP |
159 | |
160 | /* read or write any buffer using cmd53 */ | |
3c793822 | 161 | extern int |
294f2439 RV |
162 | brcmf_sdioh_request_buffer(struct sdioh_info *si, uint pio_dma, |
163 | uint fix_inc, uint rw, uint fnc_num, | |
164 | u32 addr, uint regwidth, | |
165 | u32 buflen, u8 *buffer, struct sk_buff *pkt); | |
a9533e7e HP |
166 | |
167 | /* get cis data */ | |
3c793822 | 168 | extern int |
294f2439 | 169 | brcmf_sdioh_cis_read(struct sdioh_info *si, uint fuc, u8 *cis, u32 length); |
a9533e7e | 170 | |
3c793822 | 171 | extern int |
294f2439 | 172 | brcmf_sdioh_cfg_read(struct sdioh_info *si, uint fuc, u32 addr, u8 *data); |
3c793822 | 173 | extern int |
294f2439 | 174 | brcmf_sdioh_cfg_write(struct sdioh_info *si, uint fuc, u32 addr, u8 *data); |
a9533e7e | 175 | |
a9533e7e | 176 | /* handle iovars */ |
294f2439 | 177 | extern int brcmf_sdioh_iovar_op(struct sdioh_info *si, const char *name, |
a9533e7e HP |
178 | void *params, int plen, void *arg, int len, bool set); |
179 | ||
180 | /* Issue abort to the specified function and clear controller as needed */ | |
294f2439 | 181 | extern int brcmf_sdioh_abort(struct sdioh_info *si, uint fnc); |
a9533e7e | 182 | |
ad3a7c49 FL |
183 | /* Watchdog timer interface for pm ops */ |
184 | extern void brcmf_sdio_wdtmr_enable(bool enable); | |
185 | ||
621beaff RV |
186 | extern uint sd_msglevel; /* Debug message level */ |
187 | ||
188 | extern struct brcmf_sdmmc_instance *gInstance; | |
189 | ||
a9533e7e | 190 | #endif /* _sdio_api_h_ */ |