/kern_2.6.32/arch/alpha/kernel/sys_noritake.c

http://omnia2droid.googlecode.com/ · C · 352 lines · 219 code · 41 blank · 92 comment · 23 complexity · 07b8c068bde52c94c6f77c8eff1437fb MD5 · raw file

  1. /*
  2. * linux/arch/alpha/kernel/sys_noritake.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 NORITAKE (AlphaServer 1000A),
  9. * CORELLE (AlphaServer 800), and ALCOR Primo (AlphaStation 600A).
  10. */
  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. noritake_update_irq_hw(int irq, int mask)
  36. {
  37. int port = 0x54a;
  38. if (irq >= 32) {
  39. mask >>= 16;
  40. port = 0x54c;
  41. }
  42. outw(mask, port);
  43. }
  44. static void
  45. noritake_enable_irq(unsigned int irq)
  46. {
  47. noritake_update_irq_hw(irq, cached_irq_mask |= 1 << (irq - 16));
  48. }
  49. static void
  50. noritake_disable_irq(unsigned int irq)
  51. {
  52. noritake_update_irq_hw(irq, cached_irq_mask &= ~(1 << (irq - 16)));
  53. }
  54. static unsigned int
  55. noritake_startup_irq(unsigned int irq)
  56. {
  57. noritake_enable_irq(irq);
  58. return 0;
  59. }
  60. static void
  61. noritake_end_irq(unsigned int irq)
  62. {
  63. if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
  64. noritake_enable_irq(irq);
  65. }
  66. static struct irq_chip noritake_irq_type = {
  67. .name = "NORITAKE",
  68. .startup = noritake_startup_irq,
  69. .shutdown = noritake_disable_irq,
  70. .enable = noritake_enable_irq,
  71. .disable = noritake_disable_irq,
  72. .ack = noritake_disable_irq,
  73. .end = noritake_end_irq,
  74. };
  75. static void
  76. noritake_device_interrupt(unsigned long vector)
  77. {
  78. unsigned long pld;
  79. unsigned int i;
  80. /* Read the interrupt summary registers of NORITAKE */
  81. pld = (((unsigned long) inw(0x54c) << 32)
  82. | ((unsigned long) inw(0x54a) << 16)
  83. | ((unsigned long) inb(0xa0) << 8)
  84. | inb(0x20));
  85. /*
  86. * Now for every possible bit set, work through them and call
  87. * the appropriate interrupt handler.
  88. */
  89. while (pld) {
  90. i = ffz(~pld);
  91. pld &= pld - 1; /* clear least bit set */
  92. if (i < 16) {
  93. isa_device_interrupt(vector);
  94. } else {
  95. handle_irq(i);
  96. }
  97. }
  98. }
  99. static void
  100. noritake_srm_device_interrupt(unsigned long vector)
  101. {
  102. int irq;
  103. irq = (vector - 0x800) >> 4;
  104. /*
  105. * I really hate to do this, too, but the NORITAKE SRM console also
  106. * reports PCI vectors *lower* than I expected from the bit numbers
  107. * in the documentation.
  108. * But I really don't want to change the fixup code for allocation
  109. * of IRQs, nor the alpha_irq_mask maintenance stuff, both of which
  110. * look nice and clean now.
  111. * So, here's this additional grotty hack... :-(
  112. */
  113. if (irq >= 16)
  114. irq = irq + 1;
  115. handle_irq(irq);
  116. }
  117. static void __init
  118. noritake_init_irq(void)
  119. {
  120. long i;
  121. if (alpha_using_srm)
  122. alpha_mv.device_interrupt = noritake_srm_device_interrupt;
  123. outw(0, 0x54a);
  124. outw(0, 0x54c);
  125. for (i = 16; i < 48; ++i) {
  126. irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
  127. irq_desc[i].chip = &noritake_irq_type;
  128. }
  129. init_i8259a_irqs();
  130. common_init_isa_dma();
  131. }
  132. /*
  133. * PCI Fixup configuration.
  134. *
  135. * Summary @ 0x542, summary register #1:
  136. * Bit Meaning
  137. * 0 All valid ints from summary regs 2 & 3
  138. * 1 QLOGIC ISP1020A SCSI
  139. * 2 Interrupt Line A from slot 0
  140. * 3 Interrupt Line B from slot 0
  141. * 4 Interrupt Line A from slot 1
  142. * 5 Interrupt line B from slot 1
  143. * 6 Interrupt Line A from slot 2
  144. * 7 Interrupt Line B from slot 2
  145. * 8 Interrupt Line A from slot 3
  146. * 9 Interrupt Line B from slot 3
  147. *10 Interrupt Line A from slot 4
  148. *11 Interrupt Line B from slot 4
  149. *12 Interrupt Line A from slot 5
  150. *13 Interrupt Line B from slot 5
  151. *14 Interrupt Line A from slot 6
  152. *15 Interrupt Line B from slot 6
  153. *
  154. * Summary @ 0x544, summary register #2:
  155. * Bit Meaning
  156. * 0 OR of all unmasked ints in SR #2
  157. * 1 OR of secondary bus ints
  158. * 2 Interrupt Line C from slot 0
  159. * 3 Interrupt Line D from slot 0
  160. * 4 Interrupt Line C from slot 1
  161. * 5 Interrupt line D from slot 1
  162. * 6 Interrupt Line C from slot 2
  163. * 7 Interrupt Line D from slot 2
  164. * 8 Interrupt Line C from slot 3
  165. * 9 Interrupt Line D from slot 3
  166. *10 Interrupt Line C from slot 4
  167. *11 Interrupt Line D from slot 4
  168. *12 Interrupt Line C from slot 5
  169. *13 Interrupt Line D from slot 5
  170. *14 Interrupt Line C from slot 6
  171. *15 Interrupt Line D from slot 6
  172. *
  173. * The device to slot mapping looks like:
  174. *
  175. * Slot Device
  176. * 7 Intel PCI-EISA bridge chip
  177. * 8 DEC PCI-PCI bridge chip
  178. * 11 PCI on board slot 0
  179. * 12 PCI on board slot 1
  180. * 13 PCI on board slot 2
  181. *
  182. *
  183. * This two layered interrupt approach means that we allocate IRQ 16 and
  184. * above for PCI interrupts. The IRQ relates to which bit the interrupt
  185. * comes in on. This makes interrupt processing much easier.
  186. */
  187. static int __init
  188. noritake_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  189. {
  190. static char irq_tab[15][5] __initdata = {
  191. /*INT INTA INTB INTC INTD */
  192. /* note: IDSELs 16, 17, and 25 are CORELLE only */
  193. { 16+1, 16+1, 16+1, 16+1, 16+1}, /* IdSel 16, QLOGIC */
  194. { -1, -1, -1, -1, -1}, /* IdSel 17, S3 Trio64 */
  195. { -1, -1, -1, -1, -1}, /* IdSel 18, PCEB */
  196. { -1, -1, -1, -1, -1}, /* IdSel 19, PPB */
  197. { -1, -1, -1, -1, -1}, /* IdSel 20, ???? */
  198. { -1, -1, -1, -1, -1}, /* IdSel 21, ???? */
  199. { 16+2, 16+2, 16+3, 32+2, 32+3}, /* IdSel 22, slot 0 */
  200. { 16+4, 16+4, 16+5, 32+4, 32+5}, /* IdSel 23, slot 1 */
  201. { 16+6, 16+6, 16+7, 32+6, 32+7}, /* IdSel 24, slot 2 */
  202. { 16+8, 16+8, 16+9, 32+8, 32+9}, /* IdSel 25, slot 3 */
  203. /* The following 5 are actually on PCI bus 1, which is
  204. across the built-in bridge of the NORITAKE only. */
  205. { 16+1, 16+1, 16+1, 16+1, 16+1}, /* IdSel 16, QLOGIC */
  206. { 16+8, 16+8, 16+9, 32+8, 32+9}, /* IdSel 17, slot 3 */
  207. {16+10, 16+10, 16+11, 32+10, 32+11}, /* IdSel 18, slot 4 */
  208. {16+12, 16+12, 16+13, 32+12, 32+13}, /* IdSel 19, slot 5 */
  209. {16+14, 16+14, 16+15, 32+14, 32+15}, /* IdSel 20, slot 6 */
  210. };
  211. const long min_idsel = 5, max_idsel = 19, irqs_per_slot = 5;
  212. return COMMON_TABLE_LOOKUP;
  213. }
  214. static u8 __init
  215. noritake_swizzle(struct pci_dev *dev, u8 *pinp)
  216. {
  217. int slot, pin = *pinp;
  218. if (dev->bus->number == 0) {
  219. slot = PCI_SLOT(dev->devfn);
  220. }
  221. /* Check for the built-in bridge */
  222. else if (PCI_SLOT(dev->bus->self->devfn) == 8) {
  223. slot = PCI_SLOT(dev->devfn) + 15; /* WAG! */
  224. }
  225. else
  226. {
  227. /* Must be a card-based bridge. */
  228. do {
  229. if (PCI_SLOT(dev->bus->self->devfn) == 8) {
  230. slot = PCI_SLOT(dev->devfn) + 15;
  231. break;
  232. }
  233. pin = pci_swizzle_interrupt_pin(dev, pin);
  234. /* Move up the chain of bridges. */
  235. dev = dev->bus->self;
  236. /* Slot of the next bridge. */
  237. slot = PCI_SLOT(dev->devfn);
  238. } while (dev->bus->self);
  239. }
  240. *pinp = pin;
  241. return slot;
  242. }
  243. #if defined(CONFIG_ALPHA_GENERIC) || !defined(CONFIG_ALPHA_PRIMO)
  244. static void
  245. noritake_apecs_machine_check(unsigned long vector, unsigned long la_ptr)
  246. {
  247. #define MCHK_NO_DEVSEL 0x205U
  248. #define MCHK_NO_TABT 0x204U
  249. struct el_common *mchk_header;
  250. unsigned int code;
  251. mchk_header = (struct el_common *)la_ptr;
  252. /* Clear the error before any reporting. */
  253. mb();
  254. mb(); /* magic */
  255. draina();
  256. apecs_pci_clr_err();
  257. wrmces(0x7);
  258. mb();
  259. code = mchk_header->code;
  260. process_mcheck_info(vector, la_ptr, "NORITAKE APECS",
  261. (mcheck_expected(0)
  262. && (code == MCHK_NO_DEVSEL
  263. || code == MCHK_NO_TABT)));
  264. }
  265. #endif
  266. /*
  267. * The System Vectors
  268. */
  269. #if defined(CONFIG_ALPHA_GENERIC) || !defined(CONFIG_ALPHA_PRIMO)
  270. struct alpha_machine_vector noritake_mv __initmv = {
  271. .vector_name = "Noritake",
  272. DO_EV4_MMU,
  273. DO_DEFAULT_RTC,
  274. DO_APECS_IO,
  275. .machine_check = noritake_apecs_machine_check,
  276. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  277. .min_io_address = EISA_DEFAULT_IO_BASE,
  278. .min_mem_address = APECS_AND_LCA_DEFAULT_MEM_BASE,
  279. .nr_irqs = 48,
  280. .device_interrupt = noritake_device_interrupt,
  281. .init_arch = apecs_init_arch,
  282. .init_irq = noritake_init_irq,
  283. .init_rtc = common_init_rtc,
  284. .init_pci = common_init_pci,
  285. .pci_map_irq = noritake_map_irq,
  286. .pci_swizzle = noritake_swizzle,
  287. };
  288. ALIAS_MV(noritake)
  289. #endif
  290. #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_PRIMO)
  291. struct alpha_machine_vector noritake_primo_mv __initmv = {
  292. .vector_name = "Noritake-Primo",
  293. DO_EV5_MMU,
  294. DO_DEFAULT_RTC,
  295. DO_CIA_IO,
  296. .machine_check = cia_machine_check,
  297. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  298. .min_io_address = EISA_DEFAULT_IO_BASE,
  299. .min_mem_address = CIA_DEFAULT_MEM_BASE,
  300. .nr_irqs = 48,
  301. .device_interrupt = noritake_device_interrupt,
  302. .init_arch = cia_init_arch,
  303. .init_irq = noritake_init_irq,
  304. .init_rtc = common_init_rtc,
  305. .init_pci = cia_init_pci,
  306. .kill_arch = cia_kill_arch,
  307. .pci_map_irq = noritake_map_irq,
  308. .pci_swizzle = noritake_swizzle,
  309. };
  310. ALIAS_MV(noritake_primo)
  311. #endif