2 * linux/arch/arm/mach-s5pv310/mach-c1_c210.c
4 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
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.
11 #include <linux/platform_device.h>
12 #include <linux/serial_core.h>
13 #include <linux/input.h>
14 #include <linux/gpio.h>
15 #include <linux/gpio_keys.h>
16 #include <linux/delay.h>
17 #include <linux/cma.h>
18 #include <linux/lcd.h>
19 #include <linux/spi/spi.h>
20 #include <linux/spi/spi_gpio.h>
21 #include <linux/i2c.h>
22 #include <linux/i2c-gpio.h>
23 #include <linux/i2c/cypress_touchkey.h>
24 #include <linux/i2c/atmel_mxt_ts.h>
25 #include <linux/clk.h>
26 #include <linux/ntc.h>
27 #include <linux/regulator/machine.h>
28 #include <linux/regulator/fixed.h>
29 #include <linux/power_supply.h>
30 #include <linux/mfd/max8997.h>
31 #include <linux/mfd/max8997-private.h>
32 #include <linux/mfd/mc1n2_pdata.h>
33 #include <linux/power/max17042_battery.h>
34 #include <linux/ramoops.h>
35 #include <linux/mmcoops.h>
36 #include <linux/uart_select.h>
37 #include <linux/memblock.h>
38 #include <linux/rtc/rtc-s3c.h>
39 #include <linux/swi.h>
40 #include <linux/jack.h>
41 #include <linux/k3g.h>
42 #include <linux/kr3dh.h>
43 #include <linux/pn544.h>
44 #include <linux/tmd27711.h>
45 #include <linux/ak8975.h>
46 #include <linux/micro_usb_switch.h>
47 #include <linux/switch.h>
48 #include <linux/cm3623.h>
49 #include <linux/host_notify.h>
50 #include <linux/utsname.h>
52 #include <linux/cpufreq.h>
53 #include <linux/modem/xmm6260.h>
54 #include <linux/power/charger-manager.h>
55 #include <linux/leds-max8997.h>
56 #include <video/platform_lcd.h>
58 #include <asm/mach-types.h>
59 #include <asm/mach/arch.h>
60 #include <asm/setup.h>
61 #include <asm/cacheflush.h>
64 #include <mach/gpio.h>
65 #include <mach/regs-clock.h>
66 #include <mach/regs-pmu.h>
67 #include <mach/pm-core.h>
68 #include <mach/nt39411.h>
69 #include <mach/universal.h>
72 #include <plat/clock.h>
73 #include <plat/devs.h>
74 #include <plat/gpio-cfg.h>
75 #include <plat/gpio-core.h>
77 #include <plat/fimc.h>
78 #include <plat/csis.h>
79 #include <plat/fimg2d.h>
80 #include <plat/mali.h>
83 #include <plat/regs-otg.h>
84 #include <plat/regs-serial.h>
85 #include <plat/s5pv310.h>
87 #include <plat/fimd_drm.h>
88 #include <plat/tvout.h>
90 #include <plat/s5p_fimd_lite.h>
91 #include <plat/usb_ehci.h>
92 #include <plat/sysmmu.h>
93 #include <plat/s5p-otghost.h>
94 #include <plat/udc-hs.h>
96 #include <media/m5mo_platform.h>
98 #ifdef CONFIG_VIDEO_S5K5BAFX
99 #include <media/s5k5bafx_platform.h>
102 #include "gpio-mobile.h"
104 #include "board-mobile.h"
105 #include "../../../drivers/usb/gadget/s3c_udc.h"
107 #if CONFIG_TOUCHSCREEN_MXT224U1
108 #include <linux/i2c/mxt224_u1.h>
111 #ifdef CONFIG_INPUT_SECBRIDGE
112 #include <linux/input/sec-input-bridge.h>
115 #ifdef CONFIG_CHARGERCTRL_MAX8922
116 #include <linux/max8922-charger.h>
119 #if defined(CONFIG_DEV_THERMAL)
120 #include <plat/s5p-tmu.h>
121 #include <mach/regs-tmu.h>
124 /* Following are default values for UCON, ULCON and UFCON UART registers */
125 #define UNIVERSAL_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
126 S3C2410_UCON_RXILEVEL | \
127 S3C2410_UCON_TXIRQMODE | \
128 S3C2410_UCON_RXIRQMODE | \
129 S3C2410_UCON_RXFIFO_TOI | \
130 S3C2443_UCON_RXERR_IRQEN)
132 #define UNIVERSAL_ULCON_DEFAULT S3C2410_LCON_CS8
134 #define UNIVERSAL_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \
135 S5PV210_UFCON_TXTRIG0 | \
136 S5PV210_UFCON_RXTRIG128)
138 #define UNIVERSAL_UFCON_UART2 (S3C2410_UFCON_FIFOMODE | \
139 S5PV210_UFCON_TXTRIG0 | \
140 S5PV210_UFCON_RXTRIG4)
142 static struct class *sec_class;
143 static struct device *switch_dev;
145 extern void u1_config_sleep_gpio_table(void);
147 enum fixed_regulator_id {
148 FIXED_REG_ID_MMC = 0,
156 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_PROFILING
158 static unsigned int u1_profile_level = 0;
160 static int __init u1_profile_level_setup(char *str)
166 u1_profile_level = memparse(str, &endp);
167 if (u1_profile_level > 3)
168 u1_profile_level = 0;
170 return endp > str ? 0 : -EINVAL;
173 early_param("profile_level=", u1_profile_level_setup);
176 static struct s3c2410_uartcfg u1_uartcfgs[] __initdata = {
179 .ucon = UNIVERSAL_UCON_DEFAULT,
180 .ulcon = UNIVERSAL_ULCON_DEFAULT,
181 .ufcon = UNIVERSAL_UFCON_DEFAULT,
185 .ucon = UNIVERSAL_UCON_DEFAULT,
186 .ulcon = UNIVERSAL_ULCON_DEFAULT,
187 .ufcon = UNIVERSAL_UFCON_DEFAULT,
191 .ucon = UNIVERSAL_UCON_DEFAULT,
192 .ulcon = UNIVERSAL_ULCON_DEFAULT,
193 .ufcon = UNIVERSAL_UFCON_UART2,
197 .ucon = UNIVERSAL_UCON_DEFAULT,
198 .ulcon = UNIVERSAL_ULCON_DEFAULT,
199 .ufcon = UNIVERSAL_UFCON_DEFAULT,
203 static struct s3c2410_platform_i2c u1_i2c0_platdata __initdata = {
204 .frequency = 300 * 1000,
208 static struct k3g_platform_data u1_k3g_data = {
210 .powerdown = K3G_POWERDOWN_NORMAL,
214 .block_data_update = K3G_BLOCK_DATA_UPDATE,
215 .fullscale = K3G_FULL_SCALE_500DPS,
216 .fifo_mode = K3G_FIFO_FIFO_MODE,
217 .int2_src = K3G_INT2_OVERRUN,
218 .fifo_threshold = 16,
219 .int1_z_high_enable = K3G_Z_HIGH_INT_EN,
220 .int1_y_high_enable = K3G_Y_HIGH_INT_EN,
221 .int1_x_high_enable = K3G_X_HIGH_INT_EN,
222 .int1_latch = K3G_INTERRUPT_LATCHED,
223 .int1_z_threshold = 0x12,
224 .int1_y_threshold = 0x25,
225 .int1_x_threshold = 0x25,
226 .int1_wait_enable = K3G_INT1_WAIT_EN,
227 .int1_wait_duration = 0x10,
230 static struct kr3dh_platform_data u1_kr3dh_data = {
231 .power_mode = KR3DH_LOW_POWER_ONE_HALF_HZ,
232 .data_rate = KR3DH_ODR_50HZ,
237 .int1_cfg = KR3DH_INT_SOURCE,
238 .block_data_update = 1,
239 .fullscale = KR3DH_RANGE_2G,
240 .int1_combination = KR3DH_OR_COMBINATION,
242 .int1_z_high_enable = 1,
243 .int1_z_low_enable = 1,
244 .int1_y_high_enable = 1,
245 .int1_y_low_enable = 1,
246 .int1_x_high_enable = 1,
247 .int1_x_low_enable = 1,
248 .int1_threshold = 0x25,
249 .int1_duration = 0x01,
256 static void user_input_response_work(struct work_struct *work)
258 #ifdef CONFIG_CPU_FREQ_GOV_ONDEMAND_FLEXRATE
259 /* Run CPUFREQ with 10000us 10 times. */
260 cpufreq_ondemand_flexrate_request(10000, 10);
261 #endif /* CONFIG_CPU_FREQ_GOV_ONDEMAND_FLEXRATE */
264 static DECLARE_WORK(uir_work, user_input_response_work);
266 static __maybe_unused void user_input_response(void *data)
268 if (!work_pending(&uir_work))
269 schedule_work_on(0, &uir_work);
273 static struct i2c_board_info i2c1_devs[] __initdata = {
276 I2C_BOARD_INFO("K3G_1", 0x69),
277 .platform_data = &u1_k3g_data,
281 I2C_BOARD_INFO("KR3DH", 0x19),
282 .platform_data = &u1_kr3dh_data,
287 /* TODO: should be modify for U1 */
288 extern struct max8997_platform_data u1_max8997_pdata;
289 extern void __init u1_pmic_init(void);
291 static void haptic_control_power(struct device *dev, int on)
293 static struct regulator *regulator;
294 static DEFINE_MUTEX(lock);
303 if (regulator == NULL)
304 regulator = regulator_get(dev, "inmotor");
305 if (IS_ERR_OR_NULL(regulator)) {
311 ret = regulator_enable(regulator);
313 ret = regulator_disable(regulator);
321 struct max8997_haptic_platform_data u1_haptic_pdata = {
324 .control_power = haptic_control_power,
327 /* GPIO I2C 5 (PMIC) */
328 enum { I2C5_MAX8997 };
329 static struct i2c_board_info i2c5_devs[] __initdata = {
331 I2C_BOARD_INFO("max8997", 0xCC >> 1),
332 .platform_data = &u1_max8997_pdata,
336 static void sec_set_sub_mic_bias(bool on)
339 gpio = MOBILE_GPIO(SUB_MICBIAS_EN);
340 gpio_set_value(gpio, on);
341 pr_err(KERN_ERR "SUB_MIC_BIAS_EN GPIO set [%d] !\n", on);
344 static void sec_set_main_mic_bias(bool on)
347 gpio = MOBILE_GPIO(MICBIAS_EN);
348 gpio_set_value(gpio, on);
349 pr_err(KERN_ERR "MAIN_MIC_BIAS_EN GPIO set [%d] !\n", on);
352 static struct mc1n2_platform_data mc1n2_pdata = {
353 .set_main_mic_bias = sec_set_main_mic_bias,
354 .set_sub_mic_bias = sec_set_sub_mic_bias,
358 static struct i2c_board_info i2c6_devs[] __initdata = {
361 I2C_BOARD_INFO("mc1n2", 0x3a),
362 .platform_data = &mc1n2_pdata,
366 static void __init u1_sound_init(void)
372 /* Set PMU register to set CLK_OUT to use XUSBXTI
373 * as codec source clock */
375 __raw_writel(val, S5P_PMREG(0xA00));
377 gpio = MOBILE_GPIO(MICBIAS_EN);
378 err = gpio_request(gpio, "MICBIAS_EN");
380 pr_err(KERN_ERR "MIC_BIAS_EN GPIO set error!\n");
383 gpio_direction_output(gpio, 1);
384 gpio_set_value(gpio, 0);
386 gpio = MOBILE_GPIO(EAR_MICBIAS_EN);
387 err = gpio_request(gpio, "EAR_MICBIAS_EN");
389 pr_err(KERN_ERR "EAR_MIC_BIAS_EN GPIO set error!\n");
392 gpio_direction_output(gpio, 1);
393 gpio_set_value(gpio, 0);
395 gpio = MOBILE_GPIO(SUB_MICBIAS_EN);
396 err = gpio_request(gpio, "submic_bias");
398 pr_err(KERN_ERR "SUB_MIC_BIAS_EN GPIO set error!\n");
401 gpio_direction_output(gpio, 0);
404 static struct ak8975_platform_data universal_ak8975_data = {
405 .poll_interval = 100,
409 static struct i2c_board_info i2c7_devs[] __initdata = {
412 I2C_BOARD_INFO("ak8975", 0x0c),
413 .platform_data = &universal_ak8975_data,
420 static struct i2c_gpio_platform_data i2c9_gpio_data = {
421 .sda_pin = S5PV310_GPY4(0), /* XM0ADDR_8 */
422 .scl_pin = S5PV310_GPY4(1), /* XM0ADDR_9 */
425 static struct platform_device i2c9_gpio = {
429 .platform_data = &i2c9_gpio_data,
433 static struct max17042_reg_data max17042_init_data[] = {
434 { MAX17042_CGAIN, 0x0000 },
435 { MAX17042_MiscCFG, 0x0003 },
436 { MAX17042_LearnCFG, 0x0007 },
437 /* RCOMP: 0x0050 2011.02.29 from MAXIM */
438 { MAX17042_RCOMP0, 0x0050 },
440 /* Alert only when the battery is removed or inserted */
441 static struct max17042_reg_data max17042_alert_init_data[] = {
442 /* SALRT Threshold setting (disable) unsigned MAX/MIN */
443 { MAX17042_SALRT_Th, 0xFF00 },
444 /* VALRT Threshold setting (disable) unsigned MAX/MIN */
445 { MAX17042_VALRT_Th, 0xFF00 },
446 /* TALRT Threshold setting (disable) signed MAX/MIN */
447 { MAX17042_TALRT_Th, 0x7F80 },
449 static struct max17042_platform_data u1_battery_platform_data = {
450 .init_data = max17042_init_data,
451 .num_init_data = ARRAY_SIZE(max17042_init_data),
452 .alrt_data = max17042_alert_init_data,
453 .num_alrt_data = ARRAY_SIZE(max17042_alert_init_data),
454 .irq_base = IRQ_FUEL_BASE,
455 .enable_alert = true,
457 .r_sns = 10000, /* 10m Ohm */
460 enum { I2C9_MAX17042};
461 static struct i2c_board_info i2c9_devs[] __initdata = {
463 I2C_BOARD_INFO("max17042", 0x36),
464 .platform_data = &u1_battery_platform_data,
469 /* GPIO I2C 12 (3 Touchkey) */
470 #define TOUCHKEY_INT S5PV310_GPL0(5)
471 #define TOUCHKEY_SCL S5PV310_GPK1(0)
472 #define TOUCHKEY_SDA S5PV310_GPK1(2)
474 static struct i2c_gpio_platform_data i2c12_gpio_data = {
475 .sda_pin = S5PV310_GPK1(2), /* XMDMDATA_8 */
476 .scl_pin = S5PV310_GPK1(0), /* XMDMDATA_9 */
479 static struct platform_device i2c12_gpio = {
483 .platform_data = &i2c12_gpio_data,
487 /*===============================*/
488 /*= CYPRESS TOUCH KEY =*/
489 /*===============================*/
490 static struct cypress_pin cypress_tk_pin = {
492 .gpio_int = TOUCHKEY_INT,
493 .gpio_sda = TOUCHKEY_SDA,
494 .gpio_scl = TOUCHKEY_SCL,
497 static void cypress_tk_cfg_pin(void)
499 s3c_gpio_setpull(cypress_tk_pin.gpio_sda, S3C_GPIO_PULL_NONE);
500 s3c_gpio_setpull(cypress_tk_pin.gpio_scl, S3C_GPIO_PULL_NONE);
502 s3c_gpio_cfgpin(cypress_tk_pin.gpio_sda, S3C_GPIO_SFN(2));
503 s3c_gpio_cfgpin(cypress_tk_pin.gpio_scl, S3C_GPIO_SFN(2));
505 s3c_gpio_cfgpin(cypress_tk_pin.gpio_int, S3C_GPIO_SFN(0xf));
506 if (gpio_is_valid(cypress_tk_pin.gpio_en))
507 s3c_gpio_cfgpin(cypress_tk_pin.gpio_en, S3C_GPIO_OUTPUT);
510 static int cypress_touchkey_power(int onoff)
512 static struct regulator *regulator;
513 static DEFINE_MUTEX(lock);
519 if (enabled == !!onoff)
522 if (regulator == NULL)
523 regulator = regulator_get(NULL, "touch_2.8v");
524 if (IS_ERR_OR_NULL(regulator)) {
526 pr_err("[TK][ERROR] regulator_get fail\n");
532 ret = regulator_enable(regulator);
534 ret = regulator_disable(regulator);
545 static int cypress_touchled_power(int onoff)
547 static struct regulator *regulator;
548 static DEFINE_MUTEX(lock);
554 if (enabled == !!onoff)
557 if (regulator == NULL)
558 regulator = regulator_get(NULL, "touch_led_3.3v");
559 if (IS_ERR_OR_NULL(regulator)) {
561 pr_err("[TK][ERROR] regulator_get fail\n");
567 ret = regulator_enable(regulator);
569 ret = regulator_disable(regulator);
580 static unsigned int u1_cypress_touch_keycode[] = {
581 KEY_PHONE, /* not use this value 0x00 */
582 KEY_PHONE, /* KEY_SEND 0x01 */
583 KEY_BACK, /* KEY_END 0x02 */
586 static unsigned char u1_cypress_keycode_setbit[] = {
592 static struct cypress_platform_data cypress_tk_data = {
593 .cfg_pin = cypress_tk_cfg_pin,
594 .power_pin = cypress_touchkey_power,
595 .led_pin = cypress_touchled_power,
596 .pin = &cypress_tk_pin,
597 .keycode = u1_cypress_touch_keycode,
598 .keycode_size = ARRAY_SIZE(u1_cypress_touch_keycode),
599 .keycode_setbit = u1_cypress_keycode_setbit,
603 static struct i2c_board_info i2c12_devs_cypress[] __initdata = {
605 I2C_BOARD_INFO("cypress_tk", 0x20),
606 .platform_data = &cypress_tk_data,
610 static void __init universal_touchkey_init(void)
615 gpio = TOUCHKEY_INT; /* XMDMDATA_7 */
616 gpio_request(gpio, "3_TOUCH_INT");
617 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
618 irq = gpio_to_irq(gpio);
619 i2c12_devs_cypress[0].irq = irq;
623 static struct i2c_gpio_platform_data i2c14_gpio_data = {
624 .sda_pin = S5PV310_GPK2(2), /* XMMC2CDn */
625 .scl_pin = S5PV310_GPK3(2), /* XMMC3CDn */
626 .udelay = 1, /* 500kHz */
629 static struct platform_device i2c14_gpio = {
633 .platform_data = &i2c14_gpio_data,
637 static void cm3663_control_power_source(int enable)
639 static struct regulator *regulator;
640 static DEFINE_MUTEX(lock);
644 if (regulator == NULL)
645 regulator = regulator_get_exclusive(NULL, "led_a_2.8v");
646 WARN(IS_ERR_OR_NULL(regulator), "%s cannot get regulator\n", __func__);
647 if (IS_ERR_OR_NULL(regulator)) {
652 if (regulator_is_enabled(regulator)) {
653 regulator_disable(regulator);
659 regulator_enable(regulator);
664 static int cm3663_get_irq_gpio(void)
669 gpio = MOBILE_GPIO(PS_ALS_INT);
670 gpio_request(gpio, "PS/ALS_INT");
671 val = gpio_get_value(gpio);
677 static struct cm3623_platform_data u1_cm3663_platform_data = {
678 .control_power_source = cm3663_control_power_source,
679 .get_irq_gpio = cm3663_get_irq_gpio,
680 .ps_def = (CM3663_DR_PS_160 | CM3623_IT_PS_3 |
681 CM3623_INT_ALS_DISABLE | CM3623_INT_PS_DISABLE),
683 .als_def = (CM3623_THD_ALS_8 | CM3623_IT_ALS_800 | CM3623_WDM_ALS_WORD),
686 static struct i2c_board_info i2c14_devs[] __initdata = {
688 I2C_BOARD_INFO("CM3663", 0x22 >> 1),
689 .platform_data = &u1_cm3663_platform_data,
694 static void __init u1_sensor_init(void)
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);
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);
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);
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);
722 static struct i2c_gpio_platform_data i2c15_gpio_data = {
723 .sda_pin = S5PV310_GPY3(0), /* XM0ADDR_0 */
724 .scl_pin = S5PV310_GPY3(2), /* XM0ADDR_2 */
728 static struct platform_device i2c15_gpio = {
732 .platform_data = &i2c15_gpio_data,
736 static struct i2c_board_info i2c15_devs[] __initdata = {
743 #define GPIO_NFC_SCL_1_8V S5PV310_GPY0(0)
744 #define GPIO_NFC_SDA_1_8V S5PV310_GPY0(1)
745 #define GPIO_NFC_IRQ S5PV310_GPX1(7)
746 #define GPIO_NFC_EN S5PV310_GPL2(6)
747 #define GPIO_NFC_FIRMWARE S5PV310_GPL2(7)
749 /* GPIO_LEVEL_NONE = 2, GPIO_LEVEL_LOW = 0 */
750 static unsigned int nfc_gpio_table[][4] = {
751 {GPIO_NFC_IRQ, S3C_GPIO_INPUT, 2, S3C_GPIO_PULL_DOWN},
752 {GPIO_NFC_EN, S3C_GPIO_OUTPUT, 0, S3C_GPIO_PULL_NONE},
753 {GPIO_NFC_FIRMWARE, S3C_GPIO_OUTPUT, 0, S3C_GPIO_PULL_NONE},
754 {GPIO_NFC_SCL_1_8V, S3C_GPIO_INPUT, 2, S3C_GPIO_PULL_NONE},
755 {GPIO_NFC_SDA_1_8V, S3C_GPIO_INPUT, 2, S3C_GPIO_PULL_NONE},
758 void nfc_setup_gpio(void)
760 int array_size = ARRAY_SIZE(nfc_gpio_table);
762 for (i = 0; i < array_size; i++) {
763 gpio = nfc_gpio_table[i][0];
764 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(nfc_gpio_table[i][1]));
765 s3c_gpio_setpull(gpio, nfc_gpio_table[i][3]);
766 if (nfc_gpio_table[i][2] != 2)
767 gpio_set_value(gpio, nfc_gpio_table[i][2]);
771 static struct i2c_gpio_platform_data i2c16_gpio_data = {
772 .sda_pin = GPIO_NFC_SDA_1_8V,
773 .scl_pin = GPIO_NFC_SCL_1_8V,
777 static struct platform_device i2c16_gpio = {
781 .platform_data = &i2c16_gpio_data,
786 #if defined(CONFIG_VIDEO_S5K5BAFX)
787 #define VT_CAM_SDA_18V S5PV310_GPC1(0)
788 #define VT_CAM_SCL_18V S5PV310_GPC1(2)
790 static struct i2c_gpio_platform_data i2c17_platdata = {
791 .sda_pin = VT_CAM_SDA_18V,
792 .scl_pin = VT_CAM_SCL_18V,
794 .sda_is_open_drain = 0,
795 .scl_is_open_drain = 0,
796 .scl_is_output_only = 0,
799 static struct platform_device s3c_device_i2c17 = {
802 .dev.platform_data = &i2c17_platdata,
805 static struct i2c_board_info i2c17_devs[] __initdata = {
807 I2C_BOARD_INFO("s5k5bafx", (0x5A >> 1)),
814 #define GPIO_FM_SDA_28V S5PV310_GPB(2)
815 #define GPIO_FM_SCL_28V S5PV310_GPB(3)
817 static struct i2c_gpio_platform_data i2c18_gpio_data = {
818 .sda_pin = GPIO_FM_SDA_28V,
819 .scl_pin = GPIO_FM_SCL_28V,
822 static struct platform_device i2c18_gpio = {
826 .platform_data = &i2c18_gpio_data,
830 static struct i2c_board_info i2c18_devs[] __initdata = {
832 I2C_BOARD_INFO("si470x", (0x20 >> 1)),
838 static struct pn544_i2c_platform_data pn544_pdata = {
839 .irq_gpio = GPIO_NFC_IRQ,
840 .ven_gpio = GPIO_NFC_EN,
841 .firm_gpio = GPIO_NFC_FIRMWARE,
845 static struct i2c_board_info i2c16_devs[] __initdata = {
847 I2C_BOARD_INFO("pn544", 0x2b),
848 .platform_data = &pn544_pdata,
854 static struct s5p_usb_ehci_platdata u1_usb_ehci_pdata;
856 static void __init u1_usb_ehci_init(void)
858 struct s5p_usb_ehci_platdata *pdata = &u1_usb_ehci_pdata;
860 /* The gpios is initialized from modem_init */
861 pdata->gpio_active = MOBILE_GPIO(ACTIVE_STATE_HSIC);
863 s5p_usb_ehci_set_platdata(pdata);
867 /* we don't use OTGDRVVBUS pin for powering up otg charging pump */
868 static void u1_otg_power_cb(int enable)
871 u8 on = (u8)!!enable;
872 gpio = MOBILE_GPIO(USB_OTG_EN);
873 gpio_request(gpio, "USB_OTG_EN");
874 gpio_direction_output(gpio, on);
876 pr_info("%s: otg power = %d\n", __func__, on);
879 static void __init u1_usb_otg_init(void)
881 struct host_notify_dev *u1_otg_ndev =
882 dev_get_platdata(&s3c_device_usbgadget.dev);
883 struct sec_otghost_data *u1_otg_host_data =
884 dev_get_platdata(&s3c_device_usb_otghcd.dev);
886 u1_otg_ndev->set_booster = u1_otg_power_cb;
887 u1_otg_host_data->set_pwr_cb = u1_otg_power_cb;
891 static struct platform_device u1_modem_net = {
896 /* XMM6260 control */
897 static struct xmm6260_gpios u1_xmm6260_gpios;
899 static struct xmm6260_platform_data u1_xmm6260_pdata = {
900 .gpios = &u1_xmm6260_gpios,
905 * SLP uses standardized device name of modemctl
906 * and this is same to Android.
908 static struct platform_device u1_xmm6260 = {
912 .platform_data = &u1_xmm6260_pdata,
916 static void __init u1_modem_init(void)
918 struct xmm6260_gpios *gpios = &u1_xmm6260_gpios;
921 gpio = MOBILE_GPIO(CP_ON);
922 gpio_request(gpio, "CP_ON");
923 gpio_direction_output(gpio, 0);
926 gpio = MOBILE_GPIO(PHONE_ACTIVE);
927 gpio_request(gpio, "PHONE_ACTIVE");
928 gpios->phone_active = gpio;
930 gpio = MOBILE_GPIO(PDA_ACTIVE);
931 gpio_request(gpio, "PDA_ACTIVE");
932 gpio_direction_output(gpio, 0);
933 gpios->pda_active = gpio;
935 gpio = MOBILE_GPIO(CP_DUMP_INT);
936 gpio_request(gpio, "CP_DUMP_INT");
937 gpios->cp_dump_int = gpio;
939 gpio = MOBILE_GPIO(CP_PMU_RST);
940 gpio_request(gpio, "CP_PMU_RST");
941 gpio_direction_output(gpio, 0);
942 gpios->cp_pmu_rst = gpio;
944 gpio = MOBILE_GPIO(RESET_REQ_N);
945 gpio_request(gpio, "RESET_REQ_N");
946 gpio_direction_output(gpio, 0);
947 gpios->reset_req_n = gpio;
949 gpio = MOBILE_GPIO(IPC_SLAVE_WAKEUP);
950 gpio_request(gpio, "IPC_SLAVE_WAKEUP");
951 gpio_direction_output(gpio, 0);
952 gpios->ipc_slave_wakeup = gpio;
954 gpio = MOBILE_GPIO(IPC_HOST_WAKEUP);
955 gpio_request(gpio, "IPC_HOST_WAKEUP");
956 gpios->ipc_host_wakeup = gpio;
958 gpio = MOBILE_GPIO(SUSPEND_REQUEST_HSIC);
959 gpio_request(gpio, "SUSPEND_REQUEST_HSIC");
960 gpios->suspend_request_hsic = gpio;
962 gpio = MOBILE_GPIO(ACTIVE_STATE_HSIC);
963 gpio_request(gpio, "ACTIVE_STATE_HSIC");
964 gpio_direction_output(gpio, 0);
965 gpios->active_state_hsic = gpio;
969 static void u1_set_uart_switch(int path)
973 gpio = MOBILE_GPIO(UART_SEL);
974 gpio_request(gpio, "UART_SEL");
976 /* u1 target is gpio_high == AP */
977 if (path == UART_SW_PATH_AP)
978 gpio_set_value(gpio, GPIO_LEVEL_HIGH);
979 else if (path == UART_SW_PATH_CP)
980 gpio_set_value(gpio, GPIO_LEVEL_LOW);
986 static int u1_get_uart_switch(void)
991 gpio = MOBILE_GPIO(UART_SEL);
992 gpio_request(gpio, "UART_SEL");
993 val = gpio_get_value(gpio);
996 /* u1 target is gpio_high == AP */
997 if (val == GPIO_LEVEL_HIGH)
998 return UART_SW_PATH_AP;
999 else if (val == GPIO_LEVEL_LOW)
1000 return UART_SW_PATH_CP;
1002 return UART_SW_PATH_NA;
1005 static struct uart_select_platform_data u1_uart_select_data = {
1006 .set_uart_switch = u1_set_uart_switch,
1007 .get_uart_switch = u1_get_uart_switch,
1010 static struct platform_device u1_uart_select = {
1011 .name = "uart-select",
1014 .platform_data = &u1_uart_select_data,
1018 static struct regulator_consumer_supply emmc_supplies[] = {
1019 REGULATOR_SUPPLY("vmmc", "s3c-sdhci.0"),
1020 REGULATOR_SUPPLY("vmmc", "dw_mmc"),
1023 static struct regulator_init_data emmc_fixed_voltage_init_data = {
1025 .name = "VMEM_VDD_2.8V",
1026 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
1028 .num_consumer_supplies = ARRAY_SIZE(emmc_supplies),
1029 .consumer_supplies = emmc_supplies,
1032 static struct fixed_voltage_config emmc_fixed_voltage_config = {
1033 .supply_name = "eMMC_EN",
1034 .microvolts = 2800000,
1035 .gpio = S5PV310_GPK0(2),
1036 .enable_high = true,
1037 .init_data = &emmc_fixed_voltage_init_data,
1040 static struct platform_device emmc_fixed_voltage = {
1041 .name = "reg-fixed-voltage",
1042 .id = FIXED_REG_ID_MMC,
1044 .platform_data = &emmc_fixed_voltage_config,
1051 /* GSD4T GPS module */
1052 static struct gsd4t_platform_data u1_gsd4t_data = {
1053 .onoff = S5PV310_GPE0(3),
1054 .nrst = S5PV310_GPE0(4),
1055 .tsync = S5PV310_GPE0(1),
1056 .uart_rxd = S5PV310_GPA0(4),
1057 .uart_txd = S5PV310_GPA0(5),
1058 .uart_cts = S5PV310_GPA0(6),
1059 .uart_rts = S5PV310_GPA0(7),
1062 static struct platform_device u1_gsd4t = {
1066 .platform_data = &u1_gsd4t_data,
1072 #ifdef CONFIG_DRM_MALI
1073 static struct platform_device s5p_device_mali_drm = {
1080 #ifdef CONFIG_DRM_FIMD
1081 static struct resource fimd_drm_resource[] = {
1083 .start = S5P_PA_LCD0,
1084 .end = S5P_PA_LCD0 + S5P_SZ_LCD0 - 1,
1085 .flags = IORESOURCE_MEM,
1088 .start = S5P_PA_LCD1,
1089 .end = S5P_PA_LCD1 + S5P_SZ_LCD1 - 1,
1090 .flags = IORESOURCE_MEM,
1095 .flags = IORESOURCE_IRQ,
1100 .flags = IORESOURCE_IRQ,
1104 static struct fimd_drm_platform_data fimd_drm_pd = {
1108 static struct platform_device s5p_device_fimd_drm = {
1111 .num_resources = ARRAY_SIZE(fimd_drm_resource),
1112 .resource = fimd_drm_resource,
1114 .platform_data = &fimd_drm_pd,
1120 static struct s3c_adc_platform_data s3c_adc_pdata __initdata = {
1124 .max_adc_voltage_uV = 3300000,
1127 static void __init u1_adc_init(void)
1129 s3c_adc_set_platdata(&s3c_adc_pdata);
1132 static void ramoops_enable(int enable)
1136 clk = clk_get(NULL, "modem");
1144 static struct ramoops_platform_data u1_ramoops_data = {
1145 .mem_address = 0x13A00000, /* MODEM I/F */
1147 .enable = ramoops_enable,
1150 static struct platform_device u1_ramoops = {
1153 .platform_data = &u1_ramoops_data,
1158 static struct platform_device u1_tzpc = {
1163 #ifdef CONFIG_ANDROID_RAM_CONSOLE
1164 static struct resource ram_console_resource[] = {
1166 .flags = IORESOURCE_MEM,
1170 static struct platform_device ram_console_device = {
1171 .name = "ram_console",
1173 .num_resources = ARRAY_SIZE(ram_console_resource),
1174 .resource = ram_console_resource,
1178 static void __init u1_map_io(void)
1180 s5p_init_io(NULL, 0, S5P_VA_CHIPID);
1181 s5p_xtal_set_parent(CLK_XUSBXTI);
1182 s3c24xx_init_clocks(24000000);
1183 s3c24xx_init_uarts(u1_uartcfgs, ARRAY_SIZE(u1_uartcfgs));
1186 static unsigned long fbmem_start, fbmem_size;
1187 static int __init early_fbmem(char *p)
1194 fbmem_size = memparse(p, &endp);
1196 fbmem_start = memparse(endp + 1, &endp);
1198 return endp > p ? 0 : -EINVAL;
1200 early_param("fbmem", early_fbmem);
1202 static struct cma_region regions[] = {
1203 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMD0
1206 .size = (CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMD0
1207 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMD1
1208 + CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMD1
1213 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC0
1216 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC0 * SZ_1K,
1220 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC1
1223 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC1 * SZ_1K,
1227 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC2
1230 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC2 * SZ_1K,
1234 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC3
1237 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC3 * SZ_1K,
1242 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_S3C_MEM_CMA
1244 .name = "s3c-mem-cma",
1245 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_S3C_MEM_CMA * SZ_1K,
1250 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_JPEG
1253 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_JPEG * SZ_1K,
1256 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC
1259 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC * SZ_1K,
1262 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC0
1265 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC0 * SZ_1K,
1267 .alignment = 1 << 17,
1271 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC1
1274 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC1 * SZ_1K,
1276 .alignment = 1 << 17,
1280 #ifdef CONFIG_VIDEO_SAMSUNG_S5P_MFC
1284 { .alignment = 128 << 10 },
1285 .start = 0x42000000,
1290 .start = 0x43000000,
1295 .start = 0x51000000,
1298 #ifdef CONFIG_SEC_DEBUG
1302 .start = 0x40003000,
1308 static void __init s5pv310_reserve(void)
1310 static const char map[] __initconst =
1312 #ifdef CONFIG_VIDEO_FIMC
1318 #ifdef CONFIG_S3C_MEM_CMA_ALLOC
1319 "s3c-mem=s3c-mem-cma;"
1323 #ifdef CONFIG_SEC_DEBUG
1324 "s3c-getlog=getlog;"
1327 #if defined(CONFIG_VIDEO_SAMSUNG_S5P_MFC)
1328 "mfc=mfc,mfc0,mfc1;"
1329 "s5p-mfc/f=fw;s5p-mfc/a=b1;s5p-mfc/b=b2;"
1331 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_PROFILING
1332 "s3c-mfc/mfc=mfc;s3c-mfc/mfc0=mfc0;s3c-mfc/mfc1=mfc1;"
1334 "s3c-mfc=mfc,mfc0,mfc1;"
1341 #ifdef CONFIG_ANDROID_RAM_CONSOLE
1344 /* FIXME: ram console MUST be reserved at first time */
1345 addr = memblock_alloc_base(SZ_1M, SZ_4K, 0x60000000);
1346 ram_console_resource[0].start = addr;
1347 ram_console_resource[0].end = addr + SZ_1M - 1;
1348 pr_info("ram_console: 0x%08x ~ 0x%08x (1MB)\n",
1349 addr, addr + SZ_1M);
1353 regions[0].start = (dma_addr_t)fbmem_start;
1355 regions[0].size = (size_t)fbmem_size;
1356 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_PROFILING
1358 unsigned int regions_cnt = 0;
1359 size_t fimd_size, fimc1_size, fimc2_size, fimc3_size, mfc0_size, mfc1_size, s3c_mem_size =0;
1361 switch (u1_profile_level){
1363 case 2: /* 240 * 320 */
1364 fimd_size = 1800 * SZ_1K;
1365 fimc1_size = 3072 * SZ_1K;
1366 fimc2_size = 4096 * SZ_1K;
1367 fimc3_size = 1536 * SZ_1K;
1368 s3c_mem_size = 4096 * SZ_1K;
1369 mfc0_size = 10240 * SZ_1K;
1370 mfc1_size = 10240 * SZ_1K;
1372 case 1: /* 320 * 480 */
1373 fimd_size = 3600 * SZ_1K;
1374 fimc1_size = 3072 * SZ_1K;
1375 fimc2_size = 4096 * SZ_1K;
1376 fimc3_size = 1536 * SZ_1K;
1377 s3c_mem_size = 4096 * SZ_1K;
1378 mfc0_size = 10240 * SZ_1K;
1379 mfc1_size = 10240 * SZ_1K;
1381 default: /* 480 * 800 */
1382 fimd_size = 9000 * SZ_1K;
1383 fimc1_size = 18664* SZ_1K;
1384 fimc2_size = 24576 * SZ_1K;
1385 fimc3_size = 8192 * SZ_1K;
1386 s3c_mem_size = 24576 * SZ_1K;
1387 mfc0_size = 24576 * SZ_1K;
1388 mfc1_size = 24576 * SZ_1K;
1391 for (; regions_cnt < ARRAY_SIZE(regions) - 1 /* terminator */; ++regions_cnt){
1392 if (strncmp(regions[regions_cnt].name, "fimd", 4) == 0)
1393 regions[regions_cnt].size = PAGE_ALIGN(fimd_size);
1394 if (strncmp(regions[regions_cnt].name, "fimc1", 5) == 0)
1395 regions[regions_cnt].size = PAGE_ALIGN(fimc1_size);
1396 if (strncmp(regions[regions_cnt].name, "fimc2", 5) == 0)
1397 regions[regions_cnt].size = PAGE_ALIGN(fimc2_size);
1398 if (strncmp(regions[regions_cnt].name, "fimc3", 5) == 0)
1399 regions[regions_cnt].size = PAGE_ALIGN(fimc3_size);
1400 if (strncmp(regions[regions_cnt].name, "mfc0", 4) == 0)
1401 regions[regions_cnt].size = PAGE_ALIGN(mfc0_size);
1402 if (strncmp(regions[regions_cnt].name, "mfc1", 4) == 0)
1403 regions[regions_cnt].size = PAGE_ALIGN(mfc1_size);
1404 if (strncmp(regions[regions_cnt].name, "s3c-mem-cma", 11) == 0)
1405 regions[regions_cnt].size = PAGE_ALIGN(s3c_mem_size);
1410 cma_set_defaults(regions, map);
1411 cma_early_regions_reserve(NULL);
1413 for (; i < ARRAY_SIZE(regions) - 1 /* terminator */; ++i) {
1414 pr_info("cma: region: %-8s: 0x%08x ~ 0x%08x (%dMB) real size=%d \n",
1415 regions[i].name, regions[i].start,
1416 regions[i].start + regions[i].size,
1417 regions[i].size / SZ_1M, regions[i].size);
1421 #ifdef CONFIG_HIBERNATION
1422 static int __init u1_set_nosave_regions(void)
1426 for ( i = ARRAY_SIZE(regions) - 2; i >= 0 /* terminator */; i--) {
1427 /* MFC firmware SHOULD BE saved.
1428 * If the region is fw, don't register to nosave regions */
1429 if (strcmp(regions[i].name, "fw"))
1430 register_nosave_region_late(
1431 __phys_to_pfn(regions[i].start),
1432 __phys_to_pfn(regions[i].start +
1437 late_initcall(u1_set_nosave_regions);
1441 * GPX are saved and restored at plat-samsung/pm.c:s5c_pm_enter.
1442 * However, they are inside of pm_prepare and pm_finish, so it
1443 * does not save ours against universal_pm_prepare:2.
1445 static struct sleep_save s5pc210_gpx[] = {
1446 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C00),
1447 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C04),
1448 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C08),
1449 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C0C),
1450 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C20),
1451 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C24),
1452 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C28),
1453 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C2C),
1454 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C40),
1455 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C44),
1456 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C48),
1457 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C4C),
1458 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C60),
1459 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C64),
1460 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C68),
1461 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C6C),
1465 static struct gpio_keys_button u1_gpio_keys_tables[] = {
1467 .code = KEY_VOLUMEUP,
1468 .gpio = S5PV310_GPX2(0), /* XEINT16 */
1469 .desc = "gpio-keys: KEY_VOLUMEUP",
1472 .debounce_interval = 1,
1473 /* YUBAEK 20110905 RAMDUMP_DEBUG : Android forceable ramdump ++ */
1474 #ifdef CONFIG_INPUT_FORCE_PANIC_KEY
1475 .isr_hook = sec_debug_check_crash_key , /* VOL UP */
1477 /* YUBAEK 20110905 RAMDUMP_DEBUG : Android forceable ramdump -- */
1480 .code = KEY_VOLUMEDOWN,
1481 .gpio = S5PV310_GPX2(1), /* XEINT17 */
1482 .desc = "gpio-keys: KEY_VOLUMEDOWN",
1485 .debounce_interval = 1,
1486 /* YUBAEK 20110905 RAMDUMP_DEBUG : Android forceable ramdump ++ */
1487 #ifdef CONFIG_INPUT_FORCE_PANIC_KEY
1488 .isr_hook = sec_debug_check_crash_key , /*VOL DOWN */
1490 /* YUBAEK 20110905 RAMDUMP_DEBUG : Android forceable ramdump -- */
1494 .gpio = S5PV310_GPX2(7), /* XEINT23 */
1495 .desc = "gpio-keys: KEY_POWER",
1499 .debounce_interval = 1,
1501 /* KEY_MENU will be used */
1502 .code = KEY_MENU, /* KEY_OK */
1503 .gpio = S5PV310_GPX3(5), /* XEINT29 */
1504 .desc = "gpio-keys: KEY_MENU",
1508 .debounce_interval = 1,
1509 /* YUBAEK 20110905 RAMDUMP_DEBUG : Android forceable ramdump ++ */
1510 #ifdef CONFIG_INPUT_FORCE_PANIC_KEY
1511 .isr_hook = sec_debug_check_crash_key , /* HOME */
1513 /* YUBAEK 20110905 RAMDUMP_DEBUG : Android forceable ramdump -- */
1518 static struct gpio_keys_platform_data u1_gpio_keys_data = {
1519 .buttons = u1_gpio_keys_tables,
1520 .nbuttons = ARRAY_SIZE(u1_gpio_keys_tables),
1523 static struct platform_device u1_gpio_keys = {
1524 .name = "gpio-keys",
1526 .platform_data = &u1_gpio_keys_data,
1532 static unsigned int ld9040_lcd_enabled;
1534 static struct s3cfb_lcd ld9040 = {
1537 .width_mm = 56, //59,
1538 .height_mm = 93, //98,
1560 static int lcd_cfg_gpio(void)
1565 for (i = 0; i < 8; i++) {
1566 /* set GPF0,1,2[0:7] for RGB Interface and Data lines (32bit) */
1567 s3c_gpio_cfgpin(S5PV310_GPF0(i), S3C_GPIO_SFN(2));
1568 s3c_gpio_setpull(S5PV310_GPF0(i), S3C_GPIO_PULL_NONE);
1571 for (i = 0; i < 8; i++) {
1572 s3c_gpio_cfgpin(S5PV310_GPF1(i), S3C_GPIO_SFN(2));
1573 s3c_gpio_setpull(S5PV310_GPF1(i), S3C_GPIO_PULL_NONE);
1576 for (i = 0; i < 8; i++) {
1577 s3c_gpio_cfgpin(S5PV310_GPF2(i), S3C_GPIO_SFN(2));
1578 s3c_gpio_setpull(S5PV310_GPF2(i), S3C_GPIO_PULL_NONE);
1581 for (i = 0; i < f3_end; i++) {
1582 s3c_gpio_cfgpin(S5PV310_GPF3(i), S3C_GPIO_SFN(2));
1583 s3c_gpio_setpull(S5PV310_GPF3(i), S3C_GPIO_PULL_NONE);
1586 /* Set FIMD0 bypass */
1587 reg = __raw_readl(S3C_VA_SYS + 0x0210);
1589 __raw_writel(reg, S3C_VA_SYS + 0x0210);
1594 static int lcd_power_on(struct lcd_device *ld, int enable)
1596 static struct regulator *regulator_vcc_lcd;
1597 static struct regulator *regulator_vcc;
1598 static DEFINE_MUTEX(lock);
1599 static int enabled = -1; /* -1: unknown, 0: off, 1 : on */
1603 printk(KERN_ERR "lcd device object is NULL.\n");
1609 if (enabled == 1 && enable)
1611 if (enabled == 0 && !enable)
1614 if (regulator_vcc_lcd == NULL)
1616 regulator_get_exclusive(&ld->dev, "vcc_3.0v_lcd");
1617 if (IS_ERR_OR_NULL(regulator_vcc_lcd)) {
1619 regulator_vcc_lcd = NULL;
1623 if (regulator_vcc == NULL)
1624 regulator_vcc = regulator_get(&ld->dev, "vcc_1.8v");
1625 if (IS_ERR_OR_NULL(regulator_vcc)) {
1627 regulator_vcc = NULL;
1631 if (enabled == -1) {
1634 * Exclusively got regulator may have initial
1635 * use_count = 1; thus, we need to check is_enabled.
1637 if (!regulator_is_enabled(regulator_vcc_lcd))
1638 regulator_enable(regulator_vcc_lcd);
1639 regulator_enable(regulator_vcc);
1642 if (regulator_is_enabled(regulator_vcc_lcd))
1643 regulator_disable(regulator_vcc_lcd);
1644 /* No need to disable shared regulator */
1649 regulator_enable(regulator_vcc_lcd);
1650 regulator_enable(regulator_vcc);
1653 regulator_disable(regulator_vcc_lcd);
1654 regulator_disable(regulator_vcc);
1659 if (ld9040_lcd_enabled)
1660 ld9040_lcd_enabled = 0;
1662 mutex_unlock(&lock);
1666 static int reset_lcd(struct lcd_device *ld)
1668 static unsigned int first = 1;
1669 int reset_gpio = -1;
1671 reset_gpio = S5PV310_GPY4(5);
1674 gpio_request(reset_gpio, "MLCD_RST");
1679 gpio_direction_output(reset_gpio, 0);
1681 gpio_direction_output(reset_gpio, 1);
1686 static int __init early_lcd(char *p)
1688 if (memcmp(p, "ld9040", 6) == 0)
1689 ld9040_lcd_enabled = 1;
1693 early_param("lcd", early_lcd);
1695 static struct lcd_platform_data ld9040_platform_data = {
1697 .power_on = lcd_power_on,
1698 /* it indicates whether lcd panel is enabled from u-boot. */
1700 .reset_delay = 10, /* 10ms */
1701 .power_on_delay = 10, /* 10ms */
1702 .power_off_delay = 120, /* 120ms */
1705 #define LCD_BUS_NUM 3
1706 #define DISPLAY_CS S5PV310_GPY4(3)
1707 static struct spi_board_info spi_board_info[] __initdata = {
1709 .max_speed_hz = 1200000,
1710 .bus_num = LCD_BUS_NUM,
1713 .controller_data = (void *)DISPLAY_CS,
1717 #define DISPLAY_CLK S5PV310_GPY3(1)
1718 #define DISPLAY_SI S5PV310_GPY3(3)
1719 static struct spi_gpio_platform_data lcd_spi_gpio_data = {
1722 .miso = SPI_GPIO_NO_MISO,
1723 .num_chipselect = 1,
1726 static struct platform_device u1_spi_gpio = {
1730 .parent = &s3c_device_fb.dev,
1731 .platform_data = &lcd_spi_gpio_data,
1735 #ifdef CONFIG_VIDEO_FIMG2D
1736 static struct fimg2d_platdata fimg2d_data __initdata = {
1738 .parent_clkname = "mout_g2d0",
1739 .clkname = "sclk_fimg2d",
1740 .gate_clkname = "fimg2d",
1741 .smmu_gate_clkname = "smmu_fimg2d",
1742 .clkrate = 250 * 1000000,
1746 static struct s3c_platform_fb fb_platform_data __initdata = {
1749 #ifdef CONFIG_FB_S3C_DEFAULT_WINDOW
1750 .default_win = CONFIG_FB_S3C_DEFAULT_WINDOW,
1754 .swap = FB_SWAP_HWORD | FB_SWAP_WORD,
1757 #ifdef CONFIG_FB_S3C_HIBERNATION_LOADING
1758 #include <linux/hib_ani.h>
1760 static struct s3cfb_hib_ani hib_ani_set __initdata = {
1782 .hib_animation = hib_anis,
1787 static void __init u1_fb_init(void)
1789 struct device *dev = s3c_device_fb.dev.parent;
1790 struct samsung_pd_info *pdinfo;
1793 pdinfo = (struct samsung_pd_info *)dev->platform_data;
1794 /* fimd driver have to know LCD domain power status. */
1796 fb_platform_data.boot_on = pdinfo->boot_on;
1800 fb_platform_data.logo_on = 1;
1802 strcpy(spi_board_info[0].modalias, "ld9040");
1804 ld9040_platform_data.lcd_enabled = ld9040_lcd_enabled;
1805 spi_board_info[0].platform_data =
1806 (void *)&ld9040_platform_data;
1808 #ifdef CONFIG_FB_S3C_HIBERNATION_LOADING
1809 fb_platform_data.hib_ani = (void *)&hib_ani_set;
1811 spi_register_board_info(spi_board_info,
1812 ARRAY_SIZE(spi_board_info));
1814 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_PROFILING
1815 /* for RAM profiling each LCD resolution */
1816 switch (u1_profile_level){
1817 case 0: /* WVGA: 480 * 800 */
1819 case 1: /* HVGA: 320 * 480 */
1820 ld9040.width_mm = 320 * ld9040.width_mm / ld9040.width;
1821 ld9040.height_mm = 480 * ld9040.height_mm / ld9040.height;
1823 ld9040.height = 480;
1825 case 2: /* QVGA: 240 * 320 */
1826 ld9040.width_mm = 240 * ld9040.width_mm / ld9040.width;
1827 ld9040.height_mm = 320 * ld9040.height_mm / ld9040.height;
1829 ld9040.height = 320;
1835 printk("width = %d, height = %d, width_mm = %d, height_mm = %d\n",
1836 ld9040.width, ld9040.height, ld9040.width_mm, ld9040.height_mm);
1839 fb_platform_data.lcd_data = (struct s3cfb_lcd *)&ld9040;
1842 s3cfb_set_platdata(&fb_platform_data);
1845 /* YUBAEK 20110905 RAMDUMP_DEBUG : GPIO Dump ++ */
1846 #ifdef CONFIG_SEC_DEBUG_PERIPHERAL_DUMP_GPIO
1847 void __iomem *s5pv310_gpio_class_a_addr;
1848 void __iomem *s5pv310_gpio_class_b_addr;
1849 static void s5pv310_gpio_io_map(void)
1851 s5pv310_gpio_class_a_addr = ioremap(S5PV310_PA_GPIO1, SZ_4K);
1852 s5pv310_gpio_class_b_addr = ioremap(S5PV310_PA_GPIO2, SZ_4K);
1854 #endif /* CONFIG_SEC_DEBUG_PERIPHERAL_DUMP_GPIO */
1855 /* YUBAEK 20110905 RAMDUMP_DEBUG : GPIO Dump -- */
1858 static struct jack_platform_data u1_jack_data = {
1860 .charger_online = 0,
1862 .earjack_online = 0,
1869 static struct platform_device u1_jack = {
1873 .platform_data = &u1_jack_data,
1877 //device dependent regulator feature
1879 //============================================================
1881 //============================================================
1882 static struct regulator_consumer_supply fmradio_supplies[] = {
1888 static struct regulator_init_data fmradio_fixed_voltage_init_data = {
1890 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
1892 .num_consumer_supplies = ARRAY_SIZE(fmradio_supplies),
1893 .consumer_supplies = fmradio_supplies,
1895 #define GPIO_FM_RST S5PV310_GPB(0)
1896 static struct fixed_voltage_config fmradio_fixed_voltage_config = {
1897 .supply_name = "FM_RST",
1898 .microvolts = 2800000,
1899 .gpio = GPIO_FM_RST,
1900 .enable_high = true,
1901 .init_data = &fmradio_fixed_voltage_init_data,
1904 static struct platform_device fmradio_fixed_voltage = {
1905 .name = "reg-fixed-voltage",
1906 .id = FIXED_REG_ID_RADIO,
1908 .platform_data = &fmradio_fixed_voltage_config,
1912 static void u1_sec_switch_init(void)
1914 sec_class = class_create(THIS_MODULE, "sec");
1916 if (IS_ERR(sec_class))
1917 pr_err("Failed to create class(sec)!\n");
1919 switch_dev = device_create(sec_class, NULL, 0, NULL, "switch");
1921 if (IS_ERR(switch_dev))
1922 pr_err("Failed to create device(switch)!\n");
1924 // ret = device_create_file(switch_dev, &dev_attr_disable_vbus);
1926 // pr_err("Failed to create device file(disable_vbus)!\n");
1928 #ifdef CONFIG_TARGET_LOCALE_KOR
1929 usb_lock = device_create(sec_class, switch_dev,
1930 MKDEV(0, 0), NULL, ".usb_lock");
1932 if (IS_ERR(usb_lock)) {
1933 pr_err("Failed to create device (usb_lock)!\n");
1937 if (device_create_file(usb_lock, &dev_attr_enable) < 0)
1938 pr_err("Failed to create device file(.usblock/enable)!\n");
1942 static struct u1_charging_status_callbacks {
1943 void (*tsp_set_charging_cable) (int type);
1946 static bool is_cable_attached;
1948 static int u1_charger_cb(cable_type_t cable_type)
1950 union power_supply_propval value;
1953 switch(cable_type) {
1954 case CABLE_TYPE_NONE:
1955 case CABLE_TYPE_OTG:
1956 case CABLE_TYPE_JIG_UART_OFF:
1957 value.intval = POWER_SUPPLY_TYPE_BATTERY;
1958 is_cable_attached = false;
1960 case CABLE_TYPE_USB:
1961 case CABLE_TYPE_JIG_USB_OFF:
1962 case CABLE_TYPE_JIG_USB_ON:
1963 value.intval = POWER_SUPPLY_TYPE_USB;
1964 is_cable_attached = true;
1966 case CABLE_TYPE_DESKDOCK:
1967 case CABLE_TYPE_CARDOCK:
1968 value.intval = POWER_SUPPLY_TYPE_DOCK;
1969 is_cable_attached = true;
1972 case CABLE_TYPE_JIG_UART_OFF_VB:
1973 value.intval = POWER_SUPPLY_TYPE_MAINS;
1974 is_cable_attached = true;
1977 pr_err("%s: invalid type:%d\n", __func__, cable_type);
1981 if (charging_cbs.tsp_set_charging_cable)
1982 charging_cbs.tsp_set_charging_cable(value.intval);
1984 #ifdef CONFIG_JACK_MON
1985 jack_event_handler("charger", is_cable_attached);
1991 static struct regulator *regulator_vbus_ap;
1992 static bool ap_enabled;
1993 static DEFINE_MUTEX(usb_ap_lock);
1995 static void u1_usb_cb(u8 usb_mode)
1998 struct s3c_udc *udc = platform_get_drvdata(&s3c_device_usbgadget);
1999 struct sec_otghost_data *otg_data =
2000 dev_get_platdata(&s3c_device_usb_otghcd.dev);
2002 unsigned long inform6 = __raw_readl(S5P_INFORM6);
2004 pr_info("%s: usb mode=%d, inform6=0x%08lx\n", __func__, usb_mode, inform6);
2006 if (inform6 & RST_FLAG_CHARGE_REBOOT_CHECK ) {
2007 pr_info("%s: lpcharging: disable USB\n", __func__);
2008 ret = udc->change_usb_mode(USB_CABLE_DETACHED);
2010 pr_warn("%s: fail to change mode!!!\n", __func__);
2012 mutex_lock(&usb_ap_lock);
2014 if (regulator_vbus_ap == NULL)
2016 regulator_get_exclusive(NULL, "usb_vbus_ap_5v");
2017 if (IS_ERR_OR_NULL(regulator_vbus_ap)) {
2018 pr_err("%s: fail to get regulator\n", __func__);
2019 regulator_vbus_ap = NULL;
2024 ret = regulator_disable(regulator_vbus_ap);
2030 mutex_unlock(&usb_ap_lock);
2035 if (usb_mode == USB_OTGHOST_ATTACHED) {
2036 otg_data->set_pwr_cb(1);
2037 u1_charger_cb(CABLE_TYPE_OTG);
2040 pr_info("%s: prev_usb_mode=%d\n", __func__, udc->get_usb_mode());
2042 ret = udc->change_usb_mode(usb_mode);
2044 pr_err("%s: fail to change mode!!!\n", __func__);
2046 if (usb_mode == USB_OTGHOST_DETACHED)
2047 otg_data->set_pwr_cb(0);
2049 #ifdef CONFIG_JACK_MON
2050 if (usb_mode == USB_OTGHOST_ATTACHED)
2051 jack_event_handler("host", USB_CABLE_ATTACHED);
2052 else if (usb_mode == USB_OTGHOST_DETACHED)
2053 jack_event_handler("host", USB_CABLE_DETACHED);
2054 else if ((usb_mode == USB_CABLE_ATTACHED)
2055 || (usb_mode == USB_CABLE_DETACHED))
2056 jack_event_handler("usb", usb_mode);
2063 #if defined(CONFIG_TOUCHSCREEN_MXT224U1)
2064 static void mxt224_power_on(void)
2067 gpio = MOBILE_GPIO(TSP_LDO_ON);
2068 s3c_gpio_cfgpin(gpio, S3C_GPIO_OUTPUT);
2069 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
2070 gpio_set_value(gpio, GPIO_LEVEL_HIGH);
2073 gpio = MOBILE_GPIO(TSP_INT);
2074 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
2075 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
2077 /* printk("mxt224_power_on is finished\n"); */
2080 static void mxt224_power_off(void)
2084 gpio = MOBILE_GPIO(TSP_INT);
2085 s3c_gpio_cfgpin(gpio, S3C_GPIO_INPUT);
2086 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_DOWN);
2088 gpio = MOBILE_GPIO(TSP_LDO_ON);
2089 s3c_gpio_cfgpin(gpio, S3C_GPIO_OUTPUT);
2090 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
2091 gpio_set_value(gpio, GPIO_LEVEL_LOW);
2092 /* printk("mxt224_power_off is finished\n"); */
2095 static void mxt224_register_callback(void *function)
2097 charging_cbs.tsp_set_charging_cable = function;
2100 static void mxt224_read_ta_status(void *ta_status)
2102 bool *stat = ta_status;
2103 *stat = is_cable_attached;
2106 #define MXT224_MAX_MT_FINGERS 10
2109 Configuration for MXT224
2111 static u8 t7_config[] = {GEN_POWERCONFIG_T7,
2113 static u8 t8_config[] = {GEN_ACQUISITIONCONFIG_T8,
2114 10, 0, 5, 0, 0, 0, 9, 30};
2115 static u8 t9_config[] = {TOUCH_MULTITOUCHSCREEN_T9,
2116 131, 0, 0, 19, 11, 0, 32, MXT224_THRESHOLD, 2, 1, 0, 15, 1,
2117 13, MXT224_MAX_MT_FINGERS, 5, 40, 10, 31, 3,
2118 223, 1, 0, 0, 0, 0, 143, 55, 143, 90, 18};
2120 static u8 t18_config[] = {SPT_COMCONFIG_T18,
2122 static u8 t20_config[] = {PROCI_GRIPFACESUPPRESSION_T20,
2123 7, 0, 0, 0, 0, 0, 0, 30, 20, 4, 15, 10};
2124 static u8 t22_config[] = {PROCG_NOISESUPPRESSION_T22,
2125 13, 0, 0, 0, 0, 0, 0, 3, 30, 0, 0, 29, 34, 39,
2127 static u8 t28_config[] = {SPT_CTECONFIG_T28,
2128 0, 0, 3, 16, 19, 60};
2129 static u8 end_config[] = {RESERVED_T255};
2131 static const u8 *mxt224_config[] = {
2142 #define GPIO_READ_DONE S5PV310_GPX0(4)
2144 static struct mxt224_platform_data mxt224_data = {
2145 .max_finger_touches = MXT224_MAX_MT_FINGERS,
2146 .gpio_read_done = GPIO_READ_DONE,
2147 .config = mxt224_config,
2156 .power_on = mxt224_power_on,
2157 .power_off = mxt224_power_off,
2158 .register_cb = mxt224_register_callback,
2159 .read_ta_status = mxt224_read_ta_status,
2160 /* For the faster user response */
2161 .input_event = user_input_response,
2163 #else /* CONFIG_TOUCHSCREEN_MXT224U1 */
2164 /* FIXME: Only use for tuning */
2165 static u8 mxt_init_vals_ver_22[] __initdata = {
2166 /* MXT_GEN_COMMAND(6) */
2167 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2168 /* MXT_GEN_POWER(7) */
2170 /* MXT_GEN_ACQUIRE(8) */
2171 0x0a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x23,
2172 /* MXT_TOUCH_MULTI(9) */
2173 0x00, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00,
2174 0x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00,
2175 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2177 /* MXT_TOUCH_KEYARRAY(15) */
2178 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
2180 /* MXT_SPT_GPIOPWM(19) */
2181 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2182 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2183 /* MXT_PROCI_GRIPFACE(20) */
2184 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x28, 0x04,
2186 /* MXT_PROCG_NOISE(22) */
2187 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x23, 0x00,
2188 0x00, 0x05, 0x0f, 0x19, 0x23, 0x2d, 0x03,
2189 /* MXT_TOUCH_PROXIMITY(23) */
2190 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2191 0x00, 0x00, 0x00, 0x00, 0x00,
2192 /* MXT_PROCI_ONETOUCH(24) */
2193 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2194 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2195 /* MXT_SPT_SELFTEST(25) */
2196 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2197 0x00, 0x00, 0x00, 0x00,
2198 /* MXT_PROCI_TWOTOUCH(27) */
2199 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2200 /* MXT_SPT_CTECONFIG(28) */
2201 0x00, 0x00, 0x03, 0x08, 0x10, 0x00,
2204 static struct mxt_platform_data mxt_platform_data __refconst = {
2205 .config = mxt_init_vals_ver_22,
2206 .config_length = ARRAY_SIZE(mxt_init_vals_ver_22),
2214 .voltage = 2800000, /* 2.8V */
2215 .orient = MXT_DIAGONAL,
2216 .irqflags = IRQF_TRIGGER_FALLING,
2218 /* For the faster user response */
2219 .input_event = user_input_response,
2222 #endif /* CONFIG_TOUCHSCREEN_MXT224U1 */
2224 static struct i2c_board_info i2c3_devs[] __initdata = {
2226 #ifdef CONFIG_TOUCHSCREEN_MXT224U1
2227 I2C_BOARD_INFO("Atmel MXT224", 0x4a),
2228 .platform_data = &mxt224_data,
2230 I2C_BOARD_INFO("atmel_mxt_ts", 0x4a),
2231 .platform_data = &mxt_platform_data,
2236 static void u1_power_off(void)
2238 char rst_mode = 'r';
2239 char *str_ptr = "reset\n";
2240 int poweroff_try = 0;
2243 printk(KERN_INFO "%s: u1 power off\n", __func__);
2245 /* Check reboot charging */
2246 if (is_cable_attached || (poweroff_try >= 5)) {
2248 "%s: charger connected(%d) or power off failed(%d), reboot!\n",
2249 __func__, is_cable_attached, poweroff_try);
2253 arm_machine_restart(rst_mode, str_ptr);
2254 // arch_reset(0, 0);
2256 printk(KERN_INFO "%s: waiting for reboot.\n", __func__);
2260 /* wait for power button release */
2261 gpio = MOBILE_GPIO(nPOWER);
2262 gpio_request(gpio, "nPOWER");
2263 if (gpio_get_value(gpio)) {
2264 printk(KERN_INFO "%s: set PS_HOLD low.\n", __func__);
2266 * PS_HOLD Out/High -->
2267 * Low PS_HOLD_CONTROL, R/W, 0x1002_330C
2269 writel(readl(S5P_PS_HOLD_CONTROL) & 0xFFFFFEFF,
2270 S5P_PS_HOLD_CONTROL);
2274 /* when connected zig cable with power, we can't make PS_HOLD_CONTROL low.
2275 * we try power_off 5 times. then if it failed, do restart.
2278 "%s: Should not reach here! (poweroff_try:%d)\n",
2279 __func__, poweroff_try);
2282 /* if power button is not released, wait and check TA again */
2283 printk(KERN_INFO "%s: PowerButton is not released!.\n",
2289 static void __init u1_tsp_init(void)
2294 /* TSP_LDO_ON: XGNSS_QSIGN */
2295 gpio = MOBILE_GPIO(TSP_LDO_ON);
2296 gpio_request(gpio, "TSP_LDO_ON");
2297 gpio_direction_output(gpio, 1);
2298 gpio_export(gpio, 0);
2300 /* TSP_INT: XEINT[4] */
2301 gpio = MOBILE_GPIO(TSP_INT);
2302 gpio_request(gpio, "TSP_INT");
2303 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
2307 * Note that because TSP_LDO provides an external pull-up to TSP_INT,
2308 * the pull-up setting at GPE1(7) is useless and may be omitted in
2309 * order to reduce idle current. However, it probably needs some
2310 * sleep/delay from TSP_LDO_ON = true event because there could be
2311 * "ramp-up" delay. Before knowing this, let's just use PULL_UP here.
2313 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
2314 i2c3_devs[0].irq = gpio_to_irq(gpio);
2321 #if 0 /* TODO : need to check */
2322 extern void MHL_On(bool on);
2324 static void u1_mhl_cb(int attached)
2326 pr_info("%s(%d) NOT work\n", __func__, attached);
2328 if (attached == MAX8997_MUIC_ATTACHED) {
2335 static bool u1_is_mhl_attached(void)
2340 gpio = MOBILE_GPIO(MHL_SEL);
2341 gpio_request(gpio, "MHL_SEL");
2342 val = gpio_get_value(gpio);
2348 static int u1_set_safeout(int path)
2350 static struct regulator *regulator_vbus_cp;
2351 static bool cp_enabled;
2354 mutex_lock(&usb_ap_lock);
2356 if (regulator_vbus_ap == NULL)
2358 regulator_get_exclusive(NULL, "usb_vbus_ap_5v");
2359 if (IS_ERR_OR_NULL(regulator_vbus_ap)) {
2361 regulator_vbus_ap = NULL;
2365 if (regulator_vbus_cp == NULL)
2367 regulator_get_exclusive(NULL, "usb_vbus_cp_5v");
2368 if (IS_ERR_OR_NULL(regulator_vbus_cp)) {
2370 regulator_vbus_cp = NULL;
2374 if (path == CP_USB_MODE) {
2376 ret = regulator_disable(regulator_vbus_ap);
2383 /* regulator_vbus_cp is exclusively got */
2384 if (!regulator_is_enabled(regulator_vbus_cp))
2385 ret = regulator_enable(regulator_vbus_cp);
2391 /* AP_USB_MODE || AUDIO_MODE */
2393 /* regulator_vbus_ap is exclusively got */
2394 if (!regulator_is_enabled(regulator_vbus_ap))
2395 ret = regulator_enable(regulator_vbus_ap);
2402 ret = regulator_disable(regulator_vbus_cp);
2409 mutex_unlock(&usb_ap_lock);
2413 static struct switch_dev switch_dock = {
2417 static const char *switch_cable_names[] = {
2423 static struct switch_dev switch_usb = {
2424 .name = "switch-usb",
2425 .supported_cable = switch_cable_names,
2428 static void u1_deskdock_cb(bool attached)
2431 switch_set_state(&switch_dock, 1);
2433 switch_set_state(&switch_dock, 0);
2436 static void u1_cardock_cb(bool attached)
2439 switch_set_state(&switch_dock, 2);
2441 switch_set_state(&switch_dock, 0);
2444 static void u1_switch_dev_init(void)
2448 /* for CarDock, DeskDock */
2449 ret = switch_dev_register(&switch_dock);
2451 pr_err("Failed to register dock switch. %d\n", ret);
2453 ret = switch_dev_register(&switch_usb);
2455 pr_err("Failed to register switch-usb. %d\n", ret);
2458 static int u1_host_notify_cb(int enable)
2460 struct host_notify_dev * ndev = NULL;
2462 if (s3c_device_usbgadget.dev.platform_data)
2463 ndev = s3c_device_usbgadget.dev.platform_data;
2465 pr_err("%s: ndev is null.\n", __func__);
2469 ndev->booster = enable ? NOTIFY_POWER_ON : NOTIFY_POWER_OFF;
2470 pr_info("%s: mode %d, enable %d\n", __func__, ndev->mode, enable);
2474 struct max8997_muic_platform_data u1_muic_pdata = {
2475 .usb_cb = u1_usb_cb,
2476 .charger_cb = u1_charger_cb, /* done */
2477 .mhl_cb = u1_mhl_cb, /* done */
2478 .is_mhl_attached = u1_is_mhl_attached, /* done */
2479 .set_safeout = u1_set_safeout, /* done */
2480 .deskdock_cb = u1_deskdock_cb, /* done */
2481 .cardock_cb = u1_cardock_cb, /* done */
2482 .host_notify_cb = u1_host_notify_cb, /* done */
2483 .gpio_usb_sel = S5PV310_GPL0(6), /* done */
2484 .uart_path = -1, /* muic does not control uart path*/
2487 static void u1_set_usb_switch(int path)
2489 printk(KERN_INFO "set_usb_switch = [%d]\n",path);
2490 u1_muic_pdata.sw_path = path;
2493 static int u1_get_usb_switch(void)
2495 printk(KERN_INFO "get_usb_switch = [%d]\n",u1_muic_pdata.sw_path);
2496 return u1_muic_pdata.sw_path;
2499 /* Micro USB Switch */
2500 static struct micro_usb_switch_platform_data u1_usb_switch_data = {
2501 .set_usb_switch = u1_set_usb_switch,
2502 .get_usb_switch = u1_get_usb_switch,
2505 static struct platform_device u1_micro_usb_switch = {
2506 .name = "usb-switch",
2509 .platform_data = &u1_usb_switch_data,
2513 static void u1_pm_finish(void)
2515 /* Restore GPX conf */
2516 s3c_pm_do_restore(s5pc210_gpx, ARRAY_SIZE(s5pc210_gpx));
2519 static void u1_pm_prepare(void)
2521 /* 1. Save GPX conf */
2522 s3c_pm_do_save(s5pc210_gpx, ARRAY_SIZE(s5pc210_gpx));
2524 /* 2. Set GPX as Power Save Mode */
2526 /* 3. Debug: Look at the diff */
2527 mobile_gpios_groupx_difference();
2531 int u1_common_setup_clock(const char *sclk_name, const char *pclk_name,
2532 unsigned long rate, unsigned int rate_set)
2534 struct clk *sclk = NULL;
2535 struct clk *pclk = NULL;
2537 sclk = clk_get(NULL, sclk_name);
2539 printk(KERN_ERR "failed to get %s clock.\n", sclk_name);
2543 pclk = clk_get(NULL, pclk_name);
2545 printk(KERN_ERR "failed to get %s clock.\n", pclk_name);
2549 clk_set_parent(sclk, pclk);
2551 printk(KERN_INFO "set parent clock of %s to %s\n", sclk_name,
2559 clk_set_rate(sclk, rate);
2560 printk(KERN_INFO "set %s rate to %lu\n", sclk_name, rate);
2576 #ifdef CONFIG_S5PV310_DEV_PD
2577 static inline void powerdomain_boot_on(int pd)
2579 struct samsung_pd_info *pdinfo = (struct samsung_pd_info *)
2580 s5pv310_device_pd[pd].dev.platform_data;
2581 pdinfo->boot_on = true;
2585 #ifdef CONFIG_INPUT_SECBRIDGE
2586 //============================================================
2587 /* sec-input-bridge */
2588 //============================================================
2589 static const struct sec_input_bridge_mkey u1_rbdump_mkey_map[] = {
2590 { .type = EV_KEY , .code = KEY_VOLUMEUP },
2591 { .type = EV_KEY , .code = KEY_VOLUMEDOWN },
2592 { .type = EV_KEY , .code = KEY_MENU },
2593 { .type = EV_KEY , .code = KEY_MENU },
2594 { .type = EV_KEY , .code = KEY_VOLUMEUP },
2595 { .type = EV_KEY , .code = KEY_VOLUMEDOWN },
2596 { .type = EV_KEY , .code = KEY_VOLUMEUP },
2597 { .type = EV_KEY , .code = KEY_MENU },
2600 static const struct sec_input_bridge_mkey u1_default_mkey_map[] = {
2601 { .type = EV_KEY , .code = KEY_VOLUMEUP },
2602 { .type = EV_KEY , .code = KEY_VOLUMEDOWN },
2603 { .type = EV_KEY , .code = KEY_MENU },
2604 { .type = EV_KEY , .code = KEY_MENU },
2605 { .type = EV_KEY , .code = KEY_VOLUMEUP },
2606 { .type = EV_KEY , .code = KEY_VOLUMEUP },
2607 { .type = EV_KEY , .code = KEY_VOLUMEUP },
2608 { .type = EV_KEY , .code = KEY_MENU },
2611 static const struct sec_input_bridge_mkey u1_uart_mkey_map[] = {
2612 { .type = EV_KEY , .code = KEY_VOLUMEUP },
2613 { .type = EV_KEY , .code = KEY_VOLUMEDOWN },
2614 { .type = EV_KEY , .code = KEY_MENU },
2615 { .type = EV_KEY , .code = KEY_MENU },
2616 { .type = EV_KEY , .code = KEY_VOLUMEUP },
2617 { .type = EV_KEY , .code = KEY_MENU },
2618 { .type = EV_KEY , .code = KEY_VOLUMEDOWN },
2619 { .type = EV_KEY , .code = KEY_MENU },
2622 static void mkey_uart_path_change (void *event_data)
2624 if (u1_get_uart_switch() == UART_SW_PATH_CP)
2625 u1_set_uart_switch(UART_SW_PATH_AP);
2627 u1_set_uart_switch(UART_SW_PATH_CP);
2630 static const struct sec_input_bridge_mmap u1_mmap[] = {
2632 .mkey_map = u1_rbdump_mkey_map,
2633 .num_mkey = ARRAY_SIZE(u1_rbdump_mkey_map),
2634 .uevent_env_str = "RB_DUMP",
2636 .uevent_action = KOBJ_CHANGE,
2637 .uevent_env_str = "RB_DUMP",
2638 .uevent_env_value = "ON",
2641 .mkey_map = u1_default_mkey_map,
2642 .num_mkey = ARRAY_SIZE(u1_default_mkey_map),
2643 .uevent_env_str = "DEFAULT",
2645 .uevent_action = KOBJ_CHANGE,
2646 .uevent_env_str = "DEFAULT",
2647 .uevent_env_value = "ON",
2650 .mkey_map = u1_uart_mkey_map,
2651 .num_mkey = ARRAY_SIZE(u1_uart_mkey_map),
2652 .uevent_env_str = "UART_SW",
2654 .uevent_action = KOBJ_CHANGE,
2655 .uevent_env_str = "DEFAULT",
2656 .uevent_env_value = "ON",
2657 .pre_event_func = mkey_uart_path_change,
2661 extern int bkl_warning_operation(int on_off, int gamma);
2662 static void u1_lcd_warning_function(void)
2665 /* LCD on/off to confirm action */
2668 for (i = 0; i < 8; i++) {
2669 bkl_warning_operation(1, 0);
2672 bkl_warning_operation(1, 10);
2676 /* recovery first state */
2677 bkl_warning_operation(0, 0);
2680 static struct sec_input_bridge_platform_data u1_input_bridge_data = {
2682 .num_map = ARRAY_SIZE(u1_mmap),
2683 .lcd_warning_func = u1_lcd_warning_function,
2686 static struct platform_device u1_input_bridge = {
2687 .name = "samsung_input_bridge",
2690 .platform_data = &u1_input_bridge_data,
2695 #ifdef CONFIG_CHARGERCTRL_MAX8922
2696 #define GPIO_CHG_EN S5PV310_GPL2(2)
2697 #define GPIO_CHG_ING_N S5PV310_GPL2(4)
2698 #define GPIO_TA_nCONNECTED S5PV310_GPL2(5)
2700 static int max8922_cfg_gpio(void)
2702 s3c_gpio_cfgpin(GPIO_CHG_EN, S3C_GPIO_OUTPUT);
2703 s3c_gpio_setpull(GPIO_CHG_EN, S3C_GPIO_PULL_NONE);
2704 gpio_set_value(GPIO_CHG_EN, GPIO_LEVEL_LOW);
2706 s3c_gpio_cfgpin(GPIO_CHG_ING_N, S3C_GPIO_INPUT);
2707 s3c_gpio_setpull(GPIO_CHG_ING_N, S3C_GPIO_PULL_NONE);
2709 s3c_gpio_cfgpin(GPIO_TA_nCONNECTED, S3C_GPIO_INPUT);
2710 s3c_gpio_setpull(GPIO_TA_nCONNECTED, S3C_GPIO_PULL_NONE);
2715 static int u1_charger_topoff_cb(void)
2717 struct power_supply *psy = power_supply_get_by_name("battery");
2718 union power_supply_propval value;
2721 pr_err("%s: fail to get battery ps\n", __func__);
2725 value.intval = POWER_SUPPLY_STATUS_FULL;
2726 return psy->set_property(psy, POWER_SUPPLY_PROP_STATUS, &value);
2729 static struct regulator_consumer_supply supplies_max8922[] = {
2730 REGULATOR_SUPPLY("vinchg2", "charger-manager.0"),
2731 REGULATOR_SUPPLY("vinchg2_mach", NULL),
2734 static struct regulator_init_data max8922_charger_en_data = {
2736 .name = "MAX8922_CHARGER",
2739 .valid_ops_mask = REGULATOR_CHANGE_STATUS |
2740 REGULATOR_CHANGE_CURRENT,
2742 .num_consumer_supplies = ARRAY_SIZE(supplies_max8922),
2743 .consumer_supplies = supplies_max8922,
2745 static struct max8922_platform_data max8922_pdata = {
2746 .topoff_cb = u1_charger_topoff_cb,
2747 .cfg_gpio = max8922_cfg_gpio,
2748 .gpio_chg_en = GPIO_CHG_EN,
2749 .gpio_chg_ing = GPIO_CHG_ING_N,
2750 .gpio_ta_nconnected = GPIO_TA_nCONNECTED,
2751 .init_data = &max8922_charger_en_data,
2754 static struct platform_device max8922_device_charger = {
2755 .name = "max8922-charger",
2757 .dev.platform_data = &max8922_pdata,
2759 #endif /* CONFIG_MAX8922_CHARGER */
2761 struct led_max8997_platform_data u1_led_max8997_platform_data = {
2762 .name = "leds-torch",
2766 struct platform_device u1_device_leds_max8997 = {
2767 .name = "leds-max8997",
2769 .dev = { .platform_data = &u1_led_max8997_platform_data},
2772 #ifdef CONFIG_CHARGER_MANAGER
2773 extern struct platform_device u1_charger_manager;
2774 extern struct platform_device u1_ncp15wb473_thermistor;
2775 extern struct platform_device u1_ncp15wb473_thermistor_pmic;
2776 extern struct charger_global_desc u1_charger_g_desc;
2779 static struct platform_device *u1_devices[] __initdata = {
2780 /* Samsung Platform Devices */
2781 #ifdef CONFIG_S5PV310_DEV_PD
2782 &s5pv310_device_pd[PD_MFC],
2783 &s5pv310_device_pd[PD_G3D],
2784 &s5pv310_device_pd[PD_LCD0],
2785 &s5pv310_device_pd[PD_LCD1],
2786 &s5pv310_device_pd[PD_TV],
2787 &s5pv310_device_pd[PD_CAM],
2788 &s5pv310_device_pd[PD_GPS],
2790 #ifdef CONFIG_DRM_MALI
2791 &s5p_device_mali_drm,
2793 #ifdef CONFIG_DRM_FIMD
2794 &s5p_device_fimd_drm,
2810 &s3c_device_timer[0],
2811 &s3c_device_timer[1],
2813 #ifdef CONFIG_S3C_DEV_RTC
2816 #ifdef CONFIG_CHARGERCTRL_MAX8922
2817 &max8922_device_charger,
2820 #ifdef CONFIG_VIDEO_FIMC_MIPI
2824 #ifdef CONFIG_VIDEO_FIMC
2831 #ifdef CONFIG_VIDEO_JPEG
2837 #ifdef CONFIG_USB_GADGET
2838 &s3c_device_usbgadget,
2840 #ifdef CONFIG_USB_ANDROID_RNDIS
2843 #ifdef CONFIG_USB_ANDROID_ECM
2846 #ifdef CONFIG_USB_ANDROID
2847 &s3c_device_android_usb,
2848 &s3c_device_usb_mass_storage,
2850 #ifdef CONFIG_USB_S3C_OTG_HOST
2851 &s3c_device_usb_otghcd,
2853 #ifdef CONFIG_S3C_DEV_HSMMC4
2858 &emmc_fixed_voltage,
2865 #ifdef CONFIG_SND_S3C64XX_SOC_I2S_V4
2866 &s5pv310_device_iis0,
2868 #ifdef CONFIG_SND_S3C_SOC_PCM
2869 &s5pv310_device_pcm1,
2871 #ifdef CONFIG_SND_SOC_SMDK_WM9713
2872 &s5pv310_device_ac97,
2874 #ifdef CONFIG_SND_SAMSUNG_SOC_SPDIF
2875 &s5pv310_device_spdif,
2878 &fmradio_fixed_voltage,
2884 &u1_micro_usb_switch,
2886 #ifdef CONFIG_S3C2410_WATCHDOG
2890 #ifdef CONFIG_S5P_SYSMMU
2891 &s5p_device_sysmmu[SYSMMU_G2D],
2892 &s5p_device_sysmmu[SYSMMU_MFC_L],
2893 &s5p_device_sysmmu[SYSMMU_MFC_R],
2894 &s5p_device_sysmmu[SYSMMU_FIMC0],
2895 &s5p_device_sysmmu[SYSMMU_FIMC1],
2896 &s5p_device_sysmmu[SYSMMU_FIMC2],
2897 &s5p_device_sysmmu[SYSMMU_FIMC3],
2899 #ifdef CONFIG_VIDEO_FIMG2D
2902 #if defined(CONFIG_VIDEO_MFC5X) || defined(CONFIG_VIDEO_SAMSUNG_S5P_MFC)
2905 #ifdef CONFIG_FB_S3C
2909 #ifdef CONFIG_ANDROID_RAM_CONSOLE
2910 &ram_console_device,
2913 &u1_device_leds_max8997,
2915 #ifdef CONFIG_CHARGER_MANAGER
2916 /* Should be placed after fuel gauge, charger control chips, pmics */
2917 &u1_ncp15wb473_thermistor,
2918 &u1_ncp15wb473_thermistor_pmic,
2919 &u1_charger_manager,
2921 #ifdef CONFIG_INPUT_SECBRIDGE
2924 #ifdef CONFIG_SAMSUNG_BOOT_MODE
2925 &s3c_device_samsung_boot_mode,
2927 #ifdef CONFIG_SEC_DEBUG
2930 #ifdef CONFIG_S5PV310_STOPWATCH
2931 &s5pv310_device_stopwatch,
2933 #ifdef CONFIG_DEV_THERMAL
2938 &s5p_device_usb_ehci,
2941 extern void (*s5p_inform6_set)(char mode);
2942 extern void s5pv310_inform6_set(char mode);
2943 extern struct machine_desc *lookup_machine_type(unsigned int);
2945 static void __init u1_machine_init(void)
2948 struct machine_desc *list;
2949 list = lookup_machine_type(machine_arch_type);
2950 strcpy(utsname()->nodename, list->name);
2952 /* to support system shut down */
2953 pm_power_off = u1_power_off;
2955 /* to support inform6 set */
2956 s5p_inform6_set = s5pv310_inform6_set;
2958 /* Initialize GPIO default setting */
2959 mobile_gpios_init();
2960 s3c_config_sleep_gpio_table = u1_config_sleep_gpio_table;
2962 u1_switch_dev_init();
2964 s3c_i2c0_set_platdata(&u1_i2c0_platdata);
2967 s3c_i2c1_set_platdata(NULL);
2969 i2c_register_board_info(1, i2c1_devs, ARRAY_SIZE(i2c1_devs));
2972 s3c_i2c3_set_platdata(NULL);
2973 i2c_register_board_info(3, i2c3_devs, ARRAY_SIZE(i2c3_devs));
2975 u1_sec_switch_init();
2977 #ifdef CONFIG_S5PV310_DEV_PD
2978 s5pv310_device_pd[PD_CAM].dev.parent = &s5pv310_device_pd[PD_LCD0].dev;
2979 #ifdef CONFIG_FB_S3C
2980 s3c_device_fb.dev.parent = &s5pv310_device_pd[PD_LCD0].dev;
2981 powerdomain_boot_on(PD_LCD0);
2987 /* YUBAEK 20110905 RAMDUMP_DEBUG : GPIO Dump ++ */
2988 #ifdef CONFIG_SEC_DEBUG_PERIPHERAL_DUMP_GPIO
2989 s5pv310_gpio_io_map();
2991 /* YUBAEK 20110905 RAMDUMP_DEBUG : GPIO Dump ++ */
2994 #ifdef CONFIG_S5PV310_DEV_PD
2995 #if defined(CONFIG_VIDEO_MFC5X) || defined(CONFIG_VIDEO_SAMSUNG_S5P_MFC)
2996 s5p_device_mfc.dev.parent = &s5pv310_device_pd[PD_MFC].dev;
2997 u1_common_setup_clock("mout_mfc0", "mout_mpll", 0, 0);
2998 u1_common_setup_clock("sclk_mfc", "mout_mfc0", 200 * MHZ, 1);
3002 u1_pmic_init(); /* TODO: should be modify for U1 */
3003 s3c_i2c5_set_platdata(NULL);
3004 i2c5_devs[I2C5_MAX8997].irq = gpio_to_irq(S5PV310_GPX0(7)),
3005 i2c_register_board_info(5, i2c5_devs, ARRAY_SIZE(i2c5_devs));
3008 s3c_i2c6_set_platdata(NULL);
3009 i2c_register_board_info(6, i2c6_devs, ARRAY_SIZE(i2c6_devs));
3011 s3c_i2c7_set_platdata(NULL);
3012 i2c_register_board_info(7, i2c7_devs, ARRAY_SIZE(i2c7_devs));
3014 gpio = S5PV310_GPX2(3);
3015 gpio_request(gpio, "FUEL_ALERT");
3016 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
3017 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
3018 i2c9_devs[I2C9_MAX17042].irq = gpio_to_irq(gpio);
3019 i2c_register_board_info(9, i2c9_devs, ARRAY_SIZE(i2c9_devs));
3021 universal_touchkey_init();
3022 i2c_register_board_info(12, i2c12_devs_cypress, ARRAY_SIZE(i2c12_devs_cypress));
3024 i2c_register_board_info(14, i2c14_devs, ARRAY_SIZE(i2c14_devs));
3026 i2c_register_board_info(15, i2c15_devs, ARRAY_SIZE(i2c15_devs));
3030 i2c_register_board_info(16, i2c16_devs, ARRAY_SIZE(i2c16_devs));
3032 #if defined(CONFIG_VIDEO_S5K5BAFX)
3033 i2c_register_board_info(17, i2c17_devs, ARRAY_SIZE(i2c17_devs));
3036 i2c_register_board_info(18, i2c18_devs, ARRAY_SIZE(i2c18_devs));
3042 s3c_usb_set_serial();
3046 #ifdef CONFIG_VIDEO_FIMG2D
3047 s5p_fimg2d_set_platdata(&fimg2d_data);
3048 #ifdef CONFIG_S5PV310_DEV_PD
3049 s5p_device_fimg2d.dev.parent = &s5pv310_device_pd[PD_LCD0].dev;
3054 pm_cpu_prepare = u1_pm_prepare;
3055 pm_cpu_finish = u1_pm_finish;
3058 s3c_irq_wake(IRQ_RTC_ALARM, 1);
3061 #if defined(CONFIG_S5PV310_DEV_PD) && !defined(CONFIG_PM_RUNTIME)
3063 * These power domains should be always on
3064 * without runtime pm support.
3066 s5pv310_pd_enable(&s5pv310_device_pd[PD_MFC].dev);
3067 s5pv310_pd_enable(&s5pv310_device_pd[PD_G3D].dev);
3068 s5pv310_pd_enable(&s5pv310_device_pd[PD_LCD0].dev);
3069 s5pv310_pd_enable(&s5pv310_device_pd[PD_LCD1].dev);
3070 s5pv310_pd_enable(&s5pv310_device_pd[PD_CAM].dev);
3071 s5pv310_pd_enable(&s5pv310_device_pd[PD_TV].dev);
3072 s5pv310_pd_enable(&s5pv310_device_pd[PD_GPS].dev);
3075 #ifdef CONFIG_VIDEO_FIMG2D
3076 /* setup fimg2d parent clock. */
3077 universal_fimg2d_setup_clock("mout_g2d0", "mout_mpll");
3080 s5pv310_sdhci_init();
3081 #ifdef CONFIG_S5P_ADC
3085 #ifdef CONFIG_DEV_THERMAL
3086 s5p_tmu_set_platdata(NULL);
3089 s5pv310_camera_init();
3091 #ifdef CONFIG_CHARGER_MANAGER
3092 setup_charger_manager(&u1_charger_g_desc);
3096 platform_add_devices(u1_devices, ARRAY_SIZE(u1_devices));
3098 regulator_has_full_constraints();
3099 /* Temp. commented */
3101 if (s5pv310_subrev() != 0) {
3102 pr_emerg("\n\n This kernel does NOT support subrevision %d of S5PC210.\n\n\n",
3104 panic("Not supported subrevision");
3109 MACHINE_START(U1_C210, "U1SLP")
3110 /* Maintainer: mhban <mhban@samsung.com> */
3111 .phys_io = S3C_PA_UART & 0xfff00000,
3112 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
3113 .boot_params = S5P_PA_SDRAM + 0x100,
3114 .init_irq = s5pv310_init_irq,
3115 .map_io = u1_map_io,
3116 .init_machine = u1_machine_init,
3117 .timer = &s5pv310_timer,
3118 .reserve = &s5pv310_reserve,