aboutsummaryrefslogtreecommitdiff
path: root/arch/arm/mach-exynos/mach-nuri.c
blob: ab920e34bd0ac79a63420b3a7012007bfdc133d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
/*
 * linux/arch/arm/mach-exynos4/mach-nuri.c
 *
 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#include <linux/platform_device.h>
#include <linux/serial_core.h>
#include <linux/input.h>
#include <linux/i2c.h>
#include <linux/i2c/atmel_mxt_ts.h>
#include <linux/i2c-gpio.h>
#include <linux/gpio_keys.h>
#include <linux/gpio.h>
#include <linux/power/max8903_charger.h>
#include <linux/power/max17042_battery.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/fixed.h>
#include <linux/mfd/max8997.h>
#include <linux/mfd/max8997-private.h>
#include <linux/mmc/host.h>
#include <linux/fb.h>
#include <linux/pwm_backlight.h>
#include <linux/platform_data/i2c-s3c2410.h>
#include <linux/platform_data/mipi-csis.h>
#include <linux/platform_data/s3c-hsotg.h>
#include <linux/platform_data/usb-ehci-s5p.h>
#include <drm/exynos_drm.h>

#include <video/platform_lcd.h>
#include <video/samsung_fimd.h>
#include <media/m5mols.h>
#include <media/s5k6aa.h>
#include <media/s5p_fimc.h>
#include <media/v4l2-mediabus.h>

#include <asm/mach/arch.h>
#include <asm/mach-types.h>

#include <plat/adc.h>
#include <plat/regs-serial.h>
#include <plat/cpu.h>
#include <plat/devs.h>
#include <plat/fb.h>
#include <plat/sdhci.h>
#include <plat/clock.h>
#include <plat/gpio-cfg.h>
#include <plat/mfc.h>
#include <plat/fimc-core.h>
#include <plat/camport.h>

#include <mach/irqs.h>
#include <mach/map.h>

#include "common.h"

/* Following are default values for UCON, ULCON and UFCON UART registers */
#define NURI_UCON_DEFAULT	(S3C2410_UCON_TXILEVEL |	\
				 S3C2410_UCON_RXILEVEL |	\
				 S3C2410_UCON_TXIRQMODE |	\
				 S3C2410_UCON_RXIRQMODE |	\
				 S3C2410_UCON_RXFIFO_TOI |	\
				 S3C2443_UCON_RXERR_IRQEN)

#define NURI_ULCON_DEFAULT	S3C2410_LCON_CS8

#define NURI_UFCON_DEFAULT	(S3C2410_UFCON_FIFOMODE |	\
				 S5PV210_UFCON_TXTRIG256 |	\
				 S5PV210_UFCON_RXTRIG256)

enum fixed_regulator_id {
	FIXED_REG_ID_MMC = 0,
	FIXED_REG_ID_MAX8903,
	FIXED_REG_ID_CAM_A28V,
	FIXED_REG_ID_CAM_12V,
	FIXED_REG_ID_CAM_VT_15V,
};

static struct s3c2410_uartcfg nuri_uartcfgs[] __initdata = {
	{
		.hwport		= 0,
		.ucon		= NURI_UCON_DEFAULT,
		.ulcon		= NURI_ULCON_DEFAULT,
		.ufcon		= NURI_UFCON_DEFAULT,
	},
	{
		.hwport		= 1,
		.ucon		= NURI_UCON_DEFAULT,
		.ulcon		= NURI_ULCON_DEFAULT,
		.ufcon		= NURI_UFCON_DEFAULT,
	},
	{
		.hwport		= 2,
		.ucon		= NURI_UCON_DEFAULT,
		.ulcon		= NURI_ULCON_DEFAULT,
		.ufcon		= NURI_UFCON_DEFAULT,
	},
	{
		.hwport		= 3,
		.ucon		= NURI_UCON_DEFAULT,
		.ulcon		= NURI_ULCON_DEFAULT,
		.ufcon		= NURI_UFCON_DEFAULT,
	},
};

/* eMMC */
static struct s3c_sdhci_platdata nuri_hsmmc0_data __initdata = {
	.max_width		= 8,
	.host_caps		= (MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA |
				MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
				MMC_CAP_ERASE),
	.cd_type		= S3C_SDHCI_CD_PERMANENT,
};

static struct regulator_consumer_supply emmc_supplies[] = {
	REGULATOR_SUPPLY("vmmc", "exynos4-sdhci.0"),
	REGULATOR_SUPPLY("vmmc", "dw_mmc"),
};

static struct regulator_init_data emmc_fixed_voltage_init_data = {
	.constraints		= {
		.name		= "VMEM_VDD_2.8V",
		.valid_ops_mask	= REGULATOR_CHANGE_STATUS,
	},
	.num_consumer_supplies	= ARRAY_SIZE(emmc_supplies),
	.consumer_supplies	= emmc_supplies,
};

static struct fixed_voltage_config emmc_fixed_voltage_config = {
	.supply_name		= "MASSMEMORY_EN (inverted)",
	.microvolts		= 2800000,
	.gpio			= EXYNOS4_GPL1(1),
	.enable_high		= false,
	.init_data		= &emmc_fixed_voltage_init_data,
};

static struct platform_device emmc_fixed_voltage = {
	.name			= "reg-fixed-voltage",
	.id			= FIXED_REG_ID_MMC,
	.dev			= {
		.platform_data	= &emmc_fixed_voltage_config,
	},
};

/* SD */
static struct s3c_sdhci_platdata nuri_hsmmc2_data __initdata = {
	.max_width		= 4,
	.host_caps		= MMC_CAP_4_BIT_DATA |
				MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
	.ext_cd_gpio		= EXYNOS4_GPX3(3),	/* XEINT_27 */
	.ext_cd_gpio_invert	= 1,
	.cd_type		= S3C_SDHCI_CD_GPIO,
};

/* WLAN */
static struct s3c_sdhci_platdata nuri_hsmmc3_data __initdata = {
	.max_width		= 4,
	.host_caps		= MMC_CAP_4_BIT_DATA |
				MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
	.cd_type		= S3C_SDHCI_CD_EXTERNAL,
};

static void __init nuri_sdhci_init(void)
{
	s3c_sdhci0_set_platdata(&nuri_hsmmc0_data);
	s3c_sdhci2_set_platdata(&nuri_hsmmc2_data);
	s3c_sdhci3_set_platdata(&nuri_hsmmc3_data);
}

