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