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