Skip to content

Commit 53e6d8e

Browse files
committed
sh: mach-se: Convert SE7343 FPGA to dynamic IRQ allocation.
This gets rid of the arbitrary set of vectors used by the SE7722 FPGA interrupt controller and switches over to a completely dynamic set. No assumptions regarding a contiguous range are made, and the platform resources themselves need to be filled in lazily. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
1 parent 8c0b813 commit 53e6d8e

3 files changed

Lines changed: 53 additions & 50 deletions

File tree

‎arch/sh/boards/mach-se/7343/irq.c‎

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@
1616
#include <linux/io.h>
1717
#include <mach-se/mach/se7343.h>
1818

19+
unsigned int se7343_fpga_irq[SE7343_FPGA_IRQ_NR] = { 0, };
20+
1921
static void disable_se7343_irq(unsigned int irq)
2022
{
21-
unsigned int bit = irq - SE7343_FPGA_IRQ_BASE;
23+
unsigned int bit = (unsigned int)get_irq_chip_data(irq);
2224
ctrl_outw(ctrl_inw(PA_CPLD_IMSK) | 1 << bit, PA_CPLD_IMSK);
2325
}
2426

2527
static void enable_se7343_irq(unsigned int irq)
2628
{
27-
unsigned int bit = irq - SE7343_FPGA_IRQ_BASE;
29+
unsigned int bit = (unsigned int)get_irq_chip_data(irq);
2830
ctrl_outw(ctrl_inw(PA_CPLD_IMSK) & ~(1 << bit), PA_CPLD_IMSK);
2931
}
3032

