core_mcpcia.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. #ifndef __ALPHA_MCPCIA__H__
  2. #define __ALPHA_MCPCIA__H__
  3. /* Define to experiment with fitting everything into one 128MB HAE window.
  4. One window per bus, that is. */
  5. #define MCPCIA_ONE_HAE_WINDOW 1
  6. #include <linux/types.h>
  7. #include <asm/compiler.h>
  8. #include <asm/mce.h>
  9. /*
  10. * MCPCIA is the internal name for a core logic chipset which provides
  11. * PCI access for the RAWHIDE family of systems.
  12. *
  13. * This file is based on:
  14. *
  15. * RAWHIDE System Programmer's Manual
  16. * 16-May-96
  17. * Rev. 1.4
  18. *
  19. */
  20. /*------------------------------------------------------------------------**
  21. ** **
  22. ** I/O procedures **
  23. ** **
  24. ** inport[b|w|t|l], outport[b|w|t|l] 8:16:24:32 IO xfers **
  25. ** inportbxt: 8 bits only **
  26. ** inport: alias of inportw **
  27. ** outport: alias of outportw **
  28. ** **
  29. ** inmem[b|w|t|l], outmem[b|w|t|l] 8:16:24:32 ISA memory xfers **
  30. ** inmembxt: 8 bits only **
  31. ** inmem: alias of inmemw **
  32. ** outmem: alias of outmemw **
  33. ** **
  34. **------------------------------------------------------------------------*/
  35. /* MCPCIA ADDRESS BIT DEFINITIONS
  36. *
  37. * 3333 3333 3322 2222 2222 1111 1111 11
  38. * 9876 5432 1098 7654 3210 9876 5432 1098 7654 3210
  39. * ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
  40. * 1 000
  41. * ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
  42. * | |\|
  43. * | Byte Enable --+ |
  44. * | Transfer Length --+
  45. * +-- IO space, not cached
  46. *
  47. * Byte Transfer
  48. * Enable Length Transfer Byte Address
  49. * adr<6:5> adr<4:3> Length Enable Adder
  50. * ---------------------------------------------
  51. * 00 00 Byte 1110 0x000
  52. * 01 00 Byte 1101 0x020
  53. * 10 00 Byte 1011 0x040
  54. * 11 00 Byte 0111 0x060
  55. *
  56. * 00 01 Word 1100 0x008
  57. * 01 01 Word 1001 0x028 <= Not supported in this code.
  58. * 10 01 Word 0011 0x048
  59. *
  60. * 00 10 Tribyte 1000 0x010
  61. * 01 10 Tribyte 0001 0x030
  62. *
  63. * 10 11 Longword 0000 0x058
  64. *
  65. * Note that byte enables are asserted low.
  66. *
  67. */
  68. #define MCPCIA_MAX_HOSES 4
  69. #define MCPCIA_MID(m) ((unsigned long)(m) << 33)
  70. /* Dodge has PCI0 and PCI1 at MID 4 and 5 respectively.
  71. Durango adds PCI2 and PCI3 at MID 6 and 7 respectively. */
  72. #define MCPCIA_HOSE2MID(h) ((h) + 4)
  73. #define MCPCIA_MEM_MASK 0x07ffffff /* SPARSE Mem region mask is 27 bits */
  74. /*
  75. * Memory spaces:
  76. */
  77. #define MCPCIA_SPARSE(m) (IDENT_ADDR + 0xf000000000UL + MCPCIA_MID(m))
  78. #define MCPCIA_DENSE(m) (IDENT_ADDR + 0xf100000000UL + MCPCIA_MID(m))
  79. #define MCPCIA_IO(m) (IDENT_ADDR + 0xf180000000UL + MCPCIA_MID(m))
  80. #define MCPCIA_CONF(m) (IDENT_ADDR + 0xf1c0000000UL + MCPCIA_MID(m))
  81. #define MCPCIA_CSR(m) (IDENT_ADDR + 0xf1e0000000UL + MCPCIA_MID(m))
  82. #define MCPCIA_IO_IACK(m) (IDENT_ADDR + 0xf1f0000000UL + MCPCIA_MID(m))
  83. #define MCPCIA_DENSE_IO(m) (IDENT_ADDR + 0xe1fc000000UL + MCPCIA_MID(m))
  84. #define MCPCIA_DENSE_CONF(m) (IDENT_ADDR + 0xe1fe000000UL + MCPCIA_MID(m))
  85. /*
  86. * General Registers
  87. */
  88. #define MCPCIA_REV(m) (MCPCIA_CSR(m) + 0x000)
  89. #define MCPCIA_WHOAMI(m) (MCPCIA_CSR(m) + 0x040)
  90. #define MCPCIA_PCI_LAT(m) (MCPCIA_CSR(m) + 0x080)
  91. #define MCPCIA_CAP_CTRL(m) (MCPCIA_CSR(m) + 0x100)
  92. #define MCPCIA_HAE_MEM(m) (MCPCIA_CSR(m) + 0x400)
  93. #define MCPCIA_HAE_IO(m) (MCPCIA_CSR(m) + 0x440)
  94. #define _MCPCIA_IACK_SC(m) (MCPCIA_CSR(m) + 0x480)
  95. #define MCPCIA_HAE_DENSE(m) (MCPCIA_CSR(m) + 0x4C0)
  96. /*
  97. * Interrupt Control registers
  98. */
  99. #define MCPCIA_INT_CTL(m) (MCPCIA_CSR(m) + 0x500)
  100. #define MCPCIA_INT_REQ(m) (MCPCIA_CSR(m) + 0x540)
  101. #define MCPCIA_INT_TARG(m) (MCPCIA_CSR(m) + 0x580)
  102. #define MCPCIA_INT_ADR(m) (MCPCIA_CSR(m) + 0x5C0)
  103. #define MCPCIA_INT_ADR_EXT(m) (MCPCIA_CSR(m) + 0x600)
  104. #define MCPCIA_INT_MASK0(m) (MCPCIA_CSR(m) + 0x640)
  105. #define MCPCIA_INT_MASK1(m) (MCPCIA_CSR(m) + 0x680)
  106. #define MCPCIA_INT_ACK0(m) (MCPCIA_CSR(m) + 0x10003f00)
  107. #define MCPCIA_INT_ACK1(m) (MCPCIA_CSR(m) + 0x10003f40)
  108. /*
  109. * Performance Monitor registers
  110. */
  111. #define MCPCIA_PERF_MON(m) (MCPCIA_CSR(m) + 0x300)
  112. #define MCPCIA_PERF_CONT(m) (MCPCIA_CSR(m) + 0x340)
  113. /*
  114. * Diagnostic Registers
  115. */
  116. #define MCPCIA_CAP_DIAG(m) (MCPCIA_CSR(m) + 0x700)
  117. #define MCPCIA_TOP_OF_MEM(m) (MCPCIA_CSR(m) + 0x7C0)
  118. /*
  119. * Error registers
  120. */
  121. #define MCPCIA_MC_ERR0(m) (MCPCIA_CSR(m) + 0x800)
  122. #define MCPCIA_MC_ERR1(m) (MCPCIA_CSR(m) + 0x840)
  123. #define MCPCIA_CAP_ERR(m) (MCPCIA_CSR(m) + 0x880)
  124. #define MCPCIA_PCI_ERR1(m) (MCPCIA_CSR(m) + 0x1040)
  125. #define MCPCIA_MDPA_STAT(m) (MCPCIA_CSR(m) + 0x4000)
  126. #define MCPCIA_MDPA_SYN(m) (MCPCIA_CSR(m) + 0x4040)
  127. #define MCPCIA_MDPA_DIAG(m) (MCPCIA_CSR(m) + 0x4080)
  128. #define MCPCIA_MDPB_STAT(m) (MCPCIA_CSR(m) + 0x8000)
  129. #define MCPCIA_MDPB_SYN(m) (MCPCIA_CSR(m) + 0x8040)
  130. #define MCPCIA_MDPB_DIAG(m) (MCPCIA_CSR(m) + 0x8080)
  131. /*
  132. * PCI Address Translation Registers.
  133. */
  134. #define MCPCIA_SG_TBIA(m) (MCPCIA_CSR(m) + 0x1300)
  135. #define MCPCIA_HBASE(m) (MCPCIA_CSR(m) + 0x1340)
  136. #define MCPCIA_W0_BASE(m) (MCPCIA_CSR(m) + 0x1400)
  137. #define MCPCIA_W0_MASK(m) (MCPCIA_CSR(m) + 0x1440)
  138. #define MCPCIA_T0_BASE(m) (MCPCIA_CSR(m) + 0x1480)
  139. #define MCPCIA_W1_BASE(m) (MCPCIA_CSR(m) + 0x1500)
  140. #define MCPCIA_W1_MASK(m) (MCPCIA_CSR(m) + 0x1540)
  141. #define MCPCIA_T1_BASE(m) (MCPCIA_CSR(m) + 0x1580)
  142. #define MCPCIA_W2_BASE(m) (MCPCIA_CSR(m) + 0x1600)
  143. #define MCPCIA_W2_MASK(m) (MCPCIA_CSR(m) + 0x1640)
  144. #define MCPCIA_T2_BASE(m) (MCPCIA_CSR(m) + 0x1680)
  145. #define MCPCIA_W3_BASE(m) (MCPCIA_CSR(m) + 0x1700)
  146. #define MCPCIA_W3_MASK(m) (MCPCIA_CSR(m) + 0x1740)
  147. #define MCPCIA_T3_BASE(m) (MCPCIA_CSR(m) + 0x1780)
  148. /* Hack! Only words for bus 0. */
  149. #ifndef MCPCIA_ONE_HAE_WINDOW
  150. #define MCPCIA_HAE_ADDRESS MCPCIA_HAE_MEM(4)
  151. #endif
  152. #define MCPCIA_IACK_SC _MCPCIA_IACK_SC(4)
  153. /*
  154. * The canonical non-remaped I/O and MEM addresses have these values
  155. * subtracted out. This is arranged so that folks manipulating ISA
  156. * devices can use their familiar numbers and have them map to bus 0.
  157. */
  158. #define MCPCIA_IO_BIAS MCPCIA_IO(4)
  159. #define MCPCIA_MEM_BIAS MCPCIA_DENSE(4)
  160. /* Offset between ram physical addresses and pci64 DAC bus addresses. */
  161. #define MCPCIA_DAC_OFFSET (1UL << 40)
  162. /*
  163. * Data structure for handling MCPCIA machine checks:
  164. */
  165. struct el_MCPCIA_uncorrected_frame_mcheck {
  166. struct el_common header;
  167. struct el_common_EV5_uncorrectable_mcheck procdata;
  168. };
  169. #ifdef __KERNEL__
  170. #ifndef __EXTERN_INLINE
  171. #define __EXTERN_INLINE extern inline
  172. #define __IO_EXTERN_INLINE
  173. #endif
  174. /*
  175. * I/O functions:
  176. *
  177. * MCPCIA, the RAWHIDE family PCI/memory support chipset for the EV5 (21164)
  178. * and EV56 (21164a) processors, can use either a sparse address mapping
  179. * scheme, or the so-called byte-word PCI address space, to get at PCI memory
  180. * and I/O.
  181. *
  182. * Unfortunately, we can't use BWIO with EV5, so for now, we always use SPARSE.
  183. */
  184. /*
  185. * Memory functions. 64-bit and 32-bit accesses are done through
  186. * dense memory space, everything else through sparse space.
  187. *
  188. * For reading and writing 8 and 16 bit quantities we need to
  189. * go through one of the three sparse address mapping regions
  190. * and use the HAE_MEM CSR to provide some bits of the address.
  191. * The following few routines use only sparse address region 1
  192. * which gives 1Gbyte of accessible space which relates exactly
  193. * to the amount of PCI memory mapping *into* system address space.
  194. * See p 6-17 of the specification but it looks something like this:
  195. *
  196. * 21164 Address:
  197. *
  198. * 3 2 1
  199. * 9876543210987654321098765432109876543210
  200. * 1ZZZZ0.PCI.QW.Address............BBLL
  201. *
  202. * ZZ = SBZ
  203. * BB = Byte offset
  204. * LL = Transfer length
  205. *
  206. * PCI Address:
  207. *
  208. * 3 2 1
  209. * 10987654321098765432109876543210
  210. * HHH....PCI.QW.Address........ 00
  211. *
  212. * HHH = 31:29 HAE_MEM CSR
  213. *
  214. */
  215. #define vip volatile int __force *
  216. #define vuip volatile unsigned int __force *
  217. #ifndef MCPCIA_ONE_HAE_WINDOW
  218. #define MCPCIA_FROB_MMIO \
  219. if (__mcpcia_is_mmio(hose)) { \
  220. set_hae(hose & 0xffffffff); \
  221. hose = hose - MCPCIA_DENSE(4) + MCPCIA_SPARSE(4); \
  222. }
  223. #else
  224. #define MCPCIA_FROB_MMIO \
  225. if (__mcpcia_is_mmio(hose)) { \
  226. hose = hose - MCPCIA_DENSE(4) + MCPCIA_SPARSE(4); \
  227. }
  228. #endif
  229. extern inline int __mcpcia_is_mmio(unsigned long addr)
  230. {
  231. return (addr & 0x80000000UL) == 0;
  232. }
  233. __EXTERN_INLINE unsigned int mcpcia_ioread8(void __iomem *xaddr)
  234. {
  235. unsigned long addr = (unsigned long)xaddr & MCPCIA_MEM_MASK;
  236. unsigned long hose = (unsigned long)xaddr & ~MCPCIA_MEM_MASK;
  237. unsigned long result;
  238. MCPCIA_FROB_MMIO;
  239. result = *(vip) ((addr << 5) + hose + 0x00);
  240. return __kernel_extbl(result, addr & 3);
  241. }
  242. __EXTERN_INLINE void mcpcia_iowrite8(u8 b, void __iomem *xaddr)
  243. {
  244. unsigned long addr = (unsigned long)xaddr & MCPCIA_MEM_MASK;
  245. unsigned long hose = (unsigned long)xaddr & ~MCPCIA_MEM_MASK;
  246. unsigned long w;
  247. MCPCIA_FROB_MMIO;
  248. w = __kernel_insbl(b, addr & 3);
  249. *(vuip) ((addr << 5) + hose + 0x00) = w;
  250. }
  251. __EXTERN_INLINE unsigned int mcpcia_ioread16(void __iomem *xaddr)
  252. {
  253. unsigned long addr = (unsigned long)xaddr & MCPCIA_MEM_MASK;
  254. unsigned long hose = (unsigned long)xaddr & ~MCPCIA_MEM_MASK;
  255. unsigned long result;
  256. MCPCIA_FROB_MMIO;
  257. result = *(vip) ((addr << 5) + hose + 0x08);
  258. return __kernel_extwl(result, addr & 3);
  259. }
  260. __EXTERN_INLINE void mcpcia_iowrite16(u16 b, void __iomem *xaddr)
  261. {
  262. unsigned long addr = (unsigned long)xaddr & MCPCIA_MEM_MASK;
  263. unsigned long hose = (unsigned long)xaddr & ~MCPCIA_MEM_MASK;
  264. unsigned long w;
  265. MCPCIA_FROB_MMIO;
  266. w = __kernel_inswl(b, addr & 3);
  267. *(vuip) ((addr << 5) + hose + 0x08) = w;
  268. }
  269. __EXTERN_INLINE unsigned int mcpcia_ioread32(void __iomem *xaddr)
  270. {
  271. unsigned long addr = (unsigned long)xaddr;
  272. if (!__mcpcia_is_mmio(addr))
  273. addr = ((addr & 0xffff) << 5) + (addr & ~0xfffful) + 0x18;
  274. return *(vuip)addr;
  275. }
  276. __EXTERN_INLINE void mcpcia_iowrite32(u32 b, void __iomem *xaddr)
  277. {
  278. unsigned long addr = (unsigned long)xaddr;
  279. if (!__mcpcia_is_mmio(addr))
  280. addr = ((addr & 0xffff) << 5) + (addr & ~0xfffful) + 0x18;
  281. *(vuip)addr = b;
  282. }
  283. __EXTERN_INLINE void __iomem *mcpcia_ioportmap(unsigned long addr)
  284. {
  285. return (void __iomem *)(addr + MCPCIA_IO_BIAS);
  286. }
  287. __EXTERN_INLINE void __iomem *mcpcia_ioremap(unsigned long addr,
  288. unsigned long size)
  289. {
  290. return (void __iomem *)(addr + MCPCIA_MEM_BIAS);
  291. }
  292. __EXTERN_INLINE int mcpcia_is_ioaddr(unsigned long addr)
  293. {
  294. return addr >= MCPCIA_SPARSE(0);
  295. }
  296. __EXTERN_INLINE int mcpcia_is_mmio(const volatile void __iomem *xaddr)
  297. {
  298. unsigned long addr = (unsigned long) xaddr;
  299. return __mcpcia_is_mmio(addr);
  300. }
  301. #undef MCPCIA_FROB_MMIO
  302. #undef vip
  303. #undef vuip
  304. #undef __IO_PREFIX
  305. #define __IO_PREFIX mcpcia
  306. #define mcpcia_trivial_rw_bw 2
  307. #define mcpcia_trivial_rw_lq 1
  308. #define mcpcia_trivial_io_bw 0
  309. #define mcpcia_trivial_io_lq 0
  310. #define mcpcia_trivial_iounmap 1
  311. #include <asm/io_trivial.h>
  312. #ifdef __IO_EXTERN_INLINE
  313. #undef __EXTERN_INLINE
  314. #undef __IO_EXTERN_INLINE
  315. #endif
  316. #endif /* __KERNEL__ */
  317. #endif /* __ALPHA_MCPCIA__H__ */