Path: blob/master/arch/arm/mach-exynos4/mach-nuri.c
10817 views
/*1* linux/arch/arm/mach-exynos4/mach-nuri.c2*3* Copyright (c) 2011 Samsung Electronics Co., Ltd.4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License version 2 as7* published by the Free Software Foundation.8*/910#include <linux/platform_device.h>11#include <linux/serial_core.h>12#include <linux/input.h>13#include <linux/i2c.h>14#include <linux/i2c/atmel_mxt_ts.h>15#include <linux/gpio_keys.h>16#include <linux/gpio.h>17#include <linux/regulator/machine.h>18#include <linux/regulator/fixed.h>19#include <linux/mmc/host.h>20#include <linux/fb.h>21#include <linux/pwm_backlight.h>2223#include <video/platform_lcd.h>2425#include <asm/mach/arch.h>26#include <asm/mach-types.h>2728#include <plat/regs-serial.h>29#include <plat/exynos4.h>30#include <plat/cpu.h>31#include <plat/devs.h>32#include <plat/sdhci.h>33#include <plat/ehci.h>34#include <plat/clock.h>35#include <plat/gpio-cfg.h>36#include <plat/iic.h>3738#include <mach/map.h>3940/* Following are default values for UCON, ULCON and UFCON UART registers */41#define NURI_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \42S3C2410_UCON_RXILEVEL | \43S3C2410_UCON_TXIRQMODE | \44S3C2410_UCON_RXIRQMODE | \45S3C2410_UCON_RXFIFO_TOI | \46S3C2443_UCON_RXERR_IRQEN)4748#define NURI_ULCON_DEFAULT S3C2410_LCON_CS84950#define NURI_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \51S5PV210_UFCON_TXTRIG256 | \52S5PV210_UFCON_RXTRIG256)5354enum fixed_regulator_id {55FIXED_REG_ID_MMC = 0,56};5758static struct s3c2410_uartcfg nuri_uartcfgs[] __initdata = {59{60.hwport = 0,61.ucon = NURI_UCON_DEFAULT,62.ulcon = NURI_ULCON_DEFAULT,63.ufcon = NURI_UFCON_DEFAULT,64},65{66.hwport = 1,67.ucon = NURI_UCON_DEFAULT,68.ulcon = NURI_ULCON_DEFAULT,69.ufcon = NURI_UFCON_DEFAULT,70},71{72.hwport = 2,73.ucon = NURI_UCON_DEFAULT,74.ulcon = NURI_ULCON_DEFAULT,75.ufcon = NURI_UFCON_DEFAULT,76},77{78.hwport = 3,79.ucon = NURI_UCON_DEFAULT,80.ulcon = NURI_ULCON_DEFAULT,81.ufcon = NURI_UFCON_DEFAULT,82},83};8485/* eMMC */86static struct s3c_sdhci_platdata nuri_hsmmc0_data __initdata = {87.max_width = 8,88.host_caps = (MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA |89MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |90MMC_CAP_DISABLE | MMC_CAP_ERASE),91.cd_type = S3C_SDHCI_CD_PERMANENT,92.clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,93};9495static struct regulator_consumer_supply emmc_supplies[] = {96REGULATOR_SUPPLY("vmmc", "s3c-sdhci.0"),97REGULATOR_SUPPLY("vmmc", "dw_mmc"),98};99100static struct regulator_init_data emmc_fixed_voltage_init_data = {101.constraints = {102.name = "VMEM_VDD_2.8V",103.valid_ops_mask = REGULATOR_CHANGE_STATUS,104},105.num_consumer_supplies = ARRAY_SIZE(emmc_supplies),106.consumer_supplies = emmc_supplies,107};108109static struct fixed_voltage_config emmc_fixed_voltage_config = {110.supply_name = "MASSMEMORY_EN (inverted)",111.microvolts = 2800000,112.gpio = EXYNOS4_GPL1(1),113.enable_high = false,114.init_data = &emmc_fixed_voltage_init_data,115};116117static struct platform_device emmc_fixed_voltage = {118.name = "reg-fixed-voltage",119.id = FIXED_REG_ID_MMC,120.dev = {121.platform_data = &emmc_fixed_voltage_config,122},123};124125/* SD */126static struct s3c_sdhci_platdata nuri_hsmmc2_data __initdata = {127.max_width = 4,128.host_caps = MMC_CAP_4_BIT_DATA |129MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |130MMC_CAP_DISABLE,131.ext_cd_gpio = EXYNOS4_GPX3(3), /* XEINT_27 */132.ext_cd_gpio_invert = 1,133.cd_type = S3C_SDHCI_CD_GPIO,134.clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,135};136137/* WLAN */138static struct s3c_sdhci_platdata nuri_hsmmc3_data __initdata = {139.max_width = 4,140.host_caps = MMC_CAP_4_BIT_DATA |141MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,142.cd_type = S3C_SDHCI_CD_EXTERNAL,143.clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,144};145146static void __init nuri_sdhci_init(void)147{148s3c_sdhci0_set_platdata(&nuri_hsmmc0_data);149s3c_sdhci2_set_platdata(&nuri_hsmmc2_data);150s3c_sdhci3_set_platdata(&nuri_hsmmc3_data);151}152153/* GPIO KEYS */154static struct gpio_keys_button nuri_gpio_keys_tables[] = {155{156.code = KEY_VOLUMEUP,157.gpio = EXYNOS4_GPX2(0), /* XEINT16 */158.desc = "gpio-keys: KEY_VOLUMEUP",159.type = EV_KEY,160.active_low = 1,161.debounce_interval = 1,162}, {163.code = KEY_VOLUMEDOWN,164.gpio = EXYNOS4_GPX2(1), /* XEINT17 */165.desc = "gpio-keys: KEY_VOLUMEDOWN",166.type = EV_KEY,167.active_low = 1,168.debounce_interval = 1,169}, {170.code = KEY_POWER,171.gpio = EXYNOS4_GPX2(7), /* XEINT23 */172.desc = "gpio-keys: KEY_POWER",173.type = EV_KEY,174.active_low = 1,175.wakeup = 1,176.debounce_interval = 1,177},178};179180static struct gpio_keys_platform_data nuri_gpio_keys_data = {181.buttons = nuri_gpio_keys_tables,182.nbuttons = ARRAY_SIZE(nuri_gpio_keys_tables),183};184185static struct platform_device nuri_gpio_keys = {186.name = "gpio-keys",187.dev = {188.platform_data = &nuri_gpio_keys_data,189},190};191192static void nuri_lcd_power_on(struct plat_lcd_data *pd, unsigned int power)193{194int gpio = EXYNOS4_GPE1(5);195196gpio_request(gpio, "LVDS_nSHDN");197gpio_direction_output(gpio, power);198gpio_free(gpio);199}200201static int nuri_bl_init(struct device *dev)202{203int ret, gpio = EXYNOS4_GPE2(3);204205ret = gpio_request(gpio, "LCD_LDO_EN");206if (!ret)207gpio_direction_output(gpio, 0);208209return ret;210}211212static int nuri_bl_notify(struct device *dev, int brightness)213{214if (brightness < 1)215brightness = 0;216217gpio_set_value(EXYNOS4_GPE2(3), 1);218219return brightness;220}221222static void nuri_bl_exit(struct device *dev)223{224gpio_free(EXYNOS4_GPE2(3));225}226227/* nuri pwm backlight */228static struct platform_pwm_backlight_data nuri_backlight_data = {229.pwm_id = 0,230.pwm_period_ns = 30000,231.max_brightness = 100,232.dft_brightness = 50,233.init = nuri_bl_init,234.notify = nuri_bl_notify,235.exit = nuri_bl_exit,236};237238static struct platform_device nuri_backlight_device = {239.name = "pwm-backlight",240.id = -1,241.dev = {242.parent = &s3c_device_timer[0].dev,243.platform_data = &nuri_backlight_data,244},245};246247static struct plat_lcd_data nuri_lcd_platform_data = {248.set_power = nuri_lcd_power_on,249};250251static struct platform_device nuri_lcd_device = {252.name = "platform-lcd",253.id = -1,254.dev = {255.platform_data = &nuri_lcd_platform_data,256},257};258259/* I2C1 */260static struct i2c_board_info i2c1_devs[] __initdata = {261/* Gyro, To be updated */262};263264/* TSP */265static u8 mxt_init_vals[] = {266/* MXT_GEN_COMMAND(6) */2670x00, 0x00, 0x00, 0x00, 0x00, 0x00,268/* MXT_GEN_POWER(7) */2690x20, 0xff, 0x32,270/* MXT_GEN_ACQUIRE(8) */2710x0a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x23,272/* MXT_TOUCH_MULTI(9) */2730x00, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00,2740x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00,2750x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,2760x00,277/* MXT_TOUCH_KEYARRAY(15) */2780x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,2790x00,280/* MXT_SPT_GPIOPWM(19) */2810x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,2820x00, 0x00, 0x00, 0x00, 0x00, 0x00,283/* MXT_PROCI_GRIPFACE(20) */2840x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x28, 0x04,2850x0f, 0x0a,286/* MXT_PROCG_NOISE(22) */2870x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x23, 0x00,2880x00, 0x05, 0x0f, 0x19, 0x23, 0x2d, 0x03,289/* MXT_TOUCH_PROXIMITY(23) */2900x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,2910x00, 0x00, 0x00, 0x00, 0x00,292/* MXT_PROCI_ONETOUCH(24) */2930x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,2940x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,295/* MXT_SPT_SELFTEST(25) */2960x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,2970x00, 0x00, 0x00, 0x00,298/* MXT_PROCI_TWOTOUCH(27) */2990x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,300/* MXT_SPT_CTECONFIG(28) */3010x00, 0x00, 0x02, 0x08, 0x10, 0x00,302};303304static struct mxt_platform_data mxt_platform_data = {305.config = mxt_init_vals,306.config_length = ARRAY_SIZE(mxt_init_vals),307308.x_line = 18,309.y_line = 11,310.x_size = 1024,311.y_size = 600,312.blen = 0x1,313.threshold = 0x28,314.voltage = 2800000, /* 2.8V */315.orient = MXT_DIAGONAL_COUNTER,316.irqflags = IRQF_TRIGGER_FALLING,317};318319static struct s3c2410_platform_i2c i2c3_data __initdata = {320.flags = 0,321.bus_num = 3,322.slave_addr = 0x10,323.frequency = 400 * 1000,324.sda_delay = 100,325};326327static struct i2c_board_info i2c3_devs[] __initdata = {328{329I2C_BOARD_INFO("atmel_mxt_ts", 0x4a),330.platform_data = &mxt_platform_data,331.irq = IRQ_EINT(4),332},333};334335static void __init nuri_tsp_init(void)336{337int gpio;338339/* TOUCH_INT: XEINT_4 */340gpio = EXYNOS4_GPX0(4);341gpio_request(gpio, "TOUCH_INT");342s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));343s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);344}345346/* GPIO I2C 5 (PMIC) */347static struct i2c_board_info i2c5_devs[] __initdata = {348/* max8997, To be updated */349};350351/* USB EHCI */352static struct s5p_ehci_platdata nuri_ehci_pdata;353354static void __init nuri_ehci_init(void)355{356struct s5p_ehci_platdata *pdata = &nuri_ehci_pdata;357358s5p_ehci_set_platdata(pdata);359}360361static struct platform_device *nuri_devices[] __initdata = {362/* Samsung Platform Devices */363&emmc_fixed_voltage,364&s3c_device_hsmmc0,365&s3c_device_hsmmc2,366&s3c_device_hsmmc3,367&s3c_device_wdt,368&s3c_device_timer[0],369&s5p_device_ehci,370&s3c_device_i2c3,371372/* NURI Devices */373&nuri_gpio_keys,374&nuri_lcd_device,375&nuri_backlight_device,376};377378static void __init nuri_map_io(void)379{380s5p_init_io(NULL, 0, S5P_VA_CHIPID);381s3c24xx_init_clocks(24000000);382s3c24xx_init_uarts(nuri_uartcfgs, ARRAY_SIZE(nuri_uartcfgs));383}384385static void __init nuri_machine_init(void)386{387nuri_sdhci_init();388nuri_tsp_init();389390i2c_register_board_info(1, i2c1_devs, ARRAY_SIZE(i2c1_devs));391s3c_i2c3_set_platdata(&i2c3_data);392i2c_register_board_info(3, i2c3_devs, ARRAY_SIZE(i2c3_devs));393i2c_register_board_info(5, i2c5_devs, ARRAY_SIZE(i2c5_devs));394395nuri_ehci_init();396clk_xusbxti.rate = 24000000;397398/* Last */399platform_add_devices(nuri_devices, ARRAY_SIZE(nuri_devices));400}401402MACHINE_START(NURI, "NURI")403/* Maintainer: Kyungmin Park <[email protected]> */404.boot_params = S5P_PA_SDRAM + 0x100,405.init_irq = exynos4_init_irq,406.map_io = nuri_map_io,407.init_machine = nuri_machine_init,408.timer = &exynos4_timer,409MACHINE_END410411412