pbm.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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 <asm/io.h>
  13. #include <asm/page.h>
  14. #include <asm/oplib.h>
  15. #include <asm/prom.h>
  16. #include <asm/iommu.h>
  17. /* The abstraction used here is that there are PCI controllers,
  18. * each with one (Sabre) or two (PSYCHO/SCHIZO) PCI bus modules
  19. * underneath. Each PCI bus module uses an IOMMU (shared by both
  20. * PBMs of a controller, or per-PBM), and if a streaming buffer
  21. * is present, each PCI bus module has it's own. (ie. the IOMMU
  22. * might be shared between PBMs, the STC is never shared)
  23. * Furthermore, each PCI bus module controls it's own autonomous
  24. * PCI bus.
  25. */
  26. struct pci_controller_info;
  27. /* This contains the software state necessary to drive a PCI
  28. * controller's IOMMU.
  29. */
  30. struct pci_iommu_arena {
  31. unsigned long *map;
  32. unsigned int hint;
  33. unsigned int limit;
  34. };
  35. struct pci_iommu {
  36. /* This protects the controller's IOMMU and all
  37. * streaming buffers underneath.
  38. */
  39. spinlock_t lock;
  40. struct pci_iommu_arena arena;
  41. /* IOMMU page table, a linear array of ioptes. */
  42. iopte_t *page_table; /* The page table itself. */
  43. /* Base PCI memory space address where IOMMU mappings
  44. * begin.
  45. */
  46. u32 page_table_map_base;
  47. /* IOMMU Controller Registers */
  48. unsigned long iommu_control; /* IOMMU control register */
  49. unsigned long iommu_tsbbase; /* IOMMU page table base register */
  50. unsigned long iommu_flush; /* IOMMU page flush register */
  51. unsigned long iommu_ctxflush; /* IOMMU context flush register */
  52. /* This is a register in the PCI controller, which if
  53. * read will have no side-effects but will guarantee
  54. * completion of all previous writes into IOMMU/STC.
  55. */
  56. unsigned long write_complete_reg;
  57. /* In order to deal with some buggy third-party PCI bridges that
  58. * do wrong prefetching, we never mark valid mappings as invalid.
  59. * Instead we point them at this dummy page.
  60. */
  61. unsigned long dummy_page;
  62. unsigned long dummy_page_pa;
  63. /* CTX allocation. */
  64. unsigned long ctx_lowest_free;
  65. unsigned long ctx_bitmap[IOMMU_NUM_CTXS / (sizeof(unsigned long) * 8)];
  66. /* Here a PCI controller driver describes the areas of
  67. * PCI memory space where DMA to/from physical memory
  68. * are addressed. Drivers interrogate the PCI layer
  69. * if their device has addressing limitations. They
  70. * do so via pci_dma_supported, and pass in a mask of
  71. * DMA address bits their device can actually drive.
  72. *
  73. * The test for being usable is:
  74. * (device_mask & dma_addr_mask) == dma_addr_mask
  75. */
  76. u32 dma_addr_mask;
  77. };
  78. extern void pci_iommu_table_init(struct pci_iommu *iommu, int tsbsize, u32 dma_offset, u32 dma_addr_mask);
  79. /* This describes a PCI bus module's streaming buffer. */
  80. struct pci_strbuf {
  81. int strbuf_enabled; /* Present and using it? */
  82. /* Streaming Buffer Control Registers */
  83. unsigned long strbuf_control; /* STC control register */
  84. unsigned long strbuf_pflush; /* STC page flush register */
  85. unsigned long strbuf_fsync; /* STC flush synchronization reg */
  86. unsigned long strbuf_ctxflush; /* STC context flush register */
  87. unsigned long strbuf_ctxmatch_base; /* STC context flush match reg */
  88. unsigned long strbuf_flushflag_pa; /* Physical address of flush flag */
  89. volatile unsigned long *strbuf_flushflag; /* The flush flag itself */
  90. /* And this is the actual flush flag area.
  91. * We allocate extra because the chips require
  92. * a 64-byte aligned area.
  93. */
  94. volatile unsigned long __flushflag_buf[(64 + (64 - 1)) / sizeof(long)];
  95. };
  96. #define PCI_STC_FLUSHFLAG_INIT(STC) \
  97. (*((STC)->strbuf_flushflag) = 0UL)
  98. #define PCI_STC_FLUSHFLAG_SET(STC) \
  99. (*((STC)->strbuf_flushflag) != 0UL)
  100. /* There can be quite a few ranges and interrupt maps on a PCI
  101. * segment. Thus...
  102. */
  103. #define PROM_PCIRNG_MAX 64
  104. #define PROM_PCIIMAP_MAX 64
  105. struct pci_pbm_info {
  106. /* PCI controller we sit under. */
  107. struct pci_controller_info *parent;
  108. /* Physical address base of controller registers. */
  109. unsigned long controller_regs;
  110. /* Physical address base of PBM registers. */
  111. unsigned long pbm_regs;
  112. /* Physical address of DMA sync register, if any. */
  113. unsigned long sync_reg;
  114. /* Opaque 32-bit system bus Port ID. */
  115. u32 portid;
  116. /* Opaque 32-bit handle used for hypervisor calls. */
  117. u32 devhandle;
  118. /* Chipset version information. */
  119. int chip_type;
  120. #define PBM_CHIP_TYPE_SABRE 1
  121. #define PBM_CHIP_TYPE_PSYCHO 2
  122. #define PBM_CHIP_TYPE_SCHIZO 3
  123. #define PBM_CHIP_TYPE_SCHIZO_PLUS 4
  124. #define PBM_CHIP_TYPE_TOMATILLO 5
  125. int chip_version;
  126. int chip_revision;
  127. /* Name used for top-level resources. */
  128. char *name;
  129. /* OBP specific information. */
  130. struct device_node *prom_node;
  131. struct linux_prom_pci_ranges *pbm_ranges;
  132. int num_pbm_ranges;
  133. struct linux_prom_pci_intmap *pbm_intmap;
  134. int num_pbm_intmap;
  135. struct linux_prom_pci_intmask *pbm_intmask;
  136. u64 ino_bitmap;
  137. /* PBM I/O and Memory space resources. */
  138. struct resource io_space;
  139. struct resource mem_space;
  140. /* Base of PCI Config space, can be per-PBM or shared. */
  141. unsigned long config_space;
  142. /* State of 66MHz capabilities on this PBM. */
  143. int is_66mhz_capable;
  144. int all_devs_66mhz;
  145. /* This PBM's streaming buffer. */
  146. struct pci_strbuf stc;
  147. /* IOMMU state, potentially shared by both PBM segments. */
  148. struct pci_iommu *iommu;
  149. /* PCI slot mapping. */
  150. unsigned int pci_first_slot;
  151. /* Now things for the actual PCI bus probes. */
  152. unsigned int pci_first_busno;
  153. unsigned int pci_last_busno;
  154. struct pci_bus *pci_bus;
  155. };
  156. struct pci_controller_info {
  157. /* List of all PCI controllers. */
  158. struct pci_controller_info *next;
  159. /* Each controller gets a unique index, used mostly for
  160. * error logging purposes.
  161. */
  162. int index;
  163. /* Do the PBMs both exist in the same PCI domain? */
  164. int pbms_same_domain;
  165. /* The PCI bus modules controlled by us. */
  166. struct pci_pbm_info pbm_A;
  167. struct pci_pbm_info pbm_B;
  168. /* Operations which are controller specific. */
  169. void (*scan_bus)(struct pci_controller_info *);
  170. unsigned int (*irq_build)(struct pci_pbm_info *, struct pci_dev *, unsigned int);
  171. void (*base_address_update)(struct pci_dev *, int);
  172. void (*resource_adjust)(struct pci_dev *, struct resource *, struct resource *);
  173. /* Now things for the actual PCI bus probes. */
  174. struct pci_ops *pci_ops;
  175. unsigned int pci_first_busno;
  176. unsigned int pci_last_busno;
  177. void *starfire_cookie;
  178. };
  179. /* PCI devices which are not bridges have this placed in their pci_dev
  180. * sysdata member. This makes OBP aware PCI device drivers easier to
  181. * code.
  182. */
  183. struct pcidev_cookie {
  184. struct pci_pbm_info *pbm;
  185. struct device_node *prom_node;
  186. struct linux_prom_pci_registers prom_regs[PROMREG_MAX];
  187. int num_prom_regs;
  188. struct linux_prom_pci_registers prom_assignments[PROMREG_MAX];
  189. int num_prom_assignments;
  190. };
  191. /* Currently these are the same across all PCI controllers
  192. * we support. Someday they may not be...
  193. */
  194. #define PCI_IRQ_IGN 0x000007c0 /* Interrupt Group Number */
  195. #define PCI_IRQ_INO 0x0000003f /* Interrupt Number */
  196. #endif /* !(__SPARC64_PBM_H) */