diff options
author | Paul Mundt <lethal@linux-sh.org> | 2012-05-24 06:07:18 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2012-05-24 06:07:18 -0400 |
commit | 197b58e6651426bec8b2582013258b52cd15a444 (patch) | |
tree | b1c34f18f468a1b6689cd46b3732490e9412686e /arch/sh/boards | |
parent | 5df38b9b7676e4e46c5c13e75f023ffb82542980 (diff) |
sh: se7343: Move CPLD IRQs to irqdomain and generic irq chip.
Follows the se7722 change, see there for more information.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/boards')
-rw-r--r-- | arch/sh/boards/Kconfig | 2 | ||||
-rw-r--r-- | arch/sh/boards/mach-se/7343/irq.c | 129 | ||||
-rw-r--r-- | arch/sh/boards/mach-se/7343/setup.c | 10 |
3 files changed, 94 insertions, 47 deletions
diff --git a/arch/sh/boards/Kconfig b/arch/sh/boards/Kconfig index 525b9e32cd14..1a280048e2c3 100644 --- a/arch/sh/boards/Kconfig +++ b/arch/sh/boards/Kconfig | |||
@@ -81,6 +81,8 @@ config SH_7780_SOLUTION_ENGINE | |||
81 | config SH_7343_SOLUTION_ENGINE | 81 | config SH_7343_SOLUTION_ENGINE |
82 | bool "SolutionEngine7343" | 82 | bool "SolutionEngine7343" |
83 | select SOLUTION_ENGINE | 83 | select SOLUTION_ENGINE |
84 | select GENERIC_IRQ_CHIP | ||
85 | select IRQ_DOMAIN | ||
84 | depends on CPU_SUBTYPE_SH7343 | 86 | depends on CPU_SUBTYPE_SH7343 |
85 | help | 87 | help |
86 | Select 7343 SolutionEngine if configuring for a Hitachi | 88 | Select 7343 SolutionEngine if configuring for a Hitachi |
diff --git a/arch/sh/boards/mach-se/7343/irq.c b/arch/sh/boards/mach-se/7343/irq.c index fd45ffc48340..7646bf0486c2 100644 --- a/arch/sh/boards/mach-se/7343/irq.c +++ b/arch/sh/boards/mach-se/7343/irq.c | |||
@@ -1,86 +1,129 @@ | |||
1 | /* | 1 | /* |
2 | * linux/arch/sh/boards/se/7343/irq.c | 2 | * Hitachi UL SolutionEngine 7343 FPGA IRQ Support. |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Yoshihiro Shimoda | 4 | * Copyright (C) 2008 Yoshihiro Shimoda |
5 | * Copyright (C) 2012 Paul Mundt | ||
5 | * | 6 | * |
6 | * Based on linux/arch/sh/boards/se/7722/irq.c | 7 | * Based on linux/arch/sh/boards/se/7343/irq.c |
7 | * Copyright (C) 2007 Nobuhiro Iwamatsu | 8 | * Copyright (C) 2007 Nobuhiro Iwamatsu |
8 | * | 9 | * |
9 | * This file is subject to the terms and conditions of the GNU General Public | 10 | * This file is subject to the terms and conditions of the GNU General Public |
10 | * License. See the file "COPYING" in the main directory of this archive | 11 | * License. See the file "COPYING" in the main directory of this archive |
11 | * for more details. | 12 | * for more details. |
12 | */ | 13 | */ |
14 | #define DRV_NAME "SE7343-FPGA" | ||
15 | #define pr_fmt(fmt) DRV_NAME ": " fmt | ||
16 | |||
17 | #define irq_reg_readl ioread16 | ||
18 | #define irq_reg_writel iowrite16 | ||
19 | |||
13 | #include <linux/init.h> | 20 | #include <linux/init.h> |
14 | #include <linux/irq.h> | 21 | #include <linux/irq.h> |
15 | #include <linux/interrupt.h> | 22 | #include <linux/interrupt.h> |
23 | #include <linux/irqdomain.h> | ||
16 | #include <linux/io.h> | 24 | #include <linux/io.h> |
25 | #include <asm/sizes.h> | ||
17 | #include <mach-se/mach/se7343.h> | 26 | #include <mach-se/mach/se7343.h> |
18 | 27 | ||
19 | unsigned int se7343_fpga_irq[SE7343_FPGA_IRQ_NR] = { 0, }; | 28 | #define PA_CPLD_BASE_ADDR 0x11400000 |
29 | #define PA_CPLD_ST_REG 0x08 /* CPLD Interrupt status register */ | ||
30 | #define PA_CPLD_IMSK_REG 0x0a /* CPLD Interrupt mask register */ | ||
20 | 31 | ||
21 | static void disable_se7343_irq(struct irq_data *data) | 32 | static void __iomem *se7343_irq_regs; |
22 | { | 33 | struct irq_domain *se7343_irq_domain; |
23 | unsigned int bit = (unsigned int)irq_data_get_irq_chip_data(data); | ||
24 | __raw_writew(__raw_readw(PA_CPLD_IMSK) | 1 << bit, PA_CPLD_IMSK); | ||
25 | } | ||
26 | 34 | ||
27 | static void enable_se7343_irq(struct irq_data *data) | 35 | static void se7343_irq_demux(unsigned int irq, struct irq_desc *desc) |
28 | { | 36 | { |
29 | unsigned int bit = (unsigned int)irq_data_get_irq_chip_data(data); | 37 | struct irq_data *data = irq_get_irq_data(irq); |
30 | __raw_writew(__raw_readw(PA_CPLD_IMSK) & ~(1 << bit), PA_CPLD_IMSK); | 38 | struct irq_chip *chip = irq_data_get_irq_chip(data); |
31 | } | 39 | unsigned long mask; |
40 | int bit; | ||
32 | 41 | ||
33 | static struct irq_chip se7343_irq_chip __read_mostly = { | 42 | chip->irq_mask_ack(data); |
34 | .name = "SE7343-FPGA", | ||
35 | .irq_mask = disable_se7343_irq, | ||
36 | .irq_unmask = enable_se7343_irq, | ||
37 | }; | ||
38 | 43 | ||
39 | static void se7343_irq_demux(unsigned int irq, struct irq_desc *desc) | 44 | mask = ioread16(se7343_irq_regs + PA_CPLD_ST_REG); |
45 | |||
46 | for_each_set_bit(bit, &mask, SE7343_FPGA_IRQ_NR) | ||
47 | generic_handle_irq(irq_linear_revmap(se7343_irq_domain, bit)); | ||
48 | |||
49 | chip->irq_unmask(data); | ||
50 | } | ||
51 | |||
52 | static void __init se7343_domain_init(void) | ||
40 | { | 53 | { |
41 | unsigned short intv = __raw_readw(PA_CPLD_ST); | 54 | int i; |
42 | unsigned int ext_irq = 0; | ||
43 | 55 | ||
44 | intv &= (1 << SE7343_FPGA_IRQ_NR) - 1; | 56 | se7343_irq_domain = irq_domain_add_linear(NULL, SE7343_FPGA_IRQ_NR, |
57 | &irq_domain_simple_ops, NULL); | ||
58 | if (unlikely(!se7343_irq_domain)) { | ||
59 | printk("Failed to get IRQ domain\n"); | ||
60 | return; | ||
61 | } | ||
45 | 62 | ||
46 | for (; intv; intv >>= 1, ext_irq++) { | 63 | for (i = 0; i < SE7343_FPGA_IRQ_NR; i++) { |
47 | if (!(intv & 1)) | 64 | int irq = irq_create_mapping(se7343_irq_domain, i); |
48 | continue; | ||
49 | 65 | ||
50 | generic_handle_irq(se7343_fpga_irq[ext_irq]); | 66 | if (unlikely(irq == 0)) { |
67 | printk("Failed to allocate IRQ %d\n", i); | ||
68 | return; | ||
69 | } | ||
51 | } | 70 | } |
52 | } | 71 | } |
53 | 72 | ||
54 | /* | 73 | static void __init se7343_gc_init(void) |
55 | * Initialize IRQ setting | ||
56 | */ | ||
57 | void __init init_7343se_IRQ(void) | ||
58 | { | 74 | { |
59 | int i, irq; | 75 | struct irq_chip_generic *gc; |
76 | struct irq_chip_type *ct; | ||
77 | unsigned int irq_base; | ||
60 | 78 | ||
61 | __raw_writew(0, PA_CPLD_IMSK); /* disable all irqs */ | 79 | irq_base = irq_linear_revmap(se7343_irq_domain, 0); |
62 | __raw_writew(0x2000, 0xb03fffec); /* mrshpc irq enable */ | ||
63 | 80 | ||
64 | for (i = 0; i < SE7343_FPGA_IRQ_NR; i++) { | 81 | gc = irq_alloc_generic_chip(DRV_NAME, 1, irq_base, se7343_irq_regs, |
65 | irq = create_irq(); | 82 | handle_level_irq); |
66 | if (irq < 0) | 83 | if (unlikely(!gc)) |
67 | return; | 84 | return; |
68 | se7343_fpga_irq[i] = irq; | ||
69 | 85 | ||
70 | irq_set_chip_and_handler_name(se7343_fpga_irq[i], | 86 | ct = gc->chip_types; |
71 | &se7343_irq_chip, | 87 | ct->chip.irq_mask = irq_gc_mask_set_bit; |
72 | handle_level_irq, | 88 | ct->chip.irq_unmask = irq_gc_mask_clr_bit; |
73 | "level"); | ||
74 | 89 | ||
75 | irq_set_chip_data(se7343_fpga_irq[i], (void *)i); | 90 | ct->regs.mask = PA_CPLD_IMSK_REG; |
76 | } | 91 | |
92 | irq_setup_generic_chip(gc, IRQ_MSK(SE7343_FPGA_IRQ_NR), | ||
93 | IRQ_GC_INIT_MASK_CACHE, | ||
94 | IRQ_NOREQUEST | IRQ_NOPROBE, 0); | ||
77 | 95 | ||
78 | irq_set_chained_handler(IRQ0_IRQ, se7343_irq_demux); | 96 | irq_set_chained_handler(IRQ0_IRQ, se7343_irq_demux); |
79 | irq_set_irq_type(IRQ0_IRQ, IRQ_TYPE_LEVEL_LOW); | 97 | irq_set_irq_type(IRQ0_IRQ, IRQ_TYPE_LEVEL_LOW); |
98 | |||
80 | irq_set_chained_handler(IRQ1_IRQ, se7343_irq_demux); | 99 | irq_set_chained_handler(IRQ1_IRQ, se7343_irq_demux); |
81 | irq_set_irq_type(IRQ1_IRQ, IRQ_TYPE_LEVEL_LOW); | 100 | irq_set_irq_type(IRQ1_IRQ, IRQ_TYPE_LEVEL_LOW); |
101 | |||
82 | irq_set_chained_handler(IRQ4_IRQ, se7343_irq_demux); | 102 | irq_set_chained_handler(IRQ4_IRQ, se7343_irq_demux); |
83 | irq_set_irq_type(IRQ4_IRQ, IRQ_TYPE_LEVEL_LOW); | 103 | irq_set_irq_type(IRQ4_IRQ, IRQ_TYPE_LEVEL_LOW); |
104 | |||
84 | irq_set_chained_handler(IRQ5_IRQ, se7343_irq_demux); | 105 | irq_set_chained_handler(IRQ5_IRQ, se7343_irq_demux); |
85 | irq_set_irq_type(IRQ5_IRQ, IRQ_TYPE_LEVEL_LOW); | 106 | irq_set_irq_type(IRQ5_IRQ, IRQ_TYPE_LEVEL_LOW); |
86 | } | 107 | } |
108 | |||
109 | /* | ||
110 | * Initialize IRQ setting | ||
111 | */ | ||
112 | void __init init_7343se_IRQ(void) | ||
113 | { | ||
114 | se7343_irq_regs = ioremap(PA_CPLD_BASE_ADDR, SZ_16); | ||
115 | if (unlikely(!se7343_irq_regs)) { | ||
116 | pr_err("Failed to remap CPLD\n"); | ||
117 | return; | ||
118 | } | ||
119 | |||
120 | /* | ||
121 | * All FPGA IRQs disabled by default | ||
122 | */ | ||
123 | iowrite16(0, se7343_irq_regs + PA_CPLD_IMSK_REG); | ||
124 | |||
125 | __raw_writew(0x2000, 0xb03fffec); /* mrshpc irq enable */ | ||
126 | |||
127 | se7343_domain_init(); | ||
128 | se7343_gc_init(); | ||
129 | } | ||
diff --git a/arch/sh/boards/mach-se/7343/setup.c b/arch/sh/boards/mach-se/7343/setup.c index d2370af56d77..8ce4f2a202a8 100644 --- a/arch/sh/boards/mach-se/7343/setup.c +++ b/arch/sh/boards/mach-se/7343/setup.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <linux/serial_reg.h> | 5 | #include <linux/serial_reg.h> |
6 | #include <linux/usb/isp116x.h> | 6 | #include <linux/usb/isp116x.h> |
7 | #include <linux/delay.h> | 7 | #include <linux/delay.h> |
8 | #include <linux/irqdomain.h> | ||
8 | #include <asm/machvec.h> | 9 | #include <asm/machvec.h> |
9 | #include <mach-se/mach/se7343.h> | 10 | #include <mach-se/mach/se7343.h> |
10 | #include <asm/heartbeat.h> | 11 | #include <asm/heartbeat.h> |
@@ -145,11 +146,12 @@ static struct platform_device *sh7343se_platform_devices[] __initdata = { | |||
145 | static int __init sh7343se_devices_setup(void) | 146 | static int __init sh7343se_devices_setup(void) |
146 | { | 147 | { |
147 | /* Wire-up dynamic vectors */ | 148 | /* Wire-up dynamic vectors */ |
148 | serial_platform_data[0].irq = se7343_fpga_irq[SE7343_FPGA_IRQ_UARTA]; | 149 | serial_platform_data[0].irq = irq_find_mapping(se7343_irq_domain, |
149 | serial_platform_data[1].irq = se7343_fpga_irq[SE7343_FPGA_IRQ_UARTB]; | 150 | SE7343_FPGA_IRQ_UARTA); |
150 | 151 | serial_platform_data[1].irq = irq_find_mapping(se7343_irq_domain, | |
152 | SE7343_FPGA_IRQ_UARTB); | ||
151 | usb_resources[2].start = usb_resources[2].end = | 153 | usb_resources[2].start = usb_resources[2].end = |
152 | se7343_fpga_irq[SE7343_FPGA_IRQ_USB]; | 154 | irq_find_mapping(se7343_irq_domain, SE7343_FPGA_IRQ_USB); |
153 | 155 | ||
154 | return platform_add_devices(sh7343se_platform_devices, | 156 | return platform_add_devices(sh7343se_platform_devices, |
155 | ARRAY_SIZE(sh7343se_platform_devices)); | 157 | ARRAY_SIZE(sh7343se_platform_devices)); |