]>
Commit | Line | Data |
---|---|---|
a21765a7 | 1 | /* linux/arch/arm/plat-s3c24xx/devs.c |
1da177e4 LT |
2 | * |
3 | * Copyright (c) 2004 Simtec Electronics | |
916a0021 | 4 | * Ben Dooks <ben@simtec.co.uk> |
1da177e4 | 5 | * |
916a0021 | 6 | * Base S3C24XX platform device definitions |
1da177e4 LT |
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 | * | |
1da177e4 LT |
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> | |
b6d1f542 | 20 | #include <linux/serial_core.h> |
d052d1be | 21 | #include <linux/platform_device.h> |
fced80c7 | 22 | #include <linux/io.h> |
5a0e3ad6 | 23 | #include <linux/slab.h> |
f44c67cd | 24 | #include <linux/string.h> |
1da177e4 LT |
25 | |
26 | #include <asm/mach/arch.h> | |
27 | #include <asm/mach/map.h> | |
28 | #include <asm/mach/irq.h> | |
a09e64fb RK |
29 | #include <mach/fb.h> |
30 | #include <mach/hardware.h> | |
d91e9a7a MB |
31 | #include <mach/dma.h> |
32 | #include <mach/irqs.h> | |
1da177e4 LT |
33 | #include <asm/irq.h> |
34 | ||
a2b7ba9c | 35 | #include <plat/regs-serial.h> |
57bd4b91 | 36 | #include <plat/udc.h> |
22c810ab | 37 | #include <plat/mci.h> |
1da177e4 | 38 | |
a2b7ba9c BD |
39 | #include <plat/devs.h> |
40 | #include <plat/cpu.h> | |
13622708 | 41 | #include <plat/regs-spi.h> |
1da177e4 | 42 | |
ce8877b5 AP |
43 | #include <mach/ts.h> |
44 | ||
1da177e4 LT |
45 | /* Serial port registrations */ |
46 | ||
66a9b49a BD |
47 | static struct resource s3c2410_uart0_resource[] = { |
48 | [0] = { | |
49 | .start = S3C2410_PA_UART0, | |
50 | .end = S3C2410_PA_UART0 + 0x3fff, | |
51 | .flags = IORESOURCE_MEM, | |
52 | }, | |
53 | [1] = { | |
54 | .start = IRQ_S3CUART_RX0, | |
55 | .end = IRQ_S3CUART_ERR0, | |
56 | .flags = IORESOURCE_IRQ, | |
57 | } | |
58 | }; | |
59 | ||
60 | static struct resource s3c2410_uart1_resource[] = { | |
61 | [0] = { | |
62 | .start = S3C2410_PA_UART1, | |
63 | .end = S3C2410_PA_UART1 + 0x3fff, | |
64 | .flags = IORESOURCE_MEM, | |
65 | }, | |
66 | [1] = { | |
67 | .start = IRQ_S3CUART_RX1, | |
68 | .end = IRQ_S3CUART_ERR1, | |
69 | .flags = IORESOURCE_IRQ, | |
70 | } | |
71 | }; | |
72 | ||
73 | static struct resource s3c2410_uart2_resource[] = { | |
74 | [0] = { | |
75 | .start = S3C2410_PA_UART2, | |
76 | .end = S3C2410_PA_UART2 + 0x3fff, | |
77 | .flags = IORESOURCE_MEM, | |
78 | }, | |
79 | [1] = { | |
80 | .start = IRQ_S3CUART_RX2, | |
81 | .end = IRQ_S3CUART_ERR2, | |
82 | .flags = IORESOURCE_IRQ, | |
83 | } | |
84 | }; | |
85 | ||
dbf35992 BD |
86 | static struct resource s3c2410_uart3_resource[] = { |
87 | [0] = { | |
88 | .start = S3C2443_PA_UART3, | |
89 | .end = S3C2443_PA_UART3 + 0x3fff, | |
90 | .flags = IORESOURCE_MEM, | |
91 | }, | |
92 | [1] = { | |
93 | .start = IRQ_S3CUART_RX3, | |
94 | .end = IRQ_S3CUART_ERR3, | |
95 | .flags = IORESOURCE_IRQ, | |
96 | }, | |
97 | }; | |
98 | ||
66a9b49a BD |
99 | struct s3c24xx_uart_resources s3c2410_uart_resources[] __initdata = { |
100 | [0] = { | |
101 | .resources = s3c2410_uart0_resource, | |
102 | .nr_resources = ARRAY_SIZE(s3c2410_uart0_resource), | |
103 | }, | |
104 | [1] = { | |
105 | .resources = s3c2410_uart1_resource, | |
106 | .nr_resources = ARRAY_SIZE(s3c2410_uart1_resource), | |
107 | }, | |
108 | [2] = { | |
109 | .resources = s3c2410_uart2_resource, | |
110 | .nr_resources = ARRAY_SIZE(s3c2410_uart2_resource), | |
111 | }, | |
dbf35992 BD |
112 | [3] = { |
113 | .resources = s3c2410_uart3_resource, | |
114 | .nr_resources = ARRAY_SIZE(s3c2410_uart3_resource), | |
115 | }, | |
66a9b49a BD |
116 | }; |
117 | ||
1da177e4 LT |
118 | /* LCD Controller */ |
119 | ||
120 | static struct resource s3c_lcd_resource[] = { | |
121 | [0] = { | |
0367a8d3 LCVR |
122 | .start = S3C24XX_PA_LCD, |
123 | .end = S3C24XX_PA_LCD + S3C24XX_SZ_LCD - 1, | |
1da177e4 LT |
124 | .flags = IORESOURCE_MEM, |
125 | }, | |
126 | [1] = { | |
127 | .start = IRQ_LCD, | |
128 | .end = IRQ_LCD, | |
129 | .flags = IORESOURCE_IRQ, | |
130 | } | |
131 | ||
132 | }; | |
133 | ||
134 | static u64 s3c_device_lcd_dmamask = 0xffffffffUL; | |
135 | ||
136 | struct platform_device s3c_device_lcd = { | |
137 | .name = "s3c2410-lcd", | |
138 | .id = -1, | |
139 | .num_resources = ARRAY_SIZE(s3c_lcd_resource), | |
140 | .resource = s3c_lcd_resource, | |
141 | .dev = { | |
6904b246 BD |
142 | .dma_mask = &s3c_device_lcd_dmamask, |
143 | .coherent_dma_mask = 0xffffffffUL | |
1da177e4 LT |
144 | } |
145 | }; | |
146 | ||
147 | EXPORT_SYMBOL(s3c_device_lcd); | |
148 | ||
893b0309 | 149 | void __init s3c24xx_fb_set_platdata(struct s3c2410fb_mach_info *pd) |
f92273c1 | 150 | { |
893b0309 BD |
151 | struct s3c2410fb_mach_info *npd; |
152 | ||
f44c67cd | 153 | npd = kmemdup(pd, sizeof(*npd), GFP_KERNEL); |
893b0309 | 154 | if (npd) { |
893b0309 | 155 | s3c_device_lcd.dev.platform_data = npd; |
f44c67cd AP |
156 | npd->displays = kmemdup(pd->displays, |
157 | sizeof(struct s3c2410fb_display) * npd->num_displays, | |
158 | GFP_KERNEL); | |
159 | if (!npd->displays) | |
160 | printk(KERN_ERR "no memory for LCD display data\n"); | |
893b0309 BD |
161 | } else { |
162 | printk(KERN_ERR "no memory for LCD platform data\n"); | |
163 | } | |
f92273c1 | 164 | } |
f92273c1 | 165 | |
ce8877b5 | 166 | /* Touchscreen */ |
0fe1309b VK |
167 | |
168 | static struct resource s3c_ts_resource[] = { | |
169 | [0] = { | |
170 | .start = S3C24XX_PA_ADC, | |
171 | .end = S3C24XX_PA_ADC + S3C24XX_SZ_ADC - 1, | |
172 | .flags = IORESOURCE_MEM, | |
173 | }, | |
174 | [1] = { | |
175 | .start = IRQ_TC, | |
176 | .end = IRQ_TC, | |
177 | .flags = IORESOURCE_IRQ, | |
178 | }, | |
179 | ||
180 | }; | |
181 | ||
ce8877b5 AP |
182 | struct platform_device s3c_device_ts = { |
183 | .name = "s3c2410-ts", | |
184 | .id = -1, | |
0fe1309b VK |
185 | .dev.parent = &s3c_device_adc.dev, |
186 | .num_resources = ARRAY_SIZE(s3c_ts_resource), | |
187 | .resource = s3c_ts_resource, | |
ce8877b5 AP |
188 | }; |
189 | EXPORT_SYMBOL(s3c_device_ts); | |
190 | ||
191 | static struct s3c2410_ts_mach_info s3c2410ts_info; | |
192 | ||
193 | void __init s3c24xx_ts_set_platdata(struct s3c2410_ts_mach_info *hard_s3c2410ts_info) | |
194 | { | |
195 | memcpy(&s3c2410ts_info, hard_s3c2410ts_info, sizeof(struct s3c2410_ts_mach_info)); | |
196 | s3c_device_ts.dev.platform_data = &s3c2410ts_info; | |
197 | } | |
198 | EXPORT_SYMBOL(s3c24xx_ts_set_platdata); | |
199 | ||
1da177e4 LT |
200 | /* USB Device (Gadget)*/ |
201 | ||
202 | static struct resource s3c_usbgadget_resource[] = { | |
203 | [0] = { | |
0367a8d3 LCVR |
204 | .start = S3C24XX_PA_USBDEV, |
205 | .end = S3C24XX_PA_USBDEV + S3C24XX_SZ_USBDEV - 1, | |
1da177e4 LT |
206 | .flags = IORESOURCE_MEM, |
207 | }, | |
208 | [1] = { | |
209 | .start = IRQ_USBD, | |
210 | .end = IRQ_USBD, | |
211 | .flags = IORESOURCE_IRQ, | |
212 | } | |
213 | ||
214 | }; | |
215 | ||
216 | struct platform_device s3c_device_usbgadget = { | |
217 | .name = "s3c2410-usbgadget", | |
218 | .id = -1, | |
219 | .num_resources = ARRAY_SIZE(s3c_usbgadget_resource), | |
220 | .resource = s3c_usbgadget_resource, | |
221 | }; | |
222 | ||
223 | EXPORT_SYMBOL(s3c_device_usbgadget); | |
224 | ||
0dcfc328 AP |
225 | void __init s3c24xx_udc_set_platdata(struct s3c2410_udc_mach_info *pd) |
226 | { | |
227 | struct s3c2410_udc_mach_info *npd; | |
228 | ||
229 | npd = kmalloc(sizeof(*npd), GFP_KERNEL); | |
230 | if (npd) { | |
231 | memcpy(npd, pd, sizeof(*npd)); | |
232 | s3c_device_usbgadget.dev.platform_data = npd; | |
233 | } else { | |
234 | printk(KERN_ERR "no memory for udc platform data\n"); | |
235 | } | |
236 | } | |
237 | ||
238 | ||
1da177e4 LT |
239 | /* Watchdog */ |
240 | ||
241 | static struct resource s3c_wdt_resource[] = { | |
242 | [0] = { | |
0367a8d3 LCVR |
243 | .start = S3C24XX_PA_WATCHDOG, |
244 | .end = S3C24XX_PA_WATCHDOG + S3C24XX_SZ_WATCHDOG - 1, | |
1da177e4 LT |
245 | .flags = IORESOURCE_MEM, |
246 | }, | |
247 | [1] = { | |
248 | .start = IRQ_WDT, | |
249 | .end = IRQ_WDT, | |
250 | .flags = IORESOURCE_IRQ, | |
251 | } | |
252 | ||
253 | }; | |
254 | ||
255 | struct platform_device s3c_device_wdt = { | |
256 | .name = "s3c2410-wdt", | |
257 | .id = -1, | |
258 | .num_resources = ARRAY_SIZE(s3c_wdt_resource), | |
259 | .resource = s3c_wdt_resource, | |
260 | }; | |
261 | ||
262 | EXPORT_SYMBOL(s3c_device_wdt); | |
263 | ||
1da177e4 LT |
264 | /* IIS */ |
265 | ||
266 | static struct resource s3c_iis_resource[] = { | |
267 | [0] = { | |
0367a8d3 LCVR |
268 | .start = S3C24XX_PA_IIS, |
269 | .end = S3C24XX_PA_IIS + S3C24XX_SZ_IIS -1, | |
1da177e4 LT |
270 | .flags = IORESOURCE_MEM, |
271 | } | |
272 | }; | |
273 | ||
274 | static u64 s3c_device_iis_dmamask = 0xffffffffUL; | |
275 | ||
276 | struct platform_device s3c_device_iis = { | |
277 | .name = "s3c2410-iis", | |
278 | .id = -1, | |
279 | .num_resources = ARRAY_SIZE(s3c_iis_resource), | |
280 | .resource = s3c_iis_resource, | |
281 | .dev = { | |
282 | .dma_mask = &s3c_device_iis_dmamask, | |
283 | .coherent_dma_mask = 0xffffffffUL | |
284 | } | |
285 | }; | |
286 | ||
287 | EXPORT_SYMBOL(s3c_device_iis); | |
288 | ||
289 | /* RTC */ | |
290 | ||
291 | static struct resource s3c_rtc_resource[] = { | |
292 | [0] = { | |
0367a8d3 LCVR |
293 | .start = S3C24XX_PA_RTC, |
294 | .end = S3C24XX_PA_RTC + 0xff, | |
1da177e4 LT |
295 | .flags = IORESOURCE_MEM, |
296 | }, | |
297 | [1] = { | |
298 | .start = IRQ_RTC, | |
299 | .end = IRQ_RTC, | |
300 | .flags = IORESOURCE_IRQ, | |
301 | }, | |
302 | [2] = { | |
303 | .start = IRQ_TICK, | |
304 | .end = IRQ_TICK, | |
305 | .flags = IORESOURCE_IRQ | |
306 | } | |
307 | }; | |
308 | ||
309 | struct platform_device s3c_device_rtc = { | |
310 | .name = "s3c2410-rtc", | |
311 | .id = -1, | |
312 | .num_resources = ARRAY_SIZE(s3c_rtc_resource), | |
313 | .resource = s3c_rtc_resource, | |
314 | }; | |
315 | ||
316 | EXPORT_SYMBOL(s3c_device_rtc); | |
317 | ||
318 | /* ADC */ | |
319 | ||
320 | static struct resource s3c_adc_resource[] = { | |
321 | [0] = { | |
0367a8d3 LCVR |
322 | .start = S3C24XX_PA_ADC, |
323 | .end = S3C24XX_PA_ADC + S3C24XX_SZ_ADC - 1, | |
1da177e4 LT |
324 | .flags = IORESOURCE_MEM, |
325 | }, | |
326 | [1] = { | |
327 | .start = IRQ_TC, | |
083d06ed BD |
328 | .end = IRQ_TC, |
329 | .flags = IORESOURCE_IRQ, | |
330 | }, | |
331 | [2] = { | |
332 | .start = IRQ_ADC, | |
1da177e4 LT |
333 | .end = IRQ_ADC, |
334 | .flags = IORESOURCE_IRQ, | |
335 | } | |
336 | ||
337 | }; | |
338 | ||
339 | struct platform_device s3c_device_adc = { | |
28ab44c5 | 340 | .name = "s3c24xx-adc", |
1da177e4 LT |
341 | .id = -1, |
342 | .num_resources = ARRAY_SIZE(s3c_adc_resource), | |
343 | .resource = s3c_adc_resource, | |
344 | }; | |
345 | ||
28ab44c5 BD |
346 | /* HWMON */ |
347 | ||
348 | struct platform_device s3c_device_hwmon = { | |
c197cec5 | 349 | .name = "s3c-hwmon", |
28ab44c5 BD |
350 | .id = -1, |
351 | .dev.parent = &s3c_device_adc.dev, | |
352 | }; | |
353 | ||
1da177e4 LT |
354 | /* SDI */ |
355 | ||
356 | static struct resource s3c_sdi_resource[] = { | |
357 | [0] = { | |
ce46a9c4 BD |
358 | .start = S3C24XX_PA_SDI, |
359 | .end = S3C24XX_PA_SDI + S3C24XX_SZ_SDI - 1, | |
1da177e4 LT |
360 | .flags = IORESOURCE_MEM, |
361 | }, | |
362 | [1] = { | |
363 | .start = IRQ_SDI, | |
364 | .end = IRQ_SDI, | |
365 | .flags = IORESOURCE_IRQ, | |
366 | } | |
367 | ||
368 | }; | |
369 | ||
370 | struct platform_device s3c_device_sdi = { | |
371 | .name = "s3c2410-sdi", | |
372 | .id = -1, | |
373 | .num_resources = ARRAY_SIZE(s3c_sdi_resource), | |
374 | .resource = s3c_sdi_resource, | |
375 | }; | |
376 | ||
377 | EXPORT_SYMBOL(s3c_device_sdi); | |
378 | ||
1f138f13 | 379 | void __init s3c24xx_mci_set_platdata(struct s3c24xx_mci_pdata *pdata) |
22c810ab BD |
380 | { |
381 | struct s3c24xx_mci_pdata *npd; | |
382 | ||
383 | npd = kmemdup(pdata, sizeof(struct s3c24xx_mci_pdata), GFP_KERNEL); | |
384 | if (!npd) | |
385 | printk(KERN_ERR "%s: no memory to copy pdata", __func__); | |
386 | ||
387 | s3c_device_sdi.dev.platform_data = npd; | |
388 | } | |
389 | ||
390 | ||
1da177e4 LT |
391 | /* SPI (0) */ |
392 | ||
393 | static struct resource s3c_spi0_resource[] = { | |
394 | [0] = { | |
0367a8d3 LCVR |
395 | .start = S3C24XX_PA_SPI, |
396 | .end = S3C24XX_PA_SPI + 0x1f, | |
1da177e4 LT |
397 | .flags = IORESOURCE_MEM, |
398 | }, | |
399 | [1] = { | |
400 | .start = IRQ_SPI0, | |
401 | .end = IRQ_SPI0, | |
402 | .flags = IORESOURCE_IRQ, | |
403 | } | |
404 | ||
405 | }; | |
406 | ||