aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorMagnus Damm <damm@opensource.se>2013-07-02 05:27:49 -0400
committerSimon Horman <horms+renesas@verge.net.au>2013-07-16 21:02:29 -0400
commit210e179da2e39c965872b941a36e55ab78328e49 (patch)
tree240fba3fe6f443591e71422efa91fd37b2ae4b44 /arch/arm
parent4146fa8861419ac0d2c3607168339621586f6c03 (diff)
ARM: shmobile: Make EMEV2 platform devices more compact
Convert the EMEV2 SoC device setup code from using very verbose resources and static platform devices to the same style as more recent boards. This reduces the size of the code. Signed-off-by: Magnus Damm <damm@opensource.se> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/mach-shmobile/setup-emev2.c321
1 files changed, 61 insertions, 260 deletions
diff --git a/arch/arm/mach-shmobile/setup-emev2.c b/arch/arm/mach-shmobile/setup-emev2.c
index f6edd190a6b4..e4b46930db52 100644
--- a/arch/arm/mach-shmobile/setup-emev2.c
+++ b/arch/arm/mach-shmobile/setup-emev2.c
@@ -62,102 +62,40 @@ void __init emev2_map_io(void)
62 62
63/* UART */ 63/* UART */
64static struct resource uart0_resources[] = { 64static struct resource uart0_resources[] = {
65 [0] = { 65 DEFINE_RES_MEM(0xe1020000, 0x38),
66 .start = 0xe1020000, 66 DEFINE_RES_IRQ(40),
67 .end = 0xe1020037,
68 .flags = IORESOURCE_MEM,
69 },
70 [1] = {
71 .start = 40,
72 .flags = IORESOURCE_IRQ,
73 }
74};
75
76static struct platform_device uart0_device = {
77 .name = "serial8250-em",
78 .id = 0,
79 .num_resources = ARRAY_SIZE(uart0_resources),
80 .resource = uart0_resources,
81}; 67};
82 68
83static struct resource uart1_resources[] = { 69static struct resource uart1_resources[] = {
84 [0] = { 70 DEFINE_RES_MEM(0xe1030000, 0x38),
85 .start = 0xe1030000, 71 DEFINE_RES_IRQ(41),
86 .end = 0xe1030037,
87 .flags = IORESOURCE_MEM,
88 },
89 [1] = {
90 .start = 41,
91 .flags = IORESOURCE_IRQ,
92 }
93};
94
95static struct platform_device uart1_device = {
96 .name = "serial8250-em",
97 .id = 1,
98 .num_resources = ARRAY_SIZE(uart1_resources),
99 .resource = uart1_resources,
100}; 72};
101 73
102static struct resource uart2_resources[] = { 74static struct resource uart2_resources[] = {
103 [0] = { 75 DEFINE_RES_MEM(0xe1040000, 0x38),
104 .start = 0xe1040000, 76 DEFINE_RES_IRQ(42),
105 .end = 0xe1040037,
106 .flags = IORESOURCE_MEM,
107 },
108 [1] = {
109 .start = 42,
110 .flags = IORESOURCE_IRQ,
111 }
112};
113
114static struct platform_device uart2_device = {
115 .name = "serial8250-em",
116 .id = 2,
117 .num_resources = ARRAY_SIZE(uart2_resources),
118 .resource = uart2_resources,
119}; 77};
120 78
121static struct resource uart3_resources[] = { 79static struct resource uart3_resources[] = {
122 [0] = { 80 DEFINE_RES_MEM(0xe1050000, 0x38),
123 .start = 0xe1050000, 81 DEFINE_RES_IRQ(43),
124 .end = 0xe1050037,
125 .flags = IORESOURCE_MEM,
126 },
127 [1] = {
128 .start = 43,
129 .flags = IORESOURCE_IRQ,
130 }
131}; 82};
132 83
133static struct platform_device uart3_device = { 84#define emev2_register_uart(idx) \
134 .name = "serial8250-em", 85 platform_device_register_simple("serial8250-em", idx, \
135 .id = 3, 86 uart##idx##_resources, \
136 .num_resources = ARRAY_SIZE(uart3_resources), 87 ARRAY_SIZE(uart##idx##_resources))
137 .resource = uart3_resources,
138};
139 88
140/* STI */ 89/* STI */
141static struct resource sti_resources[] = { 90static struct resource sti_resources[] = {
142 [0] = { 91 DEFINE_RES_MEM(0xe0180000, 0x54),
143 .name = "STI", 92 DEFINE_RES_IRQ(157),
144 .start = 0xe0180000,
145 .end = 0xe0180053,
146 .flags = IORESOURCE_MEM,
147 },
148 [1] = {
149 .start = 157,
150 .flags = IORESOURCE_IRQ,
151 },
152};
153
154static struct platform_device sti_device = {
155 .name = "em_sti",
156 .id = 0,
157 .resource = sti_resources,
158 .num_resources = ARRAY_SIZE(sti_resources),
159}; 93};
160 94
95#define emev2_register_sti() \
96 platform_device_register_simple("em_sti", 0, \
97 sti_resources, \
98 ARRAY_SIZE(sti_resources))
161 99
162/* GIO */ 100/* GIO */
163static struct gpio_em_config gio0_config = { 101static struct gpio_em_config gio0_config = {
@@ -167,36 +105,10 @@ static struct gpio_em_config gio0_config = {
167}; 105};
168 106
169static struct resource gio0_resources[] = { 107static struct resource gio0_resources[] = {
170 [0] = { 108 DEFINE_RES_MEM(0xe0050000, 0x2c),
171 .name = "GIO_000", 109 DEFINE_RES_MEM(0xe0050040, 0x20),
172 .start = 0xe0050000, 110 DEFINE_RES_IRQ(99),
173 .end = 0xe005002b, 111 DEFINE_RES_IRQ(100),
174 .flags = IORESOURCE_MEM,
175 },
176 [1] = {
177 .name = "GIO_000",
178 .start = 0xe0050040,
179 .end = 0xe005005f,
180 .flags = IORESOURCE_MEM,
181 },
182 [2] = {
183 .start = 99,
184 .flags = IORESOURCE_IRQ,
185 },
186 [3] = {
187 .start = 100,
188 .flags = IORESOURCE_IRQ,
189 },
190};
191
192static struct platform_device gio0_device = {
193 .name = "em_gio",
194 .id = 0,
195 .resource = gio0_resources,
196 .num_resources = ARRAY_SIZE(gio0_resources),
197 .dev = {
198 .platform_data = &gio0_config,
199 },
200}; 112};
201 113
202static struct gpio_em_config gio1_config = { 114static struct gpio_em_config gio1_config = {
@@ -206,36 +118,10 @@ static struct gpio_em_config gio1_config = {
206}; 118};
207 119
208static struct resource gio1_resources[] = { 120static struct resource gio1_resources[] = {
209 [0] = { 121 DEFINE_RES_MEM(0xe0050080, 0x2c),
210 .name = "GIO_032", 122 DEFINE_RES_MEM(0xe00500c0, 0x20),
211 .start = 0xe0050080, 123 DEFINE_RES_IRQ(101),
212 .end = 0xe00500ab, 124 DEFINE_RES_IRQ(102),
213 .flags = IORESOURCE_MEM,
214 },
215 [1] = {
216 .name = "GIO_032",
217 .start = 0xe00500c0,
218 .end = 0xe00500df,
219 .flags = IORESOURCE_MEM,
220 },
221 [2] = {
222 .start = 101,
223 .flags = IORESOURCE_IRQ,
224 },
225 [3] = {
226 .start = 102,
227 .flags = IORESOURCE_IRQ,
228 },
229};
230
231static struct platform_device gio1_device = {
232 .name = "em_gio",
233 .id = 1,
234 .resource = gio1_resources,
235 .num_resources = ARRAY_SIZE(gio1_resources),
236 .dev = {
237 .platform_data = &gio1_config,
238 },
239}; 125};
240 126
241static struct gpio_em_config gio2_config = { 127static struct gpio_em_config gio2_config = {
@@ -245,36 +131,10 @@ static struct gpio_em_config gio2_config = {
245}; 131};
246 132
247static struct resource gio2_resources[] = { 133static struct resource gio2_resources[] = {
248 [0] = { 134 DEFINE_RES_MEM(0xe0050100, 0x2c),
249 .name = "GIO_064", 135 DEFINE_RES_MEM(0xe0050140, 0x20),
250 .start = 0xe0050100, 136 DEFINE_RES_IRQ(103),
251 .end = 0xe005012b, 137 DEFINE_RES_IRQ(104),
252 .flags = IORESOURCE_MEM,
253 },
254 [1] = {
255 .name = "GIO_064",
256 .start = 0xe0050140,
257 .end = 0xe005015f,
258 .flags = IORESOURCE_MEM,
259 },
260 [2] = {
261 .start = 103,
262 .flags = IORESOURCE_IRQ,
263 },
264 [3] = {
265 .start = 104,
266 .flags = IORESOURCE_IRQ,
267 },
268};
269
270static struct platform_device gio2_device = {
271 .name = "em_gio",
272 .id = 2,
273 .resource = gio2_resources,
274 .num_resources = ARRAY_SIZE(gio2_resources),
275 .dev = {
276 .platform_data = &gio2_config,
277 },
278}; 138};
279 139
280static struct gpio_em_config gio3_config = { 140static struct gpio_em_config gio3_config = {
@@ -284,36 +144,10 @@ static struct gpio_em_config gio3_config = {
284}; 144};
285 145
286static struct resource gio3_resources[] = { 146static struct resource gio3_resources[] = {
287 [0] = { 147 DEFINE_RES_MEM(0xe0050180, 0x2c),
288 .name = "GIO_096", 148 DEFINE_RES_MEM(0xe00501c0, 0x20),
289 .start = 0xe0050180, 149 DEFINE_RES_IRQ(105),
290 .end = 0xe00501ab, 150 DEFINE_RES_IRQ(106),
291 .flags = IORESOURCE_MEM,
292 },
293 [1] = {
294 .name = "GIO_096",
295 .start = 0xe00501c0,
296 .end = 0xe00501df,
297 .flags = IORESOURCE_MEM,
298 },
299 [2] = {
300 .start = 105,
301 .flags = IORESOURCE_IRQ,
302 },
303 [3] = {
304 .start = 106,
305 .flags = IORESOURCE_IRQ,
306 },
307};
308
309static struct platform_device gio3_device = {
310 .name = "em_gio",
311 .id = 3,
312 .resource = gio3_resources,
313 .num_resources = ARRAY_SIZE(gio3_resources),
314 .dev = {
315 .platform_data = &gio3_config,
316 },
317}; 151};
318 152
319static struct gpio_em_config gio4_config = { 153static struct gpio_em_config gio4_config = {
@@ -323,77 +157,44 @@ static struct gpio_em_config gio4_config = {
323}; 157};
324 158
325static struct resource gio4_resources[] = { 159static struct resource gio4_resources[] = {
326 [0] = { 160 DEFINE_RES_MEM(0xe0050200, 0x2c),
327 .name = "GIO_128", 161 DEFINE_RES_MEM(0xe0050240, 0x20),
328 .start = 0xe0050200, 162 DEFINE_RES_IRQ(107),
329 .end = 0xe005022b, 163 DEFINE_RES_IRQ(108),
330 .flags = IORESOURCE_MEM,
331 },
332 [1] = {
333 .name = "GIO_128",
334 .start = 0xe0050240,
335 .end = 0xe005025f,
336 .flags = IORESOURCE_MEM,
337 },
338 [2] = {
339 .start = 107,
340 .flags = IORESOURCE_IRQ,
341 },
342 [3] = {
343 .start = 108,
344 .flags = IORESOURCE_IRQ,
345 },
346}; 164};
347 165
348static struct platform_device gio4_device = { 166#define emev2_register_gio(idx) \
349 .name = "em_gio", 167 platform_device_register_resndata(&platform_bus, "em_gio", \
350 .id = 4, 168 idx, gio##idx##_resources, \
351 .resource = gio4_resources, 169 ARRAY_SIZE(gio##idx##_resources), \
352 .num_resources = ARRAY_SIZE(gio4_resources), 170 &gio##idx##_config, \
353 .dev = { 171 sizeof(struct gpio_em_config))
354 .platform_data = &gio4_config,
355 },
356};
357 172
358static struct resource pmu_resources[] = { 173static struct resource pmu_resources[] = {
359 [0] = { 174 DEFINE_RES_IRQ(152),
360 .start = 152, 175 DEFINE_RES_IRQ(153),
361 .end = 152,
362 .flags = IORESOURCE_IRQ,
363 },
364 [1] = {
365 .start = 153,
366 .end = 153,
367 .flags = IORESOURCE_IRQ,
368 },
369}; 176};
370 177
371static struct platform_device pmu_device = { 178#define emev2_register_pmu() \
372 .name = "arm-pmu", 179 platform_device_register_simple("arm-pmu", -1, \
373 .id = -1, 180 pmu_resources, \
374 .num_resources = ARRAY_SIZE(pmu_resources), 181 ARRAY_SIZE(pmu_resources))
375 .resource = pmu_resources,
376};
377
378static struct platform_device *emev2_devices[] __initdata = {
379 &uart0_device,
380 &uart1_device,
381 &uart2_device,
382 &uart3_device,
383 &sti_device,
384 &gio0_device,
385 &gio1_device,
386 &gio2_device,
387 &gio3_device,
388 &gio4_device,
389 &pmu_device,
390};
391 182
392void __init emev2_add_standard_devices(void) 183void __init emev2_add_standard_devices(void)
393{ 184{
394 emev2_clock_init(); 185 emev2_clock_init();
395 186
396 platform_add_devices(emev2_devices, ARRAY_SIZE(emev2_devices)); 187 emev2_register_uart(0);
188 emev2_register_uart(1);
189 emev2_register_uart(2);
190 emev2_register_uart(3);
191 emev2_register_sti();
192 emev2_register_gio(0);
193 emev2_register_gio(1);
194 emev2_register_gio(2);
195 emev2_register_gio(3);
196 emev2_register_gio(4);
197 emev2_register_pmu();
397} 198}
398 199
399void __init emev2_init_delay(void) 200void __init emev2_init_delay(void)