/* GPIO KEYS */
static struct gpio_keys_button nuri_gpio_keys_tables[] = {
	{
		.code			= KEY_VOLUMEUP,
		.gpio			= EXYNOS4_GPX2(0),	/* XEINT16 */
		.desc			= "gpio-keys: KEY_VOLUMEUP",
		.type			= EV_KEY,
		.active_low		= 1,
		.debounce_interval	= 1,
	}, {
		.code			= KEY_VOLUMEDOWN,
		.gpio			= EXYNOS4_GPX2(1),	/* XEINT17 */
		.desc			= "gpio-keys: KEY_VOLUMEDOWN",
		.type			= EV_KEY,
		.active_low		= 1,
		.debounce_interval	= 1,
	}, {
		.code			= KEY_POWER,
		.gpio			= EXYNOS4_GPX2(7),	/* XEINT23 */
		.desc			= "gpio-keys: KEY_POWER",
		.type			= EV_KEY,
		.active_low		= 1,
		.wakeup			= 1,
		.debounce_interval	= 1,
	},
};

static struct gpio_keys_platform_data nuri_gpio_keys_data = {
	.buttons		= nuri_gpio_keys_tables,
	.nbuttons		= ARRAY_SIZE(nuri_gpio_keys_tables),
};

static struct platform_device nuri_gpio_keys = {
	.name			= "gpio-keys",
	.dev			= {
		.platform_data	= &nuri_gpio_keys_data,
	},
};

#ifdef CONFIG_DRM_EXYNOS
static struct exynos_drm_fimd_pdata drm_fimd_pdata = {
	.panel = {
		.timing	= {
			.xres		= 1024,
			.yres		= 600,
			.hsync_len	= 40,
			.left_margin	= 79,
			.right_margin	= 200,
			.vsync_len	= 10,
			.upper_margin	= 10,
			.lower_margin	= 11,
			.refresh	= 60,
		},
	},
	.vidcon0	= VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB |
			  VIDCON0_CLKSEL_LCD,
	.vidcon1	= VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
	.default_win	= 3,
	.bpp		= 32,
};

#else
/* Frame Buffer */
static struct s3c_fb_pd_win nuri_fb_win0 = {
	.max_bpp	= 24,
	.default_bpp	= 16,
	.xres		= 1024,
	.yres		= 600,
	.virtual_x	= 1024,
	.virtual_y	= 2 * 600,
};

static struct fb_videomode nuri_lcd_timing = {
	.left_margin	= 64,
	.right_margin	= 16,
	.upper_margin	= 64,
	.lower_margin	= 1,
	.hsync_len	= 48,
	.vsync_len	= 3,
	.xres		= 1024,
	.yres		= 600,
	.refresh	= 60,
};

static struct s3c_fb_platdata nuri_fb_pdata __initdata = {
	.win[0]		= &nuri_fb_win0,
	.vtiming	= &nuri_lcd_timing,
	.vidcon0	= VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB |
			  VIDCON0_CLKSEL_LCD,
	.vidcon1	= VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
	.setup_gpio	= exynos4_fimd0_gpio_setup_24bpp,
};
#endif

static void nuri_lcd_power_on(struct plat_lcd_data *pd, unsigned int power)
{
	int gpio = EXYNOS4_GPE1(5);

	gpio_request(gpio, "LVDS_nSHDN");
	gpio_direction_output(gpio, power);
	gpio_free(gpio);
}

static int nuri_bl_init(struct device *dev)
{
	return gpio_request_one(EXYNOS4_GPE2(3), GPIOF_OUT_INIT_LOW,
				"LCD_LD0_EN");
}

static int nuri_bl_notify(struct device *dev, int brightness)
{
	if (brightness < 1)
		brightness = 0;

	gpio_set_value(EXYNOS4_GPE2(3), 1);

	return brightness;
}

static void nuri_bl_exit(struct device *dev)
{
	gpio_free(EXYNOS4_GPE2(3));
}

/* nuri pwm backlight */
static struct platform_pwm_backlight_data nuri_backlight_data = {
	.pwm_id			= 0,
	.pwm_period_ns		= 30000,
	.max_brightness		= 100,
	.dft_brightness		= 50,
	.init			= nuri_bl_init,
	.notify			= nuri_bl_notify,
	.exit			= nuri_bl_exit,
};

static struct platform_device nuri_backlight_device = {
	.name			= "pwm-backlight",
	.id			= -1,
	.dev			= {
		.parent		= &s3c_device_timer[0].dev,
		.platform_data	= &nuri_backlight_data,
	},
};

static struct plat_lcd_data nuri_lcd_platform_data = {
	.set_power		= nuri_lcd_power_on,
};

static struct platform_device nuri_lcd_device = {
	.name			= "platform-lcd",
	.id			= -1,
	.dev			= {
		.platform_data	= &nuri_lcd_platform_data,
	},
};

/* I2C1 */
static struct i2c_board_info i2c1_devs[] __initdata = {
	/* Gyro, To be updated */
};

/* TSP */
static struct mxt_platform_data mxt_platform_data = {
	.x_line			= 18,
	.y_line			= 11,
	.x_size			= 1024,
	.y_size			= 600,
	.blen			= 0x1,
	.threshold		= 0x28,
	.voltage		= 2800000,		/* 2.8V */
	.orient			= MXT_DIAGONAL_COUNTER,
	.irqflags		= IRQF_TRIGGER_FALLING,
};

static struct s3c2410_platform_i2c i2c3_data __initdata = {
	.flags		= 0,
	.bus_num	= 3,
	.slave_addr	= 0x10,
	.frequency	= 400 * 1000,
	.sda_delay	= 100,
};

static struct i2c_board_info i2c3_devs[] __initdata = {
	{
		I2C_BOARD_INFO("atmel_mxt_ts", 0x4a),
		.platform_data	= &mxt_platform_data,
		.irq		= IRQ_EINT(4),
	},
};

static void __init nuri_tsp_init(void)
{
	int gpio;

	/* TOUCH_INT: XEINT_4 */
	gpio = EXYNOS4_GPX0(4);
	gpio_request(gpio, "TOUCH_INT");
	s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
	s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
}

