2 * linux/arch/arm/mach-exynos4/mach-nuri.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/i2c.h>
15 #include <linux/i2c/atmel_mxt_ts.h>
16 #include <linux/gpio_keys.h>
17 #include <linux/gpio.h>
18 #include <linux/regulator/machine.h>
19 #include <linux/regulator/fixed.h>
20 #include <linux/mmc/host.h>
22 #include <linux/pwm_backlight.h>
24 #include <video/platform_lcd.h>
26 #include <asm/mach/arch.h>
27 #include <asm/mach-types.h>
29 #include <plat/regs-serial.h>
30 #include <plat/exynos4.h>
32 #include <plat/devs.h>
33 #include <plat/sdhci.h>
34 #include <plat/gpio-cfg.h>
39 /* Following are default values for UCON, ULCON and UFCON UART registers */
40 #define NURI_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
41 S3C2410_UCON_RXILEVEL | \
42 S3C2410_UCON_TXIRQMODE | \
43 S3C2410_UCON_RXIRQMODE | \
44 S3C2410_UCON_RXFIFO_TOI | \
45 S3C2443_UCON_RXERR_IRQEN)
47 #define NURI_ULCON_DEFAULT S3C2410_LCON_CS8
49 #define NURI_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \
50 S5PV210_UFCON_TXTRIG256 | \
51 S5PV210_UFCON_RXTRIG256)
53 enum fixed_regulator_id {
57 static struct s3c2410_uartcfg nuri_uartcfgs[] __initdata = {
60 .ucon = NURI_UCON_DEFAULT,
61 .ulcon = NURI_ULCON_DEFAULT,
62 .ufcon = NURI_UFCON_DEFAULT,
66 .ucon = NURI_UCON_DEFAULT,
67 .ulcon = NURI_ULCON_DEFAULT,
68 .ufcon = NURI_UFCON_DEFAULT,
72 .ucon = NURI_UCON_DEFAULT,
73 .ulcon = NURI_ULCON_DEFAULT,
74 .ufcon = NURI_UFCON_DEFAULT,
78 .ucon = NURI_UCON_DEFAULT,
79 .ulcon = NURI_ULCON_DEFAULT,
80 .ufcon = NURI_UFCON_DEFAULT,
85 static struct s3c_sdhci_platdata nuri_hsmmc0_data __initdata = {
87 .host_caps = (MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA |
88 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
89 MMC_CAP_DISABLE | MMC_CAP_ERASE),
90 .cd_type = S3C_SDHCI_CD_PERMANENT,
91 .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,
94 static struct regulator_consumer_supply emmc_supplies[] = {
95 REGULATOR_SUPPLY("vmmc", "s3c-sdhci.0"),
96 REGULATOR_SUPPLY("vmmc", "dw_mmc"),
99 static struct regulator_init_data emmc_fixed_voltage_init_data = {
101 .name = "VMEM_VDD_2.8V",
102 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
104 .num_consumer_supplies = ARRAY_SIZE(emmc_supplies),
105 .consumer_supplies = emmc_supplies,
108 static struct fixed_voltage_config emmc_fixed_voltage_config = {
109 .supply_name = "MASSMEMORY_EN (inverted)",
110 .microvolts = 2800000,
111 .gpio = EXYNOS4_GPL1(1),
112 .enable_high = false,
113 .init_data = &emmc_fixed_voltage_init_data,
116 static struct platform_device emmc_fixed_voltage = {
117 .name = "reg-fixed-voltage",
118 .id = FIXED_REG_ID_MMC,
120 .platform_data = &emmc_fixed_voltage_config,
125 static struct s3c_sdhci_platdata nuri_hsmmc2_data __initdata = {
127 .host_caps = MMC_CAP_4_BIT_DATA |
128 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
130 .ext_cd_gpio = EXYNOS4_GPX3(3), /* XEINT_27 */
131 .ext_cd_gpio_invert = 1,
132 .cd_type = S3C_SDHCI_CD_GPIO,
133 .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,
137 static struct s3c_sdhci_platdata nuri_hsmmc3_data __initdata = {
139 .host_caps = MMC_CAP_4_BIT_DATA |
140 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
141 .cd_type = S3C_SDHCI_CD_EXTERNAL,
142 .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,
145 static void __init nuri_sdhci_init(void)
147 s3c_sdhci0_set_platdata(&nuri_hsmmc0_data);
148 s3c_sdhci2_set_platdata(&nuri_hsmmc2_data);
149 s3c_sdhci3_set_platdata(&nuri_hsmmc3_data);
153 static struct gpio_keys_button nuri_gpio_keys_tables[] = {
155 .code = KEY_VOLUMEUP,
156 .gpio = EXYNOS4_GPX2(0), /* XEINT16 */
157 .desc = "gpio-keys: KEY_VOLUMEUP",
160 .debounce_interval = 1,
162 .code = KEY_VOLUMEDOWN,
163 .gpio = EXYNOS4_GPX2(1), /* XEINT17 */
164 .desc = "gpio-keys: KEY_VOLUMEDOWN",
167 .debounce_interval = 1,
170 .gpio = EXYNOS4_GPX2(7), /* XEINT23 */
171 .desc = "gpio-keys: KEY_POWER",
175 .debounce_interval = 1,
179 static struct gpio_keys_platform_data nuri_gpio_keys_data = {
180 .buttons = nuri_gpio_keys_tables,
181 .nbuttons = ARRAY_SIZE(nuri_gpio_keys_tables),
184 static struct platform_device nuri_gpio_keys = {
187 .platform_data = &nuri_gpio_keys_data,
191 static void nuri_lcd_power_on(struct plat_lcd_data *pd, unsigned int power)
193 int gpio = EXYNOS4_GPE1(5);
195 gpio_request(gpio, "LVDS_nSHDN");
196 gpio_direction_output(gpio, power);
200 static int nuri_bl_init(struct device *dev)
202 int ret, gpio = EXYNOS4_GPE2(3);
204 ret = gpio_request(gpio, "LCD_LDO_EN");
206 gpio_direction_output(gpio, 0);
211 static int nuri_bl_notify(struct device *dev, int brightness)
216 gpio_set_value(EXYNOS4_GPE2(3), 1);
221 static void nuri_bl_exit(struct device *dev)
223 gpio_free(EXYNOS4_GPE2(3));
226 /* nuri pwm backlight */
227 static struct platform_pwm_backlight_data nuri_backlight_data = {
229 .pwm_period_ns = 30000,
230 .max_brightness = 100,
231 .dft_brightness = 50,
232 .init = nuri_bl_init,
233 .notify = nuri_bl_notify,
234 .exit = nuri_bl_exit,
237 static struct platform_device nuri_backlight_device = {
238 .name = "pwm-backlight",
241 .parent = &s3c_device_timer[0].dev,
242 .platform_data = &nuri_backlight_data,
246 static struct plat_lcd_data nuri_lcd_platform_data = {
247 .set_power = nuri_lcd_power_on,
250 static struct platform_device nuri_lcd_device = {
251 .name = "platform-lcd",
254 .platform_data = &nuri_lcd_platform_data,
259 static struct i2c_board_info i2c1_devs[] __initdata = {
260 /* Gyro, To be updated */
264 static u8 mxt_init_vals[] = {
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, 0x00, 0x00, 0x00, 0x09, 0x23,
271 /* MXT_TOUCH_MULTI(9) */
272 0x00, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00,
273 0x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00,
274 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
276 /* MXT_TOUCH_KEYARRAY(15) */
277 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
279 /* MXT_SPT_GPIOPWM(19) */
280 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
281 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
282 /* MXT_PROCI_GRIPFACE(20) */
283 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x28, 0x04,
285 /* MXT_PROCG_NOISE(22) */
286 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x23, 0x00,
287 0x00, 0x05, 0x0f, 0x19, 0x23, 0x2d, 0x03,
288 /* MXT_TOUCH_PROXIMITY(23) */
289 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
290 0x00, 0x00, 0x00, 0x00, 0x00,
291 /* MXT_PROCI_ONETOUCH(24) */
292 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
293 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
294 /* MXT_SPT_SELFTEST(25) */
295 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
296 0x00, 0x00, 0x00, 0x00,
297 /* MXT_PROCI_TWOTOUCH(27) */
298 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
299 /* MXT_SPT_CTECONFIG(28) */
300 0x00, 0x00, 0x02, 0x08, 0x10, 0x00,
303 static struct mxt_platform_data mxt_platform_data = {
304 .config = mxt_init_vals,
305 .config_length = ARRAY_SIZE(mxt_init_vals),
313 .voltage = 2800000, /* 2.8V */
314 .orient = MXT_DIAGONAL_COUNTER,
315 .irqflags = IRQF_TRIGGER_FALLING,
318 static struct s3c2410_platform_i2c i2c3_data __initdata = {
322 .frequency = 400 * 1000,
326 static struct i2c_board_info i2c3_devs[] __initdata = {
328 I2C_BOARD_INFO("atmel_mxt_ts", 0x4a),
329 .platform_data = &mxt_platform_data,
334 static void __init nuri_tsp_init(void)
338 /* TOUCH_INT: XEINT_4 */
339 gpio = EXYNOS4_GPX0(4);
340 gpio_request(gpio, "TOUCH_INT");
341 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
342 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
345 /* GPIO I2C 5 (PMIC) */
346 static struct i2c_board_info i2c5_devs[] __initdata = {
347 /* max8997, To be updated */
350 static struct platform_device *nuri_devices[] __initdata = {
351 /* Samsung Platform Devices */
357 &s3c_device_timer[0],
363 &nuri_backlight_device,
366 static void __init nuri_map_io(void)
368 s5p_init_io(NULL, 0, S5P_VA_CHIPID);
369 s3c24xx_init_clocks(24000000);
370 s3c24xx_init_uarts(nuri_uartcfgs, ARRAY_SIZE(nuri_uartcfgs));
373 static void __init nuri_machine_init(void)
378 i2c_register_board_info(1, i2c1_devs, ARRAY_SIZE(i2c1_devs));
379 s3c_i2c3_set_platdata(&i2c3_data);
380 i2c_register_board_info(3, i2c3_devs, ARRAY_SIZE(i2c3_devs));
381 i2c_register_board_info(5, i2c5_devs, ARRAY_SIZE(i2c5_devs));
384 platform_add_devices(nuri_devices, ARRAY_SIZE(nuri_devices));
387 MACHINE_START(NURI, "NURI")
388 /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */
389 .boot_params = S5P_PA_SDRAM + 0x100,
390 .init_irq = exynos4_init_irq,
391 .map_io = nuri_map_io,
392 .init_machine = nuri_machine_init,
393 .timer = &exynos4_timer,