summaryrefstree
path: root/kernel/drivers/media/platform/exynos/camera/is-dt.c
blob: 83a9dd8470c089994912036ba7d16a99116220e6 (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
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
/*
 * Samsung Exynos5 SoC series FIMC-IS driver
 *
 * exynos5 fimc-is core functions
 *
 * 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/sched.h>
#ifdef CONFIG_OF
#include <linux/of.h>
#include <linux/of_gpio.h>
#endif

#include <exynos-is-module.h>
#include <exynos-is-sensor.h>
#include <exynos-is.h>
#include "is-config.h"
#include "is-dt.h"
#include "is-core.h"
#include "is-dvfs.h"
#include "is-interface-sensor.h"

#ifdef CONFIG_OF
static int get_pin_lookup_state(struct pinctrl *pinctrl,
	struct exynos_sensor_pin (*pin_ctrls)[GPIO_SCENARIO_MAX][GPIO_CTRL_MAX])
{
	int ret = 0;
	u32 i, j, k;
	char pin_name[30];
	struct pinctrl_state *s;

	for (i = 0; i < SENSOR_SCENARIO_MAX; ++i) {
		for (j = 0; j < GPIO_SCENARIO_MAX; ++j) {
			for (k = 0; k < GPIO_CTRL_MAX; ++k) {
				if (pin_ctrls[i][j][k].act == PIN_FUNCTION) {
					snprintf(pin_name, sizeof(pin_name), "%s%d",
						pin_ctrls[i][j][k].name,
						pin_ctrls[i][j][k].value);
					s = pinctrl_lookup_state(pinctrl, pin_name);
					if (IS_ERR_OR_NULL(s)) {
						err("pinctrl_lookup_state(%s) is failed", pin_name);
						ret = -EINVAL;
						goto p_err;
					}

					pin_ctrls[i][j][k].pin = (ulong)s;
				}
			}
		}
	}

p_err:
	return ret;
}

static int parse_gate_info(struct exynos_platform_is *pdata, struct device_node *np)
{
	int ret = 0;
	struct device_node *group_np = NULL;
	struct device_node *gate_info_np;
	struct property *prop;
	struct property *prop2;
	const __be32 *p;
	const char *s;
	u32 i = 0, u = 0;
	struct exynos_is_clk_gate_info *gate_info;

	/* get subip of is info */
	gate_info = kzalloc(sizeof(struct exynos_is_clk_gate_info), GFP_KERNEL);
	if (!gate_info) {
		printk(KERN_ERR "%s: no memory for is gate_info\n", __func__);
		return -EINVAL;
	}

	s = NULL;
	/* get gate register info */
	prop2 = of_find_property(np, "clk_gate_strs", NULL);
	of_property_for_each_u32(np, "clk_gate_enums", prop, p, u) {
		printk(KERN_INFO "int value: %d\n", u);
		s = of_prop_next_string(prop2, s);
		if (s != NULL) {
			printk(KERN_INFO "String value: %d-%s\n", u, s);
			gate_info->gate_str[u] = s;
		}
	}

	/* gate info */
	gate_info_np = of_get_child_by_name(np, "clk_gate_ctrl");
	if (!gate_info_np) {
		ret = -ENOENT;
		goto p_err;
	}
	i = 0;
	while ((group_np = of_get_next_child(gate_info_np, group_np))) {
		struct exynos_is_clk_gate_group *group =
				&gate_info->groups[i];
		of_property_for_each_u32(group_np, "mask_clk_on_org", prop, p, u) {
			printk(KERN_INFO "(%d) int1 value: %d\n", i, u);
			group->mask_clk_on_org |= (1 << u);
		}
		of_property_for_each_u32(group_np, "mask_clk_off_self_org", prop, p, u) {
			printk(KERN_INFO "(%d) int2 value: %d\n", i, u);
			group->mask_clk_off_self_org |= (1 << u);
		}
		of_property_for_each_u32(group_np, "mask_clk_off_depend", prop, p, u) {
			printk(KERN_INFO "(%d) int3 value: %d\n", i, u);
			group->mask_clk_off_depend |= (1 << u);
		}
		of_property_for_each_u32(group_np, "mask_cond_for_depend", prop, p, u) {
			printk(KERN_INFO "(%d) int4 value: %d\n", i, u);
			group->mask_cond_for_depend |= (1 << u);
		}
		i++;
		printk(KERN_INFO "(%d) [0x%x , 0x%x, 0x%x, 0x%x\n", i,
			group->mask_clk_on_org,
			group->mask_clk_off_self_org,
			group->mask_clk_off_depend,
			group->mask_cond_for_depend
		);
	}

	pdata->gate_info = gate_info;
	pdata->gate_info->clk_on_off = exynos_is_clk_gate;

	return 0;
p_err:
	kfree(gate_info);
	return ret;
}

#if defined(CONFIG_PM_DEVFREQ)
DECLARE_EXTERN_DVFS_DT(IS_SN_END);
static int parse_dvfs_data(struct exynos_platform_is *pdata, struct device_node *np, int index)
{
	int i;
	u32 temp;
	char *pprop;

	pprop = __getname();
	if (unlikely(!pprop))
		return -ENOMEM;

	for (i = 0; i < IS_SN_END; i++) {
#if defined(QOS_TNR)
		snprintf(pprop, PATH_MAX, "%s%s", is_dvfs_dt_arr[i].parse_scenario_nm, "tnr");
		DT_READ_U32(np, pprop, pdata->dvfs_data[index][is_dvfs_dt_arr[i].scenario_id][IS_DVFS_TNR]);
#endif
#if defined(QOS_INTCAM)
		snprintf(pprop, PATH_MAX, "%s%s", is_dvfs_dt_arr[i].parse_scenario_nm, "int_cam");
		DT_READ_U32(np, pprop, pdata->dvfs_data[index][is_dvfs_dt_arr[i].scenario_id][IS_DVFS_INT_CAM]);
#endif
		snprintf(pprop, PATH_MAX, "%s%s", is_dvfs_dt_arr[i].parse_scenario_nm, "int");
		DT_READ_U32(np, pprop, pdata->dvfs_data[index][is_dvfs_dt_arr[i].scenario_id][IS_DVFS_INT]);

		snprintf(pprop, PATH_MAX, "%s%s", is_dvfs_dt_arr[i].parse_scenario_nm, "cam");
		DT_READ_U32(np, pprop, pdata->dvfs_data[index][is_dvfs_dt_arr[i].scenario_id][IS_DVFS_CAM]);

		snprintf(pprop, PATH_MAX, "%s%s", is_dvfs_dt_arr[i].parse_scenario_nm, "mif");
		DT_READ_U32(np, pprop, pdata->dvfs_data[index][is_dvfs_dt_arr[i].scenario_id][IS_DVFS_MIF]);

		snprintf(pprop, PATH_MAX, "%s%s", is_dvfs_dt_arr[i].parse_scenario_nm, "i2c");
		DT_READ_U32(np, pprop, pdata->dvfs_data[index][is_dvfs_dt_arr[i].scenario_id][IS_DVFS_I2C]);

		snprintf(pprop, PATH_MAX, "%s%s", is_dvfs_dt_arr[i].parse_scenario_nm, "hpg");
		DT_READ_U32(np, pprop, pdata->dvfs_data[index][is_dvfs_dt_arr[i].scenario_id][IS_DVFS_HPG]);
	}
	__putname(pprop);

#ifdef DBG_DUMP_DVFS_DT
	for (i = 0; i < IS_SN_END; i++) {
		probe_info("---- %s ----\n", is_dvfs_dt_arr[i].parse_scenario_nm);
#if defined(QOS_TNR)
		probe_info("[%d][%d][TNR] = %d\n", index, i, pdata->dvfs_data[index][i][IS_DVFS_TNR]);
#endif
#if defined(QOS_INTCAM)
		probe_info("[%d][%d][INT_CAM] = %d\n", index, i, pdata->dvfs_data[index][i][IS_DVFS_INT_CAM]);
#endif
		probe_info("[%d][%d][INT] = %d\n", index, i, pdata->dvfs_data[index][i][IS_DVFS_INT]);
		probe_info("[%d][%d][CAM] = %d\n", index, i, pdata->dvfs_data[index][i][IS_DVFS_CAM]);
		probe_info("[%d][%d][MIF] = %d\n", index, i, pdata->dvfs_data[index][i][IS_DVFS_MIF]);
		probe_info("[%d][%d][I2C] = %d\n", index, i, pdata->dvfs_data[index][i][IS_DVFS_I2C]);
		probe_info("[%d][%d][HPG] = %d\n", index, i, pdata->dvfs_data[index][i][IS_DVFS_HPG]);
	}
#endif
	return 0;
}
#else
static int parse_dvfs_data(struct exynos_platform_is *pdata, struct device_node *np, int index)
{
	return 0;
}
#endif

