drv_types_pci.h 7.4 KB

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