summaryrefslogtreecommitdiff
path: root/arch/arm/mach-mx5/mx51_ccwmx51js_gpio.c
blob: b626605bd8fa820cb14315c6251566c1dfbb6d48 (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
/*
 * Copyright 2009 Freescale Semiconductor, Inc. All Rights Reserved.
 * Copyright 2009-2010 Digi International, Inc. All Rights Reserved.
 */

/*
 * The code contained herein is licensed under the GNU General Public
 * License. You may obtain a copy of the GNU General Public License
 * Version 2 or later at the following locations:
 *
 * http://www.opensource.org/licenses/gpl-license.html
 * http://www.gnu.org/copyleft/gpl.html
 */

#include <linux/errno.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <mach/hardware.h>
#include <mach/gpio.h>

#include "iomux.h"
#include "mx51_pins.h"
#include "board-ccwmx51.h"


/**
 * iomux settings for the external ethernet mac
 */
#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
static struct mxc_iomux_pin_cfg __initdata ccwmx51_iomux_ext_eth_pins[] = {
        {MX51_PIN_EIM_CS5, IOMUX_CONFIG_ALT0,
                        (PAD_CTL_HYS_ENABLE | PAD_CTL_PUE_KEEPER | PAD_CTL_DRV_MEDIUM), },
	{MX51_PIN_EIM_OE, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_DA0, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_DA1, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_DA2, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_DA3, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_DA4, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_DA5, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_DA6, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_DA7, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_D16, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_D17, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_D18, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_D19, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_D20, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_D21, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_D22, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_D23, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_D24, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_D25, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_D26, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_D27, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_D28, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_D29, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_D30, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_EIM_D31, IOMUX_CONFIG_ALT0,},
	{MX51_PIN_GPIO1_9, IOMUX_CONFIG_ALT0, (PAD_CTL_HYS_ENABLE | PAD_CTL_100K_PU), },
};
#endif

#if defined(CONFIG_MMC_IMX_ESDHCI) || defined(CONFIG_MMC_IMX_ESDHCI_MODULE)
static struct mxc_iomux_pin_cfg ccwmx51_iomux_mmc1_pins[] = {
	/* SDHC1*/
	{
		MX51_PIN_SD1_CMD, IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION,
		(PAD_CTL_PUE_KEEPER | PAD_CTL_PKE_ENABLE | PAD_CTL_DRV_HIGH |
		PAD_CTL_47K_PU | PAD_CTL_SRE_FAST),
	},
	{
		MX51_PIN_SD1_CLK, IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION,
		(PAD_CTL_PUE_KEEPER | PAD_CTL_PKE_ENABLE | PAD_CTL_DRV_HIGH |
		PAD_CTL_47K_PU | PAD_CTL_SRE_FAST),
	},
	{
		MX51_PIN_SD1_DATA0, IOMUX_CONFIG_ALT0,
		(PAD_CTL_PUE_KEEPER | PAD_CTL_PKE_ENABLE | PAD_CTL_DRV_HIGH |
		PAD_CTL_47K_PU | PAD_CTL_SRE_FAST),
	},
	{
		MX51_PIN_SD1_DATA1, IOMUX_CONFIG_ALT0,
		(PAD_CTL_PUE_KEEPER | PAD_CTL_PKE_ENABLE | PAD_CTL_DRV_HIGH |
		PAD_CTL_47K_PU | PAD_CTL_SRE_FAST),
	},
	{
		MX51_PIN_SD1_DATA2, IOMUX_CONFIG_ALT0,
		(PAD_CTL_PUE_KEEPER | PAD_CTL_PKE_ENABLE | PAD_CTL_DRV_HIGH |
		PAD_CTL_47K_PU | PAD_CTL_SRE_FAST),
	},
	{
		MX51_PIN_SD1_DATA3, IOMUX_CONFIG_ALT0,
		(PAD_CTL_PUE_KEEPER | PAD_CTL_PKE_ENABLE | PAD_CTL_DRV_HIGH |
		PAD_CTL_47K_PU | PAD_CTL_SRE_FAST),
	},
#ifdef CONFIG_JSCCWMX51_V1
	{
		MX51_PIN_GPIO1_0, IOMUX_CONFIG_GPIO | IOMUX_CONFIG_SION,
		(PAD_CTL_HYS_ENABLE | PAD_CTL_100K_PU),
	},
#endif
};

#ifdef CONFIG_MACH_CCWMX51JS
/* IOMUX settings, for the wireless interface on Wi-i.MX51 module */
#define SD2_PAD_CFG	(PAD_CTL_DRV_MAX | PAD_CTL_DRV_VOT_HIGH | \
			 PAD_CTL_22K_PU | PAD_CTL_PUE_PULL | \
			 PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST)
static struct mxc_iomux_pin_cfg ccwmx51_iomux_mmc2_pins[] = {
	/* SDHC2*/
	{
		MX51_PIN_SD2_CMD, IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION,
		SD2_PAD_CFG,
	},
	{
		MX51_PIN_SD2_CLK, IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION,
		SD2_PAD_CFG,
	},
	{
		MX51_PIN_SD2_DATA0, IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION,
		SD2_PAD_CFG,
	},
	{
		MX51_PIN_SD2_DATA1, IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION,
		SD2_PAD_CFG,
	},
	{
		MX51_PIN_SD2_DATA2, IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION,
		SD2_PAD_CFG,
	},
	{
		MX51_PIN_SD2_DATA3, IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION,
		SD2_PAD_CFG,
	},
};
#endif

static struct mxc_iomux_pin_cfg ccwmx51_iomux_mmc3_pins[] = {
	/* SDHC3*/
	{
		MX51_PIN_NANDF_RDY_INT, IOMUX_CONFIG_ALT5 | IOMUX_CONFIG_SION,
		(PAD_CTL_DRV_MAX | PAD_CTL_22K_PU | PAD_CTL_SRE_FAST),
	},
	{
		MX51_PIN_NANDF_CS7, IOMUX_CONFIG_ALT5,
		(PAD_CTL_DRV_MAX | PAD_CTL_22K_PU | PAD_CTL_SRE_FAST),
	},
	{	/* SD3 DATA0 */
		MX51_PIN_NANDF_D8, IOMUX_CONFIG_ALT5,
		(PAD_CTL_DRV_MAX | PAD_CTL_22K_PU | PAD_CTL_SRE_FAST),
		MUX_IN_ESDHC3_IPP_DAT0_IN_SELECT_INPUT, INPUT_CTL_PATH1
	},
	{	/* SD3 DATA1 */
		MX51_PIN_NANDF_D9, IOMUX_CONFIG_ALT5,
		(PAD_CTL_DRV_MAX | PAD_CTL_22K_PU | PAD_CTL_SRE_FAST),
		MUX_IN_ESDHC3_IPP_DAT1_IN_SELECT_INPUT, INPUT_CTL_PATH1
	},
	{	/* SD3 DATA2 */
		MX51_PIN_NANDF_D10, IOMUX_CONFIG_ALT5,
		(PAD_CTL_DRV_MAX | PAD_CTL_22K_PU | PAD_CTL_SRE_FAST),
		MUX_IN_ESDHC3_IPP_DAT2_IN_SELECT_INPUT, INPUT_CTL_PATH1
	},
	{	/* SD3 DATA3 */
		MX51_PIN_NANDF_D11, IOMUX_CONFIG_ALT5,
		(PAD_CTL_DRV_MAX | PAD_CTL_22K_PU | PAD_CTL_SRE_FAST),
		MUX_IN_ESDHC3_IPP_DAT3_IN_SELECT_INPUT, INPUT_CTL_PATH1
	},
	{	/* SD3 Card detect */
		MX51_PIN_GPIO_NAND, IOMUX_CONFIG_GPIO | IOMUX_CONFIG_SION,
		(PAD_CTL_HYS_ENABLE | PAD_CTL_100K_PU),
	},
	{	/* SD3 Write protect */
		MX51_PIN_NANDF_CS1, IOMUX_CONFIG_GPIO | IOMUX_CONFIG_SION,
		(PAD_CTL_HYS_ENABLE | PAD_CTL_100K_PU),
	},
};

