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 <linux/irq.h>
57 #include <video/platform_lcd.h>
59 #include <asm/mach-types.h>
60 #include <asm/mach/arch.h>
61 #include <asm/setup.h>
62 #include <asm/cacheflush.h>
65 #include <mach/gpio.h>
66 #include <mach/regs-clock.h>
67 #include <mach/regs-pmu.h>
68 #include <mach/pm-core.h>
69 #include <mach/nt39411.h>
70 #include <mach/universal.h>
73 #include <plat/clock.h>
74 #include <plat/devs.h>
75 #include <plat/gpio-cfg.h>
76 #include <plat/gpio-core.h>
78 #include <plat/fimg2d.h>
79 #include <plat/mali.h>
82 #include <plat/regs-otg.h>
83 #include <plat/regs-serial.h>
84 #include <plat/s5pv310.h>
86 #include <plat/fimd_drm.h>
87 #include <plat/tvout.h>
89 #include <plat/s5p_fimd_lite.h>
90 #include <plat/usb_ehci.h>
91 #include <plat/sysmmu.h>
92 #include <plat/s5p-otghost.h>
93 #include <plat/udc-hs.h>
94 #include <plat/mipi_dsim.h>
96 #include "gpio-mobile.h"
97 #include "gpio-u1hd.h"
98 #include "board-mobile.h"
99 #include "../../../drivers/usb/gadget/s3c_udc.h"
101 #ifdef CONFIG_TOUCHSCREEN_MELFAS
102 #include <linux/melfas_ts.h>
105 #ifdef CONFIG_INPUT_SECBRIDGE
106 #include <linux/input/sec-input-bridge.h>
109 #ifdef CONFIG_CHARGERCTRL_MAX8922
110 #include <linux/max8922-charger.h>
113 #if defined(CONFIG_DEV_THERMAL)
114 #include <plat/s5p-tmu.h>
115 #include <mach/regs-tmu.h>
118 #ifdef CONFIG_INPUT_GP2A
119 #include <linux/input/gp2a.h>
122 /* Following are default values for UCON, ULCON and UFCON UART registers */
123 #define UNIVERSAL_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
124 S3C2410_UCON_RXILEVEL | \
125 S3C2410_UCON_TXIRQMODE | \
126 S3C2410_UCON_RXIRQMODE | \
127 S3C2410_UCON_RXFIFO_TOI | \
128 S3C2443_UCON_RXERR_IRQEN)
130 #define UNIVERSAL_ULCON_DEFAULT S3C2410_LCON_CS8
132 #define UNIVERSAL_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \
133 S5PV210_UFCON_TXTRIG0 | \
134 S5PV210_UFCON_RXTRIG128)
136 #define UNIVERSAL_UFCON_UART2 (S3C2410_UFCON_FIFOMODE | \
137 S5PV210_UFCON_TXTRIG0 | \
138 S5PV210_UFCON_RXTRIG4)
140 extern void u1hd_config_sleep_gpio_table(void);
142 enum fixed_regulator_id {
143 FIXED_REG_ID_MMC = 0,
155 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_PROFILING
157 * This string add for profiling of each segments
165 static unsigned int u1hd_profile_level = 0;
167 static int __init u1hd_profile_level_setup(char *str)
173 u1hd_profile_level = memparse(str, &endp);
174 if (u1hd_profile_level > 3)
175 u1hd_profile_level = 0;
177 return endp > str ? 0 : -EINVAL;
180 early_param("profile_level=", u1hd_profile_level_setup);
184 static struct s3c2410_uartcfg u1hd_uartcfgs[] __initdata = {
187 .ucon = UNIVERSAL_UCON_DEFAULT,
188 .ulcon = UNIVERSAL_ULCON_DEFAULT,
189 .ufcon = UNIVERSAL_UFCON_DEFAULT,
193 .ucon = UNIVERSAL_UCON_DEFAULT,
194 .ulcon = UNIVERSAL_ULCON_DEFAULT,
195 .ufcon = UNIVERSAL_UFCON_DEFAULT,
199 .ucon = UNIVERSAL_UCON_DEFAULT,
200 .ulcon = UNIVERSAL_ULCON_DEFAULT,
201 .ufcon = UNIVERSAL_UFCON_UART2,
205 .ucon = UNIVERSAL_UCON_DEFAULT,
206 .ulcon = UNIVERSAL_ULCON_DEFAULT,
207 .ufcon = UNIVERSAL_UFCON_DEFAULT,
211 static struct s3c2410_platform_i2c u1hd_i2c0_platdata __initdata = {
212 .frequency = 300 * 1000,
216 static struct k3g_platform_data u1hd_k3g_data = {
218 .powerdown = K3G_POWERDOWN_NORMAL,
222 .block_data_update = K3G_BLOCK_DATA_UPDATE,
223 .fullscale = K3G_FULL_SCALE_500DPS,
224 .fifo_mode = K3G_FIFO_FIFO_MODE,
225 .int2_src = K3G_INT2_OVERRUN,
226 .fifo_threshold = 16,
227 .int1_z_high_enable = K3G_Z_HIGH_INT_EN,
228 .int1_y_high_enable = K3G_Y_HIGH_INT_EN,
229 .int1_x_high_enable = K3G_X_HIGH_INT_EN,
230 .int1_latch = K3G_INTERRUPT_LATCHED,
231 .int1_z_threshold = 0x12,
232 .int1_y_threshold = 0x25,
233 .int1_x_threshold = 0x25,
234 .int1_wait_enable = K3G_INT1_WAIT_EN,
235 .int1_wait_duration = 0x10,
238 static struct kr3dh_platform_data u1hd_kr3dh_data = {
239 .power_mode = KR3DH_LOW_POWER_ONE_HALF_HZ,
240 .data_rate = KR3DH_ODR_50HZ,
245 .int1_cfg = KR3DH_INT_SOURCE,
246 .block_data_update = 1,
247 .fullscale = KR3DH_RANGE_2G,
248 .int1_combination = KR3DH_OR_COMBINATION,
250 .int1_z_high_enable = 1,
251 .int1_z_low_enable = 1,
252 .int1_y_high_enable = 1,
253 .int1_y_low_enable = 1,
254 .int1_x_high_enable = 1,
255 .int1_x_low_enable = 1,
256 .int1_threshold = 0x25,
257 .int1_duration = 0x01,
264 static void user_input_response_work(struct work_struct *work)
266 #ifdef CONFIG_CPU_FREQ_GOV_ONDEMAND_FLEXRATE
267 /* Run CPUFREQ with 10000us 10 times. */
268 cpufreq_ondemand_flexrate_request(10000, 10);
269 #endif /* CONFIG_CPU_FREQ_GOV_ONDEMAND_FLEXRATE */
272 static DECLARE_WORK(uir_work, user_input_response_work);
274 static __maybe_unused void user_input_response(void *data)
276 if (!work_pending(&uir_work))
277 schedule_work_on(0, &uir_work);
281 static struct i2c_board_info i2c1_devs[] __initdata = {
284 I2C_BOARD_INFO("K3G_1", 0x69),
285 .platform_data = &u1hd_k3g_data,
289 I2C_BOARD_INFO("KR3DH", 0x19),
290 .platform_data = &u1hd_kr3dh_data,
295 /* TODO: should be modify for U1 */
296 extern struct max8997_platform_data u1hd_max8997_pdata;
297 extern void __init u1hd_pmic_init(void);
299 static void haptic_control_power(struct device *dev, int on)
301 static struct regulator *regulator;
302 static DEFINE_MUTEX(lock);
311 if (regulator == NULL)
312 regulator = regulator_get(dev, "inmotor");
313 if (IS_ERR_OR_NULL(regulator)) {
319 ret = regulator_enable(regulator);
321 ret = regulator_disable(regulator);
329 struct max8997_haptic_platform_data u1hd_haptic_pdata = {
332 .control_power = haptic_control_power,
335 /* GPIO I2C 5 (PMIC) */
336 enum { I2C5_MAX8997 };
337 static struct i2c_board_info i2c5_devs[] __initdata = {
339 I2C_BOARD_INFO("max8997", 0xCC >> 1),
340 .platform_data = &u1hd_max8997_pdata,
344 void sec_set_sub_mic_bias(bool on)
347 gpio = MOBILE_GPIO(SUB_MICBIAS_EN);
348 gpio_set_value(gpio, on);
349 pr_err(KERN_ERR "SUB_MIC_BIAS_EN GPIO set [%d] !\n", on);
352 void sec_set_main_mic_bias(bool on)
355 gpio = MOBILE_GPIO(MICBIAS_EN);
356 gpio_set_value(gpio, on);
357 pr_err(KERN_ERR "MAIN_MIC_BIAS_EN GPIO set [%d] !\n", on);
360 static struct mc1n2_platform_data mc1n2_pdata = {
361 .set_main_mic_bias = sec_set_main_mic_bias,
362 .set_sub_mic_bias = sec_set_sub_mic_bias,
366 static struct i2c_board_info i2c6_devs[] __initdata = {
369 I2C_BOARD_INFO("mc1n2", 0x3a),
370 .platform_data = &mc1n2_pdata,
374 static void __init u1hd_sound_init(void)
380 /* Set PMU register to set CLK_OUT to use XUSBXTI
381 * as codec source clock */
383 __raw_writel(val, S5P_PMREG(0xA00));
385 gpio = MOBILE_GPIO(MICBIAS_EN);
386 err = gpio_request(gpio, "MICBIAS_EN");
388 pr_err(KERN_ERR "MIC_BIAS_EN GPIO set error!\n");
391 gpio_direction_output(gpio, 1);
392 gpio_set_value(gpio, 0);
394 gpio = MOBILE_GPIO(EAR_MICBIAS_EN);
395 err = gpio_request(gpio, "EAR_MICBIAS_EN");
397 pr_err(KERN_ERR "EAR_MIC_BIAS_EN GPIO set error!\n");
400 gpio_direction_output(gpio, 1);
401 gpio_set_value(gpio, 0);
403 gpio = MOBILE_GPIO(SUB_MICBIAS_EN);
404 err = gpio_request(gpio, "submic_bias");
406 pr_err(KERN_ERR "SUB_MIC_BIAS_EN GPIO set error!\n");
409 gpio_direction_output(gpio, 0);
412 static struct ak8975_platform_data universal_ak8975_data = {
413 .poll_interval = 100,
417 static struct i2c_board_info i2c7_devs[] __initdata = {
420 I2C_BOARD_INFO("ak8975", 0x0c),
421 .platform_data = &universal_ak8975_data,
423 I2C_BOARD_INFO("s5p_ddc", 0x72 >> 1),
428 static struct s3c2410_platform_i2c i2c_data8 __initdata = {
432 .frequency = 100*1000,
437 static struct i2c_gpio_platform_data i2c9_gpio_data = {
438 .sda_pin = S5PV310_GPY4(0), /* XM0ADDR_8 */
439 .scl_pin = S5PV310_GPY4(1), /* XM0ADDR_9 */
442 static struct platform_device i2c9_gpio = {
446 .platform_data = &i2c9_gpio_data,
450 static struct max17042_reg_data max17042_init_data[] = {
451 { MAX17042_CGAIN, 0x0000 },
452 { MAX17042_MiscCFG, 0x0003 },
453 { MAX17042_LearnCFG, 0x0007 },
454 /* RCOMP: 0x0050 2011.02.29 from MAXIM */
455 { MAX17042_RCOMP0, 0x0050 },
457 /* Alert only when the battery is removed or inserted */
458 static struct max17042_reg_data max17042_alert_init_data[] = {
459 /* SALRT Threshold setting (disable) unsigned MAX/MIN */
460 { MAX17042_SALRT_Th, 0xFF00 },
461 /* VALRT Threshold setting (disable) unsigned MAX/MIN */
462 { MAX17042_VALRT_Th, 0xFF00 },
463 /* TALRT Threshold setting (disable) signed MAX/MIN */
464 { MAX17042_TALRT_Th, 0x7F80 },
466 static struct max17042_platform_data u1hd_battery_platform_data = {
467 .init_data = max17042_init_data,
468 .num_init_data = ARRAY_SIZE(max17042_init_data),
469 .alrt_data = max17042_alert_init_data,
470 .num_alrt_data = ARRAY_SIZE(max17042_alert_init_data),
471 .irq_base = IRQ_FUEL_BASE,
472 .enable_alert = true,
474 .r_sns = 10000, /* 10m Ohm */
477 enum { I2C9_MAX17042};
478 static struct i2c_board_info i2c9_devs[] __initdata = {
480 I2C_BOARD_INFO("max17042", 0x36),
481 .platform_data = &u1hd_battery_platform_data,
486 /* GPIO I2C 12 (3 Touchkey) */
487 #define TOUCHKEY_INT S5PV310_GPL0(5)
488 #define TOUCHKEY_SCL S5PV310_GPK1(0)
489 #define TOUCHKEY_SDA S5PV310_GPK1(2)
491 static struct i2c_gpio_platform_data i2c12_gpio_data = {
492 .sda_pin = S5PV310_GPK1(2), /* XMDMDATA_8 */
493 .scl_pin = S5PV310_GPK1(0), /* XMDMDATA_9 */
496 static struct platform_device i2c12_gpio = {
500 .platform_data = &i2c12_gpio_data,
504 /*===============================*/
505 /*= CYPRESS TOUCH KEY =*/
506 /*===============================*/
507 static struct cypress_pin cypress_tk_pin = {
509 .gpio_int = TOUCHKEY_INT,
510 .gpio_sda = TOUCHKEY_SDA,
511 .gpio_scl = TOUCHKEY_SCL,
514 static void cypress_tk_cfg_pin(void)
516 s3c_gpio_setpull(cypress_tk_pin.gpio_sda, S3C_GPIO_PULL_NONE);
517 s3c_gpio_setpull(cypress_tk_pin.gpio_scl, S3C_GPIO_PULL_NONE);
519 s3c_gpio_cfgpin(cypress_tk_pin.gpio_sda, S3C_GPIO_SFN(2));
520 s3c_gpio_cfgpin(cypress_tk_pin.gpio_scl, S3C_GPIO_SFN(2));
522 s3c_gpio_cfgpin(cypress_tk_pin.gpio_int, S3C_GPIO_SFN(0xf));
523 if (gpio_is_valid(cypress_tk_pin.gpio_en))
524 s3c_gpio_cfgpin(cypress_tk_pin.gpio_en, S3C_GPIO_OUTPUT);
527 static int cypress_touchkey_power(int onoff)
529 static struct regulator *regulator;
530 static DEFINE_MUTEX(lock);
536 if (enabled == !!onoff)
539 if (regulator == NULL)
540 regulator = regulator_get(NULL, "touch_2.8v");
541 if (IS_ERR_OR_NULL(regulator)) {
543 pr_err("[TK][ERROR] regulator_get fail\n");
549 ret = regulator_enable(regulator);
551 ret = regulator_disable(regulator);
562 static int cypress_touchled_power(int onoff)
564 static struct regulator *regulator;
565 static DEFINE_MUTEX(lock);
571 if (enabled == !!onoff)
574 if (regulator == NULL)
575 regulator = regulator_get(NULL, "touch_led_3.3v");
576 if (IS_ERR_OR_NULL(regulator)) {
578 pr_err("[TK][ERROR] regulator_get fail\n");
584 ret = regulator_enable(regulator);
586 ret = regulator_disable(regulator);
597 static unsigned int u1hd_cypress_touch_keycode[] = {
598 KEY_PHONE, /* not use this value 0x00 */
599 KEY_PHONE, /* KEY_SEND 0x01 */
600 KEY_BACK, /* KEY_END 0x02 */
603 static unsigned char u1hd_cypress_keycode_setbit[] = {
609 static struct cypress_platform_data cypress_tk_data = {
610 .cfg_pin = cypress_tk_cfg_pin,
611 .power_pin = cypress_touchkey_power,
612 .led_pin = cypress_touchled_power,
613 .pin = &cypress_tk_pin,
614 .keycode = u1hd_cypress_touch_keycode,
615 .keycode_size = ARRAY_SIZE(u1hd_cypress_touch_keycode),
616 .keycode_setbit = u1hd_cypress_keycode_setbit,
620 static struct i2c_board_info i2c12_devs_cypress[] __initdata = {
622 I2C_BOARD_INFO("cypress_tk", 0x20),
623 .platform_data = &cypress_tk_data,
627 static void __init universal_touchkey_init(void)
632 gpio = TOUCHKEY_INT; /* XMDMDATA_7 */
633 gpio_request(gpio, "3_TOUCH_INT");
634 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
635 irq = gpio_to_irq(gpio);
636 i2c12_devs_cypress[0].irq = irq;
639 static struct regulator_consumer_supply supplies_ps_on_led_a[] = {
640 REGULATOR_SUPPLY("led_a_2.8v", NULL),
642 static struct regulator_init_data ps_on_led_a_data = {
644 .name = "LED_A_2.8V",
645 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
652 .num_consumer_supplies = ARRAY_SIZE(supplies_ps_on_led_a),
653 .consumer_supplies = supplies_ps_on_led_a,
655 static struct fixed_voltage_config ps_on_led_a_pdata = {
656 .supply_name = "LED_A_2.8V",
657 .microvolts = 2800000,
658 .gpio = S5PV310_GPE2(3), /* PS_ON */
660 .enabled_at_boot = 0,
661 .init_data = &ps_on_led_a_data,
663 static struct platform_device ps_on_led_a_fixed_reg_dev = {
664 .name = "reg-fixed-voltage",
665 .id = FIXED_REG_ID_LED_A,
666 .dev = { .platform_data = &ps_on_led_a_pdata },
670 static struct i2c_gpio_platform_data i2c14_gpio_data = {
671 .sda_pin = S5PV310_GPK2(2), /* XMMC2CDn */
672 .scl_pin = S5PV310_GPK3(2), /* XMMC3CDn */
673 .udelay = 1, /* 500kHz */
676 static struct platform_device i2c14_gpio = {
680 .platform_data = &i2c14_gpio_data,
684 #ifdef CONFIG_INPUT_GP2A
685 static int gp2a_led_control(bool enable)
687 static struct regulator *regulator;
688 static DEFINE_MUTEX(lock);
693 if (regulator == NULL)
694 regulator = regulator_get_exclusive(NULL, "led_a_2.8v");
695 WARN(IS_ERR_OR_NULL(regulator), "%s cannot get regulator\n", __func__);
696 if (IS_ERR_OR_NULL(regulator)) {
702 if (regulator_is_enabled(regulator)) {
703 regulator_disable(regulator);
709 regulator_enable(regulator);
715 static int gp2a_get_low_threshold(void)
717 int low_threshold = 7; /* LTH value */
719 if (system_rev == 2) /* U1HD Linchbox board is not calibrated */
722 return low_threshold;
725 static struct gp2a_platform_data u1hd_gp2a_pdata = {
726 .gp2a_led_on = gp2a_led_control,
727 .p_out = S5PV310_GPX0(2),
728 .gp2a_get_low_threshold = gp2a_get_low_threshold,
731 static struct platform_device opt_gp2a = {
735 .platform_data = &u1hd_gp2a_pdata,
739 static struct i2c_board_info i2c14_devs[] __initdata = {
741 I2C_BOARD_INFO("gp2a", 0x72 >> 1),
746 static void __init u1hd_sensor_init(void)
750 gpio = S5PV310_GPX2(2); /* XEINT_18 */
751 gpio_request(gpio, "MSENSE_INT");
752 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
753 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
754 i2c7_devs[0].irq = gpio_to_irq(gpio);
756 gpio = S5PV310_GPX0(0); /* XEINT_0 */
757 gpio_request(gpio, "GYRO_INT");
758 gpio_direction_input(gpio);
759 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_DOWN);
761 gpio = S5PV310_GPX0(1); /* XEINT_1 */
762 gpio_request(gpio, "GYRO_INT1");
763 gpio_direction_input(gpio);
764 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_DOWN);
767 gpio = S5PV310_GPX3(0); /* XEINT_24 */
768 gpio_request(gpio, "ACC_INT");
769 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
770 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_DOWN);
772 /* added for gp2a light sensor*/
773 platform_device_register_simple("light_gp2a", 0, NULL, 0);
777 static struct i2c_gpio_platform_data i2c15_gpio_data = {
778 .sda_pin = S5PV310_GPY3(0), /* XM0ADDR_0 */
779 .scl_pin = S5PV310_GPY3(2), /* XM0ADDR_2 */
783 static struct platform_device i2c15_gpio = {
787 .platform_data = &i2c15_gpio_data,
791 static struct i2c_board_info i2c15_devs[] __initdata = {
793 I2C_BOARD_INFO("SII9234", 0x72>>1),
796 I2C_BOARD_INFO("SII9234A", 0x7A>>1),
799 I2C_BOARD_INFO("SII9234B", 0x92>>1),
802 I2C_BOARD_INFO("SII9234C", 0xC8>>1),
807 #define GPIO_NFC_SCL_1_8V S5PV310_GPY0(0)
808 #define GPIO_NFC_SDA_1_8V S5PV310_GPY0(1)
809 #define GPIO_NFC_IRQ S5PV310_GPX1(7)
810 #define GPIO_NFC_EN S5PV310_GPL2(6)
811 #define GPIO_NFC_FIRMWARE S5PV310_GPL2(7)
813 /* GPIO_LEVEL_NONE = 2, GPIO_LEVEL_LOW = 0 */
814 static unsigned int nfc_gpio_table[][4] = {
815 {GPIO_NFC_IRQ, S3C_GPIO_INPUT, 2, S3C_GPIO_PULL_DOWN},
816 {GPIO_NFC_EN, S3C_GPIO_OUTPUT, 0, S3C_GPIO_PULL_NONE},
817 {GPIO_NFC_FIRMWARE, S3C_GPIO_OUTPUT, 0, S3C_GPIO_PULL_NONE},
818 {GPIO_NFC_SCL_1_8V, S3C_GPIO_INPUT, 2, S3C_GPIO_PULL_NONE},
819 {GPIO_NFC_SDA_1_8V, S3C_GPIO_INPUT, 2, S3C_GPIO_PULL_NONE},
822 void u1hd_nfc_setup_gpio(void)
824 int array_size = ARRAY_SIZE(nfc_gpio_table);
826 for (i = 0; i < array_size; i++) {
827 gpio = nfc_gpio_table[i][0];
828 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(nfc_gpio_table[i][1]));
829 s3c_gpio_setpull(gpio, nfc_gpio_table[i][3]);
830 if (nfc_gpio_table[i][2] != 2)
831 gpio_set_value(gpio, nfc_gpio_table[i][2]);
835 static struct i2c_gpio_platform_data i2c16_gpio_data = {
836 .sda_pin = GPIO_NFC_SDA_1_8V,
837 .scl_pin = GPIO_NFC_SCL_1_8V,
841 static struct platform_device i2c16_gpio = {
845 .platform_data = &i2c16_gpio_data,
850 static struct pn544_i2c_platform_data pn544_pdata = {
851 .irq_gpio = GPIO_NFC_IRQ,
852 .ven_gpio = GPIO_NFC_EN,
853 .firm_gpio = GPIO_NFC_FIRMWARE,
857 static struct i2c_board_info i2c16_devs[] __initdata = {
859 I2C_BOARD_INFO("pn544", 0x2b),
860 .platform_data = &pn544_pdata,
867 #if defined(CONFIG_VIDEO_S5K5BAFX)
868 #define VT_CAM_SDA_18V S5PV310_GPC1(0)
869 #define VT_CAM_SCL_18V S5PV310_GPC1(2)
871 static struct i2c_gpio_platform_data i2c17_platdata = {
872 .sda_pin = VT_CAM_SDA_18V,
873 .scl_pin = VT_CAM_SCL_18V,
875 .sda_is_open_drain = 0,
876 .scl_is_open_drain = 0,
877 .scl_is_output_only = 0,
880 static struct platform_device s3c_device_i2c17 = {
883 .dev.platform_data = &i2c17_platdata,
886 static struct i2c_board_info i2c17_devs[] __initdata = {
888 I2C_BOARD_INFO("s5k5bafx", (0x5A >> 1)),
895 #define GPIO_FM_SDA_28V S5PV310_GPB(2)
896 #define GPIO_FM_SCL_28V S5PV310_GPB(3)
898 static struct i2c_gpio_platform_data i2c18_gpio_data = {
899 .sda_pin = GPIO_FM_SDA_28V,
900 .scl_pin = GPIO_FM_SCL_28V,
903 static struct platform_device i2c18_gpio = {
907 .platform_data = &i2c18_gpio_data,
911 static struct i2c_board_info i2c18_devs[] __initdata = {
913 I2C_BOARD_INFO("si470x", (0x20 >> 1)),
919 static struct s5p_usb_ehci_platdata u1hd_usb_ehci_pdata;
921 static void __init u1hd_usb_ehci_init(void)
923 struct s5p_usb_ehci_platdata *pdata = &u1hd_usb_ehci_pdata;
925 /* The gpios is initialized from modem_init */
926 pdata->gpio_active = MOBILE_GPIO(ACTIVE_STATE_HSIC);
928 s5p_usb_ehci_set_platdata(pdata);
932 /* we don't use OTGDRVVBUS pin for powering up otg charging pump */
933 static void u1hd_otg_power_cb(int enable)
936 u8 on = (u8)!!enable;
937 gpio = MOBILE_GPIO(USB_OTG_EN);
938 gpio_request(gpio, "USB_OTG_EN");
939 gpio_direction_output(gpio, on);
941 pr_info("%s: otg power = %d\n", __func__, on);
944 static void __init u1hd_usb_otg_init(void)
946 struct host_notify_dev *u1hd_otg_ndev =
947 dev_get_platdata(&s3c_device_usbgadget.dev);
948 struct sec_otghost_data *u1hd_otg_host_data =
949 dev_get_platdata(&s3c_device_usb_otghcd.dev);
951 u1hd_otg_ndev->set_booster = u1hd_otg_power_cb;
952 u1hd_otg_host_data->set_pwr_cb = u1hd_otg_power_cb;
956 static struct platform_device u1hd_modem_net = {
961 /* XMM6260 control */
962 static struct xmm6260_gpios u1hd_xmm6260_gpios;
964 static struct xmm6260_platform_data u1hd_xmm6260_pdata = {
965 .gpios = &u1hd_xmm6260_gpios,
970 * SLP uses standardized device name of modemctl
971 * and this is same to Android.
973 static struct platform_device u1hd_xmm6260 = {
977 .platform_data = &u1hd_xmm6260_pdata,
981 static void __init u1hd_modem_init(void)
983 struct xmm6260_gpios *gpios = &u1hd_xmm6260_gpios;
986 gpio = MOBILE_GPIO(CP_ON);
987 gpio_request(gpio, "CP_ON");
988 gpio_direction_output(gpio, 0);
991 gpio = MOBILE_GPIO(PHONE_ACTIVE);
992 gpio_request(gpio, "PHONE_ACTIVE");
993 gpios->phone_active = gpio;
995 gpio = MOBILE_GPIO(PDA_ACTIVE);
996 gpio_request(gpio, "PDA_ACTIVE");
997 gpio_direction_output(gpio, 0);
998 gpios->pda_active = gpio;
1000 gpio = MOBILE_GPIO(CP_DUMP_INT);
1001 gpio_request(gpio, "CP_DUMP_INT");
1002 gpios->cp_dump_int = gpio;
1004 gpio = MOBILE_GPIO(CP_PMU_RST);
1005 gpio_request(gpio, "CP_PMU_RST");
1006 gpio_direction_output(gpio, 0);
1007 gpios->cp_pmu_rst = gpio;
1009 gpio = MOBILE_GPIO(RESET_REQ_N);
1010 gpio_request(gpio, "RESET_REQ_N");
1011 gpio_direction_output(gpio, 0);
1012 gpios->reset_req_n = gpio;
1014 gpio = MOBILE_GPIO(IPC_SLAVE_WAKEUP);
1015 gpio_request(gpio, "IPC_SLAVE_WAKEUP");
1016 gpio_direction_output(gpio, 0);
1017 gpios->ipc_slave_wakeup = gpio;
1019 gpio = MOBILE_GPIO(IPC_HOST_WAKEUP);
1020 gpio_request(gpio, "IPC_HOST_WAKEUP");
1021 gpios->ipc_host_wakeup = gpio;
1023 gpio = MOBILE_GPIO(SUSPEND_REQUEST_HSIC);
1024 gpio_request(gpio, "SUSPEND_REQUEST_HSIC");
1025 gpios->suspend_request_hsic = gpio;
1027 gpio = MOBILE_GPIO(ACTIVE_STATE_HSIC);
1028 gpio_request(gpio, "ACTIVE_STATE_HSIC");
1029 gpio_direction_output(gpio, 0);
1030 gpios->active_state_hsic = gpio;
1034 static void u1hd_set_uart_switch(int path)
1038 gpio = MOBILE_GPIO(UART_SEL);
1039 gpio_request(gpio, "UART_SEL");
1041 /* u1hd target is gpio_high == AP */
1042 if (path == UART_SW_PATH_AP)
1043 gpio_set_value(gpio, GPIO_LEVEL_HIGH);
1044 else if (path == UART_SW_PATH_CP)
1045 gpio_set_value(gpio, GPIO_LEVEL_LOW);
1051 static int u1hd_get_uart_switch(void)
1056 gpio = MOBILE_GPIO(UART_SEL);
1057 gpio_request(gpio, "UART_SEL");
1058 val = gpio_get_value(gpio);
1061 /* u1hd target is gpio_high == AP */
1062 if (val == GPIO_LEVEL_HIGH)
1063 return UART_SW_PATH_AP;
1064 else if (val == GPIO_LEVEL_LOW)
1065 return UART_SW_PATH_CP;
1067 return UART_SW_PATH_NA;
1070 static struct uart_select_platform_data u1hd_uart_select_data = {
1071 .set_uart_switch = u1hd_set_uart_switch,
1072 .get_uart_switch = u1hd_get_uart_switch,
1075 static struct platform_device u1hd_uart_select = {
1076 .name = "uart-select",
1079 .platform_data = &u1hd_uart_select_data,
1083 static struct regulator_consumer_supply emmc_supplies[] = {
1084 REGULATOR_SUPPLY("vmmc", "s3c-sdhci.0"),
1085 REGULATOR_SUPPLY("vmmc", "dw_mmc"),
1088 static struct regulator_init_data emmc_fixed_voltage_init_data = {
1090 .name = "VMEM_VDD_2.8V",
1091 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
1093 .num_consumer_supplies = ARRAY_SIZE(emmc_supplies),
1094 .consumer_supplies = emmc_supplies,
1097 static struct fixed_voltage_config emmc_fixed_voltage_config = {
1098 .supply_name = "eMMC_EN",
1099 .microvolts = 2800000,
1100 .gpio = S5PV310_GPK0(2),
1101 .enable_high = true,
1102 .init_data = &emmc_fixed_voltage_init_data,
1105 static struct platform_device emmc_fixed_voltage = {
1106 .name = "reg-fixed-voltage",
1107 .id = FIXED_REG_ID_MMC,
1109 .platform_data = &emmc_fixed_voltage_config,
1116 /* GSD4T GPS module */
1117 static struct gsd4t_platform_data u1hd_gsd4t_data = {
1118 .onoff = S5PV310_GPE0(3),
1119 .nrst = S5PV310_GPE0(4),
1120 .tsync = S5PV310_GPE0(1),
1121 .uart_rxd = S5PV310_GPA0(4),
1122 .uart_txd = S5PV310_GPA0(5),
1123 .uart_cts = S5PV310_GPA0(6),
1124 .uart_rts = S5PV310_GPA0(7),
1127 static struct platform_device u1hd_gsd4t = {
1131 .platform_data = &u1hd_gsd4t_data,
1137 #ifdef CONFIG_DRM_MALI
1138 static struct platform_device s5p_device_mali_drm = {
1145 #ifdef CONFIG_DRM_FIMD
1146 static struct resource fimd_drm_resource[] = {
1148 .start = S5P_PA_LCD0,
1149 .end = S5P_PA_LCD0 + S5P_SZ_LCD0 - 1,
1150 .flags = IORESOURCE_MEM,
1153 .start = S5P_PA_LCD1,
1154 .end = S5P_PA_LCD1 + S5P_SZ_LCD1 - 1,
1155 .flags = IORESOURCE_MEM,
1160 .flags = IORESOURCE_IRQ,
1165 .flags = IORESOURCE_IRQ,
1169 static struct fimd_drm_platform_data fimd_drm_pd = {
1173 static struct platform_device s5p_device_fimd_drm = {
1176 .num_resources = ARRAY_SIZE(fimd_drm_resource),
1177 .resource = fimd_drm_resource,
1179 .platform_data = &fimd_drm_pd,
1185 static struct s3c_adc_platform_data s3c_adc_pdata __initdata = {
1189 .max_adc_voltage_uV = 3300000,
1192 static void __init u1hd_adc_init(void)
1194 s3c_adc_set_platdata(&s3c_adc_pdata);
1197 static void ramoops_enable(int enable)
1201 clk = clk_get(NULL, "modem");
1209 static struct ramoops_platform_data u1hd_ramoops_data = {
1210 .mem_address = 0x13A00000, /* MODEM I/F */
1212 .enable = ramoops_enable,
1215 static struct platform_device u1hd_ramoops = {
1218 .platform_data = &u1hd_ramoops_data,
1223 static struct platform_device u1hd_tzpc = {
1228 #ifdef CONFIG_ANDROID_RAM_CONSOLE
1229 static struct resource ram_console_resource[] = {
1231 .flags = IORESOURCE_MEM,
1235 static struct platform_device ram_console_device = {
1236 .name = "ram_console",
1238 .num_resources = ARRAY_SIZE(ram_console_resource),
1239 .resource = ram_console_resource,
1243 static void __init u1hd_map_io(void)
1245 s5p_init_io(NULL, 0, S5P_VA_CHIPID);
1246 s5p_xtal_set_parent(CLK_XUSBXTI);
1247 s3c24xx_init_clocks(24000000);
1248 s3c24xx_init_uarts(u1hd_uartcfgs, ARRAY_SIZE(u1hd_uartcfgs));
1251 static unsigned long fbmem_start, fbmem_size;
1252 static int __init early_fbmem(char *p)
1259 fbmem_size = memparse(p, &endp);
1261 fbmem_start = memparse(endp + 1, &endp);
1263 return endp > p ? 0 : -EINVAL;
1265 early_param("fbmem", early_fbmem);
1267 static struct cma_region regions[] = {
1268 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMD0
1271 .size = (CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMD0
1272 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMD1
1273 + CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMD1
1278 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC0
1281 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC0 * SZ_1K,
1285 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC1
1288 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC1 * SZ_1K,
1292 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC2
1295 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC2 * SZ_1K,
1299 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC3
1302 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC3 * SZ_1K,
1307 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_S3C_MEM_CMA
1309 .name = "s3c-mem-cma",
1310 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_S3C_MEM_CMA * SZ_1K,
1315 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_JPEG
1318 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_JPEG * SZ_1K,
1321 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC
1324 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC * SZ_1K,
1327 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC0
1330 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC0 * SZ_1K,
1332 .alignment = 1 << 17,
1336 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC1
1339 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC1 * SZ_1K,
1341 .alignment = 1 << 17,
1345 #ifdef CONFIG_VIDEO_SAMSUNG_S5P_TV
1351 #ifdef CONFIG_VIDEO_SAMSUNG_S5P_MFC
1355 { .alignment = 128 << 10 },
1356 .start = 0x42000000,
1361 .start = 0x43000000,
1366 .start = 0x51000000,
1369 #ifdef CONFIG_SEC_DEBUG
1373 .start = 0x40003000,
1379 static void __init s5pv310_reserve(void)
1381 static const char map[] __initconst =
1383 #ifdef CONFIG_VIDEO_FIMC
1389 #ifdef CONFIG_S3C_MEM_CMA_ALLOC
1390 "s3c-mem=s3c-mem-cma;"
1394 #ifdef CONFIG_SEC_DEBUG
1395 "s3c-getlog=getlog;"
1398 #if defined(CONFIG_VIDEO_SAMSUNG_S5P_MFC)
1399 "mfc=mfc,mfc0,mfc1;"
1400 "s5p-mfc/f=fw;s5p-mfc/a=b1;s5p-mfc/b=b2;"
1402 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_PROFILING
1403 "s3c-mfc/mfc=mfc;s3c-mfc/mfc0=mfc0;s3c-mfc/mfc1=mfc1;"
1405 "s3c-mfc=mfc,mfc0,mfc1;"
1412 #ifdef CONFIG_ANDROID_RAM_CONSOLE
1415 /* FIXME: ram console MUST be reserved at first time */
1416 addr = memblock_alloc_base(SZ_1M, SZ_4K, 0x60000000);
1417 ram_console_resource[0].start = addr;
1418 ram_console_resource[0].end = addr + SZ_1M - 1;
1419 pr_info("ram_console: 0x%08x ~ 0x%08x (1MB)\n",
1420 addr, addr + SZ_1M);
1424 regions[0].start = (dma_addr_t)fbmem_start;
1426 regions[0].size = (size_t)fbmem_size;
1428 cma_set_defaults(regions, map);
1429 cma_early_regions_reserve(NULL);
1431 for (; i < ARRAY_SIZE(regions) - 1 /* terminator */; ++i) {
1432 pr_info("cma: region: %-8s: 0x%08x ~ 0x%08x (%dMB)\n",
1433 regions[i].name, regions[i].start,
1434 regions[i].start + regions[i].size,
1435 regions[i].size / SZ_1M);
1439 #ifdef CONFIG_HIBERNATION
1440 static int __init u1hd_set_nosave_regions(void)
1444 for ( i = ARRAY_SIZE(regions) - 2; i >= 0 /* terminator */; i--) {
1445 /* MFC firmware SHOULD BE saved.
1446 * If the region is fw, don't register to nosave regions */
1447 if (strcmp(regions[i].name, "fw"))
1448 register_nosave_region_late(
1449 __phys_to_pfn(regions[i].start),
1450 __phys_to_pfn(regions[i].start +
1455 late_initcall(u1hd_set_nosave_regions);
1459 * GPX are saved and restored at plat-samsung/pm.c:s5c_pm_enter.
1460 * However, they are inside of pm_prepare and pm_finish, so it
1461 * does not save ours against universal_pm_prepare:2.
1463 static struct sleep_save s5pc210_gpx[] = {
1464 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C00),
1465 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C04),
1466 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C08),
1467 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C0C),
1468 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C20),
1469 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C24),
1470 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C28),
1471 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C2C),
1472 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C40),
1473 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C44),
1474 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C48),
1475 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C4C),
1476 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C60),
1477 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C64),
1478 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C68),
1479 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C6C),
1483 static struct gpio_keys_button u1hd_gpio_keys_tables[] = {
1485 .code = KEY_VOLUMEUP,
1486 .gpio = S5PV310_GPX2(0), /* XEINT16 */
1487 .desc = "gpio-keys: KEY_VOLUMEUP",
1490 .debounce_interval = 1,
1491 /* YUBAEK 20110905 RAMDUMP_DEBUG : Android forceable ramdump ++ */
1492 #ifdef CONFIG_INPUT_FORCE_PANIC_KEY
1493 .isr_hook = sec_debug_check_crash_key , /* VOL UP */
1495 /* YUBAEK 20110905 RAMDUMP_DEBUG : Android forceable ramdump -- */
1498 .code = KEY_VOLUMEDOWN,
1499 .gpio = S5PV310_GPX2(1), /* XEINT17 */
1500 .desc = "gpio-keys: KEY_VOLUMEDOWN",
1503 .debounce_interval = 1,
1504 /* YUBAEK 20110905 RAMDUMP_DEBUG : Android forceable ramdump ++ */
1505 #ifdef CONFIG_INPUT_FORCE_PANIC_KEY
1506 .isr_hook = sec_debug_check_crash_key , /*VOL DOWN */
1508 /* YUBAEK 20110905 RAMDUMP_DEBUG : Android forceable ramdump -- */
1512 .gpio = S5PV310_GPX2(7), /* XEINT23 */
1513 .desc = "gpio-keys: KEY_POWER",
1517 .debounce_interval = 1,
1519 /* KEY_MENU will be used */
1520 .code = KEY_MENU, /* KEY_OK */
1521 .gpio = S5PV310_GPX3(5), /* XEINT29 */
1522 .desc = "gpio-keys: KEY_MENU",
1526 .debounce_interval = 1,
1527 /* YUBAEK 20110905 RAMDUMP_DEBUG : Android forceable ramdump ++ */
1528 #ifdef CONFIG_INPUT_FORCE_PANIC_KEY
1529 .isr_hook = sec_debug_check_crash_key , /* HOME */
1531 /* YUBAEK 20110905 RAMDUMP_DEBUG : Android forceable ramdump -- */
1536 static struct gpio_keys_platform_data u1hd_gpio_keys_data = {
1537 .buttons = u1hd_gpio_keys_tables,
1538 .nbuttons = ARRAY_SIZE(u1hd_gpio_keys_tables),
1541 static struct platform_device u1hd_gpio_keys = {
1542 .name = "gpio-keys",
1544 .platform_data = &u1hd_gpio_keys_data,
1547 /* s6e8aa0 panel. */
1548 static struct s3cfb_lcd s6e8aa0 = {
1556 .dynamic_refresh = 1,
1566 .cmd_allow_len = 0xf,
1576 static int lcd_power_on(struct lcd_device *ld, int enable)
1578 static struct regulator *r_22, *r_33;
1579 static DEFINE_MUTEX(lock);
1582 dev_info(&ld->dev, "enable=%d\n", enable);
1587 r_22 = regulator_get_exclusive(&ld->dev, "vlcd_2.2v");
1588 if (IS_ERR_OR_NULL(r_22)) {
1595 r_33 = regulator_get_exclusive(&ld->dev, "vcc_3.0v_lcd");
1596 if (IS_ERR_OR_NULL(r_33)) {
1602 /* These are exclusively got regulators. use is_enabled */
1603 if (enable && regulator_is_enabled(r_22) == 0)
1604 regulator_enable(r_22);
1605 if (enable && regulator_is_enabled(r_33) == 0)
1606 regulator_enable(r_33);
1607 if (!enable && regulator_is_enabled(r_22))
1608 regulator_disable(r_22);
1609 if (!enable && regulator_is_enabled(r_33))
1610 regulator_disable(r_33);
1612 /* reset pull_down */
1614 int reset_gpio = -1;
1615 reset_gpio = S5PV310_GPY4(5);
1616 gpio_direction_output(reset_gpio, 0);
1617 dev_info(&ld->dev, "reset LOW completed.\n");
1621 mutex_unlock(&lock);
1625 static int reset_lcd(struct lcd_device *ld)
1627 static unsigned int first = 1;
1628 int reset_gpio = -1;
1630 reset_gpio = S5PV310_GPY4(5);
1633 gpio_request(reset_gpio, "MLCD_RST");
1637 gpio_direction_output(reset_gpio, 1);
1638 usleep_range(1000, 2000);
1639 gpio_direction_output(reset_gpio, 0);
1640 usleep_range(1000, 2000);
1641 gpio_direction_output(reset_gpio, 1);
1642 dev_info(&ld->dev, "reset HIGH completed.\n");
1647 int s5p_mipi_dphy_power(struct platform_device *pdev, unsigned int enable)
1649 static struct regulator *p_mipi_1_1v, *p_mipi_1_8v;
1650 static DEFINE_MUTEX(lock);
1651 static bool enabled;
1654 dev_info(&pdev->dev, "enable = %d\n", enable);
1658 if (enabled == !!enable)
1661 if (p_mipi_1_1v == NULL)
1662 p_mipi_1_1v = regulator_get(&pdev->dev, "mipi_1.1v_c210");
1663 if (IS_ERR_OR_NULL(p_mipi_1_1v)) {
1666 dev_err(&pdev->dev, "failed to get regulator.\n");
1670 if (p_mipi_1_8v == NULL)
1671 p_mipi_1_8v = regulator_get(&pdev->dev, "vmipi_1.8v");
1672 if (IS_ERR_OR_NULL(p_mipi_1_8v)) {
1675 dev_err(&pdev->dev, "failed to get regulator.\n");
1680 ret = regulator_enable(p_mipi_1_1v);
1683 ret = regulator_enable(p_mipi_1_8v);
1687 ret = regulator_disable(p_mipi_1_1v);
1690 ret = regulator_disable(p_mipi_1_8v);
1697 mutex_unlock(&lock);
1701 static struct mipi_dsim_config dsim_config = {
1702 .e_interface = DSIM_VIDEO,
1703 .e_virtual_ch = DSIM_VIRTUAL_CH_0,
1704 .e_pixel_format = DSIM_24BPP_888,
1705 .e_burst_mode = DSIM_BURST_SYNC_EVENT,
1706 .e_no_data_lane = DSIM_DATA_LANE_4,
1707 .e_byte_clk = DSIM_PLL_OUT_DIV8,
1710 * ===========================================
1711 * | P | M | S | MHz |
1712 * -------------------------------------------
1713 * | 3 | 100 | 3 | 100 |
1714 * | 3 | 100 | 2 | 200 |
1715 * | 3 | 63 | 1 | 252 |
1716 * | 4 | 100 | 1 | 300 |
1717 * | 4 | 110 | 1 | 330 |
1718 * | 12 | 350 | 1 | 350 |
1719 * | 3 | 100 | 1 | 400 |
1720 * | 4 | 150 | 1 | 450 |
1721 * | 3 | 120 | 1 | 480 |
1722 * | 12 | 250 | 0 | 500 |
1723 * | 4 | 100 | 0 | 600 |
1724 * | 3 | 81 | 0 | 648 |
1725 * | 3 | 88 | 0 | 704 |
1726 * | 3 | 90 | 0 | 720 |
1727 * | 3 | 100 | 0 | 800 |
1728 * | 12 | 425 | 0 | 850 |
1729 * | 4 | 150 | 0 | 900 |
1730 * | 12 | 475 | 0 | 950 |
1731 * | 6 | 250 | 0 | 1000 |
1732 * -------------------------------------------
1739 /* D-PHY PLL stable time spec :min = 200usec ~ max 400usec */
1740 .pll_stable_time = 500,
1742 /* escape clk : 10MHz */
1743 .esc_clk = 10 * 1000000,
1745 /* stop state holding counter after bta change count 0 ~ 0xfff */
1746 .stop_holding_cnt = 0x7ff,
1747 /* bta timeout 0 ~ 0xff */
1748 .bta_timeout = 0xff,
1749 /* lp rx timeout 0 ~ 0xffff */
1750 .rx_timeout = 0xffff,
1753 static struct s5p_platform_mipi_dsim dsim_platform_data = {
1756 .phy_enable = s5p_dsim_phy_enable,
1757 .dsim_config = &dsim_config,
1760 static struct lcd_platform_data s6e8aa0_pd = {
1762 .power_on = lcd_power_on,
1764 .power_off_delay = 120,
1765 .power_on_delay = 120,
1768 static struct mipi_dsim_lcd_device mipi_lcd_device = {
1770 .panel_id = "ams465gs01", /* U1HD */
1774 .platform_data = (void *)&s6e8aa0_pd,
1777 #ifdef CONFIG_VIDEO_FIMG2D
1778 static struct fimg2d_platdata fimg2d_data __initdata = {
1780 .parent_clkname = "mout_g2d0",
1781 .clkname = "sclk_fimg2d",
1782 .gate_clkname = "fimg2d",
1783 .smmu_gate_clkname = "smmu_fimg2d",
1784 .clkrate = 250 * 1000000,
1788 static struct s3c_platform_fb fb_platform_data __initdata = {
1791 #ifdef CONFIG_FB_S3C_DEFAULT_WINDOW
1792 .default_win = CONFIG_FB_S3C_DEFAULT_WINDOW,
1796 .swap = FB_SWAP_HWORD | FB_SWAP_WORD,
1799 #ifdef CONFIG_FB_S3C_HIBERNATION_LOADING
1800 #include <linux/hib_ani.h> /* FIXME:!! hib_ani_hd.h */
1802 static struct s3cfb_hib_ani hib_ani_set __initdata = {
1824 .hib_animation = hib_anis, /* FIXME:!! hib_anis_hd */
1830 static void __init u1hd_fb_init(void)
1832 struct device *dev = s3c_device_fb.dev.parent;
1833 struct samsung_pd_info *pdinfo;
1834 struct s5p_platform_mipi_dsim *dsim_pd;
1837 pdinfo = (struct samsung_pd_info *)dev->platform_data;
1838 /* fimd driver have to know LCD domain power status. */
1840 fb_platform_data.boot_on = pdinfo->boot_on;
1844 fb_platform_data.logo_on = 1;
1846 s5p_device_mipi_dsim0.dev.platform_data = (void *)&dsim_platform_data;
1847 dsim_pd = (struct s5p_platform_mipi_dsim *)&dsim_platform_data;
1849 strcpy(dsim_pd->lcd_panel_name, "s6e8aa0");
1850 dsim_pd->mipi_power = s5p_mipi_dphy_power;
1851 dsim_pd->lcd_panel_info = &s6e8aa0;
1852 s5p_mipi_dsi_register_lcd_device(&mipi_lcd_device);
1853 platform_device_register(&s5p_device_mipi_dsim0);
1855 s5p_device_mipi_dsim0.dev.parent = &s5pv310_device_pd[PD_LCD0].dev;
1857 #ifdef CONFIG_FB_S3C_HIBERNATION_LOADING
1858 fb_platform_data.hib_ani = (void *)&hib_ani_set;
1860 fb_platform_data.lcd_data = (struct s3cfb_lcd *)&s6e8aa0;
1861 s3cfb_set_platdata(&fb_platform_data);
1863 s3cfb_cfg_gpio(NULL);
1866 /* YUBAEK 20110905 RAMDUMP_DEBUG : GPIO Dump ++ */
1867 #ifdef CONFIG_SEC_DEBUG_PERIPHERAL_DUMP_GPIO
1868 void __iomem *s5pv310_gpio_class_a_addr;
1869 void __iomem *s5pv310_gpio_class_b_addr;
1870 static void s5pv310_gpio_io_map(void)
1872 s5pv310_gpio_class_a_addr = ioremap(S5PV310_PA_GPIO1, SZ_4K);
1873 s5pv310_gpio_class_b_addr = ioremap(S5PV310_PA_GPIO2, SZ_4K);
1875 #endif /* CONFIG_SEC_DEBUG_PERIPHERAL_DUMP_GPIO */
1876 /* YUBAEK 20110905 RAMDUMP_DEBUG : GPIO Dump -- */
1879 static struct jack_platform_data u1hd_jack_data = {
1881 .charger_online = 0,
1883 .earjack_online = 0,
1890 static struct platform_device u1hd_jack = {
1894 .platform_data = &u1hd_jack_data,
1898 //device dependent regulator feature
1900 //============================================================
1902 //============================================================
1903 static struct regulator_consumer_supply fmradio_supplies[] = {
1909 static struct regulator_init_data fmradio_fixed_voltage_init_data = {
1911 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
1913 .num_consumer_supplies = ARRAY_SIZE(fmradio_supplies),
1914 .consumer_supplies = fmradio_supplies,
1916 #define GPIO_FM_RST S5PV310_GPB(0)
1917 static struct fixed_voltage_config fmradio_fixed_voltage_config = {
1918 .supply_name = "FM_RST",
1919 .microvolts = 2800000,
1920 .gpio = GPIO_FM_RST,
1921 .enable_high = true,
1922 .init_data = &fmradio_fixed_voltage_init_data,
1925 static struct platform_device fmradio_fixed_voltage = {
1926 .name = "reg-fixed-voltage",
1927 .id = FIXED_REG_ID_RADIO,
1929 .platform_data = &fmradio_fixed_voltage_config,
1933 static void u1hd_sec_switch_init(void)
1935 sec_class = class_create(THIS_MODULE, "sec");
1937 if (IS_ERR(sec_class))
1938 pr_err("Failed to create class(sec)!\n");
1940 switch_dev = device_create(sec_class, NULL, 0, NULL, "switch");
1942 if (IS_ERR(switch_dev))
1943 pr_err("Failed to create device(switch)!\n");
1945 // ret = device_create_file(switch_dev, &dev_attr_disable_vbus);
1947 // pr_err("Failed to create device file(disable_vbus)!\n");
1949 #ifdef CONFIG_TARGET_LOCALE_KOR
1950 usb_lock = device_create(sec_class, switch_dev,
1951 MKDEV(0, 0), NULL, ".usb_lock");
1953 if (IS_ERR(usb_lock)) {
1954 pr_err("Failed to create device (usb_lock)!\n");
1958 if (device_create_file(usb_lock, &dev_attr_enable) < 0)
1959 pr_err("Failed to create device file(.usblock/enable)!\n");
1963 static struct u1hd_charging_status_callbacks {
1964 void (*tsp_set_charging_cable) (int type);
1967 static bool is_cable_attached;
1969 static int u1hd_charger_cb(cable_type_t cable_type)
1971 union power_supply_propval value;
1974 switch(cable_type) {
1975 case CABLE_TYPE_NONE:
1976 case CABLE_TYPE_OTG:
1977 case CABLE_TYPE_JIG_UART_OFF:
1978 value.intval = POWER_SUPPLY_TYPE_BATTERY;
1979 is_cable_attached = false;
1981 case CABLE_TYPE_USB:
1982 case CABLE_TYPE_JIG_USB_OFF:
1983 case CABLE_TYPE_JIG_USB_ON:
1984 value.intval = POWER_SUPPLY_TYPE_USB;
1985 is_cable_attached = true;
1987 case CABLE_TYPE_DESKDOCK:
1988 case CABLE_TYPE_CARDOCK:
1989 value.intval = POWER_SUPPLY_TYPE_DOCK;
1990 is_cable_attached = true;
1993 case CABLE_TYPE_JIG_UART_OFF_VB:
1994 value.intval = POWER_SUPPLY_TYPE_MAINS;
1995 is_cable_attached = true;
1998 pr_err("%s: invalid type:%d\n", __func__, cable_type);
2002 if (charging_cbs.tsp_set_charging_cable)
2003 charging_cbs.tsp_set_charging_cable(value.intval);
2005 #ifdef CONFIG_JACK_MON
2006 jack_event_handler("charger", is_cable_attached);
2012 static struct regulator *regulator_vbus_ap;
2013 static bool ap_enabled;
2014 static DEFINE_MUTEX(usb_ap_lock);
2016 static void u1hd_usb_cb(u8 usb_mode)
2019 struct s3c_udc *udc = platform_get_drvdata(&s3c_device_usbgadget);
2020 struct sec_otghost_data *otg_data =
2021 dev_get_platdata(&s3c_device_usb_otghcd.dev);
2023 unsigned long inform6 = __raw_readl(S5P_INFORM6);
2025 pr_info("%s: usb mode=%d, inform6=0x%08lx\n", __func__, usb_mode, inform6);
2027 if (inform6 & RST_FLAG_CHARGE_REBOOT_CHECK ) {
2028 pr_info("%s: lpcharging: disable USB\n", __func__);
2029 ret = udc->change_usb_mode(USB_CABLE_DETACHED);
2031 pr_warn("%s: fail to change mode!!!\n", __func__);
2033 mutex_lock(&usb_ap_lock);
2035 if (regulator_vbus_ap == NULL)
2037 regulator_get_exclusive(NULL, "usb_vbus_ap_5v");
2038 if (IS_ERR_OR_NULL(regulator_vbus_ap)) {
2039 pr_err("%s: fail to get regulator\n", __func__);
2040 regulator_vbus_ap = NULL;
2045 ret = regulator_disable(regulator_vbus_ap);
2051 mutex_unlock(&usb_ap_lock);
2056 if (usb_mode == USB_OTGHOST_ATTACHED) {
2057 otg_data->set_pwr_cb(1);
2058 u1hd_charger_cb(CABLE_TYPE_OTG);
2061 pr_info("%s: prev_usb_mode=%d\n", __func__, udc->get_usb_mode());
2063 ret = udc->change_usb_mode(usb_mode);
2065 pr_err("%s: fail to change mode!!!\n", __func__);
2067 if (usb_mode == USB_OTGHOST_DETACHED)
2068 otg_data->set_pwr_cb(0);
2070 #ifdef CONFIG_JACK_MON
2071 if (usb_mode == USB_OTGHOST_ATTACHED)
2072 jack_event_handler("host", USB_CABLE_ATTACHED);
2073 else if (usb_mode == USB_OTGHOST_DETACHED)
2074 jack_event_handler("host", USB_CABLE_DETACHED);
2075 else if ((usb_mode == USB_CABLE_ATTACHED)
2076 || (usb_mode == USB_CABLE_DETACHED))
2077 jack_event_handler("usb", usb_mode);
2085 #if defined(CONFIG_TOUCHSCREEN_MELFAS)
2086 static int melfas_power(int on)
2091 gpio = MOBILE_GPIO(TSP_LDO_ON);
2092 gpio_request(gpio, "TSP_LDO_ON");
2093 s3c_gpio_cfgpin(gpio, S3C_GPIO_OUTPUT);
2094 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
2095 gpio_set_value(gpio, GPIO_LEVEL_HIGH);
2098 gpio = MOBILE_GPIO(TSP_INT);
2099 gpio_request(gpio, "TSP_INT");
2100 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
2101 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
2103 regulator = regulator_get(NULL, "touch");
2104 if (IS_ERR(regulator))
2106 regulator_enable(regulator);
2107 regulator_put(regulator);
2109 printk(KERN_INFO "[TSP]melfas power on\n");
2112 gpio = MOBILE_GPIO(TSP_INT);
2113 gpio_request(gpio, "TSP_INT");
2114 s3c_gpio_cfgpin(gpio, S3C_GPIO_INPUT);
2115 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_DOWN);
2117 gpio = MOBILE_GPIO(TSP_LDO_ON);
2118 gpio_request(gpio, "TSP_LDO_ON");
2119 s3c_gpio_cfgpin(gpio, S3C_GPIO_OUTPUT);
2120 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
2121 gpio_set_value(gpio, GPIO_LEVEL_LOW);
2123 regulator = regulator_get(NULL, "touch");
2124 if (IS_ERR(regulator))
2126 if (regulator_is_enabled(regulator))
2127 regulator_force_disable(regulator);
2128 regulator_put(regulator);
2134 static int __init melfas_change_pin(int value)
2139 gpio = MOBILE_GPIO(TSP_SDA);
2140 gpio_request(gpio, "TSP_SDA");
2141 s3c_gpio_cfgpin(gpio, S3C_GPIO_OUTPUT);
2142 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
2144 gpio = MOBILE_GPIO(TSP_SCL);
2145 gpio_request(gpio, "TSP_SCL");
2146 s3c_gpio_cfgpin(gpio, S3C_GPIO_OUTPUT);
2147 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
2149 gpio = MOBILE_GPIO(TSP_SDA);
2150 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0x3));
2151 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
2154 gpio = MOBILE_GPIO(TSP_SCL);
2155 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0x3));
2156 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
2162 static struct melfas_tsi_platform_data melfas_pdata = {
2165 .power = melfas_power,
2167 /* For the faster user response */
2168 .input_event = user_input_response,
2169 .change_pin = melfas_change_pin,
2173 static struct i2c_board_info i2c3_devs[] __initdata = {
2175 #ifdef CONFIG_TOUCHSCREEN_MELFAS
2176 I2C_BOARD_INFO(MELFAS_TS_NAME, 0x48),
2177 .platform_data = &melfas_pdata,
2183 static void u1hd_power_off(void)
2185 char rst_mode = 'r';
2186 char *str_ptr = "reset\n";
2187 int poweroff_try = 0;
2190 printk(KERN_INFO "%s: u1hd power off\n", __func__);
2192 /* Check reboot charging */
2193 if (is_cable_attached || (poweroff_try >= 5)) {
2195 "%s: charger connected(%d) or power off failed(%d), reboot!\n",
2196 __func__, is_cable_attached, poweroff_try);
2200 arm_machine_restart(rst_mode, str_ptr);
2201 // arch_reset(0, 0);
2203 printk(KERN_INFO "%s: waiting for reboot.\n", __func__);
2207 /* wait for power button release */
2208 gpio = MOBILE_GPIO(nPOWER);
2209 gpio_request(gpio, "nPOWER");
2210 if (gpio_get_value(gpio)) {
2211 printk(KERN_INFO "%s: set PS_HOLD low.\n", __func__);
2213 * PS_HOLD Out/High -->
2214 * Low PS_HOLD_CONTROL, R/W, 0x1002_330C
2216 writel(readl(S5P_PS_HOLD_CONTROL) & 0xFFFFFEFF,
2217 S5P_PS_HOLD_CONTROL);
2221 /* when connected zig cable with power, we can't make PS_HOLD_CONTROL low.
2222 * we try power_off 5 times. then if it failed, do restart.
2225 "%s: Should not reach here! (poweroff_try:%d)\n",
2226 __func__, poweroff_try);
2229 /* if power button is not released, wait and check TA again */
2230 printk(KERN_INFO "%s: PowerButton is not released!.\n",
2236 static void __init u1hd_tsp_init(void)
2241 /* TSP_LDO_ON: XGNSS_QSIGN */
2242 gpio = MOBILE_GPIO(TSP_LDO_ON);
2243 gpio_request(gpio, "TSP_LDO_ON");
2244 gpio_direction_output(gpio, 1);
2245 gpio_export(gpio, 0);
2247 /* TSP_INT: XEINT[4] */
2248 gpio = MOBILE_GPIO(TSP_INT);
2249 gpio_request(gpio, "TSP_INT");
2250 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
2254 * Note that because TSP_LDO provides an external pull-up to TSP_INT,
2255 * the pull-up setting at GPE1(7) is useless and may be omitted in
2256 * order to reduce idle current. However, it probably needs some
2257 * sleep/delay from TSP_LDO_ON = true event because there could be
2258 * "ramp-up" delay. Before knowing this, let's just use PULL_UP here.
2260 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
2261 i2c3_devs[0].irq = gpio_to_irq(gpio);
2265 extern void MHL_On(bool on);
2266 static void max8997_muic_mhl_cb(int attached)
2268 pr_info("%s(%d)\n", __func__, attached);
2270 if (attached == MAX8997_MUIC_ATTACHED) {
2276 #ifdef CONFIG_JACK_MON
2277 jack_event_handler("hdmi", attached);
2281 static bool max8997_muic_is_mhl_attached(void)
2286 gpio = MOBILE_GPIO(MHL_SEL);
2287 gpio_request(gpio, "MHL_SEL");
2288 val = gpio_get_value(gpio);
2294 static int u1hd_set_safeout(int path)
2296 static struct regulator *regulator_vbus_cp;
2297 static bool cp_enabled;
2300 mutex_lock(&usb_ap_lock);
2302 if (regulator_vbus_ap == NULL)
2304 regulator_get_exclusive(NULL, "usb_vbus_ap_5v");
2305 if (IS_ERR_OR_NULL(regulator_vbus_ap)) {
2307 regulator_vbus_ap = NULL;
2311 if (regulator_vbus_cp == NULL)
2313 regulator_get_exclusive(NULL, "usb_vbus_cp_5v");
2314 if (IS_ERR_OR_NULL(regulator_vbus_cp)) {
2316 regulator_vbus_cp = NULL;
2320 if (path == CP_USB_MODE) {
2322 ret = regulator_disable(regulator_vbus_ap);
2329 if (!regulator_is_enabled(regulator_vbus_cp))
2330 ret = regulator_enable(regulator_vbus_cp);
2336 /* AP_USB_MODE || AUDIO_MODE */
2338 if (!regulator_is_enabled(regulator_vbus_ap))
2339 ret = regulator_enable(regulator_vbus_ap);
2346 ret = regulator_disable(regulator_vbus_cp);
2353 mutex_unlock(&usb_ap_lock);
2357 static struct switch_dev switch_dock = {
2361 static const char *switch_cable_names[] = {
2367 static struct switch_dev switch_usb = {
2368 .name = "switch-usb",
2369 .supported_cable = switch_cable_names,
2372 static void u1hd_deskdock_cb(bool attached)
2375 switch_set_state(&switch_dock, 1);
2377 switch_set_state(&switch_dock, 0);
2380 static void u1hd_cardock_cb(bool attached)
2383 switch_set_state(&switch_dock, 2);
2385 switch_set_state(&switch_dock, 0);
2388 static void u1hd_switch_dev_init(void)
2392 /* for CarDock, DeskDock */
2393 ret = switch_dev_register(&switch_dock);
2395 pr_err("Failed to register dock switch. %d\n", ret);
2397 ret = switch_dev_register(&switch_usb);
2399 pr_err("Failed to register switch-usb. %d\n", ret);
2402 static int u1hd_host_notify_cb(int enable)
2404 struct host_notify_dev * ndev = NULL;
2406 if (s3c_device_usbgadget.dev.platform_data)
2407 ndev = s3c_device_usbgadget.dev.platform_data;
2409 pr_err("%s: ndev is null.\n", __func__);
2413 ndev->booster = enable ? NOTIFY_POWER_ON : NOTIFY_POWER_OFF;
2414 pr_info("%s: mode %d, enable %d\n", __func__, ndev->mode, enable);
2418 struct max8997_muic_platform_data u1hd_muic_pdata = {
2419 .usb_cb = u1hd_usb_cb,
2420 .charger_cb = u1hd_charger_cb, /* done */
2421 .mhl_cb = max8997_muic_mhl_cb, /* done */
2422 .is_mhl_attached = max8997_muic_is_mhl_attached, /* done */
2423 .set_safeout = u1hd_set_safeout, /* done */
2424 .deskdock_cb = u1hd_deskdock_cb, /* done */
2425 .cardock_cb = u1hd_cardock_cb, /* done */
2426 .host_notify_cb = u1hd_host_notify_cb, /* done */
2427 .gpio_usb_sel = S5PV310_GPL0(6), /* done */
2428 .uart_path = -1, /* muic does not control uart path*/
2431 static void u1hd_set_usb_switch(int path)
2433 printk(KERN_INFO "set_usb_switch = [%d]\n",path);
2434 u1hd_muic_pdata.sw_path = path;
2437 static int u1hd_get_usb_switch(void)
2439 printk(KERN_INFO "get_usb_switch = [%d]\n",u1hd_muic_pdata.sw_path);
2440 return u1hd_muic_pdata.sw_path;
2443 /* Micro USB Switch */
2444 static struct micro_usb_switch_platform_data u1hd_usb_switch_data = {
2445 .set_usb_switch = u1hd_set_usb_switch,
2446 .get_usb_switch = u1hd_get_usb_switch,
2449 static struct platform_device u1hd_micro_usb_switch = {
2450 .name = "usb-switch",
2453 .platform_data = &u1hd_usb_switch_data,
2457 static void u1hd_pm_finish(void)
2459 /* Restore GPX conf */
2460 s3c_pm_do_restore(s5pc210_gpx, ARRAY_SIZE(s5pc210_gpx));
2463 static void u1hd_pm_prepare(void)
2465 /* 1. Save GPX conf */
2466 s3c_pm_do_save(s5pc210_gpx, ARRAY_SIZE(s5pc210_gpx));
2468 /* 2. Set GPX as Power Save Mode */
2470 /* 3. Debug: Look at the diff */
2471 mobile_gpios_groupx_difference();
2475 int u1hd_common_setup_clock(const char *sclk_name, const char *pclk_name,
2476 unsigned long rate, unsigned int rate_set)
2478 struct clk *sclk = NULL;
2479 struct clk *pclk = NULL;
2481 sclk = clk_get(NULL, sclk_name);
2483 printk(KERN_ERR "failed to get %s clock.\n", sclk_name);
2487 pclk = clk_get(NULL, pclk_name);
2489 printk(KERN_ERR "failed to get %s clock.\n", pclk_name);
2493 clk_set_parent(sclk, pclk);
2495 printk(KERN_INFO "set parent clock of %s to %s\n", sclk_name,
2503 clk_set_rate(sclk, rate);
2504 printk(KERN_INFO "set %s rate to %lu\n", sclk_name, rate);
2520 #ifdef CONFIG_S5PV310_DEV_PD
2521 static inline void powerdomain_boot_on(int pd)
2523 struct samsung_pd_info *pdinfo = (struct samsung_pd_info *)
2524 s5pv310_device_pd[pd].dev.platform_data;
2525 pdinfo->boot_on = true;
2529 #ifdef CONFIG_INPUT_SECBRIDGE
2530 //============================================================
2531 /* sec-input-bridge */
2532 //============================================================
2533 static const struct sec_input_bridge_mkey u1hd_rbdump_mkey_map[] = {
2534 { .type = EV_KEY , .code = KEY_VOLUMEUP },
2535 { .type = EV_KEY , .code = KEY_VOLUMEDOWN },
2536 { .type = EV_KEY , .code = KEY_MENU },
2537 { .type = EV_KEY , .code = KEY_MENU },
2538 { .type = EV_KEY , .code = KEY_VOLUMEUP },
2539 { .type = EV_KEY , .code = KEY_VOLUMEDOWN },
2540 { .type = EV_KEY , .code = KEY_VOLUMEUP },
2541 { .type = EV_KEY , .code = KEY_MENU },
2544 static const struct sec_input_bridge_mkey u1hd_default_mkey_map[] = {
2545 { .type = EV_KEY , .code = KEY_VOLUMEUP },
2546 { .type = EV_KEY , .code = KEY_VOLUMEDOWN },
2547 { .type = EV_KEY , .code = KEY_MENU },
2548 { .type = EV_KEY , .code = KEY_MENU },
2549 { .type = EV_KEY , .code = KEY_VOLUMEUP },
2550 { .type = EV_KEY , .code = KEY_VOLUMEUP },
2551 { .type = EV_KEY , .code = KEY_VOLUMEUP },
2552 { .type = EV_KEY , .code = KEY_MENU },
2555 static const struct sec_input_bridge_mkey u1hd_uart_mkey_map[] = {
2556 { .type = EV_KEY , .code = KEY_VOLUMEUP },
2557 { .type = EV_KEY , .code = KEY_VOLUMEDOWN },
2558 { .type = EV_KEY , .code = KEY_MENU },
2559 { .type = EV_KEY , .code = KEY_MENU },
2560 { .type = EV_KEY , .code = KEY_VOLUMEUP },
2561 { .type = EV_KEY , .code = KEY_MENU },
2562 { .type = EV_KEY , .code = KEY_VOLUMEDOWN },
2563 { .type = EV_KEY , .code = KEY_MENU },
2566 static void mkey_uart_path_change (void *event_data)
2568 if (u1hd_get_uart_switch() == UART_SW_PATH_CP)
2569 u1hd_set_uart_switch(UART_SW_PATH_AP);
2571 u1hd_set_uart_switch(UART_SW_PATH_CP);
2574 static const struct sec_input_bridge_mmap u1hd_mmap[] = {
2576 .mkey_map = u1hd_rbdump_mkey_map,
2577 .num_mkey = ARRAY_SIZE(u1hd_rbdump_mkey_map),
2578 .uevent_env_str = "RB_DUMP",
2580 .uevent_action = KOBJ_CHANGE,
2581 .uevent_env_str = "RB_DUMP",
2582 .uevent_env_value = "ON",
2585 .mkey_map = u1hd_default_mkey_map,
2586 .num_mkey = ARRAY_SIZE(u1hd_default_mkey_map),
2587 .uevent_env_str = "DEFAULT",
2589 .uevent_action = KOBJ_CHANGE,
2590 .uevent_env_str = "DEFAULT",
2591 .uevent_env_value = "ON",
2594 .mkey_map = u1hd_uart_mkey_map,
2595 .num_mkey = ARRAY_SIZE(u1hd_uart_mkey_map),
2596 .uevent_env_str = "UART_SW",
2598 .uevent_action = KOBJ_CHANGE,
2599 .uevent_env_str = "DEFAULT",
2600 .uevent_env_value = "ON",
2601 .pre_event_func = mkey_uart_path_change,
2605 static struct sec_input_bridge_platform_data u1hd_input_bridge_data = {
2607 .num_map = ARRAY_SIZE(u1hd_mmap),
2610 static struct platform_device u1hd_input_bridge = {
2611 .name = "samsung_input_bridge",
2614 .platform_data = &u1hd_input_bridge_data,
2619 #ifdef CONFIG_CHARGERCTRL_MAX8922
2620 #define GPIO_CHG_EN S5PV310_GPL2(2)
2621 #define GPIO_CHG_ING_N S5PV310_GPL2(4)
2622 #define GPIO_TA_nCONNECTED S5PV310_GPL2(5)
2624 static int max8922_cfg_gpio(void)
2626 s3c_gpio_cfgpin(GPIO_CHG_EN, S3C_GPIO_OUTPUT);
2627 s3c_gpio_setpull(GPIO_CHG_EN, S3C_GPIO_PULL_NONE);
2628 gpio_set_value(GPIO_CHG_EN, GPIO_LEVEL_LOW);
2630 s3c_gpio_cfgpin(GPIO_CHG_ING_N, S3C_GPIO_INPUT);
2631 s3c_gpio_setpull(GPIO_CHG_ING_N, S3C_GPIO_PULL_NONE);
2633 s3c_gpio_cfgpin(GPIO_TA_nCONNECTED, S3C_GPIO_INPUT);
2634 s3c_gpio_setpull(GPIO_TA_nCONNECTED, S3C_GPIO_PULL_NONE);
2639 static int u1hd_charger_topoff_cb(void)
2641 struct power_supply *psy = power_supply_get_by_name("battery");
2642 union power_supply_propval value;
2645 pr_err("%s: fail to get battery ps\n", __func__);
2649 value.intval = POWER_SUPPLY_STATUS_FULL;
2650 return psy->set_property(psy, POWER_SUPPLY_PROP_STATUS, &value);
2653 static struct regulator_consumer_supply supplies_max8922[] = {
2654 REGULATOR_SUPPLY("vinchg2", "charger-manager.0"),
2655 REGULATOR_SUPPLY("vinchg2_mach", NULL),
2658 static struct regulator_init_data max8922_charger_en_data = {
2660 .name = "MAX8922_CHARGER",
2663 .valid_ops_mask = REGULATOR_CHANGE_STATUS |
2664 REGULATOR_CHANGE_CURRENT,
2666 .num_consumer_supplies = ARRAY_SIZE(supplies_max8922),
2667 .consumer_supplies = supplies_max8922,
2669 static struct max8922_platform_data max8922_pdata = {
2670 .topoff_cb = u1hd_charger_topoff_cb,
2671 .cfg_gpio = max8922_cfg_gpio,
2672 .gpio_chg_en = GPIO_CHG_EN,
2673 .gpio_chg_ing = GPIO_CHG_ING_N,
2674 .gpio_ta_nconnected = GPIO_TA_nCONNECTED,
2675 .init_data = &max8922_charger_en_data,
2678 static struct platform_device max8922_device_charger = {
2679 .name = "max8922-charger",
2681 .dev.platform_data = &max8922_pdata,
2683 #endif /* CONFIG_MAX8922_CHARGER */
2685 struct led_max8997_platform_data u1hd_led_max8997_platform_data = {
2686 .name = "leds-torch",
2690 struct platform_device u1hd_device_leds_max8997 = {
2691 .name = "leds-max8997",
2693 .dev = { .platform_data = &u1hd_led_max8997_platform_data},
2696 #ifdef CONFIG_CHARGER_MANAGER
2697 extern struct platform_device u1hd_charger_manager;
2698 extern struct platform_device u1hd_ncp15wb473_thermistor;
2699 extern struct charger_global_desc u1hd_charger_g_desc;
2702 static struct platform_device *u1hd_devices[] __initdata = {
2703 /* Samsung Platform Devices */
2704 #ifdef CONFIG_S5PV310_DEV_PD
2705 &s5pv310_device_pd[PD_MFC],
2706 &s5pv310_device_pd[PD_G3D],
2707 &s5pv310_device_pd[PD_LCD0],
2708 &s5pv310_device_pd[PD_LCD1],
2709 &s5pv310_device_pd[PD_TV],
2710 &s5pv310_device_pd[PD_CAM],
2711 &s5pv310_device_pd[PD_GPS],
2713 #ifdef CONFIG_DRM_MALI
2714 &s5p_device_mali_drm,
2716 #ifdef CONFIG_DRM_FIMD
2717 &s5p_device_fimd_drm,
2734 &s3c_device_timer[0],
2735 &s3c_device_timer[1],
2737 #ifdef CONFIG_S3C_DEV_RTC
2740 &ps_on_led_a_fixed_reg_dev,
2741 #ifdef CONFIG_CHARGERCTRL_MAX8922
2742 &max8922_device_charger,
2745 #ifdef CONFIG_VIDEO_FIMC_MIPI
2749 #ifdef CONFIG_VIDEO_FIMC
2756 #ifdef CONFIG_VIDEO_JPEG
2762 #ifdef CONFIG_USB_GADGET
2763 &s3c_device_usbgadget,
2765 #ifdef CONFIG_USB_ANDROID_RNDIS
2768 #ifdef CONFIG_USB_ANDROID_ECM
2771 #ifdef CONFIG_USB_ANDROID
2772 &s3c_device_android_usb,
2773 &s3c_device_usb_mass_storage,
2775 #ifdef CONFIG_USB_S3C_OTG_HOST
2776 &s3c_device_usb_otghcd,
2778 #ifdef CONFIG_S3C_DEV_HSMMC4
2783 &emmc_fixed_voltage,
2790 #ifdef CONFIG_SND_S3C64XX_SOC_I2S_V4
2791 &s5pv310_device_iis0,
2793 #ifdef CONFIG_SND_S3C_SOC_PCM
2794 &s5pv310_device_pcm1,
2796 #ifdef CONFIG_SND_SOC_SMDK_WM9713
2797 &s5pv310_device_ac97,
2799 #ifdef CONFIG_SND_SAMSUNG_SOC_SPDIF
2800 &s5pv310_device_spdif,
2802 #ifdef CONFIG_SND_S5P_RP
2807 &fmradio_fixed_voltage,
2813 &u1hd_micro_usb_switch,
2815 #ifdef CONFIG_S3C2410_WATCHDOG
2819 #ifdef CONFIG_S5P_SYSMMU
2820 &s5p_device_sysmmu[SYSMMU_G2D],
2821 &s5p_device_sysmmu[SYSMMU_MFC_L],
2822 &s5p_device_sysmmu[SYSMMU_MFC_R],
2823 &s5p_device_sysmmu[SYSMMU_FIMC0],
2824 &s5p_device_sysmmu[SYSMMU_FIMC1],
2825 &s5p_device_sysmmu[SYSMMU_FIMC2],
2826 &s5p_device_sysmmu[SYSMMU_FIMC3],
2828 #ifdef CONFIG_VIDEO_FIMG2D
2831 #if defined(CONFIG_VIDEO_MFC5X) || defined(CONFIG_VIDEO_SAMSUNG_S5P_MFC)
2834 #ifdef CONFIG_VIDEO_SAMSUNG_S5P_TV
2838 #ifdef CONFIG_FB_S3C
2841 #ifdef CONFIG_ANDROID_RAM_CONSOLE
2842 &ram_console_device,
2845 &u1hd_device_leds_max8997,
2847 #ifdef CONFIG_CHARGER_MANAGER
2848 /* Should be placed after fuel gauge, charger control chips, pmics */
2849 &u1hd_ncp15wb473_thermistor,
2850 &u1hd_charger_manager,
2852 #ifdef CONFIG_INPUT_SECBRIDGE
2855 #ifdef CONFIG_SAMSUNG_BOOT_MODE
2856 &s3c_device_samsung_boot_mode,
2858 #ifdef CONFIG_SEC_DEBUG
2861 #ifdef CONFIG_S5PV310_STOPWATCH
2862 &s5pv310_device_stopwatch,
2864 #ifdef CONFIG_DEV_THERMAL
2869 &s5p_device_usb_ehci,
2870 #ifdef CONFIG_INPUT_GP2A
2875 extern void (*s5p_inform6_set)(char mode);
2876 extern void s5pv310_inform6_set(char mode);
2877 extern struct machine_desc *lookup_machine_type(unsigned int);
2879 static void __init u1hd_machine_init(void)
2882 struct machine_desc *list;
2883 list = lookup_machine_type(machine_arch_type);
2884 strcpy(utsname()->nodename, list->name);
2886 /* to support system shut down */
2887 pm_power_off = u1hd_power_off;
2889 /* to support inform6 set */
2890 s5p_inform6_set = s5pv310_inform6_set;
2892 /* Initialize GPIO default setting */
2893 mobile_gpios_init();
2894 s3c_config_sleep_gpio_table = u1hd_config_sleep_gpio_table;
2896 u1hd_switch_dev_init();
2898 s3c_i2c0_set_platdata(&u1hd_i2c0_platdata);
2901 s3c_i2c1_set_platdata(NULL);
2903 i2c_register_board_info(1, i2c1_devs, ARRAY_SIZE(i2c1_devs));
2906 s3c_i2c3_set_platdata(NULL);
2907 i2c_register_board_info(3, i2c3_devs, ARRAY_SIZE(i2c3_devs));
2909 #ifdef CONFIG_S5PV310_DEV_PD
2910 s5pv310_device_pd[PD_CAM].dev.parent = &s5pv310_device_pd[PD_LCD0].dev;
2911 #ifdef CONFIG_FB_S3C
2912 s3c_device_fb.dev.parent = &s5pv310_device_pd[PD_LCD0].dev;
2913 powerdomain_boot_on(PD_LCD0);
2918 /* YUBAEK 20110905 RAMDUMP_DEBUG : GPIO Dump ++ */
2919 #ifdef CONFIG_SEC_DEBUG_PERIPHERAL_DUMP_GPIO
2920 s5pv310_gpio_io_map();
2922 /* YUBAEK 20110905 RAMDUMP_DEBUG : GPIO Dump ++ */
2925 #ifdef CONFIG_S5PV310_DEV_PD
2926 #if defined(CONFIG_VIDEO_MFC5X) || defined(CONFIG_VIDEO_SAMSUNG_S5P_MFC)
2927 s5p_device_mfc.dev.parent = &s5pv310_device_pd[PD_MFC].dev;
2928 u1hd_common_setup_clock("mout_mfc0", "mout_mpll", 0, 0);
2929 u1hd_common_setup_clock("sclk_mfc", "mout_mfc0", 200 * MHZ, 1);
2933 u1hd_pmic_init(); /* TODO: should be modify for U1 */
2934 s3c_i2c5_set_platdata(NULL);
2935 i2c5_devs[I2C5_MAX8997].irq = gpio_to_irq(S5PV310_GPX0(7)),
2936 i2c_register_board_info(5, i2c5_devs, ARRAY_SIZE(i2c5_devs));
2939 s3c_i2c6_set_platdata(NULL);
2940 i2c_register_board_info(6, i2c6_devs, ARRAY_SIZE(i2c6_devs));
2942 s3c_i2c7_set_platdata(NULL);
2943 i2c_register_board_info(7, i2c7_devs, ARRAY_SIZE(i2c7_devs));
2945 s3c_i2c8_set_platdata(&i2c_data8);
2947 gpio = S5PV310_GPX2(3);
2948 gpio_request(gpio, "FUEL_ALERT");
2949 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
2950 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
2951 i2c9_devs[I2C9_MAX17042].irq = gpio_to_irq(gpio);
2952 i2c_register_board_info(9, i2c9_devs, ARRAY_SIZE(i2c9_devs));
2954 universal_touchkey_init();
2955 i2c_register_board_info(12, i2c12_devs_cypress, ARRAY_SIZE(i2c12_devs_cypress));
2957 i2c_register_board_info(14, i2c14_devs, ARRAY_SIZE(i2c14_devs));
2959 i2c_register_board_info(15, i2c15_devs, ARRAY_SIZE(i2c15_devs));
2962 u1hd_nfc_setup_gpio();
2963 i2c_register_board_info(16, i2c16_devs, ARRAY_SIZE(i2c16_devs));
2965 #if defined(CONFIG_VIDEO_S5K5BAFX)
2966 i2c_register_board_info(17, i2c17_devs, ARRAY_SIZE(i2c17_devs));
2969 i2c_register_board_info(18, i2c18_devs, ARRAY_SIZE(i2c18_devs));
2971 u1hd_usb_ehci_init();
2973 u1hd_usb_otg_init();
2975 s3c_usb_set_serial();
2979 #ifdef CONFIG_VIDEO_FIMG2D
2980 s5p_fimg2d_set_platdata(&fimg2d_data);
2981 #ifdef CONFIG_S5PV310_DEV_PD
2982 s5p_device_fimg2d.dev.parent = &s5pv310_device_pd[PD_LCD0].dev;
2987 pm_cpu_prepare = u1hd_pm_prepare;
2988 pm_cpu_finish = u1hd_pm_finish;
2991 s3c_irq_wake(IRQ_RTC_ALARM, 1);
2994 #if defined(CONFIG_S5PV310_DEV_PD) && !defined(CONFIG_PM_RUNTIME)
2996 * These power domains should be always on
2997 * without runtime pm support.
2999 s5pv310_pd_enable(&s5pv310_device_pd[PD_MFC].dev);
3000 s5pv310_pd_enable(&s5pv310_device_pd[PD_G3D].dev);
3001 s5pv310_pd_enable(&s5pv310_device_pd[PD_LCD0].dev);
3002 s5pv310_pd_enable(&s5pv310_device_pd[PD_LCD1].dev);
3003 s5pv310_pd_enable(&s5pv310_device_pd[PD_CAM].dev);
3004 s5pv310_pd_enable(&s5pv310_device_pd[PD_TV].dev);
3005 s5pv310_pd_enable(&s5pv310_device_pd[PD_GPS].dev);
3008 #ifdef CONFIG_VIDEO_FIMG2D
3009 /* setup fimg2d parent clock. */
3010 universal_fimg2d_setup_clock("mout_g2d0", "mout_mpll");
3013 s5pv310_sdhci_init();
3014 #ifdef CONFIG_S5P_ADC
3018 #ifdef CONFIG_DEV_THERMAL
3019 s5p_tmu_set_platdata(NULL);
3022 s5pv310_camera_init();
3025 platform_add_devices(u1hd_devices, ARRAY_SIZE(u1hd_devices));
3027 regulator_has_full_constraints();
3028 /* Temp. commented */
3030 if (s5pv310_subrev() != 0) {
3031 pr_emerg("\n\n This kernel does NOT support subrevision %d of S5PC210.\n\n\n",
3033 panic("Not supported subrevision");
3038 MACHINE_START(U1HD_C210, "U1HD")
3039 /* Maintainer: mhban <mhban@samsung.com> */
3040 .phys_io = S3C_PA_UART & 0xfff00000,
3041 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
3042 .boot_params = S5P_PA_SDRAM + 0x100,
3043 .init_irq = s5pv310_init_irq,
3044 .map_io = u1hd_map_io,
3045 .init_machine = u1hd_machine_init,
3046 .timer = &s5pv310_timer,
3047 .reserve = &s5pv310_reserve,