blob: dfdd4a54668dfb4c85dfdb9a703f714b40a69bdc [file] [log] [blame]
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +05301/*
2 * Copyright (C) ST-Ericsson SA 2010
3 *
4 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
5 * License terms: GNU General Public License (GPL), version 2.
6 */
7
8#include <linux/kernel.h>
9#include <linux/dma-mapping.h>
10#include <linux/err.h>
11#include <linux/irq.h>
12#include <linux/slab.h>
13#include <linux/platform_device.h>
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053014
Linus Walleij0f332862011-08-22 08:33:30 +010015#include <plat/gpio-nomadik.h>
Rabin Vincent01afdd12010-12-08 11:07:55 +053016
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053017#include <mach/hardware.h>
18
19#include "devices-common.h"
20
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053021static struct platform_device *
Lee Jones18403422012-02-06 11:22:21 -080022dbx500_add_gpio(struct device *parent, int id, resource_size_t addr, int irq,
Rabin Vincent01afdd12010-12-08 11:07:55 +053023 struct nmk_gpio_platform_data *pdata)
24{
25 struct resource resources[] = {
26 {
27 .start = addr,
28 .end = addr + 127,
29 .flags = IORESOURCE_MEM,
30 },
31 {
32 .start = irq,
33 .end = irq,
34 .flags = IORESOURCE_IRQ,
35 }
36 };
37
Lee Jonesb024a0c2012-02-06 11:22:25 -080038 return platform_device_register_resndata(
39 parent,
40 "gpio",
41 id,
42 resources,
43 ARRAY_SIZE(resources),
44 pdata,
45 sizeof(*pdata));
Rabin Vincent01afdd12010-12-08 11:07:55 +053046}
47
Lee Jones18403422012-02-06 11:22:21 -080048void dbx500_add_gpios(struct device *parent, resource_size_t *base, int num,
49 int irq, struct nmk_gpio_platform_data *pdata)
Rabin Vincent01afdd12010-12-08 11:07:55 +053050{
51 int first = 0;
52 int i;
53
54 for (i = 0; i < num; i++, first += 32, irq++) {
55 pdata->first_gpio = first;
56 pdata->first_irq = NOMADIK_GPIO_TO_IRQ(first);
Rabin Vincente493e062010-03-18 12:35:22 +053057 pdata->num_gpio = 32;
Rabin Vincent01afdd12010-12-08 11:07:55 +053058
Lee Jones18403422012-02-06 11:22:21 -080059 dbx500_add_gpio(parent, i, base[i], irq, pdata);
Rabin Vincent01afdd12010-12-08 11:07:55 +053060 }
61}