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