ropes.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. #ifndef _ASM_PARISC_ROPES_H_
  2. #define _ASM_PARISC_ROPES_H_
  3. #include <asm/parisc-device.h>
  4. #ifdef CONFIG_64BIT
  5. /* "low end" PA8800 machines use ZX1 chipset: PAT PDC and only run 64-bit */
  6. #define ZX1_SUPPORT
  7. #endif
  8. #ifdef CONFIG_PROC_FS
  9. /* depends on proc fs support. But costs CPU performance */
  10. #undef SBA_COLLECT_STATS
  11. #endif
  12. /*
  13. ** The number of pdir entries to "free" before issuing
  14. ** a read to PCOM register to flush out PCOM writes.
  15. ** Interacts with allocation granularity (ie 4 or 8 entries
  16. ** allocated and free'd/purged at a time might make this
  17. ** less interesting).
  18. */
  19. #define DELAYED_RESOURCE_CNT 16
  20. #define MAX_IOC 2 /* per Ike. Pluto/Astro only have 1. */
  21. #define ROPES_PER_IOC 8 /* per Ike half or Pluto/Astro */
  22. struct ioc {
  23. void __iomem *ioc_hpa; /* I/O MMU base address */
  24. char *res_map; /* resource map, bit == pdir entry */
  25. u64 *pdir_base; /* physical base address */
  26. unsigned long ibase; /* pdir IOV Space base - shared w/lba_pci */
  27. unsigned long imask; /* pdir IOV Space mask - shared w/lba_pci */
  28. #ifdef ZX1_SUPPORT
  29. unsigned long iovp_mask; /* help convert IOVA to IOVP */
  30. #endif
  31. unsigned long *res_hint; /* next avail IOVP - circular search */
  32. spinlock_t res_lock;
  33. unsigned int res_bitshift; /* from the LEFT! */
  34. unsigned int res_size; /* size of resource map in bytes */
  35. #ifdef SBA_HINT_SUPPORT
  36. /* FIXME : DMA HINTs not used */
  37. unsigned long hint_mask_pdir; /* bits used for DMA hints */
  38. unsigned int hint_shift_pdir;
  39. #endif
  40. #if DELAYED_RESOURCE_CNT > 0
  41. int saved_cnt;
  42. struct sba_dma_pair {
  43. dma_addr_t iova;
  44. size_t size;
  45. } saved[DELAYED_RESOURCE_CNT];
  46. #endif
  47. #ifdef SBA_COLLECT_STATS
  48. #define SBA_SEARCH_SAMPLE 0x100
  49. unsigned long avg_search[SBA_SEARCH_SAMPLE];
  50. unsigned long avg_idx; /* current index into avg_search */
  51. unsigned long used_pages;
  52. unsigned long msingle_calls;
  53. unsigned long msingle_pages;
  54. unsigned long msg_calls;
  55. unsigned long msg_pages;
  56. unsigned long usingle_calls;
  57. unsigned long usingle_pages;
  58. unsigned long usg_calls;
  59. unsigned long usg_pages;
  60. #endif
  61. /* STUFF We don't need in performance path */
  62. unsigned int pdir_size; /* in bytes, determined by IOV Space size */
  63. };
  64. struct sba_device {
  65. struct sba_device *next; /* list of SBA's in system */
  66. struct parisc_device *dev; /* dev found in bus walk */
  67. const char *name;
  68. void __iomem *sba_hpa; /* base address */
  69. spinlock_t sba_lock;
  70. unsigned int flags; /* state/functionality enabled */
  71. unsigned int hw_rev; /* HW revision of chip */
  72. struct resource chip_resv; /* MMIO reserved for chip */
  73. struct resource iommu_resv; /* MMIO reserved for iommu */
  74. unsigned int num_ioc; /* number of on-board IOC's */
  75. struct ioc ioc[MAX_IOC];
  76. };
  77. #define ASTRO_RUNWAY_PORT 0x582
  78. #define IKE_MERCED_PORT 0x803
  79. #define REO_MERCED_PORT 0x804
  80. #define REOG_MERCED_PORT 0x805
  81. #define PLUTO_MCKINLEY_PORT 0x880
  82. static inline int IS_ASTRO(struct parisc_device *d) {
  83. return d->id.hversion == ASTRO_RUNWAY_PORT;
  84. }
  85. static inline int IS_IKE(struct parisc_device *d) {
  86. return d->id.hversion == IKE_MERCED_PORT;
  87. }
  88. static inline int IS_PLUTO(struct parisc_device *d) {
  89. return d->id.hversion == PLUTO_MCKINLEY_PORT;
  90. }
  91. #define PLUTO_IOVA_BASE (1UL*1024*1024*1024) /* 1GB */
  92. #define PLUTO_IOVA_SIZE (1UL*1024*1024*1024) /* 1GB */
  93. #define PLUTO_GART_SIZE (PLUTO_IOVA_SIZE / 2)
  94. #define SBA_PDIR_VALID_BIT 0x8000000000000000ULL
  95. #define SBA_AGPGART_COOKIE 0x0000badbadc0ffeeULL
  96. #define SBA_FUNC_ID 0x0000 /* function id */
  97. #define SBA_FCLASS 0x0008 /* function class, bist, header, rev... */
  98. #define SBA_FUNC_SIZE 4096 /* SBA configuration function reg set */
  99. #define ASTRO_IOC_OFFSET (32 * SBA_FUNC_SIZE)
  100. #define PLUTO_IOC_OFFSET (1 * SBA_FUNC_SIZE)
  101. /* Ike's IOC's occupy functions 2 and 3 */
  102. #define IKE_IOC_OFFSET(p) ((p+2) * SBA_FUNC_SIZE)
  103. #define IOC_CTRL 0x8 /* IOC_CTRL offset */
  104. #define IOC_CTRL_TC (1 << 0) /* TOC Enable */
  105. #define IOC_CTRL_CE (1 << 1) /* Coalesce Enable */
  106. #define IOC_CTRL_DE (1 << 2) /* Dillon Enable */
  107. #define IOC_CTRL_RM (1 << 8) /* Real Mode */
  108. #define IOC_CTRL_NC (1 << 9) /* Non Coherent Mode */
  109. #define IOC_CTRL_D4 (1 << 11) /* Disable 4-byte coalescing */
  110. #define IOC_CTRL_DD (1 << 13) /* Disable distr. LMMIO range coalescing */
  111. /*
  112. ** Offsets into MBIB (Function 0 on Ike and hopefully Astro)
  113. ** Firmware programs this stuff. Don't touch it.
  114. */
  115. #define LMMIO_DIRECT0_BASE 0x300
  116. #define LMMIO_DIRECT0_MASK 0x308
  117. #define LMMIO_DIRECT0_ROUTE 0x310
  118. #define LMMIO_DIST_BASE 0x360
  119. #define LMMIO_DIST_MASK 0x368
  120. #define LMMIO_DIST_ROUTE 0x370
  121. #define IOS_DIST_BASE 0x390
  122. #define IOS_DIST_MASK 0x398
  123. #define IOS_DIST_ROUTE 0x3A0
  124. #define IOS_DIRECT_BASE 0x3C0
  125. #define IOS_DIRECT_MASK 0x3C8
  126. #define IOS_DIRECT_ROUTE 0x3D0
  127. /*
  128. ** Offsets into I/O TLB (Function 2 and 3 on Ike)
  129. */
  130. #define ROPE0_CTL 0x200 /* "regbus pci0" */
  131. #define ROPE1_CTL 0x208
  132. #define ROPE2_CTL 0x210
  133. #define ROPE3_CTL 0x218
  134. #define ROPE4_CTL 0x220
  135. #define ROPE5_CTL 0x228
  136. #define ROPE6_CTL 0x230
  137. #define ROPE7_CTL 0x238
  138. #define IOC_ROPE0_CFG 0x500 /* pluto only */
  139. #define IOC_ROPE_AO 0x10 /* Allow "Relaxed Ordering" */
  140. #define HF_ENABLE 0x40
  141. #define IOC_IBASE 0x300 /* IO TLB */
  142. #define IOC_IMASK 0x308
  143. #define IOC_PCOM 0x310
  144. #define IOC_TCNFG 0x318
  145. #define IOC_PDIR_BASE 0x320
  146. /*
  147. ** IOC supports 4/8/16/64KB page sizes (see TCNFG register)
  148. ** It's safer (avoid memory corruption) to keep DMA page mappings
  149. ** equivalently sized to VM PAGE_SIZE.
  150. **
  151. ** We really can't avoid generating a new mapping for each
  152. ** page since the Virtual Coherence Index has to be generated
  153. ** and updated for each page.
  154. **
  155. ** PAGE_SIZE could be greater than IOVP_SIZE. But not the inverse.
  156. */
  157. #define IOVP_SIZE PAGE_SIZE
  158. #define IOVP_SHIFT PAGE_SHIFT
  159. #define IOVP_MASK PAGE_MASK
  160. #define SBA_PERF_CFG 0x708 /* Performance Counter stuff */
  161. #define SBA_PERF_MASK1 0x718
  162. #define SBA_PERF_MASK2 0x730
  163. /*
  164. ** Offsets into PCI Performance Counters (functions 12 and 13)
  165. ** Controlled by PERF registers in function 2 & 3 respectively.
  166. */
  167. #define SBA_PERF_CNT1 0x200
  168. #define SBA_PERF_CNT2 0x208
  169. #define SBA_PERF_CNT3 0x210
  170. /*
  171. ** lba_device: Per instance Elroy data structure
  172. */
  173. struct lba_device {
  174. struct pci_hba_data hba;
  175. spinlock_t lba_lock;
  176. void *iosapic_obj;
  177. #ifdef CONFIG_64BIT
  178. void __iomem *iop_base; /* PA_VIEW - for IO port accessor funcs */
  179. #endif
  180. int flags; /* state/functionality enabled */
  181. int hw_rev; /* HW revision of chip */
  182. };
  183. #define ELROY_HVERS 0x782
  184. #define MERCURY_HVERS 0x783
  185. #define QUICKSILVER_HVERS 0x784
  186. static inline int IS_ELROY(struct parisc_device *d) {
  187. return (d->id.hversion == ELROY_HVERS);
  188. }
  189. static inline int IS_MERCURY(struct parisc_device *d) {
  190. return (d->id.hversion == MERCURY_HVERS);
  191. }
  192. static inline int IS_QUICKSILVER(struct parisc_device *d) {
  193. return (d->id.hversion == QUICKSILVER_HVERS);
  194. }
  195. static inline int agp_mode_mercury(void __iomem *hpa) {
  196. u64 bus_mode;
  197. bus_mode = readl(hpa + 0x0620);
  198. if (bus_mode & 1)
  199. return 1;
  200. return 0;
  201. }
  202. /*
  203. ** I/O SAPIC init function
  204. ** Caller knows where an I/O SAPIC is. LBA has an integrated I/O SAPIC.
  205. ** Call setup as part of per instance initialization.
  206. ** (ie *not* init_module() function unless only one is present.)
  207. ** fixup_irq is to initialize PCI IRQ line support and
  208. ** virtualize pcidev->irq value. To be called by pci_fixup_bus().
  209. */
  210. extern void *iosapic_register(unsigned long hpa);
  211. extern int iosapic_fixup_irq(void *obj, struct pci_dev *pcidev);
  212. #define LBA_FUNC_ID 0x0000 /* function id */
  213. #define LBA_FCLASS 0x0008 /* function class, bist, header, rev... */
  214. #define LBA_CAPABLE 0x0030 /* capabilities register */
  215. #define LBA_PCI_CFG_ADDR 0x0040 /* poke CFG address here */
  216. #define LBA_PCI_CFG_DATA 0x0048 /* read or write data here */
  217. #define LBA_PMC_MTLT 0x0050 /* Firmware sets this - read only. */
  218. #define LBA_FW_SCRATCH 0x0058 /* Firmware writes the PCI bus number here. */
  219. #define LBA_ERROR_ADDR 0x0070 /* On error, address gets logged here */
  220. #define LBA_ARB_MASK 0x0080 /* bit 0 enable arbitration. PAT/PDC enables */
  221. #define LBA_ARB_PRI 0x0088 /* firmware sets this. */
  222. #define LBA_ARB_MODE 0x0090 /* firmware sets this. */
  223. #define LBA_ARB_MTLT 0x0098 /* firmware sets this. */
  224. #define LBA_MOD_ID 0x0100 /* Module ID. PDC_PAT_CELL reports 4 */
  225. #define LBA_STAT_CTL 0x0108 /* Status & Control */
  226. #define LBA_BUS_RESET 0x01 /* Deassert PCI Bus Reset Signal */
  227. #define CLEAR_ERRLOG 0x10 /* "Clear Error Log" cmd */
  228. #define CLEAR_ERRLOG_ENABLE 0x20 /* "Clear Error Log" Enable */
  229. #define HF_ENABLE 0x40 /* enable HF mode (default is -1 mode) */
  230. #define LBA_LMMIO_BASE 0x0200 /* < 4GB I/O address range */
  231. #define LBA_LMMIO_MASK 0x0208
  232. #define LBA_GMMIO_BASE 0x0210 /* > 4GB I/O address range */
  233. #define LBA_GMMIO_MASK 0x0218
  234. #define LBA_WLMMIO_BASE 0x0220 /* All < 4GB ranges under the same *SBA* */
  235. #define LBA_WLMMIO_MASK 0x0228
  236. #define LBA_WGMMIO_BASE 0x0230 /* All > 4GB ranges under the same *SBA* */
  237. #define LBA_WGMMIO_MASK 0x0238
  238. #define LBA_IOS_BASE 0x0240 /* I/O port space for this LBA */
  239. #define LBA_IOS_MASK 0x0248
  240. #define LBA_ELMMIO_BASE 0x0250 /* Extra LMMIO range */
  241. #define LBA_ELMMIO_MASK 0x0258
  242. #define LBA_EIOS_BASE 0x0260 /* Extra I/O port space */
  243. #define LBA_EIOS_MASK 0x0268
  244. #define LBA_GLOBAL_MASK 0x0270 /* Mercury only: Global Address Mask */
  245. #define LBA_DMA_CTL 0x0278 /* firmware sets this */
  246. #define LBA_IBASE 0x0300 /* SBA DMA support */
  247. #define LBA_IMASK 0x0308
  248. /* FIXME: ignore DMA Hint stuff until we can measure performance */
  249. #define LBA_HINT_CFG 0x0310
  250. #define LBA_HINT_BASE 0x0380 /* 14 registers at every 8 bytes. */
  251. #define LBA_BUS_MODE 0x0620
  252. /* ERROR regs are needed for config cycle kluges */
  253. #define LBA_ERROR_CONFIG 0x0680
  254. #define LBA_SMART_MODE 0x20
  255. #define LBA_ERROR_STATUS 0x0688
  256. #define LBA_ROPE_CTL 0x06A0
  257. #define LBA_IOSAPIC_BASE 0x800 /* Offset of IRQ logic */
  258. #endif /*_ASM_PARISC_ROPES_H_*/