irq.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * linux/arch/sh/boards/renesas/rts7751r2d/irq.c
  3. *
  4. * Copyright (C) 2007 Magnus Damm
  5. * Copyright (C) 2000 Kazumoto Kojima
  6. *
  7. * Renesas Technology Sales RTS7751R2D Support, R2D-PLUS and R2D-1.
  8. *
  9. * Modified for RTS7751R2D by
  10. * Atom Create Engineering Co., Ltd. 2002.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/irq.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/io.h>
  16. #include <mach/r2d.h>
  17. #define R2D_NR_IRL 13
  18. enum {
  19. UNUSED = 0,
  20. /* board specific interrupt sources (R2D-1 and R2D-PLUS) */
  21. EXT, /* EXT_INT0-3 */
  22. RTC_T, RTC_A, /* Real Time Clock */
  23. AX88796, /* Ethernet controller (R2D-1 board) */
  24. KEY, /* Key input (R2D-PLUS board) */
  25. SDCARD, /* SD Card */
  26. CF_CD, CF_IDE, /* CF Card Detect + CF IDE */
  27. SM501, /* SM501 aka Voyager */
  28. PCI_INTD_RTL8139, /* Ethernet controller */
  29. PCI_INTC_PCI1520, /* Cardbus/PCMCIA bridge */
  30. PCI_INTB_RTL8139, /* Ethernet controller with HUB (R2D-PLUS board) */
  31. PCI_INTB_SLOT, /* PCI Slot 3.3v (R2D-1 board) */
  32. PCI_INTA_SLOT, /* PCI Slot 3.3v */
  33. TP, /* Touch Panel */
  34. };
  35. #ifdef CONFIG_RTS7751R2D_1
  36. /* Vectors for R2D-1 */
  37. static struct intc_vect vectors_r2d_1[] __initdata = {
  38. INTC_IRQ(EXT, IRQ_EXT),
  39. INTC_IRQ(RTC_T, IRQ_RTC_T), INTC_IRQ(RTC_A, IRQ_RTC_A),
  40. INTC_IRQ(AX88796, IRQ_AX88796), INTC_IRQ(SDCARD, IRQ_SDCARD),
  41. INTC_IRQ(CF_CD, IRQ_CF_CD), INTC_IRQ(CF_IDE, IRQ_CF_IDE), /* ng */
  42. INTC_IRQ(SM501, IRQ_VOYAGER),
  43. INTC_IRQ(PCI_INTD_RTL8139, IRQ_PCI_INTD),
  44. INTC_IRQ(PCI_INTC_PCI1520, IRQ_PCI_INTC),
  45. INTC_IRQ(PCI_INTB_SLOT, IRQ_PCI_INTB),
  46. INTC_IRQ(PCI_INTA_SLOT, IRQ_PCI_INTA),
  47. INTC_IRQ(TP, IRQ_TP),
  48. };
  49. /* IRLMSK mask register layout for R2D-1 */
  50. static struct intc_mask_reg mask_registers_r2d_1[] __initdata = {
  51. { 0xa4000000, 0, 16, /* IRLMSK */
  52. { TP, PCI_INTA_SLOT, PCI_INTB_SLOT,
  53. PCI_INTC_PCI1520, PCI_INTD_RTL8139,
  54. SM501, CF_IDE, CF_CD, SDCARD, AX88796,
  55. RTC_A, RTC_T, 0, 0, 0, EXT } },
  56. };
  57. /* IRLn to IRQ table for R2D-1 */
  58. static unsigned char irl2irq_r2d_1[R2D_NR_IRL] __initdata = {
  59. IRQ_PCI_INTD, IRQ_CF_IDE, IRQ_CF_CD, IRQ_PCI_INTC,
  60. IRQ_VOYAGER, IRQ_AX88796, IRQ_RTC_A, IRQ_RTC_T,
  61. IRQ_SDCARD, IRQ_PCI_INTA, IRQ_PCI_INTB, IRQ_EXT,
  62. IRQ_TP,
  63. };
  64. static DECLARE_INTC_DESC(intc_desc_r2d_1, "r2d-1", vectors_r2d_1,
  65. NULL, mask_registers_r2d_1, NULL, NULL);
  66. #endif /* CONFIG_RTS7751R2D_1 */
  67. #ifdef CONFIG_RTS7751R2D_PLUS
  68. /* Vectors for R2D-PLUS */
  69. static struct intc_vect vectors_r2d_plus[] __initdata = {
  70. INTC_IRQ(EXT, IRQ_EXT),
  71. INTC_IRQ(RTC_T, IRQ_RTC_T), INTC_IRQ(RTC_A, IRQ_RTC_A),
  72. INTC_IRQ(KEY, IRQ_KEY), INTC_IRQ(SDCARD, IRQ_SDCARD),
  73. INTC_IRQ(CF_CD, IRQ_CF_CD), INTC_IRQ(CF_IDE, IRQ_CF_IDE),
  74. INTC_IRQ(SM501, IRQ_VOYAGER),
  75. INTC_IRQ(PCI_INTD_RTL8139, IRQ_PCI_INTD),
  76. INTC_IRQ(PCI_INTC_PCI1520, IRQ_PCI_INTC),
  77. INTC_IRQ(PCI_INTB_RTL8139, IRQ_PCI_INTB),
  78. INTC_IRQ(PCI_INTA_SLOT, IRQ_PCI_INTA),
  79. INTC_IRQ(TP, IRQ_TP),
  80. };
  81. /* IRLMSK mask register layout for R2D-PLUS */
  82. static struct intc_mask_reg mask_registers_r2d_plus[] __initdata = {
  83. { 0xa4000000, 0, 16, /* IRLMSK */
  84. { TP, PCI_INTA_SLOT, PCI_INTB_RTL8139,
  85. PCI_INTC_PCI1520, PCI_INTD_RTL8139,
  86. SM501, CF_IDE, CF_CD, SDCARD, KEY,
  87. RTC_A, RTC_T, 0, 0, 0, EXT } },
  88. };
  89. /* IRLn to IRQ table for R2D-PLUS */
  90. static unsigned char irl2irq_r2d_plus[R2D_NR_IRL] __initdata = {
  91. IRQ_PCI_INTD, IRQ_CF_IDE, IRQ_CF_CD, IRQ_PCI_INTC,
  92. IRQ_VOYAGER, IRQ_KEY, IRQ_RTC_A, IRQ_RTC_T,
  93. IRQ_SDCARD, IRQ_PCI_INTA, IRQ_PCI_INTB, IRQ_EXT,
  94. IRQ_TP,
  95. };
  96. static DECLARE_INTC_DESC(intc_desc_r2d_plus, "r2d-plus", vectors_r2d_plus,
  97. NULL, mask_registers_r2d_plus, NULL, NULL);
  98. #endif /* CONFIG_RTS7751R2D_PLUS */
  99. static unsigned char irl2irq[R2D_NR_IRL];
  100. int rts7751r2d_irq_demux(int irq)
  101. {
  102. if (irq >= R2D_NR_IRL || irq < 0 || !irl2irq[irq])
  103. return irq;
  104. return irl2irq[irq];
  105. }
  106. /*
  107. * Initialize IRQ setting
  108. */
  109. void __init init_rts7751r2d_IRQ(void)
  110. {
  111. struct intc_desc *d;
  112. switch (__raw_readw(PA_VERREG) & 0xf0) {
  113. #ifdef CONFIG_RTS7751R2D_PLUS
  114. case 0x10:
  115. printk(KERN_INFO "Using R2D-PLUS interrupt controller.\n");
  116. d = &intc_desc_r2d_plus;
  117. memcpy(irl2irq, irl2irq_r2d_plus, R2D_NR_IRL);
  118. break;
  119. #endif
  120. #ifdef CONFIG_RTS7751R2D_1
  121. case 0x00: /* according to manual */
  122. case 0x30: /* in reality */
  123. printk(KERN_INFO "Using R2D-1 interrupt controller.\n");
  124. d = &intc_desc_r2d_1;
  125. memcpy(irl2irq, irl2irq_r2d_1, R2D_NR_IRL);
  126. break;
  127. #endif
  128. default:
  129. printk(KERN_INFO "Unknown R2D interrupt controller 0x%04x\n",
  130. __raw_readw(PA_VERREG));
  131. return;
  132. }
  133. register_intc_controller(d);
  134. }