sys_cabriolet.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. /*
  2. * linux/arch/alpha/kernel/sys_cabriolet.c
  3. *
  4. * Copyright (C) 1995 David A Rusling
  5. * Copyright (C) 1996 Jay A Estabrook
  6. * Copyright (C) 1998, 1999, 2000 Richard Henderson
  7. *
  8. * Code supporting the Cabriolet (AlphaPC64), EB66+, and EB164,
  9. * PC164 and LX164.
  10. */
  11. #include <linux/config.h>
  12. #include <linux/kernel.h>
  13. #include <linux/types.h>
  14. #include <linux/mm.h>
  15. #include <linux/sched.h>
  16. #include <linux/pci.h>
  17. #include <linux/init.h>
  18. #include <linux/bitops.h>
  19. #include <asm/ptrace.h>
  20. #include <asm/system.h>
  21. #include <asm/dma.h>
  22. #include <asm/irq.h>
  23. #include <asm/mmu_context.h>
  24. #include <asm/io.h>
  25. #include <asm/pgtable.h>
  26. #include <asm/core_apecs.h>
  27. #include <asm/core_cia.h>
  28. #include <asm/core_lca.h>
  29. #include <asm/tlbflush.h>
  30. #include "proto.h"
  31. #include "irq_impl.h"
  32. #include "pci_impl.h"
  33. #include "machvec_impl.h"
  34. /* Note mask bit is true for DISABLED irqs. */
  35. static unsigned long cached_irq_mask = ~0UL;
  36. static inline void
  37. cabriolet_update_irq_hw(unsigned int irq, unsigned long mask)
  38. {
  39. int ofs = (irq - 16) / 8;
  40. outb(mask >> (16 + ofs * 8), 0x804 + ofs);
  41. }
  42. static inline void
  43. cabriolet_enable_irq(unsigned int irq)
  44. {
  45. cabriolet_update_irq_hw(irq, cached_irq_mask &= ~(1UL << irq));
  46. }
  47. static void
  48. cabriolet_disable_irq(unsigned int irq)
  49. {
  50. cabriolet_update_irq_hw(irq, cached_irq_mask |= 1UL << irq);
  51. }
  52. static unsigned int
  53. cabriolet_startup_irq(unsigned int irq)
  54. {
  55. cabriolet_enable_irq(irq);
  56. return 0; /* never anything pending */
  57. }
  58. static void
  59. cabriolet_end_irq(unsigned int irq)
  60. {
  61. if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
  62. cabriolet_enable_irq(irq);
  63. }
  64. static struct hw_interrupt_type cabriolet_irq_type = {
  65. .typename = "CABRIOLET",
  66. .startup = cabriolet_startup_irq,
  67. .shutdown = cabriolet_disable_irq,
  68. .enable = cabriolet_enable_irq,
  69. .disable = cabriolet_disable_irq,
  70. .ack = cabriolet_disable_irq,
  71. .end = cabriolet_end_irq,
  72. };
  73. static void
  74. cabriolet_device_interrupt(unsigned long v, struct pt_regs *r)
  75. {
  76. unsigned long pld;
  77. unsigned int i;
  78. /* Read the interrupt summary registers */
  79. pld = inb(0x804) | (inb(0x805) << 8) | (inb(0x806) << 16);
  80. /*
  81. * Now for every possible bit set, work through them and call
  82. * the appropriate interrupt handler.
  83. */
  84. while (pld) {
  85. i = ffz(~pld);
  86. pld &= pld - 1; /* clear least bit set */
  87. if (i == 4) {
  88. isa_device_interrupt(v, r);
  89. } else {
  90. handle_irq(16 + i, r);
  91. }
  92. }
  93. }
  94. static void __init
  95. common_init_irq(void (*srm_dev_int)(unsigned long v, struct pt_regs *r))
  96. {
  97. init_i8259a_irqs();
  98. if (alpha_using_srm) {
  99. alpha_mv.device_interrupt = srm_dev_int;
  100. init_srm_irqs(35, 0);
  101. }
  102. else {
  103. long i;
  104. outb(0xff, 0x804);
  105. outb(0xff, 0x805);
  106. outb(0xff, 0x806);
  107. for (i = 16; i < 35; ++i) {
  108. irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
  109. irq_desc[i].handler = &cabriolet_irq_type;
  110. }
  111. }
  112. common_init_isa_dma();
  113. setup_irq(16+4, &isa_cascade_irqaction);
  114. }
  115. #ifndef CONFIG_ALPHA_PC164
  116. static void __init
  117. cabriolet_init_irq(void)
  118. {
  119. common_init_irq(srm_device_interrupt);
  120. }
  121. #endif
  122. #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_PC164)
  123. /* In theory, the PC164 has the same interrupt hardware as the other
  124. Cabriolet based systems. However, something got screwed up late
  125. in the development cycle which broke the interrupt masking hardware.
  126. Repeat, it is not possible to mask and ack interrupts. At all.
  127. In an attempt to work around this, while processing interrupts,
  128. we do not allow the IPL to drop below what it is currently. This
  129. prevents the possibility of recursion.
  130. ??? Another option might be to force all PCI devices to use edge
  131. triggered rather than level triggered interrupts. That might be
  132. too invasive though. */
  133. static void
  134. pc164_srm_device_interrupt(unsigned long v, struct pt_regs *r)
  135. {
  136. __min_ipl = getipl();
  137. srm_device_interrupt(v, r);
  138. __min_ipl = 0;
  139. }
  140. static void
  141. pc164_device_interrupt(unsigned long v, struct pt_regs *r)
  142. {
  143. __min_ipl = getipl();
  144. cabriolet_device_interrupt(v, r);
  145. __min_ipl = 0;
  146. }
  147. static void __init
  148. pc164_init_irq(void)
  149. {
  150. common_init_irq(pc164_srm_device_interrupt);
  151. }
  152. #endif
  153. /*
  154. * The EB66+ is very similar to the EB66 except that it does not have
  155. * the on-board NCR and Tulip chips. In the code below, I have used
  156. * slot number to refer to the id select line and *not* the slot
  157. * number used in the EB66+ documentation. However, in the table,
  158. * I've given the slot number, the id select line and the Jxx number
  159. * that's printed on the board. The interrupt pins from the PCI slots
  160. * are wired into 3 interrupt summary registers at 0x804, 0x805 and
  161. * 0x806 ISA.
  162. *
  163. * In the table, -1 means don't assign an IRQ number. This is usually
  164. * because it is the Saturn IO (SIO) PCI/ISA Bridge Chip.
  165. */
  166. static inline int __init
  167. eb66p_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  168. {
  169. static char irq_tab[5][5] __initdata = {
  170. /*INT INTA INTB INTC INTD */
  171. {16+0, 16+0, 16+5, 16+9, 16+13}, /* IdSel 6, slot 0, J25 */
  172. {16+1, 16+1, 16+6, 16+10, 16+14}, /* IdSel 7, slot 1, J26 */
  173. { -1, -1, -1, -1, -1}, /* IdSel 8, SIO */
  174. {16+2, 16+2, 16+7, 16+11, 16+15}, /* IdSel 9, slot 2, J27 */
  175. {16+3, 16+3, 16+8, 16+12, 16+6} /* IdSel 10, slot 3, J28 */
  176. };
  177. const long min_idsel = 6, max_idsel = 10, irqs_per_slot = 5;
  178. return COMMON_TABLE_LOOKUP;
  179. }
  180. /*
  181. * The AlphaPC64 is very similar to the EB66+ except that its slots
  182. * are numbered differently. In the code below, I have used slot
  183. * number to refer to the id select line and *not* the slot number
  184. * used in the AlphaPC64 documentation. However, in the table, I've
  185. * given the slot number, the id select line and the Jxx number that's
  186. * printed on the board. The interrupt pins from the PCI slots are
  187. * wired into 3 interrupt summary registers at 0x804, 0x805 and 0x806
  188. * ISA.
  189. *
  190. * In the table, -1 means don't assign an IRQ number. This is usually
  191. * because it is the Saturn IO (SIO) PCI/ISA Bridge Chip.
  192. */
  193. static inline int __init
  194. cabriolet_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  195. {
  196. static char irq_tab[5][5] __initdata = {
  197. /*INT INTA INTB INTC INTD */
  198. { 16+2, 16+2, 16+7, 16+11, 16+15}, /* IdSel 5, slot 2, J21 */
  199. { 16+0, 16+0, 16+5, 16+9, 16+13}, /* IdSel 6, slot 0, J19 */
  200. { 16+1, 16+1, 16+6, 16+10, 16+14}, /* IdSel 7, slot 1, J20 */
  201. { -1, -1, -1, -1, -1}, /* IdSel 8, SIO */
  202. { 16+3, 16+3, 16+8, 16+12, 16+16} /* IdSel 9, slot 3, J22 */
  203. };
  204. const long min_idsel = 5, max_idsel = 9, irqs_per_slot = 5;
  205. return COMMON_TABLE_LOOKUP;
  206. }
  207. static inline void __init
  208. cabriolet_init_pci(void)
  209. {
  210. common_init_pci();
  211. ns87312_enable_ide(0x398);
  212. }
  213. static inline void __init
  214. cia_cab_init_pci(void)
  215. {
  216. cia_init_pci();
  217. ns87312_enable_ide(0x398);
  218. }
  219. /*
  220. * The PC164 and LX164 have 19 PCI interrupts, four from each of the four
  221. * PCI slots, the SIO, PCI/IDE, and USB.
  222. *
  223. * Each of the interrupts can be individually masked. This is
  224. * accomplished by setting the appropriate bit in the mask register.
  225. * A bit is set by writing a "1" to the desired position in the mask
  226. * register and cleared by writing a "0". There are 3 mask registers
  227. * located at ISA address 804h, 805h and 806h.
  228. *
  229. * An I/O read at ISA address 804h, 805h, 806h will return the
  230. * state of the 11 PCI interrupts and not the state of the MASKED
  231. * interrupts.
  232. *
  233. * Note: A write to I/O 804h, 805h, and 806h the mask register will be
  234. * updated.
  235. *
  236. *
  237. * ISA DATA<7:0>
  238. * ISA +--------------------------------------------------------------+
  239. * ADDRESS | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  240. * +==============================================================+
  241. * 0x804 | INTB0 | USB | IDE | SIO | INTA3 |INTA2 | INTA1 | INTA0 |
  242. * +--------------------------------------------------------------+
  243. * 0x805 | INTD0 | INTC3 | INTC2 | INTC1 | INTC0 |INTB3 | INTB2 | INTB1 |
  244. * +--------------------------------------------------------------+
  245. * 0x806 | Rsrv | Rsrv | Rsrv | Rsrv | Rsrv |INTD3 | INTD2 | INTD1 |
  246. * +--------------------------------------------------------------+
  247. * * Rsrv = reserved bits
  248. * Note: The mask register is write-only.
  249. *
  250. * IdSel
  251. * 5 32 bit PCI option slot 2
  252. * 6 64 bit PCI option slot 0
  253. * 7 64 bit PCI option slot 1
  254. * 8 Saturn I/O
  255. * 9 32 bit PCI option slot 3
  256. * 10 USB
  257. * 11 IDE
  258. *
  259. */
  260. static inline int __init
  261. alphapc164_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  262. {
  263. static char irq_tab[7][5] __initdata = {
  264. /*INT INTA INTB INTC INTD */
  265. { 16+2, 16+2, 16+9, 16+13, 16+17}, /* IdSel 5, slot 2, J20 */
  266. { 16+0, 16+0, 16+7, 16+11, 16+15}, /* IdSel 6, slot 0, J29 */
  267. { 16+1, 16+1, 16+8, 16+12, 16+16}, /* IdSel 7, slot 1, J26 */
  268. { -1, -1, -1, -1, -1}, /* IdSel 8, SIO */
  269. { 16+3, 16+3, 16+10, 16+14, 16+18}, /* IdSel 9, slot 3, J19 */
  270. { 16+6, 16+6, 16+6, 16+6, 16+6}, /* IdSel 10, USB */
  271. { 16+5, 16+5, 16+5, 16+5, 16+5} /* IdSel 11, IDE */
  272. };
  273. const long min_idsel = 5, max_idsel = 11, irqs_per_slot = 5;
  274. return COMMON_TABLE_LOOKUP;
  275. }
  276. static inline void __init
  277. alphapc164_init_pci(void)
  278. {
  279. cia_init_pci();
  280. SMC93x_Init();
  281. }
  282. /*
  283. * The System Vector
  284. */
  285. #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_CABRIOLET)
  286. struct alpha_machine_vector cabriolet_mv __initmv = {
  287. .vector_name = "Cabriolet",
  288. DO_EV4_MMU,
  289. DO_DEFAULT_RTC,
  290. DO_APECS_IO,
  291. .machine_check = apecs_machine_check,
  292. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  293. .min_io_address = DEFAULT_IO_BASE,
  294. .min_mem_address = APECS_AND_LCA_DEFAULT_MEM_BASE,
  295. .nr_irqs = 35,
  296. .device_interrupt = cabriolet_device_interrupt,
  297. .init_arch = apecs_init_arch,
  298. .init_irq = cabriolet_init_irq,
  299. .init_rtc = common_init_rtc,
  300. .init_pci = cabriolet_init_pci,
  301. .pci_map_irq = cabriolet_map_irq,
  302. .pci_swizzle = common_swizzle,
  303. };
  304. #ifndef CONFIG_ALPHA_EB64P
  305. ALIAS_MV(cabriolet)
  306. #endif
  307. #endif
  308. #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EB164)
  309. struct alpha_machine_vector eb164_mv __initmv = {
  310. .vector_name = "EB164",
  311. DO_EV5_MMU,
  312. DO_DEFAULT_RTC,
  313. DO_CIA_IO,
  314. .machine_check = cia_machine_check,
  315. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  316. .min_io_address = DEFAULT_IO_BASE,
  317. .min_mem_address = CIA_DEFAULT_MEM_BASE,
  318. .nr_irqs = 35,
  319. .device_interrupt = cabriolet_device_interrupt,
  320. .init_arch = cia_init_arch,
  321. .init_irq = cabriolet_init_irq,
  322. .init_rtc = common_init_rtc,
  323. .init_pci = cia_cab_init_pci,
  324. .kill_arch = cia_kill_arch,
  325. .pci_map_irq = cabriolet_map_irq,
  326. .pci_swizzle = common_swizzle,
  327. };
  328. ALIAS_MV(eb164)
  329. #endif
  330. #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EB66P)
  331. struct alpha_machine_vector eb66p_mv __initmv = {
  332. .vector_name = "EB66+",
  333. DO_EV4_MMU,
  334. DO_DEFAULT_RTC,
  335. DO_LCA_IO,
  336. .machine_check = lca_machine_check,
  337. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  338. .min_io_address = DEFAULT_IO_BASE,
  339. .min_mem_address = APECS_AND_LCA_DEFAULT_MEM_BASE,
  340. .nr_irqs = 35,
  341. .device_interrupt = cabriolet_device_interrupt,
  342. .init_arch = lca_init_arch,
  343. .init_irq = cabriolet_init_irq,
  344. .init_rtc = common_init_rtc,
  345. .init_pci = cabriolet_init_pci,
  346. .pci_map_irq = eb66p_map_irq,
  347. .pci_swizzle = common_swizzle,
  348. };
  349. ALIAS_MV(eb66p)
  350. #endif
  351. #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_LX164)
  352. struct alpha_machine_vector lx164_mv __initmv = {
  353. .vector_name = "LX164",
  354. DO_EV5_MMU,
  355. DO_DEFAULT_RTC,
  356. DO_PYXIS_IO,
  357. .machine_check = cia_machine_check,
  358. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  359. .min_io_address = DEFAULT_IO_BASE,
  360. .min_mem_address = DEFAULT_MEM_BASE,
  361. .pci_dac_offset = PYXIS_DAC_OFFSET,
  362. .nr_irqs = 35,
  363. .device_interrupt = cabriolet_device_interrupt,
  364. .init_arch = pyxis_init_arch,
  365. .init_irq = cabriolet_init_irq,
  366. .init_rtc = common_init_rtc,
  367. .init_pci = alphapc164_init_pci,
  368. .kill_arch = cia_kill_arch,
  369. .pci_map_irq = alphapc164_map_irq,
  370. .pci_swizzle = common_swizzle,
  371. };
  372. ALIAS_MV(lx164)
  373. #endif
  374. #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_PC164)
  375. struct alpha_machine_vector pc164_mv __initmv = {
  376. .vector_name = "PC164",
  377. DO_EV5_MMU,
  378. DO_DEFAULT_RTC,
  379. DO_CIA_IO,
  380. .machine_check = cia_machine_check,
  381. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  382. .min_io_address = DEFAULT_IO_BASE,
  383. .min_mem_address = CIA_DEFAULT_MEM_BASE,
  384. .nr_irqs = 35,
  385. .device_interrupt = pc164_device_interrupt,
  386. .init_arch = cia_init_arch,
  387. .init_irq = pc164_init_irq,
  388. .init_rtc = common_init_rtc,
  389. .init_pci = alphapc164_init_pci,
  390. .kill_arch = cia_kill_arch,
  391. .pci_map_irq = alphapc164_map_irq,
  392. .pci_swizzle = common_swizzle,
  393. };
  394. ALIAS_MV(pc164)
  395. #endif