static int parse_dvfs_table(struct is_dvfs_ctrl *dvfs,
	struct exynos_platform_is *pdata, struct device_node *np)
{
	int ret = 0;
	u32 table_cnt;
	struct device_node *table_np;
	const char *dvfs_table_desc;

	table_np = NULL;

	table_cnt = 0;
	while ((table_np = of_get_next_child(np, table_np)) &&
		(table_cnt < IS_DVFS_TABLE_IDX_MAX)) {
		ret = of_property_read_string(table_np, "desc", &dvfs_table_desc);
		if (ret)
			dvfs_table_desc = "NOT defined";

		probe_info("dvfs table[%d] is %s", table_cnt, dvfs_table_desc);
		parse_dvfs_data(pdata, table_np, table_cnt);
		table_cnt++;
	}

	dvfs->dvfs_table_max = table_cnt;

	return ret;
}

static int bts_parse_data(struct device_node *np, struct is_bts_scen **data)
{
	int i;
	int ret = 0;
	int num_scen;
	struct is_bts_scen *bts_scen;

	if (of_have_populated_dt()) {
		num_scen = (unsigned int)of_property_count_strings(np, "list-scen-bts");
		if (num_scen <= 0) {
			probe_warn("There should be at least one scenario\n");
			goto err_of_property;
		}

		bts_scen = kcalloc(num_scen, sizeof(struct is_bts_scen), GFP_KERNEL);
		if (bts_scen == NULL) {
			ret = -ENOMEM;
			probe_err("no memory for bts_scen");
			goto err_alloc;
		}

		for (i = 0; i < num_scen; i++) {
			bts_scen[i].index = i;
			ret = of_property_read_string_index(np, "list-scen-bts", i, &(bts_scen[i].name));
			if (ret < 0) {
				probe_err("Unable to get name of bts scenarios\n");
				goto err_read_string;
			}
		}

		*data = bts_scen;
	} else {
		probe_warn("Invalid device tree node!\n");
	}

	return 0;

err_read_string:
	kfree(bts_scen);
err_alloc:
err_of_property:

	return ret;
}

static int parse_lic_offset_data(struct is_hardware *is_hw, struct device_node *dnode)
{
	int ret = 0;
	char *str_lic_ip;
	int elems;
	u32 offsets = LIC_CHAIN_OFFSET_NUM / 2 - 1;
	u32 set_idx = offsets + 1;
	int i, index_a, index_b;
	char *str_a, *str_b;

	str_lic_ip = __getname();
	if (unlikely(!str_lic_ip)) {
		err("[@] out of memory for str_lic_ip!");
		ret = -ENOMEM;
		goto err_alloc_str_lic_ip;
	}

	snprintf(str_lic_ip, PATH_MAX, "3AA");
	if (of_property_read_bool(dnode, str_lic_ip)) {
		elems = of_property_count_u32_elems(dnode, str_lic_ip);
		if (elems != LIC_CHAIN_OFFSET_NUM) {
			err("wrong LIC_CHAIN_OFFSET_NUM(%d!=%d)", elems, LIC_CHAIN_OFFSET_NUM);
			ret = -EINVAL;
			goto err_get_elems;
		}

		of_property_read_u32_array(dnode, str_lic_ip,
				&is_hw->lic_offset_def[0], elems);
	} else {
		err("[@] Can't fine %s node", str_lic_ip);
	}

	probe_info("[@] Parse_lic_offset_data\n");

	index_a = COREX_SETA * set_idx; /* setA */
	index_b = COREX_SETB * set_idx; /* setB */

	str_a = __getname();
	if (unlikely(!str_a)) {
		err("[@] out of memory for str_a!");
		ret = -ENOMEM;
		goto err_alloc_str_a;
	}

	str_b = __getname();
	if (unlikely(!str_b)) {
		err("[@] out of memory for str_b!");
		ret = -ENOMEM;
		goto err_alloc_str_b;
	}

	snprintf(str_a, PATH_MAX, "%d", is_hw->lic_offset_def[index_a + 0]);
	snprintf(str_b, PATH_MAX, "%d", is_hw->lic_offset_def[index_b + 0]);
	for (i = 1; i < offsets; i++) {
		snprintf(str_a, PATH_MAX, "%s, %d", str_a, is_hw->lic_offset_def[index_a + i]);
		snprintf(str_b, PATH_MAX, "%s, %d", str_b, is_hw->lic_offset_def[index_b + i]);
	}
	probe_info("[@] 3AA lic_offset_def: setA<%s>(%d), setB<%s>(%d)",
		str_a, is_hw->lic_offset_def[index_a + offsets],
		str_b, is_hw->lic_offset_def[index_b + offsets]);

	__putname(str_b);
err_alloc_str_b:
	__putname(str_a);
err_alloc_str_a:
err_get_elems:
	__putname(str_lic_ip);
err_alloc_str_lic_ip:

	return ret;
}

