1*09f455dcSMasahiro Yamada /*
2*09f455dcSMasahiro Yamada  * Copyright (c) 2010-2013, NVIDIA CORPORATION.  All rights reserved.
3*09f455dcSMasahiro Yamada  *
4*09f455dcSMasahiro Yamada  * This program is free software; you can redistribute it and/or modify it
5*09f455dcSMasahiro Yamada  * under the terms and conditions of the GNU General Public License,
6*09f455dcSMasahiro Yamada  * version 2, as published by the Free Software Foundation.
7*09f455dcSMasahiro Yamada  *
8*09f455dcSMasahiro Yamada  * This program is distributed in the hope it will be useful, but WITHOUT
9*09f455dcSMasahiro Yamada  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10*09f455dcSMasahiro Yamada  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
11*09f455dcSMasahiro Yamada  * more details.
12*09f455dcSMasahiro Yamada  *
13*09f455dcSMasahiro Yamada  * You should have received a copy of the GNU General Public License
14*09f455dcSMasahiro Yamada  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15*09f455dcSMasahiro Yamada  */
16*09f455dcSMasahiro Yamada 
17*09f455dcSMasahiro Yamada /* Tegra114 high-level function multiplexing */
18*09f455dcSMasahiro Yamada 
19*09f455dcSMasahiro Yamada #include <common.h>
20*09f455dcSMasahiro Yamada #include <asm/arch/clock.h>
21*09f455dcSMasahiro Yamada #include <asm/arch/funcmux.h>
22*09f455dcSMasahiro Yamada #include <asm/arch/pinmux.h>
23*09f455dcSMasahiro Yamada 
24*09f455dcSMasahiro Yamada int funcmux_select(enum periph_id id, int config)
25*09f455dcSMasahiro Yamada {
26*09f455dcSMasahiro Yamada 	int bad_config = config != FUNCMUX_DEFAULT;
27*09f455dcSMasahiro Yamada 
28*09f455dcSMasahiro Yamada 	switch (id) {
29*09f455dcSMasahiro Yamada 	case PERIPH_ID_UART4:
30*09f455dcSMasahiro Yamada 		switch (config) {
31*09f455dcSMasahiro Yamada 		case FUNCMUX_UART4_GMI:
32*09f455dcSMasahiro Yamada 			pinmux_set_func(PMUX_PINGRP_GMI_A16_PJ7,
33*09f455dcSMasahiro Yamada 					PMUX_FUNC_UARTD);
34*09f455dcSMasahiro Yamada 			pinmux_set_func(PMUX_PINGRP_GMI_A17_PB0,
35*09f455dcSMasahiro Yamada 					PMUX_FUNC_UARTD);
36*09f455dcSMasahiro Yamada 			pinmux_set_func(PMUX_PINGRP_GMI_A18_PB1,
37*09f455dcSMasahiro Yamada 					PMUX_FUNC_UARTD);
38*09f455dcSMasahiro Yamada 			pinmux_set_func(PMUX_PINGRP_GMI_A19_PK7,
39*09f455dcSMasahiro Yamada 					PMUX_FUNC_UARTD);
40*09f455dcSMasahiro Yamada 
41*09f455dcSMasahiro Yamada 			pinmux_set_io(PMUX_PINGRP_GMI_A16_PJ7, PMUX_PIN_OUTPUT);
42*09f455dcSMasahiro Yamada 			pinmux_set_io(PMUX_PINGRP_GMI_A17_PB0, PMUX_PIN_INPUT);
43*09f455dcSMasahiro Yamada 			pinmux_set_io(PMUX_PINGRP_GMI_A18_PB1, PMUX_PIN_INPUT);
44*09f455dcSMasahiro Yamada 			pinmux_set_io(PMUX_PINGRP_GMI_A19_PK7, PMUX_PIN_OUTPUT);
45*09f455dcSMasahiro Yamada 
46*09f455dcSMasahiro Yamada 			pinmux_tristate_disable(PMUX_PINGRP_GMI_A16_PJ7);
47*09f455dcSMasahiro Yamada 			pinmux_tristate_disable(PMUX_PINGRP_GMI_A17_PB0);
48*09f455dcSMasahiro Yamada 			pinmux_tristate_disable(PMUX_PINGRP_GMI_A18_PB1);
49*09f455dcSMasahiro Yamada 			pinmux_tristate_disable(PMUX_PINGRP_GMI_A19_PK7);
50*09f455dcSMasahiro Yamada 			break;
51*09f455dcSMasahiro Yamada 		}
52*09f455dcSMasahiro Yamada 		break;
53*09f455dcSMasahiro Yamada 
54*09f455dcSMasahiro Yamada 	/* Add other periph IDs here as needed */
55*09f455dcSMasahiro Yamada 
56*09f455dcSMasahiro Yamada 	default:
57*09f455dcSMasahiro Yamada 		debug("%s: invalid periph_id %d", __func__, id);
58*09f455dcSMasahiro Yamada 		return -1;
59*09f455dcSMasahiro Yamada 	}
60*09f455dcSMasahiro Yamada 
61*09f455dcSMasahiro Yamada 	if (bad_config) {
62*09f455dcSMasahiro Yamada 		debug("%s: invalid config %d for periph_id %d", __func__,
63*09f455dcSMasahiro Yamada 		      config, id);
64*09f455dcSMasahiro Yamada 		return -1;
65*09f455dcSMasahiro Yamada 	}
66*09f455dcSMasahiro Yamada 	return 0;
67*09f455dcSMasahiro Yamada }
68