static struct regulator_consumer_supply __initdata max8997_ldo1_[] = {
	REGULATOR_SUPPLY("vdd", "s5p-adc"), /* Used by CPU's ADC drv */
};
static struct regulator_consumer_supply __initdata max8997_ldo3_[] = {
	REGULATOR_SUPPLY("vusb_d", "s3c-hsotg"), /* USB */
	REGULATOR_SUPPLY("vddcore", "s5p-mipi-csis.0"), /* MIPI */
};
static struct regulator_consumer_supply __initdata max8997_ldo4_[] = {
	REGULATOR_SUPPLY("vddio", "s5p-mipi-csis.0"), /* MIPI */
};
static struct regulator_consumer_supply __initdata max8997_ldo5_[] = {
	REGULATOR_SUPPLY("vhsic", "modemctl"), /* MODEM */
};
static struct regulator_consumer_supply nuri_max8997_ldo6_consumer[] = {
	REGULATOR_SUPPLY("vdd_reg", "6-003c"), /* S5K6AA camera */
};
static struct regulator_consumer_supply __initdata max8997_ldo7_[] = {
	REGULATOR_SUPPLY("dig_18", "0-001f"), /* HCD803 */
};
static struct regulator_consumer_supply __initdata max8997_ldo8_[] = {
	REGULATOR_SUPPLY("vusb_a", "s3c-hsotg"), /* USB */
	REGULATOR_SUPPLY("vdac", NULL), /* Used by CPU */
};
static struct regulator_consumer_supply __initdata max8997_ldo11_[] = {
	REGULATOR_SUPPLY("vcc", "platform-lcd"), /* U804 LVDS */
};
static struct regulator_consumer_supply __initdata max8997_ldo12_[] = {
	REGULATOR_SUPPLY("vddio", "6-003c"), /* HDC802 */
};
static struct regulator_consumer_supply __initdata max8997_ldo13_[] = {
	REGULATOR_SUPPLY("vmmc", "exynos4-sdhci.2"), /* TFLASH */
};
static struct regulator_consumer_supply __initdata max8997_ldo14_[] = {
	REGULATOR_SUPPLY("inmotor", "max8997-haptic"),
};
static struct regulator_consumer_supply __initdata max8997_ldo15_[] = {
	REGULATOR_SUPPLY("avdd", "3-004a"), /* Touch Screen */
};
static struct regulator_consumer_supply __initdata max8997_ldo16_[] = {
	REGULATOR_SUPPLY("d_sensor", "0-001f"), /* HDC803 */
};
static struct regulator_consumer_supply __initdata max8997_ldo18_[] = {
	REGULATOR_SUPPLY("vdd", "3-004a"), /* Touch Screen */
};
static struct regulator_consumer_supply __initdata max8997_buck1_[] = {
	REGULATOR_SUPPLY("vdd_arm", NULL), /* CPUFREQ */
};
static struct regulator_consumer_supply __initdata max8997_buck2_[] = {
	REGULATOR_SUPPLY("vdd_int", "exynos4210-busfreq.0"), /* CPUFREQ */
};
static struct regulator_consumer_supply __initdata max8997_buck3_[] = {
	REGULATOR_SUPPLY("vdd", "mali_dev.0"), /* G3D of Exynos 4 */
};
static struct regulator_consumer_supply __initdata max8997_buck4_[] = {
	REGULATOR_SUPPLY("core", "0-001f"), /* HDC803 */
};
static struct regulator_consumer_supply __initdata max8997_buck6_[] = {
	REGULATOR_SUPPLY("dig_28", "0-001f"), /* pin "7" of HDC803 */
};
static struct regulator_consumer_supply __initdata max8997_esafeout1_[] = {
	REGULATOR_SUPPLY("usb_vbus", NULL), /* CPU's USB OTG */
};
static struct regulator_consumer_supply __initdata max8997_esafeout2_[] = {
	REGULATOR_SUPPLY("usb_vbus", "modemctl"), /* VBUS of Modem */
};

static struct regulator_consumer_supply __initdata max8997_charger_[] = {
	REGULATOR_SUPPLY("vinchg1", "charger-manager.0"),
};
static struct regulator_consumer_supply __initdata max8997_chg_toff_[] = {
	REGULATOR_SUPPLY("vinchg_stop", NULL), /* for jack interrupt handlers */
};

static struct regulator_consumer_supply __initdata max8997_32khz_ap_[] = {
	REGULATOR_SUPPLY("gps_clk", "bcm4751"),
	REGULATOR_SUPPLY("bt_clk", "bcm4330-b1"),
	REGULATOR_SUPPLY("wifi_clk", "bcm433-b1"),
};

static struct regulator_init_data __initdata max8997_ldo1_data = {
	.constraints	= {
		.name		= "VADC_3.3V_C210",
		.min_uV		= 3300000,
		.max_uV		= 3300000,
		.valid_ops_mask	= REGULATOR_CHANGE_STATUS,
		.apply_uV	= 1,
		.state_mem	= {
			.disabled	= 1,
		},
	},
	.num_consumer_supplies	= ARRAY_SIZE(max8997_ldo1_),
	.consumer_supplies	= max8997_ldo1_,
};

static struct regulator_init_data __initdata max8997_ldo2_data = {
	.constraints	= {
		.name		= "VALIVE_1.1V_C210",
		.min_uV		= 1100000,
		.max_uV		= 1100000,
		.apply_uV	= 1,
		.always_on	= 1,
		.state_mem	= {
			.enabled	= 1,
		},
	},
};

static struct regulator_init_data __initdata max8997_ldo3_data = {
	.constraints	= {
		.name		= "VUSB_1.1V_C210",
		.min_uV		= 1100000,
		.max_uV		= 1100000,
		.valid_ops_mask	= REGULATOR_CHANGE_STATUS,
		.apply_uV	= 1,
		.state_mem	= {
			.disabled	= 1,
		},
	},
	.num_consumer_supplies	= ARRAY_SIZE(max8997_ldo3_),
	.consumer_supplies	= max8997_ldo3_,
};

static struct regulator_init_data __initdata max8997_ldo4_data = {
	.constraints	= {
		.name		= "VMIPI_1.8V",
		.min_uV		= 1800000,
		.max_uV		= 1800000,
		.valid_ops_mask	= REGULATOR_CHANGE_STATUS,
		.apply_uV	= 1,
		.state_mem	= {
			.disabled	= 1,
		},
	},
	.num_consumer_supplies	= ARRAY_SIZE(max8997_ldo4_),
	.consumer_supplies	= max8997_ldo4_,
};

static struct regulator_init_data __initdata max8997_ldo5_data = {
	.constraints	= {
		.name		= "VHSIC_1.2V_C210",
		.min_uV		= 1200000,
		.max_uV		= 1200000,
		.valid_ops_mask	= REGULATOR_CHANGE_STATUS,
		.apply_uV	= 1,
		.state_mem	= {
			.disabled	= 1,
		},
	},
	.num_consumer_supplies	= ARRAY_SIZE(max8997_ldo5_),
	.consumer_supplies	= max8997_ldo5_,
};

