pbm.h 7.4 KB

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