diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2011-11-10 21:47:26 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2011-11-11 02:56:34 -0500 |
commit | 6bf2805dac7cd6c70e678e0f4852c67000c7fc21 (patch) | |
tree | 13d04d667a49cf7663bc3a20221bb6dbdfb604ce /arch/arm | |
parent | 665ccfa0904cc0a05aa882d193f9506081824d7c (diff) |
ARM: mach-shmobile: bonito: add FPGA irq demux
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-shmobile/board-bonito.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/arch/arm/mach-shmobile/board-bonito.c b/arch/arm/mach-shmobile/board-bonito.c index 5b014764e2a5..fe749e354626 100644 --- a/arch/arm/mach-shmobile/board-bonito.c +++ b/arch/arm/mach-shmobile/board-bonito.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/irq.h> | 26 | #include <linux/irq.h> |
27 | #include <linux/platform_device.h> | 27 | #include <linux/platform_device.h> |
28 | #include <linux/gpio.h> | 28 | #include <linux/gpio.h> |
29 | #include <linux/smsc911x.h> | ||
29 | #include <mach/common.h> | 30 | #include <mach/common.h> |
30 | #include <asm/mach-types.h> | 31 | #include <asm/mach-types.h> |
31 | #include <asm/mach/arch.h> | 32 | #include <asm/mach/arch.h> |
@@ -75,14 +76,25 @@ | |||
75 | /* | 76 | /* |
76 | * FPGA | 77 | * FPGA |
77 | */ | 78 | */ |
79 | #define IRQSR0 0x0020 | ||
80 | #define IRQSR1 0x0022 | ||
81 | #define IRQMR0 0x0030 | ||
82 | #define IRQMR1 0x0032 | ||
78 | #define BUSSWMR1 0x0070 | 83 | #define BUSSWMR1 0x0070 |
79 | #define BUSSWMR2 0x0072 | 84 | #define BUSSWMR2 0x0072 |
80 | #define BUSSWMR3 0x0074 | 85 | #define BUSSWMR3 0x0074 |
81 | #define BUSSWMR4 0x0076 | 86 | #define BUSSWMR4 0x0076 |
82 | 87 | ||
83 | #define LCDCR 0x10B4 | 88 | #define LCDCR 0x10B4 |
89 | #define DEVRSTCR1 0x10D0 | ||
90 | #define DEVRSTCR2 0x10D2 | ||
84 | #define A1MDSR 0x10E0 | 91 | #define A1MDSR 0x10E0 |
85 | #define BVERR 0x1100 | 92 | #define BVERR 0x1100 |
93 | |||
94 | /* FPGA IRQ */ | ||
95 | #define FPGA_IRQ_BASE (512) | ||
96 | #define FPGA_IRQ0 (FPGA_IRQ_BASE) | ||
97 | #define FPGA_IRQ1 (FPGA_IRQ_BASE + 16) | ||
86 | static u16 bonito_fpga_read(u32 offset) | 98 | static u16 bonito_fpga_read(u32 offset) |
87 | { | 99 | { |
88 | return __raw_readw(0xf0003000 + offset); | 100 | return __raw_readw(0xf0003000 + offset); |
@@ -93,6 +105,71 @@ static void bonito_fpga_write(u32 offset, u16 val) | |||
93 | __raw_writew(val, 0xf0003000 + offset); | 105 | __raw_writew(val, 0xf0003000 + offset); |
94 | } | 106 | } |
95 | 107 | ||
108 | static void bonito_fpga_irq_disable(struct irq_data *data) | ||
109 | { | ||
110 | unsigned int irq = data->irq; | ||
111 | u32 addr = (irq < 1016) ? IRQMR0 : IRQMR1; | ||
112 | int shift = irq % 16; | ||
113 | |||
114 | bonito_fpga_write(addr, bonito_fpga_read(addr) | (1 << shift)); | ||
115 | } | ||
116 | |||
117 | static void bonito_fpga_irq_enable(struct irq_data *data) | ||
118 | { | ||
119 | unsigned int irq = data->irq; | ||
120 | u32 addr = (irq < 1016) ? IRQMR0 : IRQMR1; | ||
121 | int shift = irq % 16; | ||
122 | |||
123 | bonito_fpga_write(addr, bonito_fpga_read(addr) & ~(1 << shift)); | ||
124 | } | ||
125 | |||
126 | static struct irq_chip bonito_fpga_irq_chip __read_mostly = { | ||
127 | .name = "bonito FPGA", | ||
128 | .irq_mask = bonito_fpga_irq_disable, | ||
129 | .irq_unmask = bonito_fpga_irq_enable, | ||
130 | }; | ||
131 | |||
132 | static void bonito_fpga_irq_demux(unsigned int irq, struct irq_desc *desc) | ||
133 | { | ||
134 | u32 val = bonito_fpga_read(IRQSR1) << 16 | | ||
135 | bonito_fpga_read(IRQSR0); | ||
136 | u32 mask = bonito_fpga_read(IRQMR1) << 16 | | ||
137 | bonito_fpga_read(IRQMR0); | ||
138 | |||
139 | int i; | ||
140 | |||
141 | val &= ~mask; | ||
142 | |||
143 | for (i = 0; i < 32; i++) { | ||
144 | if (!(val & (1 << i))) | ||
145 | continue; | ||
146 | |||
147 | generic_handle_irq(FPGA_IRQ_BASE + i); | ||
148 | } | ||
149 | } | ||
150 | |||
151 | static void bonito_fpga_init(void) | ||
152 | { | ||
153 | int i; | ||
154 | |||
155 | bonito_fpga_write(IRQMR0, 0xffff); /* mask all */ | ||
156 | bonito_fpga_write(IRQMR1, 0xffff); /* mask all */ | ||
157 | |||
158 | /* Device reset */ | ||
159 | bonito_fpga_write(DEVRSTCR1, | ||
160 | (1 << 2)); /* Eth */ | ||
161 | |||
162 | /* FPGA irq require special handling */ | ||
163 | for (i = FPGA_IRQ_BASE; i < FPGA_IRQ_BASE + 32; i++) { | ||
164 | irq_set_chip_and_handler_name(i, &bonito_fpga_irq_chip, | ||
165 | handle_level_irq, "level"); | ||
166 | set_irq_flags(i, IRQF_VALID); /* yuck */ | ||
167 | } | ||
168 | |||
169 | irq_set_chained_handler(evt2irq(0x0340), bonito_fpga_irq_demux); | ||
170 | irq_set_irq_type(evt2irq(0x0340), IRQ_TYPE_LEVEL_LOW); | ||
171 | } | ||
172 | |||
96 | /* | 173 | /* |
97 | * PMIC settings | 174 | * PMIC settings |
98 | * | 175 | * |
@@ -274,6 +351,7 @@ static void __init bonito_init(void) | |||
274 | u16 val; | 351 | u16 val; |
275 | 352 | ||
276 | r8a7740_pinmux_init(); | 353 | r8a7740_pinmux_init(); |
354 | bonito_fpga_init(); | ||
277 | 355 | ||
278 | pmic_settings = pmic_do_2A; | 356 | pmic_settings = pmic_do_2A; |
279 | 357 | ||