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