int is_parse_dt(struct platform_device *pdev)
{
	int ret = 0;
	struct is_core *core;
	struct is_dvfs_ctrl *dvfs;
	struct is_bts_scen **bts_scen;
	struct exynos_platform_is *pdata;
	struct device *dev;
	struct device_node *dvfs_np = NULL;
	struct device_node *vender_np = NULL;
	struct device_node *lic_offset_np = NULL;
	struct device_node *np;
	u32 mem_info[2];

	FIMC_BUG(!pdev);

	dev = &pdev->dev;
	np = dev->of_node;

	core = dev_get_drvdata(&pdev->dev);
	if (!core) {
		probe_err("core is NULL");
		return -ENOMEM;
	}

	pdata = kzalloc(sizeof(struct exynos_platform_is), GFP_KERNEL);
	if (!pdata) {
		probe_err("no memory for platform data");
		return -ENOMEM;
	}

	dvfs = &core->resourcemgr.dvfs_ctrl;
	bts_scen = &core->resourcemgr.bts_scen;
	pdata->clk_get = exynos_is_clk_get;
	pdata->clk_cfg = exynos_is_clk_cfg;
	pdata->clk_on = exynos_is_clk_on;
	pdata->clk_off = exynos_is_clk_off;
	pdata->print_clk = exynos_is_print_clk;

	of_property_read_u32(np, "num_of_3aa", &pdata->num_of_ip.taa);
	of_property_read_u32(np, "num_of_isp", &pdata->num_of_ip.isp);
	of_property_read_u32(np, "num_of_mcsc", &pdata->num_of_ip.mcsc);
	of_property_read_u32(np, "num_of_vra", &pdata->num_of_ip.vra);
	of_property_read_u32(np, "num_of_clh", &pdata->num_of_ip.clh);

	if (parse_gate_info(pdata, np) < 0)
		probe_info("can't parse clock gate info node");

	ret = of_property_read_u32(np, "chain_config", &core->chain_config);
	if (ret)
		probe_warn("chain configuration read is fail(%d)", ret);

	probe_info("FIMC-IS chain configuration: %d\n", core->chain_config);

	ret = of_property_read_u32_array(np, "secure_mem_info", mem_info, 2);
	if (ret) {
		core->secure_mem_info[0] = 0;
		core->secure_mem_info[1] = 0;
	} else {
		core->secure_mem_info[0] = mem_info[0];
		core->secure_mem_info[1] = mem_info[1];
	}
	probe_info("ret(%d) secure_mem_info(%#08lx, %#08lx)", ret,
		core->secure_mem_info[0], core->secure_mem_info[1]);

	ret = of_property_read_u32_array(np, "non_secure_mem_info", mem_info, 2);
	if (ret) {
		core->non_secure_mem_info[0] = 0;
		core->non_secure_mem_info[1] = 0;
	} else {
		core->non_secure_mem_info[0] = mem_info[0];
		core->non_secure_mem_info[1] = mem_info[1];
	}
	probe_info("ret(%d) non_secure_mem_info(%#08lx, %#08lx)", ret,
		core->non_secure_mem_info[0], core->non_secure_mem_info[1]);

	vender_np = of_get_child_by_name(np, "vender");
	if (vender_np) {
		ret = is_vender_dt(vender_np);
		if (ret)
			probe_err("is_vender_dt is fail(%d)", ret);
	}

	pdata->pinctrl = devm_pinctrl_get(dev);
	if (IS_ERR(pdata->pinctrl)) {
		probe_err("devm_pinctrl_get is fail");
		goto p_err;
	}

	dvfs_np = of_get_child_by_name(np, "is_dvfs");
	if (dvfs_np) {
		ret = parse_dvfs_table(dvfs, pdata, dvfs_np);
		if (ret)
			probe_err("parse_dvfs_table is fail(%d)", ret);
	}

	bts_parse_data(np, bts_scen);

	lic_offset_np = of_get_child_by_name(np, "lic_offsets");
	if (lic_offset_np) {
		ret = parse_lic_offset_data(&core->hardware, lic_offset_np);
		if (ret)
			probe_err("parse_lic_offset_data is fail(%d)", ret);
	}

	dev->platform_data = pdata;

	return 0;

p_err:
	kfree(pdata);
	return ret;
}

