aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMagnus Damm <damm@igel.co.jp>2007-08-12 02:29:16 -0400
committerPaul Mundt <lethal@linux-sh.org>2007-09-20 22:57:50 -0400
commit2eeec85638cebcb6fbcb2abfe182a32252f3456d (patch)
tree3b98f924a5f961d844555794a3564cbc2c3a8be5
parent73505b445dbb8ad12df468404c4dd5cde9c40c65 (diff)
sh: intc - convert board specific r2d code
This patch converts the board specific interrupt code for r2d to make use of intc. While at it we improve the Kconfig to avoid confusion. - Two sets of interrupt tables exist - one for R2D-1 and one for R2D-PLUS. - R2D-1 and R2D-PLUS use the same irq constants. - R2D-1 has AX88796 support, R2D-PLUS does not hook up that IRQ. - R2D-PLUS has KEY support, R2D-1 does not hook up that IRQ. - The number and order of IRQ values are disconnected from register bits. - Interrupt sources now start from IRQ 100. - The machvec demux function converts from irlm IRQ 0-14 to IRQ 100++. Tested on R2D-1 and R2D-PLUS boards. Version 2 adds CONFIG_RTS7751R2D_1 and CONFIG_RTS7751R2D_PLUS together with intc structured as __initdata. Signed-off-by: Magnus Damm <damm@igel.co.jp> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r--arch/sh/boards/renesas/rts7751r2d/Kconfig24
-rw-r--r--arch/sh/boards/renesas/rts7751r2d/irq.c173
-rw-r--r--arch/sh/boards/renesas/rts7751r2d/setup.c8
-rw-r--r--arch/sh/drivers/pci/ops-rts7751r2d.c8
-rw-r--r--include/asm-sh/rts7751r2d.h65
5 files changed, 181 insertions, 97 deletions
diff --git a/arch/sh/boards/renesas/rts7751r2d/Kconfig b/arch/sh/boards/renesas/rts7751r2d/Kconfig
index 7780d1fb13ff..925a7aa861a7 100644
--- a/arch/sh/boards/renesas/rts7751r2d/Kconfig
+++ b/arch/sh/boards/renesas/rts7751r2d/Kconfig
@@ -2,10 +2,28 @@ if SH_RTS7751R2D
2 2
3menu "RTS7751R2D options" 3menu "RTS7751R2D options"
4 4
5config RTS7751R2D_REV11 5choice
6 bool "RTS7751R2D Rev. 1.1 board support" 6 prompt "R2D Board Revision"
7 default RTS7751R2D_PLUS
8
9config RTS7751R2D_PLUS
10 bool "R2D-PLUS"
11 help
12 Selecting this option will configure the kernel for R2D-PLUS.
13
14 R2D-PLUS is the smaller of the two R2D board versions, equipped
15 with a single PCI slot.
16
17config RTS7751R2D_1
18 bool "R2D-1"
7 help 19 help
8 Selecting this option will support version rev. 1.1. 20 Selecting this option will configure the kernel for R2D-1.
21
22 R2D-1 is the larger of the two R2D board versions, equipped
23 with two PCI slots.
24
25endchoice
26
9endmenu 27endmenu
10 28
11endif 29endif
diff --git a/arch/sh/boards/renesas/rts7751r2d/irq.c b/arch/sh/boards/renesas/rts7751r2d/irq.c
index b97c25de3a41..e89932903caf 100644
--- a/arch/sh/boards/renesas/rts7751r2d/irq.c
+++ b/arch/sh/boards/renesas/rts7751r2d/irq.c
@@ -1,9 +1,10 @@
1/* 1/*
2 * linux/arch/sh/boards/renesas/rts7751r2d/irq.c 2 * linux/arch/sh/boards/renesas/rts7751r2d/irq.c
3 * 3 *
4 * Copyright (C) 2007 Magnus Damm
4 * Copyright (C) 2000 Kazumoto Kojima 5 * Copyright (C) 2000 Kazumoto Kojima
5 * 6 *
6 * Renesas Technology Sales RTS7751R2D Support. 7 * Renesas Technology Sales RTS7751R2D Support, R2D-PLUS and R2D-1.
7 * 8 *
8 * Modified for RTS7751R2D by 9 * Modified for RTS7751R2D by
9 * Atom Create Engineering Co., Ltd. 2002. 10 * Atom Create Engineering Co., Ltd. 2002.
@@ -16,67 +17,141 @@
16#include <asm/voyagergx.h> 17#include <asm/voyagergx.h>
17#include <asm/rts7751r2d.h> 18#include <asm/rts7751r2d.h>
18 19
19#if defined(CONFIG_RTS7751R2D_REV11) 20#define R2D_NR_IRL 13
20static int mask_pos[] = {11, 9, 8, 12, 10, 6, 5, 4, 7, 14, 13, 0, 0, 0, 0};
21#else
22static int mask_pos[] = {6, 11, 9, 8, 12, 10, 5, 4, 7, 14, 13, 0, 0, 0, 0};
23#endif
24 21
25static void enable_rts7751r2d_irq(unsigned int irq) 22enum {
26{ 23 UNUSED = 0,
27 /* Set priority in IPR back to original value */
28 ctrl_outw(ctrl_inw(IRLCNTR1) | (1 << mask_pos[irq]), IRLCNTR1);
29}
30 24
31static void disable_rts7751r2d_irq(unsigned int irq) 25 /* board specific interrupt sources (R2D-1 and R2D-PLUS) */
32{ 26 EXT, /* EXT_INT0-3 */
33 /* Set the priority in IPR to 0 */ 27 RTC_T, RTC_A, /* Real Time Clock */
34 ctrl_outw(ctrl_inw(IRLCNTR1) & (0xffff ^ (1 << mask_pos[irq])), 28 AX88796, /* Ethernet controller (R2D-1 board) */
35 IRLCNTR1); 29 KEY, /* Key input (R2D-PLUS board) */
36} 30 SDCARD, /* SD Card */
31 CF_CD, CF_IDE, /* CF Card Detect + CF IDE */
32 SM501, /* SM501 aka Voyager */
33 PCI_INTD_RTL8139, /* Ethernet controller */
34 PCI_INTC_PCI1520, /* Cardbus/PCMCIA bridge */
35 PCI_INTB_RTL8139, /* Ethernet controller with HUB (R2D-PLUS board) */
36 PCI_INTB_SLOT, /* PCI Slot 3.3v (R2D-1 board) */
37 PCI_INTA_SLOT, /* PCI Slot 3.3v */
38 TP, /* Touch Panel */
39};
40
41#ifdef CONFIG_RTS7751R2D_1
42
43/* Vectors for R2D-1 */
44static struct intc_vect vectors_r2d_1[] __initdata = {
45 INTC_IRQ(EXT, IRQ_EXT),
46 INTC_IRQ(RTC_T, IRQ_RTC_T), INTC_IRQ(RTC_A, IRQ_RTC_A),
47 INTC_IRQ(AX88796, IRQ_AX88796), INTC_IRQ(SDCARD, IRQ_SDCARD),
48 INTC_IRQ(CF_CD, IRQ_CF_CD), INTC_IRQ(CF_IDE, IRQ_CF_IDE), /* ng */
49 INTC_IRQ(SM501, IRQ_VOYAGER),
50 INTC_IRQ(PCI_INTD_RTL8139, IRQ_PCI_INTD),
51 INTC_IRQ(PCI_INTC_PCI1520, IRQ_PCI_INTC),
52 INTC_IRQ(PCI_INTB_SLOT, IRQ_PCI_INTB),
53 INTC_IRQ(PCI_INTA_SLOT, IRQ_PCI_INTA),
54 INTC_IRQ(TP, IRQ_TP),
55};
56
57/* IRLMSK mask register layout for R2D-1 */
58static struct intc_mask_reg mask_registers_r2d_1[] __initdata = {
59 { 0xa4000000, 0, 16, /* IRLMSK */
60 { TP, PCI_INTA_SLOT, PCI_INTB_SLOT,
61 PCI_INTC_PCI1520, PCI_INTD_RTL8139,
62 SM501, CF_IDE, CF_CD, SDCARD, AX88796,
63 RTC_A, RTC_T, 0, 0, 0, EXT } },
64};
65
66/* IRLn to IRQ table for R2D-1 */
67static unsigned char irl2irq_r2d_1[R2D_NR_IRL] __initdata = {
68 IRQ_PCI_INTD, IRQ_CF_IDE, IRQ_CF_CD, IRQ_PCI_INTC,
69 IRQ_VOYAGER, IRQ_AX88796, IRQ_RTC_A, IRQ_RTC_T,
70 IRQ_SDCARD, IRQ_PCI_INTA, IRQ_PCI_INTB, IRQ_EXT,
71 IRQ_TP,
72};
73
74static __initdata DECLARE_INTC_DESC(intc_desc_r2d_1, "r2d-1",
75 vectors_r2d_1, NULL, NULL,
76 mask_registers_r2d_1, NULL, NULL);
77
78#endif /* CONFIG_RTS7751R2D_1 */
79
80#ifdef CONFIG_RTS7751R2D_PLUS
81
82/* Vectors for R2D-PLUS */
83static struct intc_vect vectors_r2d_plus[] __initdata = {
84 INTC_IRQ(EXT, IRQ_EXT),
85 INTC_IRQ(RTC_T, IRQ_RTC_T), INTC_IRQ(RTC_A, IRQ_RTC_A),
86 INTC_IRQ(KEY, IRQ_KEY), INTC_IRQ(SDCARD, IRQ_SDCARD),
87 INTC_IRQ(CF_CD, IRQ_CF_CD), INTC_IRQ(CF_IDE, IRQ_CF_IDE),
88 INTC_IRQ(SM501, IRQ_VOYAGER),
89 INTC_IRQ(PCI_INTD_RTL8139, IRQ_PCI_INTD),
90 INTC_IRQ(PCI_INTC_PCI1520, IRQ_PCI_INTC),
91 INTC_IRQ(PCI_INTB_RTL8139, IRQ_PCI_INTB),
92 INTC_IRQ(PCI_INTA_SLOT, IRQ_PCI_INTA),
93 INTC_IRQ(TP, IRQ_TP),
94};
95
96/* IRLMSK mask register layout for R2D-PLUS */
97static struct intc_mask_reg mask_registers_r2d_plus[] __initdata = {
98 { 0xa4000000, 0, 16, /* IRLMSK */
99 { TP, PCI_INTA_SLOT, PCI_INTB_RTL8139,
100 PCI_INTC_PCI1520, PCI_INTD_RTL8139,
101 SM501, CF_IDE, CF_CD, SDCARD, KEY,
102 RTC_A, RTC_T, 0, 0, 0, EXT } },
103};
104
105/* IRLn to IRQ table for R2D-PLUS */
106static unsigned char irl2irq_r2d_plus[R2D_NR_IRL] __initdata = {
107 IRQ_PCI_INTD, IRQ_CF_IDE, IRQ_CF_CD, IRQ_PCI_INTC,
108 IRQ_VOYAGER, IRQ_KEY, IRQ_RTC_A, IRQ_RTC_T,
109 IRQ_SDCARD, IRQ_PCI_INTA, IRQ_PCI_INTB, IRQ_EXT,
110 IRQ_TP,
111};
112
113static __initdata DECLARE_INTC_DESC(intc_desc_r2d_plus, "r2d-plus",
114 vectors_r2d_plus, NULL, NULL,
115 mask_registers_r2d_plus, NULL, NULL);
116
117#endif /* CONFIG_RTS7751R2D_PLUS */
118
119static unsigned char irl2irq[R2D_NR_IRL];
37 120
38int rts7751r2d_irq_demux(int irq) 121int rts7751r2d_irq_demux(int irq)
39{ 122{
40 return irq; 123 if (irq >= R2D_NR_IRL || !irl2irq[irq])
41} 124 return irq;
42 125
43static struct irq_chip rts7751r2d_irq_chip __read_mostly = { 126 return irl2irq[irq];
44 .name = "rts7751r2d", 127}
45 .mask = disable_rts7751r2d_irq,
46 .unmask = enable_rts7751r2d_irq,
47 .mask_ack = disable_rts7751r2d_irq,
48};
49 128
50/* 129/*
51 * Initialize IRQ setting 130 * Initialize IRQ setting
52 */ 131 */
53void __init init_rts7751r2d_IRQ(void) 132void __init init_rts7751r2d_IRQ(void)
54{ 133{
55 int i; 134 struct intc_desc *d;
56 135
57 /* IRL0=KEY Input 136 switch (ctrl_inw(PA_BVERREG)) {
58 * IRL1=Ethernet 137#ifdef CONFIG_RTS7751R2D_PLUS
59 * IRL2=CF Card 138 case 0x10:
60 * IRL3=CF Card Insert 139 printk(KERN_INFO "Using R2D-PLUS interrupt controller.\n");
61 * IRL4=PCMCIA 140 d = &intc_desc_r2d_plus;
62 * IRL5=VOYAGER 141 memcpy(irl2irq, irl2irq_r2d_plus, R2D_NR_IRL);
63 * IRL6=RTC Alarm 142 break;
64 * IRL7=RTC Timer 143#endif
65 * IRL8=SD Card 144#ifdef CONFIG_RTS7751R2D_1
66 * IRL9=PCI Slot #1 145 case 0x11:
67 * IRL10=PCI Slot #2 146 printk(KERN_INFO "Using R2D-1 interrupt controller.\n");
68 * IRL11=Extention #0 147 d = &intc_desc_r2d_1;
69 * IRL12=Extention #1 148 memcpy(irl2irq, irl2irq_r2d_1, R2D_NR_IRL);
70 * IRL13=Extention #2 149 break;
71 * IRL14=Extention #3 150#endif
72 */ 151 default:
73 152 return;
74 for (i=0; i<15; i++) {
75 disable_irq_nosync(i);
76 set_irq_chip_and_handler_name(i, &rts7751r2d_irq_chip,
77 handle_level_irq, "level");
78 enable_rts7751r2d_irq(i);
79 } 153 }
80 154
155 register_intc_controller(d);
81 setup_voyagergx_irq(); 156 setup_voyagergx_irq();
82} 157}
diff --git a/arch/sh/boards/renesas/rts7751r2d/setup.c b/arch/sh/boards/renesas/rts7751r2d/setup.c
index 4d1bbd30e52b..90703d5d1230 100644
--- a/arch/sh/boards/renesas/rts7751r2d/setup.c
+++ b/arch/sh/boards/renesas/rts7751r2d/setup.c
@@ -54,11 +54,7 @@ static struct resource cf_ide_resources[] = {
54 .flags = IORESOURCE_MEM, 54 .flags = IORESOURCE_MEM,
55 }, 55 },
56 [2] = { 56 [2] = {
57#ifdef CONFIG_RTS7751R2D_REV11 57 .start = IRQ_CF_IDE,
58 .start = 1,
59#else
60 .start = 2,
61#endif
62 .flags = IORESOURCE_IRQ, 58 .flags = IORESOURCE_IRQ,
63 }, 59 },
64}; 60};
@@ -147,7 +143,7 @@ static int __init rts7751r2d_devices_setup(void)
147{ 143{
148 int ret; 144 int ret;
149 145
150 if (ctrl_inw(PA_BVERREG) == 0x10) { /* only working on R2D-PLUS */ 146 if (ctrl_inw(PA_BVERREG) == 0x10) { /* R2D-PLUS */
151 ret = platform_device_register(&cf_ide_device); 147 ret = platform_device_register(&cf_ide_device);
152 if (ret) 148 if (ret)
153 return ret; 149 return ret;
diff --git a/arch/sh/drivers/pci/ops-rts7751r2d.c b/arch/sh/drivers/pci/ops-rts7751r2d.c
index 4a518d948049..ec8430c8d2d1 100644
--- a/arch/sh/drivers/pci/ops-rts7751r2d.c
+++ b/arch/sh/drivers/pci/ops-rts7751r2d.c
@@ -19,10 +19,10 @@
19#include "pci-sh4.h" 19#include "pci-sh4.h"
20 20
21static u8 rts7751r2d_irq_tab[] __initdata = { 21static u8 rts7751r2d_irq_tab[] __initdata = {
22 IRQ_PCISLOT1, 22 IRQ_PCI_INTA,
23 IRQ_PCISLOT2, 23 IRQ_PCI_INTB,
24 IRQ_PCMCIA, 24 IRQ_PCI_INTC,
25 IRQ_PCIETH, 25 IRQ_PCI_INTD,
26}; 26};
27 27
28int __init pcibios_map_platform_irq(struct pci_dev *pdev, u8 slot, u8 pin) 28int __init pcibios_map_platform_irq(struct pci_dev *pdev, u8 slot, u8 pin)
diff --git a/include/asm-sh/rts7751r2d.h b/include/asm-sh/rts7751r2d.h
index 5d7800aa31b5..83b9c111f171 100644
--- a/include/asm-sh/rts7751r2d.h
+++ b/include/asm-sh/rts7751r2d.h
@@ -9,7 +9,7 @@
9 * Renesas Technology Sales RTS7751R2D support 9 * Renesas Technology Sales RTS7751R2D support
10 */ 10 */
11 11
12/* Box specific addresses. */ 12/* Board specific addresses. */
13 13
14#define PA_BCR 0xa4000000 /* FPGA */ 14#define PA_BCR 0xa4000000 /* FPGA */
15#define PA_IRLMON 0xa4000002 /* Interrupt Status control */ 15#define PA_IRLMON 0xa4000002 /* Interrupt Status control */
@@ -20,19 +20,19 @@
20#define PA_RTCCE 0xa400000c /* RTC(9701) Enable control */ 20#define PA_RTCCE 0xa400000c /* RTC(9701) Enable control */
21#define PA_PCICD 0xa400000e /* PCI Extention detect control */ 21#define PA_PCICD 0xa400000e /* PCI Extention detect control */
22#define PA_VOYAGERRTS 0xa4000020 /* VOYAGER Reset control */ 22#define PA_VOYAGERRTS 0xa4000020 /* VOYAGER Reset control */
23#if defined(CONFIG_RTS7751R2D_REV11) 23
24#define PA_AXRST 0xa4000022 /* AX_LAN Reset control */ 24#define PA_R2D1_AXRST 0xa4000022 /* AX_LAN Reset control */
25#define PA_CFRST 0xa4000024 /* CF Reset control */ 25#define PA_R2D1_CFRST 0xa4000024 /* CF Reset control */
26#define PA_ADMRTS 0xa4000026 /* SD Reset control */ 26#define PA_R2D1_ADMRTS 0xa4000026 /* SD Reset control */
27#define PA_EXTRST 0xa4000028 /* Extention Reset control */ 27#define PA_R2D1_EXTRST 0xa4000028 /* Extention Reset control */
28#define PA_CFCDINTCLR 0xa400002a /* CF Insert Interrupt clear */ 28#define PA_R2D1_CFCDINTCLR 0xa400002a /* CF Insert Interrupt clear */
29#else 29
30#define PA_CFRST 0xa4000022 /* CF Reset control */ 30#define PA_R2DPLUS_CFRST 0xa4000022 /* CF Reset control */
31#define PA_ADMRTS 0xa4000024 /* SD Reset control */ 31#define PA_R2DPLUS_ADMRTS 0xa4000024 /* SD Reset control */
32#define PA_EXTRST 0xa4000026 /* Extention Reset control */ 32#define PA_R2DPLUS_EXTRST 0xa4000026 /* Extention Reset control */
33#define PA_CFCDINTCLR 0xa4000028 /* CF Insert Interrupt clear */ 33#define PA_R2DPLUS_CFCDINTCLR 0xa4000028 /* CF Insert Interrupt clear */
34#define PA_KEYCTLCLR 0xa400002a /* Key Interrupt clear */ 34#define PA_R2DPLUS_KEYCTLCLR 0xa400002a /* Key Interrupt clear */
35#endif 35
36#define PA_POWOFF 0xa4000030 /* Board Power OFF control */ 36#define PA_POWOFF 0xa4000030 /* Board Power OFF control */
37#define PA_VERREG 0xa4000032 /* FPGA Version Register */ 37#define PA_VERREG 0xa4000032 /* FPGA Version Register */
38#define PA_INPORT 0xa4000034 /* KEY Input Port control */ 38#define PA_INPORT 0xa4000034 /* KEY Input Port control */
@@ -46,27 +46,22 @@
46 46
47#define IRLCNTR1 (PA_BCR + 0) /* Interrupt Control Register1 */ 47#define IRLCNTR1 (PA_BCR + 0) /* Interrupt Control Register1 */
48 48
49#if defined(CONFIG_RTS7751R2D_REV11) 49#define R2D_FPGA_IRQ_BASE 100
50#define IRQ_PCIETH 0 /* PCI Ethernet IRQ */ 50
51#define IRQ_CFCARD 1 /* CF Card IRQ */ 51#define IRQ_VOYAGER (R2D_FPGA_IRQ_BASE + 0)
52#define IRQ_CFINST 2 /* CF Card Insert IRQ */ 52#define IRQ_EXT (R2D_FPGA_IRQ_BASE + 1)
53#define IRQ_PCMCIA 3 /* PCMCIA IRQ */ 53#define IRQ_TP (R2D_FPGA_IRQ_BASE + 2)
54#define IRQ_VOYAGER 4 /* VOYAGER IRQ */ 54#define IRQ_RTC_T (R2D_FPGA_IRQ_BASE + 3)
55#define IRQ_ONETH 5 /* On board Ethernet IRQ */ 55#define IRQ_RTC_A (R2D_FPGA_IRQ_BASE + 4)
56#else 56#define IRQ_SDCARD (R2D_FPGA_IRQ_BASE + 5)
57#define IRQ_KEYIN 0 /* Key Input IRQ */ 57#define IRQ_CF_CD (R2D_FPGA_IRQ_BASE + 6)
58#define IRQ_PCIETH 1 /* PCI Ethernet IRQ */ 58#define IRQ_CF_IDE (R2D_FPGA_IRQ_BASE + 7)
59#define IRQ_CFCARD 2 /* CF Card IRQ */ 59#define IRQ_AX88796 (R2D_FPGA_IRQ_BASE + 8)
60#define IRQ_CFINST 3 /* CF Card Insert IRQ */ 60#define IRQ_KEY (R2D_FPGA_IRQ_BASE + 9)
61#define IRQ_PCMCIA 4 /* PCMCIA IRQ */ 61#define IRQ_PCI_INTA (R2D_FPGA_IRQ_BASE + 10)
62#define IRQ_VOYAGER 5 /* VOYAGER IRQ */ 62#define IRQ_PCI_INTB (R2D_FPGA_IRQ_BASE + 11)
63#endif 63#define IRQ_PCI_INTC (R2D_FPGA_IRQ_BASE + 12)
64#define IRQ_RTCALM 6 /* RTC Alarm IRQ */ 64#define IRQ_PCI_INTD (R2D_FPGA_IRQ_BASE + 13)
65#define IRQ_RTCTIME 7 /* RTC Timer IRQ */
66#define IRQ_SDCARD 8 /* SD Card IRQ */
67#define IRQ_PCISLOT1 9 /* PCI Slot #1 IRQ */
68#define IRQ_PCISLOT2 10 /* PCI Slot #2 IRQ */
69#define IRQ_EXTENTION 11 /* EXTn IRQ */
70 65
71/* arch/sh/boards/renesas/rts7751r2d/irq.c */ 66/* arch/sh/boards/renesas/rts7751r2d/irq.c */
72void init_rts7751r2d_IRQ(void); 67void init_rts7751r2d_IRQ(void);