void gpio_sdhc_active(int interface)
{
	int i;

	switch (interface) {
	  case 0:
		for (i = 0; i < ARRAY_SIZE(ccwmx51_iomux_mmc1_pins); i++) {
			mxc_request_iomux(ccwmx51_iomux_mmc1_pins[i].pin,
					  ccwmx51_iomux_mmc1_pins[i].mux_mode);
			if (ccwmx51_iomux_mmc1_pins[i].pad_cfg)
				mxc_iomux_set_pad(ccwmx51_iomux_mmc1_pins[i].pin,
						  ccwmx51_iomux_mmc1_pins[i].pad_cfg);
			if (ccwmx51_iomux_mmc1_pins[i].in_select)
				mxc_iomux_set_input(ccwmx51_iomux_mmc1_pins[i].in_select,
						    ccwmx51_iomux_mmc1_pins[i].in_mode);
		}
		break;
	case 1:
#ifdef CONFIG_MACH_CCWMX51JS
		for (i = 0; i < ARRAY_SIZE(ccwmx51_iomux_mmc2_pins); i++) {
			mxc_request_iomux(ccwmx51_iomux_mmc2_pins[i].pin,
					  ccwmx51_iomux_mmc2_pins[i].mux_mode);
			if (ccwmx51_iomux_mmc2_pins[i].pad_cfg)
				mxc_iomux_set_pad(ccwmx51_iomux_mmc2_pins[i].pin,
						  ccwmx51_iomux_mmc2_pins[i].pad_cfg);
			if (ccwmx51_iomux_mmc2_pins[i].in_select)
				mxc_iomux_set_input(ccwmx51_iomux_mmc2_pins[i].in_select,
						    ccwmx51_iomux_mmc2_pins[i].in_mode);
		}
#endif
		break;

	case 2:
		for (i = 0; i < ARRAY_SIZE(ccwmx51_iomux_mmc3_pins); i++) {
			mxc_request_iomux(ccwmx51_iomux_mmc3_pins[i].pin,
					  ccwmx51_iomux_mmc3_pins[i].mux_mode);
			if (ccwmx51_iomux_mmc3_pins[i].pad_cfg)
				mxc_iomux_set_pad(ccwmx51_iomux_mmc3_pins[i].pin,
						  ccwmx51_iomux_mmc3_pins[i].pad_cfg);
			if (ccwmx51_iomux_mmc3_pins[i].in_select)
				mxc_iomux_set_input(ccwmx51_iomux_mmc3_pins[i].in_select,
						    ccwmx51_iomux_mmc3_pins[i].in_mode);
		}
		break;
	}
}
EXPORT_SYMBOL(gpio_sdhc_active);
void gpio_sdhc_inactive(int module) {}
EXPORT_SYMBOL(gpio_sdhc_inactive);
#endif

#if defined(CONFIG_USB_EHCI_ARC_H1) || defined(CONFIG_USB_EHCI_ARC_H1_MODULE)
static struct mxc_iomux_pin_cfg __initdata ccwmx51_iomux_usbh1_pins[] = {
	{	/* USBH1_STP */
		MX51_PIN_USBH1_STP, IOMUX_CONFIG_ALT0,
		(PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH | PAD_CTL_PUE_KEEPER |
		PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE),
	},
	{	/* USBH1_CLK */
		MX51_PIN_USBH1_CLK, IOMUX_CONFIG_ALT0,
		(PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH | PAD_CTL_PUE_KEEPER |
		PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE | PAD_CTL_DDR_INPUT_CMOS),
	},
	{	/* USBH1_DIR */
		MX51_PIN_USBH1_DIR, IOMUX_CONFIG_ALT0,
		(PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH | PAD_CTL_PUE_KEEPER |
		PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE | PAD_CTL_DDR_INPUT_CMOS),
	},
	{	/* USBH1_NXT */
		MX51_PIN_USBH1_NXT, IOMUX_CONFIG_ALT0,
		(PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH | PAD_CTL_PUE_KEEPER |
		PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE | PAD_CTL_DDR_INPUT_CMOS),
	},
	{	/* USBH1_DATA0 */
		MX51_PIN_USBH1_DATA0, IOMUX_CONFIG_ALT0,
		(PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU |
		PAD_CTL_PUE_KEEPER | PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE),
	},
	{	/* USBH1_DATA1 */
		MX51_PIN_USBH1_DATA1, IOMUX_CONFIG_ALT0,
		(PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU |
		PAD_CTL_PUE_KEEPER | PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE),
	},
	{	/* USBH1_DATA2 */
		MX51_PIN_USBH1_DATA2, IOMUX_CONFIG_ALT0,
		(PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU |
		PAD_CTL_PUE_KEEPER | PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE),
	},
	{	/* USBH1_DATA3 */
		MX51_PIN_USBH1_DATA3, IOMUX_CONFIG_ALT0,
		(PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU |
		PAD_CTL_PUE_KEEPER | PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE),
	},
	{	/* USBH1_DATA4 */
		MX51_PIN_USBH1_DATA4, IOMUX_CONFIG_ALT0,
		(PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU |
		PAD_CTL_PUE_KEEPER | PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE),
	},
	{	/* USBH1_DATA5 */
		MX51_PIN_USBH1_DATA5, IOMUX_CONFIG_ALT0,
		(PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU |
		PAD_CTL_PUE_KEEPER | PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE),
	},
	{	/* USBH1_DATA6 */
		MX51_PIN_USBH1_DATA6, IOMUX_CONFIG_ALT0,
		(PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU |
		PAD_CTL_PUE_KEEPER | PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE),
	},
	{	/* USBH1_DATA7 */
		MX51_PIN_USBH1_DATA7, IOMUX_CONFIG_ALT0,
		(PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU |
		PAD_CTL_PUE_KEEPER | PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE),
	},
	{	/* USBH PHY RESET */
		MX51_PIN_DISPB2_SER_RS, IOMUX_CONFIG_ALT4,
		(PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH | PAD_CTL_47K_PU |
		PAD_CTL_PUE_KEEPER | PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE),
		MUX_IN_GPIO3_IPP_IND_G_IN_8_SELECT_INPUT, INPUT_CTL_PATH1
	},
};
#endif

#if defined(CONFIG_FB_MXC_SYNC_PANEL) || defined(CONFIG_FB_MXC_SYNC_PANEL_MODULE)
#if defined(CONFIG_CCWMX51_DISP0)
#define DISP1_PAD0		(PAD_CTL_PKE_ENABLE | PAD_CTL_DRV_HIGH | PAD_CTL_SRE_FAST)
static struct mxc_iomux_pin_cfg ccwmx51_iomux_video1_pins[] = {
        {       /* DISP1 DAT0 */
		MX51_PIN_DISP1_DAT0, IOMUX_CONFIG_ALT0,
		DISP1_PAD0,
	},
	{	/* DISP1 DAT1 */
		MX51_PIN_DISP1_DAT1, IOMUX_CONFIG_ALT0,
		DISP1_PAD0,
	},
	{	/* DISP1 DAT2 */
		MX51_PIN_DISP1_DAT2, IOMUX_CONFIG_ALT0,
		DISP1_PAD0,
	},
	{	/* DISP1 DAT3 */
		MX51_PIN_DISP1_DAT3, IOMUX_CONFIG_ALT0,
		DISP1_PAD0,
	},
	{	/* DISP1 DAT4 */
		MX51_PIN_DISP1_DAT4, IOMUX_CONFIG_ALT0,
		DISP1_PAD0,
	},
	{	/* DISP1 DAT5 */
		MX51_PIN_DISP1_DAT5, IOMUX_CONFIG_ALT0,
		DISP1_PAD0,
	},
	{	/* DISP1 DAT6 */
		MX51_PIN_DISP1_DAT6, IOMUX_CONFIG_ALT0,
		DISP1_PAD0,
	},
	{	/* DISP1 DAT7 */
		MX51_PIN_DISP1_DAT7, IOMUX_CONFIG_ALT0,
		DISP1_PAD0,
	},
	{	/* DISP1 DAT8 */
		MX51_PIN_DISP1_DAT8, IOMUX_CONFIG_ALT0,
		DISP1_PAD0,
	},
	{	/* DISP1 DAT9 */
		MX51_PIN_DISP1_DAT9, IOMUX_CONFIG_ALT0,
		DISP1_PAD0,
	},
	{	/* DISP1 DAT10 */
		MX51_PIN_DISP1_DAT10, IOMUX_CONFIG_ALT0,
		DISP1_PAD0,
	},
	{	/* DISP1 DAT11 */
		MX51_PIN_DISP1_DAT11, IOMUX_CONFIG_ALT0,
		DISP1_PAD0,
	},
	{	/* DISP1 DAT12 */
		MX51_PIN_DISP1_DAT12, IOMUX_CONFIG_ALT0,
		DISP1_PAD0,
	},
	{	/* DISP1 DAT13 */
		MX51_PIN_DISP1_DAT13, IOMUX_CONFIG_ALT0,
		DISP1_PAD0,
	},
	{	/* DISP1 DAT14 */
		MX51_PIN_DISP1_DAT14, IOMUX_CONFIG_ALT0,
		DISP1_PAD0,
	},
	{	/* DISP1 DAT15 */
		MX51_PIN_DISP1_DAT15, IOMUX_CONFIG_ALT0,
		DISP1_PAD0,
	},
	{	/* DISP1 DAT16 */
		MX51_PIN_DISP1_DAT16, IOMUX_CONFIG_ALT0,
		DISP1_PAD0,
	},
	{	/* DISP1 DAT17 */
		MX51_PIN_DISP1_DAT17, IOMUX_CONFIG_ALT0,
		DISP1_PAD0,
	},
	{	/* DISP1 DAT18 */
		MX51_PIN_DISP1_DAT18, IOMUX_CONFIG_ALT0,
		DISP1_PAD0,
	},
	{	/* DISP1 DAT19 */
		MX51_PIN_DISP1_DAT19, IOMUX_CONFIG_ALT0,
		DISP1_PAD0,
	},
	{	/* DISP1 DAT20 */
		MX51_PIN_DISP1_DAT20, IOMUX_CONFIG_ALT0,
		DISP1_PAD0,
	},
	{	/* DISP1 DAT21 */
                MX51_PIN_DISP1_DAT21, IOMUX_CONFIG_ALT0,
                DISP1_PAD0,
        },
#if !defined(CONFIG_CCWMX51_DISP1)
        {       /* DISP1 DAT22 */
                MX51_PIN_DISP1_DAT22, IOMUX_CONFIG_ALT0,
                DISP1_PAD0,
	},
	{	/* DISP1 DAT23 */
                MX51_PIN_DISP1_DAT23, IOMUX_CONFIG_ALT0,
                DISP1_PAD0,
        },
#endif
};
#endif

