ixp425Pci.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:9k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* ixp425Pci.h - public header file for the ixp425 PCI unit driver */
  2. /* Copyright 2002 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01a,05jun02,jb  initial version...
  7. */
  8. /*
  9. DESCRIPTION
  10. This header defines the IXP425 PCI driver interface that is made
  11. available for use by clients such as PCI device drivers.
  12. */
  13. #ifndef IXP425PCI_H
  14. #define IXP425PCI_H
  15. #include "ixp425.h" /*BSP defines*/
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. /*these specify the start PCI bus addresses for 
  20.   memory and IO BARs, note these are addresses
  21.   on the PCI bus, not ahb bus*/
  22. #define IXP425_PCI_BAR_MEM_BASE 0x100000
  23. #define IXP425_PCI_BAR_IO_BASE  0x000000
  24. /* These specify the range of AHB physical addresses
  25.    that get translated into PCI addresses*/
  26.    
  27. #define IXP425_PHYS_PCI_MEM_BASE IXP425_PCI_BASE
  28. #define IXP425_PHYS_PCI_IO_BASE  IXP425_PCI_BASE
  29. #define IXP425_PHYS_PCI_MEM_TOP  (IXP425_PCI_BASE + IXP425_PCI_SP_SIZE)
  30. /*defines required by vxWorks*/
  31. #define PCI_CLINE_SZ  0x0
  32. #define PCI_LAT_TIMER 0x0
  33. /*defines required by End driver*/
  34. #define PCI_IO_ADR0   0x0000000
  35. #define PCI_MEM_ADR0  0x0000000
  36. #define PCI_INT_LVL0  7
  37. #define PCI_INT_VEC0  7
  38. #define PCI_IO_ADR1   0x0000000
  39. #define PCI_MEM_ADR1  0x0000000
  40. #define PCI_INT_LVL1  7
  41. #define PCI_INT_VEC1  7
  42. #define PCI_IO_ADR2   0x0000000
  43. #define PCI_MEM_ADR2  0x0000000
  44. #define PCI_INT_LVL2  7
  45. #define PCI_INT_VEC2  7
  46. #define PCI_IO_ADR3   0x0000000
  47. #define PCI_MEM_ADR3  0x0000000
  48. #define PCI_INT_LVL3  7
  49. #define PCI_INT_VEC3  7
  50. #define CPU_PCI_MEM_ADRS IXP425_PHYS_PCI_MEM_BASE
  51. #define CPU_PCI_IO_ADRS  IXP425_PHYS_PCI_IO_BASE 
  52. /*define the sub vendor and subsystem to be used */
  53. #define IXP425_PCI_SUB_VENDOR_SYSTEM 0x00000000
  54. /* the simple mapping scheme sets up a flat translation whereby the bottom
  55.    64MB of SDRAM maps is accessible on the PCI bus as the bottom
  56.    64MB of PCI address space. This scheme only works for boards with 64 MB of
  57.    SDRAM or less, and should not be used under normal circumstances.*/
  58. #undef IXP425_PCI_SIMPLE_MAPPING 
  59. /*define the default settings for the controller's BARs*/
  60. #ifdef IXP425_PCI_SIMPLE_MAPPING
  61. #define IXP425_PCI_BAR_0_DEFAULT 0x00000000
  62. #define IXP425_PCI_BAR_1_DEFAULT 0x01000000
  63. #define IXP425_PCI_BAR_2_DEFAULT 0x02000000
  64. #define IXP425_PCI_BAR_3_DEFAULT 0x03000000
  65. #define IXP425_PCI_BAR_4_DEFAULT 0x00000000
  66. #define IXP425_PCI_BAR_5_DEFAULT 0x00000000
  67. #else
  68. #define IXP425_PCI_BAR_0_DEFAULT 0x40000000
  69. #define IXP425_PCI_BAR_1_DEFAULT 0x41000000
  70. #define IXP425_PCI_BAR_2_DEFAULT 0x42000000
  71. #define IXP425_PCI_BAR_3_DEFAULT 0x43000000
  72. #define IXP425_PCI_BAR_4_DEFAULT 0x00000000
  73. #define IXP425_PCI_BAR_5_DEFAULT 0x00000000
  74. #endif
  75. /*define the default setting of the AHB memory base reg*/
  76. #define IXP425_PCI_AHBMEMBASE_DEFAULT 0x00010203
  77. #define IXP425_PCI_AHBIOBASE_DEFAULT  0x0
  78. #define IXP425_PCI_PCIMEMBASE_DEFAULT 0x0
  79. #define IXP425_PCI_INTERNAL_INT_VEC 8
  80. /*define the GPIO pins used for the 4 PCI interrupts*/
  81. #define IXP425_PCI_INTA_PIN IXP425_GPIO_PIN_1
  82. /*#define IXP425_PCI_INTB_PIN IXP425_GPIO_PIN_10
  83. #define IXP425_PCI_INTC_PIN IXP425_GPIO_PIN_9
  84. #define IXP425_PCI_INTD_PIN IXP425_GPIO_PIN_8*/
  85. /*define the interrupt vector numbers used for the 4 PCI interrupts*/
  86. #define IXP425_PCI_INTA_INTERRUPT_NUM PCI_INT_LVL0
  87. #define IXP425_PCI_INTB_INTERRUPT_NUM PCI_INT_LVL1
  88. #define IXP425_PCI_INTC_INTERRUPT_NUM PCI_INT_LVL2
  89. #define IXP425_PCI_INTD_INTERRUPT_NUM PCI_INT_LVL3
  90. /*define the index into the interrupt routine linked list for
  91.   each PCI interrupt*/
  92. #define IXP425_PCI_INTA_INDEX 0
  93. #define IXP425_PCI_INTB_INDEX 1
  94. #define IXP425_PCI_INTC_INDEX 2
  95. #define IXP425_PCI_INTD_INDEX 3
  96. /*define the maximum number of bus segments - we support a single segment*/
  97. #define IXP425_PCI_MAX_BUS  1
  98. /*define the maximum number of cards per bus segment*/
  99. #define IXP425_PCI_MAX_DEV  4
  100. /*define the maximum number of functions per device*/
  101. #define IXP425_PCI_MAX_FUNC 8
  102. /* define the maximum number of separate functions that we can 
  103.    potentially have on the bus*/
  104. #define IXP425_PCI_MAX_FUNC_ON_BUS (1+ IXP425_PCI_MAX_FUNC *         
  105.                                     IXP425_PCI_MAX_DEV *          
  106.                                     IXP425_PCI_MAX_BUS)
  107. /*define the maximum number of BARs per function*/
  108. #define IXP425_PCI_MAX_BAR_PER_FUNC  6
  109. #define IXP425_PCI_MAX_BAR (IXP425_PCI_MAX_BAR_PER_FUNC * 
  110.                             IXP425_PCI_MAX_FUNC_ON_BUS)
  111. #define IXP425_PCI_DMA_DIR_IN  0
  112. #define IXP425_PCI_DMA_DIR_OUT 1
  113. /*Hardware configuration defines - these parameters are used to specify
  114.   the particular h/w configuration of the board with regard to PCI*/
  115. #define IXP425_PCI_CLK_PIN   IXP425_GPIO_CLK_0
  116. /*define whether or not we are to drive the clock through a 
  117.   GPIO pin when in host mode*/
  118. #define IXP425_PCI_GPIO_CLOCK_ON
  119. /*#undef IXP425_PCI_GPIO_CLOCK_ON*/
  120. /*define the GPIO pin used to supply the PCI reset signal*/
  121. #define IXP425_PCI_RESET_GPIO IXP425_GPIO_PIN_0
  122. /*Mode selection defines*/
  123. /*define whether byte lane routing between the Little endian PCI bus
  124.   and big endian AHB bus is performed automatically by the PCC*/
  125. #define IXP425_PCI_ENABLE_BYTE_ROUTING
  126. typedef enum
  127. {
  128.     PciClock33 = 0 
  129. } PciClockRate;
  130. enum PciBarId 
  131. {
  132.     CSR_BAR=0, 
  133.     IO_BAR, 
  134.     SD_BAR, 
  135.     NO_BAR
  136. };
  137. /*Base address register descriptor*/
  138. typedef struct 
  139. {
  140.     UINT32 size;
  141.     UINT32 address;
  142. } PciBar;
  143. typedef struct 
  144. {
  145.     UINT32 bus;
  146.     UINT32 device;
  147.     UINT32 func;
  148.     UINT32 irq;
  149.     BOOL error;
  150.     UINT16 vendor_id;
  151.     UINT16 device_id;
  152.     /*We need an extra entry in this array for dummy placeholder*/
  153.     PciBar bar[IXP425_PCI_MAX_BAR_PER_FUNC + 1];
  154. } PciDevice;
  155. typedef enum 
  156. {
  157.     PCI_OK = 0, 
  158.     PCI_ERR_PSE,  /*System Error*/
  159.     PCI_ERR_PFE,  /*Fatal Error*/
  160.     PCI_ERR_PPE,  /*Parity Error*/
  161.     PCI_ERR_AHBE, /*AHB Error*/
  162.     PCI_APDC,     /*ATP DMA transfer complete*/
  163.     PCI_PADC,     /*PTA DMA transfer complete*/
  164.     PCI_ERROR     /*General error*/
  165. }PciStatus;
  166. typedef void (*PCICALLBACKFUNC)(PciStatus status, UINT32 parameter);
  167. #if defined(__STDC__) || defined(__cplusplus)
  168. STATUS pciIomapLibInit (UINT32 mechanism, UINT32 addr0, UINT32 addr1, UINT32 addr2);
  169. STATUS pciFindDevice (UINT32 vendorId, UINT32 deviceId, UINT32 index,
  170.  UINT32 *pBusNo, UINT32 *pDeviceNo, UINT32 *pFuncNo);
  171. STATUS pciFindClass (UINT32 classCode, UINT32 index,
  172.  UINT32 *pBusNo, UINT32 *pDeviceNo, UINT32 *pFuncNo);
  173. STATUS pciConfigInByte (UINT32 busNo, UINT32 deviceNo, UINT32 funcNo, UINT32 address,
  174.  UINT8 *pData);
  175. STATUS pciConfigInWord (UINT32 busNo, UINT32 deviceNo, UINT32 funcNo, UINT32 address,
  176.  UINT16 *pData);
  177. STATUS pciConfigInLong (UINT32 busNo, UINT32 deviceNo, UINT32 funcNo, UINT32 address,
  178.  UINT32 *pData);
  179. STATUS pciConfigOutByte (UINT32 busNo, UINT32 deviceNo, UINT32 funcNo, UINT32 address,
  180.  UINT8 data);
  181. STATUS pciConfigOutWord (UINT32 busNo, UINT32 deviceNo, UINT32 funcNo, UINT32 address, 
  182.  UINT16 data);
  183. STATUS pciConfigOutLong (UINT32 busNo, UINT32 deviceNo, UINT32 funcNo, UINT32 address,
  184.  UINT32 data);
  185. STATUS pciIOInByte (void *pciAddr, UINT8 *data); 
  186. STATUS pciIOInWord (void *pciAddr, UINT16 *data); 
  187. STATUS pciIOInLong (void *pciAddr, UINT32 *data); 
  188. STATUS pciIOOutByte (void *pciAddr, UINT8 data); 
  189. STATUS pciIOOutWord (void *pciAddr, UINT16 data); 
  190. STATUS pciIOOutLong (void *pciAddr, UINT32 data); 
  191. STATUS pciMemInByte     (void *pciAddr, UINT8 *data); 
  192. STATUS pciMemInWord (void *pciAddr, UINT16 *data); 
  193. STATUS pciMemInLong (void *pciAddr, UINT32 *data); 
  194. STATUS pciMemOutByte (void *pciAddr, UINT8 data); 
  195. STATUS pciMemOutWord (void *pciAddr, UINT16 data); 
  196. STATUS pciMemOutLong (void *pciAddr, UINT32 data); 
  197. STATUS pciSpecialCycle (UINT32 busNo, UINT32 message);
  198. STATUS pciDeviceShow (UINT32 busNo);
  199. STATUS pciHeaderShow (UINT32 busNo, UINT32 deviceNo, UINT32 funcNo);
  200. STATUS pciFindClassShow (UINT32 classCode, UINT32 index);
  201. void   pciAddrShow      (void);
  202. STATUS pciIntConnect (VOIDFUNCPTR *vector, VOIDFUNCPTR routine,
  203.  UINT32 parameter);
  204. STATUS pciIntDisconnect (VOIDFUNCPTR *vector, VOIDFUNCPTR routine);
  205. PciDevice *pciInfoGet    (UINT16 device);
  206. PciDevice *pciInfoSearch (UINT32 bus, UINT32 device, UINT32 func, UINT32 count);
  207. PciDevice *pciDeviceGet  (UINT32 vendor_id, UINT32 device_id, UINT32 count);
  208. void sysPciInit        (void);
  209. void sysPciAssignAddrs (void);
  210. void *sysPciToPhys     (void *pciAddr);
  211. void *sysPhysToPci     (void *phyAddr);
  212. STATUS pciErrorCallbackRegister (PCICALLBACKFUNC routine);
  213. STATUS sysPciMappingAdd (UINT32 addr, UINT32 size);
  214. #else /* __STDC__ */
  215. STATUS pciIomapLibInit ();
  216. STATUS pciFindDevice ();
  217. STATUS pciFindClass ();
  218. STATUS pciConfigInByte ();
  219. STATUS pciConfigInWord ();
  220. STATUS pciConfigInLong ();
  221. STATUS pciConfigOutByte ();
  222. STATUS pciConfigOutWord ();
  223. STATUS pciConfigOutLong ();
  224. STATUS pciSpecialCycle ();
  225. STATUS pciIOInByte ();
  226. STATUS pciIOInWord ();
  227. STATUS pciIOInLong ();
  228. STATUS pciIOOutByte ();
  229. STATUS pciIOOutWord ();
  230. STATUS pciIOOutLong ();
  231. STATUS pciMemInByte ();
  232. STATUS pciMemInWord ();
  233. STATUS pciMemInLong ();
  234. STATUS pciMemOutByte ();
  235. STATUS pciMemOutWord ();
  236. STATUS pciMemOutLong ();
  237. STATUS pciDeviceShow ();
  238. STATUS pciHeaderShow ();
  239. STATUS pciFindClassShow ();
  240. void   pciAddrShow      ();
  241. STATUS pciIntConnect ();
  242. STATUS pciIntDisconnect ();
  243. PciDevice *pciInfoGet    ();
  244. PciDevice *pciInfoSearch ();
  245. PciDevice *pciDeviceGet  ();
  246. void sysPciInit        ();
  247. void sysPciAssignAddrs ();
  248. void *sysPciToPhys     ();
  249. void *sysPhysToPci     ();
  250. STATUS pciErrorCallbackRegister ();
  251. STATUS sysPciMappingAdd ();
  252. #endif /* __STDC__ */
  253. #ifdef __cplusplus
  254. }
  255. #endif
  256. #endif /* IXP425PCI_H */