ARM: S5PV210: Enable MFC on Goni
[pandora-kernel.git] / arch / arm / mach-s5pv210 / mach-goni.c
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/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>
29
30 #include <asm/mach/arch.h>
31 #include <asm/mach/map.h>
32 #include <asm/setup.h>
33 #include <asm/mach-types.h>
34
35 #include <mach/map.h>
36 #include <mach/regs-clock.h>
37 #include <mach/regs-fb.h>
38
39 #include <plat/gpio-cfg.h>
40 #include <plat/regs-serial.h>
41 #include <plat/s5pv210.h>
42 #include <plat/devs.h>
43 #include <plat/cpu.h>
44 #include <plat/fb.h>
45 #include <plat/iic.h>
46 #include <plat/keypad.h>
47 #include <plat/sdhci.h>
48 #include <plat/clock.h>
49 #include <plat/s5p-time.h>
50 #include <plat/mfc.h>
51 #include <plat/regs-fb-v4.h>
52
53 /* Following are default values for UCON, ULCON and UFCON UART registers */
54 #define GONI_UCON_DEFAULT       (S3C2410_UCON_TXILEVEL |        \
55                                  S3C2410_UCON_RXILEVEL |        \
56                                  S3C2410_UCON_TXIRQMODE |       \
57                                  S3C2410_UCON_RXIRQMODE |       \
58                                  S3C2410_UCON_RXFIFO_TOI |      \
59                                  S3C2443_UCON_RXERR_IRQEN)
60
61 #define GONI_ULCON_DEFAULT      S3C2410_LCON_CS8
62
63 #define GONI_UFCON_DEFAULT      S3C2410_UFCON_FIFOMODE
64
65 static struct s3c2410_uartcfg goni_uartcfgs[] __initdata = {
66         [0] = {
67                 .hwport         = 0,
68                 .flags          = 0,
69                 .ucon           = GONI_UCON_DEFAULT,
70                 .ulcon          = GONI_ULCON_DEFAULT,
71                 .ufcon          = GONI_UFCON_DEFAULT |
72                         S5PV210_UFCON_TXTRIG256 | S5PV210_UFCON_RXTRIG256,
73         },
74         [1] = {
75                 .hwport         = 1,
76                 .flags          = 0,
77                 .ucon           = GONI_UCON_DEFAULT,
78                 .ulcon          = GONI_ULCON_DEFAULT,
79                 .ufcon          = GONI_UFCON_DEFAULT |
80                         S5PV210_UFCON_TXTRIG64 | S5PV210_UFCON_RXTRIG64,
81         },
82         [2] = {
83                 .hwport         = 2,
84                 .flags          = 0,
85                 .ucon           = GONI_UCON_DEFAULT,
86                 .ulcon          = GONI_ULCON_DEFAULT,
87                 .ufcon          = GONI_UFCON_DEFAULT |
88                         S5PV210_UFCON_TXTRIG16 | S5PV210_UFCON_RXTRIG16,
89         },
90         [3] = {
91                 .hwport         = 3,
92                 .flags          = 0,
93                 .ucon           = GONI_UCON_DEFAULT,
94                 .ulcon          = GONI_ULCON_DEFAULT,
95                 .ufcon          = GONI_UFCON_DEFAULT |
96                         S5PV210_UFCON_TXTRIG16 | S5PV210_UFCON_RXTRIG16,
97         },
98 };
99
100 /* Frame Buffer */
101 static struct s3c_fb_pd_win goni_fb_win0 = {
102         .win_mode = {
103                 .left_margin    = 16,
104                 .right_margin   = 16,
105                 .upper_margin   = 2,
106                 .lower_margin   = 28,
107                 .hsync_len      = 2,
108                 .vsync_len      = 1,
109                 .xres           = 480,
110                 .yres           = 800,
111                 .refresh        = 55,
112         },
113         .max_bpp        = 32,
114         .default_bpp    = 16,
115         .virtual_x      = 480,
116         .virtual_y      = 2 * 800,
117 };
118
119 static struct s3c_fb_platdata goni_lcd_pdata __initdata = {
120         .win[0]         = &goni_fb_win0,
121         .vidcon0        = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB |
122                           VIDCON0_CLKSEL_LCD,
123         .vidcon1        = VIDCON1_INV_VCLK | VIDCON1_INV_VDEN
124                           | VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
125         .setup_gpio     = s5pv210_fb_gpio_setup_24bpp,
126 };
127
128 static int lcd_power_on(struct lcd_device *ld, int enable)
129 {
130         return 1;
131 }
132
133 static int reset_lcd(struct lcd_device *ld)
134 {
135         static unsigned int first = 1;
136         int reset_gpio = -1;
137
138         reset_gpio = S5PV210_MP05(5);
139
140         if (first) {
141                 gpio_request(reset_gpio, "MLCD_RST");
142                 first = 0;
143         }
144
145         gpio_direction_output(reset_gpio, 1);
146         return 1;
147 }
148
149 static struct lcd_platform_data goni_lcd_platform_data = {
150         .reset                  = reset_lcd,
151         .power_on               = lcd_power_on,
152         .lcd_enabled            = 0,
153         .reset_delay            = 120,  /* 120ms */
154         .power_on_delay         = 25,   /* 25ms */
155         .power_off_delay        = 200,  /* 200ms */
156 };
157
158 #define LCD_BUS_NUM     3
159 static struct spi_board_info spi_board_info[] __initdata = {
160         {
161                 .modalias       = "s6e63m0",
162                 .platform_data  = &goni_lcd_platform_data,
163                 .max_speed_hz   = 1200000,
164                 .bus_num        = LCD_BUS_NUM,
165                 .chip_select    = 0,
166                 .mode           = SPI_MODE_3,
167                 .controller_data = (void *)S5PV210_MP01(1), /* DISPLAY_CS */
168         },
169 };
170
171 static struct spi_gpio_platform_data lcd_spi_gpio_data = {
172         .sck    = S5PV210_MP04(1), /* DISPLAY_CLK */
173         .mosi   = S5PV210_MP04(3), /* DISPLAY_SI */
174         .miso   = SPI_GPIO_NO_MISO,
175         .num_chipselect = 1,
176 };
177
178 static struct platform_device goni_spi_gpio = {
179         .name   = "spi_gpio",
180         .id     = LCD_BUS_NUM,
181         .dev    = {
182                 .parent         = &s3c_device_fb.dev,
183                 .platform_data  = &lcd_spi_gpio_data,
184         },
185 };
186
187 /* KEYPAD */
188 static uint32_t keymap[] __initdata = {
189         /* KEY(row, col, keycode) */
190         KEY(0, 1, KEY_MENU),            /* Send */
191         KEY(0, 2, KEY_BACK),            /* End */
192         KEY(1, 1, KEY_CONFIG),          /* Half shot */
193         KEY(1, 2, KEY_VOLUMEUP),
194         KEY(2, 1, KEY_CAMERA),          /* Full shot */
195         KEY(2, 2, KEY_VOLUMEDOWN),
196 };
197
198 static struct matrix_keymap_data keymap_data __initdata = {
199         .keymap         = keymap,
200         .keymap_size    = ARRAY_SIZE(keymap),
201 };
202
203 static struct samsung_keypad_platdata keypad_data __initdata = {
204         .keymap_data    = &keymap_data,
205         .rows           = 3,
206         .cols           = 3,
207 };
208
209 /* Radio */
210 static struct i2c_board_info i2c1_devs[] __initdata = {
211         {
212                 I2C_BOARD_INFO("si470x", 0x10),
213         },
214 };
215
216 static void __init goni_radio_init(void)
217 {
218         int gpio;
219
220         gpio = S5PV210_GPJ2(4);                 /* XMSMDATA_4 */
221         gpio_request(gpio, "FM_INT");
222         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
223         i2c1_devs[0].irq = gpio_to_irq(gpio);
224
225         gpio = S5PV210_GPJ2(5);                 /* XMSMDATA_5 */
226         gpio_request(gpio, "FM_RST");
227         gpio_direction_output(gpio, 1);
228 }
229
230 /* TSP */
231 static struct mxt_platform_data qt602240_platform_data = {
232         .x_line         = 17,
233         .y_line         = 11,
234         .x_size         = 800,
235         .y_size         = 480,
236         .blen           = 0x21,
237         .threshold      = 0x28,
238         .voltage        = 2800000,              /* 2.8V */
239         .orient         = MXT_DIAGONAL,
240         .irqflags       = IRQF_TRIGGER_FALLING,
241 };
242
243 static struct s3c2410_platform_i2c i2c2_data __initdata = {
244         .flags          = 0,
245         .bus_num        = 2,
246         .slave_addr     = 0x10,
247         .frequency      = 400 * 1000,
248         .sda_delay      = 100,
249 };
250
251 static struct i2c_board_info i2c2_devs[] __initdata = {
252         {
253                 I2C_BOARD_INFO("qt602240_ts", 0x4a),
254                 .platform_data = &qt602240_platform_data,
255         },
256 };
257
258 static void __init goni_tsp_init(void)
259 {
260         int gpio;
261
262         gpio = S5PV210_GPJ1(3);         /* XMSMADDR_11 */
263         gpio_request(gpio, "TSP_LDO_ON");
264         gpio_direction_output(gpio, 1);
265         gpio_export(gpio, 0);
266
267         gpio = S5PV210_GPJ0(5);         /* XMSMADDR_5 */
268         gpio_request(gpio, "TSP_INT");
269
270         s5p_register_gpio_interrupt(gpio);
271         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
272         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
273         i2c2_devs[0].irq = gpio_to_irq(gpio);
274 }
275
276 /* MAX8998 regulators */
277 #if defined(CONFIG_REGULATOR_MAX8998) || defined(CONFIG_REGULATOR_MAX8998_MODULE)
278
279 static struct regulator_consumer_supply goni_ldo3_consumers[] = {
280         REGULATOR_SUPPLY("vusb_a", "s3c-hsotg"),
281 };
282
283 static struct regulator_consumer_supply goni_ldo5_consumers[] = {
284         REGULATOR_SUPPLY("vmmc", "s3c-sdhci.0"),
285 };
286
287 static struct regulator_consumer_supply goni_ldo8_consumers[] = {
288         REGULATOR_SUPPLY("vusb_d", "s3c-hsotg"),
289 };
290
291 static struct regulator_consumer_supply goni_ldo11_consumers[] = {
292         REGULATOR_SUPPLY("vddio", "0-0030"), /* "CAM_IO_2.8V" */
293 };
294
295 static struct regulator_consumer_supply goni_ldo13_consumers[] = {
296         REGULATOR_SUPPLY("vdda", "0-0030"), /* "CAM_A_2.8V" */
297 };
298
299 static struct regulator_consumer_supply goni_ldo14_consumers[] = {
300         REGULATOR_SUPPLY("vdd_core", "0-0030"), /* "CAM_CIF_1.8V" */
301 };
302
303 static struct regulator_init_data goni_ldo2_data = {
304         .constraints    = {
305                 .name           = "VALIVE_1.1V",
306                 .min_uV         = 1100000,
307                 .max_uV         = 1100000,
308                 .apply_uV       = 1,
309                 .always_on      = 1,
310                 .state_mem      = {
311                         .enabled = 1,
312                 },
313         },
314 };
315
316 static struct regulator_init_data goni_ldo3_data = {
317         .constraints    = {
318                 .name           = "VUSB+MIPI_1.1V",
319                 .min_uV         = 1100000,
320                 .max_uV         = 1100000,
321                 .apply_uV       = 1,
322                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
323         },
324         .num_consumer_supplies = ARRAY_SIZE(goni_ldo3_consumers),
325         .consumer_supplies = goni_ldo3_consumers,
326 };
327
328 static struct regulator_init_data goni_ldo4_data = {
329         .constraints    = {
330                 .name           = "VDAC_3.3V",
331                 .min_uV         = 3300000,
332                 .max_uV         = 3300000,
333                 .apply_uV       = 1,
334         },
335 };
336
337 static struct regulator_init_data goni_ldo5_data = {
338         .constraints    = {
339                 .name           = "VTF_2.8V",
340                 .min_uV         = 2800000,
341                 .max_uV         = 2800000,
342                 .apply_uV       = 1,
343                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
344         },
345         .num_consumer_supplies = ARRAY_SIZE(goni_ldo5_consumers),
346         .consumer_supplies = goni_ldo5_consumers,
347 };
348
349 static struct regulator_init_data goni_ldo6_data = {
350         .constraints    = {
351                 .name           = "VCC_3.3V",
352                 .min_uV         = 3300000,
353                 .max_uV         = 3300000,
354                 .apply_uV       = 1,
355         },
356 };
357
358 static struct regulator_init_data goni_ldo7_data = {
359         .constraints    = {
360                 .name           = "VLCD_1.8V",
361                 .min_uV         = 1800000,
362                 .max_uV         = 1800000,
363                 .apply_uV       = 1,
364                 .always_on      = 1,
365         },
366 };
367
368 static struct regulator_init_data goni_ldo8_data = {
369         .constraints    = {
370                 .name           = "VUSB+VADC_3.3V",
371                 .min_uV         = 3300000,
372                 .max_uV         = 3300000,
373                 .apply_uV       = 1,
374                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
375         },
376         .num_consumer_supplies = ARRAY_SIZE(goni_ldo8_consumers),
377         .consumer_supplies = goni_ldo8_consumers,
378 };
379
380 static struct regulator_init_data goni_ldo9_data = {
381         .constraints    = {
382                 .name           = "VCC+VCAM_2.8V",
383                 .min_uV         = 2800000,
384                 .max_uV         = 2800000,
385                 .apply_uV       = 1,
386         },
387 };
388
389 static struct regulator_init_data goni_ldo10_data = {
390         .constraints    = {
391                 .name           = "VPLL_1.1V",
392                 .min_uV         = 1100000,
393                 .max_uV         = 1100000,
394                 .apply_uV       = 1,
395                 .boot_on        = 1,
396         },
397 };
398
399 static struct regulator_init_data goni_ldo11_data = {
400         .constraints    = {
401                 .name           = "CAM_IO_2.8V",
402                 .min_uV         = 2800000,
403                 .max_uV         = 2800000,
404                 .apply_uV       = 1,
405                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
406         },
407         .num_consumer_supplies  = ARRAY_SIZE(goni_ldo11_consumers),
408         .consumer_supplies      = goni_ldo11_consumers,
409 };
410
411 static struct regulator_init_data goni_ldo12_data = {
412         .constraints    = {
413                 .name           = "CAM_ISP_1.2V",
414                 .min_uV         = 1200000,
415                 .max_uV         = 1200000,
416                 .apply_uV       = 1,
417         },
418 };
419
420 static struct regulator_init_data goni_ldo13_data = {
421         .constraints    = {
422                 .name           = "CAM_A_2.8V",
423                 .min_uV         = 2800000,
424                 .max_uV         = 2800000,
425                 .apply_uV       = 1,
426                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
427         },
428         .num_consumer_supplies  = ARRAY_SIZE(goni_ldo13_consumers),
429         .consumer_supplies      = goni_ldo13_consumers,
430 };
431
432 static struct regulator_init_data goni_ldo14_data = {
433         .constraints    = {
434                 .name           = "CAM_CIF_1.8V",
435                 .min_uV         = 1800000,
436                 .max_uV         = 1800000,
437                 .apply_uV       = 1,
438                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
439         },
440         .num_consumer_supplies  = ARRAY_SIZE(goni_ldo14_consumers),
441         .consumer_supplies      = goni_ldo14_consumers,
442 };
443
444 static struct regulator_init_data goni_ldo15_data = {
445         .constraints    = {
446                 .name           = "CAM_AF_3.3V",
447                 .min_uV         = 3300000,
448                 .max_uV         = 3300000,
449                 .apply_uV       = 1,
450         },
451 };
452
453 static struct regulator_init_data goni_ldo16_data = {
454         .constraints    = {
455                 .name           = "VMIPI_1.8V",
456                 .min_uV         = 1800000,
457                 .max_uV         = 1800000,
458                 .apply_uV       = 1,
459         },
460 };
461
462 static struct regulator_init_data goni_ldo17_data = {
463         .constraints    = {
464                 .name           = "VCC_3.0V_LCD",
465                 .min_uV         = 3000000,
466                 .max_uV         = 3000000,
467                 .apply_uV       = 1,
468                 .always_on      = 1,
469         },
470 };
471
472 /* BUCK */
473 static struct regulator_consumer_supply buck1_consumer =
474         REGULATOR_SUPPLY("vddarm", NULL);
475
476 static struct regulator_consumer_supply buck2_consumer =
477         REGULATOR_SUPPLY("vddint", NULL);
478
479 static struct regulator_init_data goni_buck1_data = {
480         .constraints    = {
481                 .name           = "VARM_1.2V",
482                 .min_uV         = 1200000,
483                 .max_uV         = 1200000,
484                 .apply_uV       = 1,
485                 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
486                                   REGULATOR_CHANGE_STATUS,
487         },
488         .num_consumer_supplies  = 1,
489         .consumer_supplies      = &buck1_consumer,
490 };
491
492 static struct regulator_init_data goni_buck2_data = {
493         .constraints    = {
494                 .name           = "VINT_1.2V",
495                 .min_uV         = 1200000,
496                 .max_uV         = 1200000,
497                 .apply_uV       = 1,
498                 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
499                                   REGULATOR_CHANGE_STATUS,
500         },
501         .num_consumer_supplies  = 1,
502         .consumer_supplies      = &buck2_consumer,
503 };
504
505 static struct regulator_init_data goni_buck3_data = {
506         .constraints    = {
507                 .name           = "VCC_1.8V",
508                 .min_uV         = 1800000,
509                 .max_uV         = 1800000,
510                 .apply_uV       = 1,
511                 .state_mem      = {
512                         .enabled = 1,
513                 },
514         },
515 };
516
517 static struct regulator_init_data goni_buck4_data = {
518         .constraints    = {
519                 .name           = "CAM_CORE_1.2V",
520                 .min_uV         = 1200000,
521                 .max_uV         = 1200000,
522                 .apply_uV       = 1,
523                 .always_on      = 1,
524         },
525 };
526
527 static struct max8998_regulator_data goni_regulators[] = {
528         { MAX8998_LDO2,  &goni_ldo2_data },
529         { MAX8998_LDO3,  &goni_ldo3_data },
530         { MAX8998_LDO4,  &goni_ldo4_data },
531         { MAX8998_LDO5,  &goni_ldo5_data },
532         { MAX8998_LDO6,  &goni_ldo6_data },
533         { MAX8998_LDO7,  &goni_ldo7_data },
534         { MAX8998_LDO8,  &goni_ldo8_data },
535         { MAX8998_LDO9,  &goni_ldo9_data },
536         { MAX8998_LDO10, &goni_ldo10_data },
537         { MAX8998_LDO11, &goni_ldo11_data },
538         { MAX8998_LDO12, &goni_ldo12_data },
539         { MAX8998_LDO13, &goni_ldo13_data },
540         { MAX8998_LDO14, &goni_ldo14_data },
541         { MAX8998_LDO15, &goni_ldo15_data },
542         { MAX8998_LDO16, &goni_ldo16_data },
543         { MAX8998_LDO17, &goni_ldo17_data },
544         { MAX8998_BUCK1, &goni_buck1_data },
545         { MAX8998_BUCK2, &goni_buck2_data },
546         { MAX8998_BUCK3, &goni_buck3_data },
547         { MAX8998_BUCK4, &goni_buck4_data },
548 };
549
550 static struct max8998_platform_data goni_max8998_pdata = {
551         .num_regulators = ARRAY_SIZE(goni_regulators),
552         .regulators     = goni_regulators,
553         .buck1_set1     = S5PV210_GPH0(3),
554         .buck1_set2     = S5PV210_GPH0(4),
555         .buck2_set3     = S5PV210_GPH0(5),
556         .buck1_voltage1 = 1200000,
557         .buck1_voltage2 = 1200000,
558         .buck1_voltage3 = 1200000,
559         .buck1_voltage4 = 1200000,
560         .buck2_voltage1 = 1200000,
561         .buck2_voltage2 = 1200000,
562 };
563 #endif
564
565 static struct regulator_consumer_supply wm8994_fixed_voltage0_supplies[] = {
566         REGULATOR_SUPPLY("DBVDD", "5-001a"),
567         REGULATOR_SUPPLY("AVDD2", "5-001a"),
568         REGULATOR_SUPPLY("CPVDD", "5-001a"),
569 };
570
571 static struct regulator_consumer_supply wm8994_fixed_voltage1_supplies[] = {
572         REGULATOR_SUPPLY("SPKVDD1", "5-001a"),
573         REGULATOR_SUPPLY("SPKVDD2", "5-001a"),
574 };
575
576 static struct regulator_init_data wm8994_fixed_voltage0_init_data = {
577         .constraints = {
578                 .always_on = 1,
579         },
580         .num_consumer_supplies  = ARRAY_SIZE(wm8994_fixed_voltage0_supplies),
581         .consumer_supplies      = wm8994_fixed_voltage0_supplies,
582 };
583
584 static struct regulator_init_data wm8994_fixed_voltage1_init_data = {
585         .constraints = {
586                 .always_on = 1,
587         },
588         .num_consumer_supplies  = ARRAY_SIZE(wm8994_fixed_voltage1_supplies),
589         .consumer_supplies      = wm8994_fixed_voltage1_supplies,
590 };
591
592 static struct fixed_voltage_config wm8994_fixed_voltage0_config = {
593         .supply_name    = "VCC_1.8V_PDA",
594         .microvolts     = 1800000,
595         .gpio           = -EINVAL,
596         .init_data      = &wm8994_fixed_voltage0_init_data,
597 };
598
599 static struct fixed_voltage_config wm8994_fixed_voltage1_config = {
600         .supply_name    = "V_BAT",
601         .microvolts     = 3700000,
602         .gpio           = -EINVAL,
603         .init_data      = &wm8994_fixed_voltage1_init_data,
604 };
605
606 static struct platform_device wm8994_fixed_voltage0 = {
607         .name           = "reg-fixed-voltage",
608         .id             = 0,
609         .dev            = {
610                 .platform_data  = &wm8994_fixed_voltage0_config,
611         },
612 };
613
614 static struct platform_device wm8994_fixed_voltage1 = {
615         .name           = "reg-fixed-voltage",
616         .id             = 1,
617         .dev            = {
618                 .platform_data  = &wm8994_fixed_voltage1_config,
619         },
620 };
621
622 static struct regulator_consumer_supply wm8994_avdd1_supply =
623         REGULATOR_SUPPLY("AVDD1", "5-001a");
624
625 static struct regulator_consumer_supply wm8994_dcvdd_supply =
626         REGULATOR_SUPPLY("DCVDD", "5-001a");
627
628 static struct regulator_init_data wm8994_ldo1_data = {
629         .constraints    = {
630                 .name           = "AVDD1_3.0V",
631                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
632         },
633         .num_consumer_supplies  = 1,
634         .consumer_supplies      = &wm8994_avdd1_supply,
635 };
636
637 static struct regulator_init_data wm8994_ldo2_data = {
638         .constraints    = {
639                 .name           = "DCVDD_1.0V",
640         },
641         .num_consumer_supplies  = 1,
642         .consumer_supplies      = &wm8994_dcvdd_supply,
643 };
644
645 static struct wm8994_pdata wm8994_platform_data = {
646         /* configure gpio1 function: 0x0001(Logic level input/output) */
647         .gpio_defaults[0] = 0x0001,
648         /* configure gpio3/4/5/7 function for AIF2 voice */
649         .gpio_defaults[2] = 0x8100,
650         .gpio_defaults[3] = 0x8100,
651         .gpio_defaults[4] = 0x8100,
652         .gpio_defaults[6] = 0x0100,
653         /* configure gpio8/9/10/11 function for AIF3 BT */
654         .gpio_defaults[7] = 0x8100,
655         .gpio_defaults[8] = 0x0100,
656         .gpio_defaults[9] = 0x0100,
657         .gpio_defaults[10] = 0x0100,
658         .ldo[0] = { S5PV210_MP03(6), NULL, &wm8994_ldo1_data }, /* XM0FRNB_2 */
659         .ldo[1] = { 0, NULL, &wm8994_ldo2_data },
660 };
661
662 /* GPIO I2C PMIC */
663 #define AP_I2C_GPIO_PMIC_BUS_4  4
664 static struct i2c_gpio_platform_data goni_i2c_gpio_pmic_data = {
665         .sda_pin        = S5PV210_GPJ4(0),      /* XMSMCSN */
666         .scl_pin        = S5PV210_GPJ4(3),      /* XMSMIRQN */
667 };
668
669 static struct platform_device goni_i2c_gpio_pmic = {
670         .name           = "i2c-gpio",
671         .id             = AP_I2C_GPIO_PMIC_BUS_4,
672         .dev            = {
673                 .platform_data  = &goni_i2c_gpio_pmic_data,
674         },
675 };
676
677 static struct i2c_board_info i2c_gpio_pmic_devs[] __initdata = {
678 #if defined(CONFIG_REGULATOR_MAX8998) || defined(CONFIG_REGULATOR_MAX8998_MODULE)
679         {
680                 /* 0xCC when SRAD = 0 */
681                 I2C_BOARD_INFO("max8998", 0xCC >> 1),
682                 .platform_data = &goni_max8998_pdata,
683         },
684 #endif
685 };
686
687 /* GPIO I2C AP 1.8V */
688 #define AP_I2C_GPIO_BUS_5       5
689 static struct i2c_gpio_platform_data goni_i2c_gpio5_data = {
690         .sda_pin        = S5PV210_MP05(3),      /* XM0ADDR_11 */
691         .scl_pin        = S5PV210_MP05(2),      /* XM0ADDR_10 */
692 };
693
694 static struct platform_device goni_i2c_gpio5 = {
695         .name           = "i2c-gpio",
696         .id             = AP_I2C_GPIO_BUS_5,
697         .dev            = {
698                 .platform_data  = &goni_i2c_gpio5_data,
699         },
700 };
701
702 static struct i2c_board_info i2c_gpio5_devs[] __initdata = {
703         {
704                 /* CS/ADDR = low 0x34 (FYI: high = 0x36) */
705                 I2C_BOARD_INFO("wm8994", 0x1a),
706                 .platform_data  = &wm8994_platform_data,
707         },
708 };
709
710 /* PMIC Power button */
711 static struct gpio_keys_button goni_gpio_keys_table[] = {
712         {
713                 .code           = KEY_POWER,
714                 .gpio           = S5PV210_GPH2(6),
715                 .desc           = "gpio-keys: KEY_POWER",
716                 .type           = EV_KEY,
717                 .active_low     = 1,
718                 .wakeup         = 1,
719                 .debounce_interval = 1,
720         },
721 };
722
723 static struct gpio_keys_platform_data goni_gpio_keys_data = {
724         .buttons        = goni_gpio_keys_table,
725         .nbuttons       = ARRAY_SIZE(goni_gpio_keys_table),
726 };
727
728 static struct platform_device goni_device_gpiokeys = {
729         .name = "gpio-keys",
730         .dev = {
731                 .platform_data = &goni_gpio_keys_data,
732         },
733 };
734
735 static void __init goni_pmic_init(void)
736 {
737         /* AP_PMIC_IRQ: EINT7 */
738         s3c_gpio_cfgpin(S5PV210_GPH0(7), S3C_GPIO_SFN(0xf));
739         s3c_gpio_setpull(S5PV210_GPH0(7), S3C_GPIO_PULL_UP);
740
741         /* nPower: EINT22 */
742         s3c_gpio_cfgpin(S5PV210_GPH2(6), S3C_GPIO_SFN(0xf));
743         s3c_gpio_setpull(S5PV210_GPH2(6), S3C_GPIO_PULL_UP);
744 }
745
746 /* MoviNAND */
747 static struct s3c_sdhci_platdata goni_hsmmc0_data __initdata = {
748         .max_width              = 4,
749         .cd_type                = S3C_SDHCI_CD_PERMANENT,
750 };
751
752 /* Wireless LAN */
753 static struct s3c_sdhci_platdata goni_hsmmc1_data __initdata = {
754         .max_width              = 4,
755         .cd_type                = S3C_SDHCI_CD_EXTERNAL,
756         /* ext_cd_{init,cleanup} callbacks will be added later */
757 };
758
759 /* External Flash */
760 #define GONI_EXT_FLASH_EN       S5PV210_MP05(4)
761 #define GONI_EXT_FLASH_CD       S5PV210_GPH3(4)
762 static struct s3c_sdhci_platdata goni_hsmmc2_data __initdata = {
763         .max_width              = 4,
764         .cd_type                = S3C_SDHCI_CD_GPIO,
765         .ext_cd_gpio            = GONI_EXT_FLASH_CD,
766         .ext_cd_gpio_invert     = 1,
767 };
768
769 static struct regulator_consumer_supply mmc2_supplies[] = {
770         REGULATOR_SUPPLY("vmmc", "s3c-sdhci.2"),
771 };
772
773 static struct regulator_init_data mmc2_fixed_voltage_init_data = {
774         .constraints            = {
775                 .name           = "V_TF_2.8V",
776                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
777         },
778         .num_consumer_supplies  = ARRAY_SIZE(mmc2_supplies),
779         .consumer_supplies      = mmc2_supplies,
780 };
781
782 static struct fixed_voltage_config mmc2_fixed_voltage_config = {
783         .supply_name            = "EXT_FLASH_EN",
784         .microvolts             = 2800000,
785         .gpio                   = GONI_EXT_FLASH_EN,
786         .enable_high            = true,
787         .init_data              = &mmc2_fixed_voltage_init_data,
788 };
789
790 static struct platform_device mmc2_fixed_voltage = {
791         .name           = "reg-fixed-voltage",
792         .id             = 2,
793         .dev            = {
794                 .platform_data  = &mmc2_fixed_voltage_config,
795         },
796 };
797
798 static void goni_setup_sdhci(void)
799 {
800         s3c_sdhci0_set_platdata(&goni_hsmmc0_data);
801         s3c_sdhci1_set_platdata(&goni_hsmmc1_data);
802         s3c_sdhci2_set_platdata(&goni_hsmmc2_data);
803 };
804
805 static struct platform_device *goni_devices[] __initdata = {
806         &s3c_device_fb,
807         &s5p_device_onenand,
808         &goni_spi_gpio,
809         &goni_i2c_gpio_pmic,
810         &goni_i2c_gpio5,
811         &mmc2_fixed_voltage,
812         &goni_device_gpiokeys,
813         &s5p_device_mfc,
814         &s5p_device_mfc_l,
815         &s5p_device_mfc_r,
816         &s3c_device_i2c0,
817         &s5p_device_fimc0,
818         &s5p_device_fimc1,
819         &s5p_device_fimc2,
820         &s3c_device_hsmmc0,
821         &s3c_device_hsmmc1,
822         &s3c_device_hsmmc2,
823         &s5pv210_device_iis0,
824         &s3c_device_usb_hsotg,
825         &samsung_device_keypad,
826         &s3c_device_i2c1,
827         &s3c_device_i2c2,
828         &wm8994_fixed_voltage0,
829         &wm8994_fixed_voltage1,
830 };
831
832 static void __init goni_sound_init(void)
833 {
834         /* Ths main clock of WM8994 codec uses the output of CLKOUT pin.
835          * The CLKOUT[9:8] set to 0x3(XUSBXTI) of 0xE010E000(OTHERS)
836          * because it needs 24MHz clock to operate WM8994 codec.
837          */
838         __raw_writel(__raw_readl(S5P_OTHERS) | (0x3 << 8), S5P_OTHERS);
839 }
840
841 static void __init goni_map_io(void)
842 {
843         s5p_init_io(NULL, 0, S5P_VA_CHIPID);
844         s3c24xx_init_clocks(24000000);
845         s3c24xx_init_uarts(goni_uartcfgs, ARRAY_SIZE(goni_uartcfgs));
846         s5p_set_timer_source(S5P_PWM3, S5P_PWM4);
847 }
848
849 static void __init goni_reserve(void)
850 {
851         s5p_mfc_reserve_mem(0x43000000, 8 << 20, 0x51000000, 8 << 20);
852 }
853
854 static void __init goni_machine_init(void)
855 {
856         /* Radio: call before I2C 1 registeration */
857         goni_radio_init();
858
859         /* I2C0 */
860         s3c_i2c0_set_platdata(NULL);
861
862         /* I2C1 */
863         s3c_i2c1_set_platdata(NULL);
864         i2c_register_board_info(1, i2c1_devs, ARRAY_SIZE(i2c1_devs));
865
866         /* TSP: call before I2C 2 registeration */
867         goni_tsp_init();
868
869         /* I2C2 */
870         s3c_i2c2_set_platdata(&i2c2_data);
871         i2c_register_board_info(2, i2c2_devs, ARRAY_SIZE(i2c2_devs));
872
873         /* PMIC */
874         goni_pmic_init();
875         i2c_register_board_info(AP_I2C_GPIO_PMIC_BUS_4, i2c_gpio_pmic_devs,
876                         ARRAY_SIZE(i2c_gpio_pmic_devs));
877         /* SDHCI */
878         goni_setup_sdhci();
879
880         /* SOUND */
881         goni_sound_init();
882         i2c_register_board_info(AP_I2C_GPIO_BUS_5, i2c_gpio5_devs,
883                         ARRAY_SIZE(i2c_gpio5_devs));
884
885         /* FB */
886         s3c_fb_set_platdata(&goni_lcd_pdata);
887
888         /* SPI */
889         spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
890
891         /* KEYPAD */
892         samsung_keypad_set_platdata(&keypad_data);
893
894         clk_xusbxti.rate = 24000000;
895
896         platform_add_devices(goni_devices, ARRAY_SIZE(goni_devices));
897 }
898
899 MACHINE_START(GONI, "GONI")
900         /* Maintainers: Kyungmin Park <kyungmin.park@samsung.com> */
901         .boot_params    = S5P_PA_SDRAM + 0x100,
902         .init_irq       = s5pv210_init_irq,
903         .map_io         = goni_map_io,
904         .init_machine   = goni_machine_init,
905         .timer          = &s5p_timer,
906         .reserve        = &goni_reserve,
907 MACHINE_END