pci_impl.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /* pci_impl.h: Helper definitions for PCI controller support.
  2. *
  3. * Copyright (C) 1999, 2007 David S. Miller (davem@davemloft.net)
  4. */
  5. #ifndef PCI_IMPL_H
  6. #define PCI_IMPL_H
  7. #include <linux/types.h>
  8. #include <linux/spinlock.h>
  9. #include <linux/pci.h>
  10. #include <linux/msi.h>
  11. #include <asm/io.h>
  12. #include <asm/prom.h>
  13. #include <asm/iommu.h>
  14. /* The abstraction used here is that there are PCI controllers,
  15. * each with one (Sabre) or two (PSYCHO/SCHIZO) PCI bus modules
  16. * underneath. Each PCI bus module uses an IOMMU (shared by both
  17. * PBMs of a controller, or per-PBM), and if a streaming buffer
  18. * is present, each PCI bus module has it's own. (ie. the IOMMU
  19. * might be shared between PBMs, the STC is never shared)
  20. * Furthermore, each PCI bus module controls it's own autonomous
  21. * PCI bus.
  22. */
  23. #define PCI_STC_FLUSHFLAG_INIT(STC) \
  24. (*((STC)->strbuf_flushflag) = 0UL)
  25. #define PCI_STC_FLUSHFLAG_SET(STC) \
  26. (*((STC)->strbuf_flushflag) != 0UL)
  27. struct pci_controller_info;
  28. struct pci_pbm_info {
  29. struct pci_pbm_info *next;
  30. int index;
  31. /* PCI controller we sit under. */
  32. struct pci_controller_info *parent;
  33. /* Physical address base of controller registers. */
  34. unsigned long controller_regs;
  35. /* Physical address base of PBM registers. */
  36. unsigned long pbm_regs;
  37. /* Physical address of DMA sync register, if any. */
  38. unsigned long sync_reg;
  39. /* Opaque 32-bit system bus Port ID. */
  40. u32 portid;
  41. /* Opaque 32-bit handle used for hypervisor calls. */
  42. u32 devhandle;
  43. /* Chipset version information. */
  44. int chip_type;
  45. #define PBM_CHIP_TYPE_SABRE 1
  46. #define PBM_CHIP_TYPE_PSYCHO 2
  47. #define PBM_CHIP_TYPE_SCHIZO 3
  48. #define PBM_CHIP_TYPE_SCHIZO_PLUS 4
  49. #define PBM_CHIP_TYPE_TOMATILLO 5
  50. int chip_version;
  51. int chip_revision;
  52. /* Name used for top-level resources. */
  53. char *name;
  54. /* OBP specific information. */
  55. struct device_node *prom_node;
  56. u64 ino_bitmap;
  57. /* PBM I/O and Memory space resources. */
  58. struct resource io_space;
  59. struct resource mem_space;
  60. /* Base of PCI Config space, can be per-PBM or shared. */
  61. unsigned long config_space;
  62. /* This will be 12 on PCI-E controllers, 8 elsewhere. */
  63. unsigned long config_space_reg_bits;
  64. /* State of 66MHz capabilities on this PBM. */
  65. int is_66mhz_capable;
  66. int all_devs_66mhz;
  67. #ifdef CONFIG_PCI_MSI
  68. /* MSI info. */
  69. u32 msiq_num;
  70. u32 msiq_ent_count;
  71. u32 msiq_first;
  72. u32 msiq_first_devino;
  73. u32 msi_num;
  74. u32 msi_first;
  75. u32 msi_data_mask;
  76. u32 msix_data_width;
  77. u64 msi32_start;
  78. u64 msi64_start;
  79. u32 msi32_len;
  80. u32 msi64_len;
  81. void *msi_queues;
  82. unsigned long *msi_bitmap;
  83. int (*setup_msi_irq)(unsigned int *virt_irq_p, struct pci_dev *pdev,
  84. struct msi_desc *entry);
  85. void (*teardown_msi_irq)(unsigned int virt_irq, struct pci_dev *pdev);
  86. #endif /* !(CONFIG_PCI_MSI) */
  87. /* This PBM's streaming buffer. */
  88. struct strbuf stc;
  89. /* IOMMU state, potentially shared by both PBM segments. */
  90. struct iommu *iommu;
  91. /* Now things for the actual PCI bus probes. */
  92. unsigned int pci_first_busno;
  93. unsigned int pci_last_busno;
  94. struct pci_bus *pci_bus;
  95. void (*scan_bus)(struct pci_pbm_info *);
  96. struct pci_ops *pci_ops;
  97. };
  98. struct pci_controller_info {
  99. /* The PCI bus modules controlled by us. */
  100. struct pci_pbm_info pbm_A;
  101. struct pci_pbm_info pbm_B;
  102. };
  103. extern struct pci_pbm_info *pci_pbm_root;
  104. extern unsigned long pci_memspace_mask;
  105. extern int pci_num_pbms;
  106. /* PCI bus scanning and fixup support. */
  107. extern void pci_iommu_table_init(struct iommu *iommu, int tsbsize,
  108. u32 dma_offset, u32 dma_addr_mask);
  109. extern void pci_get_pbm_props(struct pci_pbm_info *pbm);
  110. extern struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm);
  111. extern void pci_determine_mem_io_space(struct pci_pbm_info *pbm);
  112. extern int pci_host_bridge_read_pci_cfg(struct pci_bus *bus_dev,
  113. unsigned int devfn,
  114. int where, int size,
  115. u32 *value);
  116. extern int pci_host_bridge_write_pci_cfg(struct pci_bus *bus_dev,
  117. unsigned int devfn,
  118. int where, int size,
  119. u32 value);
  120. /* Error reporting support. */
  121. extern void pci_scan_for_target_abort(struct pci_pbm_info *, struct pci_bus *);
  122. extern void pci_scan_for_master_abort(struct pci_pbm_info *, struct pci_bus *);
  123. extern void pci_scan_for_parity_error(struct pci_pbm_info *, struct pci_bus *);
  124. /* Configuration space access. */
  125. extern void pci_config_read8(u8 *addr, u8 *ret);
  126. extern void pci_config_read16(u16 *addr, u16 *ret);
  127. extern void pci_config_read32(u32 *addr, u32 *ret);
  128. extern void pci_config_write8(u8 *addr, u8 val);
  129. extern void pci_config_write16(u16 *addr, u16 val);
  130. extern void pci_config_write32(u32 *addr, u32 val);
  131. extern struct pci_ops sun4u_pci_ops;
  132. extern struct pci_ops sun4v_pci_ops;
  133. #endif /* !(PCI_IMPL_H) */