1 /* linux/arch/arm/mach-s5pv210/mach-goni.c
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
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/kernel.h>
12 #include <linux/types.h>
13 #include <linux/init.h>
14 #include <linux/serial_core.h>
16 #include <linux/i2c.h>
17 #include <linux/i2c-gpio.h>
18 #include <linux/i2c/atmel_mxt_ts.h>
19 #include <linux/mfd/max8998.h>
20 #include <linux/mfd/wm8994/pdata.h>
21 #include <linux/regulator/fixed.h>
22 #include <linux/spi/spi.h>
23 #include <linux/spi/spi_gpio.h>
24 #include <linux/lcd.h>
25 #include <linux/gpio_keys.h>
26 #include <linux/input.h>
27 #include <linux/gpio.h>
28 #include <linux/interrupt.h>
30 #include <asm/mach/arch.h>
31 #include <asm/mach/map.h>
32 #include <asm/setup.h>
33 #include <asm/mach-types.h>
36 #include <mach/regs-clock.h>
37 #include <mach/regs-fb.h>
39 #include <plat/gpio-cfg.h>
40 #include <plat/regs-serial.h>
41 #include <plat/s5pv210.h>
42 #include <plat/devs.h>
46 #include <plat/keypad.h>
47 #include <plat/sdhci.h>
48 #include <plat/clock.h>
50 /* Following are default values for UCON, ULCON and UFCON UART registers */
51 #define GONI_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
52 S3C2410_UCON_RXILEVEL | \
53 S3C2410_UCON_TXIRQMODE | \
54 S3C2410_UCON_RXIRQMODE | \
55 S3C2410_UCON_RXFIFO_TOI | \
56 S3C2443_UCON_RXERR_IRQEN)
58 #define GONI_ULCON_DEFAULT S3C2410_LCON_CS8
60 #define GONI_UFCON_DEFAULT S3C2410_UFCON_FIFOMODE
62 static struct s3c2410_uartcfg goni_uartcfgs[] __initdata = {
66 .ucon = GONI_UCON_DEFAULT,
67 .ulcon = GONI_ULCON_DEFAULT,
68 .ufcon = GONI_UFCON_DEFAULT |
69 S5PV210_UFCON_TXTRIG256 | S5PV210_UFCON_RXTRIG256,
74 .ucon = GONI_UCON_DEFAULT,
75 .ulcon = GONI_ULCON_DEFAULT,
76 .ufcon = GONI_UFCON_DEFAULT |
77 S5PV210_UFCON_TXTRIG64 | S5PV210_UFCON_RXTRIG64,
82 .ucon = GONI_UCON_DEFAULT,
83 .ulcon = GONI_ULCON_DEFAULT,
84 .ufcon = GONI_UFCON_DEFAULT |
85 S5PV210_UFCON_TXTRIG16 | S5PV210_UFCON_RXTRIG16,
90 .ucon = GONI_UCON_DEFAULT,
91 .ulcon = GONI_ULCON_DEFAULT,
92 .ufcon = GONI_UFCON_DEFAULT |
93 S5PV210_UFCON_TXTRIG16 | S5PV210_UFCON_RXTRIG16,
98 static struct s3c_fb_pd_win goni_fb_win0 = {
114 static struct s3c_fb_platdata goni_lcd_pdata __initdata = {
115 .win[0] = &goni_fb_win0,
116 .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB |
118 .vidcon1 = VIDCON1_INV_VCLK | VIDCON1_INV_VDEN
119 | VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
120 .setup_gpio = s5pv210_fb_gpio_setup_24bpp,
123 static int lcd_power_on(struct lcd_device *ld, int enable)
128 static int reset_lcd(struct lcd_device *ld)
130 static unsigned int first = 1;
133 reset_gpio = S5PV210_MP05(5);
136 gpio_request(reset_gpio, "MLCD_RST");
140 gpio_direction_output(reset_gpio, 1);
144 static struct lcd_platform_data goni_lcd_platform_data = {
146 .power_on = lcd_power_on,
148 .reset_delay = 120, /* 120ms */
149 .power_on_delay = 25, /* 25ms */
150 .power_off_delay = 200, /* 200ms */
153 #define LCD_BUS_NUM 3
154 static struct spi_board_info spi_board_info[] __initdata = {
156 .modalias = "s6e63m0",
157 .platform_data = &goni_lcd_platform_data,
158 .max_speed_hz = 1200000,
159 .bus_num = LCD_BUS_NUM,
162 .controller_data = (void *)S5PV210_MP01(1), /* DISPLAY_CS */
166 static struct spi_gpio_platform_data lcd_spi_gpio_data = {
167 .sck = S5PV210_MP04(1), /* DISPLAY_CLK */
168 .mosi = S5PV210_MP04(3), /* DISPLAY_SI */
169 .miso = SPI_GPIO_NO_MISO,
173 static struct platform_device goni_spi_gpio = {
177 .parent = &s3c_device_fb.dev,
178 .platform_data = &lcd_spi_gpio_data,
183 static uint32_t keymap[] __initdata = {
184 /* KEY(row, col, keycode) */
185 KEY(0, 1, KEY_MENU), /* Send */
186 KEY(0, 2, KEY_BACK), /* End */
187 KEY(1, 1, KEY_CONFIG), /* Half shot */
188 KEY(1, 2, KEY_VOLUMEUP),
189 KEY(2, 1, KEY_CAMERA), /* Full shot */
190 KEY(2, 2, KEY_VOLUMEDOWN),
193 static struct matrix_keymap_data keymap_data __initdata = {
195 .keymap_size = ARRAY_SIZE(keymap),
198 static struct samsung_keypad_platdata keypad_data __initdata = {
199 .keymap_data = &keymap_data,
205 static struct i2c_board_info i2c1_devs[] __initdata = {
207 I2C_BOARD_INFO("si470x", 0x10),
211 static void __init goni_radio_init(void)
215 gpio = S5PV210_GPJ2(4); /* XMSMDATA_4 */
216 gpio_request(gpio, "FM_INT");
217 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
218 i2c1_devs[0].irq = gpio_to_irq(gpio);
220 gpio = S5PV210_GPJ2(5); /* XMSMDATA_5 */
221 gpio_request(gpio, "FM_RST");
222 gpio_direction_output(gpio, 1);
226 static struct mxt_platform_data qt602240_platform_data = {
233 .voltage = 2800000, /* 2.8V */
234 .orient = MXT_DIAGONAL,
235 .irqflags = IRQF_TRIGGER_FALLING,
238 static struct s3c2410_platform_i2c i2c2_data __initdata = {
242 .frequency = 400 * 1000,
246 static struct i2c_board_info i2c2_devs[] __initdata = {
248 I2C_BOARD_INFO("qt602240_ts", 0x4a),
249 .platform_data = &qt602240_platform_data,
253 static void __init goni_tsp_init(void)
257 gpio = S5PV210_GPJ1(3); /* XMSMADDR_11 */
258 gpio_request(gpio, "TSP_LDO_ON");
259 gpio_direction_output(gpio, 1);
260 gpio_export(gpio, 0);
262 gpio = S5PV210_GPJ0(5); /* XMSMADDR_5 */
263 gpio_request(gpio, "TSP_INT");
265 s5p_register_gpio_interrupt(gpio);
266 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
267 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
268 i2c2_devs[0].irq = gpio_to_irq(gpio);
271 /* MAX8998 regulators */
272 #if defined(CONFIG_REGULATOR_MAX8998) || defined(CONFIG_REGULATOR_MAX8998_MODULE)
274 static struct regulator_consumer_supply goni_ldo5_consumers[] = {
275 REGULATOR_SUPPLY("vmmc", "s3c-sdhci.0"),
278 static struct regulator_init_data goni_ldo2_data = {
280 .name = "VALIVE_1.1V",
291 static struct regulator_init_data goni_ldo3_data = {
293 .name = "VUSB/MIPI_1.1V",
301 static struct regulator_init_data goni_ldo4_data = {
310 static struct regulator_init_data goni_ldo5_data = {
317 .num_consumer_supplies = ARRAY_SIZE(goni_ldo5_consumers),
318 .consumer_supplies = goni_ldo5_consumers,
321 static struct regulator_init_data goni_ldo6_data = {
330 static struct regulator_init_data goni_ldo7_data = {
340 static struct regulator_init_data goni_ldo8_data = {
342 .name = "VUSB/VADC_3.3V",
350 static struct regulator_init_data goni_ldo9_data = {
352 .name = "VCC/VCAM_2.8V",
360 static struct regulator_init_data goni_ldo10_data = {
370 static struct regulator_init_data goni_ldo11_data = {
372 .name = "CAM_IO_2.8V",
380 static struct regulator_init_data goni_ldo12_data = {
382 .name = "CAM_ISP_1.2V",
390 static struct regulator_init_data goni_ldo13_data = {
392 .name = "CAM_A_2.8V",
400 static struct regulator_init_data goni_ldo14_data = {
402 .name = "CAM_CIF_1.8V",
410 static struct regulator_init_data goni_ldo15_data = {
412 .name = "CAM_AF_3.3V",
420 static struct regulator_init_data goni_ldo16_data = {
422 .name = "VMIPI_1.8V",
430 static struct regulator_init_data goni_ldo17_data = {
432 .name = "VCC_3.0V_LCD",
441 static struct regulator_consumer_supply buck1_consumer[] = {
442 { .supply = "vddarm", },
445 static struct regulator_consumer_supply buck2_consumer[] = {
446 { .supply = "vddint", },
449 static struct regulator_init_data goni_buck1_data = {
455 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
456 REGULATOR_CHANGE_STATUS,
458 .num_consumer_supplies = ARRAY_SIZE(buck1_consumer),
459 .consumer_supplies = buck1_consumer,
462 static struct regulator_init_data goni_buck2_data = {
468 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
469 REGULATOR_CHANGE_STATUS,
471 .num_consumer_supplies = ARRAY_SIZE(buck2_consumer),
472 .consumer_supplies = buck2_consumer,
475 static struct regulator_init_data goni_buck3_data = {
487 static struct regulator_init_data goni_buck4_data = {
489 .name = "CAM_CORE_1.2V",
497 static struct max8998_regulator_data goni_regulators[] = {
498 { MAX8998_LDO2, &goni_ldo2_data },
499 { MAX8998_LDO3, &goni_ldo3_data },
500 { MAX8998_LDO4, &goni_ldo4_data },
501 { MAX8998_LDO5, &goni_ldo5_data },
502 { MAX8998_LDO6, &goni_ldo6_data },
503 { MAX8998_LDO7, &goni_ldo7_data },
504 { MAX8998_LDO8, &goni_ldo8_data },
505 { MAX8998_LDO9, &goni_ldo9_data },
506 { MAX8998_LDO10, &goni_ldo10_data },
507 { MAX8998_LDO11, &goni_ldo11_data },
508 { MAX8998_LDO12, &goni_ldo12_data },
509 { MAX8998_LDO13, &goni_ldo13_data },
510 { MAX8998_LDO14, &goni_ldo14_data },
511 { MAX8998_LDO15, &goni_ldo15_data },
512 { MAX8998_LDO16, &goni_ldo16_data },
513 { MAX8998_LDO17, &goni_ldo17_data },
514 { MAX8998_BUCK1, &goni_buck1_data },
515 { MAX8998_BUCK2, &goni_buck2_data },
516 { MAX8998_BUCK3, &goni_buck3_data },
517 { MAX8998_BUCK4, &goni_buck4_data },
520 static struct max8998_platform_data goni_max8998_pdata = {
521 .num_regulators = ARRAY_SIZE(goni_regulators),
522 .regulators = goni_regulators,
523 .buck1_set1 = S5PV210_GPH0(3),
524 .buck1_set2 = S5PV210_GPH0(4),
525 .buck2_set3 = S5PV210_GPH0(5),
526 .buck1_max_voltage1 = 1200000,
527 .buck1_max_voltage2 = 1200000,
528 .buck2_max_voltage = 1200000,
532 static struct regulator_consumer_supply wm8994_fixed_voltage0_supplies[] = {
534 .dev_name = "5-001a",
537 .dev_name = "5-001a",
540 .dev_name = "5-001a",
545 static struct regulator_consumer_supply wm8994_fixed_voltage1_supplies[] = {
547 .dev_name = "5-001a",
550 .dev_name = "5-001a",
555 static struct regulator_init_data wm8994_fixed_voltage0_init_data = {
559 .num_consumer_supplies = ARRAY_SIZE(wm8994_fixed_voltage0_supplies),
560 .consumer_supplies = wm8994_fixed_voltage0_supplies,
563 static struct regulator_init_data wm8994_fixed_voltage1_init_data = {
567 .num_consumer_supplies = ARRAY_SIZE(wm8994_fixed_voltage1_supplies),
568 .consumer_supplies = wm8994_fixed_voltage1_supplies,
571 static struct fixed_voltage_config wm8994_fixed_voltage0_config = {
572 .supply_name = "VCC_1.8V_PDA",
573 .microvolts = 1800000,
575 .init_data = &wm8994_fixed_voltage0_init_data,
578 static struct fixed_voltage_config wm8994_fixed_voltage1_config = {
579 .supply_name = "V_BAT",
580 .microvolts = 3700000,
582 .init_data = &wm8994_fixed_voltage1_init_data,
585 static struct platform_device wm8994_fixed_voltage0 = {
586 .name = "reg-fixed-voltage",
589 .platform_data = &wm8994_fixed_voltage0_config,
593 static struct platform_device wm8994_fixed_voltage1 = {
594 .name = "reg-fixed-voltage",
597 .platform_data = &wm8994_fixed_voltage1_config,
601 static struct regulator_consumer_supply wm8994_avdd1_supply = {
602 .dev_name = "5-001a",
606 static struct regulator_consumer_supply wm8994_dcvdd_supply = {
607 .dev_name = "5-001a",
611 static struct regulator_init_data wm8994_ldo1_data = {
613 .name = "AVDD1_3.0V",
614 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
616 .num_consumer_supplies = 1,
617 .consumer_supplies = &wm8994_avdd1_supply,
620 static struct regulator_init_data wm8994_ldo2_data = {
622 .name = "DCVDD_1.0V",
624 .num_consumer_supplies = 1,
625 .consumer_supplies = &wm8994_dcvdd_supply,
628 static struct wm8994_pdata wm8994_platform_data = {
629 /* configure gpio1 function: 0x0001(Logic level input/output) */
630 .gpio_defaults[0] = 0x0001,
631 /* configure gpio3/4/5/7 function for AIF2 voice */
632 .gpio_defaults[2] = 0x8100,
633 .gpio_defaults[3] = 0x8100,
634 .gpio_defaults[4] = 0x8100,
635 .gpio_defaults[6] = 0x0100,
636 /* configure gpio8/9/10/11 function for AIF3 BT */
637 .gpio_defaults[7] = 0x8100,
638 .gpio_defaults[8] = 0x0100,
639 .gpio_defaults[9] = 0x0100,
640 .gpio_defaults[10] = 0x0100,
641 .ldo[0] = { S5PV210_MP03(6), NULL, &wm8994_ldo1_data }, /* XM0FRNB_2 */
642 .ldo[1] = { 0, NULL, &wm8994_ldo2_data },
646 #define AP_I2C_GPIO_PMIC_BUS_4 4
647 static struct i2c_gpio_platform_data goni_i2c_gpio_pmic_data = {
648 .sda_pin = S5PV210_GPJ4(0), /* XMSMCSN */
649 .scl_pin = S5PV210_GPJ4(3), /* XMSMIRQN */
652 static struct platform_device goni_i2c_gpio_pmic = {
654 .id = AP_I2C_GPIO_PMIC_BUS_4,
656 .platform_data = &goni_i2c_gpio_pmic_data,
660 static struct i2c_board_info i2c_gpio_pmic_devs[] __initdata = {
661 #if defined(CONFIG_REGULATOR_MAX8998) || defined(CONFIG_REGULATOR_MAX8998_MODULE)
663 /* 0xCC when SRAD = 0 */
664 I2C_BOARD_INFO("max8998", 0xCC >> 1),
665 .platform_data = &goni_max8998_pdata,
670 /* GPIO I2C AP 1.8V */
671 #define AP_I2C_GPIO_BUS_5 5
672 static struct i2c_gpio_platform_data goni_i2c_gpio5_data = {
673 .sda_pin = S5PV210_MP05(3), /* XM0ADDR_11 */
674 .scl_pin = S5PV210_MP05(2), /* XM0ADDR_10 */
677 static struct platform_device goni_i2c_gpio5 = {
679 .id = AP_I2C_GPIO_BUS_5,
681 .platform_data = &goni_i2c_gpio5_data,
685 static struct i2c_board_info i2c_gpio5_devs[] __initdata = {
687 /* CS/ADDR = low 0x34 (FYI: high = 0x36) */
688 I2C_BOARD_INFO("wm8994", 0x1a),
689 .platform_data = &wm8994_platform_data,
693 /* PMIC Power button */
694 static struct gpio_keys_button goni_gpio_keys_table[] = {
697 .gpio = S5PV210_GPH2(6),
698 .desc = "gpio-keys: KEY_POWER",
702 .debounce_interval = 1,
706 static struct gpio_keys_platform_data goni_gpio_keys_data = {
707 .buttons = goni_gpio_keys_table,
708 .nbuttons = ARRAY_SIZE(goni_gpio_keys_table),
711 static struct platform_device goni_device_gpiokeys = {
714 .platform_data = &goni_gpio_keys_data,
718 static void __init goni_pmic_init(void)
720 /* AP_PMIC_IRQ: EINT7 */
721 s3c_gpio_cfgpin(S5PV210_GPH0(7), S3C_GPIO_SFN(0xf));
722 s3c_gpio_setpull(S5PV210_GPH0(7), S3C_GPIO_PULL_UP);
725 s3c_gpio_cfgpin(S5PV210_GPH2(6), S3C_GPIO_SFN(0xf));
726 s3c_gpio_setpull(S5PV210_GPH2(6), S3C_GPIO_PULL_UP);
730 static struct s3c_sdhci_platdata goni_hsmmc0_data __initdata = {
732 .cd_type = S3C_SDHCI_CD_PERMANENT,
736 static struct s3c_sdhci_platdata goni_hsmmc1_data __initdata = {
738 .cd_type = S3C_SDHCI_CD_EXTERNAL,
739 /* ext_cd_{init,cleanup} callbacks will be added later */
743 #define GONI_EXT_FLASH_EN S5PV210_MP05(4)
744 #define GONI_EXT_FLASH_CD S5PV210_GPH3(4)
745 static struct s3c_sdhci_platdata goni_hsmmc2_data __initdata = {
747 .cd_type = S3C_SDHCI_CD_GPIO,
748 .ext_cd_gpio = GONI_EXT_FLASH_CD,
749 .ext_cd_gpio_invert = 1,
752 static struct regulator_consumer_supply mmc2_supplies[] = {
753 REGULATOR_SUPPLY("vmmc", "s3c-sdhci.2"),
756 static struct regulator_init_data mmc2_fixed_voltage_init_data = {
759 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
761 .num_consumer_supplies = ARRAY_SIZE(mmc2_supplies),
762 .consumer_supplies = mmc2_supplies,
765 static struct fixed_voltage_config mmc2_fixed_voltage_config = {
766 .supply_name = "EXT_FLASH_EN",
767 .microvolts = 2800000,
768 .gpio = GONI_EXT_FLASH_EN,
770 .init_data = &mmc2_fixed_voltage_init_data,
773 static struct platform_device mmc2_fixed_voltage = {
774 .name = "reg-fixed-voltage",
777 .platform_data = &mmc2_fixed_voltage_config,
781 static void goni_setup_sdhci(void)
783 s3c_sdhci0_set_platdata(&goni_hsmmc0_data);
784 s3c_sdhci1_set_platdata(&goni_hsmmc1_data);
785 s3c_sdhci2_set_platdata(&goni_hsmmc2_data);
788 static struct platform_device *goni_devices[] __initdata = {
795 &goni_device_gpiokeys,
802 &s5pv210_device_iis0,
803 &s3c_device_usb_hsotg,
804 &samsung_device_keypad,
807 &wm8994_fixed_voltage0,
808 &wm8994_fixed_voltage1,
811 static void __init goni_sound_init(void)
813 /* Ths main clock of WM8994 codec uses the output of CLKOUT pin.
814 * The CLKOUT[9:8] set to 0x3(XUSBXTI) of 0xE010E000(OTHERS)
815 * because it needs 24MHz clock to operate WM8994 codec.
817 __raw_writel(__raw_readl(S5P_OTHERS) | (0x3 << 8), S5P_OTHERS);
820 static void __init goni_map_io(void)
822 s5p_init_io(NULL, 0, S5P_VA_CHIPID);
823 s3c24xx_init_clocks(24000000);
824 s3c24xx_init_uarts(goni_uartcfgs, ARRAY_SIZE(goni_uartcfgs));
827 static void __init goni_machine_init(void)
829 /* Radio: call before I2C 1 registeration */
833 s3c_i2c1_set_platdata(NULL);
834 i2c_register_board_info(1, i2c1_devs, ARRAY_SIZE(i2c1_devs));
836 /* TSP: call before I2C 2 registeration */
840 s3c_i2c2_set_platdata(&i2c2_data);
841 i2c_register_board_info(2, i2c2_devs, ARRAY_SIZE(i2c2_devs));
845 i2c_register_board_info(AP_I2C_GPIO_PMIC_BUS_4, i2c_gpio_pmic_devs,
846 ARRAY_SIZE(i2c_gpio_pmic_devs));
852 i2c_register_board_info(AP_I2C_GPIO_BUS_5, i2c_gpio5_devs,
853 ARRAY_SIZE(i2c_gpio5_devs));
856 s3c_fb_set_platdata(&goni_lcd_pdata);
859 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
862 samsung_keypad_set_platdata(&keypad_data);
864 clk_xusbxti.rate = 24000000;
866 platform_add_devices(goni_devices, ARRAY_SIZE(goni_devices));
869 MACHINE_START(GONI, "GONI")
870 /* Maintainers: Kyungmin Park <kyungmin.park@samsung.com> */
871 .boot_params = S5P_PA_SDRAM + 0x100,
872 .init_irq = s5pv210_init_irq,
873 .map_io = goni_map_io,
874 .init_machine = goni_machine_init,
875 .timer = &s3c24xx_timer,