diff options
author | Magnus Damm <damm@igel.co.jp> | 2007-08-12 02:29:16 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2007-09-20 22:57:50 -0400 |
commit | 2eeec85638cebcb6fbcb2abfe182a32252f3456d (patch) | |
tree | 3b98f924a5f961d844555794a3564cbc2c3a8be5 /arch/sh/boards | |
parent | 73505b445dbb8ad12df468404c4dd5cde9c40c65 (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>
Diffstat (limited to 'arch/sh/boards')
-rw-r--r-- | arch/sh/boards/renesas/rts7751r2d/Kconfig | 24 | ||||
-rw-r--r-- | arch/sh/boards/renesas/rts7751r2d/irq.c | 173 | ||||
-rw-r--r-- | arch/sh/boards/renesas/rts7751r2d/setup.c | 8 |
3 files changed, 147 insertions, 58 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 | ||
3 | menu "RTS7751R2D options" | 3 | menu "RTS7751R2D options" |
4 | 4 | ||
5 | config RTS7751R2D_REV11 | 5 | choice |
6 | bool "RTS7751R2D Rev. 1.1 board support" | 6 | prompt "R2D Board Revision" |
7 | default RTS7751R2D_PLUS | ||
8 | |||
9 | config 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 | |||
17 | config 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 | |||
25 | endchoice | ||
26 | |||
9 | endmenu | 27 | endmenu |
10 | 28 | ||
11 | endif | 29 | endif |
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 |
20 | static int mask_pos[] = {11, 9, 8, 12, 10, 6, 5, 4, 7, 14, 13, 0, 0, 0, 0}; | ||
21 | #else | ||
22 | static int mask_pos[] = {6, 11, 9, 8, 12, 10, 5, 4, 7, 14, 13, 0, 0, 0, 0}; | ||
23 | #endif | ||
24 | 21 | ||
25 | static void enable_rts7751r2d_irq(unsigned int irq) | 22 | enum { |
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 | ||
31 | static 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 */ | ||
44 | static 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 */ | ||
58 | static 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 */ | ||
67 | static 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 | |||
74 | static __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 */ | ||
83 | static 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 */ | ||
97 | static 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 */ | ||
106 | static 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 | |||
113 | static __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 | |||
119 | static unsigned char irl2irq[R2D_NR_IRL]; | ||
37 | 120 | ||
38 | int rts7751r2d_irq_demux(int irq) | 121 | int rts7751r2d_irq_demux(int irq) |
39 | { | 122 | { |
40 | return irq; | 123 | if (irq >= R2D_NR_IRL || !irl2irq[irq]) |
41 | } | 124 | return irq; |
42 | 125 | ||
43 | static 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 | */ |
53 | void __init init_rts7751r2d_IRQ(void) | 132 | void __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; |