add chaos_calmer branch
[15.05/openwrt.git] / target / linux / brcm2708 / patches-3.18 / 0002-Add-bcm2708_gpio-driver.patch
1 From 4f339b429583965a8eb7c23474414d0730db1215 Mon Sep 17 00:00:00 2001
2 From: popcornmix <popcornmix@gmail.com>
3 Date: Wed, 8 Oct 2014 18:50:05 +0100
4 Subject: [PATCH 002/114] Add bcm2708_gpio driver
5
6 Signed-off-by: popcornmix <popcornmix@gmail.com>
7
8 bcm2708: Add extension to configure internal pulls
9
10 The bcm2708 gpio controller supports internal pulls to be used as pull-up,
11 pull-down or being entirely disabled. As it can be useful for a driver to
12 change the pull configuration from it's default pull-down state, add an
13 extension which allows configuring the pull per gpio.
14
15 Signed-off-by: Julian Scheel <julian@jusst.de>
16
17 bcm2708-gpio: Revert the use of pinctrl_request_gpio
18
19 In non-DT systems, pinctrl_request_gpio always fails causing
20 "requests probe deferral" messages. In DT systems, it isn't useful
21 because the reference counting is independent of the normal pinctrl
22 pin reservations.
23
24 gpio: Only clear the currently occurring interrupt. Avoids losing interrupts
25
26 See: linux #760
27
28 bcm2708_gpio: Avoid calling irq_unmask for all interrupts
29
30 When setting up the interrupts, specify that the handle_simple_irq
31 handler should be used. This leaves interrupt acknowledgement to
32 the caller, and prevents irq_unmask from being called for all
33 interrupts.
34
35 Issue: linux #760
36 ---
37  arch/arm/mach-bcm2708/Kconfig             |   8 +
38  arch/arm/mach-bcm2708/Makefile            |   1 +
39  arch/arm/mach-bcm2708/bcm2708.c           |  28 ++
40  arch/arm/mach-bcm2708/bcm2708_gpio.c      | 426 ++++++++++++++++++++++++++++++
41  arch/arm/mach-bcm2708/include/mach/gpio.h |  17 ++
42  include/linux/platform_data/bcm2708.h     |  23 ++
43  6 files changed, 503 insertions(+)
44  create mode 100644 arch/arm/mach-bcm2708/bcm2708_gpio.c
45  create mode 100644 arch/arm/mach-bcm2708/include/mach/gpio.h
46  create mode 100644 include/linux/platform_data/bcm2708.h
47
48 --- a/arch/arm/mach-bcm2708/Kconfig
49 +++ b/arch/arm/mach-bcm2708/Kconfig
50 @@ -9,6 +9,14 @@ config MACH_BCM2708
51         help
52           Include support for the Broadcom(R) BCM2708 platform.
53  
54 +config BCM2708_GPIO
55 +       bool "BCM2708 gpio support"
56 +       depends on MACH_BCM2708
57 +       select ARCH_REQUIRE_GPIOLIB
58 +        default y
59 +       help
60 +         Include support for the Broadcom(R) BCM2708 gpio.
61 +
62  config BCM2708_VCMEM
63         bool "Videocore Memory"
64         depends on MACH_BCM2708
65 --- a/arch/arm/mach-bcm2708/Makefile
66 +++ b/arch/arm/mach-bcm2708/Makefile
67 @@ -3,4 +3,5 @@
68  #
69  
70  obj-$(CONFIG_MACH_BCM2708)     += clock.o bcm2708.o armctrl.o vcio.o power.o dma.o
71 +obj-$(CONFIG_BCM2708_GPIO)     += bcm2708_gpio.o
72  obj-$(CONFIG_BCM2708_VCMEM)    += vc_mem.o
73 --- a/arch/arm/mach-bcm2708/bcm2708.c
74 +++ b/arch/arm/mach-bcm2708/bcm2708.c
75 @@ -331,6 +331,31 @@ static struct platform_device bcm2708_vc
76                 },
77  };
78  
79 +#ifdef CONFIG_BCM2708_GPIO
80 +#define BCM_GPIO_DRIVER_NAME "bcm2708_gpio"
81 +
82 +static struct resource bcm2708_gpio_resources[] = {
83 +       [0] = {                 /* general purpose I/O */
84 +              .start = GPIO_BASE,
85 +              .end = GPIO_BASE + SZ_4K - 1,
86 +              .flags = IORESOURCE_MEM,
87 +              },
88 +};
89 +
90 +static u64 gpio_dmamask = DMA_BIT_MASK(DMA_MASK_BITS_COMMON);
91 +
92 +static struct platform_device bcm2708_gpio_device = {
93 +       .name = BCM_GPIO_DRIVER_NAME,
94 +       .id = -1,               /* only one VideoCore I/O area */
95 +       .resource = bcm2708_gpio_resources,
96 +       .num_resources = ARRAY_SIZE(bcm2708_gpio_resources),
97 +       .dev = {
98 +               .dma_mask = &gpio_dmamask,
99 +               .coherent_dma_mask = DMA_BIT_MASK(DMA_MASK_BITS_COMMON),
100 +               },
101 +};
102 +#endif
103 +
104  static struct resource bcm2708_systemtimer_resources[] = {
105         [0] = {                 /* system timer access */
106                .start = ST_BASE,
107 @@ -473,6 +498,9 @@ void __init bcm2708_init(void)
108  
109         bcm_register_device(&bcm2708_dmaman_device);
110         bcm_register_device(&bcm2708_vcio_device);
111 +#ifdef CONFIG_BCM2708_GPIO
112 +       bcm_register_device(&bcm2708_gpio_device);
113 +#endif
114         bcm_register_device(&bcm2708_systemtimer_device);
115         bcm_register_device(&bcm2708_fb_device);
116         bcm_register_device(&bcm2708_usb_device);
117 --- /dev/null
118 +++ b/arch/arm/mach-bcm2708/bcm2708_gpio.c
119 @@ -0,0 +1,426 @@
120 +/*
121 + *  linux/arch/arm/mach-bcm2708/bcm2708_gpio.c
122 + *
123 + *  Copyright (C) 2010 Broadcom
124 + *
125 + * This program is free software; you can redistribute it and/or modify
126 + * it under the terms of the GNU General Public License version 2 as
127 + * published by the Free Software Foundation.
128 + *
129 + */
130 +
131 +#include <linux/spinlock.h>
132 +#include <linux/module.h>
133 +#include <linux/delay.h>
134 +#include <linux/list.h>
135 +#include <linux/io.h>
136 +#include <linux/irq.h>
137 +#include <linux/interrupt.h>
138 +#include <linux/slab.h>
139 +#include <mach/gpio.h>
140 +#include <linux/gpio.h>
141 +#include <linux/platform_device.h>
142 +#include <mach/platform.h>
143 +#include <linux/pinctrl/consumer.h>
144 +
145 +#include <linux/platform_data/bcm2708.h>
146 +
147 +#define BCM_GPIO_DRIVER_NAME "bcm2708_gpio"
148 +#define DRIVER_NAME BCM_GPIO_DRIVER_NAME
149 +#define BCM_GPIO_USE_IRQ 1
150 +
151 +#define GPIOFSEL(x)  (0x00+(x)*4)
152 +#define GPIOSET(x)   (0x1c+(x)*4)
153 +#define GPIOCLR(x)   (0x28+(x)*4)
154 +#define GPIOLEV(x)   (0x34+(x)*4)
155 +#define GPIOEDS(x)   (0x40+(x)*4)
156 +#define GPIOREN(x)   (0x4c+(x)*4)
157 +#define GPIOFEN(x)   (0x58+(x)*4)
158 +#define GPIOHEN(x)   (0x64+(x)*4)
159 +#define GPIOLEN(x)   (0x70+(x)*4)
160 +#define GPIOAREN(x)  (0x7c+(x)*4)
161 +#define GPIOAFEN(x)  (0x88+(x)*4)
162 +#define GPIOUD(x)    (0x94+(x)*4)
163 +#define GPIOUDCLK(x) (0x98+(x)*4)
164 +
165 +#define GPIO_BANKS 2
166 +
167 +enum { GPIO_FSEL_INPUT, GPIO_FSEL_OUTPUT,
168 +       GPIO_FSEL_ALT5, GPIO_FSEL_ALT_4,
169 +       GPIO_FSEL_ALT0, GPIO_FSEL_ALT1,
170 +       GPIO_FSEL_ALT2, GPIO_FSEL_ALT3,
171 +};
172 +
173 +       /* Each of the two spinlocks protects a different set of hardware
174 +        * regiters and data structurs. This decouples the code of the IRQ from
175 +        * the GPIO code. This also makes the case of a GPIO routine call from
176 +        * the IRQ code simpler.
177 +        */
178 +static DEFINE_SPINLOCK(lock);  /* GPIO registers */
179 +
180 +struct bcm2708_gpio {
181 +       struct list_head list;
182 +       void __iomem *base;
183 +       struct gpio_chip gc;
184 +       unsigned long rising[(BCM2708_NR_GPIOS + 31) / 32];
185 +       unsigned long falling[(BCM2708_NR_GPIOS + 31) / 32];
186 +       unsigned long high[(BCM2708_NR_GPIOS + 31) / 32];
187 +       unsigned long low[(BCM2708_NR_GPIOS + 31) / 32];
188 +};
189 +
190 +static int bcm2708_set_function(struct gpio_chip *gc, unsigned offset,
191 +                               int function)
192 +{
193 +       struct bcm2708_gpio *gpio = container_of(gc, struct bcm2708_gpio, gc);
194 +       unsigned long flags;
195 +       unsigned gpiodir;
196 +       unsigned gpio_bank = offset / 10;
197 +       unsigned gpio_field_offset = (offset - 10 * gpio_bank) * 3;
198 +
199 +//printk(KERN_ERR DRIVER_NAME ": bcm2708_gpio_set_function %p (%d,%d)\n", gc, offset, function);
200 +       if (offset >= BCM2708_NR_GPIOS)
201 +               return -EINVAL;
202 +
203 +       spin_lock_irqsave(&lock, flags);
204 +
205 +       gpiodir = readl(gpio->base + GPIOFSEL(gpio_bank));
206 +       gpiodir &= ~(7 << gpio_field_offset);
207 +       gpiodir |= function << gpio_field_offset;
208 +       writel(gpiodir, gpio->base + GPIOFSEL(gpio_bank));
209 +       spin_unlock_irqrestore(&lock, flags);
210 +       gpiodir = readl(gpio->base + GPIOFSEL(gpio_bank));
211 +
212 +       return 0;
213 +}
214 +
215 +static int bcm2708_gpio_dir_in(struct gpio_chip *gc, unsigned offset)
216 +{
217 +       return bcm2708_set_function(gc, offset, GPIO_FSEL_INPUT);
218 +}
219 +
220 +static void bcm2708_gpio_set(struct gpio_chip *gc, unsigned offset, int value);
221 +static int bcm2708_gpio_dir_out(struct gpio_chip *gc, unsigned offset,
222 +                               int value)
223 +{
224 +       int ret;
225 +       ret = bcm2708_set_function(gc, offset, GPIO_FSEL_OUTPUT);
226 +       if (ret >= 0)
227 +               bcm2708_gpio_set(gc, offset, value);
228 +       return ret;
229 +}
230 +
231 +static int bcm2708_gpio_get(struct gpio_chip *gc, unsigned offset)
232 +{
233 +       struct bcm2708_gpio *gpio = container_of(gc, struct bcm2708_gpio, gc);
234 +       unsigned gpio_bank = offset / 32;
235 +       unsigned gpio_field_offset = (offset - 32 * gpio_bank);
236 +       unsigned lev;
237 +
238 +       if (offset >= BCM2708_NR_GPIOS)
239 +               return 0;
240 +       lev = readl(gpio->base + GPIOLEV(gpio_bank));
241 +//printk(KERN_ERR DRIVER_NAME ": bcm2708_gpio_get %p (%d)=%d\n", gc, offset, 0x1 & (lev>>gpio_field_offset));
242 +       return 0x1 & (lev >> gpio_field_offset);
243 +}
244 +
245 +static void bcm2708_gpio_set(struct gpio_chip *gc, unsigned offset, int value)
246 +{
247 +       struct bcm2708_gpio *gpio = container_of(gc, struct bcm2708_gpio, gc);
248 +       unsigned gpio_bank = offset / 32;
249 +       unsigned gpio_field_offset = (offset - 32 * gpio_bank);
250 +//printk(KERN_ERR DRIVER_NAME ": bcm2708_gpio_set %p (%d=%d)\n", gc, offset, value);
251 +       if (offset >= BCM2708_NR_GPIOS)
252 +               return;
253 +       if (value)
254 +               writel(1 << gpio_field_offset, gpio->base + GPIOSET(gpio_bank));
255 +       else
256 +               writel(1 << gpio_field_offset, gpio->base + GPIOCLR(gpio_bank));
257 +}
258 +
259 +/**********************
260 + * extension to configure pullups
261 + */
262 +int bcm2708_gpio_setpull(struct gpio_chip *gc, unsigned offset,
263 +               bcm2708_gpio_pull_t value)
264 +{
265 +       struct bcm2708_gpio *gpio = container_of(gc, struct bcm2708_gpio, gc);
266 +       unsigned gpio_bank = offset / 32;
267 +       unsigned gpio_field_offset = (offset - 32 * gpio_bank);
268 +
269 +       if (offset >= BCM2708_NR_GPIOS)
270 +               return -EINVAL;
271 +
272 +       switch (value) {
273 +       case BCM2708_PULL_UP:
274 +               writel(2, gpio->base + GPIOUD(0));
275 +               break;
276 +       case BCM2708_PULL_DOWN:
277 +               writel(1, gpio->base + GPIOUD(0));
278 +               break;
279 +       case BCM2708_PULL_OFF:
280 +               writel(0, gpio->base + GPIOUD(0));
281 +               break;
282 +       }
283 +
284 +       udelay(5);
285 +       writel(1 << gpio_field_offset, gpio->base + GPIOUDCLK(gpio_bank));
286 +       udelay(5);
287 +       writel(0, gpio->base + GPIOUD(0));
288 +       writel(0 << gpio_field_offset, gpio->base + GPIOUDCLK(gpio_bank));
289 +
290 +       return 0;
291 +}
292 +EXPORT_SYMBOL(bcm2708_gpio_setpull);
293 +
294 +/*************************************************************************************************************************
295 + * bcm2708 GPIO IRQ
296 + */
297 +
298 +#if BCM_GPIO_USE_IRQ
299 +
300 +static int bcm2708_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
301 +{
302 +       return gpio_to_irq(gpio);
303 +}
304 +
305 +static int bcm2708_gpio_irq_set_type(struct irq_data *d, unsigned type)
306 +{
307 +       unsigned irq = d->irq;
308 +       struct bcm2708_gpio *gpio = irq_get_chip_data(irq);
309 +       unsigned gn = irq_to_gpio(irq);
310 +       unsigned gb = gn / 32;
311 +       unsigned go = gn % 32;
312 +
313 +       gpio->rising[gb]  &= ~(1 << go);
314 +       gpio->falling[gb] &= ~(1 << go);
315 +       gpio->high[gb]    &= ~(1 << go);
316 +       gpio->low[gb]     &= ~(1 << go);
317 +
318 +       if (type & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING | IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH))
319 +               return -EINVAL;
320 +
321 +       if (type & IRQ_TYPE_EDGE_RISING)
322 +               gpio->rising[gb] |= (1 << go);
323 +       if (type & IRQ_TYPE_EDGE_FALLING)
324 +               gpio->falling[gb] |= (1 << go);
325 +       if (type & IRQ_TYPE_LEVEL_HIGH)
326 +               gpio->high[gb] |= (1 << go);
327 +       if (type & IRQ_TYPE_LEVEL_LOW)
328 +               gpio->low[gb] |= (1 << go);
329 +       return 0;
330 +}
331 +
332 +static void bcm2708_gpio_irq_mask(struct irq_data *d)
333 +{
334 +       unsigned irq = d->irq;
335 +       struct bcm2708_gpio *gpio = irq_get_chip_data(irq);
336 +       unsigned gn = irq_to_gpio(irq);
337 +       unsigned gb = gn / 32;
338 +       unsigned long rising  = readl(gpio->base + GPIOREN(gb));
339 +       unsigned long falling = readl(gpio->base + GPIOFEN(gb));
340 +       unsigned long high    = readl(gpio->base + GPIOHEN(gb));
341 +       unsigned long low     = readl(gpio->base + GPIOLEN(gb));
342 +
343 +       gn = gn % 32;
344 +
345 +       writel(rising  & ~(1 << gn), gpio->base + GPIOREN(gb));
346 +       writel(falling & ~(1 << gn), gpio->base + GPIOFEN(gb));
347 +       writel(high    & ~(1 << gn), gpio->base + GPIOHEN(gb));
348 +       writel(low     & ~(1 << gn), gpio->base + GPIOLEN(gb));
349 +}
350 +
351 +static void bcm2708_gpio_irq_unmask(struct irq_data *d)
352 +{
353 +       unsigned irq = d->irq;
354 +       struct bcm2708_gpio *gpio = irq_get_chip_data(irq);
355 +       unsigned gn = irq_to_gpio(irq);
356 +       unsigned gb = gn / 32;
357 +       unsigned go = gn % 32;
358 +       unsigned long rising  = readl(gpio->base + GPIOREN(gb));
359 +       unsigned long falling = readl(gpio->base + GPIOFEN(gb));
360 +       unsigned long high    = readl(gpio->base + GPIOHEN(gb));
361 +       unsigned long low     = readl(gpio->base + GPIOLEN(gb));
362 +
363 +       if (gpio->rising[gb] & (1 << go)) {
364 +               writel(rising |  (1 << go), gpio->base + GPIOREN(gb));
365 +       } else {
366 +               writel(rising & ~(1 << go), gpio->base + GPIOREN(gb));
367 +       }
368 +
369 +       if (gpio->falling[gb] & (1 << go)) {
370 +               writel(falling |  (1 << go), gpio->base + GPIOFEN(gb));
371 +       } else {
372 +               writel(falling & ~(1 << go), gpio->base + GPIOFEN(gb));
373 +       }
374 +
375 +       if (gpio->high[gb] & (1 << go)) {
376 +               writel(high |  (1 << go), gpio->base + GPIOHEN(gb));
377 +       } else {
378 +               writel(high & ~(1 << go), gpio->base + GPIOHEN(gb));
379 +       }
380 +
381 +       if (gpio->low[gb] & (1 << go)) {
382 +               writel(low |  (1 << go), gpio->base + GPIOLEN(gb));
383 +       } else {
384 +               writel(low & ~(1 << go), gpio->base + GPIOLEN(gb));
385 +       }
386 +}
387 +
388 +static struct irq_chip bcm2708_irqchip = {
389 +       .name = "GPIO",
390 +       .irq_enable = bcm2708_gpio_irq_unmask,
391 +       .irq_disable = bcm2708_gpio_irq_mask,
392 +       .irq_unmask = bcm2708_gpio_irq_unmask,
393 +       .irq_mask = bcm2708_gpio_irq_mask,
394 +       .irq_set_type = bcm2708_gpio_irq_set_type,
395 +};
396 +
397 +static irqreturn_t bcm2708_gpio_interrupt(int irq, void *dev_id)
398 +{
399 +       unsigned long edsr;
400 +       unsigned bank;
401 +       int i;
402 +       unsigned gpio;
403 +       unsigned level_bits;
404 +       struct bcm2708_gpio *gpio_data = dev_id;
405 +
406 +       for (bank = 0; bank < GPIO_BANKS; bank++) {
407 +               edsr = readl(__io_address(GPIO_BASE) + GPIOEDS(bank));
408 +               level_bits = gpio_data->high[bank] | gpio_data->low[bank];
409 +
410 +               for_each_set_bit(i, &edsr, 32) {
411 +                       gpio = i + bank * 32;
412 +                       /* ack edge triggered IRQs immediately */
413 +                       if (!(level_bits & (1<<i)))
414 +                               writel(1<<i,
415 +                                      __io_address(GPIO_BASE) + GPIOEDS(bank));
416 +                       generic_handle_irq(gpio_to_irq(gpio));
417 +                       /* ack level triggered IRQ after handling them */
418 +                       if (level_bits & (1<<i))
419 +                               writel(1<<i,
420 +                                      __io_address(GPIO_BASE) + GPIOEDS(bank));
421 +               }
422 +       }
423 +       return IRQ_HANDLED;
424 +}
425 +
426 +static struct irqaction bcm2708_gpio_irq = {
427 +       .name = "BCM2708 GPIO catchall handler",
428 +       .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
429 +       .handler = bcm2708_gpio_interrupt,
430 +};
431 +
432 +static void bcm2708_gpio_irq_init(struct bcm2708_gpio *ucb)
433 +{
434 +       unsigned irq;
435 +
436 +       ucb->gc.to_irq = bcm2708_gpio_to_irq;
437 +
438 +       for (irq = GPIO_IRQ_START; irq < (GPIO_IRQ_START + GPIO_IRQS); irq++) {
439 +               irq_set_chip_data(irq, ucb);
440 +               irq_set_chip_and_handler(irq, &bcm2708_irqchip,
441 +                                        handle_simple_irq);
442 +               set_irq_flags(irq, IRQF_VALID);
443 +       }
444 +
445 +       bcm2708_gpio_irq.dev_id = ucb;
446 +       setup_irq(IRQ_GPIO3, &bcm2708_gpio_irq);
447 +}
448 +
449 +#else
450 +
451 +static void bcm2708_gpio_irq_init(struct bcm2708_gpio *ucb)
452 +{
453 +}
454 +
455 +#endif /* #if BCM_GPIO_USE_IRQ ***************************************************************************************************************** */
456 +
457 +static int bcm2708_gpio_probe(struct platform_device *dev)
458 +{
459 +       struct bcm2708_gpio *ucb;
460 +       struct resource *res;
461 +       int bank;
462 +       int err = 0;
463 +
464 +       printk(KERN_INFO DRIVER_NAME ": bcm2708_gpio_probe %p\n", dev);
465 +
466 +       ucb = kzalloc(sizeof(*ucb), GFP_KERNEL);
467 +       if (NULL == ucb) {
468 +               printk(KERN_ERR DRIVER_NAME ": failed to allocate "
469 +                      "mailbox memory\n");
470 +               err = -ENOMEM;
471 +               goto err;
472 +       }
473 +
474 +       res = platform_get_resource(dev, IORESOURCE_MEM, 0);
475 +
476 +       platform_set_drvdata(dev, ucb);
477 +       ucb->base = __io_address(GPIO_BASE);
478 +
479 +       ucb->gc.label = "bcm2708_gpio";
480 +       ucb->gc.base = 0;
481 +       ucb->gc.ngpio = BCM2708_NR_GPIOS;
482 +       ucb->gc.owner = THIS_MODULE;
483 +
484 +       ucb->gc.direction_input = bcm2708_gpio_dir_in;
485 +       ucb->gc.direction_output = bcm2708_gpio_dir_out;
486 +       ucb->gc.get = bcm2708_gpio_get;
487 +       ucb->gc.set = bcm2708_gpio_set;
488 +       ucb->gc.can_sleep = 0;
489 +
490 +       for (bank = 0; bank < GPIO_BANKS; bank++) {
491 +               writel(0, ucb->base + GPIOREN(bank));
492 +               writel(0, ucb->base + GPIOFEN(bank));
493 +               writel(0, ucb->base + GPIOHEN(bank));
494 +               writel(0, ucb->base + GPIOLEN(bank));
495 +               writel(0, ucb->base + GPIOAREN(bank));
496 +               writel(0, ucb->base + GPIOAFEN(bank));
497 +               writel(~0, ucb->base + GPIOEDS(bank));
498 +       }
499 +
500 +       bcm2708_gpio_irq_init(ucb);
501 +
502 +       err = gpiochip_add(&ucb->gc);
503 +
504 +err:
505 +       return err;
506 +
507 +}
508 +
509 +static int bcm2708_gpio_remove(struct platform_device *dev)
510 +{
511 +       int err = 0;
512 +       struct bcm2708_gpio *ucb = platform_get_drvdata(dev);
513 +
514 +       printk(KERN_ERR DRIVER_NAME ": bcm2708_gpio_remove %p\n", dev);
515 +
516 +       gpiochip_remove(&ucb->gc);
517 +
518 +       platform_set_drvdata(dev, NULL);
519 +       kfree(ucb);
520 +
521 +       return err;
522 +}
523 +
524 +static struct platform_driver bcm2708_gpio_driver = {
525 +       .probe = bcm2708_gpio_probe,
526 +       .remove = bcm2708_gpio_remove,
527 +       .driver = {
528 +                  .name = "bcm2708_gpio"},
529 +};
530 +
531 +static int __init bcm2708_gpio_init(void)
532 +{
533 +       return platform_driver_register(&bcm2708_gpio_driver);
534 +}
535 +
536 +static void __exit bcm2708_gpio_exit(void)
537 +{
538 +       platform_driver_unregister(&bcm2708_gpio_driver);
539 +}
540 +
541 +module_init(bcm2708_gpio_init);
542 +module_exit(bcm2708_gpio_exit);
543 +
544 +MODULE_DESCRIPTION("Broadcom BCM2708 GPIO driver");
545 +MODULE_LICENSE("GPL");
546 --- /dev/null
547 +++ b/arch/arm/mach-bcm2708/include/mach/gpio.h
548 @@ -0,0 +1,17 @@
549 +/*
550 + * arch/arm/mach-bcm2708/include/mach/gpio.h
551 + *
552 + * This file is licensed under the terms of the GNU General Public
553 + * License version 2.  This program is licensed "as is" without any
554 + * warranty of any kind, whether express or implied.
555 + */
556 +
557 +#ifndef __ASM_ARCH_GPIO_H
558 +#define __ASM_ARCH_GPIO_H
559 +
560 +#define BCM2708_NR_GPIOS 54 // number of gpio lines
561 +
562 +#define gpio_to_irq(x) ((x) + GPIO_IRQ_START)
563 +#define irq_to_gpio(x) ((x) - GPIO_IRQ_START)
564 +
565 +#endif
566 --- /dev/null
567 +++ b/include/linux/platform_data/bcm2708.h
568 @@ -0,0 +1,23 @@
569 +/*
570 + * include/linux/platform_data/bcm2708.h
571 + *
572 + * This program is free software; you can redistribute it and/or modify
573 + * it under the terms of the GNU General Public License version 2 as
574 + * published by the Free Software Foundation.
575 + *
576 + * (C) 2014 Julian Scheel <julian@jusst.de>
577 + *
578 + */
579 +#ifndef __BCM2708_H_
580 +#define __BCM2708_H_
581 +
582 +typedef enum {
583 +       BCM2708_PULL_OFF,
584 +       BCM2708_PULL_UP,
585 +       BCM2708_PULL_DOWN
586 +} bcm2708_gpio_pull_t;
587 +
588 +extern int bcm2708_gpio_setpull(struct gpio_chip *gc, unsigned offset,
589 +               bcm2708_gpio_pull_t value);
590 +
591 +#endif