blob: 574f009c3c31099437d581250449f60d7264119d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/sh/boards/renesas/rts7751r2d/irq.c
3 *
Magnus Damm2eeec852007-08-12 15:29:16 +09004 * Copyright (C) 2007 Magnus Damm
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * Copyright (C) 2000 Kazumoto Kojima
6 *
Magnus Damm2eeec852007-08-12 15:29:16 +09007 * Renesas Technology Sales RTS7751R2D Support, R2D-PLUS and R2D-1.
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 *
9 * Modified for RTS7751R2D by
10 * Atom Create Engineering Co., Ltd. 2002.
11 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/init.h>
13#include <linux/irq.h>
Paul Mundt9c575482007-02-15 18:20:52 +090014#include <linux/interrupt.h>
Paul Mundt082c44d2006-10-19 16:16:18 +090015#include <linux/io.h>
Paul Mundt7639a452008-10-20 13:02:48 +090016#include <mach/r2d.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Magnus Damm2eeec852007-08-12 15:29:16 +090018#define R2D_NR_IRL 13
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
Magnus Damm2eeec852007-08-12 15:29:16 +090020enum {
21 UNUSED = 0,
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
Magnus Damm2eeec852007-08-12 15:29:16 +090023 /* 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 */
42static struct intc_vect vectors_r2d_1[] __initdata = {
43 INTC_IRQ(EXT, IRQ_EXT),
44 INTC_IRQ(RTC_T, IRQ_RTC_T), INTC_IRQ(RTC_A, IRQ_RTC_A),
45 INTC_IRQ(AX88796, IRQ_AX88796), INTC_IRQ(SDCARD, IRQ_SDCARD),
46 INTC_IRQ(CF_CD, IRQ_CF_CD), INTC_IRQ(CF_IDE, IRQ_CF_IDE), /* ng */
47 INTC_IRQ(SM501, IRQ_VOYAGER),
48 INTC_IRQ(PCI_INTD_RTL8139, IRQ_PCI_INTD),
49 INTC_IRQ(PCI_INTC_PCI1520, IRQ_PCI_INTC),
50 INTC_IRQ(PCI_INTB_SLOT, IRQ_PCI_INTB),
51 INTC_IRQ(PCI_INTA_SLOT, IRQ_PCI_INTA),
52 INTC_IRQ(TP, IRQ_TP),
53};
54
55/* IRLMSK mask register layout for R2D-1 */
56static struct intc_mask_reg mask_registers_r2d_1[] __initdata = {
57 { 0xa4000000, 0, 16, /* IRLMSK */
58 { TP, PCI_INTA_SLOT, PCI_INTB_SLOT,
59 PCI_INTC_PCI1520, PCI_INTD_RTL8139,
60 SM501, CF_IDE, CF_CD, SDCARD, AX88796,
61 RTC_A, RTC_T, 0, 0, 0, EXT } },
62};
63
64/* IRLn to IRQ table for R2D-1 */
65static unsigned char irl2irq_r2d_1[R2D_NR_IRL] __initdata = {
66 IRQ_PCI_INTD, IRQ_CF_IDE, IRQ_CF_CD, IRQ_PCI_INTC,
67 IRQ_VOYAGER, IRQ_AX88796, IRQ_RTC_A, IRQ_RTC_T,
68 IRQ_SDCARD, IRQ_PCI_INTA, IRQ_PCI_INTB, IRQ_EXT,
69 IRQ_TP,
70};
71
Magnus Damm5c37e022007-08-17 00:45:35 +090072static DECLARE_INTC_DESC(intc_desc_r2d_1, "r2d-1", vectors_r2d_1,
Magnus Damm7f3edee2008-01-10 14:08:55 +090073 NULL, mask_registers_r2d_1, NULL, NULL);
Magnus Damm2eeec852007-08-12 15:29:16 +090074
75#endif /* CONFIG_RTS7751R2D_1 */
76
77#ifdef CONFIG_RTS7751R2D_PLUS
78
79/* Vectors for R2D-PLUS */
80static struct intc_vect vectors_r2d_plus[] __initdata = {
81 INTC_IRQ(EXT, IRQ_EXT),
82 INTC_IRQ(RTC_T, IRQ_RTC_T), INTC_IRQ(RTC_A, IRQ_RTC_A),
83 INTC_IRQ(KEY, IRQ_KEY), INTC_IRQ(SDCARD, IRQ_SDCARD),
84 INTC_IRQ(CF_CD, IRQ_CF_CD), INTC_IRQ(CF_IDE, IRQ_CF_IDE),
85 INTC_IRQ(SM501, IRQ_VOYAGER),
86 INTC_IRQ(PCI_INTD_RTL8139, IRQ_PCI_INTD),
87 INTC_IRQ(PCI_INTC_PCI1520, IRQ_PCI_INTC),
88 INTC_IRQ(PCI_INTB_RTL8139, IRQ_PCI_INTB),
89 INTC_IRQ(PCI_INTA_SLOT, IRQ_PCI_INTA),
90 INTC_IRQ(TP, IRQ_TP),
91};
92
93/* IRLMSK mask register layout for R2D-PLUS */
94static struct intc_mask_reg mask_registers_r2d_plus[] __initdata = {
95 { 0xa4000000, 0, 16, /* IRLMSK */
96 { TP, PCI_INTA_SLOT, PCI_INTB_RTL8139,
97 PCI_INTC_PCI1520, PCI_INTD_RTL8139,
98 SM501, CF_IDE, CF_CD, SDCARD, KEY,
99 RTC_A, RTC_T, 0, 0, 0, EXT } },
100};
101
102/* IRLn to IRQ table for R2D-PLUS */
103static unsigned char irl2irq_r2d_plus[R2D_NR_IRL] __initdata = {
104 IRQ_PCI_INTD, IRQ_CF_IDE, IRQ_CF_CD, IRQ_PCI_INTC,
105 IRQ_VOYAGER, IRQ_KEY, IRQ_RTC_A, IRQ_RTC_T,
106 IRQ_SDCARD, IRQ_PCI_INTA, IRQ_PCI_INTB, IRQ_EXT,
107 IRQ_TP,
108};
109
Magnus Damm5c37e022007-08-17 00:45:35 +0900110static DECLARE_INTC_DESC(intc_desc_r2d_plus, "r2d-plus", vectors_r2d_plus,
Magnus Damm7f3edee2008-01-10 14:08:55 +0900111 NULL, mask_registers_r2d_plus, NULL, NULL);
Magnus Damm2eeec852007-08-12 15:29:16 +0900112
113#endif /* CONFIG_RTS7751R2D_PLUS */
114
115static unsigned char irl2irq[R2D_NR_IRL];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
117int rts7751r2d_irq_demux(int irq)
118{
Roel Kluin90163322009-11-02 16:14:42 +0000119 if (irq >= R2D_NR_IRL || irq < 0 || !irl2irq[irq])
Magnus Damm2eeec852007-08-12 15:29:16 +0900120 return irq;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121
Magnus Damm2eeec852007-08-12 15:29:16 +0900122 return irl2irq[irq];
123}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125/*
126 * Initialize IRQ setting
127 */
128void __init init_rts7751r2d_IRQ(void)
129{
Magnus Damm2eeec852007-08-12 15:29:16 +0900130 struct intc_desc *d;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131
Paul Mundt9d56dd32010-01-26 12:58:40 +0900132 switch (__raw_readw(PA_VERREG) & 0xf0) {
Magnus Damm2eeec852007-08-12 15:29:16 +0900133#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
Magnus Damm9cbf3be2007-10-10 18:03:58 +0900141 case 0x00: /* according to manual */
142 case 0x30: /* in reality */
Magnus Damm2eeec852007-08-12 15:29:16 +0900143 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:
Magnus Damm9cbf3be2007-10-10 18:03:58 +0900149 printk(KERN_INFO "Unknown R2D interrupt controller 0x%04x\n",
Paul Mundt9d56dd32010-01-26 12:58:40 +0900150 __raw_readw(PA_VERREG));
Magnus Damm2eeec852007-08-12 15:29:16 +0900151 return;
Paul Mundt9c575482007-02-15 18:20:52 +0900152 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153
Magnus Damm2eeec852007-08-12 15:29:16 +0900154 register_intc_controller(d);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155}