static struct regulator_init_data __initdata max8997_ldo6_data = {
	.constraints	= {
		.name		= "VCC_1.8V_PDA",
		.min_uV		= 1800000,
		.max_uV		= 1800000,
		.apply_uV	= 1,
		.always_on	= 1,
		.state_mem	= {
			.enabled	= 1,
		},
	},
	.num_consumer_supplies	= ARRAY_SIZE(nuri_max8997_ldo6_consumer),
	.consumer_supplies	= nuri_max8997_ldo6_consumer,
};

static struct regulator_init_data __initdata max8997_ldo7_data = {
	.constraints	= {
		.name		= "CAM_ISP_1.8V",
		.min_uV		= 1800000,
		.max_uV		= 1800000,
		.valid_ops_mask	= REGULATOR_CHANGE_STATUS,
		.apply_uV	= 1,
		.state_mem	= {
			.disabled	= 1,
		},
	},
	.num_consumer_supplies	= ARRAY_SIZE(max8997_ldo7_),
	.consumer_supplies	= max8997_ldo7_,
};

static struct regulator_init_data __initdata max8997_ldo8_data = {
	.constraints	= {
		.name		= "VUSB+VDAC_3.3V_C210",
		.min_uV		= 3300000,
		.max_uV		= 3300000,
		.valid_ops_mask	= REGULATOR_CHANGE_STATUS,
		.apply_uV	= 1,
		.state_mem	= {
			.disabled	= 1,
		},
	},
	.num_consumer_supplies	= ARRAY_SIZE(max8997_ldo8_),
	.consumer_supplies	= max8997_ldo8_,
};

static struct regulator_init_data __initdata max8997_ldo9_data = {
	.constraints	= {
		.name		= "VCC_2.8V_PDA",
		.min_uV		= 2800000,
		.max_uV		= 2800000,
		.apply_uV	= 1,
		.always_on	= 1,
		.state_mem	= {
			.enabled	= 1,
		},
	},
};

static struct regulator_init_data __initdata max8997_ldo10_data = {
	.constraints	= {
		.name		= "VPLL_1.1V_C210",
		.min_uV		= 1100000,
		.max_uV		= 1100000,
		.apply_uV	= 1,
		.always_on	= 1,
		.state_mem	= {
			.disabled	= 1,
		},
	},
};

static struct regulator_init_data __initdata max8997_ldo11_data = {
	.constraints	= {
		.name		= "LVDS_VDD3.3V",
		.min_uV		= 3300000,
		.max_uV		= 3300000,
		.valid_ops_mask	= REGULATOR_CHANGE_STATUS,
		.apply_uV	= 1,
		.boot_on	= 1,
		.state_mem	= {
			.disabled	= 1,
		},
	},
	.num_consumer_supplies	= ARRAY_SIZE(max8997_ldo11_),
	.consumer_supplies	= max8997_ldo11_,
};

static struct regulator_init_data __initdata max8997_ldo12_data = {
	.constraints	= {
		.name		= "VT_CAM_1.8V",
		.min_uV		= 1800000,
		.max_uV		= 1800000,
		.valid_ops_mask	= REGULATOR_CHANGE_STATUS,
		.apply_uV	= 1,
		.state_mem	= {
			.disabled	= 1,
		},
	},
	.num_consumer_supplies	= ARRAY_SIZE(max8997_ldo12_),
	.consumer_supplies	= max8997_ldo12_,
};

static struct regulator_init_data __initdata max8997_ldo13_data = {
	.constraints	= {
		.name		= "VTF_2.8V",
		.min_uV		= 2800000,
		.max_uV		= 2800000,
		.valid_ops_mask	= REGULATOR_CHANGE_STATUS,
		.apply_uV	= 1,
		.state_mem	= {
			.disabled	= 1,
		},
	},
	.num_consumer_supplies	= ARRAY_SIZE(max8997_ldo13_),
	.consumer_supplies	= max8997_ldo13_,
};

static struct regulator_init_data __initdata max8997_ldo14_data = {
	.constraints	= {
		.name		= "VCC_3.0V_MOTOR",
		.min_uV		= 3000000,
		.max_uV		= 3000000,
		.valid_ops_mask	= REGULATOR_CHANGE_STATUS,
		.apply_uV	= 1,
		.state_mem	= {
			.disabled	= 1,
		},
	},
	.num_consumer_supplies	= ARRAY_SIZE(max8997_ldo14_),
	.consumer_supplies	= max8997_ldo14_,
};

static struct regulator_init_data __initdata max8997_ldo15_data = {
	.constraints	= {
		.name		= "VTOUCH_ADVV2.8V",
		.min_uV		= 2800000,
		.max_uV		= 2800000,
		.apply_uV	= 1,
		.valid_ops_mask	= REGULATOR_CHANGE_STATUS,
		.state_mem	= {
			.disabled	= 1,
		},
	},
	.num_consumer_supplies	= ARRAY_SIZE(max8997_ldo15_),
	.consumer_supplies	= max8997_ldo15_,
};

static struct regulator_init_data __initdata max8997_ldo16_data = {
	.constraints	= {
		.name		= "CAM_SENSOR_IO_1.8V",
		.min_uV		= 1800000,
		.max_uV		= 1800000,
		.valid_ops_mask	= REGULATOR_CHANGE_STATUS,
		.apply_uV	= 1,
		.state_mem	= {
			.disabled	= 1,
		},
	},
	.num_consumer_supplies	= ARRAY_SIZE(max8997_ldo16_),
	.consumer_supplies	= max8997_ldo16_,
};

static struct regulator_init_data __initdata max8997_ldo18_data = {
	.constraints	= {
		.name		= "VTOUCH_VDD2.8V",
		.min_uV		= 2800000,
		.max_uV		= 2800000,
		.valid_ops_mask	= REGULATOR_CHANGE_STATUS,
		.apply_uV	= 1,
		.state_mem	= {
			.disabled	= 1,
		},
	},
	.num_consumer_supplies	= ARRAY_SIZE(max8997_ldo18_),
	.consumer_supplies	= max8997_ldo18_,
};

static struct regulator_init_data __initdata max8997_ldo21_data = {
	.constraints	= {
		.name		= "VDDQ_M1M2_1.2V",
		.min_uV		= 1200000,
		.max_uV		= 1200000,
		.apply_uV	= 1,
		.always_on	= 1,
		.state_mem	= {
			.disabled	= 1,
		},
	},
};

static struct regulator_init_data __initdata max8997_buck1_data = {
	.constraints	= {
		.name		= "VARM_1.2V_C210",
		.min_uV		= 900000,
		.max_uV		= 1350000,
		.valid_ops_mask	= REGULATOR_CHANGE_VOLTAGE,
		.always_on	= 1,
		.state_mem	= {
			.disabled	= 1,
		},
	},
	.num_consumer_supplies = ARRAY_SIZE(max8997_buck1_),
	.consumer_supplies = max8997_buck1_,
};