#if defined(CONFIG_CCWMX51_DISP1)
#define DISP2_PAD0		(PAD_CTL_PKE_ENABLE | PAD_CTL_DRV_HIGH | PAD_CTL_SRE_FAST)
static struct mxc_iomux_pin_cfg ccwmx51_iomux_video2_pins[] = {
        /* This interface can be enabled only if the FEC interface is disabled */
        {       /* DISP2 DAT0 */
                MX51_PIN_DISP2_DAT0, IOMUX_CONFIG_ALT0,
                DISP2_PAD0,
        },
        {       /* DISP2 DAT1 */
                MX51_PIN_DISP2_DAT1, IOMUX_CONFIG_ALT0,
                DISP2_PAD0,
        },
        {       /* DISP2 DAT2 */
                MX51_PIN_DISP2_DAT2, IOMUX_CONFIG_ALT0,
                DISP2_PAD0,
        },
        {       /* DISP2 DAT3 */
                MX51_PIN_DISP2_DAT3, IOMUX_CONFIG_ALT0,
                DISP2_PAD0,
        },
        {       /* DISP2 DAT4 */
                MX51_PIN_DISP2_DAT4, IOMUX_CONFIG_ALT0,
                DISP2_PAD0,
        },
        {       /* DISP2 DAT5 */
                MX51_PIN_DISP2_DAT5, IOMUX_CONFIG_ALT0,
                DISP2_PAD0,
        },
        {       /* DISP2 DAT6 */
                MX51_PIN_DISP2_DAT6, IOMUX_CONFIG_ALT0,
                DISP2_PAD0,
        },
        {       /* DISP2 DAT7 */
                MX51_PIN_DISP2_DAT7, IOMUX_CONFIG_ALT0,
                DISP2_PAD0,
        },
        {       /* DISP2 DAT8 */
                MX51_PIN_DISP2_DAT8, IOMUX_CONFIG_ALT0,
                DISP2_PAD0,
        },
        {       /* DISP2 DAT9 */
                MX51_PIN_DISP2_DAT9, IOMUX_CONFIG_ALT0,
                DISP2_PAD0,
        },
        {       /* DISP2 DAT10 */
                MX51_PIN_DISP2_DAT10, IOMUX_CONFIG_ALT0,
                DISP2_PAD0,
        },
        {       /* DISP2 DAT11 */
                MX51_PIN_DISP2_DAT11, IOMUX_CONFIG_ALT0,
                DISP2_PAD0,
        },
        {       /* DISP2 DAT12 */
                MX51_PIN_DISP2_DAT12, IOMUX_CONFIG_ALT0,
                DISP2_PAD0,
        },
        {       /* DISP2 DAT13 */
                MX51_PIN_DISP2_DAT13, IOMUX_CONFIG_ALT0,
                DISP2_PAD0,
        },
        {       /* DISP2 DAT14 */
                MX51_PIN_DISP2_DAT14, IOMUX_CONFIG_ALT0,
                DISP2_PAD0,
        },
        {       /* DISP2 DAT15 */
                MX51_PIN_DISP2_DAT15, IOMUX_CONFIG_ALT0,
                DISP2_PAD0,
        },
        {       /* DISP2 16 (also DISP1 DAT22) */
                MX51_PIN_DISP1_DAT22, IOMUX_CONFIG_ALT5,
                DISP2_PAD0,
        },
        {       /* DISP2 17 (also DISP1 DAT23) */
                MX51_PIN_DISP1_DAT23, IOMUX_CONFIG_ALT5,
                DISP2_PAD0,
        },
        {       /* DISP2 HSYNC */
                MX51_PIN_DI2_PIN2, IOMUX_CONFIG_ALT0,
                DISP2_PAD0,
        },
        {       /* DISP2 VSYNC */
                MX51_PIN_DI2_PIN3, IOMUX_CONFIG_ALT0,
                DISP2_PAD0,
        },
        {       /* DISP2 PCLK */
                MX51_PIN_DI2_DISP_CLK, IOMUX_CONFIG_ALT0,
                DISP2_PAD0,
        },
        {       /* DISP2 DRDY */
                MX51_PIN_DI_GP4, IOMUX_CONFIG_ALT4,
                DISP2_PAD0,
        },
};
#endif
#endif

#if defined(CONFIG_I2C_MXC) || defined(CONFIG_I2C_MXC_MODULE)
static struct mxc_iomux_pin_cfg __initdata ccwmx51_iomux_i2c_pins[] = {
#if defined (CONFIG_I2C_MXC_SELECT1)
	{
		MX51_PIN_SD2_CMD, IOMUX_CONFIG_ALT1 | IOMUX_CONFIG_SION,
		(PAD_CTL_SRE_FAST | PAD_CTL_ODE_OPENDRAIN_ENABLE | PAD_CTL_HYS_ENABLE |
		PAD_CTL_100K_PU | PAD_CTL_DRV_HIGH),
		MUX_IN_I2C1_IPP_SDA_IN_SELECT_INPUT, INPUT_CTL_PATH2,
	},
	{
		MX51_PIN_SD2_CLK, IOMUX_CONFIG_ALT1 | IOMUX_CONFIG_SION,
		(PAD_CTL_SRE_FAST | PAD_CTL_ODE_OPENDRAIN_ENABLE | PAD_CTL_HYS_ENABLE |
		PAD_CTL_100K_PU | PAD_CTL_DRV_HIGH),
		MUX_IN_I2C1_IPP_SCL_IN_SELECT_INPUT, INPUT_CTL_PATH2,
	},
#endif
#ifdef CONFIG_I2C_MXC_SELECT2
	{
		MX51_PIN_GPIO1_2, IOMUX_CONFIG_ALT2 | IOMUX_CONFIG_SION,
		(PAD_CTL_SRE_FAST | PAD_CTL_ODE_OPENDRAIN_ENABLE | PAD_CTL_DRV_HIGH |
		PAD_CTL_100K_PU | PAD_CTL_HYS_ENABLE),
		MUX_IN_I2C2_IPP_SCL_IN_SELECT_INPUT, INPUT_CTL_PATH3,
	},
	{
		MX51_PIN_GPIO1_3, IOMUX_CONFIG_ALT2 | IOMUX_CONFIG_SION,
		(PAD_CTL_SRE_FAST | PAD_CTL_ODE_OPENDRAIN_ENABLE | PAD_CTL_DRV_HIGH |
		PAD_CTL_100K_PU | PAD_CTL_HYS_ENABLE),
		MUX_IN_I2C2_IPP_SDA_IN_SELECT_INPUT, INPUT_CTL_PATH3,
	},
#endif
#ifdef CONFIG_I2C_MXC_SELECT3
	{
		MX51_PIN_I2C1_CLK, IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION,
		(PAD_CTL_ODE_OPENDRAIN_NONE | PAD_CTL_HYS_ENABLE |
		PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU | PAD_CTL_SRE_SLOW),
	},
	{
		MX51_PIN_I2C1_DAT, IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION,
		(PAD_CTL_ODE_OPENDRAIN_NONE | PAD_CTL_HYS_ENABLE |
		PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU | PAD_CTL_SRE_SLOW),
	}
#endif
};
#endif /* defined(CONFIG_I2C_MXC) || defined(CONFIG_I2C_MXC_MODULE) */

static struct mxc_iomux_pin_cfg __initdata ccwmx51_iomux_devices_pins[] = {
	{	/* PMIC interrupt line */
		MX51_PIN_GPIO1_5, IOMUX_CONFIG_GPIO | IOMUX_CONFIG_SION,
		(PAD_CTL_SRE_SLOW | PAD_CTL_DRV_MEDIUM | PAD_CTL_100K_PU |
		PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_VOT_HIGH),
	},
#if defined(CONFIG_INPUT_MMA7455L) || defined(CONFIG_INPUT_MMA7455L_MODULE)
	{	/* MMA7455L interrupt line */
		MX51_PIN_GPIO1_6, IOMUX_CONFIG_GPIO,
	},
	{
		MX51_PIN_GPIO1_7, IOMUX_CONFIG_ALT2,
		(PAD_CTL_DRV_HIGH | PAD_CTL_PUE_PULL |
		PAD_CTL_100K_PU | PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST),
	},
#endif
};

#if defined(CONFIG_SND_SOC_WM8753) || defined(CONFIG_SND_SOC_WM8753_MODULE)
static struct mxc_iomux_pin_cfg __initdata ccwmx51_audio_pins[] = {

