Minkyu Kang | caf8b1f2 | 2011-02-28 20:39:43 +0900 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-exynos4/mach-nuri.c |
| 3 | * |
| 4 | * Copyright (c) 2011 Samsung Electronics Co., Ltd. |
| 5 | * |
| 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. |
| 9 | */ |
| 10 | |
| 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/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> |
Donghwa Lee | cc7df87 | 2011-03-08 07:17:09 +0900 | [diff] [blame] | 20 | #include <linux/fb.h> |
| 21 | #include <linux/pwm_backlight.h> |
| 22 | |
| 23 | #include <video/platform_lcd.h> |
Minkyu Kang | caf8b1f2 | 2011-02-28 20:39:43 +0900 | [diff] [blame] | 24 | |
| 25 | #include <asm/mach/arch.h> |
| 26 | #include <asm/mach-types.h> |
| 27 | |
| 28 | #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> |
Joonyoung Shim | 01da92f | 2011-04-08 13:22:11 +0900 | [diff] [blame^] | 33 | #include <plat/ehci.h> |
| 34 | #include <plat/clock.h> |
Minkyu Kang | caf8b1f2 | 2011-02-28 20:39:43 +0900 | [diff] [blame] | 35 | |
| 36 | #include <mach/map.h> |
| 37 | |
| 38 | /* Following are default values for UCON, ULCON and UFCON UART registers */ |
| 39 | #define NURI_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \ |
| 40 | S3C2410_UCON_RXILEVEL | \ |
| 41 | S3C2410_UCON_TXIRQMODE | \ |
| 42 | S3C2410_UCON_RXIRQMODE | \ |
| 43 | S3C2410_UCON_RXFIFO_TOI | \ |
| 44 | S3C2443_UCON_RXERR_IRQEN) |
| 45 | |
| 46 | #define NURI_ULCON_DEFAULT S3C2410_LCON_CS8 |
| 47 | |
| 48 | #define NURI_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \ |
| 49 | S5PV210_UFCON_TXTRIG256 | \ |
| 50 | S5PV210_UFCON_RXTRIG256) |
| 51 | |
| 52 | enum fixed_regulator_id { |
| 53 | FIXED_REG_ID_MMC = 0, |
| 54 | }; |
| 55 | |
| 56 | static struct s3c2410_uartcfg nuri_uartcfgs[] __initdata = { |
| 57 | { |
| 58 | .hwport = 0, |
| 59 | .ucon = NURI_UCON_DEFAULT, |
| 60 | .ulcon = NURI_ULCON_DEFAULT, |
| 61 | .ufcon = NURI_UFCON_DEFAULT, |
| 62 | }, |
| 63 | { |
| 64 | .hwport = 1, |
| 65 | .ucon = NURI_UCON_DEFAULT, |
| 66 | .ulcon = NURI_ULCON_DEFAULT, |
| 67 | .ufcon = NURI_UFCON_DEFAULT, |
| 68 | }, |
| 69 | { |
| 70 | .hwport = 2, |
| 71 | .ucon = NURI_UCON_DEFAULT, |
| 72 | .ulcon = NURI_ULCON_DEFAULT, |
| 73 | .ufcon = NURI_UFCON_DEFAULT, |
| 74 | }, |
| 75 | { |
| 76 | .hwport = 3, |
| 77 | .ucon = NURI_UCON_DEFAULT, |
| 78 | .ulcon = NURI_ULCON_DEFAULT, |
| 79 | .ufcon = NURI_UFCON_DEFAULT, |
| 80 | }, |
| 81 | }; |
| 82 | |
| 83 | /* eMMC */ |
| 84 | static struct s3c_sdhci_platdata nuri_hsmmc0_data __initdata = { |
| 85 | .max_width = 8, |
| 86 | .host_caps = (MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA | |
| 87 | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED | |
| 88 | MMC_CAP_DISABLE | MMC_CAP_ERASE), |
| 89 | .cd_type = S3C_SDHCI_CD_PERMANENT, |
| 90 | .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL, |
| 91 | }; |
| 92 | |
| 93 | static struct regulator_consumer_supply emmc_supplies[] = { |
| 94 | REGULATOR_SUPPLY("vmmc", "s3c-sdhci.0"), |
| 95 | REGULATOR_SUPPLY("vmmc", "dw_mmc"), |
| 96 | }; |
| 97 | |
| 98 | static struct regulator_init_data emmc_fixed_voltage_init_data = { |
| 99 | .constraints = { |
| 100 | .name = "VMEM_VDD_2.8V", |
| 101 | .valid_ops_mask = REGULATOR_CHANGE_STATUS, |
| 102 | }, |
| 103 | .num_consumer_supplies = ARRAY_SIZE(emmc_supplies), |
| 104 | .consumer_supplies = emmc_supplies, |
| 105 | }; |
| 106 | |
| 107 | static struct fixed_voltage_config emmc_fixed_voltage_config = { |
| 108 | .supply_name = "MASSMEMORY_EN (inverted)", |
| 109 | .microvolts = 2800000, |
| 110 | .gpio = EXYNOS4_GPL1(1), |
| 111 | .enable_high = false, |
| 112 | .init_data = &emmc_fixed_voltage_init_data, |
| 113 | }; |
| 114 | |
| 115 | static struct platform_device emmc_fixed_voltage = { |
| 116 | .name = "reg-fixed-voltage", |
| 117 | .id = FIXED_REG_ID_MMC, |
| 118 | .dev = { |
| 119 | .platform_data = &emmc_fixed_voltage_config, |
| 120 | }, |
| 121 | }; |
| 122 | |
| 123 | /* SD */ |
| 124 | static struct s3c_sdhci_platdata nuri_hsmmc2_data __initdata = { |
| 125 | .max_width = 4, |
| 126 | .host_caps = MMC_CAP_4_BIT_DATA | |
| 127 | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED | |
| 128 | MMC_CAP_DISABLE, |
| 129 | .ext_cd_gpio = EXYNOS4_GPX3(3), /* XEINT_27 */ |
| 130 | .ext_cd_gpio_invert = 1, |
| 131 | .cd_type = S3C_SDHCI_CD_GPIO, |
| 132 | .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL, |
| 133 | }; |
| 134 | |
| 135 | /* WLAN */ |
| 136 | static struct s3c_sdhci_platdata nuri_hsmmc3_data __initdata = { |
| 137 | .max_width = 4, |
| 138 | .host_caps = MMC_CAP_4_BIT_DATA | |
| 139 | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED, |
| 140 | .cd_type = S3C_SDHCI_CD_EXTERNAL, |
| 141 | .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL, |
| 142 | }; |
| 143 | |
| 144 | static void __init nuri_sdhci_init(void) |
| 145 | { |
| 146 | s3c_sdhci0_set_platdata(&nuri_hsmmc0_data); |
| 147 | s3c_sdhci2_set_platdata(&nuri_hsmmc2_data); |
| 148 | s3c_sdhci3_set_platdata(&nuri_hsmmc3_data); |
| 149 | } |
| 150 | |
| 151 | /* GPIO KEYS */ |
| 152 | static struct gpio_keys_button nuri_gpio_keys_tables[] = { |
| 153 | { |
| 154 | .code = KEY_VOLUMEUP, |
| 155 | .gpio = EXYNOS4_GPX2(0), /* XEINT16 */ |
| 156 | .desc = "gpio-keys: KEY_VOLUMEUP", |
| 157 | .type = EV_KEY, |
| 158 | .active_low = 1, |
| 159 | .debounce_interval = 1, |
| 160 | }, { |
| 161 | .code = KEY_VOLUMEDOWN, |
| 162 | .gpio = EXYNOS4_GPX2(1), /* XEINT17 */ |
| 163 | .desc = "gpio-keys: KEY_VOLUMEDOWN", |
| 164 | .type = EV_KEY, |
| 165 | .active_low = 1, |
| 166 | .debounce_interval = 1, |
| 167 | }, { |
| 168 | .code = KEY_POWER, |
| 169 | .gpio = EXYNOS4_GPX2(7), /* XEINT23 */ |
| 170 | .desc = "gpio-keys: KEY_POWER", |
| 171 | .type = EV_KEY, |
| 172 | .active_low = 1, |
| 173 | .wakeup = 1, |
| 174 | .debounce_interval = 1, |
| 175 | }, |
| 176 | }; |
| 177 | |
| 178 | static struct gpio_keys_platform_data nuri_gpio_keys_data = { |
| 179 | .buttons = nuri_gpio_keys_tables, |
| 180 | .nbuttons = ARRAY_SIZE(nuri_gpio_keys_tables), |
| 181 | }; |
| 182 | |
| 183 | static struct platform_device nuri_gpio_keys = { |
| 184 | .name = "gpio-keys", |
| 185 | .dev = { |
| 186 | .platform_data = &nuri_gpio_keys_data, |
| 187 | }, |
| 188 | }; |
| 189 | |
Donghwa Lee | cc7df87 | 2011-03-08 07:17:09 +0900 | [diff] [blame] | 190 | static void nuri_lcd_power_on(struct plat_lcd_data *pd, unsigned int power) |
| 191 | { |
| 192 | int gpio = EXYNOS4_GPE1(5); |
| 193 | |
| 194 | gpio_request(gpio, "LVDS_nSHDN"); |
| 195 | gpio_direction_output(gpio, power); |
| 196 | gpio_free(gpio); |
| 197 | } |
| 198 | |
| 199 | static int nuri_bl_init(struct device *dev) |
| 200 | { |
| 201 | int ret, gpio = EXYNOS4_GPE2(3); |
| 202 | |
| 203 | ret = gpio_request(gpio, "LCD_LDO_EN"); |
| 204 | if (!ret) |
| 205 | gpio_direction_output(gpio, 0); |
| 206 | |
| 207 | return ret; |
| 208 | } |
| 209 | |
| 210 | static int nuri_bl_notify(struct device *dev, int brightness) |
| 211 | { |
| 212 | if (brightness < 1) |
| 213 | brightness = 0; |
| 214 | |
| 215 | gpio_set_value(EXYNOS4_GPE2(3), 1); |
| 216 | |
| 217 | return brightness; |
| 218 | } |
| 219 | |
| 220 | static void nuri_bl_exit(struct device *dev) |
| 221 | { |
| 222 | gpio_free(EXYNOS4_GPE2(3)); |
| 223 | } |
| 224 | |
| 225 | /* nuri pwm backlight */ |
| 226 | static struct platform_pwm_backlight_data nuri_backlight_data = { |
| 227 | .pwm_id = 0, |
| 228 | .pwm_period_ns = 30000, |
| 229 | .max_brightness = 100, |
| 230 | .dft_brightness = 50, |
| 231 | .init = nuri_bl_init, |
| 232 | .notify = nuri_bl_notify, |
| 233 | .exit = nuri_bl_exit, |
| 234 | }; |
| 235 | |
| 236 | static struct platform_device nuri_backlight_device = { |
| 237 | .name = "pwm-backlight", |
| 238 | .id = -1, |
| 239 | .dev = { |
| 240 | .parent = &s3c_device_timer[0].dev, |
| 241 | .platform_data = &nuri_backlight_data, |
| 242 | }, |
| 243 | }; |
| 244 | |
| 245 | static struct plat_lcd_data nuri_lcd_platform_data = { |
| 246 | .set_power = nuri_lcd_power_on, |
| 247 | }; |
| 248 | |
| 249 | static struct platform_device nuri_lcd_device = { |
| 250 | .name = "platform-lcd", |
| 251 | .id = -1, |
| 252 | .dev = { |
| 253 | .platform_data = &nuri_lcd_platform_data, |
| 254 | }, |
| 255 | }; |
| 256 | |
Minkyu Kang | caf8b1f2 | 2011-02-28 20:39:43 +0900 | [diff] [blame] | 257 | /* I2C1 */ |
| 258 | static struct i2c_board_info i2c1_devs[] __initdata = { |
| 259 | /* Gyro, To be updated */ |
| 260 | }; |
| 261 | |
| 262 | /* GPIO I2C 5 (PMIC) */ |
| 263 | static struct i2c_board_info i2c5_devs[] __initdata = { |
| 264 | /* max8997, To be updated */ |
| 265 | }; |
| 266 | |
Joonyoung Shim | 01da92f | 2011-04-08 13:22:11 +0900 | [diff] [blame^] | 267 | /* USB EHCI */ |
| 268 | static struct s5p_ehci_platdata nuri_ehci_pdata; |
| 269 | |
| 270 | static void __init nuri_ehci_init(void) |
| 271 | { |
| 272 | struct s5p_ehci_platdata *pdata = &nuri_ehci_pdata; |
| 273 | |
| 274 | s5p_ehci_set_platdata(pdata); |
| 275 | } |
| 276 | |
Minkyu Kang | caf8b1f2 | 2011-02-28 20:39:43 +0900 | [diff] [blame] | 277 | static struct platform_device *nuri_devices[] __initdata = { |
| 278 | /* Samsung Platform Devices */ |
| 279 | &emmc_fixed_voltage, |
| 280 | &s3c_device_hsmmc0, |
| 281 | &s3c_device_hsmmc2, |
| 282 | &s3c_device_hsmmc3, |
| 283 | &s3c_device_wdt, |
Donghwa Lee | cc7df87 | 2011-03-08 07:17:09 +0900 | [diff] [blame] | 284 | &s3c_device_timer[0], |
Joonyoung Shim | 01da92f | 2011-04-08 13:22:11 +0900 | [diff] [blame^] | 285 | &s5p_device_ehci, |
Minkyu Kang | caf8b1f2 | 2011-02-28 20:39:43 +0900 | [diff] [blame] | 286 | |
| 287 | /* NURI Devices */ |
| 288 | &nuri_gpio_keys, |
Donghwa Lee | cc7df87 | 2011-03-08 07:17:09 +0900 | [diff] [blame] | 289 | &nuri_lcd_device, |
| 290 | &nuri_backlight_device, |
Minkyu Kang | caf8b1f2 | 2011-02-28 20:39:43 +0900 | [diff] [blame] | 291 | }; |
| 292 | |
| 293 | static void __init nuri_map_io(void) |
| 294 | { |
| 295 | s5p_init_io(NULL, 0, S5P_VA_CHIPID); |
| 296 | s3c24xx_init_clocks(24000000); |
| 297 | s3c24xx_init_uarts(nuri_uartcfgs, ARRAY_SIZE(nuri_uartcfgs)); |
| 298 | } |
| 299 | |
| 300 | static void __init nuri_machine_init(void) |
| 301 | { |
| 302 | nuri_sdhci_init(); |
| 303 | |
| 304 | i2c_register_board_info(1, i2c1_devs, ARRAY_SIZE(i2c1_devs)); |
| 305 | i2c_register_board_info(5, i2c5_devs, ARRAY_SIZE(i2c5_devs)); |
| 306 | |
Joonyoung Shim | 01da92f | 2011-04-08 13:22:11 +0900 | [diff] [blame^] | 307 | nuri_ehci_init(); |
| 308 | clk_xusbxti.rate = 24000000; |
| 309 | |
Minkyu Kang | caf8b1f2 | 2011-02-28 20:39:43 +0900 | [diff] [blame] | 310 | /* Last */ |
| 311 | platform_add_devices(nuri_devices, ARRAY_SIZE(nuri_devices)); |
| 312 | } |
| 313 | |
| 314 | MACHINE_START(NURI, "NURI") |
| 315 | /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */ |
| 316 | .boot_params = S5P_PA_SDRAM + 0x100, |
| 317 | .init_irq = exynos4_init_irq, |
| 318 | .map_io = nuri_map_io, |
| 319 | .init_machine = nuri_machine_init, |
| 320 | .timer = &exynos4_timer, |
| 321 | MACHINE_END |