Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 1 | /* |
| 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> |
Linus Walleij | 7cb15e1 | 2012-10-10 14:27:58 +0200 | [diff] [blame] | 14 | #include <linux/platform_data/pinctrl-nomadik.h> |
Rabin Vincent | 01afdd1 | 2010-12-08 11:07:55 +0530 | [diff] [blame] | 15 | |
Arnd Bergmann | eba52748b | 2013-03-21 22:51:08 +0100 | [diff] [blame] | 16 | #include "irqs.h" |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 17 | |
| 18 | #include "devices-common.h" |
| 19 | |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 20 | static struct platform_device * |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 21 | dbx500_add_gpio(struct device *parent, int id, resource_size_t addr, int irq, |
Rabin Vincent | 01afdd1 | 2010-12-08 11:07:55 +0530 | [diff] [blame] | 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 | |
Lee Jones | b024a0c | 2012-02-06 11:22:25 -0800 | [diff] [blame] | 37 | return platform_device_register_resndata( |
| 38 | parent, |
| 39 | "gpio", |
| 40 | id, |
| 41 | resources, |
| 42 | ARRAY_SIZE(resources), |
| 43 | pdata, |
| 44 | sizeof(*pdata)); |
Rabin Vincent | 01afdd1 | 2010-12-08 11:07:55 +0530 | [diff] [blame] | 45 | } |
| 46 | |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 47 | void dbx500_add_gpios(struct device *parent, resource_size_t *base, int num, |
| 48 | int irq, struct nmk_gpio_platform_data *pdata) |
Rabin Vincent | 01afdd1 | 2010-12-08 11:07:55 +0530 | [diff] [blame] | 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); |
Rabin Vincent | e493e06 | 2010-03-18 12:35:22 +0530 | [diff] [blame] | 56 | pdata->num_gpio = 32; |
Rabin Vincent | 01afdd1 | 2010-12-08 11:07:55 +0530 | [diff] [blame] | 57 | |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 58 | dbx500_add_gpio(parent, i, base[i], irq, pdata); |
Rabin Vincent | 01afdd1 | 2010-12-08 11:07:55 +0530 | [diff] [blame] | 59 | } |
| 60 | } |