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.
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>
16 #include <plat/gpio-nomadik.h>
18 #include <mach/hardware.h>
20 #include "devices-common.h"
23 dbx500_add_amba_device(const char *name
, resource_size_t base
,
24 int irq
, void *pdata
, unsigned int periphid
)
26 struct amba_device
*dev
;
29 dev
= amba_device_alloc(name
, base
, SZ_4K
);
31 return ERR_PTR(-ENOMEM
);
33 dev
->dma_mask
= DMA_BIT_MASK(32);
34 dev
->dev
.coherent_dma_mask
= DMA_BIT_MASK(32);
38 dev
->periphid
= periphid
;
40 dev
->dev
.platform_data
= pdata
;
42 ret
= amba_device_add(dev
, &iomem_resource
);
51 static struct platform_device
*
52 dbx500_add_platform_device(const char *name
, int id
, void *pdata
,
53 struct resource
*res
, int resnum
)
55 struct platform_device
*dev
;
58 dev
= platform_device_alloc(name
, id
);
60 return ERR_PTR(-ENOMEM
);
62 dev
->dev
.coherent_dma_mask
= DMA_BIT_MASK(32);
63 dev
->dev
.dma_mask
= &dev
->dev
.coherent_dma_mask
;
65 ret
= platform_device_add_resources(dev
, res
, resnum
);
69 dev
->dev
.platform_data
= pdata
;
71 ret
= platform_device_add(dev
);
78 platform_device_put(dev
);
82 struct platform_device
*
83 dbx500_add_platform_device_4k1irq(const char *name
, int id
,
87 struct resource resources
[] = {
90 .end
= base
+ SZ_4K
- 1,
91 .flags
= IORESOURCE_MEM
,
96 .flags
= IORESOURCE_IRQ
,
100 return dbx500_add_platform_device(name
, id
, pdata
, resources
,
101 ARRAY_SIZE(resources
));
104 static struct platform_device
*
105 dbx500_add_gpio(int id
, resource_size_t addr
, int irq
,
106 struct nmk_gpio_platform_data
*pdata
)
108 struct resource resources
[] = {
112 .flags
= IORESOURCE_MEM
,
117 .flags
= IORESOURCE_IRQ
,
121 return platform_device_register_resndata(NULL
, "gpio", id
,
122 resources
, ARRAY_SIZE(resources
),
123 pdata
, sizeof(*pdata
));
126 void dbx500_add_gpios(resource_size_t
*base
, int num
, int irq
,
127 struct nmk_gpio_platform_data
*pdata
)
132 for (i
= 0; i
< num
; i
++, first
+= 32, irq
++) {
133 pdata
->first_gpio
= first
;
134 pdata
->first_irq
= NOMADIK_GPIO_TO_IRQ(first
);
135 pdata
->num_gpio
= 32;
137 dbx500_add_gpio(i
, base
[i
], irq
, pdata
);
This page took 0.049102 seconds and 6 git commands to generate.