drv_types_pci.h 7.6 KB

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