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 c563e5418d80..c3bc094c27e5 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; |
@@ -46,6 +47,8 @@ dbx500_add_amba_device(const char *name, resource_size_t base, | |||
46 | 47 | ||
47 | dev->dev.platform_data = pdata; | 48 | dev->dev.platform_data = pdata; |
48 | 49 | ||
50 | dev->dev.parent = parent; | ||
51 | |||
49 | ret = amba_device_register(dev, &iomem_resource); | 52 | ret = amba_device_register(dev, &iomem_resource); |
50 | if (ret) { | 53 | if (ret) { |
51 | kfree(dev); | 54 | kfree(dev); |
@@ -56,60 +59,7 @@ dbx500_add_amba_device(const char *name, resource_size_t base, | |||
56 | } | 59 | } |
57 | 60 | ||
58 | static struct platform_device * | 61 | static struct platform_device * |
59 | dbx500_add_platform_device(const char *name, int id, void *pdata, | 62 | dbx500_add_gpio(struct device *parent, int id, resource_size_t addr, int irq, |
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 | |||
84 | out_free: | ||
85 | platform_device_put(dev); | ||
86 | return ERR_PTR(ret); | ||
87 | } | ||
88 | |||
89 | struct platform_device * | ||
90 | dbx500_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 | |||
111 | static struct platform_device * | ||
112 | dbx500_add_gpio(int id, resource_size_t addr, int irq, | ||
113 | struct nmk_gpio_platform_data *pdata) | 63 | struct nmk_gpio_platform_data *pdata) |
114 | { | 64 | { |
115 | struct resource resources[] = { | 65 | struct resource resources[] = { |
@@ -125,13 +75,18 @@ dbx500_add_gpio(int id, resource_size_t addr, int irq, | |||
125 | } | 75 | } |
126 | }; | 76 | }; |
127 | 77 | ||
128 | return platform_device_register_resndata(NULL, "gpio", id, | 78 | return platform_device_register_resndata( |
129 | resources, ARRAY_SIZE(resources), | 79 | parent, |
130 | pdata, sizeof(*pdata)); | 80 | "gpio", |
81 | id, | ||
82 | resources, | ||
83 | ARRAY_SIZE(resources), | ||
84 | pdata, | ||
85 | sizeof(*pdata)); | ||
131 | } | 86 | } |
132 | 87 | ||
133 | void dbx500_add_gpios(resource_size_t *base, int num, int irq, | 88 | void dbx500_add_gpios(struct device *parent, resource_size_t *base, int num, |
134 | struct nmk_gpio_platform_data *pdata) | 89 | int irq, struct nmk_gpio_platform_data *pdata) |
135 | { | 90 | { |
136 | int first = 0; | 91 | int first = 0; |
137 | int i; | 92 | int i; |
@@ -141,6 +96,6 @@ void dbx500_add_gpios(resource_size_t *base, int num, int irq, | |||
141 | pdata->first_irq = NOMADIK_GPIO_TO_IRQ(first); | 96 | pdata->first_irq = NOMADIK_GPIO_TO_IRQ(first); |
142 | pdata->num_gpio = 32; | 97 | pdata->num_gpio = 32; |
143 | 98 | ||
144 | dbx500_add_gpio(i, base[i], irq, pdata); | 99 | dbx500_add_gpio(parent, i, base[i], irq, pdata); |
145 | } | 100 | } |
146 | } | 101 | } |