	/* TODO: the SSI interface should be selectable through configuration */
	{	/* AUD3_BB_CK */
		MX51_PIN_AUD3_BB_CK, IOMUX_CONFIG_ALT0 ,
		(PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU |
		PAD_CTL_HYS_NONE | PAD_CTL_ODE_OPENDRAIN_NONE | PAD_CTL_PKE_ENABLE |
		PAD_CTL_PUE_KEEPER ),
	},
	{	/* AUD3_BB_FS */
		MX51_PIN_AUD3_BB_FS, IOMUX_CONFIG_ALT0 ,
		(PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH | PAD_CTL_HYS_NONE |
		PAD_CTL_PUE_KEEPER | PAD_CTL_PKE_ENABLE),
	},
	{	/* AUD3_BB_RXD */
		MX51_PIN_AUD3_BB_RXD, IOMUX_CONFIG_ALT0 ,
		(PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH | PAD_CTL_HYS_NONE |
		PAD_CTL_PUE_KEEPER | PAD_CTL_PKE_ENABLE),
	},
	{	/* AUD3_BB_TXD */
		MX51_PIN_AUD3_BB_TXD, IOMUX_CONFIG_ALT0 ,
		(PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU |
		PAD_CTL_HYS_NONE | PAD_CTL_ODE_OPENDRAIN_NONE | PAD_CTL_PKE_ENABLE |
		PAD_CTL_PUE_KEEPER ),
	},
};
#endif

#if defined CONFIG_VIDEO_MXC_IPU_CAMERA
static struct mxc_iomux_pin_cfg __initdata ccwmx51_camera_pins[] = {
		/* CSI0 camera interface 1 */
	{
		MX51_PIN_CSI1_D12, IOMUX_CONFIG_ALT0, PAD_CTL_HYS_NONE,
	},
	{
		MX51_PIN_CSI1_D13, IOMUX_CONFIG_ALT0, PAD_CTL_HYS_NONE,
	},
	{
		MX51_PIN_CSI1_D14, IOMUX_CONFIG_ALT0, PAD_CTL_HYS_NONE,
	},
	{
		MX51_PIN_CSI1_D15, IOMUX_CONFIG_ALT0, PAD_CTL_HYS_NONE,
	},
	{
		MX51_PIN_CSI1_D16, IOMUX_CONFIG_ALT0, PAD_CTL_HYS_NONE,
	},
	{
		MX51_PIN_CSI1_D17, IOMUX_CONFIG_ALT0, PAD_CTL_HYS_NONE,
	},
	{
		MX51_PIN_CSI1_D18, IOMUX_CONFIG_ALT0, PAD_CTL_HYS_NONE,
	},
	{
		MX51_PIN_CSI1_D19, IOMUX_CONFIG_ALT0, PAD_CTL_HYS_NONE,
	},
	{
		MX51_PIN_CSI1_VSYNC, IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION,
		(PAD_CTL_HYS_NONE | PAD_CTL_SRE_SLOW),
	},
	{
		MX51_PIN_CSI1_HSYNC, IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION,
		(PAD_CTL_HYS_NONE | PAD_CTL_SRE_SLOW),
	},
	/* Configure GPIO3_13 as RESET for camera 1 */
	{
		MX51_PIN_CSI1_D9, IOMUX_CONFIG_ALT3,
		(PAD_CTL_HYS_NONE | PAD_CTL_DRV_MEDIUM | PAD_CTL_SRE_FAST),
	},
	/* CSI2 camera interface 2 */
	{
		MX51_PIN_CSI2_D12, IOMUX_CONFIG_ALT0, PAD_CTL_HYS_NONE,
	},
	{
		MX51_PIN_CSI2_D13, IOMUX_CONFIG_ALT0, PAD_CTL_HYS_NONE,
	},
	{
		MX51_PIN_CSI2_D14, IOMUX_CONFIG_ALT0, PAD_CTL_HYS_NONE,
	},
	{
		MX51_PIN_CSI2_D15, IOMUX_CONFIG_ALT0, PAD_CTL_HYS_NONE,
	},
	{
		MX51_PIN_CSI2_D16, IOMUX_CONFIG_ALT0, PAD_CTL_HYS_NONE,
	},
	{
		MX51_PIN_CSI2_D17, IOMUX_CONFIG_ALT0, PAD_CTL_HYS_NONE,
	},
	{
		MX51_PIN_CSI2_D18, IOMUX_CONFIG_ALT0, PAD_CTL_HYS_NONE,
	},
	{
		MX51_PIN_CSI2_D19, IOMUX_CONFIG_ALT0, PAD_CTL_HYS_NONE,
	},
	{
		MX51_PIN_CSI2_VSYNC, IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION,
		(PAD_CTL_HYS_NONE | PAD_CTL_SRE_SLOW),
	},
	{
		MX51_PIN_CSI2_HSYNC, IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION,
		(PAD_CTL_HYS_NONE | PAD_CTL_SRE_SLOW),
	},
	{
		MX51_PIN_CSI2_PIXCLK, IOMUX_CONFIG_ALT0,
		(PAD_CTL_HYS_NONE | PAD_CTL_SRE_SLOW),
	},
	/* Configure GPIO3_7 as RESET for camera 2 */
	{
		MX51_PIN_DISPB2_SER_CLK, IOMUX_CONFIG_ALT4,
		(PAD_CTL_HYS_NONE | PAD_CTL_DRV_MEDIUM | PAD_CTL_SRE_FAST | IOMUX_CONFIG_SION),
		MUX_IN_GPIO3_IPP_IND_G_IN_7_SELECT_INPUT,
		INPUT_CTL_PATH1
	 },
};
#endif /* #if defined CONFIG_VIDEO_MXC_IPU_CAMERA */

