aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2015-01-14 20:29:16 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2015-01-29 10:24:46 -0500
commit83508093f448e929bf55d07dd08246d22b03d753 (patch)
tree60a1ecb382a012bb5626b556f7c2aa848f7038d0
parent7a8ca0a0c480fedf91bdbadf8b90edd5374ce18b (diff)
ARM: 8278/1: sa1100: split irq handling for low GPIOs
Low GPIO pins use an interrupt in SC interrupts space. However it's possible to handle them as if all the GPIO interrupts are instead tied to single GPIO handler, which later decodes GEDR register and chain-calls next IRQ handler. So split first 11 interrupts into system part (IRQ_GPIO0_SC - IRQ_GPIO10_SC) which work exactly like the rest of system controller interrupts and real GPIO interrupts (IRQ_GPIO0..IRQ_GPIO10). A single handler sa1100_gpio_handler then decodes and calls next handler. Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Tested-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/mach-sa1100/include/mach/irqs.h73
-rw-r--r--arch/arm/mach-sa1100/irq.c87
-rw-r--r--drivers/gpio/gpio-sa1100.c2
3 files changed, 93 insertions, 69 deletions
diff --git a/arch/arm/mach-sa1100/include/mach/irqs.h b/arch/arm/mach-sa1100/include/mach/irqs.h
index de0983494c7e..734e30e406a3 100644
--- a/arch/arm/mach-sa1100/include/mach/irqs.h
+++ b/arch/arm/mach-sa1100/include/mach/irqs.h
@@ -8,17 +8,17 @@
8 * 2001/11/14 RMK Cleaned up and standardised a lot of the IRQs. 8 * 2001/11/14 RMK Cleaned up and standardised a lot of the IRQs.
9 */ 9 */
10 10
11#define IRQ_GPIO0 1 11#define IRQ_GPIO0_SC 1
12#define IRQ_GPIO1 2 12#define IRQ_GPIO1_SC 2
13#define IRQ_GPIO2 3 13#define IRQ_GPIO2_SC 3
14#define IRQ_GPIO3 4 14#define IRQ_GPIO3_SC 4
15#define IRQ_GPIO4 5 15#define IRQ_GPIO4_SC 5
16#define IRQ_GPIO5 6 16#define IRQ_GPIO5_SC 6
17#define IRQ_GPIO6 7 17#define IRQ_GPIO6_SC 7
18#define IRQ_GPIO7 8 18#define IRQ_GPIO7_SC 8
19#define IRQ_GPIO8 9 19#define IRQ_GPIO8_SC 9
20#define IRQ_GPIO9 10 20#define IRQ_GPIO9_SC 10
21#define IRQ_GPIO10 11 21#define IRQ_GPIO10_SC 11
22#define IRQ_GPIO11_27 12 22#define IRQ_GPIO11_27 12
23#define IRQ_LCD 13 /* LCD controller */ 23#define IRQ_LCD 13 /* LCD controller */
24#define IRQ_Ser0UDC 14 /* Ser. port 0 UDC */ 24#define IRQ_Ser0UDC 14 /* Ser. port 0 UDC */
@@ -41,32 +41,43 @@
41#define IRQ_RTC1Hz 31 /* RTC 1 Hz clock */ 41#define IRQ_RTC1Hz 31 /* RTC 1 Hz clock */
42#define IRQ_RTCAlrm 32 /* RTC Alarm */ 42#define IRQ_RTCAlrm 32 /* RTC Alarm */
43 43
44#define IRQ_GPIO11 33 44#define IRQ_GPIO0 33
45#define IRQ_GPIO12 34 45#define IRQ_GPIO1 34
46#define IRQ_GPIO13 35 46#define IRQ_GPIO2 35
47#define IRQ_GPIO14 36 47#define IRQ_GPIO3 36
48#define IRQ_GPIO15 37 48#define IRQ_GPIO4 37
49#define IRQ_GPIO16 38 49#define IRQ_GPIO5 38
50#define IRQ_GPIO17 39 50#define IRQ_GPIO6 39
51#define IRQ_GPIO18 40 51#define IRQ_GPIO7 40
52#define IRQ_GPIO19 41 52#define IRQ_GPIO8 41
53#define IRQ_GPIO20 42 53#define IRQ_GPIO9 42
54#define IRQ_GPIO21 43 54#define IRQ_GPIO10 43
55#define IRQ_GPIO22 44 55#define IRQ_GPIO11 44
56#define IRQ_GPIO23 45 56#define IRQ_GPIO12 45
57#define IRQ_GPIO24 46 57#define IRQ_GPIO13 46
58#define IRQ_GPIO25 47 58#define IRQ_GPIO14 47
59#define IRQ_GPIO26 48 59#define IRQ_GPIO15 48
60#define IRQ_GPIO27 49 60#define IRQ_GPIO16 49
61#define IRQ_GPIO17 50
62#define IRQ_GPIO18 51
63#define IRQ_GPIO19 52
64#define IRQ_GPIO20 53
65#define IRQ_GPIO21 54
66#define IRQ_GPIO22 55
67#define IRQ_GPIO23 56
68#define IRQ_GPIO24 57
69#define IRQ_GPIO25 58
70#define IRQ_GPIO26 59
71#define IRQ_GPIO27 60
61 72
62/* 73/*
63 * The next 16 interrupts are for board specific purposes. Since 74 * The next 16 interrupts are for board specific purposes. Since
64 * the kernel can only run on one machine at a time, we can re-use 75 * the kernel can only run on one machine at a time, we can re-use
65 * these. If you need more, increase IRQ_BOARD_END, but keep it 76 * these. If you need more, increase IRQ_BOARD_END, but keep it
66 * within sensible limits. IRQs 49 to 64 are available. 77 * within sensible limits. IRQs 61 to 76 are available.
67 */ 78 */
68#define IRQ_BOARD_START 50 79#define IRQ_BOARD_START 61
69#define IRQ_BOARD_END 66 80#define IRQ_BOARD_END 77
70 81
71/* 82/*
72 * Figure out the MAX IRQ number. 83 * Figure out the MAX IRQ number.
diff --git a/arch/arm/mach-sa1100/irq.c b/arch/arm/mach-sa1100/irq.c
index 63e2901db416..2dc6a2a9c60c 100644
--- a/arch/arm/mach-sa1100/irq.c
+++ b/arch/arm/mach-sa1100/irq.c
@@ -87,7 +87,7 @@ static struct irq_domain *sa1100_normal_irqdomain;
87 */ 87 */
88static int GPIO_IRQ_rising_edge; 88static int GPIO_IRQ_rising_edge;
89static int GPIO_IRQ_falling_edge; 89static int GPIO_IRQ_falling_edge;
90static int GPIO_IRQ_mask = (1 << 11) - 1; 90static int GPIO_IRQ_mask;
91 91
92static int sa1100_gpio_type(struct irq_data *d, unsigned int type) 92static int sa1100_gpio_type(struct irq_data *d, unsigned int type)
93{ 93{
@@ -124,6 +124,26 @@ static void sa1100_gpio_ack(struct irq_data *d)
124 GEDR = BIT(d->hwirq); 124 GEDR = BIT(d->hwirq);
125} 125}
126 126
127static void sa1100_gpio_mask(struct irq_data *d)
128{
129 unsigned int mask = BIT(d->hwirq);
130
131 GPIO_IRQ_mask &= ~mask;
132
133 GRER &= ~mask;
134 GFER &= ~mask;
135}
136
137static void sa1100_gpio_unmask(struct irq_data *d)
138{
139 unsigned int mask = BIT(d->hwirq);
140
141 GPIO_IRQ_mask |= mask;
142
143 GRER = GPIO_IRQ_rising_edge & GPIO_IRQ_mask;
144 GFER = GPIO_IRQ_falling_edge & GPIO_IRQ_mask;
145}
146
127static int sa1100_gpio_wake(struct irq_data *d, unsigned int on) 147static int sa1100_gpio_wake(struct irq_data *d, unsigned int on)
128{ 148{
129 if (on) 149 if (on)
@@ -139,8 +159,8 @@ static int sa1100_gpio_wake(struct irq_data *d, unsigned int on)
139static struct irq_chip sa1100_low_gpio_chip = { 159static struct irq_chip sa1100_low_gpio_chip = {
140 .name = "GPIO-l", 160 .name = "GPIO-l",
141 .irq_ack = sa1100_gpio_ack, 161 .irq_ack = sa1100_gpio_ack,
142 .irq_mask = sa1100_mask_irq, 162 .irq_mask = sa1100_gpio_mask,
143 .irq_unmask = sa1100_unmask_irq, 163 .irq_unmask = sa1100_gpio_unmask,
144 .irq_set_type = sa1100_gpio_type, 164 .irq_set_type = sa1100_gpio_type,
145 .irq_set_wake = sa1100_gpio_wake, 165 .irq_set_wake = sa1100_gpio_wake,
146}; 166};
@@ -163,16 +183,16 @@ static struct irq_domain_ops sa1100_low_gpio_irqdomain_ops = {
163static struct irq_domain *sa1100_low_gpio_irqdomain; 183static struct irq_domain *sa1100_low_gpio_irqdomain;
164 184
165/* 185/*
166 * IRQ11 (GPIO11 through 27) handler. We enter here with the 186 * IRQ 0-11 (GPIO) handler. We enter here with the
167 * irq_controller_lock held, and IRQs disabled. Decode the IRQ 187 * irq_controller_lock held, and IRQs disabled. Decode the IRQ
168 * and call the handler. 188 * and call the handler.
169 */ 189 */
170static void 190static void
171sa1100_high_gpio_handler(unsigned int irq, struct irq_desc *desc) 191sa1100_gpio_handler(unsigned int irq, struct irq_desc *desc)
172{ 192{
173 unsigned int mask; 193 unsigned int mask;
174 194
175 mask = GEDR & 0xfffff800; 195 mask = GEDR;
176 do { 196 do {
177 /* 197 /*
178 * clear down all currently active IRQ sources. 198 * clear down all currently active IRQ sources.
@@ -180,8 +200,7 @@ sa1100_high_gpio_handler(unsigned int irq, struct irq_desc *desc)
180 */ 200 */
181 GEDR = mask; 201 GEDR = mask;
182 202
183 irq = IRQ_GPIO11; 203 irq = IRQ_GPIO0;
184 mask >>= 11;
185 do { 204 do {
186 if (mask & 1) 205 if (mask & 1)
187 generic_handle_irq(irq); 206 generic_handle_irq(irq);
@@ -189,7 +208,7 @@ sa1100_high_gpio_handler(unsigned int irq, struct irq_desc *desc)
189 irq++; 208 irq++;
190 } while (mask); 209 } while (mask);
191 210
192 mask = GEDR & 0xfffff800; 211 mask = GEDR;
193 } while (mask); 212 } while (mask);
194} 213}
195 214
@@ -198,31 +217,11 @@ sa1100_high_gpio_handler(unsigned int irq, struct irq_desc *desc)
198 * In addition, the IRQs are all collected up into one bit in the 217 * In addition, the IRQs are all collected up into one bit in the
199 * interrupt controller registers. 218 * interrupt controller registers.
200 */ 219 */
201static void sa1100_high_gpio_mask(struct irq_data *d)
202{
203 unsigned int mask = BIT(d->hwirq);
204
205 GPIO_IRQ_mask &= ~mask;
206
207 GRER &= ~mask;
208 GFER &= ~mask;
209}
210
211static void sa1100_high_gpio_unmask(struct irq_data *d)
212{
213 unsigned int mask = BIT(d->hwirq);
214
215 GPIO_IRQ_mask |= mask;
216
217 GRER = GPIO_IRQ_rising_edge & GPIO_IRQ_mask;
218 GFER = GPIO_IRQ_falling_edge & GPIO_IRQ_mask;
219}
220
221static struct irq_chip sa1100_high_gpio_chip = { 220static struct irq_chip sa1100_high_gpio_chip = {
222 .name = "GPIO-h", 221 .name = "GPIO-h",
223 .irq_ack = sa1100_gpio_ack, 222 .irq_ack = sa1100_gpio_ack,
224 .irq_mask = sa1100_high_gpio_mask, 223 .irq_mask = sa1100_gpio_mask,
225 .irq_unmask = sa1100_high_gpio_unmask, 224 .irq_unmask = sa1100_gpio_unmask,
226 .irq_set_type = sa1100_gpio_type, 225 .irq_set_type = sa1100_gpio_type,
227 .irq_set_wake = sa1100_gpio_wake, 226 .irq_set_wake = sa1100_gpio_wake,
228}; 227};
@@ -325,7 +324,7 @@ sa1100_handle_irq(struct pt_regs *regs)
325 if (mask == 0) 324 if (mask == 0)
326 break; 325 break;
327 326
328 handle_IRQ(ffs(mask) - 1 + IRQ_GPIO0, regs); 327 handle_IRQ(ffs(mask) - 1 + IRQ_GPIO0_SC, regs);
329 } while (1); 328 } while (1);
330} 329}
331 330
@@ -350,22 +349,36 @@ void __init sa1100_init_irq(void)
350 */ 349 */
351 ICCR = 1; 350 ICCR = 1;
352 351
352 sa1100_normal_irqdomain = irq_domain_add_legacy(NULL,
353 32, IRQ_GPIO0_SC, 0,
354 &sa1100_normal_irqdomain_ops, NULL);
355
353 sa1100_low_gpio_irqdomain = irq_domain_add_legacy(NULL, 356 sa1100_low_gpio_irqdomain = irq_domain_add_legacy(NULL,
354 11, IRQ_GPIO0, 0, 357 11, IRQ_GPIO0, 0,
355 &sa1100_low_gpio_irqdomain_ops, NULL); 358 &sa1100_low_gpio_irqdomain_ops, NULL);
356 359
357 sa1100_normal_irqdomain = irq_domain_add_legacy(NULL,
358 21, IRQ_GPIO11_27, 11,
359 &sa1100_normal_irqdomain_ops, NULL);
360
361 sa1100_high_gpio_irqdomain = irq_domain_add_legacy(NULL, 360 sa1100_high_gpio_irqdomain = irq_domain_add_legacy(NULL,
362 17, IRQ_GPIO11, 11, 361 17, IRQ_GPIO11, 11,
363 &sa1100_high_gpio_irqdomain_ops, NULL); 362 &sa1100_high_gpio_irqdomain_ops, NULL);
364 363
365 /* 364 /*
365 * Install handlers for GPIO 0-10 edge detect interrupts
366 */
367 irq_set_chained_handler(IRQ_GPIO0_SC, sa1100_gpio_handler);
368 irq_set_chained_handler(IRQ_GPIO1_SC, sa1100_gpio_handler);
369 irq_set_chained_handler(IRQ_GPIO2_SC, sa1100_gpio_handler);
370 irq_set_chained_handler(IRQ_GPIO3_SC, sa1100_gpio_handler);
371 irq_set_chained_handler(IRQ_GPIO4_SC, sa1100_gpio_handler);
372 irq_set_chained_handler(IRQ_GPIO5_SC, sa1100_gpio_handler);
373 irq_set_chained_handler(IRQ_GPIO6_SC, sa1100_gpio_handler);
374 irq_set_chained_handler(IRQ_GPIO7_SC, sa1100_gpio_handler);
375 irq_set_chained_handler(IRQ_GPIO8_SC, sa1100_gpio_handler);
376 irq_set_chained_handler(IRQ_GPIO9_SC, sa1100_gpio_handler);
377 irq_set_chained_handler(IRQ_GPIO10_SC, sa1100_gpio_handler);
378 /*
366 * Install handler for GPIO 11-27 edge detect interrupts 379 * Install handler for GPIO 11-27 edge detect interrupts
367 */ 380 */
368 irq_set_chained_handler(IRQ_GPIO11_27, sa1100_high_gpio_handler); 381 irq_set_chained_handler(IRQ_GPIO11_27, sa1100_gpio_handler);
369 382
370 set_handle_irq(sa1100_handle_irq); 383 set_handle_irq(sa1100_handle_irq);
371 384
diff --git a/drivers/gpio/gpio-sa1100.c b/drivers/gpio/gpio-sa1100.c
index a90be34e4d5c..5b5d3c7bb84e 100644
--- a/drivers/gpio/gpio-sa1100.c
+++ b/drivers/gpio/gpio-sa1100.c
@@ -50,7 +50,7 @@ static int sa1100_direction_output(struct gpio_chip *chip, unsigned offset, int
50 50
51static int sa1100_to_irq(struct gpio_chip *chip, unsigned offset) 51static int sa1100_to_irq(struct gpio_chip *chip, unsigned offset)
52{ 52{
53 return offset < 11 ? (IRQ_GPIO0 + offset) : (IRQ_GPIO11 - 11 + offset); 53 return IRQ_GPIO0 + offset;
54} 54}
55 55
56static struct gpio_chip sa1100_gpio_chip = { 56static struct gpio_chip sa1100_gpio_chip = {