1
2
3
4
5
6
7
8#ifndef _RTW_IO_H_
9#define _RTW_IO_H_
10
11#define NUM_IOREQ 8
12
13#define MAX_PROT_SZ (64-16)
14
15#define _IOREADY 0
16#define _IO_WAIT_COMPLETE 1
17#define _IO_WAIT_RSP 2
18
19
20#define _IOSZ_MASK_ (0x7F)
21#define _IO_WRITE_ BIT(7)
22#define _IO_FIXED_ BIT(8)
23#define _IO_BURST_ BIT(9)
24#define _IO_BYTE_ BIT(10)
25#define _IO_HW_ BIT(11)
26#define _IO_WORD_ BIT(12)
27#define _IO_SYNC_ BIT(13)
28#define _IO_CMDMASK_ (0x1F80)
29
30
31
32
33
34
35
36
37
38
39#define _IO_ERR_ BIT(2)
40#define _IO_SUCCESS_ BIT(1)
41#define _IO_DONE_ BIT(0)
42
43
44#define IO_RD32 (_IO_SYNC_ | _IO_WORD_)
45#define IO_RD16 (_IO_SYNC_ | _IO_HW_)
46#define IO_RD8 (_IO_SYNC_ | _IO_BYTE_)
47
48#define IO_RD32_ASYNC (_IO_WORD_)
49#define IO_RD16_ASYNC (_IO_HW_)
50#define IO_RD8_ASYNC (_IO_BYTE_)
51
52#define IO_WR32 (_IO_WRITE_ | _IO_SYNC_ | _IO_WORD_)
53#define IO_WR16 (_IO_WRITE_ | _IO_SYNC_ | _IO_HW_)
54#define IO_WR8 (_IO_WRITE_ | _IO_SYNC_ | _IO_BYTE_)
55
56#define IO_WR32_ASYNC (_IO_WRITE_ | _IO_WORD_)
57#define IO_WR16_ASYNC (_IO_WRITE_ | _IO_HW_)
58#define IO_WR8_ASYNC (_IO_WRITE_ | _IO_BYTE_)
59
60
61
62
63
64
65
66#define IO_WR_BURST(x) (_IO_WRITE_ | _IO_SYNC_ | _IO_BURST_ | ((x) & _IOSZ_MASK_))
67#define IO_RD_BURST(x) (_IO_SYNC_ | _IO_BURST_ | ((x) & _IOSZ_MASK_))
68
69
70
71
72
73#define _INTF_ASYNC_ BIT(0)
74
75struct intf_priv;
76struct intf_hdl;
77struct io_queue;
78
79struct _io_ops {
80 u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr);
81 u16 (*_read16)(struct intf_hdl *pintfhdl, u32 addr);
82 u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr);
83
84 int (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val);
85 int (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val);
86 int (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val);
87 int (*_writeN)(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata);
88
89 int (*_write8_async)(struct intf_hdl *pintfhdl, u32 addr, u8 val);
90 int (*_write16_async)(struct intf_hdl *pintfhdl, u32 addr, u16 val);
91 int (*_write32_async)(struct intf_hdl *pintfhdl, u32 addr, u32 val);
92
93 void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem);
94 void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem);
95
96 void (*_sync_irp_protocol_rw)(struct io_queue *pio_q);
97
98 u32 (*_read_interrupt)(struct intf_hdl *pintfhdl, u32 addr);
99
100 u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem);
101 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem);
102
103 u32 (*_write_scsi)(struct intf_hdl *pintfhdl, u32 cnt, u8 *pmem);
104
105 void (*_read_port_cancel)(struct intf_hdl *pintfhdl);
106 void (*_write_port_cancel)(struct intf_hdl *pintfhdl);
107
108 u8 (*_sd_f0_read8)(struct intf_hdl *pintfhdl, u32 addr);
109};
110
111struct io_req {
112 struct list_head list;
113 u32 addr;
114 volatile u32 val;
115 u32 command;
116 u32 status;
117 u8 *pbuf;
118 _sema sema;
119
120 void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt);
121 u8 *cnxt;
122};
123
124struct intf_hdl {
125 struct adapter *padapter;
126 struct dvobj_priv *pintf_dev;
127
128 struct _io_ops io_ops;
129};
130
131struct reg_protocol_rd {
132
133#ifdef __LITTLE_ENDIAN
134
135
136 u32 NumOfTrans:4;
137 u32 Reserved1:4;
138 u32 Reserved2:24;
139
140 u32 ByteCount:7;
141 u32 WriteEnable:1;
142 u32 FixOrContinuous:1;
143 u32 BurstMode:1;
144 u32 Byte1Access:1;
145 u32 Byte2Access:1;
146 u32 Byte4Access:1;
147 u32 Reserved3:3;
148 u32 Reserved4:16;
149
150 u32 BusAddress;
151
152
153#else
154
155
156
157 u32 Reserved1 :4;
158 u32 NumOfTrans :4;
159
160 u32 Reserved2 :24;
161
162
163 u32 WriteEnable : 1;
164 u32 ByteCount :7;
165
166
167 u32 Reserved3 : 3;
168 u32 Byte4Access : 1;
169
170 u32 Byte2Access : 1;
171 u32 Byte1Access : 1;
172 u32 BurstMode :1 ;
173 u32 FixOrContinuous : 1;
174
175 u32 Reserved4 : 16;
176
177
178 u32 BusAddress;
179
180
181
182
183#endif
184
185};
186
187
188struct reg_protocol_wt {
189
190
191#ifdef __LITTLE_ENDIAN
192
193
194 u32 NumOfTrans:4;
195 u32 Reserved1:4;
196 u32 Reserved2:24;
197
198 u32 ByteCount:7;
199 u32 WriteEnable:1;
200 u32 FixOrContinuous:1;
201 u32 BurstMode:1;
202 u32 Byte1Access:1;
203 u32 Byte2Access:1;
204 u32 Byte4Access:1;
205 u32 Reserved3:3;
206 u32 Reserved4:16;
207
208 u32 BusAddress;
209
210 u32 Value;
211
212#else
213
214 u32 Reserved1 :4;
215 u32 NumOfTrans :4;
216
217 u32 Reserved2 :24;
218
219
220 u32 WriteEnable : 1;
221 u32 ByteCount :7;
222
223 u32 Reserved3 : 3;
224 u32 Byte4Access : 1;
225
226 u32 Byte2Access : 1;
227 u32 Byte1Access : 1;
228 u32 BurstMode :1 ;
229 u32 FixOrContinuous : 1;
230
231 u32 Reserved4 : 16;
232
233
234 u32 BusAddress;
235
236
237 u32 Value;
238
239#endif
240
241};
242#define SD_IO_TRY_CNT (8)
243#define MAX_CONTINUAL_IO_ERR SD_IO_TRY_CNT
244
245int rtw_inc_and_chk_continual_io_error(struct dvobj_priv *dvobj);
246void rtw_reset_continual_io_error(struct dvobj_priv *dvobj);
247
248
249
250
251
252
253struct io_queue {
254 _lock lock;
255 struct list_head free_ioreqs;
256 struct list_head pending;
257 struct list_head processing;
258 u8 *free_ioreqs_buf;
259 u8 *pallocated_free_ioreqs_buf;
260 struct intf_hdl intf;
261};
262
263struct io_priv{
264
265 struct adapter *padapter;
266
267 struct intf_hdl intf;
268
269};
270
271extern uint ioreq_flush(struct adapter *adapter, struct io_queue *ioqueue);
272extern void sync_ioreq_enqueue(struct io_req *preq, struct io_queue *ioqueue);
273extern uint sync_ioreq_flush(struct adapter *adapter, struct io_queue *ioqueue);
274
275
276extern uint free_ioreq(struct io_req *preq, struct io_queue *pio_queue);
277extern struct io_req *alloc_ioreq(struct io_queue *pio_q);
278
279extern uint register_intf_hdl(u8 *dev, struct intf_hdl *pintfhdl);
280extern void unregister_intf_hdl(struct intf_hdl *pintfhdl);
281
282extern void _rtw_attrib_read(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
283extern void _rtw_attrib_write(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
284
285extern u8 _rtw_read8(struct adapter *adapter, u32 addr);
286extern u16 _rtw_read16(struct adapter *adapter, u32 addr);
287extern u32 _rtw_read32(struct adapter *adapter, u32 addr);
288
289extern int _rtw_write8(struct adapter *adapter, u32 addr, u8 val);
290extern int _rtw_write16(struct adapter *adapter, u32 addr, u16 val);
291extern int _rtw_write32(struct adapter *adapter, u32 addr, u32 val);
292
293extern u8 _rtw_sd_f0_read8(struct adapter *adapter, u32 addr);
294
295extern u32 _rtw_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
296
297#define rtw_read8(adapter, addr) _rtw_read8((adapter), (addr))
298#define rtw_read16(adapter, addr) _rtw_read16((adapter), (addr))
299#define rtw_read32(adapter, addr) _rtw_read32((adapter), (addr))
300
301#define rtw_write8(adapter, addr, val) _rtw_write8((adapter), (addr), (val))
302#define rtw_write16(adapter, addr, val) _rtw_write16((adapter), (addr), (val))
303#define rtw_write32(adapter, addr, val) _rtw_write32((adapter), (addr), (val))
304
305#define rtw_write_port(adapter, addr, cnt, mem) _rtw_write_port((adapter), (addr), (cnt), (mem))
306
307#define rtw_sd_f0_read8(adapter, addr) _rtw_sd_f0_read8((adapter), (addr))
308
309extern void rtw_write_scsi(struct adapter *adapter, u32 cnt, u8 *pmem);
310
311
312extern void ioreq_read8(struct adapter *adapter, u32 addr, u8 *pval);
313extern void ioreq_read16(struct adapter *adapter, u32 addr, u16 *pval);
314extern void ioreq_read32(struct adapter *adapter, u32 addr, u32 *pval);
315extern void ioreq_write8(struct adapter *adapter, u32 addr, u8 val);
316extern void ioreq_write16(struct adapter *adapter, u32 addr, u16 val);
317extern void ioreq_write32(struct adapter *adapter, u32 addr, u32 val);
318
319
320extern uint async_read8(struct adapter *adapter, u32 addr, u8 *pbuff,
321 void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt);
322extern uint async_read16(struct adapter *adapter, u32 addr, u8 *pbuff,
323 void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt);
324extern uint async_read32(struct adapter *adapter, u32 addr, u8 *pbuff,
325 void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt);
326
327extern void async_read_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
328extern void async_read_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
329
330extern void async_write8(struct adapter *adapter, u32 addr, u8 val,
331 void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt);
332extern void async_write16(struct adapter *adapter, u32 addr, u16 val,
333 void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt);
334extern void async_write32(struct adapter *adapter, u32 addr, u32 val,
335 void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt);
336
337extern void async_write_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
338extern void async_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
339
340
341int rtw_init_io_priv(struct adapter *padapter, void (*set_intf_ops)(struct adapter *padapter, struct _io_ops *pops));
342
343
344extern uint alloc_io_queue(struct adapter *adapter);
345extern void free_io_queue(struct adapter *adapter);
346extern void async_bus_io(struct io_queue *pio_q);
347extern void bus_sync_io(struct io_queue *pio_q);
348extern u32 _ioreq2rwmem(struct io_queue *pio_q);
349extern void dev_power_down(struct adapter * Adapter, u8 bpwrup);
350
351#define PlatformEFIOWrite1Byte(_a, _b, _c) \
352 rtw_write8(_a, _b, _c)
353#define PlatformEFIOWrite2Byte(_a, _b, _c) \
354 rtw_write16(_a, _b, _c)
355#define PlatformEFIOWrite4Byte(_a, _b, _c) \
356 rtw_write32(_a, _b, _c)
357
358#define PlatformEFIORead1Byte(_a, _b) \
359 rtw_read8(_a, _b)
360#define PlatformEFIORead2Byte(_a, _b) \
361 rtw_read16(_a, _b)
362#define PlatformEFIORead4Byte(_a, _b) \
363 rtw_read32(_a, _b)
364
365#endif
366