pbm.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /* $Id: pbm.h,v 1.27 2001/08/12 13:18:23 davem Exp $
  2. * pbm.h: UltraSparc PCI controller software state.
  3. *
  4. * Copyright (C) 1997, 1998, 1999 David S. Miller (davem@redhat.com)
  5. */
  6. #ifndef __SPARC64_PBM_H
  7. #define __SPARC64_PBM_H
  8. #include <linux/types.h>
  9. #include <linux/pci.h>
  10. #include <linux/ioport.h>
  11. #include <linux/spinlock.h>
  12. #include <linux/msi.h>
  13. #include <asm/io.h>
  14. #include <asm/page.h>
  15. #include <asm/oplib.h>
  16. #include <asm/prom.h>
  17. #include <asm/of_device.h>
  18. #include <asm/iommu.h>
  19. /* The abstraction used here is that there are PCI controllers,
  20. * each with one (Sabre) or two (PSYCHO/SCHIZO) PCI bus modules
  21. * underneath. Each PCI bus module uses an IOMMU (shared by both
  22. * PBMs of a controller, or per-PBM), and if a streaming buffer
  23. * is present, each PCI bus module has it's own. (ie. the IOMMU
  24. * might be shared between PBMs, the STC is never shared)
  25. * Furthermore, each PCI bus module controls it's own autonomous
  26. * PCI bus.
  27. */
  28. struct pci_controller_info;
  29. /* This contains the software state necessary to drive a PCI
  30. * controller's IOMMU.
  31. */
  32. struct pci_iommu {
  33. /* This protects the controller's IOMMU and all
  34. * streaming buffers underneath.
  35. */
  36. spinlock_t lock;
  37. struct iommu_arena arena;
  38. /* IOMMU page table, a linear array of ioptes. */
  39. iopte_t *page_table; /* The page table itself. */
  40. /* Base PCI memory space address where IOMMU mappings
  41. * begin.
  42. */
  43. u32 page_table_map_base;
  44. /* IOMMU Controller Registers */
  45. unsigned long iommu_control; /* IOMMU control register */
  46. unsigned long iommu_tsbbase; /* IOMMU page table base register */
  47. unsigned long iommu_flush; /* IOMMU page flush register */
  48. unsigned long iommu_ctxflush; /* IOMMU context flush register */
  49. /* This is a register in the PCI controller, which if
  50. * read will have no side-effects but will guarantee
  51. * completion of all previous writes into IOMMU/STC.
  52. */
  53. unsigned long write_complete_reg;
  54. /* In order to deal with some buggy third-party PCI bridges that
  55. * do wrong prefetching, we never mark valid mappings as invalid.
  56. * Instead we point them at this dummy page.
  57. */
  58. unsigned long dummy_page;
  59. unsigned long dummy_page_pa;
  60. /* CTX allocation. */
  61. unsigned long ctx_lowest_free;
  62. DECLARE_BITMAP(ctx_bitmap, IOMMU_NUM_CTXS);
  63. /* Here a PCI controller driver describes the areas of
  64. * PCI memory space where DMA to/from physical memory
  65. * are addressed. Drivers interrogate the PCI layer
  66. * if their device has addressing limitations. They
  67. * do so via pci_dma_supported, and pass in a mask of
  68. * DMA address bits their device can actually drive.
  69. *
  70. * The test for being usable is:
  71. * (device_mask & dma_addr_mask) == dma_addr_mask
  72. */
  73. u32 dma_addr_mask;
  74. };
  75. extern void pci_iommu_table_init(struct pci_iommu *iommu, int tsbsize, u32 dma_offset, u32 dma_addr_mask);
  76. /* This describes a PCI bus module's streaming buffer. */
  77. struct pci_strbuf {
  78. int strbuf_enabled; /* Present and using it? */
  79. /* Streaming Buffer Control Registers */
  80. unsigned long strbuf_control; /* STC control register */
  81. unsigned long strbuf_pflush; /* STC page flush register */
  82. unsigned long strbuf_fsync; /* STC flush synchronization reg */
  83. unsigned long strbuf_ctxflush; /* STC context flush register */
  84. unsigned long strbuf_ctxmatch_base; /* STC context flush match reg */
  85. unsigned long strbuf_flushflag_pa; /* Physical address of flush flag */
  86. volatile unsigned long *strbuf_flushflag; /* The flush flag itself */
  87. /* And this is the actual flush flag area.
  88. * We allocate extra because the chips require
  89. * a 64-byte aligned area.
  90. */
  91. volatile unsigned long __flushflag_buf[(64 + (64 - 1)) / sizeof(long)];
  92. };
  93. #define PCI_STC_FLUSHFLAG_INIT(STC) \
  94. (*((STC)->strbuf_flushflag) = 0UL)
  95. #define PCI_STC_FLUSHFLAG_SET(STC) \
  96. (*((STC)->strbuf_flushflag) != 0UL)
  97. /* There can be quite a few ranges and interrupt maps on a PCI
  98. * segment. Thus...
  99. */
  100. #define PROM_PCIRNG_MAX 64
  101. #define PROM_PCIIMAP_MAX 64
  102. struct pci_pbm_info {
  103. /* PCI controller we sit under. */
  104. struct pci_controller_info *parent;
  105. /* Physical address base of controller registers. */
  106. unsigned long controller_regs;
  107. /* Physical address base of PBM registers. */
  108. unsigned long pbm_regs;
  109. /* Physical address of DMA sync register, if any. */
  110. unsigned long sync_reg;
  111. /* Opaque 32-bit system bus Port ID. */
  112. u32 portid;
  113. /* Opaque 32-bit handle used for hypervisor calls. */
  114. u32 devhandle;
  115. /* Chipset version information. */
  116. int chip_type;
  117. #define PBM_CHIP_TYPE_SABRE 1
  118. #define PBM_CHIP_TYPE_PSYCHO 2
  119. #define PBM_CHIP_TYPE_SCHIZO 3
  120. #define PBM_CHIP_TYPE_SCHIZO_PLUS 4
  121. #define PBM_CHIP_TYPE_TOMATILLO 5
  122. int chip_version;
  123. int chip_revision;
  124. /* Name used for top-level resources. */
  125. char *name;
  126. /* OBP specific information. */
  127. struct device_node *prom_node;
  128. u64 ino_bitmap;
  129. /* PBM I/O and Memory space resources. */
  130. struct resource io_space;
  131. struct resource mem_space;
  132. /* Base of PCI Config space, can be per-PBM or shared. */
  133. unsigned long config_space;
  134. /* State of 66MHz capabilities on this PBM. */
  135. int is_66mhz_capable;
  136. int all_devs_66mhz;
  137. #ifdef CONFIG_PCI_MSI
  138. /* MSI info. */
  139. u32 msiq_num;
  140. u32 msiq_ent_count;
  141. u32 msiq_first;
  142. u32 msiq_first_devino;
  143. u32 msi_num;
  144. u32 msi_first;
  145. u32 msi_data_mask;
  146. u32 msix_data_width;
  147. u64 msi32_start;
  148. u64 msi64_start;
  149. u32 msi32_len;
  150. u32 msi64_len;
  151. void *msi_queues;
  152. unsigned long *msi_bitmap;
  153. #endif /* !(CONFIG_PCI_MSI) */
  154. /* This PBM's streaming buffer. */
  155. struct pci_strbuf stc;
  156. /* IOMMU state, potentially shared by both PBM segments. */
  157. struct pci_iommu *iommu;
  158. /* Now things for the actual PCI bus probes. */
  159. unsigned int pci_first_busno;
  160. unsigned int pci_last_busno;
  161. struct pci_bus *pci_bus;
  162. };
  163. struct pci_controller_info {
  164. /* List of all PCI controllers. */
  165. struct pci_controller_info *next;
  166. /* Each controller gets a unique index, used mostly for
  167. * error logging purposes.
  168. */
  169. int index;
  170. /* The PCI bus modules controlled by us. */
  171. struct pci_pbm_info pbm_A;
  172. struct pci_pbm_info pbm_B;
  173. /* Operations which are controller specific. */
  174. void (*scan_bus)(struct pci_controller_info *);
  175. #ifdef CONFIG_PCI_MSI
  176. int (*setup_msi_irq)(unsigned int *virt_irq_p, struct pci_dev *pdev,
  177. struct msi_desc *entry);
  178. void (*teardown_msi_irq)(unsigned int virt_irq, struct pci_dev *pdev);
  179. #endif
  180. /* Now things for the actual PCI bus probes. */
  181. struct pci_ops *pci_ops;
  182. unsigned int pci_first_busno;
  183. unsigned int pci_last_busno;
  184. };
  185. #endif /* !(__SPARC64_PBM_H) */