pbm.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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. struct pci_controller_info;
  26. /* This contains the software state necessary to drive a PCI
  27. * controller's IOMMU.
  28. */
  29. struct pci_iommu_arena {
  30. unsigned long *map;
  31. unsigned int hint;
  32. unsigned int limit;
  33. };
  34. struct pci_iommu {
  35. /* This protects the controller's IOMMU and all
  36. * streaming buffers underneath.
  37. */
  38. spinlock_t lock;
  39. struct pci_iommu_arena arena;
  40. /* IOMMU page table, a linear array of ioptes. */
  41. iopte_t *page_table; /* The page table itself. */
  42. /* Base PCI memory space address where IOMMU mappings
  43. * begin.
  44. */
  45. u32 page_table_map_base;
  46. /* IOMMU Controller Registers */
  47. unsigned long iommu_control; /* IOMMU control register */
  48. unsigned long iommu_tsbbase; /* IOMMU page table base register */
  49. unsigned long iommu_flush; /* IOMMU page flush register */
  50. unsigned long iommu_ctxflush; /* IOMMU context flush register */
  51. /* This is a register in the PCI controller, which if
  52. * read will have no side-effects but will guarantee
  53. * completion of all previous writes into IOMMU/STC.
  54. */
  55. unsigned long write_complete_reg;
  56. /* In order to deal with some buggy third-party PCI bridges that
  57. * do wrong prefetching, we never mark valid mappings as invalid.
  58. * Instead we point them at this dummy page.
  59. */
  60. unsigned long dummy_page;
  61. unsigned long dummy_page_pa;
  62. /* CTX allocation. */
  63. unsigned long ctx_lowest_free;
  64. unsigned long ctx_bitmap[IOMMU_NUM_CTXS / (sizeof(unsigned long) * 8)];
  65. /* Here a PCI controller driver describes the areas of
  66. * PCI memory space where DMA to/from physical memory
  67. * are addressed. Drivers interrogate the PCI layer
  68. * if their device has addressing limitations. They
  69. * do so via pci_dma_supported, and pass in a mask of
  70. * DMA address bits their device can actually drive.
  71. *
  72. * The test for being usable is:
  73. * (device_mask & dma_addr_mask) == dma_addr_mask
  74. */
  75. u32 dma_addr_mask;
  76. };
  77. extern void pci_iommu_table_init(struct pci_iommu *iommu, int tsbsize, u32 dma_offset, u32 dma_addr_mask);
  78. /* This describes a PCI bus module's streaming buffer. */
  79. struct pci_strbuf {
  80. int strbuf_enabled; /* Present and using it? */
  81. /* Streaming Buffer Control Registers */
  82. unsigned long strbuf_control; /* STC control register */
  83. unsigned long strbuf_pflush; /* STC page flush register */
  84. unsigned long strbuf_fsync; /* STC flush synchronization reg */
  85. unsigned long strbuf_ctxflush; /* STC context flush register */
  86. unsigned long strbuf_ctxmatch_base; /* STC context flush match reg */
  87. unsigned long strbuf_flushflag_pa; /* Physical address of flush flag */
  88. volatile unsigned long *strbuf_flushflag; /* The flush flag itself */
  89. /* And this is the actual flush flag area.
  90. * We allocate extra because the chips require
  91. * a 64-byte aligned area.
  92. */
  93. volatile unsigned long __flushflag_buf[(64 + (64 - 1)) / sizeof(long)];
  94. };
  95. #define PCI_STC_FLUSHFLAG_INIT(STC) \
  96. (*((STC)->strbuf_flushflag) = 0UL)
  97. #define PCI_STC_FLUSHFLAG_SET(STC) \
  98. (*((STC)->strbuf_flushflag) != 0UL)
  99. /* There can be quite a few ranges and interrupt maps on a PCI
  100. * segment. Thus...
  101. */
  102. #define PROM_PCIRNG_MAX 64
  103. #define PROM_PCIIMAP_MAX 64
  104. struct pci_pbm_info {
  105. /* PCI controller we sit under. */
  106. struct pci_controller_info *parent;
  107. /* Physical address base of controller registers. */
  108. unsigned long controller_regs;
  109. /* Physical address base of PBM registers. */
  110. unsigned long pbm_regs;
  111. /* Physical address of DMA sync register, if any. */
  112. unsigned long sync_reg;
  113. /* Opaque 32-bit system bus Port ID. */
  114. u32 portid;
  115. /* Opaque 32-bit handle used for hypervisor calls. */
  116. u32 devhandle;
  117. /* Chipset version information. */
  118. int chip_type;
  119. #define PBM_CHIP_TYPE_SABRE 1
  120. #define PBM_CHIP_TYPE_PSYCHO 2
  121. #define PBM_CHIP_TYPE_SCHIZO 3
  122. #define PBM_CHIP_TYPE_SCHIZO_PLUS 4
  123. #define PBM_CHIP_TYPE_TOMATILLO 5
  124. int chip_version;
  125. int chip_revision;
  126. /* Name used for top-level resources. */
  127. char name[64];
  128. /* OBP specific information. */
  129. int prom_node;
  130. char prom_name[64];
  131. struct linux_prom_pci_ranges pbm_ranges[PROM_PCIRNG_MAX];
  132. int num_pbm_ranges;
  133. struct linux_prom_pci_intmap pbm_intmap[PROM_PCIIMAP_MAX];
  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. char prom_name[64];
  186. int prom_node;
  187. struct linux_prom_pci_registers prom_regs[PROMREG_MAX];
  188. int num_prom_regs;
  189. struct linux_prom_pci_registers prom_assignments[PROMREG_MAX];
  190. int num_prom_assignments;
  191. };
  192. /* Currently these are the same across all PCI controllers
  193. * we support. Someday they may not be...
  194. */
  195. #define PCI_IRQ_IGN 0x000007c0 /* Interrupt Group Number */
  196. #define PCI_IRQ_INO 0x0000003f /* Interrupt Number */
  197. #endif /* !(__SPARC64_PBM_H) */