int is_sensor_parse_dt(struct platform_device *pdev)
{
	int ret;
	struct exynos_platform_is_sensor *pdata;
	struct device_node *dnode;
	struct device *dev;
	int elems;
	int i;

	FIMC_BUG(!pdev);
	FIMC_BUG(!pdev->dev.of_node);

	dev = &pdev->dev;
	dnode = dev->of_node;

	pdata = kzalloc(sizeof(struct exynos_platform_is_sensor), GFP_KERNEL);
	if (!pdata) {
		err("%s: no memory for platform data", __func__);
		return -ENOMEM;
	}

	pdata->iclk_cfg = exynos_is_sensor_iclk_cfg;
	pdata->iclk_on = exynos_is_sensor_iclk_on;
	pdata->iclk_off = exynos_is_sensor_iclk_off;
	pdata->mclk_on = exynos_is_sensor_mclk_on;
	pdata->mclk_off = exynos_is_sensor_mclk_off;
	pdata->mclk_force_off = is_sensor_mclk_force_off;

	ret = of_property_read_u32(dnode, "id", &pdata->id);
	if (ret) {
		err("id read is fail(%d)", ret);
		goto err_read_id;
	}

	ret = of_property_read_u32(dnode, "scenario", &pdata->scenario);
	if (ret) {
		err("scenario read is fail(%d)", ret);
		goto err_read_scenario;
	}

	ret = of_property_read_u32(dnode, "csi_ch", &pdata->csi_ch);
	if (ret) {
		err("csi_ch read is fail(%d)", ret);
		goto err_read_csi_ch;
	}

	ret = of_property_read_u32(dnode, "csi_mux", &pdata->csi_mux);
	if (ret) {
		probe_info("skip phy-csi mux data read (%d)", ret);
	}

	ret = of_property_read_u32(dnode, "multi_ch", &pdata->multi_ch);
	if (ret) {
		probe_info("skip multi_ch bool data read (%d)", ret);
	}

	elems = of_property_count_u32_elems(dnode, "dma_ch");
	if (elems >= CSI_VIRTUAL_CH_MAX) {
		if (elems % CSI_VIRTUAL_CH_MAX) {
			err("the length of DMA ch. is not a multiple of VC Max");
			ret = -EINVAL;
			goto err_read_dma_ch;
		}

		if (elems != of_property_count_u32_elems(dnode, "vc_ch")) {
			err("the length of DMA ch. does not match VC ch.");
			ret = -EINVAL;
			goto err_read_vc_ch;
		}

		pdata->dma_ch = kcalloc(elems, sizeof(*pdata->dma_ch), GFP_KERNEL);
		if (!pdata->dma_ch) {
			err("out of memory for DMA ch.");
			ret = -EINVAL;
			goto err_alloc_dma_ch;
		}

		pdata->vc_ch = kcalloc(elems, sizeof(*pdata->vc_ch), GFP_KERNEL);
		if (!pdata->vc_ch) {
			err("out of memory for VC ch.");
			ret = -EINVAL;
			goto err_alloc_vc_ch;
		}

		for (i = 0; i < elems; i++) {
			pdata->dma_ch[i] = -1;
			pdata->vc_ch[i] = -1;
		}

		if (!of_property_read_u32_array(dnode, "dma_ch", pdata->dma_ch,
					elems)) {
			if (!of_property_read_u32_array(dnode, "vc_ch",
						pdata->vc_ch,
						elems)) {
				pdata->dma_abstract = true;
				pdata->num_of_ch_mode = elems / CSI_VIRTUAL_CH_MAX;
			} else {
				warn("failed to read vc_ch\n");
			}
		} else {
			warn("failed to read dma_ch\n");
		}

	}

	ret = of_property_read_u32(dnode, "use_cphy", &pdata->use_cphy);
	if (ret)
		probe_info("use_cphy read is fail(%d)", ret);

	ret = of_property_read_u32(dnode, "scramble", &pdata->scramble);
	if (ret)
		probe_info("scramble read is fail(%d)", ret);

	if (of_property_read_bool(dnode, "use_ssvc0_internal"))
		set_bit(SUBDEV_SSVC0_INTERNAL_USE, &pdata->internal_state);

	if (of_property_read_bool(dnode, "use_ssvc1_internal"))
		set_bit(SUBDEV_SSVC1_INTERNAL_USE, &pdata->internal_state);

	if (of_property_read_bool(dnode, "use_ssvc2_internal"))
		set_bit(SUBDEV_SSVC2_INTERNAL_USE, &pdata->internal_state);

	if (of_property_read_bool(dnode, "use_ssvc3_internal"))
		set_bit(SUBDEV_SSVC3_INTERNAL_USE, &pdata->internal_state);

	ret = of_property_read_u32(dnode, "use_module_sel", &pdata->use_module_sel);
	if (ret)
		pdata->use_module_sel = MODULE_SEL_NONE;

	info("use_module_sel = %d\n", pdata->use_module_sel);

	ret = of_property_read_u32(dnode, "i2c_dummy_enable", &pdata->i2c_dummy_enable);
	if (ret)
		probe_info("i2c_dummy_enable is false(%d)", ret);

	/* used to Runtime module selection */
	if (pdata->use_module_sel) {
		int i;
		int identifier_cnt =
			of_property_count_elems_of_size(dnode, "module_sel_identifier", sizeof(u32));

		pdata->module_sel_cnt =
			of_property_count_elems_of_size(dnode, "module_sel_sensor_id", sizeof(u32));
		if (pdata->module_sel_cnt != identifier_cnt) {
			err("not matched cnt (module:%d, identifier:%d\n",
					pdata->module_sel_cnt, identifier_cnt - 1);
			goto err_read_is_bns;
		}

		ret = of_property_read_u32(dnode, "module_sel_idx", &pdata->module_sel_idx);
		if (ret)
			err("skip read module_sel_idx, read by EEPROM should be read");

		pdata->module_sel_sensor_id = devm_kzalloc(dev, sizeof(u32) * pdata->module_sel_cnt, GFP_KERNEL);
		if (!pdata->module_sel_sensor_id) {
			err("pdata->module_sel_sensor_id is NULL");
			ret = -ENOMEM;
			goto err_read_is_bns;
		}

		pdata->module_sel_val = devm_kzalloc(dev, sizeof(u32) * pdata->module_sel_cnt, GFP_KERNEL);
		if (!pdata->module_sel_sensor_id) {
			err("pdata->module_sel_val is NULL");
			ret = -ENOMEM;
			goto err_read_is_bns;
		}

		for (i = 0; i < pdata->module_sel_cnt; i++) {
			ret = of_property_read_u32_index(dnode, "module_sel_sensor_id",
								i, &pdata->module_sel_sensor_id[i]);
			if (ret) {
				err("read module_sel_sensor_id failed(%d)", ret);
				goto err_read_is_bns;
			}

			ret = of_property_read_u32_index(dnode, "module_sel_identifier",
								i, &pdata->module_sel_val[i]);
			if (ret) {
				err("read module_sel_val failed(%d)", ret);
				goto err_read_is_bns;
			}

			info("Runtime module sel(%d): sensor_id:%d, identifier:%d\n",
					i, pdata->module_sel_sensor_id[i], pdata->module_sel_val[i]);
		}
	}

	pdev->id = pdata->id;
	dev->platform_data = pdata;

	return 0;

err_alloc_vc_ch:
err_read_is_bns:
	kfree(pdata->dma_ch);

err_alloc_dma_ch:
err_read_vc_ch:
err_read_dma_ch:
err_read_csi_ch:
err_read_scenario:
err_read_id:
	kfree(pdata);

	return ret;
}

static int parse_af_data(struct exynos_platform_is_module *pdata, struct device_node *dnode)
{
	u32 temp;
	char *pprop;

	DT_READ_U32(dnode, "product_name", pdata->af_product_name);
	DT_READ_U32(dnode, "i2c_addr", pdata->af_i2c_addr);
	DT_READ_U32(dnode, "i2c_ch", pdata->af_i2c_ch);

	return 0;
}

static int parse_flash_data(struct exynos_platform_is_module *pdata, struct device_node *dnode)
{
	u32 temp;
	char *pprop;

	DT_READ_U32(dnode, "product_name", pdata->flash_product_name);
	DT_READ_U32(dnode, "flash_first_gpio", pdata->flash_first_gpio);
	DT_READ_U32(dnode, "flash_second_gpio", pdata->flash_second_gpio);

	return 0;
}

static int parse_ois_data(struct exynos_platform_is_module *pdata, struct device_node *dnode)
{
	u32 temp;
	char *pprop;

	DT_READ_U32(dnode, "product_name", pdata->ois_product_name);
	DT_READ_U32(dnode, "i2c_addr", pdata->ois_i2c_addr);
	DT_READ_U32(dnode, "i2c_ch", pdata->ois_i2c_ch);

	return 0;
}

static int parse_mcu_data(struct exynos_platform_is_module *pdata, struct device_node *dnode)
{
	u32 temp;
	char *pprop;

	DT_READ_U32(dnode, "product_name", pdata->mcu_product_name);
	DT_READ_U32(dnode, "i2c_addr", pdata->mcu_i2c_addr);
	DT_READ_U32(dnode, "i2c_ch", pdata->mcu_i2c_ch);

	return 0;
}

static int parse_aperture_data(struct exynos_platform_is_module *pdata, struct device_node *dnode)
{
	u32 temp;
	char *pprop;

	DT_READ_U32(dnode, "product_name", pdata->aperture_product_name);
	DT_READ_U32(dnode, "i2c_addr", pdata->aperture_i2c_addr);
	DT_READ_U32(dnode, "i2c_ch", pdata->aperture_i2c_ch);

	return 0;
}

