irq.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * arch/mips/ddb5476/irq.c -- NEC DDB Vrc-5476 interrupt routines
  3. *
  4. * Copyright (C) 2000 Geert Uytterhoeven <geert@sonycom.com>
  5. * Sony Software Development Center Europe (SDCE), Brussels
  6. *
  7. * Re-write the whole thing to use new irq.c file.
  8. * Copyright (C) 2001 MontaVista Software Inc.
  9. * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
  10. *
  11. */
  12. #include <linux/init.h>
  13. #include <linux/sched.h>
  14. #include <linux/types.h>
  15. #include <linux/interrupt.h>
  16. #include <asm/i8259.h>
  17. #include <asm/io.h>
  18. #include <asm/ptrace.h>
  19. #include <asm/ddb5xxx/ddb5xxx.h>
  20. #define M1543_PNP_CONFIG 0x03f0 /* PnP Config Port */
  21. #define M1543_PNP_INDEX 0x03f0 /* PnP Index Port */
  22. #define M1543_PNP_DATA 0x03f1 /* PnP Data Port */
  23. #define M1543_PNP_ALT_CONFIG 0x0370 /* Alternative PnP Config Port */
  24. #define M1543_PNP_ALT_INDEX 0x0370 /* Alternative PnP Index Port */
  25. #define M1543_PNP_ALT_DATA 0x0371 /* Alternative PnP Data Port */
  26. #define M1543_INT1_MASTER_CTRL 0x0020 /* INT_1 (master) Control Register */
  27. #define M1543_INT1_MASTER_MASK 0x0021 /* INT_1 (master) Mask Register */
  28. #define M1543_INT1_SLAVE_CTRL 0x00a0 /* INT_1 (slave) Control Register */
  29. #define M1543_INT1_SLAVE_MASK 0x00a1 /* INT_1 (slave) Mask Register */
  30. #define M1543_INT1_MASTER_ELCR 0x04d0 /* INT_1 (master) Edge/Level Control */
  31. #define M1543_INT1_SLAVE_ELCR 0x04d1 /* INT_1 (slave) Edge/Level Control */
  32. static void m1543_irq_setup(void)
  33. {
  34. /*
  35. * The ALI M1543 has 13 interrupt inputs, IRQ1..IRQ13. Not all
  36. * the possible IO sources in the M1543 are in use by us. We will
  37. * use the following mapping:
  38. *
  39. * IRQ1 - keyboard (default set by M1543)
  40. * IRQ3 - reserved for UART B (default set by M1543) (note that
  41. * the schematics for the DDB Vrc-5476 board seem to
  42. * indicate that IRQ3 is connected to the DS1386
  43. * watchdog timer interrupt output so we might have
  44. * a conflict)
  45. * IRQ4 - reserved for UART A (default set by M1543)
  46. * IRQ5 - parallel (default set by M1543)
  47. * IRQ8 - DS1386 time of day (RTC) interrupt
  48. * IRQ9 - USB (hardwired in ddb_setup)
  49. * IRQ10 - PMU (hardwired in ddb_setup)
  50. * IRQ12 - mouse
  51. * IRQ14,15 - IDE controller (need to be confirmed, jsun)
  52. */
  53. /*
  54. * Assing mouse interrupt to IRQ12
  55. */
  56. /* Enter configuration mode */
  57. outb(0x51, M1543_PNP_CONFIG);
  58. outb(0x23, M1543_PNP_CONFIG);
  59. /* Select logical device 7 (Keyboard) */
  60. outb(0x07, M1543_PNP_INDEX);
  61. outb(0x07, M1543_PNP_DATA);
  62. /* Select IRQ12 */
  63. outb(0x72, M1543_PNP_INDEX);
  64. outb(0x0c, M1543_PNP_DATA);
  65. /* Leave configration mode */
  66. outb(0xbb, M1543_PNP_CONFIG);
  67. }
  68. static void nile4_irq_setup(void)
  69. {
  70. int i;
  71. /* Map all interrupts to CPU int #0 (IP2) */
  72. nile4_map_irq_all(0);
  73. /* PCI INTA#-E# must be level triggered */
  74. nile4_set_pci_irq_level_or_edge(0, 1);
  75. nile4_set_pci_irq_level_or_edge(1, 1);
  76. nile4_set_pci_irq_level_or_edge(2, 1);
  77. nile4_set_pci_irq_level_or_edge(3, 1);
  78. /* PCI INTA#, B#, D# must be active low, INTC# must be active high */
  79. nile4_set_pci_irq_polarity(0, 0);
  80. nile4_set_pci_irq_polarity(1, 0);
  81. nile4_set_pci_irq_polarity(2, 1);
  82. nile4_set_pci_irq_polarity(3, 0);
  83. for (i = 0; i < 16; i++)
  84. nile4_clear_irq(i);
  85. /* Enable CPU int #0 */
  86. nile4_enable_irq_output(0);
  87. /* memory resource acquire in ddb_setup */
  88. }
  89. static struct irqaction irq_cascade = { no_action, 0, CPU_MASK_NONE, "cascade", NULL, NULL };
  90. static struct irqaction irq_error = { no_action, 0, CPU_MASK_NONE, "error", NULL, NULL };
  91. extern asmlinkage void ddb5476_handle_int(void);
  92. extern int setup_irq(unsigned int irq, struct irqaction *irqaction);
  93. extern void mips_cpu_irq_init(u32 irq_base);
  94. extern void vrc5476_irq_init(u32 irq_base);
  95. void __init arch_init_irq(void)
  96. {
  97. /* hardware initialization */
  98. nile4_irq_setup();
  99. m1543_irq_setup();
  100. /* controller setup */
  101. init_i8259_irqs();
  102. vrc5476_irq_init(VRC5476_IRQ_BASE);
  103. mips_cpu_irq_init(CPU_IRQ_BASE);
  104. /* setup cascade interrupts */
  105. setup_irq(VRC5476_IRQ_BASE + VRC5476_I8259_CASCADE, &irq_cascade);
  106. setup_irq(CPU_IRQ_BASE + CPU_VRC5476_CASCADE, &irq_cascade);
  107. /* setup error interrupts for debugging */
  108. setup_irq(VRC5476_IRQ_BASE + VRC5476_IRQ_CPCE, &irq_error);
  109. setup_irq(VRC5476_IRQ_BASE + VRC5476_IRQ_CNTD, &irq_error);
  110. setup_irq(VRC5476_IRQ_BASE + VRC5476_IRQ_MCE, &irq_error);
  111. setup_irq(VRC5476_IRQ_BASE + VRC5476_IRQ_LBRT, &irq_error);
  112. setup_irq(VRC5476_IRQ_BASE + VRC5476_IRQ_PCIS, &irq_error);
  113. setup_irq(VRC5476_IRQ_BASE + VRC5476_IRQ_PCI, &irq_error);
  114. /* setup the grandpa intr vector */
  115. set_except_vector(0, ddb5476_handle_int);
  116. }