S3C: Backported the s3c2410 touchscreen from openmoko
[linux-2.6/mini2440.git] / arch / arm / plat-s3c24xx / devs.c
blobfbba93d61c1f79a31e375f1149711666f233f5ff
1 /* linux/arch/arm/plat-s3c24xx/devs.c
3 * Copyright (c) 2004 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
6 * Base S3C24XX platform device definitions
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.
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>
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>
33 #include <plat/regs-serial.h>
34 #include <plat/udc.h>
36 #include <plat/devs.h>
37 #include <plat/cpu.h>
38 #include <plat/regs-spi.h>
40 /* Serial port registrations */
42 static struct resource s3c2410_uart0_resource[] = {
43 [0] = {
44 .start = S3C2410_PA_UART0,
45 .end = S3C2410_PA_UART0 + 0x3fff,
46 .flags = IORESOURCE_MEM,
48 [1] = {
49 .start = IRQ_S3CUART_RX0,
50 .end = IRQ_S3CUART_ERR0,
51 .flags = IORESOURCE_IRQ,
55 static struct resource s3c2410_uart1_resource[] = {
56 [0] = {
57 .start = S3C2410_PA_UART1,
58 .end = S3C2410_PA_UART1 + 0x3fff,
59 .flags = IORESOURCE_MEM,
61 [1] = {
62 .start = IRQ_S3CUART_RX1,
63 .end = IRQ_S3CUART_ERR1,
64 .flags = IORESOURCE_IRQ,
68 static struct resource s3c2410_uart2_resource[] = {
69 [0] = {
70 .start = S3C2410_PA_UART2,
71 .end = S3C2410_PA_UART2 + 0x3fff,
72 .flags = IORESOURCE_MEM,
74 [1] = {
75 .start = IRQ_S3CUART_RX2,
76 .end = IRQ_S3CUART_ERR2,
77 .flags = IORESOURCE_IRQ,
81 static struct resource s3c2410_uart3_resource[] = {
82 [0] = {
83 .start = S3C2443_PA_UART3,
84 .end = S3C2443_PA_UART3 + 0x3fff,
85 .flags = IORESOURCE_MEM,
87 [1] = {
88 .start = IRQ_S3CUART_RX3,
89 .end = IRQ_S3CUART_ERR3,
90 .flags = IORESOURCE_IRQ,
94 struct s3c24xx_uart_resources s3c2410_uart_resources[] __initdata = {
95 [0] = {
96 .resources = s3c2410_uart0_resource,
97 .nr_resources = ARRAY_SIZE(s3c2410_uart0_resource),
99 [1] = {
100 .resources = s3c2410_uart1_resource,
101 .nr_resources = ARRAY_SIZE(s3c2410_uart1_resource),
103 [2] = {
104 .resources = s3c2410_uart2_resource,
105 .nr_resources = ARRAY_SIZE(s3c2410_uart2_resource),
107 [3] = {
108 .resources = s3c2410_uart3_resource,
109 .nr_resources = ARRAY_SIZE(s3c2410_uart3_resource),
113 /* yart devices */
115 static struct platform_device s3c24xx_uart_device0 = {
116 .id = 0,
119 static struct platform_device s3c24xx_uart_device1 = {
120 .id = 1,
123 static struct platform_device s3c24xx_uart_device2 = {
124 .id = 2,
127 static struct platform_device s3c24xx_uart_device3 = {
128 .id = 3,
131 struct platform_device *s3c24xx_uart_src[4] = {
132 &s3c24xx_uart_device0,
133 &s3c24xx_uart_device1,
134 &s3c24xx_uart_device2,
135 &s3c24xx_uart_device3,
138 struct platform_device *s3c24xx_uart_devs[4] = {
141 /* LCD Controller */
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,
149 [1] = {
150 .start = IRQ_LCD,
151 .end = IRQ_LCD,
152 .flags = IORESOURCE_IRQ,
157 static u64 s3c_device_lcd_dmamask = 0xffffffffUL;
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
170 EXPORT_SYMBOL(s3c_device_lcd);
172 void __init s3c24xx_fb_set_platdata(struct s3c2410fb_mach_info *pd)
174 struct s3c2410fb_mach_info *npd;
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");
185 /* NAND Controller */
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,
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,
202 EXPORT_SYMBOL(s3c_device_nand);
204 /* Touchscreen */
205 struct platform_device s3c_device_ts = {
206 .name = "s3c2410-ts",
207 .id = -1,
210 EXPORT_SYMBOL(s3c_device_ts);
212 static struct s3c2410_ts_mach_info s3c2410ts_info;
214 void set_s3c2410ts_info(struct s3c2410_ts_mach_info *hard_s3c2410ts_info)
216 memcpy(&s3c2410ts_info,hard_s3c2410ts_info,sizeof(struct s3c2410_ts_mach_info));
217 s3c_device_ts.dev.platform_data = &s3c2410ts_info;
219 EXPORT_SYMBOL(set_s3c2410ts_info);
221 /* USB Device (Gadget)*/
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,
229 [1] = {
230 .start = IRQ_USBD,
231 .end = IRQ_USBD,
232 .flags = IORESOURCE_IRQ,
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,
244 EXPORT_SYMBOL(s3c_device_usbgadget);
246 void __init s3c24xx_udc_set_platdata(struct s3c2410_udc_mach_info *pd)
248 struct s3c2410_udc_mach_info *npd;
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");
260 /* Watchdog */
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,
268 [1] = {
269 .start = IRQ_WDT,
270 .end = IRQ_WDT,
271 .flags = IORESOURCE_IRQ,
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,
283 EXPORT_SYMBOL(s3c_device_wdt);
285 /* IIS */
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,
295 static u64 s3c_device_iis_dmamask = 0xffffffffUL;
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
308 EXPORT_SYMBOL(s3c_device_iis);
310 /* RTC */
312 static struct resource s3c_rtc_resource[] = {
313 [0] = {
314 .start = S3C24XX_PA_RTC,
315 .end = S3C24XX_PA_RTC + 0xff,
316 .flags = IORESOURCE_MEM,
318 [1] = {
319 .start = IRQ_RTC,
320 .end = IRQ_RTC,
321 .flags = IORESOURCE_IRQ,
323 [2] = {
324 .start = IRQ_TICK,
325 .end = IRQ_TICK,
326 .flags = IORESOURCE_IRQ
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,
337 EXPORT_SYMBOL(s3c_device_rtc);
339 /* ADC */
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,
347 [1] = {
348 .start = IRQ_TC,
349 .end = IRQ_TC,
350 .flags = IORESOURCE_IRQ,
352 [2] = {
353 .start = IRQ_ADC,
354 .end = IRQ_ADC,
355 .flags = IORESOURCE_IRQ,
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,
367 /* HWMON */
369 struct platform_device s3c_device_hwmon = {
370 .name = "s3c24xx-hwmon",
371 .id = -1,
372 .dev.parent = &s3c_device_adc.dev,
375 /* SDI */
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,
383 [1] = {
384 .start = IRQ_SDI,
385 .end = IRQ_SDI,
386 .flags = IORESOURCE_IRQ,
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,
398 EXPORT_SYMBOL(s3c_device_sdi);
400 /* SPI (0) */
402 static struct resource s3c_spi0_resource[] = {
403 [0] = {
404 .start = S3C24XX_PA_SPI,
405 .end = S3C24XX_PA_SPI + 0x1f,
406 .flags = IORESOURCE_MEM,
408 [1] = {
409 .start = IRQ_SPI0,
410 .end = IRQ_SPI0,
411 .flags = IORESOURCE_IRQ,
416 static u64 s3c_device_spi0_dmamask = 0xffffffffUL;
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
429 EXPORT_SYMBOL(s3c_device_spi0);
431 /* SPI (1) */
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,
439 [1] = {
440 .start = IRQ_SPI1,
441 .end = IRQ_SPI1,
442 .flags = IORESOURCE_IRQ,
447 static u64 s3c_device_spi1_dmamask = 0xffffffffUL;
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
460 EXPORT_SYMBOL(s3c_device_spi1);
462 #ifdef CONFIG_CPU_S3C2440
464 /* Camif Controller */
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,
472 [1] = {
473 .start = IRQ_CAM,
474 .end = IRQ_CAM,
475 .flags = IORESOURCE_IRQ,
480 static u64 s3c_device_camif_dmamask = 0xffffffffUL;
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
493 EXPORT_SYMBOL(s3c_device_camif);
495 #endif // CONFIG_CPU_S32440