1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 ******************************************************************************/
19 #include <osdep_service.h>
20 #include <osdep_intf.h>
22 #include <asm/byteorder.h>
23 #include <linux/semaphore.h>
24 #include <linux/list.h>
25 /* include <linux/smp_lock.h> */
26 #include <linux/spinlock.h>
27 #include <asm/atomic.h>
29 #include <linux/usb.h>
30 #include <linux/usb/ch9.h>
32 #define rtw_usb_buffer_alloc(dev, size, dma) usb_alloc_coherent((dev), (size), (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL), (dma))
33 #define rtw_usb_buffer_free(dev, size, addr, dma) usb_free_coherent((dev), (size), (addr), (dma))
37 #define MAX_PROT_SZ (64-16)
40 #define _IO_WAIT_COMPLETE 1
41 #define _IO_WAIT_RSP 2
44 #define _IOSZ_MASK_ (0x7F)
45 #define _IO_WRITE_ BIT(7)
46 #define _IO_FIXED_ BIT(8)
47 #define _IO_BURST_ BIT(9)
48 #define _IO_BYTE_ BIT(10)
49 #define _IO_HW_ BIT(11)
50 #define _IO_WORD_ BIT(12)
51 #define _IO_SYNC_ BIT(13)
52 #define _IO_CMDMASK_ (0x1F80)
56 For prompt mode accessing, caller shall free io_req
57 Otherwise, io_handler will free io_req
63 #define _IO_ERR_ BIT(2)
64 #define _IO_SUCCESS_ BIT(1)
65 #define _IO_DONE_ BIT(0)
68 #define IO_RD32 (_IO_SYNC_ | _IO_WORD_)
69 #define IO_RD16 (_IO_SYNC_ | _IO_HW_)
70 #define IO_RD8 (_IO_SYNC_ | _IO_BYTE_)
72 #define IO_RD32_ASYNC (_IO_WORD_)
73 #define IO_RD16_ASYNC (_IO_HW_)
74 #define IO_RD8_ASYNC (_IO_BYTE_)
76 #define IO_WR32 (_IO_WRITE_ | _IO_SYNC_ | _IO_WORD_)
77 #define IO_WR16 (_IO_WRITE_ | _IO_SYNC_ | _IO_HW_)
78 #define IO_WR8 (_IO_WRITE_ | _IO_SYNC_ | _IO_BYTE_)
80 #define IO_WR32_ASYNC (_IO_WRITE_ | _IO_WORD_)
81 #define IO_WR16_ASYNC (_IO_WRITE_ | _IO_HW_)
82 #define IO_WR8_ASYNC (_IO_WRITE_ | _IO_BYTE_)
86 Only Sync. burst accessing is provided.
90 #define IO_WR_BURST(x) (_IO_WRITE_ | _IO_SYNC_ | _IO_BURST_ | ( (x) & _IOSZ_MASK_))
91 #define IO_RD_BURST(x) (_IO_SYNC_ | _IO_BURST_ | ( (x) & _IOSZ_MASK_))
95 /* below is for the intf_option bit defition... */
97 #define _INTF_ASYNC_ BIT(0) /* support async io */
102 struct list_head list;
108 struct semaphore sema;
110 void (*_async_io_callback)(struct rtw_adapter *padater, struct io_req *pio_req, u8 *cnxt);
114 struct reg_protocol_rd {
116 #ifdef __LITTLE_ENDIAN
124 u32 WriteEnable:1; /* 0:read, 1:write */
125 u32 FixOrContinuous:1; /* 0:continuous, 1: Fix */
156 u32 FixOrContinuous : 1;
171 struct reg_protocol_wt {
174 #ifdef __LITTLE_ENDIAN
182 u32 WriteEnable:1; /* 0:read, 1:write */
183 u32 FixOrContinuous:1; /* 0:continuous, 1: Fix */
212 u32 FixOrContinuous : 1;
226 #define PlatformEFIOWrite1Byte(_a, _b, _c) \
227 rtl8723au_write8(_a, _b, _c)
228 #define PlatformEFIOWrite2Byte(_a, _b, _c) \
229 rtl8723au_write16(_a, _b, _c)
230 #define PlatformEFIOWrite4Byte(_a, _b, _c) \
231 rtl8723au_write32(_a, _b, _c)
233 #define PlatformEFIORead1Byte(_a, _b) rtl8723au_read8(_a, _b)
234 #define PlatformEFIORead2Byte(_a, _b) rtl8723au_read16(_a, _b)
235 #define PlatformEFIORead4Byte(_a, _b) rtl8723au_read32(_a, _b)
237 #endif /* _RTL8711_IO_H_ */