sys_mikasa.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /*
  2. * linux/arch/alpha/kernel/sys_mikasa.c
  3. *
  4. * Copyright (C) 1995 David A Rusling
  5. * Copyright (C) 1996 Jay A Estabrook
  6. * Copyright (C) 1998, 1999 Richard Henderson
  7. *
  8. * Code supporting the MIKASA (AlphaServer 1000).
  9. */
  10. #include <linux/config.h>
  11. #include <linux/kernel.h>
  12. #include <linux/types.h>
  13. #include <linux/mm.h>
  14. #include <linux/sched.h>
  15. #include <linux/pci.h>
  16. #include <linux/init.h>
  17. #include <linux/bitops.h>
  18. #include <asm/ptrace.h>
  19. #include <asm/system.h>
  20. #include <asm/dma.h>
  21. #include <asm/irq.h>
  22. #include <asm/mmu_context.h>
  23. #include <asm/io.h>
  24. #include <asm/pgtable.h>
  25. #include <asm/core_apecs.h>
  26. #include <asm/core_cia.h>
  27. #include <asm/tlbflush.h>
  28. #include "proto.h"
  29. #include "irq_impl.h"
  30. #include "pci_impl.h"
  31. #include "machvec_impl.h"
  32. /* Note mask bit is true for ENABLED irqs. */
  33. static int cached_irq_mask;
  34. static inline void
  35. mikasa_update_irq_hw(int mask)
  36. {
  37. outw(mask, 0x536);
  38. }
  39. static inline void
  40. mikasa_enable_irq(unsigned int irq)
  41. {
  42. mikasa_update_irq_hw(cached_irq_mask |= 1 << (irq - 16));
  43. }
  44. static void
  45. mikasa_disable_irq(unsigned int irq)
  46. {
  47. mikasa_update_irq_hw(cached_irq_mask &= ~(1 << (irq - 16)));
  48. }
  49. static unsigned int
  50. mikasa_startup_irq(unsigned int irq)
  51. {
  52. mikasa_enable_irq(irq);
  53. return 0;
  54. }
  55. static void
  56. mikasa_end_irq(unsigned int irq)
  57. {
  58. if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
  59. mikasa_enable_irq(irq);
  60. }
  61. static struct hw_interrupt_type mikasa_irq_type = {
  62. .typename = "MIKASA",
  63. .startup = mikasa_startup_irq,
  64. .shutdown = mikasa_disable_irq,
  65. .enable = mikasa_enable_irq,
  66. .disable = mikasa_disable_irq,
  67. .ack = mikasa_disable_irq,
  68. .end = mikasa_end_irq,
  69. };
  70. static void
  71. mikasa_device_interrupt(unsigned long vector, struct pt_regs *regs)
  72. {
  73. unsigned long pld;
  74. unsigned int i;
  75. /* Read the interrupt summary registers */
  76. pld = (((~inw(0x534) & 0x0000ffffUL) << 16)
  77. | (((unsigned long) inb(0xa0)) << 8)
  78. | inb(0x20));
  79. /*
  80. * Now for every possible bit set, work through them and call
  81. * the appropriate interrupt handler.
  82. */
  83. while (pld) {
  84. i = ffz(~pld);
  85. pld &= pld - 1; /* clear least bit set */
  86. if (i < 16) {
  87. isa_device_interrupt(vector, regs);
  88. } else {
  89. handle_irq(i, regs);
  90. }
  91. }
  92. }
  93. static void __init
  94. mikasa_init_irq(void)
  95. {
  96. long i;
  97. if (alpha_using_srm)
  98. alpha_mv.device_interrupt = srm_device_interrupt;
  99. mikasa_update_irq_hw(0);
  100. for (i = 16; i < 32; ++i) {
  101. irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
  102. irq_desc[i].handler = &mikasa_irq_type;
  103. }
  104. init_i8259a_irqs();
  105. common_init_isa_dma();
  106. }
  107. /*
  108. * PCI Fixup configuration.
  109. *
  110. * Summary @ 0x536:
  111. * Bit Meaning
  112. * 0 Interrupt Line A from slot 0
  113. * 1 Interrupt Line B from slot 0
  114. * 2 Interrupt Line C from slot 0
  115. * 3 Interrupt Line D from slot 0
  116. * 4 Interrupt Line A from slot 1
  117. * 5 Interrupt line B from slot 1
  118. * 6 Interrupt Line C from slot 1
  119. * 7 Interrupt Line D from slot 1
  120. * 8 Interrupt Line A from slot 2
  121. * 9 Interrupt Line B from slot 2
  122. *10 Interrupt Line C from slot 2
  123. *11 Interrupt Line D from slot 2
  124. *12 NCR 810 SCSI
  125. *13 Power Supply Fail
  126. *14 Temperature Warn
  127. *15 Reserved
  128. *
  129. * The device to slot mapping looks like:
  130. *
  131. * Slot Device
  132. * 6 NCR SCSI controller
  133. * 7 Intel PCI-EISA bridge chip
  134. * 11 PCI on board slot 0
  135. * 12 PCI on board slot 1
  136. * 13 PCI on board slot 2
  137. *
  138. *
  139. * This two layered interrupt approach means that we allocate IRQ 16 and
  140. * above for PCI interrupts. The IRQ relates to which bit the interrupt
  141. * comes in on. This makes interrupt processing much easier.
  142. */
  143. static int __init
  144. mikasa_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  145. {
  146. static char irq_tab[8][5] __initdata = {
  147. /*INT INTA INTB INTC INTD */
  148. {16+12, 16+12, 16+12, 16+12, 16+12}, /* IdSel 17, SCSI */
  149. { -1, -1, -1, -1, -1}, /* IdSel 18, PCEB */
  150. { -1, -1, -1, -1, -1}, /* IdSel 19, ???? */
  151. { -1, -1, -1, -1, -1}, /* IdSel 20, ???? */
  152. { -1, -1, -1, -1, -1}, /* IdSel 21, ???? */
  153. { 16+0, 16+0, 16+1, 16+2, 16+3}, /* IdSel 22, slot 0 */
  154. { 16+4, 16+4, 16+5, 16+6, 16+7}, /* IdSel 23, slot 1 */
  155. { 16+8, 16+8, 16+9, 16+10, 16+11}, /* IdSel 24, slot 2 */
  156. };
  157. const long min_idsel = 6, max_idsel = 13, irqs_per_slot = 5;
  158. return COMMON_TABLE_LOOKUP;
  159. }
  160. #if defined(CONFIG_ALPHA_GENERIC) || !defined(CONFIG_ALPHA_PRIMO)
  161. static void
  162. mikasa_apecs_machine_check(unsigned long vector, unsigned long la_ptr,
  163. struct pt_regs * regs)
  164. {
  165. #define MCHK_NO_DEVSEL 0x205U
  166. #define MCHK_NO_TABT 0x204U
  167. struct el_common *mchk_header;
  168. unsigned int code;
  169. mchk_header = (struct el_common *)la_ptr;
  170. /* Clear the error before any reporting. */
  171. mb();
  172. mb(); /* magic */
  173. draina();
  174. apecs_pci_clr_err();
  175. wrmces(0x7);
  176. mb();
  177. code = mchk_header->code;
  178. process_mcheck_info(vector, la_ptr, regs, "MIKASA APECS",
  179. (mcheck_expected(0)
  180. && (code == MCHK_NO_DEVSEL
  181. || code == MCHK_NO_TABT)));
  182. }
  183. #endif
  184. /*
  185. * The System Vector
  186. */
  187. #if defined(CONFIG_ALPHA_GENERIC) || !defined(CONFIG_ALPHA_PRIMO)
  188. struct alpha_machine_vector mikasa_mv __initmv = {
  189. .vector_name = "Mikasa",
  190. DO_EV4_MMU,
  191. DO_DEFAULT_RTC,
  192. DO_APECS_IO,
  193. .machine_check = mikasa_apecs_machine_check,
  194. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  195. .min_io_address = DEFAULT_IO_BASE,
  196. .min_mem_address = APECS_AND_LCA_DEFAULT_MEM_BASE,
  197. .nr_irqs = 32,
  198. .device_interrupt = mikasa_device_interrupt,
  199. .init_arch = apecs_init_arch,
  200. .init_irq = mikasa_init_irq,
  201. .init_rtc = common_init_rtc,
  202. .init_pci = common_init_pci,
  203. .pci_map_irq = mikasa_map_irq,
  204. .pci_swizzle = common_swizzle,
  205. };
  206. ALIAS_MV(mikasa)
  207. #endif
  208. #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_PRIMO)
  209. struct alpha_machine_vector mikasa_primo_mv __initmv = {
  210. .vector_name = "Mikasa-Primo",
  211. DO_EV5_MMU,
  212. DO_DEFAULT_RTC,
  213. DO_CIA_IO,
  214. .machine_check = cia_machine_check,
  215. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  216. .min_io_address = DEFAULT_IO_BASE,
  217. .min_mem_address = CIA_DEFAULT_MEM_BASE,
  218. .nr_irqs = 32,
  219. .device_interrupt = mikasa_device_interrupt,
  220. .init_arch = cia_init_arch,
  221. .init_irq = mikasa_init_irq,
  222. .init_rtc = common_init_rtc,
  223. .init_pci = cia_init_pci,
  224. .kill_arch = cia_kill_arch,
  225. .pci_map_irq = mikasa_map_irq,
  226. .pci_swizzle = common_swizzle,
  227. };
  228. ALIAS_MV(mikasa_primo)
  229. #endif