aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-ux500/devices-common.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-01-06 19:50:35 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2011-01-06 19:50:35 -0500
commit3c0cb7c31c206aaedb967e44b98442bbeb17a6c4 (patch)
tree3ecba45d7ffae4fba4a5aafaef4af5b0b1105bde /arch/arm/mach-ux500/devices-common.c
parentf70f5b9dc74ca7d0a64c4ead3fb28da09dc1b234 (diff)
parent404a02cbd2ae8bf256a2fa1169bdfe86bb5ebb34 (diff)
Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm
* 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm: (416 commits) ARM: DMA: add support for DMA debugging ARM: PL011: add DMA burst threshold support for ST variants ARM: PL011: Add support for transmit DMA ARM: PL011: Ensure IRQs are disabled in UART interrupt handler ARM: PL011: Separate hardware FIFO size from TTY FIFO size ARM: PL011: Allow better handling of vendor data ARM: PL011: Ensure error flags are clear at startup ARM: PL011: include revision number in boot-time port printk ARM: vexpress: add sched_clock() for Versatile Express ARM i.MX53: Make MX53 EVK bootable ARM i.MX53: Some bug fix about MX53 MSL code ARM: 6607/1: sa1100: Update platform device registration ARM: 6606/1: sa1100: Fix platform device registration ARM i.MX51: rename IPU irqs ARM i.MX51: Add ipu clock support ARM: imx/mx27_3ds: Add PMIC support ARM: DMA: Replace page_to_dma()/dma_to_page() with pfn_to_dma()/dma_to_pfn() mx51: fix usb clock support MX51: Add support for usb host 2 arch/arm/plat-mxc/ehci.c: fix errors/typos ...
Diffstat (limited to 'arch/arm/mach-ux500/devices-common.c')
-rw-r--r--arch/arm/mach-ux500/devices-common.c145
1 files changed, 145 insertions, 0 deletions
diff --git a/arch/arm/mach-ux500/devices-common.c b/arch/arm/mach-ux500/devices-common.c
new file mode 100644
index 000000000000..fe69f5fac1bb
--- /dev/null
+++ b/arch/arm/mach-ux500/devices-common.c
@@ -0,0 +1,145 @@
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>
14#include <linux/amba/bus.h>
15
16#include <plat/gpio.h>
17
18#include <mach/hardware.h>
19
20#include "devices-common.h"
21
22struct amba_device *
23dbx500_add_amba_device(const char *name, resource_size_t base,
24 int irq, void *pdata, unsigned int periphid)
25{
26 struct amba_device *dev;
27 int ret;
28
29 dev = kzalloc(sizeof *dev, GFP_KERNEL);
30 if (!dev)
31 return ERR_PTR(-ENOMEM);
32
33 dev->dev.init_name = name;
34
35 dev->res.start = base;
36 dev->res.end = base + SZ_4K - 1;
37 dev->res.flags = IORESOURCE_MEM;
38
39 dev->dma_mask = DMA_BIT_MASK(32);
40 dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
41
42 dev->irq[0] = irq;
43 dev->irq[1] = NO_IRQ;
44
45 dev->periphid = periphid;
46
47 dev->dev.platform_data = pdata;
48
49 ret = amba_device_register(dev, &iomem_resource);
50 if (ret) {
51 kfree(dev);
52 return ERR_PTR(ret);
53 }
54
55 return dev;
56}
57
58static struct platform_device *
59dbx500_add_platform_device(const char *name, int id, void *pdata,
60 struct resource *res, int resnum)
61{
62 struct platform_device *dev;
63 int ret;
64
65 dev = platform_device_alloc(name, id);
66 if (!dev)
67 return ERR_PTR(-ENOMEM);
68
69 dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
70 dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
71
72 ret = platform_device_add_resources(dev, res, resnum);
73 if (ret)
74 goto out_free;
75
76 dev->dev.platform_data = pdata;
77
78 ret = platform_device_add(dev);
79 if (ret)
80 goto out_free;
81
82 return dev;
83
84out_free:
85 platform_device_put(dev);
86 return ERR_PTR(ret);
87}
88
89struct platform_device *
90dbx500_add_platform_device_4k1irq(const char *name, int id,
91 resource_size_t base,
92 int irq, void *pdata)
93{
94 struct resource resources[] = {
95 [0] = {
96 .start = base,
97 .end = base + SZ_4K - 1,
98 .flags = IORESOURCE_MEM,
99 },
100 [1] = {
101 .start = irq,
102 .end = irq,
103 .flags = IORESOURCE_IRQ,
104 }
105 };
106
107 return dbx500_add_platform_device(name, id, pdata, resources,
108 ARRAY_SIZE(resources));
109}
110
111static struct platform_device *
112dbx500_add_gpio(int id, resource_size_t addr, int irq,
113 struct nmk_gpio_platform_data *pdata)
114{
115 struct resource resources[] = {
116 {
117 .start = addr,
118 .end = addr + 127,
119 .flags = IORESOURCE_MEM,
120 },
121 {
122 .start = irq,
123 .end = irq,
124 .flags = IORESOURCE_IRQ,
125 }
126 };
127
128 return platform_device_register_resndata(NULL, "gpio", id,
129 resources, ARRAY_SIZE(resources),
130 pdata, sizeof(*pdata));
131}
132
133void dbx500_add_gpios(resource_size_t *base, int num, int irq,
134 struct nmk_gpio_platform_data *pdata)
135{
136 int first = 0;
137 int i;
138
139 for (i = 0; i < num; i++, first += 32, irq++) {
140 pdata->first_gpio = first;
141 pdata->first_irq = NOMADIK_GPIO_TO_IRQ(first);
142
143 dbx500_add_gpio(i, base[i], irq, pdata);
144 }
145}