static struct regulator_init_data __initdata max8997_buck2_data = {
	.constraints	= {
		.name		= "VINT_1.1V_C210",
		.min_uV		= 900000,
		.max_uV		= 1200000,
		.valid_ops_mask	= REGULATOR_CHANGE_VOLTAGE,
		.always_on	= 1,
		.state_mem	= {
			.disabled	= 1,
		},
	},
	.num_consumer_supplies = ARRAY_SIZE(max8997_buck2_),
	.consumer_supplies = max8997_buck2_,
};

static struct regulator_init_data __initdata max8997_buck3_data = {
	.constraints	= {
		.name		= "VG3D_1.1V_C210",
		.min_uV		= 900000,
		.max_uV		= 1100000,
		.valid_ops_mask	= REGULATOR_CHANGE_VOLTAGE |
				  REGULATOR_CHANGE_STATUS,
		.state_mem	= {
			.disabled	= 1,
		},
	},
	.num_consumer_supplies = ARRAY_SIZE(max8997_buck3_),
	.consumer_supplies = max8997_buck3_,
};

static struct regulator_init_data __initdata max8997_buck4_data = {
	.constraints	= {
		.name		= "CAM_ISP_CORE_1.2V",
		.min_uV		= 1200000,
		.max_uV		= 1200000,
		.apply_uV	= 1,
		.valid_ops_mask	= REGULATOR_CHANGE_STATUS,
		.state_mem	= {
			.disabled	= 1,
		},
	},
	.num_consumer_supplies = ARRAY_SIZE(max8997_buck4_),
	.consumer_supplies = max8997_buck4_,
};

static struct regulator_init_data __initdata max8997_buck5_data = {
	.constraints	= {
		.name		= "VMEM_1.2V_C210",
		.min_uV		= 1200000,
		.max_uV		= 1200000,
		.apply_uV	= 1,
		.always_on	= 1,
		.state_mem	= {
			.enabled	= 1,
		},
	},
};

static struct regulator_init_data __initdata max8997_buck6_data = {
	.constraints	= {
		.name		= "CAM_AF_2.8V",
		.min_uV		= 2800000,
		.max_uV		= 2800000,
		.valid_ops_mask	= REGULATOR_CHANGE_STATUS,
		.state_mem	= {
			.disabled	= 1,
		},
	},
	.num_consumer_supplies = ARRAY_SIZE(max8997_buck6_),
	.consumer_supplies = max8997_buck6_,
};

static struct regulator_init_data __initdata max8997_buck7_data = {
	.constraints	= {
		.name		= "VCC_SUB_2.0V",
		.min_uV		= 2000000,
		.max_uV		= 2000000,
		.apply_uV	= 1,
		.always_on	= 1,
		.state_mem	= {
			.enabled	= 1,
		},
	},
};

static struct regulator_init_data __initdata max8997_32khz_ap_data = {
	.constraints	= {
		.name		= "32KHz AP",
		.always_on	= 1,
		.state_mem	= {
			.enabled	= 1,
		},
	},
	.num_consumer_supplies = ARRAY_SIZE(max8997_32khz_ap_),
	.consumer_supplies = max8997_32khz_ap_,
};

static struct regulator_init_data __initdata max8997_32khz_cp_data = {
	.constraints	= {
		.name		= "32KHz CP",
		.state_mem	= {
			.disabled	= 1,
		},
	},
};

static struct regulator_init_data __initdata max8997_vichg_data = {
	.constraints	= {
		.name		= "VICHG",
		.state_mem	= {
			.disabled	= 1,
		},
	},
};

static struct regulator_init_data __initdata max8997_esafeout1_data = {
	.constraints	= {
		.name		= "SAFEOUT1",
		.valid_ops_mask	= REGULATOR_CHANGE_STATUS,
		.always_on	= 1,
		.state_mem	= {
			.disabled	= 1,
		},
	},
	.num_consumer_supplies	= ARRAY_SIZE(max8997_esafeout1_),
	.consumer_supplies	= max8997_esafeout1_,
};

static struct regulator_init_data __initdata max8997_esafeout2_data = {
	.constraints	= {
		.name		= "SAFEOUT2",
		.valid_ops_mask	= REGULATOR_CHANGE_STATUS,
		.state_mem	= {
			.disabled	= 1,
		},
	},
	.num_consumer_supplies	= ARRAY_SIZE(max8997_esafeout2_),
	.consumer_supplies	= max8997_esafeout2_,
};

static struct regulator_init_data __initdata max8997_charger_cv_data = {
	.constraints	= {
		.name		= "CHARGER_CV",
		.min_uV		= 4200000,
		.max_uV		= 4200000,
		.apply_uV	= 1,
	},
};

static struct regulator_init_data __initdata max8997_charger_data = {
	.constraints	= {
		.name		= "CHARGER",
		.min_uA		= 200000,
		.max_uA		= 950000,
		.boot_on	= 1,
		.valid_ops_mask = REGULATOR_CHANGE_STATUS |
				REGULATOR_CHANGE_CURRENT,
	},
	.num_consumer_supplies	= ARRAY_SIZE(max8997_charger_),
	.consumer_supplies	= max8997_charger_,
};

static struct regulator_init_data __initdata max8997_charger_topoff_data = {
	.constraints	= {
		.name		= "CHARGER TOPOFF",
		.min_uA		= 50000,
		.max_uA		= 200000,
		.valid_ops_mask = REGULATOR_CHANGE_CURRENT,
	},
	.num_consumer_supplies	= ARRAY_SIZE(max8997_chg_toff_),
	.consumer_supplies	= max8997_chg_toff_,
};

static struct max8997_regulator_data __initdata nuri_max8997_regulators[] = {
	{ MAX8997_LDO1, &max8997_ldo1_data },
	{ MAX8997_LDO2, &max8997_ldo2_data },
	{ MAX8997_LDO3, &max8997_ldo3_data },
	{ MAX8997_LDO4, &max8997_ldo4_data },
	{ MAX8997_LDO5, &max8997_ldo5_data },
	{ MAX8997_LDO6, &max8997_ldo6_data },
	{ MAX8997_LDO7, &max8997_ldo7_data },
	{ MAX8997_LDO8, &max8997_ldo8_data },
	{ MAX8997_LDO9, &max8997_ldo9_data },
	{ MAX8997_LDO10, &max8997_ldo10_data },
	{ MAX8997_LDO11, &max8997_ldo11_data },
	{ MAX8997_LDO12, &max8997_ldo12_data },
	{ MAX8997_LDO13, &max8997_ldo13_data },
	{ MAX8997_LDO14, &max8997_ldo14_data },
	{ MAX8997_LDO15, &max8997_ldo15_data },
	{ MAX8997_LDO16, &max8997_ldo16_data },

