upload tizen1.0 source
[kernel/linux-2.6.36.git] / arch / arm / mach-s5pv310 / mach-u1_c210.c
1 /*
2  * linux/arch/arm/mach-s5pv310/mach-c1_c210.c
3  *
4  * Copyright (c) 2011 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/cypress_touchkey.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/power_supply.h>
30 #include <linux/mfd/max8997.h>
31 #include <linux/mfd/max8997-private.h>
32 #include <linux/mfd/mc1n2_pdata.h>
33 #include <linux/power/max17042_battery.h>
34 #include <linux/ramoops.h>
35 #include <linux/mmcoops.h>
36 #include <linux/uart_select.h>
37 #include <linux/memblock.h>
38 #include <linux/rtc/rtc-s3c.h>
39 #include <linux/swi.h>
40 #include <linux/jack.h>
41 #include <linux/k3g.h>
42 #include <linux/kr3dh.h>
43 #include <linux/pn544.h>
44 #include <linux/tmd27711.h>
45 #include <linux/ak8975.h>
46 #include <linux/micro_usb_switch.h>
47 #include <linux/switch.h>
48 #include <linux/cm3623.h>
49 #include <linux/host_notify.h>
50 #include <linux/utsname.h>
51
52 #include <linux/cpufreq.h>
53 #include <linux/modem/xmm6260.h>
54 #include <linux/power/charger-manager.h>
55 #include <linux/leds-max8997.h>
56 #include <video/platform_lcd.h>
57
58 #include <asm/mach-types.h>
59 #include <asm/mach/arch.h>
60 #include <asm/setup.h>
61 #include <asm/cacheflush.h>
62
63 #include <mach/map.h>
64 #include <mach/gpio.h>
65 #include <mach/regs-clock.h>
66 #include <mach/regs-pmu.h>
67 #include <mach/pm-core.h>
68 #include <mach/nt39411.h>
69 #include <mach/universal.h>
70
71 #include <plat/cpu.h>
72 #include <plat/clock.h>
73 #include <plat/devs.h>
74 #include <plat/gpio-cfg.h>
75 #include <plat/gpio-core.h>
76 #include <plat/fb.h>
77 #include <plat/fimc.h>
78 #include <plat/csis.h>
79 #include <plat/fimg2d.h>
80 #include <plat/mali.h>
81 #include <plat/iic.h>
82 #include <plat/pm.h>
83 #include <plat/regs-otg.h>
84 #include <plat/regs-serial.h>
85 #include <plat/s5pv310.h>
86 #include <plat/adc.h>
87 #include <plat/fimd_drm.h>
88 #include <plat/tvout.h>
89 #include <plat/pd.h>
90 #include <plat/s5p_fimd_lite.h>
91 #include <plat/usb_ehci.h>
92 #include <plat/sysmmu.h>
93 #include <plat/s5p-otghost.h>
94 #include <plat/udc-hs.h>
95
96 #include <media/m5mo_platform.h>
97
98 #ifdef CONFIG_VIDEO_S5K5BAFX
99 #include <media/s5k5bafx_platform.h>
100 #endif
101
102 #include "gpio-mobile.h"
103 #include "gpio-u1.h"
104 #include "board-mobile.h"
105 #include "../../../drivers/usb/gadget/s3c_udc.h"
106
107 #if CONFIG_TOUCHSCREEN_MXT224U1
108 #include <linux/i2c/mxt224_u1.h>
109 #endif
110
111 #ifdef CONFIG_INPUT_SECBRIDGE
112 #include <linux/input/sec-input-bridge.h>
113 #endif
114
115 #ifdef CONFIG_CHARGERCTRL_MAX8922
116 #include <linux/max8922-charger.h>
117 #endif
118
119 #if defined(CONFIG_DEV_THERMAL)
120 #include <plat/s5p-tmu.h>
121 #include <mach/regs-tmu.h>
122 #endif
123
124 /* Following are default values for UCON, ULCON and UFCON UART registers */
125 #define UNIVERSAL_UCON_DEFAULT  (S3C2410_UCON_TXILEVEL |        \
126                                  S3C2410_UCON_RXILEVEL |        \
127                                  S3C2410_UCON_TXIRQMODE |       \
128                                  S3C2410_UCON_RXIRQMODE |       \
129                                  S3C2410_UCON_RXFIFO_TOI |      \
130                                  S3C2443_UCON_RXERR_IRQEN)
131
132 #define UNIVERSAL_ULCON_DEFAULT S3C2410_LCON_CS8
133
134 #define UNIVERSAL_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE |       \
135                                  S5PV210_UFCON_TXTRIG0 |        \
136                                  S5PV210_UFCON_RXTRIG128)
137
138 #define UNIVERSAL_UFCON_UART2   (S3C2410_UFCON_FIFOMODE |       \
139                                  S5PV210_UFCON_TXTRIG0 |        \
140                                  S5PV210_UFCON_RXTRIG4)
141
142 static struct class *sec_class;
143 static struct device *switch_dev;
144
145 extern void u1_config_sleep_gpio_table(void);
146
147 enum fixed_regulator_id {
148         FIXED_REG_ID_MMC = 0,
149         FIXED_REG_ID_CAM0,
150         FIXED_REG_ID_CAM1,
151         FIXED_REG_ID_CAM2,
152         FIXED_REG_ID_CAM3,
153         FIXED_REG_ID_RADIO,
154 };
155
156 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_PROFILING
157
158 static unsigned int u1_profile_level = 0;
159
160 static int __init u1_profile_level_setup(char *str)
161 {
162     char *endp;
163     if (!str)
164         return -EINVAL;
165
166     u1_profile_level = memparse(str, &endp);
167     if (u1_profile_level > 3)
168         u1_profile_level = 0;
169
170     return endp > str ? 0 : -EINVAL;
171 }
172
173 early_param("profile_level=", u1_profile_level_setup);
174 #endif
175
176 static struct s3c2410_uartcfg u1_uartcfgs[] __initdata = {
177         {
178                 .hwport         = 0,
179                 .ucon           = UNIVERSAL_UCON_DEFAULT,
180                 .ulcon          = UNIVERSAL_ULCON_DEFAULT,
181                 .ufcon          = UNIVERSAL_UFCON_DEFAULT,
182         },
183         {
184                 .hwport         = 1,
185                 .ucon           = UNIVERSAL_UCON_DEFAULT,
186                 .ulcon          = UNIVERSAL_ULCON_DEFAULT,
187                 .ufcon          = UNIVERSAL_UFCON_DEFAULT,
188         },
189         {
190                 .hwport         = 2,
191                 .ucon           = UNIVERSAL_UCON_DEFAULT,
192                 .ulcon          = UNIVERSAL_ULCON_DEFAULT,
193                 .ufcon          = UNIVERSAL_UFCON_UART2,
194         },
195         {
196                 .hwport         = 3,
197                 .ucon           = UNIVERSAL_UCON_DEFAULT,
198                 .ulcon          = UNIVERSAL_ULCON_DEFAULT,
199                 .ufcon          = UNIVERSAL_UFCON_DEFAULT,
200         },
201 };
202
203 static struct s3c2410_platform_i2c u1_i2c0_platdata __initdata = {
204         .frequency      = 300 * 1000,
205         .sda_delay      = 200,
206 };
207
208 static struct k3g_platform_data u1_k3g_data = {
209         .irq2                   = IRQ_EINT(1),
210         .powerdown              = K3G_POWERDOWN_NORMAL,
211         .zen                    = K3G_Z_EN,
212         .yen                    = K3G_Y_EN,
213         .xen                    = K3G_X_EN,
214         .block_data_update      = K3G_BLOCK_DATA_UPDATE,
215         .fullscale              = K3G_FULL_SCALE_500DPS,
216         .fifo_mode              = K3G_FIFO_FIFO_MODE,
217         .int2_src               = K3G_INT2_OVERRUN,
218         .fifo_threshold         = 16,
219         .int1_z_high_enable     = K3G_Z_HIGH_INT_EN,
220         .int1_y_high_enable     = K3G_Y_HIGH_INT_EN,
221         .int1_x_high_enable     = K3G_X_HIGH_INT_EN,
222         .int1_latch             = K3G_INTERRUPT_LATCHED,
223         .int1_z_threshold       = 0x12,
224         .int1_y_threshold       = 0x25,
225         .int1_x_threshold       = 0x25,
226         .int1_wait_enable       = K3G_INT1_WAIT_EN,
227         .int1_wait_duration     = 0x10,
228 };
229
230 static struct kr3dh_platform_data u1_kr3dh_data = {
231         .power_mode             = KR3DH_LOW_POWER_ONE_HALF_HZ,
232         .data_rate              = KR3DH_ODR_50HZ,
233         .zen                    = 1,
234         .yen                    = 1,
235         .xen                    = 1,
236         .int1_latch             = 1,
237         .int1_cfg               = KR3DH_INT_SOURCE,
238         .block_data_update      = 1,
239         .fullscale              = KR3DH_RANGE_2G,
240         .int1_combination       = KR3DH_OR_COMBINATION,
241         .int1_6d_enable         = 1,
242         .int1_z_high_enable     = 1,
243         .int1_z_low_enable      = 1,
244         .int1_y_high_enable     = 1,
245         .int1_y_low_enable      = 1,
246         .int1_x_high_enable     = 1,
247         .int1_x_low_enable      = 1,
248         .int1_threshold         = 0x25,
249         .int1_duration          = 0x01,
250         .negate_x               = 0,
251         .negate_y               = 0,
252         .negate_z               = 1,
253         .change_xy              = 1,
254 };
255
256 static void user_input_response_work(struct work_struct *work)
257 {
258 #ifdef CONFIG_CPU_FREQ_GOV_ONDEMAND_FLEXRATE
259         /* Run CPUFREQ with 10000us 10 times. */
260         cpufreq_ondemand_flexrate_request(10000, 10);
261 #endif /* CONFIG_CPU_FREQ_GOV_ONDEMAND_FLEXRATE */
262 }
263
264 static DECLARE_WORK(uir_work, user_input_response_work);
265
266 static __maybe_unused void user_input_response(void *data)
267 {
268         if (!work_pending(&uir_work))
269                 schedule_work_on(0, &uir_work);
270 }
271
272 /* I2C1 */
273 static struct i2c_board_info i2c1_devs[] __initdata = {
274         {
275                 /* Gyro sensor */
276                 I2C_BOARD_INFO("K3G_1", 0x69),
277                 .platform_data  = &u1_k3g_data,
278                 .irq            = IRQ_EINT(0),
279         }, {
280                 /* Accelerometer */
281                 I2C_BOARD_INFO("KR3DH", 0x19),
282                 .platform_data  = &u1_kr3dh_data,
283                 .irq            = IRQ_EINT(24),
284         }
285 };
286
287 /* TODO: should be modify for U1 */
288 extern struct max8997_platform_data u1_max8997_pdata;
289 extern void __init u1_pmic_init(void);
290
291 static void haptic_control_power(struct device *dev, int on)
292 {
293         static struct regulator *regulator;
294         static DEFINE_MUTEX(lock);
295         static bool enabled;
296         int ret;
297
298         mutex_lock(&lock);
299
300         if (enabled == !!on)
301                 goto out;
302
303         if (regulator == NULL)
304                 regulator = regulator_get(dev, "inmotor");
305         if (IS_ERR_OR_NULL(regulator)) {
306                 regulator = NULL;
307                 goto out;
308         }
309
310         if (on)
311                 ret = regulator_enable(regulator);
312         else
313                 ret = regulator_disable(regulator);
314
315         if (!ret)
316                 enabled = !!on;
317 out:
318         mutex_unlock(&lock);
319 }
320
321 struct max8997_haptic_platform_data u1_haptic_pdata = {
322         .name           = "vibtone",
323         .pwm_timer      = 1,
324         .control_power  = haptic_control_power,
325 };
326
327 /* GPIO I2C 5 (PMIC) */
328 enum { I2C5_MAX8997 };
329 static struct i2c_board_info i2c5_devs[] __initdata = {
330         [I2C5_MAX8997] = {
331                 I2C_BOARD_INFO("max8997", 0xCC >> 1),
332                 .platform_data  = &u1_max8997_pdata,
333         },
334 };
335
336 static void sec_set_sub_mic_bias(bool on)
337 {
338         int gpio;
339         gpio = MOBILE_GPIO(SUB_MICBIAS_EN);
340         gpio_set_value(gpio, on);
341         pr_err(KERN_ERR "SUB_MIC_BIAS_EN GPIO set [%d] !\n", on);
342 }
343
344 static void sec_set_main_mic_bias(bool on)
345 {
346         int gpio;
347         gpio = MOBILE_GPIO(MICBIAS_EN);
348         gpio_set_value(gpio, on);
349         pr_err(KERN_ERR "MAIN_MIC_BIAS_EN GPIO set [%d] !\n", on);
350 }
351
352 static struct mc1n2_platform_data mc1n2_pdata = {
353         .set_main_mic_bias = sec_set_main_mic_bias,
354         .set_sub_mic_bias = sec_set_sub_mic_bias,
355 };
356
357 /* GPIO I2C 6 */
358 static struct i2c_board_info i2c6_devs[] __initdata = {
359         {
360                 /* Audio Codec */
361                 I2C_BOARD_INFO("mc1n2", 0x3a),
362                 .platform_data = &mc1n2_pdata,
363         },
364 };
365
366 static void __init u1_sound_init(void)
367 {
368         int val;
369         int err;
370         int gpio;
371
372         /* Set PMU register to set CLK_OUT to use XUSBXTI
373          * as codec source clock */
374         val = 0x900;
375         __raw_writel(val, S5P_PMREG(0xA00));
376
377         gpio = MOBILE_GPIO(MICBIAS_EN);
378         err = gpio_request(gpio, "MICBIAS_EN");
379         if (err) {
380                 pr_err(KERN_ERR "MIC_BIAS_EN GPIO set error!\n");
381                 return;
382         }
383         gpio_direction_output(gpio, 1);
384         gpio_set_value(gpio, 0);
385
386         gpio = MOBILE_GPIO(EAR_MICBIAS_EN);
387         err = gpio_request(gpio, "EAR_MICBIAS_EN");
388         if (err) {
389                 pr_err(KERN_ERR "EAR_MIC_BIAS_EN GPIO set error!\n");
390                 return;
391         }
392         gpio_direction_output(gpio, 1);
393         gpio_set_value(gpio, 0);
394
395         gpio = MOBILE_GPIO(SUB_MICBIAS_EN);
396         err = gpio_request(gpio, "submic_bias");
397         if (err) {
398                 pr_err(KERN_ERR "SUB_MIC_BIAS_EN GPIO set error!\n");
399                 return;
400         }
401         gpio_direction_output(gpio, 0);
402 }
403
404 static struct ak8975_platform_data universal_ak8975_data = {
405         .poll_interval = 100,
406 };
407
408 /* I2C7 */
409 static struct i2c_board_info i2c7_devs[] __initdata = {
410         {
411                 /* Compass */
412                 I2C_BOARD_INFO("ak8975", 0x0c),
413                 .platform_data  = &universal_ak8975_data,
414         },
415 };
416
417 /* I2C8: HDMI */
418
419 /* I2C9 */
420 static struct i2c_gpio_platform_data i2c9_gpio_data = {
421         .sda_pin                = S5PV310_GPY4(0),      /* XM0ADDR_8 */
422         .scl_pin                = S5PV310_GPY4(1),      /* XM0ADDR_9 */
423 };
424
425 static struct platform_device i2c9_gpio = {
426         .name                   = "i2c-gpio",
427         .id                     = 9,
428         .dev                    = {
429                 .platform_data  = &i2c9_gpio_data,
430         },
431 };
432
433 static struct max17042_reg_data max17042_init_data[] = {
434         { MAX17042_CGAIN,               0x0000 },
435         { MAX17042_MiscCFG,             0x0003 },
436         { MAX17042_LearnCFG,            0x0007 },
437         /* RCOMP: 0x0050 2011.02.29 from MAXIM */
438         { MAX17042_RCOMP0,              0x0050 },
439 };
440 /* Alert only when the battery is removed or inserted */
441 static struct max17042_reg_data max17042_alert_init_data[] = {
442         /* SALRT Threshold setting (disable) unsigned MAX/MIN */
443         { MAX17042_SALRT_Th,    0xFF00 },
444         /* VALRT Threshold setting (disable) unsigned MAX/MIN */
445         { MAX17042_VALRT_Th,    0xFF00 },
446         /* TALRT Threshold setting (disable) signed MAX/MIN */
447         { MAX17042_TALRT_Th,    0x7F80 },
448 };
449 static struct max17042_platform_data u1_battery_platform_data = {
450         .init_data = max17042_init_data,
451         .num_init_data = ARRAY_SIZE(max17042_init_data),
452         .alrt_data = max17042_alert_init_data,
453         .num_alrt_data = ARRAY_SIZE(max17042_alert_init_data),
454         .irq_base = IRQ_FUEL_BASE,
455         .enable_alert = true,
456         .wakeup = true,
457         .r_sns = 10000, /* 10m Ohm */
458 };
459
460 enum { I2C9_MAX17042};
461 static struct i2c_board_info i2c9_devs[] __initdata = {
462         [I2C9_MAX17042] = {
463                 I2C_BOARD_INFO("max17042", 0x36),
464                 .platform_data = &u1_battery_platform_data,
465         },
466 };
467
468
469 /* GPIO I2C 12 (3 Touchkey) */
470 #define TOUCHKEY_INT    S5PV310_GPL0(5)
471 #define TOUCHKEY_SCL    S5PV310_GPK1(0)
472 #define TOUCHKEY_SDA    S5PV310_GPK1(2)
473
474 static struct i2c_gpio_platform_data i2c12_gpio_data = {
475         .sda_pin                = S5PV310_GPK1(2),      /* XMDMDATA_8 */
476         .scl_pin                = S5PV310_GPK1(0),      /* XMDMDATA_9 */
477 };
478
479 static struct platform_device i2c12_gpio = {
480         .name                   = "i2c-gpio",
481         .id                     = 12,
482         .dev                    = {
483                 .platform_data  = &i2c12_gpio_data,
484         },
485 };
486
487 /*===============================*/
488 /*=     CYPRESS TOUCH KEY       =*/
489 /*===============================*/
490 static struct cypress_pin cypress_tk_pin = {
491         .gpio_en        = -1,
492         .gpio_int       = TOUCHKEY_INT,
493         .gpio_sda       = TOUCHKEY_SDA,
494         .gpio_scl       = TOUCHKEY_SCL,
495 };
496
497 static void cypress_tk_cfg_pin(void)
498 {
499         s3c_gpio_setpull(cypress_tk_pin.gpio_sda, S3C_GPIO_PULL_NONE);
500         s3c_gpio_setpull(cypress_tk_pin.gpio_scl, S3C_GPIO_PULL_NONE);
501
502         s3c_gpio_cfgpin(cypress_tk_pin.gpio_sda, S3C_GPIO_SFN(2));
503         s3c_gpio_cfgpin(cypress_tk_pin.gpio_scl, S3C_GPIO_SFN(2));
504
505         s3c_gpio_cfgpin(cypress_tk_pin.gpio_int, S3C_GPIO_SFN(0xf));
506         if (gpio_is_valid(cypress_tk_pin.gpio_en))
507                 s3c_gpio_cfgpin(cypress_tk_pin.gpio_en, S3C_GPIO_OUTPUT);
508 };
509
510 static int cypress_touchkey_power(int onoff)
511 {
512         static struct regulator *regulator;
513         static DEFINE_MUTEX(lock);
514         static bool enabled;
515         int ret = 0;
516
517         mutex_lock(&lock);
518
519         if (enabled == !!onoff)
520                 goto out;
521
522         if (regulator == NULL)
523                 regulator = regulator_get(NULL, "touch_2.8v");
524         if (IS_ERR_OR_NULL(regulator)) {
525                 regulator = NULL;
526                 pr_err("[TK][ERROR] regulator_get fail\n");
527                 ret = -EINVAL;
528                 goto out;
529         }
530
531         if (onoff)
532                 ret = regulator_enable(regulator);
533         else
534                 ret = regulator_disable(regulator);
535
536         if (!ret)
537                 enabled = !!onoff;
538
539         msleep(100);
540 out:
541         mutex_unlock(&lock);
542         return ret;
543 }
544
545 static int cypress_touchled_power(int onoff)
546 {
547         static struct regulator *regulator;
548         static DEFINE_MUTEX(lock);
549         static bool enabled;
550         int ret = 0;
551
552         mutex_lock(&lock);
553
554         if (enabled == !!onoff)
555                 goto out;
556
557         if (regulator == NULL)
558                 regulator = regulator_get(NULL, "touch_led_3.3v");
559         if (IS_ERR_OR_NULL(regulator)) {
560                 regulator = NULL;
561                 pr_err("[TK][ERROR] regulator_get fail\n");
562                 ret = -EINVAL;
563                 goto out;
564         }
565
566         if (onoff)
567                 ret = regulator_enable(regulator);
568         else
569                 ret = regulator_disable(regulator);
570
571         if (!ret)
572                 enabled = !!onoff;
573
574         msleep(100);
575 out:
576         mutex_unlock(&lock);
577         return ret;
578 }
579
580 static unsigned int u1_cypress_touch_keycode[] = {
581         KEY_PHONE,      /* not use this value 0x00 */
582         KEY_PHONE,      /* KEY_SEND 0x01 */
583         KEY_BACK,       /* KEY_END 0x02 */
584 };
585
586 static unsigned char u1_cypress_keycode_setbit[] = {
587         0,
588         1,
589         1,
590 };
591
592 static struct cypress_platform_data cypress_tk_data = {
593         .cfg_pin                = cypress_tk_cfg_pin,
594         .power_pin              = cypress_touchkey_power,
595         .led_pin                = cypress_touchled_power,
596         .pin                    = &cypress_tk_pin,
597         .keycode                = u1_cypress_touch_keycode,
598         .keycode_size   = ARRAY_SIZE(u1_cypress_touch_keycode),
599         .keycode_setbit = u1_cypress_keycode_setbit,
600         .gpio_control   = 0,
601 };
602
603 static struct i2c_board_info i2c12_devs_cypress[] __initdata = {
604         {
605                 I2C_BOARD_INFO("cypress_tk", 0x20),
606                 .platform_data  = &cypress_tk_data,
607         },
608 };
609
610 static void __init universal_touchkey_init(void)
611 {
612         int gpio;
613         int irq;
614
615         gpio = TOUCHKEY_INT;                    /* XMDMDATA_7 */
616         gpio_request(gpio, "3_TOUCH_INT");
617         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
618         irq = gpio_to_irq(gpio);
619         i2c12_devs_cypress[0].irq = irq;
620 }
621
622 /* I2C14: Light */
623 static struct i2c_gpio_platform_data i2c14_gpio_data = {
624         .sda_pin                = S5PV310_GPK2(2),      /* XMMC2CDn */
625         .scl_pin                = S5PV310_GPK3(2),      /* XMMC3CDn */
626         .udelay                 = 1,                    /* 500kHz   */
627 };
628
629 static struct platform_device i2c14_gpio = {
630         .name                   = "i2c-gpio",
631         .id                     = 14,
632         .dev                    = {
633                 .platform_data  = &i2c14_gpio_data,
634         },
635 };
636
637 static void cm3663_control_power_source(int enable)
638 {
639         static struct regulator *regulator;
640         static DEFINE_MUTEX(lock);
641
642         mutex_lock(&lock);
643
644         if (regulator == NULL)
645                 regulator = regulator_get_exclusive(NULL, "led_a_2.8v");
646         WARN(IS_ERR_OR_NULL(regulator), "%s cannot get regulator\n", __func__);
647         if (IS_ERR_OR_NULL(regulator)) {
648                 regulator = NULL;
649                 goto out;
650         }
651
652         if (regulator_is_enabled(regulator)) {
653                 regulator_disable(regulator);
654                 if (enable)
655                         msleep(15);
656         }
657
658         if (enable)
659                 regulator_enable(regulator);
660 out:
661         mutex_unlock(&lock);
662 }
663
664 static int cm3663_get_irq_gpio(void)
665 {
666         int val;
667         int gpio;
668
669         gpio = MOBILE_GPIO(PS_ALS_INT);
670         gpio_request(gpio, "PS/ALS_INT");
671         val = gpio_get_value(gpio);
672         gpio_free(gpio);
673
674         return val;
675 }
676
677 static struct cm3623_platform_data u1_cm3663_platform_data = {
678         .control_power_source   = cm3663_control_power_source,
679         .get_irq_gpio = cm3663_get_irq_gpio,
680         .ps_def         = (CM3663_DR_PS_160 | CM3623_IT_PS_3 |
681                         CM3623_INT_ALS_DISABLE | CM3623_INT_PS_DISABLE),
682         .ps_thd         = 0x0C,
683         .als_def        = (CM3623_THD_ALS_8 | CM3623_IT_ALS_800 | CM3623_WDM_ALS_WORD),
684 };
685
686 static struct i2c_board_info i2c14_devs[] __initdata = {
687         {
688                 I2C_BOARD_INFO("CM3663", 0x22 >> 1),
689                 .platform_data  = &u1_cm3663_platform_data,
690                 .irq = IRQ_EINT(2),
691         },
692 };
693
694 static void __init u1_sensor_init(void)
695 {
696         int gpio;
697
698         gpio = S5PV310_GPX2(2); /* XEINT_18 */
699         gpio_request(gpio, "MSENSE_INT");
700         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
701         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
702         i2c7_devs[0].irq = gpio_to_irq(gpio);
703
704         gpio = S5PV310_GPX0(0); /* XEINT_0 */
705         gpio_request(gpio, "GYRO_INT");
706         gpio_direction_input(gpio);
707         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_DOWN);
708
709         gpio = S5PV310_GPX0(1); /* XEINT_1 */
710         gpio_request(gpio, "GYRO_INT1");
711         gpio_direction_input(gpio);
712         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_DOWN);
713
714
715         gpio = S5PV310_GPX3(0); /* XEINT_24 */
716         gpio_request(gpio, "ACC_INT");
717         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
718         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_DOWN);
719 }
720
721 /* I2C15: MHL */
722 static struct i2c_gpio_platform_data i2c15_gpio_data = {
723         .sda_pin                = S5PV310_GPY3(0),      /* XM0ADDR_0 */
724         .scl_pin                = S5PV310_GPY3(2),      /* XM0ADDR_2 */
725         .udelay                 = 1,
726 };
727
728 static struct platform_device i2c15_gpio = {
729         .name                   = "i2c-gpio",
730         .id                     = 15,
731         .dev                    = {
732                 .platform_data  = &i2c15_gpio_data,
733         },
734 };
735
736 static struct i2c_board_info i2c15_devs[] __initdata = {
737         /*
738          * TODO SII9234
739          */
740 };
741
742 /* I2C16: NFC */
743 #define GPIO_NFC_SCL_1_8V               S5PV310_GPY0(0)
744 #define GPIO_NFC_SDA_1_8V               S5PV310_GPY0(1)
745 #define GPIO_NFC_IRQ                    S5PV310_GPX1(7)
746 #define GPIO_NFC_EN                             S5PV310_GPL2(6)
747 #define GPIO_NFC_FIRMWARE               S5PV310_GPL2(7)
748
749 /* GPIO_LEVEL_NONE = 2, GPIO_LEVEL_LOW = 0 */
750 static unsigned int nfc_gpio_table[][4] = {
751         {GPIO_NFC_IRQ, S3C_GPIO_INPUT, 2, S3C_GPIO_PULL_DOWN},
752         {GPIO_NFC_EN, S3C_GPIO_OUTPUT, 0, S3C_GPIO_PULL_NONE},
753         {GPIO_NFC_FIRMWARE, S3C_GPIO_OUTPUT, 0, S3C_GPIO_PULL_NONE},
754         {GPIO_NFC_SCL_1_8V, S3C_GPIO_INPUT, 2, S3C_GPIO_PULL_NONE},
755         {GPIO_NFC_SDA_1_8V, S3C_GPIO_INPUT, 2, S3C_GPIO_PULL_NONE},
756 };
757
758 void nfc_setup_gpio(void)
759 {
760         int array_size = ARRAY_SIZE(nfc_gpio_table);
761         u32 i, gpio;
762         for (i = 0; i < array_size; i++) {
763                 gpio = nfc_gpio_table[i][0];
764                 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(nfc_gpio_table[i][1]));
765                 s3c_gpio_setpull(gpio, nfc_gpio_table[i][3]);
766                 if (nfc_gpio_table[i][2] != 2)
767                         gpio_set_value(gpio, nfc_gpio_table[i][2]);
768         }
769 }
770
771 static struct i2c_gpio_platform_data i2c16_gpio_data = {
772         .sda_pin                = GPIO_NFC_SDA_1_8V,
773         .scl_pin                = GPIO_NFC_SCL_1_8V,
774         .udelay                 = 1,
775 };
776
777 static struct platform_device i2c16_gpio = {
778         .name                   = "i2c-gpio",
779         .id                     = 16,
780         .dev                    = {
781                 .platform_data  = &i2c16_gpio_data,
782         },
783 };
784
785 /* I2C17: VGA CAM */
786 #if defined(CONFIG_VIDEO_S5K5BAFX)
787 #define VT_CAM_SDA_18V          S5PV310_GPC1(0)
788 #define VT_CAM_SCL_18V          S5PV310_GPC1(2)
789
790 static struct i2c_gpio_platform_data i2c17_platdata = {
791         .sda_pin                = VT_CAM_SDA_18V,
792         .scl_pin                = VT_CAM_SCL_18V,
793         .udelay                 = 2,
794         .sda_is_open_drain = 0,
795         .scl_is_open_drain = 0,
796         .scl_is_output_only = 0,
797 };
798
799 static struct platform_device s3c_device_i2c17 = {
800         .name           = "i2c-gpio",
801         .id                     = 17,
802         .dev.platform_data      = &i2c17_platdata,
803 };
804 /*
805 static struct i2c_board_info i2c17_devs[] __initdata = {
806         {
807                 I2C_BOARD_INFO("s5k5bafx", (0x5A >> 1)),
808         }
809 };
810 */
811 #endif
812
813 /* I2C18: FM RADIO*/
814 #define GPIO_FM_SDA_28V                 S5PV310_GPB(2)
815 #define GPIO_FM_SCL_28V                 S5PV310_GPB(3)
816
817 static struct i2c_gpio_platform_data i2c18_gpio_data = {
818         .sda_pin                = GPIO_FM_SDA_28V,
819         .scl_pin                = GPIO_FM_SCL_28V,
820 };
821
822 static struct platform_device i2c18_gpio = {
823         .name                   = "i2c-gpio",
824         .id                     = 18,
825         .dev                    = {
826                 .platform_data  = &i2c18_gpio_data,
827         },
828 };
829
830 static struct i2c_board_info i2c18_devs[] __initdata = {
831         {
832                 I2C_BOARD_INFO("si470x", (0x20 >> 1)),
833                 .irq = IRQ_EINT(20),
834         }
835 };
836
837 /* I2C16 */
838 static struct pn544_i2c_platform_data pn544_pdata = {
839         .irq_gpio = GPIO_NFC_IRQ,
840         .ven_gpio = GPIO_NFC_EN,
841         .firm_gpio = GPIO_NFC_FIRMWARE,
842 };
843
844 /* PN65NET1 NFC */
845 static struct i2c_board_info i2c16_devs[] __initdata = {
846         {
847                 I2C_BOARD_INFO("pn544", 0x2b),
848                 .platform_data  = &pn544_pdata,
849                 .irq            = IRQ_EINT(15),
850         },
851 };
852
853 /* USB EHCI */
854 static struct s5p_usb_ehci_platdata u1_usb_ehci_pdata;
855
856 static void __init u1_usb_ehci_init(void)
857 {
858         struct s5p_usb_ehci_platdata *pdata = &u1_usb_ehci_pdata;
859
860         /* The gpios is initialized from modem_init */
861         pdata->gpio_active = MOBILE_GPIO(ACTIVE_STATE_HSIC);
862
863         s5p_usb_ehci_set_platdata(pdata);
864 }
865
866 /* USB OTG */
867 /* we don't use OTGDRVVBUS pin for powering up otg charging pump */
868 static void u1_otg_power_cb(int enable)
869 {
870         int gpio;
871         u8 on = (u8)!!enable;
872         gpio = MOBILE_GPIO(USB_OTG_EN);
873         gpio_request(gpio, "USB_OTG_EN");
874         gpio_direction_output(gpio, on);
875         gpio_free(gpio);
876         pr_info("%s: otg power = %d\n", __func__, on);
877 }
878
879 static void __init u1_usb_otg_init(void)
880 {
881         struct host_notify_dev *u1_otg_ndev =
882                         dev_get_platdata(&s3c_device_usbgadget.dev);
883         struct sec_otghost_data *u1_otg_host_data =
884                         dev_get_platdata(&s3c_device_usb_otghcd.dev);
885
886         u1_otg_ndev->set_booster = u1_otg_power_cb;
887         u1_otg_host_data->set_pwr_cb = u1_otg_power_cb;
888 }
889
890 /* MODEM Net */
891 static struct platform_device u1_modem_net = {
892         .name                   = "modem_net",
893         .id                     = -1,
894 };
895
896 /* XMM6260 control */
897 static struct xmm6260_gpios u1_xmm6260_gpios;
898
899 static struct xmm6260_platform_data u1_xmm6260_pdata = {
900         .gpios                  = &u1_xmm6260_gpios,
901         .wakeup                 = 1,
902 };
903
904 /*
905  * SLP uses standardized device name of modemctl
906  * and this is same to Android.
907  */
908 static struct platform_device u1_xmm6260 = {
909         .name                   = "modemctl",
910         .id                     = -1,
911         .dev                    = {
912                 .platform_data  = &u1_xmm6260_pdata,
913         },
914 };
915
916 static void __init u1_modem_init(void)
917 {
918         struct xmm6260_gpios *gpios = &u1_xmm6260_gpios;
919         int gpio;
920
921         gpio = MOBILE_GPIO(CP_ON);
922         gpio_request(gpio, "CP_ON");
923         gpio_direction_output(gpio, 0);
924         gpios->cp_on = gpio;
925
926         gpio = MOBILE_GPIO(PHONE_ACTIVE);
927         gpio_request(gpio, "PHONE_ACTIVE");
928         gpios->phone_active = gpio;
929
930         gpio = MOBILE_GPIO(PDA_ACTIVE);
931         gpio_request(gpio, "PDA_ACTIVE");
932         gpio_direction_output(gpio, 0);
933         gpios->pda_active = gpio;
934
935         gpio = MOBILE_GPIO(CP_DUMP_INT);
936         gpio_request(gpio, "CP_DUMP_INT");
937         gpios->cp_dump_int = gpio;
938
939         gpio = MOBILE_GPIO(CP_PMU_RST);
940         gpio_request(gpio, "CP_PMU_RST");
941         gpio_direction_output(gpio, 0);
942         gpios->cp_pmu_rst = gpio;
943
944         gpio = MOBILE_GPIO(RESET_REQ_N);
945         gpio_request(gpio, "RESET_REQ_N");
946         gpio_direction_output(gpio, 0);
947         gpios->reset_req_n = gpio;
948
949         gpio = MOBILE_GPIO(IPC_SLAVE_WAKEUP);
950         gpio_request(gpio, "IPC_SLAVE_WAKEUP");
951         gpio_direction_output(gpio, 0);
952         gpios->ipc_slave_wakeup = gpio;
953
954         gpio = MOBILE_GPIO(IPC_HOST_WAKEUP);
955         gpio_request(gpio, "IPC_HOST_WAKEUP");
956         gpios->ipc_host_wakeup = gpio;
957
958         gpio = MOBILE_GPIO(SUSPEND_REQUEST_HSIC);
959         gpio_request(gpio, "SUSPEND_REQUEST_HSIC");
960         gpios->suspend_request_hsic = gpio;
961
962         gpio = MOBILE_GPIO(ACTIVE_STATE_HSIC);
963         gpio_request(gpio, "ACTIVE_STATE_HSIC");
964         gpio_direction_output(gpio, 0);
965         gpios->active_state_hsic = gpio;
966 }
967
968 /* Uart Select */
969 static void u1_set_uart_switch(int path)
970 {
971         int gpio;
972
973         gpio = MOBILE_GPIO(UART_SEL);
974         gpio_request(gpio, "UART_SEL");
975
976         /* u1 target is gpio_high == AP */
977         if (path == UART_SW_PATH_AP)
978                 gpio_set_value(gpio, GPIO_LEVEL_HIGH);
979         else if (path == UART_SW_PATH_CP)
980                 gpio_set_value(gpio, GPIO_LEVEL_LOW);
981
982         gpio_free(gpio);
983         return;
984 }
985
986 static int u1_get_uart_switch(void)
987 {
988         int val;
989         int gpio;
990
991         gpio = MOBILE_GPIO(UART_SEL);
992         gpio_request(gpio, "UART_SEL");
993         val = gpio_get_value(gpio);
994         gpio_free(gpio);
995
996         /* u1 target is gpio_high == AP */
997         if (val == GPIO_LEVEL_HIGH)
998                 return UART_SW_PATH_AP;
999         else if (val == GPIO_LEVEL_LOW)
1000                 return UART_SW_PATH_CP;
1001         else
1002                 return UART_SW_PATH_NA;
1003 }
1004
1005 static struct uart_select_platform_data u1_uart_select_data = {
1006         .set_uart_switch        = u1_set_uart_switch,
1007         .get_uart_switch        = u1_get_uart_switch,
1008 };
1009
1010 static struct platform_device u1_uart_select = {
1011         .name                   = "uart-select",
1012         .id                     = -1,
1013         .dev                    = {
1014                 .platform_data  = &u1_uart_select_data,
1015         },
1016 };
1017
1018 static struct regulator_consumer_supply emmc_supplies[] = {
1019         REGULATOR_SUPPLY("vmmc", "s3c-sdhci.0"),
1020         REGULATOR_SUPPLY("vmmc", "dw_mmc"),
1021 };
1022
1023 static struct regulator_init_data emmc_fixed_voltage_init_data = {
1024         .constraints            = {
1025                 .name           = "VMEM_VDD_2.8V",
1026                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
1027         },
1028         .num_consumer_supplies  = ARRAY_SIZE(emmc_supplies),
1029         .consumer_supplies      = emmc_supplies,
1030 };
1031
1032 static struct fixed_voltage_config emmc_fixed_voltage_config = {
1033         .supply_name            = "eMMC_EN",
1034         .microvolts             = 2800000,
1035         .gpio                   = S5PV310_GPK0(2),
1036         .enable_high            = true,
1037         .init_data              = &emmc_fixed_voltage_init_data,
1038 };
1039
1040 static struct platform_device emmc_fixed_voltage = {
1041         .name                   = "reg-fixed-voltage",
1042         .id                     = FIXED_REG_ID_MMC,
1043         .dev                    = {
1044                 .platform_data  = &emmc_fixed_voltage_config,
1045         },
1046 };
1047
1048 #ifdef CONFIG_GSD4T
1049 #include "gsd4t.h"
1050
1051 /* GSD4T GPS module */
1052 static struct gsd4t_platform_data u1_gsd4t_data = {
1053         .onoff          = S5PV310_GPE0(3),
1054         .nrst           = S5PV310_GPE0(4),
1055         .tsync          = S5PV310_GPE0(1),
1056         .uart_rxd       = S5PV310_GPA0(4),
1057         .uart_txd       = S5PV310_GPA0(5),
1058         .uart_cts       = S5PV310_GPA0(6),
1059         .uart_rts       = S5PV310_GPA0(7),
1060 };
1061
1062 static struct platform_device u1_gsd4t = {
1063         .name                   = "gsd4t",
1064         .id                     = -1,
1065         .dev                    = {
1066                 .platform_data  = &u1_gsd4t_data,
1067         },
1068 };
1069 #endif
1070
1071 /* MALI DRM. */
1072 #ifdef CONFIG_DRM_MALI
1073 static struct platform_device s5p_device_mali_drm = {
1074         .name                   = "mali_drm",
1075         .id                     = -1,
1076 };
1077 #endif
1078
1079 /* FIMD DRM. */
1080 #ifdef CONFIG_DRM_FIMD
1081 static struct resource fimd_drm_resource[] = {
1082         [0] = {
1083                 .start          = S5P_PA_LCD0,
1084                 .end            = S5P_PA_LCD0 + S5P_SZ_LCD0 - 1,
1085                 .flags          = IORESOURCE_MEM,
1086         },
1087         [1] = {
1088                 .start          = S5P_PA_LCD1,
1089                 .end            = S5P_PA_LCD1 + S5P_SZ_LCD1 - 1,
1090                 .flags          = IORESOURCE_MEM,
1091         },
1092         [2] = {
1093                 .start          = IRQ_LCD1,
1094                 .end            = IRQ_LCD1,
1095                 .flags          = IORESOURCE_IRQ,
1096         },
1097         [3] = {
1098                 .start          = IRQ_LCD0,
1099                 .end            = IRQ_LCD0,
1100                 .flags          = IORESOURCE_IRQ,
1101         },
1102 };
1103
1104 static struct fimd_drm_platform_data fimd_drm_pd = {
1105         .hw_ver = 0x70,
1106 };
1107
1108 static struct platform_device s5p_device_fimd_drm = {
1109         .name                   = "fimd_drm",
1110         .id                     = -1,
1111         .num_resources          = ARRAY_SIZE(fimd_drm_resource),
1112         .resource               = fimd_drm_resource,
1113         .dev                    = {
1114                 .platform_data = &fimd_drm_pd,
1115         },
1116 };
1117 #endif
1118
1119 /* ADC */
1120 static struct s3c_adc_platform_data s3c_adc_pdata __initdata = {
1121         .delay                  = 1000,
1122         .presc                  = 49,
1123         .resolution             = 12,
1124         .max_adc_voltage_uV     = 3300000,
1125 };
1126
1127 static void __init u1_adc_init(void)
1128 {
1129         s3c_adc_set_platdata(&s3c_adc_pdata);
1130 }
1131
1132 static void ramoops_enable(int enable)
1133 {
1134         struct clk *clk;
1135
1136         clk = clk_get(NULL, "modem");
1137         if (enable)
1138                 clk_enable(clk);
1139         else
1140                 clk_disable(clk);
1141         clk_put(clk);
1142 }
1143
1144 static struct ramoops_platform_data u1_ramoops_data = {
1145         .mem_address            = 0x13A00000,           /* MODEM I/F */
1146         .mem_size               = SZ_16K,
1147         .enable                 = ramoops_enable,
1148 };
1149
1150 static struct platform_device u1_ramoops = {
1151         .name                   = "ramoops",
1152         .dev                    = {
1153                 .platform_data  = &u1_ramoops_data,
1154         },
1155 };
1156
1157 /* TZPC */
1158 static struct platform_device u1_tzpc = {
1159         .name                   = "tzpc",
1160         .id                     = -1,
1161 };
1162
1163 #ifdef CONFIG_ANDROID_RAM_CONSOLE
1164 static struct resource ram_console_resource[] = {
1165         [0] = {
1166                 .flags = IORESOURCE_MEM,
1167         },
1168 };
1169
1170 static struct platform_device ram_console_device = {
1171         .name                   = "ram_console",
1172         .id                     = -1,
1173         .num_resources          = ARRAY_SIZE(ram_console_resource),
1174         .resource               = ram_console_resource,
1175 };
1176 #endif
1177
1178 static void __init u1_map_io(void)
1179 {
1180         s5p_init_io(NULL, 0, S5P_VA_CHIPID);
1181         s5p_xtal_set_parent(CLK_XUSBXTI);
1182         s3c24xx_init_clocks(24000000);
1183         s3c24xx_init_uarts(u1_uartcfgs, ARRAY_SIZE(u1_uartcfgs));
1184 }
1185
1186 static unsigned long fbmem_start, fbmem_size;
1187 static int __init early_fbmem(char *p)
1188 {
1189         char *endp;
1190
1191         if (!p)
1192                 return -EINVAL;
1193
1194         fbmem_size = memparse(p, &endp);
1195         if (*endp == '@')
1196                 fbmem_start = memparse(endp + 1, &endp);
1197
1198         return endp > p ? 0 : -EINVAL;
1199 }
1200 early_param("fbmem", early_fbmem);
1201
1202 static struct cma_region regions[] = {
1203 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMD0
1204         {
1205                 .name = "fimd",
1206                 .size = (CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMD0
1207 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMD1
1208                                 + CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMD1
1209 #endif
1210                         ) * SZ_1K,
1211         },
1212 #endif
1213 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC0
1214                 {
1215                         .name = "fimc0",
1216                         .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC0 * SZ_1K,
1217                         .start = 0
1218                 },
1219 #endif
1220 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC1
1221                 {
1222                         .name = "fimc1",
1223                         .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC1 * SZ_1K,
1224                         .start = 0
1225                 },
1226 #endif
1227 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC2
1228                 {
1229                         .name = "fimc2",
1230                         .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC2 * SZ_1K,
1231                         .start = 0
1232                 },
1233 #endif
1234 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC3
1235                 {
1236                         .name = "fimc3",
1237                         .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC3 * SZ_1K,
1238                         .start = 0
1239                 },
1240 #endif
1241
1242 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_S3C_MEM_CMA
1243                 {
1244                         .name = "s3c-mem-cma",
1245                         .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_S3C_MEM_CMA * SZ_1K,
1246                         .start = 0
1247                 },
1248 #endif
1249
1250 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_JPEG
1251         {
1252                 .name           = "jpeg",
1253                 .size           = CONFIG_VIDEO_SAMSUNG_MEMSIZE_JPEG *  SZ_1K,
1254         },
1255 #endif
1256 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC
1257         {
1258                 .name = "mfc",
1259                 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC *  SZ_1K,
1260         },
1261 #endif
1262 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC0
1263         {
1264                 .name = "mfc0",
1265                 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC0 * SZ_1K,
1266                 {
1267                         .alignment = 1 << 17,
1268                 },
1269         },
1270 #endif
1271 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC1
1272         {
1273                 .name = "mfc1",
1274                 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC1 * SZ_1K,
1275                 {
1276                         .alignment = 1 << 17,
1277                 },
1278         },
1279 #endif
1280 #ifdef CONFIG_VIDEO_SAMSUNG_S5P_MFC
1281         {
1282                 .name           = "fw",
1283                 .size           = 1 << 20,
1284                 { .alignment    = 128 << 10 },
1285                 .start          = 0x42000000,
1286         },
1287         {
1288                 .name           = "b1",
1289                 .size           = 32 << 20,
1290                 .start          = 0x43000000,
1291         },
1292         {
1293                 .name           = "b2",
1294                 .size           = 32 << 20,
1295                 .start          = 0x51000000,
1296         },
1297 #endif
1298 #ifdef CONFIG_SEC_DEBUG
1299         {
1300                 .name           = "getlog",
1301                 .size           = 1 << 12,
1302                 .start          = 0x40003000,
1303         },
1304 #endif
1305         { }
1306 };
1307
1308 static void __init s5pv310_reserve(void)
1309 {
1310         static const char map[] __initconst =
1311                 "s3cfb=fimd;"
1312 #ifdef CONFIG_VIDEO_FIMC
1313                 "s3c-fimc.0=fimc0;"
1314                 "s3c-fimc.1=fimc1;"
1315                 "s3c-fimc.2=fimc2;"
1316                 "s3c-fimc.3=fimc3;"
1317 #endif
1318 #ifdef CONFIG_S3C_MEM_CMA_ALLOC
1319                 "s3c-mem=s3c-mem-cma;"
1320 #endif
1321
1322                 "s5p-jpeg=jpeg;"
1323 #ifdef CONFIG_SEC_DEBUG
1324                 "s3c-getlog=getlog;"
1325 #endif
1326
1327 #if defined(CONFIG_VIDEO_SAMSUNG_S5P_MFC)
1328                 "mfc=mfc,mfc0,mfc1;"
1329                 "s5p-mfc/f=fw;s5p-mfc/a=b1;s5p-mfc/b=b2;"
1330 #else
1331 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_PROFILING
1332                 "s3c-mfc/mfc=mfc;s3c-mfc/mfc0=mfc0;s3c-mfc/mfc1=mfc1;"
1333 #else
1334                 "s3c-mfc=mfc,mfc0,mfc1;"
1335 #endif
1336 #endif
1337                 "*=b1,b2";
1338
1339         unsigned int i = 0;
1340
1341 #ifdef CONFIG_ANDROID_RAM_CONSOLE
1342         unsigned int addr;
1343
1344         /* FIXME: ram console MUST be reserved at first time */
1345         addr = memblock_alloc_base(SZ_1M, SZ_4K, 0x60000000);
1346         ram_console_resource[0].start = addr;
1347         ram_console_resource[0].end = addr + SZ_1M - 1;
1348         pr_info("ram_console: 0x%08x ~ 0x%08x (1MB)\n",
1349                         addr, addr + SZ_1M);
1350 #endif
1351
1352         if (fbmem_start)
1353                 regions[0].start = (dma_addr_t)fbmem_start;
1354         if (fbmem_size)
1355                 regions[0].size = (size_t)fbmem_size;
1356 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_PROFILING
1357 {
1358         unsigned int regions_cnt = 0;
1359         size_t fimd_size, fimc1_size, fimc2_size, fimc3_size, mfc0_size, mfc1_size, s3c_mem_size =0;
1360
1361         switch (u1_profile_level){
1362         case 3:
1363         case 2: /* 240 * 320 */
1364                 fimd_size = 1800 * SZ_1K;
1365                 fimc1_size = 3072 * SZ_1K;
1366                 fimc2_size = 4096 * SZ_1K;
1367                 fimc3_size = 1536 * SZ_1K;
1368                 s3c_mem_size = 4096 * SZ_1K;
1369                 mfc0_size = 10240 * SZ_1K;
1370                 mfc1_size = 10240 * SZ_1K;
1371                 break;
1372         case 1: /* 320 * 480 */
1373                 fimd_size = 3600 * SZ_1K;
1374                 fimc1_size = 3072 * SZ_1K;
1375                 fimc2_size = 4096 * SZ_1K;
1376                 fimc3_size = 1536 * SZ_1K;
1377                 s3c_mem_size = 4096 * SZ_1K;
1378                 mfc0_size = 10240 * SZ_1K;
1379                 mfc1_size = 10240 * SZ_1K;
1380                 break;
1381         default:        /* 480 * 800 */
1382                 fimd_size = 9000 * SZ_1K;
1383                 fimc1_size = 18664* SZ_1K;
1384                 fimc2_size = 24576 * SZ_1K;
1385                 fimc3_size = 8192 * SZ_1K;
1386                 s3c_mem_size = 24576 * SZ_1K;
1387                 mfc0_size = 24576 * SZ_1K;
1388                 mfc1_size = 24576 * SZ_1K;
1389                 break;
1390         }
1391         for (; regions_cnt < ARRAY_SIZE(regions) - 1 /* terminator */; ++regions_cnt){
1392                 if (strncmp(regions[regions_cnt].name, "fimd", 4) == 0)
1393                 regions[regions_cnt].size = PAGE_ALIGN(fimd_size);
1394                 if (strncmp(regions[regions_cnt].name, "fimc1", 5) == 0)
1395                 regions[regions_cnt].size = PAGE_ALIGN(fimc1_size);
1396                 if (strncmp(regions[regions_cnt].name, "fimc2", 5) == 0)
1397                 regions[regions_cnt].size = PAGE_ALIGN(fimc2_size);
1398                 if (strncmp(regions[regions_cnt].name, "fimc3", 5) == 0)
1399                 regions[regions_cnt].size = PAGE_ALIGN(fimc3_size);
1400                 if (strncmp(regions[regions_cnt].name, "mfc0", 4) == 0)
1401                 regions[regions_cnt].size = PAGE_ALIGN(mfc0_size);
1402                 if (strncmp(regions[regions_cnt].name, "mfc1", 4) == 0)
1403                 regions[regions_cnt].size = PAGE_ALIGN(mfc1_size);
1404                 if (strncmp(regions[regions_cnt].name, "s3c-mem-cma", 11) == 0)
1405                 regions[regions_cnt].size = PAGE_ALIGN(s3c_mem_size);
1406         }
1407 }
1408 #endif
1409
1410         cma_set_defaults(regions, map);
1411         cma_early_regions_reserve(NULL);
1412
1413         for (; i < ARRAY_SIZE(regions) - 1 /* terminator */; ++i) {
1414                 pr_info("cma: region: %-8s: 0x%08x ~ 0x%08x (%dMB) real size=%d \n",
1415                                 regions[i].name, regions[i].start,
1416                                 regions[i].start + regions[i].size,
1417                                 regions[i].size / SZ_1M, regions[i].size);
1418         }
1419 }
1420
1421 #ifdef CONFIG_HIBERNATION
1422 static int __init u1_set_nosave_regions(void)
1423 {
1424         int i;
1425
1426         for ( i = ARRAY_SIZE(regions) - 2; i >= 0 /* terminator */; i--) {
1427                 /* MFC firmware SHOULD BE saved.
1428                  * If the region is fw, don't register to nosave regions */
1429                 if (strcmp(regions[i].name, "fw"))
1430                         register_nosave_region_late(
1431                                         __phys_to_pfn(regions[i].start),
1432                                         __phys_to_pfn(regions[i].start +
1433                                                 regions[i].size));
1434         }
1435         return 0;
1436 }
1437 late_initcall(u1_set_nosave_regions);
1438 #endif
1439
1440 /*
1441  * GPX are saved and restored at plat-samsung/pm.c:s5c_pm_enter.
1442  * However, they are inside of pm_prepare and pm_finish, so it
1443  * does not save ours against universal_pm_prepare:2.
1444  */
1445 static struct sleep_save s5pc210_gpx[] = {
1446         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C00),
1447         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C04),
1448         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C08),
1449         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C0C),
1450         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C20),
1451         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C24),
1452         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C28),
1453         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C2C),
1454         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C40),
1455         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C44),
1456         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C48),
1457         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C4C),
1458         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C60),
1459         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C64),
1460         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C68),
1461         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C6C),
1462 };
1463
1464 /* GPIO KEYS */
1465 static struct gpio_keys_button u1_gpio_keys_tables[] = {
1466         {
1467                 .code                   = KEY_VOLUMEUP,
1468                 .gpio                   = S5PV310_GPX2(0),      /* XEINT16 */
1469                 .desc                   = "gpio-keys: KEY_VOLUMEUP",
1470                 .type                   = EV_KEY,
1471                 .active_low             = 1,
1472                 .debounce_interval      = 1,
1473 /* YUBAEK 20110905 RAMDUMP_DEBUG : Android forceable ramdump ++ */
1474         #ifdef CONFIG_INPUT_FORCE_PANIC_KEY
1475                 .isr_hook = sec_debug_check_crash_key , /* VOL UP */
1476         #endif
1477 /* YUBAEK 20110905 RAMDUMP_DEBUG : Android forceable ramdump -- */
1478
1479         }, {
1480                 .code                   = KEY_VOLUMEDOWN,
1481                 .gpio                   = S5PV310_GPX2(1),      /* XEINT17 */
1482                 .desc                   = "gpio-keys: KEY_VOLUMEDOWN",
1483                 .type                   = EV_KEY,
1484                 .active_low             = 1,
1485                 .debounce_interval      = 1,
1486 /* YUBAEK 20110905 RAMDUMP_DEBUG : Android forceable ramdump ++ */
1487         #ifdef CONFIG_INPUT_FORCE_PANIC_KEY
1488                 .isr_hook = sec_debug_check_crash_key , /*VOL DOWN */
1489         #endif
1490 /* YUBAEK 20110905 RAMDUMP_DEBUG : Android forceable ramdump -- */
1491
1492         }, {
1493                 .code                   = KEY_POWER,
1494                 .gpio                   = S5PV310_GPX2(7),      /* XEINT23 */
1495                 .desc                   = "gpio-keys: KEY_POWER",
1496                 .type                   = EV_KEY,
1497                 .active_low             = 1,
1498                 .wakeup                 = 1,
1499                 .debounce_interval      = 1,
1500         }, {
1501                                         /* KEY_MENU will be used */
1502                 .code                   = KEY_MENU,             /* KEY_OK */
1503                 .gpio                   = S5PV310_GPX3(5),      /* XEINT29 */
1504                 .desc                   = "gpio-keys: KEY_MENU",
1505                 .type                   = EV_KEY,
1506                 .active_low             = 1,
1507                 .wakeup                 = 1,
1508                 .debounce_interval      = 1,
1509 /* YUBAEK 20110905 RAMDUMP_DEBUG : Android forceable ramdump ++ */
1510         #ifdef CONFIG_INPUT_FORCE_PANIC_KEY
1511                 .isr_hook = sec_debug_check_crash_key , /* HOME */
1512         #endif
1513 /* YUBAEK 20110905 RAMDUMP_DEBUG : Android forceable ramdump -- */
1514
1515         },
1516 };
1517
1518 static struct gpio_keys_platform_data u1_gpio_keys_data = {
1519         .buttons                = u1_gpio_keys_tables,
1520         .nbuttons               = ARRAY_SIZE(u1_gpio_keys_tables),
1521 };
1522
1523 static struct platform_device u1_gpio_keys = {
1524         .name                   = "gpio-keys",
1525         .dev                    = {
1526                 .platform_data  = &u1_gpio_keys_data,
1527         },
1528 };
1529
1530
1531
1532 static unsigned int ld9040_lcd_enabled;
1533
1534 static struct s3cfb_lcd ld9040 = {
1535         .width = 480,
1536         .height = 800,
1537         .width_mm = 56, //59,
1538         .height_mm = 93, //98,
1539         .bpp = 24,
1540
1541         .freq = 60,
1542         .timing = {
1543                 .h_fp = 16,
1544                 .h_bp = 16,
1545                 .h_sw = 2,
1546                 .v_fp = 4,
1547                 .v_fpe = 1,
1548                 .v_bp = 6,
1549                 .v_bpe = 1,
1550                 .v_sw = 2,
1551         },
1552         .polarity = {
1553                 .rise_vclk = 1,
1554                 .inv_hsync = 1,
1555                 .inv_vsync = 1,
1556                 .inv_vden = 1,
1557         },
1558 };
1559
1560 static int lcd_cfg_gpio(void)
1561 {
1562         int i, f3_end = 4;
1563         u32 reg;
1564
1565         for (i = 0; i < 8; i++) {
1566                 /* set GPF0,1,2[0:7] for RGB Interface and Data lines (32bit) */
1567                 s3c_gpio_cfgpin(S5PV310_GPF0(i), S3C_GPIO_SFN(2));
1568                 s3c_gpio_setpull(S5PV310_GPF0(i), S3C_GPIO_PULL_NONE);
1569
1570         }
1571         for (i = 0; i < 8; i++) {
1572                 s3c_gpio_cfgpin(S5PV310_GPF1(i), S3C_GPIO_SFN(2));
1573                 s3c_gpio_setpull(S5PV310_GPF1(i), S3C_GPIO_PULL_NONE);
1574         }
1575
1576         for (i = 0; i < 8; i++) {
1577                 s3c_gpio_cfgpin(S5PV310_GPF2(i), S3C_GPIO_SFN(2));
1578                 s3c_gpio_setpull(S5PV310_GPF2(i), S3C_GPIO_PULL_NONE);
1579         }
1580
1581         for (i = 0; i < f3_end; i++) {
1582                 s3c_gpio_cfgpin(S5PV310_GPF3(i), S3C_GPIO_SFN(2));
1583                 s3c_gpio_setpull(S5PV310_GPF3(i), S3C_GPIO_PULL_NONE);
1584         }
1585
1586         /* Set FIMD0 bypass */
1587         reg = __raw_readl(S3C_VA_SYS + 0x0210);
1588         reg |= (1<<1);
1589         __raw_writel(reg, S3C_VA_SYS + 0x0210);
1590
1591         return 0;
1592 }
1593
1594 static int lcd_power_on(struct lcd_device *ld, int enable)
1595 {
1596         static struct regulator *regulator_vcc_lcd;
1597         static struct regulator *regulator_vcc;
1598         static DEFINE_MUTEX(lock);
1599         static int enabled = -1; /* -1: unknown, 0: off, 1 : on */
1600         int ret = 0;
1601
1602         if (ld == NULL) {
1603                 printk(KERN_ERR "lcd device object is NULL.\n");
1604                 return 0;
1605         }
1606
1607         mutex_lock(&lock);
1608
1609         if (enabled == 1 && enable)
1610                 goto out;
1611         if (enabled == 0 && !enable)
1612                 goto out;
1613
1614         if (regulator_vcc_lcd == NULL)
1615                 regulator_vcc_lcd =
1616                     regulator_get_exclusive(&ld->dev, "vcc_3.0v_lcd");
1617         if (IS_ERR_OR_NULL(regulator_vcc_lcd)) {
1618                 ret = -1;
1619                 regulator_vcc_lcd = NULL;
1620                 goto out;
1621         }
1622
1623         if (regulator_vcc == NULL)
1624                 regulator_vcc = regulator_get(&ld->dev, "vcc_1.8v");
1625         if (IS_ERR_OR_NULL(regulator_vcc)) {
1626                 ret = -1;
1627                 regulator_vcc = NULL;
1628                 goto out;
1629         }
1630
1631         if (enabled == -1) {
1632                 if (enable) {
1633                         /*
1634                          * Exclusively got regulator may have initial
1635                          * use_count = 1; thus, we need to check is_enabled.
1636                          */
1637                         if (!regulator_is_enabled(regulator_vcc_lcd))
1638                                 regulator_enable(regulator_vcc_lcd);
1639                         regulator_enable(regulator_vcc);
1640                         enabled = 1;
1641                 } else {
1642                         if (regulator_is_enabled(regulator_vcc_lcd))
1643                                 regulator_disable(regulator_vcc_lcd);
1644                         /* No need to disable shared regulator */
1645                         enabled = 0;
1646                 }
1647         } else {
1648                 if (enable) {
1649                         regulator_enable(regulator_vcc_lcd);
1650                         regulator_enable(regulator_vcc);
1651                         enabled = 1;
1652                 } else {
1653                         regulator_disable(regulator_vcc_lcd);
1654                         regulator_disable(regulator_vcc);
1655                         enabled = 0;
1656                 }
1657         }
1658
1659         if (ld9040_lcd_enabled)
1660                 ld9040_lcd_enabled = 0;
1661 out:
1662         mutex_unlock(&lock);
1663         return ret;
1664 }
1665
1666 static int reset_lcd(struct lcd_device *ld)
1667 {
1668         static unsigned int first = 1;
1669         int reset_gpio = -1;
1670
1671         reset_gpio = S5PV310_GPY4(5);
1672
1673         if (first) {
1674                 gpio_request(reset_gpio, "MLCD_RST");
1675                 first = 0;
1676         }
1677
1678         mdelay(10);
1679         gpio_direction_output(reset_gpio, 0);
1680         mdelay(10);
1681         gpio_direction_output(reset_gpio, 1);
1682
1683         return 1;
1684 }
1685
1686 static int __init early_lcd(char *p)
1687 {
1688         if (memcmp(p, "ld9040", 6) == 0)
1689                 ld9040_lcd_enabled = 1;
1690
1691         return 0;
1692 }
1693 early_param("lcd", early_lcd);
1694
1695 static struct lcd_platform_data ld9040_platform_data = {
1696         .reset                  = reset_lcd,
1697         .power_on               = lcd_power_on,
1698         /* it indicates whether lcd panel is enabled from u-boot. */
1699         .lcd_enabled            = 1,
1700         .reset_delay            = 10,   /* 10ms */
1701         .power_on_delay         = 10,   /* 10ms */
1702         .power_off_delay        = 120,  /* 120ms */
1703 };
1704
1705 #define LCD_BUS_NUM     3
1706 #define DISPLAY_CS      S5PV310_GPY4(3)
1707 static struct spi_board_info spi_board_info[] __initdata = {
1708         {
1709                 .max_speed_hz   = 1200000,
1710                 .bus_num        = LCD_BUS_NUM,
1711                 .chip_select    = 0,
1712                 .mode           = SPI_MODE_3,
1713                 .controller_data = (void *)DISPLAY_CS,
1714         },
1715 };
1716
1717 #define DISPLAY_CLK     S5PV310_GPY3(1)
1718 #define DISPLAY_SI      S5PV310_GPY3(3)
1719 static struct spi_gpio_platform_data lcd_spi_gpio_data = {
1720         .sck                    = DISPLAY_CLK,
1721         .mosi                   = DISPLAY_SI,
1722         .miso                   = SPI_GPIO_NO_MISO,
1723         .num_chipselect         = 1,
1724 };
1725
1726 static struct platform_device u1_spi_gpio = {
1727         .name                   = "spi_gpio",
1728         .id                     = LCD_BUS_NUM,
1729         .dev                    = {
1730                 .parent         = &s3c_device_fb.dev,
1731                 .platform_data  = &lcd_spi_gpio_data,
1732         },
1733 };
1734
1735 #ifdef CONFIG_VIDEO_FIMG2D
1736 static struct fimg2d_platdata fimg2d_data __initdata = {
1737         .hw_ver                 = 30,
1738         .parent_clkname         = "mout_g2d0",
1739         .clkname                = "sclk_fimg2d",
1740         .gate_clkname           = "fimg2d",
1741         .smmu_gate_clkname      = "smmu_fimg2d",
1742         .clkrate                = 250 * 1000000,
1743 };
1744 #endif
1745
1746 static struct s3c_platform_fb fb_platform_data __initdata = {
1747         .hw_ver                 = 0x70,
1748         .nr_wins                = 5,
1749 #ifdef CONFIG_FB_S3C_DEFAULT_WINDOW
1750         .default_win            = CONFIG_FB_S3C_DEFAULT_WINDOW,
1751 #else
1752         .default_win            = 0,
1753 #endif
1754         .swap                   = FB_SWAP_HWORD | FB_SWAP_WORD,
1755 };
1756
1757 #ifdef CONFIG_FB_S3C_HIBERNATION_LOADING
1758 #include <linux/hib_ani.h>
1759
1760 static struct s3cfb_hib_ani hib_ani_set __initdata = {
1761         .text_ani1 = {
1762                 .width = 378,
1763                 .height = 39,
1764                 .x_point = 51,
1765                 .y_point =193,
1766
1767         },
1768         .text_ani2 = {
1769                 .width = 184,
1770                 .height = 64,
1771                 .x_point = 150,
1772                 .y_point = 650,
1773
1774         },
1775         .count_ani = {
1776                 .width = 170,
1777                 .height = 171,
1778                 .x_point = 154,
1779                 .y_point = 320,
1780         },
1781         .delay = 400,
1782         .hib_animation = hib_anis,
1783
1784 };
1785 #endif
1786
1787 static void __init u1_fb_init(void)
1788 {
1789         struct device *dev = s3c_device_fb.dev.parent;
1790         struct samsung_pd_info *pdinfo;
1791
1792         if (dev) {
1793                 pdinfo = (struct samsung_pd_info *)dev->platform_data;
1794                 /* fimd driver have to know LCD domain power status. */
1795                 if (pdinfo)
1796                         fb_platform_data.boot_on = pdinfo->boot_on;
1797         }
1798
1799         if (fbmem_start)
1800                 fb_platform_data.logo_on = 1;
1801
1802         strcpy(spi_board_info[0].modalias, "ld9040");
1803
1804         ld9040_platform_data.lcd_enabled = ld9040_lcd_enabled;
1805         spi_board_info[0].platform_data =
1806         (void *)&ld9040_platform_data;
1807
1808 #ifdef CONFIG_FB_S3C_HIBERNATION_LOADING
1809         fb_platform_data.hib_ani = (void *)&hib_ani_set;
1810 #endif
1811         spi_register_board_info(spi_board_info,
1812         ARRAY_SIZE(spi_board_info));
1813
1814 #ifdef  CONFIG_VIDEO_SAMSUNG_MEMSIZE_PROFILING
1815         /* for RAM profiling each LCD resolution */
1816         switch (u1_profile_level){
1817         case 0: /* WVGA: 480 * 800 */
1818                 break;
1819         case 1: /* HVGA: 320 * 480 */
1820                 ld9040.width_mm = 320 * ld9040.width_mm / ld9040.width;
1821                 ld9040.height_mm = 480 * ld9040.height_mm / ld9040.height;
1822                 ld9040.width = 320;
1823                 ld9040.height = 480;
1824                 break;
1825         case 2: /* QVGA: 240 * 320 */
1826                 ld9040.width_mm = 240 * ld9040.width_mm / ld9040.width;
1827                 ld9040.height_mm = 320 * ld9040.height_mm / ld9040.height;
1828                 ld9040.width = 240;
1829                 ld9040.height = 320;
1830                 break;
1831         case 3:
1832         default:
1833                 break;
1834         }
1835         printk("width = %d, height = %d, width_mm = %d, height_mm = %d\n",
1836                                 ld9040.width, ld9040.height, ld9040.width_mm, ld9040.height_mm);
1837 #endif
1838
1839         fb_platform_data.lcd_data = (struct s3cfb_lcd *)&ld9040;
1840
1841         lcd_cfg_gpio();
1842         s3cfb_set_platdata(&fb_platform_data);
1843 }
1844
1845 /* YUBAEK 20110905 RAMDUMP_DEBUG : GPIO Dump ++ */
1846 #ifdef CONFIG_SEC_DEBUG_PERIPHERAL_DUMP_GPIO
1847 void __iomem *s5pv310_gpio_class_a_addr;
1848 void __iomem *s5pv310_gpio_class_b_addr;
1849 static void s5pv310_gpio_io_map(void)
1850 {
1851     s5pv310_gpio_class_a_addr = ioremap(S5PV310_PA_GPIO1, SZ_4K);
1852     s5pv310_gpio_class_b_addr = ioremap(S5PV310_PA_GPIO2, SZ_4K);
1853 }
1854 #endif /* CONFIG_SEC_DEBUG_PERIPHERAL_DUMP_GPIO */
1855 /* YUBAEK 20110905 RAMDUMP_DEBUG : GPIO Dump -- */
1856
1857 /* Jack */
1858 static struct jack_platform_data u1_jack_data = {
1859         .usb_online             = 0,
1860         .charger_online         = 0,
1861         .hdmi_online            = -1,
1862         .earjack_online         = 0,
1863         .earkey_online          = 0,
1864         .ums_online             = -1,
1865         .cdrom_online           = -1,
1866         .jig_online             = 0,
1867 };
1868
1869 static struct platform_device u1_jack = {
1870         .name                   = "jack",
1871         .id                     = -1,
1872         .dev                    = {
1873                 .platform_data  = &u1_jack_data,
1874         },
1875 };
1876
1877 //device dependent regulator feature
1878
1879 //============================================================
1880 // FM Radio
1881 //============================================================
1882 static struct regulator_consumer_supply fmradio_supplies[] = {
1883         {
1884                 .supply         = "vradio",
1885         },
1886 };
1887
1888 static struct regulator_init_data fmradio_fixed_voltage_init_data = {
1889         .constraints    = {
1890                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
1891         },
1892         .num_consumer_supplies  = ARRAY_SIZE(fmradio_supplies),
1893         .consumer_supplies      = fmradio_supplies,
1894 };
1895 #define GPIO_FM_RST             S5PV310_GPB(0)
1896 static struct fixed_voltage_config fmradio_fixed_voltage_config = {
1897         .supply_name            = "FM_RST",
1898         .microvolts             = 2800000,
1899         .gpio                   = GPIO_FM_RST,
1900         .enable_high            = true,
1901         .init_data              = &fmradio_fixed_voltage_init_data,
1902 };
1903
1904 static struct platform_device fmradio_fixed_voltage = {
1905         .name           = "reg-fixed-voltage",
1906         .id             = FIXED_REG_ID_RADIO,
1907         .dev            = {
1908                 .platform_data  = &fmradio_fixed_voltage_config,
1909         },
1910 };
1911
1912 static void u1_sec_switch_init(void)
1913 {
1914         sec_class = class_create(THIS_MODULE, "sec");
1915
1916         if (IS_ERR(sec_class))
1917                 pr_err("Failed to create class(sec)!\n");
1918
1919         switch_dev = device_create(sec_class, NULL, 0, NULL, "switch");
1920
1921         if (IS_ERR(switch_dev))
1922                 pr_err("Failed to create device(switch)!\n");
1923
1924 //      ret = device_create_file(switch_dev, &dev_attr_disable_vbus);
1925 //      if (ret)
1926 //              pr_err("Failed to create device file(disable_vbus)!\n");
1927
1928 #ifdef CONFIG_TARGET_LOCALE_KOR
1929         usb_lock = device_create(sec_class, switch_dev,
1930                                 MKDEV(0, 0), NULL, ".usb_lock");
1931
1932         if (IS_ERR(usb_lock)) {
1933                 pr_err("Failed to create device (usb_lock)!\n");
1934                 return;
1935         }
1936
1937         if (device_create_file(usb_lock, &dev_attr_enable) < 0)
1938                 pr_err("Failed to create device file(.usblock/enable)!\n");
1939 #endif
1940 };
1941
1942 static struct u1_charging_status_callbacks {
1943 void    (*tsp_set_charging_cable) (int type);
1944 } charging_cbs;
1945
1946 static bool is_cable_attached;
1947
1948 static int u1_charger_cb(cable_type_t cable_type)
1949 {
1950         union power_supply_propval value;
1951         int ret = 0;
1952
1953         switch(cable_type) {
1954         case CABLE_TYPE_NONE:
1955         case CABLE_TYPE_OTG:
1956         case CABLE_TYPE_JIG_UART_OFF:
1957                 value.intval = POWER_SUPPLY_TYPE_BATTERY;
1958                 is_cable_attached = false;
1959                 break;
1960         case CABLE_TYPE_USB:
1961         case CABLE_TYPE_JIG_USB_OFF:
1962         case CABLE_TYPE_JIG_USB_ON:
1963                 value.intval = POWER_SUPPLY_TYPE_USB;
1964                 is_cable_attached = true;
1965                 break;
1966         case CABLE_TYPE_DESKDOCK:
1967         case CABLE_TYPE_CARDOCK:
1968                 value.intval = POWER_SUPPLY_TYPE_DOCK;
1969                 is_cable_attached = true;
1970                 break;
1971         case CABLE_TYPE_TA:
1972         case CABLE_TYPE_JIG_UART_OFF_VB:
1973                 value.intval = POWER_SUPPLY_TYPE_MAINS;
1974                 is_cable_attached = true;
1975                 break;
1976         default:
1977                 pr_err("%s: invalid type:%d\n", __func__, cable_type);
1978                 return -EINVAL;
1979         }
1980
1981         if (charging_cbs.tsp_set_charging_cable)
1982                 charging_cbs.tsp_set_charging_cable(value.intval);
1983
1984 #ifdef CONFIG_JACK_MON
1985         jack_event_handler("charger", is_cable_attached);
1986 #endif
1987
1988         return ret;
1989 }
1990
1991 static struct regulator *regulator_vbus_ap;
1992 static bool ap_enabled;
1993 static DEFINE_MUTEX(usb_ap_lock);
1994
1995 static void u1_usb_cb(u8 usb_mode)
1996 {
1997         int ret;
1998         struct s3c_udc *udc = platform_get_drvdata(&s3c_device_usbgadget);
1999         struct sec_otghost_data *otg_data =
2000                         dev_get_platdata(&s3c_device_usb_otghcd.dev);
2001
2002         unsigned long inform6 = __raw_readl(S5P_INFORM6);
2003
2004         pr_info("%s: usb mode=%d, inform6=0x%08lx\n", __func__, usb_mode, inform6);
2005
2006         if (inform6 & RST_FLAG_CHARGE_REBOOT_CHECK ) {
2007                 pr_info("%s: lpcharging: disable USB\n", __func__);
2008                 ret = udc->change_usb_mode(USB_CABLE_DETACHED);
2009                 if (ret < 0)
2010                         pr_warn("%s: fail to change mode!!!\n", __func__);
2011
2012                 mutex_lock(&usb_ap_lock);
2013
2014                 if (regulator_vbus_ap == NULL)
2015                         regulator_vbus_ap =
2016                             regulator_get_exclusive(NULL, "usb_vbus_ap_5v");
2017                 if (IS_ERR_OR_NULL(regulator_vbus_ap)) {
2018                         pr_err("%s: fail to get regulator\n", __func__);
2019                         regulator_vbus_ap = NULL;
2020                         goto out;
2021                 }
2022
2023                 if (ap_enabled) {
2024                         ret = regulator_disable(regulator_vbus_ap);
2025                         if (ret)
2026                                 goto out;
2027                         ap_enabled = false;
2028                 }
2029 out:
2030                 mutex_unlock(&usb_ap_lock);
2031                 return;
2032         }
2033
2034         if (udc) {
2035                 if (usb_mode == USB_OTGHOST_ATTACHED) {
2036                         otg_data->set_pwr_cb(1);
2037                         u1_charger_cb(CABLE_TYPE_OTG);
2038                 }
2039
2040                 pr_info("%s: prev_usb_mode=%d\n", __func__, udc->get_usb_mode());
2041
2042                 ret = udc->change_usb_mode(usb_mode);
2043                 if (ret < 0)
2044                         pr_err("%s: fail to change mode!!!\n", __func__);
2045
2046                 if (usb_mode == USB_OTGHOST_DETACHED)
2047                         otg_data->set_pwr_cb(0);
2048
2049 #ifdef CONFIG_JACK_MON
2050                 if (usb_mode == USB_OTGHOST_ATTACHED)
2051                         jack_event_handler("host", USB_CABLE_ATTACHED);
2052                 else if (usb_mode == USB_OTGHOST_DETACHED)
2053                         jack_event_handler("host", USB_CABLE_DETACHED);
2054                 else if ((usb_mode == USB_CABLE_ATTACHED)
2055                                 || (usb_mode == USB_CABLE_DETACHED))
2056                         jack_event_handler("usb", usb_mode);
2057 #endif
2058         }
2059 }
2060
2061 /* I2C3: TSP */
2062
2063 #if defined(CONFIG_TOUCHSCREEN_MXT224U1)
2064 static void mxt224_power_on(void)
2065 {
2066         int gpio = 0;
2067         gpio = MOBILE_GPIO(TSP_LDO_ON);
2068         s3c_gpio_cfgpin(gpio, S3C_GPIO_OUTPUT);
2069         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
2070         gpio_set_value(gpio, GPIO_LEVEL_HIGH);
2071
2072         mdelay(70);
2073         gpio = MOBILE_GPIO(TSP_INT);
2074         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
2075         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
2076         /*mdelay(40); */
2077         /* printk("mxt224_power_on is finished\n"); */
2078 }
2079
2080 static void mxt224_power_off(void)
2081 {
2082         int gpio = 0;
2083
2084         gpio = MOBILE_GPIO(TSP_INT);
2085         s3c_gpio_cfgpin(gpio, S3C_GPIO_INPUT);
2086         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_DOWN);
2087
2088         gpio = MOBILE_GPIO(TSP_LDO_ON);
2089         s3c_gpio_cfgpin(gpio, S3C_GPIO_OUTPUT);
2090         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
2091         gpio_set_value(gpio, GPIO_LEVEL_LOW);
2092         /* printk("mxt224_power_off is finished\n"); */
2093 }
2094
2095 static void mxt224_register_callback(void *function)
2096 {
2097         charging_cbs.tsp_set_charging_cable = function;
2098 }
2099
2100 static void mxt224_read_ta_status(void *ta_status)
2101 {
2102         bool *stat = ta_status;
2103         *stat = is_cable_attached;
2104 }
2105
2106 #define MXT224_MAX_MT_FINGERS 10
2107
2108 /*
2109         Configuration for MXT224
2110 */
2111 static u8 t7_config[] = {GEN_POWERCONFIG_T7,
2112                                 64, 255, 15};
2113 static u8 t8_config[] = {GEN_ACQUISITIONCONFIG_T8,
2114                                 10, 0, 5, 0, 0, 0, 9, 30};
2115 static u8 t9_config[] = {TOUCH_MULTITOUCHSCREEN_T9,
2116                                 131, 0, 0, 19, 11, 0, 32, MXT224_THRESHOLD, 2, 1, 0, 15, 1,
2117                                 13, MXT224_MAX_MT_FINGERS, 5, 40, 10, 31, 3,
2118                                 223, 1, 0, 0, 0, 0, 143, 55, 143, 90, 18};
2119
2120 static u8 t18_config[] = {SPT_COMCONFIG_T18,
2121                                 0, 1};
2122 static u8 t20_config[] = {PROCI_GRIPFACESUPPRESSION_T20,
2123                                 7, 0, 0, 0, 0, 0, 0, 30, 20, 4, 15, 10};
2124 static u8 t22_config[] = {PROCG_NOISESUPPRESSION_T22,
2125                                 13, 0, 0, 0, 0, 0, 0, 3, 30, 0, 0,  29, 34, 39,
2126                                 49, 58, 3};
2127 static u8 t28_config[] = {SPT_CTECONFIG_T28,
2128                                 0, 0, 3, 16, 19, 60};
2129 static u8 end_config[] = {RESERVED_T255};
2130
2131 static const u8 *mxt224_config[] = {
2132         t7_config,
2133         t8_config,
2134         t9_config,
2135         t18_config,
2136         t20_config,
2137         t22_config,
2138         t28_config,
2139         end_config,
2140 };
2141
2142 #define GPIO_READ_DONE  S5PV310_GPX0(4)
2143
2144 static struct mxt224_platform_data mxt224_data = {
2145         .max_finger_touches = MXT224_MAX_MT_FINGERS,
2146         .gpio_read_done = GPIO_READ_DONE,
2147         .config = mxt224_config,
2148         .min_x = 0,
2149         .max_x = 480,
2150         .min_y = 0,
2151         .max_y = 800,
2152         .min_z = 0,
2153         .max_z = 255,
2154         .min_w = 0,
2155         .max_w = 30,
2156         .power_on = mxt224_power_on,
2157         .power_off = mxt224_power_off,
2158         .register_cb = mxt224_register_callback,
2159         .read_ta_status = mxt224_read_ta_status,
2160         /* For the faster user response */
2161         .input_event            = user_input_response,
2162 };
2163 #else /* CONFIG_TOUCHSCREEN_MXT224U1 */
2164 /* FIXME: Only use for tuning */
2165 static u8 mxt_init_vals_ver_22[] __initdata = {
2166         /* MXT_GEN_COMMAND(6) */
2167         0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2168         /* MXT_GEN_POWER(7) */
2169         0x20, 0xff, 0x32,
2170         /* MXT_GEN_ACQUIRE(8) */
2171         0x0a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x23,
2172         /* MXT_TOUCH_MULTI(9) */
2173         0x00, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00,
2174         0x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00,
2175         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2176         0x00,
2177         /* MXT_TOUCH_KEYARRAY(15) */
2178         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
2179         0x00,
2180         /* MXT_SPT_GPIOPWM(19) */
2181         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2182         0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2183         /* MXT_PROCI_GRIPFACE(20) */
2184         0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x28, 0x04,
2185         0x0f, 0x0a,
2186         /* MXT_PROCG_NOISE(22) */
2187         0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x23, 0x00,
2188         0x00, 0x05, 0x0f, 0x19, 0x23, 0x2d, 0x03,
2189         /* MXT_TOUCH_PROXIMITY(23) */
2190         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2191         0x00, 0x00, 0x00, 0x00, 0x00,
2192         /* MXT_PROCI_ONETOUCH(24) */
2193         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2194         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2195         /* MXT_SPT_SELFTEST(25) */
2196         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2197         0x00, 0x00, 0x00, 0x00,
2198         /* MXT_PROCI_TWOTOUCH(27) */
2199         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2200         /* MXT_SPT_CTECONFIG(28) */
2201         0x00, 0x00, 0x03, 0x08, 0x10, 0x00,
2202 };
2203
2204 static struct mxt_platform_data mxt_platform_data __refconst = {
2205         .config                 = mxt_init_vals_ver_22,
2206         .config_length          = ARRAY_SIZE(mxt_init_vals_ver_22),
2207
2208         .x_line                 = 19,
2209         .y_line                 = 11,
2210         .x_size                 = 800,
2211         .y_size                 = 480,
2212         .blen                   = 0x11,
2213         .threshold              = 0x28,
2214         .voltage                = 2800000,              /* 2.8V */
2215         .orient                 = MXT_DIAGONAL,
2216         .irqflags               = IRQF_TRIGGER_FALLING,
2217
2218         /* For the faster user response */
2219         .input_event            = user_input_response,
2220 };
2221
2222 #endif /* CONFIG_TOUCHSCREEN_MXT224U1 */
2223
2224 static struct i2c_board_info i2c3_devs[] __initdata = {
2225         {
2226 #ifdef CONFIG_TOUCHSCREEN_MXT224U1
2227                 I2C_BOARD_INFO("Atmel MXT224", 0x4a),
2228                 .platform_data  = &mxt224_data,
2229 #else
2230                 I2C_BOARD_INFO("atmel_mxt_ts", 0x4a),
2231                 .platform_data  = &mxt_platform_data,
2232 #endif
2233         },
2234 };
2235
2236 static void u1_power_off(void)
2237 {
2238         char rst_mode = 'r';
2239         char *str_ptr = "reset\n";
2240         int poweroff_try = 0;
2241         int gpio;
2242
2243         printk(KERN_INFO "%s: u1 power off\n", __func__);
2244         while (1) {
2245                 /* Check reboot charging */
2246                 if (is_cable_attached || (poweroff_try >= 5)) {
2247                 printk(KERN_INFO
2248                         "%s: charger connected(%d) or power off failed(%d), reboot!\n",
2249                                 __func__, is_cable_attached, poweroff_try);
2250
2251                         flush_cache_all();
2252                         outer_flush_all();
2253                         arm_machine_restart(rst_mode, str_ptr);
2254 //                        arch_reset(0, 0);
2255
2256                         printk(KERN_INFO "%s: waiting for reboot.\n", __func__);
2257                         while (1);
2258                 }
2259
2260                 /* wait for power button release */
2261                 gpio = MOBILE_GPIO(nPOWER);
2262                 gpio_request(gpio, "nPOWER");
2263                 if (gpio_get_value(gpio)) {
2264                         printk(KERN_INFO "%s: set PS_HOLD low.\n", __func__);
2265                         /* power off code
2266                          * PS_HOLD Out/High -->
2267                          * Low PS_HOLD_CONTROL, R/W, 0x1002_330C
2268                          */
2269                         writel(readl(S5P_PS_HOLD_CONTROL) & 0xFFFFFEFF,
2270                                 S5P_PS_HOLD_CONTROL);
2271
2272                         ++poweroff_try;
2273
2274                         /* when connected zig cable with power, we can't make PS_HOLD_CONTROL low.
2275                          * we try power_off 5 times. then if it failed, do restart.
2276                          */
2277                         printk(KERN_INFO
2278                                 "%s: Should not reach here! (poweroff_try:%d)\n",
2279                                 __func__, poweroff_try);
2280                 }
2281
2282                 /* if power button is not released, wait and check TA again */
2283                 printk(KERN_INFO "%s: PowerButton is not released!.\n",
2284                         __func__);
2285                 mdelay(1000);
2286         }
2287 }
2288
2289 static void __init u1_tsp_init(void)
2290 {
2291         int gpio;
2292
2293 #if 1
2294         /* TSP_LDO_ON: XGNSS_QSIGN */
2295         gpio = MOBILE_GPIO(TSP_LDO_ON);
2296         gpio_request(gpio, "TSP_LDO_ON");
2297         gpio_direction_output(gpio, 1);
2298         gpio_export(gpio, 0);
2299
2300         /* TSP_INT: XEINT[4] */
2301         gpio = MOBILE_GPIO(TSP_INT);
2302         gpio_request(gpio, "TSP_INT");
2303         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
2304
2305 #endif
2306         /*
2307          * Note that because TSP_LDO provides an external pull-up to TSP_INT,
2308          * the pull-up setting at GPE1(7) is useless and may be omitted in
2309          * order to reduce idle current. However, it probably needs some
2310          * sleep/delay from TSP_LDO_ON = true event because there could be
2311          * "ramp-up" delay. Before knowing this, let's just use PULL_UP here.
2312          */
2313         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
2314         i2c3_devs[0].irq = gpio_to_irq(gpio);
2315
2316 }
2317
2318
2319
2320
2321 #if 0 /* TODO : need to check */
2322 extern void MHL_On(bool on);
2323 #endif
2324 static void u1_mhl_cb(int attached)
2325 {
2326         pr_info("%s(%d) NOT work\n", __func__, attached);
2327 #if 0
2328         if (attached == MAX8997_MUIC_ATTACHED) {
2329                 MHL_On(1);
2330         } else
2331                 MHL_On(0);
2332 #endif
2333 }
2334
2335 static bool u1_is_mhl_attached(void)
2336 {
2337         int val;
2338         int gpio;
2339
2340         gpio = MOBILE_GPIO(MHL_SEL);
2341         gpio_request(gpio, "MHL_SEL");
2342         val = gpio_get_value(gpio);
2343         gpio_free(gpio);
2344
2345         return !!val;
2346 }
2347
2348 static int u1_set_safeout(int path)
2349 {
2350         static struct regulator *regulator_vbus_cp;
2351         static bool cp_enabled;
2352         int ret = 0;
2353
2354         mutex_lock(&usb_ap_lock);
2355
2356         if (regulator_vbus_ap == NULL)
2357                 regulator_vbus_ap =
2358                     regulator_get_exclusive(NULL, "usb_vbus_ap_5v");
2359         if (IS_ERR_OR_NULL(regulator_vbus_ap)) {
2360                 ret = -ENODEV;
2361                 regulator_vbus_ap = NULL;
2362                 goto out;
2363         }
2364
2365         if (regulator_vbus_cp == NULL)
2366                 regulator_vbus_cp =
2367                     regulator_get_exclusive(NULL, "usb_vbus_cp_5v");
2368         if (IS_ERR_OR_NULL(regulator_vbus_cp)) {
2369                 ret = -ENODEV;
2370                 regulator_vbus_cp = NULL;
2371                 goto out;
2372         }
2373
2374         if (path == CP_USB_MODE) {
2375                 if (ap_enabled) {
2376                         ret = regulator_disable(regulator_vbus_ap);
2377                         if (ret)
2378                                 goto out;
2379                         ap_enabled = false;
2380                 }
2381
2382                 if (!cp_enabled) {
2383                         /* regulator_vbus_cp is exclusively got */
2384                         if (!regulator_is_enabled(regulator_vbus_cp))
2385                                 ret = regulator_enable(regulator_vbus_cp);
2386                         if (ret)
2387                                 goto out;
2388                         cp_enabled = true;
2389                 }
2390         } else {
2391                 /* AP_USB_MODE || AUDIO_MODE */
2392                 if (!ap_enabled) {
2393                         /* regulator_vbus_ap is exclusively got */
2394                         if (!regulator_is_enabled(regulator_vbus_ap))
2395                                 ret = regulator_enable(regulator_vbus_ap);
2396                         if (ret)
2397                                 goto out;
2398                         ap_enabled = true;
2399                 }
2400
2401                 if (cp_enabled) {
2402                         ret = regulator_disable(regulator_vbus_cp);
2403                         if (ret)
2404                                 goto out;
2405                         cp_enabled = false;
2406                 }
2407         }
2408 out:
2409         mutex_unlock(&usb_ap_lock);
2410         return ret;
2411 }
2412
2413 static struct switch_dev switch_dock = {
2414         .name = "dock",
2415 };
2416
2417 static const char *switch_cable_names[] = {
2418         "TA",
2419         "USB",
2420         NULL,
2421 };
2422
2423 static struct switch_dev switch_usb = {
2424         .name = "switch-usb",
2425         .supported_cable = switch_cable_names,
2426 };
2427
2428 static void u1_deskdock_cb(bool attached)
2429 {
2430         if (attached)
2431                 switch_set_state(&switch_dock, 1);
2432         else
2433                 switch_set_state(&switch_dock, 0);
2434 }
2435
2436 static void u1_cardock_cb(bool attached)
2437 {
2438         if (attached)
2439                 switch_set_state(&switch_dock, 2);
2440         else
2441                 switch_set_state(&switch_dock, 0);
2442 }
2443
2444 static void u1_switch_dev_init(void)
2445 {
2446         int ret;
2447
2448         /* for CarDock, DeskDock */
2449         ret = switch_dev_register(&switch_dock);
2450         if (ret < 0)
2451                 pr_err("Failed to register dock switch. %d\n", ret);
2452
2453         ret = switch_dev_register(&switch_usb);
2454         if (ret < 0)
2455                 pr_err("Failed to register switch-usb. %d\n", ret);
2456 }
2457
2458 static int u1_host_notify_cb(int enable)
2459 {
2460         struct host_notify_dev * ndev = NULL;
2461
2462         if (s3c_device_usbgadget.dev.platform_data)
2463                 ndev = s3c_device_usbgadget.dev.platform_data;
2464         else {
2465                 pr_err("%s: ndev is null.\n", __func__);
2466                 return -1;
2467         }
2468
2469         ndev->booster = enable ? NOTIFY_POWER_ON : NOTIFY_POWER_OFF;
2470         pr_info("%s: mode %d, enable %d\n", __func__, ndev->mode, enable);
2471         return ndev->mode;
2472 }
2473
2474 struct max8997_muic_platform_data u1_muic_pdata = {
2475         .usb_cb = u1_usb_cb,
2476         .charger_cb = u1_charger_cb, /* done */
2477         .mhl_cb = u1_mhl_cb, /* done */
2478         .is_mhl_attached = u1_is_mhl_attached, /* done */
2479         .set_safeout = u1_set_safeout, /* done */
2480         .deskdock_cb = u1_deskdock_cb, /* done */
2481         .cardock_cb = u1_cardock_cb, /* done */
2482         .host_notify_cb = u1_host_notify_cb, /* done */
2483         .gpio_usb_sel = S5PV310_GPL0(6),        /* done */
2484         .uart_path = -1,        /* muic does not control uart path*/
2485 };
2486
2487 static void u1_set_usb_switch(int path)
2488 {
2489         printk(KERN_INFO "set_usb_switch = [%d]\n",path);
2490         u1_muic_pdata.sw_path = path;
2491 }
2492
2493 static int u1_get_usb_switch(void)
2494 {
2495         printk(KERN_INFO "get_usb_switch = [%d]\n",u1_muic_pdata.sw_path);
2496         return u1_muic_pdata.sw_path;
2497 }
2498
2499 /* Micro USB Switch */
2500 static struct micro_usb_switch_platform_data u1_usb_switch_data = {
2501         .set_usb_switch         = u1_set_usb_switch,
2502         .get_usb_switch         = u1_get_usb_switch,
2503 };
2504
2505 static struct platform_device u1_micro_usb_switch = {
2506         .name                   = "usb-switch",
2507         .id                     = -1,
2508         .dev                    = {
2509                 .platform_data  = &u1_usb_switch_data,
2510         },
2511 };
2512
2513 static void u1_pm_finish(void)
2514 {
2515         /* Restore GPX conf */
2516         s3c_pm_do_restore(s5pc210_gpx, ARRAY_SIZE(s5pc210_gpx));
2517 }
2518
2519 static void u1_pm_prepare(void)
2520 {
2521         /* 1. Save GPX conf */
2522         s3c_pm_do_save(s5pc210_gpx, ARRAY_SIZE(s5pc210_gpx));
2523
2524         /* 2. Set GPX as Power Save Mode */
2525
2526         /* 3. Debug: Look at the diff */
2527         mobile_gpios_groupx_difference();
2528
2529 }
2530
2531 int u1_common_setup_clock(const char *sclk_name, const char *pclk_name,
2532                 unsigned long rate, unsigned int rate_set)
2533 {
2534         struct clk *sclk = NULL;
2535         struct clk *pclk = NULL;
2536
2537         sclk = clk_get(NULL, sclk_name);
2538         if (IS_ERR(sclk)) {
2539                 printk(KERN_ERR "failed to get %s clock.\n", sclk_name);
2540                 goto err_clk;
2541         }
2542
2543         pclk = clk_get(NULL, pclk_name);
2544         if (IS_ERR(pclk)) {
2545                 printk(KERN_ERR "failed to get %s clock.\n", pclk_name);
2546                 goto err_clk;
2547         }
2548
2549         clk_set_parent(sclk, pclk);
2550
2551         printk(KERN_INFO "set parent clock of %s to %s\n", sclk_name,
2552                         pclk_name);
2553         if (!rate_set)
2554                 goto set_end;
2555
2556         if (!rate)
2557                 rate = 200 * MHZ;
2558
2559         clk_set_rate(sclk, rate);
2560         printk(KERN_INFO "set %s rate to %lu\n", sclk_name, rate);
2561
2562 set_end:
2563         clk_put(sclk);
2564         clk_put(pclk);
2565
2566         return 0;
2567
2568 err_clk:
2569         clk_put(sclk);
2570         clk_put(pclk);
2571
2572         return -EINVAL;
2573
2574 }
2575
2576 #ifdef CONFIG_S5PV310_DEV_PD
2577 static inline void powerdomain_boot_on(int pd)
2578 {
2579         struct samsung_pd_info *pdinfo = (struct samsung_pd_info *)
2580                 s5pv310_device_pd[pd].dev.platform_data;
2581         pdinfo->boot_on = true;
2582 }
2583 #endif
2584
2585 #ifdef CONFIG_INPUT_SECBRIDGE
2586 //============================================================
2587 /* sec-input-bridge */
2588 //============================================================
2589 static const struct sec_input_bridge_mkey u1_rbdump_mkey_map[] = {
2590         { .type = EV_KEY , .code = KEY_VOLUMEUP                 },
2591         { .type = EV_KEY , .code = KEY_VOLUMEDOWN               },
2592         { .type = EV_KEY , .code = KEY_MENU                             },
2593         { .type = EV_KEY , .code = KEY_MENU                             },
2594         { .type = EV_KEY , .code = KEY_VOLUMEUP                 },
2595         { .type = EV_KEY , .code = KEY_VOLUMEDOWN               },
2596         { .type = EV_KEY , .code = KEY_VOLUMEUP                 },
2597         { .type = EV_KEY , .code = KEY_MENU                             },
2598 };
2599
2600 static const struct sec_input_bridge_mkey u1_default_mkey_map[] = {
2601         { .type = EV_KEY , .code = KEY_VOLUMEUP                 },
2602         { .type = EV_KEY , .code = KEY_VOLUMEDOWN               },
2603         { .type = EV_KEY , .code = KEY_MENU                             },
2604         { .type = EV_KEY , .code = KEY_MENU                             },
2605         { .type = EV_KEY , .code = KEY_VOLUMEUP                 },
2606         { .type = EV_KEY , .code = KEY_VOLUMEUP                 },
2607         { .type = EV_KEY , .code = KEY_VOLUMEUP                 },
2608         { .type = EV_KEY , .code = KEY_MENU                             },
2609 };
2610
2611 static const struct sec_input_bridge_mkey u1_uart_mkey_map[] = {
2612         { .type = EV_KEY , .code = KEY_VOLUMEUP                 },
2613         { .type = EV_KEY , .code = KEY_VOLUMEDOWN               },
2614         { .type = EV_KEY , .code = KEY_MENU                             },
2615         { .type = EV_KEY , .code = KEY_MENU                             },
2616         { .type = EV_KEY , .code = KEY_VOLUMEUP                 },
2617         { .type = EV_KEY , .code = KEY_MENU                             },
2618         { .type = EV_KEY , .code = KEY_VOLUMEDOWN               },
2619         { .type = EV_KEY , .code = KEY_MENU                             },
2620 };
2621
2622 static void mkey_uart_path_change (void *event_data)
2623 {
2624         if (u1_get_uart_switch() == UART_SW_PATH_CP)
2625                 u1_set_uart_switch(UART_SW_PATH_AP);
2626         else
2627                 u1_set_uart_switch(UART_SW_PATH_CP);
2628 }
2629
2630 static const struct sec_input_bridge_mmap u1_mmap[] = {
2631         {
2632                 .mkey_map = u1_rbdump_mkey_map,
2633                 .num_mkey = ARRAY_SIZE(u1_rbdump_mkey_map),
2634                 .uevent_env_str = "RB_DUMP",
2635                 .enable_uevent = 1,
2636                 .uevent_action = KOBJ_CHANGE,
2637                 .uevent_env_str = "RB_DUMP",
2638                 .uevent_env_value = "ON",
2639         },
2640         {
2641                 .mkey_map = u1_default_mkey_map,
2642                 .num_mkey = ARRAY_SIZE(u1_default_mkey_map),
2643                 .uevent_env_str = "DEFAULT",
2644                 .enable_uevent = 1,
2645                 .uevent_action = KOBJ_CHANGE,
2646                 .uevent_env_str = "DEFAULT",
2647                 .uevent_env_value = "ON",
2648         },
2649         {
2650                 .mkey_map = u1_uart_mkey_map,
2651                 .num_mkey = ARRAY_SIZE(u1_uart_mkey_map),
2652                 .uevent_env_str = "UART_SW",
2653                 .enable_uevent = 0,
2654                 .uevent_action = KOBJ_CHANGE,
2655                 .uevent_env_str = "DEFAULT",
2656                 .uevent_env_value = "ON",
2657                 .pre_event_func = mkey_uart_path_change,
2658         },
2659 };
2660
2661 extern int bkl_warning_operation(int on_off, int gamma);
2662 static void u1_lcd_warning_function(void)
2663 {
2664         int i;
2665         /* LCD on/off to confirm action */
2666         ssleep(2);
2667
2668         for (i = 0; i < 8; i++) {
2669                 bkl_warning_operation(1, 0);
2670                 msleep(500);
2671
2672                 bkl_warning_operation(1, 10);
2673                 msleep(500);
2674         }
2675
2676         /* recovery first state */
2677         bkl_warning_operation(0, 0);
2678 }
2679
2680 static struct sec_input_bridge_platform_data u1_input_bridge_data = {
2681         .mmap = u1_mmap,
2682         .num_map = ARRAY_SIZE(u1_mmap),
2683         .lcd_warning_func = u1_lcd_warning_function,
2684 };
2685
2686 static struct platform_device u1_input_bridge = {
2687         .name   = "samsung_input_bridge",
2688         .id             = -1,
2689         .dev    = {
2690                 .platform_data = &u1_input_bridge_data,
2691         },
2692 };
2693 #endif
2694
2695 #ifdef CONFIG_CHARGERCTRL_MAX8922
2696 #define GPIO_CHG_EN             S5PV310_GPL2(2)
2697 #define GPIO_CHG_ING_N          S5PV310_GPL2(4)
2698 #define GPIO_TA_nCONNECTED      S5PV310_GPL2(5)
2699
2700 static int max8922_cfg_gpio(void)
2701 {
2702         s3c_gpio_cfgpin(GPIO_CHG_EN, S3C_GPIO_OUTPUT);
2703         s3c_gpio_setpull(GPIO_CHG_EN, S3C_GPIO_PULL_NONE);
2704         gpio_set_value(GPIO_CHG_EN, GPIO_LEVEL_LOW);
2705
2706         s3c_gpio_cfgpin(GPIO_CHG_ING_N, S3C_GPIO_INPUT);
2707         s3c_gpio_setpull(GPIO_CHG_ING_N, S3C_GPIO_PULL_NONE);
2708
2709         s3c_gpio_cfgpin(GPIO_TA_nCONNECTED, S3C_GPIO_INPUT);
2710         s3c_gpio_setpull(GPIO_TA_nCONNECTED, S3C_GPIO_PULL_NONE);
2711
2712         return 0;
2713 }
2714
2715 static int u1_charger_topoff_cb(void)
2716 {
2717         struct power_supply *psy = power_supply_get_by_name("battery");
2718         union power_supply_propval value;
2719
2720         if (!psy) {
2721                 pr_err("%s: fail to get battery ps\n", __func__);
2722                 return -ENODEV;
2723         }
2724
2725         value.intval = POWER_SUPPLY_STATUS_FULL;
2726         return psy->set_property(psy, POWER_SUPPLY_PROP_STATUS, &value);
2727 }
2728
2729 static struct regulator_consumer_supply supplies_max8922[] = {
2730         REGULATOR_SUPPLY("vinchg2", "charger-manager.0"),
2731         REGULATOR_SUPPLY("vinchg2_mach", NULL),
2732 };
2733
2734 static struct regulator_init_data max8922_charger_en_data = {
2735         .constraints = {
2736                 .name           = "MAX8922_CHARGER",
2737                 .min_uA = 395000,
2738                 .max_uA = 650000,
2739                 .valid_ops_mask = REGULATOR_CHANGE_STATUS |
2740                                 REGULATOR_CHANGE_CURRENT,
2741         },
2742         .num_consumer_supplies = ARRAY_SIZE(supplies_max8922),
2743         .consumer_supplies = supplies_max8922,
2744 };
2745 static struct max8922_platform_data max8922_pdata = {
2746         .topoff_cb = u1_charger_topoff_cb,
2747         .cfg_gpio = max8922_cfg_gpio,
2748         .gpio_chg_en = GPIO_CHG_EN,
2749         .gpio_chg_ing = GPIO_CHG_ING_N,
2750         .gpio_ta_nconnected = GPIO_TA_nCONNECTED,
2751         .init_data = &max8922_charger_en_data,
2752 };
2753
2754 static struct platform_device max8922_device_charger = {
2755         .name = "max8922-charger",
2756         .id = 0,
2757         .dev.platform_data = &max8922_pdata,
2758 };
2759 #endif /* CONFIG_MAX8922_CHARGER */
2760
2761 struct led_max8997_platform_data u1_led_max8997_platform_data = {
2762         .name = "leds-torch",
2763         .brightness = 0,
2764 };
2765
2766 struct platform_device u1_device_leds_max8997 = {
2767         .name   = "leds-max8997",
2768         .id     = -1,
2769         .dev = { .platform_data = &u1_led_max8997_platform_data},
2770 };
2771
2772 #ifdef CONFIG_CHARGER_MANAGER
2773 extern struct platform_device u1_charger_manager;
2774 extern struct platform_device u1_ncp15wb473_thermistor;
2775 extern struct platform_device u1_ncp15wb473_thermistor_pmic;
2776 extern struct charger_global_desc u1_charger_g_desc;
2777 #endif
2778
2779 static struct platform_device *u1_devices[] __initdata = {
2780         /* Samsung Platform Devices */
2781 #ifdef CONFIG_S5PV310_DEV_PD
2782         &s5pv310_device_pd[PD_MFC],
2783         &s5pv310_device_pd[PD_G3D],
2784         &s5pv310_device_pd[PD_LCD0],
2785         &s5pv310_device_pd[PD_LCD1],
2786         &s5pv310_device_pd[PD_TV],
2787         &s5pv310_device_pd[PD_CAM],
2788         &s5pv310_device_pd[PD_GPS],
2789 #endif
2790 #ifdef CONFIG_DRM_MALI
2791         &s5p_device_mali_drm,
2792 #endif
2793 #ifdef CONFIG_DRM_FIMD
2794         &s5p_device_fimd_drm,
2795 #endif
2796         &s3c_device_i2c0,
2797         &s3c_device_i2c1,
2798         &s3c_device_i2c3,
2799         &s3c_device_i2c5,
2800         &s3c_device_i2c6,
2801         &s3c_device_i2c7,
2802         &i2c9_gpio,
2803         &i2c12_gpio,
2804         &i2c14_gpio,
2805         &i2c15_gpio,
2806         &i2c16_gpio,
2807         &s3c_device_i2c17,
2808         &i2c18_gpio,
2809
2810         &s3c_device_timer[0],
2811         &s3c_device_timer[1],
2812
2813 #ifdef CONFIG_S3C_DEV_RTC
2814         &s3c_device_rtc,
2815 #endif
2816 #ifdef CONFIG_CHARGERCTRL_MAX8922
2817         &max8922_device_charger,
2818 #endif
2819
2820 #ifdef CONFIG_VIDEO_FIMC_MIPI
2821         &s3c_device_csis0,
2822         &s3c_device_csis1,
2823 #endif
2824 #ifdef CONFIG_VIDEO_FIMC
2825         &s3c_device_fimc0,
2826         &s3c_device_fimc1,
2827         &s3c_device_fimc2,
2828         &s3c_device_fimc3,
2829 #endif
2830
2831 #ifdef CONFIG_VIDEO_JPEG
2832         &s5p_device_jpeg,
2833 #endif
2834
2835         &u1_gpio_keys,
2836
2837 #ifdef CONFIG_USB_GADGET
2838         &s3c_device_usbgadget,
2839 #endif
2840 #ifdef CONFIG_USB_ANDROID_RNDIS
2841        &s3c_device_rndis,
2842 #endif
2843 #ifdef CONFIG_USB_ANDROID_ECM
2844        &s3c_device_ecm,
2845 #endif
2846 #ifdef CONFIG_USB_ANDROID
2847     &s3c_device_android_usb,
2848     &s3c_device_usb_mass_storage,
2849 #endif
2850 #ifdef CONFIG_USB_S3C_OTG_HOST
2851         &s3c_device_usb_otghcd,
2852 #endif
2853 #ifdef CONFIG_S3C_DEV_HSMMC4
2854         &s3c_device_hsmmc4,
2855 #else
2856         &s3c_device_hsmmc0,
2857 #endif
2858         &emmc_fixed_voltage,
2859         &s3c_device_hsmmc2,
2860         &s3c_device_hsmmc3,
2861
2862         &u1_uart_select,
2863         &s3c_device_adc,
2864
2865 #ifdef CONFIG_SND_S3C64XX_SOC_I2S_V4
2866         &s5pv310_device_iis0,
2867 #endif
2868 #ifdef CONFIG_SND_S3C_SOC_PCM
2869         &s5pv310_device_pcm1,
2870 #endif
2871 #ifdef CONFIG_SND_SOC_SMDK_WM9713
2872         &s5pv310_device_ac97,
2873 #endif
2874 #ifdef CONFIG_SND_SAMSUNG_SOC_SPDIF
2875         &s5pv310_device_spdif,
2876 #endif
2877         &u1_jack,
2878         &fmradio_fixed_voltage,
2879         &s5pv310_bcm4330,
2880 #ifdef CONFIG_GSD4T
2881         &u1_gsd4t,
2882 #endif
2883         &u1_ramoops,
2884         &u1_micro_usb_switch,
2885
2886 #ifdef CONFIG_S3C2410_WATCHDOG
2887         &s3c_device_wdt,
2888 #endif
2889
2890 #ifdef CONFIG_S5P_SYSMMU
2891         &s5p_device_sysmmu[SYSMMU_G2D],
2892         &s5p_device_sysmmu[SYSMMU_MFC_L],
2893         &s5p_device_sysmmu[SYSMMU_MFC_R],
2894         &s5p_device_sysmmu[SYSMMU_FIMC0],
2895         &s5p_device_sysmmu[SYSMMU_FIMC1],
2896         &s5p_device_sysmmu[SYSMMU_FIMC2],
2897         &s5p_device_sysmmu[SYSMMU_FIMC3],
2898 #endif
2899 #ifdef CONFIG_VIDEO_FIMG2D
2900         &s5p_device_fimg2d,
2901 #endif
2902 #if defined(CONFIG_VIDEO_MFC5X) || defined(CONFIG_VIDEO_SAMSUNG_S5P_MFC)
2903         &s5p_device_mfc,
2904 #endif
2905 #ifdef CONFIG_FB_S3C
2906         &s3c_device_fb,
2907         &u1_spi_gpio,
2908 #endif
2909 #ifdef CONFIG_ANDROID_RAM_CONSOLE
2910         &ram_console_device,
2911 #endif
2912         &u1_tzpc,
2913         &u1_device_leds_max8997,
2914
2915 #ifdef CONFIG_CHARGER_MANAGER
2916         /* Should be placed after fuel gauge, charger control chips, pmics */
2917         &u1_ncp15wb473_thermistor,
2918         &u1_ncp15wb473_thermistor_pmic,
2919         &u1_charger_manager,
2920 #endif
2921 #ifdef CONFIG_INPUT_SECBRIDGE
2922         &u1_input_bridge,
2923 #endif
2924 #ifdef CONFIG_SAMSUNG_BOOT_MODE
2925         &s3c_device_samsung_boot_mode,
2926 #endif
2927 #ifdef CONFIG_SEC_DEBUG
2928         &s3c_device_getlog,
2929 #endif
2930 #ifdef CONFIG_S5PV310_STOPWATCH
2931         &s5pv310_device_stopwatch,
2932 #endif
2933 #ifdef CONFIG_DEV_THERMAL
2934         &s5p_device_tmu,
2935 #endif
2936         &u1_xmm6260,
2937         &u1_modem_net,
2938         &s5p_device_usb_ehci,
2939 };
2940
2941 extern void (*s5p_inform6_set)(char mode);
2942 extern void s5pv310_inform6_set(char mode);
2943 extern struct machine_desc *lookup_machine_type(unsigned int);
2944
2945 static void __init u1_machine_init(void)
2946 {
2947         int gpio;
2948         struct machine_desc *list;
2949         list = lookup_machine_type(machine_arch_type);
2950         strcpy(utsname()->nodename, list->name);
2951
2952         /* to support system shut down */
2953         pm_power_off = u1_power_off;
2954
2955         /* to support inform6 set */
2956         s5p_inform6_set = s5pv310_inform6_set;
2957
2958         /* Initialize GPIO default setting */
2959         mobile_gpios_init();
2960         s3c_config_sleep_gpio_table = u1_config_sleep_gpio_table;
2961
2962         u1_switch_dev_init();
2963
2964         s3c_i2c0_set_platdata(&u1_i2c0_platdata);
2965
2966         u1_sensor_init();
2967         s3c_i2c1_set_platdata(NULL);
2968
2969         i2c_register_board_info(1, i2c1_devs, ARRAY_SIZE(i2c1_devs));
2970
2971         u1_tsp_init();
2972         s3c_i2c3_set_platdata(NULL);
2973         i2c_register_board_info(3, i2c3_devs, ARRAY_SIZE(i2c3_devs));
2974
2975         u1_sec_switch_init();
2976
2977 #ifdef CONFIG_S5PV310_DEV_PD
2978         s5pv310_device_pd[PD_CAM].dev.parent = &s5pv310_device_pd[PD_LCD0].dev;
2979 #ifdef CONFIG_FB_S3C
2980         s3c_device_fb.dev.parent = &s5pv310_device_pd[PD_LCD0].dev;
2981         powerdomain_boot_on(PD_LCD0);
2982 #endif
2983 #endif
2984         u1_fb_init();
2985
2986
2987 /* YUBAEK 20110905 RAMDUMP_DEBUG : GPIO Dump ++ */
2988 #ifdef CONFIG_SEC_DEBUG_PERIPHERAL_DUMP_GPIO
2989         s5pv310_gpio_io_map();
2990 #endif
2991 /* YUBAEK 20110905 RAMDUMP_DEBUG : GPIO Dump ++ */
2992
2993
2994 #ifdef CONFIG_S5PV310_DEV_PD
2995 #if defined(CONFIG_VIDEO_MFC5X) || defined(CONFIG_VIDEO_SAMSUNG_S5P_MFC)
2996         s5p_device_mfc.dev.parent = &s5pv310_device_pd[PD_MFC].dev;
2997         u1_common_setup_clock("mout_mfc0", "mout_mpll", 0, 0);
2998         u1_common_setup_clock("sclk_mfc", "mout_mfc0", 200 * MHZ, 1);
2999 #endif
3000 #endif
3001
3002         u1_pmic_init(); /* TODO: should be modify for U1 */
3003         s3c_i2c5_set_platdata(NULL);
3004         i2c5_devs[I2C5_MAX8997].irq = gpio_to_irq(S5PV310_GPX0(7)),
3005         i2c_register_board_info(5, i2c5_devs, ARRAY_SIZE(i2c5_devs));
3006
3007         u1_sound_init();
3008         s3c_i2c6_set_platdata(NULL);
3009         i2c_register_board_info(6, i2c6_devs, ARRAY_SIZE(i2c6_devs));
3010
3011         s3c_i2c7_set_platdata(NULL);
3012         i2c_register_board_info(7, i2c7_devs, ARRAY_SIZE(i2c7_devs));
3013
3014         gpio = S5PV310_GPX2(3);
3015         gpio_request(gpio, "FUEL_ALERT");
3016         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
3017         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
3018         i2c9_devs[I2C9_MAX17042].irq = gpio_to_irq(gpio);
3019         i2c_register_board_info(9, i2c9_devs, ARRAY_SIZE(i2c9_devs));
3020
3021         universal_touchkey_init();
3022         i2c_register_board_info(12, i2c12_devs_cypress, ARRAY_SIZE(i2c12_devs_cypress));
3023
3024         i2c_register_board_info(14, i2c14_devs, ARRAY_SIZE(i2c14_devs));
3025
3026         i2c_register_board_info(15, i2c15_devs, ARRAY_SIZE(i2c15_devs));
3027
3028         /* NFC sensor */
3029         nfc_setup_gpio();
3030         i2c_register_board_info(16, i2c16_devs, ARRAY_SIZE(i2c16_devs));
3031 /*
3032 #if defined(CONFIG_VIDEO_S5K5BAFX)
3033         i2c_register_board_info(17, i2c17_devs, ARRAY_SIZE(i2c17_devs));
3034 #endif
3035 */
3036         i2c_register_board_info(18, i2c18_devs, ARRAY_SIZE(i2c18_devs));
3037
3038         u1_usb_ehci_init();
3039
3040         u1_usb_otg_init();
3041
3042         s3c_usb_set_serial();
3043
3044         u1_modem_init();
3045
3046 #ifdef CONFIG_VIDEO_FIMG2D
3047         s5p_fimg2d_set_platdata(&fimg2d_data);
3048 #ifdef CONFIG_S5PV310_DEV_PD
3049         s5p_device_fimg2d.dev.parent = &s5pv310_device_pd[PD_LCD0].dev;
3050 #endif
3051 #endif
3052
3053 #ifdef CONFIG_PM
3054         pm_cpu_prepare = u1_pm_prepare;
3055         pm_cpu_finish = u1_pm_finish;
3056
3057         s3c_pm_init();
3058         s3c_irq_wake(IRQ_RTC_ALARM, 1);
3059 #endif
3060
3061 #if defined(CONFIG_S5PV310_DEV_PD) && !defined(CONFIG_PM_RUNTIME)
3062         /*
3063          * These power domains should be always on
3064          * without runtime pm support.
3065          */
3066         s5pv310_pd_enable(&s5pv310_device_pd[PD_MFC].dev);
3067         s5pv310_pd_enable(&s5pv310_device_pd[PD_G3D].dev);
3068         s5pv310_pd_enable(&s5pv310_device_pd[PD_LCD0].dev);
3069         s5pv310_pd_enable(&s5pv310_device_pd[PD_LCD1].dev);
3070         s5pv310_pd_enable(&s5pv310_device_pd[PD_CAM].dev);
3071         s5pv310_pd_enable(&s5pv310_device_pd[PD_TV].dev);
3072         s5pv310_pd_enable(&s5pv310_device_pd[PD_GPS].dev);
3073 #endif
3074
3075 #ifdef CONFIG_VIDEO_FIMG2D
3076         /* setup fimg2d parent clock. */
3077         universal_fimg2d_setup_clock("mout_g2d0", "mout_mpll");
3078 #endif
3079
3080         s5pv310_sdhci_init();
3081 #ifdef CONFIG_S5P_ADC
3082         u1_adc_init();
3083 #endif
3084
3085 #ifdef CONFIG_DEV_THERMAL
3086         s5p_tmu_set_platdata(NULL);
3087 #endif
3088
3089         s5pv310_camera_init();
3090
3091 #ifdef CONFIG_CHARGER_MANAGER
3092         setup_charger_manager(&u1_charger_g_desc);
3093 #endif
3094
3095         /* Last */
3096         platform_add_devices(u1_devices, ARRAY_SIZE(u1_devices));
3097
3098         regulator_has_full_constraints();
3099 /* Temp. commented */
3100 #if 0
3101         if (s5pv310_subrev() != 0) {
3102                 pr_emerg("\n\n This kernel does NOT support subrevision %d of S5PC210.\n\n\n",
3103                         s5pv310_subrev());
3104                 panic("Not supported subrevision");
3105         }
3106 #endif
3107 }
3108
3109 MACHINE_START(U1_C210, "U1SLP")
3110         /* Maintainer: mhban <mhban@samsung.com> */
3111         .phys_io        = S3C_PA_UART & 0xfff00000,
3112         .io_pg_offst    = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
3113         .boot_params    = S5P_PA_SDRAM + 0x100,
3114         .init_irq       = s5pv310_init_irq,
3115         .map_io         = u1_map_io,
3116         .init_machine   = u1_machine_init,
3117         .timer          = &s5pv310_timer,
3118         .reserve        = &s5pv310_reserve,
3119 MACHINE_END