#if defined(CONFIG_SPI_MXC) || defined(CONFIG_SPI_MXC_MODULE)
static struct mxc_iomux_pin_cfg __initdata ccwmx51_cspi_pins[] = {
#ifdef CONFIG_SPI_MXC_SELECT1
	/* ECSPI1 */
	{	/* MISO */
		MX51_PIN_CSPI1_MISO, IOMUX_CONFIG_ALT0,
		(PAD_CTL_HYS_NONE | PAD_CTL_ODE_OPENDRAIN_NONE | PAD_CTL_PUE_KEEPER | PAD_CTL_DRV_HIGH |
		PAD_CTL_SRE_FAST),
	},
	{	/* MOSI */
		MX51_PIN_CSPI1_MOSI, IOMUX_CONFIG_ALT0,
		(PAD_CTL_HYS_NONE | PAD_CTL_ODE_OPENDRAIN_NONE | PAD_CTL_PUE_KEEPER | PAD_CTL_DRV_HIGH |
		PAD_CTL_SRE_FAST),
	},
	{	/* SCLK */
		MX51_PIN_CSPI1_SCLK, IOMUX_CONFIG_ALT0,
		(PAD_CTL_HYS_NONE | PAD_CTL_ODE_OPENDRAIN_NONE | PAD_CTL_PUE_KEEPER | PAD_CTL_DRV_HIGH |
		PAD_CTL_SRE_FAST),
	},
	{	/* SS0 */
		MX51_PIN_CSPI1_SS0, IOMUX_CONFIG_GPIO,
		(PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH | PAD_CTL_47K_PU |
		PAD_CTL_PUE_KEEPER | PAD_CTL_PKE_ENABLE),
	},

#if defined(CONFIG_JSCCWMX51_V1)
	{	/* TS CS for LCD1 on CCWMX51 EAK */
		MX51_PIN_DI1_D1_CS, IOMUX_CONFIG_ALT4,
		(PAD_CTL_SRE_SLOW | PAD_CTL_DRV_MEDIUM | PAD_CTL_ODE_OPENDRAIN_NONE |
		PAD_CTL_PUE_KEEPER | PAD_CTL_HYS_NONE),
		MUX_IN_GPIO3_IPP_IND_G_IN_4_SELECT_INPUT,INPUT_CTL_PATH1
	},
	{	/* TS CS for LCD2 on CCWMX51 EAK */
		MX51_PIN_CSPI1_RDY, IOMUX_CONFIG_ALT3,
		(PAD_CTL_SRE_SLOW | PAD_CTL_DRV_MEDIUM | PAD_CTL_ODE_OPENDRAIN_NONE |
		PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_NONE),
		MUX_IN_AUDMUX_P4_INPUT_TXFS_AMX_SELECT_INPUT,INPUT_CTL_PATH1
	},
#else
	{	/* TS CS for LCD1 and  LCD2 on CCWMX51 JSK */
		MX51_PIN_CSPI1_RDY, IOMUX_CONFIG_ALT3,
		(PAD_CTL_SRE_SLOW | PAD_CTL_DRV_MEDIUM | PAD_CTL_ODE_OPENDRAIN_NONE |
		PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_NONE),
		MUX_IN_AUDMUX_P4_INPUT_TXFS_AMX_SELECT_INPUT,INPUT_CTL_PATH1
	},
#endif

#ifdef CONFIG_SPI_MXC_SELECT1_SS1
	{	/* SS1 */
		MX51_PIN_CSPI1_SS1, IOMUX_CONFIG_GPIO,
		(PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH | PAD_CTL_47K_PU |
		PAD_CTL_PUE_KEEPER | PAD_CTL_PKE_ENABLE),
	},
#endif
#endif
#if defined(CONFIG_SPI_MXC_SELECT2) && (!defined(CONFIG_PATA_FSL) && !defined(CONFIG_PATA_FSL_MODULE))
	/* ECSPI2 */
	{	/* SCLK */
		MX51_PIN_NANDF_RB2, IOMUX_CONFIG_ALT2,
		(PAD_CTL_SRE_SLOW | PAD_CTL_ODE_OPENDRAIN_NONE | PAD_CTL_DRV_LOW |
		PAD_CTL_PUE_KEEPER | PAD_CTL_HYS_ENABLE),
	},
	{	/* MISO */
		MX51_PIN_NANDF_RB3, IOMUX_CONFIG_ALT2,
		(PAD_CTL_SRE_SLOW | PAD_CTL_ODE_OPENDRAIN_NONE | PAD_CTL_DRV_HIGH |
		PAD_CTL_PUE_KEEPER | PAD_CTL_HYS_ENABLE),
	},
	{	/* MOSI */
		MX51_PIN_NANDF_D15, IOMUX_CONFIG_ALT2,
		(PAD_CTL_SRE_SLOW | PAD_CTL_ODE_OPENDRAIN_NONE | PAD_CTL_DRV_HIGH |
		PAD_CTL_PUE_KEEPER | PAD_CTL_HYS_ENABLE),
	},
	{	/* SS0 */
		MX51_PIN_NANDF_RDY_INT, IOMUX_CONFIG_ALT2,
		(PAD_CTL_SRE_SLOW | PAD_CTL_ODE_OPENDRAIN_NONE | PAD_CTL_DRV_LOW |
		PAD_CTL_PUE_KEEPER | PAD_CTL_HYS_ENABLE),
	},
	{	/* SI_VER_TO2, SS1 */
		MX51_PIN_NANDF_D12, IOMUX_CONFIG_ALT2,
		(PAD_CTL_SRE_SLOW | PAD_CTL_ODE_OPENDRAIN_NONE | PAD_CTL_DRV_HIGH |
		PAD_CTL_PUE_KEEPER | PAD_CTL_HYS_ENABLE),
	},
	{	/* SI_VER_TO2, RDY */
		MX51_PIN_NANDF_RB1, IOMUX_CONFIG_ALT2,
		(PAD_CTL_SRE_SLOW | PAD_CTL_ODE_OPENDRAIN_NONE | PAD_CTL_DRV_LOW |
		PAD_CTL_PUE_KEEPER | PAD_CTL_HYS_ENABLE),
	},
#endif
#ifdef CONFIG_SPI_MXC_SELECT3
	/* ECSPI3 */
	{
		MX51_PIN_USBH1_CLK, IOMUX_CONFIG_ALT2,
		(PAD_CTL_ODE_OPENDRAIN_NONE | PAD_CTL_HYS_ENABLE | PAD_CTL_100K_PU |
		 PAD_CTL_DRV_MEDIUM | PAD_CTL_HYS_ENABLE | PAD_CTL_SRE_SLOW),
	},
	{
		MX51_PIN_USBH1_DATA4, IOMUX_CONFIG_ALT2,
		(PAD_CTL_ODE_OPENDRAIN_NONE | PAD_CTL_HYS_ENABLE | PAD_CTL_PUE_KEEPER |
		PAD_CTL_DRV_MEDIUM | PAD_CTL_HYS_ENABLE | PAD_CTL_SRE_SLOW),
	},
	{
		MX51_PIN_USBH1_DATA5, IOMUX_CONFIG_ALT2,
		(PAD_CTL_ODE_OPENDRAIN_NONE | PAD_CTL_HYS_ENABLE | PAD_CTL_PUE_KEEPER |
		PAD_CTL_DRV_MEDIUM | PAD_CTL_HYS_ENABLE | PAD_CTL_SRE_SLOW),
	},
	{
		MX51_PIN_USBH1_NXT, IOMUX_CONFIG_ALT2,
		(PAD_CTL_ODE_OPENDRAIN_NONE | PAD_CTL_HYS_ENABLE | PAD_CTL_PUE_KEEPER |
		PAD_CTL_DRV_MEDIUM | PAD_CTL_HYS_ENABLE | PAD_CTL_SRE_SLOW),
	},
	{
		MX51_PIN_USBH1_DIR, IOMUX_CONFIG_ALT2,
		(PAD_CTL_ODE_OPENDRAIN_NONE | PAD_CTL_HYS_ENABLE | PAD_CTL_100K_PU |
		PAD_CTL_DRV_MEDIUM | PAD_CTL_HYS_ENABLE | PAD_CTL_SRE_SLOW),
	},
	{
		MX51_PIN_USBH1_STP, IOMUX_CONFIG_ALT2,
		(PAD_CTL_ODE_OPENDRAIN_NONE | PAD_CTL_HYS_ENABLE | PAD_CTL_PUE_KEEPER |
		PAD_CTL_DRV_MEDIUM | PAD_CTL_HYS_ENABLE | PAD_CTL_SRE_SLOW),
	},
#endif
};

/* workaround for ecspi chipselect pin may not keep correct level when idle */
void ccwmx51_gpio_spi_chipselect_active(int busnum, int ssb_pol, int chipselect)
{
	u8 mask = 0x1 << (chipselect - 1);

	/* Deassert/Assert the different CS lines for the different buses */
	switch (busnum) {
	case 1:
		switch (chipselect) {
		case 0x1:
			gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_CSPI1_SS1),
				       (ssb_pol & mask) ?  0 : 1);
#ifdef CONFIG_CCWMX51_SECOND_TOUCH
			gpio_set_value(IOMUX_TO_GPIO(SECOND_TS_SPI_SS_PIN), 1);
#endif
			gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_CSPI1_SS0),
				       (ssb_pol & mask) ?  1 : 0);
			break;
		case 0x2:
			gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_CSPI1_SS0),
				       (ssb_pol & mask) ?  0 : 1);
#ifdef CONFIG_CCWMX51_SECOND_TOUCH
			gpio_set_value(IOMUX_TO_GPIO(SECOND_TS_SPI_SS_PIN), 1);
#endif
			gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_CSPI1_SS1),
				       (ssb_pol & mask) ?  1 : 0);
			break;
#ifdef CONFIG_CCWMX51_SECOND_TOUCH
		case 0x4:
			gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_CSPI1_SS0),
				       (ssb_pol & mask) ?  0 : 1);
			gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_CSPI1_SS1),
				       (ssb_pol & mask) ?  0 : 1);
			gpio_set_value(IOMUX_TO_GPIO(SECOND_TS_SPI_SS_PIN), 0);
			break;
#endif
		default:
			break;
		}
		break;
	case 2:
	case 3:
	default:
		break;
	}
}
EXPORT_SYMBOL(ccwmx51_gpio_spi_chipselect_active);

void ccwmx51_gpio_spi_chipselect_inactive(int busnum, int ssb_pol,
					  int chipselect)
{
	u8 mask = 0x1 << (chipselect - 1);

	switch (busnum) {
	case 1:
		switch (chipselect) {
		case 0x1:
			gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_CSPI1_SS0),
				       (ssb_pol & mask) ?  0 : 1);
			break;
		case 0x2:
			gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_CSPI1_SS1),
				       (ssb_pol & mask) ?  0 : 1);
			break;
#ifdef CONFIG_CCWMX51_SECOND_TOUCH
		case 0x4:
			gpio_set_value(IOMUX_TO_GPIO(SECOND_TS_SPI_SS_PIN), 1);
			break;
#endif
		default:
			break;
		}
		break;
	case 2:
	case 3:
	default:
		break;
        }
}
EXPORT_SYMBOL(ccwmx51_gpio_spi_chipselect_inactive);
#endif /* defined(CONFIG_SPI_MXC) || defined(CONFIG_SPI_MXC_MODULE) */

