2 * linux/arch/arm/mach-omap/gpio.c
4 * Support functions for OMAP GPIO
6 * Copyright (C) 2003 Nokia Corporation
7 * Written by Juha Yrjölä <juha.yrjola@nokia.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #include <linux/config.h>
15 #include <linux/init.h>
16 #include <linux/module.h>
17 #include <linux/sched.h>
18 #include <linux/interrupt.h>
19 #include <linux/ptrace.h>
21 #include <asm/hardware.h>
23 #include <asm/arch/irqs.h>
24 #include <asm/arch/gpio.h>
25 #include <asm/mach/irq.h>
30 * OMAP1510 GPIO registers
32 #define OMAP1510_GPIO_BASE 0xfffce000
33 #define OMAP1510_GPIO_DATA_INPUT 0x00
34 #define OMAP1510_GPIO_DATA_OUTPUT 0x04
35 #define OMAP1510_GPIO_DIR_CONTROL 0x08
36 #define OMAP1510_GPIO_INT_CONTROL 0x0c
37 #define OMAP1510_GPIO_INT_MASK 0x10
38 #define OMAP1510_GPIO_INT_STATUS 0x14
39 #define OMAP1510_GPIO_PIN_CONTROL 0x18
41 #define OMAP1510_IH_GPIO_BASE 64
44 * OMAP1610 specific GPIO registers
46 #define OMAP1610_GPIO1_BASE 0xfffbe400
47 #define OMAP1610_GPIO2_BASE 0xfffbec00
48 #define OMAP1610_GPIO3_BASE 0xfffbb400
49 #define OMAP1610_GPIO4_BASE 0xfffbbc00
50 #define OMAP1610_GPIO_REVISION 0x0000
51 #define OMAP1610_GPIO_SYSCONFIG 0x0010
52 #define OMAP1610_GPIO_SYSSTATUS 0x0014
53 #define OMAP1610_GPIO_IRQSTATUS1 0x0018
54 #define OMAP1610_GPIO_IRQENABLE1 0x001c
55 #define OMAP1610_GPIO_DATAIN 0x002c
56 #define OMAP1610_GPIO_DATAOUT 0x0030
57 #define OMAP1610_GPIO_DIRECTION 0x0034
58 #define OMAP1610_GPIO_EDGE_CTRL1 0x0038
59 #define OMAP1610_GPIO_EDGE_CTRL2 0x003c
60 #define OMAP1610_GPIO_CLEAR_IRQENABLE1 0x009c
61 #define OMAP1610_GPIO_CLEAR_DATAOUT 0x00b0
62 #define OMAP1610_GPIO_SET_IRQENABLE1 0x00dc
63 #define OMAP1610_GPIO_SET_DATAOUT 0x00f0
66 * OMAP730 specific GPIO registers
68 #define OMAP730_GPIO1_BASE 0xfffbc000
69 #define OMAP730_GPIO2_BASE 0xfffbc800
70 #define OMAP730_GPIO3_BASE 0xfffbd000
71 #define OMAP730_GPIO4_BASE 0xfffbd800
72 #define OMAP730_GPIO5_BASE 0xfffbe000
73 #define OMAP730_GPIO6_BASE 0xfffbe800
74 #define OMAP730_GPIO_DATA_INPUT 0x00
75 #define OMAP730_GPIO_DATA_OUTPUT 0x04
76 #define OMAP730_GPIO_DIR_CONTROL 0x08
77 #define OMAP730_GPIO_INT_CONTROL 0x0c
78 #define OMAP730_GPIO_INT_MASK 0x10
79 #define OMAP730_GPIO_INT_STATUS 0x14
81 #define OMAP_MPUIO_MASK (~OMAP_MAX_GPIO_LINES & 0xff)
86 u16 virtual_irq_start
;
92 #define METHOD_MPUIO 0
93 #define METHOD_GPIO_1510 1
94 #define METHOD_GPIO_1610 2
95 #define METHOD_GPIO_730 3
97 #if defined(CONFIG_ARCH_OMAP1610) || defined(CONFIG_ARCH_OMAP1710) || defined(CONFIG_ARCH_OMAP5912)
98 static struct gpio_bank gpio_bank_1610
[5] = {
99 { OMAP_MPUIO_BASE
, INT_MPUIO
, IH_MPUIO_BASE
, METHOD_MPUIO
},
100 { OMAP1610_GPIO1_BASE
, INT_GPIO_BANK1
, IH_GPIO_BASE
, METHOD_GPIO_1610
},
101 { OMAP1610_GPIO2_BASE
, INT_1610_GPIO_BANK2
, IH_GPIO_BASE
+ 16, METHOD_GPIO_1610
},
102 { OMAP1610_GPIO3_BASE
, INT_1610_GPIO_BANK3
, IH_GPIO_BASE
+ 32, METHOD_GPIO_1610
},
103 { OMAP1610_GPIO4_BASE
, INT_1610_GPIO_BANK4
, IH_GPIO_BASE
+ 48, METHOD_GPIO_1610
},
107 #ifdef CONFIG_ARCH_OMAP1510
108 static struct gpio_bank gpio_bank_1510
[2] = {
109 { OMAP_MPUIO_BASE
, INT_MPUIO
, IH_MPUIO_BASE
, METHOD_MPUIO
},
110 { OMAP1510_GPIO_BASE
, INT_GPIO_BANK1
, IH_GPIO_BASE
, METHOD_GPIO_1510
}
114 #ifdef CONFIG_ARCH_OMAP730
115 static struct gpio_bank gpio_bank_730
[7] = {
116 { OMAP_MPUIO_BASE
, INT_730_MPUIO
, IH_MPUIO_BASE
, METHOD_MPUIO
},
117 { OMAP730_GPIO1_BASE
, INT_GPIO_BANK1
, IH_GPIO_BASE
, METHOD_GPIO_730
},
118 { OMAP730_GPIO2_BASE
, INT_730_GPIO_BANK2
, IH_GPIO_BASE
+ 32, METHOD_GPIO_730
},
119 { OMAP730_GPIO3_BASE
, INT_730_GPIO_BANK3
, IH_GPIO_BASE
+ 64, METHOD_GPIO_730
},
120 { OMAP730_GPIO4_BASE
, INT_730_GPIO_BANK4
, IH_GPIO_BASE
+ 96, METHOD_GPIO_730
},
121 { OMAP730_GPIO5_BASE
, INT_730_GPIO_BANK5
, IH_GPIO_BASE
+ 128, METHOD_GPIO_730
},
122 { OMAP730_GPIO6_BASE
, INT_730_GPIO_BANK6
, IH_GPIO_BASE
+ 160, METHOD_GPIO_730
},
126 static struct gpio_bank
*gpio_bank
;
127 static int gpio_bank_count
;
129 static inline struct gpio_bank
*get_gpio_bank(int gpio
)
131 #ifdef CONFIG_ARCH_OMAP1510
132 if (cpu_is_omap1510()) {
133 if (OMAP_GPIO_IS_MPUIO(gpio
))
134 return &gpio_bank
[0];
135 return &gpio_bank
[1];
138 #if defined(CONFIG_ARCH_OMAP1610) || defined(CONFIG_ARCH_OMAP1710) || defined(CONFIG_ARCH_OMAP5912)
139 if (cpu_is_omap1610() || cpu_is_omap1710() || cpu_is_omap5912()) {
140 if (OMAP_GPIO_IS_MPUIO(gpio
))
141 return &gpio_bank
[0];
142 return &gpio_bank
[1 + (gpio
>> 4)];
145 #ifdef CONFIG_ARCH_OMAP730
146 if (cpu_is_omap730()) {
147 if (OMAP_GPIO_IS_MPUIO(gpio
))
148 return &gpio_bank
[0];
149 return &gpio_bank
[1 + (gpio
>> 5)];
154 static inline int get_gpio_index(int gpio
)
156 if (cpu_is_omap730())
162 static inline int gpio_valid(int gpio
)
166 if (OMAP_GPIO_IS_MPUIO(gpio
)) {
167 if ((gpio
& OMAP_MPUIO_MASK
) > 16)
171 #ifdef CONFIG_ARCH_OMAP1510
172 if (cpu_is_omap1510() && gpio
< 16)
175 #if defined(CONFIG_ARCH_OMAP1610) || defined(CONFIG_ARCH_OMAP1710) || defined(CONFIG_ARCH_OMAP5912)
176 if ((cpu_is_omap1610() || cpu_is_omap1710() || cpu_is_omap5912()) && gpio
< 64)
179 #ifdef CONFIG_ARCH_OMAP730
180 if (cpu_is_omap730() && gpio
< 192)
186 static int check_gpio(int gpio
)
188 if (unlikely(gpio_valid(gpio
)) < 0) {
189 printk(KERN_ERR
"omap-gpio: invalid GPIO %d\n", gpio
);
196 static void _set_gpio_direction(struct gpio_bank
*bank
, int gpio
, int is_input
)
198 u32 reg
= bank
->base
;
201 switch (bank
->method
) {
203 reg
+= OMAP_MPUIO_IO_CNTL
;
205 case METHOD_GPIO_1510
:
206 reg
+= OMAP1510_GPIO_DIR_CONTROL
;
208 case METHOD_GPIO_1610
:
209 reg
+= OMAP1610_GPIO_DIRECTION
;
211 case METHOD_GPIO_730
:
212 reg
+= OMAP730_GPIO_DIR_CONTROL
;
215 l
= __raw_readl(reg
);
220 __raw_writel(l
, reg
);
223 void omap_set_gpio_direction(int gpio
, int is_input
)
225 struct gpio_bank
*bank
;
227 if (check_gpio(gpio
) < 0)
229 bank
= get_gpio_bank(gpio
);
230 spin_lock(&bank
->lock
);
231 _set_gpio_direction(bank
, get_gpio_index(gpio
), is_input
);
232 spin_unlock(&bank
->lock
);
235 static void _set_gpio_dataout(struct gpio_bank
*bank
, int gpio
, int enable
)
237 u32 reg
= bank
->base
;
240 switch (bank
->method
) {
242 reg
+= OMAP_MPUIO_OUTPUT
;
243 l
= __raw_readl(reg
);
249 case METHOD_GPIO_1510
:
250 reg
+= OMAP1510_GPIO_DATA_OUTPUT
;
251 l
= __raw_readl(reg
);
257 case METHOD_GPIO_1610
:
259 reg
+= OMAP1610_GPIO_SET_DATAOUT
;
261 reg
+= OMAP1610_GPIO_CLEAR_DATAOUT
;
264 case METHOD_GPIO_730
:
265 reg
+= OMAP730_GPIO_DATA_OUTPUT
;
266 l
= __raw_readl(reg
);
276 __raw_writel(l
, reg
);
279 void omap_set_gpio_dataout(int gpio
, int enable
)
281 struct gpio_bank
*bank
;
283 if (check_gpio(gpio
) < 0)
285 bank
= get_gpio_bank(gpio
);
286 spin_lock(&bank
->lock
);
287 _set_gpio_dataout(bank
, get_gpio_index(gpio
), enable
);
288 spin_unlock(&bank
->lock
);
291 int omap_get_gpio_datain(int gpio
)
293 struct gpio_bank
*bank
;
296 if (check_gpio(gpio
) < 0)
298 bank
= get_gpio_bank(gpio
);
300 switch (bank
->method
) {
302 reg
+= OMAP_MPUIO_INPUT_LATCH
;
304 case METHOD_GPIO_1510
:
305 reg
+= OMAP1510_GPIO_DATA_INPUT
;
307 case METHOD_GPIO_1610
:
308 reg
+= OMAP1610_GPIO_DATAIN
;
314 return (__raw_readl(reg
) & (1 << get_gpio_index(gpio
))) != 0;
317 static void _set_gpio_edge_ctrl(struct gpio_bank
*bank
, int gpio
, int edge
)
319 u32 reg
= bank
->base
;
322 switch (bank
->method
) {
324 reg
+= OMAP_MPUIO_GPIO_INT_EDGE
;
325 l
= __raw_readl(reg
);
326 if (edge
== OMAP_GPIO_RISING_EDGE
)
330 __raw_writel(l
, reg
);
332 case METHOD_GPIO_1510
:
333 reg
+= OMAP1510_GPIO_INT_CONTROL
;
334 l
= __raw_readl(reg
);
335 if (edge
== OMAP_GPIO_RISING_EDGE
)
339 __raw_writel(l
, reg
);
341 case METHOD_GPIO_1610
:
344 reg
+= OMAP1610_GPIO_EDGE_CTRL2
;
346 reg
+= OMAP1610_GPIO_EDGE_CTRL1
;
348 l
= __raw_readl(reg
);
349 l
&= ~(3 << (gpio
<< 1));
350 l
|= edge
<< (gpio
<< 1);
351 __raw_writel(l
, reg
);
353 case METHOD_GPIO_730
:
354 reg
+= OMAP730_GPIO_INT_CONTROL
;
355 l
= __raw_readl(reg
);
356 if (edge
== OMAP_GPIO_RISING_EDGE
)
360 __raw_writel(l
, reg
);
368 void omap_set_gpio_edge_ctrl(int gpio
, int edge
)
370 struct gpio_bank
*bank
;
372 if (check_gpio(gpio
) < 0)
374 bank
= get_gpio_bank(gpio
);
375 spin_lock(&bank
->lock
);
376 _set_gpio_edge_ctrl(bank
, get_gpio_index(gpio
), edge
);
377 spin_unlock(&bank
->lock
);
381 static int _get_gpio_edge_ctrl(struct gpio_bank
*bank
, int gpio
)
383 u32 reg
= bank
->base
, l
;
385 switch (bank
->method
) {
387 l
= __raw_readl(reg
+ OMAP_MPUIO_GPIO_INT_EDGE
);
388 return (l
& (1 << gpio
)) ?
389 OMAP_GPIO_RISING_EDGE
: OMAP_GPIO_FALLING_EDGE
;
390 case METHOD_GPIO_1510
:
391 l
= __raw_readl(reg
+ OMAP1510_GPIO_INT_CONTROL
);
392 return (l
& (1 << gpio
)) ?
393 OMAP_GPIO_RISING_EDGE
: OMAP_GPIO_FALLING_EDGE
;
394 case METHOD_GPIO_1610
:
396 reg
+= OMAP1610_GPIO_EDGE_CTRL2
;
398 reg
+= OMAP1610_GPIO_EDGE_CTRL1
;
399 return (__raw_readl(reg
) >> ((gpio
& 0x07) << 1)) & 0x03;
400 case METHOD_GPIO_730
:
401 l
= __raw_readl(reg
+ OMAP730_GPIO_INT_CONTROL
);
402 return (l
& (1 << gpio
)) ?
403 OMAP_GPIO_RISING_EDGE
: OMAP_GPIO_FALLING_EDGE
;
410 static void _clear_gpio_irqstatus(struct gpio_bank
*bank
, int gpio
)
412 u32 reg
= bank
->base
;
414 switch (bank
->method
) {
416 /* MPUIO irqstatus cannot be cleared one bit at a time,
417 * so do nothing here */
419 case METHOD_GPIO_1510
:
420 reg
+= OMAP1510_GPIO_INT_STATUS
;
422 case METHOD_GPIO_1610
:
423 reg
+= OMAP1610_GPIO_IRQSTATUS1
;
425 case METHOD_GPIO_730
:
426 reg
+= OMAP730_GPIO_INT_STATUS
;
432 __raw_writel(1 << get_gpio_index(gpio
), reg
);
435 static void _set_gpio_irqenable(struct gpio_bank
*bank
, int gpio
, int enable
)
437 u32 reg
= bank
->base
;
440 switch (bank
->method
) {
442 reg
+= OMAP_MPUIO_GPIO_MASKIT
;
443 l
= __raw_readl(reg
);
449 case METHOD_GPIO_1510
:
450 reg
+= OMAP1510_GPIO_INT_MASK
;
451 l
= __raw_readl(reg
);
457 case METHOD_GPIO_1610
:
459 reg
+= OMAP1610_GPIO_SET_IRQENABLE1
;
460 _clear_gpio_irqstatus(bank
, gpio
);
462 reg
+= OMAP1610_GPIO_CLEAR_IRQENABLE1
;
465 case METHOD_GPIO_730
:
466 reg
+= OMAP730_GPIO_INT_MASK
;
467 l
= __raw_readl(reg
);
477 __raw_writel(l
, reg
);
480 int omap_request_gpio(int gpio
)
482 struct gpio_bank
*bank
;
484 if (check_gpio(gpio
) < 0)
487 bank
= get_gpio_bank(gpio
);
488 spin_lock(&bank
->lock
);
489 if (unlikely(bank
->reserved_map
& (1 << get_gpio_index(gpio
)))) {
490 printk(KERN_ERR
"omap-gpio: GPIO %d is already reserved!\n", gpio
);
492 spin_unlock(&bank
->lock
);
495 bank
->reserved_map
|= (1 << get_gpio_index(gpio
));
496 #ifdef CONFIG_ARCH_OMAP1510
497 if (bank
->method
== METHOD_GPIO_1510
) {
500 /* Claim the pin for the ARM */
501 reg
= bank
->base
+ OMAP1510_GPIO_PIN_CONTROL
;
502 __raw_writel(__raw_readl(reg
) | (1 << get_gpio_index(gpio
)), reg
);
505 spin_unlock(&bank
->lock
);
510 void omap_free_gpio(int gpio
)
512 struct gpio_bank
*bank
;
514 if (check_gpio(gpio
) < 0)
516 bank
= get_gpio_bank(gpio
);
517 spin_lock(&bank
->lock
);
518 if (unlikely(!(bank
->reserved_map
& (1 << get_gpio_index(gpio
))))) {
519 printk(KERN_ERR
"omap-gpio: GPIO %d wasn't reserved!\n", gpio
);
521 spin_unlock(&bank
->lock
);
524 bank
->reserved_map
&= ~(1 << get_gpio_index(gpio
));
525 _set_gpio_direction(bank
, get_gpio_index(gpio
), 1);
526 _set_gpio_irqenable(bank
, get_gpio_index(gpio
), 0);
527 spin_unlock(&bank
->lock
);
530 static void gpio_irq_handler(unsigned int irq
, struct irqdesc
*desc
,
531 struct pt_regs
*regs
)
534 struct gpio_bank
*bank
= (struct gpio_bank
*) desc
->data
;
537 * Acknowledge the parent IRQ.
539 desc
->chip
->ack(irq
);
541 /* Since the level 1 GPIO interrupt cascade (IRQ14) is configured as
542 * edge-sensitive, we need to unmask it here in order to avoid missing
543 * any additional GPIO interrupts that might occur after the last time
544 * we check for pending GPIO interrupts here.
545 * We are relying on the fact that this interrupt handler was installed
546 * with the SA_INTERRUPT flag so that interrupts are disabled at the
547 * CPU while it is executing.
549 desc
->chip
->unmask(irq
);
551 if (bank
->method
== METHOD_MPUIO
)
552 isr_reg
= bank
->base
+ OMAP_MPUIO_GPIO_INT
;
553 #ifdef CONFIG_ARCH_OMAP1510
554 if (bank
->method
== METHOD_GPIO_1510
)
555 isr_reg
= bank
->base
+ OMAP1510_GPIO_INT_STATUS
;
557 #if defined(CONFIG_ARCH_OMAP1610) || defined(CONFIG_ARCH_OMAP1710) || defined(CONFIG_ARCH_OMAP5912)
558 if (bank
->method
== METHOD_GPIO_1610
)
559 isr_reg
= bank
->base
+ OMAP1610_GPIO_IRQSTATUS1
;
561 #ifdef CONFIG_ARCH_OMAP730
562 if (bank
->method
== METHOD_GPIO_730
)
563 isr_reg
= bank
->base
+ OMAP730_GPIO_INT_STATUS
;
566 u32 isr
= __raw_readl(isr_reg
);
567 unsigned int gpio_irq
;
571 gpio_irq
= bank
->virtual_irq_start
;
573 for (; isr
!= 0; isr
>>= 1, gpio_irq
++) {
575 struct irqdesc
*d
= irq_desc
+ gpio_irq
;
576 d
->handle(gpio_irq
, d
, regs
);
582 static void gpio_ack_irq(unsigned int irq
)
584 unsigned int gpio
= irq
- IH_GPIO_BASE
;
585 struct gpio_bank
*bank
= get_gpio_bank(gpio
);
587 #ifdef CONFIG_ARCH_OMAP1510
588 if (bank
->method
== METHOD_GPIO_1510
)
589 __raw_writew(1 << (gpio
& 0x0f), bank
->base
+ OMAP1510_GPIO_INT_STATUS
);
591 #if defined(CONFIG_ARCH_OMAP1610) || defined(CONFIG_ARCH_OMAP1710) || defined(CONFIG_ARCH_OMAP5912)
592 if (bank
->method
== METHOD_GPIO_1610
)
593 __raw_writew(1 << (gpio
& 0x0f), bank
->base
+ OMAP1610_GPIO_IRQSTATUS1
);
595 #ifdef CONFIG_ARCH_OMAP730
596 if (bank
->method
== METHOD_GPIO_730
)
597 __raw_writel(1 << (gpio
& 0x1f), bank
->base
+ OMAP730_GPIO_INT_STATUS
);
601 static void gpio_mask_irq(unsigned int irq
)
603 unsigned int gpio
= irq
- IH_GPIO_BASE
;
604 struct gpio_bank
*bank
= get_gpio_bank(gpio
);
606 _set_gpio_irqenable(bank
, get_gpio_index(gpio
), 0);
609 static void gpio_unmask_irq(unsigned int irq
)
611 unsigned int gpio
= irq
- IH_GPIO_BASE
;
612 struct gpio_bank
*bank
= get_gpio_bank(gpio
);
614 if (_get_gpio_edge_ctrl(bank
, get_gpio_index(gpio
)) == OMAP_GPIO_NO_EDGE
) {
615 printk(KERN_ERR
"OMAP GPIO %d: trying to enable GPIO IRQ while no edge is set\n",
617 _set_gpio_edge_ctrl(bank
, get_gpio_index(gpio
), OMAP_GPIO_RISING_EDGE
);
619 _set_gpio_irqenable(bank
, get_gpio_index(gpio
), 1);
622 static void mpuio_ack_irq(unsigned int irq
)
624 /* The ISR is reset automatically, so do nothing here. */
627 static void mpuio_mask_irq(unsigned int irq
)
629 unsigned int gpio
= OMAP_MPUIO(irq
- IH_MPUIO_BASE
);
630 struct gpio_bank
*bank
= get_gpio_bank(gpio
);
632 _set_gpio_irqenable(bank
, get_gpio_index(gpio
), 0);
635 static void mpuio_unmask_irq(unsigned int irq
)
637 unsigned int gpio
= OMAP_MPUIO(irq
- IH_MPUIO_BASE
);
638 struct gpio_bank
*bank
= get_gpio_bank(gpio
);
640 _set_gpio_irqenable(bank
, get_gpio_index(gpio
), 1);
643 static struct irqchip gpio_irq_chip
= {
645 .mask
= gpio_mask_irq
,
646 .unmask
= gpio_unmask_irq
,
649 static struct irqchip mpuio_irq_chip
= {
650 .ack
= mpuio_ack_irq
,
651 .mask
= mpuio_mask_irq
,
652 .unmask
= mpuio_unmask_irq
655 static int initialized
= 0;
657 static int __init
_omap_gpio_init(void)
660 struct gpio_bank
*bank
;
664 #ifdef CONFIG_ARCH_OMAP1510
665 if (cpu_is_omap1510()) {
666 printk(KERN_INFO
"OMAP1510 GPIO hardware\n");
668 gpio_bank
= gpio_bank_1510
;
671 #if defined(CONFIG_ARCH_OMAP1610) || defined(CONFIG_ARCH_OMAP1710) || defined(CONFIG_ARCH_OMAP5912)
672 if (cpu_is_omap1610() || cpu_is_omap1710() || cpu_is_omap5912()) {
676 gpio_bank
= gpio_bank_1610
;
677 rev
= omap_readw(gpio_bank
[1].base
+ OMAP1610_GPIO_REVISION
);
678 printk(KERN_INFO
"OMAP GPIO hardware version %d.%d\n",
679 (rev
>> 4) & 0x0f, rev
& 0x0f);
682 #ifdef CONFIG_ARCH_OMAP730
683 if (cpu_is_omap730()) {
684 printk(KERN_INFO
"OMAP730 GPIO hardware\n");
686 gpio_bank
= gpio_bank_730
;
689 for (i
= 0; i
< gpio_bank_count
; i
++) {
690 int j
, gpio_count
= 16;
692 bank
= &gpio_bank
[i
];
693 bank
->reserved_map
= 0;
694 bank
->base
= IO_ADDRESS(bank
->base
);
695 spin_lock_init(&bank
->lock
);
696 if (bank
->method
== METHOD_MPUIO
) {
697 omap_writew(0xFFFF, OMAP_MPUIO_BASE
+ OMAP_MPUIO_GPIO_MASKIT
);
699 #ifdef CONFIG_ARCH_OMAP1510
700 if (bank
->method
== METHOD_GPIO_1510
) {
701 __raw_writew(0xffff, bank
->base
+ OMAP1510_GPIO_INT_MASK
);
702 __raw_writew(0x0000, bank
->base
+ OMAP1510_GPIO_INT_STATUS
);
705 #if defined(CONFIG_ARCH_OMAP1610) || defined(CONFIG_ARCH_OMAP1710) || defined(CONFIG_ARCH_OMAP5912)
706 if (bank
->method
== METHOD_GPIO_1610
) {
707 __raw_writew(0x0000, bank
->base
+ OMAP1610_GPIO_IRQENABLE1
);
708 __raw_writew(0xffff, bank
->base
+ OMAP1610_GPIO_IRQSTATUS1
);
711 #ifdef CONFIG_ARCH_OMAP730
712 if (bank
->method
== METHOD_GPIO_730
) {
713 __raw_writel(0xffffffff, bank
->base
+ OMAP730_GPIO_INT_MASK
);
714 __raw_writel(0x00000000, bank
->base
+ OMAP730_GPIO_INT_STATUS
);
716 gpio_count
= 32; /* 730 has 32-bit GPIOs */
719 for (j
= bank
->virtual_irq_start
;
720 j
< bank
->virtual_irq_start
+ gpio_count
; j
++) {
721 if (bank
->method
== METHOD_MPUIO
)
722 set_irq_chip(j
, &mpuio_irq_chip
);
724 set_irq_chip(j
, &gpio_irq_chip
);
725 set_irq_handler(j
, do_level_IRQ
);
726 set_irq_flags(j
, IRQF_VALID
);
728 set_irq_chained_handler(bank
->irq
, gpio_irq_handler
);
729 set_irq_data(bank
->irq
, bank
);
732 /* Enable system clock for GPIO module.
733 * The CAM_CLK_CTRL *is* really the right place. */
734 if (cpu_is_omap1610() || cpu_is_omap1710())
735 omap_writel(omap_readl(ULPD_CAM_CLK_CTRL
) | 0x04, ULPD_CAM_CLK_CTRL
);
741 * This may get called early from board specific init
743 int omap_gpio_init(void)
746 return _omap_gpio_init();
751 EXPORT_SYMBOL(omap_request_gpio
);
752 EXPORT_SYMBOL(omap_free_gpio
);
753 EXPORT_SYMBOL(omap_set_gpio_direction
);
754 EXPORT_SYMBOL(omap_set_gpio_dataout
);
755 EXPORT_SYMBOL(omap_get_gpio_datain
);
756 EXPORT_SYMBOL(omap_set_gpio_edge_ctrl
);
758 arch_initcall(omap_gpio_init
);