Merge branch 'nfs-for-2.6.35' of git://git.linux-nfs.org/projects/trondmy/nfs-2.6
[pandora-kernel.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 EXPORT_SYMBOL(s3c24xx_ts_set_platdata);
198
199 /* USB Device (Gadget)*/
200
201 static struct resource s3c_usbgadget_resource[] = {
202         [0] = {
203                 .start = S3C24XX_PA_USBDEV,
204                 .end   = S3C24XX_PA_USBDEV + S3C24XX_SZ_USBDEV - 1,
205                 .flags = IORESOURCE_MEM,
206         },
207         [1] = {
208                 .start = IRQ_USBD,
209                 .end   = IRQ_USBD,
210                 .flags = IORESOURCE_IRQ,
211         }
212
213 };
214
215 struct platform_device s3c_device_usbgadget = {
216         .name             = "s3c2410-usbgadget",
217         .id               = -1,
218         .num_resources    = ARRAY_SIZE(s3c_usbgadget_resource),
219         .resource         = s3c_usbgadget_resource,
220 };
221
222 EXPORT_SYMBOL(s3c_device_usbgadget);
223
224 void __init s3c24xx_udc_set_platdata(struct s3c2410_udc_mach_info *pd)
225 {
226         struct s3c2410_udc_mach_info *npd;
227
228         npd = kmalloc(sizeof(*npd), GFP_KERNEL);
229         if (npd) {
230                 memcpy(npd, pd, sizeof(*npd));
231                 s3c_device_usbgadget.dev.platform_data = npd;
232         } else {
233                 printk(KERN_ERR "no memory for udc platform data\n");
234         }
235 }
236
237
238 /* Watchdog */
239
240 static struct resource s3c_wdt_resource[] = {
241         [0] = {
242                 .start = S3C24XX_PA_WATCHDOG,
243                 .end   = S3C24XX_PA_WATCHDOG + S3C24XX_SZ_WATCHDOG - 1,
244                 .flags = IORESOURCE_MEM,
245         },
246         [1] = {
247                 .start = IRQ_WDT,
248                 .end   = IRQ_WDT,
249                 .flags = IORESOURCE_IRQ,
250         }
251
252 };
253
254 struct platform_device s3c_device_wdt = {
255         .name             = "s3c2410-wdt",
256         .id               = -1,
257         .num_resources    = ARRAY_SIZE(s3c_wdt_resource),
258         .resource         = s3c_wdt_resource,
259 };
260
261 EXPORT_SYMBOL(s3c_device_wdt);
262
263 /* IIS */
264
265 static struct resource s3c_iis_resource[] = {
266         [0] = {
267                 .start = S3C24XX_PA_IIS,
268                 .end   = S3C24XX_PA_IIS + S3C24XX_SZ_IIS -1,
269                 .flags = IORESOURCE_MEM,
270         }
271 };
272
273 static u64 s3c_device_iis_dmamask = 0xffffffffUL;
274
275 struct platform_device s3c_device_iis = {
276         .name             = "s3c2410-iis",
277         .id               = -1,
278         .num_resources    = ARRAY_SIZE(s3c_iis_resource),
279         .resource         = s3c_iis_resource,
280         .dev              = {
281                 .dma_mask = &s3c_device_iis_dmamask,
282                 .coherent_dma_mask = 0xffffffffUL
283         }
284 };
285
286 EXPORT_SYMBOL(s3c_device_iis);
287
288 /* RTC */
289
290 static struct resource s3c_rtc_resource[] = {
291         [0] = {
292                 .start = S3C24XX_PA_RTC,
293                 .end   = S3C24XX_PA_RTC + 0xff,
294                 .flags = IORESOURCE_MEM,
295         },
296         [1] = {
297                 .start = IRQ_RTC,
298                 .end   = IRQ_RTC,
299                 .flags = IORESOURCE_IRQ,
300         },
301         [2] = {
302                 .start = IRQ_TICK,
303                 .end   = IRQ_TICK,
304                 .flags = IORESOURCE_IRQ
305         }
306 };
307
308 struct platform_device s3c_device_rtc = {
309         .name             = "s3c2410-rtc",
310         .id               = -1,
311         .num_resources    = ARRAY_SIZE(s3c_rtc_resource),
312         .resource         = s3c_rtc_resource,
313 };
314
315 EXPORT_SYMBOL(s3c_device_rtc);
316
317 /* ADC */
318
319 static struct resource s3c_adc_resource[] = {
320         [0] = {
321                 .start = S3C24XX_PA_ADC,
322                 .end   = S3C24XX_PA_ADC + S3C24XX_SZ_ADC - 1,
323                 .flags = IORESOURCE_MEM,
324         },
325         [1] = {
326                 .start = IRQ_TC,
327                 .end   = IRQ_TC,
328                 .flags = IORESOURCE_IRQ,
329         },
330         [2] = {
331                 .start = IRQ_ADC,
332                 .end   = IRQ_ADC,
333                 .flags = IORESOURCE_IRQ,
334         }
335
336 };
337
338 struct platform_device s3c_device_adc = {
339         .name             = "s3c24xx-adc",
340         .id               = -1,
341         .num_resources    = ARRAY_SIZE(s3c_adc_resource),
342         .resource         = s3c_adc_resource,
343 };
344
345 /* SDI */
346
347 static struct resource s3c_sdi_resource[] = {
348         [0] = {
349                 .start = S3C24XX_PA_SDI,
350                 .end   = S3C24XX_PA_SDI + S3C24XX_SZ_SDI - 1,
351                 .flags = IORESOURCE_MEM,
352         },
353         [1] = {
354                 .start = IRQ_SDI,
355                 .end   = IRQ_SDI,
356                 .flags = IORESOURCE_IRQ,
357         }
358
359 };
360
361 struct platform_device s3c_device_sdi = {
362         .name             = "s3c2410-sdi",
363         .id               = -1,
364         .num_resources    = ARRAY_SIZE(s3c_sdi_resource),
365         .resource         = s3c_sdi_resource,
366 };
367
368 EXPORT_SYMBOL(s3c_device_sdi);
369
370 void __init s3c24xx_mci_set_platdata(struct s3c24xx_mci_pdata *pdata)
371 {
372         struct s3c24xx_mci_pdata *npd;
373
374         npd = kmemdup(pdata, sizeof(struct s3c24xx_mci_pdata), GFP_KERNEL);
375         if (!npd)
376                 printk(KERN_ERR "%s: no memory to copy pdata", __func__);
377
378         s3c_device_sdi.dev.platform_data = npd;
379 }
380
381
382 /* SPI (0) */
383
384 static struct resource s3c_spi0_resource[] = {
385         [0] = {
386                 .start = S3C24XX_PA_SPI,
387                 .end   = S3C24XX_PA_SPI + 0x1f,
388                 .flags = IORESOURCE_MEM,
389         },
390         [1] = {
391                 .start = IRQ_SPI0,
392                 .end   = IRQ_SPI0,
393                 .flags = IORESOURCE_IRQ,
394         }
395
396 };
397
398 static u64 s3c_device_spi0_dmamask = 0xffffffffUL;
399
400 struct platform_device s3c_device_spi0 = {
401         .name             = "s3c2410-spi",
402         .id               = 0,
403         .num_resources    = ARRAY_SIZE(s3c_spi0_resource),
404         .resource         = s3c_spi0_resource,
405         .dev              = {
406                 .dma_mask = &s3c_device_spi0_dmamask,
407                 .coherent_dma_mask = 0xffffffffUL
408         }
409 };
410
411 EXPORT_SYMBOL(s3c_device_spi0);
412
413 /* SPI (1) */
414
415 static struct resource s3c_spi1_resource[] = {
416         [0] = {
417                 .start = S3C24XX_PA_SPI + S3C2410_SPI1,
418                 .end   = S3C24XX_PA_SPI + S3C2410_SPI1 + 0x1f,
419                 .flags = IORESOURCE_MEM,
420         },
421         [1] = {
422                 .start = IRQ_SPI1,
423                 .end   = IRQ_SPI1,
424                 .flags = IORESOURCE_IRQ,
425         }
426
427 };
428
429 static u64 s3c_device_spi1_dmamask = 0xffffffffUL;
430
431 struct platform_device s3c_device_spi1 = {
432         .name             = "s3c2410-spi",
433         .id               = 1,
434         .num_resources    = ARRAY_SIZE(s3c_spi1_resource),
435         .resource         = s3c_spi1_resource,
436         .dev              = {
437                 .dma_mask = &s3c_device_spi1_dmamask,
438                 .coherent_dma_mask = 0xffffffffUL
439         }
440 };
441
442 EXPORT_SYMBOL(s3c_device_spi1);
443
444 #ifdef CONFIG_CPU_S3C2440
445
446 /* Camif Controller */
447
448 static struct resource s3c_camif_resource[] = {
449         [0] = {
450                 .start = S3C2440_PA_CAMIF,
451                 .end   = S3C2440_PA_CAMIF + S3C2440_SZ_CAMIF - 1,
452                 .flags = IORESOURCE_MEM,
453         },
454         [1] = {
455                 .start = IRQ_CAM,
456                 .end   = IRQ_CAM,
457                 .flags = IORESOURCE_IRQ,
458         }
459
460 };
461
462 static u64 s3c_device_camif_dmamask = 0xffffffffUL;
463
464 struct platform_device s3c_device_camif = {
465         .name             = "s3c2440-camif",
466         .id               = -1,
467         .num_resources    = ARRAY_SIZE(s3c_camif_resource),
468         .resource         = s3c_camif_resource,
469         .dev              = {
470                 .dma_mask = &s3c_device_camif_dmamask,
471                 .coherent_dma_mask = 0xffffffffUL
472         }
473 };
474
475 EXPORT_SYMBOL(s3c_device_camif);
476
477 /* AC97 */
478
479 static struct resource s3c_ac97_resource[] = {
480         [0] = {
481                 .start = S3C2440_PA_AC97,
482                 .end   = S3C2440_PA_AC97 + S3C2440_SZ_AC97 -1,
483                 .flags = IORESOURCE_MEM,
484         },
485         [1] = {
486                 .start = IRQ_S3C244x_AC97,
487                 .end   = IRQ_S3C244x_AC97,
488                 .flags = IORESOURCE_IRQ,
489         },
490         [2] = {
491                 .name  = "PCM out",
492                 .start = DMACH_PCM_OUT,
493                 .end   = DMACH_PCM_OUT,
494                 .flags = IORESOURCE_DMA,
495         },
496         [3] = {
497                 .name  = "PCM in",
498                 .start = DMACH_PCM_IN,
499                 .end   = DMACH_PCM_IN,
500                 .flags = IORESOURCE_DMA,
501         },
502         [4] = {
503                 .name  = "Mic in",
504                 .start = DMACH_MIC_IN,
505                 .end   = DMACH_MIC_IN,
506                 .flags = IORESOURCE_DMA,
507         },
508 };
509
510 static u64 s3c_device_ac97_dmamask = 0xffffffffUL;
511
512 struct platform_device s3c_device_ac97 = {
513         .name             = "s3c-ac97",
514         .id               = -1,
515         .num_resources    = ARRAY_SIZE(s3c_ac97_resource),
516         .resource         = s3c_ac97_resource,
517         .dev              = {
518                 .dma_mask = &s3c_device_ac97_dmamask,
519                 .coherent_dma_mask = 0xffffffffUL
520         }
521 };
522
523 EXPORT_SYMBOL(s3c_device_ac97);
524
525 #endif // CONFIG_CPU_S32440