mach-goni.c revision 528ef1b5f3998cd3199926526b4c188d52e4ba7c
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/regulator/fixed.h> 20#include <linux/spi/spi.h> 21#include <linux/spi/spi_gpio.h> 22#include <linux/lcd.h> 23#include <linux/gpio_keys.h> 24#include <linux/input.h> 25#include <linux/gpio.h> 26 27#include <asm/mach/arch.h> 28#include <asm/mach/map.h> 29#include <asm/setup.h> 30#include <asm/mach-types.h> 31 32#include <mach/map.h> 33#include <mach/regs-clock.h> 34#include <mach/regs-fb.h> 35 36#include <plat/gpio-cfg.h> 37#include <plat/regs-serial.h> 38#include <plat/s5pv210.h> 39#include <plat/devs.h> 40#include <plat/cpu.h> 41#include <plat/fb.h> 42#include <plat/iic.h> 43#include <plat/keypad.h> 44#include <plat/sdhci.h> 45#include <plat/clock.h> 46 47/* Following are default values for UCON, ULCON and UFCON UART registers */ 48#define GONI_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \ 49 S3C2410_UCON_RXILEVEL | \ 50 S3C2410_UCON_TXIRQMODE | \ 51 S3C2410_UCON_RXIRQMODE | \ 52 S3C2410_UCON_RXFIFO_TOI | \ 53 S3C2443_UCON_RXERR_IRQEN) 54 55#define GONI_ULCON_DEFAULT S3C2410_LCON_CS8 56 57#define GONI_UFCON_DEFAULT S3C2410_UFCON_FIFOMODE 58 59static struct s3c2410_uartcfg goni_uartcfgs[] __initdata = { 60 [0] = { 61 .hwport = 0, 62 .flags = 0, 63 .ucon = GONI_UCON_DEFAULT, 64 .ulcon = GONI_ULCON_DEFAULT, 65 .ufcon = GONI_UFCON_DEFAULT | 66 S5PV210_UFCON_TXTRIG256 | S5PV210_UFCON_RXTRIG256, 67 }, 68 [1] = { 69 .hwport = 1, 70 .flags = 0, 71 .ucon = GONI_UCON_DEFAULT, 72 .ulcon = GONI_ULCON_DEFAULT, 73 .ufcon = GONI_UFCON_DEFAULT | 74 S5PV210_UFCON_TXTRIG64 | S5PV210_UFCON_RXTRIG64, 75 }, 76 [2] = { 77 .hwport = 2, 78 .flags = 0, 79 .ucon = GONI_UCON_DEFAULT, 80 .ulcon = GONI_ULCON_DEFAULT, 81 .ufcon = GONI_UFCON_DEFAULT | 82 S5PV210_UFCON_TXTRIG16 | S5PV210_UFCON_RXTRIG16, 83 }, 84 [3] = { 85 .hwport = 3, 86 .flags = 0, 87 .ucon = GONI_UCON_DEFAULT, 88 .ulcon = GONI_ULCON_DEFAULT, 89 .ufcon = GONI_UFCON_DEFAULT | 90 S5PV210_UFCON_TXTRIG16 | S5PV210_UFCON_RXTRIG16, 91 }, 92}; 93 94/* Frame Buffer */ 95static struct s3c_fb_pd_win goni_fb_win0 = { 96 .win_mode = { 97 .left_margin = 16, 98 .right_margin = 16, 99 .upper_margin = 2, 100 .lower_margin = 28, 101 .hsync_len = 2, 102 .vsync_len = 1, 103 .xres = 480, 104 .yres = 800, 105 .refresh = 55, 106 }, 107 .max_bpp = 32, 108 .default_bpp = 16, 109}; 110 111static struct s3c_fb_platdata goni_lcd_pdata __initdata = { 112 .win[0] = &goni_fb_win0, 113 .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB | 114 VIDCON0_CLKSEL_LCD, 115 .vidcon1 = VIDCON1_INV_VCLK | VIDCON1_INV_VDEN 116 | VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC, 117 .setup_gpio = s5pv210_fb_gpio_setup_24bpp, 118}; 119 120static int lcd_power_on(struct lcd_device *ld, int enable) 121{ 122 return 1; 123} 124 125static int reset_lcd(struct lcd_device *ld) 126{ 127 static unsigned int first = 1; 128 int reset_gpio = -1; 129 130 reset_gpio = S5PV210_MP05(5); 131 132 if (first) { 133 gpio_request(reset_gpio, "MLCD_RST"); 134 first = 0; 135 } 136 137 gpio_direction_output(reset_gpio, 1); 138 return 1; 139} 140 141static struct lcd_platform_data goni_lcd_platform_data = { 142 .reset = reset_lcd, 143 .power_on = lcd_power_on, 144 .lcd_enabled = 0, 145 .reset_delay = 120, /* 120ms */ 146 .power_on_delay = 25, /* 25ms */ 147 .power_off_delay = 200, /* 200ms */ 148}; 149 150#define LCD_BUS_NUM 3 151static struct spi_board_info spi_board_info[] __initdata = { 152 { 153 .modalias = "s6e63m0", 154 .platform_data = &goni_lcd_platform_data, 155 .max_speed_hz = 1200000, 156 .bus_num = LCD_BUS_NUM, 157 .chip_select = 0, 158 .mode = SPI_MODE_3, 159 .controller_data = (void *)S5PV210_MP01(1), /* DISPLAY_CS */ 160 }, 161}; 162 163static struct spi_gpio_platform_data lcd_spi_gpio_data = { 164 .sck = S5PV210_MP04(1), /* DISPLAY_CLK */ 165 .mosi = S5PV210_MP04(3), /* DISPLAY_SI */ 166 .miso = SPI_GPIO_NO_MISO, 167 .num_chipselect = 1, 168}; 169 170static struct platform_device goni_spi_gpio = { 171 .name = "spi_gpio", 172 .id = LCD_BUS_NUM, 173 .dev = { 174 .parent = &s3c_device_fb.dev, 175 .platform_data = &lcd_spi_gpio_data, 176 }, 177}; 178 179/* KEYPAD */ 180static uint32_t keymap[] __initdata = { 181 /* KEY(row, col, keycode) */ 182 KEY(0, 1, KEY_MENU), /* Send */ 183 KEY(0, 2, KEY_BACK), /* End */ 184 KEY(1, 1, KEY_CONFIG), /* Half shot */ 185 KEY(1, 2, KEY_VOLUMEUP), 186 KEY(2, 1, KEY_CAMERA), /* Full shot */ 187 KEY(2, 2, KEY_VOLUMEDOWN), 188}; 189 190static struct matrix_keymap_data keymap_data __initdata = { 191 .keymap = keymap, 192 .keymap_size = ARRAY_SIZE(keymap), 193}; 194 195static struct samsung_keypad_platdata keypad_data __initdata = { 196 .keymap_data = &keymap_data, 197 .rows = 3, 198 .cols = 3, 199}; 200 201/* Radio */ 202static struct i2c_board_info i2c1_devs[] __initdata = { 203 { 204 I2C_BOARD_INFO("si470x", 0x10), 205 }, 206}; 207 208static void __init goni_radio_init(void) 209{ 210 int gpio; 211 212 gpio = S5PV210_GPJ2(4); /* XMSMDATA_4 */ 213 gpio_request(gpio, "FM_INT"); 214 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf)); 215 i2c1_devs[0].irq = gpio_to_irq(gpio); 216 217 gpio = S5PV210_GPJ2(5); /* XMSMDATA_5 */ 218 gpio_request(gpio, "FM_RST"); 219 gpio_direction_output(gpio, 1); 220} 221 222/* MAX8998 regulators */ 223#if defined(CONFIG_REGULATOR_MAX8998) || defined(CONFIG_REGULATOR_MAX8998_MODULE) 224 225static struct regulator_consumer_supply goni_ldo5_consumers[] = { 226 REGULATOR_SUPPLY("vmmc", "s3c-sdhci.0"), 227}; 228 229static struct regulator_init_data goni_ldo2_data = { 230 .constraints = { 231 .name = "VALIVE_1.1V", 232 .min_uV = 1100000, 233 .max_uV = 1100000, 234 .apply_uV = 1, 235 .always_on = 1, 236 .state_mem = { 237 .enabled = 1, 238 }, 239 }, 240}; 241 242static struct regulator_init_data goni_ldo3_data = { 243 .constraints = { 244 .name = "VUSB/MIPI_1.1V", 245 .min_uV = 1100000, 246 .max_uV = 1100000, 247 .apply_uV = 1, 248 .always_on = 1, 249 }, 250}; 251 252static struct regulator_init_data goni_ldo4_data = { 253 .constraints = { 254 .name = "VDAC_3.3V", 255 .min_uV = 3300000, 256 .max_uV = 3300000, 257 .apply_uV = 1, 258 }, 259}; 260 261static struct regulator_init_data goni_ldo5_data = { 262 .constraints = { 263 .name = "VTF_2.8V", 264 .min_uV = 2800000, 265 .max_uV = 2800000, 266 .apply_uV = 1, 267 }, 268 .num_consumer_supplies = ARRAY_SIZE(goni_ldo5_consumers), 269 .consumer_supplies = goni_ldo5_consumers, 270}; 271 272static struct regulator_init_data goni_ldo6_data = { 273 .constraints = { 274 .name = "VCC_3.3V", 275 .min_uV = 3300000, 276 .max_uV = 3300000, 277 .apply_uV = 1, 278 }, 279}; 280 281static struct regulator_init_data goni_ldo7_data = { 282 .constraints = { 283 .name = "VLCD_1.8V", 284 .min_uV = 1800000, 285 .max_uV = 1800000, 286 .apply_uV = 1, 287 .always_on = 1, 288 }, 289}; 290 291static struct regulator_init_data goni_ldo8_data = { 292 .constraints = { 293 .name = "VUSB/VADC_3.3V", 294 .min_uV = 3300000, 295 .max_uV = 3300000, 296 .apply_uV = 1, 297 .always_on = 1, 298 }, 299}; 300 301static struct regulator_init_data goni_ldo9_data = { 302 .constraints = { 303 .name = "VCC/VCAM_2.8V", 304 .min_uV = 2800000, 305 .max_uV = 2800000, 306 .apply_uV = 1, 307 .always_on = 1, 308 }, 309}; 310 311static struct regulator_init_data goni_ldo10_data = { 312 .constraints = { 313 .name = "VPLL_1.1V", 314 .min_uV = 1100000, 315 .max_uV = 1100000, 316 .apply_uV = 1, 317 .boot_on = 1, 318 }, 319}; 320 321static struct regulator_init_data goni_ldo11_data = { 322 .constraints = { 323 .name = "CAM_IO_2.8V", 324 .min_uV = 2800000, 325 .max_uV = 2800000, 326 .apply_uV = 1, 327 .always_on = 1, 328 }, 329}; 330 331static struct regulator_init_data goni_ldo12_data = { 332 .constraints = { 333 .name = "CAM_ISP_1.2V", 334 .min_uV = 1200000, 335 .max_uV = 1200000, 336 .apply_uV = 1, 337 .always_on = 1, 338 }, 339}; 340 341static struct regulator_init_data goni_ldo13_data = { 342 .constraints = { 343 .name = "CAM_A_2.8V", 344 .min_uV = 2800000, 345 .max_uV = 2800000, 346 .apply_uV = 1, 347 .always_on = 1, 348 }, 349}; 350 351static struct regulator_init_data goni_ldo14_data = { 352 .constraints = { 353 .name = "CAM_CIF_1.8V", 354 .min_uV = 1800000, 355 .max_uV = 1800000, 356 .apply_uV = 1, 357 .always_on = 1, 358 }, 359}; 360 361static struct regulator_init_data goni_ldo15_data = { 362 .constraints = { 363 .name = "CAM_AF_3.3V", 364 .min_uV = 3300000, 365 .max_uV = 3300000, 366 .apply_uV = 1, 367 .always_on = 1, 368 }, 369}; 370 371static struct regulator_init_data goni_ldo16_data = { 372 .constraints = { 373 .name = "VMIPI_1.8V", 374 .min_uV = 1800000, 375 .max_uV = 1800000, 376 .apply_uV = 1, 377 .always_on = 1, 378 }, 379}; 380 381static struct regulator_init_data goni_ldo17_data = { 382 .constraints = { 383 .name = "VCC_3.0V_LCD", 384 .min_uV = 3000000, 385 .max_uV = 3000000, 386 .apply_uV = 1, 387 .always_on = 1, 388 }, 389}; 390 391/* BUCK */ 392static struct regulator_consumer_supply buck1_consumer[] = { 393 { .supply = "vddarm", }, 394}; 395 396static struct regulator_consumer_supply buck2_consumer[] = { 397 { .supply = "vddint", }, 398}; 399 400static struct regulator_init_data goni_buck1_data = { 401 .constraints = { 402 .name = "VARM_1.2V", 403 .min_uV = 1200000, 404 .max_uV = 1200000, 405 .apply_uV = 1, 406 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | 407 REGULATOR_CHANGE_STATUS, 408 }, 409 .num_consumer_supplies = ARRAY_SIZE(buck1_consumer), 410 .consumer_supplies = buck1_consumer, 411}; 412 413static struct regulator_init_data goni_buck2_data = { 414 .constraints = { 415 .name = "VINT_1.2V", 416 .min_uV = 1200000, 417 .max_uV = 1200000, 418 .apply_uV = 1, 419 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | 420 REGULATOR_CHANGE_STATUS, 421 }, 422 .num_consumer_supplies = ARRAY_SIZE(buck2_consumer), 423 .consumer_supplies = buck2_consumer, 424}; 425 426static struct regulator_init_data goni_buck3_data = { 427 .constraints = { 428 .name = "VCC_1.8V", 429 .min_uV = 1800000, 430 .max_uV = 1800000, 431 .apply_uV = 1, 432 .state_mem = { 433 .enabled = 1, 434 }, 435 }, 436}; 437 438static struct regulator_init_data goni_buck4_data = { 439 .constraints = { 440 .name = "CAM_CORE_1.2V", 441 .min_uV = 1200000, 442 .max_uV = 1200000, 443 .apply_uV = 1, 444 .always_on = 1, 445 }, 446}; 447 448static struct max8998_regulator_data goni_regulators[] = { 449 { MAX8998_LDO2, &goni_ldo2_data }, 450 { MAX8998_LDO3, &goni_ldo3_data }, 451 { MAX8998_LDO4, &goni_ldo4_data }, 452 { MAX8998_LDO5, &goni_ldo5_data }, 453 { MAX8998_LDO6, &goni_ldo6_data }, 454 { MAX8998_LDO7, &goni_ldo7_data }, 455 { MAX8998_LDO8, &goni_ldo8_data }, 456 { MAX8998_LDO9, &goni_ldo9_data }, 457 { MAX8998_LDO10, &goni_ldo10_data }, 458 { MAX8998_LDO11, &goni_ldo11_data }, 459 { MAX8998_LDO12, &goni_ldo12_data }, 460 { MAX8998_LDO13, &goni_ldo13_data }, 461 { MAX8998_LDO14, &goni_ldo14_data }, 462 { MAX8998_LDO15, &goni_ldo15_data }, 463 { MAX8998_LDO16, &goni_ldo16_data }, 464 { MAX8998_LDO17, &goni_ldo17_data }, 465 { MAX8998_BUCK1, &goni_buck1_data }, 466 { MAX8998_BUCK2, &goni_buck2_data }, 467 { MAX8998_BUCK3, &goni_buck3_data }, 468 { MAX8998_BUCK4, &goni_buck4_data }, 469}; 470 471static struct max8998_platform_data goni_max8998_pdata = { 472 .num_regulators = ARRAY_SIZE(goni_regulators), 473 .regulators = goni_regulators, 474}; 475#endif 476 477/* GPIO I2C PMIC */ 478#define AP_I2C_GPIO_PMIC_BUS_4 4 479static struct i2c_gpio_platform_data goni_i2c_gpio_pmic_data = { 480 .sda_pin = S5PV210_GPJ4(0), /* XMSMCSN */ 481 .scl_pin = S5PV210_GPJ4(3), /* XMSMIRQN */ 482}; 483 484static struct platform_device goni_i2c_gpio_pmic = { 485 .name = "i2c-gpio", 486 .id = AP_I2C_GPIO_PMIC_BUS_4, 487 .dev = { 488 .platform_data = &goni_i2c_gpio_pmic_data, 489 }, 490}; 491 492static struct i2c_board_info i2c_gpio_pmic_devs[] __initdata = { 493#if defined(CONFIG_REGULATOR_MAX8998) || defined(CONFIG_REGULATOR_MAX8998_MODULE) 494 { 495 /* 0xCC when SRAD = 0 */ 496 I2C_BOARD_INFO("max8998", 0xCC >> 1), 497 .platform_data = &goni_max8998_pdata, 498 }, 499#endif 500}; 501 502/* PMIC Power button */ 503static struct gpio_keys_button goni_gpio_keys_table[] = { 504 { 505 .code = KEY_POWER, 506 .gpio = S5PV210_GPH2(6), 507 .desc = "gpio-keys: KEY_POWER", 508 .type = EV_KEY, 509 .active_low = 1, 510 .wakeup = 1, 511 .debounce_interval = 1, 512 }, 513}; 514 515static struct gpio_keys_platform_data goni_gpio_keys_data = { 516 .buttons = goni_gpio_keys_table, 517 .nbuttons = ARRAY_SIZE(goni_gpio_keys_table), 518}; 519 520static struct platform_device goni_device_gpiokeys = { 521 .name = "gpio-keys", 522 .dev = { 523 .platform_data = &goni_gpio_keys_data, 524 }, 525}; 526 527static void __init goni_pmic_init(void) 528{ 529 /* AP_PMIC_IRQ: EINT7 */ 530 s3c_gpio_cfgpin(S5PV210_GPH0(7), S3C_GPIO_SFN(0xf)); 531 s3c_gpio_setpull(S5PV210_GPH0(7), S3C_GPIO_PULL_UP); 532 533 /* nPower: EINT22 */ 534 s3c_gpio_cfgpin(S5PV210_GPH2(6), S3C_GPIO_SFN(0xf)); 535 s3c_gpio_setpull(S5PV210_GPH2(6), S3C_GPIO_PULL_UP); 536} 537 538/* MoviNAND */ 539static struct s3c_sdhci_platdata goni_hsmmc0_data __initdata = { 540 .max_width = 4, 541 .cd_type = S3C_SDHCI_CD_PERMANENT, 542}; 543 544/* Wireless LAN */ 545static struct s3c_sdhci_platdata goni_hsmmc1_data __initdata = { 546 .max_width = 4, 547 .cd_type = S3C_SDHCI_CD_EXTERNAL, 548 /* ext_cd_{init,cleanup} callbacks will be added later */ 549}; 550 551/* External Flash */ 552#define GONI_EXT_FLASH_EN S5PV210_MP05(4) 553#define GONI_EXT_FLASH_CD S5PV210_GPH3(4) 554static struct s3c_sdhci_platdata goni_hsmmc2_data __initdata = { 555 .max_width = 4, 556 .cd_type = S3C_SDHCI_CD_GPIO, 557 .ext_cd_gpio = GONI_EXT_FLASH_CD, 558 .ext_cd_gpio_invert = 1, 559}; 560 561static struct regulator_consumer_supply mmc2_supplies[] = { 562 REGULATOR_SUPPLY("vmmc", "s3c-sdhci.2"), 563}; 564 565static struct regulator_init_data mmc2_fixed_voltage_init_data = { 566 .constraints = { 567 .name = "V_TF_2.8V", 568 .valid_ops_mask = REGULATOR_CHANGE_STATUS, 569 }, 570 .num_consumer_supplies = ARRAY_SIZE(mmc2_supplies), 571 .consumer_supplies = mmc2_supplies, 572}; 573 574static struct fixed_voltage_config mmc2_fixed_voltage_config = { 575 .supply_name = "EXT_FLASH_EN", 576 .microvolts = 2800000, 577 .gpio = GONI_EXT_FLASH_EN, 578 .enable_high = true, 579 .init_data = &mmc2_fixed_voltage_init_data, 580}; 581 582static struct platform_device mmc2_fixed_voltage = { 583 .name = "reg-fixed-voltage", 584 .id = 2, 585 .dev = { 586 .platform_data = &mmc2_fixed_voltage_config, 587 }, 588}; 589 590static void goni_setup_sdhci(void) 591{ 592 s3c_sdhci0_set_platdata(&goni_hsmmc0_data); 593 s3c_sdhci1_set_platdata(&goni_hsmmc1_data); 594 s3c_sdhci2_set_platdata(&goni_hsmmc2_data); 595}; 596 597static struct platform_device *goni_devices[] __initdata = { 598 &s3c_device_fb, 599 &s5p_device_onenand, 600 &goni_spi_gpio, 601 &goni_i2c_gpio_pmic, 602 &mmc2_fixed_voltage, 603 &goni_device_gpiokeys, 604 &s5p_device_fimc0, 605 &s5p_device_fimc1, 606 &s5p_device_fimc2, 607 &s3c_device_hsmmc0, 608 &s3c_device_hsmmc1, 609 &s3c_device_hsmmc2, 610 &s3c_device_usb_hsotg, 611 &samsung_device_keypad, 612 &s3c_device_i2c1, 613}; 614 615static void __init goni_map_io(void) 616{ 617 s5p_init_io(NULL, 0, S5P_VA_CHIPID); 618 s3c24xx_init_clocks(24000000); 619 s3c24xx_init_uarts(goni_uartcfgs, ARRAY_SIZE(goni_uartcfgs)); 620} 621 622static void __init goni_machine_init(void) 623{ 624 /* Radio: call before I2C 1 registeration */ 625 goni_radio_init(); 626 627 /* I2C1 */ 628 s3c_i2c1_set_platdata(NULL); 629 i2c_register_board_info(1, i2c1_devs, ARRAY_SIZE(i2c1_devs)); 630 631 /* PMIC */ 632 goni_pmic_init(); 633 i2c_register_board_info(AP_I2C_GPIO_PMIC_BUS_4, i2c_gpio_pmic_devs, 634 ARRAY_SIZE(i2c_gpio_pmic_devs)); 635 /* SDHCI */ 636 goni_setup_sdhci(); 637 638 /* FB */ 639 s3c_fb_set_platdata(&goni_lcd_pdata); 640 641 /* SPI */ 642 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info)); 643 644 /* KEYPAD */ 645 samsung_keypad_set_platdata(&keypad_data); 646 647 clk_xusbxti.rate = 24000000; 648 649 platform_add_devices(goni_devices, ARRAY_SIZE(goni_devices)); 650} 651 652MACHINE_START(GONI, "GONI") 653 /* Maintainers: Kyungmin Park <kyungmin.park@samsung.com> */ 654 .phys_io = S3C_PA_UART & 0xfff00000, 655 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc, 656 .boot_params = S5P_PA_SDRAM + 0x100, 657 .init_irq = s5pv210_init_irq, 658 .map_io = goni_map_io, 659 .init_machine = goni_machine_init, 660 .timer = &s3c24xx_timer, 661MACHINE_END 662