	{ MAX8997_LDO18, &max8997_ldo18_data },
	{ MAX8997_LDO21, &max8997_ldo21_data },

	{ MAX8997_BUCK1, &max8997_buck1_data },
	{ MAX8997_BUCK2, &max8997_buck2_data },
	{ MAX8997_BUCK3, &max8997_buck3_data },
	{ MAX8997_BUCK4, &max8997_buck4_data },
	{ MAX8997_BUCK5, &max8997_buck5_data },
	{ MAX8997_BUCK6, &max8997_buck6_data },
	{ MAX8997_BUCK7, &max8997_buck7_data },

	{ MAX8997_EN32KHZ_AP, &max8997_32khz_ap_data },
	{ MAX8997_EN32KHZ_CP, &max8997_32khz_cp_data },

	{ MAX8997_ENVICHG, &max8997_vichg_data },
	{ MAX8997_ESAFEOUT1, &max8997_esafeout1_data },
	{ MAX8997_ESAFEOUT2, &max8997_esafeout2_data },
	{ MAX8997_CHARGER_CV, &max8997_charger_cv_data },
	{ MAX8997_CHARGER, &max8997_charger_data },
	{ MAX8997_CHARGER_TOPOFF, &max8997_charger_topoff_data },
};

static struct max8997_platform_data __initdata nuri_max8997_pdata = {
	.wakeup			= 1,

	.num_regulators		= ARRAY_SIZE(nuri_max8997_regulators),
	.regulators		= nuri_max8997_regulators,

	.buck125_gpios = { EXYNOS4_GPX0(5), EXYNOS4_GPX0(6), EXYNOS4_GPL0(0) },

	.buck1_voltage[0] = 1350000, /* 1.35V */
	.buck1_voltage[1] = 1300000, /* 1.3V */
	.buck1_voltage[2] = 1250000, /* 1.25V */
	.buck1_voltage[3] = 1200000, /* 1.2V */
	.buck1_voltage[4] = 1150000, /* 1.15V */
	.buck1_voltage[5] = 1100000, /* 1.1V */
	.buck1_voltage[6] = 1000000, /* 1.0V */
	.buck1_voltage[7] = 950000, /* 0.95V */

	.buck2_voltage[0] = 1100000, /* 1.1V */
	.buck2_voltage[1] = 1000000, /* 1.0V */
	.buck2_voltage[2] = 950000, /* 0.95V */
	.buck2_voltage[3] = 900000, /* 0.9V */
	.buck2_voltage[4] = 1100000, /* 1.1V */
	.buck2_voltage[5] = 1000000, /* 1.0V */
	.buck2_voltage[6] = 950000, /* 0.95V */
	.buck2_voltage[7] = 900000, /* 0.9V */

	.buck5_voltage[0] = 1200000, /* 1.2V */
	.buck5_voltage[1] = 1200000, /* 1.2V */
	.buck5_voltage[2] = 1200000, /* 1.2V */
	.buck5_voltage[3] = 1200000, /* 1.2V */
	.buck5_voltage[4] = 1200000, /* 1.2V */
	.buck5_voltage[5] = 1200000, /* 1.2V */
	.buck5_voltage[6] = 1200000, /* 1.2V */
	.buck5_voltage[7] = 1200000, /* 1.2V */
};

/* GPIO I2C 5 (PMIC) */
enum { I2C5_MAX8997 };
static struct i2c_board_info i2c5_devs[] __initdata = {
	[I2C5_MAX8997] = {
		I2C_BOARD_INFO("max8997", 0xCC >> 1),
		.platform_data	= &nuri_max8997_pdata,
	},
};

static struct max17042_platform_data nuri_battery_platform_data = {
};

/* GPIO I2C 9 (Fuel Gauge) */
static struct i2c_gpio_platform_data i2c9_gpio_data = {
	.sda_pin		= EXYNOS4_GPY4(0),      /* XM0ADDR_8 */
	.scl_pin		= EXYNOS4_GPY4(1),      /* XM0ADDR_9 */
};
static struct platform_device i2c9_gpio = {
	.name			= "i2c-gpio",
	.id			= 9,
	.dev			= {
		.platform_data	= &i2c9_gpio_data,
	},
};
enum { I2C9_MAX17042};
static struct i2c_board_info i2c9_devs[] __initdata = {
	[I2C9_MAX17042] = {
		I2C_BOARD_INFO("max17042", 0x36),
		.platform_data = &nuri_battery_platform_data,
	},
};

/* MAX8903 Secondary Charger */
static struct regulator_consumer_supply supplies_max8903[] = {
	REGULATOR_SUPPLY("vinchg2", "charger-manager.0"),
};

static struct regulator_init_data max8903_charger_en_data = {
	.constraints = {
		.name		= "VOUT_CHARGER",
		.valid_ops_mask = REGULATOR_CHANGE_STATUS,
		.boot_on	= 1,
	},
	.num_consumer_supplies = ARRAY_SIZE(supplies_max8903),
	.consumer_supplies = supplies_max8903,
};

static struct fixed_voltage_config max8903_charger_en = {
	.supply_name = "VOUT_CHARGER",
	.microvolts = 5000000, /* Assume 5VDC */
	.gpio = EXYNOS4_GPY4(5), /* TA_EN negaged */
	.enable_high = 0, /* Enable = Low */
	.enabled_at_boot = 1,
	.init_data = &max8903_charger_en_data,
};

static struct platform_device max8903_fixed_reg_dev = {
	.name = "reg-fixed-voltage",
	.id = FIXED_REG_ID_MAX8903,
	.dev = { .platform_data	= &max8903_charger_en },
};

static struct max8903_pdata nuri_max8903 = {
	/*
	 * cen: don't control with the driver, let it be
	 * controlled by regulator above
	 */
	.dok = EXYNOS4_GPX1(4), /* TA_nCONNECTED */
	/* uok, usus: not connected */
	.chg = EXYNOS4_GPE2(0), /* TA_nCHG */
	/* flt: vcc_1.8V_pda */
	.dcm = EXYNOS4_GPL0(1), /* CURR_ADJ */

	.dc_valid = true,
	.usb_valid = false, /* USB is not wired to MAX8903 */
};

static struct platform_device nuri_max8903_device = {
	.name			= "max8903-charger",
	.dev			= {
		.platform_data	= &nuri_max8903,
	},
};

