]>
git.ipfire.org Git - people/ms/u-boot.git/blob - arch/arm/cpu/armv7/exynos/pinmux.c
b929486da9c2c99766084bf5440d19a81016a3a1
2 * Copyright (c) 2012 Samsung Electronics.
3 * Abhilash Kesavan <a.kesavan@samsung.com>
5 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/arch/gpio.h>
11 #include <asm/arch/pinmux.h>
12 #include <asm/arch/sromc.h>
14 static void exynos5_uart_config(int peripheral
)
20 start
= EXYNOS5_GPIO_A00
;
24 start
= EXYNOS5_GPIO_D00
;
28 start
= EXYNOS5_GPIO_A10
;
32 start
= EXYNOS5_GPIO_A14
;
36 debug("%s: invalid peripheral %d", __func__
, peripheral
);
39 for (i
= start
; i
< start
+ count
; i
++) {
40 gpio_set_pull(i
, S5P_GPIO_PULL_NONE
);
41 gpio_cfg_pin(i
, S5P_GPIO_FUNC(0x2));
45 static void exynos5420_uart_config(int peripheral
)
51 start
= EXYNOS5420_GPIO_A00
;
55 start
= EXYNOS5420_GPIO_A04
;
59 start
= EXYNOS5420_GPIO_A10
;
63 start
= EXYNOS5420_GPIO_A14
;
67 debug("%s: invalid peripheral %d", __func__
, peripheral
);
71 for (i
= start
; i
< start
+ count
; i
++) {
72 gpio_set_pull(i
, S5P_GPIO_PULL_NONE
);
73 gpio_cfg_pin(i
, S5P_GPIO_FUNC(0x2));
77 static int exynos5_mmc_config(int peripheral
, int flags
)
79 int i
, start
, start_ext
, gpio_func
= 0;
82 case PERIPH_ID_SDMMC0
:
83 start
= EXYNOS5_GPIO_C00
;
84 start_ext
= EXYNOS5_GPIO_C10
;
85 gpio_func
= S5P_GPIO_FUNC(0x2);
87 case PERIPH_ID_SDMMC1
:
88 start
= EXYNOS5_GPIO_C20
;
91 case PERIPH_ID_SDMMC2
:
92 start
= EXYNOS5_GPIO_C30
;
93 start_ext
= EXYNOS5_GPIO_C43
;
94 gpio_func
= S5P_GPIO_FUNC(0x3);
96 case PERIPH_ID_SDMMC3
:
97 start
= EXYNOS5_GPIO_C40
;
101 debug("%s: invalid peripheral %d", __func__
, peripheral
);
104 if ((flags
& PINMUX_FLAG_8BIT_MODE
) && !start_ext
) {
105 debug("SDMMC device %d does not support 8bit mode",
109 if (flags
& PINMUX_FLAG_8BIT_MODE
) {
110 for (i
= start_ext
; i
<= (start_ext
+ 3); i
++) {
111 gpio_cfg_pin(i
, gpio_func
);
112 gpio_set_pull(i
, S5P_GPIO_PULL_UP
);
113 gpio_set_drv(i
, S5P_GPIO_DRV_4X
);
116 for (i
= start
; i
< (start
+ 2); i
++) {
117 gpio_cfg_pin(i
, S5P_GPIO_FUNC(0x2));
118 gpio_set_pull(i
, S5P_GPIO_PULL_NONE
);
119 gpio_set_drv(i
, S5P_GPIO_DRV_4X
);
121 for (i
= (start
+ 3); i
<= (start
+ 6); i
++) {
122 gpio_cfg_pin(i
, S5P_GPIO_FUNC(0x2));
123 gpio_set_pull(i
, S5P_GPIO_PULL_UP
);
124 gpio_set_drv(i
, S5P_GPIO_DRV_4X
);
130 static int exynos5420_mmc_config(int peripheral
, int flags
)
132 int i
, start
= 0, start_ext
= 0;
134 switch (peripheral
) {
135 case PERIPH_ID_SDMMC0
:
136 start
= EXYNOS5420_GPIO_C00
;
137 start_ext
= EXYNOS5420_GPIO_C30
;
139 case PERIPH_ID_SDMMC1
:
140 start
= EXYNOS5420_GPIO_C10
;
141 start_ext
= EXYNOS5420_GPIO_D14
;
143 case PERIPH_ID_SDMMC2
:
144 start
= EXYNOS5420_GPIO_C20
;
149 debug("%s: invalid peripheral %d", __func__
, peripheral
);
153 if ((flags
& PINMUX_FLAG_8BIT_MODE
) && !start_ext
) {
154 debug("SDMMC device %d does not support 8bit mode",
159 if (flags
& PINMUX_FLAG_8BIT_MODE
) {
160 for (i
= start_ext
; i
<= (start_ext
+ 3); i
++) {
161 gpio_cfg_pin(i
, S5P_GPIO_FUNC(0x2));
162 gpio_set_pull(i
, S5P_GPIO_PULL_UP
);
163 gpio_set_drv(i
, S5P_GPIO_DRV_4X
);
167 for (i
= start
; i
< (start
+ 3); i
++) {
169 * MMC0 is intended to be used for eMMC. The
170 * card detect pin is used as a VDDEN signal to
171 * power on the eMMC. The 5420 iROM makes
172 * this same assumption.
174 if ((peripheral
== PERIPH_ID_SDMMC0
) && (i
== (start
+ 2))) {
175 gpio_set_value(i
, 1);
176 gpio_cfg_pin(i
, S5P_GPIO_OUTPUT
);
178 gpio_cfg_pin(i
, S5P_GPIO_FUNC(0x2));
180 gpio_set_pull(i
, S5P_GPIO_PULL_NONE
);
181 gpio_set_drv(i
, S5P_GPIO_DRV_4X
);
184 for (i
= (start
+ 3); i
<= (start
+ 6); i
++) {
185 gpio_cfg_pin(i
, S5P_GPIO_FUNC(0x2));
186 gpio_set_pull(i
, S5P_GPIO_PULL_UP
);
187 gpio_set_drv(i
, S5P_GPIO_DRV_4X
);
193 static void exynos5_sromc_config(int flags
)
200 * GPY0[0] SROM_CSn[0]
201 * GPY0[1] SROM_CSn[1](2)
202 * GPY0[2] SROM_CSn[2]
203 * GPY0[3] SROM_CSn[3]
207 * GPY1[0] EBI_BEn[0](2)
208 * GPY1[1] EBI_BEn[1](2)
209 * GPY1[2] SROM_WAIT(2)
210 * GPY1[3] EBI_DATA_RDn(2)
212 gpio_cfg_pin(EXYNOS5_GPIO_Y00
+ (flags
& PINMUX_FLAG_BANK
),
214 gpio_cfg_pin(EXYNOS5_GPIO_Y04
, S5P_GPIO_FUNC(2));
215 gpio_cfg_pin(EXYNOS5_GPIO_Y05
, S5P_GPIO_FUNC(2));
217 for (i
= 0; i
< 4; i
++)
218 gpio_cfg_pin(EXYNOS5_GPIO_Y10
+ i
, S5P_GPIO_FUNC(2));
221 * EBI: 8 Addrss Lines
223 * GPY3[0] EBI_ADDR[0](2)
224 * GPY3[1] EBI_ADDR[1](2)
225 * GPY3[2] EBI_ADDR[2](2)
226 * GPY3[3] EBI_ADDR[3](2)
227 * GPY3[4] EBI_ADDR[4](2)
228 * GPY3[5] EBI_ADDR[5](2)
229 * GPY3[6] EBI_ADDR[6](2)
230 * GPY3[7] EBI_ADDR[7](2)
234 * GPY5[0] EBI_DATA[0](2)
235 * GPY5[1] EBI_DATA[1](2)
236 * GPY5[2] EBI_DATA[2](2)
237 * GPY5[3] EBI_DATA[3](2)
238 * GPY5[4] EBI_DATA[4](2)
239 * GPY5[5] EBI_DATA[5](2)
240 * GPY5[6] EBI_DATA[6](2)
241 * GPY5[7] EBI_DATA[7](2)
243 * GPY6[0] EBI_DATA[8](2)
244 * GPY6[1] EBI_DATA[9](2)
245 * GPY6[2] EBI_DATA[10](2)
246 * GPY6[3] EBI_DATA[11](2)
247 * GPY6[4] EBI_DATA[12](2)
248 * GPY6[5] EBI_DATA[13](2)
249 * GPY6[6] EBI_DATA[14](2)
250 * GPY6[7] EBI_DATA[15](2)
252 for (i
= 0; i
< 8; i
++) {
253 gpio_cfg_pin(EXYNOS5_GPIO_Y30
+ i
, S5P_GPIO_FUNC(2));
254 gpio_set_pull(EXYNOS5_GPIO_Y30
+ i
, S5P_GPIO_PULL_UP
);
256 gpio_cfg_pin(EXYNOS5_GPIO_Y50
+ i
, S5P_GPIO_FUNC(2));
257 gpio_set_pull(EXYNOS5_GPIO_Y50
+ i
, S5P_GPIO_PULL_UP
);
259 gpio_cfg_pin(EXYNOS5_GPIO_Y60
+ i
, S5P_GPIO_FUNC(2));
260 gpio_set_pull(EXYNOS5_GPIO_Y60
+ i
, S5P_GPIO_PULL_UP
);
264 static void exynos5_i2c_config(int peripheral
, int flags
)
266 switch (peripheral
) {
268 gpio_cfg_pin(EXYNOS5_GPIO_B30
, S5P_GPIO_FUNC(0x2));
269 gpio_cfg_pin(EXYNOS5_GPIO_B31
, S5P_GPIO_FUNC(0x2));
272 gpio_cfg_pin(EXYNOS5_GPIO_B32
, S5P_GPIO_FUNC(0x2));
273 gpio_cfg_pin(EXYNOS5_GPIO_B33
, S5P_GPIO_FUNC(0x2));
276 gpio_cfg_pin(EXYNOS5_GPIO_A06
, S5P_GPIO_FUNC(0x3));
277 gpio_cfg_pin(EXYNOS5_GPIO_A07
, S5P_GPIO_FUNC(0x3));
280 gpio_cfg_pin(EXYNOS5_GPIO_A12
, S5P_GPIO_FUNC(0x3));
281 gpio_cfg_pin(EXYNOS5_GPIO_A13
, S5P_GPIO_FUNC(0x3));
284 gpio_cfg_pin(EXYNOS5_GPIO_A20
, S5P_GPIO_FUNC(0x3));
285 gpio_cfg_pin(EXYNOS5_GPIO_A21
, S5P_GPIO_FUNC(0x3));
288 gpio_cfg_pin(EXYNOS5_GPIO_A22
, S5P_GPIO_FUNC(0x3));
289 gpio_cfg_pin(EXYNOS5_GPIO_A23
, S5P_GPIO_FUNC(0x3));
292 gpio_cfg_pin(EXYNOS5_GPIO_B13
, S5P_GPIO_FUNC(0x4));
293 gpio_cfg_pin(EXYNOS5_GPIO_B14
, S5P_GPIO_FUNC(0x4));
296 gpio_cfg_pin(EXYNOS5_GPIO_B22
, S5P_GPIO_FUNC(0x3));
297 gpio_cfg_pin(EXYNOS5_GPIO_B23
, S5P_GPIO_FUNC(0x3));
302 static void exynos5420_i2c_config(int peripheral
)
304 switch (peripheral
) {
306 gpio_cfg_pin(EXYNOS5420_GPIO_B30
, S5P_GPIO_FUNC(0x2));
307 gpio_cfg_pin(EXYNOS5420_GPIO_B31
, S5P_GPIO_FUNC(0x2));
310 gpio_cfg_pin(EXYNOS5420_GPIO_B32
, S5P_GPIO_FUNC(0x2));
311 gpio_cfg_pin(EXYNOS5420_GPIO_B33
, S5P_GPIO_FUNC(0x2));
314 gpio_cfg_pin(EXYNOS5420_GPIO_A06
, S5P_GPIO_FUNC(0x3));
315 gpio_cfg_pin(EXYNOS5420_GPIO_A07
, S5P_GPIO_FUNC(0x3));
318 gpio_cfg_pin(EXYNOS5420_GPIO_A12
, S5P_GPIO_FUNC(0x3));
319 gpio_cfg_pin(EXYNOS5420_GPIO_A13
, S5P_GPIO_FUNC(0x3));
322 gpio_cfg_pin(EXYNOS5420_GPIO_A20
, S5P_GPIO_FUNC(0x3));
323 gpio_cfg_pin(EXYNOS5420_GPIO_A21
, S5P_GPIO_FUNC(0x3));
326 gpio_cfg_pin(EXYNOS5420_GPIO_A22
, S5P_GPIO_FUNC(0x3));
327 gpio_cfg_pin(EXYNOS5420_GPIO_A23
, S5P_GPIO_FUNC(0x3));
330 gpio_cfg_pin(EXYNOS5420_GPIO_B13
, S5P_GPIO_FUNC(0x4));
331 gpio_cfg_pin(EXYNOS5420_GPIO_B14
, S5P_GPIO_FUNC(0x4));
334 gpio_cfg_pin(EXYNOS5420_GPIO_B22
, S5P_GPIO_FUNC(0x3));
335 gpio_cfg_pin(EXYNOS5420_GPIO_B23
, S5P_GPIO_FUNC(0x3));
338 gpio_cfg_pin(EXYNOS5420_GPIO_B34
, S5P_GPIO_FUNC(0x2));
339 gpio_cfg_pin(EXYNOS5420_GPIO_B35
, S5P_GPIO_FUNC(0x2));
342 gpio_cfg_pin(EXYNOS5420_GPIO_B36
, S5P_GPIO_FUNC(0x2));
343 gpio_cfg_pin(EXYNOS5420_GPIO_B37
, S5P_GPIO_FUNC(0x2));
345 case PERIPH_ID_I2C10
:
346 gpio_cfg_pin(EXYNOS5420_GPIO_B40
, S5P_GPIO_FUNC(0x2));
347 gpio_cfg_pin(EXYNOS5420_GPIO_B41
, S5P_GPIO_FUNC(0x2));
352 static void exynos5_i2s_config(int peripheral
)
356 switch (peripheral
) {
358 for (i
= 0; i
< 5; i
++)
359 gpio_cfg_pin(EXYNOS5_GPIO_Z0
+ i
, S5P_GPIO_FUNC(0x02));
362 for (i
= 0; i
< 5; i
++)
363 gpio_cfg_pin(EXYNOS5_GPIO_B00
+ i
, S5P_GPIO_FUNC(0x02));
368 void exynos5_spi_config(int peripheral
)
370 int cfg
= 0, pin
= 0, i
;
372 switch (peripheral
) {
374 cfg
= S5P_GPIO_FUNC(0x2);
375 pin
= EXYNOS5_GPIO_A20
;
378 cfg
= S5P_GPIO_FUNC(0x2);
379 pin
= EXYNOS5_GPIO_A24
;
382 cfg
= S5P_GPIO_FUNC(0x5);
383 pin
= EXYNOS5_GPIO_B11
;
386 cfg
= S5P_GPIO_FUNC(0x2);
387 pin
= EXYNOS5_GPIO_F10
;
390 for (i
= 0; i
< 2; i
++) {
391 gpio_cfg_pin(EXYNOS5_GPIO_F02
+ i
, S5P_GPIO_FUNC(0x4));
392 gpio_cfg_pin(EXYNOS5_GPIO_E04
+ i
, S5P_GPIO_FUNC(0x4));
396 if (peripheral
!= PERIPH_ID_SPI4
) {
397 for (i
= pin
; i
< pin
+ 4; i
++)
398 gpio_cfg_pin(i
, cfg
);
402 void exynos5420_spi_config(int peripheral
)
406 switch (peripheral
) {
408 pin
= EXYNOS5420_GPIO_A20
;
409 cfg
= S5P_GPIO_FUNC(0x2);
412 pin
= EXYNOS5420_GPIO_A24
;
413 cfg
= S5P_GPIO_FUNC(0x2);
416 pin
= EXYNOS5420_GPIO_B11
;
417 cfg
= S5P_GPIO_FUNC(0x5);
420 pin
= EXYNOS5420_GPIO_F10
;
421 cfg
= S5P_GPIO_FUNC(0x2);
430 debug("%s: invalid peripheral %d", __func__
, peripheral
);
434 if (peripheral
!= PERIPH_ID_SPI4
) {
435 for (i
= pin
; i
< pin
+ 4; i
++)
436 gpio_cfg_pin(i
, cfg
);
438 for (i
= 0; i
< 2; i
++) {
439 gpio_cfg_pin(EXYNOS5420_GPIO_F02
+ i
,
441 gpio_cfg_pin(EXYNOS5420_GPIO_E04
+ i
,
447 static int exynos5_pinmux_config(int peripheral
, int flags
)
449 switch (peripheral
) {
450 case PERIPH_ID_UART0
:
451 case PERIPH_ID_UART1
:
452 case PERIPH_ID_UART2
:
453 case PERIPH_ID_UART3
:
454 exynos5_uart_config(peripheral
);
456 case PERIPH_ID_SDMMC0
:
457 case PERIPH_ID_SDMMC1
:
458 case PERIPH_ID_SDMMC2
:
459 case PERIPH_ID_SDMMC3
:
460 return exynos5_mmc_config(peripheral
, flags
);
461 case PERIPH_ID_SROMC
:
462 exynos5_sromc_config(flags
);
472 exynos5_i2c_config(peripheral
, flags
);
476 exynos5_i2s_config(peripheral
);
483 exynos5_spi_config(peripheral
);
486 debug("%s: invalid peripheral %d", __func__
, peripheral
);
493 static int exynos5420_pinmux_config(int peripheral
, int flags
)
495 switch (peripheral
) {
496 case PERIPH_ID_UART0
:
497 case PERIPH_ID_UART1
:
498 case PERIPH_ID_UART2
:
499 case PERIPH_ID_UART3
:
500 exynos5420_uart_config(peripheral
);
502 case PERIPH_ID_SDMMC0
:
503 case PERIPH_ID_SDMMC1
:
504 case PERIPH_ID_SDMMC2
:
505 case PERIPH_ID_SDMMC3
:
506 return exynos5420_mmc_config(peripheral
, flags
);
512 exynos5420_spi_config(peripheral
);
524 case PERIPH_ID_I2C10
:
525 exynos5420_i2c_config(peripheral
);
528 debug("%s: invalid peripheral %d", __func__
, peripheral
);
535 static void exynos4_i2c_config(int peripheral
, int flags
)
537 switch (peripheral
) {
539 gpio_cfg_pin(EXYNOS4_GPIO_D10
, S5P_GPIO_FUNC(0x2));
540 gpio_cfg_pin(EXYNOS4_GPIO_D11
, S5P_GPIO_FUNC(0x2));
543 gpio_cfg_pin(EXYNOS4_GPIO_D12
, S5P_GPIO_FUNC(0x2));
544 gpio_cfg_pin(EXYNOS4_GPIO_D13
, S5P_GPIO_FUNC(0x2));
547 gpio_cfg_pin(EXYNOS4_GPIO_A06
, S5P_GPIO_FUNC(0x3));
548 gpio_cfg_pin(EXYNOS4_GPIO_A07
, S5P_GPIO_FUNC(0x3));
551 gpio_cfg_pin(EXYNOS4_GPIO_A12
, S5P_GPIO_FUNC(0x3));
552 gpio_cfg_pin(EXYNOS4_GPIO_A13
, S5P_GPIO_FUNC(0x3));
555 gpio_cfg_pin(EXYNOS4_GPIO_B2
, S5P_GPIO_FUNC(0x3));
556 gpio_cfg_pin(EXYNOS4_GPIO_B3
, S5P_GPIO_FUNC(0x3));
559 gpio_cfg_pin(EXYNOS4_GPIO_B6
, S5P_GPIO_FUNC(0x3));
560 gpio_cfg_pin(EXYNOS4_GPIO_B7
, S5P_GPIO_FUNC(0x3));
563 gpio_cfg_pin(EXYNOS4_GPIO_C13
, S5P_GPIO_FUNC(0x4));
564 gpio_cfg_pin(EXYNOS4_GPIO_C14
, S5P_GPIO_FUNC(0x4));
567 gpio_cfg_pin(EXYNOS4_GPIO_D02
, S5P_GPIO_FUNC(0x3));
568 gpio_cfg_pin(EXYNOS4_GPIO_D03
, S5P_GPIO_FUNC(0x3));
573 static int exynos4_mmc_config(int peripheral
, int flags
)
575 int i
, start
= 0, start_ext
= 0;
576 unsigned int func
, ext_func
;
578 switch (peripheral
) {
579 case PERIPH_ID_SDMMC0
:
580 start
= EXYNOS4_GPIO_K00
;
581 start_ext
= EXYNOS4_GPIO_K13
;
582 func
= S5P_GPIO_FUNC(0x2);
583 ext_func
= S5P_GPIO_FUNC(0x3);
585 case PERIPH_ID_SDMMC2
:
586 start
= EXYNOS4_GPIO_K20
;
587 start_ext
= EXYNOS4_GPIO_K33
;
588 func
= S5P_GPIO_FUNC(0x2);
589 ext_func
= S5P_GPIO_FUNC(0x3);
591 case PERIPH_ID_SDMMC4
:
592 start
= EXYNOS4_GPIO_K00
;
593 start_ext
= EXYNOS4_GPIO_K13
;
594 func
= S5P_GPIO_FUNC(0x3);
595 ext_func
= S5P_GPIO_FUNC(0x4);
600 for (i
= start
; i
< (start
+ 7); i
++) {
601 if (i
== (start
+ 2))
603 gpio_cfg_pin(i
, func
);
604 gpio_set_pull(i
, S5P_GPIO_PULL_NONE
);
605 gpio_set_drv(i
, S5P_GPIO_DRV_4X
);
607 /* SDMMC2 do not use 8bit mode at exynos4 */
608 if (flags
& PINMUX_FLAG_8BIT_MODE
) {
609 for (i
= start_ext
; i
< (start_ext
+ 4); i
++) {
610 gpio_cfg_pin(i
, ext_func
);
611 gpio_set_pull(i
, S5P_GPIO_PULL_NONE
);
612 gpio_set_drv(i
, S5P_GPIO_DRV_4X
);
619 static void exynos4_uart_config(int peripheral
)
623 switch (peripheral
) {
624 case PERIPH_ID_UART0
:
625 start
= EXYNOS4_GPIO_A00
;
628 case PERIPH_ID_UART1
:
629 start
= EXYNOS4_GPIO_A04
;
632 case PERIPH_ID_UART2
:
633 start
= EXYNOS4_GPIO_A10
;
636 case PERIPH_ID_UART3
:
637 start
= EXYNOS4_GPIO_A14
;
641 debug("%s: invalid peripheral %d", __func__
, peripheral
);
644 for (i
= start
; i
< (start
+ count
); i
++) {
645 gpio_set_pull(i
, S5P_GPIO_PULL_NONE
);
646 gpio_cfg_pin(i
, S5P_GPIO_FUNC(0x2));
650 static void exynos4x12_i2c_config(int peripheral
, int flags
)
652 switch (peripheral
) {
654 gpio_cfg_pin(EXYNOS4X12_GPIO_D10
, S5P_GPIO_FUNC(0x2));
655 gpio_cfg_pin(EXYNOS4X12_GPIO_D11
, S5P_GPIO_FUNC(0x2));
658 gpio_cfg_pin(EXYNOS4X12_GPIO_D12
, S5P_GPIO_FUNC(0x2));
659 gpio_cfg_pin(EXYNOS4X12_GPIO_D13
, S5P_GPIO_FUNC(0x2));
662 gpio_cfg_pin(EXYNOS4X12_GPIO_A06
, S5P_GPIO_FUNC(0x3));
663 gpio_cfg_pin(EXYNOS4X12_GPIO_A07
, S5P_GPIO_FUNC(0x3));
666 gpio_cfg_pin(EXYNOS4X12_GPIO_A12
, S5P_GPIO_FUNC(0x3));
667 gpio_cfg_pin(EXYNOS4X12_GPIO_A13
, S5P_GPIO_FUNC(0x3));
670 gpio_cfg_pin(EXYNOS4X12_GPIO_B2
, S5P_GPIO_FUNC(0x3));
671 gpio_cfg_pin(EXYNOS4X12_GPIO_B3
, S5P_GPIO_FUNC(0x3));
674 gpio_cfg_pin(EXYNOS4X12_GPIO_B6
, S5P_GPIO_FUNC(0x3));
675 gpio_cfg_pin(EXYNOS4X12_GPIO_B7
, S5P_GPIO_FUNC(0x3));
678 gpio_cfg_pin(EXYNOS4X12_GPIO_C13
, S5P_GPIO_FUNC(0x4));
679 gpio_cfg_pin(EXYNOS4X12_GPIO_C14
, S5P_GPIO_FUNC(0x4));
682 gpio_cfg_pin(EXYNOS4X12_GPIO_D02
, S5P_GPIO_FUNC(0x3));
683 gpio_cfg_pin(EXYNOS4X12_GPIO_D03
, S5P_GPIO_FUNC(0x3));
688 static int exynos4x12_mmc_config(int peripheral
, int flags
)
690 int i
, start
= 0, start_ext
= 0;
691 unsigned int func
, ext_func
;
693 switch (peripheral
) {
694 case PERIPH_ID_SDMMC0
:
695 start
= EXYNOS4X12_GPIO_K00
;
696 start_ext
= EXYNOS4X12_GPIO_K13
;
697 func
= S5P_GPIO_FUNC(0x2);
698 ext_func
= S5P_GPIO_FUNC(0x3);
700 case PERIPH_ID_SDMMC2
:
701 start
= EXYNOS4X12_GPIO_K20
;
702 start_ext
= EXYNOS4X12_GPIO_K33
;
703 func
= S5P_GPIO_FUNC(0x2);
704 ext_func
= S5P_GPIO_FUNC(0x3);
706 case PERIPH_ID_SDMMC4
:
707 start
= EXYNOS4X12_GPIO_K00
;
708 start_ext
= EXYNOS4X12_GPIO_K13
;
709 func
= S5P_GPIO_FUNC(0x3);
710 ext_func
= S5P_GPIO_FUNC(0x4);
715 for (i
= start
; i
< (start
+ 7); i
++) {
716 if (i
== (start
+ 2))
718 gpio_cfg_pin(i
, func
);
719 gpio_set_pull(i
, S5P_GPIO_PULL_NONE
);
720 gpio_set_drv(i
, S5P_GPIO_DRV_4X
);
722 if (flags
& PINMUX_FLAG_8BIT_MODE
) {
723 for (i
= start_ext
; i
< (start_ext
+ 4); i
++) {
724 gpio_cfg_pin(i
, ext_func
);
725 gpio_set_pull(i
, S5P_GPIO_PULL_NONE
);
726 gpio_set_drv(i
, S5P_GPIO_DRV_4X
);
733 static void exynos4x12_uart_config(int peripheral
)
737 switch (peripheral
) {
738 case PERIPH_ID_UART0
:
739 start
= EXYNOS4X12_GPIO_A00
;
742 case PERIPH_ID_UART1
:
743 start
= EXYNOS4X12_GPIO_A04
;
746 case PERIPH_ID_UART2
:
747 start
= EXYNOS4X12_GPIO_A10
;
750 case PERIPH_ID_UART3
:
751 start
= EXYNOS4X12_GPIO_A14
;
755 debug("%s: invalid peripheral %d", __func__
, peripheral
);
758 for (i
= start
; i
< (start
+ count
); i
++) {
759 gpio_set_pull(i
, S5P_GPIO_PULL_NONE
);
760 gpio_cfg_pin(i
, S5P_GPIO_FUNC(0x2));
764 static int exynos4_pinmux_config(int peripheral
, int flags
)
766 switch (peripheral
) {
767 case PERIPH_ID_UART0
:
768 case PERIPH_ID_UART1
:
769 case PERIPH_ID_UART2
:
770 case PERIPH_ID_UART3
:
771 exynos4_uart_config(peripheral
);
781 exynos4_i2c_config(peripheral
, flags
);
783 case PERIPH_ID_SDMMC0
:
784 case PERIPH_ID_SDMMC2
:
785 case PERIPH_ID_SDMMC4
:
786 return exynos4_mmc_config(peripheral
, flags
);
787 case PERIPH_ID_SDMMC1
:
788 case PERIPH_ID_SDMMC3
:
789 debug("SDMMC device %d not implemented\n", peripheral
);
792 debug("%s: invalid peripheral %d", __func__
, peripheral
);
799 static int exynos4x12_pinmux_config(int peripheral
, int flags
)
801 switch (peripheral
) {
802 case PERIPH_ID_UART0
:
803 case PERIPH_ID_UART1
:
804 case PERIPH_ID_UART2
:
805 case PERIPH_ID_UART3
:
806 exynos4x12_uart_config(peripheral
);
816 exynos4x12_i2c_config(peripheral
, flags
);
818 case PERIPH_ID_SDMMC0
:
819 case PERIPH_ID_SDMMC2
:
820 case PERIPH_ID_SDMMC4
:
821 return exynos4x12_mmc_config(peripheral
, flags
);
822 case PERIPH_ID_SDMMC1
:
823 case PERIPH_ID_SDMMC3
:
824 debug("SDMMC device %d not implemented\n", peripheral
);
827 debug("%s: invalid peripheral %d", __func__
, peripheral
);
834 int exynos_pinmux_config(int peripheral
, int flags
)
836 if (cpu_is_exynos5()) {
837 if (proid_is_exynos5420())
838 return exynos5420_pinmux_config(peripheral
, flags
);
839 else if (proid_is_exynos5250())
840 return exynos5_pinmux_config(peripheral
, flags
);
841 } else if (cpu_is_exynos4()) {
842 if (proid_is_exynos4412())
843 return exynos4x12_pinmux_config(peripheral
, flags
);
845 return exynos4_pinmux_config(peripheral
, flags
);
848 debug("pinmux functionality not supported\n");
853 #ifdef CONFIG_OF_CONTROL
854 static int exynos4_pinmux_decode_periph_id(const void *blob
, int node
)
859 err
= fdtdec_get_int_array(blob
, node
, "interrupts", cell
,
862 debug(" invalid peripheral id\n");
863 return PERIPH_ID_NONE
;
869 static int exynos5_pinmux_decode_periph_id(const void *blob
, int node
)
874 err
= fdtdec_get_int_array(blob
, node
, "interrupts", cell
,
877 return PERIPH_ID_NONE
;
882 int pinmux_decode_periph_id(const void *blob
, int node
)
884 if (cpu_is_exynos5())
885 return exynos5_pinmux_decode_periph_id(blob
, node
);
886 else if (cpu_is_exynos4())
887 return exynos4_pinmux_decode_periph_id(blob
, node
);
889 return PERIPH_ID_NONE
;