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 void exynos5_spi_config(int peripheral)
383 int cfg = 0, pin = 0, i;
385 switch (peripheral) {
387 cfg = S5P_GPIO_FUNC(0x2);
388 pin = EXYNOS5_GPIO_A20;
391 cfg = S5P_GPIO_FUNC(0x2);
392 pin = EXYNOS5_GPIO_A24;
395 cfg = S5P_GPIO_FUNC(0x5);
396 pin = EXYNOS5_GPIO_B11;
399 cfg = S5P_GPIO_FUNC(0x2);
400 pin = EXYNOS5_GPIO_F10;
403 for (i = 0; i < 2; i++) {
404 gpio_cfg_pin(EXYNOS5_GPIO_F02 + i, S5P_GPIO_FUNC(0x4));
405 gpio_cfg_pin(EXYNOS5_GPIO_E04 + i, S5P_GPIO_FUNC(0x4));
409 if (peripheral != PERIPH_ID_SPI4) {
410 for (i = pin; i < pin + 4; i++)
411 gpio_cfg_pin(i, cfg);
415 void exynos5420_spi_config(int peripheral)
419 switch (peripheral) {
421 pin = EXYNOS5420_GPIO_A20;
422 cfg = S5P_GPIO_FUNC(0x2);
425 pin = EXYNOS5420_GPIO_A24;
426 cfg = S5P_GPIO_FUNC(0x2);
429 pin = EXYNOS5420_GPIO_B11;
430 cfg = S5P_GPIO_FUNC(0x5);
433 pin = EXYNOS5420_GPIO_F10;
434 cfg = S5P_GPIO_FUNC(0x2);
443 debug("%s: invalid peripheral %d", __func__, peripheral);
447 if (peripheral != PERIPH_ID_SPI4) {
448 for (i = pin; i < pin + 4; i++)
449 gpio_cfg_pin(i, cfg);
451 for (i = 0; i < 2; i++) {
452 gpio_cfg_pin(EXYNOS5420_GPIO_F02 + i,
454 gpio_cfg_pin(EXYNOS5420_GPIO_E04 + i,
460 static int exynos5_pinmux_config(int peripheral, int flags)
462 switch (peripheral) {
463 case PERIPH_ID_UART0:
464 case PERIPH_ID_UART1:
465 case PERIPH_ID_UART2:
466 case PERIPH_ID_UART3:
467 exynos5_uart_config(peripheral);
469 case PERIPH_ID_SDMMC0:
470 case PERIPH_ID_SDMMC1:
471 case PERIPH_ID_SDMMC2:
472 case PERIPH_ID_SDMMC3:
473 return exynos5_mmc_config(peripheral, flags);
474 case PERIPH_ID_SROMC:
475 exynos5_sromc_config(flags);
485 exynos5_i2c_config(peripheral, flags);
489 exynos5_i2s_config(peripheral);
496 exynos5_spi_config(peripheral);
498 case PERIPH_ID_DPHPD:
499 /* Set Hotplug detect for DP */
500 gpio_cfg_pin(EXYNOS5_GPIO_X07, S5P_GPIO_FUNC(0x3));
503 * Hotplug detect should have an external pullup; disable the
504 * internal pulldown so they don't fight.
506 gpio_set_pull(EXYNOS5_GPIO_X07, S5P_GPIO_PULL_NONE);
509 gpio_cfg_pin(EXYNOS5_GPIO_B20, S5P_GPIO_FUNC(2));
512 debug("%s: invalid peripheral %d", __func__, peripheral);
519 static int exynos5420_pinmux_config(int peripheral, int flags)
521 switch (peripheral) {
522 case PERIPH_ID_UART0:
523 case PERIPH_ID_UART1:
524 case PERIPH_ID_UART2:
525 case PERIPH_ID_UART3:
526 exynos5420_uart_config(peripheral);
528 case PERIPH_ID_SDMMC0:
529 case PERIPH_ID_SDMMC1:
530 case PERIPH_ID_SDMMC2:
531 case PERIPH_ID_SDMMC3:
532 return exynos5420_mmc_config(peripheral, flags);
538 exynos5420_spi_config(peripheral);
550 case PERIPH_ID_I2C10:
551 exynos5420_i2c_config(peripheral);
554 gpio_cfg_pin(EXYNOS5420_GPIO_B20, S5P_GPIO_FUNC(2));
557 debug("%s: invalid peripheral %d", __func__, peripheral);
564 static void exynos4_i2c_config(int peripheral, int flags)
566 switch (peripheral) {
568 gpio_cfg_pin(EXYNOS4_GPIO_D10, S5P_GPIO_FUNC(0x2));
569 gpio_cfg_pin(EXYNOS4_GPIO_D11, S5P_GPIO_FUNC(0x2));
572 gpio_cfg_pin(EXYNOS4_GPIO_D12, S5P_GPIO_FUNC(0x2));
573 gpio_cfg_pin(EXYNOS4_GPIO_D13, S5P_GPIO_FUNC(0x2));
576 gpio_cfg_pin(EXYNOS4_GPIO_A06, S5P_GPIO_FUNC(0x3));
577 gpio_cfg_pin(EXYNOS4_GPIO_A07, S5P_GPIO_FUNC(0x3));
580 gpio_cfg_pin(EXYNOS4_GPIO_A12, S5P_GPIO_FUNC(0x3));
581 gpio_cfg_pin(EXYNOS4_GPIO_A13, S5P_GPIO_FUNC(0x3));
584 gpio_cfg_pin(EXYNOS4_GPIO_B2, S5P_GPIO_FUNC(0x3));
585 gpio_cfg_pin(EXYNOS4_GPIO_B3, S5P_GPIO_FUNC(0x3));
588 gpio_cfg_pin(EXYNOS4_GPIO_B6, S5P_GPIO_FUNC(0x3));
589 gpio_cfg_pin(EXYNOS4_GPIO_B7, S5P_GPIO_FUNC(0x3));
592 gpio_cfg_pin(EXYNOS4_GPIO_C13, S5P_GPIO_FUNC(0x4));
593 gpio_cfg_pin(EXYNOS4_GPIO_C14, S5P_GPIO_FUNC(0x4));
596 gpio_cfg_pin(EXYNOS4_GPIO_D02, S5P_GPIO_FUNC(0x3));
597 gpio_cfg_pin(EXYNOS4_GPIO_D03, S5P_GPIO_FUNC(0x3));
602 static int exynos4_mmc_config(int peripheral, int flags)
604 int i, start = 0, start_ext = 0;
605 unsigned int func, ext_func;
607 switch (peripheral) {
608 case PERIPH_ID_SDMMC0:
609 start = EXYNOS4_GPIO_K00;
610 start_ext = EXYNOS4_GPIO_K13;
611 func = S5P_GPIO_FUNC(0x2);
612 ext_func = S5P_GPIO_FUNC(0x3);
614 case PERIPH_ID_SDMMC2:
615 start = EXYNOS4_GPIO_K20;
616 start_ext = EXYNOS4_GPIO_K33;
617 func = S5P_GPIO_FUNC(0x2);
618 ext_func = S5P_GPIO_FUNC(0x3);
620 case PERIPH_ID_SDMMC4:
621 start = EXYNOS4_GPIO_K00;
622 start_ext = EXYNOS4_GPIO_K13;
623 func = S5P_GPIO_FUNC(0x3);
624 ext_func = S5P_GPIO_FUNC(0x4);
629 for (i = start; i < (start + 7); i++) {
630 if (i == (start + 2))
632 gpio_cfg_pin(i, func);
633 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
634 gpio_set_drv(i, S5P_GPIO_DRV_4X);
636 /* SDMMC2 do not use 8bit mode at exynos4 */
637 if (flags & PINMUX_FLAG_8BIT_MODE) {
638 for (i = start_ext; i < (start_ext + 4); i++) {
639 gpio_cfg_pin(i, ext_func);
640 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
641 gpio_set_drv(i, S5P_GPIO_DRV_4X);
648 static void exynos4_uart_config(int peripheral)
652 switch (peripheral) {
653 case PERIPH_ID_UART0:
654 start = EXYNOS4_GPIO_A00;
657 case PERIPH_ID_UART1:
658 start = EXYNOS4_GPIO_A04;
661 case PERIPH_ID_UART2:
662 start = EXYNOS4_GPIO_A10;
665 case PERIPH_ID_UART3:
666 start = EXYNOS4_GPIO_A14;
670 debug("%s: invalid peripheral %d", __func__, peripheral);
673 for (i = start; i < (start + count); i++) {
674 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
675 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
679 static void exynos4x12_i2c_config(int peripheral, int flags)
681 switch (peripheral) {
683 gpio_cfg_pin(EXYNOS4X12_GPIO_D10, S5P_GPIO_FUNC(0x2));
684 gpio_cfg_pin(EXYNOS4X12_GPIO_D11, S5P_GPIO_FUNC(0x2));
687 gpio_cfg_pin(EXYNOS4X12_GPIO_D12, S5P_GPIO_FUNC(0x2));
688 gpio_cfg_pin(EXYNOS4X12_GPIO_D13, S5P_GPIO_FUNC(0x2));
691 gpio_cfg_pin(EXYNOS4X12_GPIO_A06, S5P_GPIO_FUNC(0x3));
692 gpio_cfg_pin(EXYNOS4X12_GPIO_A07, S5P_GPIO_FUNC(0x3));
695 gpio_cfg_pin(EXYNOS4X12_GPIO_A12, S5P_GPIO_FUNC(0x3));
696 gpio_cfg_pin(EXYNOS4X12_GPIO_A13, S5P_GPIO_FUNC(0x3));
699 gpio_cfg_pin(EXYNOS4X12_GPIO_B2, S5P_GPIO_FUNC(0x3));
700 gpio_cfg_pin(EXYNOS4X12_GPIO_B3, S5P_GPIO_FUNC(0x3));
703 gpio_cfg_pin(EXYNOS4X12_GPIO_B6, S5P_GPIO_FUNC(0x3));
704 gpio_cfg_pin(EXYNOS4X12_GPIO_B7, S5P_GPIO_FUNC(0x3));
707 gpio_cfg_pin(EXYNOS4X12_GPIO_C13, S5P_GPIO_FUNC(0x4));
708 gpio_cfg_pin(EXYNOS4X12_GPIO_C14, S5P_GPIO_FUNC(0x4));
711 gpio_cfg_pin(EXYNOS4X12_GPIO_D02, S5P_GPIO_FUNC(0x3));
712 gpio_cfg_pin(EXYNOS4X12_GPIO_D03, S5P_GPIO_FUNC(0x3));
717 static int exynos4x12_mmc_config(int peripheral, int flags)
719 int i, start = 0, start_ext = 0;
720 unsigned int func, ext_func;
722 switch (peripheral) {
723 case PERIPH_ID_SDMMC0:
724 start = EXYNOS4X12_GPIO_K00;
725 start_ext = EXYNOS4X12_GPIO_K13;
726 func = S5P_GPIO_FUNC(0x2);
727 ext_func = S5P_GPIO_FUNC(0x3);
729 case PERIPH_ID_SDMMC2:
730 start = EXYNOS4X12_GPIO_K20;
731 start_ext = EXYNOS4X12_GPIO_K33;
732 func = S5P_GPIO_FUNC(0x2);
733 ext_func = S5P_GPIO_FUNC(0x3);
735 case PERIPH_ID_SDMMC4:
736 start = EXYNOS4X12_GPIO_K00;
737 start_ext = EXYNOS4X12_GPIO_K13;
738 func = S5P_GPIO_FUNC(0x3);
739 ext_func = S5P_GPIO_FUNC(0x4);
744 for (i = start; i < (start + 7); i++) {
745 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
746 if (i == (start + 2))
748 gpio_cfg_pin(i, func);
749 gpio_set_drv(i, S5P_GPIO_DRV_4X);
751 if (flags & PINMUX_FLAG_8BIT_MODE) {
752 for (i = start_ext; i < (start_ext + 4); i++) {
753 gpio_cfg_pin(i, ext_func);
754 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
755 gpio_set_drv(i, S5P_GPIO_DRV_4X);
762 static void exynos4x12_uart_config(int peripheral)
766 switch (peripheral) {
767 case PERIPH_ID_UART0:
768 start = EXYNOS4X12_GPIO_A00;
771 case PERIPH_ID_UART1:
772 start = EXYNOS4X12_GPIO_A04;
775 case PERIPH_ID_UART2:
776 start = EXYNOS4X12_GPIO_A10;
779 case PERIPH_ID_UART3:
780 start = EXYNOS4X12_GPIO_A14;
784 debug("%s: invalid peripheral %d", __func__, peripheral);
787 for (i = start; i < (start + count); i++) {
788 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
789 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
793 static int exynos4_pinmux_config(int peripheral, int flags)
795 switch (peripheral) {
796 case PERIPH_ID_UART0:
797 case PERIPH_ID_UART1:
798 case PERIPH_ID_UART2:
799 case PERIPH_ID_UART3:
800 exynos4_uart_config(peripheral);
810 exynos4_i2c_config(peripheral, flags);
812 case PERIPH_ID_SDMMC0:
813 case PERIPH_ID_SDMMC2:
814 case PERIPH_ID_SDMMC4:
815 return exynos4_mmc_config(peripheral, flags);
816 case PERIPH_ID_SDMMC1:
817 case PERIPH_ID_SDMMC3:
818 debug("SDMMC device %d not implemented\n", peripheral);
821 debug("%s: invalid peripheral %d", __func__, peripheral);
828 static int exynos4x12_pinmux_config(int peripheral, int flags)
830 switch (peripheral) {
831 case PERIPH_ID_UART0:
832 case PERIPH_ID_UART1:
833 case PERIPH_ID_UART2:
834 case PERIPH_ID_UART3:
835 exynos4x12_uart_config(peripheral);
845 exynos4x12_i2c_config(peripheral, flags);
847 case PERIPH_ID_SDMMC0:
848 case PERIPH_ID_SDMMC2:
849 case PERIPH_ID_SDMMC4:
850 return exynos4x12_mmc_config(peripheral, flags);
851 case PERIPH_ID_SDMMC1:
852 case PERIPH_ID_SDMMC3:
853 debug("SDMMC device %d not implemented\n", peripheral);
856 debug("%s: invalid peripheral %d", __func__, peripheral);
863 int exynos_pinmux_config(int peripheral, int flags)
865 if (cpu_is_exynos5()) {
866 if (proid_is_exynos542x())
867 return exynos5420_pinmux_config(peripheral, flags);
868 else if (proid_is_exynos5250())
869 return exynos5_pinmux_config(peripheral, flags);
870 } else if (cpu_is_exynos4()) {
871 if (proid_is_exynos4412())
872 return exynos4x12_pinmux_config(peripheral, flags);
874 return exynos4_pinmux_config(peripheral, flags);
877 debug("pinmux functionality not supported\n");
882 #if CONFIG_IS_ENABLED(OF_CONTROL)
883 static int exynos4_pinmux_decode_periph_id(const void *blob, int node)
888 err = fdtdec_get_int_array(blob, node, "interrupts", cell,
891 debug(" invalid peripheral id\n");
892 return PERIPH_ID_NONE;
898 static int exynos5_pinmux_decode_periph_id(const void *blob, int node)
903 err = fdtdec_get_int_array(blob, node, "interrupts", cell,
906 return PERIPH_ID_NONE;
911 int pinmux_decode_periph_id(const void *blob, int node)
913 if (cpu_is_exynos5())
914 return exynos5_pinmux_decode_periph_id(blob, node);
915 else if (cpu_is_exynos4())
916 return exynos4_pinmux_decode_periph_id(blob, node);
918 return PERIPH_ID_NONE;