upload tizen1.0 source
[kernel/linux-2.6.36.git] / arch / arm / mach-s5pv310 / mach-universal_c210.c
1 /*
2  * linux/arch/arm/mach-s5pv310/mach-universal_c210.c
3  *
4  * Copyright (c) 2010 Samsung Electronics Co., Ltd.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10
11 #include <linux/platform_device.h>
12 #include <linux/serial_core.h>
13 #include <linux/input.h>
14 #include <linux/gpio.h>
15 #include <linux/gpio_keys.h>
16 #include <linux/delay.h>
17 #include <linux/cma.h>
18 #include <linux/lcd.h>
19 #include <linux/spi/spi.h>
20 #include <linux/spi/spi_gpio.h>
21 #include <linux/i2c.h>
22 #include <linux/i2c-gpio.h>
23 #include <linux/i2c/mcs.h>
24 #include <linux/i2c/atmel_mxt_ts.h>
25 #include <linux/clk.h>
26 #include <linux/ntc.h>
27 #include <linux/regulator/machine.h>
28 #include <linux/regulator/fixed.h>
29 #include <linux/regulator/max8952.h>
30 #include <linux/mfd/max8998.h>
31 #include <linux/mfd/max8998-private.h>
32 #include <linux/mmc/host.h>
33 #include <linux/ak8975.h>
34 #include <linux/tmd27711.h>
35 #include <linux/pn544.h>
36 #include <linux/jack.h>
37 #include <linux/fsa9480.h>
38 #include <linux/kr3dh.h>
39 #include <linux/k3g.h>
40 #include <linux/max17040_battery.h>
41 #include <linux/ramoops.h>
42 #include <linux/mmcoops.h>
43 #include <linux/micro_usb_switch.h>
44 #include <linux/uart_select.h>
45 #include <linux/memblock.h>
46 #include <linux/rtc/rtc-s3c.h>
47
48 #include <asm/mach-types.h>
49 #include <asm/mach/arch.h>
50 #include <asm/setup.h>
51
52 #include <mach/map.h>
53 #include <mach/gpio.h>
54 #include <mach/regs-clock.h>
55 #include <mach/regs-pmu.h>
56
57 #include <plat/cpu.h>
58 #include <plat/devs.h>
59 #include <plat/gpio-cfg.h>
60 #include <plat/gpio-core.h>
61 #include <plat/fb.h>
62 #include <plat/fimc-core.h>
63 #include <plat/mipi_csis.h>
64 #include <plat/fimg2d.h>
65 #include <plat/mali.h>
66 #include <plat/iic.h>
67 #include <plat/pm.h>
68 #include <plat/regs-otg.h>
69 #include <plat/regs-serial.h>
70 #include <plat/s5pv310.h>
71 #include <plat/sdhci.h>
72 #include <plat/adc.h>
73 #include <plat/fimd_drm.h>
74 #include <plat/s5p-charger.h>
75 #include <plat/s5p-charger-breaker.h>
76 #include <plat/tvout.h>
77 #include <plat/pd.h>
78
79 #include <media/s5p_fimc.h>
80 #include <media/m5mols.h>
81 #include <media/s5k6aafx.h>
82
83 #include <sound/a1026.h>
84 #include "modemctl.h"
85 #include "bcm4751.h"
86 #include "bcm4330.h"
87 #include "gpio-mobile.h"
88 #include "gpio-universal.h"
89
90 /* Following are default values for UCON, ULCON and UFCON UART registers */
91 #define UNIVERSAL_UCON_DEFAULT  (S3C2410_UCON_TXILEVEL |        \
92                                  S3C2410_UCON_RXILEVEL |        \
93                                  S3C2410_UCON_TXIRQMODE |       \
94                                  S3C2410_UCON_RXIRQMODE |       \
95                                  S3C2410_UCON_RXFIFO_TOI |      \
96                                  S3C2443_UCON_RXERR_IRQEN)
97
98 #define UNIVERSAL_ULCON_DEFAULT S3C2410_LCON_CS8
99
100 #define UNIVERSAL_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE |       \
101                                  S5PV210_UFCON_TXTRIG256 |      \
102                                  S5PV210_UFCON_RXTRIG256)
103
104 static int hwrevision(int hwrev)
105 {
106         return ((system_rev & 0xFF) == hwrev);
107 }
108
109 static struct s3c2410_uartcfg universal_uartcfgs[] __initdata = {
110         {
111                 .hwport         = 0,
112                 .ucon           = UNIVERSAL_UCON_DEFAULT,
113                 .ulcon          = UNIVERSAL_ULCON_DEFAULT,
114                 .ufcon          = UNIVERSAL_UFCON_DEFAULT,
115         },
116         {
117                 .hwport         = 1,
118                 .ucon           = UNIVERSAL_UCON_DEFAULT,
119                 .ulcon          = UNIVERSAL_ULCON_DEFAULT,
120                 .ufcon          = UNIVERSAL_UFCON_DEFAULT,
121         },
122 #ifndef CONFIG_FIQ_DEBUGGER
123         {
124                 .hwport         = 2,
125                 .ucon           = UNIVERSAL_UCON_DEFAULT,
126                 .ulcon          = UNIVERSAL_ULCON_DEFAULT,
127                 .ufcon          = UNIVERSAL_UFCON_DEFAULT,
128         },
129 #endif
130         {
131                 .hwport         = 3,
132                 .ucon           = UNIVERSAL_UCON_DEFAULT,
133                 .ulcon          = UNIVERSAL_ULCON_DEFAULT,
134                 .ufcon          = UNIVERSAL_UFCON_DEFAULT,
135         },
136 };
137
138 static struct s3c2410_platform_i2c universal_i2c0_platdata __initdata = {
139         .frequency      = 300 * 1000,
140         .sda_delay      = 200,
141 };
142
143 static struct k3g_platform_data universal_k3g_data = {
144         .irq2                   = IRQ_EINT(1),
145         .powerdown              = K3G_POWERDOWN_NORMAL,
146         .zen                    = K3G_Z_EN,
147         .yen                    = K3G_Y_EN,
148         .xen                    = K3G_X_EN,
149         .block_data_update      = K3G_BLOCK_DATA_UPDATE,
150         .fullscale              = K3G_FULL_SCALE_2000DPS,
151         .fifo_mode              = K3G_FIFO_FIFO_MODE,
152         .int2_src               = K3G_INT2_OVERRUN,
153         .fifo_threshold         = 16,
154         .int1_enable            = K3G_INT1_EN,
155         .int1_z_high_enable     = K3G_Z_HIGH_INT_EN,
156         .int1_y_high_enable     = K3G_Y_HIGH_INT_EN,
157         .int1_x_high_enable     = K3G_X_HIGH_INT_EN,
158         .int1_latch             = K3G_INTERRUPT_LATCHED,
159         .int1_z_threshold       = 0x12,
160         .int1_y_threshold       = 0x25,
161         .int1_x_threshold       = 0x25,
162         .int1_wait_enable       = K3G_INT1_WAIT_EN,
163         .int1_wait_duration     = 0x10,
164 };
165
166 /* I2C1 */
167 static struct i2c_board_info i2c1_devs[] __initdata = {
168         {
169                 /* Gyro sensor */
170                 I2C_BOARD_INFO("K3G", 0x69),
171                 .platform_data  = &universal_k3g_data,
172                 .irq            = IRQ_EINT(0),
173         },
174 #ifdef CONFIG_VIDEO_TVOUT
175         {
176                 I2C_BOARD_INFO("s5p_ddc", (0x74 >> 1)),
177         },
178 #endif
179 };
180
181 /* I2C3: TSP */
182 static struct mxt_platform_data mxt_platform_data = {
183         .x_line                 = 19,
184         .y_line                 = 11,
185         .x_size                 = 800,
186         .y_size                 = 480,
187         .blen                   = 0x11,
188         .threshold              = 0x28,
189         .voltage                = 2800000,              /* 2.8V */
190         .orient                 = MXT_DIAGONAL,
191         .irqflags               = IRQF_TRIGGER_FALLING,
192 };
193
194 static struct i2c_board_info i2c3_devs[] __initdata = {
195         {
196                 I2C_BOARD_INFO("atmel_mxt_ts", 0x4a),
197                 .platform_data  = &mxt_platform_data,
198         },
199 };
200
201 static void __init universal_tsp_init(void)
202 {
203         int gpio;
204
205         /* TSP_LDO_ON: XMDMADDR_11 */
206         gpio = S5PV310_GPE2(3);
207         gpio_request(gpio, "TSP_LDO_ON");
208         gpio_direction_output(gpio, 1);
209         gpio_export(gpio, 0);
210
211         /* TSP_INT: XMDMADDR_7 */
212         gpio = S5PV310_GPE1(7);
213         gpio_request(gpio, "TSP_INT");
214         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
215         /*
216          * Note that because TSP_LDO provides an external pull-up to TSP_INT,
217          * the pull-up setting at GPE1(7) is useless and may be omitted in
218          * order to reduce idle current. However, it probably needs some
219          * sleep/delay from TSP_LDO_ON = true event because there could be
220          * "ramp-up" delay. Before knowing this, let's just use PULL_UP here.
221          */
222         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
223         i2c3_devs[0].irq = gpio_to_irq(gpio);
224 }
225
226 static struct kr3dh_platform_data universal_kr3dh_data = {
227         .power_mode             = KR3DH_NORMAL_MODE,
228         .data_rate              = KR3DH_ODR_50HZ,
229         .zen                    = 1,
230         .yen                    = 1,
231         .xen                    = 1,
232         .int1_latch             = 1,
233         .int1_cfg               = KR3DH_INT_SOURCE,
234         .block_data_update      = 1,
235         .fullscale              = KR3DH_RANGE_2G,
236         .int1_combination       = KR3DH_OR_COMBINATION,
237         .int1_6d_enable         = 1,
238         .int1_z_high_enable     = 1,
239         .int1_z_low_enable      = 1,
240         .int1_y_high_enable     = 1,
241         .int1_y_low_enable      = 1,
242         .int1_x_high_enable     = 1,
243         .int1_x_low_enable      = 1,
244         .int1_threshold         = 0x25,
245         .int1_duration          = 0x01,
246         .negate_x               = 1,
247         .negate_y               = 1,
248         .negate_z               = 0,
249 };
250
251 /* I2C4 */
252 static struct i2c_board_info i2c4_devs[] __initdata = {
253         {
254                 I2C_BOARD_INFO("si470x", 0x10),
255         }, {
256                 I2C_BOARD_INFO("KR3DH", 0x19),
257                 .platform_data  = &universal_kr3dh_data,
258                 .irq            = IRQ_EINT(20),
259         },
260 };
261
262 static void __init universal_fmradio_init(void)
263 {
264         int gpio;
265
266         gpio = S5PV310_GPE3(4);         /* XMDMDATA_4 */
267         gpio_request(gpio, "FM_INT");
268         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
269         i2c4_devs[0].irq = gpio_to_irq(gpio);
270         gpio_free(gpio);
271
272         gpio = S5PV310_GPE3(5);         /* XMDMDATA_5 */
273         gpio_request(gpio, "FM_nRST");
274         gpio_direction_output(gpio, 1);
275         gpio_free(gpio);
276 }
277
278 /* I2C5: PMICs LP3974, MAX8952 */
279 static struct regulator_consumer_supply max8952_consumer[] = {
280         {
281                 .supply         = "varm_1.2v_c210", /* obsolete */
282         }, {
283                 .supply         = "vdd_arm",
284         },
285 };
286
287 static struct max8952_platform_data universal_max8952_pdata = {
288         .gpio_vid0              = S5PV310_GPX0(3),
289         .gpio_vid1              = S5PV310_GPX0(4),
290         .gpio_en                = -1, /* Not controllable, set "Always High" */
291         .default_mode           = 3, /* vid0 = 1, vid1 = 1 */
292         .dvs_mode               = { 13, 23, 43, 33 },
293                 /*
294                  *      0.90 1.00 1.20 1.10V (Defaule: 1.10V)
295                  * 1.10V is 0x3 so that we can reduce current at sleep
296                  * because there are pull-up's at vid0 and vid1 and 1.10V is
297                  * the default voltage (cpufreq is supposed to set at the
298                  * default voltage/frequency during suspend).
299                  */
300         .sync_freq              = 0, /* default: fastest */
301         .ramp_speed             = 0, /* default: fastest */
302
303         .reg_data               = {
304                 .constraints    = {
305                         .name           = "VARM_1.2V",
306                         .min_uV         = 770000,
307                         .max_uV         = 1400000,
308                         .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
309                         .always_on      = 1,
310                         .state_mem      = {
311                                 .enabled        = 1,
312                                 .disabled       = 0,
313                                 /*
314                                  * MAX8952's EN is connected to an
315                                  * uncontrollable pin. Assume it is
316                                  * "ON".
317                                  */
318                         }
319                 },
320                 .num_consumer_supplies  = ARRAY_SIZE(max8952_consumer),
321                 .consumer_supplies      = max8952_consumer,
322         },
323 };
324
325 static struct regulator_consumer_supply lp3974_buck1_consumer[] = {
326         {
327                 .supply         = "vint_1.1v_c210", /* obsolete */
328         }, {
329                 .supply         = "vdd_int",
330         },
331 };
332
333 static struct regulator_consumer_supply lp3974_buck2_consumer[] = {
334         {
335                 .supply         = "vg3d_1.2v_c210", /* obsolete */
336         }, {
337                 .supply         = "vg3d",
338         },
339 };
340
341 static struct regulator_consumer_supply lp3974_buck3_consumer[] = {
342         {
343                 .supply         = "vcc_1.8v_pda",
344         },
345 };
346
347 static struct regulator_consumer_supply lp3974_buck4_consumer[] = {
348         {
349                 .supply         = "vmem_1.2v_c210",
350         },
351 };
352
353 static struct regulator_consumer_supply lp3974_ldo2_consumer[] = {
354         REGULATOR_SUPPLY("valive", NULL),
355 };
356
357 static struct regulator_consumer_supply lp3974_ldo3_consumer[] = {
358         REGULATOR_SUPPLY("vusb_a", NULL),
359         REGULATOR_SUPPLY("vmipi_1.1v", NULL),
360 };
361
362 static struct regulator_consumer_supply lp3974_ldo4_consumer[] = {
363         REGULATOR_SUPPLY("vadc", NULL),
364         REGULATOR_SUPPLY("vadc", "s5p-charger"),
365 };
366
367 static struct regulator_consumer_supply lp3974_ldo5_consumer[] = {
368         REGULATOR_SUPPLY("vmmc", "s3c-sdhci.2"),
369 };
370
371 static struct regulator_consumer_supply lp3974_ldo7_consumer[] = {
372         REGULATOR_SUPPLY("vmipi_1.8v", NULL),
373         REGULATOR_SUPPLY("vlcd_1.8v", NULL),
374 };
375
376 static struct regulator_consumer_supply lp3974_ldo8_consumer[] = {
377         REGULATOR_SUPPLY("vusb_d", NULL),
378         REGULATOR_SUPPLY("vdac", NULL),
379 };
380
381 static struct regulator_consumer_supply lp3974_ldo9_consumer[] = {
382         REGULATOR_SUPPLY("vcc_2.8v_pda", NULL),
383         REGULATOR_SUPPLY("vddio", "0-003c"),
384 };
385
386 static struct regulator_consumer_supply lp3974_ldo10_consumer[] = {
387         REGULATOR_SUPPLY("vpll", NULL),
388 };
389
390 static struct regulator_consumer_supply lp3974_ldo11_consumer[] = {
391         {
392                 .supply         = "cam_af_3.3v",
393         },
394         REGULATOR_SUPPLY("dig_28", "0-001f"),   /* CAM_AF_3.3V */
395 };
396
397 static struct regulator_consumer_supply lp3974_ldo12_consumer[] = {
398         {
399                 .supply         = "ps_2.8v",
400         },
401 };
402
403 static struct regulator_consumer_supply lp3974_ldo13_consumer[] = {
404         REGULATOR_SUPPLY("vhsic", NULL),
405 };
406
407 static struct regulator_consumer_supply lp3974_ldo14_consumer[] = {
408         {
409                 .supply         = "cam_i_host_1.8v",
410         },
411         REGULATOR_SUPPLY("dig_18", "0-001f"),   /* CAM_I_HOST_1.8V */
412 };
413
414 static struct regulator_consumer_supply lp3974_ldo15_consumer[] = {
415         REGULATOR_SUPPLY("dig_12", "0-001f"),   /* CAM_S_DIG_1.2V */
416         REGULATOR_SUPPLY("fm33_core_1.2v", NULL),
417 };
418
419 static struct regulator_consumer_supply lp3974_ldo16_consumer[] = {
420         REGULATOR_SUPPLY("a_sensor", "0-001f"),
421         REGULATOR_SUPPLY("vdda", "0-003c"),
422 };
423
424 static struct regulator_consumer_supply lp3974_ldo17_consumer[] = {
425         REGULATOR_SUPPLY("vlcd_3.0v", NULL),
426         REGULATOR_SUPPLY("mipi_csi", "s5p-mipi-csis.0"),
427 };
428
429 static struct regulator_consumer_supply lp3974_esafeout1_consumer[] = {
430         {
431                 .supply         = "usb_vbus_ap_5v",
432         },
433 };
434
435 static struct regulator_consumer_supply lp3974_esafeout2_consumer[] = {
436         {
437                 .supply         = "usb_vbus_cp_5v",
438         },
439 };
440
441 static struct regulator_consumer_supply lp3974_charger_consumer[] = {
442         REGULATOR_SUPPLY("vinchg", "s5p-charger"),
443         REGULATOR_SUPPLY("vinchg", "s5p-charger-breaker"),
444 };
445
446 static struct regulator_init_data lp3974_buck1_data = {
447         .constraints    = {
448                 .name           = "VINT_1.1V",
449                 .min_uV         = 750000,
450                 .max_uV         = 1500000,
451                 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
452                         REGULATOR_CHANGE_STATUS,
453                 .boot_on        = 1,
454                 .state_mem      = {
455                         .enabled = 0,
456                         .disabled = 1,
457                 },
458         },
459         .num_consumer_supplies = ARRAY_SIZE(lp3974_buck1_consumer),
460         .consumer_supplies = lp3974_buck1_consumer,
461 };
462
463 static struct regulator_init_data lp3974_buck2_data = {
464         .constraints    = {
465                 .name           = "VG3D_1.2V",
466                 .min_uV         = 1100000, /* Default after boot */
467                 .max_uV         = 1200000, /* For max performance */
468                 .valid_ops_mask = REGULATOR_CHANGE_STATUS |
469                                         REGULATOR_CHANGE_VOLTAGE,
470                 .boot_on        = 0,
471                 .state_mem      = {
472                         .enabled = 0,
473                         .disabled = 1,
474                 },
475         },
476         .num_consumer_supplies = ARRAY_SIZE(lp3974_buck2_consumer),
477         .consumer_supplies = lp3974_buck2_consumer,
478 };
479
480 static struct regulator_init_data lp3974_buck3_data = {
481         .constraints    = {
482                 .name           = "VCC_1.8V",
483                 .min_uV         = 1800000,
484                 .max_uV         = 1800000,
485                 .apply_uV       = 1,
486                 .always_on      = 1,
487                 .state_mem      = {
488                         .enabled = 1,
489                         .disabled = 0,
490                 },
491         },
492         .num_consumer_supplies = ARRAY_SIZE(lp3974_buck3_consumer),
493         .consumer_supplies = lp3974_buck3_consumer,
494 };
495
496 static struct regulator_init_data lp3974_buck4_data = {
497         .constraints    = {
498                 .name           = "VMEM_1.2V",
499                 .min_uV         = 1200000,
500                 .max_uV         = 1200000,
501                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
502                 .boot_on        = 1,
503                 .apply_uV       = 1,
504                 .state_mem      = {
505                         .enabled = 1,
506                         .disabled = 0,
507                 },
508         },
509         .num_consumer_supplies  = ARRAY_SIZE(lp3974_buck4_consumer),
510         .consumer_supplies      = lp3974_buck4_consumer,
511 };
512
513 static struct regulator_init_data lp3974_ldo2_data = {
514         .constraints    = {
515                 .name           = "VALIVE_1.2V",
516                 .min_uV         = 1200000,
517                 .max_uV         = 1200000,
518                 .apply_uV       = 1,
519                 .always_on      = 1,
520                 .state_mem      = {
521                         .enabled = 1,
522                         .disabled = 0,
523                 },
524         },
525         .num_consumer_supplies  = ARRAY_SIZE(lp3974_ldo2_consumer),
526         .consumer_supplies      = lp3974_ldo2_consumer,
527 };
528
529 static struct regulator_init_data lp3974_ldo3_data = {
530         .constraints    = {
531                 .name           = "VUSB/MIPI_1.1V",
532                 .min_uV         = 1100000,
533                 .max_uV         = 1100000,
534                 .apply_uV       = 1,
535                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
536                 .state_mem      = {
537                         .enabled = 0,
538                         .disabled = 1,
539                 },
540         },
541         .num_consumer_supplies  = ARRAY_SIZE(lp3974_ldo3_consumer),
542         .consumer_supplies      = lp3974_ldo3_consumer,
543 };
544
545 static struct regulator_init_data lp3974_ldo4_data = {
546         .constraints    = {
547                 .name           = "VADC_3.3V",
548                 .min_uV         = 3300000,
549                 .max_uV         = 3300000,
550                 .apply_uV       = 1,
551                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
552                 .always_on      = 1,
553                 .state_mem      = {
554                         .enabled = 1,
555                         .disabled = 0,
556                 },
557         },
558         .num_consumer_supplies  = ARRAY_SIZE(lp3974_ldo4_consumer),
559         .consumer_supplies      = lp3974_ldo4_consumer,
560 };
561
562 static struct regulator_init_data lp3974_ldo5_data = {
563         .constraints    = {
564                 .name           = "VTF_2.8V",
565                 .min_uV         = 2800000,
566                 .max_uV         = 2800000,
567                 .apply_uV       = 1,
568                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
569                 .state_mem      = {
570                         .enabled = 0,
571                         .disabled = 1,
572                 },
573         },
574         .num_consumer_supplies  = ARRAY_SIZE(lp3974_ldo5_consumer),
575         .consumer_supplies      = lp3974_ldo5_consumer,
576 };
577
578 static struct regulator_init_data lp3974_ldo6_data = {
579         .constraints    = {
580                 .name           = "LDO6",
581                 .min_uV         = 2000000,
582                 .max_uV         = 2000000,
583                 .apply_uV       = 1,
584                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
585                 .state_mem      = {
586                         .enabled = 0,
587                         .disabled = 1,
588                 },
589         },
590 };
591
592 static struct regulator_init_data lp3974_ldo7_data = {
593         .constraints    = {
594                 .name           = "VLCD/VMIPI_1.8V",
595                 .min_uV         = 1800000,
596                 .max_uV         = 1800000,
597                 .apply_uV       = 1,
598                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
599                 .state_mem      = {
600                         .enabled = 0,
601                         .disabled = 1,
602                 },
603         },
604         .num_consumer_supplies  = ARRAY_SIZE(lp3974_ldo7_consumer),
605         .consumer_supplies      = lp3974_ldo7_consumer,
606 };
607
608 static struct regulator_init_data lp3974_ldo8_data = {
609         .constraints    = {
610                 .name           = "VUSB/VDAC_3.3V",
611                 .min_uV         = 3300000,
612                 .max_uV         = 3300000,
613                 .apply_uV       = 1,
614                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
615                 .state_mem      = {
616                         .enabled = 0,
617                         .disabled = 1,
618                 },
619         },
620         .num_consumer_supplies  = ARRAY_SIZE(lp3974_ldo8_consumer),
621         .consumer_supplies      = lp3974_ldo8_consumer,
622 };
623
624 static struct regulator_init_data lp3974_ldo9_data = {
625         .constraints    = {
626                 .name           = "VCC_2.8V",
627                 .min_uV         = 2800000,
628                 .max_uV         = 2800000,
629                 .apply_uV       = 1,
630                 .always_on      = 1,
631                 .state_mem      = {
632                         .enabled = 1,
633                         .disabled = 0,
634                 },
635         },
636         .num_consumer_supplies  = ARRAY_SIZE(lp3974_ldo9_consumer),
637         .consumer_supplies      = lp3974_ldo9_consumer,
638 };
639
640 static struct regulator_init_data lp3974_ldo10_data = {
641         .constraints    = {
642                 .name           = "VPLL_1.1V",
643                 .min_uV         = 1100000,
644                 .max_uV         = 1100000,
645                 .apply_uV       = 1,
646                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
647                 .state_mem      = {
648                         .enabled = 0,
649                         .disabled = 1,
650                 },
651         },
652         .num_consumer_supplies  = ARRAY_SIZE(lp3974_ldo10_consumer),
653         .consumer_supplies      = lp3974_ldo10_consumer,
654 };
655
656 static struct regulator_init_data lp3974_ldo11_data = {
657         .constraints    = {
658                 .name           = "CAM_AF_3.3V",
659                 .min_uV         = 3300000,
660                 .max_uV         = 3300000,
661                 .apply_uV       = 1,
662                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
663                 .state_mem      = {
664                         .enabled = 0,
665                         .disabled = 1,
666                 },
667         },
668         .num_consumer_supplies  = ARRAY_SIZE(lp3974_ldo11_consumer),
669         .consumer_supplies      = lp3974_ldo11_consumer,
670 };
671
672 static struct regulator_init_data lp3974_ldo12_data = {
673         .constraints    = {
674                 .name           = "PS_2.8V",
675                 .min_uV         = 2800000,
676                 .max_uV         = 2800000,
677                 .apply_uV       = 1,
678                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
679                 .state_mem      = {
680                         .enabled = 0,
681                         .disabled = 1,
682                 },
683         },
684         .num_consumer_supplies  = ARRAY_SIZE(lp3974_ldo12_consumer),
685         .consumer_supplies      = lp3974_ldo12_consumer,
686 };
687
688 static struct regulator_init_data lp3974_ldo13_data = {
689         .constraints    = {
690                 .name           = "VHSIC_1.2V",
691                 .min_uV         = 1200000,
692                 .max_uV         = 1200000,
693                 .apply_uV       = 1,
694                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
695                 .state_mem      = {
696                         .enabled = 0,
697                         .disabled = 1,
698                 },
699         },
700         .num_consumer_supplies  = ARRAY_SIZE(lp3974_ldo13_consumer),
701         .consumer_supplies      = lp3974_ldo13_consumer,
702 };
703
704 static struct regulator_init_data lp3974_ldo14_data = {
705         .constraints    = {
706                 .name           = "CAM_I_HOST_1.8V",
707                 .min_uV         = 1800000,
708                 .max_uV         = 1800000,
709                 .apply_uV       = 1,
710                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
711                 .state_mem      = {
712                         .enabled = 0,
713                         .disabled = 1,
714                 },
715         },
716         .num_consumer_supplies  = ARRAY_SIZE(lp3974_ldo14_consumer),
717         .consumer_supplies      = lp3974_ldo14_consumer,
718 };
719
720 static struct regulator_init_data lp3974_ldo15_data = {
721         .constraints    = {
722                 .name           = "CAM_S_DIG/FM33_CORE_1.2V",
723                 .min_uV         = 1200000,
724                 .max_uV         = 1200000,
725                 .apply_uV       = 1,
726                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
727                 .state_mem      = {
728                         .enabled = 0,
729                         .disabled = 1,
730                 },
731         },
732         .num_consumer_supplies  = ARRAY_SIZE(lp3974_ldo15_consumer),
733         .consumer_supplies      = lp3974_ldo15_consumer,
734 };
735
736 static struct regulator_init_data lp3974_ldo16_data = {
737         .constraints    = {
738                 .name           = "CAM_S_ANA_2.8V",
739                 .min_uV         = 2800000,
740                 .max_uV         = 2800000,
741                 .apply_uV       = 1,
742                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
743                 .state_mem      = {
744                         .enabled = 0,
745                         .disabled = 1,
746                 },
747         },
748         .num_consumer_supplies  = ARRAY_SIZE(lp3974_ldo16_consumer),
749         .consumer_supplies      = lp3974_ldo16_consumer,
750 };
751
752 static struct regulator_init_data lp3974_ldo17_data = {
753         .constraints    = {
754                 .name           = "VCC_3.0V_LCD",
755                 .min_uV         = 3000000,
756                 .max_uV         = 3000000,
757                 .apply_uV       = 1,
758                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
759                 .state_mem      = {
760                         .enabled = 0,
761                         .disabled = 1,
762                 },
763         },
764         .num_consumer_supplies  = ARRAY_SIZE(lp3974_ldo17_consumer),
765         .consumer_supplies      = lp3974_ldo17_consumer,
766 };
767
768 static struct regulator_init_data lp3974_32khz_ap_data = {
769         .constraints    = {
770                 .name           = "32KHz AP",
771                 .always_on      = 1,
772                 .state_mem      = {
773                         .enabled = 1,
774                         .disabled = 0,
775                 },
776         },
777 };
778
779 static struct regulator_init_data lp3974_32khz_cp_data = {
780         .constraints    = {
781                 .name           = "32KHz CP",
782                 .state_mem      = {
783                         .enabled = 0,
784                         .disabled = 1,
785                 },
786         },
787 };
788
789 static struct regulator_init_data lp3974_vichg_data = {
790         .constraints    = {
791                 .name           = "VICHG",
792                 .state_mem      = {
793                         .enabled = 0,
794                         .disabled = 1,
795                 },
796         },
797 };
798
799 static struct regulator_init_data lp3974_esafeout1_data = {
800         .constraints    = {
801                 .name           = "SAFEOUT1",
802                 .min_uV         = 4800000,
803                 .max_uV         = 4800000,
804                 .apply_uV       = 1,
805                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
806                 .state_mem      = {
807                         .enabled = 0,
808                         .disabled = 1,
809                 },
810         },
811         .num_consumer_supplies  = ARRAY_SIZE(lp3974_esafeout1_consumer),
812         .consumer_supplies      = lp3974_esafeout1_consumer,
813 };
814
815 static struct regulator_init_data lp3974_esafeout2_data = {
816         .constraints    = {
817                 .name           = "SAFEOUT2",
818                 .min_uV         = 4800000,
819                 .max_uV         = 4800000,
820                 .apply_uV       = 1,
821                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
822                 .state_mem      = {
823                         .enabled = 0,
824                         .disabled = 1,
825                 },
826         },
827         .num_consumer_supplies  = ARRAY_SIZE(lp3974_esafeout2_consumer),
828         .consumer_supplies      = lp3974_esafeout2_consumer,
829 };
830
831 static struct regulator_init_data lp3974_charger_data = {
832         .constraints    = {
833                 .name           = "CHARGER",
834                 .min_uA         = 100000,
835                 .max_uA         = 800000,
836                 .boot_on        = 1,
837                 .valid_ops_mask = REGULATOR_CHANGE_STATUS |
838                         REGULATOR_CHANGE_CURRENT,
839         },
840         .num_consumer_supplies  = ARRAY_SIZE(lp3974_charger_consumer),
841         .consumer_supplies      = lp3974_charger_consumer,
842 };
843
844 static struct max8998_regulator_data lp3974_regulators[] = {
845         { MAX8998_LDO2,  &lp3974_ldo2_data },
846         { MAX8998_LDO3,  &lp3974_ldo3_data },
847         { MAX8998_LDO4,  &lp3974_ldo4_data },
848         { MAX8998_LDO5,  &lp3974_ldo5_data },
849         { MAX8998_LDO6,  &lp3974_ldo6_data },
850         { MAX8998_LDO7,  &lp3974_ldo7_data },
851         { MAX8998_LDO8,  &lp3974_ldo8_data },
852         { MAX8998_LDO9,  &lp3974_ldo9_data },
853         { MAX8998_LDO10, &lp3974_ldo10_data },
854         { MAX8998_LDO11, &lp3974_ldo11_data },
855         { MAX8998_LDO12, &lp3974_ldo12_data },
856         { MAX8998_LDO13, &lp3974_ldo13_data },
857         { MAX8998_LDO14, &lp3974_ldo14_data },
858         { MAX8998_LDO15, &lp3974_ldo15_data },
859         { MAX8998_LDO16, &lp3974_ldo16_data },
860         { MAX8998_LDO17, &lp3974_ldo17_data },
861         { MAX8998_BUCK1, &lp3974_buck1_data },
862         { MAX8998_BUCK2, &lp3974_buck2_data },
863         { MAX8998_BUCK3, &lp3974_buck3_data },
864         { MAX8998_BUCK4, &lp3974_buck4_data },
865         { MAX8998_EN32KHZ_AP, &lp3974_32khz_ap_data },
866         { MAX8998_EN32KHZ_CP, &lp3974_32khz_cp_data },
867         { MAX8998_ENVICHG, &lp3974_vichg_data },
868         { MAX8998_ESAFEOUT1, &lp3974_esafeout1_data },
869         { MAX8998_ESAFEOUT2, &lp3974_esafeout2_data },
870         { MAX8998_CHARGER, &lp3974_charger_data },
871 };
872
873 static struct max8998_platform_data universal_lp3974_pdata = {
874         .irq_base               = IRQ_PMIC_BASE,
875         .num_regulators         = ARRAY_SIZE(lp3974_regulators),
876         .regulators             = lp3974_regulators,
877         .buck1_voltage1         = 1100000,      /* INT */
878         .buck1_voltage2         = 1000000,
879         .buck1_voltage3         = 1100000,
880         .buck1_voltage4         = 1000000,
881         .buck1_set1             = S5PV310_GPX0(5),
882         .buck1_set2             = S5PV310_GPX0(6),
883         .buck2_voltage1         = 1200000,      /* G3D */
884         .buck2_voltage2         = 1100000,
885         .buck1_default_idx      = 0,
886         .buck2_set3             = S5PV310_GPE2(0),
887         .buck2_default_idx      = 0,
888         .wakeup                 = true,
889         .eoc                    = 150,
890         .restart                = 100,
891         .timeout                = 5,
892 };
893
894 static void __init universal_pmic_init(void)
895 {
896         int gpio;
897
898         gpio = S5PV310_GPE2(0);
899         gpio_request(gpio, "BUCK2_EN");
900         gpio_direction_output(gpio, universal_lp3974_pdata.buck2_default_idx);
901         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
902
903         gpio = S5PV310_GPX0(5);
904         gpio_request(gpio, "BUCK1_EN_A");
905         gpio_direction_output(gpio,
906                         universal_lp3974_pdata.buck1_default_idx % 2);
907         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
908
909         gpio = S5PV310_GPX0(6);
910         gpio_request(gpio, "BUCK1_EN_B");
911         gpio_direction_output(gpio,
912                         (universal_lp3974_pdata.buck1_default_idx / 2) % 2);
913         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
914
915         gpio = S5PV310_GPX0(7);
916         gpio_request(gpio, "AP_PMIC_IRQ");
917         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
918         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
919
920         /* TO BE ENABLED LATER
921         regulator_has_full_constraints();
922         */
923 }
924
925 /* GPIO I2C 5 (PMIC) */
926 enum { I2C5_MAX8952, I2C5_LP3974 };
927 static struct i2c_board_info i2c5_devs[] __initdata = {
928         [I2C5_MAX8952] = {
929                 I2C_BOARD_INFO("max8952", 0xC0 >> 1),
930                 .platform_data  = &universal_max8952_pdata,
931         },
932         [I2C5_LP3974] = {
933                 I2C_BOARD_INFO("lp3974-regerr", 0xCC >> 1),
934                 .platform_data  = &universal_lp3974_pdata,
935         },
936 };
937
938 static void __init universal_sound_init(void)
939 {
940         int val;
941
942         /* Set PMU register to set CLK_OUT to use XUSBXTI
943          * as codec source clock */
944         val = 0x900;
945         __raw_writel(val, S5P_PMREG(0xA00));
946 }
947
948 /* GPIO I2C 6 */
949 static struct i2c_board_info i2c6_devs_rev00[] __initdata = {
950         {
951                 /* Audio Codec */
952                 I2C_BOARD_INFO("mc1n2", 0x3a),
953         },
954 };
955
956 static struct a1026_platform_data universal_a1026_pdata = {
957         .reset                  = S5PV310_GPL2(4),      /* XGNSS_GPIO_3 */
958         .wake_up                = S5PV310_GPL2(3),      /* XGNSS_GPIO_4 */
959         .i2c_clk                = S5PV310_GPC1(3),      /* XI2S2SDO - CODEC_SDA_1.8V */
960         .i2c_data               = S5PV310_GPC1(4),      /* XI2S2SDI - CODEC_SCL_1.8V */
961 };
962
963 static struct i2c_board_info i2c6_devs_rev02[] __initdata = {
964         {
965                 /* Audio Codec */
966                 I2C_BOARD_INFO("mc1n2", 0x3a),
967         }, {
968                 /* 2MIC NS */
969                 I2C_BOARD_INFO("a1026", 0x3e),
970                 .platform_data  = &universal_a1026_pdata,
971         },
972 };
973
974 static struct ak8975_platform_data universal_ak8975_data = {
975         .poll_interval = 100,
976 };
977
978 /* I2C7 */
979 static struct i2c_board_info i2c7_devs[] __initdata = {
980         {
981                 /* Compass */
982                 I2C_BOARD_INFO("ak8975", 0x0c),
983                 .platform_data  = &universal_ak8975_data,
984         },
985 };
986
987 static void __init universal_sensor_init(void)
988 {
989         int gpio;
990
991         gpio = S5PV310_GPE1(5); /* XMDMADDR_5 */
992         gpio_request(gpio, "MSENSE_INT");
993         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
994         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
995         i2c7_devs[0].irq = gpio_to_irq(gpio);
996
997         gpio = S5PV310_GPX0(0); /* XEINT_0 */
998         gpio_request(gpio, "GYRO_INT");
999         gpio_direction_input(gpio);
1000         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_DOWN);
1001
1002         gpio = S5PV310_GPX0(1); /* XEINT_1 */
1003         gpio_request(gpio, "GYRO_INT1");
1004         gpio_direction_input(gpio);
1005         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_DOWN);
1006
1007         gpio = S5PV310_GPX0(2); /* XEINT_2 */
1008         gpio_request(gpio, "PS/ALS_INT");
1009         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
1010         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
1011
1012         gpio = S5PV310_GPX2(4); /* XEINT_20 */
1013         gpio_request(gpio, "ACC_INT");
1014         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
1015         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_DOWN);
1016 }
1017
1018 /* I2C8: HDMI */
1019
1020 /* I2C9 */
1021 static struct i2c_gpio_platform_data i2c9_gpio_data = {
1022         .sda_pin                = S5PV310_GPY4(0),      /* XM0ADDR_8 */
1023         .scl_pin                = S5PV310_GPY4(1),      /* XM0ADDR_9 */
1024 };
1025
1026 static struct platform_device i2c9_gpio = {
1027         .name                   = "i2c-gpio",
1028         .id                     = 9,
1029         .dev                    = {
1030                 .platform_data  = &i2c9_gpio_data,
1031         },
1032 };
1033
1034 static struct max17040_platform_data universal_battery_platform_data = {
1035         .rcomp          = 0x9700,       /* 1500mAh */
1036 };
1037
1038 static struct i2c_board_info i2c9_devs[] __initdata = {
1039         {
1040                 I2C_BOARD_INFO("max17040", 0x36),
1041                 .platform_data  = &universal_battery_platform_data,
1042         },
1043 };
1044
1045 /* GPIO I2C 10 (Micro USB Switch) */
1046 static void fsa9480_cfg_gpio(void)
1047 {
1048         /* EINT24: JACK_nINT */
1049         s3c_gpio_cfgpin(S5PV310_GPX3(0), S3C_GPIO_SFN(0x0));
1050         gpio_request(S5PV310_GPX3(0), "JACK_nINT");
1051         s3c_gpio_setpull(S5PV310_GPX3(0), S3C_GPIO_PULL_NONE);
1052
1053         /* GPE2_4: TA_CURRENT_SEL */
1054         s3c_gpio_cfgpin(S5PV310_GPE2(4), S3C_GPIO_INPUT);
1055         gpio_request(S5PV310_GPE2(4), "TA_CURRENT_SEL");
1056         s3c_gpio_setpull(S5PV310_GPE2(4), S3C_GPIO_PULL_UP);
1057 }
1058
1059 static void universal_usb_cb(u8 attached);
1060 static void universal_charger_cb(u8 attached);
1061 static void universal_jig_cb(u8 attached);
1062 static void universal_fsa9480_reset_cb(void);
1063 static void universal_usb_power(u8 on);
1064
1065 static struct fsa9480_platform_data universal_fsa9480_platform_data = {
1066         .cfg_gpio               = fsa9480_cfg_gpio,
1067         .usb_cb                 = universal_usb_cb,
1068         .uart_cb                = NULL,
1069         .charger_cb             = universal_charger_cb,
1070         .jig_cb                 = universal_jig_cb,
1071         .reset_cb               = universal_fsa9480_reset_cb,
1072         .usb_power              = universal_usb_power,
1073         .wakeup                 = 1,
1074 };
1075
1076 static struct i2c_gpio_platform_data i2c10_gpio_data = {
1077         .sda_pin                = S5PV310_GPE1(0),      /* XMDMADDR_0 */
1078         .scl_pin                = S5PV310_GPE1(1),      /* XMDMADDR_1 */
1079 };
1080
1081 static struct platform_device i2c10_gpio = {
1082         .name                   = "i2c-gpio",
1083         .id                     = 10,
1084         .dev                    = {
1085                 .platform_data  = &i2c10_gpio_data,
1086         },
1087 };
1088
1089 static struct i2c_board_info i2c10_devs[] __initdata = {
1090         {
1091                 I2C_BOARD_INFO("fsa9480", 0x25),
1092                 .platform_data  = &universal_fsa9480_platform_data,
1093                 .irq            = IRQ_EINT(24),
1094         },
1095 };
1096
1097 /* GPIO I2C 12 (3 Touchkey) */
1098 #define TOUCHKEY_EN     S5PV310_GPE3(3)         /* XMDMDATA_3 */
1099 #define TOUCHKEY_INTR   S5PV310_GPE3(7)
1100 #define TOUCHKEY_SDA    S5PV310_GPE4(0)
1101 #define TOUCHKEY_SCL    S5PV310_GPE4(1)
1102
1103 static uint32_t touchkey_keymap[] = {
1104         /* MCS_KEY_MAP(value, keycode) */
1105 #ifdef ANDROID_KEYMAP
1106         MCS_KEY_MAP(0, KEY_MENU),               /* KEY_SEND */
1107         MCS_KEY_MAP(1, KEY_BACK),               /* KEY_END */
1108 #else
1109         MCS_KEY_MAP(0, KEY_PHONE),              /* KEY_SEND */
1110         /* KEY_BACK will be used */
1111         MCS_KEY_MAP(1, KEY_EXIT),               /* KEY_END */
1112 #endif
1113 };
1114
1115 static void touchkey_poweron(bool enable)
1116 {
1117         gpio_set_value(TOUCHKEY_EN, enable);
1118 }
1119
1120 static void touchkey_cfg_pin_fw(int use)
1121 {
1122         if (use == 1) {
1123                 s3c_gpio_cfgpin(TOUCHKEY_SDA, S3C_GPIO_OUTPUT);
1124                 s3c_gpio_cfgpin(TOUCHKEY_SCL, S3C_GPIO_OUTPUT);
1125                 s3c_gpio_cfgpin(TOUCHKEY_INTR, S3C_GPIO_OUTPUT);
1126
1127                 s3c_gpio_setpull(TOUCHKEY_SDA, S3C_GPIO_PULL_NONE);
1128                 s3c_gpio_setpull(TOUCHKEY_SCL, S3C_GPIO_PULL_NONE);
1129                 s3c_gpio_setpull(TOUCHKEY_INTR, S3C_GPIO_PULL_NONE);
1130
1131                 gpio_direction_output(TOUCHKEY_SDA, 0);
1132                 gpio_direction_output(TOUCHKEY_SCL, 0);
1133                 gpio_direction_output(TOUCHKEY_INTR, 0);
1134         } else {
1135                 s3c_gpio_setpull(TOUCHKEY_SDA, S3C_GPIO_PULL_UP);
1136                 s3c_gpio_setpull(TOUCHKEY_SCL, S3C_GPIO_PULL_UP);
1137                 s3c_gpio_setpull(TOUCHKEY_INTR, S3C_GPIO_PULL_UP);
1138
1139                 s3c_gpio_cfgpin(TOUCHKEY_SDA, S3C_GPIO_SFN(2));
1140                 s3c_gpio_cfgpin(TOUCHKEY_SCL, S3C_GPIO_SFN(2));
1141                 s3c_gpio_cfgpin(TOUCHKEY_INTR, S3C_GPIO_SFN(0xf));
1142         }
1143 }
1144
1145 static struct mcs_platform_data touchkey_data = {
1146         .poweron                = touchkey_poweron,
1147         .cfg_pin_fw             = touchkey_cfg_pin_fw,
1148         .fw_ver                 = 0x02,         /* MCS5080 Firnware Version */
1149         .md_ver                 = 0x01,         /* MCS5080 Module Version */
1150         .keymap                 = touchkey_keymap,
1151         .keymap_size            = ARRAY_SIZE(touchkey_keymap),
1152         .key_maxval             = 2,
1153 };
1154
1155 static struct i2c_gpio_platform_data i2c12_gpio_data = {
1156         .sda_pin                = S5PV310_GPE4(0),      /* XMDMDATA_8 */
1157         .scl_pin                = S5PV310_GPE4(1),      /* XMDMDATA_9 */
1158 };
1159
1160 static struct platform_device i2c12_gpio = {
1161         .name                   = "i2c-gpio",
1162         .id                     = 12,
1163         .dev                    = {
1164                 .platform_data  = &i2c12_gpio_data,
1165         },
1166 };
1167
1168 static struct i2c_board_info i2c12_devs[] __initdata = {
1169         {
1170                 I2C_BOARD_INFO("mcs5080_touchkey", 0x20),
1171                 .platform_data  = &touchkey_data,
1172         },
1173 };
1174
1175 static void __init universal_touchkey_init(void)
1176 {
1177         int gpio;
1178         int irq;
1179
1180         gpio = S5PV310_GPE3(7);                 /* XMDMDATA_7 */
1181         gpio_request(gpio, "3_TOUCH_INT");
1182         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
1183         irq = gpio_to_irq(gpio);
1184         i2c12_devs[0].irq = irq;
1185
1186         gpio = S5PV310_GPE3(3);                 /* XMDMDATA_3 */
1187         gpio_request(gpio, "3_TOUCH_EN");
1188         gpio_direction_output(gpio, 1);
1189         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
1190 }
1191
1192 static void tmd27711_control_power_source(int enable)
1193 {
1194         struct regulator *regulator = regulator_get(NULL, "ps_2.8v");
1195         static int disabled = 1;
1196
1197         if (IS_ERR_OR_NULL(regulator))
1198                 return;
1199
1200         if (enable) {
1201                 if (!disabled) {
1202                         regulator_disable(regulator);
1203                         disabled = 1;
1204                 }
1205                 regulator_enable(regulator);
1206                 disabled = 0;
1207         } else {
1208                 regulator_disable(regulator);
1209                 disabled = 1;
1210         }
1211
1212         regulator_put(regulator);
1213 }
1214
1215 static struct tmd27711_platform_data universal_tmd27711_data = {
1216         .control_power_source           = tmd27711_control_power_source,
1217         .power_on                       = TMD27711_PON,
1218         .wait_enable                    = TMD27711_WEN,
1219         .wait_time                      = 0xf2, /* 35.36 ms */
1220
1221         /* Proximity */
1222         .ps_enable                      = TMD27711_PEN,
1223         .ps_interrupt_h_thres           = 700,
1224         .ps_interrupt_l_thres           = 600,
1225         .ps_interrupt_enable            = TMD27711_PIEN,
1226         .ps_time                        = 0xff,
1227         .ps_interrupt_persistence       = 0x30,
1228         .ps_pulse_count                 = 0x08,
1229         .ps_drive_strength              = TMD27711_PDRIVE_12MA,
1230         .ps_diode                       = TMD27711_PDIODE_CH1_DIODE,
1231
1232         /* Ambient Light */
1233         .als_enable                     = TMD27711_AEN,
1234         .als_time                       = 200, /* 152.32 ms */
1235         .als_interrupt_persistence      = 1,
1236         .als_gain                       = TMD27711_AGAIN_16X,
1237 };
1238
1239 /* I2C14 */
1240 static struct i2c_gpio_platform_data i2c14_gpio_data = {
1241         .sda_pin                = S5PV310_GPK2(2),      /* XMMC2CDn */
1242         .scl_pin                = S5PV310_GPK3(2),      /* XMMC3CDn */
1243         .udelay                 = 1,                    /* 500kHz   */
1244 };
1245
1246 static struct platform_device i2c14_gpio = {
1247         .name                   = "i2c-gpio",
1248         .id                     = 14,
1249         .dev                    = {
1250                 .platform_data  = &i2c14_gpio_data,
1251         },
1252 };
1253
1254 static struct i2c_board_info i2c14_devs[] __initdata = {
1255         {
1256                 I2C_BOARD_INFO("TMD27711", 0x39),
1257                 .platform_data  = &universal_tmd27711_data,
1258                 .irq            = IRQ_EINT(2),
1259         },
1260 };
1261
1262 /* I2C15: NFC */
1263 #define GPIO_NFC_SCL_1_8V               S5PV310_GPY3(0)
1264 #define GPIO_NFC_SDA_1_8V               S5PV310_GPY3(2)
1265 #define GPIO_NFC_IRQ                    S5PV310_GPX1(7)
1266 #define GPIO_NFC_EN                             S5PV310_GPY3(7)
1267 #define GPIO_NFC_FIRMWARE               S5PV310_GPY4(4)
1268
1269 /* GPIO_LEVEL_NONE = 2, GPIO_LEVEL_LOW = 0 */
1270 static unsigned int nfc_gpio_table[][4] = {
1271         {GPIO_NFC_IRQ, S3C_GPIO_INPUT, 2, S3C_GPIO_PULL_DOWN},
1272         {GPIO_NFC_EN, S3C_GPIO_OUTPUT, 0, S3C_GPIO_PULL_NONE},
1273         {GPIO_NFC_FIRMWARE, S3C_GPIO_OUTPUT, 0, S3C_GPIO_PULL_NONE},
1274         {GPIO_NFC_SCL_1_8V, S3C_GPIO_INPUT, 2, S3C_GPIO_PULL_NONE},
1275         {GPIO_NFC_SDA_1_8V, S3C_GPIO_INPUT, 2, S3C_GPIO_PULL_NONE},
1276 };
1277
1278 void nfc_setup_gpio(void)
1279 {
1280         int array_size = ARRAY_SIZE(nfc_gpio_table);
1281         u32 i, gpio;
1282         for (i = 0; i < array_size; i++) {
1283                 gpio = nfc_gpio_table[i][0];
1284                 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(nfc_gpio_table[i][1]));
1285                 s3c_gpio_setpull(gpio, nfc_gpio_table[i][3]);
1286                 if (nfc_gpio_table[i][2] != 2)
1287                         gpio_set_value(gpio, nfc_gpio_table[i][2]);
1288         }
1289 }
1290
1291 static struct i2c_gpio_platform_data i2c15_gpio_data = {
1292         .sda_pin                = S5PV310_GPY3(2),      /* XM0ADDR_2 */
1293         .scl_pin                = S5PV310_GPY3(0),      /* XM0ADDR_0 */
1294         .udelay                 = 1,
1295 };
1296
1297 static struct platform_device i2c15_gpio = {
1298         .name                   = "i2c-gpio",
1299         .id                     = 15,
1300         .dev                    = {
1301                 .platform_data  = &i2c15_gpio_data,
1302         },
1303 };
1304
1305 /* I2C15 */
1306 static struct pn544_i2c_platform_data pn544_pdata = {
1307         .irq_gpio = GPIO_NFC_IRQ,
1308         .ven_gpio = GPIO_NFC_EN,
1309         .firm_gpio = GPIO_NFC_FIRMWARE,
1310 };
1311
1312 static struct i2c_board_info i2c15_devs[] __initdata = {
1313         {
1314                 I2C_BOARD_INFO("pn544", 0x2b),
1315                 .platform_data  = &pn544_pdata,
1316                 .irq            = IRQ_EINT(15),         /* NFC_IRQ */
1317         },
1318 };
1319
1320 /* GPIO KEYS */
1321 static struct gpio_keys_button universal_gpio_keys_tables[] = {
1322         {
1323                 .code                   = KEY_VOLUMEUP,
1324                 .gpio                   = S5PV310_GPX2(0),      /* XEINT16 */
1325                 .desc                   = "gpio-keys: KEY_VOLUMEUP",
1326                 .type                   = EV_KEY,
1327                 .active_low             = 1,
1328                 .debounce_interval      = 1,
1329         }, {
1330                 .code                   = KEY_VOLUMEDOWN,
1331                 .gpio                   = S5PV310_GPX2(1),      /* XEINT17 */
1332                 .desc                   = "gpio-keys: KEY_VOLUMEDOWN",
1333                 .type                   = EV_KEY,
1334                 .active_low             = 1,
1335                 .debounce_interval      = 1,
1336         }, {
1337                 .code                   = KEY_CONFIG,
1338                 .gpio                   = S5PV310_GPX2(2),      /* XEINT18 */
1339                 .desc                   = "gpio-keys: KEY_CONFIG",
1340                 .type                   = EV_KEY,
1341                 .active_low             = 1,
1342                 .debounce_interval      = 1,
1343         }, {
1344                 .code                   = KEY_CAMERA,
1345                 .gpio                   = S5PV310_GPX2(3),      /* XEINT19 */
1346                 .desc                   = "gpio-keys: KEY_CAMERA",
1347                 .type                   = EV_KEY,
1348                 .active_low             = 1,
1349                 .debounce_interval      = 1,
1350         }, {
1351                 .code                   = KEY_POWER,
1352                 .gpio                   = S5PV310_GPX2(7),      /* XEINT23 */
1353                 .desc                   = "gpio-keys: KEY_POWER",
1354                 .type                   = EV_KEY,
1355                 .active_low             = 1,
1356                 .wakeup                 = 1,
1357                 .debounce_interval      = 1,
1358         }, {
1359                                         /* KEY_MENU will be used */
1360                 .code                   = KEY_FRONT,            /* KEY_OK */
1361                 .gpio                   = S5PV310_GPX3(5),      /* XEINT29 */
1362                 .desc                   = "gpio-keys: KEY_MENU",
1363                 .type                   = EV_KEY,
1364                 .active_low             = 1,
1365                 .debounce_interval      = 1,
1366         },
1367 };
1368
1369 static struct gpio_keys_platform_data universal_gpio_keys_data = {
1370         .buttons                = universal_gpio_keys_tables,
1371         .nbuttons               = ARRAY_SIZE(universal_gpio_keys_tables),
1372 };
1373
1374 static struct platform_device universal_gpio_keys = {
1375         .name                   = "gpio-keys",
1376         .dev                    = {
1377                 .platform_data  = &universal_gpio_keys_data,
1378         },
1379 };
1380
1381 static unsigned int ld9040_lcd_enabled;
1382
1383 static struct s3cfb_lcd ld9040 = {
1384         .width = 480,
1385         .height = 800,
1386         .width_mm = 59,
1387         .height_mm = 98,
1388         .bpp = 24,
1389
1390         .freq = 60,
1391         .timing = {
1392                 .h_fp = 16,
1393                 .h_bp = 16,
1394                 .h_sw = 2,
1395                 .v_fp = 4,
1396                 .v_fpe = 1,
1397                 .v_bp = 6,
1398                 .v_bpe = 1,
1399                 .v_sw = 2,
1400         },
1401         .polarity = {
1402                 .rise_vclk = 1,
1403                 .inv_hsync = 1,
1404                 .inv_vsync = 1,
1405                 .inv_vden = 1,
1406         },
1407 };
1408
1409 static int lcd_cfg_gpio(void)
1410 {
1411         int i, f3_end = 4;
1412         u32 reg;
1413
1414         for (i = 0; i < 8; i++) {
1415                 /* set GPF0,1,2[0:7] for RGB Interface and Data lines (32bit) */
1416                 s3c_gpio_cfgpin(S5PV310_GPF0(i), S3C_GPIO_SFN(2));
1417                 s3c_gpio_setpull(S5PV310_GPF0(i), S3C_GPIO_PULL_NONE);
1418
1419         }
1420         for (i = 0; i < 8; i++) {
1421                 s3c_gpio_cfgpin(S5PV310_GPF1(i), S3C_GPIO_SFN(2));
1422                 s3c_gpio_setpull(S5PV310_GPF1(i), S3C_GPIO_PULL_NONE);
1423         }
1424
1425         for (i = 0; i < 8; i++) {
1426                 s3c_gpio_cfgpin(S5PV310_GPF2(i), S3C_GPIO_SFN(2));
1427                 s3c_gpio_setpull(S5PV310_GPF2(i), S3C_GPIO_PULL_NONE);
1428         }
1429
1430         for (i = 0; i < f3_end; i++) {
1431                 s3c_gpio_cfgpin(S5PV310_GPF3(i), S3C_GPIO_SFN(2));
1432                 s3c_gpio_setpull(S5PV310_GPF3(i), S3C_GPIO_PULL_NONE);
1433         }
1434
1435         /* Set FIMD0 bypass */
1436         reg = __raw_readl(S3C_VA_SYS + 0x0210);
1437         reg |= (1<<1);
1438         __raw_writel(reg, S3C_VA_SYS + 0x0210);
1439
1440         return 0;
1441 }
1442
1443 static int lcd_power_on(struct lcd_device *ld, int enable)
1444 {
1445         struct regulator *regulator;
1446
1447         if (ld == NULL) {
1448                 printk(KERN_ERR "lcd device object is NULL.\n");
1449                 return 0;
1450         }
1451
1452         if (enable) {
1453                 regulator = regulator_get(NULL, "vlcd_3.0v");
1454                 if (IS_ERR(regulator))
1455                         return 0;
1456                 regulator_enable(regulator);
1457                 regulator_put(regulator);
1458                 regulator = regulator_get(NULL, "vlcd_1.8v");
1459                 if (IS_ERR(regulator))
1460                         return 0;
1461                 regulator_enable(regulator);
1462                 regulator_put(regulator);
1463         } else {
1464                 regulator = regulator_get(NULL, "vlcd_1.8v");
1465                 if (IS_ERR(regulator))
1466                         return 0;
1467                 if (regulator_is_enabled(regulator))
1468                         regulator_force_disable(regulator);
1469                 regulator_put(regulator);
1470                 regulator = regulator_get(NULL, "vlcd_3.0v");
1471                 if (IS_ERR(regulator))
1472                         return 0;
1473                 if (regulator_is_enabled(regulator))
1474                         regulator_force_disable(regulator);
1475                 regulator_put(regulator);
1476         }
1477
1478         return 1;
1479 }
1480
1481 static int reset_lcd(struct lcd_device *ld)
1482 {
1483         static unsigned int first = 1;
1484         int reset_gpio = -1;
1485
1486         reset_gpio = S5PV310_GPY4(5);
1487
1488         if (first) {
1489                 gpio_request(reset_gpio, "MLCD_RST");
1490                 first = 0;
1491         }
1492
1493         mdelay(10);
1494         gpio_direction_output(reset_gpio, 0);
1495         mdelay(10);
1496         gpio_direction_output(reset_gpio, 1);
1497
1498         return 1;
1499 }
1500
1501 static void __init early_lcd(char **param)
1502 {
1503         (*param)++;
1504
1505         if (strncmp(*param, "ld9040", 6) == 0)
1506                 ld9040_lcd_enabled = 1;
1507 }
1508 __early_param("lcd", early_lcd);
1509
1510 static struct lcd_platform_data ld9040_platform_data = {
1511         .reset                  = reset_lcd,
1512         .power_on               = lcd_power_on,
1513         /* it indicates whether lcd panel is enabled from u-boot. */
1514         .lcd_enabled            = 1,
1515         .reset_delay            = 10,   /* 10ms */
1516         .power_on_delay         = 10,   /* 10ms */
1517         .power_off_delay        = 120,  /* 120ms */
1518 };
1519
1520 #define LCD_BUS_NUM     3
1521 #define DISPLAY_CS      S5PV310_GPY4(3)
1522 static struct spi_board_info spi_board_info[] __initdata = {
1523         {
1524                 .max_speed_hz   = 1200000,
1525                 .bus_num        = LCD_BUS_NUM,
1526                 .chip_select    = 0,
1527                 .mode           = SPI_MODE_3,
1528                 .controller_data = (void *)DISPLAY_CS,
1529         },
1530 };
1531
1532 #define DISPLAY_CLK     S5PV310_GPY3(1)
1533 #define DISPLAY_SI      S5PV310_GPY3(3)
1534 static struct spi_gpio_platform_data lcd_spi_gpio_data = {
1535         .sck                    = DISPLAY_CLK,
1536         .mosi                   = DISPLAY_SI,
1537         .miso                   = SPI_GPIO_NO_MISO,
1538         .num_chipselect         = 1,
1539 };
1540
1541 static struct platform_device universal_spi_gpio = {
1542         .name                   = "spi_gpio",
1543         .id                     = LCD_BUS_NUM,
1544         .dev                    = {
1545                 .parent         = &s3c_device_fb.dev,
1546                 .platform_data  = &lcd_spi_gpio_data,
1547         },
1548 };
1549
1550 #ifdef CONFIG_VIDEO_FIMG2D
1551 static struct fimg2d_platdata fimg2d_data __initdata = {
1552         .hw_ver                 = 30,
1553         .parent_clkname         = "mout_g2d0",
1554         .clkname                = "sclk_fimg2d",
1555         .gate_clkname           = "fimg2d",
1556         .smmu_gate_clkname      = "smmu_fimg2d",
1557         .clkrate                = 250 * 1000000,
1558 };
1559 #endif
1560
1561 static struct s3c_platform_fb fb_platform_data __initdata = {
1562         .hw_ver                 = 0x70,
1563         .clk_name               = "fimd",
1564         .nr_wins                = 5,
1565 #ifdef CONFIG_FB_S3C_DEFAULT_WINDOW
1566         .default_win            = CONFIG_FB_S3C_DEFAULT_WINDOW,
1567 #else
1568         .default_win            = 0,
1569 #endif
1570         .swap                   = FB_SWAP_HWORD | FB_SWAP_WORD,
1571 };
1572
1573 #ifdef CONFIG_FB_S3C
1574 static void __init universal_fb_init(void)
1575 {
1576         strcpy(spi_board_info[0].modalias, "ld9040");
1577
1578         /* workaround: because of early_lcd not working */
1579         ld9040_platform_data.lcd_enabled = 1;
1580         spi_board_info[0].platform_data =
1581                 (void *)&ld9040_platform_data;
1582
1583         spi_register_board_info(spi_board_info,
1584                 ARRAY_SIZE(spi_board_info));
1585
1586         fb_platform_data.lcd_data = (struct s3cfb_lcd *)&ld9040;
1587
1588         lcd_cfg_gpio();
1589         s3cfb_set_platdata(&fb_platform_data);
1590 }
1591 #endif
1592
1593 /*
1594  * CAMERA Fixed voltage regulators
1595  * The Source of regulators is V_BAT. And, the consumer name only specified in
1596  * the driver, was registered Fixed regulator.
1597  */
1598
1599 /* CIF(or VGA) attached at the front: S5K6AAFX */
1600 static struct regulator_consumer_supply supplies_cam_pwr_en2[] = {
1601         REGULATOR_SUPPLY("core", "0-003c"),
1602 };
1603
1604 /* MEGA attached at the back: M5MOLS */
1605 static struct regulator_consumer_supply supplies_8m_core_en[] = {
1606         REGULATOR_SUPPLY("core", "0-001f"),
1607 };
1608 static struct regulator_consumer_supply supplies_cam_pwr_en1[] = {
1609         REGULATOR_SUPPLY("d_sensor", "0-001f"),
1610 };
1611
1612 static struct regulator_init_data cam_fixreg_init_data[] = {
1613         [0] = {
1614                 .constraints = { .valid_ops_mask = REGULATOR_CHANGE_STATUS },
1615                 .num_consumer_supplies  = ARRAY_SIZE(supplies_cam_pwr_en2),
1616                 .consumer_supplies      = supplies_cam_pwr_en2,
1617         },
1618         [1] = {
1619                 .constraints = { .valid_ops_mask = REGULATOR_CHANGE_STATUS },
1620                 .num_consumer_supplies  = ARRAY_SIZE(supplies_8m_core_en),
1621                 .consumer_supplies      = supplies_8m_core_en,
1622         },
1623         [2] = {
1624                 .constraints = { .valid_ops_mask = REGULATOR_CHANGE_STATUS },
1625                 .num_consumer_supplies  = ARRAY_SIZE(supplies_cam_pwr_en1),
1626                 .consumer_supplies      = supplies_cam_pwr_en1,
1627         },
1628 };
1629
1630 static struct fixed_voltage_config cam_fixreg_cfg[] = {
1631         [0] = {
1632                 .supply_name    = "CAM_PWR_EN2",
1633                 .microvolts     = 2800000,
1634                 .gpio           = S5PV310_GPE2(1),
1635                 .enable_high    = 1,
1636                 .init_data      = &cam_fixreg_init_data[0],
1637         },
1638         [1] = {
1639                 .supply_name    = "CAM_8M_CORE_EN",
1640                 .microvolts     = 1200000,
1641                 .gpio           = S5PV310_GPE2(2),
1642                 .enable_high    = 1,
1643                 .init_data      = &cam_fixreg_init_data[1],
1644         },
1645         [2] = {
1646                 .supply_name    = "CAM_PWR_EN1",
1647                 .microvolts     = 1800000,
1648                 .gpio           = S5PV310_GPE3(0),
1649                 .enable_high    = 1,
1650                 .init_data      = &cam_fixreg_init_data[2],
1651         },
1652 };
1653
1654 static struct platform_device camera_fixed_reg_dev[] = {
1655         {
1656                 .name = "reg-fixed-voltage", .id = 1,
1657                 .dev = { .platform_data = &cam_fixreg_cfg[0] },
1658         }, {
1659                 .name = "reg-fixed-voltage", .id = 2,
1660                 .dev = { .platform_data = &cam_fixreg_cfg[1] },
1661         }, {
1662                 .name = "reg-fixed-voltage", .id = 3,
1663                 .dev = { .platform_data = &cam_fixreg_cfg[2] },
1664         },
1665 };
1666
1667 static struct s5p_platform_mipi_csis mipi_csis0_pldata = {
1668         .clk_rate       = 166000000UL,
1669         .lanes          = 2,
1670         .alignment      = 32,
1671         .hs_settle      = 12,
1672         .phy_enable     = s5p_csis_phy_enable,
1673 };
1674
1675 static int s5k6aafx_additional_set_power(struct device *dev, int on)
1676 {
1677         int gpio_i2c;
1678
1679         gpio_i2c = MOBILE_GPIO(CAM_LEVEL_EN2);
1680
1681         if (on)
1682                 gpio_set_value(gpio_i2c, 1);
1683         else
1684                 gpio_set_value(gpio_i2c, 0);
1685
1686         return 0;
1687 }
1688
1689 static struct s5k6aafx_platform_data s5k6aafx_pldata = {
1690         .set_power      = s5k6aafx_additional_set_power,
1691         .clk_rate       = 16000000UL,
1692         .gpio_nreset    = -EINVAL,
1693         .gpio_nstby     = -EINVAL,
1694 };
1695
1696 static struct i2c_board_info s5k6aafx_board_info = {
1697         I2C_BOARD_INFO("S5K6AAFX", 0x3C),
1698         .platform_data = &s5k6aafx_pldata,
1699 };
1700
1701 static int m5mols_additional_set_power(struct device *dev, int on)
1702 {
1703         /*
1704          * The M5MOLS's main power on/off are controlled inside the driver.
1705          * But, the pin setting I2C level-shiftter on/off, and additional pins
1706          * (n-reset, mclk for M5MOLS) is a board specific side. So, in this
1707          * function, the 2 kinds of pins are controlled.
1708          */
1709         int gpio_i2c, gpio_opt;
1710
1711         gpio_opt = MOBILE_GPIO(CAM_LEVEL_EN1);  /* Negative Enable */
1712         gpio_i2c = MOBILE_GPIO(CAM_LEVEL_EN2);
1713
1714         if (on) {
1715                 gpio_set_value(gpio_opt, 0);
1716                 gpio_set_value(gpio_i2c, 1);
1717         } else {
1718                 gpio_set_value(gpio_opt, 1);
1719                 gpio_set_value(gpio_i2c, 0);
1720         }
1721
1722         return 0;
1723 }
1724
1725 static struct m5mols_platform_data m5mols_platdata = {
1726         .set_power      = m5mols_additional_set_power,
1727         .gpio_rst       = -EINVAL,
1728         .rst_polarity   = true,         /* positive reset */
1729 };
1730
1731 static struct i2c_board_info m5mols_board_info = {
1732         I2C_BOARD_INFO("M5MOLS", 0x1F),
1733         .platform_data = &m5mols_platdata,
1734 };
1735
1736 static struct s5p_fimc_isp_info universal_vga_cam_sensor = {
1737         .mux_id         = 0,
1738         .flags          = FIMC_CLK_INV_PCLK | FIMC_CLK_INV_VSYNC,
1739         .bus_type       = FIMC_ITU_601,
1740         .board_info     = &s5k6aafx_board_info,
1741         .clk_frequency  = 24000000UL,
1742         .i2c_bus_num    = 0,
1743 };
1744
1745 static struct s5p_fimc_isp_info universal_8m_cam_sensor = {
1746         .mux_id         = 0,
1747         .flags          = FIMC_CLK_INV_PCLK | FIMC_CLK_INV_VSYNC,
1748         .bus_type       = FIMC_MIPI_CSI2,
1749         .board_info     = &m5mols_board_info,
1750         .clk_frequency  = 24000000UL,
1751         .i2c_bus_num    = 0,
1752         .csi_data_align = 32,
1753 };
1754
1755 static struct s5p_fimc_isp_info *universal_camera_sensors[] = {
1756        &universal_vga_cam_sensor,
1757        &universal_8m_cam_sensor,
1758 };
1759
1760 static struct s5p_platform_fimc universal_fimc_plat_data[] = {
1761         [0] = { /* FIMC0 */
1762                 .isp_info       = universal_camera_sensors,
1763                 .num_clients    = ARRAY_SIZE(universal_camera_sensors),
1764         },
1765 };
1766
1767 int __init s5pv310_fimc_setup_clks(void)
1768 {
1769         int err = 0;
1770         int i;
1771         struct clk *clock, *parent;
1772
1773         struct device *fimc_devs[] = {
1774                 &s5p_device_fimc0.dev,
1775                 &s5p_device_fimc1.dev,
1776                 &s5p_device_fimc2.dev,
1777                 &s5p_device_fimc3.dev
1778         };
1779
1780         parent = clk_get(NULL, "mout_epll");
1781         if (IS_ERR(parent))
1782                 return PTR_ERR(parent);
1783
1784         for (i = 0; err == 0 && i < ARRAY_SIZE(fimc_devs); i++) {
1785                 if (fimc_devs[i]) {
1786                         clock = clk_get(fimc_devs[i], "sclk_fimc");
1787                         if (IS_ERR(clock)) {
1788                                 err = PTR_ERR(clock);
1789                                 printk(KERN_ERR"couldn't get sclk_fimc.%d\n", i);
1790                                 break;
1791                         }
1792                         clk_set_parent(clock, parent);
1793                         clk_put(clock);
1794                 }
1795         }
1796         clk_put(parent);
1797
1798         if (err)
1799                 goto clk_err;
1800
1801         /* Set parent clock of the MIPI-CSIS interfaces */
1802         parent = clk_get(NULL, "mout_mpll");
1803         if (IS_ERR(parent)) {
1804                 err = PTR_ERR(parent);
1805                 printk(KERN_ERR "failed to get clock mout_mpll\n");
1806                 goto clk_err;
1807         }
1808
1809         clock = clk_get(&s5p_device_mipi_csis0.dev, "sclk_csis");
1810         if (IS_ERR(clock))
1811                 err = PTR_ERR(clock);
1812         else
1813                 clk_set_parent(clock, parent);
1814         clk_put(parent);
1815
1816         if (err) {
1817                 printk(KERN_ERR "failed to get clock sclk_csis.0\n");
1818                 goto clk_err;
1819         }
1820
1821         /* Set parent clock of FIMC external clock for image processors */
1822         parent = clk_get(NULL, "sclk_vpll");
1823         if (IS_ERR(parent)) {
1824                 printk(KERN_ERR "failed to get clock sclk_vpll\n");
1825                 err = PTR_ERR(parent);
1826                 goto clk_err;
1827         }
1828
1829         clock = clk_get(fimc_devs[0], "sclk_cam");
1830         if (IS_ERR(clock)) {
1831                 printk(KERN_ERR "failed to get clock sclk_cam.0\n");
1832                 clk_put(parent);
1833                 err = PTR_ERR(clock);
1834                 goto clk_err;
1835         }
1836
1837         clk_set_parent(clock, parent);
1838         clk_put(parent);
1839
1840         clk_disable(clock);
1841         clk_put(clock);
1842
1843 clk_err:
1844         printk("%s%s: %s\n", err ? "WARNING! " : "", __func__,
1845                err ? "failed!" : "succedded.");
1846
1847         return err;
1848 }
1849
1850 #define cfg_camif_pin(pin) do {                  \
1851         s3c_gpio_cfgpin(pin, S3C_GPIO_SFN(2));   \
1852         s3c_gpio_setpull(pin, S3C_GPIO_PULL_UP); \
1853 } while(0)
1854
1855 static void universal_camera_init(void)
1856 {
1857         int gpio;
1858         int i;
1859
1860         /* Configuration Camera0(camA) pin for unviersal */
1861         for (i = 0; i < 8; i++)
1862                 cfg_camif_pin(S5PV310_GPJ0(i));
1863         for (i = 0; i < 5; i++)
1864                 cfg_camif_pin(S5PV310_GPJ1(i));
1865
1866         /* Assign gpios for the sensor drivers */
1867         s5k6aafx_pldata.gpio_nreset     = MOBILE_GPIO(CAM_VGA_NRST);
1868         s5k6aafx_pldata.gpio_nstby      = MOBILE_GPIO(CAM_VGA_NSTBY);
1869
1870         m5mols_platdata.gpio_rst        = MOBILE_GPIO(CAM_MEGA_NRST);
1871
1872         /* Camera fixed voltage regulators */
1873         for (i = 0; i < ARRAY_SIZE(camera_fixed_reg_dev); i++)
1874                 platform_device_register(&camera_fixed_reg_dev[i]);
1875
1876         /* set pin to default state, for dual camera issue */
1877         gpio = MOBILE_GPIO(CAM_MEGA_NRST);
1878         gpio_set_value(gpio, 0);
1879         gpio = MOBILE_GPIO(CAM_VGA_NRST);
1880         gpio_set_value(gpio, 0);
1881         gpio = MOBILE_GPIO(CAM_VGA_NSTBY);
1882         gpio_set_value(gpio, 0);
1883 }
1884
1885 /* Modem control */
1886 static struct modemctl_platform_data universal_modemctl_data __initdata = {
1887         .name                   = "xmm6260",
1888         .wakeup                 = 1,
1889 };
1890
1891 static struct platform_device universal_modemctl __initdata = {
1892         .name                   = "modemctl",
1893         .id                     = -1,
1894         .dev                    = {
1895                 .platform_data  = &universal_modemctl_data,
1896         },
1897 };
1898
1899 /* eMMC */
1900 static struct s3c_sdhci_platdata universal_hsmmc0_data __initdata = {
1901         .max_width              = 8,
1902         .host_caps              = (MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA |
1903                            MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
1904                            MMC_CAP_DISABLE),
1905         .cd_type                = S3C_SDHCI_CD_PERMANENT,
1906         .clk_type               = S3C_SDHCI_CLK_DIV_EXTERNAL,
1907 };
1908
1909 static struct regulator_consumer_supply mmc0_supplies[] = {
1910         REGULATOR_SUPPLY("vmmc", "s3c-sdhci.0"),
1911 };
1912
1913 static struct regulator_init_data mmc0_fixed_voltage_init_data = {
1914         .constraints            = {
1915                 .name           = "VMEM_VDD_2.8V",
1916                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
1917         },
1918         .num_consumer_supplies  = ARRAY_SIZE(mmc0_supplies),
1919         .consumer_supplies      = mmc0_supplies,
1920 };
1921
1922 static struct fixed_voltage_config mmc0_fixed_voltage_config = {
1923         .supply_name            = "MASSMEMORY_EN",
1924         .microvolts             = 2800000,
1925         .gpio                   = S5PV310_GPE1(3),
1926         .enable_high            = true,
1927         .init_data              = &mmc0_fixed_voltage_init_data,
1928 };
1929
1930 static struct platform_device mmc0_fixed_voltage = {
1931         .name                   = "reg-fixed-voltage",
1932         .id                     = 0,
1933         .dev                    = {
1934                 .platform_data  = &mmc0_fixed_voltage_config,
1935         },
1936 };
1937
1938 /* SD */
1939 static struct s3c_sdhci_platdata universal_hsmmc2_data __initdata = {
1940         .max_width              = 4,
1941         .host_caps              = MMC_CAP_4_BIT_DATA |
1942                                 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
1943                                 MMC_CAP_DISABLE,
1944         .ext_cd_gpio            = S5PV310_GPX3(4),      /* XEINT_28 */
1945         .ext_cd_gpio_invert     = 1,
1946         .cd_type                = S3C_SDHCI_CD_GPIO,
1947         .clk_type               = S3C_SDHCI_CLK_DIV_EXTERNAL,
1948 };
1949
1950 /* WLAN */
1951 static void (*wlan_notify_change_cb)(struct platform_device *dev, int state);
1952
1953 static int wlan_ext_cd_init(void (*cb)(struct platform_device *dev, int state))
1954 {
1955         wlan_notify_change_cb = cb;
1956         return 0;
1957 }
1958
1959 static int wlan_ext_cd_cleanup(void (*cb)(struct platform_device *dev, int state))
1960 {
1961         wlan_notify_change_cb = NULL;
1962         return 0;
1963 }
1964
1965 static int universal_wlan_host_enable(int on)
1966 {
1967         if (wlan_notify_change_cb)
1968                 (*wlan_notify_change_cb)(&s3c_device_hsmmc3, on);
1969         return 0;
1970 }
1971
1972 static struct s3c_sdhci_platdata universal_hsmmc3_data __initdata = {
1973         .max_width              = 4,
1974         .host_caps              = (MMC_CAP_4_BIT_DATA |
1975                            MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
1976                            MMC_CAP_DISABLE),
1977         .cd_type                = S3C_SDHCI_CD_EXTERNAL,
1978         .ext_cd_init            = &wlan_ext_cd_init,
1979         .ext_cd_cleanup         = &wlan_ext_cd_cleanup,
1980         .clk_type               = S3C_SDHCI_CLK_DIV_EXTERNAL,
1981 };
1982
1983 static void __init universal_sdhci_init(void)
1984 {
1985         unsigned int gpio;
1986
1987         gpio = S5PV310_GPX3(4); /* T-Flash Detect */
1988         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
1989         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
1990
1991         s3c_sdhci0_set_platdata(&universal_hsmmc0_data);
1992         s3c_sdhci2_set_platdata(&universal_hsmmc2_data);
1993         s3c_sdhci3_set_platdata(&universal_hsmmc3_data);
1994 }
1995
1996 /* BCM4330 */
1997 static struct bcm4330_platform_data bcm4330_data = {
1998         .wlan_en                = S5PV310_GPE3(1),
1999         .wlan_host_wake         = S5PV310_GPX2(5),
2000         .bt_en                  = S5PV310_GPE1(2),
2001         .bt_nrst                = S5PV310_GPE1(4),
2002         .bt_host_wake           = S5PV310_GPX2(6),
2003         .bt_wake                = S5PV310_GPX3(1),
2004         .bt_uart[0]             = S5PV310_GPA0(0),      /* XuRXD[0]     */
2005         .bt_uart[1]             = S5PV310_GPA0(1),      /* XuTXD[0]     */
2006         .bt_uart[2]             = S5PV310_GPA0(2),      /* XuCTSn[0]    */
2007         .bt_uart[3]             = S5PV310_GPA0(3),      /* XuRTSn[0]    */
2008         .wlan_host_enable       = &universal_wlan_host_enable,
2009 };
2010
2011 static struct platform_device universal_bcm4330 = {
2012         .name                   = "bcm4330",
2013         .id                     = -1,
2014         .dev                    = {
2015                 .platform_data  = &bcm4330_data,
2016         },
2017 };
2018
2019  /* Jack */
2020 static struct jack_platform_data universal_jack_data = {
2021         .usb_online             = 0,
2022         .charger_online         = 0,
2023         .hdmi_online            = -1,
2024         .earjack_online         = 0,
2025         .earkey_online          = -1,
2026         .ums_online             = -1,
2027         .cdrom_online           = -1,
2028         .jig_online             = 0,
2029 };
2030
2031 static void universal_vbus_enable(int on, char *name)
2032 {
2033         struct regulator *regulator;
2034
2035         regulator = regulator_get(NULL, name);
2036         if (IS_ERR(regulator))
2037                 return;
2038
2039         if (on)
2040                 regulator_enable(regulator);
2041         else
2042                 regulator_force_disable(regulator);
2043
2044         regulator_put(regulator);
2045 }
2046
2047 static void universal_usb_path_power(int on, int path)
2048 {
2049         if (path == USB_PATH_AP)
2050                 universal_vbus_enable(on, "usb_vbus_ap_5v");
2051         else if (path == USB_PATH_CP)
2052                 universal_vbus_enable(on, "usb_vbus_cp_5v");
2053         else {
2054                 universal_vbus_enable(0, "usb_vbus_ap_5v");
2055                 universal_vbus_enable(0, "usb_vbus_cp_5v");
2056         }
2057 }
2058
2059 static int universal_get_usb_switch(void);
2060
2061 static void universal_usb_power(u8 on)
2062 {
2063         universal_usb_path_power(on, universal_get_usb_switch());
2064 }
2065
2066 #ifdef CONFIG_REGULATOR
2067 static struct regulator *reg_charger;
2068 #endif
2069 static void universal_usb_cb(u8 attached)
2070 {
2071 #ifdef CONFIG_JACK_MON
2072         jack_event_handler("usb", attached);
2073 #endif
2074         universal_usb_power(attached);
2075 #ifdef CONFIG_REGULATOR
2076         if (reg_charger == NULL) {
2077                 reg_charger = regulator_get(NULL, "vinchg");
2078                 if (IS_ERR_OR_NULL(reg_charger)) {
2079                         pr_err("Cannot get regulator: vinchg (%ld)\n",
2080                                         PTR_ERR(reg_charger));
2081                         reg_charger = NULL;
2082                 }
2083         }
2084
2085         /* set 475mA MAX */
2086         if (reg_charger && attached)
2087                 regulator_set_current_limit(reg_charger, 200000, 475000);
2088 #endif
2089 }
2090
2091 static void universal_charger_cb(u8 attached)
2092 {
2093 #ifdef CONFIG_JACK_MON
2094         jack_event_handler("charger", attached);
2095 #endif
2096 #ifdef CONFIG_REGULATOR
2097         if (reg_charger == NULL) {
2098                 reg_charger = regulator_get(NULL, "vinchg");
2099                 if (IS_ERR_OR_NULL(reg_charger)) {
2100                         pr_err("Cannot get regulator: vinchg (%ld)\n",
2101                                         PTR_ERR(reg_charger));
2102                         reg_charger = NULL;
2103                 }
2104         }
2105
2106         /* set 600mA MAX */
2107         if (reg_charger && attached)
2108                 regulator_set_current_limit(reg_charger, 200000, 600000);
2109 #endif
2110 }
2111
2112 static void universal_jig_cb(u8 attached)
2113 {
2114 #ifdef CONFIG_JACK_MON
2115         jack_event_handler("jig", attached);
2116 #endif
2117 }
2118
2119 static void universal_fsa9480_reset_cb(void)
2120 {
2121 #ifdef CONFIG_JACK_MON
2122         jack_event_handler("", 0);
2123 #endif
2124 }
2125
2126 static struct platform_device universal_jack = {
2127         .name                   = "jack",
2128         .id                     = -1,
2129         .dev                    = {
2130                 .platform_data  = &universal_jack_data,
2131         },
2132 };
2133
2134 static void universal_set_usb_switch(int path)
2135 {
2136         if (path == USB_PATH_AP)
2137                 fsa9480_set_switch("DHOST");
2138         else if (path == USB_PATH_CP)
2139                 fsa9480_set_switch("AUDIO");
2140 }
2141
2142 static int universal_get_usb_switch(void)
2143 {
2144         char buf[16];
2145
2146         fsa9480_get_switch(buf);
2147
2148         if (!strncmp(buf, "AUDIO", 5))
2149                 return USB_PATH_CP;
2150         else if (!strncmp(buf, "DHOST", 5))
2151                 return USB_PATH_AP;
2152         else if (!strncmp(buf, "AUTO", 4))
2153                 return USB_PATH_AP;
2154
2155         return USB_PATH_NA;
2156 }
2157
2158 /* Micro USB Switch */
2159 static struct micro_usb_switch_platform_data universal_usb_switch_data = {
2160         .usb_power              = universal_usb_path_power,
2161         .set_usb_switch         = universal_set_usb_switch,
2162         .get_usb_switch         = universal_get_usb_switch,
2163 };
2164
2165 static struct platform_device universal_micro_usb_switch = {
2166         .name                   = "usb-switch",
2167         .id                     = -1,
2168         .dev                    = {
2169                 .platform_data  = &universal_usb_switch_data,
2170         },
2171 };
2172
2173 /* Uart Select */
2174 static struct uart_select_platform_data universal_uart_select_data = {
2175         .gpio                   = S5PV310_GPY4(7),
2176         .cpu_on_low             = CP,
2177         .cpu_by_default         = AP,
2178 };
2179
2180 static struct platform_device universal_uart_select = {
2181         .name                   = "uart-select",
2182         .id                     = -1,
2183         .dev                    = {
2184                 .platform_data  = &universal_uart_select_data,
2185         },
2186 };
2187
2188 /* BCM4751 GPS */
2189 static struct bcm4751_platform_data universal_bcm4751_data = {
2190         .regpu                  = S5PV310_GPE0(3),      /* XMDMIRQn */
2191         .nrst                   = S5PV310_GPE0(4),      /* XMDMADVN */
2192         .uart_rxd               = S5PV310_GPA0(4),      /* XURXD[1] */
2193 };
2194
2195 static struct platform_device universal_bcm4751 = {
2196         .name                   = "bcm4751",
2197         .id                     = -1,
2198         .dev                    = {
2199                 .platform_data  = &universal_bcm4751_data,
2200         },
2201 };
2202
2203 /* MALI DRM. */
2204 #ifdef CONFIG_DRM_MALI
2205 static struct platform_device s5p_device_mali_drm = {
2206         .name                   = "mali_drm",
2207         .id                     = -1,
2208 };
2209 #endif
2210
2211 /* FIMD DRM. */
2212 #ifdef CONFIG_DRM_FIMD
2213 static struct resource fimd_drm_resource[] = {
2214         [0] = {
2215                 .start  = S5P_PA_LCD0,
2216                 .end    = S5P_PA_LCD0 + S5P_SZ_LCD0 - 1,
2217                 .flags  = IORESOURCE_MEM,
2218         },
2219         [1] = {
2220                 .start  = S5P_PA_LCD1,
2221                 .end    = S5P_PA_LCD1 + S5P_SZ_LCD1 - 1,
2222                 .flags  = IORESOURCE_MEM,
2223         },
2224         [2] = {
2225                 .start  = IRQ_LCD1,
2226                 .end    = IRQ_LCD1,
2227                 .flags  = IORESOURCE_IRQ,
2228         },
2229         [3] = {
2230                 .start  = IRQ_LCD0,
2231                 .end    = IRQ_LCD0,
2232                 .flags  = IORESOURCE_IRQ,
2233         },
2234 };
2235
2236 static struct fimd_drm_platform_data fimd_drm_pd = {
2237         .hw_ver = 0x70,
2238 };
2239
2240 static struct platform_device s5p_device_fimd_drm = {
2241         .name                   = "fimd_drm",
2242         .id                     = -1,
2243         .num_resources          = ARRAY_SIZE(fimd_drm_resource),
2244         .resource               = fimd_drm_resource,
2245         .dev                    = {
2246                 .platform_data = &fimd_drm_pd,
2247         },
2248 };
2249 #endif
2250
2251 /* ADC */
2252 static struct s3c_adc_platform_data s3c_adc_pdata __initdata = {
2253         .delay                  = 1000,
2254         .presc                  = 49,
2255         .resolution             = 12,
2256         .max_adc_voltage_uV     = 3300000,
2257 };
2258
2259 static void __init universal_adc_init(void)
2260 {
2261         s3c_adc_set_platdata(&s3c_adc_pdata);
2262 }
2263
2264 static void ramoops_enable(int enable)
2265 {
2266         struct clk *clk;
2267
2268         clk = clk_get(NULL, "modem");
2269         if (enable)
2270                 clk_enable(clk);
2271         else
2272                 clk_disable(clk);
2273         clk_put(clk);
2274 }
2275
2276 static struct ramoops_platform_data universal_ramoops_data = {
2277         .mem_address            = 0x13A00000,           /* MODEM I/F */
2278         .mem_size               = SZ_16K,
2279         .enable                 = ramoops_enable,
2280 };
2281
2282 static struct platform_device universal_ramoops = {
2283         .name                   = "ramoops",
2284         .dev                    = {
2285                 .platform_data  = &universal_ramoops_data,
2286         },
2287 };
2288
2289 static struct mmcoops_platform_data universal_mmcoops_data = {
2290         .pdev                   = &s3c_device_hsmmc0,
2291         .start                  = 64,                   /* 32KiB offset */
2292         .size                   = 16,                   /* 8KiB */
2293 };
2294
2295 static struct platform_device universal_mmcoops = {
2296         .name                   = "mmcoops",
2297         .dev                    = {
2298                 .platform_data  = &universal_mmcoops_data,
2299         },
2300 };
2301
2302 #ifdef CONFIG_LCD_OOPS
2303 /* workaround. */
2304 static struct platform_device universal_lcdoops = {
2305         .name                   = "lcdoops",
2306         .dev                    = {
2307                 .platform_data  = NULL,
2308         },
2309 };
2310 #endif
2311
2312 #ifdef CONFIG_ANDROID_RAM_CONSOLE
2313 static struct resource ram_console_resource[] = {
2314         [0] = {
2315                 .flags = IORESOURCE_MEM,
2316         },
2317 };
2318
2319 static struct platform_device ram_console_device = {
2320         .name                   = "ram_console",
2321         .id                     = -1,
2322         .num_resources          = ARRAY_SIZE(ram_console_resource),
2323         .resource               = ram_console_resource,
2324 };
2325 #endif
2326
2327 #ifdef CONFIG_SENSORS_NTC_THERMISTOR
2328 static unsigned int read_thermistor_uV(void)
2329 {
2330         struct s3c_adc_request req = {
2331                 .list           = NULL,
2332                 .callback       = NULL,
2333                 .param          = 0,
2334                 .channel        = 6, /* XADCAIN_6 */
2335         };
2336
2337         return s3c_adc_convert_uV(s3c_adc_get(&req));
2338 }
2339
2340 static struct ntc_thermistor_platform_data ncp15wb473_pdata = {
2341         .read_uV        = read_thermistor_uV,
2342         .pullup_uV      = 3300000, /* VADC_3.3V_C210 */
2343         .pullup_ohm     = 100000, /* R817 in Aquila Rev 1.9 */
2344         .pulldown_ohm   = 100000, /* R818 in Aquila Rev 1.9 */
2345         .connect        = NTC_CONNECTED_GROUND,
2346 };
2347
2348 static struct platform_device universal_ncp15wb473_thermistor = {
2349         .name                   = "ncp15wb473",
2350         .dev                    = {
2351                 .platform_data = &ncp15wb473_pdata,
2352         },
2353 };
2354
2355 #ifdef CONFIG_S5P_CHARGER_BREAKER
2356 static const char *s5p_charger_supplies[] = {"vinchg"};
2357
2358 static struct s5p_charger_breaker_pdata charger_breaker_pdata = {
2359         .supplies               = s5p_charger_supplies,
2360         .num_supplies           = ARRAY_SIZE(s5p_charger_supplies),
2361
2362         .thermistor             = &universal_ncp15wb473_thermistor.dev,
2363         .thermistor_sensor_id   = 1,
2364
2365         .setup_for_pm_loop      = true,
2366
2367         .interval_ms            = 30000,
2368         .too_hot                = 65,
2369         .hot                    = 60,
2370         .too_cold               = -5,
2371         .cold                   = 0,
2372         .number_of_measure      = 7,
2373         .discard_extreme        = true,
2374 };
2375
2376 static struct platform_device universal_charger_breaker = {
2377         .name                   = "s5p-charger-breaker",
2378         .id                     = -1,
2379         .dev                    = {
2380                 .platform_data  = &charger_breaker_pdata,
2381         },
2382 };
2383
2384 #ifdef CONFIG_S5P_CHARGER
2385 static bool universal_config_s5p_charger;
2386 extern bool ntc_monitor_pm_loop(bool*);
2387
2388 static char *regulators4charger[] = {
2389         "vadc",
2390 };
2391
2392 static char *s5p_charger_controls[] = {
2393         "max8997_pmic", "max8903_charger" };
2394
2395 static struct s5p_charger_pdata s5p_charger_pdata = {
2396         .wakeup_interval_charging       = 30000,
2397         .fullbatt_voltage_ck_delay      = 30000,
2398         .fullbatt_voltage_ck_uV         = 100000,
2399         .fuel_gauge                     = "max17040_battery",
2400         .th_cap                         = {1, 3, 5},
2401         .th_uV                          = {3700000, 3800000, 3900000},
2402         .battery_control                = s5p_charger_controls,
2403         .num_battery_control            = ARRAY_SIZE(s5p_charger_controls),
2404         .battery_charger                = s5p_charger_supplies,
2405         .num_battery_charger            = ARRAY_SIZE(s5p_charger_supplies),
2406         .rtc_name                       = "rtc1", /* s3c-rtc with tick */
2407         .pm_loop_func                   = ntc_monitor_pm_loop,
2408         .num_regulators_for_charger     = ARRAY_SIZE(regulators4charger),
2409         .regulators_for_charger         = regulators4charger,
2410         .irq_battery_full               = IRQ_PMIC_BASE + MAX8998_IRQ_DONER,
2411         .irq_battery_out                = IRQ_PMIC_BASE + MAX8998_STATUS_DETBAT,
2412
2413         /* Ignore capacity if it's below 10% and the voltage is over 4.2V */
2414         .full_battery_voltage_uV        = 4200000,
2415         .override_capacity_ovp          = 10,
2416 };
2417
2418 static struct platform_device s5p_charger = {
2419         .name   = "s5p-charger",
2420         .id     = -1,
2421         .dev    = {
2422                 .platform_data = &s5p_charger_pdata,
2423         },
2424 };
2425
2426 static int __init s5p_charger_init(void)
2427 {
2428         if (universal_config_s5p_charger) {
2429                 platform_device_register(&s5p_charger);
2430                 platform_device_register(&universal_charger_breaker);
2431         }
2432         return 0;
2433 }
2434 /* s5p charger depends on other devices. register later */
2435 late_initcall(s5p_charger_init);
2436 #endif
2437 #endif /* CONFIG_S5P_CHARGER_BREAKER */
2438 #endif /* CONFIG_SENSORS_NTC_THERMISTOR */
2439
2440 static struct platform_device *universal_devices[] __initdata = {
2441 #ifdef CONFIG_FIQ_DEBUGGER
2442         &s5pv310_device_fiqdbg_uart2,
2443 #endif
2444         /* Samsung Platform Devices */
2445 #ifdef CONFIG_S5PV310_DEV_PD
2446         &s5pv310_device_pd[PD_MFC],
2447         &s5pv310_device_pd[PD_G3D],
2448         &s5pv310_device_pd[PD_LCD0],
2449         &s5pv310_device_pd[PD_LCD1],
2450         &s5pv310_device_pd[PD_TV],
2451         &s5pv310_device_pd[PD_CAM],
2452         &s5pv310_device_pd[PD_GPS],
2453 #endif
2454 #ifdef CONFIG_DRM_MALI
2455         &s5p_device_mali_drm,
2456 #endif
2457 #ifdef CONFIG_DRM_FIMD
2458         &s5p_device_fimd_drm,
2459 #endif
2460         &universal_gpio_keys,
2461         &s5p_device_onenand,
2462         &s3c_device_i2c0,
2463         &s3c_device_i2c1,
2464         &s3c_device_i2c3,
2465         &s3c_device_i2c4,
2466         &s3c_device_i2c5,
2467         &s3c_device_i2c6,
2468         &s3c_device_i2c7,
2469         &s3c_device_i2c8,
2470         &i2c9_gpio,
2471         &i2c10_gpio,
2472         &i2c12_gpio,
2473         &i2c14_gpio,
2474         /* Universal Devices */
2475         &universal_bcm4330,
2476         &universal_bcm4751,
2477         &universal_ramoops,
2478         &universal_mmcoops,
2479 #ifdef CONFIG_S5P_SYSMMU
2480         &s5p_device_sysmmu,
2481 #endif
2482 #ifdef CONFIG_FB_S3C
2483         &s3c_device_fb,
2484         &universal_spi_gpio,
2485 #endif
2486 #ifdef CONFIG_VIDEO_FIMG2D
2487         &s5p_device_fimg2d,
2488 #endif
2489 #ifdef CONFIG_VIDEO_SAMSUNG_S5P_MFC
2490         &s5p_device_mfc,
2491 #endif
2492
2493 #if defined(CONFIG_VIDEO_SAMSUNG_S5P_FIMC) || \
2494         defined(CONFIG_VIDEO_SAMSUNG_S5P_FIMC_MODULE)
2495         &s5p_device_fimc0,
2496         &s5p_device_fimc1,
2497         &s5p_device_fimc2,
2498         &s5p_device_fimc3,
2499 #endif
2500 #if defined(CONFIG_VIDEO_S5P_MIPI_CSIS) || \
2501         defined(CONFIG_VIDEO_S5P_MIPI_CSIS_MODULE)
2502         &s5p_device_mipi_csis0,
2503 #endif
2504         &s5p_device_usb_ehci,
2505         &universal_modemctl,
2506 #ifdef CONFIG_S3C_DEV_RTC
2507         &s3c_device_rtc,
2508 #endif
2509 #ifdef CONFIG_USB_GADGET
2510         &s3c_device_usbgadget,
2511 #endif
2512         &s3c_device_hsmmc0,
2513         &mmc0_fixed_voltage,
2514         &s3c_device_hsmmc2,
2515         &s3c_device_hsmmc3,
2516 #ifdef CONFIG_SND_SOC
2517         &s5pv310_device_i2s0,
2518 #endif
2519 #ifdef CONFIG_VIDEO_TVOUT
2520        &s5p_device_tvout,
2521        &s5p_device_cec,
2522        &s5p_device_hpd,
2523 #endif
2524 #ifdef CONFIG_VIDEO_SAMSUNG_S5P_TV
2525         &s5p_device_hdmi,
2526         &s5p_device_mixer,
2527 #endif
2528         &universal_jack,
2529         &universal_micro_usb_switch,
2530         &universal_uart_select,
2531         &s3c_device_adc,
2532 #ifdef CONFIG_ANDROID_RAM_CONSOLE
2533         &ram_console_device,
2534 #endif
2535 #ifdef CONFIG_SENSORS_NTC_THERMISTOR
2536         &universal_ncp15wb473_thermistor,
2537 #endif
2538 };
2539
2540 #if defined(CONFIG_VIDEO_TVOUT)
2541 static struct s5p_platform_hpd hdmi_hpd_data __initdata = {
2542
2543 };
2544 static struct s5p_platform_cec hdmi_cec_data __initdata = {
2545
2546 };
2547 #endif
2548
2549 extern void s5p_reserve_bootmem(void);
2550
2551 static void __init universal_map_io(void)
2552 {
2553         s5p_init_io(NULL, 0, S5P_VA_CHIPID);
2554         s3c24xx_init_clocks(24000000);
2555         s3c24xx_init_uarts(universal_uartcfgs, ARRAY_SIZE(universal_uartcfgs));
2556 }
2557
2558 static void __init s5pv310_reserve(void)
2559 {
2560         static struct cma_region regions[] = {
2561 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMD0
2562                 {
2563                         .name = "fimd",
2564                         .size = (CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMD0
2565 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMD1
2566                                 + CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMD1
2567 #endif
2568                                 ) * SZ_1K,
2569                 },
2570 #endif
2571 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC0
2572                 {
2573                         .name = "fimc0",
2574                         .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC0 * SZ_1K,
2575                 },
2576 #endif
2577 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC1
2578                 {
2579                         .name = "fimc1",
2580                         .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC1 * SZ_1K,
2581                 },
2582 #endif
2583 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC2
2584                 {
2585                         .name = "fimc2",
2586                         .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC2 * SZ_1K,
2587                 },
2588 #endif
2589 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC3
2590                 {
2591                         .name = "fimc3",
2592                         .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC3 * SZ_1K,
2593                 },
2594 #endif
2595 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_MALI
2596 #if !defined(CONFIG_MALI_OSMEM_ONLY)
2597                 {
2598                         .name = "mali",
2599                         .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_MALI * SZ_1K,
2600                 },
2601 #endif
2602 #endif
2603 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC
2604                 {
2605                         .name = "mfc",
2606                         .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC *  SZ_1K,
2607                 },
2608 #endif
2609 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC0
2610                 {
2611                         .name = "mfc0",
2612                         .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC0 * SZ_1K,
2613                         {
2614                                 .alignment = 1 << 17,
2615                         },
2616                 },
2617 #endif
2618 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC1
2619                 {
2620                         .name = "mfc1",
2621                         .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC1 * SZ_1K,
2622                         {
2623                                 .alignment = 1 << 17,
2624                         },
2625                 },
2626 #endif
2627 #ifdef CONFIG_VIDEO_SAMSUNG_S5P_MFC
2628                 {
2629                         .name           = "fw",
2630                         .size           = 1 << 20,
2631                         { .alignment    = 128 << 10 },
2632                         .start          = 0x42000000,
2633                 },
2634                 {
2635                         .name           = "b1",
2636                         .size           = 32 << 20,
2637                         .start          = 0x43000000,
2638                 },
2639                 {
2640                         .name           = "b2",
2641                         .size           = 32 << 20,
2642                         .start          = 0x51000000,
2643                 },
2644                 {
2645                         .name           = "fb",
2646                         .size           =  32 << 20,
2647                 },
2648 #endif
2649                 { }
2650         };
2651
2652         static const char map[] __initconst =
2653                 "s3cfb=fimd;"
2654                 "s5p-fimc.0=fimc0;s5p-fimc.1=fimc1;s5p-fimc.2=fimc2;"
2655                 "s5p-fimc.3=fimc3;"
2656                 "mfc=mfc,mfc0,mfc1;s5p-mfc/f=fw;s5p-mfc/a=b1;s5p-mfc/b=b2;"
2657                 "mali_dev/dedicated_mem=mali;"
2658                 "s5p-mixer=fb;"
2659                 "*=b1,b2";
2660
2661         unsigned int i = 0;
2662
2663 #ifdef CONFIG_ANDROID_RAM_CONSOLE
2664         unsigned int addr;
2665
2666         /* FIXME: ram console MUST be reserved at first time */
2667         addr = memblock_alloc(SZ_1M, SZ_4K);
2668         ram_console_resource[0].start = addr;
2669         ram_console_resource[0].end = addr + SZ_1M - 1;
2670         pr_info("ram_console: 0x%08x ~ 0x%08x (1MB)\n",
2671                         addr, addr + SZ_1M);
2672 #endif
2673
2674         cma_set_defaults(regions, map);
2675         cma_early_regions_reserve(NULL);
2676
2677         for (; i < ARRAY_SIZE(regions) - 1 /* terminator */; ++i) {
2678                 pr_info("cma: region: %-8s: 0x%08x ~ 0x%08x (%dMB)\n",
2679                         regions[i].name, regions[i].start,
2680                         regions[i].start + regions[i].size,
2681                         regions[i].size / SZ_1M);
2682         }
2683 }
2684
2685 /**
2686  * universal_gpio_init()
2687  *
2688  * There are GPIOs that are NOT handled by device drivers becuase;
2689  * a) No devices are connected to the specific GPIOs, or
2690  * b) No device drivers are loaded for the corresponding devices.
2691  *
2692  * Such GPIOs may incur unnecessary current according to the board
2693  * schematics. Therefore, we may need to configure such GPIOs.
2694  */
2695 static void __init universal_gpio_init(void)
2696 {
2697         int gpio;
2698
2699         gpio = S5PV310_GPX3(3);         /* GLNA_ON */
2700         gpio_request(gpio, "GLNA_ON");
2701         gpio_direction_output(gpio, 0);
2702         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
2703
2704         /* FIXME check the HDMI_5V */
2705         gpio = S5PV310_GPE0(1);         /* HDMI_EN1 */
2706         gpio_request(gpio, "HDMI_EN1");
2707         gpio_direction_output(gpio, 0);
2708         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
2709 }
2710
2711 static void __init universal_modem_init(void)
2712 {
2713         struct modemctl_platform_data *pdata = &universal_modemctl_data;
2714         int gpio;
2715
2716         gpio = MOBILE_GPIO(CP_ON);
2717         gpio_request(gpio, "CP_ON");
2718         gpio_direction_output(gpio, 0);
2719         pdata->gpio_phone_on = gpio;
2720
2721         gpio = MOBILE_GPIO(PHONE_ACTIVE);
2722         gpio_request(gpio, "PHONE_ACTIVE");
2723         pdata->gpio_phone_active = gpio;
2724
2725         gpio = MOBILE_GPIO(PDA_ACTIVE);
2726         gpio_request(gpio, "PDA_ACTIVE");
2727         gpio_direction_output(gpio, 0);
2728         pdata->gpio_pda_active = gpio;
2729
2730         gpio = MOBILE_GPIO(CP_PMU_RST);
2731         gpio_request(gpio, "CP_PMU_RST");
2732         gpio_direction_output(gpio, 0);
2733         pdata->gpio_cp_reset = gpio;
2734
2735         gpio = MOBILE_GPIO(RESET_REQ_N);
2736         gpio_request(gpio, "RESET_REQ_N");
2737         gpio_direction_output(gpio, 0);
2738         pdata->gpio_cp_req_reset = gpio;
2739
2740         gpio = MOBILE_GPIO(IPC_SLAVE_WAKEUP);
2741         gpio_request(gpio, "IPC_SLAVE_WAKEUP");
2742         gpio_direction_output(gpio, 0);
2743         pdata->gpio_ipc_slave_wakeup = gpio;
2744
2745         gpio = MOBILE_GPIO(IPC_HOST_WAKEUP);
2746         gpio_request(gpio, "IPC_HOST_WAKEUP");
2747         pdata->gpio_ipc_host_wakeup = gpio;
2748
2749         gpio = MOBILE_GPIO(SUSPEND_REQUEST_HSIC);
2750         gpio_request(gpio, "SUSPEND_REQUEST_HSIC");
2751         pdata->gpio_suspend_request = gpio;
2752
2753         gpio = MOBILE_GPIO(ACTIVE_STATE_HSIC);
2754         gpio_request(gpio, "ACTIVE_STATE_HSIC");
2755         gpio_direction_output(gpio, 0);
2756         pdata->gpio_active_state = gpio;
2757 }
2758
2759 /*
2760  * GPX are saved and restored at plat-samsung/pm.c:s5c_pm_enter.
2761  * However, they are inside of pm_prepare and pm_finish, so it
2762  * does not save ours against universal_pm_prepare:2.
2763  */
2764 static struct sleep_save s5pc210_gpx[] = {
2765         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C00),
2766         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C04),
2767         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C08),
2768         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C0C),
2769         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C20),
2770         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C24),
2771         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C28),
2772         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C2C),
2773         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C40),
2774         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C44),
2775         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C48),
2776         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C4C),
2777         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C60),
2778         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C64),
2779         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C68),
2780         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C6C),
2781 };
2782
2783 #ifdef CONFIG_UNIVERSAL_C210_POWEROFF_WORKAROUND
2784 static void universal_power_off(void)
2785 {
2786         struct regulator *reg;
2787
2788         pr_emerg("POWEROFF: WORKAOUND\n");
2789
2790         /* Turn LDO9 Off (LP3974 ONLY. MAX8998 CANNOT DO THIS) */
2791         reg = regulator_get(NULL, "vcc_2.8v_pda");
2792         if (IS_ERR_OR_NULL(reg))
2793                 pr_emerg("LDO9 cannot be found.\n");
2794         else
2795                 regulator_force_disable(reg);
2796
2797         panic("The power should be already turned off.\n");
2798 }
2799 #endif
2800
2801 static void universal_pm_finish(void)
2802 {
2803         /* Restore GPX conf */
2804         s3c_pm_do_restore(s5pc210_gpx, ARRAY_SIZE(s5pc210_gpx));
2805 }
2806
2807 static void universal_pm_prepare(void)
2808 {
2809         int gpio;
2810
2811         /* 1. Save GPX conf */
2812         s3c_pm_do_save(s5pc210_gpx, ARRAY_SIZE(s5pc210_gpx));
2813
2814         /* 2. Set GPX as Power Save Mode */
2815         /* 2-a. PMIC */
2816         gpio = S5PV310_GPX0(3); /* PULL_UP is connected at board */
2817         gpio_direction_output(gpio, 1);
2818         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
2819         gpio = S5PV310_GPX0(4); /* PULL_UP is connected at board */
2820         gpio_direction_output(gpio, 1);
2821         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
2822         gpio = S5PV310_GPX0(5);
2823         gpio_direction_output(gpio, 0);
2824         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
2825         gpio = S5PV310_GPX0(6);
2826         gpio_direction_output(gpio, 0);
2827         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
2828         gpio = S5PV310_GPX0(7);
2829         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
2830         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
2831
2832         /* 2-b. Gyro sensor */
2833         gpio = S5PV310_GPX0(0);
2834         gpio_direction_input(gpio);
2835         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_DOWN);
2836         gpio = S5PV310_GPX0(1);
2837         gpio_direction_input(gpio);
2838         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_DOWN);
2839
2840         /* 2-c. Proximity sensor */
2841         gpio = S5PV310_GPX0(2);
2842         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
2843         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_DOWN);
2844
2845         /* 2-d. Accelerometer */
2846         gpio = S5PV310_GPX2(4);
2847         gpio_direction_input(gpio);
2848         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_DOWN);
2849
2850         /* 2-e. Modem */
2851         gpio = S5PV310_GPX1(6);
2852         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_DOWN);
2853
2854         /* 3. Debug: Look at the diff */
2855         mobile_gpios_groupx_difference();
2856
2857 }
2858
2859 static void __init universal_rev00_fixup(void)
2860 {
2861         /* Rev 0.0 connected with inverter so active low */
2862         mmc0_fixed_voltage_config.gpio = S5PV310_GPE3(6);
2863         mmc0_fixed_voltage_config.enable_high = false;
2864
2865         universal_bcm4751_data.regpu = S5PV310_GPK1(0);
2866         universal_bcm4751_data.nrst =S5PV310_GPK1(2);
2867
2868         /* TODO BT_EN */
2869 }
2870
2871 int universal_mfc_setup_clock(const char *sclk_name, const char *pclk_name,
2872                 unsigned long rate, unsigned int rate_set)
2873 {
2874         struct clk *sclk = NULL;
2875         struct clk *pclk = NULL;
2876
2877         sclk = clk_get(NULL, sclk_name);
2878         if (IS_ERR(sclk)) {
2879                 printk(KERN_ERR "failed to get %s clock.\n", sclk_name);
2880                 goto err_clk;
2881         }
2882
2883         pclk = clk_get(NULL, pclk_name);
2884         if (IS_ERR(pclk)) {
2885                 printk(KERN_ERR "failed to get %s clock.\n", pclk_name);
2886                 goto err_clk;
2887         }
2888
2889         clk_set_parent(sclk, pclk);
2890
2891         printk(KERN_INFO "set parent clock of %s to %s\n", sclk_name,
2892                         pclk_name);
2893         if (!rate_set)
2894                 goto set_end;
2895
2896         if (!rate)
2897                 rate = 200 * MHZ;
2898
2899         clk_set_rate(sclk, rate);
2900         printk(KERN_INFO "set mfc sclk rate to %lu\n", rate);
2901
2902 set_end:
2903         clk_put(sclk);
2904         clk_put(pclk);
2905
2906         return 0;
2907
2908 err_clk:
2909         clk_put(sclk);
2910         clk_put(pclk);
2911
2912         return -EINVAL;
2913
2914 }
2915
2916 #ifdef CONFIG_S5PV310_DEV_PD
2917 static void inline powerdomain_boot_on(int pd)
2918 {
2919         struct samsung_pd_info *pdinfo = (struct samsung_pd_info *)
2920                 s5pv310_device_pd[pd].dev.platform_data;
2921         pdinfo->boot_on = true;
2922 }
2923 #endif
2924
2925 static void __init universal_machine_init(void)
2926 {
2927         mobile_gpios_init_universal();
2928
2929         if (hwrevision(0))
2930                 universal_rev00_fixup();
2931
2932         s3c_i2c0_set_platdata(&universal_i2c0_platdata);
2933
2934         s3c_i2c1_set_platdata(NULL);
2935         i2c_register_board_info(1, i2c1_devs, ARRAY_SIZE(i2c1_devs));
2936
2937         universal_tsp_init();
2938         s3c_i2c3_set_platdata(NULL);
2939         i2c_register_board_info(3, i2c3_devs, ARRAY_SIZE(i2c3_devs));
2940
2941         universal_sensor_init();
2942         universal_fmradio_init();
2943         s3c_i2c4_set_platdata(NULL);
2944         i2c_register_board_info(4, i2c4_devs, ARRAY_SIZE(i2c4_devs));
2945
2946         universal_pmic_init();
2947         s3c_i2c5_set_platdata(NULL);
2948         i2c5_devs[I2C5_LP3974].irq = gpio_to_irq(S5PV310_GPX0(7)),
2949         i2c_register_board_info(5, i2c5_devs, ARRAY_SIZE(i2c5_devs));
2950
2951         universal_sound_init();
2952         s3c_i2c6_set_platdata(NULL);
2953         if (hwrevision(0) || hwrevision(1))
2954                 i2c_register_board_info(6, i2c6_devs_rev00,
2955                                 ARRAY_SIZE(i2c6_devs_rev00));
2956         else
2957                 i2c_register_board_info(6, i2c6_devs_rev02,
2958                                 ARRAY_SIZE(i2c6_devs_rev02));
2959
2960         s3c_i2c7_set_platdata(NULL);
2961         i2c_register_board_info(7, i2c7_devs, ARRAY_SIZE(i2c7_devs));
2962
2963         s3c_i2c8_set_platdata(NULL);
2964
2965         i2c_register_board_info(9, i2c9_devs, ARRAY_SIZE(i2c9_devs));
2966
2967         i2c_register_board_info(10, i2c10_devs, ARRAY_SIZE(i2c10_devs));
2968
2969         universal_touchkey_init();
2970         i2c_register_board_info(12, i2c12_devs, ARRAY_SIZE(i2c12_devs));
2971
2972         i2c_register_board_info(14, i2c14_devs, ARRAY_SIZE(i2c14_devs));
2973
2974         if (hwrevision(3))
2975         {
2976                 /* NFC sensor */
2977                 nfc_setup_gpio();
2978                 i2c_register_board_info(15, i2c15_devs, ARRAY_SIZE(i2c15_devs));
2979         }
2980
2981         universal_modem_init();
2982
2983 #ifdef CONFIG_FB_S3C
2984         universal_fb_init();
2985 #endif
2986 #ifdef CONFIG_S5PV310_DEV_PD
2987 #ifdef CONFIG_VIDEO_SAMSUNG_S5P_MFC
2988         s5p_device_mfc.dev.parent = &s5pv310_device_pd[PD_MFC].dev;
2989         universal_mfc_setup_clock("mout_mfc0", "mout_mpll", 0, 0);
2990         universal_mfc_setup_clock("sclk_mfc", "mout_mfc0", 200 * MHZ, 1);
2991 #endif
2992 #endif
2993 #ifdef CONFIG_VIDEO_FIMG2D
2994         s5p_fimg2d_set_platdata(&fimg2d_data);
2995 #ifdef CONFIG_S5PV310_DEV_PD
2996         s5p_device_fimg2d.dev.parent = &s5pv310_device_pd[PD_LCD0].dev;
2997 #endif
2998 #endif
2999 #ifdef CONFIG_PM
3000         pm_cpu_prepare = universal_pm_prepare;
3001         pm_cpu_finish = universal_pm_finish;
3002
3003         s3c_pm_init();
3004         s3c_irq_wake(IRQ_RTC_ALARM, 1);
3005         universal_gpio_init();
3006 #endif
3007
3008 #if defined(CONFIG_S5PV310_DEV_PD) && !defined(CONFIG_PM_RUNTIME)
3009         /*
3010          * These power domains should be always on
3011          * without runtime pm support.
3012          */
3013         s5pv310_pd_enable(&s5pv310_device_pd[PD_MFC]);
3014         s5pv310_pd_enable(&s5pv310_device_pd[PD_G3D]);
3015         s5pv310_pd_enable(&s5pv310_device_pd[PD_LCD0]);
3016         s5pv310_pd_enable(&s5pv310_device_pd[PD_LCD1]);
3017         s5pv310_pd_enable(&s5pv310_device_pd[PD_CAM]);
3018         s5pv310_pd_enable(&s5pv310_device_pd[PD_TV]);
3019         s5pv310_pd_enable(&s5pv310_device_pd[PD_GPS]);
3020 #endif
3021
3022 #ifdef CONFIG_VIDEO_FIMG2D
3023         /* setup fimg2d parent clock. */
3024         universal_fimg2d_setup_clock("mout_g2d0", "mout_mpll");
3025 #endif
3026         universal_sdhci_init();
3027 #ifdef CONFIG_S5P_ADC
3028         universal_adc_init();
3029 #endif
3030
3031 #ifdef CONFIG_UNIVERSAL_C210_POWEROFF_WORKAROUND
3032         /*
3033          * Registered at pm_power_off_prepare because system often halts
3034          * at kernel_power_off() before calling pm_power_off because of
3035          * an issue of disable_cpu called at power_off.
3036          */
3037         pm_power_off_prepare = universal_power_off;
3038 #endif
3039
3040 #ifdef CONFIG_S5PV310_DEV_PD
3041 #ifdef CONFIG_FB_S3C
3042         s3c_device_fb.dev.parent = &s5pv310_device_pd[PD_LCD0].dev;
3043         powerdomain_boot_on(PD_LCD0);
3044 #endif
3045 #endif
3046
3047 #if defined(CONFIG_VIDEO_SAMSUNG_S5P_FIMC) || \
3048         defined(CONFIG_VIDEO_SAMSUNG_S5P_FIMC_MODULE)
3049         s3c_fimc_setname(0, "s5pv310-fimc");
3050         s3c_fimc_setname(1, "s5pv310-fimc");
3051         s3c_fimc_setname(2, "s5pv310-fimc");
3052         s3c_fimc_setname(3, "s5pv310-fimc");
3053 #ifdef CONFIG_S5PV310_DEV_PD
3054         s5p_device_fimc0.dev.parent = &s5pv310_device_pd[PD_CAM].dev;
3055         s5p_device_fimc1.dev.parent = &s5pv310_device_pd[PD_CAM].dev;
3056         s5p_device_fimc2.dev.parent = &s5pv310_device_pd[PD_CAM].dev;
3057         s5p_device_fimc3.dev.parent = &s5pv310_device_pd[PD_CAM].dev;
3058 #endif
3059         s3c_set_platdata(&universal_fimc_plat_data[0],
3060                          sizeof(universal_fimc_plat_data[0]),
3061                          &s5p_device_fimc0);
3062 #endif /* CONFIG_VIDEO_SAMSUNG_S5P_FIMC */
3063
3064 #if defined(CONFIG_VIDEO_S5P_MIPI_CSIS) || \
3065         defined(CONFIG_VIDEO_S5P_MIPI_CSIS_MODULE)
3066         s3c_set_platdata(&mipi_csis0_pldata, sizeof(mipi_csis0_pldata),
3067                          &s5p_device_mipi_csis0);
3068 #ifdef CONFIG_S5PV310_DEV_PD
3069         s5p_device_mipi_csis0.dev.parent = &s5pv310_device_pd[PD_CAM].dev;
3070 #endif
3071 #endif
3072         universal_camera_init();
3073 #if defined(CONFIG_VIDEO_TVOUT)
3074        s5p_hdmi_hpd_set_platdata(&hdmi_hpd_data);
3075        s5p_hdmi_cec_set_platdata(&hdmi_cec_data);
3076 #ifdef CONFIG_S5PV310_DEV_PD
3077         s5p_device_tvout.dev.parent = &s5pv310_device_pd[PD_TV].dev;
3078 #endif
3079 #endif
3080
3081         /* Add 15th i2c device for pn544 nfc chip*/
3082         if (hwrevision(3))
3083                 platform_device_register(&i2c15_gpio);
3084
3085         /* Last */
3086         platform_add_devices(universal_devices, ARRAY_SIZE(universal_devices));
3087
3088         /*
3089          * setup parent clk for fimc, camera, mipi clks. It must be called after
3090          * platform_add_device() for enable enumerating the name of struct clk.
3091          */
3092         s5pv310_fimc_setup_clks();
3093 #ifdef CONFIG_S5P_CHARGER
3094         universal_config_s5p_charger = true;
3095 #endif
3096 }
3097
3098 MACHINE_START(UNIVERSAL_C210, "UNIVERSAL_C210")
3099         /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */
3100         .phys_io        = S3C_PA_UART & 0xfff00000,
3101         .io_pg_offst    = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
3102         .boot_params    = S5P_PA_SDRAM + 0x100,
3103         .init_irq       = s5pv310_init_irq,
3104         .map_io         = universal_map_io,
3105         .init_machine   = universal_machine_init,
3106         .timer          = &s5pv310_evt0_timer,
3107         .reserve        = &s5pv310_reserve,
3108 MACHINE_END