net: wireless: rockchip_wlan: add rtl8723cs support
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8723cs / include / drv_types_pci.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
4  *
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.
8  *
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
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  *
19  ******************************************************************************/
20 #ifndef __DRV_TYPES_PCI_H__
21 #define __DRV_TYPES_PCI_H__
22
23
24 #ifdef PLATFORM_LINUX
25         #include <linux/pci.h>
26 #endif
27
28
29 #define INTEL_VENDOR_ID                         0x8086
30 #define SIS_VENDOR_ID                                   0x1039
31 #define ATI_VENDOR_ID                                   0x1002
32 #define ATI_DEVICE_ID                                   0x7914
33 #define AMD_VENDOR_ID                                   0x1022
34
35 #define PCI_MAX_BRIDGE_NUMBER                   255
36 #define PCI_MAX_DEVICES                         32
37 #define PCI_MAX_FUNCTION                                8
38
39 #define PCI_CONF_ADDRESS                                0x0CF8   /* PCI Configuration Space Address */
40 #define PCI_CONF_DATA                                   0x0CFC   /* PCI Configuration Space Data */
41
42 #define PCI_CLASS_BRIDGE_DEV                    0x06
43 #define PCI_SUBCLASS_BR_PCI_TO_PCI      0x04
44
45 #define PCI_CAPABILITY_ID_PCI_EXPRESS   0x10
46
47 #define U1DONTCARE                                      0xFF
48 #define U2DONTCARE                                      0xFFFF
49 #define U4DONTCARE                                      0xFFFFFFFF
50
51 #define PCI_VENDER_ID_REALTEK           0x10ec
52
53 #define HAL_HW_PCI_8180_DEVICE_ID       0x8180
54 #define HAL_HW_PCI_8185_DEVICE_ID               0x8185  /* 8185 or 8185b */
55 #define HAL_HW_PCI_8188_DEVICE_ID               0x8188  /* 8185b                 */
56 #define HAL_HW_PCI_8198_DEVICE_ID               0x8198  /* 8185b                 */
57 #define HAL_HW_PCI_8190_DEVICE_ID               0x8190  /* 8190 */
58 #define HAL_HW_PCI_8723E_DEVICE_ID              0x8723  /* 8723E */
59 #define HAL_HW_PCI_8192_DEVICE_ID               0x8192  /* 8192 PCI-E */
60 #define HAL_HW_PCI_8192SE_DEVICE_ID             0x8192  /* 8192 SE */
61 #define HAL_HW_PCI_8174_DEVICE_ID               0x8174  /* 8192 SE */
62 #define HAL_HW_PCI_8173_DEVICE_ID               0x8173  /* 8191 SE Crab */
63 #define HAL_HW_PCI_8172_DEVICE_ID               0x8172  /* 8191 SE RE */
64 #define HAL_HW_PCI_8171_DEVICE_ID               0x8171  /* 8191 SE Unicron */
65 #define HAL_HW_PCI_0045_DEVICE_ID                       0x0045  /* 8190 PCI for Ceraga */
66 #define HAL_HW_PCI_0046_DEVICE_ID                       0x0046  /* 8190 Cardbus for Ceraga */
67 #define HAL_HW_PCI_0044_DEVICE_ID                       0x0044  /* 8192e PCIE for Ceraga */
68 #define HAL_HW_PCI_0047_DEVICE_ID                       0x0047  /* 8192e Express Card for Ceraga */
69 #define HAL_HW_PCI_700F_DEVICE_ID                       0x700F
70 #define HAL_HW_PCI_701F_DEVICE_ID                       0x701F
71 #define HAL_HW_PCI_DLINK_DEVICE_ID              0x3304
72 #define HAL_HW_PCI_8188EE_DEVICE_ID             0x8179
73
74 #define HAL_MEMORY_MAPPED_IO_RANGE_8190PCI              0x1000     /* 8190 support 16 pages of IO registers */
75 #define HAL_HW_PCI_REVISION_ID_8190PCI                  0x00
76 #define HAL_MEMORY_MAPPED_IO_RANGE_8192PCIE     0x4000  /* 8192 support 16 pages of IO registers */
77 #define HAL_HW_PCI_REVISION_ID_8192PCIE                 0x01
78 #define HAL_MEMORY_MAPPED_IO_RANGE_8192SE               0x4000  /* 8192 support 16 pages of IO registers */
79 #define HAL_HW_PCI_REVISION_ID_8192SE                   0x10
80 #define HAL_HW_PCI_REVISION_ID_8192CE                   0x1
81 #define HAL_MEMORY_MAPPED_IO_RANGE_8192CE               0x4000  /* 8192 support 16 pages of IO registers */
82 #define HAL_HW_PCI_REVISION_ID_8192DE                   0x0
83 #define HAL_MEMORY_MAPPED_IO_RANGE_8192DE               0x4000  /* 8192 support 16 pages of IO registers */
84
85 enum pci_bridge_vendor {
86         PCI_BRIDGE_VENDOR_INTEL = 0x0,/* 0b'0000,0001 */
87         PCI_BRIDGE_VENDOR_ATI, /* = 0x02, */ /* 0b'0000,0010 */
88         PCI_BRIDGE_VENDOR_AMD, /* = 0x04, */ /* 0b'0000,0100 */
89         PCI_BRIDGE_VENDOR_SIS ,/* = 0x08, */ /* 0b'0000,1000 */
90         PCI_BRIDGE_VENDOR_UNKNOWN, /* = 0x40, */ /* 0b'0100,0000 */
91         PCI_BRIDGE_VENDOR_MAX ,/* = 0x80 */
92 } ;
93
94 /* copy this data structor defination from MSDN SDK */
95 typedef struct _PCI_COMMON_CONFIG {
96         u16     VendorID;
97         u16     DeviceID;
98         u16     Command;
99         u16     Status;
100         u8      RevisionID;
101         u8      ProgIf;
102         u8      SubClass;
103         u8      BaseClass;
104         u8      CacheLineSize;
105         u8      LatencyTimer;
106         u8      HeaderType;
107         u8      BIST;
108
109         union {
110                 struct _PCI_HEADER_TYPE_0 {
111                         u32     BaseAddresses[6];
112                         u32     CIS;
113                         u16     SubVendorID;
114                         u16     SubSystemID;
115                         u32     ROMBaseAddress;
116                         u8      CapabilitiesPtr;
117                         u8      Reserved1[3];
118                         u32     Reserved2;
119
120                         u8      InterruptLine;
121                         u8      InterruptPin;
122                         u8      MinimumGrant;
123                         u8      MaximumLatency;
124                 } type0;
125 #if 0
126                 struct _PCI_HEADER_TYPE_1 {
127                         ULONG BaseAddresses[PCI_TYPE1_ADDRESSES];
128                         UCHAR PrimaryBusNumber;
129                         UCHAR SecondaryBusNumber;
130                         UCHAR SubordinateBusNumber;
131                         UCHAR SecondaryLatencyTimer;
132                         UCHAR IOBase;
133                         UCHAR IOLimit;
134                         USHORT SecondaryStatus;
135                         USHORT MemoryBase;
136                         USHORT MemoryLimit;
137                         USHORT PrefetchableMemoryBase;
138                         USHORT PrefetchableMemoryLimit;
139                         ULONG PrefetchableMemoryBaseUpper32;
140                         ULONG PrefetchableMemoryLimitUpper32;
141                         USHORT IOBaseUpper;
142                         USHORT IOLimitUpper;
143                         ULONG Reserved2;
144                         ULONG ExpansionROMBase;
145                         UCHAR InterruptLine;
146                         UCHAR InterruptPin;
147                         USHORT BridgeControl;
148                 } type1;
149
150                 struct _PCI_HEADER_TYPE_2 {
151                         ULONG BaseAddress;
152                         UCHAR CapabilitiesPtr;
153                         UCHAR Reserved2;
154                         USHORT SecondaryStatus;
155                         UCHAR PrimaryBusNumber;
156                         UCHAR CardbusBusNumber;
157                         UCHAR SubordinateBusNumber;
158                         UCHAR CardbusLatencyTimer;
159                         ULONG MemoryBase0;
160                         ULONG MemoryLimit0;
161                         ULONG MemoryBase1;
162                         ULONG MemoryLimit1;
163                         USHORT IOBase0_LO;
164                         USHORT IOBase0_HI;
165                         USHORT IOLimit0_LO;
166                         USHORT IOLimit0_HI;
167                         USHORT IOBase1_LO;
168                         USHORT IOBase1_HI;
169                         USHORT IOLimit1_LO;
170                         USHORT IOLimit1_HI;
171                         UCHAR InterruptLine;
172                         UCHAR InterruptPin;
173                         USHORT BridgeControl;
174                         USHORT SubVendorID;
175                         USHORT SubSystemID;
176                         ULONG LegacyBaseAddress;
177                         UCHAR Reserved3[56];
178                         ULONG SystemControl;
179                         UCHAR MultiMediaControl;
180                         UCHAR GeneralStatus;
181                         UCHAR Reserved4[2];
182                         UCHAR GPIO0Control;
183                         UCHAR GPIO1Control;
184                         UCHAR GPIO2Control;
185                         UCHAR GPIO3Control;
186                         ULONG IRQMuxRouting;
187                         UCHAR RetryStatus;
188                         UCHAR CardControl;
189                         UCHAR DeviceControl;
190                         UCHAR Diagnostic;
191                 } type2;
192 #endif
193         } u;
194
195         u8      DeviceSpecific[108];
196 } PCI_COMMON_CONFIG , *PPCI_COMMON_CONFIG;
197
198 typedef struct _RT_PCI_CAPABILITIES_HEADER {
199         u8   CapabilityID;
200         u8   Next;
201 } RT_PCI_CAPABILITIES_HEADER, *PRT_PCI_CAPABILITIES_HEADER;
202
203 struct pci_priv {
204         BOOLEAN         pci_clk_req;
205
206         u8      pciehdr_offset;
207         /* PCIeCap is only differece between B-cut and C-cut. */
208         /* Configuration Space offset 72[7:4] */
209         /* 0: A/B cut */
210         /* 1: C cut and later. */
211         u8      pcie_cap;
212         u8      linkctrl_reg;
213
214         u8      busnumber;
215         u8      devnumber;
216         u8      funcnumber;
217
218         u8      pcibridge_busnum;
219         u8      pcibridge_devnum;
220         u8      pcibridge_funcnum;
221         u8      pcibridge_vendor;
222         u16     pcibridge_vendorid;
223         u16     pcibridge_deviceid;
224         u8      pcibridge_pciehdr_offset;
225         u8      pcibridge_linkctrlreg;
226
227         u8      amd_l1_patch;
228 };
229
230 typedef struct _RT_ISR_CONTENT {
231         union {
232                 u32                     IntArray[2];
233                 u32                     IntReg4Byte;
234                 u16                     IntReg2Byte;
235         };
236 } RT_ISR_CONTENT, *PRT_ISR_CONTENT;
237
238 /* #define RegAddr(addr)           (addr + 0xB2000000UL) */
239 /* some platform macros will def here */
240 static inline void NdisRawWritePortUlong(u32 port,  u32 val)
241 {
242         outl(val, port);
243         /* writel(val, (u8 *)RegAddr(port));     */
244 }
245
246 static inline void NdisRawWritePortUchar(u32 port,  u8 val)
247 {
248         outb(val, port);
249         /* writeb(val, (u8 *)RegAddr(port)); */
250 }
251
252 static inline void NdisRawReadPortUchar(u32 port, u8 *pval)
253 {
254         *pval = inb(port);
255         /* *pval = readb((u8 *)RegAddr(port)); */
256 }
257
258 static inline void NdisRawReadPortUshort(u32 port, u16 *pval)
259 {
260         *pval = inw(port);
261         /* *pval = readw((u8 *)RegAddr(port)); */
262 }
263
264 static inline void NdisRawReadPortUlong(u32 port, u32 *pval)
265 {
266         *pval = inl(port);
267         /* *pval = readl((u8 *)RegAddr(port)); */
268 }
269
270
271 #endif