1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2012 Samsung Electronics.
4 * Abhilash Kesavan <a.kesavan@samsung.com>
10 #include <asm/arch/pinmux.h>
11 #include <asm/arch/sromc.h>
13 static void exynos5_uart_config(int peripheral)
19 start = EXYNOS5_GPIO_A00;
23 start = EXYNOS5_GPIO_D00;
27 start = EXYNOS5_GPIO_A10;
31 start = EXYNOS5_GPIO_A14;
35 debug("%s: invalid peripheral %d", __func__, peripheral);
38 for (i = start; i < start + count; i++) {
39 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
40 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
44 static void exynos5420_uart_config(int peripheral)
50 start = EXYNOS5420_GPIO_A00;
54 start = EXYNOS5420_GPIO_A04;
58 start = EXYNOS5420_GPIO_A10;
62 start = EXYNOS5420_GPIO_A14;
66 debug("%s: invalid peripheral %d", __func__, peripheral);
70 for (i = start; i < start + count; i++) {
71 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
72 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
76 static int exynos5_mmc_config(int peripheral, int flags)
78 int i, start, start_ext, gpio_func = 0;
81 case PERIPH_ID_SDMMC0:
82 start = EXYNOS5_GPIO_C00;
83 start_ext = EXYNOS5_GPIO_C10;
84 gpio_func = S5P_GPIO_FUNC(0x2);
86 case PERIPH_ID_SDMMC1:
87 start = EXYNOS5_GPIO_C20;
90 case PERIPH_ID_SDMMC2:
91 start = EXYNOS5_GPIO_C30;
92 start_ext = EXYNOS5_GPIO_C43;
93 gpio_func = S5P_GPIO_FUNC(0x3);
95 case PERIPH_ID_SDMMC3:
96 start = EXYNOS5_GPIO_C40;
100 debug("%s: invalid peripheral %d", __func__, peripheral);
103 if ((flags & PINMUX_FLAG_8BIT_MODE) && !start_ext) {
104 debug("SDMMC device %d does not support 8bit mode",
108 if (flags & PINMUX_FLAG_8BIT_MODE) {
109 for (i = start_ext; i <= (start_ext + 3); i++) {
110 gpio_cfg_pin(i, gpio_func);
111 gpio_set_pull(i, S5P_GPIO_PULL_UP);
112 gpio_set_drv(i, S5P_GPIO_DRV_4X);
115 for (i = start; i < (start + 2); i++) {
116 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
117 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
118 gpio_set_drv(i, S5P_GPIO_DRV_4X);
120 for (i = (start + 3); i <= (start + 6); i++) {
121 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
122 gpio_set_pull(i, S5P_GPIO_PULL_UP);
123 gpio_set_drv(i, S5P_GPIO_DRV_4X);
129 static int exynos5420_mmc_config(int peripheral, int flags)
131 int i, start = 0, start_ext = 0;
133 switch (peripheral) {
134 case PERIPH_ID_SDMMC0:
135 start = EXYNOS5420_GPIO_C00;
136 start_ext = EXYNOS5420_GPIO_C30;
138 case PERIPH_ID_SDMMC1:
139 start = EXYNOS5420_GPIO_C10;
140 start_ext = EXYNOS5420_GPIO_D14;
142 case PERIPH_ID_SDMMC2:
143 start = EXYNOS5420_GPIO_C20;
148 debug("%s: invalid peripheral %d", __func__, peripheral);
152 if ((flags & PINMUX_FLAG_8BIT_MODE) && !start_ext) {
153 debug("SDMMC device %d does not support 8bit mode",
158 if (flags & PINMUX_FLAG_8BIT_MODE) {
159 for (i = start_ext; i <= (start_ext + 3); i++) {
160 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
161 gpio_set_pull(i, S5P_GPIO_PULL_UP);
162 gpio_set_drv(i, S5P_GPIO_DRV_4X);
166 for (i = start; i < (start + 3); i++) {
168 * MMC0 is intended to be used for eMMC. The
169 * card detect pin is used as a VDDEN signal to
170 * power on the eMMC. The 5420 iROM makes
171 * this same assumption.
173 if ((peripheral == PERIPH_ID_SDMMC0) && (i == (start + 2))) {
174 #ifndef CONFIG_SPL_BUILD
175 gpio_request(i, "sdmmc0_vdden");
177 gpio_set_value(i, 1);
178 gpio_cfg_pin(i, S5P_GPIO_OUTPUT);
180 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
182 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
183 gpio_set_drv(i, S5P_GPIO_DRV_4X);
186 for (i = (start + 3); i <= (start + 6); i++) {
187 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
188 gpio_set_pull(i, S5P_GPIO_PULL_UP);
189 gpio_set_drv(i, S5P_GPIO_DRV_4X);
195 static void exynos5_sromc_config(int flags)
202 * GPY0[0] SROM_CSn[0]
203 * GPY0[1] SROM_CSn[1](2)
204 * GPY0[2] SROM_CSn[2]
205 * GPY0[3] SROM_CSn[3]
209 * GPY1[0] EBI_BEn[0](2)
210 * GPY1[1] EBI_BEn[1](2)
211 * GPY1[2] SROM_WAIT(2)
212 * GPY1[3] EBI_DATA_RDn(2)
214 gpio_cfg_pin(EXYNOS5_GPIO_Y00 + (flags & PINMUX_FLAG_BANK),
216 gpio_cfg_pin(EXYNOS5_GPIO_Y04, S5P_GPIO_FUNC(2));
217 gpio_cfg_pin(EXYNOS5_GPIO_Y05, S5P_GPIO_FUNC(2));
219 for (i = 0; i < 4; i++)
220 gpio_cfg_pin(EXYNOS5_GPIO_Y10 + i, S5P_GPIO_FUNC(2));
223 * EBI: 8 Addrss Lines
225 * GPY3[0] EBI_ADDR[0](2)
226 * GPY3[1] EBI_ADDR[1](2)
227 * GPY3[2] EBI_ADDR[2](2)
228 * GPY3[3] EBI_ADDR[3](2)
229 * GPY3[4] EBI_ADDR[4](2)
230 * GPY3[5] EBI_ADDR[5](2)
231 * GPY3[6] EBI_ADDR[6](2)
232 * GPY3[7] EBI_ADDR[7](2)
236 * GPY5[0] EBI_DATA[0](2)
237 * GPY5[1] EBI_DATA[1](2)
238 * GPY5[2] EBI_DATA[2](2)
239 * GPY5[3] EBI_DATA[3](2)
240 * GPY5[4] EBI_DATA[4](2)
241 * GPY5[5] EBI_DATA[5](2)
242 * GPY5[6] EBI_DATA[6](2)
243 * GPY5[7] EBI_DATA[7](2)
245 * GPY6[0] EBI_DATA[8](2)
246 * GPY6[1] EBI_DATA[9](2)
247 * GPY6[2] EBI_DATA[10](2)
248 * GPY6[3] EBI_DATA[11](2)
249 * GPY6[4] EBI_DATA[12](2)
250 * GPY6[5] EBI_DATA[13](2)
251 * GPY6[6] EBI_DATA[14](2)
252 * GPY6[7] EBI_DATA[15](2)
254 for (i = 0; i < 8; i++) {
255 gpio_cfg_pin(EXYNOS5_GPIO_Y30 + i, S5P_GPIO_FUNC(2));
256 gpio_set_pull(EXYNOS5_GPIO_Y30 + i, S5P_GPIO_PULL_UP);
258 gpio_cfg_pin(EXYNOS5_GPIO_Y50 + i, S5P_GPIO_FUNC(2));
259 gpio_set_pull(EXYNOS5_GPIO_Y50 + i, S5P_GPIO_PULL_UP);
261 gpio_cfg_pin(EXYNOS5_GPIO_Y60 + i, S5P_GPIO_FUNC(2));
262 gpio_set_pull(EXYNOS5_GPIO_Y60 + i, S5P_GPIO_PULL_UP);
266 static void exynos5_i2c_config(int peripheral, int flags)
271 if (flags & PINMUX_FLAG_HS_MODE) {
279 switch (peripheral) {
281 gpio_cfg_pin(EXYNOS5_GPIO_B30, S5P_GPIO_FUNC(func01));
282 gpio_cfg_pin(EXYNOS5_GPIO_B31, S5P_GPIO_FUNC(func01));
285 gpio_cfg_pin(EXYNOS5_GPIO_B32, S5P_GPIO_FUNC(func01));
286 gpio_cfg_pin(EXYNOS5_GPIO_B33, S5P_GPIO_FUNC(func01));
289 gpio_cfg_pin(EXYNOS5_GPIO_A06, S5P_GPIO_FUNC(func23));
290 gpio_cfg_pin(EXYNOS5_GPIO_A07, S5P_GPIO_FUNC(func23));
293 gpio_cfg_pin(EXYNOS5_GPIO_A12, S5P_GPIO_FUNC(func23));
294 gpio_cfg_pin(EXYNOS5_GPIO_A13, S5P_GPIO_FUNC(func23));
297 gpio_cfg_pin(EXYNOS5_GPIO_A20, S5P_GPIO_FUNC(0x3));
298 gpio_cfg_pin(EXYNOS5_GPIO_A21, S5P_GPIO_FUNC(0x3));
301 gpio_cfg_pin(EXYNOS5_GPIO_A22, S5P_GPIO_FUNC(0x3));
302 gpio_cfg_pin(EXYNOS5_GPIO_A23, S5P_GPIO_FUNC(0x3));
305 gpio_cfg_pin(EXYNOS5_GPIO_B13, S5P_GPIO_FUNC(0x4));
306 gpio_cfg_pin(EXYNOS5_GPIO_B14, S5P_GPIO_FUNC(0x4));
309 gpio_cfg_pin(EXYNOS5_GPIO_B22, S5P_GPIO_FUNC(0x3));
310 gpio_cfg_pin(EXYNOS5_GPIO_B23, S5P_GPIO_FUNC(0x3));
315 static void exynos5420_i2c_config(int peripheral)
317 switch (peripheral) {
319 gpio_cfg_pin(EXYNOS5420_GPIO_B30, S5P_GPIO_FUNC(0x2));
320 gpio_cfg_pin(EXYNOS5420_GPIO_B31, S5P_GPIO_FUNC(0x2));
323 gpio_cfg_pin(EXYNOS5420_GPIO_B32, S5P_GPIO_FUNC(0x2));
324 gpio_cfg_pin(EXYNOS5420_GPIO_B33, S5P_GPIO_FUNC(0x2));
327 gpio_cfg_pin(EXYNOS5420_GPIO_A06, S5P_GPIO_FUNC(0x3));
328 gpio_cfg_pin(EXYNOS5420_GPIO_A07, S5P_GPIO_FUNC(0x3));
331 gpio_cfg_pin(EXYNOS5420_GPIO_A12, S5P_GPIO_FUNC(0x3));
332 gpio_cfg_pin(EXYNOS5420_GPIO_A13, S5P_GPIO_FUNC(0x3));
335 gpio_cfg_pin(EXYNOS5420_GPIO_A20, S5P_GPIO_FUNC(0x3));
336 gpio_cfg_pin(EXYNOS5420_GPIO_A21, S5P_GPIO_FUNC(0x3));
339 gpio_cfg_pin(EXYNOS5420_GPIO_A22, S5P_GPIO_FUNC(0x3));
340 gpio_cfg_pin(EXYNOS5420_GPIO_A23, S5P_GPIO_FUNC(0x3));
343 gpio_cfg_pin(EXYNOS5420_GPIO_B13, S5P_GPIO_FUNC(0x4));
344 gpio_cfg_pin(EXYNOS5420_GPIO_B14, S5P_GPIO_FUNC(0x4));
347 gpio_cfg_pin(EXYNOS5420_GPIO_B22, S5P_GPIO_FUNC(0x3));
348 gpio_cfg_pin(EXYNOS5420_GPIO_B23, S5P_GPIO_FUNC(0x3));
351 gpio_cfg_pin(EXYNOS5420_GPIO_B34, S5P_GPIO_FUNC(0x2));
352 gpio_cfg_pin(EXYNOS5420_GPIO_B35, S5P_GPIO_FUNC(0x2));
355 gpio_cfg_pin(EXYNOS5420_GPIO_B36, S5P_GPIO_FUNC(0x2));
356 gpio_cfg_pin(EXYNOS5420_GPIO_B37, S5P_GPIO_FUNC(0x2));
358 case PERIPH_ID_I2C10:
359 gpio_cfg_pin(EXYNOS5420_GPIO_B40, S5P_GPIO_FUNC(0x2));
360 gpio_cfg_pin(EXYNOS5420_GPIO_B41, S5P_GPIO_FUNC(0x2));
365 static void exynos5_i2s_config(int peripheral)
369 switch (peripheral) {
371 for (i = 0; i < 5; i++)
372 gpio_cfg_pin(EXYNOS5_GPIO_Z0 + i, S5P_GPIO_FUNC(0x02));
375 for (i = 0; i < 5; i++)
376 gpio_cfg_pin(EXYNOS5_GPIO_B00 + i, S5P_GPIO_FUNC(0x02));
381 static void exynos5420_i2s_config(int peripheral)
385 switch (peripheral) {
387 for (i = 0; i < 5; i++)
388 gpio_cfg_pin(EXYNOS5420_GPIO_Z0 + i,
389 S5P_GPIO_FUNC(0x02));
395 void exynos5_spi_config(int peripheral)
397 int cfg = 0, pin = 0, i;
399 switch (peripheral) {
401 cfg = S5P_GPIO_FUNC(0x2);
402 pin = EXYNOS5_GPIO_A20;
405 cfg = S5P_GPIO_FUNC(0x2);
406 pin = EXYNOS5_GPIO_A24;
409 cfg = S5P_GPIO_FUNC(0x5);
410 pin = EXYNOS5_GPIO_B11;
413 cfg = S5P_GPIO_FUNC(0x2);
414 pin = EXYNOS5_GPIO_F10;
417 for (i = 0; i < 2; i++) {
418 gpio_cfg_pin(EXYNOS5_GPIO_F02 + i, S5P_GPIO_FUNC(0x4));
419 gpio_cfg_pin(EXYNOS5_GPIO_E04 + i, S5P_GPIO_FUNC(0x4));
423 if (peripheral != PERIPH_ID_SPI4) {
424 for (i = pin; i < pin + 4; i++)
425 gpio_cfg_pin(i, cfg);
429 void exynos5420_spi_config(int peripheral)
433 switch (peripheral) {
435 pin = EXYNOS5420_GPIO_A20;
436 cfg = S5P_GPIO_FUNC(0x2);
439 pin = EXYNOS5420_GPIO_A24;
440 cfg = S5P_GPIO_FUNC(0x2);
443 pin = EXYNOS5420_GPIO_B11;
444 cfg = S5P_GPIO_FUNC(0x5);
447 pin = EXYNOS5420_GPIO_F10;
448 cfg = S5P_GPIO_FUNC(0x2);
457 debug("%s: invalid peripheral %d", __func__, peripheral);
461 if (peripheral != PERIPH_ID_SPI4) {
462 for (i = pin; i < pin + 4; i++)
463 gpio_cfg_pin(i, cfg);
465 for (i = 0; i < 2; i++) {
466 gpio_cfg_pin(EXYNOS5420_GPIO_F02 + i,
468 gpio_cfg_pin(EXYNOS5420_GPIO_E04 + i,
474 static int exynos5_pinmux_config(int peripheral, int flags)
476 switch (peripheral) {
477 case PERIPH_ID_UART0:
478 case PERIPH_ID_UART1:
479 case PERIPH_ID_UART2:
480 case PERIPH_ID_UART3:
481 exynos5_uart_config(peripheral);
483 case PERIPH_ID_SDMMC0:
484 case PERIPH_ID_SDMMC1:
485 case PERIPH_ID_SDMMC2:
486 case PERIPH_ID_SDMMC3:
487 return exynos5_mmc_config(peripheral, flags);
488 case PERIPH_ID_SROMC:
489 exynos5_sromc_config(flags);
499 exynos5_i2c_config(peripheral, flags);
503 exynos5_i2s_config(peripheral);
510 exynos5_spi_config(peripheral);
512 case PERIPH_ID_DPHPD:
513 /* Set Hotplug detect for DP */
514 gpio_cfg_pin(EXYNOS5_GPIO_X07, S5P_GPIO_FUNC(0x3));
517 * Hotplug detect should have an external pullup; disable the
518 * internal pulldown so they don't fight.
520 gpio_set_pull(EXYNOS5_GPIO_X07, S5P_GPIO_PULL_NONE);
523 gpio_cfg_pin(EXYNOS5_GPIO_B20, S5P_GPIO_FUNC(2));
526 debug("%s: invalid peripheral %d", __func__, peripheral);
533 static int exynos5420_pinmux_config(int peripheral, int flags)
535 switch (peripheral) {
536 case PERIPH_ID_UART0:
537 case PERIPH_ID_UART1:
538 case PERIPH_ID_UART2:
539 case PERIPH_ID_UART3:
540 exynos5420_uart_config(peripheral);
542 case PERIPH_ID_SDMMC0:
543 case PERIPH_ID_SDMMC1:
544 case PERIPH_ID_SDMMC2:
545 case PERIPH_ID_SDMMC3:
546 return exynos5420_mmc_config(peripheral, flags);
552 exynos5420_spi_config(peripheral);
564 case PERIPH_ID_I2C10:
565 exynos5420_i2c_config(peripheral);
568 exynos5420_i2s_config(peripheral);
571 gpio_cfg_pin(EXYNOS5420_GPIO_B20, S5P_GPIO_FUNC(2));
574 debug("%s: invalid peripheral %d", __func__, peripheral);
581 static void exynos4_i2c_config(int peripheral, int flags)
583 switch (peripheral) {
585 gpio_cfg_pin(EXYNOS4_GPIO_D10, S5P_GPIO_FUNC(0x2));
586 gpio_cfg_pin(EXYNOS4_GPIO_D11, S5P_GPIO_FUNC(0x2));
589 gpio_cfg_pin(EXYNOS4_GPIO_D12, S5P_GPIO_FUNC(0x2));
590 gpio_cfg_pin(EXYNOS4_GPIO_D13, S5P_GPIO_FUNC(0x2));
593 gpio_cfg_pin(EXYNOS4_GPIO_A06, S5P_GPIO_FUNC(0x3));
594 gpio_cfg_pin(EXYNOS4_GPIO_A07, S5P_GPIO_FUNC(0x3));
597 gpio_cfg_pin(EXYNOS4_GPIO_A12, S5P_GPIO_FUNC(0x3));
598 gpio_cfg_pin(EXYNOS4_GPIO_A13, S5P_GPIO_FUNC(0x3));
601 gpio_cfg_pin(EXYNOS4_GPIO_B2, S5P_GPIO_FUNC(0x3));
602 gpio_cfg_pin(EXYNOS4_GPIO_B3, S5P_GPIO_FUNC(0x3));
605 gpio_cfg_pin(EXYNOS4_GPIO_B6, S5P_GPIO_FUNC(0x3));
606 gpio_cfg_pin(EXYNOS4_GPIO_B7, S5P_GPIO_FUNC(0x3));
609 gpio_cfg_pin(EXYNOS4_GPIO_C13, S5P_GPIO_FUNC(0x4));
610 gpio_cfg_pin(EXYNOS4_GPIO_C14, S5P_GPIO_FUNC(0x4));
613 gpio_cfg_pin(EXYNOS4_GPIO_D02, S5P_GPIO_FUNC(0x3));
614 gpio_cfg_pin(EXYNOS4_GPIO_D03, S5P_GPIO_FUNC(0x3));
619 static int exynos4_mmc_config(int peripheral, int flags)
621 int i, start = 0, start_ext = 0;
622 unsigned int func, ext_func;
624 switch (peripheral) {
625 case PERIPH_ID_SDMMC0:
626 start = EXYNOS4_GPIO_K00;
627 start_ext = EXYNOS4_GPIO_K13;
628 func = S5P_GPIO_FUNC(0x2);
629 ext_func = S5P_GPIO_FUNC(0x3);
631 case PERIPH_ID_SDMMC2:
632 start = EXYNOS4_GPIO_K20;
633 start_ext = EXYNOS4_GPIO_K33;
634 func = S5P_GPIO_FUNC(0x2);
635 ext_func = S5P_GPIO_FUNC(0x3);
637 case PERIPH_ID_SDMMC4:
638 start = EXYNOS4_GPIO_K00;
639 start_ext = EXYNOS4_GPIO_K13;
640 func = S5P_GPIO_FUNC(0x3);
641 ext_func = S5P_GPIO_FUNC(0x4);
646 for (i = start; i < (start + 7); i++) {
647 if (i == (start + 2))
649 gpio_cfg_pin(i, func);
650 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
651 gpio_set_drv(i, S5P_GPIO_DRV_4X);
653 /* SDMMC2 do not use 8bit mode at exynos4 */
654 if (flags & PINMUX_FLAG_8BIT_MODE) {
655 for (i = start_ext; i < (start_ext + 4); i++) {
656 gpio_cfg_pin(i, ext_func);
657 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
658 gpio_set_drv(i, S5P_GPIO_DRV_4X);
665 static void exynos4_uart_config(int peripheral)
669 switch (peripheral) {
670 case PERIPH_ID_UART0:
671 start = EXYNOS4_GPIO_A00;
674 case PERIPH_ID_UART1:
675 start = EXYNOS4_GPIO_A04;
678 case PERIPH_ID_UART2:
679 start = EXYNOS4_GPIO_A10;
682 case PERIPH_ID_UART3:
683 start = EXYNOS4_GPIO_A14;
687 debug("%s: invalid peripheral %d", __func__, peripheral);
690 for (i = start; i < (start + count); i++) {
691 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
692 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
696 static void exynos4x12_i2c_config(int peripheral, int flags)
698 switch (peripheral) {
700 gpio_cfg_pin(EXYNOS4X12_GPIO_D10, S5P_GPIO_FUNC(0x2));
701 gpio_cfg_pin(EXYNOS4X12_GPIO_D11, S5P_GPIO_FUNC(0x2));
704 gpio_cfg_pin(EXYNOS4X12_GPIO_D12, S5P_GPIO_FUNC(0x2));
705 gpio_cfg_pin(EXYNOS4X12_GPIO_D13, S5P_GPIO_FUNC(0x2));
708 gpio_cfg_pin(EXYNOS4X12_GPIO_A06, S5P_GPIO_FUNC(0x3));
709 gpio_cfg_pin(EXYNOS4X12_GPIO_A07, S5P_GPIO_FUNC(0x3));
712 gpio_cfg_pin(EXYNOS4X12_GPIO_A12, S5P_GPIO_FUNC(0x3));
713 gpio_cfg_pin(EXYNOS4X12_GPIO_A13, S5P_GPIO_FUNC(0x3));
716 gpio_cfg_pin(EXYNOS4X12_GPIO_B2, S5P_GPIO_FUNC(0x3));
717 gpio_cfg_pin(EXYNOS4X12_GPIO_B3, S5P_GPIO_FUNC(0x3));
720 gpio_cfg_pin(EXYNOS4X12_GPIO_B6, S5P_GPIO_FUNC(0x3));
721 gpio_cfg_pin(EXYNOS4X12_GPIO_B7, S5P_GPIO_FUNC(0x3));
724 gpio_cfg_pin(EXYNOS4X12_GPIO_C13, S5P_GPIO_FUNC(0x4));
725 gpio_cfg_pin(EXYNOS4X12_GPIO_C14, S5P_GPIO_FUNC(0x4));
728 gpio_cfg_pin(EXYNOS4X12_GPIO_D02, S5P_GPIO_FUNC(0x3));
729 gpio_cfg_pin(EXYNOS4X12_GPIO_D03, S5P_GPIO_FUNC(0x3));
734 static int exynos4x12_mmc_config(int peripheral, int flags)
736 int i, start = 0, start_ext = 0;
737 unsigned int func, ext_func;
739 switch (peripheral) {
740 case PERIPH_ID_SDMMC0:
741 start = EXYNOS4X12_GPIO_K00;
742 start_ext = EXYNOS4X12_GPIO_K13;
743 func = S5P_GPIO_FUNC(0x2);
744 ext_func = S5P_GPIO_FUNC(0x3);
746 case PERIPH_ID_SDMMC2:
747 start = EXYNOS4X12_GPIO_K20;
748 start_ext = EXYNOS4X12_GPIO_K33;
749 func = S5P_GPIO_FUNC(0x2);
750 ext_func = S5P_GPIO_FUNC(0x3);
752 case PERIPH_ID_SDMMC4:
753 start = EXYNOS4X12_GPIO_K00;
754 start_ext = EXYNOS4X12_GPIO_K13;
755 func = S5P_GPIO_FUNC(0x3);
756 ext_func = S5P_GPIO_FUNC(0x4);
761 for (i = start; i < (start + 7); i++) {
762 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
763 if (i == (start + 2))
765 gpio_cfg_pin(i, func);
766 gpio_set_drv(i, S5P_GPIO_DRV_4X);
768 if (flags & PINMUX_FLAG_8BIT_MODE) {
769 for (i = start_ext; i < (start_ext + 4); i++) {
770 gpio_cfg_pin(i, ext_func);
771 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
772 gpio_set_drv(i, S5P_GPIO_DRV_4X);
779 static void exynos4x12_uart_config(int peripheral)
783 switch (peripheral) {
784 case PERIPH_ID_UART0:
785 start = EXYNOS4X12_GPIO_A00;
788 case PERIPH_ID_UART1:
789 start = EXYNOS4X12_GPIO_A04;
792 case PERIPH_ID_UART2:
793 start = EXYNOS4X12_GPIO_A10;
796 case PERIPH_ID_UART3:
797 start = EXYNOS4X12_GPIO_A14;
801 debug("%s: invalid peripheral %d", __func__, peripheral);
804 for (i = start; i < (start + count); i++) {
805 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
806 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
810 static int exynos4_pinmux_config(int peripheral, int flags)
812 switch (peripheral) {
813 case PERIPH_ID_UART0:
814 case PERIPH_ID_UART1:
815 case PERIPH_ID_UART2:
816 case PERIPH_ID_UART3:
817 exynos4_uart_config(peripheral);
827 exynos4_i2c_config(peripheral, flags);
829 case PERIPH_ID_SDMMC0:
830 case PERIPH_ID_SDMMC2:
831 case PERIPH_ID_SDMMC4:
832 return exynos4_mmc_config(peripheral, flags);
833 case PERIPH_ID_SDMMC1:
834 case PERIPH_ID_SDMMC3:
835 debug("SDMMC device %d not implemented\n", peripheral);
838 debug("%s: invalid peripheral %d", __func__, peripheral);
845 static int exynos4x12_pinmux_config(int peripheral, int flags)
847 switch (peripheral) {
848 case PERIPH_ID_UART0:
849 case PERIPH_ID_UART1:
850 case PERIPH_ID_UART2:
851 case PERIPH_ID_UART3:
852 exynos4x12_uart_config(peripheral);
862 exynos4x12_i2c_config(peripheral, flags);
864 case PERIPH_ID_SDMMC0:
865 case PERIPH_ID_SDMMC2:
866 case PERIPH_ID_SDMMC4:
867 return exynos4x12_mmc_config(peripheral, flags);
868 case PERIPH_ID_SDMMC1:
869 case PERIPH_ID_SDMMC3:
870 debug("SDMMC device %d not implemented\n", peripheral);
873 debug("%s: invalid peripheral %d", __func__, peripheral);
880 int exynos_pinmux_config(int peripheral, int flags)
882 if (cpu_is_exynos5()) {
883 if (proid_is_exynos542x())
884 return exynos5420_pinmux_config(peripheral, flags);
885 else if (proid_is_exynos5250())
886 return exynos5_pinmux_config(peripheral, flags);
887 } else if (cpu_is_exynos4()) {
888 if (proid_is_exynos4412())
889 return exynos4x12_pinmux_config(peripheral, flags);
891 return exynos4_pinmux_config(peripheral, flags);
894 debug("pinmux functionality not supported\n");
899 #if CONFIG_IS_ENABLED(OF_CONTROL)
900 static int exynos4_pinmux_decode_periph_id(const void *blob, int node)
905 err = fdtdec_get_int_array(blob, node, "interrupts", cell,
908 debug(" invalid peripheral id\n");
909 return PERIPH_ID_NONE;
915 static int exynos5_pinmux_decode_periph_id(const void *blob, int node)
920 err = fdtdec_get_int_array(blob, node, "interrupts", cell,
923 return PERIPH_ID_NONE;
928 int pinmux_decode_periph_id(const void *blob, int node)
930 if (cpu_is_exynos5())
931 return exynos5_pinmux_decode_periph_id(blob, node);
932 else if (cpu_is_exynos4())
933 return exynos4_pinmux_decode_periph_id(blob, node);
935 return PERIPH_ID_NONE;