pci.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* PCI.h - PCI functions header file */
  2. /* Copyright - Galileo technology. */
  3. #ifndef __INCpcih
  4. #define __INCpcih
  5. /* includes */
  6. #include "core.h"
  7. #include "memory.h"
  8. /* According to PCI REV 2.1 MAX agents allowed on the bus are -21- */
  9. #define PCI_MAX_DEVICES 22
  10. /* Macros */
  11. #define SELF 32
  12. /* Defines for the access regions. */
  13. #define PREFETCH_ENABLE BIT12
  14. #define PREFETCH_DISABLE NO_BIT
  15. #define DELAYED_READ_ENABLE BIT13
  16. /* #define CACHING_ENABLE BIT14 */
  17. /* aggressive prefetch: PCI slave prefetch two burst in advance*/
  18. #define AGGRESSIVE_PREFETCH BIT16
  19. /* read line aggresive prefetch: PCI slave prefetch two burst in advance*/
  20. #define READ_LINE_AGGRESSIVE_PREFETCH BIT17
  21. /* read multiple aggresive prefetch: PCI slave prefetch two burst in advance*/
  22. #define READ_MULTI_AGGRESSIVE_PREFETCH BIT18
  23. #define MAX_BURST_4 NO_BIT
  24. #define MAX_BURST_8 BIT20 /* Bits[21:20] = 01 */
  25. #define MAX_BURST_16 BIT21 /* Bits[21:20] = 10 */
  26. #define PCI_BYTE_SWAP NO_BIT /* Bits[25:24] = 00 */
  27. #define PCI_NO_SWAP BIT24 /* Bits[25:24] = 01 */
  28. #define PCI_BYTE_AND_WORD_SWAP BIT25 /* Bits[25:24] = 10 */
  29. #define PCI_WORD_SWAP (BIT24 | BIT25) /* Bits[25:24] = 11 */
  30. #define PCI_ACCESS_PROTECT BIT28
  31. #define PCI_WRITE_PROTECT BIT29
  32. /* typedefs */
  33. typedef enum __pciAccessRegions{REGION0,REGION1,REGION2,REGION3,REGION4,REGION5,
  34. REGION6,REGION7} PCI_ACCESS_REGIONS;
  35. typedef enum __pciAgentPrio{LOW_AGENT_PRIO,HI_AGENT_PRIO} PCI_AGENT_PRIO;
  36. typedef enum __pciAgentPark{PARK_ON_AGENT,DONT_PARK_ON_AGENT} PCI_AGENT_PARK;
  37. typedef enum __pciSnoopType{PCI_NO_SNOOP,PCI_SNOOP_WT,PCI_SNOOP_WB}
  38. PCI_SNOOP_TYPE;
  39. typedef enum __pciSnoopRegion{PCI_SNOOP_REGION0,PCI_SNOOP_REGION1,
  40. PCI_SNOOP_REGION2,PCI_SNOOP_REGION3}
  41. PCI_SNOOP_REGION;
  42. typedef enum __memPciHost{PCI_HOST0,PCI_HOST1} PCI_HOST;
  43. typedef enum __memPciRegion{PCI_REGION0,PCI_REGION1,
  44. PCI_REGION2,PCI_REGION3,
  45. PCI_IO}
  46. PCI_REGION;
  47. /* read/write configuration registers on local PCI bus. */
  48. void pciWriteConfigReg(PCI_HOST host, unsigned int regOffset,
  49. unsigned int pciDevNum, unsigned int data);
  50. unsigned int pciReadConfigReg (PCI_HOST host, unsigned int regOffset,
  51. unsigned int pciDevNum);
  52. /* read/write configuration registers on another PCI bus. */
  53. void pciOverBridgeWriteConfigReg(PCI_HOST host,
  54. unsigned int regOffset,
  55. unsigned int pciDevNum,
  56. unsigned int busNum,unsigned int data);
  57. unsigned int pciOverBridgeReadConfigReg(PCI_HOST host,
  58. unsigned int regOffset,
  59. unsigned int pciDevNum,
  60. unsigned int busNum);
  61. /* Master`s memory space */
  62. bool pciMapSpace(PCI_HOST host, PCI_REGION region,
  63. unsigned int remapBase,
  64. unsigned int deviceBase,
  65. unsigned int deviceLength);
  66. unsigned int pciGetSpaceBase(PCI_HOST host, PCI_REGION region);
  67. unsigned int pciGetSpaceSize(PCI_HOST host, PCI_REGION region);
  68. /* Slave`s memory space */
  69. void pciMapMemoryBank(PCI_HOST host, MEMORY_BANK bank,
  70. unsigned int pci0Dram0Base, unsigned int pci0Dram0Size);
  71. /* PCI region options */
  72. bool pciSetRegionFeatures(PCI_HOST host, PCI_ACCESS_REGIONS region,
  73. unsigned int features, unsigned int baseAddress,
  74. unsigned int regionLength);
  75. void pciDisableAccessRegion(PCI_HOST host, PCI_ACCESS_REGIONS region);
  76. /* PCI arbiter */
  77. bool pciArbiterEnable(PCI_HOST host);
  78. bool pciArbiterDisable(PCI_HOST host);
  79. bool pciParkingDisable(PCI_HOST host, PCI_AGENT_PARK internalAgent,
  80. PCI_AGENT_PARK externalAgent0,
  81. PCI_AGENT_PARK externalAgent1,
  82. PCI_AGENT_PARK externalAgent2,
  83. PCI_AGENT_PARK externalAgent3,
  84. PCI_AGENT_PARK externalAgent4,
  85. PCI_AGENT_PARK externalAgent5);
  86. bool pciSetRegionSnoopMode(PCI_HOST host, PCI_SNOOP_REGION region,
  87. PCI_SNOOP_TYPE snoopType,
  88. unsigned int baseAddress,
  89. unsigned int regionLength);
  90. #endif /* __INCpcih */