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