Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[pandora-kernel.git] / arch / arm / mach-s3c2410 / devs.c
1 /* linux/arch/arm/mach-s3c2410/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/platform_device.h>
21
22 #include <asm/mach/arch.h>
23 #include <asm/mach/map.h>
24 #include <asm/mach/irq.h>
25 #include <asm/arch/fb.h>
26 #include <asm/hardware.h>
27 #include <asm/io.h>
28 #include <asm/irq.h>
29
30 #include <asm/arch/regs-serial.h>
31
32 #include "devs.h"
33 #include "cpu.h"
34
35 /* Serial port registrations */
36
37 static struct resource s3c2410_uart0_resource[] = {
38         [0] = {
39                 .start = S3C2410_PA_UART0,
40                 .end   = S3C2410_PA_UART0 + 0x3fff,
41                 .flags = IORESOURCE_MEM,
42         },
43         [1] = {
44                 .start = IRQ_S3CUART_RX0,
45                 .end   = IRQ_S3CUART_ERR0,
46                 .flags = IORESOURCE_IRQ,
47         }
48 };
49
50 static struct resource s3c2410_uart1_resource[] = {
51         [0] = {
52                 .start = S3C2410_PA_UART1,
53                 .end   = S3C2410_PA_UART1 + 0x3fff,
54                 .flags = IORESOURCE_MEM,
55         },
56         [1] = {
57                 .start = IRQ_S3CUART_RX1,
58                 .end   = IRQ_S3CUART_ERR1,
59                 .flags = IORESOURCE_IRQ,
60         }
61 };
62
63 static struct resource s3c2410_uart2_resource[] = {
64         [0] = {
65                 .start = S3C2410_PA_UART2,
66                 .end   = S3C2410_PA_UART2 + 0x3fff,
67                 .flags = IORESOURCE_MEM,
68         },
69         [1] = {
70                 .start = IRQ_S3CUART_RX2,
71                 .end   = IRQ_S3CUART_ERR2,
72                 .flags = IORESOURCE_IRQ,
73         }
74 };
75
76 struct s3c24xx_uart_resources s3c2410_uart_resources[] __initdata = {
77         [0] = {
78                 .resources      = s3c2410_uart0_resource,
79                 .nr_resources   = ARRAY_SIZE(s3c2410_uart0_resource),
80         },
81         [1] = {
82                 .resources      = s3c2410_uart1_resource,
83                 .nr_resources   = ARRAY_SIZE(s3c2410_uart1_resource),
84         },
85         [2] = {
86                 .resources      = s3c2410_uart2_resource,
87                 .nr_resources   = ARRAY_SIZE(s3c2410_uart2_resource),
88         },
89 };
90
91 /* yart devices */
92
93 static struct platform_device s3c24xx_uart_device0 = {
94         .id             = 0,
95 };
96
97 static struct platform_device s3c24xx_uart_device1 = {
98         .id             = 1,
99 };
100
101 static struct platform_device s3c24xx_uart_device2 = {
102         .id             = 2,
103 };
104
105 struct platform_device *s3c24xx_uart_src[3] = {
106         &s3c24xx_uart_device0,
107         &s3c24xx_uart_device1,
108         &s3c24xx_uart_device2,
109 };
110
111 struct platform_device *s3c24xx_uart_devs[3] = {
112 };
113
114 /* USB Host Controller */
115
116 static struct resource s3c_usb_resource[] = {
117         [0] = {
118                 .start = S3C24XX_PA_USBHOST,
119                 .end   = S3C24XX_PA_USBHOST + S3C24XX_SZ_USBHOST - 1,
120                 .flags = IORESOURCE_MEM,
121         },
122         [1] = {
123                 .start = IRQ_USBH,
124                 .end   = IRQ_USBH,
125                 .flags = IORESOURCE_IRQ,
126         }
127 };
128
129 static u64 s3c_device_usb_dmamask = 0xffffffffUL;
130
131 struct platform_device s3c_device_usb = {
132         .name             = "s3c2410-ohci",
133         .id               = -1,
134         .num_resources    = ARRAY_SIZE(s3c_usb_resource),
135         .resource         = s3c_usb_resource,
136         .dev              = {
137                 .dma_mask = &s3c_device_usb_dmamask,
138                 .coherent_dma_mask = 0xffffffffUL
139         }
140 };
141
142 EXPORT_SYMBOL(s3c_device_usb);
143
144 /* LCD Controller */
145
146 static struct resource s3c_lcd_resource[] = {
147         [0] = {
148                 .start = S3C24XX_PA_LCD,
149                 .end   = S3C24XX_PA_LCD + S3C24XX_SZ_LCD - 1,
150                 .flags = IORESOURCE_MEM,
151         },
152         [1] = {
153                 .start = IRQ_LCD,
154                 .end   = IRQ_LCD,
155                 .flags = IORESOURCE_IRQ,
156         }
157
158 };
159
160 static u64 s3c_device_lcd_dmamask = 0xffffffffUL;
161
162 struct platform_device s3c_device_lcd = {
163         .name             = "s3c2410-lcd",
164         .id               = -1,
165         .num_resources    = ARRAY_SIZE(s3c_lcd_resource),
166         .resource         = s3c_lcd_resource,
167         .dev              = {
168                 .dma_mask               = &s3c_device_lcd_dmamask,
169                 .coherent_dma_mask      = 0xffffffffUL
170         }
171 };
172
173 EXPORT_SYMBOL(s3c_device_lcd);
174
175 void __init s3c24xx_fb_set_platdata(struct s3c2410fb_mach_info *pd)
176 {
177         struct s3c2410fb_mach_info *npd;
178
179         npd = kmalloc(sizeof(*npd), GFP_KERNEL);
180         if (npd) {
181                 memcpy(npd, pd, sizeof(*npd));
182                 s3c_device_lcd.dev.platform_data = npd;
183         } else {
184                 printk(KERN_ERR "no memory for LCD platform data\n");
185         }
186 }
187
188 /* NAND Controller */
189
190 static struct resource s3c_nand_resource[] = {
191         [0] = {
192                 .start = S3C2410_PA_NAND,
193                 .end   = S3C2410_PA_NAND + S3C24XX_SZ_NAND - 1,
194                 .flags = IORESOURCE_MEM,
195         }
196 };
197
198 struct platform_device s3c_device_nand = {
199         .name             = "s3c2410-nand",
200         .id               = -1,
201         .num_resources    = ARRAY_SIZE(s3c_nand_resource),
202         .resource         = s3c_nand_resource,
203 };
204
205 EXPORT_SYMBOL(s3c_device_nand);
206
207 /* USB Device (Gadget)*/
208
209 static struct resource s3c_usbgadget_resource[] = {
210         [0] = {
211                 .start = S3C24XX_PA_USBDEV,
212                 .end   = S3C24XX_PA_USBDEV + S3C24XX_SZ_USBDEV - 1,
213                 .flags = IORESOURCE_MEM,
214         },
215         [1] = {
216                 .start = IRQ_USBD,
217                 .end   = IRQ_USBD,
218                 .flags = IORESOURCE_IRQ,
219         }
220
221 };
222
223 struct platform_device s3c_device_usbgadget = {
224         .name             = "s3c2410-usbgadget",
225         .id               = -1,
226         .num_resources    = ARRAY_SIZE(s3c_usbgadget_resource),
227         .resource         = s3c_usbgadget_resource,
228 };
229
230 EXPORT_SYMBOL(s3c_device_usbgadget);
231
232 /* Watchdog */
233
234 static struct resource s3c_wdt_resource[] = {
235         [0] = {
236                 .start = S3C24XX_PA_WATCHDOG,
237                 .end   = S3C24XX_PA_WATCHDOG + S3C24XX_SZ_WATCHDOG - 1,
238                 .flags = IORESOURCE_MEM,
239         },
240         [1] = {
241                 .start = IRQ_WDT,
242                 .end   = IRQ_WDT,
243                 .flags = IORESOURCE_IRQ,
244         }
245
246 };
247
248 struct platform_device s3c_device_wdt = {
249         .name             = "s3c2410-wdt",
250         .id               = -1,
251         .num_resources    = ARRAY_SIZE(s3c_wdt_resource),
252         .resource         = s3c_wdt_resource,
253 };
254
255 EXPORT_SYMBOL(s3c_device_wdt);
256
257 /* I2C */
258
259 static struct resource s3c_i2c_resource[] = {
260         [0] = {
261                 .start = S3C24XX_PA_IIC,
262                 .end   = S3C24XX_PA_IIC + S3C24XX_SZ_IIC - 1,
263                 .flags = IORESOURCE_MEM,
264         },
265         [1] = {
266                 .start = IRQ_IIC,
267                 .end   = IRQ_IIC,
268                 .flags = IORESOURCE_IRQ,
269         }
270
271 };
272
273 struct platform_device s3c_device_i2c = {
274         .name             = "s3c2410-i2c",
275         .id               = -1,
276         .num_resources    = ARRAY_SIZE(s3c_i2c_resource),
277         .resource         = s3c_i2c_resource,
278 };
279
280 EXPORT_SYMBOL(s3c_device_i2c);
281
282 /* IIS */
283
284 static struct resource s3c_iis_resource[] = {
285         [0] = {
286                 .start = S3C24XX_PA_IIS,
287                 .end   = S3C24XX_PA_IIS + S3C24XX_SZ_IIS -1,
288                 .flags = IORESOURCE_MEM,
289         }
290 };
291
292 static u64 s3c_device_iis_dmamask = 0xffffffffUL;
293
294 struct platform_device s3c_device_iis = {
295         .name             = "s3c2410-iis",
296         .id               = -1,
297         .num_resources    = ARRAY_SIZE(s3c_iis_resource),
298         .resource         = s3c_iis_resource,
299         .dev              = {
300                 .dma_mask = &s3c_device_iis_dmamask,
301                 .coherent_dma_mask = 0xffffffffUL
302         }
303 };
304
305 EXPORT_SYMBOL(s3c_device_iis);
306
307 /* RTC */
308
309 static struct resource s3c_rtc_resource[] = {
310         [0] = {
311                 .start = S3C24XX_PA_RTC,
312                 .end   = S3C24XX_PA_RTC + 0xff,
313                 .flags = IORESOURCE_MEM,
314         },
315         [1] = {
316                 .start = IRQ_RTC,
317                 .end   = IRQ_RTC,
318                 .flags = IORESOURCE_IRQ,
319         },
320         [2] = {
321                 .start = IRQ_TICK,
322                 .end   = IRQ_TICK,
323                 .flags = IORESOURCE_IRQ
324         }
325 };
326
327 struct platform_device s3c_device_rtc = {
328         .name             = "s3c2410-rtc",
329         .id               = -1,
330         .num_resources    = ARRAY_SIZE(s3c_rtc_resource),
331         .resource         = s3c_rtc_resource,
332 };
333
334 EXPORT_SYMBOL(s3c_device_rtc);
335
336 /* ADC */
337
338 static struct resource s3c_adc_resource[] = {
339         [0] = {
340                 .start = S3C24XX_PA_ADC,
341                 .end   = S3C24XX_PA_ADC + S3C24XX_SZ_ADC - 1,
342                 .flags = IORESOURCE_MEM,
343         },
344         [1] = {
345                 .start = IRQ_TC,
346                 .end   = IRQ_TC,
347                 .flags = IORESOURCE_IRQ,
348         },
349         [2] = {
350                 .start = IRQ_ADC,
351                 .end   = IRQ_ADC,
352                 .flags = IORESOURCE_IRQ,
353         }
354
355 };
356
357 struct platform_device s3c_device_adc = {
358         .name             = "s3c2410-adc",
359         .id               = -1,
360         .num_resources    = ARRAY_SIZE(s3c_adc_resource),
361         .resource         = s3c_adc_resource,
362 };
363
364 /* SDI */
365
366 static struct resource s3c_sdi_resource[] = {
367         [0] = {
368                 .start = S3C2410_PA_SDI,
369                 .end   = S3C2410_PA_SDI + S3C24XX_SZ_SDI - 1,
370                 .flags = IORESOURCE_MEM,
371         },
372         [1] = {
373                 .start = IRQ_SDI,
374                 .end   = IRQ_SDI,
375                 .flags = IORESOURCE_IRQ,
376         }
377
378 };
379
380 struct platform_device s3c_device_sdi = {
381         .name             = "s3c2410-sdi",
382         .id               = -1,
383         .num_resources    = ARRAY_SIZE(s3c_sdi_resource),
384         .resource         = s3c_sdi_resource,
385 };
386
387 EXPORT_SYMBOL(s3c_device_sdi);
388
389 /* SPI (0) */
390
391 static struct resource s3c_spi0_resource[] = {
392         [0] = {
393                 .start = S3C24XX_PA_SPI,
394                 .end   = S3C24XX_PA_SPI + 0x1f,
395                 .flags = IORESOURCE_MEM,
396         },
397         [1] = {
398                 .start = IRQ_SPI0,
399                 .end   = IRQ_SPI0,
400                 .flags = IORESOURCE_IRQ,
401         }
402
403 };
404
405 static u64 s3c_device_spi0_dmamask = 0xffffffffUL;
406
407 struct platform_device s3c_device_spi0 = {
408         .name             = "s3c2410-spi",
409         .id               = 0,
410         .num_resources    = ARRAY_SIZE(s3c_spi0_resource),
411         .resource         = s3c_spi0_resource,
412         .dev              = {
413                 .dma_mask = &s3c_device_spi0_dmamask,
414                 .coherent_dma_mask = 0xffffffffUL
415         }
416 };
417
418 EXPORT_SYMBOL(s3c_device_spi0);
419
420 /* SPI (1) */
421
422 static struct resource s3c_spi1_resource[] = {
423         [0] = {
424                 .start = S3C24XX_PA_SPI + 0x20,
425                 .end   = S3C24XX_PA_SPI + 0x20 + 0x1f,
426                 .flags = IORESOURCE_MEM,
427         },
428         [1] = {
429                 .start = IRQ_SPI1,
430                 .end   = IRQ_SPI1,
431                 .flags = IORESOURCE_IRQ,
432         }
433
434 };
435
436 static u64 s3c_device_spi1_dmamask = 0xffffffffUL;
437
438 struct platform_device s3c_device_spi1 = {
439         .name             = "s3c2410-spi",
440         .id               = 1,
441         .num_resources    = ARRAY_SIZE(s3c_spi1_resource),
442         .resource         = s3c_spi1_resource,
443         .dev              = {
444                 .dma_mask = &s3c_device_spi1_dmamask,
445                 .coherent_dma_mask = 0xffffffffUL
446         }
447 };
448
449 EXPORT_SYMBOL(s3c_device_spi1);
450
451 /* pwm timer blocks */
452
453 static struct resource s3c_timer0_resource[] = {
454         [0] = {
455                 .start = S3C24XX_PA_TIMER + 0x0C,
456                 .end   = S3C24XX_PA_TIMER + 0x0C + 0xB,
457                 .flags = IORESOURCE_MEM,
458         },
459         [1] = {
460                 .start = IRQ_TIMER0,
461                 .end   = IRQ_TIMER0,
462                 .flags = IORESOURCE_IRQ,
463         }
464
465 };
466
467 struct platform_device s3c_device_timer0 = {
468         .name             = "s3c2410-timer",
469         .id               = 0,
470         .num_resources    = ARRAY_SIZE(s3c_timer0_resource),
471         .resource         = s3c_timer0_resource,
472 };
473
474 EXPORT_SYMBOL(s3c_device_timer0);
475
476 /* timer 1 */
477
478 static struct resource s3c_timer1_resource[] = {
479         [0] = {
480                 .start = S3C24XX_PA_TIMER + 0x18,
481                 .end   = S3C24XX_PA_TIMER + 0x23,
482                 .flags = IORESOURCE_MEM,
483         },
484         [1] = {
485                 .start = IRQ_TIMER1,
486                 .end   = IRQ_TIMER1,
487                 .flags = IORESOURCE_IRQ,
488         }
489
490 };
491
492 struct platform_device s3c_device_timer1 = {
493         .name             = "s3c2410-timer",
494         .id               = 1,
495         .num_resources    = ARRAY_SIZE(s3c_timer1_resource),
496         .resource         = s3c_timer1_resource,
497 };
498
499 EXPORT_SYMBOL(s3c_device_timer1);
500
501 /* timer 2 */
502
503 static struct resource s3c_timer2_resource[] = {
504         [0] = {
505                 .start = S3C24XX_PA_TIMER + 0x24,
506                 .end   = S3C24XX_PA_TIMER + 0x2F,
507                 .flags = IORESOURCE_MEM,
508         },
509         [1] = {
510                 .start = IRQ_TIMER2,
511                 .end   = IRQ_TIMER2,
512                 .flags = IORESOURCE_IRQ,
513         }
514
515 };
516
517 struct platform_device s3c_device_timer2 = {
518         .name             = "s3c2410-timer",
519         .id               = 2,
520         .num_resources    = ARRAY_SIZE(s3c_timer2_resource),
521         .resource         = s3c_timer2_resource,
522 };
523
524 EXPORT_SYMBOL(s3c_device_timer2);
525
526 /* timer 3 */
527
528 static struct resource s3c_timer3_resource[] = {
529         [0] = {
530                 .start = S3C24XX_PA_TIMER + 0x30,
531                 .end   = S3C24XX_PA_TIMER + 0x3B,
532                 .flags = IORESOURCE_MEM,
533         },
534         [1] = {
535                 .start = IRQ_TIMER3,
536                 .end   = IRQ_TIMER3,
537                 .flags = IORESOURCE_IRQ,
538         }
539
540 };
541
542 struct platform_device s3c_device_timer3 = {
543         .name             = "s3c2410-timer",
544         .id               = 3,
545         .num_resources    = ARRAY_SIZE(s3c_timer3_resource),
546         .resource         = s3c_timer3_resource,
547 };
548
549 EXPORT_SYMBOL(s3c_device_timer3);
550
551 #ifdef CONFIG_CPU_S3C2440
552
553 /* Camif Controller */
554
555 static struct resource s3c_camif_resource[] = {
556         [0] = {
557                 .start = S3C2440_PA_CAMIF,
558                 .end   = S3C2440_PA_CAMIF + S3C2440_SZ_CAMIF - 1,
559                 .flags = IORESOURCE_MEM,
560         },
561         [1] = {
562                 .start = IRQ_CAM,
563                 .end   = IRQ_CAM,
564                 .flags = IORESOURCE_IRQ,
565         }
566
567 };
568
569 static u64 s3c_device_camif_dmamask = 0xffffffffUL;
570
571 struct platform_device s3c_device_camif = {
572         .name             = "s3c2440-camif",
573         .id               = -1,
574         .num_resources    = ARRAY_SIZE(s3c_camif_resource),
575         .resource         = s3c_camif_resource,
576         .dev              = {
577                 .dma_mask = &s3c_device_camif_dmamask,
578                 .coherent_dma_mask = 0xffffffffUL
579         }
580 };
581
582 EXPORT_SYMBOL(s3c_device_camif);
583
584 #endif // CONFIG_CPU_S32440