blob: a8fcac6038bbf67e492d52ceb62e45cd9d8bf753 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Tom Warren8981bff2014-01-24 12:46:15 -07002/*
3 * (C) Copyright 2013
4 * NVIDIA Corporation <www.nvidia.com>
Tom Warren8981bff2014-01-24 12:46:15 -07005 */
6
7/* Tegra124 high-level function multiplexing */
8
9#include <common.h>
10#include <asm/arch/clock.h>
11#include <asm/arch/funcmux.h>
12#include <asm/arch/pinmux.h>
13
14int funcmux_select(enum periph_id id, int config)
15{
16 int bad_config = config != FUNCMUX_DEFAULT;
17
18 switch (id) {
19 case PERIPH_ID_UART4:
20 switch (config) {
21 case FUNCMUX_UART4_GPIO: /* TXD,RXD,CTS,RTS */
Stephen Warren6685f042014-03-21 12:29:01 -060022 pinmux_set_func(PMUX_PINGRP_PJ7, PMUX_FUNC_UARTD);
23 pinmux_set_func(PMUX_PINGRP_PB0, PMUX_FUNC_UARTD);
24 pinmux_set_func(PMUX_PINGRP_PB1, PMUX_FUNC_UARTD);
25 pinmux_set_func(PMUX_PINGRP_PK7, PMUX_FUNC_UARTD);
Tom Warren8981bff2014-01-24 12:46:15 -070026
Stephen Warren6685f042014-03-21 12:29:01 -060027 pinmux_set_io(PMUX_PINGRP_PJ7, PMUX_PIN_OUTPUT);
28 pinmux_set_io(PMUX_PINGRP_PB0, PMUX_PIN_INPUT);
29 pinmux_set_io(PMUX_PINGRP_PB1, PMUX_PIN_INPUT);
30 pinmux_set_io(PMUX_PINGRP_PK7, PMUX_PIN_OUTPUT);
Tom Warren8981bff2014-01-24 12:46:15 -070031
Stephen Warren6685f042014-03-21 12:29:01 -060032 pinmux_tristate_disable(PMUX_PINGRP_PJ7);
33 pinmux_tristate_disable(PMUX_PINGRP_PB0);
34 pinmux_tristate_disable(PMUX_PINGRP_PB1);
35 pinmux_tristate_disable(PMUX_PINGRP_PK7);
Tom Warren8981bff2014-01-24 12:46:15 -070036 break;
37 }
38 break;
39
40 case PERIPH_ID_UART1:
41 switch (config) {
42 case FUNCMUX_UART1_KBC:
Stephen Warren6685f042014-03-21 12:29:01 -060043 pinmux_set_func(PMUX_PINGRP_KB_ROW9_PS1,
44 PMUX_FUNC_UARTA);
45 pinmux_set_func(PMUX_PINGRP_KB_ROW10_PS2,
46 PMUX_FUNC_UARTA);
Tom Warren8981bff2014-01-24 12:46:15 -070047
Stephen Warren6685f042014-03-21 12:29:01 -060048 pinmux_set_io(PMUX_PINGRP_KB_ROW9_PS1, PMUX_PIN_OUTPUT);
49 pinmux_set_io(PMUX_PINGRP_KB_ROW10_PS2, PMUX_PIN_INPUT);
Tom Warren8981bff2014-01-24 12:46:15 -070050
Stephen Warren6685f042014-03-21 12:29:01 -060051 pinmux_tristate_disable(PMUX_PINGRP_KB_ROW9_PS1);
52 pinmux_tristate_disable(PMUX_PINGRP_KB_ROW10_PS2);
Tom Warren8981bff2014-01-24 12:46:15 -070053 break;
54 }
55 break;
56
57 /* Add other periph IDs here as needed */
58
59 default:
60 debug("%s: invalid periph_id %d", __func__, id);
61 return -1;
62 }
63
64 if (bad_config) {
65 debug("%s: invalid config %d for periph_id %d", __func__,
66 config, id);
67 return -1;
68 }
69 return 0;
70}