Merge branch 'prcm_scm_misc_fixes_3.2' of git://git.pwsan.com/linux-2.6 into fixes
[pandora-kernel.git] / arch / arm / mach-exynos4 / mach-nuri.c
1 /*
2  * linux/arch/arm/mach-exynos4/mach-nuri.c
3  *
4  * Copyright (c) 2011 Samsung Electronics Co., Ltd.
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/platform_device.h>
12 #include <linux/serial_core.h>
13 #include <linux/input.h>
14 #include <linux/i2c.h>
15 #include <linux/i2c/atmel_mxt_ts.h>
16 #include <linux/i2c-gpio.h>
17 #include <linux/gpio_keys.h>
18 #include <linux/gpio.h>
19 #include <linux/power/max8903_charger.h>
20 #include <linux/power/max17042_battery.h>
21 #include <linux/regulator/machine.h>
22 #include <linux/regulator/fixed.h>
23 #include <linux/mfd/max8997.h>
24 #include <linux/mfd/max8997-private.h>
25 #include <linux/mmc/host.h>
26 #include <linux/fb.h>
27 #include <linux/pwm_backlight.h>
28
29 #include <video/platform_lcd.h>
30
31 #include <asm/mach/arch.h>
32 #include <asm/mach-types.h>
33
34 #include <plat/adc.h>
35 #include <plat/regs-serial.h>
36 #include <plat/exynos4.h>
37 #include <plat/cpu.h>
38 #include <plat/devs.h>
39 #include <plat/sdhci.h>
40 #include <plat/ehci.h>
41 #include <plat/clock.h>
42 #include <plat/gpio-cfg.h>
43 #include <plat/iic.h>
44 #include <plat/mfc.h>
45 #include <plat/pd.h>
46
47 #include <mach/map.h>
48
49 /* Following are default values for UCON, ULCON and UFCON UART registers */
50 #define NURI_UCON_DEFAULT       (S3C2410_UCON_TXILEVEL |        \
51                                  S3C2410_UCON_RXILEVEL |        \
52                                  S3C2410_UCON_TXIRQMODE |       \
53                                  S3C2410_UCON_RXIRQMODE |       \
54                                  S3C2410_UCON_RXFIFO_TOI |      \
55                                  S3C2443_UCON_RXERR_IRQEN)
56
57 #define NURI_ULCON_DEFAULT      S3C2410_LCON_CS8
58
59 #define NURI_UFCON_DEFAULT      (S3C2410_UFCON_FIFOMODE |       \
60                                  S5PV210_UFCON_TXTRIG256 |      \
61                                  S5PV210_UFCON_RXTRIG256)
62
63 enum fixed_regulator_id {
64         FIXED_REG_ID_MMC = 0,
65         FIXED_REG_ID_MAX8903,
66 };
67
68 static struct s3c2410_uartcfg nuri_uartcfgs[] __initdata = {
69         {
70                 .hwport         = 0,
71                 .ucon           = NURI_UCON_DEFAULT,
72                 .ulcon          = NURI_ULCON_DEFAULT,
73                 .ufcon          = NURI_UFCON_DEFAULT,
74         },
75         {
76                 .hwport         = 1,
77                 .ucon           = NURI_UCON_DEFAULT,
78                 .ulcon          = NURI_ULCON_DEFAULT,
79                 .ufcon          = NURI_UFCON_DEFAULT,
80         },
81         {
82                 .hwport         = 2,
83                 .ucon           = NURI_UCON_DEFAULT,
84                 .ulcon          = NURI_ULCON_DEFAULT,
85                 .ufcon          = NURI_UFCON_DEFAULT,
86         },
87         {
88                 .hwport         = 3,
89                 .ucon           = NURI_UCON_DEFAULT,
90                 .ulcon          = NURI_ULCON_DEFAULT,
91                 .ufcon          = NURI_UFCON_DEFAULT,
92         },
93 };
94
95 /* eMMC */
96 static struct s3c_sdhci_platdata nuri_hsmmc0_data __initdata = {
97         .max_width              = 8,
98         .host_caps              = (MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA |
99                                 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
100                                 MMC_CAP_DISABLE | MMC_CAP_ERASE),
101         .cd_type                = S3C_SDHCI_CD_PERMANENT,
102         .clk_type               = S3C_SDHCI_CLK_DIV_EXTERNAL,
103 };
104
105 static struct regulator_consumer_supply emmc_supplies[] = {
106         REGULATOR_SUPPLY("vmmc", "s3c-sdhci.0"),
107         REGULATOR_SUPPLY("vmmc", "dw_mmc"),
108 };
109
110 static struct regulator_init_data emmc_fixed_voltage_init_data = {
111         .constraints            = {
112                 .name           = "VMEM_VDD_2.8V",
113                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
114         },
115         .num_consumer_supplies  = ARRAY_SIZE(emmc_supplies),
116         .consumer_supplies      = emmc_supplies,
117 };
118
119 static struct fixed_voltage_config emmc_fixed_voltage_config = {
120         .supply_name            = "MASSMEMORY_EN (inverted)",
121         .microvolts             = 2800000,
122         .gpio                   = EXYNOS4_GPL1(1),
123         .enable_high            = false,
124         .init_data              = &emmc_fixed_voltage_init_data,
125 };
126
127 static struct platform_device emmc_fixed_voltage = {
128         .name                   = "reg-fixed-voltage",
129         .id                     = FIXED_REG_ID_MMC,
130         .dev                    = {
131                 .platform_data  = &emmc_fixed_voltage_config,
132         },
133 };
134
135 /* SD */
136 static struct s3c_sdhci_platdata nuri_hsmmc2_data __initdata = {
137         .max_width              = 4,
138         .host_caps              = MMC_CAP_4_BIT_DATA |
139                                 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
140                                 MMC_CAP_DISABLE,
141         .ext_cd_gpio            = EXYNOS4_GPX3(3),      /* XEINT_27 */
142         .ext_cd_gpio_invert     = 1,
143         .cd_type                = S3C_SDHCI_CD_GPIO,
144         .clk_type               = S3C_SDHCI_CLK_DIV_EXTERNAL,
145 };
146
147 /* WLAN */
148 static struct s3c_sdhci_platdata nuri_hsmmc3_data __initdata = {
149         .max_width              = 4,
150         .host_caps              = MMC_CAP_4_BIT_DATA |
151                                 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
152         .cd_type                = S3C_SDHCI_CD_EXTERNAL,
153         .clk_type               = S3C_SDHCI_CLK_DIV_EXTERNAL,
154 };
155
156 static void __init nuri_sdhci_init(void)
157 {
158         s3c_sdhci0_set_platdata(&nuri_hsmmc0_data);
159         s3c_sdhci2_set_platdata(&nuri_hsmmc2_data);
160         s3c_sdhci3_set_platdata(&nuri_hsmmc3_data);
161 }
162
163 /* GPIO KEYS */
164 static struct gpio_keys_button nuri_gpio_keys_tables[] = {
165         {
166                 .code                   = KEY_VOLUMEUP,
167                 .gpio                   = EXYNOS4_GPX2(0),      /* XEINT16 */
168                 .desc                   = "gpio-keys: KEY_VOLUMEUP",
169                 .type                   = EV_KEY,
170                 .active_low             = 1,
171                 .debounce_interval      = 1,
172         }, {
173                 .code                   = KEY_VOLUMEDOWN,
174                 .gpio                   = EXYNOS4_GPX2(1),      /* XEINT17 */
175                 .desc                   = "gpio-keys: KEY_VOLUMEDOWN",
176                 .type                   = EV_KEY,
177                 .active_low             = 1,
178                 .debounce_interval      = 1,
179         }, {
180                 .code                   = KEY_POWER,
181                 .gpio                   = EXYNOS4_GPX2(7),      /* XEINT23 */
182                 .desc                   = "gpio-keys: KEY_POWER",
183                 .type                   = EV_KEY,
184                 .active_low             = 1,
185                 .wakeup                 = 1,
186                 .debounce_interval      = 1,
187         },
188 };
189
190 static struct gpio_keys_platform_data nuri_gpio_keys_data = {
191         .buttons                = nuri_gpio_keys_tables,
192         .nbuttons               = ARRAY_SIZE(nuri_gpio_keys_tables),
193 };
194
195 static struct platform_device nuri_gpio_keys = {
196         .name                   = "gpio-keys",
197         .dev                    = {
198                 .platform_data  = &nuri_gpio_keys_data,
199         },
200 };
201
202 static void nuri_lcd_power_on(struct plat_lcd_data *pd, unsigned int power)
203 {
204         int gpio = EXYNOS4_GPE1(5);
205
206         gpio_request(gpio, "LVDS_nSHDN");
207         gpio_direction_output(gpio, power);
208         gpio_free(gpio);
209 }
210
211 static int nuri_bl_init(struct device *dev)
212 {
213         int ret, gpio = EXYNOS4_GPE2(3);
214
215         ret = gpio_request(gpio, "LCD_LDO_EN");
216         if (!ret)
217                 gpio_direction_output(gpio, 0);
218
219         return ret;
220 }
221
222 static int nuri_bl_notify(struct device *dev, int brightness)
223 {
224         if (brightness < 1)
225                 brightness = 0;
226
227         gpio_set_value(EXYNOS4_GPE2(3), 1);
228
229         return brightness;
230 }
231
232 static void nuri_bl_exit(struct device *dev)
233 {
234         gpio_free(EXYNOS4_GPE2(3));
235 }
236
237 /* nuri pwm backlight */
238 static struct platform_pwm_backlight_data nuri_backlight_data = {
239         .pwm_id                 = 0,
240         .pwm_period_ns          = 30000,
241         .max_brightness         = 100,
242         .dft_brightness         = 50,
243         .init                   = nuri_bl_init,
244         .notify                 = nuri_bl_notify,
245         .exit                   = nuri_bl_exit,
246 };
247
248 static struct platform_device nuri_backlight_device = {
249         .name                   = "pwm-backlight",
250         .id                     = -1,
251         .dev                    = {
252                 .parent         = &s3c_device_timer[0].dev,
253                 .platform_data  = &nuri_backlight_data,
254         },
255 };
256
257 static struct plat_lcd_data nuri_lcd_platform_data = {
258         .set_power              = nuri_lcd_power_on,
259 };
260
261 static struct platform_device nuri_lcd_device = {
262         .name                   = "platform-lcd",
263         .id                     = -1,
264         .dev                    = {
265                 .platform_data  = &nuri_lcd_platform_data,
266         },
267 };
268
269 /* I2C1 */
270 static struct i2c_board_info i2c1_devs[] __initdata = {
271         /* Gyro, To be updated */
272 };
273
274 /* TSP */
275 static u8 mxt_init_vals[] = {
276         /* MXT_GEN_COMMAND(6) */
277         0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
278         /* MXT_GEN_POWER(7) */
279         0x20, 0xff, 0x32,
280         /* MXT_GEN_ACQUIRE(8) */
281         0x0a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x23,
282         /* MXT_TOUCH_MULTI(9) */
283         0x00, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00,
284         0x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00,
285         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
286         0x00,
287         /* MXT_TOUCH_KEYARRAY(15) */
288         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
289         0x00,
290         /* MXT_SPT_GPIOPWM(19) */
291         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
292         0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
293         /* MXT_PROCI_GRIPFACE(20) */
294         0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x28, 0x04,
295         0x0f, 0x0a,
296         /* MXT_PROCG_NOISE(22) */
297         0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x23, 0x00,
298         0x00, 0x05, 0x0f, 0x19, 0x23, 0x2d, 0x03,
299         /* MXT_TOUCH_PROXIMITY(23) */
300         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
301         0x00, 0x00, 0x00, 0x00, 0x00,
302         /* MXT_PROCI_ONETOUCH(24) */
303         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
304         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
305         /* MXT_SPT_SELFTEST(25) */
306         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
307         0x00, 0x00, 0x00, 0x00,
308         /* MXT_PROCI_TWOTOUCH(27) */
309         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
310         /* MXT_SPT_CTECONFIG(28) */
311         0x00, 0x00, 0x02, 0x08, 0x10, 0x00,
312 };
313
314 static struct mxt_platform_data mxt_platform_data = {
315         .config                 = mxt_init_vals,
316         .config_length          = ARRAY_SIZE(mxt_init_vals),
317
318         .x_line                 = 18,
319         .y_line                 = 11,
320         .x_size                 = 1024,
321         .y_size                 = 600,
322         .blen                   = 0x1,
323         .threshold              = 0x28,
324         .voltage                = 2800000,              /* 2.8V */
325         .orient                 = MXT_DIAGONAL_COUNTER,
326         .irqflags               = IRQF_TRIGGER_FALLING,
327 };
328
329 static struct s3c2410_platform_i2c i2c3_data __initdata = {
330         .flags          = 0,
331         .bus_num        = 3,
332         .slave_addr     = 0x10,
333         .frequency      = 400 * 1000,
334         .sda_delay      = 100,
335 };
336
337 static struct i2c_board_info i2c3_devs[] __initdata = {
338         {
339                 I2C_BOARD_INFO("atmel_mxt_ts", 0x4a),
340                 .platform_data  = &mxt_platform_data,
341                 .irq            = IRQ_EINT(4),
342         },
343 };
344
345 static void __init nuri_tsp_init(void)
346 {
347         int gpio;
348
349         /* TOUCH_INT: XEINT_4 */
350         gpio = EXYNOS4_GPX0(4);
351         gpio_request(gpio, "TOUCH_INT");
352         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
353         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
354 }
355
356 static struct regulator_consumer_supply __initdata max8997_ldo1_[] = {
357         REGULATOR_SUPPLY("vdd", "s5p-adc"), /* Used by CPU's ADC drv */
358 };
359 static struct regulator_consumer_supply __initdata max8997_ldo3_[] = {
360         REGULATOR_SUPPLY("vdd11", "s5p-mipi-csis.0"), /* MIPI */
361 };
362 static struct regulator_consumer_supply __initdata max8997_ldo4_[] = {
363         REGULATOR_SUPPLY("vdd18", "s5p-mipi-csis.0"), /* MIPI */
364 };
365 static struct regulator_consumer_supply __initdata max8997_ldo5_[] = {
366         REGULATOR_SUPPLY("vhsic", "modemctl"), /* MODEM */
367 };
368 static struct regulator_consumer_supply __initdata max8997_ldo7_[] = {
369         REGULATOR_SUPPLY("dig_18", "0-001f"), /* HCD803 */
370 };
371 static struct regulator_consumer_supply __initdata max8997_ldo8_[] = {
372         REGULATOR_SUPPLY("vusb_d", NULL), /* Used by CPU */
373         REGULATOR_SUPPLY("vdac", NULL), /* Used by CPU */
374 };
375 static struct regulator_consumer_supply __initdata max8997_ldo11_[] = {
376         REGULATOR_SUPPLY("vcc", "platform-lcd"), /* U804 LVDS */
377 };
378 static struct regulator_consumer_supply __initdata max8997_ldo12_[] = {
379         REGULATOR_SUPPLY("vddio", "6-003c"), /* HDC802 */
380 };
381 static struct regulator_consumer_supply __initdata max8997_ldo13_[] = {
382         REGULATOR_SUPPLY("vmmc", "s3c-sdhci.2"), /* TFLASH */
383 };
384 static struct regulator_consumer_supply __initdata max8997_ldo14_[] = {
385         REGULATOR_SUPPLY("inmotor", "max8997-haptic"),
386 };
387 static struct regulator_consumer_supply __initdata max8997_ldo15_[] = {
388         REGULATOR_SUPPLY("avdd", "3-004a"), /* Touch Screen */
389 };
390 static struct regulator_consumer_supply __initdata max8997_ldo16_[] = {
391         REGULATOR_SUPPLY("d_sensor", "0-001f"), /* HDC803 */
392 };
393 static struct regulator_consumer_supply __initdata max8997_ldo18_[] = {
394         REGULATOR_SUPPLY("vdd", "3-004a"), /* Touch Screen */
395 };
396 static struct regulator_consumer_supply __initdata max8997_buck1_[] = {
397         REGULATOR_SUPPLY("vdd_arm", NULL), /* CPUFREQ */
398 };
399 static struct regulator_consumer_supply __initdata max8997_buck2_[] = {
400         REGULATOR_SUPPLY("vdd_int", NULL), /* CPUFREQ */
401 };
402 static struct regulator_consumer_supply __initdata max8997_buck3_[] = {
403         REGULATOR_SUPPLY("vdd", "mali_dev.0"), /* G3D of Exynos 4 */
404 };
405 static struct regulator_consumer_supply __initdata max8997_buck4_[] = {
406         REGULATOR_SUPPLY("core", "0-001f"), /* HDC803 */
407 };
408 static struct regulator_consumer_supply __initdata max8997_buck6_[] = {
409         REGULATOR_SUPPLY("dig_28", "0-001f"), /* pin "7" of HDC803 */
410 };
411 static struct regulator_consumer_supply __initdata max8997_esafeout1_[] = {
412         REGULATOR_SUPPLY("usb_vbus", NULL), /* CPU's USB OTG */
413 };
414 static struct regulator_consumer_supply __initdata max8997_esafeout2_[] = {
415         REGULATOR_SUPPLY("usb_vbus", "modemctl"), /* VBUS of Modem */
416 };
417
418 static struct regulator_consumer_supply __initdata max8997_charger_[] = {
419         REGULATOR_SUPPLY("vinchg1", "charger-manager.0"),
420 };
421 static struct regulator_consumer_supply __initdata max8997_chg_toff_[] = {
422         REGULATOR_SUPPLY("vinchg_stop", NULL), /* for jack interrupt handlers */
423 };
424
425 static struct regulator_consumer_supply __initdata max8997_32khz_ap_[] = {
426         REGULATOR_SUPPLY("gps_clk", "bcm4751"),
427         REGULATOR_SUPPLY("bt_clk", "bcm4330-b1"),
428         REGULATOR_SUPPLY("wifi_clk", "bcm433-b1"),
429 };
430
431 static struct regulator_init_data __initdata max8997_ldo1_data = {
432         .constraints    = {
433                 .name           = "VADC_3.3V_C210",
434                 .min_uV         = 3300000,
435                 .max_uV         = 3300000,
436                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
437                 .apply_uV       = 1,
438                 .state_mem      = {
439                         .disabled       = 1,
440                 },
441         },
442         .num_consumer_supplies  = ARRAY_SIZE(max8997_ldo1_),
443         .consumer_supplies      = max8997_ldo1_,
444 };
445
446 static struct regulator_init_data __initdata max8997_ldo2_data = {
447         .constraints    = {
448                 .name           = "VALIVE_1.1V_C210",
449                 .min_uV         = 1100000,
450                 .max_uV         = 1100000,
451                 .apply_uV       = 1,
452                 .always_on      = 1,
453                 .state_mem      = {
454                         .enabled        = 1,
455                 },
456         },
457 };
458
459 static struct regulator_init_data __initdata max8997_ldo3_data = {
460         .constraints    = {
461                 .name           = "VUSB_1.1V_C210",
462                 .min_uV         = 1100000,
463                 .max_uV         = 1100000,
464                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
465                 .apply_uV       = 1,
466                 .state_mem      = {
467                         .disabled       = 1,
468                 },
469         },
470         .num_consumer_supplies  = ARRAY_SIZE(max8997_ldo3_),
471         .consumer_supplies      = max8997_ldo3_,
472 };
473
474 static struct regulator_init_data __initdata max8997_ldo4_data = {
475         .constraints    = {
476                 .name           = "VMIPI_1.8V",
477                 .min_uV         = 1800000,
478                 .max_uV         = 1800000,
479                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
480                 .apply_uV       = 1,
481                 .state_mem      = {
482                         .disabled       = 1,
483                 },
484         },
485         .num_consumer_supplies  = ARRAY_SIZE(max8997_ldo4_),
486         .consumer_supplies      = max8997_ldo4_,
487 };
488
489 static struct regulator_init_data __initdata max8997_ldo5_data = {
490         .constraints    = {
491                 .name           = "VHSIC_1.2V_C210",
492                 .min_uV         = 1200000,
493                 .max_uV         = 1200000,
494                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
495                 .apply_uV       = 1,
496                 .state_mem      = {
497                         .disabled       = 1,
498                 },
499         },
500         .num_consumer_supplies  = ARRAY_SIZE(max8997_ldo5_),
501         .consumer_supplies      = max8997_ldo5_,
502 };
503
504 static struct regulator_init_data __initdata max8997_ldo6_data = {
505         .constraints    = {
506                 .name           = "VCC_1.8V_PDA",
507                 .min_uV         = 1800000,
508                 .max_uV         = 1800000,
509                 .apply_uV       = 1,
510                 .always_on      = 1,
511                 .state_mem      = {
512                         .enabled        = 1,
513                 },
514         },
515 };
516
517 static struct regulator_init_data __initdata max8997_ldo7_data = {
518         .constraints    = {
519                 .name           = "CAM_ISP_1.8V",
520                 .min_uV         = 1800000,
521                 .max_uV         = 1800000,
522                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
523                 .apply_uV       = 1,
524                 .state_mem      = {
525                         .disabled       = 1,
526                 },
527         },
528         .num_consumer_supplies  = ARRAY_SIZE(max8997_ldo7_),
529         .consumer_supplies      = max8997_ldo7_,
530 };
531
532 static struct regulator_init_data __initdata max8997_ldo8_data = {
533         .constraints    = {
534                 .name           = "VUSB/VDAC_3.3V_C210",
535                 .min_uV         = 3300000,
536                 .max_uV         = 3300000,
537                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
538                 .apply_uV       = 1,
539                 .state_mem      = {
540                         .disabled       = 1,
541                 },
542         },
543         .num_consumer_supplies  = ARRAY_SIZE(max8997_ldo8_),
544         .consumer_supplies      = max8997_ldo8_,
545 };
546
547 static struct regulator_init_data __initdata max8997_ldo9_data = {
548         .constraints    = {
549                 .name           = "VCC_2.8V_PDA",
550                 .min_uV         = 2800000,
551                 .max_uV         = 2800000,
552                 .apply_uV       = 1,
553                 .always_on      = 1,
554                 .state_mem      = {
555                         .enabled        = 1,
556                 },
557         },
558 };
559
560 static struct regulator_init_data __initdata max8997_ldo10_data = {
561         .constraints    = {
562                 .name           = "VPLL_1.1V_C210",
563                 .min_uV         = 1100000,
564                 .max_uV         = 1100000,
565                 .apply_uV       = 1,
566                 .always_on      = 1,
567                 .state_mem      = {
568                         .disabled       = 1,
569                 },
570         },
571 };
572
573 static struct regulator_init_data __initdata max8997_ldo11_data = {
574         .constraints    = {
575                 .name           = "LVDS_VDD3.3V",
576                 .min_uV         = 3300000,
577                 .max_uV         = 3300000,
578                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
579                 .apply_uV       = 1,
580                 .boot_on        = 1,
581                 .state_mem      = {
582                         .disabled       = 1,
583                 },
584         },
585         .num_consumer_supplies  = ARRAY_SIZE(max8997_ldo11_),
586         .consumer_supplies      = max8997_ldo11_,
587 };
588
589 static struct regulator_init_data __initdata max8997_ldo12_data = {
590         .constraints    = {
591                 .name           = "VT_CAM_1.8V",
592                 .min_uV         = 1800000,
593                 .max_uV         = 1800000,
594                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
595                 .apply_uV       = 1,
596                 .state_mem      = {
597                         .disabled       = 1,
598                 },
599         },
600         .num_consumer_supplies  = ARRAY_SIZE(max8997_ldo12_),
601         .consumer_supplies      = max8997_ldo12_,
602 };
603
604 static struct regulator_init_data __initdata max8997_ldo13_data = {
605         .constraints    = {
606                 .name           = "VTF_2.8V",
607                 .min_uV         = 2800000,
608                 .max_uV         = 2800000,
609                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
610                 .apply_uV       = 1,
611                 .state_mem      = {
612                         .disabled       = 1,
613                 },
614         },
615         .num_consumer_supplies  = ARRAY_SIZE(max8997_ldo13_),
616         .consumer_supplies      = max8997_ldo13_,
617 };
618
619 static struct regulator_init_data __initdata max8997_ldo14_data = {
620         .constraints    = {
621                 .name           = "VCC_3.0V_MOTOR",
622                 .min_uV         = 3000000,
623                 .max_uV         = 3000000,
624                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
625                 .apply_uV       = 1,
626                 .state_mem      = {
627                         .disabled       = 1,
628                 },
629         },
630         .num_consumer_supplies  = ARRAY_SIZE(max8997_ldo14_),
631         .consumer_supplies      = max8997_ldo14_,
632 };
633
634 static struct regulator_init_data __initdata max8997_ldo15_data = {
635         .constraints    = {
636                 .name           = "VTOUCH_ADVV2.8V",
637                 .min_uV         = 2800000,
638                 .max_uV         = 2800000,
639                 .apply_uV       = 1,
640                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
641                 .state_mem      = {
642                         .disabled       = 1,
643                 },
644         },
645         .num_consumer_supplies  = ARRAY_SIZE(max8997_ldo15_),
646         .consumer_supplies      = max8997_ldo15_,
647 };
648
649 static struct regulator_init_data __initdata max8997_ldo16_data = {
650         .constraints    = {
651                 .name           = "CAM_SENSOR_IO_1.8V",
652                 .min_uV         = 1800000,
653                 .max_uV         = 1800000,
654                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
655                 .apply_uV       = 1,
656                 .state_mem      = {
657                         .disabled       = 1,
658                 },
659         },
660         .num_consumer_supplies  = ARRAY_SIZE(max8997_ldo16_),
661         .consumer_supplies      = max8997_ldo16_,
662 };
663
664 static struct regulator_init_data __initdata max8997_ldo18_data = {
665         .constraints    = {
666                 .name           = "VTOUCH_VDD2.8V",
667                 .min_uV         = 2800000,
668                 .max_uV         = 2800000,
669                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
670                 .apply_uV       = 1,
671                 .state_mem      = {
672                         .disabled       = 1,
673                 },
674         },
675         .num_consumer_supplies  = ARRAY_SIZE(max8997_ldo18_),
676         .consumer_supplies      = max8997_ldo18_,
677 };
678
679 static struct regulator_init_data __initdata max8997_ldo21_data = {
680         .constraints    = {
681                 .name           = "VDDQ_M1M2_1.2V",
682                 .min_uV         = 1200000,
683                 .max_uV         = 1200000,
684                 .apply_uV       = 1,
685                 .always_on      = 1,
686                 .state_mem      = {
687                         .disabled       = 1,
688                 },
689         },
690 };
691
692 static struct regulator_init_data __initdata max8997_buck1_data = {
693         .constraints    = {
694                 .name           = "VARM_1.2V_C210",
695                 .min_uV         = 900000,
696                 .max_uV         = 1350000,
697                 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
698                 .always_on      = 1,
699                 .state_mem      = {
700                         .disabled       = 1,
701                 },
702         },
703         .num_consumer_supplies = ARRAY_SIZE(max8997_buck1_),
704         .consumer_supplies = max8997_buck1_,
705 };
706
707 static struct regulator_init_data __initdata max8997_buck2_data = {
708         .constraints    = {
709                 .name           = "VINT_1.1V_C210",
710                 .min_uV         = 900000,
711                 .max_uV         = 1100000,
712                 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
713                 .always_on      = 1,
714                 .state_mem      = {
715                         .disabled       = 1,
716                 },
717         },
718         .num_consumer_supplies = ARRAY_SIZE(max8997_buck2_),
719         .consumer_supplies = max8997_buck2_,
720 };
721
722 static struct regulator_init_data __initdata max8997_buck3_data = {
723         .constraints    = {
724                 .name           = "VG3D_1.1V_C210",
725                 .min_uV         = 900000,
726                 .max_uV         = 1100000,
727                 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
728                                   REGULATOR_CHANGE_STATUS,
729                 .state_mem      = {
730                         .disabled       = 1,
731                 },
732         },
733         .num_consumer_supplies = ARRAY_SIZE(max8997_buck3_),
734         .consumer_supplies = max8997_buck3_,
735 };
736
737 static struct regulator_init_data __initdata max8997_buck4_data = {
738         .constraints    = {
739                 .name           = "CAM_ISP_CORE_1.2V",
740                 .min_uV         = 1200000,
741                 .max_uV         = 1200000,
742                 .apply_uV       = 1,
743                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
744                 .state_mem      = {
745                         .disabled       = 1,
746                 },
747         },
748         .num_consumer_supplies = ARRAY_SIZE(max8997_buck4_),
749         .consumer_supplies = max8997_buck4_,
750 };
751
752 static struct regulator_init_data __initdata max8997_buck5_data = {
753         .constraints    = {
754                 .name           = "VMEM_1.2V_C210",
755                 .min_uV         = 1200000,
756                 .max_uV         = 1200000,
757                 .apply_uV       = 1,
758                 .always_on      = 1,
759                 .state_mem      = {
760                         .enabled        = 1,
761                 },
762         },
763 };
764
765 static struct regulator_init_data __initdata max8997_buck6_data = {
766         .constraints    = {
767                 .name           = "CAM_AF_2.8V",
768                 .min_uV         = 2800000,
769                 .max_uV         = 2800000,
770                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
771                 .state_mem      = {
772                         .disabled       = 1,
773                 },
774         },
775         .num_consumer_supplies = ARRAY_SIZE(max8997_buck6_),
776         .consumer_supplies = max8997_buck6_,
777 };
778
779 static struct regulator_init_data __initdata max8997_buck7_data = {
780         .constraints    = {
781                 .name           = "VCC_SUB_2.0V",
782                 .min_uV         = 2000000,
783                 .max_uV         = 2000000,
784                 .apply_uV       = 1,
785                 .always_on      = 1,
786                 .state_mem      = {
787                         .enabled        = 1,
788                 },
789         },
790 };
791
792 static struct regulator_init_data __initdata max8997_32khz_ap_data = {
793         .constraints    = {
794                 .name           = "32KHz AP",
795                 .always_on      = 1,
796                 .state_mem      = {
797                         .enabled        = 1,
798                 },
799         },
800         .num_consumer_supplies = ARRAY_SIZE(max8997_32khz_ap_),
801         .consumer_supplies = max8997_32khz_ap_,
802 };
803
804 static struct regulator_init_data __initdata max8997_32khz_cp_data = {
805         .constraints    = {
806                 .name           = "32KHz CP",
807                 .state_mem      = {
808                         .disabled       = 1,
809                 },
810         },
811 };
812
813 static struct regulator_init_data __initdata max8997_vichg_data = {
814         .constraints    = {
815                 .name           = "VICHG",
816                 .state_mem      = {
817                         .disabled       = 1,
818                 },
819         },
820 };
821
822 static struct regulator_init_data __initdata max8997_esafeout1_data = {
823         .constraints    = {
824                 .name           = "SAFEOUT1",
825                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
826                 .state_mem      = {
827                         .disabled       = 1,
828                 },
829         },
830         .num_consumer_supplies  = ARRAY_SIZE(max8997_esafeout1_),
831         .consumer_supplies      = max8997_esafeout1_,
832 };
833
834 static struct regulator_init_data __initdata max8997_esafeout2_data = {
835         .constraints    = {
836                 .name           = "SAFEOUT2",
837                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
838                 .state_mem      = {
839                         .disabled       = 1,
840                 },
841         },
842         .num_consumer_supplies  = ARRAY_SIZE(max8997_esafeout2_),
843         .consumer_supplies      = max8997_esafeout2_,
844 };
845
846 static struct regulator_init_data __initdata max8997_charger_cv_data = {
847         .constraints    = {
848                 .name           = "CHARGER_CV",
849                 .min_uV         = 4200000,
850                 .max_uV         = 4200000,
851                 .apply_uV       = 1,
852         },
853 };
854
855 static struct regulator_init_data __initdata max8997_charger_data = {
856         .constraints    = {
857                 .name           = "CHARGER",
858                 .min_uA         = 200000,
859                 .max_uA         = 950000,
860                 .boot_on        = 1,
861                 .valid_ops_mask = REGULATOR_CHANGE_STATUS |
862                                 REGULATOR_CHANGE_CURRENT,
863         },
864         .num_consumer_supplies  = ARRAY_SIZE(max8997_charger_),
865         .consumer_supplies      = max8997_charger_,
866 };
867
868 static struct regulator_init_data __initdata max8997_charger_topoff_data = {
869         .constraints    = {
870                 .name           = "CHARGER TOPOFF",
871                 .min_uA         = 50000,
872                 .max_uA         = 200000,
873                 .valid_ops_mask = REGULATOR_CHANGE_CURRENT,
874         },
875         .num_consumer_supplies  = ARRAY_SIZE(max8997_chg_toff_),
876         .consumer_supplies      = max8997_chg_toff_,
877 };
878
879 static struct max8997_regulator_data __initdata nuri_max8997_regulators[] = {
880         { MAX8997_LDO1, &max8997_ldo1_data },
881         { MAX8997_LDO2, &max8997_ldo2_data },
882         { MAX8997_LDO3, &max8997_ldo3_data },
883         { MAX8997_LDO4, &max8997_ldo4_data },
884         { MAX8997_LDO5, &max8997_ldo5_data },
885         { MAX8997_LDO6, &max8997_ldo6_data },
886         { MAX8997_LDO7, &max8997_ldo7_data },
887         { MAX8997_LDO8, &max8997_ldo8_data },
888         { MAX8997_LDO9, &max8997_ldo9_data },
889         { MAX8997_LDO10, &max8997_ldo10_data },
890         { MAX8997_LDO11, &max8997_ldo11_data },
891         { MAX8997_LDO12, &max8997_ldo12_data },
892         { MAX8997_LDO13, &max8997_ldo13_data },
893         { MAX8997_LDO14, &max8997_ldo14_data },
894         { MAX8997_LDO15, &max8997_ldo15_data },
895         { MAX8997_LDO16, &max8997_ldo16_data },
896
897         { MAX8997_LDO18, &max8997_ldo18_data },
898         { MAX8997_LDO21, &max8997_ldo21_data },
899
900         { MAX8997_BUCK1, &max8997_buck1_data },
901         { MAX8997_BUCK2, &max8997_buck2_data },
902         { MAX8997_BUCK3, &max8997_buck3_data },
903         { MAX8997_BUCK4, &max8997_buck4_data },
904         { MAX8997_BUCK5, &max8997_buck5_data },
905         { MAX8997_BUCK6, &max8997_buck6_data },
906         { MAX8997_BUCK7, &max8997_buck7_data },
907
908         { MAX8997_EN32KHZ_AP, &max8997_32khz_ap_data },
909         { MAX8997_EN32KHZ_CP, &max8997_32khz_cp_data },
910
911         { MAX8997_ENVICHG, &max8997_vichg_data },
912         { MAX8997_ESAFEOUT1, &max8997_esafeout1_data },
913         { MAX8997_ESAFEOUT2, &max8997_esafeout2_data },
914         { MAX8997_CHARGER_CV, &max8997_charger_cv_data },
915         { MAX8997_CHARGER, &max8997_charger_data },
916         { MAX8997_CHARGER_TOPOFF, &max8997_charger_topoff_data },
917 };
918
919 static struct max8997_platform_data __initdata nuri_max8997_pdata = {
920         .wakeup                 = 1,
921
922         .num_regulators         = ARRAY_SIZE(nuri_max8997_regulators),
923         .regulators             = nuri_max8997_regulators,
924
925         .buck125_gpios = { EXYNOS4_GPX0(5), EXYNOS4_GPX0(6), EXYNOS4_GPL0(0) },
926         .buck2_gpiodvs = true,
927
928         .buck1_voltage[0] = 1350000, /* 1.35V */
929         .buck1_voltage[1] = 1300000, /* 1.3V */
930         .buck1_voltage[2] = 1250000, /* 1.25V */
931         .buck1_voltage[3] = 1200000, /* 1.2V */
932         .buck1_voltage[4] = 1150000, /* 1.15V */
933         .buck1_voltage[5] = 1100000, /* 1.1V */
934         .buck1_voltage[6] = 1000000, /* 1.0V */
935         .buck1_voltage[7] = 950000, /* 0.95V */
936
937         .buck2_voltage[0] = 1100000, /* 1.1V */
938         .buck2_voltage[1] = 1000000, /* 1.0V */
939         .buck2_voltage[2] = 950000, /* 0.95V */
940         .buck2_voltage[3] = 900000, /* 0.9V */
941         .buck2_voltage[4] = 1100000, /* 1.1V */
942         .buck2_voltage[5] = 1000000, /* 1.0V */
943         .buck2_voltage[6] = 950000, /* 0.95V */
944         .buck2_voltage[7] = 900000, /* 0.9V */
945
946         .buck5_voltage[0] = 1200000, /* 1.2V */
947         .buck5_voltage[1] = 1200000, /* 1.2V */
948         .buck5_voltage[2] = 1200000, /* 1.2V */
949         .buck5_voltage[3] = 1200000, /* 1.2V */
950         .buck5_voltage[4] = 1200000, /* 1.2V */
951         .buck5_voltage[5] = 1200000, /* 1.2V */
952         .buck5_voltage[6] = 1200000, /* 1.2V */
953         .buck5_voltage[7] = 1200000, /* 1.2V */
954 };
955
956 /* GPIO I2C 5 (PMIC) */
957 enum { I2C5_MAX8997 };
958 static struct i2c_board_info i2c5_devs[] __initdata = {
959         [I2C5_MAX8997] = {
960                 I2C_BOARD_INFO("max8997", 0xCC >> 1),
961                 .platform_data  = &nuri_max8997_pdata,
962         },
963 };
964
965 static struct max17042_platform_data nuri_battery_platform_data = {
966 };
967
968 /* GPIO I2C 9 (Fuel Gauge) */
969 static struct i2c_gpio_platform_data i2c9_gpio_data = {
970         .sda_pin                = EXYNOS4_GPY4(0),      /* XM0ADDR_8 */
971         .scl_pin                = EXYNOS4_GPY4(1),      /* XM0ADDR_9 */
972 };
973 static struct platform_device i2c9_gpio = {
974         .name                   = "i2c-gpio",
975         .id                     = 9,
976         .dev                    = {
977                 .platform_data  = &i2c9_gpio_data,
978         },
979 };
980 enum { I2C9_MAX17042};
981 static struct i2c_board_info i2c9_devs[] __initdata = {
982         [I2C9_MAX17042] = {
983                 I2C_BOARD_INFO("max17042", 0x36),
984                 .platform_data = &nuri_battery_platform_data,
985         },
986 };
987
988 /* MAX8903 Secondary Charger */
989 static struct regulator_consumer_supply supplies_max8903[] = {
990         REGULATOR_SUPPLY("vinchg2", "charger-manager.0"),
991 };
992
993 static struct regulator_init_data max8903_charger_en_data = {
994         .constraints = {
995                 .name           = "VOUT_CHARGER",
996                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
997                 .boot_on        = 1,
998         },
999         .num_consumer_supplies = ARRAY_SIZE(supplies_max8903),
1000         .consumer_supplies = supplies_max8903,
1001 };
1002
1003 static struct fixed_voltage_config max8903_charger_en = {
1004         .supply_name = "VOUT_CHARGER",
1005         .microvolts = 5000000, /* Assume 5VDC */
1006         .gpio = EXYNOS4_GPY4(5), /* TA_EN negaged */
1007         .enable_high = 0, /* Enable = Low */
1008         .enabled_at_boot = 1,
1009         .init_data = &max8903_charger_en_data,
1010 };
1011
1012 static struct platform_device max8903_fixed_reg_dev = {
1013         .name = "reg-fixed-voltage",
1014         .id = FIXED_REG_ID_MAX8903,
1015         .dev = { .platform_data = &max8903_charger_en },
1016 };
1017
1018 static struct max8903_pdata nuri_max8903 = {
1019         /*
1020          * cen: don't control with the driver, let it be
1021          * controlled by regulator above
1022          */
1023         .dok = EXYNOS4_GPX1(4), /* TA_nCONNECTED */
1024         /* uok, usus: not connected */
1025         .chg = EXYNOS4_GPE2(0), /* TA_nCHG */
1026         /* flt: vcc_1.8V_pda */
1027         .dcm = EXYNOS4_GPL0(1), /* CURR_ADJ */
1028
1029         .dc_valid = true,
1030         .usb_valid = false, /* USB is not wired to MAX8903 */
1031 };
1032
1033 static struct platform_device nuri_max8903_device = {
1034         .name                   = "max8903-charger",
1035         .dev                    = {
1036                 .platform_data  = &nuri_max8903,
1037         },
1038 };
1039
1040 static struct device *nuri_cm_devices[] = {
1041         &s3c_device_i2c5.dev,
1042         &s3c_device_adc.dev,
1043         NULL, /* Reserved for UART */
1044         NULL,
1045 };
1046
1047 static void __init nuri_power_init(void)
1048 {
1049         int gpio;
1050         int irq_base = IRQ_GPIO_END + 1;
1051         int ta_en = 0;
1052
1053         nuri_max8997_pdata.irq_base = irq_base;
1054         irq_base += MAX8997_IRQ_NR;
1055
1056         gpio = EXYNOS4_GPX0(7);
1057         gpio_request(gpio, "AP_PMIC_IRQ");
1058         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
1059         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
1060
1061         gpio = EXYNOS4_GPX2(3);
1062         gpio_request(gpio, "FUEL_ALERT");
1063         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
1064         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
1065
1066         gpio = nuri_max8903.dok;
1067         gpio_request(gpio, "TA_nCONNECTED");
1068         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
1069         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
1070         ta_en = gpio_get_value(gpio) ? 0 : 1;
1071
1072         gpio = nuri_max8903.chg;
1073         gpio_request(gpio, "TA_nCHG");
1074         gpio_direction_input(gpio);
1075
1076         gpio = nuri_max8903.dcm;
1077         gpio_request(gpio, "CURR_ADJ");
1078         gpio_direction_output(gpio, ta_en);
1079 }
1080
1081 /* USB EHCI */
1082 static struct s5p_ehci_platdata nuri_ehci_pdata;
1083
1084 static void __init nuri_ehci_init(void)
1085 {
1086         struct s5p_ehci_platdata *pdata = &nuri_ehci_pdata;
1087
1088         s5p_ehci_set_platdata(pdata);
1089 }
1090
1091 static struct platform_device *nuri_devices[] __initdata = {
1092         /* Samsung Platform Devices */
1093         &s3c_device_i2c5, /* PMIC should initialize first */
1094         &emmc_fixed_voltage,
1095         &s3c_device_hsmmc0,
1096         &s3c_device_hsmmc2,
1097         &s3c_device_hsmmc3,
1098         &s3c_device_wdt,
1099         &s3c_device_timer[0],
1100         &s5p_device_ehci,
1101         &s3c_device_i2c3,
1102         &i2c9_gpio,
1103         &s3c_device_adc,
1104         &s3c_device_rtc,
1105         &s5p_device_mfc,
1106         &s5p_device_mfc_l,
1107         &s5p_device_mfc_r,
1108         &exynos4_device_pd[PD_MFC],
1109
1110         /* NURI Devices */
1111         &nuri_gpio_keys,
1112         &nuri_lcd_device,
1113         &nuri_backlight_device,
1114         &max8903_fixed_reg_dev,
1115         &nuri_max8903_device,
1116 };
1117
1118 static void __init nuri_map_io(void)
1119 {
1120         s5p_init_io(NULL, 0, S5P_VA_CHIPID);
1121         s3c24xx_init_clocks(24000000);
1122         s3c24xx_init_uarts(nuri_uartcfgs, ARRAY_SIZE(nuri_uartcfgs));
1123 }
1124
1125 static void __init nuri_reserve(void)
1126 {
1127         s5p_mfc_reserve_mem(0x43000000, 8 << 20, 0x51000000, 8 << 20);
1128 }
1129
1130 static void __init nuri_machine_init(void)
1131 {
1132         nuri_sdhci_init();
1133         nuri_tsp_init();
1134         nuri_power_init();
1135
1136         i2c_register_board_info(1, i2c1_devs, ARRAY_SIZE(i2c1_devs));
1137         s3c_i2c3_set_platdata(&i2c3_data);
1138         i2c_register_board_info(3, i2c3_devs, ARRAY_SIZE(i2c3_devs));
1139         s3c_i2c5_set_platdata(NULL);
1140         i2c5_devs[I2C5_MAX8997].irq = gpio_to_irq(EXYNOS4_GPX0(7));
1141         i2c_register_board_info(5, i2c5_devs, ARRAY_SIZE(i2c5_devs));
1142         i2c9_devs[I2C9_MAX17042].irq = gpio_to_irq(EXYNOS4_GPX2(3));
1143         i2c_register_board_info(9, i2c9_devs, ARRAY_SIZE(i2c9_devs));
1144
1145         nuri_ehci_init();
1146         clk_xusbxti.rate = 24000000;
1147
1148         /* Last */
1149         platform_add_devices(nuri_devices, ARRAY_SIZE(nuri_devices));
1150         s5p_device_mfc.dev.parent = &exynos4_device_pd[PD_MFC].dev;
1151 }
1152
1153 MACHINE_START(NURI, "NURI")
1154         /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */
1155         .atag_offset    = 0x100,
1156         .init_irq       = exynos4_init_irq,
1157         .map_io         = nuri_map_io,
1158         .init_machine   = nuri_machine_init,
1159         .timer          = &exynos4_timer,
1160         .reserve        = &nuri_reserve,
1161 MACHINE_END