#if defined(CONFIG_PATA_FSL) || defined(CONFIG_PATA_FSL_MODULE)
static struct mxc_iomux_pin_cfg ata_iomux_pins[] = {
        {
                MX51_PIN_NANDF_ALE, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_CS2, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_CS3, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_CS4, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_CS5, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_CS6, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_RE_B, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_WE_B, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_CLE, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_RB0, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_WP_B, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_GPIO_NAND, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_RB1, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_D0, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_D1, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_D2, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_D3, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_D4, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_D5, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_D6, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_D7, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_D8, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_D9, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_D10, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_D11, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_D12, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_D13, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_D14, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
        {
                MX51_PIN_NANDF_D15, IOMUX_CONFIG_ALT1,
                (PAD_CTL_DRV_HIGH | PAD_CTL_DRV_VOT_HIGH),
        },
};

void gpio_ata_active(void)
{
	int i;

	for (i = 0; i < ARRAY_SIZE(ata_iomux_pins); i++) {
		mxc_request_iomux(ata_iomux_pins[i].pin,
				  ata_iomux_pins[i].mux_mode);
		if (ata_iomux_pins[i].pad_cfg)
			mxc_iomux_set_pad(ata_iomux_pins[i].pin,
					  ata_iomux_pins[i].pad_cfg);
		if (ata_iomux_pins[i].in_select)
			mxc_iomux_set_input(ata_iomux_pins[i].in_select,
					    ata_iomux_pins[i].in_mode);
	}
}
EXPORT_SYMBOL(gpio_ata_active);
void gpio_ata_inactive(void) {}
EXPORT_SYMBOL(gpio_ata_inactive);
#endif /* CONFIG_PATA_FSL || CONFIG_PATA_FSL_MODULE */

void __init ccwmx51_io_init(void)
{
        int i;

#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
        for (i = 0; i < ARRAY_SIZE(ccwmx51_iomux_ext_eth_pins); i++) {
                mxc_request_iomux(ccwmx51_iomux_ext_eth_pins[i].pin,
                                ccwmx51_iomux_ext_eth_pins[i].mux_mode);
		if (ccwmx51_iomux_ext_eth_pins[i].pad_cfg)
			mxc_iomux_set_pad(ccwmx51_iomux_ext_eth_pins[i].pin,
					ccwmx51_iomux_ext_eth_pins[i].pad_cfg);
		if (ccwmx51_iomux_ext_eth_pins[i].in_select)
			mxc_iomux_set_input(ccwmx51_iomux_ext_eth_pins[i].in_select,
					ccwmx51_iomux_ext_eth_pins[i].in_mode);
	}
#endif

#if defined CONFIG_VIDEO_MXC_IPU_CAMERA
	for (i = 0; i < ARRAY_SIZE(ccwmx51_camera_pins); i++) {
		mxc_request_iomux(ccwmx51_camera_pins[i].pin,
				ccwmx51_camera_pins[i].mux_mode);
		if (ccwmx51_camera_pins[i].pad_cfg)
			mxc_iomux_set_pad(ccwmx51_camera_pins[i].pin,
					ccwmx51_camera_pins[i].pad_cfg);
		if (ccwmx51_camera_pins[i].in_select)
			mxc_iomux_set_input(ccwmx51_camera_pins[i].in_select,
					ccwmx51_camera_pins[i].in_mode);
	}

	/* Configure non muxed pins */
	mxc_iomux_set_pad(MX51_PIN_CSI1_PIXCLK,PAD_CTL_HYS_NONE | PAD_CTL_SRE_SLOW);
	mxc_iomux_set_pad(MX51_PIN_CSI2_PIXCLK,PAD_CTL_HYS_NONE | PAD_CTL_SRE_SLOW);
	mxc_iomux_set_pad(MX51_PIN_CSI1_MCLK,PAD_CTL_DRV_HIGH | PAD_CTL_SRE_SLOW);

	/* Camera 1 reset */
	gpio_request(IOMUX_TO_GPIO(MX51_PIN_CSI1_D9), "gpio3_13");
	gpio_direction_output(IOMUX_TO_GPIO(MX51_PIN_CSI1_D9), 0);
	// Take camera out of reset
	gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_CSI1_D9), 0);
	msleep(100);
	gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_CSI1_D9), 1);
	msleep(100);

	/* Camera 2 reset */
	gpio_request(IOMUX_TO_GPIO(MX51_PIN_DISPB2_SER_CLK), "gpio3_7");
	gpio_direction_output(IOMUX_TO_GPIO(MX51_PIN_DISPB2_SER_CLK), 0);
	// Take camera out of reset
	gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_DISPB2_SER_CLK), 0);
	msleep(100);
	gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_DISPB2_SER_CLK), 1);
	msleep(100);
#endif

#if defined(CONFIG_USB_EHCI_ARC_H1) || defined(CONFIG_USB_EHCI_ARC_H1_MODULE)
	for (i = 0; i < ARRAY_SIZE(ccwmx51_iomux_usbh1_pins); i++) {
		mxc_request_iomux(ccwmx51_iomux_usbh1_pins[i].pin,
				  ccwmx51_iomux_usbh1_pins[i].mux_mode);
		if (ccwmx51_iomux_usbh1_pins[i].pad_cfg)
			mxc_iomux_set_pad(ccwmx51_iomux_usbh1_pins[i].pin,
					  ccwmx51_iomux_usbh1_pins[i].pad_cfg);
		if (ccwmx51_iomux_usbh1_pins[i].in_select)
			mxc_iomux_set_input(ccwmx51_iomux_usbh1_pins[i].in_select,
					    ccwmx51_iomux_usbh1_pins[i].in_mode);
	}
#endif

#if defined(CONFIG_I2C_MXC) || defined(CONFIG_I2C_MXC_MODULE)
        for (i = 0; i < ARRAY_SIZE(ccwmx51_iomux_i2c_pins); i++) {
                mxc_request_iomux(ccwmx51_iomux_i2c_pins[i].pin,
				ccwmx51_iomux_i2c_pins[i].mux_mode);
		if (ccwmx51_iomux_i2c_pins[i].pad_cfg)
			mxc_iomux_set_pad(ccwmx51_iomux_i2c_pins[i].pin,
					ccwmx51_iomux_i2c_pins[i].pad_cfg);
		if (ccwmx51_iomux_i2c_pins[i].in_select)
			mxc_iomux_set_input(ccwmx51_iomux_i2c_pins[i].in_select,
					ccwmx51_iomux_i2c_pins[i].in_mode);
	}
#endif

#if defined(CONFIG_SND_SOC_WM8753) || defined(CONFIG_SND_SOC_WM8753_MODULE)
	for (i = 0; i < ARRAY_SIZE(ccwmx51_audio_pins); i++) {
		mxc_request_iomux(ccwmx51_audio_pins[i].pin,
				  ccwmx51_audio_pins[i].mux_mode);
		if (ccwmx51_audio_pins[i].pad_cfg)
			mxc_iomux_set_pad(ccwmx51_audio_pins[i].pin,
					  ccwmx51_audio_pins[i].pad_cfg);
		if (ccwmx51_audio_pins[i].in_select)
			mxc_iomux_set_input(ccwmx51_audio_pins[i].in_select,
					    ccwmx51_audio_pins[i].in_mode);
	}
#endif

#if defined(CONFIG_SPI_MXC) || defined(CONFIG_SPI_MXC_MODULE)
	for (i = 0; i < ARRAY_SIZE(ccwmx51_cspi_pins); i++) {
		mxc_request_iomux(ccwmx51_cspi_pins[i].pin,
				  ccwmx51_cspi_pins[i].mux_mode);
		if (ccwmx51_cspi_pins[i].pad_cfg)
			mxc_iomux_set_pad(ccwmx51_cspi_pins[i].pin,
					  ccwmx51_cspi_pins[i].pad_cfg);
		if (ccwmx51_cspi_pins[i].in_select)
			mxc_iomux_set_input(ccwmx51_cspi_pins[i].in_select,
					    ccwmx51_cspi_pins[i].in_mode);
	}
#ifdef CONFIG_SPI_MXC_SELECT1
	gpio_request(IOMUX_TO_GPIO(MX51_PIN_CSPI1_SS0), "cspi1_ss0");
	gpio_direction_output(IOMUX_TO_GPIO(MX51_PIN_CSPI1_SS0), 0);
	gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_CSPI1_SS0), 0);
#ifdef CONFIG_SPI_MXC_SELECT1_SS1
	gpio_request(IOMUX_TO_GPIO(MX51_PIN_CSPI1_SS1), "cspi1_ss1");
	gpio_direction_output(IOMUX_TO_GPIO(MX51_PIN_CSPI1_SS1), 0);
	gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_CSPI1_SS1), 0);
#endif
#endif

#ifndef CONFIG_SPI_MXC_SELECT2
        /* Configure as GPIO to be used to read LED status */
        mxc_config_iomux(MX51_PIN_NANDF_RB2,IOMUX_CONFIG_ALT3 | IOMUX_CONFIG_SION);
        mxc_iomux_set_pad(MX51_PIN_NANDF_RB2,PAD_CTL_HYS_ENABLE | PAD_CTL_100K_PU);
#if !defined(CONFIG_PATA_FSL) && !defined(CONFIG_PATA_FSL_MODULE)
        mxc_config_iomux(MX51_PIN_NANDF_RB1,IOMUX_CONFIG_ALT3 | IOMUX_CONFIG_SION);
        mxc_iomux_set_pad(MX51_PIN_NANDF_RB1,PAD_CTL_HYS_ENABLE | PAD_CTL_100K_PU);
#endif /* !defined(CONFIG_PATA_FSL) && !defined(CONFIG_PATA_FSL_MODULE) */
#endif

#endif

        for (i = 0; i < ARRAY_SIZE(ccwmx51_iomux_devices_pins); i++) {
		mxc_request_iomux(ccwmx51_iomux_devices_pins[i].pin,
				  ccwmx51_iomux_devices_pins[i].mux_mode);
		if (ccwmx51_iomux_devices_pins[i].pad_cfg)
			mxc_iomux_set_pad(ccwmx51_iomux_devices_pins[i].pin,
					  ccwmx51_iomux_devices_pins[i].pad_cfg);
		if (ccwmx51_iomux_devices_pins[i].in_select)
			mxc_iomux_set_input(ccwmx51_iomux_devices_pins[i].in_select,
					    ccwmx51_iomux_devices_pins[i].in_mode);
	}

	/* PMIC interrupt line */
	gpio_request(IOMUX_TO_GPIO(MX51_PIN_GPIO1_5), "gpio1_5");
	gpio_direction_input(IOMUX_TO_GPIO(MX51_PIN_GPIO1_5));

