Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
irq.c
Go to the documentation of this file.
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 
18 #define R2D_NR_IRL 13
19 
20 enum {
21  UNUSED = 0,
22 
23  /* board specific interrupt sources (R2D-1 and R2D-PLUS) */
24  EXT, /* EXT_INT0-3 */
25  RTC_T, RTC_A, /* Real Time Clock */
26  AX88796, /* Ethernet controller (R2D-1 board) */
27  KEY, /* Key input (R2D-PLUS board) */
28  SDCARD, /* SD Card */
29  CF_CD, CF_IDE, /* CF Card Detect + CF IDE */
30  SM501, /* SM501 aka Voyager */
31  PCI_INTD_RTL8139, /* Ethernet controller */
32  PCI_INTC_PCI1520, /* Cardbus/PCMCIA bridge */
33  PCI_INTB_RTL8139, /* Ethernet controller with HUB (R2D-PLUS board) */
34  PCI_INTB_SLOT, /* PCI Slot 3.3v (R2D-1 board) */
35  PCI_INTA_SLOT, /* PCI Slot 3.3v */
36  TP, /* Touch Panel */
37 };
38 
39 #ifdef CONFIG_RTS7751R2D_1
40 
41 /* Vectors for R2D-1 */
42 static struct intc_vect vectors_r2d_1[] __initdata = {
52  INTC_IRQ(TP, IRQ_TP),
53 };
54 
55 /* IRLMSK mask register layout for R2D-1 */
56 static struct intc_mask_reg mask_registers_r2d_1[] __initdata = {
57  { 0xa4000000, 0, 16, /* IRLMSK */
61  RTC_A, RTC_T, 0, 0, 0, EXT } },
62 };
63 
64 /* IRLn to IRQ table for R2D-1 */
65 static unsigned char irl2irq_r2d_1[R2D_NR_IRL] __initdata = {
69  IRQ_TP,
70 };
71 
72 static DECLARE_INTC_DESC(intc_desc_r2d_1, "r2d-1", vectors_r2d_1,
73  NULL, mask_registers_r2d_1, NULL, NULL);
74 
75 #endif /* CONFIG_RTS7751R2D_1 */
76 
77 #ifdef CONFIG_RTS7751R2D_PLUS
78 
79 /* Vectors for R2D-PLUS */
80 static struct intc_vect vectors_r2d_plus[] __initdata = {
90  INTC_IRQ(TP, IRQ_TP),
91 };
92 
93 /* IRLMSK mask register layout for R2D-PLUS */
94 static struct intc_mask_reg mask_registers_r2d_plus[] __initdata = {
95  { 0xa4000000, 0, 16, /* IRLMSK */
99  RTC_A, RTC_T, 0, 0, 0, EXT } },
100 };
101 
102 /* IRLn to IRQ table for R2D-PLUS */
103 static unsigned char irl2irq_r2d_plus[R2D_NR_IRL] __initdata = {
107  IRQ_TP,
108 };
109 
110 static DECLARE_INTC_DESC(intc_desc_r2d_plus, "r2d-plus", vectors_r2d_plus,
111  NULL, mask_registers_r2d_plus, NULL, NULL);
112 
113 #endif /* CONFIG_RTS7751R2D_PLUS */
114 
115 static unsigned char irl2irq[R2D_NR_IRL];
116 
118 {
119  if (irq >= R2D_NR_IRL || irq < 0 || !irl2irq[irq])
120  return irq;
121 
122  return irl2irq[irq];
123 }
124 
125 /*
126  * Initialize IRQ setting
127  */
129 {
130  struct intc_desc *d;
131 
132  switch (__raw_readw(PA_VERREG) & 0xf0) {
133 #ifdef CONFIG_RTS7751R2D_PLUS
134  case 0x10:
135  printk(KERN_INFO "Using R2D-PLUS interrupt controller.\n");
136  d = &intc_desc_r2d_plus;
137  memcpy(irl2irq, irl2irq_r2d_plus, R2D_NR_IRL);
138  break;
139 #endif
140 #ifdef CONFIG_RTS7751R2D_1
141  case 0x00: /* according to manual */
142  case 0x30: /* in reality */
143  printk(KERN_INFO "Using R2D-1 interrupt controller.\n");
144  d = &intc_desc_r2d_1;
145  memcpy(irl2irq, irl2irq_r2d_1, R2D_NR_IRL);
146  break;
147 #endif
148  default:
149  printk(KERN_INFO "Unknown R2D interrupt controller 0x%04x\n",
151  return;
152  }
153 
155 }