static void __init nuri_power_init(void)
{
	int gpio;
	int ta_en = 0;

	gpio = EXYNOS4_GPX0(7);
	gpio_request(gpio, "AP_PMIC_IRQ");
	s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
	s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);

	gpio = EXYNOS4_GPX2(3);
	gpio_request(gpio, "FUEL_ALERT");
	s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
	s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);

	gpio = nuri_max8903.dok;
	gpio_request(gpio, "TA_nCONNECTED");
	s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
	s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
	ta_en = gpio_get_value(gpio) ? 0 : 1;

	gpio = nuri_max8903.chg;
	gpio_request(gpio, "TA_nCHG");
	gpio_direction_input(gpio);

	gpio = nuri_max8903.dcm;
	gpio_request(gpio, "CURR_ADJ");
	gpio_direction_output(gpio, ta_en);
}

/* USB EHCI */
static struct s5p_ehci_platdata nuri_ehci_pdata;

static void __init nuri_ehci_init(void)
{
	struct s5p_ehci_platdata *pdata = &nuri_ehci_pdata;

	s5p_ehci_set_platdata(pdata);
}

/* USB OTG */
static struct s3c_hsotg_plat nuri_hsotg_pdata;

/* CAMERA */
static struct regulator_consumer_supply cam_vt_cam15_supply =
	REGULATOR_SUPPLY("vdd_core", "6-003c");

static struct regulator_init_data cam_vt_cam15_reg_init_data = {
	.constraints = { .valid_ops_mask = REGULATOR_CHANGE_STATUS },
	.num_consumer_supplies = 1,
	.consumer_supplies = &cam_vt_cam15_supply,
};

static struct fixed_voltage_config cam_vt_cam15_fixed_voltage_cfg = {
	.supply_name	= "VT_CAM_1.5V",
	.microvolts	= 1500000,
	.gpio		= EXYNOS4_GPE2(2), /* VT_CAM_1.5V_EN */
	.enable_high	= 1,
	.init_data	= &cam_vt_cam15_reg_init_data,
};

static struct platform_device cam_vt_cam15_fixed_rdev = {
	.name = "reg-fixed-voltage", .id = FIXED_REG_ID_CAM_VT_15V,
	.dev = { .platform_data	= &cam_vt_cam15_fixed_voltage_cfg },
};

static struct regulator_consumer_supply cam_vdda_supply[] = {
	REGULATOR_SUPPLY("vdda", "6-003c"),
	REGULATOR_SUPPLY("a_sensor", "0-001f"),
};

static struct regulator_init_data cam_vdda_reg_init_data = {
	.constraints = { .valid_ops_mask = REGULATOR_CHANGE_STATUS },
	.num_consumer_supplies = ARRAY_SIZE(cam_vdda_supply),
	.consumer_supplies = cam_vdda_supply,
};

static struct fixed_voltage_config cam_vdda_fixed_voltage_cfg = {
	.supply_name	= "CAM_IO_EN",
	.microvolts	= 2800000,
	.gpio		= EXYNOS4_GPE2(1), /* CAM_IO_EN */
	.enable_high	= 1,
	.init_data	= &cam_vdda_reg_init_data,
};

static struct platform_device cam_vdda_fixed_rdev = {
	.name = "reg-fixed-voltage", .id = FIXED_REG_ID_CAM_A28V,
	.dev = { .platform_data	= &cam_vdda_fixed_voltage_cfg },
};

static struct regulator_consumer_supply camera_8m_12v_supply =
	REGULATOR_SUPPLY("dig_12", "0-001f");

static struct regulator_init_data cam_8m_12v_reg_init_data = {
	.num_consumer_supplies	= 1,
	.consumer_supplies	= &camera_8m_12v_supply,
	.constraints = {
		.valid_ops_mask = REGULATOR_CHANGE_STATUS
	},
};

static struct fixed_voltage_config cam_8m_12v_fixed_voltage_cfg = {
	.supply_name	= "8M_1.2V",
	.microvolts	= 1200000,
	.gpio		= EXYNOS4_GPE2(5), /* 8M_1.2V_EN */
	.enable_high	= 1,
	.init_data	= &cam_8m_12v_reg_init_data,
};

static struct platform_device cam_8m_12v_fixed_rdev = {
	.name = "reg-fixed-voltage", .id = FIXED_REG_ID_CAM_12V,
	.dev = { .platform_data = &cam_8m_12v_fixed_voltage_cfg },
};

static struct s5p_platform_mipi_csis mipi_csis_platdata = {
	.clk_rate	= 166000000UL,
	.lanes		= 2,
	.hs_settle	= 12,
};

#define GPIO_CAM_MEGA_RST	EXYNOS4_GPY3(7) /* ISP_RESET */
#define GPIO_CAM_8M_ISP_INT	EXYNOS4_GPL2(5)
#define GPIO_CAM_VT_NSTBY	EXYNOS4_GPL2(0)
#define GPIO_CAM_VT_NRST	EXYNOS4_GPL2(1)

static struct s5k6aa_platform_data s5k6aa_pldata = {
	.mclk_frequency	= 24000000UL,
	.gpio_reset	= { GPIO_CAM_VT_NRST, 0 },
	.gpio_stby	= { GPIO_CAM_VT_NSTBY, 0 },
	.bus_type	= V4L2_MBUS_PARALLEL,
	.horiz_flip	= 1,
};

static struct i2c_board_info s5k6aa_board_info = {
	I2C_BOARD_INFO("S5K6AA", 0x3c),
	.platform_data = &s5k6aa_pldata,
};

static struct m5mols_platform_data m5mols_platdata = {
	.gpio_reset = GPIO_CAM_MEGA_RST,
};

static struct i2c_board_info m5mols_board_info = {
	I2C_BOARD_INFO("M5MOLS", 0x1F),
	.platform_data	= &m5mols_platdata,
};

static struct fimc_source_info nuri_camera_sensors[] = {
	{
		.flags		= V4L2_MBUS_PCLK_SAMPLE_RISING |
				  V4L2_MBUS_VSYNC_ACTIVE_LOW,
		.fimc_bus_type	= FIMC_BUS_TYPE_ITU_601,
		.board_info	= &s5k6aa_board_info,
		.clk_frequency	= 24000000UL,
		.i2c_bus_num	= 6,
	}, {
		.flags		= V4L2_MBUS_PCLK_SAMPLE_FALLING |
				  V4L2_MBUS_VSYNC_ACTIVE_LOW,
		.fimc_bus_type	= FIMC_BUS_TYPE_MIPI_CSI2,
		.board_info	= &m5mols_board_info,
		.clk_frequency	= 24000000UL,
	},
};

static struct s5p_platform_fimc fimc_md_platdata = {
	.source_info	= nuri_camera_sensors,
	.num_clients	= ARRAY_SIZE(nuri_camera_sensors),
};

