blob: e68791855d2260d640bb1561c98ef6eff8b8e0e9 [file] [log] [blame]
Joonyoung Shim2e57da42010-05-19 23:15:32 +09001/* 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>
Marek Szyprowski3965fde2010-07-14 19:38:18 +090015#include <linux/fb.h>
Marek Szyprowskiba149f32010-07-14 19:39:47 +090016#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>
Joonyoung Shim2e57da42010-05-19 23:15:32 +090022
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>
Marek Szyprowski3965fde2010-07-14 19:38:18 +090030#include <mach/regs-fb.h>
Joonyoung Shim2e57da42010-05-19 23:15:32 +090031
Marek Szyprowskiba149f32010-07-14 19:39:47 +090032#include <plat/gpio-cfg.h>
Joonyoung Shim2e57da42010-05-19 23:15:32 +090033#include <plat/regs-serial.h>
34#include <plat/s5pv210.h>
35#include <plat/devs.h>
36#include <plat/cpu.h>
Marek Szyprowski3965fde2010-07-14 19:38:18 +090037#include <plat/fb.h>
Joonyoung Shim2a555582010-09-09 08:17:43 +090038#include <plat/keypad.h>
Marek Szyprowski19b90c72010-08-05 18:00:18 +090039#include <plat/sdhci.h>
Marek Szyprowskid5889d52010-09-30 20:59:46 +090040#include <plat/clock.h>
Joonyoung Shim2e57da42010-05-19 23:15:32 +090041
42/* Following are default values for UCON, ULCON and UFCON UART registers */
Kukjin Kimc8def082010-07-21 09:19:51 +090043#define GONI_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
Joonyoung Shim2e57da42010-05-19 23:15:32 +090044 S3C2410_UCON_RXILEVEL | \
45 S3C2410_UCON_TXIRQMODE | \
46 S3C2410_UCON_RXIRQMODE | \
47 S3C2410_UCON_RXFIFO_TOI | \
48 S3C2443_UCON_RXERR_IRQEN)
49
Kukjin Kimc8def082010-07-21 09:19:51 +090050#define GONI_ULCON_DEFAULT S3C2410_LCON_CS8
Joonyoung Shim2e57da42010-05-19 23:15:32 +090051
Kukjin Kimf2b7e3c2010-08-06 21:34:55 +090052#define GONI_UFCON_DEFAULT S3C2410_UFCON_FIFOMODE
Joonyoung Shim2e57da42010-05-19 23:15:32 +090053
54static struct s3c2410_uartcfg goni_uartcfgs[] __initdata = {
55 [0] = {
56 .hwport = 0,
57 .flags = 0,
Kukjin Kimc8def082010-07-21 09:19:51 +090058 .ucon = GONI_UCON_DEFAULT,
59 .ulcon = GONI_ULCON_DEFAULT,
Kukjin Kimf2b7e3c2010-08-06 21:34:55 +090060 .ufcon = GONI_UFCON_DEFAULT |
Joonyoung Shimbbf7b352010-06-24 19:28:55 +090061 S5PV210_UFCON_TXTRIG256 | S5PV210_UFCON_RXTRIG256,
Joonyoung Shim2e57da42010-05-19 23:15:32 +090062 },
63 [1] = {
64 .hwport = 1,
65 .flags = 0,
Kukjin Kimc8def082010-07-21 09:19:51 +090066 .ucon = GONI_UCON_DEFAULT,
67 .ulcon = GONI_ULCON_DEFAULT,
Kukjin Kimf2b7e3c2010-08-06 21:34:55 +090068 .ufcon = GONI_UFCON_DEFAULT |
Joonyoung Shimbbf7b352010-06-24 19:28:55 +090069 S5PV210_UFCON_TXTRIG64 | S5PV210_UFCON_RXTRIG64,
Joonyoung Shim2e57da42010-05-19 23:15:32 +090070 },
71 [2] = {
72 .hwport = 2,
73 .flags = 0,
Kukjin Kimc8def082010-07-21 09:19:51 +090074 .ucon = GONI_UCON_DEFAULT,
75 .ulcon = GONI_ULCON_DEFAULT,
Kukjin Kimf2b7e3c2010-08-06 21:34:55 +090076 .ufcon = GONI_UFCON_DEFAULT |
Joonyoung Shimbbf7b352010-06-24 19:28:55 +090077 S5PV210_UFCON_TXTRIG16 | S5PV210_UFCON_RXTRIG16,
Joonyoung Shim2e57da42010-05-19 23:15:32 +090078 },
79 [3] = {
80 .hwport = 3,
81 .flags = 0,
Kukjin Kimc8def082010-07-21 09:19:51 +090082 .ucon = GONI_UCON_DEFAULT,
83 .ulcon = GONI_ULCON_DEFAULT,
Kukjin Kimf2b7e3c2010-08-06 21:34:55 +090084 .ufcon = GONI_UFCON_DEFAULT |
Joonyoung Shimbbf7b352010-06-24 19:28:55 +090085 S5PV210_UFCON_TXTRIG16 | S5PV210_UFCON_RXTRIG16,
Joonyoung Shim2e57da42010-05-19 23:15:32 +090086 },
87};
88
Marek Szyprowski3965fde2010-07-14 19:38:18 +090089/* Frame Buffer */
90static struct s3c_fb_pd_win goni_fb_win0 = {
91 .win_mode = {
Marek Szyprowski3965fde2010-07-14 19:38:18 +090092 .left_margin = 16,
93 .right_margin = 16,
Marek Szyprowski9d1fc392010-09-29 21:49:17 +090094 .upper_margin = 2,
Marek Szyprowski3965fde2010-07-14 19:38:18 +090095 .lower_margin = 28,
96 .hsync_len = 2,
Marek Szyprowski9d1fc392010-09-29 21:49:17 +090097 .vsync_len = 1,
Marek Szyprowski3965fde2010-07-14 19:38:18 +090098 .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
Joonyoung Shim2a555582010-09-09 08:17:43 +0900115/* 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
Marek Szyprowskiba149f32010-07-14 19:39:47 +0900137/* 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
Marek Szyprowski19b90c72010-08-05 18:00:18 +0900447/* 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};
Marek Szyprowskiba149f32010-07-14 19:39:47 +0900479
Joonyoung Shim2e57da42010-05-19 23:15:32 +0900480static struct platform_device *goni_devices[] __initdata = {
Marek Szyprowski3965fde2010-07-14 19:38:18 +0900481 &s3c_device_fb,
Kukjin Kim13904fb2010-08-27 13:56:54 +0900482 &s5p_device_onenand,
Marek Szyprowskiba149f32010-07-14 19:39:47 +0900483 &goni_i2c_gpio_pmic,
484 &goni_device_gpiokeys,
Sylwester Nawrocki9f488c62010-08-09 16:55:34 +0900485 &s5p_device_fimc0,
486 &s5p_device_fimc1,
487 &s5p_device_fimc2,
Marek Szyprowski19b90c72010-08-05 18:00:18 +0900488 &s3c_device_hsmmc0,
489 &s3c_device_hsmmc1,
490 &s3c_device_hsmmc2,
Marek Szyprowskid5889d52010-09-30 20:59:46 +0900491 &s3c_device_usb_hsotg,
Joonyoung Shim2a555582010-09-09 08:17:43 +0900492 &samsung_device_keypad,
Joonyoung Shim2e57da42010-05-19 23:15:32 +0900493};
494
495static void __init goni_map_io(void)
496{
497 s5p_init_io(NULL, 0, S5P_VA_CHIPID);
498 s3c24xx_init_clocks(24000000);
499 s3c24xx_init_uarts(goni_uartcfgs, ARRAY_SIZE(goni_uartcfgs));
500}
501
502static void __init goni_machine_init(void)
503{
Marek Szyprowskiba149f32010-07-14 19:39:47 +0900504 /* PMIC */
505 goni_pmic_init();
506 i2c_register_board_info(AP_I2C_GPIO_PMIC_BUS_4, i2c_gpio_pmic_devs,
507 ARRAY_SIZE(i2c_gpio_pmic_devs));
Marek Szyprowski19b90c72010-08-05 18:00:18 +0900508 /* SDHCI */
509 goni_setup_sdhci();
510
Marek Szyprowski3965fde2010-07-14 19:38:18 +0900511 /* FB */
512 s3c_fb_set_platdata(&goni_lcd_pdata);
513
Joonyoung Shim2a555582010-09-09 08:17:43 +0900514 /* KEYPAD */
515 samsung_keypad_set_platdata(&keypad_data);
516
Marek Szyprowskid5889d52010-09-30 20:59:46 +0900517 clk_xusbxti.rate = 24000000;
518
Joonyoung Shim2e57da42010-05-19 23:15:32 +0900519 platform_add_devices(goni_devices, ARRAY_SIZE(goni_devices));
520}
521
522MACHINE_START(GONI, "GONI")
523 /* Maintainers: Kyungmin Park <kyungmin.park@samsung.com> */
524 .phys_io = S3C_PA_UART & 0xfff00000,
525 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
526 .boot_params = S5P_PA_SDRAM + 0x100,
527 .init_irq = s5pv210_init_irq,
528 .map_io = goni_map_io,
529 .init_machine = goni_machine_init,
530 .timer = &s3c24xx_timer,
531MACHINE_END