blob: 8c6de1c9968f4bf22eb2ac78e3d0c676b1c8b8e1 [file] [log] [blame]
Ben Dooksa21765a2007-02-11 18:31:01 +01001/* linux/arch/arm/plat-s3c24xx/devs.c
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 *
3 * Copyright (c) 2004 Simtec Electronics
Ben Dooks916a0022006-09-06 19:03:21 +01004 * Ben Dooks <ben@simtec.co.uk>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 *
Ben Dooks916a0022006-09-06 19:03:21 +01006 * Base S3C24XX platform device definitions
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 *
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 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070012*/
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>
Ben Dooksb6d1f542006-12-17 23:22:26 +010020#include <linux/serial_core.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010021#include <linux/platform_device.h>
Russell Kingfced80c2008-09-06 12:10:45 +010022#include <linux/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
24#include <asm/mach/arch.h>
25#include <asm/mach/map.h>
26#include <asm/mach/irq.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010027#include <mach/fb.h>
28#include <mach/hardware.h>
Mark Brownd91e9a72009-08-05 18:29:57 +010029#include <mach/dma.h>
30#include <mach/irqs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include <asm/irq.h>
32
Ben Dooksa2b7ba92008-10-07 22:26:09 +010033#include <plat/regs-serial.h>
Ben Dooks57bd4b92008-10-30 10:14:37 +000034#include <plat/udc.h>
Ben Dooks22c810a2010-01-18 16:24:22 +090035#include <plat/mci.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Ben Dooksa2b7ba92008-10-07 22:26:09 +010037#include <plat/devs.h>
38#include <plat/cpu.h>
Ben Dooks13622702008-10-30 10:14:38 +000039#include <plat/regs-spi.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
Arnaud Patardce8877b2009-12-23 19:25:05 +000041#include <mach/ts.h>
42
Linus Torvalds1da177e2005-04-16 15:20:36 -070043/* Serial port registrations */
44
Ben Dooks66a9b492006-06-18 23:04:05 +010045static 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
58static 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
71static 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
Ben Dooksdbf35992008-11-04 15:29:09 +000084static 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
Ben Dooks66a9b492006-06-18 23:04:05 +010097struct 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 },
Ben Dooksdbf35992008-11-04 15:29:09 +0000110 [3] = {
111 .resources = s3c2410_uart3_resource,
112 .nr_resources = ARRAY_SIZE(s3c2410_uart3_resource),
113 },
Ben Dooks66a9b492006-06-18 23:04:05 +0100114};
115
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116/* LCD Controller */
117
118static struct resource s3c_lcd_resource[] = {
119 [0] = {
Lucas Correia Villa Real0367a8d2006-01-26 15:20:50 +0000120 .start = S3C24XX_PA_LCD,
121 .end = S3C24XX_PA_LCD + S3C24XX_SZ_LCD - 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 .flags = IORESOURCE_MEM,
123 },
124 [1] = {
125 .start = IRQ_LCD,
126 .end = IRQ_LCD,
127 .flags = IORESOURCE_IRQ,
128 }
129
130};
131
132static u64 s3c_device_lcd_dmamask = 0xffffffffUL;
133
134struct 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 = {
Ben Dooks6904b242005-06-29 11:09:15 +0100140 .dma_mask = &s3c_device_lcd_dmamask,
141 .coherent_dma_mask = 0xffffffffUL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 }
143};
144
145EXPORT_SYMBOL(s3c_device_lcd);
146
Ben Dooks893b0302005-10-28 15:31:45 +0100147void __init s3c24xx_fb_set_platdata(struct s3c2410fb_mach_info *pd)
Arnaud Patardf92273c2005-09-09 13:10:10 -0700148{
Ben Dooks893b0302005-10-28 15:31:45 +0100149 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 }
Arnaud Patardf92273c2005-09-09 13:10:10 -0700158}
Arnaud Patardf92273c2005-09-09 13:10:10 -0700159
Arnaud Patardce8877b2009-12-23 19:25:05 +0000160/* Touchscreen */
Vasily Khoruzhick0fe13092010-02-18 18:32:27 +0200161
162static 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
Arnaud Patardce8877b2009-12-23 19:25:05 +0000176struct platform_device s3c_device_ts = {
177 .name = "s3c2410-ts",
178 .id = -1,
Vasily Khoruzhick0fe13092010-02-18 18:32:27 +0200179 .dev.parent = &s3c_device_adc.dev,
180 .num_resources = ARRAY_SIZE(s3c_ts_resource),
181 .resource = s3c_ts_resource,
Arnaud Patardce8877b2009-12-23 19:25:05 +0000182};
183EXPORT_SYMBOL(s3c_device_ts);
184
185static struct s3c2410_ts_mach_info s3c2410ts_info;
186
187void __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}
192EXPORT_SYMBOL(s3c24xx_ts_set_platdata);
193
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194/* USB Device (Gadget)*/
195
196static struct resource s3c_usbgadget_resource[] = {
197 [0] = {
Lucas Correia Villa Real0367a8d2006-01-26 15:20:50 +0000198 .start = S3C24XX_PA_USBDEV,
199 .end = S3C24XX_PA_USBDEV + S3C24XX_SZ_USBDEV - 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 .flags = IORESOURCE_MEM,
201 },
202 [1] = {
203 .start = IRQ_USBD,
204 .end = IRQ_USBD,
205 .flags = IORESOURCE_IRQ,
206 }
207
208};
209
210struct 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
217EXPORT_SYMBOL(s3c_device_usbgadget);
218
Arnaud Patard0dcfc322007-02-13 00:18:33 +0100219void __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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233/* Watchdog */
234
235static struct resource s3c_wdt_resource[] = {
236 [0] = {
Lucas Correia Villa Real0367a8d2006-01-26 15:20:50 +0000237 .start = S3C24XX_PA_WATCHDOG,
238 .end = S3C24XX_PA_WATCHDOG + S3C24XX_SZ_WATCHDOG - 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 .flags = IORESOURCE_MEM,
240 },
241 [1] = {
242 .start = IRQ_WDT,
243 .end = IRQ_WDT,
244 .flags = IORESOURCE_IRQ,
245 }
246
247};
248
249struct 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
256EXPORT_SYMBOL(s3c_device_wdt);
257
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258/* IIS */
259
260static struct resource s3c_iis_resource[] = {
261 [0] = {
Lucas Correia Villa Real0367a8d2006-01-26 15:20:50 +0000262 .start = S3C24XX_PA_IIS,
263 .end = S3C24XX_PA_IIS + S3C24XX_SZ_IIS -1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 .flags = IORESOURCE_MEM,
265 }
266};
267
268static u64 s3c_device_iis_dmamask = 0xffffffffUL;
269
270struct 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
281EXPORT_SYMBOL(s3c_device_iis);
282
283/* RTC */
284
285static struct resource s3c_rtc_resource[] = {
286 [0] = {
Lucas Correia Villa Real0367a8d2006-01-26 15:20:50 +0000287 .start = S3C24XX_PA_RTC,
288 .end = S3C24XX_PA_RTC + 0xff,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 .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
303struct 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
310EXPORT_SYMBOL(s3c_device_rtc);
311
312/* ADC */
313
314static struct resource s3c_adc_resource[] = {
315 [0] = {
Lucas Correia Villa Real0367a8d2006-01-26 15:20:50 +0000316 .start = S3C24XX_PA_ADC,
317 .end = S3C24XX_PA_ADC + S3C24XX_SZ_ADC - 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 .flags = IORESOURCE_MEM,
319 },
320 [1] = {
321 .start = IRQ_TC,
Ben Dooks083d06e2006-02-08 22:03:31 +0000322 .end = IRQ_TC,
323 .flags = IORESOURCE_IRQ,
324 },
325 [2] = {
326 .start = IRQ_ADC,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327 .end = IRQ_ADC,
328 .flags = IORESOURCE_IRQ,
329 }
330
331};
332
333struct platform_device s3c_device_adc = {
Ben Dooks28ab44c5b2008-12-18 14:20:04 +0000334 .name = "s3c24xx-adc",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 .id = -1,
336 .num_resources = ARRAY_SIZE(s3c_adc_resource),
337 .resource = s3c_adc_resource,
338};
339
Ben Dooks28ab44c5b2008-12-18 14:20:04 +0000340/* HWMON */
341
342struct platform_device s3c_device_hwmon = {
Ben Dooksc197cec2009-07-18 10:12:25 +0100343 .name = "s3c-hwmon",
Ben Dooks28ab44c5b2008-12-18 14:20:04 +0000344 .id = -1,
345 .dev.parent = &s3c_device_adc.dev,
346};
347
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348/* SDI */
349
350static struct resource s3c_sdi_resource[] = {
351 [0] = {
Ben Dooksce46a9c2008-10-21 14:06:26 +0100352 .start = S3C24XX_PA_SDI,
353 .end = S3C24XX_PA_SDI + S3C24XX_SZ_SDI - 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 .flags = IORESOURCE_MEM,
355 },
356 [1] = {
357 .start = IRQ_SDI,
358 .end = IRQ_SDI,
359 .flags = IORESOURCE_IRQ,
360 }
361
362};
363
364struct 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
371EXPORT_SYMBOL(s3c_device_sdi);
372
Ben Dooks22c810a2010-01-18 16:24:22 +0900373void 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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385/* SPI (0) */
386
387static struct resource s3c_spi0_resource[] = {
388 [0] = {
Lucas Correia Villa Real0367a8d2006-01-26 15:20:50 +0000389 .start = S3C24XX_PA_SPI,
390 .end = S3C24XX_PA_SPI + 0x1f,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 .flags = IORESOURCE_MEM,
392 },
393 [1] = {
394 .start = IRQ_SPI0,
395 .end = IRQ_SPI0,
396 .flags = IORESOURCE_IRQ,
397 }
398
399};
400
Albrecht Dreß66be0c32006-03-15 16:03:05 +0000401static u64 s3c_device_spi0_dmamask = 0xffffffffUL;
402
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403struct 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,
Albrecht Dreß66be0c32006-03-15 16:03:05 +0000408 .dev = {
409 .dma_mask = &s3c_device_spi0_dmamask,
410 .coherent_dma_mask = 0xffffffffUL
411 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412};
413
414EXPORT_SYMBOL(s3c_device_spi0);
415
416/* SPI (1) */
417
418static struct resource s3c_spi1_resource[] = {
419 [0] = {
Sandeep Sanjay Patile9033822007-05-16 10:51:45 +0100420 .start = S3C24XX_PA_SPI + S3C2410_SPI1,
421 .end = S3C24XX_PA_SPI + S3C2410_SPI1 + 0x1f,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422 .flags = IORESOURCE_MEM,
423 },
424 [1] = {
425 .start = IRQ_SPI1,
426 .end = IRQ_SPI1,
427 .flags = IORESOURCE_IRQ,
428 }
429
430};
431
Albrecht Dreß66be0c32006-03-15 16:03:05 +0000432static u64 s3c_device_spi1_dmamask = 0xffffffffUL;
433
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434struct 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,
Albrecht Dreß66be0c32006-03-15 16:03:05 +0000439 .dev = {
440 .dma_mask = &s3c_device_spi1_dmamask,
441 .coherent_dma_mask = 0xffffffffUL
442 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443};
444
445EXPORT_SYMBOL(s3c_device_spi1);
446
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447#ifdef CONFIG_CPU_S3C2440
448
449/* Camif Controller */
450
451static struct resource s3c_camif_resource[] = {
452 [0] = {
453 .start = S3C2440_PA_CAMIF,
Ben Dooksa0e0adb2005-10-28 15:26:42 +0100454 .end = S3C2440_PA_CAMIF + S3C2440_SZ_CAMIF - 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 .flags = IORESOURCE_MEM,
456 },
457 [1] = {
458 .start = IRQ_CAM,
459 .end = IRQ_CAM,
460 .flags = IORESOURCE_IRQ,
461 }
462
463};
464
465static u64 s3c_device_camif_dmamask = 0xffffffffUL;
466
467struct 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
478EXPORT_SYMBOL(s3c_device_camif);
479
Mark Brownd91e9a72009-08-05 18:29:57 +0100480/* AC97 */
481
482static 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
513static u64 s3c_device_ac97_dmamask = 0xffffffffUL;
514
515struct 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
526EXPORT_SYMBOL(s3c_device_ac97);
527
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528#endif // CONFIG_CPU_S32440