blob: 5d3403ae441697ecfc7d1e5ad461a7f9f4604635 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0
Tom Warren61c6d0e2012-12-11 13:34:15 +00002/*
3 * Copyright (c) 2010-2012, NVIDIA CORPORATION. All rights reserved.
Tom Warren61c6d0e2012-12-11 13:34:15 +00004 */
5
6/* Tegra30 high-level function multiplexing */
7
Simon Glass0f2af882020-05-10 11:40:05 -06008#include <log.h>
Tom Warren61c6d0e2012-12-11 13:34:15 +00009#include <asm/arch/clock.h>
10#include <asm/arch/funcmux.h>
11#include <asm/arch/pinmux.h>
12
13int funcmux_select(enum periph_id id, int config)
14{
15 int bad_config = config != FUNCMUX_DEFAULT;
16
17 switch (id) {
18 case PERIPH_ID_UART1:
19 switch (config) {
20 case FUNCMUX_UART1_ULPI:
Stephen Warren43eed912014-03-21 12:28:59 -060021 pinmux_set_func(PMUX_PINGRP_ULPI_DATA0_PO1,
22 PMUX_FUNC_UARTA);
23 pinmux_set_func(PMUX_PINGRP_ULPI_DATA1_PO2,
24 PMUX_FUNC_UARTA);
25 pinmux_set_func(PMUX_PINGRP_ULPI_DATA2_PO3,
26 PMUX_FUNC_UARTA);
27 pinmux_set_func(PMUX_PINGRP_ULPI_DATA3_PO4,
28 PMUX_FUNC_UARTA);
29 pinmux_tristate_disable(PMUX_PINGRP_ULPI_DATA0_PO1);
30 pinmux_tristate_disable(PMUX_PINGRP_ULPI_DATA1_PO2);
31 pinmux_tristate_disable(PMUX_PINGRP_ULPI_DATA2_PO3);
32 pinmux_tristate_disable(PMUX_PINGRP_ULPI_DATA3_PO4);
Tom Warren61c6d0e2012-12-11 13:34:15 +000033 break;
34 }
35 break;
Jonas Schwöbela2c9b972024-01-22 14:40:27 +020036 case PERIPH_ID_UART5:
37 switch (config) {
38 case FUNCMUX_UART5_SDMMC1:
39 pinmux_set_func(PMUX_PINGRP_SDMMC1_DAT3_PY4,
40 PMUX_FUNC_UARTE);
41 pinmux_set_func(PMUX_PINGRP_SDMMC1_DAT2_PY5,
42 PMUX_FUNC_UARTE);
43
44 pinmux_set_io(PMUX_PINGRP_SDMMC1_DAT3_PY4, PMUX_PIN_OUTPUT);
45 pinmux_set_io(PMUX_PINGRP_SDMMC1_DAT2_PY5, PMUX_PIN_INPUT);
46
47 pinmux_tristate_disable(PMUX_PINGRP_SDMMC1_DAT3_PY4);
48 pinmux_tristate_disable(PMUX_PINGRP_SDMMC1_DAT2_PY5);
49 break;
50 }
51 break;
Tom Warren61c6d0e2012-12-11 13:34:15 +000052
53 /* Add other periph IDs here as needed */
54
55 default:
56 debug("%s: invalid periph_id %d", __func__, id);
57 return -1;
58 }
59
60 if (bad_config) {
61 debug("%s: invalid config %d for periph_id %d", __func__,
62 config, id);
63 return -1;
64 }
65 return 0;
66}