mach-goni.c revision 9d1fc39c2c47e7bd15c56a976e5cb7f5541669f1
1/* linux/arch/arm/mach-s5pv210/mach-goni.c 2 * 3 * Copyright (c) 2010 Samsung Electronics Co., Ltd. 4 * http://www.samsung.com/ 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/kernel.h> 12#include <linux/types.h> 13#include <linux/init.h> 14#include <linux/serial_core.h> 15#include <linux/fb.h> 16#include <linux/i2c.h> 17#include <linux/i2c-gpio.h> 18#include <linux/mfd/max8998.h> 19#include <linux/gpio_keys.h> 20#include <linux/input.h> 21#include <linux/gpio.h> 22 23#include <asm/mach/arch.h> 24#include <asm/mach/map.h> 25#include <asm/setup.h> 26#include <asm/mach-types.h> 27 28#include <mach/map.h> 29#include <mach/regs-clock.h> 30#include <mach/regs-fb.h> 31 32#include <plat/gpio-cfg.h> 33#include <plat/regs-serial.h> 34#include <plat/s5pv210.h> 35#include <plat/devs.h> 36#include <plat/cpu.h> 37#include <plat/fb.h> 38#include <plat/keypad.h> 39#include <plat/sdhci.h> 40 41/* Following are default values for UCON, ULCON and UFCON UART registers */ 42#define GONI_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \ 43 S3C2410_UCON_RXILEVEL | \ 44 S3C2410_UCON_TXIRQMODE | \ 45 S3C2410_UCON_RXIRQMODE | \ 46 S3C2410_UCON_RXFIFO_TOI | \ 47 S3C2443_UCON_RXERR_IRQEN) 48 49#define GONI_ULCON_DEFAULT S3C2410_LCON_CS8 50 51#define GONI_UFCON_DEFAULT S3C2410_UFCON_FIFOMODE 52 53static struct s3c2410_uartcfg goni_uartcfgs[] __initdata = { 54 [0] = { 55 .hwport = 0, 56 .flags = 0, 57 .ucon = GONI_UCON_DEFAULT, 58 .ulcon = GONI_ULCON_DEFAULT, 59 .ufcon = GONI_UFCON_DEFAULT | 60 S5PV210_UFCON_TXTRIG256 | S5PV210_UFCON_RXTRIG256, 61 }, 62 [1] = { 63 .hwport = 1, 64 .flags = 0, 65 .ucon = GONI_UCON_DEFAULT, 66 .ulcon = GONI_ULCON_DEFAULT, 67 .ufcon = GONI_UFCON_DEFAULT | 68 S5PV210_UFCON_TXTRIG64 | S5PV210_UFCON_RXTRIG64, 69 }, 70 [2] = { 71 .hwport = 2, 72 .flags = 0, 73 .ucon = GONI_UCON_DEFAULT, 74 .ulcon = GONI_ULCON_DEFAULT, 75 .ufcon = GONI_UFCON_DEFAULT | 76 S5PV210_UFCON_TXTRIG16 | S5PV210_UFCON_RXTRIG16, 77 }, 78 [3] = { 79 .hwport = 3, 80 .flags = 0, 81 .ucon = GONI_UCON_DEFAULT, 82 .ulcon = GONI_ULCON_DEFAULT, 83 .ufcon = GONI_UFCON_DEFAULT | 84 S5PV210_UFCON_TXTRIG16 | S5PV210_UFCON_RXTRIG16, 85 }, 86}; 87 88/* Frame Buffer */ 89static struct s3c_fb_pd_win goni_fb_win0 = { 90 .win_mode = { 91 .pixclock = 1000000000000ULL / ((16+16+2+480)*(28+3+2+800)*55), 92 .left_margin = 16, 93 .right_margin = 16, 94 .upper_margin = 2, 95 .lower_margin = 28, 96 .hsync_len = 2, 97 .vsync_len = 1, 98 .xres = 480, 99 .yres = 800, 100 .refresh = 55, 101 }, 102 .max_bpp = 32, 103 .default_bpp = 16, 104}; 105 106static struct s3c_fb_platdata goni_lcd_pdata __initdata = { 107 .win[0] = &goni_fb_win0, 108 .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB | 109 VIDCON0_CLKSEL_LCD, 110 .vidcon1 = VIDCON1_INV_VCLK | VIDCON1_INV_VDEN 111 | VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC, 112 .setup_gpio = s5pv210_fb_gpio_setup_24bpp, 113}; 114 115/* KEYPAD */ 116static uint32_t keymap[] __initdata = { 117 /* KEY(row, col, keycode) */ 118 KEY(0, 1, KEY_MENU), /* Send */ 119 KEY(0, 2, KEY_BACK), /* End */ 120 KEY(1, 1, KEY_CONFIG), /* Half shot */ 121 KEY(1, 2, KEY_VOLUMEUP), 122 KEY(2, 1, KEY_CAMERA), /* Full shot */ 123 KEY(2, 2, KEY_VOLUMEDOWN), 124}; 125 126static struct matrix_keymap_data keymap_data __initdata = { 127 .keymap = keymap, 128 .keymap_size = ARRAY_SIZE(keymap), 129}; 130 131static struct samsung_keypad_platdata keypad_data __initdata = { 132 .keymap_data = &keymap_data, 133 .rows = 3, 134 .cols = 3, 135}; 136 137/* MAX8998 regulators */ 138#if defined(CONFIG_REGULATOR_MAX8998) || defined(CONFIG_REGULATOR_MAX8998_MODULE) 139 140static struct regulator_init_data goni_ldo2_data = { 141 .constraints = { 142 .name = "VALIVE_1.1V", 143 .min_uV = 1100000, 144 .max_uV = 1100000, 145 .apply_uV = 1, 146 .always_on = 1, 147 .state_mem = { 148 .enabled = 1, 149 }, 150 }, 151}; 152 153static struct regulator_init_data goni_ldo3_data = { 154 .constraints = { 155 .name = "VUSB/MIPI_1.1V", 156 .min_uV = 1100000, 157 .max_uV = 1100000, 158 .apply_uV = 1, 159 .always_on = 1, 160 }, 161}; 162 163static struct regulator_init_data goni_ldo4_data = { 164 .constraints = { 165 .name = "VDAC_3.3V", 166 .min_uV = 3300000, 167 .max_uV = 3300000, 168 .apply_uV = 1, 169 }, 170}; 171 172static struct regulator_init_data goni_ldo5_data = { 173 .constraints = { 174 .name = "VTF_2.8V", 175 .min_uV = 2800000, 176 .max_uV = 2800000, 177 .apply_uV = 1, 178 }, 179}; 180 181static struct regulator_init_data goni_ldo6_data = { 182 .constraints = { 183 .name = "VCC_3.3V", 184 .min_uV = 3300000, 185 .max_uV = 3300000, 186 .apply_uV = 1, 187 }, 188}; 189 190static struct regulator_init_data goni_ldo7_data = { 191 .constraints = { 192 .name = "VLCD_1.8V", 193 .min_uV = 1800000, 194 .max_uV = 1800000, 195 .apply_uV = 1, 196 .always_on = 1, 197 }, 198}; 199 200static struct regulator_init_data goni_ldo8_data = { 201 .constraints = { 202 .name = "VUSB/VADC_3.3V", 203 .min_uV = 3300000, 204 .max_uV = 3300000, 205 .apply_uV = 1, 206 .always_on = 1, 207 }, 208}; 209 210static struct regulator_init_data goni_ldo9_data = { 211 .constraints = { 212 .name = "VCC/VCAM_2.8V", 213 .min_uV = 2800000, 214 .max_uV = 2800000, 215 .apply_uV = 1, 216 .always_on = 1, 217 }, 218}; 219 220static struct regulator_init_data goni_ldo10_data = { 221 .constraints = { 222 .name = "VPLL_1.1V", 223 .min_uV = 1100000, 224 .max_uV = 1100000, 225 .apply_uV = 1, 226 .boot_on = 1, 227 }, 228}; 229 230static struct regulator_init_data goni_ldo11_data = { 231 .constraints = { 232 .name = "CAM_IO_2.8V", 233 .min_uV = 2800000, 234 .max_uV = 2800000, 235 .apply_uV = 1, 236 .always_on = 1, 237 }, 238}; 239 240static struct regulator_init_data goni_ldo12_data = { 241 .constraints = { 242 .name = "CAM_ISP_1.2V", 243 .min_uV = 1200000, 244 .max_uV = 1200000, 245 .apply_uV = 1, 246 .always_on = 1, 247 }, 248}; 249 250static struct regulator_init_data goni_ldo13_data = { 251 .constraints = { 252 .name = "CAM_A_2.8V", 253 .min_uV = 2800000, 254 .max_uV = 2800000, 255 .apply_uV = 1, 256 .always_on = 1, 257 }, 258}; 259 260static struct regulator_init_data goni_ldo14_data = { 261 .constraints = { 262 .name = "CAM_CIF_1.8V", 263 .min_uV = 1800000, 264 .max_uV = 1800000, 265 .apply_uV = 1, 266 .always_on = 1, 267 }, 268}; 269 270static struct regulator_init_data goni_ldo15_data = { 271 .constraints = { 272 .name = "CAM_AF_3.3V", 273 .min_uV = 3300000, 274 .max_uV = 3300000, 275 .apply_uV = 1, 276 .always_on = 1, 277 }, 278}; 279 280static struct regulator_init_data goni_ldo16_data = { 281 .constraints = { 282 .name = "VMIPI_1.8V", 283 .min_uV = 1800000, 284 .max_uV = 1800000, 285 .apply_uV = 1, 286 .always_on = 1, 287 }, 288}; 289 290static struct regulator_init_data goni_ldo17_data = { 291 .constraints = { 292 .name = "VCC_3.0V_LCD", 293 .min_uV = 3000000, 294 .max_uV = 3000000, 295 .apply_uV = 1, 296 .always_on = 1, 297 }, 298}; 299 300/* BUCK */ 301static struct regulator_consumer_supply buck1_consumer[] = { 302 { .supply = "vddarm", }, 303}; 304 305static struct regulator_consumer_supply buck2_consumer[] = { 306 { .supply = "vddint", }, 307}; 308 309static struct regulator_init_data goni_buck1_data = { 310 .constraints = { 311 .name = "VARM_1.2V", 312 .min_uV = 1200000, 313 .max_uV = 1200000, 314 .apply_uV = 1, 315 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | 316 REGULATOR_CHANGE_STATUS, 317 }, 318 .num_consumer_supplies = ARRAY_SIZE(buck1_consumer), 319 .consumer_supplies = buck1_consumer, 320}; 321 322static struct regulator_init_data goni_buck2_data = { 323 .constraints = { 324 .name = "VINT_1.2V", 325 .min_uV = 1200000, 326 .max_uV = 1200000, 327 .apply_uV = 1, 328 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | 329 REGULATOR_CHANGE_STATUS, 330 }, 331 .num_consumer_supplies = ARRAY_SIZE(buck2_consumer), 332 .consumer_supplies = buck2_consumer, 333}; 334 335static struct regulator_init_data goni_buck3_data = { 336 .constraints = { 337 .name = "VCC_1.8V", 338 .min_uV = 1800000, 339 .max_uV = 1800000, 340 .apply_uV = 1, 341 .state_mem = { 342 .enabled = 1, 343 }, 344 }, 345}; 346 347static struct regulator_init_data goni_buck4_data = { 348 .constraints = { 349 .name = "CAM_CORE_1.2V", 350 .min_uV = 1200000, 351 .max_uV = 1200000, 352 .apply_uV = 1, 353 .always_on = 1, 354 }, 355}; 356 357static struct max8998_regulator_data goni_regulators[] = { 358 { MAX8998_LDO2, &goni_ldo2_data }, 359 { MAX8998_LDO3, &goni_ldo3_data }, 360 { MAX8998_LDO4, &goni_ldo4_data }, 361 { MAX8998_LDO5, &goni_ldo5_data }, 362 { MAX8998_LDO6, &goni_ldo6_data }, 363 { MAX8998_LDO7, &goni_ldo7_data }, 364 { MAX8998_LDO8, &goni_ldo8_data }, 365 { MAX8998_LDO9, &goni_ldo9_data }, 366 { MAX8998_LDO10, &goni_ldo10_data }, 367 { MAX8998_LDO11, &goni_ldo11_data }, 368 { MAX8998_LDO12, &goni_ldo12_data }, 369 { MAX8998_LDO13, &goni_ldo13_data }, 370 { MAX8998_LDO14, &goni_ldo14_data }, 371 { MAX8998_LDO15, &goni_ldo15_data }, 372 { MAX8998_LDO16, &goni_ldo16_data }, 373 { MAX8998_LDO17, &goni_ldo17_data }, 374 { MAX8998_BUCK1, &goni_buck1_data }, 375 { MAX8998_BUCK2, &goni_buck2_data }, 376 { MAX8998_BUCK3, &goni_buck3_data }, 377 { MAX8998_BUCK4, &goni_buck4_data }, 378}; 379 380static struct max8998_platform_data goni_max8998_pdata = { 381 .num_regulators = ARRAY_SIZE(goni_regulators), 382 .regulators = goni_regulators, 383}; 384#endif 385 386/* GPIO I2C PMIC */ 387#define AP_I2C_GPIO_PMIC_BUS_4 4 388static struct i2c_gpio_platform_data goni_i2c_gpio_pmic_data = { 389 .sda_pin = S5PV210_GPJ4(0), /* XMSMCSN */ 390 .scl_pin = S5PV210_GPJ4(3), /* XMSMIRQN */ 391}; 392 393static struct platform_device goni_i2c_gpio_pmic = { 394 .name = "i2c-gpio", 395 .id = AP_I2C_GPIO_PMIC_BUS_4, 396 .dev = { 397 .platform_data = &goni_i2c_gpio_pmic_data, 398 }, 399}; 400 401static struct i2c_board_info i2c_gpio_pmic_devs[] __initdata = { 402#if defined(CONFIG_REGULATOR_MAX8998) || defined(CONFIG_REGULATOR_MAX8998_MODULE) 403 { 404 /* 0xCC when SRAD = 0 */ 405 I2C_BOARD_INFO("max8998", 0xCC >> 1), 406 .platform_data = &goni_max8998_pdata, 407 }, 408#endif 409}; 410 411/* PMIC Power button */ 412static struct gpio_keys_button goni_gpio_keys_table[] = { 413 { 414 .code = KEY_POWER, 415 .gpio = S5PV210_GPH2(6), 416 .desc = "gpio-keys: KEY_POWER", 417 .type = EV_KEY, 418 .active_low = 1, 419 .wakeup = 1, 420 .debounce_interval = 1, 421 }, 422}; 423 424static struct gpio_keys_platform_data goni_gpio_keys_data = { 425 .buttons = goni_gpio_keys_table, 426 .nbuttons = ARRAY_SIZE(goni_gpio_keys_table), 427}; 428 429static struct platform_device goni_device_gpiokeys = { 430 .name = "gpio-keys", 431 .dev = { 432 .platform_data = &goni_gpio_keys_data, 433 }, 434}; 435 436static void __init goni_pmic_init(void) 437{ 438 /* AP_PMIC_IRQ: EINT7 */ 439 s3c_gpio_cfgpin(S5PV210_GPH0(7), S3C_GPIO_SFN(0xf)); 440 s3c_gpio_setpull(S5PV210_GPH0(7), S3C_GPIO_PULL_UP); 441 442 /* nPower: EINT22 */ 443 s3c_gpio_cfgpin(S5PV210_GPH2(6), S3C_GPIO_SFN(0xf)); 444 s3c_gpio_setpull(S5PV210_GPH2(6), S3C_GPIO_PULL_UP); 445} 446 447/* MoviNAND */ 448static struct s3c_sdhci_platdata goni_hsmmc0_data __initdata = { 449 .max_width = 4, 450 .cd_type = S3C_SDHCI_CD_PERMANENT, 451}; 452 453/* Wireless LAN */ 454static struct s3c_sdhci_platdata goni_hsmmc1_data __initdata = { 455 .max_width = 4, 456 .cd_type = S3C_SDHCI_CD_EXTERNAL, 457 /* ext_cd_{init,cleanup} callbacks will be added later */ 458}; 459 460/* External Flash */ 461#define GONI_EXT_FLASH_EN S5PV210_MP05(4) 462#define GONI_EXT_FLASH_CD S5PV210_GPH3(4) 463static struct s3c_sdhci_platdata goni_hsmmc2_data __initdata = { 464 .max_width = 4, 465 .cd_type = S3C_SDHCI_CD_GPIO, 466 .ext_cd_gpio = GONI_EXT_FLASH_CD, 467 .ext_cd_gpio_invert = 1, 468}; 469 470static void goni_setup_sdhci(void) 471{ 472 gpio_request(GONI_EXT_FLASH_EN, "FLASH_EN"); 473 gpio_direction_output(GONI_EXT_FLASH_EN, 1); 474 475 s3c_sdhci0_set_platdata(&goni_hsmmc0_data); 476 s3c_sdhci1_set_platdata(&goni_hsmmc1_data); 477 s3c_sdhci2_set_platdata(&goni_hsmmc2_data); 478}; 479 480static struct platform_device *goni_devices[] __initdata = { 481 &s3c_device_fb, 482 &s5p_device_onenand, 483 &goni_i2c_gpio_pmic, 484 &goni_device_gpiokeys, 485 &s5p_device_fimc0, 486 &s5p_device_fimc1, 487 &s5p_device_fimc2, 488 &s3c_device_hsmmc0, 489 &s3c_device_hsmmc1, 490 &s3c_device_hsmmc2, 491 &samsung_device_keypad, 492}; 493 494static void __init goni_map_io(void) 495{ 496 s5p_init_io(NULL, 0, S5P_VA_CHIPID); 497 s3c24xx_init_clocks(24000000); 498 s3c24xx_init_uarts(goni_uartcfgs, ARRAY_SIZE(goni_uartcfgs)); 499} 500 501static void __init goni_machine_init(void) 502{ 503 /* PMIC */ 504 goni_pmic_init(); 505 i2c_register_board_info(AP_I2C_GPIO_PMIC_BUS_4, i2c_gpio_pmic_devs, 506 ARRAY_SIZE(i2c_gpio_pmic_devs)); 507 /* SDHCI */ 508 goni_setup_sdhci(); 509 510 /* FB */ 511 s3c_fb_set_platdata(&goni_lcd_pdata); 512 513 /* KEYPAD */ 514 samsung_keypad_set_platdata(&keypad_data); 515 516 platform_add_devices(goni_devices, ARRAY_SIZE(goni_devices)); 517} 518 519MACHINE_START(GONI, "GONI") 520 /* Maintainers: Kyungmin Park <kyungmin.park@samsung.com> */ 521 .phys_io = S3C_PA_UART & 0xfff00000, 522 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc, 523 .boot_params = S5P_PA_SDRAM + 0x100, 524 .init_irq = s5pv210_init_irq, 525 .map_io = goni_map_io, 526 .init_machine = goni_machine_init, 527 .timer = &s3c24xx_timer, 528MACHINE_END 529