2 * linux/arch/arm/mach-s5pv310/mach-slp10_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/atmel_mxt_ts.h>
24 #include <linux/clk.h>
25 #include <linux/ntc.h>
26 #include <linux/regulator/machine.h>
27 #include <linux/regulator/fixed.h>
28 #include <linux/mfd/max8997.h>
29 #include <linux/mfd/max8997-private.h>
30 #include <linux/mmc/host.h>
31 #include <linux/power/max17042_battery.h>
32 #include <linux/power/max8903_charger.h>
33 #include <linux/ramoops.h>
34 #include <linux/mmcoops.h>
35 #include <linux/uart_select.h>
36 #include <linux/memblock.h>
37 #include <linux/rtc/rtc-s3c.h>
38 #include <linux/pwm_backlight.h>
39 #include <linux/jack.h>
40 #include <linux/k3g.h>
41 #include <linux/kr3dh.h>
42 #include <linux/micro_usb_switch.h>
43 #include <linux/switch.h>
44 #include <linux/bh1721.h>
45 #include <linux/sii9234_platform.h>
46 #include <linux/utsname.h>
47 #include <linux/cpufreq.h>
48 #include <linux/modem/xmm6260.h>
49 #include <linux/power/charger-manager.h>
50 #include <video/platform_lcd.h>
52 #include <asm/mach-types.h>
53 #include <asm/mach/arch.h>
54 #include <asm/setup.h>
57 #include <mach/gpio.h>
58 #include <mach/regs-clock.h>
59 #include <mach/regs-pmu.h>
60 #include <mach/universal.h>
63 #include <plat/clock.h>
64 #include <plat/devs.h>
65 #include <plat/gpio-cfg.h>
66 #include <plat/gpio-core.h>
68 #include <plat/fimg2d.h>
69 #include <plat/mali.h>
72 #include <plat/regs-otg.h>
73 #include <plat/regs-serial.h>
74 #include <plat/s5pv310.h>
75 #include <plat/sdhci.h>
77 #include <plat/fimd_drm.h>
78 #include <plat/tvout.h>
80 #include <plat/s5p_fimd_ext.h>
81 #include <plat/s5p_fimd_lite.h>
82 #include <plat/usb_ehci.h>
83 #include <plat/mdnie.h>
84 #include <plat/sysmmu.h>
85 #include <plat/s5p-otghost.h>
86 #include <plat/udc-hs.h>
90 #include "gpio-mobile.h"
91 #include "gpio-slp10.h"
92 #include "board-mobile.h"
93 #include "../../../drivers/usb/gadget/s3c_udc.h"
94 #if defined(CONFIG_DEV_THERMAL)
95 #include <plat/s5p-tmu.h>
96 #include <mach/regs-tmu.h>
99 /* Following are default values for UCON, ULCON and UFCON UART registers */
100 #define UNIVERSAL_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
101 S3C2410_UCON_RXILEVEL | \
102 S3C2410_UCON_TXIRQMODE | \
103 S3C2410_UCON_RXIRQMODE | \
104 S3C2410_UCON_RXFIFO_TOI | \
105 S3C2443_UCON_RXERR_IRQEN)
107 #define UNIVERSAL_ULCON_DEFAULT S3C2410_LCON_CS8
109 #define UNIVERSAL_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \
110 S5PV210_UFCON_TXTRIG256 | \
111 S5PV210_UFCON_RXTRIG256)
113 enum fixed_regulator_id {
114 FIXED_REG_ID_MMC = 0,
116 FIXED_REG_ID_BACKLIGHT,
120 FIXED_REG_ID_MAX8903,
124 /* Enable when use it really */
125 static int hwrevision(int hwrev)
127 return ((system_rev & 0xFF) == hwrev);
131 static struct s3c2410_uartcfg slp10_uartcfgs[] __initdata = {
134 .ucon = UNIVERSAL_UCON_DEFAULT,
135 .ulcon = UNIVERSAL_ULCON_DEFAULT,
136 .ufcon = UNIVERSAL_UFCON_DEFAULT,
140 .ucon = UNIVERSAL_UCON_DEFAULT,
141 .ulcon = UNIVERSAL_ULCON_DEFAULT,
142 .ufcon = UNIVERSAL_UFCON_DEFAULT,
146 .ucon = UNIVERSAL_UCON_DEFAULT,
147 .ulcon = UNIVERSAL_ULCON_DEFAULT,
148 .ufcon = UNIVERSAL_UFCON_DEFAULT,
152 .ucon = UNIVERSAL_UCON_DEFAULT,
153 .ulcon = UNIVERSAL_ULCON_DEFAULT,
154 .ufcon = UNIVERSAL_UFCON_DEFAULT,
158 static struct s3c2410_platform_i2c slp10_i2c0_platdata __initdata = {
159 .frequency = 300 * 1000,
163 static struct k3g_platform_data slp10_k3g_data = {
165 .powerdown = K3G_POWERDOWN_NORMAL,
169 .block_data_update = K3G_BLOCK_DATA_UPDATE,
170 .fullscale = K3G_FULL_SCALE_2000DPS,
171 .fifo_mode = K3G_FIFO_FIFO_MODE,
172 .int2_src = K3G_INT2_OVERRUN,
173 .fifo_threshold = 16,
174 .int1_enable = K3G_INT1_EN,
175 .int1_z_high_enable = K3G_Z_HIGH_INT_EN,
176 .int1_y_high_enable = K3G_Y_HIGH_INT_EN,
177 .int1_x_high_enable = K3G_X_HIGH_INT_EN,
178 .int1_latch = K3G_INTERRUPT_LATCHED,
179 .int1_z_threshold = 0x12,
180 .int1_y_threshold = 0x25,
181 .int1_x_threshold = 0x25,
182 .int1_wait_enable = K3G_INT1_WAIT_EN,
183 .int1_wait_duration = 0x10,
186 static struct kr3dh_platform_data slp10_kr3dh_data = {
187 .power_mode = KR3DH_LOW_POWER_10HZ,
188 .data_rate = KR3DH_ODR_50HZ,
193 .int1_cfg = KR3DH_INT_SOURCE,
194 .block_data_update = 1,
195 .fullscale = KR3DH_RANGE_2G,
196 .int1_combination = KR3DH_OR_COMBINATION,
198 .int1_z_high_enable = 1,
199 .int1_z_low_enable = 1,
200 .int1_y_high_enable = 1,
201 .int1_y_low_enable = 1,
202 .int1_x_high_enable = 1,
203 .int1_x_low_enable = 1,
204 .int1_threshold = 0x25,
205 .int1_duration = 0x01,
212 static struct kr3dh_platform_data slp10_rev06_kr3dh_data = {
213 .power_mode = KR3DH_LOW_POWER_10HZ,
214 .data_rate = KR3DH_ODR_50HZ,
219 .int1_cfg = KR3DH_INT_SOURCE,
220 .block_data_update = 1,
221 .fullscale = KR3DH_RANGE_2G,
222 .int1_combination = KR3DH_OR_COMBINATION,
224 .int1_z_high_enable = 1,
225 .int1_z_low_enable = 1,
226 .int1_y_high_enable = 1,
227 .int1_y_low_enable = 1,
228 .int1_x_high_enable = 1,
229 .int1_x_low_enable = 1,
230 .int1_threshold = 0x25,
231 .int1_duration = 0x01,
238 #ifdef CONFIG_CPU_FREQ_TICKLE
239 static void user_input_response(void *data)
241 /* core 0's cpufreq controls both cores */
242 cpufreq_tickle_cpu(100, 0);
247 static struct i2c_board_info i2c1_devs[] __initdata = {
250 I2C_BOARD_INFO("K3G", 0x69),
251 .platform_data = &slp10_k3g_data,
255 I2C_BOARD_INFO("KR3DH", 0x19),
256 /* platform_data will be set in sensor_init*/
263 /* FIXME: Only use for tuning */
264 static u8 mxt_init_vals[] __initdata = {
265 /* MXT_GEN_COMMAND(6) */
266 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
267 /* MXT_GEN_POWER(7) */
269 /* MXT_GEN_ACQUIRE(8) */
270 0x0a, 0x00, 0x05, 0x0a, 0x00, 0x00, 0x00, 0x30, 0x32, 0x19,
271 /* MXT_TOUCH_MULTI(9) */
272 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
273 0x00, 0x03, 0x01, 0x2e, 0x0a, 0x05, 0x05, 0x0a, 0x00, 0x00,
274 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
275 0x12, 0x0a, 0x01, 0x03,
276 /* MXT_TOUCH_KEYARRAY(15) */
277 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
279 /* MXT_PROCG_NOISE(22) */
280 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00,
281 0x00, 0x0a, 0x0f, 0x14, 0x19, 0x1e, 0x00,
282 /* MXT_PROCI_ONETOUCH(24) */
283 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
284 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
285 /* MXT_SPT_SELFTEST(25) */
286 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
287 0x00, 0x00, 0x00, 0x00,
288 /* MXT_PROCI_TWOTOUCH(27) */
289 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
290 /* MXT_SPT_CTECONFIG(28) */
291 0x00, 0x00, 0x00, 0x08, 0x36, 0x00,
292 /* MXT_PROCI_GRIP(40) */
293 0x11, 0x00, 0x00, 0x0f, 0x0f,
294 /* MXT_PROCI_PALM(41) */
295 0x01, 0x00, 0x00, 0x28, 0x05, 0x05,
298 static struct mxt_platform_data mxt_platform_data __refconst = {
299 .config = mxt_init_vals,
300 .config_length = ARRAY_SIZE(mxt_init_vals),
308 .voltage = 3300000, /* 3.3V */
309 .orient = MXT_VERTICAL_FLIP,
310 .irqflags = IRQF_TRIGGER_FALLING,
312 #ifdef CONFIG_CPU_FREQ_TICKLE
313 /* For the faster user response */
314 .input_event = user_input_response,
318 static struct i2c_board_info i2c3_devs[] __initdata = {
320 I2C_BOARD_INFO("atmel_mxt_ts", 0x4c),
321 .platform_data = &mxt_platform_data,
326 static void slp10_power_off(void)
329 char *str_ptr = "reset\n";
330 int poweroff_try = 0;
333 printk(KERN_INFO "%s: u1 power off\n", __func__);
335 /* Check reboot charging */
336 // if (is_cable_attached || (poweroff_try >= 5)) {
337 if (poweroff_try >= 5) {
339 "%s: power off failed(%d), reboot!\n",
340 __func__, poweroff_try);
342 // flush_cache_all();
343 // outer_flush_all();
344 arm_machine_restart(rst_mode, str_ptr);
347 printk(KERN_INFO "%s: waiting for reboot.\n", __func__);
351 /* wait for power button release */
352 // gpio = MOBILE_GPIO(nPOWER);
353 // gpio_request(gpio, "nPOWER");
354 gpio = S5PV310_GPX2(7);
355 if (gpio_get_value(gpio)) {
356 printk(KERN_INFO "%s: set PS_HOLD low.\n", __func__);
358 * PS_HOLD Out/High -->
359 * Low PS_HOLD_CONTROL, R/W, 0x1002_330C
361 writel(readl(S5P_PS_HOLD_CONTROL) & 0xFFFFFEFF,
362 S5P_PS_HOLD_CONTROL);
366 /* when connected zig cable with power, we can't make PS_HOLD_CONTROL low.
367 * we try power_off 5 times. then if it failed, do restart.
370 "%s: Should not reach here! (poweroff_try:%d)\n",
371 __func__, poweroff_try);
374 /* if power button is not released, wait and check TA again */
375 printk(KERN_INFO "%s: PowerButton is not released!.\n",
382 static void __init slp10_tsp_init(void)
386 /* TOUCH_INT: XEINT_4 */
387 gpio = S5PV310_GPX0(4);
388 gpio_request(gpio, "TOUCH_INT");
389 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
390 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
392 /* TOUCH_RST : XGNSS_GPIO_4 */
393 gpio = S5PV310_GPL2(4);
394 gpio_request(gpio, "TOUCH_RST");
395 gpio_direction_output(gpio, 1);
399 static struct s3c2410_platform_i2c slp10_i2c3_platdata __initdata = {
403 .frequency = 380 * 1000,
407 #ifdef CONFIG_MHL_SII9234
408 static void mhl_cfg_gpio(void)
412 /* HDMI_EN : VSIL_1.2A, VSIL_1.2C, VCC_3.3V_MHL, VCC_1.8V_MHL */
413 gpio = S5PV310_GPX2(4);
414 gpio_request(gpio, "HDMI_EN");
415 gpio_direction_output(gpio, 0);
418 gpio = S5PV310_GPF3(4);
419 gpio_request(gpio, "MHL_RST");
420 gpio_direction_output(gpio, 0);
423 #define MHL_INT S5PV310_GPF3(5)
426 static void mhl_enable(unsigned int enable)
428 int hdmi_en, mhl_rst;
430 hdmi_en = S5PV310_GPX2(4);
431 mhl_rst = S5PV310_GPF3(4);
434 printk(KERN_INFO "SII9234 MHL enable.\n");
436 gpio_set_value(hdmi_en, 1);
437 gpio_set_value(mhl_rst, 0);
439 gpio_set_value(mhl_rst, 1);
440 /* FIXME just rising edge only??? */
442 printk(KERN_INFO "SII9234 MHL disable.\n");
444 gpio_set_value(hdmi_en, 0);
445 gpio_set_value(mhl_rst, 0);
449 static struct sii9234_platform_data slp10_sii9234_pdata = {
450 .cfg_pin = mhl_cfg_gpio,
451 .enable = mhl_enable,
455 extern struct max8997_platform_data slp10_max8997_pdata;
456 extern void __init slp10_pmic_init(void);
457 extern struct charger_global_desc slp7_charger_g_desc;
459 static void haptic_control_power(struct device *dev, int on)
461 struct regulator *regulator;
462 static bool status = false;
465 regulator = regulator_get(dev, "inmotor");
466 if (IS_ERR_OR_NULL(regulator))
468 regulator_enable(regulator);
469 regulator_put(regulator);
473 regulator = regulator_get(dev, "inmotor");
474 if (IS_ERR_OR_NULL(regulator))
477 if (regulator_is_enabled(regulator))
478 regulator_disable(regulator);
479 regulator_put(regulator);
484 struct max8997_haptic_platform_data slp10_haptic_pdata = {
487 .control_power = haptic_control_power,
490 /* GPIO I2C 5 (PMIC) */
491 enum { I2C5_MAX8997 };
492 static struct i2c_board_info i2c5_devs[] __initdata = {
494 I2C_BOARD_INFO("max8997", 0xCC >> 1),
495 .platform_data = &slp10_max8997_pdata,
500 static struct i2c_board_info i2c6_devs[] __initdata = {
503 I2C_BOARD_INFO("mc1n2", 0x3a),
507 static void __init slp10_sound_init(void)
511 /* Set PMU register to set CLK_OUT to use XUSBXTI
512 * as codec source clock */
514 __raw_writel(val, S5P_PMREG(0xA00));
518 static struct i2c_board_info i2c7_devs[] __initdata = {
521 I2C_BOARD_INFO("ak8975", 0x0c),
525 static void __init slp10_sensor_init(void)
529 gpio = S5PV310_GPX2(2); /* XEINT_18 */
530 gpio_request(gpio, "MSENSE_INT");
531 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
532 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
533 i2c7_devs[0].irq = gpio_to_irq(gpio);
535 gpio = S5PV310_GPX0(0); /* XEINT_0 */
536 gpio_request(gpio, "GYRO_INT");
537 gpio_direction_input(gpio);
538 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_DOWN);
540 gpio = S5PV310_GPX0(1); /* XEINT_1 */
541 gpio_request(gpio, "GYRO_INT1");
542 gpio_direction_input(gpio);
543 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_DOWN);
545 gpio = S5PV310_GPX3(0); /* XEINT_24 */
546 gpio_request(gpio, "ACC_INT");
547 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
548 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_DOWN);
550 if ((system_rev & 0xFF) == 0x6)
551 i2c1_devs[1].platform_data = &slp10_rev06_kr3dh_data;
553 i2c1_devs[1].platform_data = &slp10_kr3dh_data;
559 static struct i2c_gpio_platform_data i2c9_gpio_data = {
560 .sda_pin = S5PV310_GPY4(0), /* XM0ADDR_8 */
561 .scl_pin = S5PV310_GPY4(1), /* XM0ADDR_9 */
564 static struct platform_device i2c9_gpio = {
568 .platform_data = &i2c9_gpio_data,
572 static struct max17042_reg_data max17042_init_data[] = {
573 { MAX17042_CGAIN, 8192 },
574 { MAX17042_MiscCFG, 0x0003 },
575 { MAX17042_LearnCFG, 0x0007 },
576 /* RCOMP: 0x0050 2011.02.29 from MAXIM */
577 { MAX17042_RCOMP0, 0x0050 },
578 { MAX17042_DesignCap, 0x1F40 }, /* 4000mAh */
580 /* Alert only when the battery is removed or inserted */
581 static struct max17042_reg_data max17042_alert_init_data[] = {
582 /* SALRT Threshold setting (disable) unsigned MAX/MIN */
583 { MAX17042_SALRT_Th, 0xFF00 },
584 /* VALRT Threshold setting (disable) unsigned MAX/MIN */
585 { MAX17042_VALRT_Th, 0xFF00 },
586 /* TALRT Threshold setting (disable) signed MAX/MIN */
587 { MAX17042_TALRT_Th, 0x7F80 },
589 static struct max17042_platform_data slp10_battery_platform_data = {
590 .init_data = max17042_init_data,
591 .num_init_data = ARRAY_SIZE(max17042_init_data),
592 .alrt_data = max17042_alert_init_data,
593 .num_alrt_data = ARRAY_SIZE(max17042_alert_init_data),
594 .irq_base = IRQ_FUEL_BASE,
595 .enable_alert = true,
597 .r_sns = 10000, /* 10m Ohm */
600 enum { I2C9_MAX17042};
601 static struct i2c_board_info i2c9_devs[] __initdata = {
603 I2C_BOARD_INFO("max17042", 0x36),
604 .platform_data = &slp10_battery_platform_data,
610 static struct bh1721_platform_data bh1721_plat_data = {
612 .power_control = NULL,
615 static void light_sensor_toggle(int gpio, int toggle)
617 gpio_direction_output(gpio, toggle);
620 static int light_sensor_power_control(int onoff)
622 struct regulator *regulator;
623 static DEFINE_MUTEX(lock);
629 if (enabled == !!onoff)
632 if (regulator == NULL)
633 regulator = regulator_get(NULL, "vadc");
634 if (IS_ERR_OR_NULL(regulator)) {
636 pr_err("[LS][ERROR] regulator_get fail\n");
642 ret = regulator_enable(regulator);
646 ret = regulator_disable(regulator);
656 static void __init slp10_light_sensor_init(void)
658 struct bh1721_platform_data *pdata = &bh1721_plat_data;
661 gpio = S5PV310_GPX0(2); /* XEINT_2 */
662 gpio_request(gpio, "LIGHT_nINT");
663 gpio_direction_output(gpio, 0);
664 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
666 pdata->reset = light_sensor_toggle;
667 pdata->power_control = light_sensor_power_control;
671 static struct i2c_gpio_platform_data i2c14_gpio_data = {
672 .sda_pin = S5PV310_GPK2(2), /* XMMC2CDn */
673 .scl_pin = S5PV310_GPK3(2), /* XMMC3CDn */
674 .udelay = 1, /* 500kHz */
677 static struct platform_device i2c14_gpio = {
681 .platform_data = &i2c14_gpio_data,
685 static struct i2c_board_info i2c14_devs[] __initdata = {
687 I2C_BOARD_INFO("bh1721", 0x23),
688 .platform_data = &bh1721_plat_data,
693 static struct i2c_gpio_platform_data i2c15_gpio_data = {
694 .sda_pin = S5PV310_GPY3(0), /* XM0ADDR_0 */
695 .scl_pin = S5PV310_GPY3(2), /* XM0ADDR_2 */
699 static struct platform_device i2c15_gpio = {
703 .platform_data = &i2c15_gpio_data,
707 static struct i2c_board_info i2c15_devs[] __initdata = {
708 #ifdef CONFIG_MHL_SII9234
710 I2C_BOARD_INFO("sii9234", 0x72),
711 .platform_data = &slp10_sii9234_pdata,
718 static struct s5p_usb_ehci_platdata slp10_usb_ehci_pdata;
720 static void __init slp10_usb_ehci_init(void)
722 struct s5p_usb_ehci_platdata *pdata = &slp10_usb_ehci_pdata;
724 /* The gpios is initialized from modem_init */
725 pdata->gpio_active = MOBILE_GPIO(ACTIVE_STATE_HSIC);
727 s5p_usb_ehci_set_platdata(pdata);
731 /* we don't use OTGDRVVBUS pin for powering up otg charging pump */
732 static void slp10_otg_power_cb(int enable)
735 u8 on = (u8)!!enable;
736 gpio = MOBILE_GPIO(USB_OTG_EN);
737 gpio_request(gpio, "USB_OTG_EN");
738 gpio_direction_output(gpio, on);
740 pr_info("%s: otg power = %d\n", __func__, on);
743 static void __init slp10_usb_otg_init(void)
745 struct host_notify_dev *slp10_otg_ndev =
746 dev_get_platdata(&s3c_device_usbgadget.dev);
747 struct sec_otghost_data *slp10_otg_host_data =
748 dev_get_platdata(&s3c_device_usb_otghcd.dev);
750 slp10_otg_ndev->set_booster = slp10_otg_power_cb;
751 slp10_otg_host_data->set_pwr_cb = slp10_otg_power_cb;
755 static struct platform_device slp10_modem_net = {
761 /* XMM6260 control */
762 static struct xmm6260_gpios slp10_xmm6260_gpios;
764 static struct xmm6260_platform_data slp10_xmm6260_pdata = {
765 .gpios = &slp10_xmm6260_gpios,
769 static struct platform_device slp10_xmm6260 = {
770 /* FIXME: Use modemctl name because of platform dependency */
774 .platform_data = &slp10_xmm6260_pdata,
778 static void __init slp10_modem_init(void)
780 struct xmm6260_gpios *gpios = &slp10_xmm6260_gpios;
783 gpio = MOBILE_GPIO(CP_ON);
784 gpio_request(gpio, "CP_ON");
785 gpio_direction_output(gpio, 0);
788 gpio = MOBILE_GPIO(PHONE_ACTIVE);
789 gpio_request(gpio, "PHONE_ACTIVE");
790 gpios->phone_active = gpio;
792 gpio = MOBILE_GPIO(PDA_ACTIVE);
793 gpio_request(gpio, "PDA_ACTIVE");
794 gpio_direction_output(gpio, 0);
795 gpios->pda_active = gpio;
797 gpio = MOBILE_GPIO(CP_DUMP_INT);
798 gpio_request(gpio, "CP_DUMP_INT");
799 gpios->cp_dump_int = gpio;
801 gpio = MOBILE_GPIO(CP_RST);
802 gpio_request(gpio, "CP_RST");
803 gpio_direction_output(gpio, 0);
804 gpios->cp_pmu_rst = gpio;
806 gpio = MOBILE_GPIO(RESET_REQ_N);
807 gpio_request(gpio, "RESET_REQ_N");
808 gpio_direction_output(gpio, 0);
809 gpios->reset_req_n = gpio;
811 gpio = MOBILE_GPIO(IPC_SLAVE_WAKEUP);
812 gpio_request(gpio, "IPC_SLAVE_WAKEUP");
813 gpio_direction_output(gpio, 0);
814 gpios->ipc_slave_wakeup = gpio;
816 gpio = MOBILE_GPIO(IPC_HOST_WAKEUP);
817 gpio_request(gpio, "IPC_HOST_WAKEUP");
818 gpios->ipc_host_wakeup = gpio;
820 gpio = MOBILE_GPIO(SUSPEND_REQUEST_HSIC);
821 gpio_request(gpio, "SUSPEND_REQUEST_HSIC");
822 gpios->suspend_request_hsic = gpio;
824 gpio = MOBILE_GPIO(ACTIVE_STATE_HSIC);
825 gpio_request(gpio, "ACTIVE_STATE_HSIC");
826 gpio_direction_output(gpio, 0);
827 gpios->active_state_hsic = gpio;
831 static void slp10_set_uart_switch(int path)
835 gpio = MOBILE_GPIO(UART_SEL);
836 gpio_request(gpio, "UART_SEL");
838 /* slp10 target is gpio_high == AP */
839 if (path == UART_SW_PATH_AP)
840 gpio_set_value(gpio, GPIO_LEVEL_HIGH);
841 else if (path == UART_SW_PATH_CP)
842 gpio_set_value(gpio, GPIO_LEVEL_LOW);
848 static int slp10_get_uart_switch(void)
853 gpio = MOBILE_GPIO(UART_SEL);
854 gpio_request(gpio, "UART_SEL");
855 val = gpio_get_value(gpio);
858 /* slp10 target is gpio_high == AP */
859 if (val == GPIO_LEVEL_HIGH)
860 return UART_SW_PATH_AP;
861 else if (val == GPIO_LEVEL_LOW)
862 return UART_SW_PATH_CP;
864 return UART_SW_PATH_NA;
867 static struct uart_select_platform_data slp10_uart_select_data = {
868 .set_uart_switch = slp10_set_uart_switch,
869 .get_uart_switch = slp10_get_uart_switch,
872 static struct platform_device slp10_uart_select = {
873 .name = "uart-select",
876 .platform_data = &slp10_uart_select_data,
881 #ifndef CONFIG_S3C_DEV_HSMMC4
882 static struct s3c_sdhci_platdata slp10_hsmmc0_data __initdata = {
884 .host_caps = (MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA |
885 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
887 .cd_type = S3C_SDHCI_CD_PERMANENT,
888 .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,
892 static struct regulator_consumer_supply emmc_supplies[] = {
893 REGULATOR_SUPPLY("vmmc", "s3c-sdhci.0"),
894 REGULATOR_SUPPLY("vmmc", "dw_mmc"),
897 static struct regulator_init_data emmc_fixed_voltage_init_data = {
899 .name = "VMEM_VDD_2.8V",
900 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
902 .num_consumer_supplies = ARRAY_SIZE(emmc_supplies),
903 .consumer_supplies = emmc_supplies,
906 static struct fixed_voltage_config emmc_fixed_voltage_config = {
907 .supply_name = "MASSMEMORY_EN (inverted)",
908 .microvolts = 2800000,
909 .gpio = S5PV310_GPL1(1),
910 .enable_high = false,
911 .init_data = &emmc_fixed_voltage_init_data,
914 static struct platform_device emmc_fixed_voltage = {
915 .name = "reg-fixed-voltage",
916 .id = FIXED_REG_ID_MMC,
918 .platform_data = &emmc_fixed_voltage_config,
923 static void (*wlan_notify_change_cb)(struct platform_device *dev, int state);
925 static int wlan_ext_cd_init(void (*cb)(struct platform_device *dev, int state))
927 wlan_notify_change_cb = cb;
931 static int wlan_ext_cd_cleanup(void (*cb)(struct platform_device *dev, int state))
933 wlan_notify_change_cb = NULL;
937 static int slp10_wlan_host_enable(int on)
939 if (wlan_notify_change_cb)
940 (*wlan_notify_change_cb)(&s3c_device_hsmmc3, on);
944 static struct s3c_sdhci_platdata slp10_hsmmc3_data __initdata = {
946 .host_caps = (MMC_CAP_4_BIT_DATA |
947 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
948 .pm_caps = MMC_PM_KEEP_POWER,
949 .cd_type = S3C_SDHCI_CD_EXTERNAL,
950 .ext_cd_init = &wlan_ext_cd_init,
951 .ext_cd_cleanup = &wlan_ext_cd_cleanup,
952 .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,
955 static void __init slp10_sdhci_init(void)
959 gpio = S5PV310_GPX3(3); /* T-Flash Detect */
960 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
961 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
963 #ifndef CONFIG_S3C_DEV_HSMMC4
964 s3c_sdhci0_set_platdata(&slp10_hsmmc0_data);
966 s3c_sdhci3_set_platdata(&slp10_hsmmc3_data);
970 static struct bcm4330_platform_data bcm4330_data = {
971 .wlan_en = S5PV310_GPL1(2), /* XGNSS_EPOCH */
972 .wlan_host_wake = S5PV310_GPX2(5), /* XEINT[21] */
973 .bt_en = S5PV310_GPL0(4), /* XGNSS_QMAG */
974 .bt_nrst = S5PV310_GPL1(0), /* XGNSS_SCL */
975 .bt_host_wake = S5PV310_GPX2(6), /* XEINT[22] */
976 .bt_wake = S5PV310_GPX3(1), /* XEINT[25] */
977 .bt_uart[0] = S5PV310_GPA0(0), /* XuRXD[0] */
978 .bt_uart[1] = S5PV310_GPA0(1), /* XuTXD[0] */
979 .bt_uart[2] = S5PV310_GPA0(2), /* XuCTSn[0] */
980 .bt_uart[3] = S5PV310_GPA0(3), /* XuRTSn[0] */
981 .wlan_host_enable = &slp10_wlan_host_enable,
984 static struct platform_device slp10_bcm4330 = {
985 .name = "bcm4330-b1",
988 .platform_data = &bcm4330_data,
993 #ifdef CONFIG_DRM_MALI
994 static struct platform_device s5p_device_mali_drm = {
1001 #ifdef CONFIG_DRM_FIMD
1002 static struct resource fimd_drm_resource[] = {
1004 .start = S5P_PA_LCD0,
1005 .end = S5P_PA_LCD0 + S5P_SZ_LCD0 - 1,
1006 .flags = IORESOURCE_MEM,
1009 .start = S5P_PA_LCD1,
1010 .end = S5P_PA_LCD1 + S5P_SZ_LCD1 - 1,
1011 .flags = IORESOURCE_MEM,
1016 .flags = IORESOURCE_IRQ,
1021 .flags = IORESOURCE_IRQ,
1025 static struct fimd_drm_platform_data fimd_drm_pd = {
1029 static struct platform_device s5p_device_fimd_drm = {
1032 .num_resources = ARRAY_SIZE(fimd_drm_resource),
1033 .resource = fimd_drm_resource,
1035 .platform_data = &fimd_drm_pd,
1041 static struct bcm4751_platform_data slp10_bcm4751_data = {
1042 .regpu = S5PV310_GPK0(2), /* XMMC0_CDN */
1043 .nrst = S5PV310_GPL0(2), /* XGNSS_IMAG */
1044 .uart_rxd = S5PV310_GPA0(4), /* XURXD[1] */
1045 .clk_int = S5PV310_GPY3(6), /* XM0ADDR[6] */
1048 static struct platform_device slp10_bcm4751 = {
1052 .platform_data = &slp10_bcm4751_data,
1057 static struct s3c_adc_platform_data s3c_adc_pdata __initdata = {
1061 .max_adc_voltage_uV = 3300000,
1064 static void __init slp10_adc_init(void)
1066 s3c_adc_set_platdata(&s3c_adc_pdata);
1069 static void ramoops_enable(int enable)
1073 clk = clk_get(NULL, "modem");
1081 static struct ramoops_platform_data slp10_ramoops_data = {
1082 .mem_address = 0x13A00000, /* MODEM I/F */
1084 .enable = ramoops_enable,
1087 static struct platform_device slp10_ramoops = {
1090 .platform_data = &slp10_ramoops_data,
1095 static struct platform_device slp10_tzpc = {
1100 #ifdef CONFIG_ANDROID_RAM_CONSOLE
1101 static struct resource ram_console_resource[] = {
1103 .flags = IORESOURCE_MEM,
1107 static struct platform_device ram_console_device = {
1108 .name = "ram_console",
1110 .num_resources = ARRAY_SIZE(ram_console_resource),
1111 .resource = ram_console_resource,
1115 static void __init slp10_map_io(void)
1117 s5p_init_io(NULL, 0, S5P_VA_CHIPID);
1118 s5p_xtal_set_parent(CLK_XUSBXTI);
1119 s3c24xx_init_clocks(24000000);
1120 s3c24xx_init_uarts(slp10_uartcfgs, ARRAY_SIZE(slp10_uartcfgs));
1123 static unsigned long fbmem_start, fbmem_size;
1124 static int __init early_fbmem(char *p)
1131 fbmem_size = memparse(p, &endp);
1133 fbmem_start = memparse(endp + 1, &endp);
1135 return endp > p ? 0 : -EINVAL;
1137 early_param("fbmem", early_fbmem);
1139 static void __init s5pv310_reserve(void)
1141 static struct cma_region regions[] = {
1142 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMD0
1146 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMD1
1152 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_JPEG
1155 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_JPEG * SZ_1K,
1158 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC
1161 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC * SZ_1K,
1164 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC0
1167 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC0 * SZ_1K,
1169 .alignment = 1 << 17,
1173 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC1
1176 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_MFC1 * SZ_1K,
1178 .alignment = 1 << 17,
1182 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC0
1185 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC0 * SZ_1K,
1189 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC1
1192 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC1 * SZ_1K,
1196 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC2
1199 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC2 * SZ_1K,
1203 #ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC3
1206 .size = CONFIG_VIDEO_SAMSUNG_MEMSIZE_FIMC3 * SZ_1K,
1213 static const char map[] __initconst =
1215 #ifdef CONFIG_VIDEO_FIMC
1222 "s3c-mfc=mfc,mfc0,mfc1;"
1227 #ifdef CONFIG_ANDROID_RAM_CONSOLE
1230 /* FIXME: ram console MUST be reserved at first time */
1231 addr = memblock_alloc_base(SZ_1M, SZ_4K, 0x60000000);
1232 ram_console_resource[0].start = addr;
1233 ram_console_resource[0].end = addr + SZ_1M - 1;
1234 pr_info("ram_console: 0x%08x ~ 0x%08x (1MB)\n",
1235 addr, addr + SZ_1M);
1239 regions[0].start = (dma_addr_t)fbmem_start;
1241 regions[0].size = (size_t)fbmem_size;
1243 cma_set_defaults(regions, map);
1244 cma_early_regions_reserve(NULL);
1246 for (; i < ARRAY_SIZE(regions) - 1 /* terminator */; ++i) {
1247 pr_info("cma: region: %-8s: 0x%08x ~ 0x%08x (%dMB)\n",
1248 regions[i].name, regions[i].start,
1249 regions[i].start + regions[i].size,
1250 regions[i].size / SZ_1M);
1255 * GPX are saved and restored at plat-samsung/pm.c:s5c_pm_enter.
1256 * However, they are inside of pm_prepare and pm_finish, so it
1257 * does not save ours against universal_pm_prepare:2.
1259 static struct sleep_save s5pc210_gpx[] = {
1260 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C00),
1261 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C04),
1262 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C08),
1263 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C0C),
1264 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C20),
1265 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C24),
1266 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C28),
1267 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C2C),
1268 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C40),
1269 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C44),
1270 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C48),
1271 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C4C),
1272 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C60),
1273 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C64),
1274 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C68),
1275 SAVE_ITEM(S5P_VA_GPIO2 + 0x0C6C),
1279 static struct gpio_keys_button slp10_gpio_keys_tables[] = {
1281 .code = KEY_HOME, /* FIXME: VOLUMEUP */
1282 .gpio = S5PV310_GPX2(0), /* XEINT16 */
1283 .desc = "gpio-keys: KEY_VOLUMEUP",
1286 .debounce_interval = 1,
1288 .code = KEY_MENU, /* FIXME: MENU */
1289 .gpio = S5PV310_GPX2(1), /* XEINT17 */
1290 .desc = "gpio-keys: KEY_MENU",
1294 .debounce_interval = 1,
1297 .gpio = S5PV310_GPX2(7), /* XEINT23 */
1298 .desc = "gpio-keys: KEY_POWER",
1302 .debounce_interval = 1,
1306 static struct gpio_keys_platform_data slp10_gpio_keys_data = {
1307 .buttons = slp10_gpio_keys_tables,
1308 .nbuttons = ARRAY_SIZE(slp10_gpio_keys_tables),
1311 static struct platform_device slp10_gpio_keys = {
1312 .name = "gpio-keys",
1314 .platform_data = &slp10_gpio_keys_data,
1320 static unsigned int slp10_lcd_enabled;
1322 static struct s3cfb_lcd slp10_lcd = {
1348 static int lcd_cfg_gpio(void)
1350 int gpio, i, f3_end = 4;
1353 for (i = 0; i < 8; i++) {
1354 /* set GPF0,1,2[0:7] for RGB Interface and Data lines (32bit) */
1355 s3c_gpio_cfgpin(S5PV310_GPF0(i), S3C_GPIO_SFN(2));
1356 s3c_gpio_setpull(S5PV310_GPF0(i), S3C_GPIO_PULL_NONE);
1359 for (i = 0; i < 8; i++) {
1360 s3c_gpio_cfgpin(S5PV310_GPF1(i), S3C_GPIO_SFN(2));
1361 s3c_gpio_setpull(S5PV310_GPF1(i), S3C_GPIO_PULL_NONE);
1364 for (i = 0; i < 8; i++) {
1365 s3c_gpio_cfgpin(S5PV310_GPF2(i), S3C_GPIO_SFN(2));
1366 s3c_gpio_setpull(S5PV310_GPF2(i), S3C_GPIO_PULL_NONE);
1369 for (i = 0; i < f3_end; i++) {
1370 s3c_gpio_cfgpin(S5PV310_GPF3(i), S3C_GPIO_SFN(2));
1371 s3c_gpio_setpull(S5PV310_GPF3(i), S3C_GPIO_PULL_NONE);
1374 /* Set FIMD0 bypass */
1375 reg = __raw_readl(S3C_VA_SYS + 0x0210);
1377 __raw_writel(reg, S3C_VA_SYS + 0x0210);
1379 /* LED_BACKLIGHT_RESET */
1380 gpio = S5PV310_GPE3(2);
1381 gpio_request(gpio, "LED_BACKLIGHT_RESET");
1382 gpio_direction_output(gpio, 1);
1387 static struct regulator_consumer_supply lcd_supplies[] = {
1388 REGULATOR_SUPPLY("LVDS_nSHDN", "platform-lcd"),
1391 static struct regulator_init_data lcd_fixed_voltage_init_data = {
1393 .name = "LVDS_nSHDN",
1394 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
1396 .num_consumer_supplies = ARRAY_SIZE(lcd_supplies),
1397 .consumer_supplies = lcd_supplies,
1400 static struct fixed_voltage_config lcd_fixed_voltage_config = {
1401 .supply_name = "LVDS_nSHDN",
1402 .microvolts = 2800000,
1403 .gpio = S5PV310_GPE1(5),
1404 .enable_high = true,
1405 .enabled_at_boot = true,
1406 .init_data = &lcd_fixed_voltage_init_data,
1409 static struct platform_device lcd_fixed_voltage = {
1410 .name = "reg-fixed-voltage",
1411 .id = FIXED_REG_ID_LCD,
1413 .platform_data = &lcd_fixed_voltage_config,
1417 static struct regulator_consumer_supply backlight_supplies[] = {
1418 REGULATOR_SUPPLY("LCD_LDO_EN", "pwm-backlight"),
1421 static struct regulator_init_data backlight_fixed_voltage_init_data = {
1423 .name = "LCD_LDO_EN",
1424 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
1426 .num_consumer_supplies = ARRAY_SIZE(backlight_supplies),
1427 .consumer_supplies = backlight_supplies,
1430 static struct fixed_voltage_config backlight_fixed_voltage_config = {
1431 .supply_name = "LCD_LDO_EN",
1432 .microvolts = 2800000,
1433 .gpio = S5PV310_GPE2(3),
1434 .enable_high = true,
1435 .enabled_at_boot = true,
1436 .init_data = &backlight_fixed_voltage_init_data,
1439 static struct platform_device backlight_fixed_voltage = {
1440 .name = "reg-fixed-voltage",
1441 .id = FIXED_REG_ID_BACKLIGHT,
1443 .platform_data = &backlight_fixed_voltage_config,
1447 static int slp10_backlight_power_on(struct backlight_device *bd, int enable)
1449 struct regulator *regulator;
1452 regulator = regulator_get(&bd->dev, "LCD_LDO_EN");
1453 if (IS_ERR(regulator))
1456 regulator_enable(regulator);
1457 regulator_put(regulator);
1459 regulator = regulator_get(&bd->dev, "LCD_LDO_EN");
1460 if (IS_ERR(regulator))
1463 regulator_disable(regulator);
1464 regulator_put(regulator);
1470 static int slp10_lcd_power_on(struct lcd_device *ld, unsigned int enable)
1472 struct regulator *regulator;
1475 printk(KERN_ERR "lcd device object is NULL.\n");
1480 regulator = regulator_get(&ld->dev, "LVDS_nSHDN");
1481 if (IS_ERR(regulator))
1484 regulator_enable(regulator);
1485 regulator_put(regulator);
1487 regulator = regulator_get(&ld->dev, "vcc_1.8v");
1488 if (IS_ERR(regulator))
1491 regulator_enable(regulator);
1492 regulator_put(regulator);
1494 regulator = regulator_get(&ld->dev, "vcc_1.8v");
1495 if (IS_ERR(regulator))
1498 regulator_disable(regulator);
1499 regulator_put(regulator);
1501 regulator = regulator_get(&ld->dev, "LVDS_nSHDN");
1502 if (IS_ERR(regulator))
1505 regulator_disable(regulator);
1506 regulator_put(regulator);
1512 static int slp10_backlight_init(struct device *dev)
1515 s3c_gpio_cfgpin(S5PV310_GPD0(0), S3C_GPIO_SFN(2));
1516 s3c_gpio_setpull(S5PV310_GPD0(0), S3C_GPIO_PULL_NONE);
1521 static int slp10_backlight_notify(struct device *dev, int brightness)
1529 static void __init early_lcd(char **param)
1532 if (strncmp(*param, "nt39411", 7) == 0)
1533 slp10_lcd_enabled = 1;
1535 __early_param("lcd", early_lcd);
1537 /* SLP10 backlight */
1538 static struct platform_pwm_backlight_data slp10_backlight_data = {
1540 .pwm_period_ns = 30000,
1541 .max_brightness = 100,
1542 .dft_brightness = 50,
1543 .init = slp10_backlight_init,
1544 .notify = slp10_backlight_notify,
1545 .power_on = slp10_backlight_power_on,
1548 static struct platform_device slp10_backlight_device = {
1549 .name = "pwm-backlight",
1552 .platform_data = &slp10_backlight_data,
1555 static struct plat_lcd_data slp10_lcd_platform_data = {
1556 .set_power = slp10_lcd_power_on,
1559 static struct platform_device slp10_lcd_device = {
1560 .name = "platform-lcd",
1563 .platform_data = &slp10_lcd_platform_data,
1567 #ifdef CONFIG_VIDEO_FIMG2D
1568 static struct fimg2d_platdata fimg2d_data __initdata = {
1570 .parent_clkname = "mout_g2d0",
1571 .clkname = "sclk_fimg2d",
1572 .gate_clkname = "fimg2d",
1573 .smmu_gate_clkname = "smmu_fimg2d",
1574 .clkrate = 250 * 1000000,
1578 static struct s3c_platform_fb fb_platform_data __initdata = {
1581 #ifdef CONFIG_FB_S3C_DEFAULT_WINDOW
1582 .default_win = CONFIG_FB_S3C_DEFAULT_WINDOW,
1586 .swap = FB_SWAP_HWORD | FB_SWAP_WORD,
1587 .screen_type = SCREEN_PORTRAIT,
1590 static void __init slp10_fb_init(void)
1592 struct device *dev = s3c_device_fb.dev.parent;
1593 struct samsung_pd_info *pdinfo;
1596 pdinfo = (struct samsung_pd_info *)dev->platform_data;
1597 /* fimd driver have to know LCD domain power status. */
1599 fb_platform_data.boot_on = pdinfo->boot_on;
1603 fb_platform_data.logo_on = 1;
1605 fb_platform_data.lcd_data = (struct s3cfb_lcd *)&slp10_lcd;
1607 platform_device_register(&slp10_lcd_device);
1608 platform_device_register(&lcd_fixed_voltage);
1609 platform_device_register(&slp10_backlight_device);
1610 platform_device_register(&backlight_fixed_voltage);
1613 s3cfb_set_platdata(&fb_platform_data);
1617 static struct jack_platform_data slp10_jack_data = {
1619 .charger_online = 0,
1621 .earjack_online = 0,
1622 .earkey_online = -1,
1628 static struct platform_device slp10_jack = {
1632 .platform_data = &slp10_jack_data,
1636 static struct slp10_charging_status_callbacks {
1637 void (*tsp_set_charging_cable) (int type);
1640 static bool is_cable_attached;
1642 static int slp10_charger_cb(cable_type_t cable_type)
1644 struct power_supply *psy = power_supply_get_by_name("battery");
1645 union power_supply_propval value;
1648 if(!psy || !psy->set_property) {
1649 pr_err("%s: fail to get battery psy\n", __func__);
1653 switch(cable_type) {
1654 case CABLE_TYPE_NONE:
1655 case CABLE_TYPE_OTG:
1656 case CABLE_TYPE_JIG_UART_OFF:
1657 value.intval = POWER_SUPPLY_TYPE_BATTERY;
1658 is_cable_attached = false;
1660 case CABLE_TYPE_USB:
1661 case CABLE_TYPE_JIG_USB_OFF:
1662 case CABLE_TYPE_JIG_USB_ON:
1663 value.intval = POWER_SUPPLY_TYPE_USB;
1664 is_cable_attached = true;
1666 case CABLE_TYPE_DESKDOCK:
1667 case CABLE_TYPE_CARDOCK:
1668 value.intval = POWER_SUPPLY_TYPE_DOCK;
1669 is_cable_attached = true;
1672 case CABLE_TYPE_JIG_UART_OFF_VB:
1673 value.intval = POWER_SUPPLY_TYPE_MAINS;
1674 is_cable_attached = true;
1677 pr_err("%s: invalid type:%d\n", __func__, cable_type);
1682 pr_err("%s: regulator_set failed. %d\n", __func__, ret);
1686 if (charging_cbs.tsp_set_charging_cable)
1687 charging_cbs.tsp_set_charging_cable(value.intval);
1689 ret = psy->set_property(psy, POWER_SUPPLY_PROP_ONLINE, &value);
1691 #ifdef CONFIG_JACK_MON
1692 jack_event_handler("charger", is_cable_attached);
1698 static struct regulator *regulator_vbus_ap;
1699 static bool ap_enabled;
1700 static DEFINE_MUTEX(usb_ap_lock);
1702 static void slp10_usb_cb(u8 usb_mode)
1705 struct s3c_udc *udc = platform_get_drvdata(&s3c_device_usbgadget);
1706 struct sec_otghost_data *otg_data =
1707 dev_get_platdata(&s3c_device_usb_otghcd.dev);
1709 unsigned long inform6 = __raw_readl(S5P_INFORM6);
1711 pr_info("%s: usb mode=%d, inform6=0x%08lx\n", __func__, usb_mode, inform6);
1713 if (inform6 & RST_FLAG_CHARGE_REBOOT_CHECK ) {
1714 pr_info("%s: lpcharging: disable USB\n", __func__);
1715 ret = udc->change_usb_mode(USB_CABLE_DETACHED);
1717 pr_warn("%s: fail to change mode!!!\n", __func__);
1719 mutex_lock(&usb_ap_lock);
1721 if (regulator_vbus_ap == NULL)
1723 regulator_get_exclusive(NULL, "usb_vbus_ap_5v");
1724 if (IS_ERR_OR_NULL(regulator_vbus_ap)) {
1725 pr_err("%s: fail to get regulator\n", __func__);
1726 regulator_vbus_ap = NULL;
1731 ret = regulator_disable(regulator_vbus_ap);
1737 mutex_unlock(&usb_ap_lock);
1742 if (usb_mode == USB_OTGHOST_ATTACHED) {
1743 otg_data->set_pwr_cb(1);
1744 slp10_charger_cb(CABLE_TYPE_OTG);
1747 pr_info("%s: prev_usb_mode=%d\n", __func__, udc->get_usb_mode());
1749 ret = udc->change_usb_mode(usb_mode);
1751 pr_err("%s: fail to change mode!!!\n", __func__);
1753 if (usb_mode == USB_OTGHOST_DETACHED)
1754 otg_data->set_pwr_cb(0);
1756 #ifdef CONFIG_JACK_MON
1757 if (usb_mode == USB_OTGHOST_ATTACHED)
1758 jack_event_handler("host", USB_CABLE_ATTACHED);
1759 else if (usb_mode == USB_OTGHOST_DETACHED)
1760 jack_event_handler("host", USB_CABLE_DETACHED);
1761 else if ((usb_mode == USB_CABLE_ATTACHED)
1762 || (usb_mode == USB_CABLE_DETACHED))
1763 jack_event_handler("usb", usb_mode);
1768 static int slp10_set_safeout(int path)
1770 static struct regulator *regulator_vbus_cp;
1771 static bool cp_enabled;
1774 mutex_lock(&usb_ap_lock);
1776 if (regulator_vbus_ap == NULL)
1778 regulator_get_exclusive(NULL, "usb_vbus_ap_5v");
1779 if (IS_ERR_OR_NULL(regulator_vbus_ap)) {
1781 regulator_vbus_ap = NULL;
1785 if (regulator_vbus_cp == NULL)
1787 regulator_get_exclusive(NULL, "usb_vbus_cp_5v");
1788 if (IS_ERR_OR_NULL(regulator_vbus_cp)) {
1790 regulator_vbus_cp = NULL;
1794 if (path == CP_USB_MODE) {
1796 ret = regulator_disable(regulator_vbus_ap);
1803 /* regulator_vbus_cp is exclusively got */
1804 if (!regulator_is_enabled(regulator_vbus_cp))
1805 ret = regulator_enable(regulator_vbus_cp);
1811 /* AP_USB_MODE || AUDIO_MODE */
1813 /* regulator_vbus_ap is exclusively got */
1814 if (!regulator_is_enabled(regulator_vbus_ap))
1815 ret = regulator_enable(regulator_vbus_ap);
1822 ret = regulator_disable(regulator_vbus_cp);
1829 mutex_unlock(&usb_ap_lock);
1833 static struct switch_dev switch_dock = {
1837 static void slp10_deskdock_cb(bool attached)
1840 switch_set_state(&switch_dock, 1);
1842 switch_set_state(&switch_dock, 0);
1845 static void slp10_cardock_cb(bool attached)
1848 switch_set_state(&switch_dock, 2);
1850 switch_set_state(&switch_dock, 0);
1853 static void slp10_muic_init_cb(void)
1857 /* for CarDock, DeskDock */
1858 ret = switch_dev_register(&switch_dock);
1860 pr_err("Failed to register dock switch. %d\n", ret);
1863 static int slp10_host_notify_cb(int enable)
1865 struct host_notify_dev * ndev = NULL;
1867 if (s3c_device_usbgadget.dev.platform_data)
1868 ndev = s3c_device_usbgadget.dev.platform_data;
1870 pr_err("%s: ndev is null.\n", __func__);
1874 ndev->booster = enable ? NOTIFY_POWER_ON : NOTIFY_POWER_OFF;
1875 pr_info("%s: mode %d, enable %d\n", __func__, ndev->mode, enable);
1879 struct max8997_muic_platform_data slp10_muic_pdata = {
1880 .usb_cb = slp10_usb_cb,
1881 .charger_cb = slp10_charger_cb, /* done */
1882 .set_safeout = slp10_set_safeout, /* done */
1883 .init_cb = slp10_muic_init_cb, /* done */
1884 .deskdock_cb = slp10_deskdock_cb, /* done */
1885 .cardock_cb = slp10_cardock_cb, /* done */
1886 .host_notify_cb = slp10_host_notify_cb, /* done */
1887 .gpio_usb_sel = -1, /* not used */
1888 .uart_path = -1, /* muic does not control uart path*/
1891 static void slp10_set_usb_switch(int path)
1893 printk(KERN_INFO "set_usb_switch = [%d]\n",path);
1894 slp10_muic_pdata.sw_path = path;
1897 static int slp10_get_usb_switch(void)
1899 printk(KERN_INFO "get_usb_switch = [%d]\n",slp10_muic_pdata.sw_path);
1900 return slp10_muic_pdata.sw_path;
1903 /* Micro USB Switch */
1904 static struct micro_usb_switch_platform_data slp10_usb_switch_data = {
1905 .set_usb_switch = slp10_set_usb_switch,
1906 .get_usb_switch = slp10_get_usb_switch,
1909 static struct platform_device slp10_micro_usb_switch = {
1910 .name = "usb-switch",
1913 .platform_data = &slp10_usb_switch_data,
1918 static void slp10_pm_finish(void)
1920 /* Restore GPX conf */
1921 s3c_pm_do_restore(s5pc210_gpx, ARRAY_SIZE(s5pc210_gpx));
1924 static void slp10_pm_prepare(void)
1926 /* 1. Save GPX conf */
1927 s3c_pm_do_save(s5pc210_gpx, ARRAY_SIZE(s5pc210_gpx));
1929 /* 2. Set GPX as Power Save Mode */
1931 /* 3. Debug: Look at the diff */
1932 mobile_gpios_groupx_difference();
1936 int slp10_common_setup_clock(const char *sclk_name, const char *pclk_name,
1937 unsigned long rate, unsigned int rate_set)
1939 struct clk *sclk = NULL;
1940 struct clk *pclk = NULL;
1942 sclk = clk_get(NULL, sclk_name);
1944 printk(KERN_ERR "failed to get %s clock.\n", sclk_name);
1948 pclk = clk_get(NULL, pclk_name);
1950 printk(KERN_ERR "failed to get %s clock.\n", pclk_name);
1954 clk_set_parent(sclk, pclk);
1956 printk(KERN_INFO "set parent clock of %s to %s\n", sclk_name,
1964 clk_set_rate(sclk, rate);
1965 printk(KERN_INFO "set %s rate to %lu\n", sclk_name, rate);
1982 #ifdef CONFIG_S5PV310_DEV_PD
1983 static void inline powerdomain_boot_on(int pd)
1985 struct samsung_pd_info *pdinfo = (struct samsung_pd_info *)
1986 s5pv310_device_pd[pd].dev.platform_data;
1988 pdinfo->boot_on = true;
1992 #ifdef CONFIG_CHARGERCTRL_MAX8903
1993 static struct regulator_consumer_supply supplies_max8903[] = {
1994 REGULATOR_SUPPLY("vinchg2", "charger-manager.0"),
1997 static struct regulator_init_data max8903_charger_en_data = {
1999 .name = "VOUT_CHARGER",
2000 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
2003 .num_consumer_supplies = ARRAY_SIZE(supplies_max8903),
2004 .consumer_supplies = supplies_max8903,
2007 static struct fixed_voltage_config max8903_charger_en = {
2008 .supply_name = "VOUT_CHARGER",
2009 .microvolts = 5000000, /* Assume 5VDC */
2010 .gpio = S5PV310_GPY4(5), /* TA_EN negaged */
2011 .enable_high = 0, /* Enable = Low */
2012 .enabled_at_boot = 1,
2013 .init_data = &max8903_charger_en_data,
2016 static struct platform_device max8903_fixed_reg_dev = {
2017 .name = "reg-fixed-voltage",
2018 .id = FIXED_REG_ID_MAX8903,
2019 .dev = { .platform_data = &max8903_charger_en },
2022 static struct max8903_pdata slp10_max8903 = {
2024 * cen: don't control with the driver, let it be
2025 * controlled by regulator above
2027 .dok = S5PV310_GPX1(4), /* TA_nCONNECTED */
2028 /* uok, usus: not connected */
2029 .chg = S5PV310_GPE2(0), /* TA_nCHG */
2030 /* flt: vcc_1.8V_pda */
2031 .dcm = S5PV310_GPL0(1), /* CURR_ADJ */
2034 .usb_valid = false, /* USB is not wired to MAX8903 */
2037 static struct platform_device slp10_max8903_device = {
2038 .name = "max8903-charger",
2040 .platform_data = &slp10_max8903,
2044 static void max8903_init(void)
2049 gpio = slp10_max8903.dok;
2050 gpio_request(gpio, "TA_nCONNECTED");
2051 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
2052 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
2053 ta_en = gpio_get_value(gpio) ? 0 : 1;
2055 gpio = slp10_max8903.chg;
2056 gpio_request(gpio, "TA_nCHG");
2057 gpio_direction_input(gpio);
2059 gpio = slp10_max8903.dcm;
2060 gpio_request(gpio, "CURR_ADJ");
2061 gpio_direction_output(gpio, ta_en);
2065 #ifdef CONFIG_MHL_SII9234
2066 static void __init slp10_mhl_init(void)
2071 gpio_request(gpio, "MHL_INT");
2072 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
2073 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
2075 slp10_sii9234_pdata.mhl_int = gpio_to_irq(gpio);
2078 #define slp10_mhl_init() do { } while (0)
2081 #ifdef CONFIG_CHARGER_MANAGER
2082 extern struct platform_device slp7_charger_manager;
2083 extern struct platform_device slp7_ncp15wb473_thermistor;
2085 static struct platform_device *slp10_devices[] __initdata = {
2086 /* Samsung Platform Devices */
2087 #ifdef CONFIG_S5PV310_DEV_PD
2088 &s5pv310_device_pd[PD_MFC],
2089 &s5pv310_device_pd[PD_G3D],
2090 &s5pv310_device_pd[PD_LCD0],
2091 &s5pv310_device_pd[PD_LCD1],
2092 &s5pv310_device_pd[PD_TV],
2093 &s5pv310_device_pd[PD_CAM],
2094 &s5pv310_device_pd[PD_GPS],
2096 #ifdef CONFIG_DRM_MALI
2097 &s5p_device_mali_drm,
2099 #ifdef CONFIG_DRM_FIMD
2100 &s5p_device_fimd_drm,
2112 &s3c_device_timer[0],
2113 &s3c_device_timer[1],
2115 #ifdef CONFIG_S3C_DEV_RTC
2119 #ifdef CONFIG_VIDEO_JPEG
2122 #ifdef CONFIG_VIDEO_FIMC
2129 #ifdef CONFIG_USB_GADGET
2130 &s3c_device_usbgadget,
2132 #ifdef CONFIG_USB_ANDROID_RNDIS
2135 #ifdef CONFIG_USB_ANDROID_ECM
2138 #ifdef CONFIG_USB_ANDROID
2139 &s3c_device_android_usb,
2140 &s3c_device_usb_mass_storage,
2142 #ifdef CONFIG_USB_S3C_OTG_HOST
2143 &s3c_device_usb_otghcd,
2145 #ifdef CONFIG_S3C_DEV_HSMMC4
2150 &emmc_fixed_voltage,
2156 #ifdef CONFIG_SND_S3C64XX_SOC_I2S_V4
2157 &s5pv310_device_iis0,
2159 #ifdef CONFIG_SND_S3C_SOC_PCM
2160 &s5pv310_device_pcm1,
2162 #ifdef CONFIG_SND_SOC_SMDK_WM9713
2163 &s5pv310_device_ac97,
2165 #ifdef CONFIG_SND_SAMSUNG_SOC_SPDIF
2166 &s5pv310_device_spdif,
2168 #ifdef CONFIG_SND_S5P_RP
2176 &slp10_micro_usb_switch,
2178 #ifdef CONFIG_S3C2410_WATCHDOG
2182 #ifdef CONFIG_FB_S3C
2185 #ifdef CONFIG_VIDEO_FIMG2D
2188 #ifdef CONFIG_VIDEO_MFC5X
2192 #ifdef CONFIG_S5P_SYSMMU
2193 &s5p_device_sysmmu[SYSMMU_G2D],
2194 &s5p_device_sysmmu[SYSMMU_MFC_L],
2195 &s5p_device_sysmmu[SYSMMU_MFC_R],
2196 &s5p_device_sysmmu[SYSMMU_FIMC0],
2197 &s5p_device_sysmmu[SYSMMU_FIMC1],
2198 &s5p_device_sysmmu[SYSMMU_FIMC2],
2199 &s5p_device_sysmmu[SYSMMU_FIMC3],
2201 #ifdef CONFIG_ANDROID_RAM_CONSOLE
2202 &ram_console_device,
2204 #ifdef CONFIG_CHARGERCTRL_MAX8903
2205 &slp10_max8903_device,
2206 &max8903_fixed_reg_dev,
2209 #ifdef CONFIG_CHARGER_MANAGER
2210 /* Should be placed after fuel gauge, charger control chips, pmics */
2211 #ifdef CONFIG_SENSORS_NTC_THERMISTOR
2212 &slp7_ncp15wb473_thermistor, /* No changes made from SLP7 */
2214 &slp7_charger_manager, /* No changes made from SLP7 */
2216 #ifdef CONFIG_DEV_THERMAL
2221 &s5p_device_usb_ehci,
2224 extern void (*s5p_inform6_set)(char mode);
2225 extern void s5pv310_inform6_set(char mode);
2226 extern struct machine_desc *lookup_machine_type(unsigned int);
2228 static void __init slp10_machine_init(void)
2232 struct machine_desc *list;
2233 list = lookup_machine_type(machine_arch_type);
2234 strcpy(utsname()->nodename, list->name);
2236 /* Initialize GPIO default setting */
2237 mobile_gpios_init();
2239 /* to support system shut down */
2240 pm_power_off = slp10_power_off;
2242 /* to support inform6 set */
2243 s5p_inform6_set = s5pv310_inform6_set;
2245 s3c_i2c0_set_platdata(&slp10_i2c0_platdata);
2247 slp10_sensor_init();
2248 slp10_light_sensor_init();
2249 s3c_i2c1_set_platdata(NULL);
2250 i2c_register_board_info(1, i2c1_devs, ARRAY_SIZE(i2c1_devs));
2253 s3c_i2c3_set_platdata(&slp10_i2c3_platdata);
2254 i2c_register_board_info(3, i2c3_devs, ARRAY_SIZE(i2c3_devs));
2256 #ifdef CONFIG_S5PV310_DEV_PD
2257 #ifdef CONFIG_FB_S3C
2258 s3c_device_fb.dev.parent = &s5pv310_device_pd[PD_LCD0].dev;
2259 powerdomain_boot_on(PD_LCD0);
2264 slp10_common_setup_clock("sclk_mdnie0", "mout_mpll", 400 * MHZ, 1);
2266 #ifdef CONFIG_CHARGERCTRL_MAX8903
2270 s3c_i2c5_set_platdata(NULL);
2271 i2c5_devs[I2C5_MAX8997].irq = gpio_to_irq(S5PV310_GPX0(7)), /* AP_PMIC_IRQ */
2272 i2c_register_board_info(5, i2c5_devs, ARRAY_SIZE(i2c5_devs));
2275 s3c_i2c6_set_platdata(NULL);
2276 i2c_register_board_info(6, i2c6_devs, ARRAY_SIZE(i2c6_devs));
2280 s3c_i2c7_set_platdata(NULL);
2281 i2c_register_board_info(7, i2c7_devs, ARRAY_SIZE(i2c7_devs));
2283 gpio = S5PV310_GPX2(3);
2284 gpio_request(gpio, "FUEL_ALERT");
2285 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
2286 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
2287 i2c9_devs[I2C9_MAX17042].irq = gpio_to_irq(gpio);
2288 i2c_register_board_info(9, i2c9_devs, ARRAY_SIZE(i2c9_devs));
2290 i2c_register_board_info(14, i2c14_devs, ARRAY_SIZE(i2c14_devs));
2292 i2c_register_board_info(15, i2c15_devs, ARRAY_SIZE(i2c15_devs));
2294 slp10_usb_ehci_init();
2295 slp10_usb_otg_init();
2299 #ifdef CONFIG_VIDEO_FIMG2D
2300 s5p_fimg2d_set_platdata(&fimg2d_data);
2301 #ifdef CONFIG_S5PV310_DEV_PD
2302 s5p_device_fimg2d.dev.parent = &s5pv310_device_pd[PD_LCD0].dev;
2307 pm_cpu_prepare = slp10_pm_prepare;
2308 pm_cpu_finish = slp10_pm_finish;
2311 s3c_irq_wake(IRQ_RTC_ALARM, 1);
2314 #if defined(CONFIG_S5PV310_DEV_PD) && !defined(CONFIG_PM_RUNTIME)
2316 * These power domains should be always on
2317 * without runtime pm support.
2319 s5pv310_pd_enable(&s5pv310_device_pd[PD_MFC].dev);
2320 s5pv310_pd_enable(&s5pv310_device_pd[PD_G3D].dev);
2321 s5pv310_pd_enable(&s5pv310_device_pd[PD_LCD0].dev);
2322 s5pv310_pd_enable(&s5pv310_device_pd[PD_LCD1].dev);
2323 s5pv310_pd_enable(&s5pv310_device_pd[PD_CAM].dev);
2324 s5pv310_pd_enable(&s5pv310_device_pd[PD_TV].dev);
2325 s5pv310_pd_enable(&s5pv310_device_pd[PD_GPS].dev);
2328 #ifdef CONFIG_VIDEO_FIMG2D
2329 /* setup fimg2d parent clock. */
2330 universal_fimg2d_setup_clock("mout_g2d0", "mout_mpll");
2332 #ifdef CONFIG_S5PV310_DEV_PD
2333 #ifdef CONFIG_VIDEO_MFC5X
2334 s5p_device_mfc.dev.parent = &s5pv310_device_pd[PD_MFC].dev;
2335 slp10_common_setup_clock("mout_mfc0", "mout_mpll", 0, 0);
2336 slp10_common_setup_clock("sclk_mfc", "mout_mfc0", 200 * MHZ, 1);
2341 #ifdef CONFIG_S5P_ADC
2345 #ifdef CONFIG_DEV_THERMAL
2346 s5p_tmu_set_platdata(NULL);
2349 #ifdef CONFIG_VIDEO_JPEG
2350 #ifdef CONFIG_S5PV310_DEV_PD
2351 s5p_device_jpeg.dev.parent = &s5pv310_device_pd[PD_CAM].dev;
2354 #ifdef CONFIG_CHARGER_MANAGER
2355 setup_charger_manager(&slp7_charger_g_desc);
2358 s5pv310_camera_init();
2361 platform_add_devices(slp10_devices, ARRAY_SIZE(slp10_devices));
2362 regulator_has_full_constraints();
2364 subrev = s5pv310_subrev();
2365 /* to support new STAB10 target*/
2366 if ((subrev != 0) && (subrev != 1)) {
2367 pr_emerg("\n\n This kernel does NOT support subrevision %d of S5PC210.\n\n\n", subrev);
2368 panic("Not supported subrevision");
2372 MACHINE_START(SLP10_C210, "SLP10_C210")
2373 /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */
2374 .phys_io = S3C_PA_UART & 0xfff00000,
2375 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
2376 .boot_params = S5P_PA_SDRAM + 0x100,
2377 .init_irq = s5pv310_init_irq,
2378 .map_io = slp10_map_io,
2379 .init_machine = slp10_machine_init,
2380 .timer = &s5pv310_timer,
2381 .reserve = &s5pv310_reserve,