static int parse_vc_extra_data(struct exynos_platform_is_module *pdata, struct device_node *dnode)
{
	int idx_stat;
	int idx_dt;
	char *str_stat;

	str_stat = __getname();
	if (unlikely(!str_stat)) {
		err("out of memory for str_stat.");
		return -ENOMEM;
	}

	for (idx_stat = 0; idx_stat < VC_BUF_DATA_TYPE_MAX; idx_stat++) {
		idx_dt = 0;
		snprintf(str_stat, PATH_MAX, "%s%d", "stat", idx_stat);
		if (!of_find_property(dnode, str_stat, NULL)) {
			pdata->vc_extra_info[idx_stat].stat_type = VC_STAT_TYPE_INVALID;
			pdata->vc_extra_info[idx_stat].sensor_mode = VC_SENSOR_MODE_INVALID;
			pdata->vc_extra_info[idx_stat].max_width = 0;
			pdata->vc_extra_info[idx_stat].max_height = 0;
			pdata->vc_extra_info[idx_stat].max_element = 0;
			continue;
		}

		of_property_read_u32_index(dnode, str_stat, idx_dt++, &pdata->vc_extra_info[idx_stat].stat_type);
		of_property_read_u32_index(dnode, str_stat, idx_dt++, &pdata->vc_extra_info[idx_stat].sensor_mode);
		of_property_read_u32_index(dnode, str_stat, idx_dt++, &pdata->vc_extra_info[idx_stat].max_width);
		of_property_read_u32_index(dnode, str_stat, idx_dt++, &pdata->vc_extra_info[idx_stat].max_height);
		of_property_read_u32_index(dnode, str_stat, idx_dt++, &pdata->vc_extra_info[idx_stat].max_element);
	}

	__putname(str_stat);

	return 0;
}

