aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-02-12 11:51:56 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-12 11:51:56 -0500
commit42cf0f203e877cc7e502883d43b3f72149033d86 (patch)
tree3658297d62f28d7bfaa148099b08001aa9904229 /drivers/gpio
parenta2f0bb03f7c499e3db72c70a62b1aa5c55d6a82b (diff)
parentdf9ab9771c64f5229843bfe2a20fe0ee6ac59fc1 (diff)
Merge branch 'for-linus' of git://ftp.arm.linux.org.uk/~rmk/linux-arm
Pull ARM updates from Russell King: - clang assembly fixes from Ard - optimisations and cleanups for Aurora L2 cache support - efficient L2 cache support for secure monitor API on Exynos SoCs - debug menu cleanup from Daniel Thompson to allow better behaviour for multiplatform kernels - StrongARM SA11x0 conversion to irq domains, and pxa_timer - kprobes updates for older ARM CPUs - move probes support out of arch/arm/kernel to arch/arm/probes - add inline asm support for the rbit (reverse bits) instruction - provide an ARM mode secondary CPU entry point (for Qualcomm CPUs) - remove the unused ARMv3 user access code - add driver_override support to AMBA Primecell bus * 'for-linus' of git://ftp.arm.linux.org.uk/~rmk/linux-arm: (55 commits) ARM: 8256/1: driver coamba: add device binding path 'driver_override' ARM: 8301/1: qcom: Use secondary_startup_arm() ARM: 8302/1: Add a secondary_startup that assumes ARM mode ARM: 8300/1: teach __asmeq that r11 == fp and r12 == ip ARM: kprobes: Fix compilation error caused by superfluous '*' ARM: 8297/1: cache-l2x0: optimize aurora range operations ARM: 8296/1: cache-l2x0: clean up aurora cache handling ARM: 8284/1: sa1100: clear RCSR_SMR on resume ARM: 8283/1: sa1100: collie: clear PWER register on machine init ARM: 8282/1: sa1100: use handle_domain_irq ARM: 8281/1: sa1100: move GPIO-related IRQ code to gpio driver ARM: 8280/1: sa1100: switch to irq_domain_add_simple() ARM: 8279/1: sa1100: merge both GPIO irqdomains ARM: 8278/1: sa1100: split irq handling for low GPIOs ARM: 8291/1: replace magic number with PAGE_SHIFT macro in fixup_pv code ARM: 8290/1: decompressor: fix a wrong comment ARM: 8286/1: mm: Fix dma_contiguous_reserve comment ARM: 8248/1: pm: remove outdated comment ARM: 8274/1: Fix DEBUG_LL for multi-platform kernels (without PL01X) ARM: 8273/1: Seperate DEBUG_UART_PHYS from DEBUG_LL on EP93XX ...
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpio-sa1100.c199
1 files changed, 198 insertions, 1 deletions
diff --git a/drivers/gpio/gpio-sa1100.c b/drivers/gpio/gpio-sa1100.c
index a90be34e4d5c..bec397a60204 100644
--- a/drivers/gpio/gpio-sa1100.c
+++ b/drivers/gpio/gpio-sa1100.c
@@ -11,6 +11,7 @@
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/io.h> 13#include <linux/io.h>
14#include <linux/syscore_ops.h>
14#include <mach/hardware.h> 15#include <mach/hardware.h>
15#include <mach/irqs.h> 16#include <mach/irqs.h>
16 17
@@ -50,7 +51,7 @@ static int sa1100_direction_output(struct gpio_chip *chip, unsigned offset, int
50 51
51static int sa1100_to_irq(struct gpio_chip *chip, unsigned offset) 52static int sa1100_to_irq(struct gpio_chip *chip, unsigned offset)
52{ 53{
53 return offset < 11 ? (IRQ_GPIO0 + offset) : (IRQ_GPIO11 - 11 + offset); 54 return IRQ_GPIO0 + offset;
54} 55}
55 56
56static struct gpio_chip sa1100_gpio_chip = { 57static struct gpio_chip sa1100_gpio_chip = {
@@ -64,7 +65,203 @@ static struct gpio_chip sa1100_gpio_chip = {
64 .ngpio = GPIO_MAX + 1, 65 .ngpio = GPIO_MAX + 1,
65}; 66};
66 67
68/*
69 * SA1100 GPIO edge detection for IRQs:
70 * IRQs are generated on Falling-Edge, Rising-Edge, or both.
71 * Use this instead of directly setting GRER/GFER.
72 */
73static int GPIO_IRQ_rising_edge;
74static int GPIO_IRQ_falling_edge;
75static int GPIO_IRQ_mask;
76
77static int sa1100_gpio_type(struct irq_data *d, unsigned int type)
78{
79 unsigned int mask;
80
81 mask = BIT(d->hwirq);
82
83 if (type == IRQ_TYPE_PROBE) {
84 if ((GPIO_IRQ_rising_edge | GPIO_IRQ_falling_edge) & mask)
85 return 0;
86 type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING;
87 }
88
89 if (type & IRQ_TYPE_EDGE_RISING)
90 GPIO_IRQ_rising_edge |= mask;
91 else
92 GPIO_IRQ_rising_edge &= ~mask;
93 if (type & IRQ_TYPE_EDGE_FALLING)
94 GPIO_IRQ_falling_edge |= mask;
95 else
96 GPIO_IRQ_falling_edge &= ~mask;
97
98 GRER = GPIO_IRQ_rising_edge & GPIO_IRQ_mask;
99 GFER = GPIO_IRQ_falling_edge & GPIO_IRQ_mask;
100
101 return 0;
102}
103
104/*
105 * GPIO IRQs must be acknowledged.
106 */
107static void sa1100_gpio_ack(struct irq_data *d)
108{
109 GEDR = BIT(d->hwirq);
110}
111
112static void sa1100_gpio_mask(struct irq_data *d)
113{
114 unsigned int mask = BIT(d->hwirq);
115
116 GPIO_IRQ_mask &= ~mask;
117
118 GRER &= ~mask;
119 GFER &= ~mask;
120}
121
122static void sa1100_gpio_unmask(struct irq_data *d)
123{
124 unsigned int mask = BIT(d->hwirq);
125
126 GPIO_IRQ_mask |= mask;
127
128 GRER = GPIO_IRQ_rising_edge & GPIO_IRQ_mask;
129 GFER = GPIO_IRQ_falling_edge & GPIO_IRQ_mask;
130}
131
132static int sa1100_gpio_wake(struct irq_data *d, unsigned int on)
133{
134 if (on)
135 PWER |= BIT(d->hwirq);
136 else
137 PWER &= ~BIT(d->hwirq);
138 return 0;
139}
140
141/*
142 * This is for GPIO IRQs
143 */
144static struct irq_chip sa1100_gpio_irq_chip = {
145 .name = "GPIO",
146 .irq_ack = sa1100_gpio_ack,
147 .irq_mask = sa1100_gpio_mask,
148 .irq_unmask = sa1100_gpio_unmask,
149 .irq_set_type = sa1100_gpio_type,
150 .irq_set_wake = sa1100_gpio_wake,
151};
152
153static int sa1100_gpio_irqdomain_map(struct irq_domain *d,
154 unsigned int irq, irq_hw_number_t hwirq)
155{
156 irq_set_chip_and_handler(irq, &sa1100_gpio_irq_chip,
157 handle_edge_irq);
158 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
159
160 return 0;
161}
162
163static struct irq_domain_ops sa1100_gpio_irqdomain_ops = {
164 .map = sa1100_gpio_irqdomain_map,
165 .xlate = irq_domain_xlate_onetwocell,
166};
167
168static struct irq_domain *sa1100_gpio_irqdomain;
169
170/*
171 * IRQ 0-11 (GPIO) handler. We enter here with the
172 * irq_controller_lock held, and IRQs disabled. Decode the IRQ
173 * and call the handler.
174 */
175static void
176sa1100_gpio_handler(unsigned int irq, struct irq_desc *desc)
177{
178 unsigned int mask;
179
180 mask = GEDR;
181 do {
182 /*
183 * clear down all currently active IRQ sources.
184 * We will be processing them all.
185 */
186 GEDR = mask;
187
188 irq = IRQ_GPIO0;
189 do {
190 if (mask & 1)
191 generic_handle_irq(irq);
192 mask >>= 1;
193 irq++;
194 } while (mask);
195
196 mask = GEDR;
197 } while (mask);
198}
199
200static int sa1100_gpio_suspend(void)
201{
202 /*
203 * Set the appropriate edges for wakeup.
204 */
205 GRER = PWER & GPIO_IRQ_rising_edge;
206 GFER = PWER & GPIO_IRQ_falling_edge;
207
208 /*
209 * Clear any pending GPIO interrupts.
210 */
211 GEDR = GEDR;
212
213 return 0;
214}
215
216static void sa1100_gpio_resume(void)
217{
218 GRER = GPIO_IRQ_rising_edge & GPIO_IRQ_mask;
219 GFER = GPIO_IRQ_falling_edge & GPIO_IRQ_mask;
220}
221
222static struct syscore_ops sa1100_gpio_syscore_ops = {
223 .suspend = sa1100_gpio_suspend,
224 .resume = sa1100_gpio_resume,
225};
226
227static int __init sa1100_gpio_init_devicefs(void)
228{
229 register_syscore_ops(&sa1100_gpio_syscore_ops);
230 return 0;
231}
232
233device_initcall(sa1100_gpio_init_devicefs);
234
67void __init sa1100_init_gpio(void) 235void __init sa1100_init_gpio(void)
68{ 236{
237 /* clear all GPIO edge detects */
238 GFER = 0;
239 GRER = 0;
240 GEDR = -1;
241
69 gpiochip_add(&sa1100_gpio_chip); 242 gpiochip_add(&sa1100_gpio_chip);
243
244 sa1100_gpio_irqdomain = irq_domain_add_simple(NULL,
245 28, IRQ_GPIO0,
246 &sa1100_gpio_irqdomain_ops, NULL);
247
248 /*
249 * Install handlers for GPIO 0-10 edge detect interrupts
250 */
251 irq_set_chained_handler(IRQ_GPIO0_SC, sa1100_gpio_handler);
252 irq_set_chained_handler(IRQ_GPIO1_SC, sa1100_gpio_handler);
253 irq_set_chained_handler(IRQ_GPIO2_SC, sa1100_gpio_handler);
254 irq_set_chained_handler(IRQ_GPIO3_SC, sa1100_gpio_handler);
255 irq_set_chained_handler(IRQ_GPIO4_SC, sa1100_gpio_handler);
256 irq_set_chained_handler(IRQ_GPIO5_SC, sa1100_gpio_handler);
257 irq_set_chained_handler(IRQ_GPIO6_SC, sa1100_gpio_handler);
258 irq_set_chained_handler(IRQ_GPIO7_SC, sa1100_gpio_handler);
259 irq_set_chained_handler(IRQ_GPIO8_SC, sa1100_gpio_handler);
260 irq_set_chained_handler(IRQ_GPIO9_SC, sa1100_gpio_handler);
261 irq_set_chained_handler(IRQ_GPIO10_SC, sa1100_gpio_handler);
262 /*
263 * Install handler for GPIO 11-27 edge detect interrupts
264 */
265 irq_set_chained_handler(IRQ_GPIO11_27, sa1100_gpio_handler);
266
70} 267}