Merge branch 'master'; commit 'v2.6.38-rc7' into next
[deliverable/linux.git] / arch / arm / plat-s3c24xx / devs.c
1 /* linux/arch/arm/plat-s3c24xx/devs.c
2 *
3 * Copyright (c) 2004 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6 * Base S3C24XX platform device definitions
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 */
13
14 #include <linux/kernel.h>
15 #include <linux/types.h>
16 #include <linux/interrupt.h>
17 #include <linux/list.h>
18 #include <linux/timer.h>
19 #include <linux/init.h>
20 #include <linux/serial_core.h>
21 #include <linux/platform_device.h>
22 #include <linux/io.h>
23 #include <linux/slab.h>
24 #include <linux/string.h>
25
26 #include <asm/mach/arch.h>
27 #include <asm/mach/map.h>
28 #include <asm/mach/irq.h>
29 #include <mach/fb.h>
30 #include <mach/hardware.h>
31 #include <mach/dma.h>
32 #include <mach/irqs.h>
33 #include <asm/irq.h>
34
35 #include <plat/regs-serial.h>
36 #include <plat/udc.h>
37 #include <plat/mci.h>
38
39 #include <plat/devs.h>
40 #include <plat/cpu.h>
41 #include <plat/regs-spi.h>
42 #include <plat/ts.h>
43
44 /* Serial port registrations */
45
46 static struct resource s3c2410_uart0_resource[] = {
47 [0] = {
48 .start = S3C2410_PA_UART0,
49 .end = S3C2410_PA_UART0 + 0x3fff,
50 .flags = IORESOURCE_MEM,
51 },
52 [1] = {
53 .start = IRQ_S3CUART_RX0,
54 .end = IRQ_S3CUART_ERR0,
55 .flags = IORESOURCE_IRQ,
56 }
57 };
58
59 static struct resource s3c2410_uart1_resource[] = {
60 [0] = {
61 .start = S3C2410_PA_UART1,
62 .end = S3C2410_PA_UART1 + 0x3fff,
63 .flags = IORESOURCE_MEM,
64 },
65 [1] = {
66 .start = IRQ_S3CUART_RX1,
67 .end = IRQ_S3CUART_ERR1,
68 .flags = IORESOURCE_IRQ,
69 }
70 };
71
72 static struct resource s3c2410_uart2_resource[] = {
73 [0] = {
74 .start = S3C2410_PA_UART2,
75 .end = S3C2410_PA_UART2 + 0x3fff,
76 .flags = IORESOURCE_MEM,
77 },
78 [1] = {
79 .start = IRQ_S3CUART_RX2,
80 .end = IRQ_S3CUART_ERR2,
81 .flags = IORESOURCE_IRQ,
82 }
83 };
84
85 static struct resource s3c2410_uart3_resource[] = {
86 [0] = {
87 .start = S3C2443_PA_UART3,
88 .end = S3C2443_PA_UART3 + 0x3fff,
89 .flags = IORESOURCE_MEM,
90 },
91 [1] = {
92 .start = IRQ_S3CUART_RX3,
93 .end = IRQ_S3CUART_ERR3,
94 .flags = IORESOURCE_IRQ,
95 },
96 };
97
98 struct s3c24xx_uart_resources s3c2410_uart_resources[] __initdata = {
99 [0] = {
100 .resources = s3c2410_uart0_resource,
101 .nr_resources = ARRAY_SIZE(s3c2410_uart0_resource),
102 },
103 [1] = {
104 .resources = s3c2410_uart1_resource,
105 .nr_resources = ARRAY_SIZE(s3c2410_uart1_resource),
106 },
107 [2] = {
108 .resources = s3c2410_uart2_resource,
109 .nr_resources = ARRAY_SIZE(s3c2410_uart2_resource),
110 },
111 [3] = {
112 .resources = s3c2410_uart3_resource,
113 .nr_resources = ARRAY_SIZE(s3c2410_uart3_resource),
114 },
115 };
116
117 /* LCD Controller */
118
119 static struct resource s3c_lcd_resource[] = {
120 [0] = {
121 .start = S3C24XX_PA_LCD,
122 .end = S3C24XX_PA_LCD + S3C24XX_SZ_LCD - 1,
123 .flags = IORESOURCE_MEM,
124 },
125 [1] = {
126 .start = IRQ_LCD,
127 .end = IRQ_LCD,
128 .flags = IORESOURCE_IRQ,
129 }
130
131 };
132
133 static u64 s3c_device_lcd_dmamask = 0xffffffffUL;
134
135 struct platform_device s3c_device_lcd = {
136 .name = "s3c2410-lcd",
137 .id = -1,
138 .num_resources = ARRAY_SIZE(s3c_lcd_resource),
139 .resource = s3c_lcd_resource,
140 .dev = {
141 .dma_mask = &s3c_device_lcd_dmamask,
142 .coherent_dma_mask = 0xffffffffUL
143 }
144 };
145
146 EXPORT_SYMBOL(s3c_device_lcd);
147
148 void __init s3c24xx_fb_set_platdata(struct s3c2410fb_mach_info *pd)
149 {
150 struct s3c2410fb_mach_info *npd;
151
152 npd = kmemdup(pd, sizeof(*npd), GFP_KERNEL);
153 if (npd) {
154 s3c_device_lcd.dev.platform_data = npd;
155 npd->displays = kmemdup(pd->displays,
156 sizeof(struct s3c2410fb_display) * npd->num_displays,
157 GFP_KERNEL);
158 if (!npd->displays)
159 printk(KERN_ERR "no memory for LCD display data\n");
160 } else {
161 printk(KERN_ERR "no memory for LCD platform data\n");
162 }
163 }
164
165 /* Touchscreen */
166
167 static struct resource s3c_ts_resource[] = {
168 [0] = {
169 .start = S3C24XX_PA_ADC,
170 .end = S3C24XX_PA_ADC + S3C24XX_SZ_ADC - 1,
171 .flags = IORESOURCE_MEM,
172 },
173 [1] = {
174 .start = IRQ_TC,
175 .end = IRQ_TC,
176 .flags = IORESOURCE_IRQ,
177 },
178
179 };
180
181 struct platform_device s3c_device_ts = {
182 .name = "s3c2410-ts",
183 .id = -1,
184 .dev.parent = &s3c_device_adc.dev,
185 .num_resources = ARRAY_SIZE(s3c_ts_resource),
186 .resource = s3c_ts_resource,
187 };
188 EXPORT_SYMBOL(s3c_device_ts);
189
190 static struct s3c2410_ts_mach_info s3c2410ts_info;
191
192 void __init s3c24xx_ts_set_platdata(struct s3c2410_ts_mach_info *hard_s3c2410ts_info)
193 {
194 memcpy(&s3c2410ts_info, hard_s3c2410ts_info, sizeof(struct s3c2410_ts_mach_info));
195 s3c_device_ts.dev.platform_data = &s3c2410ts_info;
196 }
197
198 /* USB Device (Gadget)*/
199
200 static struct resource s3c_usbgadget_resource[] = {
201 [0] = {
202 .start = S3C24XX_PA_USBDEV,
203 .end = S3C24XX_PA_USBDEV + S3C24XX_SZ_USBDEV - 1,
204 .flags = IORESOURCE_MEM,
205 },
206 [1] = {
207 .start = IRQ_USBD,
208 .end = IRQ_USBD,
209 .flags = IORESOURCE_IRQ,
210 }
211
212 };
213
214 struct platform_device s3c_device_usbgadget = {
215 .name = "s3c2410-usbgadget",
216 .id = -1,
217 .num_resources = ARRAY_SIZE(s3c_usbgadget_resource),
218 .resource = s3c_usbgadget_resource,
219 };
220
221 EXPORT_SYMBOL(s3c_device_usbgadget);
222
223 void __init s3c24xx_udc_set_platdata(struct s3c2410_udc_mach_info *pd)
224 {
225 struct s3c2410_udc_mach_info *npd;
226
227 npd = kmalloc(sizeof(*npd), GFP_KERNEL);
228 if (npd) {
229 memcpy(npd, pd, sizeof(*npd));
230 s3c_device_usbgadget.dev.platform_data = npd;
231 } else {
232 printk(KERN_ERR "no memory for udc platform data\n");
233 }
234 }
235
236 /* IIS */
237
238 static struct resource s3c_iis_resource[] = {
239 [0] = {
240 .start = S3C24XX_PA_IIS,
241 .end = S3C24XX_PA_IIS + S3C24XX_SZ_IIS -1,
242 .flags = IORESOURCE_MEM,
243 }
244 };
245
246 static u64 s3c_device_iis_dmamask = 0xffffffffUL;
247
248 struct platform_device s3c_device_iis = {
249 .name = "s3c24xx-iis",
250 .id = -1,
251 .num_resources = ARRAY_SIZE(s3c_iis_resource),
252 .resource = s3c_iis_resource,
253 .dev = {
254 .dma_mask = &s3c_device_iis_dmamask,
255 .coherent_dma_mask = 0xffffffffUL
256 }
257 };
258
259 EXPORT_SYMBOL(s3c_device_iis);
260
261 /* RTC */
262
263 static struct resource s3c_rtc_resource[] = {
264 [0] = {
265 .start = S3C24XX_PA_RTC,
266 .end = S3C24XX_PA_RTC + 0xff,
267 .flags = IORESOURCE_MEM,
268 },
269 [1] = {
270 .start = IRQ_RTC,
271 .end = IRQ_RTC,
272 .flags = IORESOURCE_IRQ,
273 },
274 [2] = {
275 .start = IRQ_TICK,
276 .end = IRQ_TICK,
277 .flags = IORESOURCE_IRQ
278 }
279 };
280
281 struct platform_device s3c_device_rtc = {
282 .name = "s3c2410-rtc",
283 .id = -1,
284 .num_resources = ARRAY_SIZE(s3c_rtc_resource),
285 .resource = s3c_rtc_resource,
286 };
287
288 EXPORT_SYMBOL(s3c_device_rtc);
289
290 /* ADC */
291
292 static struct resource s3c_adc_resource[] = {
293 [0] = {
294 .start = S3C24XX_PA_ADC,
295 .end = S3C24XX_PA_ADC + S3C24XX_SZ_ADC - 1,
296 .flags = IORESOURCE_MEM,
297 },
298 [1] = {
299 .start = IRQ_TC,
300 .end = IRQ_TC,
301 .flags = IORESOURCE_IRQ,
302 },
303 [2] = {
304 .start = IRQ_ADC,
305 .end = IRQ_ADC,
306 .flags = IORESOURCE_IRQ,
307 }
308
309 };
310
311 struct platform_device s3c_device_adc = {
312 .name = "s3c24xx-adc",
313 .id = -1,
314 .num_resources = ARRAY_SIZE(s3c_adc_resource),
315 .resource = s3c_adc_resource,
316 };
317
318 /* SDI */
319
320 static struct resource s3c_sdi_resource[] = {
321 [0] = {
322 .start = S3C24XX_PA_SDI,
323 .end = S3C24XX_PA_SDI + S3C24XX_SZ_SDI - 1,
324 .flags = IORESOURCE_MEM,
325 },
326 [1] = {
327 .start = IRQ_SDI,
328 .end = IRQ_SDI,
329 .flags = IORESOURCE_IRQ,
330 }
331
332 };
333
334 struct platform_device s3c_device_sdi = {
335 .name = "s3c2410-sdi",
336 .id = -1,
337 .num_resources = ARRAY_SIZE(s3c_sdi_resource),
338 .resource = s3c_sdi_resource,
339 };
340
341 EXPORT_SYMBOL(s3c_device_sdi);
342
343 void __init s3c24xx_mci_set_platdata(struct s3c24xx_mci_pdata *pdata)
344 {
345 struct s3c24xx_mci_pdata *npd;
346
347 npd = kmemdup(pdata, sizeof(struct s3c24xx_mci_pdata), GFP_KERNEL);
348 if (!npd)
349 printk(KERN_ERR "%s: no memory to copy pdata", __func__);
350
351 s3c_device_sdi.dev.platform_data = npd;
352 }
353
354
355 /* SPI (0) */
356
357 static struct resource s3c_spi0_resource[] = {
358 [0] = {
359 .start = S3C24XX_PA_SPI,
360 .end = S3C24XX_PA_SPI + 0x1f,
361 .flags = IORESOURCE_MEM,
362 },
363 [1] = {
364 .start = IRQ_SPI0,
365 .end = IRQ_SPI0,
366 .flags = IORESOURCE_IRQ,
367 }
368
369 };
370
371 static u64 s3c_device_spi0_dmamask = 0xffffffffUL;
372
373 struct platform_device s3c_device_spi0 = {
374 .name = "s3c2410-spi",
375 .id = 0,
376 .num_resources = ARRAY_SIZE(s3c_spi0_resource),
377 .resource = s3c_spi0_resource,
378 .dev = {
379 .dma_mask = &s3c_device_spi0_dmamask,
380 .coherent_dma_mask = 0xffffffffUL
381 }
382 };
383
384 EXPORT_SYMBOL(s3c_device_spi0);
385
386 /* SPI (1) */
387
388 static struct resource s3c_spi1_resource[] = {
389 [0] = {
390 .start = S3C24XX_PA_SPI + S3C2410_SPI1,
391 .end = S3C24XX_PA_SPI + S3C2410_SPI1 + 0x1f,
392 .flags = IORESOURCE_MEM,
393 },
394 [1] = {
395 .start = IRQ_SPI1,
396 .end = IRQ_SPI1,
397 .flags = IORESOURCE_IRQ,
398 }
399
400 };
401
402 static u64 s3c_device_spi1_dmamask = 0xffffffffUL;
403
404 struct platform_device s3c_device_spi1 = {
405 .name = "s3c2410-spi",
406 .id = 1,
407 .num_resources = ARRAY_SIZE(s3c_spi1_resource),
408 .resource = s3c_spi1_resource,
409 .dev = {
410 .dma_mask = &s3c_device_spi1_dmamask,
411 .coherent_dma_mask = 0xffffffffUL
412 }
413 };
414
415 EXPORT_SYMBOL(s3c_device_spi1);
416
417 #ifdef CONFIG_CPU_S3C2440
418
419 /* Camif Controller */
420
421 static struct resource s3c_camif_resource[] = {
422 [0] = {
423 .start = S3C2440_PA_CAMIF,
424 .end = S3C2440_PA_CAMIF + S3C2440_SZ_CAMIF - 1,
425 .flags = IORESOURCE_MEM,
426 },
427 [1] = {
428 .start = IRQ_CAM,
429 .end = IRQ_CAM,
430 .flags = IORESOURCE_IRQ,
431 }
432
433 };
434
435 static u64 s3c_device_camif_dmamask = 0xffffffffUL;
436
437 struct platform_device s3c_device_camif = {
438 .name = "s3c2440-camif",
439 .id = -1,
440 .num_resources = ARRAY_SIZE(s3c_camif_resource),
441 .resource = s3c_camif_resource,
442 .dev = {
443 .dma_mask = &s3c_device_camif_dmamask,
444 .coherent_dma_mask = 0xffffffffUL
445 }
446 };
447
448 EXPORT_SYMBOL(s3c_device_camif);
449
450 /* AC97 */
451
452 static struct resource s3c_ac97_resource[] = {
453 [0] = {
454 .start = S3C2440_PA_AC97,
455 .end = S3C2440_PA_AC97 + S3C2440_SZ_AC97 -1,
456 .flags = IORESOURCE_MEM,
457 },
458 [1] = {
459 .start = IRQ_S3C244x_AC97,
460 .end = IRQ_S3C244x_AC97,
461 .flags = IORESOURCE_IRQ,
462 },
463 [2] = {
464 .name = "PCM out",
465 .start = DMACH_PCM_OUT,
466 .end = DMACH_PCM_OUT,
467 .flags = IORESOURCE_DMA,
468 },
469 [3] = {
470 .name = "PCM in",
471 .start = DMACH_PCM_IN,
472 .end = DMACH_PCM_IN,
473 .flags = IORESOURCE_DMA,
474 },
475 [4] = {
476 .name = "Mic in",
477 .start = DMACH_MIC_IN,
478 .end = DMACH_MIC_IN,
479 .flags = IORESOURCE_DMA,
480 },
481 };
482
483 static u64 s3c_device_audio_dmamask = 0xffffffffUL;
484
485 struct platform_device s3c_device_ac97 = {
486 .name = "samsung-ac97",
487 .id = -1,
488 .num_resources = ARRAY_SIZE(s3c_ac97_resource),
489 .resource = s3c_ac97_resource,
490 .dev = {
491 .dma_mask = &s3c_device_audio_dmamask,
492 .coherent_dma_mask = 0xffffffffUL
493 }
494 };
495
496 EXPORT_SYMBOL(s3c_device_ac97);
497
498 /* ASoC I2S */
499
500 struct platform_device s3c2412_device_iis = {
501 .name = "s3c2412-iis",
502 .id = -1,
503 .dev = {
504 .dma_mask = &s3c_device_audio_dmamask,
505 .coherent_dma_mask = 0xffffffffUL
506 }
507 };
508
509 EXPORT_SYMBOL(s3c2412_device_iis);
510
511 #endif // CONFIG_CPU_S32440
This page took 0.041087 seconds and 6 git commands to generate.