Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Generic GPIO driver for logic cells found in the Nomadik SoC |
| 3 | * |
| 4 | * Copyright (C) 2008,2009 STMicroelectronics |
| 5 | * Copyright (C) 2009 Alessandro Rubini <rubini@unipv.it> |
| 6 | * Rewritten based on work by Prafulla WADASKAR <prafulla.wadaskar@st.com> |
Linus Walleij | 33d7864 | 2011-06-09 11:08:47 +0200 | [diff] [blame] | 7 | * Copyright (C) 2011 Linus Walleij <linus.walleij@linaro.org> |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 8 | * |
| 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. |
| 12 | */ |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/device.h> |
Rabin Vincent | 3e3c62c | 2010-03-03 04:52:34 +0100 | [diff] [blame] | 17 | #include <linux/platform_device.h> |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 18 | #include <linux/io.h> |
Rabin Vincent | af7dc22 | 2010-05-06 11:14:17 +0100 | [diff] [blame] | 19 | #include <linux/clk.h> |
| 20 | #include <linux/err.h> |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 21 | #include <linux/gpio.h> |
| 22 | #include <linux/spinlock.h> |
| 23 | #include <linux/interrupt.h> |
| 24 | #include <linux/irq.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 25 | #include <linux/slab.h> |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 26 | |
Will Deacon | adfed15 | 2011-02-28 10:12:29 +0000 | [diff] [blame] | 27 | #include <asm/mach/irq.h> |
| 28 | |
Rabin Vincent | 378be06 | 2010-06-02 06:06:29 +0100 | [diff] [blame] | 29 | #include <plat/pincfg.h> |
Linus Walleij | 0f33286 | 2011-08-22 08:33:30 +0100 | [diff] [blame] | 30 | #include <plat/gpio-nomadik.h> |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 31 | |
| 32 | /* |
| 33 | * The GPIO module in the Nomadik family of Systems-on-Chip is an |
| 34 | * AMBA device, managing 32 pins and alternate functions. The logic block |
Jonas Aaberg | 9c66ee6 | 2010-10-13 13:14:17 +0200 | [diff] [blame] | 35 | * is currently used in the Nomadik and ux500. |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 36 | * |
| 37 | * Symbols in this file are called "nmk_gpio" for "nomadik gpio" |
| 38 | */ |
| 39 | |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 40 | #define NMK_GPIO_PER_CHIP 32 |
| 41 | |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 42 | struct nmk_gpio_chip { |
| 43 | struct gpio_chip chip; |
| 44 | void __iomem *addr; |
Rabin Vincent | af7dc22 | 2010-05-06 11:14:17 +0100 | [diff] [blame] | 45 | struct clk *clk; |
Rabin Vincent | 33b744b | 2010-10-14 10:38:03 +0530 | [diff] [blame] | 46 | unsigned int bank; |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 47 | unsigned int parent_irq; |
Virupax Sadashivpetimath | 2c8bb0e | 2010-11-11 14:10:38 +0530 | [diff] [blame] | 48 | int secondary_parent_irq; |
Rabin Vincent | 33b744b | 2010-10-14 10:38:03 +0530 | [diff] [blame] | 49 | u32 (*get_secondary_status)(unsigned int bank); |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 50 | void (*set_ioforce)(bool enable); |
Rabin Vincent | c0fcb8d | 2010-03-03 04:48:54 +0100 | [diff] [blame] | 51 | spinlock_t lock; |
Linus Walleij | 33d7864 | 2011-06-09 11:08:47 +0200 | [diff] [blame] | 52 | bool sleepmode; |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 53 | /* Keep track of configured edges */ |
| 54 | u32 edge_rising; |
| 55 | u32 edge_falling; |
Rabin Vincent | b9df468 | 2011-02-10 11:45:58 +0530 | [diff] [blame] | 56 | u32 real_wake; |
| 57 | u32 rwimsc; |
| 58 | u32 fwimsc; |
Rabin Vincent | 6c12fe8 | 2011-05-23 12:13:33 +0530 | [diff] [blame] | 59 | u32 rimsc; |
| 60 | u32 fimsc; |
Rickard Andersson | bc6f5cf | 2011-05-24 23:07:17 +0200 | [diff] [blame] | 61 | u32 pull_up; |
Rabin Vincent | ebc6178 | 2011-09-28 15:49:11 +0530 | [diff] [blame] | 62 | u32 lowemi; |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 63 | }; |
| 64 | |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 65 | static struct nmk_gpio_chip * |
| 66 | nmk_gpio_chips[DIV_ROUND_UP(ARCH_NR_GPIOS, NMK_GPIO_PER_CHIP)]; |
| 67 | |
| 68 | static DEFINE_SPINLOCK(nmk_gpio_slpm_lock); |
| 69 | |
| 70 | #define NUM_BANKS ARRAY_SIZE(nmk_gpio_chips) |
| 71 | |
Rabin Vincent | 6f9a974 | 2010-06-02 05:50:28 +0100 | [diff] [blame] | 72 | static void __nmk_gpio_set_mode(struct nmk_gpio_chip *nmk_chip, |
| 73 | unsigned offset, int gpio_mode) |
| 74 | { |
| 75 | u32 bit = 1 << offset; |
| 76 | u32 afunc, bfunc; |
| 77 | |
| 78 | afunc = readl(nmk_chip->addr + NMK_GPIO_AFSLA) & ~bit; |
| 79 | bfunc = readl(nmk_chip->addr + NMK_GPIO_AFSLB) & ~bit; |
| 80 | if (gpio_mode & NMK_GPIO_ALT_A) |
| 81 | afunc |= bit; |
| 82 | if (gpio_mode & NMK_GPIO_ALT_B) |
| 83 | bfunc |= bit; |
| 84 | writel(afunc, nmk_chip->addr + NMK_GPIO_AFSLA); |
| 85 | writel(bfunc, nmk_chip->addr + NMK_GPIO_AFSLB); |
| 86 | } |
| 87 | |
Rabin Vincent | 81a3c29 | 2010-05-27 12:39:23 +0100 | [diff] [blame] | 88 | static void __nmk_gpio_set_slpm(struct nmk_gpio_chip *nmk_chip, |
| 89 | unsigned offset, enum nmk_gpio_slpm mode) |
| 90 | { |
| 91 | u32 bit = 1 << offset; |
| 92 | u32 slpm; |
| 93 | |
| 94 | slpm = readl(nmk_chip->addr + NMK_GPIO_SLPC); |
| 95 | if (mode == NMK_GPIO_SLPM_NOCHANGE) |
| 96 | slpm |= bit; |
| 97 | else |
| 98 | slpm &= ~bit; |
| 99 | writel(slpm, nmk_chip->addr + NMK_GPIO_SLPC); |
| 100 | } |
| 101 | |
Rabin Vincent | 5b327ed | 2010-05-27 12:29:50 +0100 | [diff] [blame] | 102 | static void __nmk_gpio_set_pull(struct nmk_gpio_chip *nmk_chip, |
| 103 | unsigned offset, enum nmk_gpio_pull pull) |
| 104 | { |
| 105 | u32 bit = 1 << offset; |
| 106 | u32 pdis; |
| 107 | |
| 108 | pdis = readl(nmk_chip->addr + NMK_GPIO_PDIS); |
Rickard Andersson | bc6f5cf | 2011-05-24 23:07:17 +0200 | [diff] [blame] | 109 | if (pull == NMK_GPIO_PULL_NONE) { |
Rabin Vincent | 5b327ed | 2010-05-27 12:29:50 +0100 | [diff] [blame] | 110 | pdis |= bit; |
Rickard Andersson | bc6f5cf | 2011-05-24 23:07:17 +0200 | [diff] [blame] | 111 | nmk_chip->pull_up &= ~bit; |
| 112 | } else { |
Rabin Vincent | 5b327ed | 2010-05-27 12:29:50 +0100 | [diff] [blame] | 113 | pdis &= ~bit; |
Rickard Andersson | bc6f5cf | 2011-05-24 23:07:17 +0200 | [diff] [blame] | 114 | } |
| 115 | |
Rabin Vincent | 5b327ed | 2010-05-27 12:29:50 +0100 | [diff] [blame] | 116 | writel(pdis, nmk_chip->addr + NMK_GPIO_PDIS); |
| 117 | |
Rickard Andersson | bc6f5cf | 2011-05-24 23:07:17 +0200 | [diff] [blame] | 118 | if (pull == NMK_GPIO_PULL_UP) { |
| 119 | nmk_chip->pull_up |= bit; |
Rabin Vincent | 5b327ed | 2010-05-27 12:29:50 +0100 | [diff] [blame] | 120 | writel(bit, nmk_chip->addr + NMK_GPIO_DATS); |
Rickard Andersson | bc6f5cf | 2011-05-24 23:07:17 +0200 | [diff] [blame] | 121 | } else if (pull == NMK_GPIO_PULL_DOWN) { |
| 122 | nmk_chip->pull_up &= ~bit; |
Rabin Vincent | 5b327ed | 2010-05-27 12:29:50 +0100 | [diff] [blame] | 123 | writel(bit, nmk_chip->addr + NMK_GPIO_DATC); |
Rickard Andersson | bc6f5cf | 2011-05-24 23:07:17 +0200 | [diff] [blame] | 124 | } |
Rabin Vincent | 5b327ed | 2010-05-27 12:29:50 +0100 | [diff] [blame] | 125 | } |
| 126 | |
Rabin Vincent | ebc6178 | 2011-09-28 15:49:11 +0530 | [diff] [blame] | 127 | static void __nmk_gpio_set_lowemi(struct nmk_gpio_chip *nmk_chip, |
| 128 | unsigned offset, bool lowemi) |
| 129 | { |
| 130 | u32 bit = BIT(offset); |
| 131 | bool enabled = nmk_chip->lowemi & bit; |
| 132 | |
| 133 | if (lowemi == enabled) |
| 134 | return; |
| 135 | |
| 136 | if (lowemi) |
| 137 | nmk_chip->lowemi |= bit; |
| 138 | else |
| 139 | nmk_chip->lowemi &= ~bit; |
| 140 | |
| 141 | writel_relaxed(nmk_chip->lowemi, |
| 142 | nmk_chip->addr + NMK_GPIO_LOWEMI); |
| 143 | } |
| 144 | |
Rabin Vincent | 378be06 | 2010-06-02 06:06:29 +0100 | [diff] [blame] | 145 | static void __nmk_gpio_make_input(struct nmk_gpio_chip *nmk_chip, |
| 146 | unsigned offset) |
| 147 | { |
| 148 | writel(1 << offset, nmk_chip->addr + NMK_GPIO_DIRC); |
| 149 | } |
| 150 | |
Rabin Vincent | 6720db7 | 2010-09-02 11:28:48 +0100 | [diff] [blame] | 151 | static void __nmk_gpio_set_output(struct nmk_gpio_chip *nmk_chip, |
| 152 | unsigned offset, int val) |
| 153 | { |
| 154 | if (val) |
| 155 | writel(1 << offset, nmk_chip->addr + NMK_GPIO_DATS); |
| 156 | else |
| 157 | writel(1 << offset, nmk_chip->addr + NMK_GPIO_DATC); |
| 158 | } |
| 159 | |
| 160 | static void __nmk_gpio_make_output(struct nmk_gpio_chip *nmk_chip, |
| 161 | unsigned offset, int val) |
| 162 | { |
| 163 | writel(1 << offset, nmk_chip->addr + NMK_GPIO_DIRS); |
| 164 | __nmk_gpio_set_output(nmk_chip, offset, val); |
| 165 | } |
| 166 | |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 167 | static void __nmk_gpio_set_mode_safe(struct nmk_gpio_chip *nmk_chip, |
| 168 | unsigned offset, int gpio_mode, |
| 169 | bool glitch) |
| 170 | { |
Rabin Vincent | 6c12fe8 | 2011-05-23 12:13:33 +0530 | [diff] [blame] | 171 | u32 rwimsc = nmk_chip->rwimsc; |
| 172 | u32 fwimsc = nmk_chip->fwimsc; |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 173 | |
| 174 | if (glitch && nmk_chip->set_ioforce) { |
| 175 | u32 bit = BIT(offset); |
| 176 | |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 177 | /* Prevent spurious wakeups */ |
| 178 | writel(rwimsc & ~bit, nmk_chip->addr + NMK_GPIO_RWIMSC); |
| 179 | writel(fwimsc & ~bit, nmk_chip->addr + NMK_GPIO_FWIMSC); |
| 180 | |
| 181 | nmk_chip->set_ioforce(true); |
| 182 | } |
| 183 | |
| 184 | __nmk_gpio_set_mode(nmk_chip, offset, gpio_mode); |
| 185 | |
| 186 | if (glitch && nmk_chip->set_ioforce) { |
| 187 | nmk_chip->set_ioforce(false); |
| 188 | |
| 189 | writel(rwimsc, nmk_chip->addr + NMK_GPIO_RWIMSC); |
| 190 | writel(fwimsc, nmk_chip->addr + NMK_GPIO_FWIMSC); |
| 191 | } |
| 192 | } |
| 193 | |
Rabin Vincent | 6c42ad1 | 2011-05-23 12:22:18 +0530 | [diff] [blame] | 194 | static void |
| 195 | nmk_gpio_disable_lazy_irq(struct nmk_gpio_chip *nmk_chip, unsigned offset) |
| 196 | { |
| 197 | u32 falling = nmk_chip->fimsc & BIT(offset); |
| 198 | u32 rising = nmk_chip->rimsc & BIT(offset); |
| 199 | int gpio = nmk_chip->chip.base + offset; |
| 200 | int irq = NOMADIK_GPIO_TO_IRQ(gpio); |
| 201 | struct irq_data *d = irq_get_irq_data(irq); |
| 202 | |
| 203 | if (!rising && !falling) |
| 204 | return; |
| 205 | |
| 206 | if (!d || !irqd_irq_disabled(d)) |
| 207 | return; |
| 208 | |
| 209 | if (rising) { |
| 210 | nmk_chip->rimsc &= ~BIT(offset); |
| 211 | writel_relaxed(nmk_chip->rimsc, |
| 212 | nmk_chip->addr + NMK_GPIO_RIMSC); |
| 213 | } |
| 214 | |
| 215 | if (falling) { |
| 216 | nmk_chip->fimsc &= ~BIT(offset); |
| 217 | writel_relaxed(nmk_chip->fimsc, |
| 218 | nmk_chip->addr + NMK_GPIO_FIMSC); |
| 219 | } |
| 220 | |
| 221 | dev_dbg(nmk_chip->chip.dev, "%d: clearing interrupt mask\n", gpio); |
| 222 | } |
| 223 | |
Rabin Vincent | 378be06 | 2010-06-02 06:06:29 +0100 | [diff] [blame] | 224 | static void __nmk_config_pin(struct nmk_gpio_chip *nmk_chip, unsigned offset, |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 225 | pin_cfg_t cfg, bool sleep, unsigned int *slpmregs) |
Rabin Vincent | 378be06 | 2010-06-02 06:06:29 +0100 | [diff] [blame] | 226 | { |
| 227 | static const char *afnames[] = { |
| 228 | [NMK_GPIO_ALT_GPIO] = "GPIO", |
| 229 | [NMK_GPIO_ALT_A] = "A", |
| 230 | [NMK_GPIO_ALT_B] = "B", |
| 231 | [NMK_GPIO_ALT_C] = "C" |
| 232 | }; |
| 233 | static const char *pullnames[] = { |
| 234 | [NMK_GPIO_PULL_NONE] = "none", |
| 235 | [NMK_GPIO_PULL_UP] = "up", |
| 236 | [NMK_GPIO_PULL_DOWN] = "down", |
| 237 | [3] /* illegal */ = "??" |
| 238 | }; |
| 239 | static const char *slpmnames[] = { |
Rabin Vincent | 7e3f7e5 | 2010-09-02 11:28:05 +0100 | [diff] [blame] | 240 | [NMK_GPIO_SLPM_INPUT] = "input/wakeup", |
| 241 | [NMK_GPIO_SLPM_NOCHANGE] = "no-change/no-wakeup", |
Rabin Vincent | 378be06 | 2010-06-02 06:06:29 +0100 | [diff] [blame] | 242 | }; |
| 243 | |
| 244 | int pin = PIN_NUM(cfg); |
| 245 | int pull = PIN_PULL(cfg); |
| 246 | int af = PIN_ALT(cfg); |
| 247 | int slpm = PIN_SLPM(cfg); |
Rabin Vincent | 6720db7 | 2010-09-02 11:28:48 +0100 | [diff] [blame] | 248 | int output = PIN_DIR(cfg); |
| 249 | int val = PIN_VAL(cfg); |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 250 | bool glitch = af == NMK_GPIO_ALT_C; |
Rabin Vincent | 378be06 | 2010-06-02 06:06:29 +0100 | [diff] [blame] | 251 | |
Rabin Vincent | dacdc96 | 2010-12-03 20:35:37 +0530 | [diff] [blame] | 252 | dev_dbg(nmk_chip->chip.dev, "pin %d [%#lx]: af %s, pull %s, slpm %s (%s%s)\n", |
| 253 | pin, cfg, afnames[af], pullnames[pull], slpmnames[slpm], |
Rabin Vincent | 6720db7 | 2010-09-02 11:28:48 +0100 | [diff] [blame] | 254 | output ? "output " : "input", |
| 255 | output ? (val ? "high" : "low") : ""); |
Rabin Vincent | 378be06 | 2010-06-02 06:06:29 +0100 | [diff] [blame] | 256 | |
Rabin Vincent | dacdc96 | 2010-12-03 20:35:37 +0530 | [diff] [blame] | 257 | if (sleep) { |
| 258 | int slpm_pull = PIN_SLPM_PULL(cfg); |
| 259 | int slpm_output = PIN_SLPM_DIR(cfg); |
| 260 | int slpm_val = PIN_SLPM_VAL(cfg); |
| 261 | |
Rabin Vincent | 3546d15 | 2010-11-25 11:38:27 +0530 | [diff] [blame] | 262 | af = NMK_GPIO_ALT_GPIO; |
| 263 | |
Rabin Vincent | dacdc96 | 2010-12-03 20:35:37 +0530 | [diff] [blame] | 264 | /* |
| 265 | * The SLPM_* values are normal values + 1 to allow zero to |
| 266 | * mean "same as normal". |
| 267 | */ |
| 268 | if (slpm_pull) |
| 269 | pull = slpm_pull - 1; |
| 270 | if (slpm_output) |
| 271 | output = slpm_output - 1; |
| 272 | if (slpm_val) |
| 273 | val = slpm_val - 1; |
| 274 | |
| 275 | dev_dbg(nmk_chip->chip.dev, "pin %d: sleep pull %s, dir %s, val %s\n", |
| 276 | pin, |
| 277 | slpm_pull ? pullnames[pull] : "same", |
| 278 | slpm_output ? (output ? "output" : "input") : "same", |
| 279 | slpm_val ? (val ? "high" : "low") : "same"); |
| 280 | } |
| 281 | |
Rabin Vincent | 6720db7 | 2010-09-02 11:28:48 +0100 | [diff] [blame] | 282 | if (output) |
| 283 | __nmk_gpio_make_output(nmk_chip, offset, val); |
| 284 | else { |
| 285 | __nmk_gpio_make_input(nmk_chip, offset); |
| 286 | __nmk_gpio_set_pull(nmk_chip, offset, pull); |
| 287 | } |
| 288 | |
Rabin Vincent | ebc6178 | 2011-09-28 15:49:11 +0530 | [diff] [blame] | 289 | __nmk_gpio_set_lowemi(nmk_chip, offset, PIN_LOWEMI(cfg)); |
| 290 | |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 291 | /* |
Rabin Vincent | 6c42ad1 | 2011-05-23 12:22:18 +0530 | [diff] [blame] | 292 | * If the pin is switching to altfunc, and there was an interrupt |
| 293 | * installed on it which has been lazy disabled, actually mask the |
| 294 | * interrupt to prevent spurious interrupts that would occur while the |
| 295 | * pin is under control of the peripheral. Only SKE does this. |
| 296 | */ |
| 297 | if (af != NMK_GPIO_ALT_GPIO) |
| 298 | nmk_gpio_disable_lazy_irq(nmk_chip, offset); |
| 299 | |
| 300 | /* |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 301 | * If we've backed up the SLPM registers (glitch workaround), modify |
| 302 | * the backups since they will be restored. |
| 303 | */ |
| 304 | if (slpmregs) { |
| 305 | if (slpm == NMK_GPIO_SLPM_NOCHANGE) |
| 306 | slpmregs[nmk_chip->bank] |= BIT(offset); |
| 307 | else |
| 308 | slpmregs[nmk_chip->bank] &= ~BIT(offset); |
| 309 | } else |
| 310 | __nmk_gpio_set_slpm(nmk_chip, offset, slpm); |
| 311 | |
| 312 | __nmk_gpio_set_mode_safe(nmk_chip, offset, af, glitch); |
| 313 | } |
| 314 | |
| 315 | /* |
| 316 | * Safe sequence used to switch IOs between GPIO and Alternate-C mode: |
| 317 | * - Save SLPM registers |
| 318 | * - Set SLPM=0 for the IOs you want to switch and others to 1 |
| 319 | * - Configure the GPIO registers for the IOs that are being switched |
| 320 | * - Set IOFORCE=1 |
| 321 | * - Modify the AFLSA/B registers for the IOs that are being switched |
| 322 | * - Set IOFORCE=0 |
| 323 | * - Restore SLPM registers |
| 324 | * - Any spurious wake up event during switch sequence to be ignored and |
| 325 | * cleared |
| 326 | */ |
| 327 | static void nmk_gpio_glitch_slpm_init(unsigned int *slpm) |
| 328 | { |
| 329 | int i; |
| 330 | |
| 331 | for (i = 0; i < NUM_BANKS; i++) { |
| 332 | struct nmk_gpio_chip *chip = nmk_gpio_chips[i]; |
| 333 | unsigned int temp = slpm[i]; |
| 334 | |
| 335 | if (!chip) |
| 336 | break; |
| 337 | |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 338 | clk_enable(chip->clk); |
| 339 | |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 340 | slpm[i] = readl(chip->addr + NMK_GPIO_SLPC); |
| 341 | writel(temp, chip->addr + NMK_GPIO_SLPC); |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | static void nmk_gpio_glitch_slpm_restore(unsigned int *slpm) |
| 346 | { |
| 347 | int i; |
| 348 | |
| 349 | for (i = 0; i < NUM_BANKS; i++) { |
| 350 | struct nmk_gpio_chip *chip = nmk_gpio_chips[i]; |
| 351 | |
| 352 | if (!chip) |
| 353 | break; |
| 354 | |
| 355 | writel(slpm[i], chip->addr + NMK_GPIO_SLPC); |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 356 | |
| 357 | clk_disable(chip->clk); |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 358 | } |
| 359 | } |
| 360 | |
| 361 | static int __nmk_config_pins(pin_cfg_t *cfgs, int num, bool sleep) |
| 362 | { |
| 363 | static unsigned int slpm[NUM_BANKS]; |
| 364 | unsigned long flags; |
| 365 | bool glitch = false; |
| 366 | int ret = 0; |
| 367 | int i; |
| 368 | |
| 369 | for (i = 0; i < num; i++) { |
| 370 | if (PIN_ALT(cfgs[i]) == NMK_GPIO_ALT_C) { |
| 371 | glitch = true; |
| 372 | break; |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | spin_lock_irqsave(&nmk_gpio_slpm_lock, flags); |
| 377 | |
| 378 | if (glitch) { |
| 379 | memset(slpm, 0xff, sizeof(slpm)); |
| 380 | |
| 381 | for (i = 0; i < num; i++) { |
| 382 | int pin = PIN_NUM(cfgs[i]); |
| 383 | int offset = pin % NMK_GPIO_PER_CHIP; |
| 384 | |
| 385 | if (PIN_ALT(cfgs[i]) == NMK_GPIO_ALT_C) |
| 386 | slpm[pin / NMK_GPIO_PER_CHIP] &= ~BIT(offset); |
| 387 | } |
| 388 | |
| 389 | nmk_gpio_glitch_slpm_init(slpm); |
| 390 | } |
| 391 | |
| 392 | for (i = 0; i < num; i++) { |
| 393 | struct nmk_gpio_chip *nmk_chip; |
| 394 | int pin = PIN_NUM(cfgs[i]); |
| 395 | |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 396 | nmk_chip = irq_get_chip_data(NOMADIK_GPIO_TO_IRQ(pin)); |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 397 | if (!nmk_chip) { |
| 398 | ret = -EINVAL; |
| 399 | break; |
| 400 | } |
| 401 | |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 402 | clk_enable(nmk_chip->clk); |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 403 | spin_lock(&nmk_chip->lock); |
| 404 | __nmk_config_pin(nmk_chip, pin - nmk_chip->chip.base, |
| 405 | cfgs[i], sleep, glitch ? slpm : NULL); |
| 406 | spin_unlock(&nmk_chip->lock); |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 407 | clk_disable(nmk_chip->clk); |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | if (glitch) |
| 411 | nmk_gpio_glitch_slpm_restore(slpm); |
| 412 | |
| 413 | spin_unlock_irqrestore(&nmk_gpio_slpm_lock, flags); |
| 414 | |
| 415 | return ret; |
Rabin Vincent | 378be06 | 2010-06-02 06:06:29 +0100 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | /** |
| 419 | * nmk_config_pin - configure a pin's mux attributes |
| 420 | * @cfg: pin confguration |
| 421 | * |
| 422 | * Configures a pin's mode (alternate function or GPIO), its pull up status, |
| 423 | * and its sleep mode based on the specified configuration. The @cfg is |
| 424 | * usually one of the SoC specific macros defined in mach/<soc>-pins.h. These |
| 425 | * are constructed using, and can be further enhanced with, the macros in |
| 426 | * plat/pincfg.h. |
| 427 | * |
| 428 | * If a pin's mode is set to GPIO, it is configured as an input to avoid |
| 429 | * side-effects. The gpio can be manipulated later using standard GPIO API |
| 430 | * calls. |
| 431 | */ |
Rabin Vincent | dacdc96 | 2010-12-03 20:35:37 +0530 | [diff] [blame] | 432 | int nmk_config_pin(pin_cfg_t cfg, bool sleep) |
Rabin Vincent | 378be06 | 2010-06-02 06:06:29 +0100 | [diff] [blame] | 433 | { |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 434 | return __nmk_config_pins(&cfg, 1, sleep); |
Rabin Vincent | 378be06 | 2010-06-02 06:06:29 +0100 | [diff] [blame] | 435 | } |
| 436 | EXPORT_SYMBOL(nmk_config_pin); |
| 437 | |
| 438 | /** |
| 439 | * nmk_config_pins - configure several pins at once |
| 440 | * @cfgs: array of pin configurations |
| 441 | * @num: number of elments in the array |
| 442 | * |
| 443 | * Configures several pins using nmk_config_pin(). Refer to that function for |
| 444 | * further information. |
| 445 | */ |
| 446 | int nmk_config_pins(pin_cfg_t *cfgs, int num) |
| 447 | { |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 448 | return __nmk_config_pins(cfgs, num, false); |
Rabin Vincent | 378be06 | 2010-06-02 06:06:29 +0100 | [diff] [blame] | 449 | } |
| 450 | EXPORT_SYMBOL(nmk_config_pins); |
| 451 | |
Rabin Vincent | dacdc96 | 2010-12-03 20:35:37 +0530 | [diff] [blame] | 452 | int nmk_config_pins_sleep(pin_cfg_t *cfgs, int num) |
| 453 | { |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 454 | return __nmk_config_pins(cfgs, num, true); |
Rabin Vincent | dacdc96 | 2010-12-03 20:35:37 +0530 | [diff] [blame] | 455 | } |
| 456 | EXPORT_SYMBOL(nmk_config_pins_sleep); |
| 457 | |
Rabin Vincent | 5b327ed | 2010-05-27 12:29:50 +0100 | [diff] [blame] | 458 | /** |
Rabin Vincent | 81a3c29 | 2010-05-27 12:39:23 +0100 | [diff] [blame] | 459 | * nmk_gpio_set_slpm() - configure the sleep mode of a pin |
| 460 | * @gpio: pin number |
| 461 | * @mode: NMK_GPIO_SLPM_INPUT or NMK_GPIO_SLPM_NOCHANGE, |
| 462 | * |
Linus Walleij | 33d7864 | 2011-06-09 11:08:47 +0200 | [diff] [blame] | 463 | * This register is actually in the pinmux layer, not the GPIO block itself. |
| 464 | * The GPIO1B_SLPM register defines the GPIO mode when SLEEP/DEEP-SLEEP |
| 465 | * mode is entered (i.e. when signal IOFORCE is HIGH by the platform code). |
| 466 | * Each GPIO can be configured to be forced into GPIO mode when IOFORCE is |
| 467 | * HIGH, overriding the normal setting defined by GPIO_AFSELx registers. |
| 468 | * When IOFORCE returns LOW (by software, after SLEEP/DEEP-SLEEP exit), |
| 469 | * the GPIOs return to the normal setting defined by GPIO_AFSELx registers. |
Rabin Vincent | 7e3f7e5 | 2010-09-02 11:28:05 +0100 | [diff] [blame] | 470 | * |
Linus Walleij | 33d7864 | 2011-06-09 11:08:47 +0200 | [diff] [blame] | 471 | * If @mode is NMK_GPIO_SLPM_INPUT, the corresponding GPIO is switched to GPIO |
| 472 | * mode when signal IOFORCE is HIGH (i.e. when SLEEP/DEEP-SLEEP mode is |
| 473 | * entered) regardless of the altfunction selected. Also wake-up detection is |
| 474 | * ENABLED. |
| 475 | * |
| 476 | * If @mode is NMK_GPIO_SLPM_NOCHANGE, the corresponding GPIO remains |
| 477 | * controlled by NMK_GPIO_DATC, NMK_GPIO_DATS, NMK_GPIO_DIR, NMK_GPIO_PDIS |
| 478 | * (for altfunction GPIO) or respective on-chip peripherals (for other |
| 479 | * altfuncs) when IOFORCE is HIGH. Also wake-up detection DISABLED. |
| 480 | * |
| 481 | * Note that enable_irq_wake() will automatically enable wakeup detection. |
Rabin Vincent | 81a3c29 | 2010-05-27 12:39:23 +0100 | [diff] [blame] | 482 | */ |
| 483 | int nmk_gpio_set_slpm(int gpio, enum nmk_gpio_slpm mode) |
| 484 | { |
| 485 | struct nmk_gpio_chip *nmk_chip; |
| 486 | unsigned long flags; |
| 487 | |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 488 | nmk_chip = irq_get_chip_data(NOMADIK_GPIO_TO_IRQ(gpio)); |
Rabin Vincent | 81a3c29 | 2010-05-27 12:39:23 +0100 | [diff] [blame] | 489 | if (!nmk_chip) |
| 490 | return -EINVAL; |
| 491 | |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 492 | clk_enable(nmk_chip->clk); |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 493 | spin_lock_irqsave(&nmk_gpio_slpm_lock, flags); |
| 494 | spin_lock(&nmk_chip->lock); |
| 495 | |
Rabin Vincent | 81a3c29 | 2010-05-27 12:39:23 +0100 | [diff] [blame] | 496 | __nmk_gpio_set_slpm(nmk_chip, gpio - nmk_chip->chip.base, mode); |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 497 | |
| 498 | spin_unlock(&nmk_chip->lock); |
| 499 | spin_unlock_irqrestore(&nmk_gpio_slpm_lock, flags); |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 500 | clk_disable(nmk_chip->clk); |
Rabin Vincent | 81a3c29 | 2010-05-27 12:39:23 +0100 | [diff] [blame] | 501 | |
| 502 | return 0; |
| 503 | } |
| 504 | |
| 505 | /** |
Rabin Vincent | 5b327ed | 2010-05-27 12:29:50 +0100 | [diff] [blame] | 506 | * nmk_gpio_set_pull() - enable/disable pull up/down on a gpio |
| 507 | * @gpio: pin number |
| 508 | * @pull: one of NMK_GPIO_PULL_DOWN, NMK_GPIO_PULL_UP, and NMK_GPIO_PULL_NONE |
| 509 | * |
| 510 | * Enables/disables pull up/down on a specified pin. This only takes effect if |
| 511 | * the pin is configured as an input (either explicitly or by the alternate |
| 512 | * function). |
| 513 | * |
| 514 | * NOTE: If enabling the pull up/down, the caller must ensure that the GPIO is |
| 515 | * configured as an input. Otherwise, due to the way the controller registers |
| 516 | * work, this function will change the value output on the pin. |
| 517 | */ |
| 518 | int nmk_gpio_set_pull(int gpio, enum nmk_gpio_pull pull) |
| 519 | { |
| 520 | struct nmk_gpio_chip *nmk_chip; |
| 521 | unsigned long flags; |
| 522 | |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 523 | nmk_chip = irq_get_chip_data(NOMADIK_GPIO_TO_IRQ(gpio)); |
Rabin Vincent | 5b327ed | 2010-05-27 12:29:50 +0100 | [diff] [blame] | 524 | if (!nmk_chip) |
| 525 | return -EINVAL; |
| 526 | |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 527 | clk_enable(nmk_chip->clk); |
Rabin Vincent | 5b327ed | 2010-05-27 12:29:50 +0100 | [diff] [blame] | 528 | spin_lock_irqsave(&nmk_chip->lock, flags); |
| 529 | __nmk_gpio_set_pull(nmk_chip, gpio - nmk_chip->chip.base, pull); |
| 530 | spin_unlock_irqrestore(&nmk_chip->lock, flags); |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 531 | clk_disable(nmk_chip->clk); |
Rabin Vincent | 5b327ed | 2010-05-27 12:29:50 +0100 | [diff] [blame] | 532 | |
| 533 | return 0; |
| 534 | } |
| 535 | |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 536 | /* Mode functions */ |
Jonas Aaberg | 9c66ee6 | 2010-10-13 13:14:17 +0200 | [diff] [blame] | 537 | /** |
| 538 | * nmk_gpio_set_mode() - set the mux mode of a gpio pin |
| 539 | * @gpio: pin number |
| 540 | * @gpio_mode: one of NMK_GPIO_ALT_GPIO, NMK_GPIO_ALT_A, |
| 541 | * NMK_GPIO_ALT_B, and NMK_GPIO_ALT_C |
| 542 | * |
| 543 | * Sets the mode of the specified pin to one of the alternate functions or |
| 544 | * plain GPIO. |
| 545 | */ |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 546 | int nmk_gpio_set_mode(int gpio, int gpio_mode) |
| 547 | { |
| 548 | struct nmk_gpio_chip *nmk_chip; |
| 549 | unsigned long flags; |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 550 | |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 551 | nmk_chip = irq_get_chip_data(NOMADIK_GPIO_TO_IRQ(gpio)); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 552 | if (!nmk_chip) |
| 553 | return -EINVAL; |
| 554 | |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 555 | clk_enable(nmk_chip->clk); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 556 | spin_lock_irqsave(&nmk_chip->lock, flags); |
Rabin Vincent | 6f9a974 | 2010-06-02 05:50:28 +0100 | [diff] [blame] | 557 | __nmk_gpio_set_mode(nmk_chip, gpio - nmk_chip->chip.base, gpio_mode); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 558 | spin_unlock_irqrestore(&nmk_chip->lock, flags); |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 559 | clk_disable(nmk_chip->clk); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 560 | |
| 561 | return 0; |
| 562 | } |
| 563 | EXPORT_SYMBOL(nmk_gpio_set_mode); |
| 564 | |
| 565 | int nmk_gpio_get_mode(int gpio) |
| 566 | { |
| 567 | struct nmk_gpio_chip *nmk_chip; |
| 568 | u32 afunc, bfunc, bit; |
| 569 | |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 570 | nmk_chip = irq_get_chip_data(NOMADIK_GPIO_TO_IRQ(gpio)); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 571 | if (!nmk_chip) |
| 572 | return -EINVAL; |
| 573 | |
| 574 | bit = 1 << (gpio - nmk_chip->chip.base); |
| 575 | |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 576 | clk_enable(nmk_chip->clk); |
| 577 | |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 578 | afunc = readl(nmk_chip->addr + NMK_GPIO_AFSLA) & bit; |
| 579 | bfunc = readl(nmk_chip->addr + NMK_GPIO_AFSLB) & bit; |
| 580 | |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 581 | clk_disable(nmk_chip->clk); |
| 582 | |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 583 | return (afunc ? NMK_GPIO_ALT_A : 0) | (bfunc ? NMK_GPIO_ALT_B : 0); |
| 584 | } |
| 585 | EXPORT_SYMBOL(nmk_gpio_get_mode); |
| 586 | |
| 587 | |
| 588 | /* IRQ functions */ |
| 589 | static inline int nmk_gpio_get_bitmask(int gpio) |
| 590 | { |
| 591 | return 1 << (gpio % 32); |
| 592 | } |
| 593 | |
Lennert Buytenhek | f272c00 | 2010-11-29 11:16:48 +0100 | [diff] [blame] | 594 | static void nmk_gpio_irq_ack(struct irq_data *d) |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 595 | { |
| 596 | int gpio; |
| 597 | struct nmk_gpio_chip *nmk_chip; |
| 598 | |
Lennert Buytenhek | f272c00 | 2010-11-29 11:16:48 +0100 | [diff] [blame] | 599 | gpio = NOMADIK_IRQ_TO_GPIO(d->irq); |
| 600 | nmk_chip = irq_data_get_irq_chip_data(d); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 601 | if (!nmk_chip) |
| 602 | return; |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 603 | |
| 604 | clk_enable(nmk_chip->clk); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 605 | writel(nmk_gpio_get_bitmask(gpio), nmk_chip->addr + NMK_GPIO_IC); |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 606 | clk_disable(nmk_chip->clk); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 607 | } |
| 608 | |
Rabin Vincent | 4d4e20f | 2010-06-16 06:09:34 +0100 | [diff] [blame] | 609 | enum nmk_gpio_irq_type { |
| 610 | NORMAL, |
| 611 | WAKE, |
| 612 | }; |
| 613 | |
Rabin Vincent | 040e5ec | 2010-05-06 10:42:42 +0100 | [diff] [blame] | 614 | static void __nmk_gpio_irq_modify(struct nmk_gpio_chip *nmk_chip, |
Rabin Vincent | 4d4e20f | 2010-06-16 06:09:34 +0100 | [diff] [blame] | 615 | int gpio, enum nmk_gpio_irq_type which, |
| 616 | bool enable) |
Rabin Vincent | 040e5ec | 2010-05-06 10:42:42 +0100 | [diff] [blame] | 617 | { |
| 618 | u32 bitmask = nmk_gpio_get_bitmask(gpio); |
Rabin Vincent | 6c12fe8 | 2011-05-23 12:13:33 +0530 | [diff] [blame] | 619 | u32 *rimscval; |
| 620 | u32 *fimscval; |
| 621 | u32 rimscreg; |
| 622 | u32 fimscreg; |
| 623 | |
| 624 | if (which == NORMAL) { |
| 625 | rimscreg = NMK_GPIO_RIMSC; |
| 626 | fimscreg = NMK_GPIO_FIMSC; |
| 627 | rimscval = &nmk_chip->rimsc; |
| 628 | fimscval = &nmk_chip->fimsc; |
| 629 | } else { |
| 630 | rimscreg = NMK_GPIO_RWIMSC; |
| 631 | fimscreg = NMK_GPIO_FWIMSC; |
| 632 | rimscval = &nmk_chip->rwimsc; |
| 633 | fimscval = &nmk_chip->fwimsc; |
| 634 | } |
Rabin Vincent | 040e5ec | 2010-05-06 10:42:42 +0100 | [diff] [blame] | 635 | |
| 636 | /* we must individually set/clear the two edges */ |
| 637 | if (nmk_chip->edge_rising & bitmask) { |
Rabin Vincent | 040e5ec | 2010-05-06 10:42:42 +0100 | [diff] [blame] | 638 | if (enable) |
Rabin Vincent | 6c12fe8 | 2011-05-23 12:13:33 +0530 | [diff] [blame] | 639 | *rimscval |= bitmask; |
Rabin Vincent | 040e5ec | 2010-05-06 10:42:42 +0100 | [diff] [blame] | 640 | else |
Rabin Vincent | 6c12fe8 | 2011-05-23 12:13:33 +0530 | [diff] [blame] | 641 | *rimscval &= ~bitmask; |
| 642 | writel(*rimscval, nmk_chip->addr + rimscreg); |
Rabin Vincent | 040e5ec | 2010-05-06 10:42:42 +0100 | [diff] [blame] | 643 | } |
| 644 | if (nmk_chip->edge_falling & bitmask) { |
Rabin Vincent | 040e5ec | 2010-05-06 10:42:42 +0100 | [diff] [blame] | 645 | if (enable) |
Rabin Vincent | 6c12fe8 | 2011-05-23 12:13:33 +0530 | [diff] [blame] | 646 | *fimscval |= bitmask; |
Rabin Vincent | 040e5ec | 2010-05-06 10:42:42 +0100 | [diff] [blame] | 647 | else |
Rabin Vincent | 6c12fe8 | 2011-05-23 12:13:33 +0530 | [diff] [blame] | 648 | *fimscval &= ~bitmask; |
| 649 | writel(*fimscval, nmk_chip->addr + fimscreg); |
Rabin Vincent | 040e5ec | 2010-05-06 10:42:42 +0100 | [diff] [blame] | 650 | } |
| 651 | } |
| 652 | |
Rabin Vincent | b9df468 | 2011-02-10 11:45:58 +0530 | [diff] [blame] | 653 | static void __nmk_gpio_set_wake(struct nmk_gpio_chip *nmk_chip, |
| 654 | int gpio, bool on) |
| 655 | { |
Rabin Vincent | b982ff0 | 2011-04-26 09:03:27 +0530 | [diff] [blame] | 656 | /* |
| 657 | * Ensure WAKEUP_ENABLE is on. No need to disable it if wakeup is |
| 658 | * disabled, since setting SLPM to 1 increases power consumption, and |
| 659 | * wakeup is anyhow controlled by the RIMSC and FIMSC registers. |
| 660 | */ |
| 661 | if (nmk_chip->sleepmode && on) { |
Linus Walleij | 33d7864 | 2011-06-09 11:08:47 +0200 | [diff] [blame] | 662 | __nmk_gpio_set_slpm(nmk_chip, gpio - nmk_chip->chip.base, |
Rabin Vincent | b982ff0 | 2011-04-26 09:03:27 +0530 | [diff] [blame] | 663 | NMK_GPIO_SLPM_WAKEUP_ENABLE); |
Linus Walleij | 33d7864 | 2011-06-09 11:08:47 +0200 | [diff] [blame] | 664 | } |
| 665 | |
Rabin Vincent | b9df468 | 2011-02-10 11:45:58 +0530 | [diff] [blame] | 666 | __nmk_gpio_irq_modify(nmk_chip, gpio, WAKE, on); |
| 667 | } |
| 668 | |
| 669 | static int nmk_gpio_irq_maskunmask(struct irq_data *d, bool enable) |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 670 | { |
| 671 | int gpio; |
| 672 | struct nmk_gpio_chip *nmk_chip; |
| 673 | unsigned long flags; |
Rabin Vincent | 040e5ec | 2010-05-06 10:42:42 +0100 | [diff] [blame] | 674 | u32 bitmask; |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 675 | |
Lennert Buytenhek | f272c00 | 2010-11-29 11:16:48 +0100 | [diff] [blame] | 676 | gpio = NOMADIK_IRQ_TO_GPIO(d->irq); |
| 677 | nmk_chip = irq_data_get_irq_chip_data(d); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 678 | bitmask = nmk_gpio_get_bitmask(gpio); |
| 679 | if (!nmk_chip) |
Rabin Vincent | 4d4e20f | 2010-06-16 06:09:34 +0100 | [diff] [blame] | 680 | return -EINVAL; |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 681 | |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 682 | clk_enable(nmk_chip->clk); |
Rabin Vincent | b9df468 | 2011-02-10 11:45:58 +0530 | [diff] [blame] | 683 | spin_lock_irqsave(&nmk_gpio_slpm_lock, flags); |
| 684 | spin_lock(&nmk_chip->lock); |
| 685 | |
| 686 | __nmk_gpio_irq_modify(nmk_chip, gpio, NORMAL, enable); |
| 687 | |
| 688 | if (!(nmk_chip->real_wake & bitmask)) |
| 689 | __nmk_gpio_set_wake(nmk_chip, gpio, enable); |
| 690 | |
| 691 | spin_unlock(&nmk_chip->lock); |
| 692 | spin_unlock_irqrestore(&nmk_gpio_slpm_lock, flags); |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 693 | clk_disable(nmk_chip->clk); |
Rabin Vincent | 4d4e20f | 2010-06-16 06:09:34 +0100 | [diff] [blame] | 694 | |
| 695 | return 0; |
Rabin Vincent | 040e5ec | 2010-05-06 10:42:42 +0100 | [diff] [blame] | 696 | } |
| 697 | |
Lennert Buytenhek | f272c00 | 2010-11-29 11:16:48 +0100 | [diff] [blame] | 698 | static void nmk_gpio_irq_mask(struct irq_data *d) |
Rabin Vincent | 040e5ec | 2010-05-06 10:42:42 +0100 | [diff] [blame] | 699 | { |
Rabin Vincent | b9df468 | 2011-02-10 11:45:58 +0530 | [diff] [blame] | 700 | nmk_gpio_irq_maskunmask(d, false); |
Rabin Vincent | 4d4e20f | 2010-06-16 06:09:34 +0100 | [diff] [blame] | 701 | } |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 702 | |
Lennert Buytenhek | f272c00 | 2010-11-29 11:16:48 +0100 | [diff] [blame] | 703 | static void nmk_gpio_irq_unmask(struct irq_data *d) |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 704 | { |
Rabin Vincent | b9df468 | 2011-02-10 11:45:58 +0530 | [diff] [blame] | 705 | nmk_gpio_irq_maskunmask(d, true); |
Rabin Vincent | 4d4e20f | 2010-06-16 06:09:34 +0100 | [diff] [blame] | 706 | } |
| 707 | |
Lennert Buytenhek | f272c00 | 2010-11-29 11:16:48 +0100 | [diff] [blame] | 708 | static int nmk_gpio_irq_set_wake(struct irq_data *d, unsigned int on) |
Rabin Vincent | 4d4e20f | 2010-06-16 06:09:34 +0100 | [diff] [blame] | 709 | { |
Rabin Vincent | 7e3f7e5 | 2010-09-02 11:28:05 +0100 | [diff] [blame] | 710 | struct nmk_gpio_chip *nmk_chip; |
| 711 | unsigned long flags; |
Rabin Vincent | b9df468 | 2011-02-10 11:45:58 +0530 | [diff] [blame] | 712 | u32 bitmask; |
Rabin Vincent | 7e3f7e5 | 2010-09-02 11:28:05 +0100 | [diff] [blame] | 713 | int gpio; |
| 714 | |
Lennert Buytenhek | f272c00 | 2010-11-29 11:16:48 +0100 | [diff] [blame] | 715 | gpio = NOMADIK_IRQ_TO_GPIO(d->irq); |
| 716 | nmk_chip = irq_data_get_irq_chip_data(d); |
Rabin Vincent | 7e3f7e5 | 2010-09-02 11:28:05 +0100 | [diff] [blame] | 717 | if (!nmk_chip) |
| 718 | return -EINVAL; |
Rabin Vincent | b9df468 | 2011-02-10 11:45:58 +0530 | [diff] [blame] | 719 | bitmask = nmk_gpio_get_bitmask(gpio); |
Rabin Vincent | 7e3f7e5 | 2010-09-02 11:28:05 +0100 | [diff] [blame] | 720 | |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 721 | clk_enable(nmk_chip->clk); |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 722 | spin_lock_irqsave(&nmk_gpio_slpm_lock, flags); |
| 723 | spin_lock(&nmk_chip->lock); |
| 724 | |
Linus Walleij | 479a0c7 | 2011-09-20 10:50:15 +0200 | [diff] [blame] | 725 | if (irqd_irq_disabled(d)) |
Rabin Vincent | b9df468 | 2011-02-10 11:45:58 +0530 | [diff] [blame] | 726 | __nmk_gpio_set_wake(nmk_chip, gpio, on); |
| 727 | |
| 728 | if (on) |
| 729 | nmk_chip->real_wake |= bitmask; |
| 730 | else |
| 731 | nmk_chip->real_wake &= ~bitmask; |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 732 | |
| 733 | spin_unlock(&nmk_chip->lock); |
| 734 | spin_unlock_irqrestore(&nmk_gpio_slpm_lock, flags); |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 735 | clk_disable(nmk_chip->clk); |
Rabin Vincent | 7e3f7e5 | 2010-09-02 11:28:05 +0100 | [diff] [blame] | 736 | |
| 737 | return 0; |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 738 | } |
| 739 | |
Lennert Buytenhek | f272c00 | 2010-11-29 11:16:48 +0100 | [diff] [blame] | 740 | static int nmk_gpio_irq_set_type(struct irq_data *d, unsigned int type) |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 741 | { |
Linus Walleij | 479a0c7 | 2011-09-20 10:50:15 +0200 | [diff] [blame] | 742 | bool enabled = !irqd_irq_disabled(d); |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 743 | bool wake = irqd_is_wakeup_set(d); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 744 | int gpio; |
| 745 | struct nmk_gpio_chip *nmk_chip; |
| 746 | unsigned long flags; |
| 747 | u32 bitmask; |
| 748 | |
Lennert Buytenhek | f272c00 | 2010-11-29 11:16:48 +0100 | [diff] [blame] | 749 | gpio = NOMADIK_IRQ_TO_GPIO(d->irq); |
| 750 | nmk_chip = irq_data_get_irq_chip_data(d); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 751 | bitmask = nmk_gpio_get_bitmask(gpio); |
| 752 | if (!nmk_chip) |
| 753 | return -EINVAL; |
| 754 | |
| 755 | if (type & IRQ_TYPE_LEVEL_HIGH) |
| 756 | return -EINVAL; |
| 757 | if (type & IRQ_TYPE_LEVEL_LOW) |
| 758 | return -EINVAL; |
| 759 | |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 760 | clk_enable(nmk_chip->clk); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 761 | spin_lock_irqsave(&nmk_chip->lock, flags); |
| 762 | |
Rabin Vincent | 7a852d8 | 2010-05-06 10:43:55 +0100 | [diff] [blame] | 763 | if (enabled) |
Rabin Vincent | 4d4e20f | 2010-06-16 06:09:34 +0100 | [diff] [blame] | 764 | __nmk_gpio_irq_modify(nmk_chip, gpio, NORMAL, false); |
| 765 | |
Rabin Vincent | b9df468 | 2011-02-10 11:45:58 +0530 | [diff] [blame] | 766 | if (enabled || wake) |
Rabin Vincent | 4d4e20f | 2010-06-16 06:09:34 +0100 | [diff] [blame] | 767 | __nmk_gpio_irq_modify(nmk_chip, gpio, WAKE, false); |
Rabin Vincent | 7a852d8 | 2010-05-06 10:43:55 +0100 | [diff] [blame] | 768 | |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 769 | nmk_chip->edge_rising &= ~bitmask; |
| 770 | if (type & IRQ_TYPE_EDGE_RISING) |
| 771 | nmk_chip->edge_rising |= bitmask; |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 772 | |
| 773 | nmk_chip->edge_falling &= ~bitmask; |
| 774 | if (type & IRQ_TYPE_EDGE_FALLING) |
| 775 | nmk_chip->edge_falling |= bitmask; |
Rabin Vincent | 7a852d8 | 2010-05-06 10:43:55 +0100 | [diff] [blame] | 776 | |
| 777 | if (enabled) |
Rabin Vincent | 4d4e20f | 2010-06-16 06:09:34 +0100 | [diff] [blame] | 778 | __nmk_gpio_irq_modify(nmk_chip, gpio, NORMAL, true); |
| 779 | |
Rabin Vincent | b9df468 | 2011-02-10 11:45:58 +0530 | [diff] [blame] | 780 | if (enabled || wake) |
Rabin Vincent | 4d4e20f | 2010-06-16 06:09:34 +0100 | [diff] [blame] | 781 | __nmk_gpio_irq_modify(nmk_chip, gpio, WAKE, true); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 782 | |
| 783 | spin_unlock_irqrestore(&nmk_chip->lock, flags); |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 784 | clk_disable(nmk_chip->clk); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 785 | |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 786 | return 0; |
| 787 | } |
| 788 | |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 789 | static unsigned int nmk_gpio_irq_startup(struct irq_data *d) |
| 790 | { |
| 791 | struct nmk_gpio_chip *nmk_chip = irq_data_get_irq_chip_data(d); |
| 792 | |
| 793 | clk_enable(nmk_chip->clk); |
| 794 | nmk_gpio_irq_unmask(d); |
| 795 | return 0; |
| 796 | } |
| 797 | |
| 798 | static void nmk_gpio_irq_shutdown(struct irq_data *d) |
| 799 | { |
| 800 | struct nmk_gpio_chip *nmk_chip = irq_data_get_irq_chip_data(d); |
| 801 | |
| 802 | nmk_gpio_irq_mask(d); |
| 803 | clk_disable(nmk_chip->clk); |
| 804 | } |
| 805 | |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 806 | static struct irq_chip nmk_gpio_irq_chip = { |
| 807 | .name = "Nomadik-GPIO", |
Lennert Buytenhek | f272c00 | 2010-11-29 11:16:48 +0100 | [diff] [blame] | 808 | .irq_ack = nmk_gpio_irq_ack, |
| 809 | .irq_mask = nmk_gpio_irq_mask, |
| 810 | .irq_unmask = nmk_gpio_irq_unmask, |
| 811 | .irq_set_type = nmk_gpio_irq_set_type, |
| 812 | .irq_set_wake = nmk_gpio_irq_set_wake, |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 813 | .irq_startup = nmk_gpio_irq_startup, |
| 814 | .irq_shutdown = nmk_gpio_irq_shutdown, |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 815 | }; |
| 816 | |
Rabin Vincent | 33b744b | 2010-10-14 10:38:03 +0530 | [diff] [blame] | 817 | static void __nmk_gpio_irq_handler(unsigned int irq, struct irq_desc *desc, |
| 818 | u32 status) |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 819 | { |
| 820 | struct nmk_gpio_chip *nmk_chip; |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 821 | struct irq_chip *host_chip = irq_get_chip(irq); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 822 | unsigned int first_irq; |
| 823 | |
Will Deacon | adfed15 | 2011-02-28 10:12:29 +0000 | [diff] [blame] | 824 | chained_irq_enter(host_chip, desc); |
Rabin Vincent | aaedaa2 | 2010-03-03 04:50:27 +0100 | [diff] [blame] | 825 | |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 826 | nmk_chip = irq_get_handler_data(irq); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 827 | first_irq = NOMADIK_GPIO_TO_IRQ(nmk_chip->chip.base); |
Rabin Vincent | 33b744b | 2010-10-14 10:38:03 +0530 | [diff] [blame] | 828 | while (status) { |
| 829 | int bit = __ffs(status); |
| 830 | |
| 831 | generic_handle_irq(first_irq + bit); |
| 832 | status &= ~BIT(bit); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 833 | } |
Rabin Vincent | aaedaa2 | 2010-03-03 04:50:27 +0100 | [diff] [blame] | 834 | |
Will Deacon | adfed15 | 2011-02-28 10:12:29 +0000 | [diff] [blame] | 835 | chained_irq_exit(host_chip, desc); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 836 | } |
| 837 | |
Rabin Vincent | 33b744b | 2010-10-14 10:38:03 +0530 | [diff] [blame] | 838 | static void nmk_gpio_irq_handler(unsigned int irq, struct irq_desc *desc) |
| 839 | { |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 840 | struct nmk_gpio_chip *nmk_chip = irq_get_handler_data(irq); |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 841 | u32 status; |
| 842 | |
| 843 | clk_enable(nmk_chip->clk); |
| 844 | status = readl(nmk_chip->addr + NMK_GPIO_IS); |
| 845 | clk_disable(nmk_chip->clk); |
Rabin Vincent | 33b744b | 2010-10-14 10:38:03 +0530 | [diff] [blame] | 846 | |
| 847 | __nmk_gpio_irq_handler(irq, desc, status); |
| 848 | } |
| 849 | |
| 850 | static void nmk_gpio_secondary_irq_handler(unsigned int irq, |
| 851 | struct irq_desc *desc) |
| 852 | { |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 853 | struct nmk_gpio_chip *nmk_chip = irq_get_handler_data(irq); |
Rabin Vincent | 33b744b | 2010-10-14 10:38:03 +0530 | [diff] [blame] | 854 | u32 status = nmk_chip->get_secondary_status(nmk_chip->bank); |
| 855 | |
| 856 | __nmk_gpio_irq_handler(irq, desc, status); |
| 857 | } |
| 858 | |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 859 | static int nmk_gpio_init_irq(struct nmk_gpio_chip *nmk_chip) |
| 860 | { |
| 861 | unsigned int first_irq; |
| 862 | int i; |
| 863 | |
| 864 | first_irq = NOMADIK_GPIO_TO_IRQ(nmk_chip->chip.base); |
Rabin Vincent | e493e06 | 2010-03-18 12:35:22 +0530 | [diff] [blame] | 865 | for (i = first_irq; i < first_irq + nmk_chip->chip.ngpio; i++) { |
Thomas Gleixner | f38c02f | 2011-03-24 13:35:09 +0100 | [diff] [blame] | 866 | irq_set_chip_and_handler(i, &nmk_gpio_irq_chip, |
| 867 | handle_edge_irq); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 868 | set_irq_flags(i, IRQF_VALID); |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 869 | irq_set_chip_data(i, nmk_chip); |
| 870 | irq_set_irq_type(i, IRQ_TYPE_EDGE_FALLING); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 871 | } |
Rabin Vincent | 33b744b | 2010-10-14 10:38:03 +0530 | [diff] [blame] | 872 | |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 873 | irq_set_chained_handler(nmk_chip->parent_irq, nmk_gpio_irq_handler); |
| 874 | irq_set_handler_data(nmk_chip->parent_irq, nmk_chip); |
Rabin Vincent | 33b744b | 2010-10-14 10:38:03 +0530 | [diff] [blame] | 875 | |
| 876 | if (nmk_chip->secondary_parent_irq >= 0) { |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 877 | irq_set_chained_handler(nmk_chip->secondary_parent_irq, |
Rabin Vincent | 33b744b | 2010-10-14 10:38:03 +0530 | [diff] [blame] | 878 | nmk_gpio_secondary_irq_handler); |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 879 | irq_set_handler_data(nmk_chip->secondary_parent_irq, nmk_chip); |
Rabin Vincent | 33b744b | 2010-10-14 10:38:03 +0530 | [diff] [blame] | 880 | } |
| 881 | |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 882 | return 0; |
| 883 | } |
| 884 | |
| 885 | /* I/O Functions */ |
| 886 | static int nmk_gpio_make_input(struct gpio_chip *chip, unsigned offset) |
| 887 | { |
| 888 | struct nmk_gpio_chip *nmk_chip = |
| 889 | container_of(chip, struct nmk_gpio_chip, chip); |
| 890 | |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 891 | clk_enable(nmk_chip->clk); |
| 892 | |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 893 | writel(1 << offset, nmk_chip->addr + NMK_GPIO_DIRC); |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 894 | |
| 895 | clk_disable(nmk_chip->clk); |
| 896 | |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 897 | return 0; |
| 898 | } |
| 899 | |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 900 | static int nmk_gpio_get_input(struct gpio_chip *chip, unsigned offset) |
| 901 | { |
| 902 | struct nmk_gpio_chip *nmk_chip = |
| 903 | container_of(chip, struct nmk_gpio_chip, chip); |
| 904 | u32 bit = 1 << offset; |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 905 | int value; |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 906 | |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 907 | clk_enable(nmk_chip->clk); |
| 908 | |
| 909 | value = (readl(nmk_chip->addr + NMK_GPIO_DAT) & bit) != 0; |
| 910 | |
| 911 | clk_disable(nmk_chip->clk); |
| 912 | |
| 913 | return value; |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 914 | } |
| 915 | |
| 916 | static void nmk_gpio_set_output(struct gpio_chip *chip, unsigned offset, |
| 917 | int val) |
| 918 | { |
| 919 | struct nmk_gpio_chip *nmk_chip = |
| 920 | container_of(chip, struct nmk_gpio_chip, chip); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 921 | |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 922 | clk_enable(nmk_chip->clk); |
| 923 | |
Rabin Vincent | 6720db7 | 2010-09-02 11:28:48 +0100 | [diff] [blame] | 924 | __nmk_gpio_set_output(nmk_chip, offset, val); |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 925 | |
| 926 | clk_disable(nmk_chip->clk); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 927 | } |
| 928 | |
Rabin Vincent | 6647c6c | 2010-05-27 12:22:42 +0100 | [diff] [blame] | 929 | static int nmk_gpio_make_output(struct gpio_chip *chip, unsigned offset, |
| 930 | int val) |
| 931 | { |
| 932 | struct nmk_gpio_chip *nmk_chip = |
| 933 | container_of(chip, struct nmk_gpio_chip, chip); |
| 934 | |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 935 | clk_enable(nmk_chip->clk); |
| 936 | |
Rabin Vincent | 6720db7 | 2010-09-02 11:28:48 +0100 | [diff] [blame] | 937 | __nmk_gpio_make_output(nmk_chip, offset, val); |
Rabin Vincent | 6647c6c | 2010-05-27 12:22:42 +0100 | [diff] [blame] | 938 | |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 939 | clk_disable(nmk_chip->clk); |
| 940 | |
Rabin Vincent | 6647c6c | 2010-05-27 12:22:42 +0100 | [diff] [blame] | 941 | return 0; |
| 942 | } |
| 943 | |
Rabin Vincent | 0d2aec9 | 2010-06-16 06:10:43 +0100 | [diff] [blame] | 944 | static int nmk_gpio_to_irq(struct gpio_chip *chip, unsigned offset) |
| 945 | { |
| 946 | struct nmk_gpio_chip *nmk_chip = |
| 947 | container_of(chip, struct nmk_gpio_chip, chip); |
| 948 | |
| 949 | return NOMADIK_GPIO_TO_IRQ(nmk_chip->chip.base) + offset; |
| 950 | } |
| 951 | |
Rabin Vincent | d0b543c | 2010-03-04 17:39:05 +0530 | [diff] [blame] | 952 | #ifdef CONFIG_DEBUG_FS |
| 953 | |
| 954 | #include <linux/seq_file.h> |
| 955 | |
| 956 | static void nmk_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) |
| 957 | { |
| 958 | int mode; |
| 959 | unsigned i; |
| 960 | unsigned gpio = chip->base; |
| 961 | int is_out; |
| 962 | struct nmk_gpio_chip *nmk_chip = |
| 963 | container_of(chip, struct nmk_gpio_chip, chip); |
| 964 | const char *modes[] = { |
| 965 | [NMK_GPIO_ALT_GPIO] = "gpio", |
| 966 | [NMK_GPIO_ALT_A] = "altA", |
| 967 | [NMK_GPIO_ALT_B] = "altB", |
| 968 | [NMK_GPIO_ALT_C] = "altC", |
| 969 | }; |
| 970 | |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 971 | clk_enable(nmk_chip->clk); |
| 972 | |
Rabin Vincent | d0b543c | 2010-03-04 17:39:05 +0530 | [diff] [blame] | 973 | for (i = 0; i < chip->ngpio; i++, gpio++) { |
| 974 | const char *label = gpiochip_is_requested(chip, i); |
| 975 | bool pull; |
| 976 | u32 bit = 1 << i; |
| 977 | |
Rabin Vincent | d0b543c | 2010-03-04 17:39:05 +0530 | [diff] [blame] | 978 | is_out = readl(nmk_chip->addr + NMK_GPIO_DIR) & bit; |
| 979 | pull = !(readl(nmk_chip->addr + NMK_GPIO_PDIS) & bit); |
| 980 | mode = nmk_gpio_get_mode(gpio); |
| 981 | seq_printf(s, " gpio-%-3d (%-20.20s) %s %s %s %s", |
Rabin Vincent | 8ea72a3 | 2011-05-24 23:07:09 +0200 | [diff] [blame] | 982 | gpio, label ?: "(none)", |
Rabin Vincent | d0b543c | 2010-03-04 17:39:05 +0530 | [diff] [blame] | 983 | is_out ? "out" : "in ", |
| 984 | chip->get |
| 985 | ? (chip->get(chip, i) ? "hi" : "lo") |
| 986 | : "? ", |
| 987 | (mode < 0) ? "unknown" : modes[mode], |
| 988 | pull ? "pull" : "none"); |
Rabin Vincent | 8ea72a3 | 2011-05-24 23:07:09 +0200 | [diff] [blame] | 989 | |
| 990 | if (label && !is_out) { |
| 991 | int irq = gpio_to_irq(gpio); |
| 992 | struct irq_desc *desc = irq_to_desc(irq); |
| 993 | |
| 994 | /* This races with request_irq(), set_irq_type(), |
| 995 | * and set_irq_wake() ... but those are "rare". |
| 996 | */ |
| 997 | if (irq >= 0 && desc->action) { |
| 998 | char *trigger; |
| 999 | u32 bitmask = nmk_gpio_get_bitmask(gpio); |
| 1000 | |
| 1001 | if (nmk_chip->edge_rising & bitmask) |
| 1002 | trigger = "edge-rising"; |
| 1003 | else if (nmk_chip->edge_falling & bitmask) |
| 1004 | trigger = "edge-falling"; |
| 1005 | else |
| 1006 | trigger = "edge-undefined"; |
| 1007 | |
| 1008 | seq_printf(s, " irq-%d %s%s", |
| 1009 | irq, trigger, |
| 1010 | irqd_is_wakeup_set(&desc->irq_data) |
| 1011 | ? " wakeup" : ""); |
| 1012 | } |
| 1013 | } |
| 1014 | |
Rabin Vincent | d0b543c | 2010-03-04 17:39:05 +0530 | [diff] [blame] | 1015 | seq_printf(s, "\n"); |
| 1016 | } |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 1017 | |
| 1018 | clk_disable(nmk_chip->clk); |
Rabin Vincent | d0b543c | 2010-03-04 17:39:05 +0530 | [diff] [blame] | 1019 | } |
| 1020 | |
| 1021 | #else |
| 1022 | #define nmk_gpio_dbg_show NULL |
| 1023 | #endif |
| 1024 | |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 1025 | /* This structure is replicated for each GPIO block allocated at probe time */ |
| 1026 | static struct gpio_chip nmk_gpio_template = { |
| 1027 | .direction_input = nmk_gpio_make_input, |
| 1028 | .get = nmk_gpio_get_input, |
| 1029 | .direction_output = nmk_gpio_make_output, |
| 1030 | .set = nmk_gpio_set_output, |
Rabin Vincent | 0d2aec9 | 2010-06-16 06:10:43 +0100 | [diff] [blame] | 1031 | .to_irq = nmk_gpio_to_irq, |
Rabin Vincent | d0b543c | 2010-03-04 17:39:05 +0530 | [diff] [blame] | 1032 | .dbg_show = nmk_gpio_dbg_show, |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 1033 | .can_sleep = 0, |
| 1034 | }; |
| 1035 | |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 1036 | void nmk_gpio_clocks_enable(void) |
| 1037 | { |
| 1038 | int i; |
| 1039 | |
| 1040 | for (i = 0; i < NUM_BANKS; i++) { |
| 1041 | struct nmk_gpio_chip *chip = nmk_gpio_chips[i]; |
| 1042 | |
| 1043 | if (!chip) |
| 1044 | continue; |
| 1045 | |
| 1046 | clk_enable(chip->clk); |
| 1047 | } |
| 1048 | } |
| 1049 | |
| 1050 | void nmk_gpio_clocks_disable(void) |
| 1051 | { |
| 1052 | int i; |
| 1053 | |
| 1054 | for (i = 0; i < NUM_BANKS; i++) { |
| 1055 | struct nmk_gpio_chip *chip = nmk_gpio_chips[i]; |
| 1056 | |
| 1057 | if (!chip) |
| 1058 | continue; |
| 1059 | |
| 1060 | clk_disable(chip->clk); |
| 1061 | } |
| 1062 | } |
| 1063 | |
Rabin Vincent | b9df468 | 2011-02-10 11:45:58 +0530 | [diff] [blame] | 1064 | /* |
| 1065 | * Called from the suspend/resume path to only keep the real wakeup interrupts |
| 1066 | * (those that have had set_irq_wake() called on them) as wakeup interrupts, |
| 1067 | * and not the rest of the interrupts which we needed to have as wakeups for |
| 1068 | * cpuidle. |
| 1069 | * |
| 1070 | * PM ops are not used since this needs to be done at the end, after all the |
| 1071 | * other drivers are done with their suspend callbacks. |
| 1072 | */ |
| 1073 | void nmk_gpio_wakeups_suspend(void) |
| 1074 | { |
| 1075 | int i; |
| 1076 | |
| 1077 | for (i = 0; i < NUM_BANKS; i++) { |
| 1078 | struct nmk_gpio_chip *chip = nmk_gpio_chips[i]; |
| 1079 | |
| 1080 | if (!chip) |
| 1081 | break; |
| 1082 | |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 1083 | clk_enable(chip->clk); |
| 1084 | |
Rabin Vincent | b9df468 | 2011-02-10 11:45:58 +0530 | [diff] [blame] | 1085 | writel(chip->rwimsc & chip->real_wake, |
| 1086 | chip->addr + NMK_GPIO_RWIMSC); |
| 1087 | writel(chip->fwimsc & chip->real_wake, |
| 1088 | chip->addr + NMK_GPIO_FWIMSC); |
| 1089 | |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 1090 | clk_disable(chip->clk); |
Rabin Vincent | b9df468 | 2011-02-10 11:45:58 +0530 | [diff] [blame] | 1091 | } |
| 1092 | } |
| 1093 | |
| 1094 | void nmk_gpio_wakeups_resume(void) |
| 1095 | { |
| 1096 | int i; |
| 1097 | |
| 1098 | for (i = 0; i < NUM_BANKS; i++) { |
| 1099 | struct nmk_gpio_chip *chip = nmk_gpio_chips[i]; |
| 1100 | |
| 1101 | if (!chip) |
| 1102 | break; |
| 1103 | |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 1104 | clk_enable(chip->clk); |
| 1105 | |
Rabin Vincent | b9df468 | 2011-02-10 11:45:58 +0530 | [diff] [blame] | 1106 | writel(chip->rwimsc, chip->addr + NMK_GPIO_RWIMSC); |
| 1107 | writel(chip->fwimsc, chip->addr + NMK_GPIO_FWIMSC); |
| 1108 | |
Rabin Vincent | 3c0227d | 2011-09-20 10:50:03 +0200 | [diff] [blame] | 1109 | clk_disable(chip->clk); |
Rabin Vincent | b9df468 | 2011-02-10 11:45:58 +0530 | [diff] [blame] | 1110 | } |
| 1111 | } |
| 1112 | |
Rickard Andersson | bc6f5cf | 2011-05-24 23:07:17 +0200 | [diff] [blame] | 1113 | /* |
| 1114 | * Read the pull up/pull down status. |
| 1115 | * A bit set in 'pull_up' means that pull up |
| 1116 | * is selected if pull is enabled in PDIS register. |
| 1117 | * Note: only pull up/down set via this driver can |
| 1118 | * be detected due to HW limitations. |
| 1119 | */ |
| 1120 | void nmk_gpio_read_pull(int gpio_bank, u32 *pull_up) |
| 1121 | { |
| 1122 | if (gpio_bank < NUM_BANKS) { |
| 1123 | struct nmk_gpio_chip *chip = nmk_gpio_chips[gpio_bank]; |
| 1124 | |
| 1125 | if (!chip) |
| 1126 | return; |
| 1127 | |
| 1128 | *pull_up = chip->pull_up; |
| 1129 | } |
| 1130 | } |
| 1131 | |
Uwe Kleine-König | fd0d67d | 2010-09-02 16:13:35 +0100 | [diff] [blame] | 1132 | static int __devinit nmk_gpio_probe(struct platform_device *dev) |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 1133 | { |
Rabin Vincent | 3e3c62c | 2010-03-03 04:52:34 +0100 | [diff] [blame] | 1134 | struct nmk_gpio_platform_data *pdata = dev->dev.platform_data; |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 1135 | struct nmk_gpio_chip *nmk_chip; |
| 1136 | struct gpio_chip *chip; |
Rabin Vincent | 3e3c62c | 2010-03-03 04:52:34 +0100 | [diff] [blame] | 1137 | struct resource *res; |
Rabin Vincent | af7dc22 | 2010-05-06 11:14:17 +0100 | [diff] [blame] | 1138 | struct clk *clk; |
Rabin Vincent | 33b744b | 2010-10-14 10:38:03 +0530 | [diff] [blame] | 1139 | int secondary_irq; |
Linus Walleij | 8d91771 | 2012-04-17 10:15:54 +0200 | [diff] [blame^] | 1140 | void __iomem *base; |
Rabin Vincent | 3e3c62c | 2010-03-03 04:52:34 +0100 | [diff] [blame] | 1141 | int irq; |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 1142 | int ret; |
| 1143 | |
Rabin Vincent | 3e3c62c | 2010-03-03 04:52:34 +0100 | [diff] [blame] | 1144 | if (!pdata) |
| 1145 | return -ENODEV; |
| 1146 | |
| 1147 | res = platform_get_resource(dev, IORESOURCE_MEM, 0); |
| 1148 | if (!res) { |
| 1149 | ret = -ENOENT; |
| 1150 | goto out; |
| 1151 | } |
| 1152 | |
| 1153 | irq = platform_get_irq(dev, 0); |
| 1154 | if (irq < 0) { |
| 1155 | ret = irq; |
| 1156 | goto out; |
| 1157 | } |
| 1158 | |
Rabin Vincent | 33b744b | 2010-10-14 10:38:03 +0530 | [diff] [blame] | 1159 | secondary_irq = platform_get_irq(dev, 1); |
| 1160 | if (secondary_irq >= 0 && !pdata->get_secondary_status) { |
| 1161 | ret = -EINVAL; |
| 1162 | goto out; |
| 1163 | } |
| 1164 | |
Rabin Vincent | 3e3c62c | 2010-03-03 04:52:34 +0100 | [diff] [blame] | 1165 | if (request_mem_region(res->start, resource_size(res), |
| 1166 | dev_name(&dev->dev)) == NULL) { |
| 1167 | ret = -EBUSY; |
| 1168 | goto out; |
| 1169 | } |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 1170 | |
Linus Walleij | 8d91771 | 2012-04-17 10:15:54 +0200 | [diff] [blame^] | 1171 | base = ioremap(res->start, resource_size(res)); |
| 1172 | if (!base) { |
| 1173 | ret = -ENOMEM; |
| 1174 | goto out_release; |
| 1175 | } |
| 1176 | |
Rabin Vincent | af7dc22 | 2010-05-06 11:14:17 +0100 | [diff] [blame] | 1177 | clk = clk_get(&dev->dev, NULL); |
| 1178 | if (IS_ERR(clk)) { |
| 1179 | ret = PTR_ERR(clk); |
Linus Walleij | 8d91771 | 2012-04-17 10:15:54 +0200 | [diff] [blame^] | 1180 | goto out_unmap; |
Rabin Vincent | af7dc22 | 2010-05-06 11:14:17 +0100 | [diff] [blame] | 1181 | } |
| 1182 | |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 1183 | nmk_chip = kzalloc(sizeof(*nmk_chip), GFP_KERNEL); |
| 1184 | if (!nmk_chip) { |
| 1185 | ret = -ENOMEM; |
Rabin Vincent | af7dc22 | 2010-05-06 11:14:17 +0100 | [diff] [blame] | 1186 | goto out_clk; |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 1187 | } |
| 1188 | /* |
| 1189 | * The virt address in nmk_chip->addr is in the nomadik register space, |
| 1190 | * so we can simply convert the resource address, without remapping |
| 1191 | */ |
Rabin Vincent | 33b744b | 2010-10-14 10:38:03 +0530 | [diff] [blame] | 1192 | nmk_chip->bank = dev->id; |
Rabin Vincent | af7dc22 | 2010-05-06 11:14:17 +0100 | [diff] [blame] | 1193 | nmk_chip->clk = clk; |
Linus Walleij | 8d91771 | 2012-04-17 10:15:54 +0200 | [diff] [blame^] | 1194 | nmk_chip->addr = base; |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 1195 | nmk_chip->chip = nmk_gpio_template; |
Rabin Vincent | 3e3c62c | 2010-03-03 04:52:34 +0100 | [diff] [blame] | 1196 | nmk_chip->parent_irq = irq; |
Rabin Vincent | 33b744b | 2010-10-14 10:38:03 +0530 | [diff] [blame] | 1197 | nmk_chip->secondary_parent_irq = secondary_irq; |
| 1198 | nmk_chip->get_secondary_status = pdata->get_secondary_status; |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 1199 | nmk_chip->set_ioforce = pdata->set_ioforce; |
Linus Walleij | 33d7864 | 2011-06-09 11:08:47 +0200 | [diff] [blame] | 1200 | nmk_chip->sleepmode = pdata->supports_sleepmode; |
Rabin Vincent | c0fcb8d | 2010-03-03 04:48:54 +0100 | [diff] [blame] | 1201 | spin_lock_init(&nmk_chip->lock); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 1202 | |
| 1203 | chip = &nmk_chip->chip; |
| 1204 | chip->base = pdata->first_gpio; |
Rabin Vincent | e493e06 | 2010-03-18 12:35:22 +0530 | [diff] [blame] | 1205 | chip->ngpio = pdata->num_gpio; |
Rabin Vincent | 8d568ae | 2010-12-08 11:07:54 +0530 | [diff] [blame] | 1206 | chip->label = pdata->name ?: dev_name(&dev->dev); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 1207 | chip->dev = &dev->dev; |
| 1208 | chip->owner = THIS_MODULE; |
| 1209 | |
Rabin Vincent | ebc6178 | 2011-09-28 15:49:11 +0530 | [diff] [blame] | 1210 | clk_enable(nmk_chip->clk); |
| 1211 | nmk_chip->lowemi = readl_relaxed(nmk_chip->addr + NMK_GPIO_LOWEMI); |
| 1212 | clk_disable(nmk_chip->clk); |
| 1213 | |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 1214 | ret = gpiochip_add(&nmk_chip->chip); |
| 1215 | if (ret) |
| 1216 | goto out_free; |
| 1217 | |
Rabin Vincent | 01727e6 | 2010-12-13 12:02:40 +0530 | [diff] [blame] | 1218 | BUG_ON(nmk_chip->bank >= ARRAY_SIZE(nmk_gpio_chips)); |
| 1219 | |
| 1220 | nmk_gpio_chips[nmk_chip->bank] = nmk_chip; |
Rabin Vincent | 3e3c62c | 2010-03-03 04:52:34 +0100 | [diff] [blame] | 1221 | platform_set_drvdata(dev, nmk_chip); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 1222 | |
| 1223 | nmk_gpio_init_irq(nmk_chip); |
| 1224 | |
Grant Likely | 64842aa | 2011-11-06 11:36:18 -0700 | [diff] [blame] | 1225 | dev_info(&dev->dev, "at address %p\n", |
| 1226 | nmk_chip->addr); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 1227 | return 0; |
| 1228 | |
Rabin Vincent | 3e3c62c | 2010-03-03 04:52:34 +0100 | [diff] [blame] | 1229 | out_free: |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 1230 | kfree(nmk_chip); |
Rabin Vincent | af7dc22 | 2010-05-06 11:14:17 +0100 | [diff] [blame] | 1231 | out_clk: |
| 1232 | clk_disable(clk); |
| 1233 | clk_put(clk); |
Linus Walleij | 8d91771 | 2012-04-17 10:15:54 +0200 | [diff] [blame^] | 1234 | out_unmap: |
| 1235 | iounmap(base); |
Rabin Vincent | 3e3c62c | 2010-03-03 04:52:34 +0100 | [diff] [blame] | 1236 | out_release: |
| 1237 | release_mem_region(res->start, resource_size(res)); |
| 1238 | out: |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 1239 | dev_err(&dev->dev, "Failure %i for GPIO %i-%i\n", ret, |
| 1240 | pdata->first_gpio, pdata->first_gpio+31); |
| 1241 | return ret; |
| 1242 | } |
| 1243 | |
Rabin Vincent | 3e3c62c | 2010-03-03 04:52:34 +0100 | [diff] [blame] | 1244 | static struct platform_driver nmk_gpio_driver = { |
| 1245 | .driver = { |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 1246 | .owner = THIS_MODULE, |
| 1247 | .name = "gpio", |
Rabin Vincent | 5317e4d1 | 2011-02-10 09:29:53 +0530 | [diff] [blame] | 1248 | }, |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 1249 | .probe = nmk_gpio_probe, |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 1250 | }; |
| 1251 | |
| 1252 | static int __init nmk_gpio_init(void) |
| 1253 | { |
Rabin Vincent | 3e3c62c | 2010-03-03 04:52:34 +0100 | [diff] [blame] | 1254 | return platform_driver_register(&nmk_gpio_driver); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 1255 | } |
| 1256 | |
Rabin Vincent | 33f45ea | 2010-06-02 06:09:52 +0100 | [diff] [blame] | 1257 | core_initcall(nmk_gpio_init); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 1258 | |
| 1259 | MODULE_AUTHOR("Prafulla WADASKAR and Alessandro Rubini"); |
| 1260 | MODULE_DESCRIPTION("Nomadik GPIO Driver"); |
| 1261 | MODULE_LICENSE("GPL"); |