1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#ifndef _BRCM_SDH_H_
18#define _BRCM_SDH_H_
19
20#include <linux/skbuff.h>
21
22#define SDIO_FUNC_0 0
23#define SDIO_FUNC_1 1
24#define SDIO_FUNC_2 2
25
26#define SDIOD_FBR_SIZE 0x100
27
28
29#define SDIO_FUNC_ENABLE_1 0x02
30#define SDIO_FUNC_ENABLE_2 0x04
31
32
33#define SDIO_FUNC_READY_1 0x02
34#define SDIO_FUNC_READY_2 0x04
35
36
37#define INTR_STATUS_FUNC1 0x2
38#define INTR_STATUS_FUNC2 0x4
39
40
41#define SDIOD_MAX_IOFUNCS 7
42
43
44#define REG_F0_REG_MASK 0x7FF
45#define REG_F1_MISC_MASK 0x1FFFF
46
47
48#define SBSDIO_NUM_FUNCTION 3
49
50
51#define SDIO_CCCR_BRCM_CARDCAP 0xf0
52#define SDIO_CCCR_BRCM_CARDCAP_CMD14_SUPPORT 0x02
53#define SDIO_CCCR_BRCM_CARDCAP_CMD14_EXT 0x04
54#define SDIO_CCCR_BRCM_CARDCAP_CMD_NODEC 0x08
55#define SDIO_CCCR_BRCM_CARDCTRL 0xf1
56#define SDIO_CCCR_BRCM_CARDCTRL_WLANRESET 0x02
57#define SDIO_CCCR_BRCM_SEPINT 0xf2
58
59#define SDIO_SEPINT_MASK 0x01
60#define SDIO_SEPINT_OE 0x02
61#define SDIO_SEPINT_ACT_HI 0x04
62
63
64
65
66#define SBSDIO_SPROM_CS 0x10000
67
68#define SBSDIO_SPROM_INFO 0x10001
69
70#define SBSDIO_SPROM_DATA_LOW 0x10002
71
72#define SBSDIO_SPROM_DATA_HIGH 0x10003
73
74#define SBSDIO_SPROM_ADDR_LOW 0x10004
75
76#define SBSDIO_SPROM_ADDR_HIGH 0x10005
77
78#define SBSDIO_CHIP_CTRL_DATA 0x10006
79
80#define SBSDIO_CHIP_CTRL_EN 0x10007
81
82#define SBSDIO_WATERMARK 0x10008
83
84#define SBSDIO_DEVICE_CTL 0x10009
85
86
87#define SBSDIO_FUNC1_SBADDRLOW 0x1000A
88
89#define SBSDIO_FUNC1_SBADDRMID 0x1000B
90
91#define SBSDIO_FUNC1_SBADDRHIGH 0x1000C
92
93#define SBSDIO_FUNC1_FRAMECTRL 0x1000D
94
95#define SBSDIO_FUNC1_CHIPCLKCSR 0x1000E
96
97#define SBSDIO_FUNC1_SDIOPULLUP 0x1000F
98
99#define SBSDIO_FUNC1_WFRAMEBCLO 0x10019
100
101#define SBSDIO_FUNC1_WFRAMEBCHI 0x1001A
102
103#define SBSDIO_FUNC1_RFRAMEBCLO 0x1001B
104
105#define SBSDIO_FUNC1_RFRAMEBCHI 0x1001C
106
107#define SBSDIO_FUNC1_MESBUSYCTRL 0x1001D
108
109#define SBSDIO_FUNC1_WAKEUPCTRL 0x1001E
110#define SBSDIO_FUNC1_WCTRL_ALPWAIT_MASK 0x1
111#define SBSDIO_FUNC1_WCTRL_ALPWAIT_SHIFT 0
112#define SBSDIO_FUNC1_WCTRL_HTWAIT_MASK 0x2
113#define SBSDIO_FUNC1_WCTRL_HTWAIT_SHIFT 1
114#define SBSDIO_FUNC1_SLEEPCSR 0x1001F
115#define SBSDIO_FUNC1_SLEEPCSR_KSO_MASK 0x1
116#define SBSDIO_FUNC1_SLEEPCSR_KSO_SHIFT 0
117#define SBSDIO_FUNC1_SLEEPCSR_KSO_EN 1
118#define SBSDIO_FUNC1_SLEEPCSR_DEVON_MASK 0x2
119#define SBSDIO_FUNC1_SLEEPCSR_DEVON_SHIFT 1
120
121#define SBSDIO_FUNC1_MISC_REG_START 0x10000
122#define SBSDIO_FUNC1_MISC_REG_LIMIT 0x1001F
123
124
125
126
127#define SBSDIO_SB_OFT_ADDR_MASK 0x07FFF
128#define SBSDIO_SB_OFT_ADDR_LIMIT 0x08000
129
130#define SBSDIO_SB_ACCESS_2_4B_FLAG 0x08000
131
132
133
134#define SBSDIO_SBADDRLOW_MASK 0x80
135#define SBSDIO_SBADDRMID_MASK 0xff
136#define SBSDIO_SBADDRHIGH_MASK 0xffU
137
138#define SBSDIO_SBWINDOW_MASK 0xffff8000
139
140#define SDIOH_READ 0
141#define SDIOH_WRITE 1
142
143#define SDIOH_DATA_FIX 0
144#define SDIOH_DATA_INC 1
145
146
147#define SUCCESS 0
148#define ERROR 1
149
150
151#define BRCMF_SDALIGN (1 << 6)
152
153
154#define BRCMF_WD_POLL_MS 10
155
156struct brcmf_sdreg {
157 int func;
158 int offset;
159 int value;
160};
161
162struct brcmf_sdio;
163
164struct brcmf_sdio_dev {
165 struct sdio_func *func[SDIO_MAX_FUNCS];
166 u8 num_funcs;
167 u32 func_cis_ptr[SDIOD_MAX_IOFUNCS];
168 u32 sbwad;
169 void *bus;
170 atomic_t suspend;
171 wait_queue_head_t request_byte_wait;
172 wait_queue_head_t request_word_wait;
173 wait_queue_head_t request_buffer_wait;
174 struct device *dev;
175 struct brcmf_bus *bus_if;
176 struct brcmfmac_sdio_platform_data *pdata;
177 bool oob_irq_requested;
178 bool irq_en;
179 spinlock_t irq_en_lock;
180 bool irq_wake;
181};
182
183
184extern int brcmf_sdio_intr_register(struct brcmf_sdio_dev *sdiodev);
185extern int brcmf_sdio_intr_unregister(struct brcmf_sdio_dev *sdiodev);
186
187
188extern u8 brcmf_sdio_regrb(struct brcmf_sdio_dev *sdiodev, u32 addr, int *ret);
189extern u32 brcmf_sdio_regrl(struct brcmf_sdio_dev *sdiodev, u32 addr, int *ret);
190extern void brcmf_sdio_regwb(struct brcmf_sdio_dev *sdiodev, u32 addr,
191 u8 data, int *ret);
192extern void brcmf_sdio_regwl(struct brcmf_sdio_dev *sdiodev, u32 addr,
193 u32 data, int *ret);
194extern int brcmf_sdio_regrw_helper(struct brcmf_sdio_dev *sdiodev, u32 addr,
195 void *data, bool write);
196
197
198
199
200
201
202
203
204
205
206
207
208
209extern int
210brcmf_sdcard_send_pkt(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn,
211 uint flags, struct sk_buff_head *pktq);
212extern int
213brcmf_sdcard_send_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn,
214 uint flags, u8 *buf, uint nbytes);
215
216extern int
217brcmf_sdcard_recv_pkt(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn,
218 uint flags, struct sk_buff *pkt);
219extern int
220brcmf_sdcard_recv_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn,
221 uint flags, u8 *buf, uint nbytes);
222extern int
223brcmf_sdcard_recv_chain(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn,
224 uint flags, struct sk_buff_head *pktq);
225
226
227
228
229#define SDIO_REQ_4BYTE 0x1
230
231#define SDIO_REQ_FIXED 0x2
232
233
234
235
236
237
238
239
240extern int brcmf_sdcard_rwdata(struct brcmf_sdio_dev *sdiodev, uint rw,
241 u32 addr, u8 *buf, uint nbytes);
242extern int brcmf_sdio_ramrw(struct brcmf_sdio_dev *sdiodev, bool write,
243 u32 address, u8 *data, uint size);
244
245
246extern int brcmf_sdcard_abort(struct brcmf_sdio_dev *sdiodev, uint fn);
247
248
249extern int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev);
250extern int brcmf_sdio_remove(struct brcmf_sdio_dev *sdiodev);
251
252
253
254
255
256extern int brcmf_sdioh_attach(struct brcmf_sdio_dev *sdiodev);
257extern void brcmf_sdioh_detach(struct brcmf_sdio_dev *sdiodev);
258
259
260extern int brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw,
261 uint fnc, uint addr, u8 *byte);
262
263
264extern int
265brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev,
266 uint rw, uint fnc, uint addr,
267 u32 *word, uint nbyte);
268
269
270extern void brcmf_sdio_wdtmr_enable(struct brcmf_sdio_dev *sdiodev,
271 bool enable);
272
273extern void *brcmf_sdbrcm_probe(u32 regsva, struct brcmf_sdio_dev *sdiodev);
274extern void brcmf_sdbrcm_disconnect(void *ptr);
275extern void brcmf_sdbrcm_isr(void *arg);
276
277extern void brcmf_sdbrcm_wd_timer(struct brcmf_sdio *bus, uint wdtick);
278
279extern void brcmf_pm_resume_wait(struct brcmf_sdio_dev *sdiodev,
280 wait_queue_head_t *wq);
281extern bool brcmf_pm_resume_error(struct brcmf_sdio_dev *sdiodev);
282#endif
283