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