#if defined(CONFIG_USB_EHCI_ARC_H1) || defined(CONFIG_USB_EHCI_ARC_H1_MODULE)
	/* USB PHY/HUB reset*/
	gpio_request(IOMUX_TO_GPIO(MX51_PIN_DISPB2_SER_RS), "gpio3_8");
	gpio_direction_output(IOMUX_TO_GPIO(MX51_PIN_DISPB2_SER_RS), 0);
	msleep(1);
	gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_DISPB2_SER_RS), 1);
#endif

	/* Configure user key 1 as GPIO */
#if defined(CONFIG_JSCCWMX51_V2)
	mxc_config_iomux(MX51_PIN_DISPB2_SER_DIO,IOMUX_CONFIG_ALT4 | IOMUX_CONFIG_SION);
	mxc_iomux_set_input(MUX_IN_GPIO3_IPP_IND_G_IN_6_SELECT_INPUT,INPUT_CTL_PATH1);
#endif

	/* Configure Digital IO as GPIO */
#if defined(CONFIG_JSCCWMX51_V1)
#if !defined(CONFIG_PATA_FSL) && !defined(CONFIG_PATA_FSL_MODULE)
	mxc_config_iomux(MX51_PIN_NANDF_CS4,IOMUX_CONFIG_ALT3 | IOMUX_CONFIG_SION);
	mxc_config_iomux(MX51_PIN_NANDF_CS5,IOMUX_CONFIG_ALT3 | IOMUX_CONFIG_SION);
	mxc_config_iomux(MX51_PIN_NANDF_CS6,IOMUX_CONFIG_ALT3 | IOMUX_CONFIG_SION);
#endif
#if !defined(CONFIG_MMC_IMX_ESDHCI) && !defined(CONFIG_MMC_IMX_ESDHCI_MODULE)
	mxc_config_iomux(MX51_PIN_NANDF_CS7,IOMUX_CONFIG_ALT3 | IOMUX_CONFIG_SION);
#endif

	mxc_config_iomux(MX51_PIN_DISPB2_SER_DIN,IOMUX_CONFIG_ALT4 | IOMUX_CONFIG_SION);
	mxc_iomux_set_input(MUX_IN_GPIO3_IPP_IND_G_IN_5_SELECT_INPUT,INPUT_CTL_PATH1);
	mxc_config_iomux(MX51_PIN_DISPB2_SER_DIO,IOMUX_CONFIG_ALT4 | IOMUX_CONFIG_SION);
	mxc_iomux_set_input(MUX_IN_GPIO3_IPP_IND_G_IN_6_SELECT_INPUT,INPUT_CTL_PATH1);
#if !defined (CONFIG_VIDEO_MXC_IPU_CAMERA)
	mxc_config_iomux(MX51_PIN_DISPB2_SER_CLK,IOMUX_CONFIG_ALT4 | IOMUX_CONFIG_SION);
	mxc_iomux_set_input(MUX_IN_GPIO3_IPP_IND_G_IN_7_SELECT_INPUT,INPUT_CTL_PATH1);
#endif
#if !defined(CONFIG_USB_EHCI_ARC_H1) && !defined(CONFIG_USB_EHCI_ARC_H1_MODULE)
	mxc_config_iomux(MX51_PIN_DISPB2_SER_RS,IOMUX_CONFIG_ALT4 | IOMUX_CONFIG_SION);
	mxc_iomux_set_input(MUX_IN_GPIO3_IPP_IND_G_IN_8_SELECT_INPUT,INPUT_CTL_PATH1);
#endif
#endif

#if defined(CONFIG_JSCCWMX51_V2)
#if !defined (CONFIG_SPI_MXC_SELECT2)
	mxc_config_iomux(MX51_PIN_NANDF_RB3,IOMUX_CONFIG_ALT3 | IOMUX_CONFIG_SION);
#endif

#if !defined(CONFIG_PATA_FSL) && !defined(CONFIG_PATA_FSL_MODULE)
	mxc_config_iomux(MX51_PIN_NANDF_CS2,IOMUX_CONFIG_ALT3 | IOMUX_CONFIG_SION);
	mxc_config_iomux(MX51_PIN_NANDF_CS4,IOMUX_CONFIG_ALT3 | IOMUX_CONFIG_SION);
	mxc_config_iomux(MX51_PIN_NANDF_CS5,IOMUX_CONFIG_ALT3 | IOMUX_CONFIG_SION);
	mxc_config_iomux(MX51_PIN_NANDF_CS6,IOMUX_CONFIG_ALT3 | IOMUX_CONFIG_SION);
#endif

#if !defined(CONFIG_SPI_MXC_SELECT2) || (!defined(CONFIG_PATA_FSL) && !defined(CONFIG_PATA_FSL_MODULE))
	mxc_config_iomux(MX51_PIN_NANDF_RB1,IOMUX_CONFIG_ALT3 | IOMUX_CONFIG_SION);
	mxc_config_iomux(MX51_PIN_NANDF_RB2,IOMUX_CONFIG_ALT3 | IOMUX_CONFIG_SION);
#endif
	mxc_config_iomux(MX51_PIN_DISPB2_SER_DIO,IOMUX_CONFIG_ALT4 | IOMUX_CONFIG_SION);
	mxc_iomux_set_input(MUX_IN_GPIO3_IPP_IND_G_IN_6_SELECT_INPUT,INPUT_CTL_PATH1);
#endif

}

#ifdef CONFIG_CCWMX51_SECOND_TOUCH
void ccwmx51_2nd_touch_gpio_init(void)
{
	/* Second touch interface interrupt line */
	mxc_request_iomux(SECOND_TS_IRQ_PIN, IOMUX_CONFIG_GPIO);
	mxc_iomux_set_pad(SECOND_TS_IRQ_PIN, PAD_CTL_SRE_FAST | PAD_CTL_HYS_ENABLE);
	mxc_iomux_set_input(MUX_IN_GPIO3_IPP_IND_G_IN_3_SELECT_INPUT, INPUT_CTL_PATH1);

	/* SECOND_TS_SPI_SS_PIN depends on configuration, check board-ccwmx51 to see options */
	mxc_request_iomux(SECOND_TS_SPI_SS_PIN, IOMUX_CONFIG_GPIO);
	mxc_iomux_set_pad(SECOND_TS_SPI_SS_PIN, PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH |
			  PAD_CTL_47K_PU | PAD_CTL_PUE_KEEPER | PAD_CTL_PKE_ENABLE);

	/* Configure the Slave Select signal as gpio, to workaround a silicon errata */
	gpio_request(IOMUX_TO_GPIO(SECOND_TS_SPI_SS_PIN), "ts2_spi_ss");
	gpio_direction_output(IOMUX_TO_GPIO(SECOND_TS_SPI_SS_PIN), 1);
	gpio_set_value(IOMUX_TO_GPIO(SECOND_TS_SPI_SS_PIN), 1);

	/* Configure 2nd touch interrupt line */
	gpio_request(IOMUX_TO_GPIO(SECOND_TS_IRQ_PIN), "ts2_irq");
	gpio_direction_input(IOMUX_TO_GPIO(SECOND_TS_IRQ_PIN));

	/**
	 * Configure gpio line to detect which touch is connected to each
	 * display interface
	 */
	mxc_config_iomux(MX51_PIN_DI1_D1_CS, IOMUX_CONFIG_GPIO);
	mxc_iomux_set_pad(MX51_PIN_DI1_D1_CS, PAD_CTL_SRE_FAST | PAD_CTL_HYS_ENABLE);
	mxc_iomux_set_input(MUX_IN_GPIO3_IPP_IND_G_IN_4_SELECT_INPUT, INPUT_CTL_PATH1);
}
#else
void ccwmx51_2nd_touch_gpio_init(void) {}
#endif

#if defined(CONFIG_SERIAL_MXC) || defined(CONFIG_SERIAL_MXC_MODULE)
#define SERIAL_PORT_PAD		(PAD_CTL_HYS_ENABLE | PAD_CTL_PKE_ENABLE | \
				 PAD_CTL_PUE_PULL | PAD_CTL_DRV_HIGH | \
				 PAD_CTL_SRE_FAST)

