ARM: EXYNOS: Add DRM core device support for Universal C210 board
[platform/adaptation/renesas_rcar/renesas_kernel.git] / arch / arm / mach-exynos / mach-universal_c210.c
1 /* linux/arch/arm/mach-exynos4/mach-universal_c210.c
2  *
3  * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8 */
9
10 #include <linux/platform_device.h>
11 #include <linux/serial_core.h>
12 #include <linux/input.h>
13 #include <linux/i2c.h>
14 #include <linux/gpio_keys.h>
15 #include <linux/gpio.h>
16 #include <linux/interrupt.h>
17 #include <linux/fb.h>
18 #include <linux/mfd/max8998.h>
19 #include <linux/regulator/machine.h>
20 #include <linux/regulator/fixed.h>
21 #include <linux/regulator/max8952.h>
22 #include <linux/mmc/host.h>
23 #include <linux/i2c-gpio.h>
24 #include <linux/i2c/mcs.h>
25 #include <linux/i2c/atmel_mxt_ts.h>
26 #include <drm/exynos_drm.h>
27
28 #include <asm/mach/arch.h>
29 #include <asm/hardware/gic.h>
30 #include <asm/mach-types.h>
31
32 #include <plat/regs-serial.h>
33 #include <plat/clock.h>
34 #include <plat/cpu.h>
35 #include <plat/devs.h>
36 #include <plat/iic.h>
37 #include <plat/gpio-cfg.h>
38 #include <plat/fb.h>
39 #include <plat/mfc.h>
40 #include <plat/sdhci.h>
41 #include <plat/pd.h>
42 #include <plat/regs-fb-v4.h>
43 #include <plat/fimc-core.h>
44 #include <plat/camport.h>
45 #include <plat/mipi_csis.h>
46
47 #include <mach/map.h>
48
49 #include <media/v4l2-mediabus.h>
50 #include <media/s5p_fimc.h>
51 #include <media/m5mols.h>
52 #include <media/s5k6aa.h>
53
54 #include "common.h"
55
56 /* Following are default values for UCON, ULCON and UFCON UART registers */
57 #define UNIVERSAL_UCON_DEFAULT  (S3C2410_UCON_TXILEVEL |        \
58                                  S3C2410_UCON_RXILEVEL |        \
59                                  S3C2410_UCON_TXIRQMODE |       \
60                                  S3C2410_UCON_RXIRQMODE |       \
61                                  S3C2410_UCON_RXFIFO_TOI |      \
62                                  S3C2443_UCON_RXERR_IRQEN)
63
64 #define UNIVERSAL_ULCON_DEFAULT S3C2410_LCON_CS8
65
66 #define UNIVERSAL_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE |       \
67                                  S5PV210_UFCON_TXTRIG256 |      \
68                                  S5PV210_UFCON_RXTRIG256)
69
70 static struct s3c2410_uartcfg universal_uartcfgs[] __initdata = {
71         [0] = {
72                 .hwport         = 0,
73                 .ucon           = UNIVERSAL_UCON_DEFAULT,
74                 .ulcon          = UNIVERSAL_ULCON_DEFAULT,
75                 .ufcon          = UNIVERSAL_UFCON_DEFAULT,
76         },
77         [1] = {
78                 .hwport         = 1,
79                 .ucon           = UNIVERSAL_UCON_DEFAULT,
80                 .ulcon          = UNIVERSAL_ULCON_DEFAULT,
81                 .ufcon          = UNIVERSAL_UFCON_DEFAULT,
82         },
83         [2] = {
84                 .hwport         = 2,
85                 .ucon           = UNIVERSAL_UCON_DEFAULT,
86                 .ulcon          = UNIVERSAL_ULCON_DEFAULT,
87                 .ufcon          = UNIVERSAL_UFCON_DEFAULT,
88         },
89         [3] = {
90                 .hwport         = 3,
91                 .ucon           = UNIVERSAL_UCON_DEFAULT,
92                 .ulcon          = UNIVERSAL_ULCON_DEFAULT,
93                 .ufcon          = UNIVERSAL_UFCON_DEFAULT,
94         },
95 };
96
97 static struct regulator_consumer_supply max8952_consumer =
98         REGULATOR_SUPPLY("vdd_arm", NULL);
99
100 static struct max8952_platform_data universal_max8952_pdata __initdata = {
101         .gpio_vid0      = EXYNOS4_GPX0(3),
102         .gpio_vid1      = EXYNOS4_GPX0(4),
103         .gpio_en        = -1, /* Not controllable, set "Always High" */
104         .default_mode   = 0, /* vid0 = 0, vid1 = 0 */
105         .dvs_mode       = { 48, 32, 28, 18 }, /* 1.25, 1.20, 1.05, 0.95V */
106         .sync_freq      = 0, /* default: fastest */
107         .ramp_speed     = 0, /* default: fastest */
108
109         .reg_data       = {
110                 .constraints    = {
111                         .name           = "VARM_1.2V",
112                         .min_uV         = 770000,
113                         .max_uV         = 1400000,
114                         .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
115                         .always_on      = 1,
116                         .boot_on        = 1,
117                 },
118                 .num_consumer_supplies  = 1,
119                 .consumer_supplies      = &max8952_consumer,
120         },
121 };
122
123 static struct regulator_consumer_supply lp3974_buck1_consumer =
124         REGULATOR_SUPPLY("vdd_int", NULL);
125
126 static struct regulator_consumer_supply lp3974_buck2_consumer =
127         REGULATOR_SUPPLY("vddg3d", NULL);
128
129 static struct regulator_consumer_supply lp3974_buck3_consumer[] = {
130         REGULATOR_SUPPLY("vdet", "s5p-sdo"),
131         REGULATOR_SUPPLY("vdd_reg", "0-003c"),
132 };
133
134 static struct regulator_init_data lp3974_buck1_data = {
135         .constraints    = {
136                 .name           = "VINT_1.1V",
137                 .min_uV         = 750000,
138                 .max_uV         = 1500000,
139                 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
140                         REGULATOR_CHANGE_STATUS,
141                 .boot_on        = 1,
142                 .state_mem      = {
143                         .disabled       = 1,
144                 },
145         },
146         .num_consumer_supplies = 1,
147         .consumer_supplies = &lp3974_buck1_consumer,
148 };
149
150 static struct regulator_init_data lp3974_buck2_data = {
151         .constraints    = {
152                 .name           = "VG3D_1.1V",
153                 .min_uV         = 750000,
154                 .max_uV         = 1500000,
155                 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
156                         REGULATOR_CHANGE_STATUS,
157                 .boot_on        = 1,
158                 .state_mem      = {
159                         .disabled       = 1,
160                 },
161         },
162         .num_consumer_supplies = 1,
163         .consumer_supplies = &lp3974_buck2_consumer,
164 };
165
166 static struct regulator_init_data lp3974_buck3_data = {
167         .constraints    = {
168                 .name           = "VCC_1.8V",
169                 .min_uV         = 1800000,
170                 .max_uV         = 1800000,
171                 .apply_uV       = 1,
172                 .always_on      = 1,
173                 .state_mem      = {
174                         .enabled        = 1,
175                 },
176         },
177         .num_consumer_supplies = ARRAY_SIZE(lp3974_buck3_consumer),
178         .consumer_supplies = lp3974_buck3_consumer,
179 };
180
181 static struct regulator_init_data lp3974_buck4_data = {
182         .constraints    = {
183                 .name           = "VMEM_1.2V",
184                 .min_uV         = 1200000,
185                 .max_uV         = 1200000,
186                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
187                 .apply_uV       = 1,
188                 .state_mem      = {
189                         .disabled       = 1,
190                 },
191         },
192 };
193
194 static struct regulator_init_data lp3974_ldo2_data = {
195         .constraints    = {
196                 .name           = "VALIVE_1.2V",
197                 .min_uV         = 1200000,
198                 .max_uV         = 1200000,
199                 .apply_uV       = 1,
200                 .always_on      = 1,
201                 .state_mem      = {
202                         .enabled        = 1,
203                 },
204         },
205 };
206
207 static struct regulator_consumer_supply lp3974_ldo3_consumer[] = {
208         REGULATOR_SUPPLY("vdd", "exynos4-hdmi"),
209         REGULATOR_SUPPLY("vdd_pll", "exynos4-hdmi"),
210         REGULATOR_SUPPLY("vdd11", "s5p-mipi-csis.0"),
211 };
212
213 static struct regulator_init_data lp3974_ldo3_data = {
214         .constraints    = {
215                 .name           = "VUSB+MIPI_1.1V",
216                 .min_uV         = 1100000,
217                 .max_uV         = 1100000,
218                 .apply_uV       = 1,
219                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
220                 .state_mem      = {
221                         .disabled       = 1,
222                 },
223         },
224         .num_consumer_supplies = ARRAY_SIZE(lp3974_ldo3_consumer),
225         .consumer_supplies = lp3974_ldo3_consumer,
226 };
227
228 static struct regulator_consumer_supply lp3974_ldo4_consumer[] = {
229         REGULATOR_SUPPLY("vdd_osc", "exynos4-hdmi"),
230 };
231
232 static struct regulator_init_data lp3974_ldo4_data = {
233         .constraints    = {
234                 .name           = "VADC_3.3V",
235                 .min_uV         = 3300000,
236                 .max_uV         = 3300000,
237                 .apply_uV       = 1,
238                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
239                 .state_mem      = {
240                         .disabled       = 1,
241                 },
242         },
243         .num_consumer_supplies = ARRAY_SIZE(lp3974_ldo4_consumer),
244         .consumer_supplies = lp3974_ldo4_consumer,
245 };
246
247 static struct regulator_init_data lp3974_ldo5_data = {
248         .constraints    = {
249                 .name           = "VTF_2.8V",
250                 .min_uV         = 2800000,
251                 .max_uV         = 2800000,
252                 .apply_uV       = 1,
253                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
254                 .state_mem      = {
255                         .disabled       = 1,
256                 },
257         },
258 };
259
260 static struct regulator_init_data lp3974_ldo6_data = {
261         .constraints    = {
262                 .name           = "LDO6",
263                 .min_uV         = 2000000,
264                 .max_uV         = 2000000,
265                 .apply_uV       = 1,
266                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
267                 .state_mem      = {
268                         .disabled       = 1,
269                 },
270         },
271 };
272
273 static struct regulator_consumer_supply lp3974_ldo7_consumer[] = {
274         REGULATOR_SUPPLY("vdd18", "s5p-mipi-csis.0"),
275 };
276
277 static struct regulator_init_data lp3974_ldo7_data = {
278         .constraints    = {
279                 .name           = "VLCD+VMIPI_1.8V",
280                 .min_uV         = 1800000,
281                 .max_uV         = 1800000,
282                 .apply_uV       = 1,
283                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
284                 .state_mem      = {
285                         .disabled       = 1,
286                 },
287         },
288         .num_consumer_supplies  = ARRAY_SIZE(lp3974_ldo7_consumer),
289         .consumer_supplies      = lp3974_ldo7_consumer,
290 };
291
292 static struct regulator_consumer_supply lp3974_ldo8_consumer[] = {
293         REGULATOR_SUPPLY("vdd33a_dac", "s5p-sdo"),
294 };
295
296 static struct regulator_init_data lp3974_ldo8_data = {
297         .constraints    = {
298                 .name           = "VUSB+VDAC_3.3V",
299                 .min_uV         = 3300000,
300                 .max_uV         = 3300000,
301                 .apply_uV       = 1,
302                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
303                 .state_mem      = {
304                         .disabled       = 1,
305                 },
306         },
307         .num_consumer_supplies = ARRAY_SIZE(lp3974_ldo8_consumer),
308         .consumer_supplies = lp3974_ldo8_consumer,
309 };
310
311 static struct regulator_consumer_supply lp3974_ldo9_consumer =
312         REGULATOR_SUPPLY("vddio", "0-003c");
313
314 static struct regulator_init_data lp3974_ldo9_data = {
315         .constraints    = {
316                 .name           = "VCC_2.8V",
317                 .min_uV         = 2800000,
318                 .max_uV         = 2800000,
319                 .apply_uV       = 1,
320                 .always_on      = 1,
321                 .state_mem      = {
322                         .enabled        = 1,
323                 },
324         },
325         .num_consumer_supplies  = 1,
326         .consumer_supplies      = &lp3974_ldo9_consumer,
327 };
328
329 static struct regulator_init_data lp3974_ldo10_data = {
330         .constraints    = {
331                 .name           = "VPLL_1.1V",
332                 .min_uV         = 1100000,
333                 .max_uV         = 1100000,
334                 .boot_on        = 1,
335                 .apply_uV       = 1,
336                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
337                 .state_mem      = {
338                         .disabled       = 1,
339                 },
340         },
341 };
342
343 static struct regulator_consumer_supply lp3974_ldo11_consumer =
344         REGULATOR_SUPPLY("dig_28", "0-001f");
345
346 static struct regulator_init_data lp3974_ldo11_data = {
347         .constraints    = {
348                 .name           = "CAM_AF_3.3V",
349                 .min_uV         = 3300000,
350                 .max_uV         = 3300000,
351                 .apply_uV       = 1,
352                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
353                 .state_mem      = {
354                         .disabled       = 1,
355                 },
356         },
357         .num_consumer_supplies  = 1,
358         .consumer_supplies      = &lp3974_ldo11_consumer,
359 };
360
361 static struct regulator_init_data lp3974_ldo12_data = {
362         .constraints    = {
363                 .name           = "PS_2.8V",
364                 .min_uV         = 2800000,
365                 .max_uV         = 2800000,
366                 .apply_uV       = 1,
367                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
368                 .state_mem      = {
369                         .disabled       = 1,
370                 },
371         },
372 };
373
374 static struct regulator_init_data lp3974_ldo13_data = {
375         .constraints    = {
376                 .name           = "VHIC_1.2V",
377                 .min_uV         = 1200000,
378                 .max_uV         = 1200000,
379                 .apply_uV       = 1,
380                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
381                 .state_mem      = {
382                         .disabled       = 1,
383                 },
384         },
385 };
386
387 static struct regulator_consumer_supply lp3974_ldo14_consumer =
388         REGULATOR_SUPPLY("dig_18", "0-001f");
389
390 static struct regulator_init_data lp3974_ldo14_data = {
391         .constraints    = {
392                 .name           = "CAM_I_HOST_1.8V",
393                 .min_uV         = 1800000,
394                 .max_uV         = 1800000,
395                 .apply_uV       = 1,
396                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
397                 .state_mem      = {
398                         .disabled       = 1,
399                 },
400         },
401         .num_consumer_supplies  = 1,
402         .consumer_supplies      = &lp3974_ldo14_consumer,
403 };
404
405
406 static struct regulator_consumer_supply lp3974_ldo15_consumer =
407         REGULATOR_SUPPLY("dig_12", "0-001f");
408
409 static struct regulator_init_data lp3974_ldo15_data = {
410         .constraints    = {
411                 .name           = "CAM_S_DIG+FM33_CORE_1.2V",
412                 .min_uV         = 1200000,
413                 .max_uV         = 1200000,
414                 .apply_uV       = 1,
415                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
416                 .state_mem      = {
417                         .disabled       = 1,
418                 },
419         },
420         .num_consumer_supplies  = 1,
421         .consumer_supplies      = &lp3974_ldo15_consumer,
422 };
423
424 static struct regulator_consumer_supply lp3974_ldo16_consumer[] = {
425         REGULATOR_SUPPLY("vdda", "0-003c"),
426         REGULATOR_SUPPLY("a_sensor", "0-001f"),
427 };
428
429 static struct regulator_init_data lp3974_ldo16_data = {
430         .constraints    = {
431                 .name           = "CAM_S_ANA_2.8V",
432                 .min_uV         = 2800000,
433                 .max_uV         = 2800000,
434                 .apply_uV       = 1,
435                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
436                 .state_mem      = {
437                         .disabled       = 1,
438                 },
439         },
440         .num_consumer_supplies  = ARRAY_SIZE(lp3974_ldo16_consumer),
441         .consumer_supplies      = lp3974_ldo16_consumer,
442 };
443
444 static struct regulator_init_data lp3974_ldo17_data = {
445         .constraints    = {
446                 .name           = "VCC_3.0V_LCD",
447                 .min_uV         = 3000000,
448                 .max_uV         = 3000000,
449                 .apply_uV       = 1,
450                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
451                 .boot_on        = 1,
452                 .state_mem      = {
453                         .disabled       = 1,
454                 },
455         },
456 };
457
458 static struct regulator_init_data lp3974_32khz_ap_data = {
459         .constraints    = {
460                 .name           = "32KHz AP",
461                 .always_on      = 1,
462                 .state_mem      = {
463                         .enabled        = 1,
464                 },
465         },
466 };
467
468 static struct regulator_init_data lp3974_32khz_cp_data = {
469         .constraints    = {
470                 .name           = "32KHz CP",
471                 .state_mem      = {
472                         .disabled       = 1,
473                 },
474         },
475 };
476
477 static struct regulator_init_data lp3974_vichg_data = {
478         .constraints    = {
479                 .name           = "VICHG",
480                 .state_mem      = {
481                         .disabled       = 1,
482                 },
483         },
484 };
485
486 static struct regulator_init_data lp3974_esafeout1_data = {
487         .constraints    = {
488                 .name           = "SAFEOUT1",
489                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
490                 .state_mem      = {
491                         .enabled        = 1,
492                 },
493         },
494 };
495
496 static struct regulator_init_data lp3974_esafeout2_data = {
497         .constraints    = {
498                 .name           = "SAFEOUT2",
499                 .boot_on        = 1,
500                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
501                 .state_mem      = {
502                         .enabled        = 1,
503                 },
504         },
505 };
506
507 static struct max8998_regulator_data lp3974_regulators[] = {
508         { MAX8998_LDO2,  &lp3974_ldo2_data },
509         { MAX8998_LDO3,  &lp3974_ldo3_data },
510         { MAX8998_LDO4,  &lp3974_ldo4_data },
511         { MAX8998_LDO5,  &lp3974_ldo5_data },
512         { MAX8998_LDO6,  &lp3974_ldo6_data },
513         { MAX8998_LDO7,  &lp3974_ldo7_data },
514         { MAX8998_LDO8,  &lp3974_ldo8_data },
515         { MAX8998_LDO9,  &lp3974_ldo9_data },
516         { MAX8998_LDO10, &lp3974_ldo10_data },
517         { MAX8998_LDO11, &lp3974_ldo11_data },
518         { MAX8998_LDO12, &lp3974_ldo12_data },
519         { MAX8998_LDO13, &lp3974_ldo13_data },
520         { MAX8998_LDO14, &lp3974_ldo14_data },
521         { MAX8998_LDO15, &lp3974_ldo15_data },
522         { MAX8998_LDO16, &lp3974_ldo16_data },
523         { MAX8998_LDO17, &lp3974_ldo17_data },
524         { MAX8998_BUCK1, &lp3974_buck1_data },
525         { MAX8998_BUCK2, &lp3974_buck2_data },
526         { MAX8998_BUCK3, &lp3974_buck3_data },
527         { MAX8998_BUCK4, &lp3974_buck4_data },
528         { MAX8998_EN32KHZ_AP, &lp3974_32khz_ap_data },
529         { MAX8998_EN32KHZ_CP, &lp3974_32khz_cp_data },
530         { MAX8998_ENVICHG, &lp3974_vichg_data },
531         { MAX8998_ESAFEOUT1, &lp3974_esafeout1_data },
532         { MAX8998_ESAFEOUT2, &lp3974_esafeout2_data },
533 };
534
535 static struct max8998_platform_data universal_lp3974_pdata = {
536         .num_regulators         = ARRAY_SIZE(lp3974_regulators),
537         .regulators             = lp3974_regulators,
538         .buck1_voltage1         = 1100000,      /* INT */
539         .buck1_voltage2         = 1000000,
540         .buck1_voltage3         = 1100000,
541         .buck1_voltage4         = 1000000,
542         .buck1_set1             = EXYNOS4_GPX0(5),
543         .buck1_set2             = EXYNOS4_GPX0(6),
544         .buck2_voltage1         = 1200000,      /* G3D */
545         .buck2_voltage2         = 1100000,
546         .buck1_default_idx      = 0,
547         .buck2_set3             = EXYNOS4_GPE2(0),
548         .buck2_default_idx      = 0,
549         .wakeup                 = true,
550 };
551
552
553 enum fixed_regulator_id {
554         FIXED_REG_ID_MMC0,
555         FIXED_REG_ID_HDMI_5V,
556         FIXED_REG_ID_CAM_S_IF,
557         FIXED_REG_ID_CAM_I_CORE,
558         FIXED_REG_ID_CAM_VT_DIO,
559 };
560
561 static struct regulator_consumer_supply hdmi_fixed_consumer =
562         REGULATOR_SUPPLY("hdmi-en", "exynos4-hdmi");
563
564 static struct regulator_init_data hdmi_fixed_voltage_init_data = {
565         .constraints            = {
566                 .name           = "HDMI_5V",
567                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
568         },
569         .num_consumer_supplies  = 1,
570         .consumer_supplies      = &hdmi_fixed_consumer,
571 };
572
573 static struct fixed_voltage_config hdmi_fixed_voltage_config = {
574         .supply_name            = "HDMI_EN1",
575         .microvolts             = 5000000,
576         .gpio                   = EXYNOS4_GPE0(1),
577         .enable_high            = true,
578         .init_data              = &hdmi_fixed_voltage_init_data,
579 };
580
581 static struct platform_device hdmi_fixed_voltage = {
582         .name                   = "reg-fixed-voltage",
583         .id                     = FIXED_REG_ID_HDMI_5V,
584         .dev                    = {
585                 .platform_data  = &hdmi_fixed_voltage_config,
586         },
587 };
588
589 /* GPIO I2C 5 (PMIC) */
590 static struct i2c_board_info i2c5_devs[] __initdata = {
591         {
592                 I2C_BOARD_INFO("max8952", 0xC0 >> 1),
593                 .platform_data  = &universal_max8952_pdata,
594         }, {
595                 I2C_BOARD_INFO("lp3974", 0xCC >> 1),
596                 .platform_data  = &universal_lp3974_pdata,
597         },
598 };
599
600 /* I2C3 (TSP) */
601 static struct mxt_platform_data qt602240_platform_data = {
602         .x_line         = 19,
603         .y_line         = 11,
604         .x_size         = 800,
605         .y_size         = 480,
606         .blen           = 0x11,
607         .threshold      = 0x28,
608         .voltage        = 2800000,              /* 2.8V */
609         .orient         = MXT_DIAGONAL,
610         .irqflags       = IRQF_TRIGGER_FALLING,
611 };
612
613 static struct i2c_board_info i2c3_devs[] __initdata = {
614         {
615                 I2C_BOARD_INFO("qt602240_ts", 0x4a),
616                 .platform_data = &qt602240_platform_data,
617         },
618 };
619
620 static void __init universal_tsp_init(void)
621 {
622         int gpio;
623
624         /* TSP_LDO_ON: XMDMADDR_11 */
625         gpio = EXYNOS4_GPE2(3);
626         gpio_request_one(gpio, GPIOF_OUT_INIT_HIGH, "TSP_LDO_ON");
627         gpio_export(gpio, 0);
628
629         /* TSP_INT: XMDMADDR_7 */
630         gpio = EXYNOS4_GPE1(7);
631         gpio_request(gpio, "TSP_INT");
632
633         s5p_register_gpio_interrupt(gpio);
634         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
635         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
636         i2c3_devs[0].irq = gpio_to_irq(gpio);
637 }
638
639
640 /* GPIO I2C 12 (3 Touchkey) */
641 static uint32_t touchkey_keymap[] = {
642         /* MCS_KEY_MAP(value, keycode) */
643         MCS_KEY_MAP(0, KEY_MENU),               /* KEY_SEND */
644         MCS_KEY_MAP(1, KEY_BACK),               /* KEY_END */
645 };
646
647 static struct mcs_platform_data touchkey_data = {
648         .keymap         = touchkey_keymap,
649         .keymap_size    = ARRAY_SIZE(touchkey_keymap),
650         .key_maxval     = 2,
651 };
652
653 /* GPIO I2C 3_TOUCH 2.8V */
654 #define I2C_GPIO_BUS_12         12
655 static struct i2c_gpio_platform_data i2c_gpio12_data = {
656         .sda_pin        = EXYNOS4_GPE4(0),      /* XMDMDATA_8 */
657         .scl_pin        = EXYNOS4_GPE4(1),      /* XMDMDATA_9 */
658 };
659
660 static struct platform_device i2c_gpio12 = {
661         .name           = "i2c-gpio",
662         .id             = I2C_GPIO_BUS_12,
663         .dev            = {
664                 .platform_data  = &i2c_gpio12_data,
665         },
666 };
667
668 static struct i2c_board_info i2c_gpio12_devs[] __initdata = {
669         {
670                 I2C_BOARD_INFO("mcs5080_touchkey", 0x20),
671                 .platform_data = &touchkey_data,
672         },
673 };
674
675 static void __init universal_touchkey_init(void)
676 {
677         int gpio;
678
679         gpio = EXYNOS4_GPE3(7);                 /* XMDMDATA_7 */
680         gpio_request(gpio, "3_TOUCH_INT");
681         s5p_register_gpio_interrupt(gpio);
682         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
683         i2c_gpio12_devs[0].irq = gpio_to_irq(gpio);
684
685         gpio = EXYNOS4_GPE3(3);                 /* XMDMDATA_3 */
686         gpio_request_one(gpio, GPIOF_OUT_INIT_HIGH, "3_TOUCH_EN");
687 }
688
689 static struct s3c2410_platform_i2c universal_i2c0_platdata __initdata = {
690         .frequency      = 300 * 1000,
691         .sda_delay      = 200,
692 };
693
694 /* GPIO KEYS */
695 static struct gpio_keys_button universal_gpio_keys_tables[] = {
696         {
697                 .code                   = KEY_VOLUMEUP,
698                 .gpio                   = EXYNOS4_GPX2(0),      /* XEINT16 */
699                 .desc                   = "gpio-keys: KEY_VOLUMEUP",
700                 .type                   = EV_KEY,
701                 .active_low             = 1,
702                 .debounce_interval      = 1,
703         }, {
704                 .code                   = KEY_VOLUMEDOWN,
705                 .gpio                   = EXYNOS4_GPX2(1),      /* XEINT17 */
706                 .desc                   = "gpio-keys: KEY_VOLUMEDOWN",
707                 .type                   = EV_KEY,
708                 .active_low             = 1,
709                 .debounce_interval      = 1,
710         }, {
711                 .code                   = KEY_CONFIG,
712                 .gpio                   = EXYNOS4_GPX2(2),      /* XEINT18 */
713                 .desc                   = "gpio-keys: KEY_CONFIG",
714                 .type                   = EV_KEY,
715                 .active_low             = 1,
716                 .debounce_interval      = 1,
717         }, {
718                 .code                   = KEY_CAMERA,
719                 .gpio                   = EXYNOS4_GPX2(3),      /* XEINT19 */
720                 .desc                   = "gpio-keys: KEY_CAMERA",
721                 .type                   = EV_KEY,
722                 .active_low             = 1,
723                 .debounce_interval      = 1,
724         }, {
725                 .code                   = KEY_OK,
726                 .gpio                   = EXYNOS4_GPX3(5),      /* XEINT29 */
727                 .desc                   = "gpio-keys: KEY_OK",
728                 .type                   = EV_KEY,
729                 .active_low             = 1,
730                 .debounce_interval      = 1,
731         },
732 };
733
734 static struct gpio_keys_platform_data universal_gpio_keys_data = {
735         .buttons        = universal_gpio_keys_tables,
736         .nbuttons       = ARRAY_SIZE(universal_gpio_keys_tables),
737 };
738
739 static struct platform_device universal_gpio_keys = {
740         .name                   = "gpio-keys",
741         .dev                    = {
742                 .platform_data  = &universal_gpio_keys_data,
743         },
744 };
745
746 /* eMMC */
747 static struct s3c_sdhci_platdata universal_hsmmc0_data __initdata = {
748         .max_width              = 8,
749         .host_caps              = (MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA |
750                                 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
751         .host_caps2             = MMC_CAP2_BROKEN_VOLTAGE,
752         .cd_type                = S3C_SDHCI_CD_PERMANENT,
753         .clk_type               = S3C_SDHCI_CLK_DIV_EXTERNAL,
754 };
755
756 static struct regulator_consumer_supply mmc0_supplies[] = {
757         REGULATOR_SUPPLY("vmmc", "exynos4-sdhci.0"),
758 };
759
760 static struct regulator_init_data mmc0_fixed_voltage_init_data = {
761         .constraints            = {
762                 .name           = "VMEM_VDD_2.8V",
763                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
764         },
765         .num_consumer_supplies  = ARRAY_SIZE(mmc0_supplies),
766         .consumer_supplies      = mmc0_supplies,
767 };
768
769 static struct fixed_voltage_config mmc0_fixed_voltage_config = {
770         .supply_name            = "MASSMEMORY_EN",
771         .microvolts             = 2800000,
772         .gpio                   = EXYNOS4_GPE1(3),
773         .enable_high            = true,
774         .init_data              = &mmc0_fixed_voltage_init_data,
775 };
776
777 static struct platform_device mmc0_fixed_voltage = {
778         .name                   = "reg-fixed-voltage",
779         .id                     = FIXED_REG_ID_MMC0,
780         .dev                    = {
781                 .platform_data  = &mmc0_fixed_voltage_config,
782         },
783 };
784
785 /* SD */
786 static struct s3c_sdhci_platdata universal_hsmmc2_data __initdata = {
787         .max_width              = 4,
788         .host_caps              = MMC_CAP_4_BIT_DATA |
789                                 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
790         .ext_cd_gpio            = EXYNOS4_GPX3(4),      /* XEINT_28 */
791         .ext_cd_gpio_invert     = 1,
792         .cd_type                = S3C_SDHCI_CD_GPIO,
793         .clk_type               = S3C_SDHCI_CLK_DIV_EXTERNAL,
794 };
795
796 /* WiFi */
797 static struct s3c_sdhci_platdata universal_hsmmc3_data __initdata = {
798         .max_width              = 4,
799         .host_caps              = MMC_CAP_4_BIT_DATA |
800                                 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
801         .cd_type                = S3C_SDHCI_CD_EXTERNAL,
802 };
803
804 static void __init universal_sdhci_init(void)
805 {
806         s3c_sdhci0_set_platdata(&universal_hsmmc0_data);
807         s3c_sdhci2_set_platdata(&universal_hsmmc2_data);
808         s3c_sdhci3_set_platdata(&universal_hsmmc3_data);
809 }
810
811 /* I2C1 */
812 static struct i2c_board_info i2c1_devs[] __initdata = {
813         /* Gyro, To be updated */
814 };
815
816 #ifdef CONFIG_DRM_EXYNOS
817 static struct exynos_drm_fimd_pdata drm_fimd_pdata = {
818         .panel = {
819                 .timing = {
820                         .left_margin    = 16,
821                         .right_margin   = 16,
822                         .upper_margin   = 2,
823                         .lower_margin   = 28,
824                         .hsync_len      = 2,
825                         .vsync_len      = 1,
826                         .xres           = 480,
827                         .yres           = 800,
828                         .refresh        = 55,
829                 },
830         },
831         .vidcon0        = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB |
832                           VIDCON0_CLKSEL_LCD,
833         .vidcon1        = VIDCON1_INV_VCLK | VIDCON1_INV_VDEN
834                           | VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
835         .default_win    = 3,
836         .bpp            = 32,
837 };
838 #else
839 /* Frame Buffer */
840 static struct s3c_fb_pd_win universal_fb_win0 = {
841         .win_mode = {
842                 .left_margin    = 16,
843                 .right_margin   = 16,
844                 .upper_margin   = 2,
845                 .lower_margin   = 28,
846                 .hsync_len      = 2,
847                 .vsync_len      = 1,
848                 .xres           = 480,
849                 .yres           = 800,
850                 .refresh        = 55,
851         },
852         .max_bpp        = 32,
853         .default_bpp    = 16,
854         .virtual_x      = 480,
855         .virtual_y      = 2 * 800,
856 };
857
858 static struct s3c_fb_platdata universal_lcd_pdata __initdata = {
859         .win[0]         = &universal_fb_win0,
860         .vidcon0        = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB |
861                           VIDCON0_CLKSEL_LCD,
862         .vidcon1        = VIDCON1_INV_VCLK | VIDCON1_INV_VDEN
863                           | VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
864         .setup_gpio     = exynos4_fimd0_gpio_setup_24bpp,
865 };
866 #endif
867
868 static struct regulator_consumer_supply cam_vt_dio_supply =
869         REGULATOR_SUPPLY("vdd_core", "0-003c");
870
871 static struct regulator_init_data cam_vt_dio_reg_init_data = {
872         .constraints = { .valid_ops_mask = REGULATOR_CHANGE_STATUS },
873         .num_consumer_supplies = 1,
874         .consumer_supplies = &cam_vt_dio_supply,
875 };
876
877 static struct fixed_voltage_config cam_vt_dio_fixed_voltage_cfg = {
878         .supply_name    = "CAM_VT_D_IO",
879         .microvolts     = 2800000,
880         .gpio           = EXYNOS4_GPE2(1), /* CAM_PWR_EN2 */
881         .enable_high    = 1,
882         .init_data      = &cam_vt_dio_reg_init_data,
883 };
884
885 static struct platform_device cam_vt_dio_fixed_reg_dev = {
886         .name = "reg-fixed-voltage", .id = FIXED_REG_ID_CAM_VT_DIO,
887         .dev = { .platform_data = &cam_vt_dio_fixed_voltage_cfg },
888 };
889
890 static struct regulator_consumer_supply cam_i_core_supply =
891         REGULATOR_SUPPLY("core", "0-001f");
892
893 static struct regulator_init_data cam_i_core_reg_init_data = {
894         .constraints = { .valid_ops_mask = REGULATOR_CHANGE_STATUS },
895         .num_consumer_supplies = 1,
896         .consumer_supplies = &cam_i_core_supply,
897 };
898
899 static struct fixed_voltage_config cam_i_core_fixed_voltage_cfg = {
900         .supply_name    = "CAM_I_CORE_1.2V",
901         .microvolts     = 1200000,
902         .gpio           = EXYNOS4_GPE2(2),      /* CAM_8M_CORE_EN */
903         .enable_high    = 1,
904         .init_data      = &cam_i_core_reg_init_data,
905 };
906
907 static struct platform_device cam_i_core_fixed_reg_dev = {
908         .name = "reg-fixed-voltage", .id = FIXED_REG_ID_CAM_I_CORE,
909         .dev = { .platform_data = &cam_i_core_fixed_voltage_cfg },
910 };
911
912 static struct regulator_consumer_supply cam_s_if_supply =
913         REGULATOR_SUPPLY("d_sensor", "0-001f");
914
915 static struct regulator_init_data cam_s_if_reg_init_data = {
916         .constraints = { .valid_ops_mask = REGULATOR_CHANGE_STATUS },
917         .num_consumer_supplies = 1,
918         .consumer_supplies = &cam_s_if_supply,
919 };
920
921 static struct fixed_voltage_config cam_s_if_fixed_voltage_cfg = {
922         .supply_name    = "CAM_S_IF_1.8V",
923         .microvolts     = 1800000,
924         .gpio           = EXYNOS4_GPE3(0),      /* CAM_PWR_EN1 */
925         .enable_high    = 1,
926         .init_data      = &cam_s_if_reg_init_data,
927 };
928
929 static struct platform_device cam_s_if_fixed_reg_dev = {
930         .name = "reg-fixed-voltage", .id = FIXED_REG_ID_CAM_S_IF,
931         .dev = { .platform_data = &cam_s_if_fixed_voltage_cfg },
932 };
933
934 static struct s5p_platform_mipi_csis mipi_csis_platdata = {
935         .clk_rate       = 166000000UL,
936         .lanes          = 2,
937         .alignment      = 32,
938         .hs_settle      = 12,
939         .phy_enable     = s5p_csis_phy_enable,
940 };
941
942 #define GPIO_CAM_LEVEL_EN(n)    EXYNOS4_GPE4(n + 3)
943 #define GPIO_CAM_8M_ISP_INT     EXYNOS4_GPX1(5) /* XEINT_13 */
944 #define GPIO_CAM_MEGA_nRST      EXYNOS4_GPE2(5)
945 #define GPIO_CAM_VGA_NRST       EXYNOS4_GPE4(7)
946 #define GPIO_CAM_VGA_NSTBY      EXYNOS4_GPE4(6)
947
948 static int s5k6aa_set_power(int on)
949 {
950         gpio_set_value(GPIO_CAM_LEVEL_EN(2), !!on);
951         return 0;
952 }
953
954 static struct s5k6aa_platform_data s5k6aa_platdata = {
955         .mclk_frequency = 21600000UL,
956         .gpio_reset     = { GPIO_CAM_VGA_NRST, 0 },
957         .gpio_stby      = { GPIO_CAM_VGA_NSTBY, 0 },
958         .bus_type       = V4L2_MBUS_PARALLEL,
959         .horiz_flip     = 1,
960         .set_power      = s5k6aa_set_power,
961 };
962
963 static struct i2c_board_info s5k6aa_board_info = {
964         I2C_BOARD_INFO("S5K6AA", 0x3C),
965         .platform_data = &s5k6aa_platdata,
966 };
967
968 static int m5mols_set_power(struct device *dev, int on)
969 {
970         gpio_set_value(GPIO_CAM_LEVEL_EN(1), !on);
971         gpio_set_value(GPIO_CAM_LEVEL_EN(2), !!on);
972         return 0;
973 }
974
975 static struct m5mols_platform_data m5mols_platdata = {
976         .gpio_reset     = GPIO_CAM_MEGA_nRST,
977         .reset_polarity = 0,
978         .set_power      = m5mols_set_power,
979 };
980
981 static struct i2c_board_info m5mols_board_info = {
982         I2C_BOARD_INFO("M5MOLS", 0x1F),
983         .platform_data = &m5mols_platdata,
984 };
985
986 static struct s5p_fimc_isp_info universal_camera_sensors[] = {
987         {
988                 .mux_id         = 0,
989                 .flags          = V4L2_MBUS_PCLK_SAMPLE_FALLING |
990                                   V4L2_MBUS_VSYNC_ACTIVE_LOW,
991                 .bus_type       = FIMC_ITU_601,
992                 .board_info     = &s5k6aa_board_info,
993                 .i2c_bus_num    = 0,
994                 .clk_frequency  = 24000000UL,
995         }, {
996                 .mux_id         = 0,
997                 .flags          = V4L2_MBUS_PCLK_SAMPLE_FALLING |
998                                   V4L2_MBUS_VSYNC_ACTIVE_LOW,
999                 .bus_type       = FIMC_MIPI_CSI2,
1000                 .board_info     = &m5mols_board_info,
1001                 .i2c_bus_num    = 0,
1002                 .clk_frequency  = 24000000UL,
1003                 .csi_data_align = 32,
1004         },
1005 };
1006
1007 static struct s5p_platform_fimc fimc_md_platdata = {
1008         .isp_info       = universal_camera_sensors,
1009         .num_clients    = ARRAY_SIZE(universal_camera_sensors),
1010 };
1011
1012 static struct gpio universal_camera_gpios[] = {
1013         { GPIO_CAM_LEVEL_EN(1), GPIOF_OUT_INIT_HIGH, "CAM_LVL_EN1" },
1014         { GPIO_CAM_LEVEL_EN(2), GPIOF_OUT_INIT_LOW,  "CAM_LVL_EN2" },
1015         { GPIO_CAM_8M_ISP_INT,  GPIOF_IN,            "8M_ISP_INT"  },
1016         { GPIO_CAM_MEGA_nRST,   GPIOF_OUT_INIT_LOW,  "CAM_8M_NRST" },
1017         { GPIO_CAM_VGA_NRST,    GPIOF_OUT_INIT_LOW,  "CAM_VGA_NRST"  },
1018         { GPIO_CAM_VGA_NSTBY,   GPIOF_OUT_INIT_LOW,  "CAM_VGA_NSTBY" },
1019 };
1020
1021 static void __init universal_camera_init(void)
1022 {
1023         s3c_set_platdata(&mipi_csis_platdata, sizeof(mipi_csis_platdata),
1024                          &s5p_device_mipi_csis0);
1025         s3c_set_platdata(&fimc_md_platdata,  sizeof(fimc_md_platdata),
1026                          &s5p_device_fimc_md);
1027
1028         if (gpio_request_array(universal_camera_gpios,
1029                                ARRAY_SIZE(universal_camera_gpios))) {
1030                 pr_err("%s: GPIO request failed\n", __func__);
1031                 return;
1032         }
1033
1034         if (!s3c_gpio_cfgpin(GPIO_CAM_8M_ISP_INT, S3C_GPIO_SFN(0xf)))
1035                 m5mols_board_info.irq = gpio_to_irq(GPIO_CAM_8M_ISP_INT);
1036         else
1037                 pr_err("Failed to configure 8M_ISP_INT GPIO\n");
1038
1039         /* Free GPIOs controlled directly by the sensor drivers. */
1040         gpio_free(GPIO_CAM_MEGA_nRST);
1041         gpio_free(GPIO_CAM_8M_ISP_INT);
1042         gpio_free(GPIO_CAM_VGA_NRST);
1043         gpio_free(GPIO_CAM_VGA_NSTBY);
1044
1045         if (exynos4_fimc_setup_gpio(S5P_CAMPORT_A))
1046                 pr_err("Camera port A setup failed\n");
1047 }
1048
1049 static struct platform_device *universal_devices[] __initdata = {
1050         /* Samsung Platform Devices */
1051         &s5p_device_mipi_csis0,
1052         &s5p_device_fimc0,
1053         &s5p_device_fimc1,
1054         &s5p_device_fimc2,
1055         &s5p_device_fimc3,
1056         &s5p_device_g2d,
1057         &mmc0_fixed_voltage,
1058         &s3c_device_hsmmc0,
1059         &s3c_device_hsmmc2,
1060         &s3c_device_hsmmc3,
1061         &s3c_device_i2c0,
1062         &s3c_device_i2c3,
1063         &s3c_device_i2c5,
1064         &s5p_device_i2c_hdmiphy,
1065         &hdmi_fixed_voltage,
1066         &s5p_device_hdmi,
1067         &s5p_device_sdo,
1068         &s5p_device_mixer,
1069
1070         /* Universal Devices */
1071         &i2c_gpio12,
1072         &universal_gpio_keys,
1073         &s5p_device_onenand,
1074         &s5p_device_fimd0,
1075         &s5p_device_jpeg,
1076 #ifdef CONFIG_DRM_EXYNOS
1077         &exynos_device_drm,
1078 #endif
1079         &s5p_device_mfc,
1080         &s5p_device_mfc_l,
1081         &s5p_device_mfc_r,
1082         &cam_vt_dio_fixed_reg_dev,
1083         &cam_i_core_fixed_reg_dev,
1084         &cam_s_if_fixed_reg_dev,
1085         &s5p_device_fimc_md,
1086 };
1087
1088 static void __init universal_map_io(void)
1089 {
1090         clk_xusbxti.rate = 24000000;
1091         exynos_init_io(NULL, 0);
1092         s3c24xx_init_clocks(24000000);
1093         s3c24xx_init_uarts(universal_uartcfgs, ARRAY_SIZE(universal_uartcfgs));
1094 }
1095
1096 static void s5p_tv_setup(void)
1097 {
1098         /* direct HPD to HDMI chip */
1099         gpio_request_one(EXYNOS4_GPX3(7), GPIOF_IN, "hpd-plug");
1100         s3c_gpio_cfgpin(EXYNOS4_GPX3(7), S3C_GPIO_SFN(0x3));
1101         s3c_gpio_setpull(EXYNOS4_GPX3(7), S3C_GPIO_PULL_NONE);
1102 }
1103
1104 static void __init universal_reserve(void)
1105 {
1106         s5p_mfc_reserve_mem(0x43000000, 8 << 20, 0x51000000, 8 << 20);
1107 }
1108
1109 static void __init universal_machine_init(void)
1110 {
1111         universal_sdhci_init();
1112         s5p_tv_setup();
1113
1114         s3c_i2c0_set_platdata(&universal_i2c0_platdata);
1115         i2c_register_board_info(1, i2c1_devs, ARRAY_SIZE(i2c1_devs));
1116
1117         universal_tsp_init();
1118         s3c_i2c3_set_platdata(NULL);
1119         i2c_register_board_info(3, i2c3_devs, ARRAY_SIZE(i2c3_devs));
1120
1121         s3c_i2c5_set_platdata(NULL);
1122         s5p_i2c_hdmiphy_set_platdata(NULL);
1123         i2c_register_board_info(5, i2c5_devs, ARRAY_SIZE(i2c5_devs));
1124
1125 #ifdef CONFIG_DRM_EXYNOS
1126         s5p_device_fimd0.dev.platform_data = &drm_fimd_pdata;
1127         exynos4_fimd0_gpio_setup_24bpp();
1128 #else
1129         s5p_fimd0_set_platdata(&universal_lcd_pdata);
1130 #endif
1131
1132         universal_touchkey_init();
1133         i2c_register_board_info(I2C_GPIO_BUS_12, i2c_gpio12_devs,
1134                         ARRAY_SIZE(i2c_gpio12_devs));
1135
1136         universal_camera_init();
1137
1138         /* Last */
1139         platform_add_devices(universal_devices, ARRAY_SIZE(universal_devices));
1140 }
1141
1142 MACHINE_START(UNIVERSAL_C210, "UNIVERSAL_C210")
1143         /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */
1144         .atag_offset    = 0x100,
1145         .init_irq       = exynos4_init_irq,
1146         .map_io         = universal_map_io,
1147         .handle_irq     = gic_handle_irq,
1148         .init_machine   = universal_machine_init,
1149         .timer          = &exynos4_timer,
1150         .reserve        = &universal_reserve,
1151         .restart        = exynos4_restart,
1152 MACHINE_END