upload tizen1.0 source
[kernel/linux-2.6.36.git] / arch / arm / mach-s5pv310 / mach-slp10_c210.c
1 /*
2  * linux/arch/arm/mach-s5pv310/mach-slp10_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/atmel_mxt_ts.h>
24 #include <linux/clk.h>
25 #include <linux/ntc.h>
26 #include <linux/regulator/machine.h>
27 #include <linux/regulator/fixed.h>
28 #include <linux/mfd/max8997.h>
29 #include <linux/mfd/max8997-private.h>
30 #include <linux/mmc/host.h>
31 #include <linux/power/max17042_battery.h>
32 #include <linux/power/max8903_charger.h>
33 #include <linux/ramoops.h>
34 #include <linux/mmcoops.h>
35 #include <linux/uart_select.h>
36 #include <linux/memblock.h>
37 #include <linux/rtc/rtc-s3c.h>
38 #include <linux/pwm_backlight.h>
39 #include <linux/jack.h>
40 #include <linux/k3g.h>
41 #include <linux/kr3dh.h>
42 #include <linux/micro_usb_switch.h>
43 #include <linux/switch.h>
44 #include <linux/bh1721.h>
45 #include <linux/sii9234_platform.h>
46 #include <linux/utsname.h>
47 #include <linux/cpufreq.h>
48 #include <linux/modem/xmm6260.h>
49 #include <linux/power/charger-manager.h>
50 #include <video/platform_lcd.h>
51
52 #include <asm/mach-types.h>
53 #include <asm/mach/arch.h>
54 #include <asm/setup.h>
55
56 #include <mach/map.h>
57 #include <mach/gpio.h>
58 #include <mach/regs-clock.h>
59 #include <mach/regs-pmu.h>
60 #include <mach/universal.h>
61
62 #include <plat/cpu.h>
63 #include <plat/clock.h>
64 #include <plat/devs.h>
65 #include <plat/gpio-cfg.h>
66 #include <plat/gpio-core.h>
67 #include <plat/fb.h>
68 #include <plat/fimg2d.h>
69 #include <plat/mali.h>
70 #include <plat/iic.h>
71 #include <plat/pm.h>
72 #include <plat/regs-otg.h>
73 #include <plat/regs-serial.h>
74 #include <plat/s5pv310.h>
75 #include <plat/sdhci.h>
76 #include <plat/adc.h>
77 #include <plat/fimd_drm.h>
78 #include <plat/tvout.h>
79 #include <plat/pd.h>
80 #include <plat/s5p_fimd_ext.h>
81 #include <plat/s5p_fimd_lite.h>
82 #include <plat/usb_ehci.h>
83 #include <plat/mdnie.h>
84 #include <plat/sysmmu.h>
85 #include <plat/s5p-otghost.h>
86 #include <plat/udc-hs.h>
87
88 #include "bcm4330.h"
89 #include "bcm4751.h"
90 #include "gpio-mobile.h"
91 #include "gpio-slp10.h"
92 #include "board-mobile.h"
93 #include "../../../drivers/usb/gadget/s3c_udc.h"
94 #if defined(CONFIG_DEV_THERMAL)
95 #include <plat/s5p-tmu.h>
96 #include <mach/regs-tmu.h>
97 #endif
98
99 /* Following are default values for UCON, ULCON and UFCON UART registers */
100 #define UNIVERSAL_UCON_DEFAULT  (S3C2410_UCON_TXILEVEL |        \
101                                  S3C2410_UCON_RXILEVEL |        \
102                                  S3C2410_UCON_TXIRQMODE |       \
103                                  S3C2410_UCON_RXIRQMODE |       \
104                                  S3C2410_UCON_RXFIFO_TOI |      \
105                                  S3C2443_UCON_RXERR_IRQEN)
106
107 #define UNIVERSAL_ULCON_DEFAULT S3C2410_LCON_CS8
108
109 #define UNIVERSAL_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE |       \
110                                  S5PV210_UFCON_TXTRIG256 |      \
111                                  S5PV210_UFCON_RXTRIG256)
112
113 enum fixed_regulator_id {
114         FIXED_REG_ID_MMC = 0,
115         FIXED_REG_ID_LCD,
116         FIXED_REG_ID_BACKLIGHT,
117         FIXED_REG_ID_CAM0,
118         FIXED_REG_ID_CAM1,
119         FIXED_REG_ID_CAM2,
120         FIXED_REG_ID_MAX8903,
121 };
122
123 #if 0
124 /* Enable when use it really */
125 static int hwrevision(int hwrev)
126 {
127         return ((system_rev & 0xFF) == hwrev);
128 }
129 #endif
130
131 static struct s3c2410_uartcfg slp10_uartcfgs[] __initdata = {
132         {
133                 .hwport         = 0,
134                 .ucon           = UNIVERSAL_UCON_DEFAULT,
135                 .ulcon          = UNIVERSAL_ULCON_DEFAULT,
136                 .ufcon          = UNIVERSAL_UFCON_DEFAULT,
137         },
138         {
139                 .hwport         = 1,
140                 .ucon           = UNIVERSAL_UCON_DEFAULT,
141                 .ulcon          = UNIVERSAL_ULCON_DEFAULT,
142                 .ufcon          = UNIVERSAL_UFCON_DEFAULT,
143         },
144         {
145                 .hwport         = 2,
146                 .ucon           = UNIVERSAL_UCON_DEFAULT,
147                 .ulcon          = UNIVERSAL_ULCON_DEFAULT,
148                 .ufcon          = UNIVERSAL_UFCON_DEFAULT,
149         },
150         {
151                 .hwport         = 3,
152                 .ucon           = UNIVERSAL_UCON_DEFAULT,
153                 .ulcon          = UNIVERSAL_ULCON_DEFAULT,
154                 .ufcon          = UNIVERSAL_UFCON_DEFAULT,
155         },
156 };
157
158 static struct s3c2410_platform_i2c slp10_i2c0_platdata __initdata = {
159         .frequency      = 300 * 1000,
160         .sda_delay      = 200,
161 };
162
163 static struct k3g_platform_data slp10_k3g_data = {
164         .irq2                   = IRQ_EINT(1),
165         .powerdown              = K3G_POWERDOWN_NORMAL,
166         .zen                    = K3G_Z_EN,
167         .yen                    = K3G_Y_EN,
168         .xen                    = K3G_X_EN,
169         .block_data_update      = K3G_BLOCK_DATA_UPDATE,
170         .fullscale              = K3G_FULL_SCALE_2000DPS,
171         .fifo_mode              = K3G_FIFO_FIFO_MODE,
172         .int2_src               = K3G_INT2_OVERRUN,
173         .fifo_threshold         = 16,
174         .int1_enable            = K3G_INT1_EN,
175         .int1_z_high_enable     = K3G_Z_HIGH_INT_EN,
176         .int1_y_high_enable     = K3G_Y_HIGH_INT_EN,
177         .int1_x_high_enable     = K3G_X_HIGH_INT_EN,
178         .int1_latch             = K3G_INTERRUPT_LATCHED,
179         .int1_z_threshold       = 0x12,
180         .int1_y_threshold       = 0x25,
181         .int1_x_threshold       = 0x25,
182         .int1_wait_enable       = K3G_INT1_WAIT_EN,
183         .int1_wait_duration     = 0x10,
184 };
185
186 static struct kr3dh_platform_data slp10_kr3dh_data = {
187         .power_mode             = KR3DH_LOW_POWER_10HZ,
188         .data_rate              = KR3DH_ODR_50HZ,
189         .zen                    = 1,
190         .yen                    = 1,
191         .xen                    = 1,
192         .int1_latch             = 1,
193         .int1_cfg               = KR3DH_INT_SOURCE,
194         .block_data_update      = 1,
195         .fullscale              = KR3DH_RANGE_2G,
196         .int1_combination       = KR3DH_OR_COMBINATION,
197         .int1_6d_enable         = 1,
198         .int1_z_high_enable     = 1,
199         .int1_z_low_enable      = 1,
200         .int1_y_high_enable     = 1,
201         .int1_y_low_enable      = 1,
202         .int1_x_high_enable     = 1,
203         .int1_x_low_enable      = 1,
204         .int1_threshold         = 0x25,
205         .int1_duration          = 0x01,
206         .negate_x               = 0,
207         .negate_y               = 0,
208         .negate_z               = 1,
209         .change_xy              = 1,
210 };
211
212 static struct kr3dh_platform_data slp10_rev06_kr3dh_data = {
213         .power_mode             = KR3DH_LOW_POWER_10HZ,
214         .data_rate              = KR3DH_ODR_50HZ,
215         .zen                    = 1,
216         .yen                    = 1,
217         .xen                    = 1,
218         .int1_latch             = 1,
219         .int1_cfg               = KR3DH_INT_SOURCE,
220         .block_data_update      = 1,
221         .fullscale              = KR3DH_RANGE_2G,
222         .int1_combination       = KR3DH_OR_COMBINATION,
223         .int1_6d_enable         = 1,
224         .int1_z_high_enable     = 1,
225         .int1_z_low_enable      = 1,
226         .int1_y_high_enable     = 1,
227         .int1_y_low_enable      = 1,
228         .int1_x_high_enable     = 1,
229         .int1_x_low_enable      = 1,
230         .int1_threshold         = 0x25,
231         .int1_duration          = 0x01,
232         .negate_x               = 0,
233         .negate_y               = 1,
234         .negate_z               = 0,
235         .change_xy              = 1,
236 };
237
238 #ifdef CONFIG_CPU_FREQ_TICKLE
239 static void user_input_response(void *data)
240 {
241         /* core 0's cpufreq controls both cores */
242         cpufreq_tickle_cpu(100, 0);
243 }
244 #endif
245
246 /* I2C1 */
247 static struct i2c_board_info i2c1_devs[] __initdata = {
248         {
249                 /* Gyro sensor */
250                 I2C_BOARD_INFO("K3G", 0x69),
251                 .platform_data  = &slp10_k3g_data,
252                 .irq            = IRQ_EINT(0),
253         }, {
254                 /* Accelerometer */
255                 I2C_BOARD_INFO("KR3DH", 0x19),
256                 /* platform_data will be set in sensor_init*/
257                 .irq            = IRQ_EINT(24),
258         }
259 };
260
261 /* I2C3: TSP */
262
263 /* FIXME: Only use for tuning */
264 static u8 mxt_init_vals[] __initdata = {
265         /* MXT_GEN_COMMAND(6) */
266         0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
267         /* MXT_GEN_POWER(7) */
268         0x20, 0xff, 0x32,
269         /* MXT_GEN_ACQUIRE(8) */
270         0x0a, 0x00, 0x05, 0x0a, 0x00, 0x00, 0x00, 0x30, 0x32, 0x19,
271         /* MXT_TOUCH_MULTI(9) */
272         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
273         0x00, 0x03, 0x01, 0x2e, 0x0a, 0x05, 0x05, 0x0a, 0x00, 0x00,
274         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
275         0x12, 0x0a, 0x01, 0x03,
276         /* MXT_TOUCH_KEYARRAY(15) */
277         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
278         0x00,
279         /* MXT_PROCG_NOISE(22) */
280         0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00,
281         0x00, 0x0a, 0x0f, 0x14, 0x19, 0x1e, 0x00,
282         /* MXT_PROCI_ONETOUCH(24) */
283         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
284         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
285         /* MXT_SPT_SELFTEST(25) */
286         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
287         0x00, 0x00, 0x00, 0x00,
288         /* MXT_PROCI_TWOTOUCH(27) */
289         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
290         /* MXT_SPT_CTECONFIG(28) */
291         0x00, 0x00, 0x00, 0x08, 0x36, 0x00,
292         /* MXT_PROCI_GRIP(40) */
293         0x11, 0x00, 0x00, 0x0f, 0x0f,
294         /* MXT_PROCI_PALM(41) */
295         0x01, 0x00, 0x00, 0x28, 0x05, 0x05,
296 };
297
298 static struct mxt_platform_data mxt_platform_data __refconst = {
299         .config                 = mxt_init_vals,
300         .config_length          = ARRAY_SIZE(mxt_init_vals),
301
302         .x_line                 = 27,
303         .y_line                 = 42,
304         .x_size                 = 800,
305         .y_size                 = 1280,
306         .blen                   = 0x11,
307         .threshold              = 0x30,
308         .voltage                = 3300000,              /* 3.3V */
309         .orient                 = MXT_VERTICAL_FLIP,
310         .irqflags               = IRQF_TRIGGER_FALLING,
311
312 #ifdef CONFIG_CPU_FREQ_TICKLE
313         /* For the faster user response */
314         .input_event            = user_input_response,
315 #endif
316 };
317
318 static struct i2c_board_info i2c3_devs[] __initdata = {
319         {
320                 I2C_BOARD_INFO("atmel_mxt_ts", 0x4c),
321                 .platform_data  = &mxt_platform_data,
322                 .irq            = IRQ_EINT(4),
323         },
324 };
325
326 static void slp10_power_off(void)
327 {
328         char rst_mode = 'r';
329         char *str_ptr = "reset\n";
330         int poweroff_try = 0;
331         int gpio;
332
333         printk(KERN_INFO "%s: u1 power off\n", __func__);
334         while (1) {
335                 /* Check reboot charging */
336 //              if (is_cable_attached || (poweroff_try >= 5)) {
337                 if (poweroff_try >= 5) {
338                 printk(KERN_INFO
339                         "%s: power off failed(%d), reboot!\n",
340                                 __func__, poweroff_try);
341
342 //                      flush_cache_all();
343 //                      outer_flush_all();
344                         arm_machine_restart(rst_mode, str_ptr);
345 //                      arch_reset(0, 0);
346
347                         printk(KERN_INFO "%s: waiting for reboot.\n", __func__);
348                         while (1);
349                 }
350
351                 /* wait for power button release */
352 //              gpio = MOBILE_GPIO(nPOWER);
353 //              gpio_request(gpio, "nPOWER");
354                 gpio = S5PV310_GPX2(7);
355                 if (gpio_get_value(gpio)) {
356                         printk(KERN_INFO "%s: set PS_HOLD low.\n", __func__);
357                         /* power off code
358                          * PS_HOLD Out/High -->
359                          * Low PS_HOLD_CONTROL, R/W, 0x1002_330C
360                          */
361                         writel(readl(S5P_PS_HOLD_CONTROL) & 0xFFFFFEFF,
362                                 S5P_PS_HOLD_CONTROL);
363
364                         ++poweroff_try;
365
366                         /* when connected zig cable with power, we can't make PS_HOLD_CONTROL low.
367                          * we try power_off 5 times. then if it failed, do restart.
368                          */
369                         printk(KERN_INFO
370                                 "%s: Should not reach here! (poweroff_try:%d)\n",
371                                 __func__, poweroff_try);
372                 }
373
374                 /* if power button is not released, wait and check TA again */
375                 printk(KERN_INFO "%s: PowerButton is not released!.\n",
376                         __func__);
377                 mdelay(1000);
378         }
379 }
380
381
382 static void __init slp10_tsp_init(void)
383 {
384         int gpio;
385
386         /* TOUCH_INT: XEINT_4 */
387         gpio = S5PV310_GPX0(4);
388         gpio_request(gpio, "TOUCH_INT");
389         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
390         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
391
392         /* TOUCH_RST : XGNSS_GPIO_4 */
393         gpio = S5PV310_GPL2(4);
394         gpio_request(gpio, "TOUCH_RST");
395         gpio_direction_output(gpio, 1);
396 }
397
398 /* Workaround */
399 static struct s3c2410_platform_i2c slp10_i2c3_platdata __initdata = {
400         .flags          = 0,
401         .bus_num        = 3,
402         .slave_addr     = 0x10,
403         .frequency      = 380 * 1000,
404         .sda_delay      = 100,
405 };
406
407 #ifdef CONFIG_MHL_SII9234
408 static void mhl_cfg_gpio(void)
409 {
410         int gpio;
411
412         /* HDMI_EN : VSIL_1.2A, VSIL_1.2C, VCC_3.3V_MHL, VCC_1.8V_MHL */
413         gpio = S5PV310_GPX2(4);
414         gpio_request(gpio, "HDMI_EN");
415         gpio_direction_output(gpio, 0);
416
417         /* MHL_RST */
418         gpio = S5PV310_GPF3(4);
419         gpio_request(gpio, "MHL_RST");
420         gpio_direction_output(gpio, 0);
421
422         /* MHL_INT */
423 #define MHL_INT         S5PV310_GPF3(5)
424 }
425
426 static void mhl_enable(unsigned int enable)
427 {
428         int hdmi_en, mhl_rst;
429
430         hdmi_en = S5PV310_GPX2(4);
431         mhl_rst = S5PV310_GPF3(4);
432
433         if (enable) {
434                 printk(KERN_INFO "SII9234 MHL enable.\n");
435
436                 gpio_set_value(hdmi_en, 1);
437                 gpio_set_value(mhl_rst, 0);
438                 msleep(200);
439                 gpio_set_value(mhl_rst, 1);
440                 /* FIXME just rising edge only??? */
441         } else {
442                 printk(KERN_INFO "SII9234 MHL disable.\n");
443
444                 gpio_set_value(hdmi_en, 0);
445                 gpio_set_value(mhl_rst, 0);
446         }
447 }
448
449 static struct sii9234_platform_data slp10_sii9234_pdata = {
450         .cfg_pin        = mhl_cfg_gpio,
451         .enable         = mhl_enable,
452 };
453 #endif
454
455 extern struct max8997_platform_data slp10_max8997_pdata;
456 extern void __init slp10_pmic_init(void);
457 extern struct charger_global_desc slp7_charger_g_desc;
458
459 static void haptic_control_power(struct device *dev, int on)
460 {
461         struct regulator *regulator;
462         static bool status = false;
463
464         if (on && !status) {
465                 regulator = regulator_get(dev, "inmotor");
466                 if (IS_ERR_OR_NULL(regulator))
467                         return;
468                 regulator_enable(regulator);
469                 regulator_put(regulator);
470                 status = true;
471         }
472         if (!on && status) {
473                 regulator = regulator_get(dev, "inmotor");
474                 if (IS_ERR_OR_NULL(regulator))
475                         return;
476
477                 if (regulator_is_enabled(regulator))
478                         regulator_disable(regulator);
479                 regulator_put(regulator);
480                 status = false;
481         }
482 }
483
484 struct max8997_haptic_platform_data slp10_haptic_pdata = {
485         .name           = "vibtone",
486         .pwm_timer      = 1,
487         .control_power  = haptic_control_power,
488 };
489
490 /* GPIO I2C 5 (PMIC) */
491 enum { I2C5_MAX8997 };
492 static struct i2c_board_info i2c5_devs[] __initdata = {
493         [I2C5_MAX8997] = {
494                 I2C_BOARD_INFO("max8997", 0xCC >> 1),
495                 .platform_data  = &slp10_max8997_pdata,
496         },
497 };
498
499 /* GPIO I2C 6 */
500 static struct i2c_board_info i2c6_devs[] __initdata = {
501         {
502                 /* Audio Codec */
503                 I2C_BOARD_INFO("mc1n2", 0x3a),
504         },
505 };
506
507 static void __init slp10_sound_init(void)
508 {
509         int val;
510
511         /* Set PMU register to set CLK_OUT to use XUSBXTI
512          * as codec source clock */
513         val = 0x900;
514         __raw_writel(val, S5P_PMREG(0xA00));
515 }
516
517 /* I2C7 */
518 static struct i2c_board_info i2c7_devs[] __initdata = {
519         {
520                 /* Compass */
521                 I2C_BOARD_INFO("ak8975", 0x0c),
522         },
523 };
524
525 static void __init slp10_sensor_init(void)
526 {
527         int gpio;
528
529         gpio = S5PV310_GPX2(2); /* XEINT_18 */
530         gpio_request(gpio, "MSENSE_INT");
531         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
532         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
533         i2c7_devs[0].irq = gpio_to_irq(gpio);
534
535         gpio = S5PV310_GPX0(0); /* XEINT_0 */
536         gpio_request(gpio, "GYRO_INT");
537         gpio_direction_input(gpio);
538         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_DOWN);
539
540         gpio = S5PV310_GPX0(1); /* XEINT_1 */
541         gpio_request(gpio, "GYRO_INT1");
542         gpio_direction_input(gpio);
543         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_DOWN);
544
545         gpio = S5PV310_GPX3(0); /* XEINT_24 */
546         gpio_request(gpio, "ACC_INT");
547         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
548         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_DOWN);
549
550         if ((system_rev & 0xFF) == 0x6)
551                 i2c1_devs[1].platform_data = &slp10_rev06_kr3dh_data;
552         else
553                 i2c1_devs[1].platform_data = &slp10_kr3dh_data;
554 }
555
556 /* I2C8: HDMI */
557
558 /* I2C9 */
559 static struct i2c_gpio_platform_data i2c9_gpio_data = {
560         .sda_pin                = S5PV310_GPY4(0),      /* XM0ADDR_8 */
561         .scl_pin                = S5PV310_GPY4(1),      /* XM0ADDR_9 */
562 };
563
564 static struct platform_device i2c9_gpio = {
565         .name                   = "i2c-gpio",
566         .id                     = 9,
567         .dev                    = {
568                 .platform_data  = &i2c9_gpio_data,
569         },
570 };
571
572 static struct max17042_reg_data max17042_init_data[] = {
573         { MAX17042_CGAIN,               8192 },
574         { MAX17042_MiscCFG,             0x0003 },
575         { MAX17042_LearnCFG,            0x0007 },
576         /* RCOMP: 0x0050 2011.02.29 from MAXIM */
577         { MAX17042_RCOMP0,              0x0050 },
578         { MAX17042_DesignCap,           0x1F40 }, /* 4000mAh */
579 };
580 /* Alert only when the battery is removed or inserted */
581 static struct max17042_reg_data max17042_alert_init_data[] = {
582         /* SALRT Threshold setting (disable) unsigned MAX/MIN */
583         { MAX17042_SALRT_Th,    0xFF00 },
584         /* VALRT Threshold setting (disable) unsigned MAX/MIN */
585         { MAX17042_VALRT_Th,    0xFF00 },
586         /* TALRT Threshold setting (disable) signed MAX/MIN */
587         { MAX17042_TALRT_Th,    0x7F80 },
588 };
589 static struct max17042_platform_data slp10_battery_platform_data = {
590         .init_data = max17042_init_data,
591         .num_init_data = ARRAY_SIZE(max17042_init_data),
592         .alrt_data = max17042_alert_init_data,
593         .num_alrt_data = ARRAY_SIZE(max17042_alert_init_data),
594         .irq_base = IRQ_FUEL_BASE,
595         .enable_alert = true,
596         .wakeup = true,
597         .r_sns = 10000, /* 10m Ohm */
598 };
599
600 enum { I2C9_MAX17042};
601 static struct i2c_board_info i2c9_devs[] __initdata = {
602         [I2C9_MAX17042] = {
603                 I2C_BOARD_INFO("max17042", 0x36),
604                 .platform_data = &slp10_battery_platform_data,
605         },
606 };
607
608 /* I2C14: Light */
609
610 static struct bh1721_platform_data bh1721_plat_data = {
611         .reset = NULL,
612         .power_control = NULL,
613 };
614
615 static void light_sensor_toggle(int gpio, int toggle)
616 {
617         gpio_direction_output(gpio, toggle);
618 }
619
620 static int light_sensor_power_control(int onoff)
621 {
622         struct regulator *regulator;
623         static DEFINE_MUTEX(lock);
624         static bool enabled;
625         int ret = 0;
626
627         mutex_lock(&lock);
628
629         if (enabled == !!onoff)
630                 goto out;
631                 
632         if (regulator == NULL)
633                 regulator = regulator_get(NULL, "vadc");
634         if (IS_ERR_OR_NULL(regulator)) {
635                 regulator = NULL;
636                 pr_err("[LS][ERROR] regulator_get fail\n");
637                 ret = -EINVAL;
638                 goto out;
639         }
640
641         if (onoff) {
642                 ret = regulator_enable(regulator);
643                 msleep(1);
644         }
645         else
646                 ret = regulator_disable(regulator);
647
648         if (!ret)
649                 enabled = !!onoff;
650
651 out:
652         mutex_unlock(&lock);
653         return ret;
654 }
655
656 static void __init slp10_light_sensor_init(void)
657 {
658         struct bh1721_platform_data *pdata = &bh1721_plat_data;
659         int gpio;
660
661         gpio = S5PV310_GPX0(2); /* XEINT_2 */
662         gpio_request(gpio, "LIGHT_nINT");
663         gpio_direction_output(gpio, 0);
664         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
665
666         pdata->reset = light_sensor_toggle;
667         pdata->power_control = light_sensor_power_control;
668         pdata->gpio = gpio;
669 }
670
671 static struct i2c_gpio_platform_data i2c14_gpio_data = {
672         .sda_pin                = S5PV310_GPK2(2),      /* XMMC2CDn */
673         .scl_pin                = S5PV310_GPK3(2),      /* XMMC3CDn */
674         .udelay                 = 1,                    /* 500kHz   */
675 };
676
677 static struct platform_device i2c14_gpio = {
678         .name                   = "i2c-gpio",
679         .id                     = 14,
680         .dev                    = {
681                 .platform_data  = &i2c14_gpio_data,
682         },
683 };
684
685 static struct i2c_board_info i2c14_devs[] __initdata = {
686         {
687                 I2C_BOARD_INFO("bh1721", 0x23),
688                 .platform_data = &bh1721_plat_data,
689         },
690 };
691
692 /* I2C15: MHL */
693 static struct i2c_gpio_platform_data i2c15_gpio_data = {
694         .sda_pin                = S5PV310_GPY3(0),      /* XM0ADDR_0 */
695         .scl_pin                = S5PV310_GPY3(2),      /* XM0ADDR_2 */
696         .udelay                 = 2,
697 };
698
699 static struct platform_device i2c15_gpio = {
700         .name                   = "i2c-gpio",
701         .id                     = 15,
702         .dev                    = {
703                 .platform_data  = &i2c15_gpio_data,
704         },
705 };
706
707 static struct i2c_board_info i2c15_devs[] __initdata = {
708 #ifdef CONFIG_MHL_SII9234
709         {
710                 I2C_BOARD_INFO("sii9234", 0x72),
711                 .platform_data = &slp10_sii9234_pdata,
712         },
713 #endif
714 };
715
716
717 /* USB EHCI */
718 static struct s5p_usb_ehci_platdata slp10_usb_ehci_pdata;
719
720 static void __init slp10_usb_ehci_init(void)
721 {
722         struct s5p_usb_ehci_platdata *pdata = &slp10_usb_ehci_pdata;
723
724         /* The gpios is initialized from modem_init */
725         pdata->gpio_active = MOBILE_GPIO(ACTIVE_STATE_HSIC);
726
727         s5p_usb_ehci_set_platdata(pdata);
728 }
729
730 /* USB OTG */
731 /* we don't use OTGDRVVBUS pin for powering up otg charging pump */
732 static void slp10_otg_power_cb(int enable)
733 {
734         int gpio;
735         u8 on = (u8)!!enable;
736         gpio = MOBILE_GPIO(USB_OTG_EN);
737         gpio_request(gpio, "USB_OTG_EN");
738         gpio_direction_output(gpio, on);
739         gpio_free(gpio);
740         pr_info("%s: otg power = %d\n", __func__, on);
741 }
742
743 static void __init slp10_usb_otg_init(void)
744 {
745         struct host_notify_dev *slp10_otg_ndev =
746                         dev_get_platdata(&s3c_device_usbgadget.dev);
747         struct sec_otghost_data *slp10_otg_host_data =
748                         dev_get_platdata(&s3c_device_usb_otghcd.dev);
749
750         slp10_otg_ndev->set_booster = slp10_otg_power_cb;
751         slp10_otg_host_data->set_pwr_cb = slp10_otg_power_cb;
752 }
753
754 /* MODEM Net */
755 static struct platform_device slp10_modem_net = {
756         .name                   = "modem_net",
757         .id                     = -1,
758 };
759
760
761 /* XMM6260 control */
762 static struct xmm6260_gpios slp10_xmm6260_gpios;
763
764 static struct xmm6260_platform_data slp10_xmm6260_pdata = {
765         .gpios                  = &slp10_xmm6260_gpios,
766         .wakeup                 = 1,
767 };
768
769 static struct platform_device slp10_xmm6260 = {
770         /* FIXME: Use modemctl name because of platform dependency */
771         .name                   = "modemctl",
772         .id                     = -1,
773         .dev                    = {
774                 .platform_data  = &slp10_xmm6260_pdata,
775         },
776 };
777
778 static void __init slp10_modem_init(void)
779 {
780         struct xmm6260_gpios *gpios = &slp10_xmm6260_gpios;
781         int gpio;
782
783         gpio = MOBILE_GPIO(CP_ON);
784         gpio_request(gpio, "CP_ON");
785         gpio_direction_output(gpio, 0);
786         gpios->cp_on = gpio;
787
788         gpio = MOBILE_GPIO(PHONE_ACTIVE);
789         gpio_request(gpio, "PHONE_ACTIVE");
790         gpios->phone_active = gpio;
791
792         gpio = MOBILE_GPIO(PDA_ACTIVE);
793         gpio_request(gpio, "PDA_ACTIVE");
794         gpio_direction_output(gpio, 0);
795         gpios->pda_active = gpio;
796
797         gpio = MOBILE_GPIO(CP_DUMP_INT);
798         gpio_request(gpio, "CP_DUMP_INT");
799         gpios->cp_dump_int = gpio;
800
801         gpio = MOBILE_GPIO(CP_RST);
802         gpio_request(gpio, "CP_RST");
803         gpio_direction_output(gpio, 0);
804         gpios->cp_pmu_rst = gpio;
805
806         gpio = MOBILE_GPIO(RESET_REQ_N);
807         gpio_request(gpio, "RESET_REQ_N");
808         gpio_direction_output(gpio, 0);
809         gpios->reset_req_n = gpio;
810
811         gpio = MOBILE_GPIO(IPC_SLAVE_WAKEUP);
812         gpio_request(gpio, "IPC_SLAVE_WAKEUP");
813         gpio_direction_output(gpio, 0);
814         gpios->ipc_slave_wakeup = gpio;
815
816         gpio = MOBILE_GPIO(IPC_HOST_WAKEUP);
817         gpio_request(gpio, "IPC_HOST_WAKEUP");
818         gpios->ipc_host_wakeup = gpio;
819
820         gpio = MOBILE_GPIO(SUSPEND_REQUEST_HSIC);
821         gpio_request(gpio, "SUSPEND_REQUEST_HSIC");
822         gpios->suspend_request_hsic = gpio;
823
824         gpio = MOBILE_GPIO(ACTIVE_STATE_HSIC);
825         gpio_request(gpio, "ACTIVE_STATE_HSIC");
826         gpio_direction_output(gpio, 0);
827         gpios->active_state_hsic = gpio;
828 }
829
830 /* Uart Select */
831 static void slp10_set_uart_switch(int path)
832 {
833         int gpio;
834
835         gpio = MOBILE_GPIO(UART_SEL);
836         gpio_request(gpio, "UART_SEL");
837
838         /* slp10 target is gpio_high == AP */
839         if (path == UART_SW_PATH_AP)
840                 gpio_set_value(gpio, GPIO_LEVEL_HIGH);
841         else if (path == UART_SW_PATH_CP)
842                 gpio_set_value(gpio, GPIO_LEVEL_LOW);
843
844         gpio_free(gpio);
845         return;
846 }
847
848 static int slp10_get_uart_switch(void)
849 {
850         int val;
851         int gpio;
852
853         gpio = MOBILE_GPIO(UART_SEL);
854         gpio_request(gpio, "UART_SEL");
855         val = gpio_get_value(gpio);
856         gpio_free(gpio);
857
858         /* slp10 target is gpio_high == AP */
859         if (val == GPIO_LEVEL_HIGH)
860                 return UART_SW_PATH_AP;
861         else if (val == GPIO_LEVEL_LOW)
862                 return UART_SW_PATH_CP;
863         else
864                 return UART_SW_PATH_NA;
865 }
866
867 static struct uart_select_platform_data slp10_uart_select_data = {
868         .set_uart_switch        = slp10_set_uart_switch,
869         .get_uart_switch        = slp10_get_uart_switch,
870 };
871
872 static struct platform_device slp10_uart_select = {
873         .name                   = "uart-select",
874         .id                     = -1,
875         .dev                    = {
876                 .platform_data  = &slp10_uart_select_data,
877         },
878 };
879
880 /* eMMC */
881 #ifndef CONFIG_S3C_DEV_HSMMC4
882 static struct s3c_sdhci_platdata slp10_hsmmc0_data __initdata = {
883         .max_width              = 8,
884         .host_caps              = (MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA |
885                            MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
886                            MMC_CAP_DISABLE),
887         .cd_type                = S3C_SDHCI_CD_PERMANENT,
888         .clk_type               = S3C_SDHCI_CLK_DIV_EXTERNAL,
889 };
890 #endif
891
892 static struct regulator_consumer_supply emmc_supplies[] = {
893         REGULATOR_SUPPLY("vmmc", "s3c-sdhci.0"),
894         REGULATOR_SUPPLY("vmmc", "dw_mmc"),
895 };
896
897 static struct regulator_init_data emmc_fixed_voltage_init_data = {
898         .constraints            = {
899                 .name           = "VMEM_VDD_2.8V",
900                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
901         },
902         .num_consumer_supplies  = ARRAY_SIZE(emmc_supplies),
903         .consumer_supplies      = emmc_supplies,
904 };
905
906 static struct fixed_voltage_config emmc_fixed_voltage_config = {
907         .supply_name            = "MASSMEMORY_EN (inverted)",
908         .microvolts             = 2800000,
909         .gpio                   = S5PV310_GPL1(1),
910         .enable_high            = false,
911         .init_data              = &emmc_fixed_voltage_init_data,
912 };
913
914 static struct platform_device emmc_fixed_voltage = {
915         .name                   = "reg-fixed-voltage",
916         .id                     = FIXED_REG_ID_MMC,
917         .dev                    = {
918                 .platform_data  = &emmc_fixed_voltage_config,
919         },
920 };
921
922 /* WLAN */
923 static void (*wlan_notify_change_cb)(struct platform_device *dev, int state);
924
925 static int wlan_ext_cd_init(void (*cb)(struct platform_device *dev, int state))
926 {
927         wlan_notify_change_cb = cb;
928         return 0;
929 }
930
931 static int wlan_ext_cd_cleanup(void (*cb)(struct platform_device *dev, int state))
932 {
933         wlan_notify_change_cb = NULL;
934         return 0;
935 }
936
937 static int slp10_wlan_host_enable(int on)
938 {
939         if (wlan_notify_change_cb)
940                 (*wlan_notify_change_cb)(&s3c_device_hsmmc3, on);
941         return 0;
942 }
943
944 static struct s3c_sdhci_platdata slp10_hsmmc3_data __initdata = {
945         .max_width              = 4,
946         .host_caps              = (MMC_CAP_4_BIT_DATA |
947                            MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
948         .pm_caps                = MMC_PM_KEEP_POWER,
949         .cd_type                = S3C_SDHCI_CD_EXTERNAL,
950         .ext_cd_init            = &wlan_ext_cd_init,
951         .ext_cd_cleanup         = &wlan_ext_cd_cleanup,
952         .clk_type               = S3C_SDHCI_CLK_DIV_EXTERNAL,
953 };
954
955 static void __init slp10_sdhci_init(void)
956 {
957         unsigned int gpio;
958
959         gpio = S5PV310_GPX3(3); /* T-Flash Detect */
960         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
961         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
962
963 #ifndef CONFIG_S3C_DEV_HSMMC4
964         s3c_sdhci0_set_platdata(&slp10_hsmmc0_data);
965 #endif
966         s3c_sdhci3_set_platdata(&slp10_hsmmc3_data);
967 }
968
969 /* BCM4330 */
970 static struct bcm4330_platform_data bcm4330_data = {
971         .wlan_en                = S5PV310_GPL1(2),      /* XGNSS_EPOCH  */
972         .wlan_host_wake         = S5PV310_GPX2(5),      /* XEINT[21]    */
973         .bt_en                  = S5PV310_GPL0(4),      /* XGNSS_QMAG   */
974         .bt_nrst                = S5PV310_GPL1(0),      /* XGNSS_SCL    */
975         .bt_host_wake           = S5PV310_GPX2(6),      /* XEINT[22]    */
976         .bt_wake                = S5PV310_GPX3(1),      /* XEINT[25]    */
977         .bt_uart[0]             = S5PV310_GPA0(0),      /* XuRXD[0]     */
978         .bt_uart[1]             = S5PV310_GPA0(1),      /* XuTXD[0]     */
979         .bt_uart[2]             = S5PV310_GPA0(2),      /* XuCTSn[0]    */
980         .bt_uart[3]             = S5PV310_GPA0(3),      /* XuRTSn[0]    */
981         .wlan_host_enable       = &slp10_wlan_host_enable,
982 };
983
984 static struct platform_device slp10_bcm4330 = {
985         .name                   = "bcm4330-b1",
986         .id                     = -1,
987         .dev                    = {
988                 .platform_data  = &bcm4330_data,
989         },
990 };
991
992 /* MALI DRM. */
993 #ifdef CONFIG_DRM_MALI
994 static struct platform_device s5p_device_mali_drm = {
995         .name                   = "mali_drm",
996         .id                     = -1,
997 };
998 #endif
999
1000 /* FIMD DRM. */
1001 #ifdef CONFIG_DRM_FIMD
1002 static struct resource fimd_drm_resource[] = {
1003         [0] = {
1004                 .start          = S5P_PA_LCD0,
1005                 .end            = S5P_PA_LCD0 + S5P_SZ_LCD0 - 1,
1006                 .flags          = IORESOURCE_MEM,
1007         },
1008         [1] = {
1009                 .start          = S5P_PA_LCD1,
1010                 .end            = S5P_PA_LCD1 + S5P_SZ_LCD1 - 1,
1011                 .flags          = IORESOURCE_MEM,
1012         },
1013         [2] = {
1014                 .start          = IRQ_LCD1,
1015                 .end            = IRQ_LCD1,
1016                 .flags          = IORESOURCE_IRQ,
1017         },
1018         [3] = {
1019                 .start          = IRQ_LCD0,
1020                 .end            = IRQ_LCD0,
1021                 .flags          = IORESOURCE_IRQ,
1022         },
1023 };
1024
1025 static struct fimd_drm_platform_data fimd_drm_pd = {
1026         .hw_ver = 0x70,
1027 };
1028
1029 static struct platform_device s5p_device_fimd_drm = {
1030         .name                   = "fimd_drm",
1031         .id                     = -1,
1032         .num_resources          = ARRAY_SIZE(fimd_drm_resource),
1033         .resource               = fimd_drm_resource,
1034         .dev                    = {
1035                 .platform_data = &fimd_drm_pd,
1036         },
1037 };
1038 #endif
1039
1040 /* BCM4751 GPS */
1041 static struct bcm4751_platform_data slp10_bcm4751_data = {
1042         .regpu                  = S5PV310_GPK0(2),      /* XMMC0_CDN */
1043         .nrst                   = S5PV310_GPL0(2),      /* XGNSS_IMAG */
1044         .uart_rxd               = S5PV310_GPA0(4),      /* XURXD[1] */
1045         .clk_int                = S5PV310_GPY3(6),      /* XM0ADDR[6] */
1046 };
1047
1048 static struct platform_device slp10_bcm4751 = {
1049         .name                   = "bcm4751",
1050         .id                     = -1,
1051         .dev                    = {
1052                 .platform_data  = &slp10_bcm4751_data,
1053         },
1054 };
1055
1056 /* ADC */
1057 static struct s3c_adc_platform_data s3c_adc_pdata __initdata = {
1058         .delay                  = 1000,
1059         .presc                  = 49,
1060         .resolution             = 12,
1061         .max_adc_voltage_uV     = 3300000,
1062 };
1063
1064 static void __init slp10_adc_init(void)
1065 {
1066         s3c_adc_set_platdata(&s3c_adc_pdata);
1067 }
1068
1069 static void ramoops_enable(int enable)
1070 {
1071         struct clk *clk;
1072
1073         clk = clk_get(NULL, "modem");
1074         if (enable)
1075                 clk_enable(clk);
1076         else
1077                 clk_disable(clk);
1078         clk_put(clk);
1079 }
1080
1081 static struct ramoops_platform_data slp10_ramoops_data = {
1082         .mem_address            = 0x13A00000,           /* MODEM I/F */
1083         .mem_size               = SZ_16K,
1084         .enable                 = ramoops_enable,
1085 };
1086
1087 static struct platform_device slp10_ramoops = {
1088         .name                   = "ramoops",
1089         .dev                    = {
1090                 .platform_data  = &slp10_ramoops_data,
1091         },
1092 };
1093
1094 /* TZPC */
1095 static struct platform_device slp10_tzpc = {
1096         .name                   = "tzpc",
1097         .id                     = -1,
1098 };
1099
1100 #ifdef CONFIG_ANDROID_RAM_CONSOLE
1101 static struct resource ram_console_resource[] = {
1102         [0] = {
1103                 .flags = IORESOURCE_MEM,
1104         },
1105 };
1106
1107 static struct platform_device ram_console_device = {
1108         .name                   = "ram_console",
1109         .id                     = -1,
1110         .num_resources          = ARRAY_SIZE(ram_console_resource),
1111         .resource               = ram_console_resource,
1112 };
1113 #endif
1114
1115 static void __init slp10_map_io(void)
1116 {
1117         s5p_init_io(NULL, 0, S5P_VA_CHIPID);
1118         s5p_xtal_set_parent(CLK_XUSBXTI);
1119         s3c24xx_init_clocks(24000000);
1120         s3c24xx_init_uarts(slp10_uartcfgs, ARRAY_SIZE(slp10_uartcfgs));
1121 }
1122
1123 static unsigned long fbmem_start, fbmem_size;
1124 static int __init early_fbmem(char *p)
1125 {
1126         char *endp;
1127
1128         if (!p)
1129                 return -EINVAL;
1130
1131         fbmem_size = memparse(p, &endp);
1132         if (*endp == '@')
1133                 fbmem_start = memparse(endp + 1, &endp);
1134
1135         return endp > p ? 0 : -EINVAL;
1136 }
1137 early_param("fbmem", early_fbmem);
1138
1139 static void __init s5pv310_reserve(void)
1140 {
1141         static struct cma_region regions[] = {
1142 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMD0
1143                 {
1144                         .name = "fimd",
1145                         .size = (36 << 20
1146 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMD1
1147                                 + 36 << 20
1148 #endif
1149                                 ),
1150                 },
1151 #endif
1152 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_JPEG
1153                 {
1154                         .name           = "jpeg",
1155                         .size           = CONFIG_VIDEO_SAMSUNG_MEMSIZE_JPEG *  SZ_1K,
1156                 },
1157 #endif
1158 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC
1159                 {
1160                         .name = "mfc",
1161                         .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC *  SZ_1K,
1162                 },
1163 #endif
1164 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC0
1165                 {
1166                         .name = "mfc0",
1167                         .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC0 * SZ_1K,
1168                         {
1169                                 .alignment = 1 << 17,
1170                         },
1171                 },
1172 #endif
1173 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC1
1174                 {
1175                         .name = "mfc1",
1176                         .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC1 * SZ_1K,
1177                         {
1178                                 .alignment = 1 << 17,
1179                         },
1180                 },
1181 #endif
1182 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC0
1183                 {
1184                         .name = "fimc0",
1185                         .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC0 * SZ_1K,
1186                         .start = 0
1187                 },
1188 #endif
1189 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC1
1190                 {
1191                         .name = "fimc1",
1192                         .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC1 * SZ_1K,
1193                         .start = 0
1194                 },
1195 #endif
1196 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC2
1197                 {
1198                         .name = "fimc2",
1199                         .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC2 * SZ_1K,
1200                         .start = 0
1201                 },
1202 #endif
1203 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC3
1204                 {
1205                         .name = "fimc3",
1206                         .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC3 * SZ_1K,
1207                         .start = 0
1208                 },
1209 #endif
1210                 { }
1211         };
1212
1213         static const char map[] __initconst =
1214                 "s3cfb=fimd;"
1215 #ifdef CONFIG_VIDEO_FIMC
1216                 "s3c-fimc.0=fimc0;"
1217                 "s3c-fimc.1=fimc1;"
1218                 "s3c-fimc.2=fimc2;"
1219                 "s3c-fimc.3=fimc3;"
1220 #endif
1221                 "s5p-jpeg=jpeg;"
1222                 "s3c-mfc=mfc,mfc0,mfc1;"
1223                 "*=b1,b2";
1224
1225         unsigned int i = 0;
1226
1227 #ifdef CONFIG_ANDROID_RAM_CONSOLE
1228         unsigned int addr;
1229
1230         /* FIXME: ram console MUST be reserved at first time */
1231         addr = memblock_alloc_base(SZ_1M, SZ_4K, 0x60000000);
1232         ram_console_resource[0].start = addr;
1233         ram_console_resource[0].end = addr + SZ_1M - 1;
1234         pr_info("ram_console: 0x%08x ~ 0x%08x (1MB)\n",
1235                         addr, addr + SZ_1M);
1236 #endif
1237
1238         if (fbmem_start)
1239                 regions[0].start = (dma_addr_t)fbmem_start;
1240         if (fbmem_size)
1241                 regions[0].size = (size_t)fbmem_size;
1242
1243         cma_set_defaults(regions, map);
1244         cma_early_regions_reserve(NULL);
1245
1246         for (; i < ARRAY_SIZE(regions) - 1 /* terminator */; ++i) {
1247                 pr_info("cma: region: %-8s: 0x%08x ~ 0x%08x (%dMB)\n",
1248                         regions[i].name, regions[i].start,
1249                         regions[i].start + regions[i].size,
1250                         regions[i].size / SZ_1M);
1251         }
1252 }
1253
1254 /*
1255  * GPX are saved and restored at plat-samsung/pm.c:s5c_pm_enter.
1256  * However, they are inside of pm_prepare and pm_finish, so it
1257  * does not save ours against universal_pm_prepare:2.
1258  */
1259 static struct sleep_save s5pc210_gpx[] = {
1260         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C00),
1261         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C04),
1262         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C08),
1263         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C0C),
1264         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C20),
1265         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C24),
1266         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C28),
1267         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C2C),
1268         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C40),
1269         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C44),
1270         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C48),
1271         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C4C),
1272         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C60),
1273         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C64),
1274         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C68),
1275         SAVE_ITEM(S5P_VA_GPIO2 + 0x0C6C),
1276 };
1277
1278 /* GPIO KEYS */
1279 static struct gpio_keys_button slp10_gpio_keys_tables[] = {
1280         {
1281                 .code                   = KEY_HOME,             /* FIXME: VOLUMEUP */
1282                 .gpio                   = S5PV310_GPX2(0),      /* XEINT16 */
1283                 .desc                   = "gpio-keys: KEY_VOLUMEUP",
1284                 .type                   = EV_KEY,
1285                 .active_low             = 1,
1286                 .debounce_interval      = 1,
1287         }, {
1288                 .code                   = KEY_MENU,             /* FIXME: MENU */
1289                 .gpio                   = S5PV310_GPX2(1),      /* XEINT17 */
1290                 .desc                   = "gpio-keys: KEY_MENU",
1291                 .type                   = EV_KEY,
1292                 .active_low             = 1,
1293                 .wakeup                 = 1,
1294                 .debounce_interval      = 1,
1295         }, {
1296                 .code                   = KEY_POWER,
1297                 .gpio                   = S5PV310_GPX2(7),      /* XEINT23 */
1298                 .desc                   = "gpio-keys: KEY_POWER",
1299                 .type                   = EV_KEY,
1300                 .active_low             = 1,
1301                 .wakeup                 = 1,
1302                 .debounce_interval      = 1,
1303         },
1304 };
1305
1306 static struct gpio_keys_platform_data slp10_gpio_keys_data = {
1307         .buttons                = slp10_gpio_keys_tables,
1308         .nbuttons               = ARRAY_SIZE(slp10_gpio_keys_tables),
1309 };
1310
1311 static struct platform_device slp10_gpio_keys = {
1312         .name                   = "gpio-keys",
1313         .dev                    = {
1314                 .platform_data  = &slp10_gpio_keys_data,
1315         },
1316 };
1317
1318
1319
1320 static unsigned int slp10_lcd_enabled;
1321
1322 static struct s3cfb_lcd slp10_lcd = {
1323         .width                  = 1280,
1324         .height                 = 800,
1325         .width_mm = 217,
1326         .height_mm = 136,
1327         .bpp                    = 24,
1328
1329         .freq                   = 60,
1330         .timing = {
1331                 .h_fp           = 16,
1332                 .h_bp           = 64,
1333                 .h_sw           = 48,
1334                 .v_fp           = 1,
1335                 .v_fpe          = 1,
1336                 .v_bp           = 12,
1337                 .v_bpe          = 1,
1338                 .v_sw           = 3,
1339         },
1340         .polarity = {
1341                 .rise_vclk      = 1,
1342                 .inv_hsync      = 1,
1343                 .inv_vsync      = 1,
1344                 .inv_vden       = 0,
1345         },
1346 };
1347
1348 static int lcd_cfg_gpio(void)
1349 {
1350         int gpio, i, f3_end = 4;
1351         u32 reg;
1352
1353         for (i = 0; i < 8; i++) {
1354                 /* set GPF0,1,2[0:7] for RGB Interface and Data lines (32bit) */
1355                 s3c_gpio_cfgpin(S5PV310_GPF0(i), S3C_GPIO_SFN(2));
1356                 s3c_gpio_setpull(S5PV310_GPF0(i), S3C_GPIO_PULL_NONE);
1357
1358         }
1359         for (i = 0; i < 8; i++) {
1360                 s3c_gpio_cfgpin(S5PV310_GPF1(i), S3C_GPIO_SFN(2));
1361                 s3c_gpio_setpull(S5PV310_GPF1(i), S3C_GPIO_PULL_NONE);
1362         }
1363
1364         for (i = 0; i < 8; i++) {
1365                 s3c_gpio_cfgpin(S5PV310_GPF2(i), S3C_GPIO_SFN(2));
1366                 s3c_gpio_setpull(S5PV310_GPF2(i), S3C_GPIO_PULL_NONE);
1367         }
1368
1369         for (i = 0; i < f3_end; i++) {
1370                 s3c_gpio_cfgpin(S5PV310_GPF3(i), S3C_GPIO_SFN(2));
1371                 s3c_gpio_setpull(S5PV310_GPF3(i), S3C_GPIO_PULL_NONE);
1372         }
1373
1374         /* Set FIMD0 bypass */
1375         reg = __raw_readl(S3C_VA_SYS + 0x0210);
1376         reg |= (1<<1);
1377         __raw_writel(reg, S3C_VA_SYS + 0x0210);
1378
1379         /* LED_BACKLIGHT_RESET */
1380         gpio = S5PV310_GPE3(2);
1381         gpio_request(gpio, "LED_BACKLIGHT_RESET");
1382         gpio_direction_output(gpio, 1);
1383
1384         return 0;
1385 }
1386
1387 static struct regulator_consumer_supply lcd_supplies[] = {
1388         REGULATOR_SUPPLY("LVDS_nSHDN", "platform-lcd"),
1389 };
1390
1391 static struct regulator_init_data lcd_fixed_voltage_init_data = {
1392         .constraints            = {
1393                 .name           = "LVDS_nSHDN",
1394                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
1395         },
1396         .num_consumer_supplies  = ARRAY_SIZE(lcd_supplies),
1397         .consumer_supplies      = lcd_supplies,
1398 };
1399
1400 static struct fixed_voltage_config lcd_fixed_voltage_config = {
1401         .supply_name            = "LVDS_nSHDN",
1402         .microvolts             = 2800000,
1403         .gpio                   = S5PV310_GPE1(5),
1404         .enable_high            = true,
1405         .enabled_at_boot        = true,
1406         .init_data              = &lcd_fixed_voltage_init_data,
1407 };
1408
1409 static struct platform_device lcd_fixed_voltage = {
1410         .name                   = "reg-fixed-voltage",
1411         .id                     = FIXED_REG_ID_LCD,
1412         .dev                    = {
1413                 .platform_data  = &lcd_fixed_voltage_config,
1414         },
1415 };
1416
1417 static struct regulator_consumer_supply backlight_supplies[] = {
1418         REGULATOR_SUPPLY("LCD_LDO_EN", "pwm-backlight"),
1419 };
1420
1421 static struct regulator_init_data backlight_fixed_voltage_init_data = {
1422         .constraints            = {
1423                 .name           = "LCD_LDO_EN",
1424                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
1425         },
1426         .num_consumer_supplies  = ARRAY_SIZE(backlight_supplies),
1427         .consumer_supplies      = backlight_supplies,
1428 };
1429
1430 static struct fixed_voltage_config backlight_fixed_voltage_config = {
1431         .supply_name            = "LCD_LDO_EN",
1432         .microvolts             = 2800000,
1433         .gpio                   = S5PV310_GPE2(3),
1434         .enable_high            = true,
1435         .enabled_at_boot        = true,
1436         .init_data              = &backlight_fixed_voltage_init_data,
1437 };
1438
1439 static struct platform_device backlight_fixed_voltage = {
1440         .name                   = "reg-fixed-voltage",
1441         .id                     = FIXED_REG_ID_BACKLIGHT,
1442         .dev                    = {
1443                 .platform_data  = &backlight_fixed_voltage_config,
1444         },
1445 };
1446
1447 static int slp10_backlight_power_on(struct backlight_device *bd, int enable)
1448 {
1449         struct regulator *regulator;
1450
1451         if (enable) {
1452                 regulator = regulator_get(&bd->dev, "LCD_LDO_EN");
1453                 if (IS_ERR(regulator))
1454                         return -1;
1455
1456                 regulator_enable(regulator);
1457                 regulator_put(regulator);
1458         } else {
1459                 regulator = regulator_get(&bd->dev, "LCD_LDO_EN");
1460                 if (IS_ERR(regulator))
1461                         return -1;
1462
1463                 regulator_disable(regulator);
1464                 regulator_put(regulator);
1465         }
1466
1467         return 0;
1468 }
1469
1470 static int slp10_lcd_power_on(struct lcd_device *ld, unsigned int enable)
1471 {
1472         struct regulator *regulator;
1473
1474         if (ld == NULL) {
1475                 printk(KERN_ERR "lcd device object is NULL.\n");
1476                 return 0;
1477         }
1478
1479         if (enable) {
1480                 regulator = regulator_get(&ld->dev, "LVDS_nSHDN");
1481                 if (IS_ERR(regulator))
1482                         return -1;
1483
1484                 regulator_enable(regulator);
1485                 regulator_put(regulator);
1486
1487                 regulator = regulator_get(&ld->dev, "vcc_1.8v");
1488                 if (IS_ERR(regulator))
1489                         return -1;
1490
1491                 regulator_enable(regulator);
1492                 regulator_put(regulator);
1493         } else {
1494                 regulator = regulator_get(&ld->dev, "vcc_1.8v");
1495                 if (IS_ERR(regulator))
1496                         return -1;
1497
1498                 regulator_disable(regulator);
1499                 regulator_put(regulator);
1500
1501                 regulator = regulator_get(&ld->dev, "LVDS_nSHDN");
1502                 if (IS_ERR(regulator))
1503                         return -1;
1504
1505                 regulator_disable(regulator);
1506                 regulator_put(regulator);
1507         }
1508
1509         return 0;
1510 }
1511
1512 static int slp10_backlight_init(struct device *dev)
1513 {
1514         /* pwm backlight */
1515         s3c_gpio_cfgpin(S5PV310_GPD0(0), S3C_GPIO_SFN(2));
1516         s3c_gpio_setpull(S5PV310_GPD0(0), S3C_GPIO_PULL_NONE);
1517
1518         return 1;
1519 }
1520
1521 static int slp10_backlight_notify(struct device *dev, int brightness)
1522 {
1523         if (brightness < 1)
1524                 brightness = 1;
1525
1526         return brightness;
1527 }
1528
1529 static void __init early_lcd(char **param)
1530 {
1531         (*param)++;
1532         if (strncmp(*param, "nt39411", 7) == 0)
1533                 slp10_lcd_enabled = 1;
1534 }
1535 __early_param("lcd", early_lcd);
1536
1537 /* SLP10 backlight */
1538 static struct platform_pwm_backlight_data slp10_backlight_data = {
1539         .pwm_id                 = 0,
1540         .pwm_period_ns          = 30000,
1541         .max_brightness         = 100,
1542         .dft_brightness         = 50,
1543         .init                   = slp10_backlight_init,
1544         .notify                 = slp10_backlight_notify,
1545         .power_on               = slp10_backlight_power_on,
1546 };
1547
1548 static struct platform_device slp10_backlight_device = {
1549         .name                   = "pwm-backlight",
1550         .id                     = -1,
1551         .dev                    = {
1552                 .platform_data  = &slp10_backlight_data,
1553         },
1554 };
1555 static struct plat_lcd_data slp10_lcd_platform_data = {
1556         .set_power              = slp10_lcd_power_on,
1557 };
1558
1559 static struct platform_device slp10_lcd_device = {
1560         .name                   = "platform-lcd",
1561         .id                     = -1,
1562         .dev                    = {
1563                 .platform_data  = &slp10_lcd_platform_data,
1564         },
1565 };
1566
1567 #ifdef CONFIG_VIDEO_FIMG2D
1568 static struct fimg2d_platdata fimg2d_data __initdata = {
1569         .hw_ver                 = 30,
1570         .parent_clkname         = "mout_g2d0",
1571         .clkname                = "sclk_fimg2d",
1572         .gate_clkname           = "fimg2d",
1573         .smmu_gate_clkname      = "smmu_fimg2d",
1574         .clkrate                = 250 * 1000000,
1575 };
1576 #endif
1577
1578 static struct s3c_platform_fb fb_platform_data __initdata = {
1579         .hw_ver                 = 0x70,
1580         .nr_wins                = 5,
1581 #ifdef CONFIG_FB_S3C_DEFAULT_WINDOW
1582         .default_win            = CONFIG_FB_S3C_DEFAULT_WINDOW,
1583 #else
1584         .default_win            = 0,
1585 #endif
1586         .swap                   = FB_SWAP_HWORD | FB_SWAP_WORD,
1587         .screen_type            = SCREEN_PORTRAIT,
1588 };
1589
1590 static void __init slp10_fb_init(void)
1591 {
1592         struct device *dev = s3c_device_fb.dev.parent;
1593         struct samsung_pd_info *pdinfo;
1594
1595         if (dev) {
1596                 pdinfo = (struct samsung_pd_info *)dev->platform_data;
1597                 /* fimd driver have to know LCD domain power status. */
1598                 if (pdinfo)
1599                         fb_platform_data.boot_on = pdinfo->boot_on;
1600         }
1601
1602         if (fbmem_start)
1603                 fb_platform_data.logo_on = 1;
1604
1605         fb_platform_data.lcd_data = (struct s3cfb_lcd *)&slp10_lcd;
1606
1607         platform_device_register(&slp10_lcd_device);
1608         platform_device_register(&lcd_fixed_voltage);
1609         platform_device_register(&slp10_backlight_device);
1610         platform_device_register(&backlight_fixed_voltage);
1611         lcd_cfg_gpio();
1612
1613         s3cfb_set_platdata(&fb_platform_data);
1614 }
1615
1616 /* Jack */
1617 static struct jack_platform_data slp10_jack_data = {
1618         .usb_online             = 0,
1619         .charger_online         = 0,
1620         .hdmi_online            = -1,
1621         .earjack_online         = 0,
1622         .earkey_online          = -1,
1623         .ums_online             = -1,
1624         .cdrom_online           = -1,
1625         .jig_online             = -1,
1626 };
1627
1628 static struct platform_device slp10_jack = {
1629         .name                   = "jack",
1630         .id                     = -1,
1631         .dev                    = {
1632                 .platform_data  = &slp10_jack_data,
1633         },
1634 };
1635
1636 static struct slp10_charging_status_callbacks {
1637 void    (*tsp_set_charging_cable) (int type);
1638 } charging_cbs;
1639
1640 static bool is_cable_attached;
1641
1642 static int slp10_charger_cb(cable_type_t cable_type)
1643 {
1644         struct power_supply *psy = power_supply_get_by_name("battery");
1645         union power_supply_propval value;
1646         int ret = 0;
1647
1648         if(!psy || !psy->set_property) {
1649                 pr_err("%s: fail to get battery psy\n", __func__);
1650                 return -ENODEV;
1651         }
1652
1653         switch(cable_type) {
1654         case CABLE_TYPE_NONE:
1655         case CABLE_TYPE_OTG:
1656         case CABLE_TYPE_JIG_UART_OFF:
1657                 value.intval = POWER_SUPPLY_TYPE_BATTERY;
1658                 is_cable_attached = false;
1659                 break;
1660         case CABLE_TYPE_USB:
1661         case CABLE_TYPE_JIG_USB_OFF:
1662         case CABLE_TYPE_JIG_USB_ON:
1663                 value.intval = POWER_SUPPLY_TYPE_USB;
1664                 is_cable_attached = true;
1665                 break;
1666         case CABLE_TYPE_DESKDOCK:
1667         case CABLE_TYPE_CARDOCK:
1668                 value.intval = POWER_SUPPLY_TYPE_DOCK;
1669                 is_cable_attached = true;
1670                 break;
1671         case CABLE_TYPE_TA:
1672         case CABLE_TYPE_JIG_UART_OFF_VB:
1673                 value.intval = POWER_SUPPLY_TYPE_MAINS;
1674                 is_cable_attached = true;
1675                 break;
1676         default:
1677                 pr_err("%s: invalid type:%d\n", __func__, cable_type);
1678                 return -EINVAL;
1679         }
1680
1681         if (ret < 0) {
1682                 pr_err("%s: regulator_set failed. %d\n", __func__, ret);
1683                 return -EACCES;
1684         }
1685
1686         if (charging_cbs.tsp_set_charging_cable)
1687                 charging_cbs.tsp_set_charging_cable(value.intval);
1688
1689         ret = psy->set_property(psy, POWER_SUPPLY_PROP_ONLINE, &value);
1690
1691 #ifdef CONFIG_JACK_MON
1692         jack_event_handler("charger", is_cable_attached);
1693 #endif
1694
1695         return ret;
1696 }
1697
1698 static struct regulator *regulator_vbus_ap;
1699 static bool ap_enabled;
1700 static DEFINE_MUTEX(usb_ap_lock);
1701
1702 static void slp10_usb_cb(u8 usb_mode)
1703 {
1704         int ret;
1705         struct s3c_udc *udc = platform_get_drvdata(&s3c_device_usbgadget);
1706         struct sec_otghost_data *otg_data =
1707                         dev_get_platdata(&s3c_device_usb_otghcd.dev);
1708
1709         unsigned long inform6 = __raw_readl(S5P_INFORM6);
1710
1711         pr_info("%s: usb mode=%d, inform6=0x%08lx\n", __func__, usb_mode, inform6);
1712
1713         if (inform6 & RST_FLAG_CHARGE_REBOOT_CHECK ) {
1714                 pr_info("%s: lpcharging: disable USB\n", __func__);
1715                 ret = udc->change_usb_mode(USB_CABLE_DETACHED);
1716                 if (ret < 0)
1717                         pr_warn("%s: fail to change mode!!!\n", __func__);
1718
1719                 mutex_lock(&usb_ap_lock);
1720
1721                 if (regulator_vbus_ap == NULL)
1722                         regulator_vbus_ap =
1723                             regulator_get_exclusive(NULL, "usb_vbus_ap_5v");
1724                 if (IS_ERR_OR_NULL(regulator_vbus_ap)) {
1725                         pr_err("%s: fail to get regulator\n", __func__);
1726                         regulator_vbus_ap = NULL;
1727                         goto out;
1728                 }
1729
1730                 if (ap_enabled) {
1731                         ret = regulator_disable(regulator_vbus_ap);
1732                         if (ret)
1733                                 goto out;
1734                         ap_enabled = false;
1735                 }
1736 out:
1737                 mutex_unlock(&usb_ap_lock);
1738                 return;
1739         }
1740
1741         if (udc) {
1742                 if (usb_mode == USB_OTGHOST_ATTACHED) {
1743                         otg_data->set_pwr_cb(1);
1744                         slp10_charger_cb(CABLE_TYPE_OTG);
1745                 }
1746
1747                 pr_info("%s: prev_usb_mode=%d\n", __func__, udc->get_usb_mode());
1748
1749                 ret = udc->change_usb_mode(usb_mode);
1750                 if (ret < 0)
1751                         pr_err("%s: fail to change mode!!!\n", __func__);
1752
1753                 if (usb_mode == USB_OTGHOST_DETACHED)
1754                         otg_data->set_pwr_cb(0);
1755
1756 #ifdef CONFIG_JACK_MON
1757                 if (usb_mode == USB_OTGHOST_ATTACHED)
1758                         jack_event_handler("host", USB_CABLE_ATTACHED);
1759                 else if (usb_mode == USB_OTGHOST_DETACHED)
1760                         jack_event_handler("host", USB_CABLE_DETACHED);
1761                 else if ((usb_mode == USB_CABLE_ATTACHED)
1762                                 || (usb_mode == USB_CABLE_DETACHED)) 
1763                         jack_event_handler("usb", usb_mode);
1764 #endif
1765         }
1766 }
1767
1768 static int slp10_set_safeout(int path)
1769 {
1770         static struct regulator *regulator_vbus_cp;
1771         static bool cp_enabled;
1772         int ret = 0;
1773
1774         mutex_lock(&usb_ap_lock);
1775
1776         if (regulator_vbus_ap == NULL)
1777                 regulator_vbus_ap =
1778                     regulator_get_exclusive(NULL, "usb_vbus_ap_5v");
1779         if (IS_ERR_OR_NULL(regulator_vbus_ap)) {
1780                 ret = -ENODEV;
1781                 regulator_vbus_ap = NULL;
1782                 goto out;
1783         }
1784
1785         if (regulator_vbus_cp == NULL)
1786                 regulator_vbus_cp =
1787                     regulator_get_exclusive(NULL, "usb_vbus_cp_5v");
1788         if (IS_ERR_OR_NULL(regulator_vbus_cp)) {
1789                 ret = -ENODEV;
1790                 regulator_vbus_cp = NULL;
1791                 goto out;
1792         }
1793
1794         if (path == CP_USB_MODE) {
1795                 if (ap_enabled) {
1796                         ret = regulator_disable(regulator_vbus_ap);
1797                         if (ret)
1798                                 goto out;
1799                         ap_enabled = false;
1800                 }
1801
1802                 if (!cp_enabled) {
1803                         /* regulator_vbus_cp is exclusively got */
1804                         if (!regulator_is_enabled(regulator_vbus_cp))
1805                                 ret = regulator_enable(regulator_vbus_cp);
1806                         if (ret)
1807                                 goto out;
1808                         cp_enabled = true;
1809                 }
1810         } else {
1811                 /* AP_USB_MODE || AUDIO_MODE */
1812                 if (!ap_enabled) {
1813                         /* regulator_vbus_ap is exclusively got */
1814                         if (!regulator_is_enabled(regulator_vbus_ap))
1815                                 ret = regulator_enable(regulator_vbus_ap);
1816                         if (ret)
1817                                 goto out;
1818                         ap_enabled = true;
1819                 }
1820
1821                 if (cp_enabled) {
1822                         ret = regulator_disable(regulator_vbus_cp);
1823                         if (ret)
1824                                 goto out;
1825                         cp_enabled = false;
1826                 }
1827         }
1828 out:
1829         mutex_unlock(&usb_ap_lock);
1830         return ret;
1831 }
1832
1833 static struct switch_dev switch_dock = {
1834         .name = "dock",
1835 };
1836
1837 static void slp10_deskdock_cb(bool attached)
1838 {
1839         if (attached)
1840                 switch_set_state(&switch_dock, 1);
1841         else
1842                 switch_set_state(&switch_dock, 0);
1843 }
1844
1845 static void slp10_cardock_cb(bool attached)
1846 {
1847         if (attached)
1848                 switch_set_state(&switch_dock, 2);
1849         else
1850                 switch_set_state(&switch_dock, 0);
1851 }
1852
1853 static void slp10_muic_init_cb(void)
1854 {
1855         int ret;
1856
1857         /* for CarDock, DeskDock */
1858         ret = switch_dev_register(&switch_dock);
1859         if (ret < 0)
1860                 pr_err("Failed to register dock switch. %d\n", ret);
1861 }
1862
1863 static int slp10_host_notify_cb(int enable)
1864 {
1865         struct host_notify_dev * ndev = NULL;
1866
1867         if (s3c_device_usbgadget.dev.platform_data)
1868                 ndev = s3c_device_usbgadget.dev.platform_data;
1869         else {
1870                 pr_err("%s: ndev is null.\n", __func__);
1871                 return -1;
1872         }
1873
1874         ndev->booster = enable ? NOTIFY_POWER_ON : NOTIFY_POWER_OFF;
1875         pr_info("%s: mode %d, enable %d\n", __func__, ndev->mode, enable);
1876         return ndev->mode;
1877 }
1878
1879 struct max8997_muic_platform_data slp10_muic_pdata = {
1880         .usb_cb = slp10_usb_cb,
1881         .charger_cb = slp10_charger_cb, /* done */
1882         .set_safeout = slp10_set_safeout, /* done */
1883         .init_cb = slp10_muic_init_cb,  /* done */
1884         .deskdock_cb = slp10_deskdock_cb, /* done */
1885         .cardock_cb = slp10_cardock_cb, /* done */
1886         .host_notify_cb = slp10_host_notify_cb, /* done */
1887         .gpio_usb_sel = -1, /* not used */
1888         .uart_path = -1,        /* muic does not control uart path*/
1889 };
1890
1891 static void slp10_set_usb_switch(int path)
1892 {
1893         printk(KERN_INFO "set_usb_switch = [%d]\n",path);
1894         slp10_muic_pdata.sw_path = path;
1895 }
1896
1897 static int slp10_get_usb_switch(void)
1898 {
1899         printk(KERN_INFO "get_usb_switch = [%d]\n",slp10_muic_pdata.sw_path);
1900         return slp10_muic_pdata.sw_path;
1901 }
1902
1903 /* Micro USB Switch */
1904 static struct micro_usb_switch_platform_data slp10_usb_switch_data = {
1905         .set_usb_switch         = slp10_set_usb_switch,
1906         .get_usb_switch         = slp10_get_usb_switch,
1907 };
1908
1909 static struct platform_device slp10_micro_usb_switch = {
1910         .name                   = "usb-switch",
1911         .id                     = -1,
1912         .dev                    = {
1913                 .platform_data  = &slp10_usb_switch_data,
1914         },
1915 };
1916
1917
1918 static void slp10_pm_finish(void)
1919 {
1920         /* Restore GPX conf */
1921         s3c_pm_do_restore(s5pc210_gpx, ARRAY_SIZE(s5pc210_gpx));
1922 }
1923
1924 static void slp10_pm_prepare(void)
1925 {
1926         /* 1. Save GPX conf */
1927         s3c_pm_do_save(s5pc210_gpx, ARRAY_SIZE(s5pc210_gpx));
1928
1929         /* 2. Set GPX as Power Save Mode */
1930
1931         /* 3. Debug: Look at the diff */
1932         mobile_gpios_groupx_difference();
1933
1934 }
1935
1936 int slp10_common_setup_clock(const char *sclk_name, const char *pclk_name,
1937                 unsigned long rate, unsigned int rate_set)
1938 {
1939         struct clk *sclk = NULL;
1940         struct clk *pclk = NULL;
1941
1942         sclk = clk_get(NULL, sclk_name);
1943         if (IS_ERR(sclk)) {
1944                 printk(KERN_ERR "failed to get %s clock.\n", sclk_name);
1945                 goto err_clk1;
1946         }
1947
1948         pclk = clk_get(NULL, pclk_name);
1949         if (IS_ERR(pclk)) {
1950                 printk(KERN_ERR "failed to get %s clock.\n", pclk_name);
1951                 goto err_clk2;
1952         }
1953
1954         clk_set_parent(sclk, pclk);
1955
1956         printk(KERN_INFO "set parent clock of %s to %s\n", sclk_name,
1957                         pclk_name);
1958         if (!rate_set)
1959                 goto set_end;
1960
1961         if (!rate)
1962                 rate = 200 * MHZ;
1963
1964         clk_set_rate(sclk, rate);
1965         printk(KERN_INFO "set %s rate to %lu\n", sclk_name, rate);
1966
1967 set_end:
1968         clk_put(sclk);
1969         clk_put(pclk);
1970
1971         return 0;
1972
1973 err_clk2:
1974         clk_put(pclk);
1975 err_clk1:
1976         clk_put(sclk);
1977
1978         return -EINVAL;
1979
1980 }
1981
1982 #ifdef CONFIG_S5PV310_DEV_PD
1983 static void inline powerdomain_boot_on(int pd)
1984 {
1985         struct samsung_pd_info *pdinfo = (struct samsung_pd_info *)
1986                 s5pv310_device_pd[pd].dev.platform_data;
1987
1988         pdinfo->boot_on = true;
1989 }
1990 #endif
1991
1992 #ifdef CONFIG_CHARGERCTRL_MAX8903
1993 static struct regulator_consumer_supply supplies_max8903[] = {
1994         REGULATOR_SUPPLY("vinchg2", "charger-manager.0"),
1995 };
1996
1997 static struct regulator_init_data max8903_charger_en_data = {
1998         .constraints = {
1999                 .name           = "VOUT_CHARGER",
2000                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
2001                 .boot_on        = 1,
2002         },
2003         .num_consumer_supplies = ARRAY_SIZE(supplies_max8903),
2004         .consumer_supplies = supplies_max8903,
2005 };
2006
2007 static struct fixed_voltage_config max8903_charger_en = {
2008         .supply_name = "VOUT_CHARGER",
2009         .microvolts = 5000000, /* Assume 5VDC */
2010         .gpio = S5PV310_GPY4(5), /* TA_EN negaged */
2011         .enable_high = 0, /* Enable = Low */
2012         .enabled_at_boot = 1,
2013         .init_data = &max8903_charger_en_data,
2014 };
2015
2016 static struct platform_device max8903_fixed_reg_dev = {
2017         .name = "reg-fixed-voltage",
2018         .id = FIXED_REG_ID_MAX8903,
2019         .dev = { .platform_data = &max8903_charger_en },
2020 };
2021
2022 static struct max8903_pdata slp10_max8903 = {
2023         /*
2024          * cen: don't control with the driver, let it be
2025          * controlled by regulator above
2026          */
2027         .dok = S5PV310_GPX1(4), /* TA_nCONNECTED */
2028         /* uok, usus: not connected */
2029         .chg = S5PV310_GPE2(0), /* TA_nCHG */
2030         /* flt: vcc_1.8V_pda */
2031         .dcm = S5PV310_GPL0(1), /* CURR_ADJ */
2032
2033         .dc_valid = true,
2034         .usb_valid = false, /* USB is not wired to MAX8903 */
2035 };
2036
2037 static struct platform_device slp10_max8903_device = {
2038         .name                   = "max8903-charger",
2039         .dev                    = {
2040                 .platform_data  = &slp10_max8903,
2041         },
2042 };
2043
2044 static void max8903_init(void)
2045 {
2046         int gpio;
2047         int ta_en = 0;
2048
2049         gpio = slp10_max8903.dok;
2050         gpio_request(gpio, "TA_nCONNECTED");
2051         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
2052         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
2053         ta_en = gpio_get_value(gpio) ? 0 : 1;
2054
2055         gpio = slp10_max8903.chg;
2056         gpio_request(gpio, "TA_nCHG");
2057         gpio_direction_input(gpio);
2058
2059         gpio = slp10_max8903.dcm;
2060         gpio_request(gpio, "CURR_ADJ");
2061         gpio_direction_output(gpio, ta_en);
2062 }
2063 #endif
2064
2065 #ifdef CONFIG_MHL_SII9234
2066 static void __init slp10_mhl_init(void)
2067 {
2068         int gpio;
2069
2070         gpio = MHL_INT;
2071         gpio_request(gpio, "MHL_INT");
2072         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
2073         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
2074
2075         slp10_sii9234_pdata.mhl_int = gpio_to_irq(gpio);
2076 }
2077 #else
2078 #define slp10_mhl_init()                        do { } while (0)
2079 #endif
2080
2081 #ifdef CONFIG_CHARGER_MANAGER
2082 extern struct platform_device slp7_charger_manager;
2083 extern struct platform_device slp7_ncp15wb473_thermistor;
2084 #endif
2085 static struct platform_device *slp10_devices[] __initdata = {
2086         /* Samsung Platform Devices */
2087 #ifdef CONFIG_S5PV310_DEV_PD
2088         &s5pv310_device_pd[PD_MFC],
2089         &s5pv310_device_pd[PD_G3D],
2090         &s5pv310_device_pd[PD_LCD0],
2091         &s5pv310_device_pd[PD_LCD1],
2092         &s5pv310_device_pd[PD_TV],
2093         &s5pv310_device_pd[PD_CAM],
2094         &s5pv310_device_pd[PD_GPS],
2095 #endif
2096 #ifdef CONFIG_DRM_MALI
2097         &s5p_device_mali_drm,
2098 #endif
2099 #ifdef CONFIG_DRM_FIMD
2100         &s5p_device_fimd_drm,
2101 #endif
2102         &s3c_device_i2c0,
2103         &s3c_device_i2c1,
2104         &s3c_device_i2c3,
2105         &s3c_device_i2c5,
2106         &s3c_device_i2c6,
2107         &s3c_device_i2c7,
2108         &i2c9_gpio,
2109         &i2c14_gpio,
2110         &i2c15_gpio,
2111
2112         &s3c_device_timer[0],
2113         &s3c_device_timer[1],
2114         &slp10_gpio_keys,
2115 #ifdef CONFIG_S3C_DEV_RTC
2116         &s3c_device_rtc,
2117 #endif
2118
2119 #ifdef CONFIG_VIDEO_JPEG
2120         &s5p_device_jpeg,
2121 #endif
2122 #ifdef CONFIG_VIDEO_FIMC
2123         &s3c_device_fimc0,
2124         &s3c_device_fimc1,
2125         &s3c_device_fimc2,
2126         &s3c_device_fimc3,
2127 #endif
2128
2129 #ifdef CONFIG_USB_GADGET
2130         &s3c_device_usbgadget,
2131 #endif
2132 #ifdef CONFIG_USB_ANDROID_RNDIS
2133         &s3c_device_rndis,
2134 #endif
2135 #ifdef CONFIG_USB_ANDROID_ECM
2136         &s3c_device_ecm,
2137 #endif
2138 #ifdef CONFIG_USB_ANDROID
2139         &s3c_device_android_usb,
2140         &s3c_device_usb_mass_storage,
2141 #endif
2142 #ifdef CONFIG_USB_S3C_OTG_HOST
2143         &s3c_device_usb_otghcd,
2144 #endif
2145 #ifdef CONFIG_S3C_DEV_HSMMC4
2146         &s3c_device_hsmmc4,
2147 #else
2148         &s3c_device_hsmmc0,
2149 #endif
2150         &emmc_fixed_voltage,
2151         &s3c_device_hsmmc3,
2152
2153         &slp10_uart_select,
2154         &s3c_device_adc,
2155
2156 #ifdef CONFIG_SND_S3C64XX_SOC_I2S_V4
2157         &s5pv310_device_iis0,
2158 #endif
2159 #ifdef CONFIG_SND_S3C_SOC_PCM
2160         &s5pv310_device_pcm1,
2161 #endif
2162 #ifdef CONFIG_SND_SOC_SMDK_WM9713
2163         &s5pv310_device_ac97,
2164 #endif
2165 #ifdef CONFIG_SND_SAMSUNG_SOC_SPDIF
2166         &s5pv310_device_spdif,
2167 #endif
2168 #ifdef CONFIG_SND_S5P_RP
2169         &s5pv310_device_rp,
2170 #endif
2171
2172         &slp10_jack,
2173         &slp10_bcm4330,
2174         &slp10_bcm4751,
2175         &slp10_ramoops,
2176         &slp10_micro_usb_switch,
2177
2178 #ifdef CONFIG_S3C2410_WATCHDOG
2179         &s3c_device_wdt,
2180 #endif
2181
2182 #ifdef CONFIG_FB_S3C
2183         &s3c_device_fb,
2184 #endif
2185 #ifdef CONFIG_VIDEO_FIMG2D
2186         &s5p_device_fimg2d,
2187 #endif
2188 #ifdef CONFIG_VIDEO_MFC5X
2189         &s5p_device_mfc,
2190 #endif
2191
2192 #ifdef CONFIG_S5P_SYSMMU
2193         &s5p_device_sysmmu[SYSMMU_G2D],
2194         &s5p_device_sysmmu[SYSMMU_MFC_L],
2195         &s5p_device_sysmmu[SYSMMU_MFC_R],
2196         &s5p_device_sysmmu[SYSMMU_FIMC0],
2197         &s5p_device_sysmmu[SYSMMU_FIMC1],
2198         &s5p_device_sysmmu[SYSMMU_FIMC2],
2199         &s5p_device_sysmmu[SYSMMU_FIMC3],
2200 #endif
2201 #ifdef CONFIG_ANDROID_RAM_CONSOLE
2202         &ram_console_device,
2203 #endif
2204 #ifdef CONFIG_CHARGERCTRL_MAX8903
2205         &slp10_max8903_device,
2206         &max8903_fixed_reg_dev,
2207 #endif
2208         &slp10_tzpc,
2209 #ifdef CONFIG_CHARGER_MANAGER
2210         /* Should be placed after fuel gauge, charger control chips, pmics */
2211 #ifdef CONFIG_SENSORS_NTC_THERMISTOR
2212         &slp7_ncp15wb473_thermistor, /* No changes made from SLP7 */
2213 #endif
2214         &slp7_charger_manager, /* No changes made from SLP7 */
2215 #endif
2216 #ifdef CONFIG_DEV_THERMAL
2217         &s5p_device_tmu,
2218 #endif
2219         &slp10_xmm6260,
2220         &slp10_modem_net,
2221         &s5p_device_usb_ehci,
2222 };
2223
2224 extern void (*s5p_inform6_set)(char mode);
2225 extern void s5pv310_inform6_set(char mode);
2226 extern struct machine_desc *lookup_machine_type(unsigned int);
2227
2228 static void __init slp10_machine_init(void)
2229 {
2230         int gpio;
2231         int subrev;
2232         struct machine_desc *list;
2233         list = lookup_machine_type(machine_arch_type);
2234         strcpy(utsname()->nodename, list->name);
2235
2236         /* Initialize GPIO default setting */
2237         mobile_gpios_init();
2238
2239         /* to support system shut down */
2240         pm_power_off = slp10_power_off;
2241
2242         /* to support inform6 set */
2243         s5p_inform6_set = s5pv310_inform6_set;
2244
2245         s3c_i2c0_set_platdata(&slp10_i2c0_platdata);
2246
2247         slp10_sensor_init();
2248         slp10_light_sensor_init();
2249         s3c_i2c1_set_platdata(NULL);
2250         i2c_register_board_info(1, i2c1_devs, ARRAY_SIZE(i2c1_devs));
2251
2252         slp10_tsp_init();
2253         s3c_i2c3_set_platdata(&slp10_i2c3_platdata);
2254         i2c_register_board_info(3, i2c3_devs, ARRAY_SIZE(i2c3_devs));
2255
2256 #ifdef CONFIG_S5PV310_DEV_PD
2257 #ifdef CONFIG_FB_S3C
2258         s3c_device_fb.dev.parent = &s5pv310_device_pd[PD_LCD0].dev;
2259         powerdomain_boot_on(PD_LCD0);
2260 #endif
2261 #endif
2262         slp10_fb_init();
2263
2264         slp10_common_setup_clock("sclk_mdnie0", "mout_mpll", 400 * MHZ, 1);
2265
2266 #ifdef CONFIG_CHARGERCTRL_MAX8903
2267         max8903_init();
2268 #endif
2269         slp10_pmic_init();
2270         s3c_i2c5_set_platdata(NULL);
2271         i2c5_devs[I2C5_MAX8997].irq = gpio_to_irq(S5PV310_GPX0(7)), /* AP_PMIC_IRQ */
2272         i2c_register_board_info(5, i2c5_devs, ARRAY_SIZE(i2c5_devs));
2273
2274         slp10_sound_init();
2275         s3c_i2c6_set_platdata(NULL);
2276         i2c_register_board_info(6, i2c6_devs, ARRAY_SIZE(i2c6_devs));
2277
2278         slp10_mhl_init();
2279
2280         s3c_i2c7_set_platdata(NULL);
2281         i2c_register_board_info(7, i2c7_devs, ARRAY_SIZE(i2c7_devs));
2282
2283         gpio = S5PV310_GPX2(3);
2284         gpio_request(gpio, "FUEL_ALERT");
2285         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
2286         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
2287         i2c9_devs[I2C9_MAX17042].irq = gpio_to_irq(gpio);
2288         i2c_register_board_info(9, i2c9_devs, ARRAY_SIZE(i2c9_devs));
2289
2290         i2c_register_board_info(14, i2c14_devs, ARRAY_SIZE(i2c14_devs));
2291
2292         i2c_register_board_info(15, i2c15_devs, ARRAY_SIZE(i2c15_devs));
2293
2294         slp10_usb_ehci_init();
2295         slp10_usb_otg_init();
2296
2297         slp10_modem_init();
2298
2299 #ifdef CONFIG_VIDEO_FIMG2D
2300         s5p_fimg2d_set_platdata(&fimg2d_data);
2301 #ifdef CONFIG_S5PV310_DEV_PD
2302         s5p_device_fimg2d.dev.parent = &s5pv310_device_pd[PD_LCD0].dev;
2303 #endif
2304 #endif
2305
2306 #ifdef CONFIG_PM
2307         pm_cpu_prepare = slp10_pm_prepare;
2308         pm_cpu_finish = slp10_pm_finish;
2309
2310         s3c_pm_init();
2311         s3c_irq_wake(IRQ_RTC_ALARM, 1);
2312 #endif
2313
2314 #if defined(CONFIG_S5PV310_DEV_PD) && !defined(CONFIG_PM_RUNTIME)
2315         /*
2316          * These power domains should be always on
2317          * without runtime pm support.
2318          */
2319         s5pv310_pd_enable(&s5pv310_device_pd[PD_MFC].dev);
2320         s5pv310_pd_enable(&s5pv310_device_pd[PD_G3D].dev);
2321         s5pv310_pd_enable(&s5pv310_device_pd[PD_LCD0].dev);
2322         s5pv310_pd_enable(&s5pv310_device_pd[PD_LCD1].dev);
2323         s5pv310_pd_enable(&s5pv310_device_pd[PD_CAM].dev);
2324         s5pv310_pd_enable(&s5pv310_device_pd[PD_TV].dev);
2325         s5pv310_pd_enable(&s5pv310_device_pd[PD_GPS].dev);
2326 #endif
2327
2328 #ifdef CONFIG_VIDEO_FIMG2D
2329         /* setup fimg2d parent clock. */
2330         universal_fimg2d_setup_clock("mout_g2d0", "mout_mpll");
2331 #endif
2332 #ifdef CONFIG_S5PV310_DEV_PD
2333 #ifdef CONFIG_VIDEO_MFC5X
2334         s5p_device_mfc.dev.parent = &s5pv310_device_pd[PD_MFC].dev;
2335         slp10_common_setup_clock("mout_mfc0", "mout_mpll", 0, 0);
2336         slp10_common_setup_clock("sclk_mfc", "mout_mfc0", 200 * MHZ, 1);
2337 #endif
2338 #endif
2339
2340         slp10_sdhci_init();
2341 #ifdef CONFIG_S5P_ADC
2342         slp10_adc_init();
2343 #endif
2344
2345 #ifdef CONFIG_DEV_THERMAL
2346         s5p_tmu_set_platdata(NULL);
2347 #endif
2348
2349 #ifdef CONFIG_VIDEO_JPEG
2350 #ifdef CONFIG_S5PV310_DEV_PD
2351         s5p_device_jpeg.dev.parent = &s5pv310_device_pd[PD_CAM].dev;
2352 #endif
2353 #endif
2354 #ifdef CONFIG_CHARGER_MANAGER
2355         setup_charger_manager(&slp7_charger_g_desc);
2356 #endif
2357
2358         s5pv310_camera_init();
2359
2360         /* Last */
2361         platform_add_devices(slp10_devices, ARRAY_SIZE(slp10_devices));
2362         regulator_has_full_constraints();
2363
2364         subrev = s5pv310_subrev();
2365         /* to support new STAB10 target*/
2366         if ((subrev != 0) && (subrev != 1)) {
2367                 pr_emerg("\n\n This kernel does NOT support subrevision %d of S5PC210.\n\n\n", subrev);
2368                 panic("Not supported subrevision");
2369         }
2370 }
2371
2372 MACHINE_START(SLP10_C210, "SLP10_C210")
2373         /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */
2374         .phys_io        = S3C_PA_UART & 0xfff00000,
2375         .io_pg_offst    = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
2376         .boot_params    = S5P_PA_SDRAM + 0x100,
2377         .init_irq       = s5pv310_init_irq,
2378         .map_io         = slp10_map_io,
2379         .init_machine   = slp10_machine_init,
2380         .timer          = &s5pv310_timer,
2381         .reserve        = &s5pv310_reserve,
2382 MACHINE_END