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