@@ -38,18 +40,15 @@ static struct irq_chip se7343_irq_chip __read_mostly = {
3840
static void se7343_irq_demux(unsigned int irq, struct irq_desc *desc)
3941
{
4042
unsigned short intv = ctrl_inw(PA_CPLD_ST);
41-
struct irq_desc *ext_desc;
42-
unsigned int ext_irq = SE7343_FPGA_IRQ_BASE;
43+
unsigned int ext_irq = 0;
4344

4445
intv &= (1 << SE7343_FPGA_IRQ_NR) - 1;
4546

46-
while (intv) {
47-
if (intv & 1) {
48-
ext_desc = irq_desc + ext_irq;
49-
handle_level_irq(ext_irq, ext_desc);
50-
}
51-
intv >>= 1;
52-
ext_irq++;
47+
for (; intv; intv >>= 1, ext_irq++) {
48+
if (!(intv & 1))
49+
continue;
50+
51+
generic_handle_irq(se7343_fpga_irq[ext_irq]);
5352
}
5453
}
5554

@@ -58,16 +57,24 @@ static void se7343_irq_demux(unsigned int irq, struct irq_desc *desc)
5857
*/
5958
void __init init_7343se_IRQ(void)
6059
{
61-
int i;
60+
int i, irq;
6261

6362
ctrl_outw(0, PA_CPLD_IMSK); /* disable all irqs */
6463
ctrl_outw(0x2000, 0xb03fffec); /* mrshpc irq enable */
6564

66-
for (i = 0; i < SE7343_FPGA_IRQ_NR; i++)
67-
set_irq_chip_and_handler_name(SE7343_FPGA_IRQ_BASE + i,
65+
for (i = 0; i < SE7343_FPGA_IRQ_NR; i++) {
66+
irq = create_irq();
67+
if (irq < 0)
68+
return;
69+
se7343_fpga_irq[i] = irq;
70+
71+
set_irq_chip_and_handler_name(se7343_fpga_irq[i],
6872
&se7343_irq_chip,
6973
handle_level_irq, "level");
7074

75+
set_irq_chip_data(se7343_fpga_irq[i], (void *)i);
76+
}
77+
7178
set_irq_chained_handler(IRQ0_IRQ, se7343_irq_demux);
7279
set_irq_type(IRQ0_IRQ, IRQ_TYPE_LEVEL_LOW);
7380
set_irq_chained_handler(IRQ1_IRQ, se7343_irq_demux);

‎arch/sh/boards/mach-se/7343/setup.c‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,13 @@ static struct plat_serial8250_port serial_platform_data[] = {
8282
.mapbase = 0x16000000,
8383
.regshift = 1,
8484
.flags = ST16C2550C_FLAGS,
85-
.irq = UARTA_IRQ,
8685
.uartclk = 7372800,
8786
},
8887
[1] = {
8988
.iotype = UPIO_MEM,
9089
.mapbase = 0x17000000,
9190
.regshift = 1,
9291
.flags = ST16C2550C_FLAGS,
93-
.irq = UARTB_IRQ,
9492
.uartclk = 7372800,
9593
},
9694
{ },
@@ -121,7 +119,7 @@ static struct resource usb_resources[] = {
121119
.flags = IORESOURCE_MEM,
122120
},
123121
[2] = {
124-
.start = USB_IRQ,
122+
/* Filled in later */
125123
.flags = IORESOURCE_IRQ,
126124
},
127125
};
@@ -138,8 +136,8 @@ static struct isp116x_platform_data usb_platform_data = {
138136
static struct platform_device usb_device = {
139137
.name = "isp116x-hcd",
140138
.id = -1,
141-
.num_resources = ARRAY_SIZE(usb_resources),
142-
.resource = usb_resources,
139+
.num_resources = ARRAY_SIZE(usb_resources),
140+
.resource = usb_resources,
143141
.dev = {
144142
.platform_data = &usb_platform_data,
145143
},
@@ -155,6 +153,13 @@ static struct platform_device *sh7343se_platform_devices[] __initdata = {
155153

156154
static int __init sh7343se_devices_setup(void)
157155
{
156+
/* Wire-up dynamic vectors */
157+
serial_platform_data[0].irq = se7343_fpga_irq[SE7343_FPGA_IRQ_UARTA];
158+
serial_platform_data[1].irq = se7343_fpga_irq[SE7343_FPGA_IRQ_UARTB];
159+
160+
usb_resources[2].start = usb_resources[2].end =
161+
se7343_fpga_irq[SE7343_FPGA_IRQ_USB];
162+
158163
return platform_add_devices(sh7343se_platform_devices,
159164
ARRAY_SIZE(sh7343se_platform_devices));
160165
}
@@ -179,6 +184,5 @@ static void __init sh7343se_setup(char **cmdline_p)
179184
static struct sh_machine_vector mv_7343se __initmv = {
180185
.mv_name = "SolutionEngine 7343",
181186
.mv_setup = sh7343se_setup,
182-
.mv_nr_irqs = SE7343_FPGA_IRQ_BASE + SE7343_FPGA_IRQ_NR,
183187
.mv_init_irq = init_7343se_IRQ,
184188
};

‎arch/sh/include/mach-se/mach/se7343.h‎

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -94,26 +94,26 @@
9494

9595
#define PORT_DRVCR 0xA4050180
9696

97-
#define PORT_PADR 0xA4050120
98-
#define PORT_PBDR 0xA4050122
99-
#define PORT_PCDR 0xA4050124
100-
#define PORT_PDDR 0xA4050126
101-
#define PORT_PEDR 0xA4050128
102-
#define PORT_PFDR 0xA405012A
103-
#define PORT_PGDR 0xA405012C
104-
#define PORT_PHDR 0xA405012E
105-
#define PORT_PJDR 0xA4050130
106-
#define PORT_PKDR 0xA4050132
107-
#define PORT_PLDR 0xA4050134
108-
#define PORT_PMDR 0xA4050136
109-
#define PORT_PNDR 0xA4050138
110-
#define PORT_PQDR 0xA405013A
111-
#define PORT_PRDR 0xA405013C
112-
#define PORT_PTDR 0xA4050160
113-
#define PORT_PUDR 0xA4050162
114-
#define PORT_PVDR 0xA4050164
115-
#define PORT_PWDR 0xA4050166
116-
#define PORT_PYDR 0xA4050168
97+
#define PORT_PADR 0xA4050120
98+
#define PORT_PBDR 0xA4050122
99+
#define PORT_PCDR 0xA4050124
100+
#define PORT_PDDR 0xA4050126
101+
#define PORT_PEDR 0xA4050128
102+
#define PORT_PFDR 0xA405012A
103+
#define PORT_PGDR 0xA405012C
104+
#define PORT_PHDR 0xA405012E
105+
#define PORT_PJDR 0xA4050130
106+
#define PORT_PKDR 0xA4050132
107+
#define PORT_PLDR 0xA4050134
108+
#define PORT_PMDR 0xA4050136
109+
#define PORT_PNDR 0xA4050138
110+
#define PORT_PQDR 0xA405013A
111+
#define PORT_PRDR 0xA405013C
112+
#define PORT_PTDR 0xA4050160
113+
#define PORT_PUDR 0xA4050162
114+
#define PORT_PVDR 0xA4050164
115+
#define PORT_PWDR 0xA4050166
116+
#define PORT_PYDR 0xA4050168
117117

118118
#define FPGA_IN 0xb1400000
119119
#define FPGA_OUT 0xb1400002
@@ -133,18 +133,10 @@
133133
#define SE7343_FPGA_IRQ_UARTB 11
134134

135135
#define SE7343_FPGA_IRQ_NR 12
136-
#define SE7343_FPGA_IRQ_BASE 120
137-
138-
#define MRSHPC_IRQ3 (SE7343_FPGA_IRQ_BASE + SE7343_FPGA_IRQ_MRSHPC3)
139-
#define MRSHPC_IRQ2 (SE7343_FPGA_IRQ_BASE + SE7343_FPGA_IRQ_MRSHPC2)
140-
#define MRSHPC_IRQ1 (SE7343_FPGA_IRQ_BASE + SE7343_FPGA_IRQ_MRSHPC1)
141-
#define MRSHPC_IRQ0 (SE7343_FPGA_IRQ_BASE + SE7343_FPGA_IRQ_MRSHPC0)
142-
#define SMC_IRQ (SE7343_FPGA_IRQ_BASE + SE7343_FPGA_IRQ_SMC)
143-
#define USB_IRQ (SE7343_FPGA_IRQ_BASE + SE7343_FPGA_IRQ_USB)
144-
#define UARTA_IRQ (SE7343_FPGA_IRQ_BASE + SE7343_FPGA_IRQ_UARTA)
145-
#define UARTB_IRQ (SE7343_FPGA_IRQ_BASE + SE7343_FPGA_IRQ_UARTB)
146136

147137
/* arch/sh/boards/se/7343/irq.c */
138+
extern unsigned int se7343_fpga_irq[];
139+
148140
void init_7343se_IRQ(void);
149141

150142
#endif /* __ASM_SH_HITACHI_SE7343_H */

0 commit comments

Comments
 (0)