blob: 991dd39f6edaca62e2531ef735b6c1996be21e34 [file] [log] [blame]
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +01001/*
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +01002 * Support functions for OMAP GPIO
3 *
Tony Lindgren92105bb2005-09-07 17:20:26 +01004 * Copyright (C) 2003-2005 Nokia Corporation
Jan Engelhardt96de0e22007-10-19 23:21:04 +02005 * Written by Juha Yrjölä <juha.yrjola@nokia.com>
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +01006 *
Santosh Shilimkar44169072009-05-28 14:16:04 -07007 * Copyright (C) 2009 Texas Instruments
8 * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
9 *
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010010 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010015#include <linux/init.h>
16#include <linux/module.h>
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010017#include <linux/interrupt.h>
Rafael J. Wysocki3c437ff2011-04-22 22:02:46 +020018#include <linux/syscore_ops.h>
Tony Lindgren92105bb2005-09-07 17:20:26 +010019#include <linux/err.h>
Russell Kingf8ce2542006-01-07 16:15:52 +000020#include <linux/clk.h>
Russell Kingfced80c2008-09-06 12:10:45 +010021#include <linux/io.h>
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -080022#include <linux/slab.h>
23#include <linux/pm_runtime.h>
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010024
Russell Kinga09e64f2008-08-05 16:14:15 +010025#include <mach/hardware.h>
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010026#include <asm/irq.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010027#include <mach/irqs.h>
Russell King1bc857f2011-07-26 10:54:55 +010028#include <asm/gpio.h>
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010029#include <asm/mach/irq.h>
30
Charulatha V03e128c2011-05-05 19:58:01 +053031static LIST_HEAD(omap_gpio_list);
32
Charulatha V6d62e212011-04-18 15:06:51 +000033struct gpio_regs {
34 u32 irqenable1;
35 u32 irqenable2;
36 u32 wake_en;
37 u32 ctrl;
38 u32 oe;
39 u32 leveldetect0;
40 u32 leveldetect1;
41 u32 risingdetect;
42 u32 fallingdetect;
43 u32 dataout;
44};
45
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010046struct gpio_bank {
Charulatha V03e128c2011-05-05 19:58:01 +053047 struct list_head node;
Tony Lindgren9f7065d2009-10-19 15:25:20 -070048 unsigned long pbase;
Tony Lindgren92105bb2005-09-07 17:20:26 +010049 void __iomem *base;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010050 u16 irq;
51 u16 virtual_irq_start;
Tony Lindgren92105bb2005-09-07 17:20:26 +010052 int method;
Tony Lindgren92105bb2005-09-07 17:20:26 +010053 u32 suspend_wakeup;
54 u32 saved_wakeup;
Juha Yrjola3ac4fa92006-12-06 17:13:52 -080055 u32 non_wakeup_gpios;
56 u32 enabled_non_wakeup_gpios;
Charulatha V6d62e212011-04-18 15:06:51 +000057 struct gpio_regs context;
Juha Yrjola3ac4fa92006-12-06 17:13:52 -080058 u32 saved_datain;
59 u32 saved_fallingdetect;
60 u32 saved_risingdetect;
Kevin Hilmanb144ff62008-01-16 21:56:15 -080061 u32 level_mask;
Cory Maccarrone4318f362010-01-08 10:29:04 -080062 u32 toggle_mask;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010063 spinlock_t lock;
David Brownell52e31342008-03-03 12:43:23 -080064 struct gpio_chip chip;
Jouni Hogander89db9482008-12-10 17:35:24 -080065 struct clk *dbck;
Charulatha V058af1e2009-11-22 10:11:25 -080066 u32 mod_usage;
Kevin Hilman8865b9b2009-01-27 11:15:34 -080067 u32 dbck_enable_mask;
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -080068 struct device *dev;
69 bool dbck_flag;
Charulatha V0cde8d02011-05-05 20:15:16 +053070 bool loses_context;
Tony Lindgren5de62b82010-12-07 16:26:58 -080071 int stride;
Kevin Hilmand5f46242011-04-21 09:23:00 -070072 u32 width;
Tarun Kanti DebBarma60a34372011-09-29 04:47:25 +053073 int context_loss_count;
Charulatha V03e128c2011-05-05 19:58:01 +053074 u16 id;
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070075
76 void (*set_dataout)(struct gpio_bank *bank, int gpio, int enable);
Tarun Kanti DebBarma60a34372011-09-29 04:47:25 +053077 int (*get_context_loss_count)(struct device *dev);
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070078
79 struct omap_gpio_reg_offs *regs;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010080};
81
Kevin Hilman129fd222011-04-22 07:59:07 -070082#define GPIO_INDEX(bank, gpio) (gpio % bank->width)
83#define GPIO_BIT(bank, gpio) (1 << GPIO_INDEX(bank, gpio))
Charulatha Vc8eef652011-05-02 15:21:42 +053084#define GPIO_MOD_CTRL_BIT BIT(0)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010085
86static void _set_gpio_direction(struct gpio_bank *bank, int gpio, int is_input)
87{
Tony Lindgren92105bb2005-09-07 17:20:26 +010088 void __iomem *reg = bank->base;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010089 u32 l;
90
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070091 reg += bank->regs->direction;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010092 l = __raw_readl(reg);
93 if (is_input)
94 l |= 1 << gpio;
95 else
96 l &= ~(1 << gpio);
97 __raw_writel(l, reg);
98}
99
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700100
101/* set data out value using dedicate set/clear register */
102static void _set_gpio_dataout_reg(struct gpio_bank *bank, int gpio, int enable)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100103{
Tony Lindgren92105bb2005-09-07 17:20:26 +0100104 void __iomem *reg = bank->base;
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700105 u32 l = GPIO_BIT(bank, gpio);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100106
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700107 if (enable)
108 reg += bank->regs->set_dataout;
109 else
110 reg += bank->regs->clr_dataout;
111
112 __raw_writel(l, reg);
113}
114
115/* set data out value using mask register */
116static void _set_gpio_dataout_mask(struct gpio_bank *bank, int gpio, int enable)
117{
118 void __iomem *reg = bank->base + bank->regs->dataout;
119 u32 gpio_bit = GPIO_BIT(bank, gpio);
120 u32 l;
121
122 l = __raw_readl(reg);
123 if (enable)
124 l |= gpio_bit;
125 else
126 l &= ~gpio_bit;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100127 __raw_writel(l, reg);
128}
129
Roger Quadrosb37c45b2009-08-05 16:53:24 +0300130static int _get_gpio_datain(struct gpio_bank *bank, int gpio)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100131{
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700132 void __iomem *reg = bank->base + bank->regs->datain;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100133
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700134 return (__raw_readl(reg) & GPIO_BIT(bank, gpio)) != 0;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100135}
136
Roger Quadrosb37c45b2009-08-05 16:53:24 +0300137static int _get_gpio_dataout(struct gpio_bank *bank, int gpio)
138{
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700139 void __iomem *reg = bank->base + bank->regs->dataout;
Roger Quadrosb37c45b2009-08-05 16:53:24 +0300140
Kevin Hilman129fd222011-04-22 07:59:07 -0700141 return (__raw_readl(reg) & GPIO_BIT(bank, gpio)) != 0;
Roger Quadrosb37c45b2009-08-05 16:53:24 +0300142}
143
Kevin Hilmanece95282011-07-12 08:18:15 -0700144static inline void _gpio_rmw(void __iomem *base, u32 reg, u32 mask, bool set)
145{
146 int l = __raw_readl(base + reg);
147
148 if (set)
149 l |= mask;
150 else
151 l &= ~mask;
152
153 __raw_writel(l, base + reg);
154}
Tony Lindgren92105bb2005-09-07 17:20:26 +0100155
Felipe Balbi168ef3d2010-05-26 14:42:23 -0700156/**
157 * _set_gpio_debounce - low level gpio debounce time
158 * @bank: the gpio bank we're acting upon
159 * @gpio: the gpio number on this @gpio
160 * @debounce: debounce time to use
161 *
162 * OMAP's debounce time is in 31us steps so we need
163 * to convert and round up to the closest unit.
164 */
165static void _set_gpio_debounce(struct gpio_bank *bank, unsigned gpio,
166 unsigned debounce)
167{
Kevin Hilman9942da02011-04-22 12:02:05 -0700168 void __iomem *reg;
Felipe Balbi168ef3d2010-05-26 14:42:23 -0700169 u32 val;
170 u32 l;
171
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -0800172 if (!bank->dbck_flag)
173 return;
174
Felipe Balbi168ef3d2010-05-26 14:42:23 -0700175 if (debounce < 32)
176 debounce = 0x01;
177 else if (debounce > 7936)
178 debounce = 0xff;
179 else
180 debounce = (debounce / 0x1f) - 1;
181
Kevin Hilman129fd222011-04-22 07:59:07 -0700182 l = GPIO_BIT(bank, gpio);
Felipe Balbi168ef3d2010-05-26 14:42:23 -0700183
Kevin Hilman9942da02011-04-22 12:02:05 -0700184 reg = bank->base + bank->regs->debounce;
Felipe Balbi168ef3d2010-05-26 14:42:23 -0700185 __raw_writel(debounce, reg);
186
Kevin Hilman9942da02011-04-22 12:02:05 -0700187 reg = bank->base + bank->regs->debounce_en;
Felipe Balbi168ef3d2010-05-26 14:42:23 -0700188 val = __raw_readl(reg);
189
190 if (debounce) {
191 val |= l;
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -0800192 clk_enable(bank->dbck);
Felipe Balbi168ef3d2010-05-26 14:42:23 -0700193 } else {
194 val &= ~l;
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -0800195 clk_disable(bank->dbck);
Felipe Balbi168ef3d2010-05-26 14:42:23 -0700196 }
Kevin Hilmanf7ec0b02010-06-09 13:53:07 +0300197 bank->dbck_enable_mask = val;
Felipe Balbi168ef3d2010-05-26 14:42:23 -0700198
199 __raw_writel(val, reg);
200}
201
Tony Lindgren140455f2010-02-12 12:26:48 -0800202#ifdef CONFIG_ARCH_OMAP2PLUS
Kevin Hilman5eb3bb92007-05-05 11:40:29 -0700203static inline void set_24xx_gpio_triggering(struct gpio_bank *bank, int gpio,
204 int trigger)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100205{
Juha Yrjola3ac4fa92006-12-06 17:13:52 -0800206 void __iomem *base = bank->base;
Tony Lindgren92105bb2005-09-07 17:20:26 +0100207 u32 gpio_bit = 1 << gpio;
208
Syed Rafiuddin78a1a6d2009-07-28 18:57:30 +0530209 if (cpu_is_omap44xx()) {
Kevin Hilmanece95282011-07-12 08:18:15 -0700210 _gpio_rmw(base, OMAP4_GPIO_LEVELDETECT0, gpio_bit,
211 trigger & IRQ_TYPE_LEVEL_LOW);
212 _gpio_rmw(base, OMAP4_GPIO_LEVELDETECT1, gpio_bit,
213 trigger & IRQ_TYPE_LEVEL_HIGH);
214 _gpio_rmw(base, OMAP4_GPIO_RISINGDETECT, gpio_bit,
215 trigger & IRQ_TYPE_EDGE_RISING);
216 _gpio_rmw(base, OMAP4_GPIO_FALLINGDETECT, gpio_bit,
217 trigger & IRQ_TYPE_EDGE_FALLING);
Syed Rafiuddin78a1a6d2009-07-28 18:57:30 +0530218 } else {
Kevin Hilmanece95282011-07-12 08:18:15 -0700219 _gpio_rmw(base, OMAP24XX_GPIO_LEVELDETECT0, gpio_bit,
220 trigger & IRQ_TYPE_LEVEL_LOW);
221 _gpio_rmw(base, OMAP24XX_GPIO_LEVELDETECT1, gpio_bit,
222 trigger & IRQ_TYPE_LEVEL_HIGH);
223 _gpio_rmw(base, OMAP24XX_GPIO_RISINGDETECT, gpio_bit,
224 trigger & IRQ_TYPE_EDGE_RISING);
225 _gpio_rmw(base, OMAP24XX_GPIO_FALLINGDETECT, gpio_bit,
226 trigger & IRQ_TYPE_EDGE_FALLING);
Syed Rafiuddin78a1a6d2009-07-28 18:57:30 +0530227 }
Juha Yrjola3ac4fa92006-12-06 17:13:52 -0800228 if (likely(!(bank->non_wakeup_gpios & gpio_bit))) {
Syed Rafiuddin78a1a6d2009-07-28 18:57:30 +0530229 if (cpu_is_omap44xx()) {
Kevin Hilmanece95282011-07-12 08:18:15 -0700230 _gpio_rmw(base, OMAP4_GPIO_IRQWAKEN0, gpio_bit,
231 trigger != 0);
Syed Rafiuddin78a1a6d2009-07-28 18:57:30 +0530232 } else {
Chunqiu Wang699117a62009-06-24 17:13:39 +0000233 /*
234 * GPIO wakeup request can only be generated on edge
235 * transitions
236 */
237 if (trigger & IRQ_TYPE_EDGE_BOTH)
Syed Rafiuddin78a1a6d2009-07-28 18:57:30 +0530238 __raw_writel(1 << gpio, bank->base
Kevin Hilman5eb3bb92007-05-05 11:40:29 -0700239 + OMAP24XX_GPIO_SETWKUENA);
Syed Rafiuddin78a1a6d2009-07-28 18:57:30 +0530240 else
241 __raw_writel(1 << gpio, bank->base
Kevin Hilman5eb3bb92007-05-05 11:40:29 -0700242 + OMAP24XX_GPIO_CLEARWKUENA);
Syed Rafiuddin78a1a6d2009-07-28 18:57:30 +0530243 }
Tero Kristoa118b5f2008-12-22 14:27:12 +0200244 }
Ambresh K55b220c2011-06-15 13:40:45 -0700245 /* This part needs to be executed always for OMAP{34xx, 44xx} */
246 if (cpu_is_omap34xx() || cpu_is_omap44xx() ||
247 (bank->non_wakeup_gpios & gpio_bit)) {
Chunqiu Wang699117a62009-06-24 17:13:39 +0000248 /*
249 * Log the edge gpio and manually trigger the IRQ
250 * after resume if the input level changes
251 * to avoid irq lost during PER RET/OFF mode
252 * Applies for omap2 non-wakeup gpio and all omap3 gpios
253 */
254 if (trigger & IRQ_TYPE_EDGE_BOTH)
Juha Yrjola3ac4fa92006-12-06 17:13:52 -0800255 bank->enabled_non_wakeup_gpios |= gpio_bit;
256 else
257 bank->enabled_non_wakeup_gpios &= ~gpio_bit;
258 }
Kevin Hilman5eb3bb92007-05-05 11:40:29 -0700259
Tarun Kanti DebBarma9ea14d82011-08-30 15:05:44 +0530260 bank->level_mask =
261 __raw_readl(bank->base + bank->regs->leveldetect0) |
262 __raw_readl(bank->base + bank->regs->leveldetect1);
Tony Lindgren92105bb2005-09-07 17:20:26 +0100263}
Juha Yrjola3ac4fa92006-12-06 17:13:52 -0800264#endif
Tony Lindgren92105bb2005-09-07 17:20:26 +0100265
Uwe Kleine-König9198bcd2010-01-29 14:20:05 -0800266#ifdef CONFIG_ARCH_OMAP1
Cory Maccarrone4318f362010-01-08 10:29:04 -0800267/*
268 * This only applies to chips that can't do both rising and falling edge
269 * detection at once. For all other chips, this function is a noop.
270 */
271static void _toggle_gpio_edge_triggering(struct gpio_bank *bank, int gpio)
272{
273 void __iomem *reg = bank->base;
274 u32 l = 0;
275
276 switch (bank->method) {
Cory Maccarrone4318f362010-01-08 10:29:04 -0800277 case METHOD_MPUIO:
Tony Lindgren5de62b82010-12-07 16:26:58 -0800278 reg += OMAP_MPUIO_GPIO_INT_EDGE / bank->stride;
Cory Maccarrone4318f362010-01-08 10:29:04 -0800279 break;
Cory Maccarrone4318f362010-01-08 10:29:04 -0800280#ifdef CONFIG_ARCH_OMAP15XX
281 case METHOD_GPIO_1510:
282 reg += OMAP1510_GPIO_INT_CONTROL;
283 break;
284#endif
285#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
286 case METHOD_GPIO_7XX:
287 reg += OMAP7XX_GPIO_INT_CONTROL;
288 break;
289#endif
290 default:
291 return;
292 }
293
294 l = __raw_readl(reg);
295 if ((l >> gpio) & 1)
296 l &= ~(1 << gpio);
297 else
298 l |= 1 << gpio;
299
300 __raw_writel(l, reg);
301}
Uwe Kleine-König9198bcd2010-01-29 14:20:05 -0800302#endif
Cory Maccarrone4318f362010-01-08 10:29:04 -0800303
Tony Lindgren92105bb2005-09-07 17:20:26 +0100304static int _set_gpio_triggering(struct gpio_bank *bank, int gpio, int trigger)
305{
306 void __iomem *reg = bank->base;
307 u32 l = 0;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100308
309 switch (bank->method) {
David Brownelle5c56ed2006-12-06 17:13:59 -0800310#ifdef CONFIG_ARCH_OMAP1
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100311 case METHOD_MPUIO:
Tony Lindgren5de62b82010-12-07 16:26:58 -0800312 reg += OMAP_MPUIO_GPIO_INT_EDGE / bank->stride;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100313 l = __raw_readl(reg);
Janusz Krzysztofik29501572010-04-05 11:38:06 +0000314 if ((trigger & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH)
Cory Maccarrone4318f362010-01-08 10:29:04 -0800315 bank->toggle_mask |= 1 << gpio;
Dmitry Baryshkov6cab4862008-07-27 04:23:31 +0100316 if (trigger & IRQ_TYPE_EDGE_RISING)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100317 l |= 1 << gpio;
Dmitry Baryshkov6cab4862008-07-27 04:23:31 +0100318 else if (trigger & IRQ_TYPE_EDGE_FALLING)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100319 l &= ~(1 << gpio);
Tony Lindgren92105bb2005-09-07 17:20:26 +0100320 else
321 goto bad;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100322 break;
David Brownelle5c56ed2006-12-06 17:13:59 -0800323#endif
324#ifdef CONFIG_ARCH_OMAP15XX
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100325 case METHOD_GPIO_1510:
326 reg += OMAP1510_GPIO_INT_CONTROL;
327 l = __raw_readl(reg);
Janusz Krzysztofik29501572010-04-05 11:38:06 +0000328 if ((trigger & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH)
Cory Maccarrone4318f362010-01-08 10:29:04 -0800329 bank->toggle_mask |= 1 << gpio;
Dmitry Baryshkov6cab4862008-07-27 04:23:31 +0100330 if (trigger & IRQ_TYPE_EDGE_RISING)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100331 l |= 1 << gpio;
Dmitry Baryshkov6cab4862008-07-27 04:23:31 +0100332 else if (trigger & IRQ_TYPE_EDGE_FALLING)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100333 l &= ~(1 << gpio);
Tony Lindgren92105bb2005-09-07 17:20:26 +0100334 else
335 goto bad;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100336 break;
David Brownelle5c56ed2006-12-06 17:13:59 -0800337#endif
Juha Yrjola3ac4fa92006-12-06 17:13:52 -0800338#ifdef CONFIG_ARCH_OMAP16XX
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100339 case METHOD_GPIO_1610:
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100340 if (gpio & 0x08)
341 reg += OMAP1610_GPIO_EDGE_CTRL2;
342 else
343 reg += OMAP1610_GPIO_EDGE_CTRL1;
344 gpio &= 0x07;
345 l = __raw_readl(reg);
346 l &= ~(3 << (gpio << 1));
Dmitry Baryshkov6cab4862008-07-27 04:23:31 +0100347 if (trigger & IRQ_TYPE_EDGE_RISING)
Tony Lindgren6e60e792006-04-02 17:46:23 +0100348 l |= 2 << (gpio << 1);
Dmitry Baryshkov6cab4862008-07-27 04:23:31 +0100349 if (trigger & IRQ_TYPE_EDGE_FALLING)
Tony Lindgren6e60e792006-04-02 17:46:23 +0100350 l |= 1 << (gpio << 1);
Juha Yrjola3ac4fa92006-12-06 17:13:52 -0800351 if (trigger)
352 /* Enable wake-up during idle for dynamic tick */
353 __raw_writel(1 << gpio, bank->base + OMAP1610_GPIO_SET_WAKEUPENA);
354 else
355 __raw_writel(1 << gpio, bank->base + OMAP1610_GPIO_CLEAR_WAKEUPENA);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100356 break;
Juha Yrjola3ac4fa92006-12-06 17:13:52 -0800357#endif
Alistair Buxtonb718aa82009-09-23 18:56:19 +0100358#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
Alistair Buxton7c006922009-09-22 10:02:58 +0100359 case METHOD_GPIO_7XX:
360 reg += OMAP7XX_GPIO_INT_CONTROL;
Zebediah C. McClure56739a62009-03-23 18:07:40 -0700361 l = __raw_readl(reg);
Janusz Krzysztofik29501572010-04-05 11:38:06 +0000362 if ((trigger & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH)
Cory Maccarrone4318f362010-01-08 10:29:04 -0800363 bank->toggle_mask |= 1 << gpio;
Zebediah C. McClure56739a62009-03-23 18:07:40 -0700364 if (trigger & IRQ_TYPE_EDGE_RISING)
365 l |= 1 << gpio;
366 else if (trigger & IRQ_TYPE_EDGE_FALLING)
367 l &= ~(1 << gpio);
368 else
369 goto bad;
370 break;
371#endif
Tony Lindgren140455f2010-02-12 12:26:48 -0800372#ifdef CONFIG_ARCH_OMAP2PLUS
Tony Lindgren92105bb2005-09-07 17:20:26 +0100373 case METHOD_GPIO_24XX:
Tony Lindgren3f1686a92010-02-15 09:27:25 -0800374 case METHOD_GPIO_44XX:
Juha Yrjola3ac4fa92006-12-06 17:13:52 -0800375 set_24xx_gpio_triggering(bank, gpio, trigger);
Mika Westerbergf7c5cc42010-12-29 13:01:31 +0200376 return 0;
Juha Yrjola3ac4fa92006-12-06 17:13:52 -0800377#endif
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100378 default:
Tony Lindgren92105bb2005-09-07 17:20:26 +0100379 goto bad;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100380 }
Tony Lindgren92105bb2005-09-07 17:20:26 +0100381 __raw_writel(l, reg);
382 return 0;
383bad:
384 return -EINVAL;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100385}
386
Lennert Buytenheke9191022010-11-29 11:17:17 +0100387static int gpio_irq_type(struct irq_data *d, unsigned type)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100388{
389 struct gpio_bank *bank;
Tony Lindgren92105bb2005-09-07 17:20:26 +0100390 unsigned gpio;
391 int retval;
David Brownella6472532008-03-03 04:33:30 -0800392 unsigned long flags;
Tony Lindgren92105bb2005-09-07 17:20:26 +0100393
Lennert Buytenheke9191022010-11-29 11:17:17 +0100394 if (!cpu_class_is_omap2() && d->irq > IH_MPUIO_BASE)
395 gpio = OMAP_MPUIO(d->irq - IH_MPUIO_BASE);
Tony Lindgren92105bb2005-09-07 17:20:26 +0100396 else
Lennert Buytenheke9191022010-11-29 11:17:17 +0100397 gpio = d->irq - IH_GPIO_BASE;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100398
David Brownelle5c56ed2006-12-06 17:13:59 -0800399 if (type & ~IRQ_TYPE_SENSE_MASK)
Tony Lindgren6e60e792006-04-02 17:46:23 +0100400 return -EINVAL;
David Brownelle5c56ed2006-12-06 17:13:59 -0800401
Tarun Kanti DebBarma9ea14d82011-08-30 15:05:44 +0530402 bank = irq_data_get_irq_chip_data(d);
403
404 if (!bank->regs->leveldetect0 &&
405 (type & (IRQ_TYPE_LEVEL_LOW|IRQ_TYPE_LEVEL_HIGH)))
Tony Lindgren92105bb2005-09-07 17:20:26 +0100406 return -EINVAL;
407
David Brownella6472532008-03-03 04:33:30 -0800408 spin_lock_irqsave(&bank->lock, flags);
Kevin Hilman129fd222011-04-22 07:59:07 -0700409 retval = _set_gpio_triggering(bank, GPIO_INDEX(bank, gpio), type);
David Brownella6472532008-03-03 04:33:30 -0800410 spin_unlock_irqrestore(&bank->lock, flags);
Kevin Hilman672e3022008-01-16 21:56:16 -0800411
412 if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH))
Thomas Gleixner6845664a2011-03-24 13:25:22 +0100413 __irq_set_handler_locked(d->irq, handle_level_irq);
Kevin Hilman672e3022008-01-16 21:56:16 -0800414 else if (type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING))
Thomas Gleixner6845664a2011-03-24 13:25:22 +0100415 __irq_set_handler_locked(d->irq, handle_edge_irq);
Kevin Hilman672e3022008-01-16 21:56:16 -0800416
Tony Lindgren92105bb2005-09-07 17:20:26 +0100417 return retval;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100418}
419
420static void _clear_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
421{
Tony Lindgren92105bb2005-09-07 17:20:26 +0100422 void __iomem *reg = bank->base;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100423
Kevin Hilmaneef4bec2011-04-21 09:17:35 -0700424 reg += bank->regs->irqstatus;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100425 __raw_writel(gpio_mask, reg);
Hiroshi DOYUbee79302006-09-25 12:41:46 +0300426
427 /* Workaround for clearing DSP GPIO interrupts to allow retention */
Kevin Hilmaneef4bec2011-04-21 09:17:35 -0700428 if (bank->regs->irqstatus2) {
429 reg = bank->base + bank->regs->irqstatus2;
Roger Quadrosbedfd152009-04-23 11:10:50 -0700430 __raw_writel(gpio_mask, reg);
Kevin Hilmaneef4bec2011-04-21 09:17:35 -0700431 }
Roger Quadrosbedfd152009-04-23 11:10:50 -0700432
433 /* Flush posted write for the irq status to avoid spurious interrupts */
434 __raw_readl(reg);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100435}
436
437static inline void _clear_gpio_irqstatus(struct gpio_bank *bank, int gpio)
438{
Kevin Hilman129fd222011-04-22 07:59:07 -0700439 _clear_gpio_irqbank(bank, GPIO_BIT(bank, gpio));
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100440}
441
Imre Deakea6dedd2006-06-26 16:16:00 -0700442static u32 _get_gpio_irqbank_mask(struct gpio_bank *bank)
443{
444 void __iomem *reg = bank->base;
Imre Deak99c47702006-06-26 16:16:07 -0700445 u32 l;
Kevin Hilmanc390aad02011-04-21 09:33:36 -0700446 u32 mask = (1 << bank->width) - 1;
Imre Deakea6dedd2006-06-26 16:16:00 -0700447
Kevin Hilman28f3b5a2011-04-21 09:53:06 -0700448 reg += bank->regs->irqenable;
Imre Deak99c47702006-06-26 16:16:07 -0700449 l = __raw_readl(reg);
Kevin Hilman28f3b5a2011-04-21 09:53:06 -0700450 if (bank->regs->irqenable_inv)
Imre Deak99c47702006-06-26 16:16:07 -0700451 l = ~l;
452 l &= mask;
453 return l;
Imre Deakea6dedd2006-06-26 16:16:00 -0700454}
455
Kevin Hilman28f3b5a2011-04-21 09:53:06 -0700456static void _enable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100457{
Tony Lindgren92105bb2005-09-07 17:20:26 +0100458 void __iomem *reg = bank->base;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100459 u32 l;
460
Kevin Hilman28f3b5a2011-04-21 09:53:06 -0700461 if (bank->regs->set_irqenable) {
462 reg += bank->regs->set_irqenable;
463 l = gpio_mask;
464 } else {
465 reg += bank->regs->irqenable;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100466 l = __raw_readl(reg);
Kevin Hilman28f3b5a2011-04-21 09:53:06 -0700467 if (bank->regs->irqenable_inv)
468 l &= ~gpio_mask;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100469 else
470 l |= gpio_mask;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100471 }
Kevin Hilman28f3b5a2011-04-21 09:53:06 -0700472
473 __raw_writel(l, reg);
474}
475
476static void _disable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
477{
478 void __iomem *reg = bank->base;
479 u32 l;
480
481 if (bank->regs->clr_irqenable) {
482 reg += bank->regs->clr_irqenable;
483 l = gpio_mask;
484 } else {
485 reg += bank->regs->irqenable;
486 l = __raw_readl(reg);
487 if (bank->regs->irqenable_inv)
488 l |= gpio_mask;
489 else
490 l &= ~gpio_mask;
491 }
492
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100493 __raw_writel(l, reg);
494}
495
496static inline void _set_gpio_irqenable(struct gpio_bank *bank, int gpio, int enable)
497{
Kevin Hilman28f3b5a2011-04-21 09:53:06 -0700498 _enable_gpio_irqbank(bank, GPIO_BIT(bank, gpio));
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100499}
500
Tony Lindgren92105bb2005-09-07 17:20:26 +0100501/*
502 * Note that ENAWAKEUP needs to be enabled in GPIO_SYSCONFIG register.
503 * 1510 does not seem to have a wake-up register. If JTAG is connected
504 * to the target, system will wake up always on GPIO events. While
505 * system is running all registered GPIO interrupts need to have wake-up
506 * enabled. When system is suspended, only selected GPIO interrupts need
507 * to have wake-up enabled.
508 */
509static int _set_gpio_wakeup(struct gpio_bank *bank, int gpio, int enable)
510{
Kevin Hilmanf64ad1a2011-04-22 09:45:27 -0700511 u32 gpio_bit = GPIO_BIT(bank, gpio);
512 unsigned long flags;
David Brownella6472532008-03-03 04:33:30 -0800513
Kevin Hilmanf64ad1a2011-04-22 09:45:27 -0700514 if (bank->non_wakeup_gpios & gpio_bit) {
515 dev_err(bank->dev,
516 "Unable to modify wakeup on non-wakeup GPIO%d\n", gpio);
Tony Lindgren92105bb2005-09-07 17:20:26 +0100517 return -EINVAL;
518 }
Kevin Hilmanf64ad1a2011-04-22 09:45:27 -0700519
520 spin_lock_irqsave(&bank->lock, flags);
521 if (enable)
522 bank->suspend_wakeup |= gpio_bit;
523 else
524 bank->suspend_wakeup &= ~gpio_bit;
525
526 spin_unlock_irqrestore(&bank->lock, flags);
527
528 return 0;
Tony Lindgren92105bb2005-09-07 17:20:26 +0100529}
530
Tony Lindgren4196dd62006-09-25 12:41:38 +0300531static void _reset_gpio(struct gpio_bank *bank, int gpio)
532{
Kevin Hilman129fd222011-04-22 07:59:07 -0700533 _set_gpio_direction(bank, GPIO_INDEX(bank, gpio), 1);
Tony Lindgren4196dd62006-09-25 12:41:38 +0300534 _set_gpio_irqenable(bank, gpio, 0);
535 _clear_gpio_irqstatus(bank, gpio);
Kevin Hilman129fd222011-04-22 07:59:07 -0700536 _set_gpio_triggering(bank, GPIO_INDEX(bank, gpio), IRQ_TYPE_NONE);
Tony Lindgren4196dd62006-09-25 12:41:38 +0300537}
538
Tony Lindgren92105bb2005-09-07 17:20:26 +0100539/* Use disable_irq_wake() and enable_irq_wake() functions from drivers */
Lennert Buytenheke9191022010-11-29 11:17:17 +0100540static int gpio_wake_enable(struct irq_data *d, unsigned int enable)
Tony Lindgren92105bb2005-09-07 17:20:26 +0100541{
Lennert Buytenheke9191022010-11-29 11:17:17 +0100542 unsigned int gpio = d->irq - IH_GPIO_BASE;
Tony Lindgren92105bb2005-09-07 17:20:26 +0100543 struct gpio_bank *bank;
544 int retval;
545
Lennert Buytenheke9191022010-11-29 11:17:17 +0100546 bank = irq_data_get_irq_chip_data(d);
Kevin Hilmanf64ad1a2011-04-22 09:45:27 -0700547 retval = _set_gpio_wakeup(bank, gpio, enable);
Tony Lindgren92105bb2005-09-07 17:20:26 +0100548
549 return retval;
550}
551
Jarkko Nikula3ff164e2008-12-10 17:35:27 -0800552static int omap_gpio_request(struct gpio_chip *chip, unsigned offset)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100553{
Jarkko Nikula3ff164e2008-12-10 17:35:27 -0800554 struct gpio_bank *bank = container_of(chip, struct gpio_bank, chip);
David Brownella6472532008-03-03 04:33:30 -0800555 unsigned long flags;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100556
David Brownella6472532008-03-03 04:33:30 -0800557 spin_lock_irqsave(&bank->lock, flags);
Tony Lindgren92105bb2005-09-07 17:20:26 +0100558
Tony Lindgren4196dd62006-09-25 12:41:38 +0300559 /* Set trigger to none. You need to enable the desired trigger with
560 * request_irq() or set_irq_type().
561 */
Jarkko Nikula3ff164e2008-12-10 17:35:27 -0800562 _set_gpio_triggering(bank, offset, IRQ_TYPE_NONE);
Tony Lindgren92105bb2005-09-07 17:20:26 +0100563
Tony Lindgren1a8bfa12005-11-10 14:26:50 +0000564#ifdef CONFIG_ARCH_OMAP15XX
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100565 if (bank->method == METHOD_GPIO_1510) {
Tony Lindgren92105bb2005-09-07 17:20:26 +0100566 void __iomem *reg;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100567
Tony Lindgren92105bb2005-09-07 17:20:26 +0100568 /* Claim the pin for MPU */
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100569 reg = bank->base + OMAP1510_GPIO_PIN_CONTROL;
Jarkko Nikula3ff164e2008-12-10 17:35:27 -0800570 __raw_writel(__raw_readl(reg) | (1 << offset), reg);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100571 }
572#endif
Charulatha Vc8eef652011-05-02 15:21:42 +0530573 if (bank->regs->ctrl && !bank->mod_usage) {
574 void __iomem *reg = bank->base + bank->regs->ctrl;
575 u32 ctrl;
Charulatha V9f096862010-05-14 12:05:27 -0700576
Charulatha Vc8eef652011-05-02 15:21:42 +0530577 ctrl = __raw_readl(reg);
578 /* Module is enabled, clocks are not gated */
579 ctrl &= ~GPIO_MOD_CTRL_BIT;
580 __raw_writel(ctrl, reg);
Charulatha V058af1e2009-11-22 10:11:25 -0800581 }
Charulatha Vc8eef652011-05-02 15:21:42 +0530582
583 bank->mod_usage |= 1 << offset;
584
David Brownella6472532008-03-03 04:33:30 -0800585 spin_unlock_irqrestore(&bank->lock, flags);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100586
587 return 0;
588}
589
Jarkko Nikula3ff164e2008-12-10 17:35:27 -0800590static void omap_gpio_free(struct gpio_chip *chip, unsigned offset)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100591{
Jarkko Nikula3ff164e2008-12-10 17:35:27 -0800592 struct gpio_bank *bank = container_of(chip, struct gpio_bank, chip);
Tarun Kanti DebBarma6ed87c52011-09-13 14:41:44 +0530593 void __iomem *base = bank->base;
David Brownella6472532008-03-03 04:33:30 -0800594 unsigned long flags;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100595
David Brownella6472532008-03-03 04:33:30 -0800596 spin_lock_irqsave(&bank->lock, flags);
Tarun Kanti DebBarma6ed87c52011-09-13 14:41:44 +0530597
598 if (bank->regs->wkup_en)
Tony Lindgren92105bb2005-09-07 17:20:26 +0100599 /* Disable wake-up during idle for dynamic tick */
Tarun Kanti DebBarma6ed87c52011-09-13 14:41:44 +0530600 _gpio_rmw(base, bank->regs->wkup_en, 1 << offset, 0);
601
Charulatha Vc8eef652011-05-02 15:21:42 +0530602 bank->mod_usage &= ~(1 << offset);
Charulatha V9f096862010-05-14 12:05:27 -0700603
Charulatha Vc8eef652011-05-02 15:21:42 +0530604 if (bank->regs->ctrl && !bank->mod_usage) {
605 void __iomem *reg = bank->base + bank->regs->ctrl;
606 u32 ctrl;
607
608 ctrl = __raw_readl(reg);
609 /* Module is disabled, clocks are gated */
610 ctrl |= GPIO_MOD_CTRL_BIT;
611 __raw_writel(ctrl, reg);
Charulatha V058af1e2009-11-22 10:11:25 -0800612 }
Charulatha Vc8eef652011-05-02 15:21:42 +0530613
Jarkko Nikula3ff164e2008-12-10 17:35:27 -0800614 _reset_gpio(bank, bank->chip.base + offset);
David Brownella6472532008-03-03 04:33:30 -0800615 spin_unlock_irqrestore(&bank->lock, flags);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100616}
617
618/*
619 * We need to unmask the GPIO bank interrupt as soon as possible to
620 * avoid missing GPIO interrupts for other lines in the bank.
621 * Then we need to mask-read-clear-unmask the triggered GPIO lines
622 * in the bank to avoid missing nested interrupts for a GPIO line.
623 * If we wait to unmask individual GPIO lines in the bank after the
624 * line's interrupt handler has been run, we may miss some nested
625 * interrupts.
626 */
Russell King10dd5ce2006-11-23 11:41:32 +0000627static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100628{
Tony Lindgren92105bb2005-09-07 17:20:26 +0100629 void __iomem *isr_reg = NULL;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100630 u32 isr;
Cory Maccarrone4318f362010-01-08 10:29:04 -0800631 unsigned int gpio_irq, gpio_index;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100632 struct gpio_bank *bank;
Imre Deakea6dedd2006-06-26 16:16:00 -0700633 u32 retrigger = 0;
634 int unmasked = 0;
Will Deaconee144182011-02-21 13:46:08 +0000635 struct irq_chip *chip = irq_desc_get_chip(desc);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100636
Will Deaconee144182011-02-21 13:46:08 +0000637 chained_irq_enter(chip, desc);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100638
Thomas Gleixner6845664a2011-03-24 13:25:22 +0100639 bank = irq_get_handler_data(irq);
Kevin Hilmaneef4bec2011-04-21 09:17:35 -0700640 isr_reg = bank->base + bank->regs->irqstatus;
Evgeny Kuznetsovb1cc4c52010-12-07 16:25:40 -0800641
642 if (WARN_ON(!isr_reg))
643 goto exit;
644
Tony Lindgren92105bb2005-09-07 17:20:26 +0100645 while(1) {
Tony Lindgren6e60e792006-04-02 17:46:23 +0100646 u32 isr_saved, level_mask = 0;
Imre Deakea6dedd2006-06-26 16:16:00 -0700647 u32 enabled;
Tony Lindgren6e60e792006-04-02 17:46:23 +0100648
Imre Deakea6dedd2006-06-26 16:16:00 -0700649 enabled = _get_gpio_irqbank_mask(bank);
650 isr_saved = isr = __raw_readl(isr_reg) & enabled;
Tony Lindgren6e60e792006-04-02 17:46:23 +0100651
652 if (cpu_is_omap15xx() && (bank->method == METHOD_MPUIO))
653 isr &= 0x0000ffff;
654
Tarun Kanti DebBarma9ea14d82011-08-30 15:05:44 +0530655 if (bank->level_mask)
Kevin Hilmanb144ff62008-01-16 21:56:15 -0800656 level_mask = bank->level_mask & enabled;
Tony Lindgren6e60e792006-04-02 17:46:23 +0100657
658 /* clear edge sensitive interrupts before handler(s) are
659 called so that we don't miss any interrupt occurred while
660 executing them */
Kevin Hilman28f3b5a2011-04-21 09:53:06 -0700661 _disable_gpio_irqbank(bank, isr_saved & ~level_mask);
Tony Lindgren6e60e792006-04-02 17:46:23 +0100662 _clear_gpio_irqbank(bank, isr_saved & ~level_mask);
Kevin Hilman28f3b5a2011-04-21 09:53:06 -0700663 _enable_gpio_irqbank(bank, isr_saved & ~level_mask);
Tony Lindgren6e60e792006-04-02 17:46:23 +0100664
665 /* if there is only edge sensitive GPIO pin interrupts
666 configured, we could unmask GPIO bank interrupt immediately */
Imre Deakea6dedd2006-06-26 16:16:00 -0700667 if (!level_mask && !unmasked) {
668 unmasked = 1;
Will Deaconee144182011-02-21 13:46:08 +0000669 chained_irq_exit(chip, desc);
Imre Deakea6dedd2006-06-26 16:16:00 -0700670 }
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100671
Imre Deakea6dedd2006-06-26 16:16:00 -0700672 isr |= retrigger;
673 retrigger = 0;
Tony Lindgren92105bb2005-09-07 17:20:26 +0100674 if (!isr)
675 break;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100676
Tony Lindgren92105bb2005-09-07 17:20:26 +0100677 gpio_irq = bank->virtual_irq_start;
678 for (; isr != 0; isr >>= 1, gpio_irq++) {
Kevin Hilman129fd222011-04-22 07:59:07 -0700679 gpio_index = GPIO_INDEX(bank, irq_to_gpio(gpio_irq));
Cory Maccarrone4318f362010-01-08 10:29:04 -0800680
Tony Lindgren92105bb2005-09-07 17:20:26 +0100681 if (!(isr & 1))
682 continue;
Thomas Gleixner29454dd2006-07-03 02:22:22 +0200683
Cory Maccarrone4318f362010-01-08 10:29:04 -0800684#ifdef CONFIG_ARCH_OMAP1
685 /*
686 * Some chips can't respond to both rising and falling
687 * at the same time. If this irq was requested with
688 * both flags, we need to flip the ICR data for the IRQ
689 * to respond to the IRQ for the opposite direction.
690 * This will be indicated in the bank toggle_mask.
691 */
692 if (bank->toggle_mask & (1 << gpio_index))
693 _toggle_gpio_edge_triggering(bank, gpio_index);
694#endif
695
Dmitry Baryshkovd8aa0252008-10-09 13:36:24 +0100696 generic_handle_irq(gpio_irq);
Tony Lindgren92105bb2005-09-07 17:20:26 +0100697 }
Tony Lindgren1a8bfa12005-11-10 14:26:50 +0000698 }
Imre Deakea6dedd2006-06-26 16:16:00 -0700699 /* if bank has any level sensitive GPIO pin interrupt
700 configured, we must unmask the bank interrupt only after
701 handler(s) are executed in order to avoid spurious bank
702 interrupt */
Evgeny Kuznetsovb1cc4c52010-12-07 16:25:40 -0800703exit:
Imre Deakea6dedd2006-06-26 16:16:00 -0700704 if (!unmasked)
Will Deaconee144182011-02-21 13:46:08 +0000705 chained_irq_exit(chip, desc);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100706}
707
Lennert Buytenheke9191022010-11-29 11:17:17 +0100708static void gpio_irq_shutdown(struct irq_data *d)
Tony Lindgren4196dd62006-09-25 12:41:38 +0300709{
Lennert Buytenheke9191022010-11-29 11:17:17 +0100710 unsigned int gpio = d->irq - IH_GPIO_BASE;
711 struct gpio_bank *bank = irq_data_get_irq_chip_data(d);
Colin Cross85ec7b92011-06-06 13:38:18 -0700712 unsigned long flags;
Tony Lindgren4196dd62006-09-25 12:41:38 +0300713
Colin Cross85ec7b92011-06-06 13:38:18 -0700714 spin_lock_irqsave(&bank->lock, flags);
Tony Lindgren4196dd62006-09-25 12:41:38 +0300715 _reset_gpio(bank, gpio);
Colin Cross85ec7b92011-06-06 13:38:18 -0700716 spin_unlock_irqrestore(&bank->lock, flags);
Tony Lindgren4196dd62006-09-25 12:41:38 +0300717}
718
Lennert Buytenheke9191022010-11-29 11:17:17 +0100719static void gpio_ack_irq(struct irq_data *d)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100720{
Lennert Buytenheke9191022010-11-29 11:17:17 +0100721 unsigned int gpio = d->irq - IH_GPIO_BASE;
722 struct gpio_bank *bank = irq_data_get_irq_chip_data(d);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100723
724 _clear_gpio_irqstatus(bank, gpio);
725}
726
Lennert Buytenheke9191022010-11-29 11:17:17 +0100727static void gpio_mask_irq(struct irq_data *d)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100728{
Lennert Buytenheke9191022010-11-29 11:17:17 +0100729 unsigned int gpio = d->irq - IH_GPIO_BASE;
730 struct gpio_bank *bank = irq_data_get_irq_chip_data(d);
Colin Cross85ec7b92011-06-06 13:38:18 -0700731 unsigned long flags;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100732
Colin Cross85ec7b92011-06-06 13:38:18 -0700733 spin_lock_irqsave(&bank->lock, flags);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100734 _set_gpio_irqenable(bank, gpio, 0);
Kevin Hilman129fd222011-04-22 07:59:07 -0700735 _set_gpio_triggering(bank, GPIO_INDEX(bank, gpio), IRQ_TYPE_NONE);
Colin Cross85ec7b92011-06-06 13:38:18 -0700736 spin_unlock_irqrestore(&bank->lock, flags);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100737}
738
Lennert Buytenheke9191022010-11-29 11:17:17 +0100739static void gpio_unmask_irq(struct irq_data *d)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100740{
Lennert Buytenheke9191022010-11-29 11:17:17 +0100741 unsigned int gpio = d->irq - IH_GPIO_BASE;
742 struct gpio_bank *bank = irq_data_get_irq_chip_data(d);
Kevin Hilman129fd222011-04-22 07:59:07 -0700743 unsigned int irq_mask = GPIO_BIT(bank, gpio);
Thomas Gleixner8c04a172011-03-24 12:40:15 +0100744 u32 trigger = irqd_get_trigger_type(d);
Colin Cross85ec7b92011-06-06 13:38:18 -0700745 unsigned long flags;
Kevin Hilman55b60192009-06-04 15:57:10 -0700746
Colin Cross85ec7b92011-06-06 13:38:18 -0700747 spin_lock_irqsave(&bank->lock, flags);
Kevin Hilman55b60192009-06-04 15:57:10 -0700748 if (trigger)
Kevin Hilman129fd222011-04-22 07:59:07 -0700749 _set_gpio_triggering(bank, GPIO_INDEX(bank, gpio), trigger);
Kevin Hilmanb144ff62008-01-16 21:56:15 -0800750
751 /* For level-triggered GPIOs, the clearing must be done after
752 * the HW source is cleared, thus after the handler has run */
753 if (bank->level_mask & irq_mask) {
754 _set_gpio_irqenable(bank, gpio, 0);
755 _clear_gpio_irqstatus(bank, gpio);
756 }
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100757
Kevin Hilman4de8c752008-01-16 21:56:14 -0800758 _set_gpio_irqenable(bank, gpio, 1);
Colin Cross85ec7b92011-06-06 13:38:18 -0700759 spin_unlock_irqrestore(&bank->lock, flags);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100760}
761
David Brownelle5c56ed2006-12-06 17:13:59 -0800762static struct irq_chip gpio_irq_chip = {
763 .name = "GPIO",
Lennert Buytenheke9191022010-11-29 11:17:17 +0100764 .irq_shutdown = gpio_irq_shutdown,
765 .irq_ack = gpio_ack_irq,
766 .irq_mask = gpio_mask_irq,
767 .irq_unmask = gpio_unmask_irq,
768 .irq_set_type = gpio_irq_type,
769 .irq_set_wake = gpio_wake_enable,
David Brownelle5c56ed2006-12-06 17:13:59 -0800770};
771
772/*---------------------------------------------------------------------*/
773
774#ifdef CONFIG_ARCH_OMAP1
775
David Brownelle5c56ed2006-12-06 17:13:59 -0800776#define bank_is_mpuio(bank) ((bank)->method == METHOD_MPUIO)
777
David Brownell11a78b72006-12-06 17:14:11 -0800778#ifdef CONFIG_ARCH_OMAP16XX
779
780#include <linux/platform_device.h>
781
Magnus Damm79ee0312009-07-08 13:22:04 +0200782static int omap_mpuio_suspend_noirq(struct device *dev)
David Brownell11a78b72006-12-06 17:14:11 -0800783{
Magnus Damm79ee0312009-07-08 13:22:04 +0200784 struct platform_device *pdev = to_platform_device(dev);
David Brownell11a78b72006-12-06 17:14:11 -0800785 struct gpio_bank *bank = platform_get_drvdata(pdev);
Tony Lindgren5de62b82010-12-07 16:26:58 -0800786 void __iomem *mask_reg = bank->base +
787 OMAP_MPUIO_GPIO_MASKIT / bank->stride;
David Brownella6472532008-03-03 04:33:30 -0800788 unsigned long flags;
David Brownell11a78b72006-12-06 17:14:11 -0800789
David Brownella6472532008-03-03 04:33:30 -0800790 spin_lock_irqsave(&bank->lock, flags);
David Brownell11a78b72006-12-06 17:14:11 -0800791 bank->saved_wakeup = __raw_readl(mask_reg);
792 __raw_writel(0xffff & ~bank->suspend_wakeup, mask_reg);
David Brownella6472532008-03-03 04:33:30 -0800793 spin_unlock_irqrestore(&bank->lock, flags);
David Brownell11a78b72006-12-06 17:14:11 -0800794
795 return 0;
796}
797
Magnus Damm79ee0312009-07-08 13:22:04 +0200798static int omap_mpuio_resume_noirq(struct device *dev)
David Brownell11a78b72006-12-06 17:14:11 -0800799{
Magnus Damm79ee0312009-07-08 13:22:04 +0200800 struct platform_device *pdev = to_platform_device(dev);
David Brownell11a78b72006-12-06 17:14:11 -0800801 struct gpio_bank *bank = platform_get_drvdata(pdev);
Tony Lindgren5de62b82010-12-07 16:26:58 -0800802 void __iomem *mask_reg = bank->base +
803 OMAP_MPUIO_GPIO_MASKIT / bank->stride;
David Brownella6472532008-03-03 04:33:30 -0800804 unsigned long flags;
David Brownell11a78b72006-12-06 17:14:11 -0800805
David Brownella6472532008-03-03 04:33:30 -0800806 spin_lock_irqsave(&bank->lock, flags);
David Brownell11a78b72006-12-06 17:14:11 -0800807 __raw_writel(bank->saved_wakeup, mask_reg);
David Brownella6472532008-03-03 04:33:30 -0800808 spin_unlock_irqrestore(&bank->lock, flags);
David Brownell11a78b72006-12-06 17:14:11 -0800809
810 return 0;
811}
812
Alexey Dobriyan47145212009-12-14 18:00:08 -0800813static const struct dev_pm_ops omap_mpuio_dev_pm_ops = {
Magnus Damm79ee0312009-07-08 13:22:04 +0200814 .suspend_noirq = omap_mpuio_suspend_noirq,
815 .resume_noirq = omap_mpuio_resume_noirq,
816};
817
Rafael J. Wysocki3c437ff2011-04-22 22:02:46 +0200818/* use platform_driver for this. */
David Brownell11a78b72006-12-06 17:14:11 -0800819static struct platform_driver omap_mpuio_driver = {
David Brownell11a78b72006-12-06 17:14:11 -0800820 .driver = {
821 .name = "mpuio",
Magnus Damm79ee0312009-07-08 13:22:04 +0200822 .pm = &omap_mpuio_dev_pm_ops,
David Brownell11a78b72006-12-06 17:14:11 -0800823 },
824};
825
826static struct platform_device omap_mpuio_device = {
827 .name = "mpuio",
828 .id = -1,
829 .dev = {
830 .driver = &omap_mpuio_driver.driver,
831 }
832 /* could list the /proc/iomem resources */
833};
834
Charulatha V03e128c2011-05-05 19:58:01 +0530835static inline void mpuio_init(struct gpio_bank *bank)
David Brownell11a78b72006-12-06 17:14:11 -0800836{
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -0800837 platform_set_drvdata(&omap_mpuio_device, bank);
David Brownellfcf126d2007-04-02 12:46:47 -0700838
David Brownell11a78b72006-12-06 17:14:11 -0800839 if (platform_driver_register(&omap_mpuio_driver) == 0)
840 (void) platform_device_register(&omap_mpuio_device);
841}
842
843#else
Charulatha V03e128c2011-05-05 19:58:01 +0530844static inline void mpuio_init(struct gpio_bank *bank) {}
David Brownell11a78b72006-12-06 17:14:11 -0800845#endif /* 16xx */
846
David Brownelle5c56ed2006-12-06 17:13:59 -0800847#else
848
David Brownelle5c56ed2006-12-06 17:13:59 -0800849#define bank_is_mpuio(bank) 0
Charulatha V03e128c2011-05-05 19:58:01 +0530850static inline void mpuio_init(struct gpio_bank *bank) {}
David Brownelle5c56ed2006-12-06 17:13:59 -0800851
852#endif
853
854/*---------------------------------------------------------------------*/
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100855
David Brownell52e31342008-03-03 12:43:23 -0800856/* REVISIT these are stupid implementations! replace by ones that
857 * don't switch on METHOD_* and which mostly avoid spinlocks
858 */
859
860static int gpio_input(struct gpio_chip *chip, unsigned offset)
861{
862 struct gpio_bank *bank;
863 unsigned long flags;
864
865 bank = container_of(chip, struct gpio_bank, chip);
866 spin_lock_irqsave(&bank->lock, flags);
867 _set_gpio_direction(bank, offset, 1);
868 spin_unlock_irqrestore(&bank->lock, flags);
869 return 0;
870}
871
Roger Quadrosb37c45b2009-08-05 16:53:24 +0300872static int gpio_is_input(struct gpio_bank *bank, int mask)
873{
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700874 void __iomem *reg = bank->base + bank->regs->direction;
Roger Quadrosb37c45b2009-08-05 16:53:24 +0300875
Roger Quadrosb37c45b2009-08-05 16:53:24 +0300876 return __raw_readl(reg) & mask;
877}
878
David Brownell52e31342008-03-03 12:43:23 -0800879static int gpio_get(struct gpio_chip *chip, unsigned offset)
880{
Roger Quadrosb37c45b2009-08-05 16:53:24 +0300881 struct gpio_bank *bank;
882 void __iomem *reg;
883 int gpio;
884 u32 mask;
885
886 gpio = chip->base + offset;
Charulatha Va8be8da2011-04-22 16:38:16 +0530887 bank = container_of(chip, struct gpio_bank, chip);
Roger Quadrosb37c45b2009-08-05 16:53:24 +0300888 reg = bank->base;
Kevin Hilman129fd222011-04-22 07:59:07 -0700889 mask = GPIO_BIT(bank, gpio);
Roger Quadrosb37c45b2009-08-05 16:53:24 +0300890
891 if (gpio_is_input(bank, mask))
892 return _get_gpio_datain(bank, gpio);
893 else
894 return _get_gpio_dataout(bank, gpio);
David Brownell52e31342008-03-03 12:43:23 -0800895}
896
897static int gpio_output(struct gpio_chip *chip, unsigned offset, int value)
898{
899 struct gpio_bank *bank;
900 unsigned long flags;
901
902 bank = container_of(chip, struct gpio_bank, chip);
903 spin_lock_irqsave(&bank->lock, flags);
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700904 bank->set_dataout(bank, offset, value);
David Brownell52e31342008-03-03 12:43:23 -0800905 _set_gpio_direction(bank, offset, 0);
906 spin_unlock_irqrestore(&bank->lock, flags);
907 return 0;
908}
909
Felipe Balbi168ef3d2010-05-26 14:42:23 -0700910static int gpio_debounce(struct gpio_chip *chip, unsigned offset,
911 unsigned debounce)
912{
913 struct gpio_bank *bank;
914 unsigned long flags;
915
916 bank = container_of(chip, struct gpio_bank, chip);
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -0800917
918 if (!bank->dbck) {
919 bank->dbck = clk_get(bank->dev, "dbclk");
920 if (IS_ERR(bank->dbck))
921 dev_err(bank->dev, "Could not get gpio dbck\n");
922 }
923
Felipe Balbi168ef3d2010-05-26 14:42:23 -0700924 spin_lock_irqsave(&bank->lock, flags);
925 _set_gpio_debounce(bank, offset, debounce);
926 spin_unlock_irqrestore(&bank->lock, flags);
927
928 return 0;
929}
930
David Brownell52e31342008-03-03 12:43:23 -0800931static void gpio_set(struct gpio_chip *chip, unsigned offset, int value)
932{
933 struct gpio_bank *bank;
934 unsigned long flags;
935
936 bank = container_of(chip, struct gpio_bank, chip);
937 spin_lock_irqsave(&bank->lock, flags);
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700938 bank->set_dataout(bank, offset, value);
David Brownell52e31342008-03-03 12:43:23 -0800939 spin_unlock_irqrestore(&bank->lock, flags);
940}
941
David Brownella007b702008-12-10 17:35:25 -0800942static int gpio_2irq(struct gpio_chip *chip, unsigned offset)
943{
944 struct gpio_bank *bank;
945
946 bank = container_of(chip, struct gpio_bank, chip);
947 return bank->virtual_irq_start + offset;
948}
949
David Brownell52e31342008-03-03 12:43:23 -0800950/*---------------------------------------------------------------------*/
951
Tony Lindgren9a748052010-12-07 16:26:56 -0800952static void __init omap_gpio_show_rev(struct gpio_bank *bank)
Tony Lindgren9f7065d2009-10-19 15:25:20 -0700953{
Kevin Hilmane5ff4442011-04-22 14:37:16 -0700954 static bool called;
Tony Lindgren9f7065d2009-10-19 15:25:20 -0700955 u32 rev;
956
Kevin Hilmane5ff4442011-04-22 14:37:16 -0700957 if (called || bank->regs->revision == USHRT_MAX)
Tony Lindgren9f7065d2009-10-19 15:25:20 -0700958 return;
959
Kevin Hilmane5ff4442011-04-22 14:37:16 -0700960 rev = __raw_readw(bank->base + bank->regs->revision);
961 pr_info("OMAP GPIO hardware version %d.%d\n",
Tony Lindgren9f7065d2009-10-19 15:25:20 -0700962 (rev >> 4) & 0x0f, rev & 0x0f);
Kevin Hilmane5ff4442011-04-22 14:37:16 -0700963
964 called = true;
Tony Lindgren9f7065d2009-10-19 15:25:20 -0700965}
966
David Brownell8ba55c52008-02-26 11:10:50 -0800967/* This lock class tells lockdep that GPIO irqs are in a different
968 * category than their parents, so it won't report false recursion.
969 */
970static struct lock_class_key gpio_lock_class;
971
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -0800972/* TODO: Cleanup cpu_is_* checks */
Charulatha V03e128c2011-05-05 19:58:01 +0530973static void omap_gpio_mod_init(struct gpio_bank *bank)
Varadarajan, Charulatha2fae7fb2010-12-07 16:26:55 -0800974{
975 if (cpu_class_is_omap2()) {
976 if (cpu_is_omap44xx()) {
977 __raw_writel(0xffffffff, bank->base +
978 OMAP4_GPIO_IRQSTATUSCLR0);
979 __raw_writel(0x00000000, bank->base +
980 OMAP4_GPIO_DEBOUNCENABLE);
981 /* Initialize interface clk ungated, module enabled */
982 __raw_writel(0, bank->base + OMAP4_GPIO_CTRL);
983 } else if (cpu_is_omap34xx()) {
984 __raw_writel(0x00000000, bank->base +
985 OMAP24XX_GPIO_IRQENABLE1);
986 __raw_writel(0xffffffff, bank->base +
987 OMAP24XX_GPIO_IRQSTATUS1);
988 __raw_writel(0x00000000, bank->base +
989 OMAP24XX_GPIO_DEBOUNCE_EN);
990
991 /* Initialize interface clk ungated, module enabled */
992 __raw_writel(0, bank->base + OMAP24XX_GPIO_CTRL);
Varadarajan, Charulatha2fae7fb2010-12-07 16:26:55 -0800993 }
994 } else if (cpu_class_is_omap1()) {
Charulatha V03e128c2011-05-05 19:58:01 +0530995 if (bank_is_mpuio(bank)) {
Tony Lindgren5de62b82010-12-07 16:26:58 -0800996 __raw_writew(0xffff, bank->base +
997 OMAP_MPUIO_GPIO_MASKIT / bank->stride);
Charulatha V03e128c2011-05-05 19:58:01 +0530998 mpuio_init(bank);
999 }
Varadarajan, Charulatha2fae7fb2010-12-07 16:26:55 -08001000 if (cpu_is_omap15xx() && bank->method == METHOD_GPIO_1510) {
1001 __raw_writew(0xffff, bank->base
1002 + OMAP1510_GPIO_INT_MASK);
1003 __raw_writew(0x0000, bank->base
1004 + OMAP1510_GPIO_INT_STATUS);
1005 }
1006 if (cpu_is_omap16xx() && bank->method == METHOD_GPIO_1610) {
1007 __raw_writew(0x0000, bank->base
1008 + OMAP1610_GPIO_IRQENABLE1);
1009 __raw_writew(0xffff, bank->base
1010 + OMAP1610_GPIO_IRQSTATUS1);
1011 __raw_writew(0x0014, bank->base
1012 + OMAP1610_GPIO_SYSCONFIG);
1013
1014 /*
1015 * Enable system clock for GPIO module.
1016 * The CAM_CLK_CTRL *is* really the right place.
1017 */
1018 omap_writel(omap_readl(ULPD_CAM_CLK_CTRL) | 0x04,
1019 ULPD_CAM_CLK_CTRL);
1020 }
1021 if (cpu_is_omap7xx() && bank->method == METHOD_GPIO_7XX) {
1022 __raw_writel(0xffffffff, bank->base
1023 + OMAP7XX_GPIO_INT_MASK);
1024 __raw_writel(0x00000000, bank->base
1025 + OMAP7XX_GPIO_INT_STATUS);
1026 }
1027 }
1028}
1029
Kevin Hilmanf8b46b52011-04-21 13:23:34 -07001030static __init void
1031omap_mpuio_alloc_gc(struct gpio_bank *bank, unsigned int irq_start,
1032 unsigned int num)
1033{
1034 struct irq_chip_generic *gc;
1035 struct irq_chip_type *ct;
1036
1037 gc = irq_alloc_generic_chip("MPUIO", 1, irq_start, bank->base,
1038 handle_simple_irq);
Todd Poynor83233742011-07-18 07:43:14 -07001039 if (!gc) {
1040 dev_err(bank->dev, "Memory alloc failed for gc\n");
1041 return;
1042 }
1043
Kevin Hilmanf8b46b52011-04-21 13:23:34 -07001044 ct = gc->chip_types;
1045
1046 /* NOTE: No ack required, reading IRQ status clears it. */
1047 ct->chip.irq_mask = irq_gc_mask_set_bit;
1048 ct->chip.irq_unmask = irq_gc_mask_clr_bit;
1049 ct->chip.irq_set_type = gpio_irq_type;
Tarun Kanti DebBarma6ed87c52011-09-13 14:41:44 +05301050
1051 if (bank->regs->wkup_en)
Kevin Hilmanf8b46b52011-04-21 13:23:34 -07001052 ct->chip.irq_set_wake = gpio_wake_enable,
1053
1054 ct->regs.mask = OMAP_MPUIO_GPIO_INT / bank->stride;
1055 irq_setup_generic_chip(gc, IRQ_MSK(num), IRQ_GC_INIT_MASK_CACHE,
1056 IRQ_NOREQUEST | IRQ_NOPROBE, 0);
1057}
1058
Russell Kingd52b31d2011-05-27 13:56:12 -07001059static void __devinit omap_gpio_chip_init(struct gpio_bank *bank)
Varadarajan, Charulatha2fae7fb2010-12-07 16:26:55 -08001060{
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -08001061 int j;
Varadarajan, Charulatha2fae7fb2010-12-07 16:26:55 -08001062 static int gpio;
1063
Varadarajan, Charulatha2fae7fb2010-12-07 16:26:55 -08001064 bank->mod_usage = 0;
1065 /*
1066 * REVISIT eventually switch from OMAP-specific gpio structs
1067 * over to the generic ones
1068 */
1069 bank->chip.request = omap_gpio_request;
1070 bank->chip.free = omap_gpio_free;
1071 bank->chip.direction_input = gpio_input;
1072 bank->chip.get = gpio_get;
1073 bank->chip.direction_output = gpio_output;
1074 bank->chip.set_debounce = gpio_debounce;
1075 bank->chip.set = gpio_set;
1076 bank->chip.to_irq = gpio_2irq;
1077 if (bank_is_mpuio(bank)) {
1078 bank->chip.label = "mpuio";
1079#ifdef CONFIG_ARCH_OMAP16XX
Tarun Kanti DebBarma6ed87c52011-09-13 14:41:44 +05301080 if (bank->regs->wkup_en)
1081 bank->chip.dev = &omap_mpuio_device.dev;
Varadarajan, Charulatha2fae7fb2010-12-07 16:26:55 -08001082#endif
1083 bank->chip.base = OMAP_MPUIO(0);
1084 } else {
1085 bank->chip.label = "gpio";
1086 bank->chip.base = gpio;
Kevin Hilmand5f46242011-04-21 09:23:00 -07001087 gpio += bank->width;
Varadarajan, Charulatha2fae7fb2010-12-07 16:26:55 -08001088 }
Kevin Hilmand5f46242011-04-21 09:23:00 -07001089 bank->chip.ngpio = bank->width;
Varadarajan, Charulatha2fae7fb2010-12-07 16:26:55 -08001090
1091 gpiochip_add(&bank->chip);
1092
1093 for (j = bank->virtual_irq_start;
Kevin Hilmand5f46242011-04-21 09:23:00 -07001094 j < bank->virtual_irq_start + bank->width; j++) {
Thomas Gleixner1475b852011-03-22 17:11:09 +01001095 irq_set_lockdep_class(j, &gpio_lock_class);
Thomas Gleixner6845664a2011-03-24 13:25:22 +01001096 irq_set_chip_data(j, bank);
Kevin Hilmanf8b46b52011-04-21 13:23:34 -07001097 if (bank_is_mpuio(bank)) {
1098 omap_mpuio_alloc_gc(bank, j, bank->width);
1099 } else {
Thomas Gleixner6845664a2011-03-24 13:25:22 +01001100 irq_set_chip(j, &gpio_irq_chip);
Kevin Hilmanf8b46b52011-04-21 13:23:34 -07001101 irq_set_handler(j, handle_simple_irq);
1102 set_irq_flags(j, IRQF_VALID);
1103 }
Varadarajan, Charulatha2fae7fb2010-12-07 16:26:55 -08001104 }
Thomas Gleixner6845664a2011-03-24 13:25:22 +01001105 irq_set_chained_handler(bank->irq, gpio_irq_handler);
1106 irq_set_handler_data(bank->irq, bank);
Varadarajan, Charulatha2fae7fb2010-12-07 16:26:55 -08001107}
1108
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -08001109static int __devinit omap_gpio_probe(struct platform_device *pdev)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +01001110{
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -08001111 struct omap_gpio_platform_data *pdata;
1112 struct resource *res;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +01001113 struct gpio_bank *bank;
Charulatha V03e128c2011-05-05 19:58:01 +05301114 int ret = 0;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +01001115
Charulatha V03e128c2011-05-05 19:58:01 +05301116 if (!pdev->dev.platform_data) {
1117 ret = -EINVAL;
1118 goto err_exit;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +01001119 }
1120
Charulatha V03e128c2011-05-05 19:58:01 +05301121 bank = kzalloc(sizeof(struct gpio_bank), GFP_KERNEL);
1122 if (!bank) {
1123 dev_err(&pdev->dev, "Memory alloc failed for gpio_bank\n");
1124 ret = -ENOMEM;
1125 goto err_exit;
1126 }
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -08001127
1128 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
1129 if (unlikely(!res)) {
Charulatha V03e128c2011-05-05 19:58:01 +05301130 dev_err(&pdev->dev, "GPIO Bank %i Invalid IRQ resource\n",
1131 pdev->id);
1132 ret = -ENODEV;
1133 goto err_free;
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -08001134 }
1135
1136 bank->irq = res->start;
Charulatha V03e128c2011-05-05 19:58:01 +05301137 bank->id = pdev->id;
1138
1139 pdata = pdev->dev.platform_data;
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -08001140 bank->virtual_irq_start = pdata->virtual_irq_start;
1141 bank->method = pdata->bank_type;
1142 bank->dev = &pdev->dev;
1143 bank->dbck_flag = pdata->dbck_flag;
Tony Lindgren5de62b82010-12-07 16:26:58 -08001144 bank->stride = pdata->bank_stride;
Kevin Hilmand5f46242011-04-21 09:23:00 -07001145 bank->width = pdata->bank_width;
Charulatha V803a2432011-05-05 17:04:12 +05301146 bank->non_wakeup_gpios = pdata->non_wakeup_gpios;
Charulatha V0cde8d02011-05-05 20:15:16 +05301147 bank->loses_context = pdata->loses_context;
Tarun Kanti DebBarma60a34372011-09-29 04:47:25 +05301148 bank->get_context_loss_count = pdata->get_context_loss_count;
Kevin Hilmanfa87931a2011-04-20 16:31:23 -07001149 bank->regs = pdata->regs;
1150
1151 if (bank->regs->set_dataout && bank->regs->clr_dataout)
1152 bank->set_dataout = _set_gpio_dataout_reg;
1153 else
1154 bank->set_dataout = _set_gpio_dataout_mask;
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -08001155
1156 spin_lock_init(&bank->lock);
1157
1158 /* Static mapping, never released */
1159 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1160 if (unlikely(!res)) {
Charulatha V03e128c2011-05-05 19:58:01 +05301161 dev_err(&pdev->dev, "GPIO Bank %i Invalid mem resource\n",
1162 pdev->id);
1163 ret = -ENODEV;
1164 goto err_free;
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -08001165 }
1166
1167 bank->base = ioremap(res->start, resource_size(res));
1168 if (!bank->base) {
Charulatha V03e128c2011-05-05 19:58:01 +05301169 dev_err(&pdev->dev, "Could not ioremap gpio bank%i\n",
1170 pdev->id);
1171 ret = -ENOMEM;
1172 goto err_free;
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -08001173 }
1174
1175 pm_runtime_enable(bank->dev);
1176 pm_runtime_get_sync(bank->dev);
1177
Charulatha V03e128c2011-05-05 19:58:01 +05301178 omap_gpio_mod_init(bank);
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -08001179 omap_gpio_chip_init(bank);
Tony Lindgren9a748052010-12-07 16:26:56 -08001180 omap_gpio_show_rev(bank);
Tony Lindgren9f7065d2009-10-19 15:25:20 -07001181
Charulatha V03e128c2011-05-05 19:58:01 +05301182 list_add_tail(&bank->node, &omap_gpio_list);
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -08001183
Charulatha V03e128c2011-05-05 19:58:01 +05301184 return ret;
1185
1186err_free:
1187 kfree(bank);
1188err_exit:
1189 return ret;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +01001190}
1191
Rafael J. Wysocki3c437ff2011-04-22 22:02:46 +02001192static int omap_gpio_suspend(void)
Tony Lindgren92105bb2005-09-07 17:20:26 +01001193{
Charulatha V03e128c2011-05-05 19:58:01 +05301194 struct gpio_bank *bank;
Tony Lindgren92105bb2005-09-07 17:20:26 +01001195
Charulatha V03e128c2011-05-05 19:58:01 +05301196 list_for_each_entry(bank, &omap_gpio_list, node) {
Tarun Kanti DebBarma6ed87c52011-09-13 14:41:44 +05301197 void __iomem *base = bank->base;
Tony Lindgren92105bb2005-09-07 17:20:26 +01001198 void __iomem *wake_status;
David Brownella6472532008-03-03 04:33:30 -08001199 unsigned long flags;
Tony Lindgren92105bb2005-09-07 17:20:26 +01001200
Tarun Kanti DebBarma6ed87c52011-09-13 14:41:44 +05301201 if (!bank->regs->wkup_en)
1202 return 0;
1203
1204 wake_status = bank->base + bank->regs->wkup_en;
Tony Lindgren92105bb2005-09-07 17:20:26 +01001205
David Brownella6472532008-03-03 04:33:30 -08001206 spin_lock_irqsave(&bank->lock, flags);
Tony Lindgren92105bb2005-09-07 17:20:26 +01001207 bank->saved_wakeup = __raw_readl(wake_status);
Tarun Kanti DebBarma6ed87c52011-09-13 14:41:44 +05301208 _gpio_rmw(base, bank->regs->wkup_en, 0xffffffff, 0);
1209 _gpio_rmw(base, bank->regs->wkup_en, bank->suspend_wakeup, 1);
David Brownella6472532008-03-03 04:33:30 -08001210 spin_unlock_irqrestore(&bank->lock, flags);
Tony Lindgren92105bb2005-09-07 17:20:26 +01001211 }
1212
1213 return 0;
1214}
1215
Rafael J. Wysocki3c437ff2011-04-22 22:02:46 +02001216static void omap_gpio_resume(void)
Tony Lindgren92105bb2005-09-07 17:20:26 +01001217{
Charulatha V03e128c2011-05-05 19:58:01 +05301218 struct gpio_bank *bank;
Tony Lindgren92105bb2005-09-07 17:20:26 +01001219
Charulatha V03e128c2011-05-05 19:58:01 +05301220 list_for_each_entry(bank, &omap_gpio_list, node) {
Tarun Kanti DebBarma6ed87c52011-09-13 14:41:44 +05301221 void __iomem *base = bank->base;
David Brownella6472532008-03-03 04:33:30 -08001222 unsigned long flags;
Tony Lindgren92105bb2005-09-07 17:20:26 +01001223
Tarun Kanti DebBarma6ed87c52011-09-13 14:41:44 +05301224 if (!bank->regs->wkup_en)
1225 return;
Tony Lindgren92105bb2005-09-07 17:20:26 +01001226
David Brownella6472532008-03-03 04:33:30 -08001227 spin_lock_irqsave(&bank->lock, flags);
Tarun Kanti DebBarma6ed87c52011-09-13 14:41:44 +05301228 _gpio_rmw(base, bank->regs->wkup_en, 0xffffffff, 0);
1229 _gpio_rmw(base, bank->regs->wkup_en, bank->saved_wakeup, 1);
David Brownella6472532008-03-03 04:33:30 -08001230 spin_unlock_irqrestore(&bank->lock, flags);
Tony Lindgren92105bb2005-09-07 17:20:26 +01001231 }
Tony Lindgren92105bb2005-09-07 17:20:26 +01001232}
1233
Rafael J. Wysocki3c437ff2011-04-22 22:02:46 +02001234static struct syscore_ops omap_gpio_syscore_ops = {
Tony Lindgren92105bb2005-09-07 17:20:26 +01001235 .suspend = omap_gpio_suspend,
1236 .resume = omap_gpio_resume,
1237};
1238
Tony Lindgren140455f2010-02-12 12:26:48 -08001239#ifdef CONFIG_ARCH_OMAP2PLUS
Juha Yrjola3ac4fa92006-12-06 17:13:52 -08001240
Tarun Kanti DebBarma60a34372011-09-29 04:47:25 +05301241static void omap_gpio_save_context(struct gpio_bank *bank);
1242static void omap_gpio_restore_context(struct gpio_bank *bank);
Juha Yrjola3ac4fa92006-12-06 17:13:52 -08001243
Paul Walmsley72e06d02010-12-21 21:05:16 -07001244void omap2_gpio_prepare_for_idle(int off_mode)
Juha Yrjola3ac4fa92006-12-06 17:13:52 -08001245{
Charulatha V03e128c2011-05-05 19:58:01 +05301246 struct gpio_bank *bank;
Juha Yrjola3ac4fa92006-12-06 17:13:52 -08001247
Charulatha V03e128c2011-05-05 19:58:01 +05301248 list_for_each_entry(bank, &omap_gpio_list, node) {
Sanjeev Premica828762010-09-23 18:27:18 -07001249 u32 l1 = 0, l2 = 0;
Kevin Hilman0aed04352010-09-22 16:06:27 -07001250 int j;
Juha Yrjola3ac4fa92006-12-06 17:13:52 -08001251
Charulatha V0cde8d02011-05-05 20:15:16 +05301252 if (!bank->loses_context)
Charulatha V03e128c2011-05-05 19:58:01 +05301253 continue;
1254
Kevin Hilman0aed04352010-09-22 16:06:27 -07001255 for (j = 0; j < hweight_long(bank->dbck_enable_mask); j++)
Kevin Hilman8865b9b2009-01-27 11:15:34 -08001256 clk_disable(bank->dbck);
1257
Paul Walmsley72e06d02010-12-21 21:05:16 -07001258 if (!off_mode)
Kevin Hilman43ffcd92009-01-27 11:09:24 -08001259 continue;
1260
1261 /* If going to OFF, remove triggering for all
1262 * non-wakeup GPIOs. Otherwise spurious IRQs will be
1263 * generated. See OMAP2420 Errata item 1.101. */
Juha Yrjola3ac4fa92006-12-06 17:13:52 -08001264 if (!(bank->enabled_non_wakeup_gpios))
Tarun Kanti DebBarma60a34372011-09-29 04:47:25 +05301265 goto save_gpio_context;
Tony Lindgren3f1686a92010-02-15 09:27:25 -08001266
Tarun Kanti DebBarma9ea14d82011-08-30 15:05:44 +05301267 bank->saved_datain = __raw_readl(bank->base +
1268 bank->regs->datain);
1269 l1 = __raw_readl(bank->base + bank->regs->fallingdetect);
1270 l2 = __raw_readl(bank->base + bank->regs->risingdetect);
Tony Lindgren3f1686a92010-02-15 09:27:25 -08001271
Juha Yrjola3ac4fa92006-12-06 17:13:52 -08001272 bank->saved_fallingdetect = l1;
1273 bank->saved_risingdetect = l2;
1274 l1 &= ~bank->enabled_non_wakeup_gpios;
1275 l2 &= ~bank->enabled_non_wakeup_gpios;
Tony Lindgren3f1686a92010-02-15 09:27:25 -08001276
Tarun Kanti DebBarma9ea14d82011-08-30 15:05:44 +05301277 __raw_writel(l1, bank->base + bank->regs->fallingdetect);
1278 __raw_writel(l2, bank->base + bank->regs->risingdetect);
Tony Lindgren3f1686a92010-02-15 09:27:25 -08001279
Tarun Kanti DebBarma60a34372011-09-29 04:47:25 +05301280save_gpio_context:
1281 if (bank->get_context_loss_count)
1282 bank->context_loss_count =
1283 bank->get_context_loss_count(bank->dev);
1284
1285 omap_gpio_save_context(bank);
Juha Yrjola3ac4fa92006-12-06 17:13:52 -08001286 }
Juha Yrjola3ac4fa92006-12-06 17:13:52 -08001287}
1288
Kevin Hilman43ffcd92009-01-27 11:09:24 -08001289void omap2_gpio_resume_after_idle(void)
Juha Yrjola3ac4fa92006-12-06 17:13:52 -08001290{
Charulatha V03e128c2011-05-05 19:58:01 +05301291 struct gpio_bank *bank;
Juha Yrjola3ac4fa92006-12-06 17:13:52 -08001292
Charulatha V03e128c2011-05-05 19:58:01 +05301293 list_for_each_entry(bank, &omap_gpio_list, node) {
Tarun Kanti DebBarma60a34372011-09-29 04:47:25 +05301294 int context_lost_cnt_after;
Sanjeev Premica828762010-09-23 18:27:18 -07001295 u32 l = 0, gen, gen0, gen1;
Kevin Hilman0aed04352010-09-22 16:06:27 -07001296 int j;
Juha Yrjola3ac4fa92006-12-06 17:13:52 -08001297
Charulatha V0cde8d02011-05-05 20:15:16 +05301298 if (!bank->loses_context)
Charulatha V03e128c2011-05-05 19:58:01 +05301299 continue;
1300
Kevin Hilman0aed04352010-09-22 16:06:27 -07001301 for (j = 0; j < hweight_long(bank->dbck_enable_mask); j++)
Kevin Hilman8865b9b2009-01-27 11:15:34 -08001302 clk_enable(bank->dbck);
1303
Tarun Kanti DebBarma60a34372011-09-29 04:47:25 +05301304 if (bank->get_context_loss_count) {
1305 context_lost_cnt_after =
1306 bank->get_context_loss_count(bank->dev);
1307 if (context_lost_cnt_after != bank->context_loss_count
1308 || !context_lost_cnt_after)
1309 omap_gpio_restore_context(bank);
1310 }
Kevin Hilman43ffcd92009-01-27 11:09:24 -08001311
Juha Yrjola3ac4fa92006-12-06 17:13:52 -08001312 if (!(bank->enabled_non_wakeup_gpios))
1313 continue;
Tony Lindgren3f1686a92010-02-15 09:27:25 -08001314
Tarun Kanti DebBarma9ea14d82011-08-30 15:05:44 +05301315 __raw_writel(bank->saved_fallingdetect,
1316 bank->base + bank->regs->fallingdetect);
1317 __raw_writel(bank->saved_risingdetect,
1318 bank->base + bank->regs->risingdetect);
1319 l = __raw_readl(bank->base + bank->regs->datain);
Tony Lindgren3f1686a92010-02-15 09:27:25 -08001320
Juha Yrjola3ac4fa92006-12-06 17:13:52 -08001321 /* Check if any of the non-wakeup interrupt GPIOs have changed
1322 * state. If so, generate an IRQ by software. This is
1323 * horribly racy, but it's the best we can do to work around
1324 * this silicon bug. */
Juha Yrjola3ac4fa92006-12-06 17:13:52 -08001325 l ^= bank->saved_datain;
Tero Kristoa118b5f2008-12-22 14:27:12 +02001326 l &= bank->enabled_non_wakeup_gpios;
Eero Nurkkala82dbb9d2009-08-28 10:51:36 -07001327
1328 /*
1329 * No need to generate IRQs for the rising edge for gpio IRQs
1330 * configured with falling edge only; and vice versa.
1331 */
1332 gen0 = l & bank->saved_fallingdetect;
1333 gen0 &= bank->saved_datain;
1334
1335 gen1 = l & bank->saved_risingdetect;
1336 gen1 &= ~(bank->saved_datain);
1337
1338 /* FIXME: Consider GPIO IRQs with level detections properly! */
1339 gen = l & (~(bank->saved_fallingdetect) &
1340 ~(bank->saved_risingdetect));
1341 /* Consider all GPIO IRQs needed to be updated */
1342 gen |= gen0 | gen1;
1343
1344 if (gen) {
Juha Yrjola3ac4fa92006-12-06 17:13:52 -08001345 u32 old0, old1;
Tony Lindgren3f1686a92010-02-15 09:27:25 -08001346
Tarun Kanti DebBarma9ea14d82011-08-30 15:05:44 +05301347 old0 = __raw_readl(bank->base +
1348 bank->regs->leveldetect0);
1349 old1 = __raw_readl(bank->base +
1350 bank->regs->leveldetect1);
1351
Sergio Aguirref00d6492010-03-03 16:21:08 +00001352 if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
Tarun Kanti DebBarma9ea14d82011-08-30 15:05:44 +05301353 old0 |= gen;
1354 old1 |= gen;
Tony Lindgren3f1686a92010-02-15 09:27:25 -08001355 }
1356
1357 if (cpu_is_omap44xx()) {
Tarun Kanti DebBarma9ea14d82011-08-30 15:05:44 +05301358 old0 |= l;
1359 old1 |= l;
Tony Lindgren3f1686a92010-02-15 09:27:25 -08001360 }
Tarun Kanti DebBarma9ea14d82011-08-30 15:05:44 +05301361 __raw_writel(old0, bank->base +
1362 bank->regs->leveldetect0);
1363 __raw_writel(old1, bank->base +
1364 bank->regs->leveldetect1);
Juha Yrjola3ac4fa92006-12-06 17:13:52 -08001365 }
1366 }
Juha Yrjola3ac4fa92006-12-06 17:13:52 -08001367}
1368
Tarun Kanti DebBarma60a34372011-09-29 04:47:25 +05301369static void omap_gpio_save_context(struct gpio_bank *bank)
Rajendra Nayak40c670f2008-09-26 17:47:48 +05301370{
Tarun Kanti DebBarma60a34372011-09-29 04:47:25 +05301371 bank->context.irqenable1 =
1372 __raw_readl(bank->base + OMAP24XX_GPIO_IRQENABLE1);
1373 bank->context.irqenable2 =
1374 __raw_readl(bank->base + OMAP24XX_GPIO_IRQENABLE2);
1375 bank->context.wake_en =
1376 __raw_readl(bank->base + OMAP24XX_GPIO_WAKE_EN);
1377 bank->context.ctrl = __raw_readl(bank->base + OMAP24XX_GPIO_CTRL);
1378 bank->context.oe = __raw_readl(bank->base + OMAP24XX_GPIO_OE);
1379 bank->context.leveldetect0 =
1380 __raw_readl(bank->base + OMAP24XX_GPIO_LEVELDETECT0);
1381 bank->context.leveldetect1 =
1382 __raw_readl(bank->base + OMAP24XX_GPIO_LEVELDETECT1);
1383 bank->context.risingdetect =
1384 __raw_readl(bank->base + OMAP24XX_GPIO_RISINGDETECT);
1385 bank->context.fallingdetect =
1386 __raw_readl(bank->base + OMAP24XX_GPIO_FALLINGDETECT);
1387 bank->context.dataout =
1388 __raw_readl(bank->base + OMAP24XX_GPIO_DATAOUT);
Rajendra Nayak40c670f2008-09-26 17:47:48 +05301389}
1390
Tarun Kanti DebBarma60a34372011-09-29 04:47:25 +05301391static void omap_gpio_restore_context(struct gpio_bank *bank)
Rajendra Nayak40c670f2008-09-26 17:47:48 +05301392{
Tarun Kanti DebBarma60a34372011-09-29 04:47:25 +05301393 __raw_writel(bank->context.irqenable1,
1394 bank->base + OMAP24XX_GPIO_IRQENABLE1);
1395 __raw_writel(bank->context.irqenable2,
1396 bank->base + OMAP24XX_GPIO_IRQENABLE2);
1397 __raw_writel(bank->context.wake_en,
1398 bank->base + OMAP24XX_GPIO_WAKE_EN);
1399 __raw_writel(bank->context.ctrl, bank->base + OMAP24XX_GPIO_CTRL);
1400 __raw_writel(bank->context.oe, bank->base + OMAP24XX_GPIO_OE);
1401 __raw_writel(bank->context.leveldetect0,
1402 bank->base + OMAP24XX_GPIO_LEVELDETECT0);
1403 __raw_writel(bank->context.leveldetect1,
1404 bank->base + OMAP24XX_GPIO_LEVELDETECT1);
1405 __raw_writel(bank->context.risingdetect,
1406 bank->base + OMAP24XX_GPIO_RISINGDETECT);
1407 __raw_writel(bank->context.fallingdetect,
1408 bank->base + OMAP24XX_GPIO_FALLINGDETECT);
1409 __raw_writel(bank->context.dataout,
1410 bank->base + OMAP24XX_GPIO_DATAOUT);
Rajendra Nayak40c670f2008-09-26 17:47:48 +05301411}
1412#endif
1413
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -08001414static struct platform_driver omap_gpio_driver = {
1415 .probe = omap_gpio_probe,
1416 .driver = {
1417 .name = "omap_gpio",
1418 },
1419};
1420
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +01001421/*
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -08001422 * gpio driver register needs to be done before
1423 * machine_init functions access gpio APIs.
1424 * Hence omap_gpio_drv_reg() is a postcore_initcall.
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +01001425 */
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -08001426static int __init omap_gpio_drv_reg(void)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +01001427{
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -08001428 return platform_driver_register(&omap_gpio_driver);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +01001429}
Varadarajan, Charulatha77640aa2010-12-07 16:26:57 -08001430postcore_initcall(omap_gpio_drv_reg);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +01001431
Tony Lindgren92105bb2005-09-07 17:20:26 +01001432static int __init omap_gpio_sysinit(void)
1433{
David Brownell11a78b72006-12-06 17:14:11 -08001434
Tony Lindgren140455f2010-02-12 12:26:48 -08001435#if defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP2PLUS)
Rafael J. Wysocki3c437ff2011-04-22 22:02:46 +02001436 if (cpu_is_omap16xx() || cpu_class_is_omap2())
1437 register_syscore_ops(&omap_gpio_syscore_ops);
Tony Lindgren92105bb2005-09-07 17:20:26 +01001438#endif
1439
Rafael J. Wysocki3c437ff2011-04-22 22:02:46 +02001440 return 0;
Tony Lindgren92105bb2005-09-07 17:20:26 +01001441}
1442
Tony Lindgren92105bb2005-09-07 17:20:26 +01001443arch_initcall(omap_gpio_sysinit);