Merge tag 'master-2014-11-25' of git://git.kernel.org/pub/scm/linux/kernel/git/linvil...
[deliverable/linux.git] / arch / arm / plat-orion / gpio.c
CommitLineData
9569dae7
LB
1/*
2 * arch/arm/plat-orion/gpio.c
3 *
4 * Marvell Orion SoC GPIO handling.
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
10
278b45b0
AL
11#define DEBUG
12
9569dae7
LB
13#include <linux/kernel.h>
14#include <linux/init.h>
07332318 15#include <linux/irq.h>
278b45b0 16#include <linux/irqdomain.h>
9569dae7
LB
17#include <linux/module.h>
18#include <linux/spinlock.h>
19#include <linux/bitops.h>
20#include <linux/io.h>
a8865655 21#include <linux/gpio.h>
ff3e660b 22#include <linux/leds.h>
278b45b0
AL
23#include <linux/of.h>
24#include <linux/of_irq.h>
25#include <linux/of_address.h>
ce91574c 26#include <plat/orion-gpio.h>
9569dae7 27
9eac6d0a
LB
28/*
29 * GPIO unit register offsets.
30 */
31#define GPIO_OUT_OFF 0x0000
32#define GPIO_IO_CONF_OFF 0x0004
33#define GPIO_BLINK_EN_OFF 0x0008
34#define GPIO_IN_POL_OFF 0x000c
35#define GPIO_DATA_IN_OFF 0x0010
36#define GPIO_EDGE_CAUSE_OFF 0x0014
37#define GPIO_EDGE_MASK_OFF 0x0018
38#define GPIO_LEVEL_MASK_OFF 0x001c
39
40struct orion_gpio_chip {
41 struct gpio_chip chip;
42 spinlock_t lock;
43 void __iomem *base;
44 unsigned long valid_input;
45 unsigned long valid_output;
46 int mask_offset;
47 int secondary_irq_base;
278b45b0 48 struct irq_domain *domain;
9eac6d0a
LB
49};
50
51static void __iomem *GPIO_OUT(struct orion_gpio_chip *ochip)
52{
53 return ochip->base + GPIO_OUT_OFF;
54}
55
56static void __iomem *GPIO_IO_CONF(struct orion_gpio_chip *ochip)
57{
58 return ochip->base + GPIO_IO_CONF_OFF;
59}
60
61static void __iomem *GPIO_BLINK_EN(struct orion_gpio_chip *ochip)
62{
63 return ochip->base + GPIO_BLINK_EN_OFF;
64}
65
66static void __iomem *GPIO_IN_POL(struct orion_gpio_chip *ochip)
67{
68 return ochip->base + GPIO_IN_POL_OFF;
69}
70
71static void __iomem *GPIO_DATA_IN(struct orion_gpio_chip *ochip)
72{
73 return ochip->base + GPIO_DATA_IN_OFF;
74}
75
76static void __iomem *GPIO_EDGE_CAUSE(struct orion_gpio_chip *ochip)
77{
78 return ochip->base + GPIO_EDGE_CAUSE_OFF;
79}
80
81static void __iomem *GPIO_EDGE_MASK(struct orion_gpio_chip *ochip)
82{
83 return ochip->base + ochip->mask_offset + GPIO_EDGE_MASK_OFF;
84}
85
86static void __iomem *GPIO_LEVEL_MASK(struct orion_gpio_chip *ochip)
87{
88 return ochip->base + ochip->mask_offset + GPIO_LEVEL_MASK_OFF;
89}
90
9569dae7 91
9eac6d0a
LB
92static struct orion_gpio_chip orion_gpio_chips[2];
93static int orion_gpio_chip_count;
94
95static inline void
96__set_direction(struct orion_gpio_chip *ochip, unsigned pin, int input)
9569dae7
LB
97{
98 u32 u;
99
9eac6d0a 100 u = readl(GPIO_IO_CONF(ochip));
9569dae7 101 if (input)
9eac6d0a 102 u |= 1 << pin;
9569dae7 103 else
9eac6d0a
LB
104 u &= ~(1 << pin);
105 writel(u, GPIO_IO_CONF(ochip));
9569dae7
LB
106}
107
9eac6d0a 108static void __set_level(struct orion_gpio_chip *ochip, unsigned pin, int high)
9569dae7
LB
109{
110 u32 u;
111
9eac6d0a 112 u = readl(GPIO_OUT(ochip));
9569dae7 113 if (high)
9eac6d0a 114 u |= 1 << pin;
9569dae7 115 else
9eac6d0a
LB
116 u &= ~(1 << pin);
117 writel(u, GPIO_OUT(ochip));
9569dae7
LB
118}
119
9eac6d0a
LB
120static inline void
121__set_blinking(struct orion_gpio_chip *ochip, unsigned pin, int blink)
9569dae7 122{
a8865655 123 u32 u;
9569dae7 124
9eac6d0a 125 u = readl(GPIO_BLINK_EN(ochip));
a8865655 126 if (blink)
9eac6d0a 127 u |= 1 << pin;
a8865655 128 else
9eac6d0a
LB
129 u &= ~(1 << pin);
130 writel(u, GPIO_BLINK_EN(ochip));
a8865655 131}
9569dae7 132
9eac6d0a
LB
133static inline int
134orion_gpio_is_valid(struct orion_gpio_chip *ochip, unsigned pin, int mode)
a8865655 135{
9eac6d0a
LB
136 if (pin >= ochip->chip.ngpio)
137 goto err_out;
138
139 if ((mode & GPIO_INPUT_OK) && !test_bit(pin, &ochip->valid_input))
140 goto err_out;
141
142 if ((mode & GPIO_OUTPUT_OK) && !test_bit(pin, &ochip->valid_output))
143 goto err_out;
144
145 return 1;
9569dae7 146
a8865655
EB
147err_out:
148 pr_debug("%s: invalid GPIO %d\n", __func__, pin);
149 return false;
9569dae7 150}
9569dae7 151
a8865655 152/*
7fd2bf3d 153 * GPIO primitives.
a8865655 154 */
9eac6d0a
LB
155static int orion_gpio_request(struct gpio_chip *chip, unsigned pin)
156{
157 struct orion_gpio_chip *ochip =
158 container_of(chip, struct orion_gpio_chip, chip);
159
160 if (orion_gpio_is_valid(ochip, pin, GPIO_INPUT_OK) ||
161 orion_gpio_is_valid(ochip, pin, GPIO_OUTPUT_OK))
162 return 0;
163
164 return -EINVAL;
165}
166
a8865655 167static int orion_gpio_direction_input(struct gpio_chip *chip, unsigned pin)
9569dae7 168{
9eac6d0a
LB
169 struct orion_gpio_chip *ochip =
170 container_of(chip, struct orion_gpio_chip, chip);
9569dae7 171 unsigned long flags;
9569dae7 172
9eac6d0a 173 if (!orion_gpio_is_valid(ochip, pin, GPIO_INPUT_OK))
9569dae7 174 return -EINVAL;
9569dae7 175
9eac6d0a
LB
176 spin_lock_irqsave(&ochip->lock, flags);
177 __set_direction(ochip, pin, 1);
178 spin_unlock_irqrestore(&ochip->lock, flags);
9569dae7
LB
179
180 return 0;
181}
9569dae7 182
9eac6d0a 183static int orion_gpio_get(struct gpio_chip *chip, unsigned pin)
9569dae7 184{
9eac6d0a
LB
185 struct orion_gpio_chip *ochip =
186 container_of(chip, struct orion_gpio_chip, chip);
9569dae7
LB
187 int val;
188
9eac6d0a
LB
189 if (readl(GPIO_IO_CONF(ochip)) & (1 << pin)) {
190 val = readl(GPIO_DATA_IN(ochip)) ^ readl(GPIO_IN_POL(ochip));
191 } else {
192 val = readl(GPIO_OUT(ochip));
193 }
9569dae7 194
9eac6d0a 195 return (val >> pin) & 1;
9569dae7 196}
9569dae7 197
9eac6d0a
LB
198static int
199orion_gpio_direction_output(struct gpio_chip *chip, unsigned pin, int value)
9569dae7 200{
9eac6d0a
LB
201 struct orion_gpio_chip *ochip =
202 container_of(chip, struct orion_gpio_chip, chip);
9569dae7 203 unsigned long flags;
a8865655 204
9eac6d0a 205 if (!orion_gpio_is_valid(ochip, pin, GPIO_OUTPUT_OK))
a8865655 206 return -EINVAL;
9569dae7 207
9eac6d0a
LB
208 spin_lock_irqsave(&ochip->lock, flags);
209 __set_blinking(ochip, pin, 0);
210 __set_level(ochip, pin, value);
211 __set_direction(ochip, pin, 0);
212 spin_unlock_irqrestore(&ochip->lock, flags);
a8865655
EB
213
214 return 0;
9569dae7 215}
9569dae7 216
9eac6d0a 217static void orion_gpio_set(struct gpio_chip *chip, unsigned pin, int value)
9569dae7 218{
9eac6d0a
LB
219 struct orion_gpio_chip *ochip =
220 container_of(chip, struct orion_gpio_chip, chip);
9569dae7 221 unsigned long flags;
9569dae7 222
9eac6d0a
LB
223 spin_lock_irqsave(&ochip->lock, flags);
224 __set_level(ochip, pin, value);
225 spin_unlock_irqrestore(&ochip->lock, flags);
9569dae7 226}
9569dae7 227
9eac6d0a 228static int orion_gpio_to_irq(struct gpio_chip *chip, unsigned pin)
9569dae7 229{
9eac6d0a
LB
230 struct orion_gpio_chip *ochip =
231 container_of(chip, struct orion_gpio_chip, chip);
9569dae7 232
278b45b0
AL
233 return irq_create_mapping(ochip->domain,
234 ochip->secondary_irq_base + pin);
a8865655 235}
9569dae7
LB
236
237/*
238 * Orion-specific GPIO API extensions.
239 */
9eac6d0a
LB
240static struct orion_gpio_chip *orion_gpio_chip_find(int pin)
241{
242 int i;
243
244 for (i = 0; i < orion_gpio_chip_count; i++) {
245 struct orion_gpio_chip *ochip = orion_gpio_chips + i;
246 struct gpio_chip *chip = &ochip->chip;
247
248 if (pin >= chip->base && pin < chip->base + chip->ngpio)
249 return ochip;
250 }
251
252 return NULL;
253}
254
9569dae7
LB
255void __init orion_gpio_set_unused(unsigned pin)
256{
9eac6d0a
LB
257 struct orion_gpio_chip *ochip = orion_gpio_chip_find(pin);
258
259 if (ochip == NULL)
260 return;
261
262 pin -= ochip->chip.base;
263
a8865655 264 /* Configure as output, drive low. */
9eac6d0a
LB
265 __set_level(ochip, pin, 0);
266 __set_direction(ochip, pin, 0);
9569dae7
LB
267}
268
28d27cf4 269void __init orion_gpio_set_valid(unsigned pin, int mode)
9569dae7 270{
9eac6d0a
LB
271 struct orion_gpio_chip *ochip = orion_gpio_chip_find(pin);
272
273 if (ochip == NULL)
274 return;
275
276 pin -= ochip->chip.base;
277
28d27cf4
NP
278 if (mode == 1)
279 mode = GPIO_INPUT_OK | GPIO_OUTPUT_OK;
9eac6d0a 280
28d27cf4 281 if (mode & GPIO_INPUT_OK)
9eac6d0a 282 __set_bit(pin, &ochip->valid_input);
9569dae7 283 else
9eac6d0a
LB
284 __clear_bit(pin, &ochip->valid_input);
285
28d27cf4 286 if (mode & GPIO_OUTPUT_OK)
9eac6d0a 287 __set_bit(pin, &ochip->valid_output);
28d27cf4 288 else
9eac6d0a 289 __clear_bit(pin, &ochip->valid_output);
9569dae7
LB
290}
291
292void orion_gpio_set_blink(unsigned pin, int blink)
293{
9eac6d0a 294 struct orion_gpio_chip *ochip = orion_gpio_chip_find(pin);
9569dae7 295 unsigned long flags;
9569dae7 296
9eac6d0a
LB
297 if (ochip == NULL)
298 return;
9569dae7 299
9eac6d0a 300 spin_lock_irqsave(&ochip->lock, flags);
92a486ea
APR
301 __set_level(ochip, pin & 31, 0);
302 __set_blinking(ochip, pin & 31, blink);
9eac6d0a 303 spin_unlock_irqrestore(&ochip->lock, flags);
9569dae7
LB
304}
305EXPORT_SYMBOL(orion_gpio_set_blink);
07332318 306
ff3e660b
APR
307#define ORION_BLINK_HALF_PERIOD 100 /* ms */
308
309int orion_gpio_led_blink_set(unsigned gpio, int state,
310 unsigned long *delay_on, unsigned long *delay_off)
311{
312
313 if (delay_on && delay_off && !*delay_on && !*delay_off)
314 *delay_on = *delay_off = ORION_BLINK_HALF_PERIOD;
315
316 switch (state) {
317 case GPIO_LED_NO_BLINK_LOW:
318 case GPIO_LED_NO_BLINK_HIGH:
319 orion_gpio_set_blink(gpio, 0);
320 gpio_set_value(gpio, state);
321 break;
322 case GPIO_LED_BLINK:
323 orion_gpio_set_blink(gpio, 1);
324 }
325 return 0;
326}
327EXPORT_SYMBOL_GPL(orion_gpio_led_blink_set);
328
07332318
LB
329
330/*****************************************************************************
331 * Orion GPIO IRQ
332 *
333 * GPIO_IN_POL register controls whether GPIO_DATA_IN will hold the same
334 * value of the line or the opposite value.
335 *
336 * Level IRQ handlers: DATA_IN is used directly as cause register.
337 * Interrupt are masked by LEVEL_MASK registers.
338 * Edge IRQ handlers: Change in DATA_IN are latched in EDGE_CAUSE.
339 * Interrupt are masked by EDGE_MASK registers.
340 * Both-edge handlers: Similar to regular Edge handlers, but also swaps
341 * the polarity to catch the next line transaction.
342 * This is a race condition that might not perfectly
343 * work on some use cases.
344 *
345 * Every eight GPIO lines are grouped (OR'ed) before going up to main
346 * cause register.
347 *
348 * EDGE cause mask
349 * data-in /--------| |-----| |----\
350 * -----| |----- ---- to main cause reg
351 * X \----------------| |----/
352 * polarity LEVEL mask
353 *
354 ****************************************************************************/
07332318 355
3b0c8d40 356static int gpio_irq_set_type(struct irq_data *d, u32 type)
07332318 357{
e59347a1
TG
358 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
359 struct irq_chip_type *ct = irq_data_get_chip_type(d);
360 struct orion_gpio_chip *ochip = gc->private;
9eac6d0a 361 int pin;
07332318
LB
362 u32 u;
363
278b45b0 364 pin = d->hwirq - ochip->secondary_irq_base;
9eac6d0a
LB
365
366 u = readl(GPIO_IO_CONF(ochip)) & (1 << pin);
07332318 367 if (!u) {
07332318
LB
368 return -EINVAL;
369 }
370
e59347a1
TG
371 type &= IRQ_TYPE_SENSE_MASK;
372 if (type == IRQ_TYPE_NONE)
07332318 373 return -EINVAL;
e59347a1
TG
374
375 /* Check if we need to change chip and handler */
376 if (!(ct->type & type))
377 if (irq_setup_alt_chip(d, type))
378 return -EINVAL;
07332318
LB
379
380 /*
381 * Configure interrupt polarity.
382 */
383 if (type == IRQ_TYPE_EDGE_RISING || type == IRQ_TYPE_LEVEL_HIGH) {
9eac6d0a
LB
384 u = readl(GPIO_IN_POL(ochip));
385 u &= ~(1 << pin);
386 writel(u, GPIO_IN_POL(ochip));
07332318 387 } else if (type == IRQ_TYPE_EDGE_FALLING || type == IRQ_TYPE_LEVEL_LOW) {
9eac6d0a
LB
388 u = readl(GPIO_IN_POL(ochip));
389 u |= 1 << pin;
390 writel(u, GPIO_IN_POL(ochip));
07332318
LB
391 } else if (type == IRQ_TYPE_EDGE_BOTH) {
392 u32 v;
393
9eac6d0a 394 v = readl(GPIO_IN_POL(ochip)) ^ readl(GPIO_DATA_IN(ochip));
07332318
LB
395
396 /*
397 * set initial polarity based on current input level
398 */
9eac6d0a
LB
399 u = readl(GPIO_IN_POL(ochip));
400 if (v & (1 << pin))
401 u |= 1 << pin; /* falling */
07332318 402 else
9eac6d0a
LB
403 u &= ~(1 << pin); /* rising */
404 writel(u, GPIO_IN_POL(ochip));
07332318 405 }
07332318
LB
406 return 0;
407}
408
278b45b0
AL
409static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
410{
411 struct orion_gpio_chip *ochip = irq_get_handler_data(irq);
412 u32 cause, type;
413 int i;
414
415 if (ochip == NULL)
416 return;
417
418 cause = readl(GPIO_DATA_IN(ochip)) & readl(GPIO_LEVEL_MASK(ochip));
419 cause |= readl(GPIO_EDGE_CAUSE(ochip)) & readl(GPIO_EDGE_MASK(ochip));
420
421 for (i = 0; i < ochip->chip.ngpio; i++) {
422 int irq;
423
424 irq = ochip->secondary_irq_base + i;
425
426 if (!(cause & (1 << i)))
427 continue;
428
f88704c9 429 type = irq_get_trigger_type(irq);
278b45b0
AL
430 if ((type & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH) {
431 /* Swap polarity (race with GPIO line) */
432 u32 polarity;
433
434 polarity = readl(GPIO_IN_POL(ochip));
435 polarity ^= 1 << i;
436 writel(polarity, GPIO_IN_POL(ochip));
437 }
438 generic_handle_irq(irq);
439 }
440}
441
8d007488
SG
442#ifdef CONFIG_DEBUG_FS
443#include <linux/seq_file.h>
444
445static void orion_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
446{
447 struct orion_gpio_chip *ochip =
448 container_of(chip, struct orion_gpio_chip, chip);
449 u32 out, io_conf, blink, in_pol, data_in, cause, edg_msk, lvl_msk;
450 int i;
451
452 out = readl_relaxed(GPIO_OUT(ochip));
453 io_conf = readl_relaxed(GPIO_IO_CONF(ochip));
454 blink = readl_relaxed(GPIO_BLINK_EN(ochip));
455 in_pol = readl_relaxed(GPIO_IN_POL(ochip));
456 data_in = readl_relaxed(GPIO_DATA_IN(ochip));
457 cause = readl_relaxed(GPIO_EDGE_CAUSE(ochip));
458 edg_msk = readl_relaxed(GPIO_EDGE_MASK(ochip));
459 lvl_msk = readl_relaxed(GPIO_LEVEL_MASK(ochip));
460
461 for (i = 0; i < chip->ngpio; i++) {
462 const char *label;
463 u32 msk;
464 bool is_out;
465
466 label = gpiochip_is_requested(chip, i);
467 if (!label)
468 continue;
469
470 msk = 1 << i;
471 is_out = !(io_conf & msk);
472
473 seq_printf(s, " gpio-%-3d (%-20.20s)", chip->base + i, label);
474
475 if (is_out) {
476 seq_printf(s, " out %s %s\n",
477 out & msk ? "hi" : "lo",
478 blink & msk ? "(blink )" : "");
479 continue;
480 }
481
482 seq_printf(s, " in %s (act %s) - IRQ",
483 (data_in ^ in_pol) & msk ? "hi" : "lo",
484 in_pol & msk ? "lo" : "hi");
485 if (!((edg_msk | lvl_msk) & msk)) {
486 seq_printf(s, " disabled\n");
487 continue;
488 }
489 if (edg_msk & msk)
490 seq_printf(s, " edge ");
491 if (lvl_msk & msk)
492 seq_printf(s, " level");
493 seq_printf(s, " (%s)\n", cause & msk ? "pending" : "clear ");
494 }
495}
496#else
497#define orion_gpio_dbg_show NULL
498#endif
499
9ece8839
ED
500static void orion_gpio_unmask_irq(struct irq_data *d)
501{
502 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
503 struct irq_chip_type *ct = irq_data_get_chip_type(d);
504 u32 reg_val;
505 u32 mask = d->mask;
506
507 irq_gc_lock(gc);
508 reg_val = irq_reg_readl(gc->reg_base + ct->regs.mask);
509 reg_val |= mask;
510 irq_reg_writel(reg_val, gc->reg_base + ct->regs.mask);
511 irq_gc_unlock(gc);
512}
513
514static void orion_gpio_mask_irq(struct irq_data *d)
515{
516 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
517 struct irq_chip_type *ct = irq_data_get_chip_type(d);
518 u32 mask = d->mask;
519 u32 reg_val;
520
521 irq_gc_lock(gc);
522 reg_val = irq_reg_readl(gc->reg_base + ct->regs.mask);
523 reg_val &= ~mask;
524 irq_reg_writel(reg_val, gc->reg_base + ct->regs.mask);
525 irq_gc_unlock(gc);
526}
527
278b45b0
AL
528void __init orion_gpio_init(struct device_node *np,
529 int gpio_base, int ngpio,
530 void __iomem *base, int mask_offset,
531 int secondary_irq_base,
532 int irqs[4])
9eac6d0a
LB
533{
534 struct orion_gpio_chip *ochip;
e59347a1
TG
535 struct irq_chip_generic *gc;
536 struct irq_chip_type *ct;
0b35a45b 537 char gc_label[16];
278b45b0 538 int i;
9eac6d0a
LB
539
540 if (orion_gpio_chip_count == ARRAY_SIZE(orion_gpio_chips))
541 return;
542
0b35a45b
HB
543 snprintf(gc_label, sizeof(gc_label), "orion_gpio%d",
544 orion_gpio_chip_count);
545
9eac6d0a 546 ochip = orion_gpio_chips + orion_gpio_chip_count;
0b35a45b 547 ochip->chip.label = kstrdup(gc_label, GFP_KERNEL);
9eac6d0a
LB
548 ochip->chip.request = orion_gpio_request;
549 ochip->chip.direction_input = orion_gpio_direction_input;
550 ochip->chip.get = orion_gpio_get;
551 ochip->chip.direction_output = orion_gpio_direction_output;
552 ochip->chip.set = orion_gpio_set;
553 ochip->chip.to_irq = orion_gpio_to_irq;
554 ochip->chip.base = gpio_base;
555 ochip->chip.ngpio = ngpio;
556 ochip->chip.can_sleep = 0;
278b45b0
AL
557#ifdef CONFIG_OF
558 ochip->chip.of_node = np;
559#endif
8d007488 560 ochip->chip.dbg_show = orion_gpio_dbg_show;
278b45b0 561
9eac6d0a
LB
562 spin_lock_init(&ochip->lock);
563 ochip->base = (void __iomem *)base;
564 ochip->valid_input = 0;
565 ochip->valid_output = 0;
566 ochip->mask_offset = mask_offset;
567 ochip->secondary_irq_base = secondary_irq_base;
568
569 gpiochip_add(&ochip->chip);
570
9eac6d0a
LB
571 /*
572 * Mask and clear GPIO interrupts.
573 */
574 writel(0, GPIO_EDGE_CAUSE(ochip));
575 writel(0, GPIO_EDGE_MASK(ochip));
576 writel(0, GPIO_LEVEL_MASK(ochip));
577
278b45b0
AL
578 /* Setup the interrupt handlers. Each chip can have up to 4
579 * interrupt handlers, with each handler dealing with 8 GPIO
580 * pins. */
581
582 for (i = 0; i < 4; i++) {
583 if (irqs[i]) {
584 irq_set_handler_data(irqs[i], ochip);
585 irq_set_chained_handler(irqs[i], gpio_irq_handler);
586 }
587 }
588
589 gc = irq_alloc_generic_chip("orion_gpio_irq", 2,
590 secondary_irq_base,
e59347a1
TG
591 ochip->base, handle_level_irq);
592 gc->private = ochip;
e59347a1
TG
593 ct = gc->chip_types;
594 ct->regs.mask = ochip->mask_offset + GPIO_LEVEL_MASK_OFF;
595 ct->type = IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW;
9ece8839
ED
596 ct->chip.irq_mask = orion_gpio_mask_irq;
597 ct->chip.irq_unmask = orion_gpio_unmask_irq;
e59347a1 598 ct->chip.irq_set_type = gpio_irq_set_type;
278b45b0 599 ct->chip.name = ochip->chip.label;
e59347a1
TG
600
601 ct++;
602 ct->regs.mask = ochip->mask_offset + GPIO_EDGE_MASK_OFF;
603 ct->regs.ack = GPIO_EDGE_CAUSE_OFF;
604 ct->type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING;
659fb32d 605 ct->chip.irq_ack = irq_gc_ack_clr_bit;
9ece8839
ED
606 ct->chip.irq_mask = orion_gpio_mask_irq;
607 ct->chip.irq_unmask = orion_gpio_unmask_irq;
e59347a1
TG
608 ct->chip.irq_set_type = gpio_irq_set_type;
609 ct->handler = handle_edge_irq;
278b45b0 610 ct->chip.name = ochip->chip.label;
e59347a1
TG
611
612 irq_setup_generic_chip(gc, IRQ_MSK(ngpio), IRQ_GC_INIT_MASK_CACHE,
613 IRQ_NOREQUEST, IRQ_LEVEL | IRQ_NOPROBE);
9eac6d0a 614
278b45b0
AL
615 /* Setup irq domain on top of the generic chip. */
616 ochip->domain = irq_domain_add_legacy(np,
617 ochip->chip.ngpio,
618 ochip->secondary_irq_base,
619 ochip->secondary_irq_base,
620 &irq_domain_simple_ops,
621 ochip);
622 if (!ochip->domain)
623 panic("%s: couldn't allocate irq domain (DT).\n",
624 ochip->chip.label);
9eac6d0a 625
278b45b0
AL
626 orion_gpio_chip_count++;
627}
This page took 0.349501 seconds and 5 git commands to generate.