static struct gpio nuri_camera_gpios[] = {
	{ GPIO_CAM_VT_NSTBY,	GPIOF_OUT_INIT_LOW, "CAM_VGA_NSTBY" },
	{ GPIO_CAM_VT_NRST,	GPIOF_OUT_INIT_LOW, "CAM_VGA_NRST"  },
	{ GPIO_CAM_8M_ISP_INT,	GPIOF_IN,           "8M_ISP_INT"  },
	{ GPIO_CAM_MEGA_RST,	GPIOF_OUT_INIT_LOW, "CAM_8M_NRST" },
};

static void __init nuri_camera_init(void)
{
	s3c_set_platdata(&mipi_csis_platdata, sizeof(mipi_csis_platdata),
			 &s5p_device_mipi_csis0);
	s3c_set_platdata(&fimc_md_platdata,  sizeof(fimc_md_platdata),
			 &s5p_device_fimc_md);

	if (gpio_request_array(nuri_camera_gpios,
			       ARRAY_SIZE(nuri_camera_gpios))) {
		pr_err("%s: GPIO request failed\n", __func__);
		return;
	}

	m5mols_board_info.irq = s5p_register_gpio_interrupt(GPIO_CAM_8M_ISP_INT);
	if (!IS_ERR_VALUE(m5mols_board_info.irq))
		s3c_gpio_cfgpin(GPIO_CAM_8M_ISP_INT, S3C_GPIO_SFN(0xF));
	else
		pr_err("%s: Failed to configure 8M_ISP_INT GPIO\n", __func__);

	/* Free GPIOs controlled directly by the sensor drivers. */
	gpio_free(GPIO_CAM_VT_NRST);
	gpio_free(GPIO_CAM_VT_NSTBY);
	gpio_free(GPIO_CAM_MEGA_RST);

	if (exynos4_fimc_setup_gpio(S5P_CAMPORT_A)) {
		pr_err("%s: Camera port A setup failed\n", __func__);
		return;
	}
	/* Increase drive strength of the sensor clock output */
	s5p_gpio_set_drvstr(EXYNOS4_GPJ1(3), S5P_GPIO_DRVSTR_LV4);
}

static struct s3c2410_platform_i2c nuri_i2c6_platdata __initdata = {
	.frequency	= 400000U,
	.sda_delay	= 200,
	.bus_num	= 6,
};

static struct s3c2410_platform_i2c nuri_i2c0_platdata __initdata = {
	.frequency	= 400000U,
	.sda_delay	= 200,
};

/* DEVFREQ controlling memory/bus */
static struct platform_device exynos4_bus_devfreq = {
	.name			= "exynos4210-busfreq",
};

static struct platform_device *nuri_devices[] __initdata = {
	/* Samsung Platform Devices */
	&s3c_device_i2c5, /* PMIC should initialize first */
	&s3c_device_i2c0,
	&s3c_device_i2c6,
	&emmc_fixed_voltage,
	&s5p_device_mipi_csis0,
	&s5p_device_fimc0,
	&s5p_device_fimc1,
	&s5p_device_fimc2,
	&s5p_device_fimc3,
	&s5p_device_fimd0,
	&s3c_device_hsmmc0,
	&s3c_device_hsmmc2,
	&s3c_device_hsmmc3,
	&s3c_device_wdt,
	&s3c_device_timer[0],
	&s5p_device_ehci,
	&s3c_device_i2c3,
	&i2c9_gpio,
	&s3c_device_adc,
	&s5p_device_g2d,
	&s5p_device_jpeg,
	&s3c_device_rtc,
	&s5p_device_mfc,
	&s5p_device_mfc_l,
	&s5p_device_mfc_r,
	&s5p_device_fimc_md,
	&s3c_device_usb_hsotg,

	/* NURI Devices */
	&nuri_gpio_keys,
	&nuri_lcd_device,
	&nuri_backlight_device,
	&max8903_fixed_reg_dev,
	&nuri_max8903_device,
	&cam_vt_cam15_fixed_rdev,
	&cam_vdda_fixed_rdev,
	&cam_8m_12v_fixed_rdev,
	&exynos4_bus_devfreq,
};

static void __init nuri_map_io(void)
{
	exynos_init_io(NULL, 0);
	s3c24xx_init_clocks(clk_xusbxti.rate);
	s3c24xx_init_uarts(nuri_uartcfgs, ARRAY_SIZE(nuri_uartcfgs));
}

static void __init nuri_reserve(void)
{
	s5p_mfc_reserve_mem(0x43000000, 8 << 20, 0x51000000, 8 << 20);
}

static void __init nuri_machine_init(void)
{
	nuri_sdhci_init();
	nuri_tsp_init();
	nuri_power_init();

	s3c_i2c0_set_platdata(&nuri_i2c0_platdata);
	i2c_register_board_info(1, i2c1_devs, ARRAY_SIZE(i2c1_devs));
	s3c_i2c3_set_platdata(&i2c3_data);
	i2c_register_board_info(3, i2c3_devs, ARRAY_SIZE(i2c3_devs));
	s3c_i2c5_set_platdata(NULL);
	i2c5_devs[I2C5_MAX8997].irq = gpio_to_irq(EXYNOS4_GPX0(7));
	i2c_register_board_info(5, i2c5_devs, ARRAY_SIZE(i2c5_devs));
	i2c9_devs[I2C9_MAX17042].irq = gpio_to_irq(EXYNOS4_GPX2(3));
	i2c_register_board_info(9, i2c9_devs, ARRAY_SIZE(i2c9_devs));
	s3c_i2c6_set_platdata(&nuri_i2c6_platdata);

#ifdef CONFIG_DRM_EXYNOS
	s5p_device_fimd0.dev.platform_data = &drm_fimd_pdata;
	exynos4_fimd0_gpio_setup_24bpp();
#else
	s5p_fimd0_set_platdata(&nuri_fb_pdata);
#endif

	nuri_camera_init();

	nuri_ehci_init();
	s3c_hsotg_set_platdata(&nuri_hsotg_pdata);

	/* Last */
	platform_add_devices(nuri_devices, ARRAY_SIZE(nuri_devices));
}

MACHINE_START(NURI, "NURI")
	/* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */
	.atag_offset	= 0x100,
	.smp		= smp_ops(exynos_smp_ops),
	.init_irq	= exynos4_init_irq,
	.map_io		= nuri_map_io,
	.init_machine	= nuri_machine_init,
	.init_late	= exynos_init_late,
	.init_time	= exynos4_timer_init,
	.reserve        = &nuri_reserve,
	.restart	= exynos4_restart,
MACHINE_END