static int parse_modes_data(struct exynos_platform_is_module *pdata, struct device_node *dnode)
{
	int ret = 0;
	struct device_node *next, *opt_np;
	int idx_mode;
	int idx_vc;
	int idx_dt;
	char *str_vc;
	struct is_sensor_cfg *cfg;
	u32 format;

	str_vc = __getname();
	if (unlikely(!str_vc)) {
		err("out of memory for str_vc.");
		ret = -ENOMEM;
		goto err_alloc_str_vc;
	}

	pdata->cfgs = of_get_child_count(dnode);
	pdata->cfg = kcalloc(pdata->cfgs, sizeof(struct is_sensor_cfg), GFP_KERNEL);
	if (!pdata->cfg) {
		err("out of memory for sensor modes.");
		ret = -ENOMEM;
		goto err_alloc_sensor_mode;

	}

	idx_mode = 0;
	for_each_child_of_node(dnode, next) {
		idx_dt = 0;
		cfg = &pdata->cfg[idx_mode];
		idx_mode++;

		of_property_read_u32_index(next, "common", idx_dt++, &cfg->width);
		of_property_read_u32_index(next, "common", idx_dt++, &cfg->height);
		of_property_read_u32_index(next, "common", idx_dt++, &cfg->framerate);
		of_property_read_u32_index(next, "common", idx_dt++, &cfg->settle);
		of_property_read_u32_index(next, "common", idx_dt++, &cfg->mode);
		of_property_read_u32_index(next, "common", idx_dt++, &cfg->lanes);
		of_property_read_u32_index(next, "common", idx_dt++, &cfg->mipi_speed);
		of_property_read_u32_index(next, "common", idx_dt++, &cfg->interleave_mode);
		of_property_read_u32_index(next, "common", idx_dt++, &cfg->lrte);
		of_property_read_u32_index(next, "common", idx_dt++, &cfg->pd_mode);
		of_property_read_u32_index(next, "common", idx_dt++, (u32 *)&cfg->ex_mode);

		opt_np = of_get_child_by_name(next, "option");
		if (opt_np && of_find_property(opt_np, "votf", NULL))
			of_property_read_u32(opt_np, "votf", &cfg->votf);
		else
			cfg->votf = 0;

		if (opt_np && of_find_property(opt_np, "scm", NULL))
			of_property_read_u32(opt_np, "scm", &cfg->scm);
		else
			cfg->scm = 0;

		if (opt_np && of_find_property(opt_np, "max_fps", NULL))
			of_property_read_u32(opt_np, "max_fps", &cfg->max_fps);
		else
			cfg->max_fps = cfg->framerate;

		if (opt_np && of_find_property(opt_np, "binning", NULL))
			of_property_read_u32(opt_np, "binning", &cfg->binning);
		else
			cfg->binning = min(BINNING(pdata->active_width, cfg->width),
					BINNING(pdata->active_height, cfg->height));

		for (idx_vc = 0; idx_vc < CSI_VIRTUAL_CH_MAX; idx_vc++) {
			idx_dt = 0;
			snprintf(str_vc, PATH_MAX,  "%s%d", "vc", idx_vc);
			of_property_read_u32_index(next, str_vc, idx_dt++, &cfg->input[idx_vc].map);

			/* input format pasing */
			of_property_read_u32_index(next, str_vc, idx_dt++, &format);
			cfg->input[idx_vc].hwformat = format & HW_FORMAT_MASK;
			cfg->input[idx_vc].extformat = format & HW_EXT_FORMAT_MASK;

			of_property_read_u32_index(next, str_vc, idx_dt++, &cfg->input[idx_vc].width);
			of_property_read_u32_index(next, str_vc, idx_dt++, &cfg->input[idx_vc].height);

			/* output format pasing */
			of_property_read_u32_index(next, str_vc, idx_dt++, &format);
			cfg->output[idx_vc].hwformat = format & HW_FORMAT_MASK;
			cfg->output[idx_vc].extformat = format & HW_EXT_FORMAT_MASK;

			of_property_read_u32_index(next, str_vc, idx_dt++, &cfg->output[idx_vc].type);
			of_property_read_u32_index(next, str_vc, idx_dt++, &cfg->output[idx_vc].width);
			of_property_read_u32_index(next, str_vc, idx_dt++, &cfg->output[idx_vc].height);
		}
	}

err_alloc_sensor_mode:
	__putname(str_vc);
err_alloc_str_vc:
	return ret;
}
static int parse_power_seq_data(struct exynos_platform_is_module *pdata, struct device_node *dnode)
{
	int ret = 0;
	u32 temp;
	char *pprop;
	struct device_node *sn_np, *seq_np;
	struct is_core *core;
	struct device_node **node_table;
	struct device_node *temp_node;
	int num;
	long *node_num;
	long temp_num;
	int i, j;
	int gpio_mclk;

	core = (struct is_core *)dev_get_drvdata(is_dev);
	if (!core) {
		probe_err("core is NULL");
		return -EINVAL;
	}

	gpio_mclk = of_get_named_gpio(dnode, "gpio_mclk", 0);
	if (gpio_is_valid(gpio_mclk)) {
		if (gpio_request_one(gpio_mclk, GPIOF_OUT_INIT_LOW, "CAM_MCLK_OUTPUT_LOW")) {
			probe_err("%s: failed to gpio request mclk\n", dnode->name);
			return -ENODEV;
		}
		gpio_free(gpio_mclk);
	} else {
		probe_err("%s: failed to get mclk\n", dnode->name);
		return -EINVAL;
	}

	for_each_child_of_node(dnode, sn_np) {
		u32 sensor_scenario, gpio_scenario;

		DT_READ_U32(sn_np, "sensor_scenario", sensor_scenario);
		DT_READ_U32(sn_np, "gpio_scenario",gpio_scenario);

		probe_info("power_seq[%s] : sensor_scenario=%d, gpio_scenario=%d\n",
			sn_np->name, sensor_scenario, gpio_scenario);

		SET_PIN_INIT(pdata, sensor_scenario, gpio_scenario);

		num = of_get_child_count(sn_np);
		node_table = kcalloc(num, sizeof(*node_table), GFP_KERNEL);
		if (!node_table) {
			err("out of memory for node_table[%s].", sn_np->name);
			return -ENOMEM;
		}

		node_num = kcalloc(num, sizeof(*node_num), GFP_KERNEL);
		if (!node_num) {
			err("out of memory for node_num[%s].", sn_np->name);
			kfree(node_table);
			return -ENOMEM;
		}

		i = 0;
		for_each_child_of_node(sn_np, seq_np) {
			node_table[i] = seq_np;
			ret = kstrtol(seq_np->name, 10, &node_num[i]);
			if (ret) {
				kfree(node_table);
				kfree(node_num);
				err("fail to kstrtol [%d]%s:%s.", i, sn_np->name, seq_np->name);
				return ret;
			}
			i++;
		}

		/* sorting */
		for (i = 0; i < num; i++) {
			for (j = i + 1; j < num; j++) {
				if (node_num[i] > node_num[j]) {
					temp_node = node_table[i];
					temp_num = node_num[i];

					node_table[i] = node_table[j];
					node_num[i] = node_num[j];

					node_table[j] = temp_node;
					node_num[j] = temp_num;
				}
			}
		}

		for (i = 0; i < num; i++) {
			int gpio;
			int idx_share;
			int idx_seq;
			int idx_prop;
			struct exynos_sensor_pin *pin;
			struct property *prop;
			int length;

			prop = of_find_property(node_table[i], "pname", &length);
			if (!prop || length <= 1)
				continue;

			idx_seq = pdata->pinctrl_index[sensor_scenario][gpio_scenario];
			pin = &pdata->pin_ctrls[sensor_scenario][gpio_scenario][idx_seq];
			pdata->pinctrl_index[sensor_scenario][gpio_scenario]++;

			gpio = of_get_named_gpio(node_table[i], "gpio", 0);
			if (gpio_is_valid(gpio)) {
				pin->pin = gpio;
				gpio_request_one(gpio, GPIOF_OUT_INIT_LOW, "CAM_GPIO_OUTPUT_LOW");
				gpio_free(gpio);
			}

			of_property_read_string(node_table[i], "pname", (const char **)&pin->name);

			idx_prop = 0;
			of_property_read_u32_index(node_table[i], "pin", idx_prop++, &pin->act);
			of_property_read_u32_index(node_table[i], "pin", idx_prop++, &pin->value);
			of_property_read_u32_index(node_table[i], "pin", idx_prop++, &pin->delay);
			of_property_read_u32_index(node_table[i], "pin", idx_prop++, &pin->voltage);

			idx_prop = 0;
			if (of_find_property(node_table[i], "share", NULL)) {
				of_property_read_u32_index(node_table[i], "share", idx_prop++, &pin->shared_rsc_type);
				of_property_read_u32_index(node_table[i], "share", idx_prop++, &idx_share);
				of_property_read_u32_index(node_table[i], "share", idx_prop++, &pin->shared_rsc_active);
				pin->shared_rsc_slock = &core->shared_rsc_slock[idx_share];
				pin->shared_rsc_count = &core->shared_rsc_count[idx_share];
			} else {
				pin->shared_rsc_type = 0;
				pin->shared_rsc_slock = NULL;
				pin->shared_rsc_count = NULL;
				pin->shared_rsc_active = 0;
			}

			if (of_find_property(node_table[i], "actuator_i2c_delay", NULL)) {
				of_property_read_u32(node_table[i], "actuator_i2c_delay", &pin->actuator_i2c_delay);
			}

			dbg("%s: gpio=%d, name=%s, act=%d, val=%d, delay=%d, volt=%d, share=<%d %d %d>\n",
				node_table[i]->name,
				pin->pin,
				pin->name,
				pin->act,
				pin->value,
				pin->delay,
				pin->voltage,
				pin->shared_rsc_type,
				share_index,
				pin->shared_rsc_active);
		}

		kfree(node_table);
		kfree(node_num);
	}

	return 0;
}

static int parse_eeprom_data(struct exynos_platform_is_module *pdata, struct device_node *dnode)
{
	u32 temp;
	char *pprop;

	DT_READ_U32(dnode, "product_name", pdata->eeprom_product_name);
	DT_READ_U32(dnode, "i2c_addr", pdata->eeprom_i2c_addr);
	DT_READ_U32(dnode, "i2c_ch", pdata->eeprom_i2c_ch);

	return 0;
}

static int parse_laser_af_data(struct exynos_platform_is_module *pdata, struct device_node *dnode)
{
	u32 temp;
	char *pprop;

	DT_READ_U32(dnode, "product_name", pdata->laser_af_product_name);

	return 0;
}

static int parse_match_seq_data(struct exynos_platform_is_module *pdata, struct device_node *dnode)
{
	int ret = 0;
	struct device_node *group_np;
	struct is_core *core;
	int num_entry;
	int i, j;
	int idx_prop;
	struct exynos_sensor_module_match *entry;

	core = (struct is_core *)dev_get_drvdata(is_dev);
	if (!core) {
		probe_err("core is NULL");
		return -EINVAL;
	}

	/*
	 * A match seq node is divided into group and entry.
	 * Group can be configured as many as MATCH_GROUP_MAX,
	 * and each group can have as many entries as MATCH_ENTRY_MAX.
	 * Each entry consists of a slave_addr, reg offset, number of byte, and expected value
	 * to compare the result with i2c transfer.
	 */
	i = 0;
	for_each_child_of_node(dnode, group_np) {
		j = 0;
		num_entry = of_property_count_elems_of_size((group_np),
				"entry", sizeof(u32)) / 5;
		for (j = 0; j < num_entry; j++) {
			entry = &pdata->match_entry[i][j];
			idx_prop = j * 5;
			of_property_read_u32_index(group_np, "entry", idx_prop++, &entry->slave_addr);
			of_property_read_u32_index(group_np, "entry", idx_prop++, &entry->reg);
			of_property_read_u32_index(group_np, "entry", idx_prop++, &entry->reg_type);
			of_property_read_u32_index(group_np, "entry", idx_prop++, &entry->expected_data);
			of_property_read_u32_index(group_np, "entry", idx_prop++, &entry->data_type);
			probe_info("%s: slave_addr(0x%04x), reg(0x%04x), reg_type(%d), expected_data(0x%04x), data_type(%d)\n",
					__func__, entry->slave_addr, entry->reg, entry->reg_type, entry->expected_data, entry->data_type);
		}
		pdata->num_of_match_entry[i] = num_entry;
		i++;
	}
	pdata->num_of_match_groups = i;

	return ret;
}

