2 * Copyright (c) 2012 Samsung Electronics.
3 * Abhilash Kesavan <a.kesavan@samsung.com>
5 * SPDX-License-Identifier: GPL-2.0+
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 #ifndef CONFIG_SPL_BUILD
176 gpio_request(i, "sdmmc0_vdden");
178 gpio_set_value(i, 1);
179 gpio_cfg_pin(i, S5P_GPIO_OUTPUT);
181 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
183 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
184 gpio_set_drv(i, S5P_GPIO_DRV_4X);
187 for (i = (start + 3); i <= (start + 6); i++) {
188 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
189 gpio_set_pull(i, S5P_GPIO_PULL_UP);
190 gpio_set_drv(i, S5P_GPIO_DRV_4X);
196 static void exynos5_sromc_config(int flags)
203 * GPY0[0] SROM_CSn[0]
204 * GPY0[1] SROM_CSn[1](2)
205 * GPY0[2] SROM_CSn[2]
206 * GPY0[3] SROM_CSn[3]
210 * GPY1[0] EBI_BEn[0](2)
211 * GPY1[1] EBI_BEn[1](2)
212 * GPY1[2] SROM_WAIT(2)
213 * GPY1[3] EBI_DATA_RDn(2)
215 gpio_cfg_pin(EXYNOS5_GPIO_Y00 + (flags & PINMUX_FLAG_BANK),
217 gpio_cfg_pin(EXYNOS5_GPIO_Y04, S5P_GPIO_FUNC(2));
218 gpio_cfg_pin(EXYNOS5_GPIO_Y05, S5P_GPIO_FUNC(2));
220 for (i = 0; i < 4; i++)
221 gpio_cfg_pin(EXYNOS5_GPIO_Y10 + i, S5P_GPIO_FUNC(2));
224 * EBI: 8 Addrss Lines
226 * GPY3[0] EBI_ADDR[0](2)
227 * GPY3[1] EBI_ADDR[1](2)
228 * GPY3[2] EBI_ADDR[2](2)
229 * GPY3[3] EBI_ADDR[3](2)
230 * GPY3[4] EBI_ADDR[4](2)
231 * GPY3[5] EBI_ADDR[5](2)
232 * GPY3[6] EBI_ADDR[6](2)
233 * GPY3[7] EBI_ADDR[7](2)
237 * GPY5[0] EBI_DATA[0](2)
238 * GPY5[1] EBI_DATA[1](2)
239 * GPY5[2] EBI_DATA[2](2)
240 * GPY5[3] EBI_DATA[3](2)
241 * GPY5[4] EBI_DATA[4](2)
242 * GPY5[5] EBI_DATA[5](2)
243 * GPY5[6] EBI_DATA[6](2)
244 * GPY5[7] EBI_DATA[7](2)
246 * GPY6[0] EBI_DATA[8](2)
247 * GPY6[1] EBI_DATA[9](2)
248 * GPY6[2] EBI_DATA[10](2)
249 * GPY6[3] EBI_DATA[11](2)
250 * GPY6[4] EBI_DATA[12](2)
251 * GPY6[5] EBI_DATA[13](2)
252 * GPY6[6] EBI_DATA[14](2)
253 * GPY6[7] EBI_DATA[15](2)
255 for (i = 0; i < 8; i++) {
256 gpio_cfg_pin(EXYNOS5_GPIO_Y30 + i, S5P_GPIO_FUNC(2));
257 gpio_set_pull(EXYNOS5_GPIO_Y30 + i, S5P_GPIO_PULL_UP);
259 gpio_cfg_pin(EXYNOS5_GPIO_Y50 + i, S5P_GPIO_FUNC(2));
260 gpio_set_pull(EXYNOS5_GPIO_Y50 + i, S5P_GPIO_PULL_UP);
262 gpio_cfg_pin(EXYNOS5_GPIO_Y60 + i, S5P_GPIO_FUNC(2));
263 gpio_set_pull(EXYNOS5_GPIO_Y60 + i, S5P_GPIO_PULL_UP);
267 static void exynos5_i2c_config(int peripheral, int flags)
272 if (flags & PINMUX_FLAG_HS_MODE) {
280 switch (peripheral) {
282 gpio_cfg_pin(EXYNOS5_GPIO_B30, S5P_GPIO_FUNC(func01));
283 gpio_cfg_pin(EXYNOS5_GPIO_B31, S5P_GPIO_FUNC(func01));
286 gpio_cfg_pin(EXYNOS5_GPIO_B32, S5P_GPIO_FUNC(func01));
287 gpio_cfg_pin(EXYNOS5_GPIO_B33, S5P_GPIO_FUNC(func01));
290 gpio_cfg_pin(EXYNOS5_GPIO_A06, S5P_GPIO_FUNC(func23));
291 gpio_cfg_pin(EXYNOS5_GPIO_A07, S5P_GPIO_FUNC(func23));
294 gpio_cfg_pin(EXYNOS5_GPIO_A12, S5P_GPIO_FUNC(func23));
295 gpio_cfg_pin(EXYNOS5_GPIO_A13, S5P_GPIO_FUNC(func23));
298 gpio_cfg_pin(EXYNOS5_GPIO_A20, S5P_GPIO_FUNC(0x3));
299 gpio_cfg_pin(EXYNOS5_GPIO_A21, S5P_GPIO_FUNC(0x3));
302 gpio_cfg_pin(EXYNOS5_GPIO_A22, S5P_GPIO_FUNC(0x3));
303 gpio_cfg_pin(EXYNOS5_GPIO_A23, S5P_GPIO_FUNC(0x3));
306 gpio_cfg_pin(EXYNOS5_GPIO_B13, S5P_GPIO_FUNC(0x4));
307 gpio_cfg_pin(EXYNOS5_GPIO_B14, S5P_GPIO_FUNC(0x4));
310 gpio_cfg_pin(EXYNOS5_GPIO_B22, S5P_GPIO_FUNC(0x3));
311 gpio_cfg_pin(EXYNOS5_GPIO_B23, S5P_GPIO_FUNC(0x3));
316 static void exynos5420_i2c_config(int peripheral)
318 switch (peripheral) {
320 gpio_cfg_pin(EXYNOS5420_GPIO_B30, S5P_GPIO_FUNC(0x2));
321 gpio_cfg_pin(EXYNOS5420_GPIO_B31, S5P_GPIO_FUNC(0x2));
324 gpio_cfg_pin(EXYNOS5420_GPIO_B32, S5P_GPIO_FUNC(0x2));
325 gpio_cfg_pin(EXYNOS5420_GPIO_B33, S5P_GPIO_FUNC(0x2));
328 gpio_cfg_pin(EXYNOS5420_GPIO_A06, S5P_GPIO_FUNC(0x3));
329 gpio_cfg_pin(EXYNOS5420_GPIO_A07, S5P_GPIO_FUNC(0x3));
332 gpio_cfg_pin(EXYNOS5420_GPIO_A12, S5P_GPIO_FUNC(0x3));
333 gpio_cfg_pin(EXYNOS5420_GPIO_A13, S5P_GPIO_FUNC(0x3));
336 gpio_cfg_pin(EXYNOS5420_GPIO_A20, S5P_GPIO_FUNC(0x3));
337 gpio_cfg_pin(EXYNOS5420_GPIO_A21, S5P_GPIO_FUNC(0x3));
340 gpio_cfg_pin(EXYNOS5420_GPIO_A22, S5P_GPIO_FUNC(0x3));
341 gpio_cfg_pin(EXYNOS5420_GPIO_A23, S5P_GPIO_FUNC(0x3));
344 gpio_cfg_pin(EXYNOS5420_GPIO_B13, S5P_GPIO_FUNC(0x4));
345 gpio_cfg_pin(EXYNOS5420_GPIO_B14, S5P_GPIO_FUNC(0x4));
348 gpio_cfg_pin(EXYNOS5420_GPIO_B22, S5P_GPIO_FUNC(0x3));
349 gpio_cfg_pin(EXYNOS5420_GPIO_B23, S5P_GPIO_FUNC(0x3));
352 gpio_cfg_pin(EXYNOS5420_GPIO_B34, S5P_GPIO_FUNC(0x2));
353 gpio_cfg_pin(EXYNOS5420_GPIO_B35, S5P_GPIO_FUNC(0x2));
356 gpio_cfg_pin(EXYNOS5420_GPIO_B36, S5P_GPIO_FUNC(0x2));
357 gpio_cfg_pin(EXYNOS5420_GPIO_B37, S5P_GPIO_FUNC(0x2));
359 case PERIPH_ID_I2C10:
360 gpio_cfg_pin(EXYNOS5420_GPIO_B40, S5P_GPIO_FUNC(0x2));
361 gpio_cfg_pin(EXYNOS5420_GPIO_B41, S5P_GPIO_FUNC(0x2));
366 static void exynos5_i2s_config(int peripheral)
370 switch (peripheral) {
372 for (i = 0; i < 5; i++)
373 gpio_cfg_pin(EXYNOS5_GPIO_Z0 + i, S5P_GPIO_FUNC(0x02));
376 for (i = 0; i < 5; i++)
377 gpio_cfg_pin(EXYNOS5_GPIO_B00 + i, S5P_GPIO_FUNC(0x02));
382 void exynos5_spi_config(int peripheral)
384 int cfg = 0, pin = 0, i;
386 switch (peripheral) {
388 cfg = S5P_GPIO_FUNC(0x2);
389 pin = EXYNOS5_GPIO_A20;
392 cfg = S5P_GPIO_FUNC(0x2);
393 pin = EXYNOS5_GPIO_A24;
396 cfg = S5P_GPIO_FUNC(0x5);
397 pin = EXYNOS5_GPIO_B11;
400 cfg = S5P_GPIO_FUNC(0x2);
401 pin = EXYNOS5_GPIO_F10;
404 for (i = 0; i < 2; i++) {
405 gpio_cfg_pin(EXYNOS5_GPIO_F02 + i, S5P_GPIO_FUNC(0x4));
406 gpio_cfg_pin(EXYNOS5_GPIO_E04 + i, S5P_GPIO_FUNC(0x4));
410 if (peripheral != PERIPH_ID_SPI4) {
411 for (i = pin; i < pin + 4; i++)
412 gpio_cfg_pin(i, cfg);
416 void exynos5420_spi_config(int peripheral)
420 switch (peripheral) {
422 pin = EXYNOS5420_GPIO_A20;
423 cfg = S5P_GPIO_FUNC(0x2);
426 pin = EXYNOS5420_GPIO_A24;
427 cfg = S5P_GPIO_FUNC(0x2);
430 pin = EXYNOS5420_GPIO_B11;
431 cfg = S5P_GPIO_FUNC(0x5);
434 pin = EXYNOS5420_GPIO_F10;
435 cfg = S5P_GPIO_FUNC(0x2);
444 debug("%s: invalid peripheral %d", __func__, peripheral);
448 if (peripheral != PERIPH_ID_SPI4) {
449 for (i = pin; i < pin + 4; i++)
450 gpio_cfg_pin(i, cfg);
452 for (i = 0; i < 2; i++) {
453 gpio_cfg_pin(EXYNOS5420_GPIO_F02 + i,
455 gpio_cfg_pin(EXYNOS5420_GPIO_E04 + i,
461 static int exynos5_pinmux_config(int peripheral, int flags)
463 switch (peripheral) {
464 case PERIPH_ID_UART0:
465 case PERIPH_ID_UART1:
466 case PERIPH_ID_UART2:
467 case PERIPH_ID_UART3:
468 exynos5_uart_config(peripheral);
470 case PERIPH_ID_SDMMC0:
471 case PERIPH_ID_SDMMC1:
472 case PERIPH_ID_SDMMC2:
473 case PERIPH_ID_SDMMC3:
474 return exynos5_mmc_config(peripheral, flags);
475 case PERIPH_ID_SROMC:
476 exynos5_sromc_config(flags);
486 exynos5_i2c_config(peripheral, flags);
490 exynos5_i2s_config(peripheral);
497 exynos5_spi_config(peripheral);
499 case PERIPH_ID_DPHPD:
500 /* Set Hotplug detect for DP */
501 gpio_cfg_pin(EXYNOS5_GPIO_X07, S5P_GPIO_FUNC(0x3));
504 * Hotplug detect should have an external pullup; disable the
505 * internal pulldown so they don't fight.
507 gpio_set_pull(EXYNOS5_GPIO_X07, S5P_GPIO_PULL_NONE);
510 debug("%s: invalid peripheral %d", __func__, peripheral);
517 static int exynos5420_pinmux_config(int peripheral, int flags)
519 switch (peripheral) {
520 case PERIPH_ID_UART0:
521 case PERIPH_ID_UART1:
522 case PERIPH_ID_UART2:
523 case PERIPH_ID_UART3:
524 exynos5420_uart_config(peripheral);
526 case PERIPH_ID_SDMMC0:
527 case PERIPH_ID_SDMMC1:
528 case PERIPH_ID_SDMMC2:
529 case PERIPH_ID_SDMMC3:
530 return exynos5420_mmc_config(peripheral, flags);
536 exynos5420_spi_config(peripheral);
548 case PERIPH_ID_I2C10:
549 exynos5420_i2c_config(peripheral);
552 debug("%s: invalid peripheral %d", __func__, peripheral);
559 static void exynos4_i2c_config(int peripheral, int flags)
561 switch (peripheral) {
563 gpio_cfg_pin(EXYNOS4_GPIO_D10, S5P_GPIO_FUNC(0x2));
564 gpio_cfg_pin(EXYNOS4_GPIO_D11, S5P_GPIO_FUNC(0x2));
567 gpio_cfg_pin(EXYNOS4_GPIO_D12, S5P_GPIO_FUNC(0x2));
568 gpio_cfg_pin(EXYNOS4_GPIO_D13, S5P_GPIO_FUNC(0x2));
571 gpio_cfg_pin(EXYNOS4_GPIO_A06, S5P_GPIO_FUNC(0x3));
572 gpio_cfg_pin(EXYNOS4_GPIO_A07, S5P_GPIO_FUNC(0x3));
575 gpio_cfg_pin(EXYNOS4_GPIO_A12, S5P_GPIO_FUNC(0x3));
576 gpio_cfg_pin(EXYNOS4_GPIO_A13, S5P_GPIO_FUNC(0x3));
579 gpio_cfg_pin(EXYNOS4_GPIO_B2, S5P_GPIO_FUNC(0x3));
580 gpio_cfg_pin(EXYNOS4_GPIO_B3, S5P_GPIO_FUNC(0x3));
583 gpio_cfg_pin(EXYNOS4_GPIO_B6, S5P_GPIO_FUNC(0x3));
584 gpio_cfg_pin(EXYNOS4_GPIO_B7, S5P_GPIO_FUNC(0x3));
587 gpio_cfg_pin(EXYNOS4_GPIO_C13, S5P_GPIO_FUNC(0x4));
588 gpio_cfg_pin(EXYNOS4_GPIO_C14, S5P_GPIO_FUNC(0x4));
591 gpio_cfg_pin(EXYNOS4_GPIO_D02, S5P_GPIO_FUNC(0x3));
592 gpio_cfg_pin(EXYNOS4_GPIO_D03, S5P_GPIO_FUNC(0x3));
597 static int exynos4_mmc_config(int peripheral, int flags)
599 int i, start = 0, start_ext = 0;
600 unsigned int func, ext_func;
602 switch (peripheral) {
603 case PERIPH_ID_SDMMC0:
604 start = EXYNOS4_GPIO_K00;
605 start_ext = EXYNOS4_GPIO_K13;
606 func = S5P_GPIO_FUNC(0x2);
607 ext_func = S5P_GPIO_FUNC(0x3);
609 case PERIPH_ID_SDMMC2:
610 start = EXYNOS4_GPIO_K20;
611 start_ext = EXYNOS4_GPIO_K33;
612 func = S5P_GPIO_FUNC(0x2);
613 ext_func = S5P_GPIO_FUNC(0x3);
615 case PERIPH_ID_SDMMC4:
616 start = EXYNOS4_GPIO_K00;
617 start_ext = EXYNOS4_GPIO_K13;
618 func = S5P_GPIO_FUNC(0x3);
619 ext_func = S5P_GPIO_FUNC(0x4);
624 for (i = start; i < (start + 7); i++) {
625 if (i == (start + 2))
627 gpio_cfg_pin(i, func);
628 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
629 gpio_set_drv(i, S5P_GPIO_DRV_4X);
631 /* SDMMC2 do not use 8bit mode at exynos4 */
632 if (flags & PINMUX_FLAG_8BIT_MODE) {
633 for (i = start_ext; i < (start_ext + 4); i++) {
634 gpio_cfg_pin(i, ext_func);
635 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
636 gpio_set_drv(i, S5P_GPIO_DRV_4X);
643 static void exynos4_uart_config(int peripheral)
647 switch (peripheral) {
648 case PERIPH_ID_UART0:
649 start = EXYNOS4_GPIO_A00;
652 case PERIPH_ID_UART1:
653 start = EXYNOS4_GPIO_A04;
656 case PERIPH_ID_UART2:
657 start = EXYNOS4_GPIO_A10;
660 case PERIPH_ID_UART3:
661 start = EXYNOS4_GPIO_A14;
665 debug("%s: invalid peripheral %d", __func__, peripheral);
668 for (i = start; i < (start + count); i++) {
669 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
670 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
674 static void exynos4x12_i2c_config(int peripheral, int flags)
676 switch (peripheral) {
678 gpio_cfg_pin(EXYNOS4X12_GPIO_D10, S5P_GPIO_FUNC(0x2));
679 gpio_cfg_pin(EXYNOS4X12_GPIO_D11, S5P_GPIO_FUNC(0x2));
682 gpio_cfg_pin(EXYNOS4X12_GPIO_D12, S5P_GPIO_FUNC(0x2));
683 gpio_cfg_pin(EXYNOS4X12_GPIO_D13, S5P_GPIO_FUNC(0x2));
686 gpio_cfg_pin(EXYNOS4X12_GPIO_A06, S5P_GPIO_FUNC(0x3));
687 gpio_cfg_pin(EXYNOS4X12_GPIO_A07, S5P_GPIO_FUNC(0x3));
690 gpio_cfg_pin(EXYNOS4X12_GPIO_A12, S5P_GPIO_FUNC(0x3));
691 gpio_cfg_pin(EXYNOS4X12_GPIO_A13, S5P_GPIO_FUNC(0x3));
694 gpio_cfg_pin(EXYNOS4X12_GPIO_B2, S5P_GPIO_FUNC(0x3));
695 gpio_cfg_pin(EXYNOS4X12_GPIO_B3, S5P_GPIO_FUNC(0x3));
698 gpio_cfg_pin(EXYNOS4X12_GPIO_B6, S5P_GPIO_FUNC(0x3));
699 gpio_cfg_pin(EXYNOS4X12_GPIO_B7, S5P_GPIO_FUNC(0x3));
702 gpio_cfg_pin(EXYNOS4X12_GPIO_C13, S5P_GPIO_FUNC(0x4));
703 gpio_cfg_pin(EXYNOS4X12_GPIO_C14, S5P_GPIO_FUNC(0x4));
706 gpio_cfg_pin(EXYNOS4X12_GPIO_D02, S5P_GPIO_FUNC(0x3));
707 gpio_cfg_pin(EXYNOS4X12_GPIO_D03, S5P_GPIO_FUNC(0x3));
712 static int exynos4x12_mmc_config(int peripheral, int flags)
714 int i, start = 0, start_ext = 0;
715 unsigned int func, ext_func;
717 switch (peripheral) {
718 case PERIPH_ID_SDMMC0:
719 start = EXYNOS4X12_GPIO_K00;
720 start_ext = EXYNOS4X12_GPIO_K13;
721 func = S5P_GPIO_FUNC(0x2);
722 ext_func = S5P_GPIO_FUNC(0x3);
724 case PERIPH_ID_SDMMC2:
725 start = EXYNOS4X12_GPIO_K20;
726 start_ext = EXYNOS4X12_GPIO_K33;
727 func = S5P_GPIO_FUNC(0x2);
728 ext_func = S5P_GPIO_FUNC(0x3);
730 case PERIPH_ID_SDMMC4:
731 start = EXYNOS4X12_GPIO_K00;
732 start_ext = EXYNOS4X12_GPIO_K13;
733 func = S5P_GPIO_FUNC(0x3);
734 ext_func = S5P_GPIO_FUNC(0x4);
739 for (i = start; i < (start + 7); i++) {
740 if (i == (start + 2))
742 gpio_cfg_pin(i, func);
743 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
744 gpio_set_drv(i, S5P_GPIO_DRV_4X);
746 if (flags & PINMUX_FLAG_8BIT_MODE) {
747 for (i = start_ext; i < (start_ext + 4); i++) {
748 gpio_cfg_pin(i, ext_func);
749 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
750 gpio_set_drv(i, S5P_GPIO_DRV_4X);
757 static void exynos4x12_uart_config(int peripheral)
761 switch (peripheral) {
762 case PERIPH_ID_UART0:
763 start = EXYNOS4X12_GPIO_A00;
766 case PERIPH_ID_UART1:
767 start = EXYNOS4X12_GPIO_A04;
770 case PERIPH_ID_UART2:
771 start = EXYNOS4X12_GPIO_A10;
774 case PERIPH_ID_UART3:
775 start = EXYNOS4X12_GPIO_A14;
779 debug("%s: invalid peripheral %d", __func__, peripheral);
782 for (i = start; i < (start + count); i++) {
783 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
784 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
788 static int exynos4_pinmux_config(int peripheral, int flags)
790 switch (peripheral) {
791 case PERIPH_ID_UART0:
792 case PERIPH_ID_UART1:
793 case PERIPH_ID_UART2:
794 case PERIPH_ID_UART3:
795 exynos4_uart_config(peripheral);
805 exynos4_i2c_config(peripheral, flags);
807 case PERIPH_ID_SDMMC0:
808 case PERIPH_ID_SDMMC2:
809 case PERIPH_ID_SDMMC4:
810 return exynos4_mmc_config(peripheral, flags);
811 case PERIPH_ID_SDMMC1:
812 case PERIPH_ID_SDMMC3:
813 debug("SDMMC device %d not implemented\n", peripheral);
816 debug("%s: invalid peripheral %d", __func__, peripheral);
823 static int exynos4x12_pinmux_config(int peripheral, int flags)
825 switch (peripheral) {
826 case PERIPH_ID_UART0:
827 case PERIPH_ID_UART1:
828 case PERIPH_ID_UART2:
829 case PERIPH_ID_UART3:
830 exynos4x12_uart_config(peripheral);
840 exynos4x12_i2c_config(peripheral, flags);
842 case PERIPH_ID_SDMMC0:
843 case PERIPH_ID_SDMMC2:
844 case PERIPH_ID_SDMMC4:
845 return exynos4x12_mmc_config(peripheral, flags);
846 case PERIPH_ID_SDMMC1:
847 case PERIPH_ID_SDMMC3:
848 debug("SDMMC device %d not implemented\n", peripheral);
851 debug("%s: invalid peripheral %d", __func__, peripheral);
858 int exynos_pinmux_config(int peripheral, int flags)
860 if (cpu_is_exynos5()) {
861 if (proid_is_exynos5420() || proid_is_exynos5800())
862 return exynos5420_pinmux_config(peripheral, flags);
863 else if (proid_is_exynos5250())
864 return exynos5_pinmux_config(peripheral, flags);
865 } else if (cpu_is_exynos4()) {
866 if (proid_is_exynos4412())
867 return exynos4x12_pinmux_config(peripheral, flags);
869 return exynos4_pinmux_config(peripheral, flags);
872 debug("pinmux functionality not supported\n");
877 #if CONFIG_IS_ENABLED(OF_CONTROL)
878 static int exynos4_pinmux_decode_periph_id(const void *blob, int node)
883 err = fdtdec_get_int_array(blob, node, "interrupts", cell,
886 debug(" invalid peripheral id\n");
887 return PERIPH_ID_NONE;
893 static int exynos5_pinmux_decode_periph_id(const void *blob, int node)
898 err = fdtdec_get_int_array(blob, node, "interrupts", cell,
901 return PERIPH_ID_NONE;
906 int pinmux_decode_periph_id(const void *blob, int node)
908 if (cpu_is_exynos5())
909 return exynos5_pinmux_decode_periph_id(blob, node);
910 else if (cpu_is_exynos4())
911 return exynos4_pinmux_decode_periph_id(blob, node);
913 return PERIPH_ID_NONE;