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

VxWorks

开发平台:

C/C++

  1. /* ixp425Pci_p.h - private 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. #ifndef IXP425PCI_P_H
  9. #define IXP425PCI_P_H
  10. #include "dllLib.h"
  11. #include "ixp425Pci.h"
  12. #ifndef BIT
  13. #define BIT(x) (1<<(x))
  14. #endif
  15. /* Mask definitions*/
  16. #define IXP425_PCI_TOP_WORD_OF_LONG_MASK        0xffff0000
  17. #define IXP425_PCI_TOP_BYTE_OF_LONG_MASK        0xff000000
  18. #define IXP425_PCI_BOTTOM_WORD_OF_LONG_MASK     0x0000ffff
  19. #define IXP425_PCI_BOTTOM_TRIBYTES_OF_LONG_MASK 0x00ffffff
  20. #define IXP425_PCI_BOTTOM_NIBBLE_OF_LONG_MASK   0x0000000f
  21. #define IXP425_PCI_MAX_UINT32                   0xffffffff
  22. #define IXP425_PCI_BAR_QUERY                    0xffffffff
  23. /* PCI command bits */
  24. #define PCI_CMD_IO_ENABLE 0x0001 /* IO access enable */
  25. #define PCI_CMD_MEM_ENABLE 0x0002 /* memory access enable */
  26. #define PCI_CMD_MASTER_ENABLE 0x0004 /* bus master enable */
  27. #define PCI_CMD_MON_ENABLE 0x0008 /* monitor special cycles enable */
  28. #define PCI_CMD_WI_ENABLE 0x0010 /* write and invalidate enable */
  29. #define PCI_CMD_SNOOP_ENABLE 0x0020 /* palette snoop enable */
  30. #define PCI_CMD_PERR_ENABLE 0x0040 /* parity error enable */
  31. #define PCI_CMD_WC_ENABLE 0x0080 /* wait cycle enable */
  32. #define PCI_CMD_SERR_ENABLE 0x0100 /* system error enable */
  33. #define PCI_CMD_FBTB_ENABLE 0x0200 /* fast back to back enable */
  34. /* PCI base address mask bits */
  35. #define PCI_PCIADDR_MASK 0x00ffffff
  36. #define PCI_MEMBASE_MASK ~0xf /* mask for memory base address */
  37. #define PCI_IOBASE_MASK ~0x3 /* mask for IO base address */
  38. #define PCI_BASE_IO 0x1 /* IO space indicator */
  39. #define PCI_BASE_BELOW_1M 0x2 /* memory locate below 1MB */
  40. #define PCI_BASE_IN_64BITS 0x4 /* memory locate anywhere in 64 bits */
  41. #define PCI_BASE_PREFETCH 0x8 /* memory prefetchable */
  42. /* PCI header type bits */
  43. #define PCI_HEADER_TYPE_MASK 0x7f /* mask for header type */
  44. #define PCI_HEADER_PCI_PCI 0x01 /* PCI to PCI bridge */
  45. #define PCI_HEADER_MULTI_FUNC 0x80 /* multi function device */
  46. /*PCI configuration regs.*/
  47. #define PCI_CFG_VENDOR_ID 0x00
  48. #define PCI_CFG_DEVICE_ID 0x02
  49. #define PCI_CFG_COMMAND 0x04
  50. #define PCI_CFG_STATUS 0x06
  51. #define PCI_CFG_REVISION 0x08
  52. #define PCI_CFG_PROGRAMMING_IF 0x09
  53. #define PCI_CFG_SUBCLASS 0x0a
  54. #define PCI_CFG_CLASS 0x0b
  55. #define PCI_CFG_CACHE_LINE_SIZE 0x0c
  56. #define PCI_CFG_LATENCY_TIMER 0x0d
  57. #define PCI_CFG_HEADER_TYPE 0x0e
  58. #define PCI_CFG_BIST 0x0f
  59. #define PCI_CFG_BASE_ADDRESS_0 0x10
  60. #define PCI_CFG_BASE_ADDRESS_1 0x14
  61. #define PCI_CFG_BASE_ADDRESS_2 0x18
  62. #define PCI_CFG_BASE_ADDRESS_3 0x1c
  63. #define PCI_CFG_BASE_ADDRESS_4 0x20
  64. #define PCI_CFG_BASE_ADDRESS_5 0x24
  65. #define PCI_CFG_CIS 0x28
  66. #define PCI_CFG_SUB_VENDOR_ID 0x2c
  67. #define PCI_CFG_SUB_SYSTEM_ID 0x2e
  68. #define PCI_CFG_EXPANSION_ROM 0x30
  69. #define PCI_CFG_RESERVED_0 0x34
  70. #define PCI_CFG_RESERVED_1 0x38
  71. #define PCI_CFG_DEV_INT_LINE 0x3c
  72. #define PCI_CFG_DEV_INT_PIN 0x3d
  73. #define PCI_CFG_MIN_GRANT 0x3e
  74. #define PCI_CFG_MAX_LATENCY 0x3f
  75. #define PCI_CFG_SPECIAL_USE     0x41
  76. #define PCI_CFG_MODE            0x43
  77. /*Configuration command bit definitions*/
  78. #define PCI_CFG_CMD_IOAE BIT(0) 
  79. #define PCI_CFG_CMD_MAE  BIT(1)
  80. #define PCI_CFG_CMD_BME  BIT(2)
  81. #define PCI_CFG_CMD_MWIE BIT(4)
  82. #define PCI_CFG_CMD_SER  BIT(8)
  83. #define PCI_CFG_CMD_FBBE BIT(9)
  84. #define PCI_CFG_CMD_MDPE BIT(24)
  85. #define PCI_CFG_CMD_STA  BIT(27)
  86. #define PCI_CFG_CMD_RTA  BIT(28)
  87. #define PCI_CFG_CMD_RMA  BIT(29)
  88. #define PCI_CFG_CMD_SSE  BIT(30)
  89. #define PCI_CFG_CMD_DPE  BIT(31)
  90. /* PCI-to-PCI bridge configuration register offsets */
  91. /* Note that only modulo-4 addresses are written to the address register */
  92. #define PCI_CFG_PRIMARY_BUS 0x18
  93. #define PCI_CFG_SECONDARY_BUS 0x19
  94. #define PCI_CFG_SUBORDINATE_BUS 0x1a
  95. #define PCI_CFG_SEC_LATENCY 0x1b
  96. #define PCI_CFG_IO_BASE 0x1c
  97. #define PCI_CFG_IO_LIMIT 0x1d
  98. #define PCI_CFG_SEC_STATUS 0x1e
  99. #define PCI_CFG_MEM_BASE 0x20
  100. #define PCI_CFG_MEM_LIMIT 0x22
  101. #define PCI_CFG_PRE_MEM_BASE 0x24
  102. #define PCI_CFG_PRE_MEM_LIMIT 0x26
  103. #define PCI_CFG_PRE_MEM_BASE_U 0x28
  104. #define PCI_CFG_PRE_MEM_LIMIT_U 0x2c
  105. #define PCI_CFG_IO_BASE_U 0x30
  106. #define PCI_CFG_IO_LIMIT_U 0x32
  107. #define PCI_CFG_ROM_BASE 0x38
  108. #define PCI_CFG_BRG_INT_LINE 0x3c
  109. #define PCI_CFG_BRG_INT_PIN 0x3d
  110. #define PCI_CFG_BRIDGE_CONTROL 0x3e
  111. /*Register addressing definitions for PCI controller configuration
  112.   and status registers*/
  113. #define PCI_CSR_BASE (0xC0000000)
  114. #define PCI_NP_AD_OFFSET       (0x00)
  115. #define PCI_NP_CBE_OFFSET      (0x04)
  116. #define PCI_NP_WDATA_OFFSET    (0x08)
  117. #define PCI_NP_RDATA_OFFSET    (0x0C)
  118. #define PCI_CRP_OFFSET         (0x10)
  119. #define PCI_CRP_WDATA_OFFSET   (0x14)
  120. #define PCI_CRP_RDATA_OFFSET   (0x18)
  121. #define PCI_CSR_OFFSET         (0x1C)
  122. #define PCI_ISR_OFFSET         (0x20)
  123. #define PCI_INTEN_OFFSET       (0x24)
  124. #define PCI_DMACTRL_OFFSET     (0x28)
  125. #define PCI_AHBMEMBASE_OFFSET  (0x2C)
  126. #define PCI_AHBIOBASE_OFFSET   (0x30)
  127. #define PCI_PCIMEMBASE_OFFSET  (0x34)
  128. #define PCI_AHBDOORBELL_OFFSET (0x38)
  129. #define PCI_PCIDOORBELL_OFFSET (0x3C)
  130. #define PCI_ATPDMA0_AHBADDR    (0x40)
  131. #define PCI_ATPDMA0_PCIADDR    (0x44)
  132. #define PCI_ATPDMA0_LENADDR    (0x48)
  133. #define PCI_ATPDMA1_AHBADDR    (0x4C)
  134. #define PCI_ATPDMA1_PCIADDR    (0x50)
  135. #define PCI_ATPDMA1_LENADDR    (0x54)
  136. #define PCI_PTADMA0_AHBADDR    (0x58)
  137. #define PCI_PTADMA0_PCIADDR    (0x5C)
  138. #define PCI_PTADMA0_LENADDR    (0x60)
  139. #define PCI_PTADMA1_AHBADDR    (0x64)
  140. #define PCI_PTADMA1_PCIADDR    (0x68)
  141. #define PCI_PTADMA1_LENADDR    (0x6C)
  142. /*Non prefetch registers bit definitions*/
  143. #define NP_CMD_INTACK      (0x0)
  144. #define NP_CMD_SPECIAL     (0x1)
  145. #define NP_CMD_IOREAD      (0x2)
  146. #define NP_CMD_IOWRITE     (0x3)
  147. #define NP_CMD_MEMREAD     (0x6)
  148. #define NP_CMD_MEMWRITE    (0x7)
  149. #define NP_CMD_CONFIGREAD  (0xa)
  150. #define NP_CMD_CONFIGWRITE (0xb)
  151. #define PCI_NP_CBE_BESL  (4)
  152. #define PCI_NP_AD_FUNCSL (8)
  153. /*Configuration Port register bit definitions*/
  154. #define PCI_CRP_WRITE BIT(16)
  155. /*CSR Register bit definitions*/
  156. #define PCI_CSR_HOST  BIT(0)
  157. #define PCI_CSR_ARBEN BIT(1)
  158. #define PCI_CSR_ADS   BIT(2)
  159. #define PCI_CSR_PDS   BIT(3)
  160. #define PCI_CSR_ABE   BIT(4)
  161. #define PCI_CSR_DBT   BIT(5)
  162. #define PCI_CSR_ASE   BIT(8)
  163. #define PCI_CSR_IC    BIT(15)
  164. /*ISR (Interrupt status) Register bit definitions*/
  165. #define PCI_ISR_PSE   BIT(0)
  166. #define PCI_ISR_PFE   BIT(1)
  167. #define PCI_ISR_PPE   BIT(2)
  168. #define PCI_ISR_AHBE  BIT(3)
  169. #define PCI_ISR_APDC  BIT(4)
  170. #define PCI_ISR_PADC  BIT(5)
  171. #define PCI_ISR_ADB   BIT(6)
  172. #define PCI_ISR_PDB   BIT(7)
  173. /*INTEN (Interrupt Enable) Register bit definitions*/
  174. #define PCI_INTEN_PSE   BIT(0)
  175. #define PCI_INTEN_PFE   BIT(1)
  176. #define PCI_INTEN_PPE   BIT(2)
  177. #define PCI_INTEN_AHBE  BIT(3)
  178. #define PCI_INTEN_APDC  BIT(4)
  179. #define PCI_INTEN_PADC  BIT(5)
  180. #define PCI_INTEN_ADB   BIT(6)
  181. #define PCI_INTEN_PDB   BIT(7)
  182. /*DMACTRL DMA Control and status Register*/
  183. #define PCI_DMACTRL_APDCEN  BIT(0)
  184. #define PCI_DMACTRL_APDC0   BIT(4)
  185. #define PCI_DMACTRL_APDE0   BIT(5)
  186. #define PCI_DMACTRL_APDC1   BIT(6)
  187. #define PCI_DMACTRL_APDE1   BIT(7)
  188. #define PCI_DMACTRL_PADCEN  BIT(8)
  189. #define PCI_DMACTRL_PADC0   BIT(12)
  190. #define PCI_DMACTRL_PADE0   BIT(13)
  191. #define PCI_DMACTRL_PADC1   BIT(14)
  192. #define PCI_DMACTRL_PADE1   BIT(15)
  193. /*DMA length registers bit definitions - these are common to all
  194.  four DMA length registers*/
  195. #define PCI_DMA_LEN_BE BIT(28)
  196. #define PCI_DMA_LEN_EN BIT(31)
  197. #define IXP425_PCI_DMA_MAX_LEN 0xffff
  198. /* number of IRQs mapped on PCI interrupt */
  199. #define PCI_IRQ_LINES 4
  200. /*Size of DMA request pools*/
  201. #define NUM_REQ_POOL 10
  202. /*Register access macros*/
  203. #ifndef IX_PCI_UNIT_TEST
  204. #define REG_WRITE(b,o,v) (*(volatile UINT32*)((b+o))=(v))
  205. #define REG_READ(b,o,v)  ((v)=(*(volatile UINT32*)((b+o))))
  206. #else
  207. #define REG_WRITE(b,o,v) registerWriteStub(b,o,v)
  208. #define REG_READ(b,o,v)  registerReadStub(b,o,&v)
  209. #endif
  210. /* structure for the device & bridge header */
  211. typedef struct pciHeaderDevice
  212.     {
  213.     UINT16 vendorId; /* vendor ID */
  214.     UINT16 deviceId; /* device ID */
  215.     UINT16 command; /* command register */
  216.     UINT16 status; /* status register */
  217.     UINT8 revisionId; /* revision ID */
  218.     UINT8 classCode; /* class code */
  219.     UINT8 subClass; /* sub class code */
  220.     UINT8 progIf; /* programming interface */
  221.     UINT8 cacheLine; /* cache line */
  222.     UINT8 latency; /* latency time */
  223.     UINT8 headerType; /* header type */
  224.     UINT8 bist; /* BIST */
  225.     UINT32      base0; /* base address 0 */
  226.     UINT32      base1; /* base address 1 */
  227.     UINT32      base2; /* base address 2 */
  228.     UINT32      base3; /* base address 3 */
  229.     UINT32      base4; /* base address 4 */
  230.     UINT32      base5; /* base address 5 */
  231.     UINT32      cis; /* cardBus CIS pointer */
  232.     UINT16      subVendorId; /* sub system vendor ID */
  233.     UINT16      subSystemId; /* sub system ID */
  234.     UINT32      romBase; /* expansion ROM base address */
  235.     UINT32      reserved0; /* reserved */
  236.     UINT32      reserved1; /* reserved */
  237.     UINT8       intLine; /* interrupt line */
  238.     UINT8       intPin; /* interrupt pin */
  239.     UINT8       minGrant; /* min Grant */
  240.     UINT8       maxLatency; /* max Latency */
  241.     } PCI_HEADER_DEVICE;
  242. typedef struct pciHeaderBridge
  243.     {
  244.     UINT16 vendorId; /* vendor ID */
  245.     UINT16 deviceId; /* device ID */
  246.     UINT16 command; /* command register */
  247.     UINT16 status; /* status register */
  248.     UINT8 revisionId; /* revision ID */
  249.     UINT8 classCode; /* class code */
  250.     UINT8 subClass; /* sub class code */
  251.     UINT8 progIf; /* programming interface */
  252.     UINT8 cacheLine; /* cache line */
  253.     UINT8 latency; /* latency time */
  254.     UINT8 headerType; /* header type */
  255.     UINT8 bist; /* BIST */
  256.     UINT32 base0; /* base address 0 */
  257.     UINT32 base1; /* base address 1 */
  258.     UINT8 priBus; /* primary bus number */
  259.     UINT8 secBus; /* secondary bus number */
  260.     UINT8 subBus; /* subordinate bus number */
  261.     UINT8 secLatency; /* secondary latency timer */
  262.     UINT8 ioBase; /* IO base */
  263.     UINT8 ioLimit; /* IO limit */
  264.     UINT16 secStatus; /* secondary status */
  265.     UINT16 memBase; /* memory base */
  266.     UINT16 memLimit; /* memory limit */
  267.     UINT16 preBase; /* prefetchable memory base */
  268.     UINT16 preLimit; /* prefetchable memory limit */
  269.     UINT32      preBaseUpper; /* prefetchable memory base upper 32 bits */
  270.     UINT32 preLimitUpper; /* prefetchable memory base upper 32 bits */
  271.     UINT16 ioBaseUpper; /* IO base upper 16 bits */
  272.     UINT16 ioLimitUpper; /* IO limit upper 16 bits */
  273.     UINT32 reserved; /* reserved */
  274.     UINT32 romBase; /* expansion ROM base address */
  275.     UINT8 intLine; /* interrupt line */
  276.     UINT8 intPin; /* interrupt pin */
  277.     UINT16 control; /* bridge control */
  278.     } PCI_HEADER_BRIDGE;
  279. typedef struct pciIntRtn
  280.     {
  281.     DL_NODE node; /* double link list */
  282.     VOIDFUNCPTR routine; /* interrupt handler */
  283.     UINT32 parameter; /* parameter of the handler */
  284.     } PCI_INT_RTN;
  285. typedef struct pciCallbackIntRtn
  286.     {
  287.     DL_NODE node; /* double link list */
  288.     PCICALLBACKFUNC routine; /* interrupt handler */
  289.     } PCI_CALLBACK_INT_RTN;
  290. #endif /* IXP425PCI_P_H */