int is_module_parse_dt(struct device *dev,
	is_moudle_callback module_callback)
{
	int ret = 0;
	struct exynos_platform_is_module *pdata;
	struct device_node *dnode;
	struct device_node *af_np;
	struct device_node *flash_np;
	struct device_node *ois_np;
	struct device_node *mcu_np;
	struct device_node *aperture_np;
	struct device_node *vc_extra_np;
	struct device_node *modes_np;
	struct device_node *power_np;
	struct device_node *eeprom_np;
	struct device_node *laser_af_np;
	struct device_node *match_np;
	u32 use = 0;

	FIMC_BUG(!dev);
	FIMC_BUG(!dev->of_node);

	dnode = dev->of_node;
	pdata = kzalloc(sizeof(struct exynos_platform_is_module), GFP_KERNEL);
	if (!pdata) {
		probe_err("%s: no memory for platform data", __func__);
		return -ENOMEM;
	}

	pdata->gpio_cfg = exynos_is_module_pins_cfg;
	pdata->gpio_dbg = exynos_is_module_pins_dbg;

	/* common data */
	ret = of_property_read_u32(dnode, "id", &pdata->id);
	if (ret) {
		probe_err("id read is fail(%d)", ret);
		goto p_err;
	}

	ret = of_property_read_u32(dnode, "mclk_ch", &pdata->mclk_ch);
	if (ret) {
		probe_err("mclk_ch read is fail(%d)", ret);
		goto p_err;
	}

	ret = of_property_read_u32(dnode, "sensor_i2c_ch", &pdata->sensor_i2c_ch);
	if (ret) {
		probe_info("i2c_ch dt parsing skipped\n");
	}

	ret = of_property_read_u32(dnode, "sensor_i2c_addr", &pdata->sensor_i2c_addr);
	if (ret) {
		probe_info("i2c_addr dt parsing skipped\n");
	}

	ret = of_property_read_u32(dnode, "position", &pdata->position);
	if (ret) {
		probe_err("position read is fail(%d)", ret);
		goto p_err;
	}

	ret = of_property_read_u32(dnode, "sensor_id", &pdata->sensor_id);
	if (ret)
		probe_warn("sensor_id read is skipped(%d)", ret);

	ret = of_property_read_u32(dnode, "active_width", &pdata->active_width);
	if (ret)
		probe_warn("active_width read is skipped(%d)", ret);

	ret = of_property_read_u32(dnode, "active_height", &pdata->active_height);
	if (ret)
		probe_warn("active_height read is skipped(%d)", ret);

	ret = of_property_read_u32(dnode, "margin_left", &pdata->margin_left);
	if (ret)
		probe_warn("margin_left read is skipped(%d)", ret);

	ret = of_property_read_u32(dnode, "margin_right", &pdata->margin_right);
	if (ret)
		probe_warn("margin_right read is skipped(%d)", ret);

	ret = of_property_read_u32(dnode, "margin_top", &pdata->margin_top);
	if (ret)
		probe_warn("margin_top read is skipped(%d)", ret);

	ret = of_property_read_u32(dnode, "margin_bottom", &pdata->margin_bottom);
	if (ret)
		probe_warn("margin_bottom read is skipped(%d)", ret);

	ret = of_property_read_u32(dnode, "max_framerate", &pdata->max_framerate);
	if (ret)
		probe_warn("max_framerate read is skipped(%d)", ret);

	ret = of_property_read_u32(dnode, "bitwidth", &pdata->bitwidth);
	if (ret)
		probe_warn("bitwidth read is skipped(%d)", ret);

	ret = of_property_read_u32(dnode, "use_retention_mode", &pdata->use_retention_mode);
	if (ret)
		probe_warn("use_retention_mode read is skipped(%d)", ret);

	ret = of_property_read_u32(dnode, "use_binning_ratio_table", &pdata->use_binning_ratio_table);
	if (ret)
		probe_warn("use_binning_ratio_table read is skipped(%d)", ret);

	ret = of_property_read_string(dnode, "sensor_maker", (const char **)&pdata->sensor_maker);
	if (ret)
		probe_warn("sensor_maker read is skipped(%d)", ret);

	ret = of_property_read_string(dnode, "sensor_name", (const char **)&pdata->sensor_name);
	if (ret)
		probe_warn("sensor_name read is skipped(%d)", ret);

	ret = of_property_read_string(dnode, "setfile_name", (const char **)&pdata->setfile_name);
	if (ret)
		probe_warn("setfile_name read is skipped(%d)", ret);

	/* vendor data */
	ret = of_property_read_u32(dnode, "rom_id", &pdata->rom_id);
	if (ret) {
		probe_info("rom_id dt parsing skipped\n");
		pdata->rom_id = ROM_ID_NOTHING;
	}

	ret = of_property_read_u32(dnode, "rom_type", &pdata->rom_type);
	if (ret) {
		probe_info("rom_type dt parsing skipped\n");
		pdata->rom_type = ROM_TYPE_NONE;
	}

	ret = of_property_read_u32(dnode, "rom_cal_index", &pdata->rom_cal_index);
	if (ret) {
		probe_info("rom_cal_index dt parsing skipped\n");
		pdata->rom_cal_index = ROM_CAL_NOTHING;
	}

	ret = of_property_read_u32(dnode, "rom_dualcal_id", &pdata->rom_dualcal_id);
	if (ret) {
		probe_info("rom_dualcal_id dt parsing skipped\n");
		pdata->rom_dualcal_id = ROM_ID_NOTHING;
	}


	ret = of_property_read_u32(dnode, "rom_dualcal_index", &pdata->rom_dualcal_index);
	if (ret) {
		probe_info("rom_dualcal_index dt parsing skipped\n");
		pdata->rom_dualcal_index = ROM_DUALCAL_NOTHING;
	}

	/* peri */
	af_np = of_get_child_by_name(dnode, "af");
	if (!af_np) {
		pdata->af_product_name = ACTUATOR_NAME_NOTHING;
	} else {
		parse_af_data(pdata, af_np);
	}

	flash_np = of_get_child_by_name(dnode, "flash");
	if (!flash_np) {
		pdata->flash_product_name = FLADRV_NAME_NOTHING;
	} else {
		parse_flash_data(pdata, flash_np);
	}

	ois_np = of_get_child_by_name(dnode, "ois");
	if (!ois_np) {
		pdata->ois_product_name = OIS_NAME_NOTHING;
	} else {
		parse_ois_data(pdata, ois_np);
	}

	mcu_np = of_get_child_by_name(dnode, "mcu");
	if (!mcu_np) {
		pdata->mcu_product_name = MCU_NAME_NOTHING;
	} else {
		parse_mcu_data(pdata, mcu_np);
	}

	aperture_np = of_get_child_by_name(dnode, "aperture");
	if (!aperture_np) {
		pdata->aperture_product_name = APERTURE_NAME_NOTHING;
	} else {
		parse_aperture_data(pdata, aperture_np);
	}

	/* vc_extra data */
	vc_extra_np = of_get_child_by_name(dnode, "vc_extra");
	if (!vc_extra_np) {
		probe_warn("sensor vc_extra are not declared to DT");
	} else {
		ret = parse_vc_extra_data(pdata, vc_extra_np);
		if (ret) {
			probe_err("parse_vc_extra_data is fail(%d)", ret);
			goto p_err;
		}
	}

	/* mode data */
	modes_np = of_get_child_by_name(dnode, "modes");
	if (!modes_np) {
		probe_warn("sensor modes are not declared to DT");
	} else {
		ret = parse_modes_data(pdata, modes_np);
		if (ret) {
			probe_err("parse_modes_data is fail(%d)", ret);
			goto p_err;
		}
	}

	/* power sequence data */
	power_np = of_get_child_by_name(dnode, "power_seq");
	if (power_np) {
		ret = of_property_read_u32(power_np, "use", &use);
		if (ret)
			probe_warn("use read is skipped");
	}

	if (power_np && use) {
		ret = parse_power_seq_data(pdata, power_np);
		if (ret) {
			probe_err("%s: parse_power_seq_data(%d)", power_np->full_name, ret);
			goto p_err;
		}
	} else {
		if (module_callback) {
			ret = module_callback(dev, pdata);
			if (ret) {
				probe_err("sensor dt callback is fail(%d)", ret);
				goto p_err;
			}
		} else {
			probe_err("sensor dt callback is NULL");
			goto p_err;
		}
	}

	eeprom_np = of_find_node_by_name(dnode, "eeprom");
	if (!eeprom_np)
		pdata->eeprom_product_name = EEPROM_NAME_NOTHING;
	else
		parse_eeprom_data(pdata, eeprom_np);

	laser_af_np = of_get_child_by_name(dnode, "laser_af");
	if (!laser_af_np)
		pdata->laser_af_product_name = LASER_AF_NAME_NOTHING;
	else
		parse_laser_af_data(pdata, laser_af_np);

	match_np = of_get_child_by_name(dnode, "match_seq");
	if (match_np) {
		ret = parse_match_seq_data(pdata, match_np);
		if (ret) {
			probe_err("%s: parse_match_seq_data(%d)", match_np->full_name, ret);
			goto p_err;
		}
	}

	pdata->pinctrl = devm_pinctrl_get(dev);
	if (IS_ERR(pdata->pinctrl)) {
		probe_err("devm_pinctrl_get is fail");
		goto p_err;
	}

	ret = get_pin_lookup_state(pdata->pinctrl, pdata->pin_ctrls);
	if (ret) {
		probe_err("get_pin_lookup_state is fail(%d)", ret);
		goto p_err;
	}

	dev->platform_data = pdata;

	return ret;

p_err:
	kfree(pdata);
	return ret;
}

