core_marvel.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. /*
  2. * Marvel systems use the IO7 I/O chip provides PCI/PCIX/AGP access
  3. *
  4. * This file is based on:
  5. *
  6. * Marvel / EV7 System Programmer's Manual
  7. * Revision 1.00
  8. * 14 May 2001
  9. */
  10. #ifndef __ALPHA_MARVEL__H__
  11. #define __ALPHA_MARVEL__H__
  12. #include <linux/types.h>
  13. #include <linux/spinlock.h>
  14. #include <asm/compiler.h>
  15. #define MARVEL_MAX_PIDS 32 /* as long as we rely on 43-bit superpage */
  16. #define MARVEL_IRQ_VEC_PE_SHIFT (10)
  17. #define MARVEL_IRQ_VEC_IRQ_MASK ((1 << MARVEL_IRQ_VEC_PE_SHIFT) - 1)
  18. #define MARVEL_NR_IRQS \
  19. (16 + (MARVEL_MAX_PIDS * (1 << MARVEL_IRQ_VEC_PE_SHIFT)))
  20. /*
  21. * EV7 RBOX Registers
  22. */
  23. typedef struct {
  24. volatile unsigned long csr __attribute__((aligned(16)));
  25. } ev7_csr;
  26. typedef struct {
  27. ev7_csr RBOX_CFG; /* 0x0000 */
  28. ev7_csr RBOX_NSVC;
  29. ev7_csr RBOX_EWVC;
  30. ev7_csr RBOX_WHAMI;
  31. ev7_csr RBOX_TCTL; /* 0x0040 */
  32. ev7_csr RBOX_INT;
  33. ev7_csr RBOX_IMASK;
  34. ev7_csr RBOX_IREQ;
  35. ev7_csr RBOX_INTQ; /* 0x0080 */
  36. ev7_csr RBOX_INTA;
  37. ev7_csr RBOX_IT;
  38. ev7_csr RBOX_SCRATCH1;
  39. ev7_csr RBOX_SCRATCH2; /* 0x00c0 */
  40. ev7_csr RBOX_L_ERR;
  41. } ev7_csrs;
  42. /*
  43. * EV7 CSR addressing macros
  44. */
  45. #define EV7_MASK40(addr) ((addr) & ((1UL << 41) - 1))
  46. #define EV7_KERN_ADDR(addr) ((void *)(IDENT_ADDR | EV7_MASK40(addr)))
  47. #define EV7_PE_MASK 0x1ffUL /* 9 bits ( 256 + mem/io ) */
  48. #define EV7_IPE(pe) ((~((long)(pe)) & EV7_PE_MASK) << 35)
  49. #define EV7_CSR_PHYS(pe, off) (EV7_IPE(pe) | (0x7FFCUL << 20) | (off))
  50. #define EV7_CSRS_PHYS(pe) (EV7_CSR_PHYS(pe, 0UL))
  51. #define EV7_CSR_KERN(pe, off) (EV7_KERN_ADDR(EV7_CSR_PHYS(pe, off)))
  52. #define EV7_CSRS_KERN(pe) (EV7_KERN_ADDR(EV7_CSRS_PHYS(pe)))
  53. #define EV7_CSR_OFFSET(name) ((unsigned long)&((ev7_csrs *)NULL)->name.csr)
  54. /*
  55. * IO7 registers
  56. */
  57. typedef struct {
  58. volatile unsigned long csr __attribute__((aligned(64)));
  59. } io7_csr;
  60. typedef struct {
  61. /* I/O Port Control Registers */
  62. io7_csr POx_CTRL; /* 0x0000 */
  63. io7_csr POx_CACHE_CTL;
  64. io7_csr POx_TIMER;
  65. io7_csr POx_IO_ADR_EXT;
  66. io7_csr POx_MEM_ADR_EXT; /* 0x0100 */
  67. io7_csr POx_XCAL_CTRL;
  68. io7_csr rsvd1[2]; /* ?? spec doesn't show 0x180 */
  69. io7_csr POx_DM_SOURCE; /* 0x0200 */
  70. io7_csr POx_DM_DEST;
  71. io7_csr POx_DM_SIZE;
  72. io7_csr POx_DM_CTRL;
  73. io7_csr rsvd2[4]; /* 0x0300 */
  74. /* AGP Control Registers -- port 3 only */
  75. io7_csr AGP_CAP_ID; /* 0x0400 */
  76. io7_csr AGP_STAT;
  77. io7_csr AGP_CMD;
  78. io7_csr rsvd3;
  79. /* I/O Port Monitor Registers */
  80. io7_csr POx_MONCTL; /* 0x0500 */
  81. io7_csr POx_CTRA;
  82. io7_csr POx_CTRB;
  83. io7_csr POx_CTR56;
  84. io7_csr POx_SCRATCH; /* 0x0600 */
  85. io7_csr POx_XTRA_A;
  86. io7_csr POx_XTRA_TS;
  87. io7_csr POx_XTRA_Z;
  88. io7_csr rsvd4; /* 0x0700 */
  89. io7_csr POx_THRESHA;
  90. io7_csr POx_THRESHB;
  91. io7_csr rsvd5[33];
  92. /* System Address Space Window Control Registers */
  93. io7_csr POx_WBASE[4]; /* 0x1000 */
  94. io7_csr POx_WMASK[4];
  95. io7_csr POx_TBASE[4];
  96. io7_csr POx_SG_TBIA;
  97. io7_csr POx_MSI_WBASE;
  98. io7_csr rsvd6[50];
  99. /* I/O Port Error Registers */
  100. io7_csr POx_ERR_SUM;
  101. io7_csr POx_FIRST_ERR;
  102. io7_csr POx_MSK_HEI;
  103. io7_csr POx_TLB_ERR;
  104. io7_csr POx_SPL_COMPLT;
  105. io7_csr POx_TRANS_SUM;
  106. io7_csr POx_FRC_PCI_ERR;
  107. io7_csr POx_MULT_ERR;
  108. io7_csr rsvd7[8];
  109. /* I/O Port End of Interrupt Registers */
  110. io7_csr EOI_DAT;
  111. io7_csr rsvd8[7];
  112. io7_csr POx_IACK_SPECIAL;
  113. io7_csr rsvd9[103];
  114. } io7_ioport_csrs;
  115. typedef struct {
  116. io7_csr IO_ASIC_REV; /* 0x30.0000 */
  117. io7_csr IO_SYS_REV;
  118. io7_csr SER_CHAIN3;
  119. io7_csr PO7_RST1;
  120. io7_csr PO7_RST2; /* 0x30.0100 */
  121. io7_csr POx_RST[4];
  122. io7_csr IO7_DWNH;
  123. io7_csr IO7_MAF;
  124. io7_csr IO7_MAF_TO;
  125. io7_csr IO7_ACC_CLUMP; /* 0x30.0300 */
  126. io7_csr IO7_PMASK;
  127. io7_csr IO7_IOMASK;
  128. io7_csr IO7_UPH;
  129. io7_csr IO7_UPH_TO; /* 0x30.0400 */
  130. io7_csr RBX_IREQ_OFF;
  131. io7_csr RBX_INTA_OFF;
  132. io7_csr INT_RTY;
  133. io7_csr PO7_MONCTL; /* 0x30.0500 */
  134. io7_csr PO7_CTRA;
  135. io7_csr PO7_CTRB;
  136. io7_csr PO7_CTR56;
  137. io7_csr PO7_SCRATCH; /* 0x30.0600 */
  138. io7_csr PO7_XTRA_A;
  139. io7_csr PO7_XTRA_TS;
  140. io7_csr PO7_XTRA_Z;
  141. io7_csr PO7_PMASK; /* 0x30.0700 */
  142. io7_csr PO7_THRESHA;
  143. io7_csr PO7_THRESHB;
  144. io7_csr rsvd1[97];
  145. io7_csr PO7_ERROR_SUM; /* 0x30.2000 */
  146. io7_csr PO7_BHOLE_MASK;
  147. io7_csr PO7_HEI_MSK;
  148. io7_csr PO7_CRD_MSK;
  149. io7_csr PO7_UNCRR_SYM; /* 0x30.2100 */
  150. io7_csr PO7_CRRCT_SYM;
  151. io7_csr PO7_ERR_PKT[2];
  152. io7_csr PO7_UGBGE_SYM; /* 0x30.2200 */
  153. io7_csr rsbv2[887];
  154. io7_csr PO7_LSI_CTL[128]; /* 0x31.0000 */
  155. io7_csr rsvd3[123];
  156. io7_csr HLT_CTL; /* 0x31.3ec0 */
  157. io7_csr HPI_CTL; /* 0x31.3f00 */
  158. io7_csr CRD_CTL;
  159. io7_csr STV_CTL;
  160. io7_csr HEI_CTL;
  161. io7_csr PO7_MSI_CTL[16]; /* 0x31.4000 */
  162. io7_csr rsvd4[240];
  163. /*
  164. * Interrupt Diagnostic / Test
  165. */
  166. struct {
  167. io7_csr INT_PND;
  168. io7_csr INT_CLR;
  169. io7_csr INT_EOI;
  170. io7_csr rsvd[29];
  171. } INT_DIAG[4];
  172. io7_csr rsvd5[125]; /* 0x31.a000 */
  173. io7_csr MISC_PND; /* 0x31.b800 */
  174. io7_csr rsvd6[31];
  175. io7_csr MSI_PND[16]; /* 0x31.c000 */
  176. io7_csr rsvd7[16];
  177. io7_csr MSI_CLR[16]; /* 0x31.c800 */
  178. } io7_port7_csrs;
  179. /*
  180. * IO7 DMA Window Base register (POx_WBASEx)
  181. */
  182. #define wbase_m_ena 0x1
  183. #define wbase_m_sg 0x2
  184. #define wbase_m_dac 0x4
  185. #define wbase_m_addr 0xFFF00000
  186. union IO7_POx_WBASE {
  187. struct {
  188. unsigned ena : 1; /* <0> */
  189. unsigned sg : 1; /* <1> */
  190. unsigned dac : 1; /* <2> -- window 3 only */
  191. unsigned rsvd1 : 17;
  192. unsigned addr : 12; /* <31:20> */
  193. unsigned rsvd2 : 32;
  194. } bits;
  195. unsigned as_long[2];
  196. unsigned as_quad;
  197. };
  198. /*
  199. * IO7 IID (Interrupt IDentifier) format
  200. *
  201. * For level-sensative interrupts, int_num is encoded as:
  202. *
  203. * bus/port slot/device INTx
  204. * <7:5> <4:2> <1:0>
  205. */
  206. union IO7_IID {
  207. struct {
  208. unsigned int_num : 9; /* <8:0> */
  209. unsigned tpu_mask : 4; /* <12:9> rsvd */
  210. unsigned msi : 1; /* 13 */
  211. unsigned ipe : 10; /* <23:14> */
  212. unsigned long rsvd : 40;
  213. } bits;
  214. unsigned int as_long[2];
  215. unsigned long as_quad;
  216. };
  217. /*
  218. * IO7 addressing macros
  219. */
  220. #define IO7_KERN_ADDR(addr) (EV7_KERN_ADDR(addr))
  221. #define IO7_PORT_MASK 0x07UL /* 3 bits of port */
  222. #define IO7_IPE(pe) (EV7_IPE(pe))
  223. #define IO7_IPORT(port) ((~((long)(port)) & IO7_PORT_MASK) << 32)
  224. #define IO7_HOSE(pe, port) (IO7_IPE(pe) | IO7_IPORT(port))
  225. #define IO7_MEM_PHYS(pe, port) (IO7_HOSE(pe, port) | 0x00000000UL)
  226. #define IO7_CONF_PHYS(pe, port) (IO7_HOSE(pe, port) | 0xFE000000UL)
  227. #define IO7_IO_PHYS(pe, port) (IO7_HOSE(pe, port) | 0xFF000000UL)
  228. #define IO7_CSR_PHYS(pe, port, off) \
  229. (IO7_HOSE(pe, port) | 0xFF800000UL | (off))
  230. #define IO7_CSRS_PHYS(pe, port) (IO7_CSR_PHYS(pe, port, 0UL))
  231. #define IO7_PORT7_CSRS_PHYS(pe) (IO7_CSR_PHYS(pe, 7, 0x300000UL))
  232. #define IO7_MEM_KERN(pe, port) (IO7_KERN_ADDR(IO7_MEM_PHYS(pe, port)))
  233. #define IO7_CONF_KERN(pe, port) (IO7_KERN_ADDR(IO7_CONF_PHYS(pe, port)))
  234. #define IO7_IO_KERN(pe, port) (IO7_KERN_ADDR(IO7_IO_PHYS(pe, port)))
  235. #define IO7_CSR_KERN(pe, port, off) (IO7_KERN_ADDR(IO7_CSR_PHYS(pe,port,off)))
  236. #define IO7_CSRS_KERN(pe, port) (IO7_KERN_ADDR(IO7_CSRS_PHYS(pe, port)))
  237. #define IO7_PORT7_CSRS_KERN(pe) (IO7_KERN_ADDR(IO7_PORT7_CSRS_PHYS(pe)))
  238. #define IO7_PLL_RNGA(pll) (((pll) >> 3) & 0x7)
  239. #define IO7_PLL_RNGB(pll) (((pll) >> 6) & 0x7)
  240. #define IO7_MEM_SPACE (2UL * 1024 * 1024 * 1024) /* 2GB MEM */
  241. #define IO7_IO_SPACE (8UL * 1024 * 1024) /* 8MB I/O */
  242. /*
  243. * Offset between ram physical addresses and pci64 DAC addresses
  244. */
  245. #define IO7_DAC_OFFSET (1UL << 49)
  246. /*
  247. * This is needed to satisify the IO() macro used in initializing the machvec
  248. */
  249. #define MARVEL_IACK_SC \
  250. ((unsigned long) \
  251. (&(((io7_ioport_csrs *)IO7_CSRS_KERN(0, 0))->POx_IACK_SPECIAL)))
  252. #ifdef __KERNEL__
  253. /*
  254. * IO7 structs
  255. */
  256. #define IO7_NUM_PORTS 4
  257. #define IO7_AGP_PORT 3
  258. struct io7_port {
  259. struct io7 *io7;
  260. struct pci_controller *hose;
  261. int enabled;
  262. unsigned int port;
  263. io7_ioport_csrs *csrs;
  264. unsigned long saved_wbase[4];
  265. unsigned long saved_wmask[4];
  266. unsigned long saved_tbase[4];
  267. };
  268. struct io7 {
  269. struct io7 *next;
  270. unsigned int pe;
  271. io7_port7_csrs *csrs;
  272. struct io7_port ports[IO7_NUM_PORTS];
  273. spinlock_t irq_lock;
  274. };
  275. #ifndef __EXTERN_INLINE
  276. # define __EXTERN_INLINE extern inline
  277. # define __IO_EXTERN_INLINE
  278. #endif
  279. /*
  280. * I/O functions. All access through linear space.
  281. */
  282. /*
  283. * Memory functions. All accesses through linear space.
  284. */
  285. #define vucp volatile unsigned char __force *
  286. #define vusp volatile unsigned short __force *
  287. extern unsigned int marvel_ioread8(void __iomem *);
  288. extern void marvel_iowrite8(u8 b, void __iomem *);
  289. __EXTERN_INLINE unsigned int marvel_ioread16(void __iomem *addr)
  290. {
  291. return __kernel_ldwu(*(vusp)addr);
  292. }
  293. __EXTERN_INLINE void marvel_iowrite16(u16 b, void __iomem *addr)
  294. {
  295. __kernel_stw(b, *(vusp)addr);
  296. }
  297. extern void __iomem *marvel_ioremap(unsigned long addr, unsigned long size);
  298. extern void marvel_iounmap(volatile void __iomem *addr);
  299. extern void __iomem *marvel_ioportmap (unsigned long addr);
  300. __EXTERN_INLINE int marvel_is_ioaddr(unsigned long addr)
  301. {
  302. return (addr >> 40) & 1;
  303. }
  304. extern int marvel_is_mmio(const volatile void __iomem *);
  305. #undef vucp
  306. #undef vusp
  307. #undef __IO_PREFIX
  308. #define __IO_PREFIX marvel
  309. #define marvel_trivial_rw_bw 1
  310. #define marvel_trivial_rw_lq 1
  311. #define marvel_trivial_io_bw 0
  312. #define marvel_trivial_io_lq 1
  313. #define marvel_trivial_iounmap 0
  314. #include <asm/io_trivial.h>
  315. #ifdef __IO_EXTERN_INLINE
  316. # undef __EXTERN_INLINE
  317. # undef __IO_EXTERN_INLINE
  318. #endif
  319. #endif /* __KERNEL__ */
  320. #endif /* __ALPHA_MARVEL__H__ */