blob: 935292a30c9979f4420d97437f9d875a32785ed1 [file] [log] [blame]
Anton Vorontsovaeec56e2010-10-27 15:33:15 -07001/*
Grant Likelyc103de22011-06-04 18:38:28 -06002 * Generic driver for memory-mapped GPIO controllers.
Anton Vorontsovaeec56e2010-10-27 15:33:15 -07003 *
4 * Copyright 2008 MontaVista Software, Inc.
5 * Copyright 2008,2010 Anton Vorontsov <cbouatmailru@gmail.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 * ....``.```~~~~````.`.`.`.`.```````'',,,.........`````......`.......
13 * ...`` ```````..
14 * ..The simplest form of a GPIO controller that the driver supports is``
15 * `.just a single "data" register, where GPIO state can be read and/or `
16 * `,..written. ,,..``~~~~ .....``.`.`.~~.```.`.........``````.```````
17 * `````````
18 ___
19_/~~|___/~| . ```~~~~~~ ___/___\___ ,~.`.`.`.`````.~~...,,,,...
20__________|~$@~~~ %~ /o*o*o*o*o*o\ .. Implementing such a GPIO .
21o ` ~~~~\___/~~~~ ` controller in FPGA is ,.`
22 `....trivial..'~`.```.```
23 * ```````
24 * .```````~~~~`..`.``.``.
25 * . The driver supports `... ,..```.`~~~```````````````....````.``,,
26 * . big-endian notation, just`. .. A bit more sophisticated controllers ,
27 * . register the device with -be`. .with a pair of set/clear-bit registers ,
28 * `.. suffix. ```~~`````....`.` . affecting the data register and the .`
29 * ``.`.``...``` ```.. output pins are also supported.`
30 * ^^ `````.`````````.,``~``~``~~``````
31 * . ^^
32 * ,..`.`.`...````````````......`.`.`.`.`.`..`.`.`..
33 * .. The expectation is that in at least some cases . ,-~~~-,
34 * .this will be used with roll-your-own ASIC/FPGA .` \ /
35 * .logic in Verilog or VHDL. ~~~`````````..`````~~` \ /
36 * ..````````......``````````` \o_
37 * |
38 * ^^ / \
39 *
40 * ...`````~~`.....``.`..........``````.`.``.```........``.
41 * ` 8, 16, 32 and 64 bits registers are supported, and``.
42 * . the number of GPIOs is determined by the width of ~
43 * .. the registers. ,............```.`.`..`.`.~~~.`.`.`~
44 * `.......````.```
45 */
46
47#include <linux/init.h>
Jamie Iles280df6b2011-05-20 00:40:19 -060048#include <linux/err.h>
Anton Vorontsovaeec56e2010-10-27 15:33:15 -070049#include <linux/bug.h>
50#include <linux/kernel.h>
51#include <linux/module.h>
52#include <linux/spinlock.h>
53#include <linux/compiler.h>
54#include <linux/types.h>
55#include <linux/errno.h>
56#include <linux/log2.h>
57#include <linux/ioport.h>
58#include <linux/io.h>
Linus Walleij0f4630f2015-12-04 14:02:58 +010059#include <linux/gpio/driver.h>
Anton Vorontsovaeec56e2010-10-27 15:33:15 -070060#include <linux/slab.h>
Linus Walleij4b637392016-01-05 11:13:28 +010061#include <linux/bitops.h>
Anton Vorontsovaeec56e2010-10-27 15:33:15 -070062#include <linux/platform_device.h>
63#include <linux/mod_devicetable.h>
Álvaro Fernández Rojase6986132016-05-13 23:07:11 +020064#include <linux/of.h>
65#include <linux/of_device.h>
Anton Vorontsovaeec56e2010-10-27 15:33:15 -070066
Jamie Iles8467afe2011-05-20 00:40:14 -060067static void bgpio_write8(void __iomem *reg, unsigned long data)
Anton Vorontsovaeec56e2010-10-27 15:33:15 -070068{
Jamie Ilesfd996232011-05-20 00:40:17 -060069 writeb(data, reg);
Anton Vorontsovaeec56e2010-10-27 15:33:15 -070070}
71
Jamie Iles8467afe2011-05-20 00:40:14 -060072static unsigned long bgpio_read8(void __iomem *reg)
Anton Vorontsovaeec56e2010-10-27 15:33:15 -070073{
Jamie Ilesfd996232011-05-20 00:40:17 -060074 return readb(reg);
Anton Vorontsovaeec56e2010-10-27 15:33:15 -070075}
76
Jamie Iles8467afe2011-05-20 00:40:14 -060077static void bgpio_write16(void __iomem *reg, unsigned long data)
78{
Jamie Ilesfd996232011-05-20 00:40:17 -060079 writew(data, reg);
Jamie Iles8467afe2011-05-20 00:40:14 -060080}
81
82static unsigned long bgpio_read16(void __iomem *reg)
83{
Jamie Ilesfd996232011-05-20 00:40:17 -060084 return readw(reg);
Jamie Iles8467afe2011-05-20 00:40:14 -060085}
86
87static void bgpio_write32(void __iomem *reg, unsigned long data)
88{
Jamie Ilesfd996232011-05-20 00:40:17 -060089 writel(data, reg);
Jamie Iles8467afe2011-05-20 00:40:14 -060090}
91
92static unsigned long bgpio_read32(void __iomem *reg)
93{
Jamie Ilesfd996232011-05-20 00:40:17 -060094 return readl(reg);
Jamie Iles8467afe2011-05-20 00:40:14 -060095}
96
97#if BITS_PER_LONG >= 64
98static void bgpio_write64(void __iomem *reg, unsigned long data)
99{
Jamie Ilesfd996232011-05-20 00:40:17 -0600100 writeq(data, reg);
Jamie Iles8467afe2011-05-20 00:40:14 -0600101}
102
103static unsigned long bgpio_read64(void __iomem *reg)
104{
Jamie Ilesfd996232011-05-20 00:40:17 -0600105 return readq(reg);
Jamie Iles8467afe2011-05-20 00:40:14 -0600106}
107#endif /* BITS_PER_LONG >= 64 */
108
Andreas Larsson2b78f1e2013-03-15 14:45:38 +0100109static void bgpio_write16be(void __iomem *reg, unsigned long data)
110{
111 iowrite16be(data, reg);
112}
113
114static unsigned long bgpio_read16be(void __iomem *reg)
115{
116 return ioread16be(reg);
117}
118
119static void bgpio_write32be(void __iomem *reg, unsigned long data)
120{
121 iowrite32be(data, reg);
122}
123
124static unsigned long bgpio_read32be(void __iomem *reg)
125{
126 return ioread32be(reg);
127}
128
Linus Walleij24efd942017-10-20 16:31:27 +0200129static unsigned long bgpio_line2mask(struct gpio_chip *gc, unsigned int line)
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700130{
Linus Walleij24efd942017-10-20 16:31:27 +0200131 if (gc->be_bits)
132 return BIT(gc->bgpio_bits - 1 - line);
133 return BIT(line);
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700134}
135
Vladimir Zapolskiyb19e7f52015-04-29 18:34:59 +0300136static int bgpio_get_set(struct gpio_chip *gc, unsigned int gpio)
137{
Linus Walleij24efd942017-10-20 16:31:27 +0200138 unsigned long pinmask = bgpio_line2mask(gc, gpio);
Linus Walleijd799a4d2018-08-03 00:52:18 +0200139 bool dir = !!(gc->bgpio_dir & pinmask);
Vladimir Zapolskiyb19e7f52015-04-29 18:34:59 +0300140
Linus Walleijd799a4d2018-08-03 00:52:18 +0200141 /*
142 * If the direction is OUT we read the value from the SET
143 * register, and if the direction is IN we read the value
144 * from the DAT register.
145 *
146 * If the direction bits are inverted, naturally this gets
147 * inverted too.
148 */
149 if (gc->bgpio_dir_inverted)
150 dir = !dir;
151
152 if (dir)
Linus Walleij0f4630f2015-12-04 14:02:58 +0100153 return !!(gc->read_reg(gc->reg_set) & pinmask);
Vladimir Zapolskiyb19e7f52015-04-29 18:34:59 +0300154 else
Linus Walleij0f4630f2015-12-04 14:02:58 +0100155 return !!(gc->read_reg(gc->reg_dat) & pinmask);
Vladimir Zapolskiyb19e7f52015-04-29 18:34:59 +0300156}
157
Linus Walleij80057cb42017-10-19 23:30:12 +0200158/*
159 * This assumes that the bits in the GPIO register are in native endianness.
160 * We only assign the function pointer if we have that.
161 */
162static int bgpio_get_set_multiple(struct gpio_chip *gc, unsigned long *mask,
163 unsigned long *bits)
164{
165 unsigned long get_mask = 0;
166 unsigned long set_mask = 0;
Linus Walleij80057cb42017-10-19 23:30:12 +0200167
Linus Walleij07c7b6a2018-01-16 09:51:51 +0100168 /* Make sure we first clear any bits that are zero when we read the register */
169 *bits &= ~*mask;
170
171 /* Exploit the fact that we know which directions are set */
Linus Walleijd799a4d2018-08-03 00:52:18 +0200172 if (gc->bgpio_dir_inverted) {
173 set_mask = *mask & ~gc->bgpio_dir;
174 get_mask = *mask & gc->bgpio_dir;
175 } else {
176 set_mask = *mask & gc->bgpio_dir;
177 get_mask = *mask & ~gc->bgpio_dir;
178 }
Linus Walleij80057cb42017-10-19 23:30:12 +0200179
180 if (set_mask)
181 *bits |= gc->read_reg(gc->reg_set) & set_mask;
182 if (get_mask)
183 *bits |= gc->read_reg(gc->reg_dat) & get_mask;
184
185 return 0;
186}
187
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700188static int bgpio_get(struct gpio_chip *gc, unsigned int gpio)
189{
Linus Walleij24efd942017-10-20 16:31:27 +0200190 return !!(gc->read_reg(gc->reg_dat) & bgpio_line2mask(gc, gpio));
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700191}
192
Linus Walleij80057cb42017-10-19 23:30:12 +0200193/*
194 * This only works if the bits in the GPIO register are in native endianness.
Linus Walleij80057cb42017-10-19 23:30:12 +0200195 */
196static int bgpio_get_multiple(struct gpio_chip *gc, unsigned long *mask,
197 unsigned long *bits)
198{
Linus Walleij07c7b6a2018-01-16 09:51:51 +0100199 /* Make sure we first clear any bits that are zero when we read the register */
200 *bits &= ~*mask;
201 *bits |= gc->read_reg(gc->reg_dat) & *mask;
Linus Walleij80057cb42017-10-19 23:30:12 +0200202 return 0;
203}
204
205/*
206 * With big endian mirrored bit order it becomes more tedious.
207 */
208static int bgpio_get_multiple_be(struct gpio_chip *gc, unsigned long *mask,
209 unsigned long *bits)
210{
211 unsigned long readmask = 0;
212 unsigned long val;
213 int bit;
214
Linus Walleij07c7b6a2018-01-16 09:51:51 +0100215 /* Make sure we first clear any bits that are zero when we read the register */
216 *bits &= ~*mask;
217
Linus Walleij80057cb42017-10-19 23:30:12 +0200218 /* Create a mirrored mask */
Linus Walleij07c7b6a2018-01-16 09:51:51 +0100219 bit = -1;
220 while ((bit = find_next_bit(mask, gc->ngpio, bit + 1)) < gc->ngpio)
Linus Walleij80057cb42017-10-19 23:30:12 +0200221 readmask |= bgpio_line2mask(gc, bit);
222
223 /* Read the register */
224 val = gc->read_reg(gc->reg_dat) & readmask;
225
226 /*
227 * Mirror the result into the "bits" result, this will give line 0
228 * in bit 0 ... line 31 in bit 31 for a 32bit register.
229 */
Linus Walleij07c7b6a2018-01-16 09:51:51 +0100230 bit = -1;
231 while ((bit = find_next_bit(&val, gc->ngpio, bit + 1)) < gc->ngpio)
Linus Walleij80057cb42017-10-19 23:30:12 +0200232 *bits |= bgpio_line2mask(gc, bit);
233
234 return 0;
235}
236
Rabin Vincent91492a42015-07-22 15:05:18 +0200237static void bgpio_set_none(struct gpio_chip *gc, unsigned int gpio, int val)
238{
239}
240
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700241static void bgpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
242{
Linus Walleij24efd942017-10-20 16:31:27 +0200243 unsigned long mask = bgpio_line2mask(gc, gpio);
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700244 unsigned long flags;
245
Linus Walleij0f4630f2015-12-04 14:02:58 +0100246 spin_lock_irqsave(&gc->bgpio_lock, flags);
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700247
248 if (val)
Linus Walleij0f4630f2015-12-04 14:02:58 +0100249 gc->bgpio_data |= mask;
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700250 else
Linus Walleij0f4630f2015-12-04 14:02:58 +0100251 gc->bgpio_data &= ~mask;
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700252
Linus Walleij0f4630f2015-12-04 14:02:58 +0100253 gc->write_reg(gc->reg_dat, gc->bgpio_data);
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700254
Linus Walleij0f4630f2015-12-04 14:02:58 +0100255 spin_unlock_irqrestore(&gc->bgpio_lock, flags);
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700256}
257
Jamie Ilese027d6f2011-05-20 00:40:16 -0600258static void bgpio_set_with_clear(struct gpio_chip *gc, unsigned int gpio,
259 int val)
260{
Linus Walleij24efd942017-10-20 16:31:27 +0200261 unsigned long mask = bgpio_line2mask(gc, gpio);
Jamie Ilese027d6f2011-05-20 00:40:16 -0600262
263 if (val)
Linus Walleij0f4630f2015-12-04 14:02:58 +0100264 gc->write_reg(gc->reg_set, mask);
Jamie Ilese027d6f2011-05-20 00:40:16 -0600265 else
Linus Walleij0f4630f2015-12-04 14:02:58 +0100266 gc->write_reg(gc->reg_clr, mask);
Jamie Ilese027d6f2011-05-20 00:40:16 -0600267}
268
Jamie Ilesdd86a0c2011-05-20 00:40:16 -0600269static void bgpio_set_set(struct gpio_chip *gc, unsigned int gpio, int val)
270{
Linus Walleij24efd942017-10-20 16:31:27 +0200271 unsigned long mask = bgpio_line2mask(gc, gpio);
Jamie Ilesdd86a0c2011-05-20 00:40:16 -0600272 unsigned long flags;
273
Linus Walleij0f4630f2015-12-04 14:02:58 +0100274 spin_lock_irqsave(&gc->bgpio_lock, flags);
Jamie Ilesdd86a0c2011-05-20 00:40:16 -0600275
276 if (val)
Linus Walleij0f4630f2015-12-04 14:02:58 +0100277 gc->bgpio_data |= mask;
Jamie Ilesdd86a0c2011-05-20 00:40:16 -0600278 else
Linus Walleij0f4630f2015-12-04 14:02:58 +0100279 gc->bgpio_data &= ~mask;
Jamie Ilesdd86a0c2011-05-20 00:40:16 -0600280
Linus Walleij0f4630f2015-12-04 14:02:58 +0100281 gc->write_reg(gc->reg_set, gc->bgpio_data);
Jamie Ilesdd86a0c2011-05-20 00:40:16 -0600282
Linus Walleij0f4630f2015-12-04 14:02:58 +0100283 spin_unlock_irqrestore(&gc->bgpio_lock, flags);
Jamie Ilesdd86a0c2011-05-20 00:40:16 -0600284}
285
Linus Walleij0f4630f2015-12-04 14:02:58 +0100286static void bgpio_multiple_get_masks(struct gpio_chip *gc,
Rojhalat Ibrahim73c4ced2015-01-14 15:46:38 +0100287 unsigned long *mask, unsigned long *bits,
288 unsigned long *set_mask,
289 unsigned long *clear_mask)
290{
291 int i;
292
293 *set_mask = 0;
294 *clear_mask = 0;
295
Linus Walleij0f4630f2015-12-04 14:02:58 +0100296 for (i = 0; i < gc->bgpio_bits; i++) {
Rojhalat Ibrahim73c4ced2015-01-14 15:46:38 +0100297 if (*mask == 0)
298 break;
299 if (__test_and_clear_bit(i, mask)) {
300 if (test_bit(i, bits))
Linus Walleij24efd942017-10-20 16:31:27 +0200301 *set_mask |= bgpio_line2mask(gc, i);
Rojhalat Ibrahim73c4ced2015-01-14 15:46:38 +0100302 else
Linus Walleij24efd942017-10-20 16:31:27 +0200303 *clear_mask |= bgpio_line2mask(gc, i);
Rojhalat Ibrahim73c4ced2015-01-14 15:46:38 +0100304 }
305 }
306}
307
Linus Walleij0f4630f2015-12-04 14:02:58 +0100308static void bgpio_set_multiple_single_reg(struct gpio_chip *gc,
Rojhalat Ibrahim73c4ced2015-01-14 15:46:38 +0100309 unsigned long *mask,
310 unsigned long *bits,
311 void __iomem *reg)
312{
313 unsigned long flags;
314 unsigned long set_mask, clear_mask;
315
Linus Walleij0f4630f2015-12-04 14:02:58 +0100316 spin_lock_irqsave(&gc->bgpio_lock, flags);
Rojhalat Ibrahim73c4ced2015-01-14 15:46:38 +0100317
Linus Walleij0f4630f2015-12-04 14:02:58 +0100318 bgpio_multiple_get_masks(gc, mask, bits, &set_mask, &clear_mask);
Rojhalat Ibrahim73c4ced2015-01-14 15:46:38 +0100319
Linus Walleij0f4630f2015-12-04 14:02:58 +0100320 gc->bgpio_data |= set_mask;
321 gc->bgpio_data &= ~clear_mask;
Rojhalat Ibrahim73c4ced2015-01-14 15:46:38 +0100322
Linus Walleij0f4630f2015-12-04 14:02:58 +0100323 gc->write_reg(reg, gc->bgpio_data);
Rojhalat Ibrahim73c4ced2015-01-14 15:46:38 +0100324
Linus Walleij0f4630f2015-12-04 14:02:58 +0100325 spin_unlock_irqrestore(&gc->bgpio_lock, flags);
Rojhalat Ibrahim73c4ced2015-01-14 15:46:38 +0100326}
327
328static void bgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask,
329 unsigned long *bits)
330{
Linus Walleij0f4630f2015-12-04 14:02:58 +0100331 bgpio_set_multiple_single_reg(gc, mask, bits, gc->reg_dat);
Rojhalat Ibrahim73c4ced2015-01-14 15:46:38 +0100332}
333
334static void bgpio_set_multiple_set(struct gpio_chip *gc, unsigned long *mask,
335 unsigned long *bits)
336{
Linus Walleij0f4630f2015-12-04 14:02:58 +0100337 bgpio_set_multiple_single_reg(gc, mask, bits, gc->reg_set);
Rojhalat Ibrahim73c4ced2015-01-14 15:46:38 +0100338}
339
340static void bgpio_set_multiple_with_clear(struct gpio_chip *gc,
341 unsigned long *mask,
342 unsigned long *bits)
343{
Rojhalat Ibrahim73c4ced2015-01-14 15:46:38 +0100344 unsigned long set_mask, clear_mask;
345
Linus Walleij0f4630f2015-12-04 14:02:58 +0100346 bgpio_multiple_get_masks(gc, mask, bits, &set_mask, &clear_mask);
Rojhalat Ibrahim73c4ced2015-01-14 15:46:38 +0100347
348 if (set_mask)
Linus Walleij0f4630f2015-12-04 14:02:58 +0100349 gc->write_reg(gc->reg_set, set_mask);
Rojhalat Ibrahim73c4ced2015-01-14 15:46:38 +0100350 if (clear_mask)
Linus Walleij0f4630f2015-12-04 14:02:58 +0100351 gc->write_reg(gc->reg_clr, clear_mask);
Rojhalat Ibrahim73c4ced2015-01-14 15:46:38 +0100352}
353
Jamie Iles31029112011-05-20 00:40:17 -0600354static int bgpio_simple_dir_in(struct gpio_chip *gc, unsigned int gpio)
355{
356 return 0;
357}
358
Rabin Vincent91492a42015-07-22 15:05:18 +0200359static int bgpio_dir_out_err(struct gpio_chip *gc, unsigned int gpio,
360 int val)
361{
362 return -EINVAL;
363}
364
Jamie Iles31029112011-05-20 00:40:17 -0600365static int bgpio_simple_dir_out(struct gpio_chip *gc, unsigned int gpio,
366 int val)
367{
368 gc->set(gc, gpio, val);
369
370 return 0;
371}
372
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700373static int bgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
374{
Jamie Iles31029112011-05-20 00:40:17 -0600375 unsigned long flags;
376
Linus Walleij0f4630f2015-12-04 14:02:58 +0100377 spin_lock_irqsave(&gc->bgpio_lock, flags);
Jamie Iles31029112011-05-20 00:40:17 -0600378
Linus Walleijd799a4d2018-08-03 00:52:18 +0200379 if (gc->bgpio_dir_inverted)
380 gc->bgpio_dir |= bgpio_line2mask(gc, gpio);
381 else
382 gc->bgpio_dir &= ~bgpio_line2mask(gc, gpio);
Linus Walleij0f4630f2015-12-04 14:02:58 +0100383 gc->write_reg(gc->reg_dir, gc->bgpio_dir);
Jamie Iles31029112011-05-20 00:40:17 -0600384
Linus Walleij0f4630f2015-12-04 14:02:58 +0100385 spin_unlock_irqrestore(&gc->bgpio_lock, flags);
Jamie Iles31029112011-05-20 00:40:17 -0600386
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700387 return 0;
388}
389
Philipp Zabeldb3b0fc2015-06-12 18:20:35 +0200390static int bgpio_get_dir(struct gpio_chip *gc, unsigned int gpio)
391{
Linus Walleij0f4630f2015-12-04 14:02:58 +0100392 /* Return 0 if output, 1 of input */
Linus Walleijd799a4d2018-08-03 00:52:18 +0200393 if (gc->bgpio_dir_inverted)
394 return !!(gc->read_reg(gc->reg_dir) & bgpio_line2mask(gc, gpio));
395 else
396 return !(gc->read_reg(gc->reg_dir) & bgpio_line2mask(gc, gpio));
Philipp Zabeldb3b0fc2015-06-12 18:20:35 +0200397}
398
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700399static int bgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
400{
Jamie Iles31029112011-05-20 00:40:17 -0600401 unsigned long flags;
402
Jamie Ilese027d6f2011-05-20 00:40:16 -0600403 gc->set(gc, gpio, val);
404
Linus Walleij0f4630f2015-12-04 14:02:58 +0100405 spin_lock_irqsave(&gc->bgpio_lock, flags);
Jamie Iles31029112011-05-20 00:40:17 -0600406
Linus Walleijd799a4d2018-08-03 00:52:18 +0200407 if (gc->bgpio_dir_inverted)
408 gc->bgpio_dir &= ~bgpio_line2mask(gc, gpio);
409 else
410 gc->bgpio_dir |= bgpio_line2mask(gc, gpio);
Linus Walleij0f4630f2015-12-04 14:02:58 +0100411 gc->write_reg(gc->reg_dir, gc->bgpio_dir);
Jamie Iles31029112011-05-20 00:40:17 -0600412
Linus Walleij0f4630f2015-12-04 14:02:58 +0100413 spin_unlock_irqrestore(&gc->bgpio_lock, flags);
Jamie Iles31029112011-05-20 00:40:17 -0600414
415 return 0;
416}
417
Jamie Iles280df6b2011-05-20 00:40:19 -0600418static int bgpio_setup_accessors(struct device *dev,
Linus Walleij0f4630f2015-12-04 14:02:58 +0100419 struct gpio_chip *gc,
Andreas Larsson2b78f1e2013-03-15 14:45:38 +0100420 bool byte_be)
Jamie Iles364b5e82011-05-20 00:40:16 -0600421{
Jamie Iles8467afe2011-05-20 00:40:14 -0600422
Linus Walleij0f4630f2015-12-04 14:02:58 +0100423 switch (gc->bgpio_bits) {
Jamie Iles8467afe2011-05-20 00:40:14 -0600424 case 8:
Linus Walleij0f4630f2015-12-04 14:02:58 +0100425 gc->read_reg = bgpio_read8;
426 gc->write_reg = bgpio_write8;
Jamie Iles8467afe2011-05-20 00:40:14 -0600427 break;
428 case 16:
Andreas Larsson2b78f1e2013-03-15 14:45:38 +0100429 if (byte_be) {
Linus Walleij0f4630f2015-12-04 14:02:58 +0100430 gc->read_reg = bgpio_read16be;
431 gc->write_reg = bgpio_write16be;
Andreas Larsson2b78f1e2013-03-15 14:45:38 +0100432 } else {
Linus Walleij0f4630f2015-12-04 14:02:58 +0100433 gc->read_reg = bgpio_read16;
434 gc->write_reg = bgpio_write16;
Andreas Larsson2b78f1e2013-03-15 14:45:38 +0100435 }
Jamie Iles8467afe2011-05-20 00:40:14 -0600436 break;
437 case 32:
Andreas Larsson2b78f1e2013-03-15 14:45:38 +0100438 if (byte_be) {
Linus Walleij0f4630f2015-12-04 14:02:58 +0100439 gc->read_reg = bgpio_read32be;
440 gc->write_reg = bgpio_write32be;
Andreas Larsson2b78f1e2013-03-15 14:45:38 +0100441 } else {
Linus Walleij0f4630f2015-12-04 14:02:58 +0100442 gc->read_reg = bgpio_read32;
443 gc->write_reg = bgpio_write32;
Andreas Larsson2b78f1e2013-03-15 14:45:38 +0100444 }
Jamie Iles8467afe2011-05-20 00:40:14 -0600445 break;
446#if BITS_PER_LONG >= 64
447 case 64:
Andreas Larsson2b78f1e2013-03-15 14:45:38 +0100448 if (byte_be) {
449 dev_err(dev,
450 "64 bit big endian byte order unsupported\n");
451 return -EINVAL;
452 } else {
Linus Walleij0f4630f2015-12-04 14:02:58 +0100453 gc->read_reg = bgpio_read64;
454 gc->write_reg = bgpio_write64;
Andreas Larsson2b78f1e2013-03-15 14:45:38 +0100455 }
Jamie Iles8467afe2011-05-20 00:40:14 -0600456 break;
457#endif /* BITS_PER_LONG >= 64 */
458 default:
Linus Walleij0f4630f2015-12-04 14:02:58 +0100459 dev_err(dev, "unsupported data width %u bits\n", gc->bgpio_bits);
Jamie Iles8467afe2011-05-20 00:40:14 -0600460 return -EINVAL;
461 }
462
Jamie Iles8467afe2011-05-20 00:40:14 -0600463 return 0;
464}
465
Jamie Ilese027d6f2011-05-20 00:40:16 -0600466/*
467 * Create the device and allocate the resources. For setting GPIO's there are
Jamie Ilesdd86a0c2011-05-20 00:40:16 -0600468 * three supported configurations:
Jamie Ilese027d6f2011-05-20 00:40:16 -0600469 *
Jamie Ilesdd86a0c2011-05-20 00:40:16 -0600470 * - single input/output register resource (named "dat").
Jamie Ilese027d6f2011-05-20 00:40:16 -0600471 * - set/clear pair (named "set" and "clr").
Jamie Ilesdd86a0c2011-05-20 00:40:16 -0600472 * - single output register resource and single input resource ("set" and
473 * dat").
Jamie Ilese027d6f2011-05-20 00:40:16 -0600474 *
475 * For the single output register, this drives a 1 by setting a bit and a zero
476 * by clearing a bit. For the set clr pair, this drives a 1 by setting a bit
477 * in the set register and clears it by setting a bit in the clear register.
478 * The configuration is detected by which resources are present.
Jamie Iles31029112011-05-20 00:40:17 -0600479 *
480 * For setting the GPIO direction, there are three supported configurations:
481 *
482 * - simple bidirection GPIO that requires no configuration.
483 * - an output direction register (named "dirout") where a 1 bit
484 * indicates the GPIO is an output.
485 * - an input direction register (named "dirin") where a 1 bit indicates
486 * the GPIO is an input.
Jamie Ilese027d6f2011-05-20 00:40:16 -0600487 */
Linus Walleij0f4630f2015-12-04 14:02:58 +0100488static int bgpio_setup_io(struct gpio_chip *gc,
Jamie Iles280df6b2011-05-20 00:40:19 -0600489 void __iomem *dat,
490 void __iomem *set,
Vladimir Zapolskiyb19e7f52015-04-29 18:34:59 +0300491 void __iomem *clr,
492 unsigned long flags)
Jamie Iles8467afe2011-05-20 00:40:14 -0600493{
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700494
Linus Walleij0f4630f2015-12-04 14:02:58 +0100495 gc->reg_dat = dat;
496 if (!gc->reg_dat)
Jamie Iles280df6b2011-05-20 00:40:19 -0600497 return -EINVAL;
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700498
Jamie Iles280df6b2011-05-20 00:40:19 -0600499 if (set && clr) {
Linus Walleij0f4630f2015-12-04 14:02:58 +0100500 gc->reg_set = set;
501 gc->reg_clr = clr;
502 gc->set = bgpio_set_with_clear;
503 gc->set_multiple = bgpio_set_multiple_with_clear;
Jamie Iles280df6b2011-05-20 00:40:19 -0600504 } else if (set && !clr) {
Linus Walleij0f4630f2015-12-04 14:02:58 +0100505 gc->reg_set = set;
506 gc->set = bgpio_set_set;
507 gc->set_multiple = bgpio_set_multiple_set;
Rabin Vincent91492a42015-07-22 15:05:18 +0200508 } else if (flags & BGPIOF_NO_OUTPUT) {
Linus Walleij0f4630f2015-12-04 14:02:58 +0100509 gc->set = bgpio_set_none;
510 gc->set_multiple = NULL;
Jamie Ilese027d6f2011-05-20 00:40:16 -0600511 } else {
Linus Walleij0f4630f2015-12-04 14:02:58 +0100512 gc->set = bgpio_set;
513 gc->set_multiple = bgpio_set_multiple;
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700514 }
515
Vladimir Zapolskiyb19e7f52015-04-29 18:34:59 +0300516 if (!(flags & BGPIOF_UNREADABLE_REG_SET) &&
Linus Walleij80057cb42017-10-19 23:30:12 +0200517 (flags & BGPIOF_READ_OUTPUT_REG_SET)) {
Linus Walleij0f4630f2015-12-04 14:02:58 +0100518 gc->get = bgpio_get_set;
Linus Walleij80057cb42017-10-19 23:30:12 +0200519 if (!gc->be_bits)
520 gc->get_multiple = bgpio_get_set_multiple;
521 /*
522 * We deliberately avoid assigning the ->get_multiple() call
523 * for big endian mirrored registers which are ALSO reflecting
524 * their value in the set register when used as output. It is
525 * simply too much complexity, let the GPIO core fall back to
526 * reading each line individually in that fringe case.
527 */
528 } else {
Linus Walleij0f4630f2015-12-04 14:02:58 +0100529 gc->get = bgpio_get;
Linus Walleij80057cb42017-10-19 23:30:12 +0200530 if (gc->be_bits)
531 gc->get_multiple = bgpio_get_multiple_be;
532 else
533 gc->get_multiple = bgpio_get_multiple;
534 }
Jamie Ilesdd86a0c2011-05-20 00:40:16 -0600535
Jamie Ilese027d6f2011-05-20 00:40:16 -0600536 return 0;
537}
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700538
Linus Walleij0f4630f2015-12-04 14:02:58 +0100539static int bgpio_setup_direction(struct gpio_chip *gc,
Jamie Iles280df6b2011-05-20 00:40:19 -0600540 void __iomem *dirout,
Rabin Vincent91492a42015-07-22 15:05:18 +0200541 void __iomem *dirin,
542 unsigned long flags)
Jamie Iles31029112011-05-20 00:40:17 -0600543{
Jamie Iles280df6b2011-05-20 00:40:19 -0600544 if (dirout && dirin) {
Jamie Iles31029112011-05-20 00:40:17 -0600545 return -EINVAL;
Jamie Iles280df6b2011-05-20 00:40:19 -0600546 } else if (dirout) {
Linus Walleij0f4630f2015-12-04 14:02:58 +0100547 gc->reg_dir = dirout;
548 gc->direction_output = bgpio_dir_out;
549 gc->direction_input = bgpio_dir_in;
550 gc->get_direction = bgpio_get_dir;
Jamie Iles280df6b2011-05-20 00:40:19 -0600551 } else if (dirin) {
Linus Walleij0f4630f2015-12-04 14:02:58 +0100552 gc->reg_dir = dirin;
Linus Walleijd799a4d2018-08-03 00:52:18 +0200553 gc->direction_output = bgpio_dir_out;
554 gc->direction_input = bgpio_dir_in;
555 gc->get_direction = bgpio_get_dir;
556 gc->bgpio_dir_inverted = true;
Jamie Iles31029112011-05-20 00:40:17 -0600557 } else {
Rabin Vincent91492a42015-07-22 15:05:18 +0200558 if (flags & BGPIOF_NO_OUTPUT)
Linus Walleij0f4630f2015-12-04 14:02:58 +0100559 gc->direction_output = bgpio_dir_out_err;
Rabin Vincent91492a42015-07-22 15:05:18 +0200560 else
Linus Walleij0f4630f2015-12-04 14:02:58 +0100561 gc->direction_output = bgpio_simple_dir_out;
562 gc->direction_input = bgpio_simple_dir_in;
Jamie Iles31029112011-05-20 00:40:17 -0600563 }
564
565 return 0;
566}
567
Anthony Fee7b42e3d2014-05-19 18:49:14 +0100568static int bgpio_request(struct gpio_chip *chip, unsigned gpio_pin)
569{
570 if (gpio_pin < chip->ngpio)
571 return 0;
572
573 return -EINVAL;
574}
575
Linus Walleijd799a4d2018-08-03 00:52:18 +0200576/**
577 * bgpio_init() - Initialize generic GPIO accessor functions
578 * @gc: the GPIO chip to set up
579 * @dev: the parent device of the new GPIO chip (compulsory)
580 * @sz: the size (width) of the MMIO registers in bytes, typically 1, 2 or 4
581 * @dat: MMIO address for the register to READ the value of the GPIO lines, it
582 * is expected that a 1 in the corresponding bit in this register means the
583 * line is asserted
584 * @set: MMIO address for the register to SET the value of the GPIO lines, it is
585 * expected that we write the line with 1 in this register to drive the GPIO line
586 * high.
587 * @clr: MMIO address for the register to CLEAR the value of the GPIO lines, it is
588 * expected that we write the line with 1 in this register to drive the GPIO line
589 * low. It is allowed to leave this address as NULL, in that case the SET register
590 * will be assumed to also clear the GPIO lines, by actively writing the line
591 * with 0.
592 * @dirout: MMIO address for the register to set the line as OUTPUT. It is assumed
593 * that setting a line to 1 in this register will turn that line into an
594 * output line. Conversely, setting the line to 0 will turn that line into
595 * an input. Either this or @dirin can be defined, but never both.
596 * @dirin: MMIO address for the register to set this line as INPUT. It is assumed
597 * that setting a line to 1 in this register will turn that line into an
598 * input line. Conversely, setting the line to 0 will turn that line into
599 * an output. Either this or @dirout can be defined, but never both.
600 * @flags: Different flags that will affect the behaviour of the device, such as
601 * endianness etc.
602 */
Linus Walleij0f4630f2015-12-04 14:02:58 +0100603int bgpio_init(struct gpio_chip *gc, struct device *dev,
Russell King4f5b0482011-09-14 16:22:29 -0700604 unsigned long sz, void __iomem *dat, void __iomem *set,
605 void __iomem *clr, void __iomem *dirout, void __iomem *dirin,
Shawn Guo3e11f7b2012-05-19 21:34:58 +0800606 unsigned long flags)
Jamie Iles280df6b2011-05-20 00:40:19 -0600607{
Jamie Ilese027d6f2011-05-20 00:40:16 -0600608 int ret;
Jamie Ilese027d6f2011-05-20 00:40:16 -0600609
Jamie Iles280df6b2011-05-20 00:40:19 -0600610 if (!is_power_of_2(sz))
611 return -EINVAL;
Jamie Ilese027d6f2011-05-20 00:40:16 -0600612
Linus Walleij0f4630f2015-12-04 14:02:58 +0100613 gc->bgpio_bits = sz * 8;
614 if (gc->bgpio_bits > BITS_PER_LONG)
Jamie Iles280df6b2011-05-20 00:40:19 -0600615 return -EINVAL;
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700616
Linus Walleij0f4630f2015-12-04 14:02:58 +0100617 spin_lock_init(&gc->bgpio_lock);
618 gc->parent = dev;
619 gc->label = dev_name(dev);
620 gc->base = -1;
621 gc->ngpio = gc->bgpio_bits;
622 gc->request = bgpio_request;
Linus Walleij80057cb42017-10-19 23:30:12 +0200623 gc->be_bits = !!(flags & BGPIOF_BIG_ENDIAN);
Jamie Iles280df6b2011-05-20 00:40:19 -0600624
Linus Walleij0f4630f2015-12-04 14:02:58 +0100625 ret = bgpio_setup_io(gc, dat, set, clr, flags);
Jamie Iles280df6b2011-05-20 00:40:19 -0600626 if (ret)
627 return ret;
628
Linus Walleij24efd942017-10-20 16:31:27 +0200629 ret = bgpio_setup_accessors(dev, gc, flags & BGPIOF_BIG_ENDIAN_BYTE_ORDER);
Jamie Iles280df6b2011-05-20 00:40:19 -0600630 if (ret)
631 return ret;
632
Linus Walleij0f4630f2015-12-04 14:02:58 +0100633 ret = bgpio_setup_direction(gc, dirout, dirin, flags);
Jamie Iles31029112011-05-20 00:40:17 -0600634 if (ret)
635 return ret;
636
Linus Walleij0f4630f2015-12-04 14:02:58 +0100637 gc->bgpio_data = gc->read_reg(gc->reg_dat);
638 if (gc->set == bgpio_set_set &&
Shawn Guo3e11f7b2012-05-19 21:34:58 +0800639 !(flags & BGPIOF_UNREADABLE_REG_SET))
Linus Walleij0f4630f2015-12-04 14:02:58 +0100640 gc->bgpio_data = gc->read_reg(gc->reg_set);
641 if (gc->reg_dir && !(flags & BGPIOF_UNREADABLE_REG_DIR))
642 gc->bgpio_dir = gc->read_reg(gc->reg_dir);
Jamie Iles924e7a92011-05-20 00:40:15 -0600643
Jamie Iles280df6b2011-05-20 00:40:19 -0600644 return ret;
645}
646EXPORT_SYMBOL_GPL(bgpio_init);
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700647
Christian Lamparter8f01c9d2016-04-29 02:53:14 +0200648#if IS_ENABLED(CONFIG_GPIO_GENERIC_PLATFORM)
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700649
Jamie Iles280df6b2011-05-20 00:40:19 -0600650static void __iomem *bgpio_map(struct platform_device *pdev,
651 const char *name,
Heiner Kallweit8d240262015-09-30 23:52:36 +0200652 resource_size_t sane_sz)
Jamie Iles280df6b2011-05-20 00:40:19 -0600653{
Jamie Iles280df6b2011-05-20 00:40:19 -0600654 struct resource *r;
Jamie Iles280df6b2011-05-20 00:40:19 -0600655 resource_size_t sz;
Jamie Iles280df6b2011-05-20 00:40:19 -0600656
657 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
Heiner Kallweit8d240262015-09-30 23:52:36 +0200658 if (!r)
Guenter Roeckb2f68b62015-10-21 00:12:00 -0700659 return NULL;
Jamie Iles280df6b2011-05-20 00:40:19 -0600660
661 sz = resource_size(r);
Heiner Kallweit8d240262015-09-30 23:52:36 +0200662 if (sz != sane_sz)
663 return IOMEM_ERR_PTR(-EINVAL);
Jamie Iles280df6b2011-05-20 00:40:19 -0600664
Heiner Kallweit8d240262015-09-30 23:52:36 +0200665 return devm_ioremap_resource(&pdev->dev, r);
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700666}
667
Álvaro Fernández Rojase6986132016-05-13 23:07:11 +0200668#ifdef CONFIG_OF
669static const struct of_device_id bgpio_of_match[] = {
Christian Lamparter05cc9952016-08-03 14:05:57 +0200670 { .compatible = "brcm,bcm6345-gpio" },
Christian Lamparterc0d30ec2016-05-13 23:07:12 +0200671 { .compatible = "wd,mbl-gpio" },
Nathan Sullivanb8c90192017-03-14 11:13:22 -0500672 { .compatible = "ni,169445-nand-gpio" },
Álvaro Fernández Rojase6986132016-05-13 23:07:11 +0200673 { }
674};
675MODULE_DEVICE_TABLE(of, bgpio_of_match);
676
677static struct bgpio_pdata *bgpio_parse_dt(struct platform_device *pdev,
678 unsigned long *flags)
679{
680 struct bgpio_pdata *pdata;
681
682 if (!of_match_device(bgpio_of_match, &pdev->dev))
683 return NULL;
684
685 pdata = devm_kzalloc(&pdev->dev, sizeof(struct bgpio_pdata),
686 GFP_KERNEL);
687 if (!pdata)
688 return ERR_PTR(-ENOMEM);
689
690 pdata->base = -1;
691
Christian Lamparter05cc9952016-08-03 14:05:57 +0200692 if (of_device_is_big_endian(pdev->dev.of_node))
693 *flags |= BGPIOF_BIG_ENDIAN_BYTE_ORDER;
694
Christian Lamparterc0d30ec2016-05-13 23:07:12 +0200695 if (of_property_read_bool(pdev->dev.of_node, "no-output"))
696 *flags |= BGPIOF_NO_OUTPUT;
697
Álvaro Fernández Rojase6986132016-05-13 23:07:11 +0200698 return pdata;
699}
700#else
701static struct bgpio_pdata *bgpio_parse_dt(struct platform_device *pdev,
702 unsigned long *flags)
703{
704 return NULL;
705}
706#endif /* CONFIG_OF */
707
Bill Pemberton38363092012-11-19 13:22:34 -0500708static int bgpio_pdev_probe(struct platform_device *pdev)
Jamie Iles280df6b2011-05-20 00:40:19 -0600709{
710 struct device *dev = &pdev->dev;
711 struct resource *r;
712 void __iomem *dat;
713 void __iomem *set;
714 void __iomem *clr;
715 void __iomem *dirout;
716 void __iomem *dirin;
717 unsigned long sz;
Álvaro Fernández Rojase6986132016-05-13 23:07:11 +0200718 unsigned long flags = 0;
Jamie Iles280df6b2011-05-20 00:40:19 -0600719 int err;
Linus Walleij0f4630f2015-12-04 14:02:58 +0100720 struct gpio_chip *gc;
Álvaro Fernández Rojase6986132016-05-13 23:07:11 +0200721 struct bgpio_pdata *pdata;
722
723 pdata = bgpio_parse_dt(pdev, &flags);
724 if (IS_ERR(pdata))
725 return PTR_ERR(pdata);
726
727 if (!pdata) {
728 pdata = dev_get_platdata(dev);
729 flags = pdev->id_entry->driver_data;
730 }
Jamie Iles280df6b2011-05-20 00:40:19 -0600731
732 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dat");
733 if (!r)
734 return -EINVAL;
735
736 sz = resource_size(r);
737
Heiner Kallweit8d240262015-09-30 23:52:36 +0200738 dat = bgpio_map(pdev, "dat", sz);
739 if (IS_ERR(dat))
740 return PTR_ERR(dat);
Jamie Iles280df6b2011-05-20 00:40:19 -0600741
Heiner Kallweit8d240262015-09-30 23:52:36 +0200742 set = bgpio_map(pdev, "set", sz);
743 if (IS_ERR(set))
744 return PTR_ERR(set);
Jamie Iles280df6b2011-05-20 00:40:19 -0600745
Heiner Kallweit8d240262015-09-30 23:52:36 +0200746 clr = bgpio_map(pdev, "clr", sz);
747 if (IS_ERR(clr))
748 return PTR_ERR(clr);
Jamie Iles280df6b2011-05-20 00:40:19 -0600749
Heiner Kallweit8d240262015-09-30 23:52:36 +0200750 dirout = bgpio_map(pdev, "dirout", sz);
751 if (IS_ERR(dirout))
752 return PTR_ERR(dirout);
Jamie Iles280df6b2011-05-20 00:40:19 -0600753
Heiner Kallweit8d240262015-09-30 23:52:36 +0200754 dirin = bgpio_map(pdev, "dirin", sz);
755 if (IS_ERR(dirin))
756 return PTR_ERR(dirin);
Jamie Iles280df6b2011-05-20 00:40:19 -0600757
Linus Walleij0f4630f2015-12-04 14:02:58 +0100758 gc = devm_kzalloc(&pdev->dev, sizeof(*gc), GFP_KERNEL);
759 if (!gc)
Jamie Iles280df6b2011-05-20 00:40:19 -0600760 return -ENOMEM;
761
Linus Walleij0f4630f2015-12-04 14:02:58 +0100762 err = bgpio_init(gc, dev, sz, dat, set, clr, dirout, dirin, flags);
Jamie Iles280df6b2011-05-20 00:40:19 -0600763 if (err)
764 return err;
765
766 if (pdata) {
Pawel Moll781f6d72014-01-30 13:18:57 +0000767 if (pdata->label)
Linus Walleij0f4630f2015-12-04 14:02:58 +0100768 gc->label = pdata->label;
769 gc->base = pdata->base;
Jamie Iles280df6b2011-05-20 00:40:19 -0600770 if (pdata->ngpio > 0)
Linus Walleij0f4630f2015-12-04 14:02:58 +0100771 gc->ngpio = pdata->ngpio;
Jamie Iles280df6b2011-05-20 00:40:19 -0600772 }
773
Linus Walleij0f4630f2015-12-04 14:02:58 +0100774 platform_set_drvdata(pdev, gc);
Jamie Iles280df6b2011-05-20 00:40:19 -0600775
Laxman Dewanganc05f8132016-02-22 17:43:28 +0530776 return devm_gpiochip_add_data(&pdev->dev, gc, NULL);
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700777}
778
779static const struct platform_device_id bgpio_id_table[] = {
Alexander Shiyan19338532014-03-16 09:10:34 +0400780 {
781 .name = "basic-mmio-gpio",
782 .driver_data = 0,
783 }, {
784 .name = "basic-mmio-gpio-be",
785 .driver_data = BGPIOF_BIG_ENDIAN,
786 },
787 { }
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700788};
789MODULE_DEVICE_TABLE(platform, bgpio_id_table);
790
791static struct platform_driver bgpio_driver = {
792 .driver = {
793 .name = "basic-mmio-gpio",
Álvaro Fernández Rojase6986132016-05-13 23:07:11 +0200794 .of_match_table = of_match_ptr(bgpio_of_match),
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700795 },
796 .id_table = bgpio_id_table,
Jamie Iles280df6b2011-05-20 00:40:19 -0600797 .probe = bgpio_pdev_probe,
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700798};
799
Mark Brown6f614152011-12-08 00:24:00 +0800800module_platform_driver(bgpio_driver);
Jamie Iles280df6b2011-05-20 00:40:19 -0600801
Grant Likelyc103de22011-06-04 18:38:28 -0600802#endif /* CONFIG_GPIO_GENERIC_PLATFORM */
Anton Vorontsovaeec56e2010-10-27 15:33:15 -0700803
804MODULE_DESCRIPTION("Driver for basic memory-mapped GPIO controllers");
805MODULE_AUTHOR("Anton Vorontsov <cbouatmailru@gmail.com>");
806MODULE_LICENSE("GPL");