#ifdef CONFIG_SPI
int is_spi_parse_dt(struct is_spi *spi)
{
	int ret = 0;
	struct device_node *np;
	struct device *dev;
	struct pinctrl_state *s;

	FIMC_BUG(!spi);

	dev = &spi->device->dev;

	np = of_find_compatible_node(NULL,NULL, spi->node);
	if(np == NULL) {
		probe_err("compatible: fail to read, spi_parse_dt");
		ret = -ENODEV;
		goto p_err;
	}

	spi->use_spi_pinctrl = of_property_read_bool(np, "use_spi_pinctrl");
	if (!spi->use_spi_pinctrl) {
		probe_info("%s: spi dt parsing skipped\n", __func__);
		goto p_err;
	}

	spi->pinctrl = devm_pinctrl_get(dev);
	if (IS_ERR(spi->pinctrl)) {
		probe_err("devm_pinctrl_get is fail");
		goto p_err;
	}

	s = pinctrl_lookup_state(spi->pinctrl, "ssn_out");
	if (IS_ERR_OR_NULL(s)) {
		probe_info("pinctrl_lookup_state(%s) is not found", "ssn_out");
		spi->pin_ssn_out = NULL;
	} else {
		spi->pin_ssn_out = s;
	}

	s = pinctrl_lookup_state(spi->pinctrl, "ssn_fn");
	if (IS_ERR_OR_NULL(s)) {
		probe_info("pinctrl_lookup_state(%s) is not found", "ssn_fn");
		spi->pin_ssn_fn = NULL;
	} else {
		spi->pin_ssn_fn = s;
	}

	s = pinctrl_lookup_state(spi->pinctrl, "ssn_inpd");
	if (IS_ERR_OR_NULL(s)) {
		probe_info("pinctrl_lookup_state(%s) is not found", "ssn_inpd");
		spi->pin_ssn_inpd = NULL;
	} else {
		spi->pin_ssn_inpd = s;
	}

	s = pinctrl_lookup_state(spi->pinctrl, "ssn_inpu");
	if (IS_ERR_OR_NULL(s)) {
		probe_info("pinctrl_lookup_state(%s) is not found", "ssn_inpu");
		spi->pin_ssn_inpu = NULL;
	} else {
		spi->pin_ssn_inpu = s;
	}

	spi->parent_pinctrl = devm_pinctrl_get(spi->device->dev.parent->parent);

	s = pinctrl_lookup_state(spi->parent_pinctrl, "spi_out");
	if (IS_ERR_OR_NULL(s)) {
		err("pinctrl_lookup_state(%s) is failed", "spi_out");
		ret = -EINVAL;
		goto p_err;
	}

	spi->parent_pin_out = s;

	s = pinctrl_lookup_state(spi->parent_pinctrl, "spi_fn");
	if (IS_ERR_OR_NULL(s)) {
		err("pinctrl_lookup_state(%s) is failed", "spi_fn");
		ret = -EINVAL;
		goto p_err;
	}

	spi->parent_pin_fn = s;

p_err:
	return ret;
}
#endif
#else
struct exynos_platform_is *is_parse_dt(struct device *dev)
{
	return ERR_PTR(-EINVAL);
}
#endif