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