blob: 2f91057a0c02380841db092f087ea9f6731efca6 [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>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090023#include <linux/slab.h>
Arnaud Patardf44c67c2010-04-22 10:47:44 +020024#include <linux/string.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26#include <asm/mach/arch.h>
27#include <asm/mach/map.h>
28#include <asm/mach/irq.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010029#include <mach/fb.h>
30#include <mach/hardware.h>
Mark Brownd91e9a72009-08-05 18:29:57 +010031#include <mach/dma.h>
32#include <mach/irqs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#include <asm/irq.h>
34
Ben Dooksa2b7ba92008-10-07 22:26:09 +010035#include <plat/regs-serial.h>
Ben Dooks57bd4b92008-10-30 10:14:37 +000036#include <plat/udc.h>
Ben Dooks22c810a2010-01-18 16:24:22 +090037#include <plat/mci.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
Ben Dooksa2b7ba92008-10-07 22:26:09 +010039#include <plat/devs.h>
40#include <plat/cpu.h>
Ben Dooks13622702008-10-30 10:14:38 +000041#include <plat/regs-spi.h>
Maurus Cuelenaere73e59b12010-05-04 13:12:41 +020042#include <plat/ts.h>
Arnaud Patardce8877b2009-12-23 19:25:05 +000043
Linus Torvalds1da177e2005-04-16 15:20:36 -070044/* Serial port registrations */
45
Ben Dooks66a9b492006-06-18 23:04:05 +010046static struct resource s3c2410_uart0_resource[] = {
47 [0] = {
48 .start = S3C2410_PA_UART0,
49 .end = S3C2410_PA_UART0 + 0x3fff,
50 .flags = IORESOURCE_MEM,
51 },
52 [1] = {
53 .start = IRQ_S3CUART_RX0,
54 .end = IRQ_S3CUART_ERR0,
55 .flags = IORESOURCE_IRQ,
56 }
57};
58
59static struct resource s3c2410_uart1_resource[] = {
60 [0] = {
61 .start = S3C2410_PA_UART1,
62 .end = S3C2410_PA_UART1 + 0x3fff,
63 .flags = IORESOURCE_MEM,
64 },
65 [1] = {
66 .start = IRQ_S3CUART_RX1,
67 .end = IRQ_S3CUART_ERR1,
68 .flags = IORESOURCE_IRQ,
69 }
70};
71
72static struct resource s3c2410_uart2_resource[] = {
73 [0] = {
74 .start = S3C2410_PA_UART2,
75 .end = S3C2410_PA_UART2 + 0x3fff,
76 .flags = IORESOURCE_MEM,
77 },
78 [1] = {
79 .start = IRQ_S3CUART_RX2,
80 .end = IRQ_S3CUART_ERR2,
81 .flags = IORESOURCE_IRQ,
82 }
83};
84
Ben Dooksdbf35992008-11-04 15:29:09 +000085static struct resource s3c2410_uart3_resource[] = {
86 [0] = {
87 .start = S3C2443_PA_UART3,
88 .end = S3C2443_PA_UART3 + 0x3fff,
89 .flags = IORESOURCE_MEM,
90 },
91 [1] = {
92 .start = IRQ_S3CUART_RX3,
93 .end = IRQ_S3CUART_ERR3,
94 .flags = IORESOURCE_IRQ,
95 },
96};
97
Ben Dooks66a9b492006-06-18 23:04:05 +010098struct s3c24xx_uart_resources s3c2410_uart_resources[] __initdata = {
99 [0] = {
100 .resources = s3c2410_uart0_resource,
101 .nr_resources = ARRAY_SIZE(s3c2410_uart0_resource),
102 },
103 [1] = {
104 .resources = s3c2410_uart1_resource,
105 .nr_resources = ARRAY_SIZE(s3c2410_uart1_resource),
106 },
107 [2] = {
108 .resources = s3c2410_uart2_resource,
109 .nr_resources = ARRAY_SIZE(s3c2410_uart2_resource),
110 },
Ben Dooksdbf35992008-11-04 15:29:09 +0000111 [3] = {
112 .resources = s3c2410_uart3_resource,
113 .nr_resources = ARRAY_SIZE(s3c2410_uart3_resource),
114 },
Ben Dooks66a9b492006-06-18 23:04:05 +0100115};
116
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117/* LCD Controller */
118
119static struct resource s3c_lcd_resource[] = {
120 [0] = {
Lucas Correia Villa Real0367a8d2006-01-26 15:20:50 +0000121 .start = S3C24XX_PA_LCD,
122 .end = S3C24XX_PA_LCD + S3C24XX_SZ_LCD - 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 .flags = IORESOURCE_MEM,
124 },
125 [1] = {
126 .start = IRQ_LCD,
127 .end = IRQ_LCD,
128 .flags = IORESOURCE_IRQ,
129 }
130
131};
132
133static u64 s3c_device_lcd_dmamask = 0xffffffffUL;
134
135struct platform_device s3c_device_lcd = {
136 .name = "s3c2410-lcd",
137 .id = -1,
138 .num_resources = ARRAY_SIZE(s3c_lcd_resource),
139 .resource = s3c_lcd_resource,
140 .dev = {
Ben Dooks6904b242005-06-29 11:09:15 +0100141 .dma_mask = &s3c_device_lcd_dmamask,
142 .coherent_dma_mask = 0xffffffffUL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 }
144};
145
146EXPORT_SYMBOL(s3c_device_lcd);
147
Ben Dooks893b0302005-10-28 15:31:45 +0100148void __init s3c24xx_fb_set_platdata(struct s3c2410fb_mach_info *pd)
Arnaud Patardf92273c2005-09-09 13:10:10 -0700149{
Ben Dooks893b0302005-10-28 15:31:45 +0100150 struct s3c2410fb_mach_info *npd;
151
Arnaud Patardf44c67c2010-04-22 10:47:44 +0200152 npd = kmemdup(pd, sizeof(*npd), GFP_KERNEL);
Ben Dooks893b0302005-10-28 15:31:45 +0100153 if (npd) {
Ben Dooks893b0302005-10-28 15:31:45 +0100154 s3c_device_lcd.dev.platform_data = npd;
Arnaud Patardf44c67c2010-04-22 10:47:44 +0200155 npd->displays = kmemdup(pd->displays,
156 sizeof(struct s3c2410fb_display) * npd->num_displays,
157 GFP_KERNEL);
158 if (!npd->displays)
159 printk(KERN_ERR "no memory for LCD display data\n");
Ben Dooks893b0302005-10-28 15:31:45 +0100160 } else {
161 printk(KERN_ERR "no memory for LCD platform data\n");
162 }
Arnaud Patardf92273c2005-09-09 13:10:10 -0700163}
Arnaud Patardf92273c2005-09-09 13:10:10 -0700164
Arnaud Patardce8877b2009-12-23 19:25:05 +0000165/* Touchscreen */
Vasily Khoruzhick0fe13092010-02-18 18:32:27 +0200166
167static struct resource s3c_ts_resource[] = {
168 [0] = {
169 .start = S3C24XX_PA_ADC,
170 .end = S3C24XX_PA_ADC + S3C24XX_SZ_ADC - 1,
171 .flags = IORESOURCE_MEM,
172 },
173 [1] = {
174 .start = IRQ_TC,
175 .end = IRQ_TC,
176 .flags = IORESOURCE_IRQ,
177 },
178
179};
180
Arnaud Patardce8877b2009-12-23 19:25:05 +0000181struct platform_device s3c_device_ts = {
182 .name = "s3c2410-ts",
183 .id = -1,
Vasily Khoruzhick0fe13092010-02-18 18:32:27 +0200184 .dev.parent = &s3c_device_adc.dev,
185 .num_resources = ARRAY_SIZE(s3c_ts_resource),
186 .resource = s3c_ts_resource,
Arnaud Patardce8877b2009-12-23 19:25:05 +0000187};
188EXPORT_SYMBOL(s3c_device_ts);
189
190static struct s3c2410_ts_mach_info s3c2410ts_info;
191
192void __init s3c24xx_ts_set_platdata(struct s3c2410_ts_mach_info *hard_s3c2410ts_info)
193{
194 memcpy(&s3c2410ts_info, hard_s3c2410ts_info, sizeof(struct s3c2410_ts_mach_info));
195 s3c_device_ts.dev.platform_data = &s3c2410ts_info;
196}
197EXPORT_SYMBOL(s3c24xx_ts_set_platdata);
198
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199/* USB Device (Gadget)*/
200
201static struct resource s3c_usbgadget_resource[] = {
202 [0] = {
Lucas Correia Villa Real0367a8d2006-01-26 15:20:50 +0000203 .start = S3C24XX_PA_USBDEV,
204 .end = S3C24XX_PA_USBDEV + S3C24XX_SZ_USBDEV - 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 .flags = IORESOURCE_MEM,
206 },
207 [1] = {
208 .start = IRQ_USBD,
209 .end = IRQ_USBD,
210 .flags = IORESOURCE_IRQ,
211 }
212
213};
214
215struct platform_device s3c_device_usbgadget = {
216 .name = "s3c2410-usbgadget",
217 .id = -1,
218 .num_resources = ARRAY_SIZE(s3c_usbgadget_resource),
219 .resource = s3c_usbgadget_resource,
220};
221
222EXPORT_SYMBOL(s3c_device_usbgadget);
223
Arnaud Patard0dcfc322007-02-13 00:18:33 +0100224void __init s3c24xx_udc_set_platdata(struct s3c2410_udc_mach_info *pd)
225{
226 struct s3c2410_udc_mach_info *npd;
227
228 npd = kmalloc(sizeof(*npd), GFP_KERNEL);
229 if (npd) {
230 memcpy(npd, pd, sizeof(*npd));
231 s3c_device_usbgadget.dev.platform_data = npd;
232 } else {
233 printk(KERN_ERR "no memory for udc platform data\n");
234 }
235}
236
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237/* IIS */
238
239static struct resource s3c_iis_resource[] = {
240 [0] = {
Lucas Correia Villa Real0367a8d2006-01-26 15:20:50 +0000241 .start = S3C24XX_PA_IIS,
242 .end = S3C24XX_PA_IIS + S3C24XX_SZ_IIS -1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 .flags = IORESOURCE_MEM,
244 }
245};
246
247static u64 s3c_device_iis_dmamask = 0xffffffffUL;
248
249struct platform_device s3c_device_iis = {
Vasily Khoruzhickada69e32010-08-30 11:28:09 +0300250 .name = "s3c24xx-iis",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 .id = -1,
252 .num_resources = ARRAY_SIZE(s3c_iis_resource),
253 .resource = s3c_iis_resource,
254 .dev = {
255 .dma_mask = &s3c_device_iis_dmamask,
256 .coherent_dma_mask = 0xffffffffUL
257 }
258};
259
260EXPORT_SYMBOL(s3c_device_iis);
261
Vasily Khoruzhickada69e32010-08-30 11:28:09 +0300262/* ASoC PCM DMA */
263
264static u64 s3c_device_audio_dmamask = 0xffffffffUL;
265
266struct platform_device s3c_device_pcm = {
267 .name = "s3c24xx-pcm-audio",
268 .id = -1,
269 .dev = {
270 .dma_mask = &s3c_device_audio_dmamask,
271 .coherent_dma_mask = 0xffffffffUL
272 }
273};
274
275EXPORT_SYMBOL(s3c_device_pcm);
276
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277/* RTC */
278
279static struct resource s3c_rtc_resource[] = {
280 [0] = {
Lucas Correia Villa Real0367a8d2006-01-26 15:20:50 +0000281 .start = S3C24XX_PA_RTC,
282 .end = S3C24XX_PA_RTC + 0xff,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 .flags = IORESOURCE_MEM,
284 },
285 [1] = {
286 .start = IRQ_RTC,
287 .end = IRQ_RTC,
288 .flags = IORESOURCE_IRQ,
289 },
290 [2] = {
291 .start = IRQ_TICK,
292 .end = IRQ_TICK,
293 .flags = IORESOURCE_IRQ
294 }
295};
296
297struct platform_device s3c_device_rtc = {
298 .name = "s3c2410-rtc",
299 .id = -1,
300 .num_resources = ARRAY_SIZE(s3c_rtc_resource),
301 .resource = s3c_rtc_resource,
302};
303
304EXPORT_SYMBOL(s3c_device_rtc);
305
306/* ADC */
307
308static struct resource s3c_adc_resource[] = {
309 [0] = {
Lucas Correia Villa Real0367a8d2006-01-26 15:20:50 +0000310 .start = S3C24XX_PA_ADC,
311 .end = S3C24XX_PA_ADC + S3C24XX_SZ_ADC - 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 .flags = IORESOURCE_MEM,
313 },
314 [1] = {
315 .start = IRQ_TC,
Ben Dooks083d06e2006-02-08 22:03:31 +0000316 .end = IRQ_TC,
317 .flags = IORESOURCE_IRQ,
318 },
319 [2] = {
320 .start = IRQ_ADC,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 .end = IRQ_ADC,
322 .flags = IORESOURCE_IRQ,
323 }
324
325};
326
327struct platform_device s3c_device_adc = {
Ben Dooks28ab44c5b2008-12-18 14:20:04 +0000328 .name = "s3c24xx-adc",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329 .id = -1,
330 .num_resources = ARRAY_SIZE(s3c_adc_resource),
331 .resource = s3c_adc_resource,
332};
333
334/* SDI */
335
336static struct resource s3c_sdi_resource[] = {
337 [0] = {
Ben Dooksce46a9c2008-10-21 14:06:26 +0100338 .start = S3C24XX_PA_SDI,
339 .end = S3C24XX_PA_SDI + S3C24XX_SZ_SDI - 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 .flags = IORESOURCE_MEM,
341 },
342 [1] = {
343 .start = IRQ_SDI,
344 .end = IRQ_SDI,
345 .flags = IORESOURCE_IRQ,
346 }
347
348};
349
350struct platform_device s3c_device_sdi = {
351 .name = "s3c2410-sdi",
352 .id = -1,
353 .num_resources = ARRAY_SIZE(s3c_sdi_resource),
354 .resource = s3c_sdi_resource,
355};
356
357EXPORT_SYMBOL(s3c_device_sdi);
358
Arnaud Patard1f138f12010-04-22 10:47:45 +0200359void __init s3c24xx_mci_set_platdata(struct s3c24xx_mci_pdata *pdata)
Ben Dooks22c810a2010-01-18 16:24:22 +0900360{
361 struct s3c24xx_mci_pdata *npd;
362
363 npd = kmemdup(pdata, sizeof(struct s3c24xx_mci_pdata), GFP_KERNEL);
364 if (!npd)
365 printk(KERN_ERR "%s: no memory to copy pdata", __func__);
366
367 s3c_device_sdi.dev.platform_data = npd;
368}
369
370
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371/* SPI (0) */
372
373static struct resource s3c_spi0_resource[] = {
374 [0] = {
Lucas Correia Villa Real0367a8d2006-01-26 15:20:50 +0000375 .start = S3C24XX_PA_SPI,
376 .end = S3C24XX_PA_SPI + 0x1f,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 .flags = IORESOURCE_MEM,
378 },
379 [1] = {
380 .start = IRQ_SPI0,
381 .end = IRQ_SPI0,
382 .flags = IORESOURCE_IRQ,
383 }
384
385};
386
Albrecht Dreß66be0c32006-03-15 16:03:05 +0000387static u64 s3c_device_spi0_dmamask = 0xffffffffUL;
388
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389struct platform_device s3c_device_spi0 = {
390 .name = "s3c2410-spi",
391 .id = 0,
392 .num_resources = ARRAY_SIZE(s3c_spi0_resource),
393 .resource = s3c_spi0_resource,
Albrecht Dreß66be0c32006-03-15 16:03:05 +0000394 .dev = {
395 .dma_mask = &s3c_device_spi0_dmamask,
396 .coherent_dma_mask = 0xffffffffUL
397 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398};
399
400EXPORT_SYMBOL(s3c_device_spi0);
401
402/* SPI (1) */
403
404static struct resource s3c_spi1_resource[] = {
405 [0] = {
Sandeep Sanjay Patile9033822007-05-16 10:51:45 +0100406 .start = S3C24XX_PA_SPI + S3C2410_SPI1,
407 .end = S3C24XX_PA_SPI + S3C2410_SPI1 + 0x1f,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 .flags = IORESOURCE_MEM,
409 },
410 [1] = {
411 .start = IRQ_SPI1,
412 .end = IRQ_SPI1,
413 .flags = IORESOURCE_IRQ,
414 }
415
416};
417
Albrecht Dreß66be0c32006-03-15 16:03:05 +0000418static u64 s3c_device_spi1_dmamask = 0xffffffffUL;
419
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420struct platform_device s3c_device_spi1 = {
421 .name = "s3c2410-spi",
422 .id = 1,
423 .num_resources = ARRAY_SIZE(s3c_spi1_resource),
424 .resource = s3c_spi1_resource,
Albrecht Dreß66be0c32006-03-15 16:03:05 +0000425 .dev = {
426 .dma_mask = &s3c_device_spi1_dmamask,
427 .coherent_dma_mask = 0xffffffffUL
428 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429};
430
431EXPORT_SYMBOL(s3c_device_spi1);
432
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433#ifdef CONFIG_CPU_S3C2440
434
435/* Camif Controller */
436
437static struct resource s3c_camif_resource[] = {
438 [0] = {
439 .start = S3C2440_PA_CAMIF,
Ben Dooksa0e0adb2005-10-28 15:26:42 +0100440 .end = S3C2440_PA_CAMIF + S3C2440_SZ_CAMIF - 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441 .flags = IORESOURCE_MEM,
442 },
443 [1] = {
444 .start = IRQ_CAM,
445 .end = IRQ_CAM,
446 .flags = IORESOURCE_IRQ,
447 }
448
449};
450
451static u64 s3c_device_camif_dmamask = 0xffffffffUL;
452
453struct platform_device s3c_device_camif = {
454 .name = "s3c2440-camif",
455 .id = -1,
456 .num_resources = ARRAY_SIZE(s3c_camif_resource),
457 .resource = s3c_camif_resource,
458 .dev = {
459 .dma_mask = &s3c_device_camif_dmamask,
460 .coherent_dma_mask = 0xffffffffUL
461 }
462};
463
464EXPORT_SYMBOL(s3c_device_camif);
465
Mark Brownd91e9a72009-08-05 18:29:57 +0100466/* AC97 */
467
468static struct resource s3c_ac97_resource[] = {
469 [0] = {
470 .start = S3C2440_PA_AC97,
471 .end = S3C2440_PA_AC97 + S3C2440_SZ_AC97 -1,
472 .flags = IORESOURCE_MEM,
473 },
474 [1] = {
475 .start = IRQ_S3C244x_AC97,
476 .end = IRQ_S3C244x_AC97,
477 .flags = IORESOURCE_IRQ,
478 },
479 [2] = {
480 .name = "PCM out",
481 .start = DMACH_PCM_OUT,
482 .end = DMACH_PCM_OUT,
483 .flags = IORESOURCE_DMA,
484 },
485 [3] = {
486 .name = "PCM in",
487 .start = DMACH_PCM_IN,
488 .end = DMACH_PCM_IN,
489 .flags = IORESOURCE_DMA,
490 },
491 [4] = {
492 .name = "Mic in",
493 .start = DMACH_MIC_IN,
494 .end = DMACH_MIC_IN,
495 .flags = IORESOURCE_DMA,
496 },
497};
498
Mark Brownd91e9a72009-08-05 18:29:57 +0100499struct platform_device s3c_device_ac97 = {
500 .name = "s3c-ac97",
501 .id = -1,
502 .num_resources = ARRAY_SIZE(s3c_ac97_resource),
503 .resource = s3c_ac97_resource,
504 .dev = {
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000505 .dma_mask = &s3c_device_audio_dmamask,
Mark Brownd91e9a72009-08-05 18:29:57 +0100506 .coherent_dma_mask = 0xffffffffUL
507 }
508};
509
510EXPORT_SYMBOL(s3c_device_ac97);
511
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000512/* ASoC I2S */
513
514struct platform_device s3c2412_device_iis = {
515 .name = "s3c2412-iis",
516 .id = -1,
517 .dev = {
518 .dma_mask = &s3c_device_audio_dmamask,
519 .coherent_dma_mask = 0xffffffffUL
520 }
521};
522
523EXPORT_SYMBOL(s3c2412_device_iis);
524
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525#endif // CONFIG_CPU_S32440