1
2
3
4
5
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>
14#include <linux/platform_data/pinctrl-nomadik.h>
15
16#include "irqs.h"
17
18#include "devices-common.h"
19
20static struct platform_device *
21dbx500_add_gpio(struct device *parent, int id, resource_size_t addr, int irq,
22 struct nmk_gpio_platform_data *pdata)
23{
24 struct resource resources[] = {
25 {
26 .start = addr,
27 .end = addr + 127,
28 .flags = IORESOURCE_MEM,
29 },
30 {
31 .start = irq,
32 .end = irq,
33 .flags = IORESOURCE_IRQ,
34 }
35 };
36
37 return platform_device_register_resndata(
38 parent,
39 "gpio",
40 id,
41 resources,
42 ARRAY_SIZE(resources),
43 pdata,
44 sizeof(*pdata));
45}
46
47void dbx500_add_gpios(struct device *parent, resource_size_t *base, int num,
48 int irq, struct nmk_gpio_platform_data *pdata)
49{
50 int first = 0;
51 int i;
52
53 for (i = 0; i < num; i++, first += 32, irq++) {
54 pdata->first_gpio = first;
55 pdata->first_irq = NOMADIK_GPIO_TO_IRQ(first);
56 pdata->num_gpio = 32;
57
58 dbx500_add_gpio(parent, i, base[i], irq, pdata);
59 }
60}
61