diff options
Diffstat (limited to 'arch/arm/mach-ux500/devices-common.c')
-rw-r--r-- | arch/arm/mach-ux500/devices-common.c | 79 |
1 files changed, 17 insertions, 62 deletions
diff --git a/arch/arm/mach-ux500/devices-common.c b/arch/arm/mach-ux500/devices-common.c index 898a64517b09..c5312a4b49f5 100644 --- a/arch/arm/mach-ux500/devices-common.c +++ b/arch/arm/mach-ux500/devices-common.c | |||
@@ -20,8 +20,9 @@ | |||
20 | #include "devices-common.h" | 20 | #include "devices-common.h" |
21 | 21 | ||
22 | struct amba_device * | 22 | struct amba_device * |
23 | dbx500_add_amba_device(const char *name, resource_size_t base, | 23 | dbx500_add_amba_device(struct device *parent, const char *name, |
24 | int irq, void *pdata, unsigned int periphid) | 24 | resource_size_t base, int irq, void *pdata, |
25 | unsigned int periphid) | ||
25 | { | 26 | { |
26 | struct amba_device *dev; | 27 | struct amba_device *dev; |
27 | int ret; | 28 | int ret; |
@@ -39,6 +40,8 @@ dbx500_add_amba_device(const char *name, resource_size_t base, | |||
39 | 40 | ||
40 | dev->dev.platform_data = pdata; | 41 | dev->dev.platform_data = pdata; |
41 | 42 | ||
43 | dev->dev.parent = parent; | ||
44 | |||
42 | ret = amba_device_add(dev, &iomem_resource); | 45 | ret = amba_device_add(dev, &iomem_resource); |
43 | if (ret) { | 46 | if (ret) { |
44 | amba_device_put(dev); | 47 | amba_device_put(dev); |
@@ -49,60 +52,7 @@ dbx500_add_amba_device(const char *name, resource_size_t base, | |||
49 | } | 52 | } |
50 | 53 | ||
51 | static struct platform_device * | 54 | static struct platform_device * |
52 | dbx500_add_platform_device(const char *name, int id, void *pdata, | 55 | dbx500_add_gpio(struct device *parent, int id, resource_size_t addr, int irq, |
53 | struct resource *res, int resnum) | ||
54 | { | ||
55 | struct platform_device *dev; | ||
56 | int ret; | ||
57 | |||
58 | dev = platform_device_alloc(name, id); | ||
59 | if (!dev) | ||
60 | return ERR_PTR(-ENOMEM); | ||
61 | |||
62 | dev->dev.coherent_dma_mask = DMA_BIT_MASK(32); | ||
63 | dev->dev.dma_mask = &dev->dev.coherent_dma_mask; | ||
64 | |||
65 | ret = platform_device_add_resources(dev, res, resnum); | ||
66 | if (ret) | ||
67 | goto out_free; | ||
68 | |||
69 | dev->dev.platform_data = pdata; | ||
70 | |||
71 | ret = platform_device_add(dev); | ||
72 | if (ret) | ||
73 | goto out_free; | ||
74 | |||
75 | return dev; | ||
76 | |||
77 | out_free: | ||
78 | platform_device_put(dev); | ||
79 | return ERR_PTR(ret); | ||
80 | } | ||
81 | |||
82 | struct platform_device * | ||
83 | dbx500_add_platform_device_4k1irq(const char *name, int id, | ||
84 | resource_size_t base, | ||
85 | int irq, void *pdata) | ||
86 | { | ||
87 | struct resource resources[] = { | ||
88 | [0] = { | ||
89 | .start = base, | ||
90 | .end = base + SZ_4K - 1, | ||
91 | .flags = IORESOURCE_MEM, | ||
92 | }, | ||
93 | [1] = { | ||
94 | .start = irq, | ||
95 | .end = irq, | ||
96 | .flags = IORESOURCE_IRQ, | ||
97 | } | ||
98 | }; | ||
99 | |||
100 | return dbx500_add_platform_device(name, id, pdata, resources, | ||
101 | ARRAY_SIZE(resources)); | ||
102 | } | ||
103 | |||
104 | static struct platform_device * | ||
105 | dbx500_add_gpio(int id, resource_size_t addr, int irq, | ||
106 | struct nmk_gpio_platform_data *pdata) | 56 | struct nmk_gpio_platform_data *pdata) |
107 | { | 57 | { |
108 | struct resource resources[] = { | 58 | struct resource resources[] = { |
@@ -118,13 +68,18 @@ dbx500_add_gpio(int id, resource_size_t addr, int irq, | |||
118 | } | 68 | } |
119 | }; | 69 | }; |
120 | 70 | ||
121 | return platform_device_register_resndata(NULL, "gpio", id, | 71 | return platform_device_register_resndata( |
122 | resources, ARRAY_SIZE(resources), | 72 | parent, |
123 | pdata, sizeof(*pdata)); | 73 | "gpio", |
74 | id, | ||
75 | resources, | ||
76 | ARRAY_SIZE(resources), | ||
77 | pdata, | ||
78 | sizeof(*pdata)); | ||
124 | } | 79 | } |
125 | 80 | ||
126 | void dbx500_add_gpios(resource_size_t *base, int num, int irq, | 81 | void dbx500_add_gpios(struct device *parent, resource_size_t *base, int num, |
127 | struct nmk_gpio_platform_data *pdata) | 82 | int irq, struct nmk_gpio_platform_data *pdata) |
128 | { | 83 | { |
129 | int first = 0; | 84 | int first = 0; |
130 | int i; | 85 | int i; |
@@ -134,6 +89,6 @@ void dbx500_add_gpios(resource_size_t *base, int num, int irq, | |||
134 | pdata->first_irq = NOMADIK_GPIO_TO_IRQ(first); | 89 | pdata->first_irq = NOMADIK_GPIO_TO_IRQ(first); |
135 | pdata->num_gpio = 32; | 90 | pdata->num_gpio = 32; |
136 | 91 | ||
137 | dbx500_add_gpio(i, base[i], irq, pdata); | 92 | dbx500_add_gpio(parent, i, base[i], irq, pdata); |
138 | } | 93 | } |
139 | } | 94 | } |