Linux 3.8-rc7
[cris-mirror.git] / arch / arm / mach-ux500 / devices-common.c
blob16b5f71e6974d5cfee37dc7b64739946c3683f1d
1 /*
2 * Copyright (C) ST-Ericsson SA 2010
4 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
5 * License terms: GNU General Public License (GPL), version 2.
6 */
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>
14 #include <linux/platform_data/pinctrl-nomadik.h>
16 #include <mach/hardware.h>
17 #include <mach/irqs.h>
19 #include "devices-common.h"
21 static struct platform_device *
22 dbx500_add_gpio(struct device *parent, int id, resource_size_t addr, int irq,
23 struct nmk_gpio_platform_data *pdata)
25 struct resource resources[] = {
27 .start = addr,
28 .end = addr + 127,
29 .flags = IORESOURCE_MEM,
32 .start = irq,
33 .end = irq,
34 .flags = IORESOURCE_IRQ,
38 return platform_device_register_resndata(
39 parent,
40 "gpio",
41 id,
42 resources,
43 ARRAY_SIZE(resources),
44 pdata,
45 sizeof(*pdata));
48 void dbx500_add_gpios(struct device *parent, resource_size_t *base, int num,
49 int irq, struct nmk_gpio_platform_data *pdata)
51 int first = 0;
52 int i;
54 for (i = 0; i < num; i++, first += 32, irq++) {
55 pdata->first_gpio = first;
56 pdata->first_irq = NOMADIK_GPIO_TO_IRQ(first);
57 pdata->num_gpio = 32;
59 dbx500_add_gpio(parent, i, base[i], irq, pdata);