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