void gpio_uart_active(int port, int no_irda)
{
	/* Configure the IOMUX control registers for the UART signals */
	switch (port) {

	case 0:		/* UART 1 IOMUX Configs */
#ifdef CONFIG_UART1_ENABLED
		mxc_request_iomux(MX51_PIN_UART1_RXD, IOMUX_CONFIG_ALT0);
		mxc_request_iomux(MX51_PIN_UART1_TXD, IOMUX_CONFIG_ALT0);
		mxc_iomux_set_pad(MX51_PIN_UART1_RXD, SERIAL_PORT_PAD);
		mxc_iomux_set_pad(MX51_PIN_UART1_TXD, SERIAL_PORT_PAD);
		mxc_iomux_set_input(MUX_IN_UART1_IPP_UART_RXD_MUX_SELECT_INPUT, INPUT_CTL_PATH0);

#if defined(CONFIG_UART1_CTS_RTS_ENABLED) || defined(CONFIG_UART1_FULL_UART_ENABLED)
		mxc_request_iomux(MX51_PIN_UART1_CTS, IOMUX_CONFIG_ALT0);
		mxc_request_iomux(MX51_PIN_UART1_RTS, IOMUX_CONFIG_ALT0);
		mxc_iomux_set_pad(MX51_PIN_UART1_CTS, SERIAL_PORT_PAD);
		mxc_iomux_set_pad(MX51_PIN_UART1_RTS, SERIAL_PORT_PAD);
		mxc_iomux_set_input(MUX_IN_UART1_IPP_UART_RTS_B_SELECT_INPUT, INPUT_CTL_PATH0);
#endif /* CONFIG_UART1_CTS_RTS_ENABLED */
#ifdef CONFIG_UART1_FULL_UART_ENABLED
		mxc_request_iomux(MX51_PIN_KEY_COL5, IOMUX_CONFIG_ALT1);	/* DCD */
		mxc_request_iomux(MX51_PIN_KEY_COL4, IOMUX_CONFIG_ALT1);	/* RI */
		mxc_request_iomux(MX51_PIN_UART3_TXD, IOMUX_CONFIG_ALT0);	/* DSR */
		mxc_request_iomux(MX51_PIN_UART3_RXD, IOMUX_CONFIG_ALT0);	/* DTR */
		mxc_iomux_set_pad(MX51_PIN_KEY_COL5, SERIAL_PORT_PAD);
		mxc_iomux_set_pad(MX51_PIN_KEY_COL4, SERIAL_PORT_PAD);
		mxc_iomux_set_pad(MX51_PIN_UART3_TXD, SERIAL_PORT_PAD);
		mxc_iomux_set_pad(MX51_PIN_UART3_RXD, SERIAL_PORT_PAD);
#endif /* CONFIG_UART1_FULL_UART_ENABLED */
#endif /* CONFIG_UART1_ENABLED */
		break;

	case 1:		/* UART 2 IOMUX Configs */
#ifdef CONFIG_UART2_ENABLED
		mxc_request_iomux(MX51_PIN_UART2_RXD, IOMUX_CONFIG_ALT0);
		mxc_request_iomux(MX51_PIN_UART2_TXD, IOMUX_CONFIG_ALT0);
		mxc_iomux_set_pad(MX51_PIN_UART2_RXD, SERIAL_PORT_PAD);
		mxc_iomux_set_pad(MX51_PIN_UART2_TXD, SERIAL_PORT_PAD);
		mxc_iomux_set_input(MUX_IN_UART2_IPP_UART_RXD_MUX_SELECT_INPUT, INPUT_CTL_PATH2);

#ifdef CONFIG_UART2_CTS_RTS_ENABLED
#if !defined(CONFIG_USB_EHCI_ARC_H1) && !defined(CONFIG_USB_EHCI_ARC_H1_MODULE)
		mxc_request_iomux(MX51_PIN_USBH1_DATA0, IOMUX_CONFIG_ALT1);	/* CTS */
		mxc_request_iomux(MX51_PIN_USBH1_DATA3, IOMUX_CONFIG_ALT1);	/* RTS */
		mxc_iomux_set_pad(MX51_PIN_USBH1_DATA0, SERIAL_PORT_PAD);
		mxc_iomux_set_pad(MX51_PIN_USBH1_DATA3, SERIAL_PORT_PAD);
		mxc_iomux_set_input(MUX_IN_UART2_IPP_UART_RTS_B_SELECT_INPUT, INPUT_CTL_PATH5);
#endif /* CONFIG_USB_EHCI_ARC_H1 && CONFIG_USB_EHCI_ARC_H1_MODULE */
#endif /* CONFIG_UART2_CTS_RTS_ENABLED */
#endif /* CONFIG_UART2_CTS_RTS_ENABLED */
		break;
	case 2:		/* UART 3 IOMUX Configs */
#ifdef CONFIG_UART3_ENABLED
		mxc_request_iomux(MX51_PIN_UART3_RXD, IOMUX_CONFIG_ALT1);
		mxc_request_iomux(MX51_PIN_UART3_TXD, IOMUX_CONFIG_ALT1);
		mxc_iomux_set_pad(MX51_PIN_UART3_RXD, SERIAL_PORT_PAD);
		mxc_iomux_set_pad(MX51_PIN_UART3_TXD, SERIAL_PORT_PAD);
		mxc_iomux_set_input(MUX_IN_UART3_IPP_UART_RXD_MUX_SELECT_INPUT, INPUT_CTL_PATH4);

#ifdef CONFIG_UART3_CTS_RTS_ENABLED
		mxc_request_iomux(MX51_PIN_KEY_COL5, IOMUX_CONFIG_ALT2);	/* CTS */
		mxc_request_iomux(MX51_PIN_KEY_COL4, IOMUX_CONFIG_ALT2);	/* RTS */
		mxc_iomux_set_pad(MX51_PIN_KEY_COL5, SERIAL_PORT_PAD);
		mxc_iomux_set_pad(MX51_PIN_KEY_COL4, SERIAL_PORT_PAD);
		mxc_iomux_set_input(MUX_IN_UART3_IPP_UART_RTS_B_SELECT_INPUT, INPUT_CTL_PATH4);
#endif /* CONFIG_UART3_CTS_RTS_ENABLED */
#endif /* CONFIG_UART3_ENABLED */
		break;
	default:
		break;
	}
}
#else
void gpio_uart_active(int port, int no_irda) {}
#endif
void gpio_uart_inactive(int port, int no_irda) {}
EXPORT_SYMBOL(gpio_uart_active);
EXPORT_SYMBOL(gpio_uart_inactive);

void gpio_video_active(int vif, u32 pad)
{
	int i;

#if defined(CONFIG_CCWMX51_DISP0)
	if (vif == 0) {
		for (i = 0; i < ARRAY_SIZE(ccwmx51_iomux_video1_pins); i++) {
			mxc_request_iomux(ccwmx51_iomux_video1_pins[i].pin,
					  ccwmx51_iomux_video1_pins[i].mux_mode);

			if (ccwmx51_iomux_video1_pins[i].in_select)
				mxc_iomux_set_input(ccwmx51_iomux_video1_pins[i].in_select,
						    ccwmx51_iomux_video1_pins[i].in_mode);
			if (!pad)
				mxc_iomux_set_pad(ccwmx51_iomux_video1_pins[i].pin,
						  ccwmx51_iomux_video1_pins[i].pad_cfg);
			else
	  			mxc_iomux_set_pad(ccwmx51_iomux_video1_pins[i].pin,
						  pad);
		}

		/* LCD1 Power Enable, as gpio */
		mxc_request_iomux(MX51_PIN_DI1_PIN11, IOMUX_CONFIG_GPIO);
    		mxc_iomux_set_pad(MX51_PIN_DI1_PIN11,
				  PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH | PAD_CTL_47K_PU |
				  PAD_CTL_PUE_KEEPER | PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE);

		gpio_request(IOMUX_TO_GPIO(MX51_PIN_DI1_PIN11), "gpio3_0");
		gpio_direction_output(IOMUX_TO_GPIO(MX51_PIN_DI1_PIN11), 0);
	}
#endif
#if defined(CONFIG_CCWMX51_DISP1)
	if (vif == 1) {
		for (i = 0; i < ARRAY_SIZE(ccwmx51_iomux_video2_pins); i++) {
			mxc_request_iomux(ccwmx51_iomux_video2_pins[i].pin,
					  ccwmx51_iomux_video2_pins[i].mux_mode);

			if (ccwmx51_iomux_video2_pins[i].in_select)
				mxc_iomux_set_input(ccwmx51_iomux_video2_pins[i].in_select,
						    ccwmx51_iomux_video2_pins[i].in_mode);
			if (!pad)
				mxc_iomux_set_pad(ccwmx51_iomux_video2_pins[i].pin,
						  ccwmx51_iomux_video2_pins[i].pad_cfg);
			else
	  			mxc_iomux_set_pad(ccwmx51_iomux_video2_pins[i].pin,
						  pad);
		}

		/* LCD2 Power Enable, as gpio */
#ifdef CONFIG_JSCCWMX51_V1
		mxc_request_iomux(MX51_PIN_DI2_PIN4, IOMUX_CONFIG_ALT0);
    		mxc_iomux_set_pad(MX51_PIN_DI2_PIN4, pad);
#else
		mxc_request_iomux(MX51_PIN_DI1_PIN12, IOMUX_CONFIG_GPIO);
    		mxc_iomux_set_pad(MX51_PIN_DI1_PIN12,
				  PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH | PAD_CTL_47K_PU |
				  PAD_CTL_PUE_KEEPER | PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE);

		gpio_request(IOMUX_TO_GPIO(MX51_PIN_DI1_PIN12), "gpio3_1");
		gpio_direction_output(IOMUX_TO_GPIO(MX51_PIN_DI1_PIN12), 0);
#endif
	}
#endif /* defined(CONFIG_CCWMX51_DISP1) */
}

void gpio_video_inactive(int vif, u32 pad)
{
}
EXPORT_SYMBOL(gpio_video_active);
EXPORT_SYMBOL(gpio_video_inactive);