• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* linux/arch/arm/plat-samsung/devs.c
2  *
3  * Copyright (c) 2011 Samsung Electronics Co., Ltd.
4  *		http://www.samsung.com
5  *
6  * Base SAMSUNG 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 #include <linux/amba/pl330.h>
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/serial_s3c.h>
22 #include <linux/platform_device.h>
23 #include <linux/io.h>
24 #include <linux/slab.h>
25 #include <linux/string.h>
26 #include <linux/dma-mapping.h>
27 #include <linux/fb.h>
28 #include <linux/gfp.h>
29 #include <linux/mtd/mtd.h>
30 #include <linux/mtd/onenand.h>
31 #include <linux/mtd/partitions.h>
32 #include <linux/mmc/host.h>
33 #include <linux/ioport.h>
34 #include <linux/sizes.h>
35 #include <linux/platform_data/s3c-hsudc.h>
36 #include <linux/platform_data/s3c-hsotg.h>
37 #include <linux/platform_data/dma-s3c24xx.h>
38 
39 #include <media/s5p_hdmi.h>
40 
41 #include <asm/irq.h>
42 #include <asm/mach/arch.h>
43 #include <asm/mach/map.h>
44 #include <asm/mach/irq.h>
45 
46 #include <mach/dma.h>
47 #include <mach/irqs.h>
48 #include <mach/map.h>
49 
50 #include <plat/cpu.h>
51 #include <plat/devs.h>
52 #include <plat/adc.h>
53 #include <linux/platform_data/ata-samsung_cf.h>
54 #include <plat/fb.h>
55 #include <plat/fb-s3c2410.h>
56 #include <linux/platform_data/hwmon-s3c.h>
57 #include <linux/platform_data/i2c-s3c2410.h>
58 #include <plat/keypad.h>
59 #include <linux/platform_data/mmc-s3cmci.h>
60 #include <linux/platform_data/mtd-nand-s3c2410.h>
61 #include <plat/pwm-core.h>
62 #include <plat/sdhci.h>
63 #include <linux/platform_data/touchscreen-s3c2410.h>
64 #include <linux/platform_data/usb-s3c2410_udc.h>
65 #include <linux/platform_data/usb-ohci-s3c2410.h>
66 #include <plat/usb-phy.h>
67 #include <plat/regs-spi.h>
68 #include <linux/platform_data/asoc-s3c.h>
69 #include <linux/platform_data/spi-s3c64xx.h>
70 
71 static u64 samsung_device_dma_mask = DMA_BIT_MASK(32);
72 
73 /* AC97 */
74 #ifdef CONFIG_CPU_S3C2440
75 static struct resource s3c_ac97_resource[] = {
76 	[0] = DEFINE_RES_MEM(S3C2440_PA_AC97, S3C2440_SZ_AC97),
77 	[1] = DEFINE_RES_IRQ(IRQ_S3C244X_AC97),
78 };
79 
80 static struct s3c_audio_pdata s3c_ac97_pdata = {
81 	.dma_playback = (void *)DMACH_PCM_OUT,
82 	.dma_capture = (void *)DMACH_PCM_IN,
83 	.dma_capture_mic = (void *)DMACH_MIC_IN,
84 };
85 
86 struct platform_device s3c_device_ac97 = {
87 	.name		= "samsung-ac97",
88 	.id		= -1,
89 	.num_resources	= ARRAY_SIZE(s3c_ac97_resource),
90 	.resource	= s3c_ac97_resource,
91 	.dev		= {
92 		.dma_mask		= &samsung_device_dma_mask,
93 		.coherent_dma_mask	= DMA_BIT_MASK(32),
94 		.platform_data		= &s3c_ac97_pdata,
95 	}
96 };
97 #endif /* CONFIG_CPU_S3C2440 */
98 
99 /* ADC */
100 
101 #ifdef CONFIG_PLAT_S3C24XX
102 static struct resource s3c_adc_resource[] = {
103 	[0] = DEFINE_RES_MEM(S3C24XX_PA_ADC, S3C24XX_SZ_ADC),
104 	[1] = DEFINE_RES_IRQ(IRQ_TC),
105 	[2] = DEFINE_RES_IRQ(IRQ_ADC),
106 };
107 
108 struct platform_device s3c_device_adc = {
109 	.name		= "s3c24xx-adc",
110 	.id		= -1,
111 	.num_resources	= ARRAY_SIZE(s3c_adc_resource),
112 	.resource	= s3c_adc_resource,
113 };
114 #endif /* CONFIG_PLAT_S3C24XX */
115 
116 #if defined(CONFIG_SAMSUNG_DEV_ADC)
117 static struct resource s3c_adc_resource[] = {
118 	[0] = DEFINE_RES_MEM(SAMSUNG_PA_ADC, SZ_256),
119 	[1] = DEFINE_RES_IRQ(IRQ_TC),
120 	[2] = DEFINE_RES_IRQ(IRQ_ADC),
121 };
122 
123 struct platform_device s3c_device_adc = {
124 	.name		= "samsung-adc",
125 	.id		= -1,
126 	.num_resources	= ARRAY_SIZE(s3c_adc_resource),
127 	.resource	= s3c_adc_resource,
128 };
129 #endif /* CONFIG_SAMSUNG_DEV_ADC */
130 
131 /* Camif Controller */
132 
133 #ifdef CONFIG_CPU_S3C2440
134 static struct resource s3c_camif_resource[] = {
135 	[0] = DEFINE_RES_MEM(S3C2440_PA_CAMIF, S3C2440_SZ_CAMIF),
136 	[1] = DEFINE_RES_IRQ(IRQ_S3C2440_CAM_C),
137 	[2] = DEFINE_RES_IRQ(IRQ_S3C2440_CAM_P),
138 };
139 
140 struct platform_device s3c_device_camif = {
141 	.name		= "s3c2440-camif",
142 	.id		= -1,
143 	.num_resources	= ARRAY_SIZE(s3c_camif_resource),
144 	.resource	= s3c_camif_resource,
145 	.dev		= {
146 		.dma_mask		= &samsung_device_dma_mask,
147 		.coherent_dma_mask	= DMA_BIT_MASK(32),
148 	}
149 };
150 #endif /* CONFIG_CPU_S3C2440 */
151 
152 /* FB */
153 
154 #ifdef CONFIG_S3C_DEV_FB
155 static struct resource s3c_fb_resource[] = {
156 	[0] = DEFINE_RES_MEM(S3C_PA_FB, SZ_16K),
157 	[1] = DEFINE_RES_IRQ(IRQ_LCD_VSYNC),
158 	[2] = DEFINE_RES_IRQ(IRQ_LCD_FIFO),
159 	[3] = DEFINE_RES_IRQ(IRQ_LCD_SYSTEM),
160 };
161 
162 struct platform_device s3c_device_fb = {
163 	.name		= "s3c-fb",
164 	.id		= -1,
165 	.num_resources	= ARRAY_SIZE(s3c_fb_resource),
166 	.resource	= s3c_fb_resource,
167 	.dev		= {
168 		.dma_mask		= &samsung_device_dma_mask,
169 		.coherent_dma_mask	= DMA_BIT_MASK(32),
170 	},
171 };
172 
s3c_fb_set_platdata(struct s3c_fb_platdata * pd)173 void __init s3c_fb_set_platdata(struct s3c_fb_platdata *pd)
174 {
175 	s3c_set_platdata(pd, sizeof(struct s3c_fb_platdata),
176 			 &s3c_device_fb);
177 }
178 #endif /* CONFIG_S3C_DEV_FB */
179 
180 /* HWMON */
181 
182 #ifdef CONFIG_S3C_DEV_HWMON
183 struct platform_device s3c_device_hwmon = {
184 	.name		= "s3c-hwmon",
185 	.id		= -1,
186 	.dev.parent	= &s3c_device_adc.dev,
187 };
188 
s3c_hwmon_set_platdata(struct s3c_hwmon_pdata * pd)189 void __init s3c_hwmon_set_platdata(struct s3c_hwmon_pdata *pd)
190 {
191 	s3c_set_platdata(pd, sizeof(struct s3c_hwmon_pdata),
192 			 &s3c_device_hwmon);
193 }
194 #endif /* CONFIG_S3C_DEV_HWMON */
195 
196 /* HSMMC */
197 
198 #ifdef CONFIG_S3C_DEV_HSMMC
199 static struct resource s3c_hsmmc_resource[] = {
200 	[0] = DEFINE_RES_MEM(S3C_PA_HSMMC0, SZ_4K),
201 	[1] = DEFINE_RES_IRQ(IRQ_HSMMC0),
202 };
203 
204 struct s3c_sdhci_platdata s3c_hsmmc0_def_platdata = {
205 	.max_width	= 4,
206 	.host_caps	= (MMC_CAP_4_BIT_DATA |
207 			   MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
208 };
209 
210 struct platform_device s3c_device_hsmmc0 = {
211 	.name		= "s3c-sdhci",
212 	.id		= 0,
213 	.num_resources	= ARRAY_SIZE(s3c_hsmmc_resource),
214 	.resource	= s3c_hsmmc_resource,
215 	.dev		= {
216 		.dma_mask		= &samsung_device_dma_mask,
217 		.coherent_dma_mask	= DMA_BIT_MASK(32),
218 		.platform_data		= &s3c_hsmmc0_def_platdata,
219 	},
220 };
221 
s3c_sdhci0_set_platdata(struct s3c_sdhci_platdata * pd)222 void s3c_sdhci0_set_platdata(struct s3c_sdhci_platdata *pd)
223 {
224 	s3c_sdhci_set_platdata(pd, &s3c_hsmmc0_def_platdata);
225 }
226 #endif /* CONFIG_S3C_DEV_HSMMC */
227 
228 #ifdef CONFIG_S3C_DEV_HSMMC1
229 static struct resource s3c_hsmmc1_resource[] = {
230 	[0] = DEFINE_RES_MEM(S3C_PA_HSMMC1, SZ_4K),
231 	[1] = DEFINE_RES_IRQ(IRQ_HSMMC1),
232 };
233 
234 struct s3c_sdhci_platdata s3c_hsmmc1_def_platdata = {
235 	.max_width	= 4,
236 	.host_caps	= (MMC_CAP_4_BIT_DATA |
237 			   MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
238 };
239 
240 struct platform_device s3c_device_hsmmc1 = {
241 	.name		= "s3c-sdhci",
242 	.id		= 1,
243 	.num_resources	= ARRAY_SIZE(s3c_hsmmc1_resource),
244 	.resource	= s3c_hsmmc1_resource,
245 	.dev		= {
246 		.dma_mask		= &samsung_device_dma_mask,
247 		.coherent_dma_mask	= DMA_BIT_MASK(32),
248 		.platform_data		= &s3c_hsmmc1_def_platdata,
249 	},
250 };
251 
s3c_sdhci1_set_platdata(struct s3c_sdhci_platdata * pd)252 void s3c_sdhci1_set_platdata(struct s3c_sdhci_platdata *pd)
253 {
254 	s3c_sdhci_set_platdata(pd, &s3c_hsmmc1_def_platdata);
255 }
256 #endif /* CONFIG_S3C_DEV_HSMMC1 */
257 
258 /* HSMMC2 */
259 
260 #ifdef CONFIG_S3C_DEV_HSMMC2
261 static struct resource s3c_hsmmc2_resource[] = {
262 	[0] = DEFINE_RES_MEM(S3C_PA_HSMMC2, SZ_4K),
263 	[1] = DEFINE_RES_IRQ(IRQ_HSMMC2),
264 };
265 
266 struct s3c_sdhci_platdata s3c_hsmmc2_def_platdata = {
267 	.max_width	= 4,
268 	.host_caps	= (MMC_CAP_4_BIT_DATA |
269 			   MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
270 };
271 
272 struct platform_device s3c_device_hsmmc2 = {
273 	.name		= "s3c-sdhci",
274 	.id		= 2,
275 	.num_resources	= ARRAY_SIZE(s3c_hsmmc2_resource),
276 	.resource	= s3c_hsmmc2_resource,
277 	.dev		= {
278 		.dma_mask		= &samsung_device_dma_mask,
279 		.coherent_dma_mask	= DMA_BIT_MASK(32),
280 		.platform_data		= &s3c_hsmmc2_def_platdata,
281 	},
282 };
283 
s3c_sdhci2_set_platdata(struct s3c_sdhci_platdata * pd)284 void s3c_sdhci2_set_platdata(struct s3c_sdhci_platdata *pd)
285 {
286 	s3c_sdhci_set_platdata(pd, &s3c_hsmmc2_def_platdata);
287 }
288 #endif /* CONFIG_S3C_DEV_HSMMC2 */
289 
290 #ifdef CONFIG_S3C_DEV_HSMMC3
291 static struct resource s3c_hsmmc3_resource[] = {
292 	[0] = DEFINE_RES_MEM(S3C_PA_HSMMC3, SZ_4K),
293 	[1] = DEFINE_RES_IRQ(IRQ_HSMMC3),
294 };
295 
296 struct s3c_sdhci_platdata s3c_hsmmc3_def_platdata = {
297 	.max_width	= 4,
298 	.host_caps	= (MMC_CAP_4_BIT_DATA |
299 			   MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
300 };
301 
302 struct platform_device s3c_device_hsmmc3 = {
303 	.name		= "s3c-sdhci",
304 	.id		= 3,
305 	.num_resources	= ARRAY_SIZE(s3c_hsmmc3_resource),
306 	.resource	= s3c_hsmmc3_resource,
307 	.dev		= {
308 		.dma_mask		= &samsung_device_dma_mask,
309 		.coherent_dma_mask	= DMA_BIT_MASK(32),
310 		.platform_data		= &s3c_hsmmc3_def_platdata,
311 	},
312 };
313 
s3c_sdhci3_set_platdata(struct s3c_sdhci_platdata * pd)314 void s3c_sdhci3_set_platdata(struct s3c_sdhci_platdata *pd)
315 {
316 	s3c_sdhci_set_platdata(pd, &s3c_hsmmc3_def_platdata);
317 }
318 #endif /* CONFIG_S3C_DEV_HSMMC3 */
319 
320 /* I2C */
321 
322 static struct resource s3c_i2c0_resource[] = {
323 	[0] = DEFINE_RES_MEM(S3C_PA_IIC, SZ_4K),
324 	[1] = DEFINE_RES_IRQ(IRQ_IIC),
325 };
326 
327 struct platform_device s3c_device_i2c0 = {
328 	.name		= "s3c2410-i2c",
329 	.id		= 0,
330 	.num_resources	= ARRAY_SIZE(s3c_i2c0_resource),
331 	.resource	= s3c_i2c0_resource,
332 };
333 
334 struct s3c2410_platform_i2c default_i2c_data __initdata = {
335 	.flags		= 0,
336 	.slave_addr	= 0x10,
337 	.frequency	= 100*1000,
338 	.sda_delay	= 100,
339 };
340 
s3c_i2c0_set_platdata(struct s3c2410_platform_i2c * pd)341 void __init s3c_i2c0_set_platdata(struct s3c2410_platform_i2c *pd)
342 {
343 	struct s3c2410_platform_i2c *npd;
344 
345 	if (!pd) {
346 		pd = &default_i2c_data;
347 		pd->bus_num = 0;
348 	}
349 
350 	npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
351 			       &s3c_device_i2c0);
352 
353 	if (!npd->cfg_gpio)
354 		npd->cfg_gpio = s3c_i2c0_cfg_gpio;
355 }
356 
357 #ifdef CONFIG_S3C_DEV_I2C1
358 static struct resource s3c_i2c1_resource[] = {
359 	[0] = DEFINE_RES_MEM(S3C_PA_IIC1, SZ_4K),
360 	[1] = DEFINE_RES_IRQ(IRQ_IIC1),
361 };
362 
363 struct platform_device s3c_device_i2c1 = {
364 	.name		= "s3c2410-i2c",
365 	.id		= 1,
366 	.num_resources	= ARRAY_SIZE(s3c_i2c1_resource),
367 	.resource	= s3c_i2c1_resource,
368 };
369 
s3c_i2c1_set_platdata(struct s3c2410_platform_i2c * pd)370 void __init s3c_i2c1_set_platdata(struct s3c2410_platform_i2c *pd)
371 {
372 	struct s3c2410_platform_i2c *npd;
373 
374 	if (!pd) {
375 		pd = &default_i2c_data;
376 		pd->bus_num = 1;
377 	}
378 
379 	npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
380 			       &s3c_device_i2c1);
381 
382 	if (!npd->cfg_gpio)
383 		npd->cfg_gpio = s3c_i2c1_cfg_gpio;
384 }
385 #endif /* CONFIG_S3C_DEV_I2C1 */
386 
387 #ifdef CONFIG_S3C_DEV_I2C2
388 static struct resource s3c_i2c2_resource[] = {
389 	[0] = DEFINE_RES_MEM(S3C_PA_IIC2, SZ_4K),
390 	[1] = DEFINE_RES_IRQ(IRQ_IIC2),
391 };
392 
393 struct platform_device s3c_device_i2c2 = {
394 	.name		= "s3c2410-i2c",
395 	.id		= 2,
396 	.num_resources	= ARRAY_SIZE(s3c_i2c2_resource),
397 	.resource	= s3c_i2c2_resource,
398 };
399 
s3c_i2c2_set_platdata(struct s3c2410_platform_i2c * pd)400 void __init s3c_i2c2_set_platdata(struct s3c2410_platform_i2c *pd)
401 {
402 	struct s3c2410_platform_i2c *npd;
403 
404 	if (!pd) {
405 		pd = &default_i2c_data;
406 		pd->bus_num = 2;
407 	}
408 
409 	npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
410 			       &s3c_device_i2c2);
411 
412 	if (!npd->cfg_gpio)
413 		npd->cfg_gpio = s3c_i2c2_cfg_gpio;
414 }
415 #endif /* CONFIG_S3C_DEV_I2C2 */
416 
417 #ifdef CONFIG_S3C_DEV_I2C3
418 static struct resource s3c_i2c3_resource[] = {
419 	[0] = DEFINE_RES_MEM(S3C_PA_IIC3, SZ_4K),
420 	[1] = DEFINE_RES_IRQ(IRQ_IIC3),
421 };
422 
423 struct platform_device s3c_device_i2c3 = {
424 	.name		= "s3c2440-i2c",
425 	.id		= 3,
426 	.num_resources	= ARRAY_SIZE(s3c_i2c3_resource),
427 	.resource	= s3c_i2c3_resource,
428 };
429 
s3c_i2c3_set_platdata(struct s3c2410_platform_i2c * pd)430 void __init s3c_i2c3_set_platdata(struct s3c2410_platform_i2c *pd)
431 {
432 	struct s3c2410_platform_i2c *npd;
433 
434 	if (!pd) {
435 		pd = &default_i2c_data;
436 		pd->bus_num = 3;
437 	}
438 
439 	npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
440 			       &s3c_device_i2c3);
441 
442 	if (!npd->cfg_gpio)
443 		npd->cfg_gpio = s3c_i2c3_cfg_gpio;
444 }
445 #endif /*CONFIG_S3C_DEV_I2C3 */
446 
447 #ifdef CONFIG_S3C_DEV_I2C4
448 static struct resource s3c_i2c4_resource[] = {
449 	[0] = DEFINE_RES_MEM(S3C_PA_IIC4, SZ_4K),
450 	[1] = DEFINE_RES_IRQ(IRQ_IIC4),
451 };
452 
453 struct platform_device s3c_device_i2c4 = {
454 	.name		= "s3c2440-i2c",
455 	.id		= 4,
456 	.num_resources	= ARRAY_SIZE(s3c_i2c4_resource),
457 	.resource	= s3c_i2c4_resource,
458 };
459 
s3c_i2c4_set_platdata(struct s3c2410_platform_i2c * pd)460 void __init s3c_i2c4_set_platdata(struct s3c2410_platform_i2c *pd)
461 {
462 	struct s3c2410_platform_i2c *npd;
463 
464 	if (!pd) {
465 		pd = &default_i2c_data;
466 		pd->bus_num = 4;
467 	}
468 
469 	npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
470 			       &s3c_device_i2c4);
471 
472 	if (!npd->cfg_gpio)
473 		npd->cfg_gpio = s3c_i2c4_cfg_gpio;
474 }
475 #endif /*CONFIG_S3C_DEV_I2C4 */
476 
477 #ifdef CONFIG_S3C_DEV_I2C5
478 static struct resource s3c_i2c5_resource[] = {
479 	[0] = DEFINE_RES_MEM(S3C_PA_IIC5, SZ_4K),
480 	[1] = DEFINE_RES_IRQ(IRQ_IIC5),
481 };
482 
483 struct platform_device s3c_device_i2c5 = {
484 	.name		= "s3c2440-i2c",
485 	.id		= 5,
486 	.num_resources	= ARRAY_SIZE(s3c_i2c5_resource),
487 	.resource	= s3c_i2c5_resource,
488 };
489 
s3c_i2c5_set_platdata(struct s3c2410_platform_i2c * pd)490 void __init s3c_i2c5_set_platdata(struct s3c2410_platform_i2c *pd)
491 {
492 	struct s3c2410_platform_i2c *npd;
493 
494 	if (!pd) {
495 		pd = &default_i2c_data;
496 		pd->bus_num = 5;
497 	}
498 
499 	npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
500 			       &s3c_device_i2c5);
501 
502 	if (!npd->cfg_gpio)
503 		npd->cfg_gpio = s3c_i2c5_cfg_gpio;
504 }
505 #endif /*CONFIG_S3C_DEV_I2C5 */
506 
507 #ifdef CONFIG_S3C_DEV_I2C6
508 static struct resource s3c_i2c6_resource[] = {
509 	[0] = DEFINE_RES_MEM(S3C_PA_IIC6, SZ_4K),
510 	[1] = DEFINE_RES_IRQ(IRQ_IIC6),
511 };
512 
513 struct platform_device s3c_device_i2c6 = {
514 	.name		= "s3c2440-i2c",
515 	.id		= 6,
516 	.num_resources	= ARRAY_SIZE(s3c_i2c6_resource),
517 	.resource	= s3c_i2c6_resource,
518 };
519 
s3c_i2c6_set_platdata(struct s3c2410_platform_i2c * pd)520 void __init s3c_i2c6_set_platdata(struct s3c2410_platform_i2c *pd)
521 {
522 	struct s3c2410_platform_i2c *npd;
523 
524 	if (!pd) {
525 		pd = &default_i2c_data;
526 		pd->bus_num = 6;
527 	}
528 
529 	npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
530 			       &s3c_device_i2c6);
531 
532 	if (!npd->cfg_gpio)
533 		npd->cfg_gpio = s3c_i2c6_cfg_gpio;
534 }
535 #endif /* CONFIG_S3C_DEV_I2C6 */
536 
537 #ifdef CONFIG_S3C_DEV_I2C7
538 static struct resource s3c_i2c7_resource[] = {
539 	[0] = DEFINE_RES_MEM(S3C_PA_IIC7, SZ_4K),
540 	[1] = DEFINE_RES_IRQ(IRQ_IIC7),
541 };
542 
543 struct platform_device s3c_device_i2c7 = {
544 	.name		= "s3c2440-i2c",
545 	.id		= 7,
546 	.num_resources	= ARRAY_SIZE(s3c_i2c7_resource),
547 	.resource	= s3c_i2c7_resource,
548 };
549 
s3c_i2c7_set_platdata(struct s3c2410_platform_i2c * pd)550 void __init s3c_i2c7_set_platdata(struct s3c2410_platform_i2c *pd)
551 {
552 	struct s3c2410_platform_i2c *npd;
553 
554 	if (!pd) {
555 		pd = &default_i2c_data;
556 		pd->bus_num = 7;
557 	}
558 
559 	npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
560 			       &s3c_device_i2c7);
561 
562 	if (!npd->cfg_gpio)
563 		npd->cfg_gpio = s3c_i2c7_cfg_gpio;
564 }
565 #endif /* CONFIG_S3C_DEV_I2C7 */
566 
567 /* I2S */
568 
569 #ifdef CONFIG_PLAT_S3C24XX
570 static struct resource s3c_iis_resource[] = {
571 	[0] = DEFINE_RES_MEM(S3C24XX_PA_IIS, S3C24XX_SZ_IIS),
572 };
573 
574 struct platform_device s3c_device_iis = {
575 	.name		= "s3c24xx-iis",
576 	.id		= -1,
577 	.num_resources	= ARRAY_SIZE(s3c_iis_resource),
578 	.resource	= s3c_iis_resource,
579 	.dev		= {
580 		.dma_mask		= &samsung_device_dma_mask,
581 		.coherent_dma_mask	= DMA_BIT_MASK(32),
582 	}
583 };
584 #endif /* CONFIG_PLAT_S3C24XX */
585 
586 /* IDE CFCON */
587 
588 #ifdef CONFIG_SAMSUNG_DEV_IDE
589 static struct resource s3c_cfcon_resource[] = {
590 	[0] = DEFINE_RES_MEM(SAMSUNG_PA_CFCON, SZ_16K),
591 	[1] = DEFINE_RES_IRQ(IRQ_CFCON),
592 };
593 
594 struct platform_device s3c_device_cfcon = {
595 	.id		= 0,
596 	.num_resources	= ARRAY_SIZE(s3c_cfcon_resource),
597 	.resource	= s3c_cfcon_resource,
598 };
599 
s3c_ide_set_platdata(struct s3c_ide_platdata * pdata)600 void __init s3c_ide_set_platdata(struct s3c_ide_platdata *pdata)
601 {
602 	s3c_set_platdata(pdata, sizeof(struct s3c_ide_platdata),
603 			 &s3c_device_cfcon);
604 }
605 #endif /* CONFIG_SAMSUNG_DEV_IDE */
606 
607 /* KEYPAD */
608 
609 #ifdef CONFIG_SAMSUNG_DEV_KEYPAD
610 static struct resource samsung_keypad_resources[] = {
611 	[0] = DEFINE_RES_MEM(SAMSUNG_PA_KEYPAD, SZ_32),
612 	[1] = DEFINE_RES_IRQ(IRQ_KEYPAD),
613 };
614 
615 struct platform_device samsung_device_keypad = {
616 	.name		= "samsung-keypad",
617 	.id		= -1,
618 	.num_resources	= ARRAY_SIZE(samsung_keypad_resources),
619 	.resource	= samsung_keypad_resources,
620 };
621 
samsung_keypad_set_platdata(struct samsung_keypad_platdata * pd)622 void __init samsung_keypad_set_platdata(struct samsung_keypad_platdata *pd)
623 {
624 	struct samsung_keypad_platdata *npd;
625 
626 	npd = s3c_set_platdata(pd, sizeof(struct samsung_keypad_platdata),
627 			&samsung_device_keypad);
628 
629 	if (!npd->cfg_gpio)
630 		npd->cfg_gpio = samsung_keypad_cfg_gpio;
631 }
632 #endif /* CONFIG_SAMSUNG_DEV_KEYPAD */
633 
634 /* LCD Controller */
635 
636 #ifdef CONFIG_PLAT_S3C24XX
637 static struct resource s3c_lcd_resource[] = {
638 	[0] = DEFINE_RES_MEM(S3C24XX_PA_LCD, S3C24XX_SZ_LCD),
639 	[1] = DEFINE_RES_IRQ(IRQ_LCD),
640 };
641 
642 struct platform_device s3c_device_lcd = {
643 	.name		= "s3c2410-lcd",
644 	.id		= -1,
645 	.num_resources	= ARRAY_SIZE(s3c_lcd_resource),
646 	.resource	= s3c_lcd_resource,
647 	.dev		= {
648 		.dma_mask		= &samsung_device_dma_mask,
649 		.coherent_dma_mask	= DMA_BIT_MASK(32),
650 	}
651 };
652 
s3c24xx_fb_set_platdata(struct s3c2410fb_mach_info * pd)653 void __init s3c24xx_fb_set_platdata(struct s3c2410fb_mach_info *pd)
654 {
655 	struct s3c2410fb_mach_info *npd;
656 
657 	npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_lcd);
658 	if (npd) {
659 		npd->displays = kmemdup(pd->displays,
660 			sizeof(struct s3c2410fb_display) * npd->num_displays,
661 			GFP_KERNEL);
662 		if (!npd->displays)
663 			printk(KERN_ERR "no memory for LCD display data\n");
664 	} else {
665 		printk(KERN_ERR "no memory for LCD platform data\n");
666 	}
667 }
668 #endif /* CONFIG_PLAT_S3C24XX */
669 
670 /* NAND */
671 
672 #ifdef CONFIG_S3C_DEV_NAND
673 static struct resource s3c_nand_resource[] = {
674 	[0] = DEFINE_RES_MEM(S3C_PA_NAND, SZ_1M),
675 };
676 
677 struct platform_device s3c_device_nand = {
678 	.name		= "s3c2410-nand",
679 	.id		= -1,
680 	.num_resources	= ARRAY_SIZE(s3c_nand_resource),
681 	.resource	= s3c_nand_resource,
682 };
683 
684 /*
685  * s3c_nand_copy_set() - copy nand set data
686  * @set: The new structure, directly copied from the old.
687  *
688  * Copy all the fields from the NAND set field from what is probably __initdata
689  * to new kernel memory. The code returns 0 if the copy happened correctly or
690  * an error code for the calling function to display.
691  *
692  * Note, we currently do not try and look to see if we've already copied the
693  * data in a previous set.
694  */
s3c_nand_copy_set(struct s3c2410_nand_set * set)695 static int __init s3c_nand_copy_set(struct s3c2410_nand_set *set)
696 {
697 	void *ptr;
698 	int size;
699 
700 	size = sizeof(struct mtd_partition) * set->nr_partitions;
701 	if (size) {
702 		ptr = kmemdup(set->partitions, size, GFP_KERNEL);
703 		set->partitions = ptr;
704 
705 		if (!ptr)
706 			return -ENOMEM;
707 	}
708 
709 	if (set->nr_map && set->nr_chips) {
710 		size = sizeof(int) * set->nr_chips;
711 		ptr = kmemdup(set->nr_map, size, GFP_KERNEL);
712 		set->nr_map = ptr;
713 
714 		if (!ptr)
715 			return -ENOMEM;
716 	}
717 
718 	if (set->ecc_layout) {
719 		ptr = kmemdup(set->ecc_layout,
720 			      sizeof(struct nand_ecclayout), GFP_KERNEL);
721 		set->ecc_layout = ptr;
722 
723 		if (!ptr)
724 			return -ENOMEM;
725 	}
726 
727 	return 0;
728 }
729 
s3c_nand_set_platdata(struct s3c2410_platform_nand * nand)730 void __init s3c_nand_set_platdata(struct s3c2410_platform_nand *nand)
731 {
732 	struct s3c2410_platform_nand *npd;
733 	int size;
734 	int ret;
735 
736 	/* note, if we get a failure in allocation, we simply drop out of the
737 	 * function. If there is so little memory available at initialisation
738 	 * time then there is little chance the system is going to run.
739 	 */
740 
741 	npd = s3c_set_platdata(nand, sizeof(struct s3c2410_platform_nand),
742 				&s3c_device_nand);
743 	if (!npd)
744 		return;
745 
746 	/* now see if we need to copy any of the nand set data */
747 
748 	size = sizeof(struct s3c2410_nand_set) * npd->nr_sets;
749 	if (size) {
750 		struct s3c2410_nand_set *from = npd->sets;
751 		struct s3c2410_nand_set *to;
752 		int i;
753 
754 		to = kmemdup(from, size, GFP_KERNEL);
755 		npd->sets = to;	/* set, even if we failed */
756 
757 		if (!to) {
758 			printk(KERN_ERR "%s: no memory for sets\n", __func__);
759 			return;
760 		}
761 
762 		for (i = 0; i < npd->nr_sets; i++) {
763 			ret = s3c_nand_copy_set(to);
764 			if (ret) {
765 				printk(KERN_ERR "%s: failed to copy set %d\n",
766 				__func__, i);
767 				return;
768 			}
769 			to++;
770 		}
771 	}
772 }
773 #endif /* CONFIG_S3C_DEV_NAND */
774 
775 /* ONENAND */
776 
777 #ifdef CONFIG_S3C_DEV_ONENAND
778 static struct resource s3c_onenand_resources[] = {
779 	[0] = DEFINE_RES_MEM(S3C_PA_ONENAND, SZ_1K),
780 	[1] = DEFINE_RES_MEM(S3C_PA_ONENAND_BUF, S3C_SZ_ONENAND_BUF),
781 	[2] = DEFINE_RES_IRQ(IRQ_ONENAND),
782 };
783 
784 struct platform_device s3c_device_onenand = {
785 	.name		= "samsung-onenand",
786 	.id		= 0,
787 	.num_resources	= ARRAY_SIZE(s3c_onenand_resources),
788 	.resource	= s3c_onenand_resources,
789 };
790 #endif /* CONFIG_S3C_DEV_ONENAND */
791 
792 #ifdef CONFIG_S3C64XX_DEV_ONENAND1
793 static struct resource s3c64xx_onenand1_resources[] = {
794 	[0] = DEFINE_RES_MEM(S3C64XX_PA_ONENAND1, SZ_1K),
795 	[1] = DEFINE_RES_MEM(S3C64XX_PA_ONENAND1_BUF, S3C64XX_SZ_ONENAND1_BUF),
796 	[2] = DEFINE_RES_IRQ(IRQ_ONENAND1),
797 };
798 
799 struct platform_device s3c64xx_device_onenand1 = {
800 	.name		= "samsung-onenand",
801 	.id		= 1,
802 	.num_resources	= ARRAY_SIZE(s3c64xx_onenand1_resources),
803 	.resource	= s3c64xx_onenand1_resources,
804 };
805 
s3c64xx_onenand1_set_platdata(struct onenand_platform_data * pdata)806 void __init s3c64xx_onenand1_set_platdata(struct onenand_platform_data *pdata)
807 {
808 	s3c_set_platdata(pdata, sizeof(struct onenand_platform_data),
809 			 &s3c64xx_device_onenand1);
810 }
811 #endif /* CONFIG_S3C64XX_DEV_ONENAND1 */
812 
813 /* PWM Timer */
814 
815 #ifdef CONFIG_SAMSUNG_DEV_PWM
816 static struct resource samsung_pwm_resource[] = {
817 	DEFINE_RES_MEM(SAMSUNG_PA_TIMER, SZ_4K),
818 };
819 
820 struct platform_device samsung_device_pwm = {
821 	.name		= "samsung-pwm",
822 	.id		= -1,
823 	.num_resources	= ARRAY_SIZE(samsung_pwm_resource),
824 	.resource	= samsung_pwm_resource,
825 };
826 
samsung_pwm_set_platdata(struct samsung_pwm_variant * pd)827 void __init samsung_pwm_set_platdata(struct samsung_pwm_variant *pd)
828 {
829 	samsung_device_pwm.dev.platform_data = pd;
830 }
831 #endif /* CONFIG_SAMSUNG_DEV_PWM */
832 
833 /* RTC */
834 
835 #ifdef CONFIG_PLAT_S3C24XX
836 static struct resource s3c_rtc_resource[] = {
837 	[0] = DEFINE_RES_MEM(S3C24XX_PA_RTC, SZ_256),
838 	[1] = DEFINE_RES_IRQ(IRQ_RTC),
839 	[2] = DEFINE_RES_IRQ(IRQ_TICK),
840 };
841 
842 struct platform_device s3c_device_rtc = {
843 	.name		= "s3c2410-rtc",
844 	.id		= -1,
845 	.num_resources	= ARRAY_SIZE(s3c_rtc_resource),
846 	.resource	= s3c_rtc_resource,
847 };
848 #endif /* CONFIG_PLAT_S3C24XX */
849 
850 #ifdef CONFIG_S3C_DEV_RTC
851 static struct resource s3c_rtc_resource[] = {
852 	[0] = DEFINE_RES_MEM(S3C_PA_RTC, SZ_256),
853 	[1] = DEFINE_RES_IRQ(IRQ_RTC_ALARM),
854 	[2] = DEFINE_RES_IRQ(IRQ_RTC_TIC),
855 };
856 
857 struct platform_device s3c_device_rtc = {
858 	.name		= "s3c64xx-rtc",
859 	.id		= -1,
860 	.num_resources	= ARRAY_SIZE(s3c_rtc_resource),
861 	.resource	= s3c_rtc_resource,
862 };
863 #endif /* CONFIG_S3C_DEV_RTC */
864 
865 /* SDI */
866 
867 #ifdef CONFIG_PLAT_S3C24XX
868 static struct resource s3c_sdi_resource[] = {
869 	[0] = DEFINE_RES_MEM(S3C24XX_PA_SDI, S3C24XX_SZ_SDI),
870 	[1] = DEFINE_RES_IRQ(IRQ_SDI),
871 };
872 
873 struct platform_device s3c_device_sdi = {
874 	.name		= "s3c2410-sdi",
875 	.id		= -1,
876 	.num_resources	= ARRAY_SIZE(s3c_sdi_resource),
877 	.resource	= s3c_sdi_resource,
878 };
879 
s3c24xx_mci_set_platdata(struct s3c24xx_mci_pdata * pdata)880 void __init s3c24xx_mci_set_platdata(struct s3c24xx_mci_pdata *pdata)
881 {
882 	s3c_set_platdata(pdata, sizeof(struct s3c24xx_mci_pdata),
883 			 &s3c_device_sdi);
884 }
885 #endif /* CONFIG_PLAT_S3C24XX */
886 
887 /* SPI */
888 
889 #ifdef CONFIG_PLAT_S3C24XX
890 static struct resource s3c_spi0_resource[] = {
891 	[0] = DEFINE_RES_MEM(S3C24XX_PA_SPI, SZ_32),
892 	[1] = DEFINE_RES_IRQ(IRQ_SPI0),
893 };
894 
895 struct platform_device s3c_device_spi0 = {
896 	.name		= "s3c2410-spi",
897 	.id		= 0,
898 	.num_resources	= ARRAY_SIZE(s3c_spi0_resource),
899 	.resource	= s3c_spi0_resource,
900 	.dev		= {
901 		.dma_mask		= &samsung_device_dma_mask,
902 		.coherent_dma_mask	= DMA_BIT_MASK(32),
903 	}
904 };
905 
906 static struct resource s3c_spi1_resource[] = {
907 	[0] = DEFINE_RES_MEM(S3C24XX_PA_SPI1, SZ_32),
908 	[1] = DEFINE_RES_IRQ(IRQ_SPI1),
909 };
910 
911 struct platform_device s3c_device_spi1 = {
912 	.name		= "s3c2410-spi",
913 	.id		= 1,
914 	.num_resources	= ARRAY_SIZE(s3c_spi1_resource),
915 	.resource	= s3c_spi1_resource,
916 	.dev		= {
917 		.dma_mask		= &samsung_device_dma_mask,
918 		.coherent_dma_mask	= DMA_BIT_MASK(32),
919 	}
920 };
921 #endif /* CONFIG_PLAT_S3C24XX */
922 
923 /* Touchscreen */
924 
925 #ifdef CONFIG_PLAT_S3C24XX
926 static struct resource s3c_ts_resource[] = {
927 	[0] = DEFINE_RES_MEM(S3C24XX_PA_ADC, S3C24XX_SZ_ADC),
928 	[1] = DEFINE_RES_IRQ(IRQ_TC),
929 };
930 
931 struct platform_device s3c_device_ts = {
932 	.name		= "s3c2410-ts",
933 	.id		= -1,
934 	.dev.parent	= &s3c_device_adc.dev,
935 	.num_resources	= ARRAY_SIZE(s3c_ts_resource),
936 	.resource	= s3c_ts_resource,
937 };
938 
s3c24xx_ts_set_platdata(struct s3c2410_ts_mach_info * hard_s3c2410ts_info)939 void __init s3c24xx_ts_set_platdata(struct s3c2410_ts_mach_info *hard_s3c2410ts_info)
940 {
941 	s3c_set_platdata(hard_s3c2410ts_info,
942 			 sizeof(struct s3c2410_ts_mach_info), &s3c_device_ts);
943 }
944 #endif /* CONFIG_PLAT_S3C24XX */
945 
946 #ifdef CONFIG_SAMSUNG_DEV_TS
947 static struct resource s3c_ts_resource[] = {
948 	[0] = DEFINE_RES_MEM(SAMSUNG_PA_ADC, SZ_256),
949 	[1] = DEFINE_RES_IRQ(IRQ_TC),
950 };
951 
952 static struct s3c2410_ts_mach_info default_ts_data __initdata = {
953 	.delay			= 10000,
954 	.presc			= 49,
955 	.oversampling_shift	= 2,
956 };
957 
958 struct platform_device s3c_device_ts = {
959 	.name		= "s3c64xx-ts",
960 	.id		= -1,
961 	.num_resources	= ARRAY_SIZE(s3c_ts_resource),
962 	.resource	= s3c_ts_resource,
963 };
964 
s3c24xx_ts_set_platdata(struct s3c2410_ts_mach_info * pd)965 void __init s3c24xx_ts_set_platdata(struct s3c2410_ts_mach_info *pd)
966 {
967 	if (!pd)
968 		pd = &default_ts_data;
969 
970 	s3c_set_platdata(pd, sizeof(struct s3c2410_ts_mach_info),
971 			 &s3c_device_ts);
972 }
973 #endif /* CONFIG_SAMSUNG_DEV_TS */
974 
975 /* USB */
976 
977 #ifdef CONFIG_S3C_DEV_USB_HOST
978 static struct resource s3c_usb_resource[] = {
979 	[0] = DEFINE_RES_MEM(S3C_PA_USBHOST, SZ_256),
980 	[1] = DEFINE_RES_IRQ(IRQ_USBH),
981 };
982 
983 struct platform_device s3c_device_ohci = {
984 	.name		= "s3c2410-ohci",
985 	.id		= -1,
986 	.num_resources	= ARRAY_SIZE(s3c_usb_resource),
987 	.resource	= s3c_usb_resource,
988 	.dev		= {
989 		.dma_mask		= &samsung_device_dma_mask,
990 		.coherent_dma_mask	= DMA_BIT_MASK(32),
991 	}
992 };
993 
994 /*
995  * s3c_ohci_set_platdata - initialise OHCI device platform data
996  * @info: The platform data.
997  *
998  * This call copies the @info passed in and sets the device .platform_data
999  * field to that copy. The @info is copied so that the original can be marked
1000  * __initdata.
1001  */
1002 
s3c_ohci_set_platdata(struct s3c2410_hcd_info * info)1003 void __init s3c_ohci_set_platdata(struct s3c2410_hcd_info *info)
1004 {
1005 	s3c_set_platdata(info, sizeof(struct s3c2410_hcd_info),
1006 			 &s3c_device_ohci);
1007 }
1008 #endif /* CONFIG_S3C_DEV_USB_HOST */
1009 
1010 /* USB Device (Gadget) */
1011 
1012 #ifdef CONFIG_PLAT_S3C24XX
1013 static struct resource s3c_usbgadget_resource[] = {
1014 	[0] = DEFINE_RES_MEM(S3C24XX_PA_USBDEV, S3C24XX_SZ_USBDEV),
1015 	[1] = DEFINE_RES_IRQ(IRQ_USBD),
1016 };
1017 
1018 struct platform_device s3c_device_usbgadget = {
1019 	.name		= "s3c2410-usbgadget",
1020 	.id		= -1,
1021 	.num_resources	= ARRAY_SIZE(s3c_usbgadget_resource),
1022 	.resource	= s3c_usbgadget_resource,
1023 };
1024 
s3c24xx_udc_set_platdata(struct s3c2410_udc_mach_info * pd)1025 void __init s3c24xx_udc_set_platdata(struct s3c2410_udc_mach_info *pd)
1026 {
1027 	s3c_set_platdata(pd, sizeof(*pd), &s3c_device_usbgadget);
1028 }
1029 #endif /* CONFIG_PLAT_S3C24XX */
1030 
1031 /* USB HSOTG */
1032 
1033 #ifdef CONFIG_S3C_DEV_USB_HSOTG
1034 static struct resource s3c_usb_hsotg_resources[] = {
1035 	[0] = DEFINE_RES_MEM(S3C_PA_USB_HSOTG, SZ_128K),
1036 	[1] = DEFINE_RES_IRQ(IRQ_OTG),
1037 };
1038 
1039 struct platform_device s3c_device_usb_hsotg = {
1040 	.name		= "s3c-hsotg",
1041 	.id		= -1,
1042 	.num_resources	= ARRAY_SIZE(s3c_usb_hsotg_resources),
1043 	.resource	= s3c_usb_hsotg_resources,
1044 	.dev		= {
1045 		.dma_mask		= &samsung_device_dma_mask,
1046 		.coherent_dma_mask	= DMA_BIT_MASK(32),
1047 	},
1048 };
1049 
s3c_hsotg_set_platdata(struct s3c_hsotg_plat * pd)1050 void __init s3c_hsotg_set_platdata(struct s3c_hsotg_plat *pd)
1051 {
1052 	struct s3c_hsotg_plat *npd;
1053 
1054 	npd = s3c_set_platdata(pd, sizeof(struct s3c_hsotg_plat),
1055 			&s3c_device_usb_hsotg);
1056 
1057 	if (!npd->phy_init)
1058 		npd->phy_init = s5p_usb_phy_init;
1059 	if (!npd->phy_exit)
1060 		npd->phy_exit = s5p_usb_phy_exit;
1061 }
1062 #endif /* CONFIG_S3C_DEV_USB_HSOTG */
1063 
1064 /* USB High Spped 2.0 Device (Gadget) */
1065 
1066 #ifdef CONFIG_PLAT_S3C24XX
1067 static struct resource s3c_hsudc_resource[] = {
1068 	[0] = DEFINE_RES_MEM(S3C2416_PA_HSUDC, S3C2416_SZ_HSUDC),
1069 	[1] = DEFINE_RES_IRQ(IRQ_USBD),
1070 };
1071 
1072 struct platform_device s3c_device_usb_hsudc = {
1073 	.name		= "s3c-hsudc",
1074 	.id		= -1,
1075 	.num_resources	= ARRAY_SIZE(s3c_hsudc_resource),
1076 	.resource	= s3c_hsudc_resource,
1077 	.dev		= {
1078 		.dma_mask		= &samsung_device_dma_mask,
1079 		.coherent_dma_mask	= DMA_BIT_MASK(32),
1080 	},
1081 };
1082 
s3c24xx_hsudc_set_platdata(struct s3c24xx_hsudc_platdata * pd)1083 void __init s3c24xx_hsudc_set_platdata(struct s3c24xx_hsudc_platdata *pd)
1084 {
1085 	s3c_set_platdata(pd, sizeof(*pd), &s3c_device_usb_hsudc);
1086 }
1087 #endif /* CONFIG_PLAT_S3C24XX */
1088 
1089 /* WDT */
1090 
1091 #ifdef CONFIG_S3C_DEV_WDT
1092 static struct resource s3c_wdt_resource[] = {
1093 	[0] = DEFINE_RES_MEM(S3C_PA_WDT, SZ_1K),
1094 	[1] = DEFINE_RES_IRQ(IRQ_WDT),
1095 };
1096 
1097 struct platform_device s3c_device_wdt = {
1098 	.name		= "s3c2410-wdt",
1099 	.id		= -1,
1100 	.num_resources	= ARRAY_SIZE(s3c_wdt_resource),
1101 	.resource	= s3c_wdt_resource,
1102 };
1103 #endif /* CONFIG_S3C_DEV_WDT */
1104 
1105 #ifdef CONFIG_S3C64XX_DEV_SPI0
1106 static struct resource s3c64xx_spi0_resource[] = {
1107 	[0] = DEFINE_RES_MEM(S3C_PA_SPI0, SZ_256),
1108 	[1] = DEFINE_RES_DMA(DMACH_SPI0_TX),
1109 	[2] = DEFINE_RES_DMA(DMACH_SPI0_RX),
1110 	[3] = DEFINE_RES_IRQ(IRQ_SPI0),
1111 };
1112 
1113 struct platform_device s3c64xx_device_spi0 = {
1114 	.name		= "s3c6410-spi",
1115 	.id		= 0,
1116 	.num_resources	= ARRAY_SIZE(s3c64xx_spi0_resource),
1117 	.resource	= s3c64xx_spi0_resource,
1118 	.dev = {
1119 		.dma_mask		= &samsung_device_dma_mask,
1120 		.coherent_dma_mask	= DMA_BIT_MASK(32),
1121 	},
1122 };
1123 
s3c64xx_spi0_set_platdata(int (* cfg_gpio)(void),int src_clk_nr,int num_cs)1124 void __init s3c64xx_spi0_set_platdata(int (*cfg_gpio)(void), int src_clk_nr,
1125 						int num_cs)
1126 {
1127 	struct s3c64xx_spi_info pd;
1128 
1129 	/* Reject invalid configuration */
1130 	if (!num_cs || src_clk_nr < 0) {
1131 		pr_err("%s: Invalid SPI configuration\n", __func__);
1132 		return;
1133 	}
1134 
1135 	pd.num_cs = num_cs;
1136 	pd.src_clk_nr = src_clk_nr;
1137 	pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi0_cfg_gpio;
1138 #if defined(CONFIG_PL330_DMA)
1139 	pd.filter = pl330_filter;
1140 #elif defined(CONFIG_S3C64XX_PL080)
1141 	pd.filter = pl08x_filter_id;
1142 #elif defined(CONFIG_S3C24XX_DMAC)
1143 	pd.filter = s3c24xx_dma_filter;
1144 #endif
1145 
1146 	s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi0);
1147 }
1148 #endif /* CONFIG_S3C64XX_DEV_SPI0 */
1149 
1150 #ifdef CONFIG_S3C64XX_DEV_SPI1
1151 static struct resource s3c64xx_spi1_resource[] = {
1152 	[0] = DEFINE_RES_MEM(S3C_PA_SPI1, SZ_256),
1153 	[1] = DEFINE_RES_DMA(DMACH_SPI1_TX),
1154 	[2] = DEFINE_RES_DMA(DMACH_SPI1_RX),
1155 	[3] = DEFINE_RES_IRQ(IRQ_SPI1),
1156 };
1157 
1158 struct platform_device s3c64xx_device_spi1 = {
1159 	.name		= "s3c6410-spi",
1160 	.id		= 1,
1161 	.num_resources	= ARRAY_SIZE(s3c64xx_spi1_resource),
1162 	.resource	= s3c64xx_spi1_resource,
1163 	.dev = {
1164 		.dma_mask		= &samsung_device_dma_mask,
1165 		.coherent_dma_mask	= DMA_BIT_MASK(32),
1166 	},
1167 };
1168 
s3c64xx_spi1_set_platdata(int (* cfg_gpio)(void),int src_clk_nr,int num_cs)1169 void __init s3c64xx_spi1_set_platdata(int (*cfg_gpio)(void), int src_clk_nr,
1170 						int num_cs)
1171 {
1172 	struct s3c64xx_spi_info pd;
1173 
1174 	/* Reject invalid configuration */
1175 	if (!num_cs || src_clk_nr < 0) {
1176 		pr_err("%s: Invalid SPI configuration\n", __func__);
1177 		return;
1178 	}
1179 
1180 	pd.num_cs = num_cs;
1181 	pd.src_clk_nr = src_clk_nr;
1182 	pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi1_cfg_gpio;
1183 #if defined(CONFIG_PL330_DMA)
1184 	pd.filter = pl330_filter;
1185 #elif defined(CONFIG_S3C64XX_PL080)
1186 	pd.filter = pl08x_filter_id;
1187 #endif
1188 
1189 	s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi1);
1190 }
1191 #endif /* CONFIG_S3C64XX_DEV_SPI1 */
1192 
1193 #ifdef CONFIG_S3C64XX_DEV_SPI2
1194 static struct resource s3c64xx_spi2_resource[] = {
1195 	[0] = DEFINE_RES_MEM(S3C_PA_SPI2, SZ_256),
1196 	[1] = DEFINE_RES_DMA(DMACH_SPI2_TX),
1197 	[2] = DEFINE_RES_DMA(DMACH_SPI2_RX),
1198 	[3] = DEFINE_RES_IRQ(IRQ_SPI2),
1199 };
1200 
1201 struct platform_device s3c64xx_device_spi2 = {
1202 	.name		= "s3c6410-spi",
1203 	.id		= 2,
1204 	.num_resources	= ARRAY_SIZE(s3c64xx_spi2_resource),
1205 	.resource	= s3c64xx_spi2_resource,
1206 	.dev = {
1207 		.dma_mask		= &samsung_device_dma_mask,
1208 		.coherent_dma_mask	= DMA_BIT_MASK(32),
1209 	},
1210 };
1211 
s3c64xx_spi2_set_platdata(int (* cfg_gpio)(void),int src_clk_nr,int num_cs)1212 void __init s3c64xx_spi2_set_platdata(int (*cfg_gpio)(void), int src_clk_nr,
1213 						int num_cs)
1214 {
1215 	struct s3c64xx_spi_info pd;
1216 
1217 	/* Reject invalid configuration */
1218 	if (!num_cs || src_clk_nr < 0) {
1219 		pr_err("%s: Invalid SPI configuration\n", __func__);
1220 		return;
1221 	}
1222 
1223 	pd.num_cs = num_cs;
1224 	pd.src_clk_nr = src_clk_nr;
1225 	pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi2_cfg_gpio;
1226 #if defined(CONFIG_PL330_DMA)
1227 	pd.filter = pl330_filter;
1228 #elif defined(CONFIG_S3C64XX_PL080)
1229 	pd.filter = pl08x_filter_id;
1230 #endif
1231 
1232 	s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi2);
1233 }
1234 #endif /* CONFIG_S3C64XX_DEV_SPI2 */
1235