]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/cpu/tegra114-common/pinmux.c
ARM: tegra: pinctrl: remove vddio
[karo-tx-uboot.git] / arch / arm / cpu / tegra114-common / pinmux.c
1 /*
2  * Copyright (c) 2010-2013, NVIDIA CORPORATION.  All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms and conditions of the GNU General Public License,
6  * version 2, as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
11  * more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15  */
16
17 /* Tegra114 pin multiplexing functions */
18
19 #include <common.h>
20 #include <asm/io.h>
21 #include <asm/arch/tegra.h>
22 #include <asm/arch/pinmux.h>
23
24 struct tegra_pingroup_desc {
25         const char *name;
26         enum pmux_func funcs[4];
27         enum pmux_pin_io io;
28 };
29
30 #define PMUX_MUXCTL_SHIFT       0
31 #define PMUX_PULL_SHIFT         2
32 #define PMUX_TRISTATE_SHIFT     4
33 #define PMUX_TRISTATE_MASK      (1 << PMUX_TRISTATE_SHIFT)
34 #define PMUX_IO_SHIFT           5
35 #define PMUX_OD_SHIFT           6
36 #define PMUX_LOCK_SHIFT         7
37 #define PMUX_IO_RESET_SHIFT     8
38 #define PMUX_RCV_SEL_SHIFT      9
39
40 #define PGRP_HSM_SHIFT          2
41 #define PGRP_SCHMT_SHIFT        3
42 #define PGRP_LPMD_SHIFT         4
43 #define PGRP_LPMD_MASK          (3 << PGRP_LPMD_SHIFT)
44 #define PGRP_DRVDN_SHIFT        12
45 #define PGRP_DRVDN_MASK         (0x7F << PGRP_DRVDN_SHIFT)
46 #define PGRP_DRVUP_SHIFT        20
47 #define PGRP_DRVUP_MASK         (0x7F << PGRP_DRVUP_SHIFT)
48 #define PGRP_SLWR_SHIFT         28
49 #define PGRP_SLWR_MASK          (3 << PGRP_SLWR_SHIFT)
50 #define PGRP_SLWF_SHIFT         30
51 #define PGRP_SLWF_MASK          (3 << PGRP_SLWF_SHIFT)
52
53 /* Convenient macro for defining pin group properties */
54 #define PIN(pg_name, vdd, f0, f1, f2, f3, iod)  \
55         {                                               \
56                 .funcs = {                              \
57                         PMUX_FUNC_ ## f0,               \
58                         PMUX_FUNC_ ## f1,               \
59                         PMUX_FUNC_ ## f2,               \
60                         PMUX_FUNC_ ## f3,               \
61                 },                                      \
62                 .io = PMUX_PIN_ ## iod,                 \
63         }
64
65 /* Input and output pins */
66 #define PINI(pg_name, vdd, f0, f1, f2, f3) \
67         PIN(pg_name, vdd, f0, f1, f2, f3, INPUT)
68 #define PINO(pg_name, vdd, f0, f1, f2, f3) \
69         PIN(pg_name, vdd, f0, f1, f2, f3, OUTPUT)
70
71 /* A pin group number which is not used */
72 #define PIN_RESERVED \
73         PIN(NONE, NONE, INVALID, INVALID, INVALID, INVALID, NONE)
74
75 const struct tegra_pingroup_desc tegra_soc_pingroups[PINGRP_COUNT] = {
76         /*      NAME      VDD      f0           f1         f2       f3  */
77         PINI(ULPI_DATA0,  BB,      SPI3,       HSI,        UARTA,   ULPI),
78         PINI(ULPI_DATA1,  BB,      SPI3,       HSI,        UARTA,   ULPI),
79         PINI(ULPI_DATA2,  BB,      SPI3,       HSI,        UARTA,   ULPI),
80         PINI(ULPI_DATA3,  BB,      SPI3,        HSI,       UARTA,   ULPI),
81         PINI(ULPI_DATA4,  BB,      SPI2,        HSI,       UARTA,   ULPI),
82         PINI(ULPI_DATA5,  BB,      SPI2,        HSI,       UARTA,   ULPI),
83         PINI(ULPI_DATA6,  BB,      SPI2,        HSI,       UARTA,   ULPI),
84         PINI(ULPI_DATA7,  BB,      SPI2,        HSI,       UARTA,   ULPI),
85         PINI(ULPI_CLK,    BB,      SPI1,       SPI5,       UARTD,   ULPI),
86         PINI(ULPI_DIR,    BB,      SPI1,       SPI5,       UARTD,   ULPI),
87         PINI(ULPI_NXT,    BB,      SPI1,       SPI5,       UARTD,   ULPI),
88         PINI(ULPI_STP,    BB,      SPI1,       SPI5,       UARTD,   ULPI),
89         PINI(DAP3_FS,     BB,      I2S2,       SPI5,       DISPA,   DISPB),
90         PINI(DAP3_DIN,    BB,      I2S2,       SPI5,       DISPA,   DISPB),
91         PINI(DAP3_DOUT,   BB,      I2S2,       SPI5,       DISPA,   DISPB),
92         PINI(DAP3_SCLK,   BB,      I2S2,       SPI5,       DISPA,   DISPB),
93         PINI(GPIO_PV0,    BB,      USB,        RSVD2,      RSVD3,   RSVD4),
94         PINI(GPIO_PV1,    BB,      RSVD1,      RSVD2,      RSVD3,   RSVD4),
95         PINI(SDMMC1_CLK,  SDMMC1,  SDMMC1,     CLK12,      RSVD3,   RSVD4),
96         PINI(SDMMC1_CMD,  SDMMC1,  SDMMC1,     SPDIF,      SPI4,    UARTA),
97         PINI(SDMMC1_DAT3, SDMMC1,  SDMMC1,     SPDIF,      SPI4,    UARTA),
98         PINI(SDMMC1_DAT2, SDMMC1,  SDMMC1,     PWM0,       SPI4,    UARTA),
99         PINI(SDMMC1_DAT1, SDMMC1,  SDMMC1,     PWM1,       SPI4,    UARTA),
100         PINI(SDMMC1_DAT0, SDMMC1,  SDMMC1,     RSVD2,      SPI4,    UARTA),
101         PIN_RESERVED,   /* Reserved by t114: 0x3060 - 0x3064 */
102         PIN_RESERVED,
103         PINI(CLK2_OUT,    SDMMC1,  EXTPERIPH2, RSVD2,      RSVD3,   RSVD4),
104         PINI(CLK2_REQ,    SDMMC1,  DAP,        RSVD2,      RSVD3,   RSVD4),
105         PIN_RESERVED,   /* Reserved by t114: 0x3070 - 0x310c */
106         PIN_RESERVED,
107         PIN_RESERVED,
108         PIN_RESERVED,
109         PIN_RESERVED,
110         PIN_RESERVED,
111         PIN_RESERVED,
112         PIN_RESERVED,
113         PIN_RESERVED,
114         PIN_RESERVED,
115         PIN_RESERVED,
116         PIN_RESERVED,
117         PIN_RESERVED,
118         PIN_RESERVED,
119         PIN_RESERVED,
120         PIN_RESERVED,
121         PIN_RESERVED,
122         PIN_RESERVED,
123         PIN_RESERVED,
124         PIN_RESERVED,
125         PIN_RESERVED,
126         PIN_RESERVED,
127         PIN_RESERVED,
128         PIN_RESERVED,
129         PIN_RESERVED,
130         PIN_RESERVED,
131         PIN_RESERVED,
132         PIN_RESERVED,
133         PIN_RESERVED,
134         PIN_RESERVED,
135         PIN_RESERVED,
136         PIN_RESERVED,
137         PIN_RESERVED,
138         PIN_RESERVED,
139         PIN_RESERVED,
140         PIN_RESERVED,
141         PIN_RESERVED,
142         PIN_RESERVED,
143         PIN_RESERVED,
144         PIN_RESERVED,
145         PINI(HDMI_INT,    LCD,     RSVD1,      RSVD2,      RSVD3,   RSVD4),
146         PINI(DDC_SCL,     LCD,     I2C4,       RSVD2,      RSVD3,   RSVD4),
147         PINI(DDC_SDA,     LCD,     I2C4,       RSVD2,      RSVD3,   RSVD4),
148         PIN_RESERVED,   /* Reserved by t114: 0x311c - 0x3160 */
149         PIN_RESERVED,
150         PIN_RESERVED,
151         PIN_RESERVED,
152         PIN_RESERVED,
153         PIN_RESERVED,
154         PIN_RESERVED,
155         PIN_RESERVED,
156         PIN_RESERVED,
157         PIN_RESERVED,
158         PIN_RESERVED,
159         PIN_RESERVED,
160         PIN_RESERVED,
161         PIN_RESERVED,
162         PIN_RESERVED,
163         PIN_RESERVED,
164         PIN_RESERVED,
165         PIN_RESERVED,
166         PINI(UART2_RXD,   UART,    UARTB,      SPDIF,      UARTA,   SPI4),
167         PINI(UART2_TXD,   UART,    UARTB,      SPDIF,      UARTA,   SPI4),
168         PINI(UART2_RTS_N, UART,    UARTA,      UARTB,      RSVD3,   SPI4),
169         PINI(UART2_CTS_N, UART,    UARTA,      UARTB,      RSVD3,   SPI4),
170         PINI(UART3_TXD,   UART,    UARTC,      RSVD2,      RSVD3,   SPI4),
171         PINI(UART3_RXD,   UART,    UARTC,      RSVD2,      RSVD3,   SPI4),
172         PINI(UART3_CTS_N, UART,    UARTC,      SDMMC1,     DTV,     SPI4),
173         PINI(UART3_RTS_N, UART,    UARTC,      PWM0,       DTV,     DISPA),
174         PINI(GPIO_PU0,    UART,    OWR,        UARTA,      RSVD3,   RSVD4),
175         PINI(GPIO_PU1,    UART,    RSVD1,      UARTA,      RSVD3,   RSVD4),
176         PINI(GPIO_PU2,    UART,    RSVD1,      UARTA,      RSVD3,   RSVD4),
177         PINI(GPIO_PU3,    UART,    PWM0,       UARTA,      DISPA,   DISPB),
178         PINI(GPIO_PU4,    UART,    PWM1,       UARTA,      DISPA,   DISPB),
179         PINI(GPIO_PU5,    UART,    PWM2,       UARTA,      DISPA,   DISPB),
180         PINI(GPIO_PU6,    UART,    PWM3,       UARTA,      USB,     DISPB),
181         PINI(GEN1_I2C_SDA, UART,   I2C1,       RSVD2,      RSVD3,   RSVD4),
182         PINI(GEN1_I2C_SCL, UART,   I2C1,       RSVD2,      RSVD3,   RSVD4),
183         PINI(DAP4_FS,     UART,    I2S3,       RSVD2,      DTV,     RSVD4),
184         PINI(DAP4_DIN,    UART,    I2S3,       RSVD2,      RSVD3,   RSVD4),
185         PINI(DAP4_DOUT,   UART,    I2S3,       RSVD2,      DTV,     RSVD4),
186         PINI(DAP4_SCLK,   UART,    I2S3,       RSVD2,      RSVD3,   RSVD4),
187         PINI(CLK3_OUT,    UART,    EXTPERIPH3, RSVD2,      RSVD3,   RSVD4),
188         PINI(CLK3_REQ,    UART,    DEV3,       RSVD2,      RSVD3,   RSVD4),
189         PINI(GMI_WP_N,    GMI,     RSVD1,      NAND,       GMI,     GMI_ALT),
190         PINI(GMI_IORDY,   GMI,     SDMMC2,     RSVD2,      GMI,     TRACE),
191         PINI(GMI_WAIT,    GMI,     SPI4,       NAND,       GMI,     DTV),
192         PINI(GMI_ADV_N,   GMI,     RSVD1,      NAND,       GMI,     TRACE),
193         PINI(GMI_CLK,     GMI,     SDMMC2,     NAND,       GMI,     TRACE),
194         PINI(GMI_CS0_N,   GMI,     RSVD1,      NAND,       GMI,     USB),
195         PINI(GMI_CS1_N,   GMI,     RSVD1,      NAND,       GMI,     SOC),
196         PINI(GMI_CS2_N,   GMI,     SDMMC2,     NAND,       GMI,     TRACE),
197         PINI(GMI_CS3_N,   GMI,     SDMMC2,     NAND,       GMI,     GMI_ALT),
198         PINI(GMI_CS4_N,   GMI,     USB,        NAND,       GMI,     TRACE),
199         PINI(GMI_CS6_N,   GMI,     NAND,       NAND_ALT,   GMI,     SPI4),
200         PINI(GMI_CS7_N,   GMI,     NAND,       NAND_ALT,   GMI,     SDMMC2),
201         PINI(GMI_AD0,     GMI,     RSVD1,      NAND,       GMI,     RSVD4),
202         PINI(GMI_AD1,     GMI,     RSVD1,      NAND,       GMI,     RSVD4),
203         PINI(GMI_AD2,     GMI,     RSVD1,      NAND,       GMI,     RSVD4),
204         PINI(GMI_AD3,     GMI,     RSVD1,      NAND,       GMI,     RSVD4),
205         PINI(GMI_AD4,     GMI,     RSVD1,      NAND,       GMI,     RSVD4),
206         PINI(GMI_AD5,     GMI,     RSVD1,      NAND,       GMI,     SPI4),
207         PINI(GMI_AD6,     GMI,     RSVD1,      NAND,       GMI,     SPI4),
208         PINI(GMI_AD7,     GMI,     RSVD1,      NAND,       GMI,     SPI4),
209         PINI(GMI_AD8,     GMI,     PWM0,       NAND,       GMI,     DTV),
210         PINI(GMI_AD9,     GMI,     PWM1,       NAND,       GMI,     CLDVFS),
211         PINI(GMI_AD10,    GMI,     PWM2,       NAND,       GMI,     CLDVFS),
212         PINI(GMI_AD11,    GMI,     PWM3,       NAND,       GMI,     USB),
213         PINI(GMI_AD12,    GMI,     SDMMC2,     NAND,       GMI,     RSVD4),
214         PINI(GMI_AD13,    GMI,     SDMMC2,     NAND,       GMI,     RSVD4),
215         PINI(GMI_AD14,    GMI,     SDMMC2,     NAND,       GMI,     DTV),
216         PINI(GMI_AD15,    GMI,     SDMMC2,     NAND,       GMI,     DTV),
217         PINI(GMI_A16,     GMI,     UARTD,      TRACE,      GMI,     GMI_ALT),
218         PINI(GMI_A17,     GMI,     UARTD,      RSVD2,      GMI,     TRACE),
219         PINI(GMI_A18,     GMI,     UARTD,      RSVD2,      GMI,     TRACE),
220         PINI(GMI_A19,     GMI,     UARTD,      SPI4,       GMI,     TRACE),
221         PINI(GMI_WR_N,    GMI,     RSVD1,      NAND,       GMI,     SPI4),
222         PINI(GMI_OE_N,    GMI,     RSVD1,      NAND,       GMI,     SOC),
223         PINI(GMI_DQS,     GMI,     SDMMC2,     NAND,       GMI,     TRACE),
224         PINI(GMI_RST_N,   GMI,     NAND,       NAND_ALT,   GMI,     RSVD4),
225         PINI(GEN2_I2C_SCL, GMI,    I2C2,       RSVD2,      GMI,     RSVD4),
226         PINI(GEN2_I2C_SDA, GMI,    I2C2,       RSVD2,      GMI,     RSVD4),
227         PINI(SDMMC4_CLK,  SDMMC4,  SDMMC4,     RSVD2,      GMI,     RSVD4),
228         PINI(SDMMC4_CMD,  SDMMC4,  SDMMC4,     RSVD2,      GMI,     RSVD4),
229         PINI(SDMMC4_DAT0, SDMMC4,  SDMMC4,     SPI3,       GMI,     RSVD4),
230         PINI(SDMMC4_DAT1, SDMMC4,  SDMMC4,     SPI3,       GMI,     RSVD4),
231         PINI(SDMMC4_DAT2, SDMMC4,  SDMMC4,     SPI3,       GMI,     RSVD4),
232         PINI(SDMMC4_DAT3, SDMMC4,  SDMMC4,     SPI3,       GMI,     RSVD4),
233         PINI(SDMMC4_DAT4, SDMMC4,  SDMMC4,     SPI3,       GMI,     RSVD4),
234         PINI(SDMMC4_DAT5, SDMMC4,  SDMMC4,     SPI3,       GMI,     RSVD4),
235         PINI(SDMMC4_DAT6, SDMMC4,  SDMMC4,     SPI3,       GMI,     RSVD4),
236         PINI(SDMMC4_DAT7, SDMMC4,  SDMMC4,     RSVD2,      GMI,     RSVD4),
237         PIN_RESERVED,   /* Reserved by t114: 0x3280 */
238         PINI(CAM_MCLK,    CAM,     VI,         VI_ALT1,    VI_ALT3, RSVD4),
239         PINI(GPIO_PCC1,   CAM,     I2S4,       RSVD2,      RSVD3,   RSVD4),
240         PINI(GPIO_PBB0,   CAM,     I2S4,       VI,         VI_ALT1, VI_ALT3),
241         PINI(CAM_I2C_SCL, CAM,     VGP1,       I2C3,       RSVD3,   RSVD4),
242         PINI(CAM_I2C_SDA, CAM,     VGP2,       I2C3,       RSVD3,   RSVD4),
243         PINI(GPIO_PBB3,   CAM,     VGP3,       DISPA,      DISPB,   RSVD4),
244         PINI(GPIO_PBB4,   CAM,     VGP4,       DISPA,      DISPB,   RSVD4),
245         PINI(GPIO_PBB5,   CAM,     VGP5,       DISPA,      DISPB,   RSVD4),
246         PINI(GPIO_PBB6,   CAM,     VGP6,       DISPA,      DISPB,   RSVD4),
247         PINI(GPIO_PBB7,   CAM,     I2S4,       RSVD2,      RSVD3,   RSVD4),
248         PINI(GPIO_PCC2,   CAM,     I2S4,       RSVD2,      RSVD3,   RSVD4),
249         PINI(JTAG_RTCK,   SYS,     RTCK,       RSVD2,      RSVD3,   RSVD4),
250         PINI(PWR_I2C_SCL, SYS,     I2CPWR,     RSVD2,      RSVD3,   RSVD4),
251         PINI(PWR_I2C_SDA, SYS,     I2CPWR,     RSVD2,      RSVD3,   RSVD4),
252         PINI(KB_ROW0,     SYS,     KBC,        RSVD2,      DTV,     RSVD4),
253         PINI(KB_ROW1,     SYS,     KBC,        RSVD2,      DTV,     RSVD4),
254         PINI(KB_ROW2,     SYS,     KBC,        RSVD2,      DTV,     SOC),
255         PINI(KB_ROW3,     SYS,     KBC,        DISPA,      RSVD3,   DISPB),
256         PINI(KB_ROW4,     SYS,     KBC,        DISPA,      SPI2,    DISPB),
257         PINI(KB_ROW5,     SYS,     KBC,        DISPA,      SPI2,    DISPB),
258         PINI(KB_ROW6,     SYS,     KBC,        DISPA,      RSVD3,   DISPB),
259         PINI(KB_ROW7,     SYS,     KBC,        RSVD2,      CLDVFS,  UARTA),
260         PINI(KB_ROW8,     SYS,     KBC,        RSVD2,      RSVD3,   UARTA),
261         PINI(KB_ROW9,     SYS,     KBC,        RSVD2,      RSVD3,   UARTA),
262         PINI(KB_ROW10,    SYS,     KBC,        RSVD2,      RSVD3,   UARTA),
263         PIN_RESERVED,   /* Reserved by t114: 0x32e8 - 0x32f8 */
264         PIN_RESERVED,
265         PIN_RESERVED,
266         PIN_RESERVED,
267         PIN_RESERVED,
268         PINI(KB_COL0,     SYS,     KBC,        USB,        SPI2,    EMC_DLL),
269         PINI(KB_COL1,     SYS,     KBC,        RSVD2,      SPI2,    EMC_DLL),
270         PINI(KB_COL2,     SYS,     KBC,        RSVD2,      SPI2,    RSVD4),
271         PINI(KB_COL3,     SYS,     KBC,        DISPA,      PWM2,    UARTA),
272         PINI(KB_COL4,     SYS,     KBC,        OWR,        SDMMC3,  UARTA),
273         PINI(KB_COL5,     SYS,     KBC,        RSVD2,      SDMMC1,  RSVD4),
274         PINI(KB_COL6,     SYS,     KBC,        RSVD2,      SPI2,    RSVD4),
275         PINI(KB_COL7,     SYS,     KBC,        RSVD2,      SPI2,    RSVD4),
276         PINI(CLK_32K_OUT, SYS,     BLINK,      SOC,        RSVD3,   RSVD4),
277         PINI(SYS_CLK_REQ, SYS,     SYSCLK,     RSVD2,      RSVD3,   RSVD4),
278         PINI(CORE_PWR_REQ, SYS,    PWRON,      RSVD2,      RSVD3,   RSVD4),
279         PINI(CPU_PWR_REQ, SYS,     CPU,        RSVD2,      RSVD3,   RSVD4),
280         PINI(PWR_INT_N,   SYS,     PMI,        RSVD2,      RSVD3,   RSVD4),
281         PINI(CLK_32K_IN,  SYS,     CLK,        RSVD2,      RSVD3,   RSVD4),
282         PINI(OWR,         SYS,     OWR,        RSVD2,      RSVD3,   RSVD4),
283         PINI(DAP1_FS,     AUDIO,   I2S0,       HDA,        GMI,     RSVD4),
284         PINI(DAP1_DIN,    AUDIO,   I2S0,       HDA,        GMI,     RSVD4),
285         PINI(DAP1_DOUT,   AUDIO,   I2S0,       HDA,        GMI,     RSVD4),
286         PINI(DAP1_SCLK,   AUDIO,   I2S0,       HDA,        GMI,     RSVD4),
287         PINI(CLK1_REQ,    AUDIO,   DAP,        DAP1,       RSVD3,   RSVD4),
288         PINI(CLK1_OUT,    AUDIO,   EXTPERIPH1, DAP2,       RSVD3,   RSVD4),
289         PINI(SPDIF_IN,    AUDIO,   SPDIF,      USB,        RSVD3,   RSVD4),
290         PINI(SPDIF_OUT,   AUDIO,   SPDIF,      RSVD2,      RSVD3,   RSVD4),
291         PINI(DAP2_FS,     AUDIO,   I2S1,       HDA,        RSVD3,   RSVD4),
292         PINI(DAP2_DIN,    AUDIO,   I2S1,       HDA,        RSVD3,   RSVD4),
293         PINI(DAP2_DOUT,   AUDIO,   I2S1,       HDA,        RSVD3,   RSVD4),
294         PINI(DAP2_SCLK,   AUDIO,   I2S1,       HDA,        RSVD3,   RSVD4),
295         PINI(DVFS_PWM,    AUDIO,   SPI6,       CLDVFS,     RSVD3,   RSVD4),
296         PINI(GPIO_X1_AUD, AUDIO,   SPI6,       RSVD2,      RSVD3,   RSVD4),
297         PINI(GPIO_X3_AUD, AUDIO,   SPI6,       SPI1,       RSVD3,   RSVD4),
298         PINI(DVFS_CLK,    AUDIO,   SPI6,       CLDVFS,     RSVD3,   RSVD4),
299         PINI(GPIO_X4_AUD, AUDIO,   RSVD1,      SPI1,       SPI2,    DAP2),
300         PINI(GPIO_X5_AUD, AUDIO,   RSVD1,      SPI1,       SPI2,    RSVD4),
301         PINI(GPIO_X6_AUD, AUDIO,   SPI6,       SPI1,       SPI2,    RSVD4),
302         PINI(GPIO_X7_AUD, AUDIO,   RSVD1,      SPI1,       SPI2,    RSVD4),
303         PIN_RESERVED,   /* Reserved by t114: 0x3388 - 0x338c */
304         PIN_RESERVED,
305         PINI(SDMMC3_CLK,  SDMMC3,  SDMMC3,     RSVD2,      RSVD3,   SPI3),
306         PINI(SDMMC3_CMD,  SDMMC3,  SDMMC3,     PWM3,       UARTA,   SPI3),
307         PINI(SDMMC3_DAT0, SDMMC3,  SDMMC3,     RSVD2,      RSVD3,   SPI3),
308         PINI(SDMMC3_DAT1, SDMMC3,  SDMMC3,     PWM2,       UARTA,   SPI3),
309         PINI(SDMMC3_DAT2, SDMMC3,  SDMMC3,     PWM1,       DISPA,   SPI3),
310         PINI(SDMMC3_DAT3, SDMMC3,  SDMMC3,     PWM0,       DISPB,   SPI3),
311         PIN_RESERVED,   /* Reserved by t114: 0x33a8 - 0x33dc */
312         PIN_RESERVED,
313         PIN_RESERVED,
314         PIN_RESERVED,
315         PIN_RESERVED,
316         PIN_RESERVED,
317         PIN_RESERVED,
318         PIN_RESERVED,
319         PIN_RESERVED,
320         PIN_RESERVED,
321         PIN_RESERVED,
322         PIN_RESERVED,
323         PIN_RESERVED,
324         PIN_RESERVED,
325         PINI(HDMI_CEC,    SYS,     CEC,        SDMMC3,     RSVD3,   SOC),
326         PINI(SDMMC1_WP_N, SDMMC1,  SDMMC1,     CLK12,      SPI4,    UARTA),
327         PINI(SDMMC3_CD_N, SYS,  SDMMC3,     OWR,        RSVD3,   RSVD4),
328         PINI(GPIO_W2_AUD, AUDIO,   SPI6,       RSVD2,      SPI2,    I2C1),
329         PINI(GPIO_W3_AUD, AUDIO,   SPI6,       SPI1,       SPI2,    I2C1),
330         PINI(USB_VBUS_EN0, LCD,    USB,        RSVD2,      RSVD3,   RSVD4),
331         PINI(USB_VBUS_EN1, LCD,    USB,        RSVD2,      RSVD3,   RSVD4),
332         PINI(SDMMC3_CLK_LB_IN,  SDMMC3, SDMMC3, RSVD2,     RSVD3,   RSVD4),
333         PINI(SDMMC3_CLK_LB_OUT, SDMMC3, SDMMC3, RSVD2,     RSVD3,   RSVD4),
334         PIN_RESERVED,   /* Reserved by t114: 0x3404 */
335         PINO(RESET_OUT_N, SYS,     RSVD1,      RSVD2,      RSVD3, RESET_OUT_N),
336 };
337
338 void pinmux_set_tristate(enum pmux_pingrp pin, int enable)
339 {
340         struct pmux_tri_ctlr *pmt =
341                         (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
342         u32 *tri = &pmt->pmt_ctl[pin];
343         u32 reg;
344
345         /* Error check on pin */
346         assert(pmux_pingrp_isvalid(pin));
347
348         reg = readl(tri);
349         if (enable)
350                 reg |= PMUX_TRISTATE_MASK;
351         else
352                 reg &= ~PMUX_TRISTATE_MASK;
353         writel(reg, tri);
354 }
355
356 void pinmux_tristate_enable(enum pmux_pingrp pin)
357 {
358         pinmux_set_tristate(pin, 1);
359 }
360
361 void pinmux_tristate_disable(enum pmux_pingrp pin)
362 {
363         pinmux_set_tristate(pin, 0);
364 }
365
366 void pinmux_set_pullupdown(enum pmux_pingrp pin, enum pmux_pull pupd)
367 {
368         struct pmux_tri_ctlr *pmt =
369                         (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
370         u32 *pull = &pmt->pmt_ctl[pin];
371         u32 reg;
372
373         /* Error check on pin and pupd */
374         assert(pmux_pingrp_isvalid(pin));
375         assert(pmux_pin_pupd_isvalid(pupd));
376
377         reg = readl(pull);
378         reg &= ~(0x3 << PMUX_PULL_SHIFT);
379         reg |= (pupd << PMUX_PULL_SHIFT);
380         writel(reg, pull);
381 }
382
383 void pinmux_set_func(enum pmux_pingrp pin, enum pmux_func func)
384 {
385         struct pmux_tri_ctlr *pmt =
386                         (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
387         u32 *muxctl = &pmt->pmt_ctl[pin];
388         int i, mux = -1;
389         u32 reg;
390
391         /* Error check on pin and func */
392         assert(pmux_pingrp_isvalid(pin));
393         assert(pmux_func_isvalid(func));
394
395         if (func & PMUX_FUNC_RSVD1) {
396                 mux = func & 0x3;
397         } else {
398                 /* Search for the appropriate function */
399                 for (i = 0; i < 4; i++) {
400                         if (tegra_soc_pingroups[pin].funcs[i] == func) {
401                                 mux = i;
402                                 break;
403                         }
404                 }
405         }
406         assert(mux != -1);
407
408         reg = readl(muxctl);
409         reg &= ~(0x3 << PMUX_MUXCTL_SHIFT);
410         reg |= (mux << PMUX_MUXCTL_SHIFT);
411         writel(reg, muxctl);
412
413 }
414
415 void pinmux_set_io(enum pmux_pingrp pin, enum pmux_pin_io io)
416 {
417         struct pmux_tri_ctlr *pmt =
418                         (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
419         u32 *pin_io = &pmt->pmt_ctl[pin];
420         u32 reg;
421
422         /* Error check on pin and io */
423         assert(pmux_pingrp_isvalid(pin));
424         assert(pmux_pin_io_isvalid(io));
425
426         reg = readl(pin_io);
427         reg &= ~(0x1 << PMUX_IO_SHIFT);
428         reg |= (io & 0x1) << PMUX_IO_SHIFT;
429         writel(reg, pin_io);
430 }
431
432 static int pinmux_set_lock(enum pmux_pingrp pin, enum pmux_pin_lock lock)
433 {
434         struct pmux_tri_ctlr *pmt =
435                         (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
436         u32 *pin_lock = &pmt->pmt_ctl[pin];
437         u32 reg;
438
439         /* Error check on pin and lock */
440         assert(pmux_pingrp_isvalid(pin));
441         assert(pmux_pin_lock_isvalid(lock));
442
443         if (lock == PMUX_PIN_LOCK_DEFAULT)
444                 return 0;
445
446         reg = readl(pin_lock);
447         reg &= ~(0x1 << PMUX_LOCK_SHIFT);
448         if (lock == PMUX_PIN_LOCK_ENABLE)
449                 reg |= (0x1 << PMUX_LOCK_SHIFT);
450         else {
451                 /* lock == DISABLE, which isn't possible */
452                 printf("%s: Warning: lock == %d, DISABLE is not allowed!\n",
453                         __func__, lock);
454         }
455         writel(reg, pin_lock);
456
457         return 0;
458 }
459
460 static int pinmux_set_od(enum pmux_pingrp pin, enum pmux_pin_od od)
461 {
462         struct pmux_tri_ctlr *pmt =
463                         (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
464         u32 *pin_od = &pmt->pmt_ctl[pin];
465         u32 reg;
466
467         /* Error check on pin and od */
468         assert(pmux_pingrp_isvalid(pin));
469         assert(pmux_pin_od_isvalid(od));
470
471         if (od == PMUX_PIN_OD_DEFAULT)
472                 return 0;
473
474         reg = readl(pin_od);
475         reg &= ~(0x1 << PMUX_OD_SHIFT);
476         if (od == PMUX_PIN_OD_ENABLE)
477                 reg |= (0x1 << PMUX_OD_SHIFT);
478         writel(reg, pin_od);
479
480         return 0;
481 }
482
483 static int pinmux_set_ioreset(enum pmux_pingrp pin,
484                                 enum pmux_pin_ioreset ioreset)
485 {
486         struct pmux_tri_ctlr *pmt =
487                         (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
488         u32 *pin_ioreset = &pmt->pmt_ctl[pin];
489         u32 reg;
490
491         /* Error check on pin and ioreset */
492         assert(pmux_pingrp_isvalid(pin));
493         assert(pmux_pin_ioreset_isvalid(ioreset));
494
495         if (ioreset == PMUX_PIN_IO_RESET_DEFAULT)
496                 return 0;
497
498         reg = readl(pin_ioreset);
499         reg &= ~(0x1 << PMUX_IO_RESET_SHIFT);
500         if (ioreset == PMUX_PIN_IO_RESET_ENABLE)
501                 reg |= (0x1 << PMUX_IO_RESET_SHIFT);
502         writel(reg, pin_ioreset);
503
504         return 0;
505 }
506
507 static int pinmux_set_rcv_sel(enum pmux_pingrp pin,
508                                 enum pmux_pin_rcv_sel rcv_sel)
509 {
510         struct pmux_tri_ctlr *pmt =
511                         (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
512         u32 *pin_rcv_sel = &pmt->pmt_ctl[pin];
513         u32 reg;
514
515         /* Error check on pin and rcv_sel */
516         assert(pmux_pingrp_isvalid(pin));
517         assert(pmux_pin_rcv_sel_isvalid(rcv_sel));
518
519         if (rcv_sel == PMUX_PIN_RCV_SEL_DEFAULT)
520                 return 0;
521
522         reg = readl(pin_rcv_sel);
523         reg &= ~(0x1 << PMUX_RCV_SEL_SHIFT);
524         if (rcv_sel == PMUX_PIN_RCV_SEL_HIGH)
525                 reg |= (0x1 << PMUX_RCV_SEL_SHIFT);
526         writel(reg, pin_rcv_sel);
527
528         return 0;
529 }
530
531 void pinmux_config_pingroup(struct pingroup_config *config)
532 {
533         enum pmux_pingrp pin = config->pingroup;
534
535         pinmux_set_func(pin, config->func);
536         pinmux_set_pullupdown(pin, config->pull);
537         pinmux_set_tristate(pin, config->tristate);
538         pinmux_set_io(pin, config->io);
539         pinmux_set_lock(pin, config->lock);
540         pinmux_set_od(pin, config->od);
541         pinmux_set_ioreset(pin, config->ioreset);
542         pinmux_set_rcv_sel(pin, config->rcv_sel);
543 }
544
545 void pinmux_config_table(struct pingroup_config *config, int len)
546 {
547         int i;
548
549         for (i = 0; i < len; i++)
550                 pinmux_config_pingroup(&config[i]);
551 }
552
553 static int padgrp_set_drvup_slwf(enum pdrive_pingrp pad, int slwf)
554 {
555         struct pmux_tri_ctlr *pmt =
556                         (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
557         u32 *pad_slwf = &pmt->pmt_drive[pad];
558         u32 reg;
559
560         /* Error check on pad and slwf */
561         assert(pmux_padgrp_isvalid(pad));
562         assert(pmux_pad_slw_isvalid(slwf));
563
564         /* NONE means unspecified/do not change/use POR value */
565         if (slwf == PGRP_SLWF_NONE)
566                 return 0;
567
568         reg = readl(pad_slwf);
569         reg &= ~PGRP_SLWF_MASK;
570         reg |= (slwf << PGRP_SLWF_SHIFT);
571         writel(reg, pad_slwf);
572
573         return 0;
574 }
575
576 static int padgrp_set_drvdn_slwr(enum pdrive_pingrp pad, int slwr)
577 {
578         struct pmux_tri_ctlr *pmt =
579                         (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
580         u32 *pad_slwr = &pmt->pmt_drive[pad];
581         u32 reg;
582
583         /* Error check on pad and slwr */
584         assert(pmux_padgrp_isvalid(pad));
585         assert(pmux_pad_slw_isvalid(slwr));
586
587         /* NONE means unspecified/do not change/use POR value */
588         if (slwr == PGRP_SLWR_NONE)
589                 return 0;
590
591         reg = readl(pad_slwr);
592         reg &= ~PGRP_SLWR_MASK;
593         reg |= (slwr << PGRP_SLWR_SHIFT);
594         writel(reg, pad_slwr);
595
596         return 0;
597 }
598
599 static int padgrp_set_drvup(enum pdrive_pingrp pad, int drvup)
600 {
601         struct pmux_tri_ctlr *pmt =
602                         (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
603         u32 *pad_drvup = &pmt->pmt_drive[pad];
604         u32 reg;
605
606         /* Error check on pad and drvup */
607         assert(pmux_padgrp_isvalid(pad));
608         assert(pmux_pad_drv_isvalid(drvup));
609
610         /* NONE means unspecified/do not change/use POR value */
611         if (drvup == PGRP_DRVUP_NONE)
612                 return 0;
613
614         reg = readl(pad_drvup);
615         reg &= ~PGRP_DRVUP_MASK;
616         reg |= (drvup << PGRP_DRVUP_SHIFT);
617         writel(reg, pad_drvup);
618
619         return 0;
620 }
621
622 static int padgrp_set_drvdn(enum pdrive_pingrp pad, int drvdn)
623 {
624         struct pmux_tri_ctlr *pmt =
625                         (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
626         u32 *pad_drvdn = &pmt->pmt_drive[pad];
627         u32 reg;
628
629         /* Error check on pad and drvdn */
630         assert(pmux_padgrp_isvalid(pad));
631         assert(pmux_pad_drv_isvalid(drvdn));
632
633         /* NONE means unspecified/do not change/use POR value */
634         if (drvdn == PGRP_DRVDN_NONE)
635                 return 0;
636
637         reg = readl(pad_drvdn);
638         reg &= ~PGRP_DRVDN_MASK;
639         reg |= (drvdn << PGRP_DRVDN_SHIFT);
640         writel(reg, pad_drvdn);
641
642         return 0;
643 }
644
645 static int padgrp_set_lpmd(enum pdrive_pingrp pad, enum pgrp_lpmd lpmd)
646 {
647         struct pmux_tri_ctlr *pmt =
648                         (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
649         u32 *pad_lpmd = &pmt->pmt_drive[pad];
650         u32 reg;
651
652         /* Error check pad and lpmd value */
653         assert(pmux_padgrp_isvalid(pad));
654         assert(pmux_pad_lpmd_isvalid(lpmd));
655
656         /* NONE means unspecified/do not change/use POR value */
657         if (lpmd == PGRP_LPMD_NONE)
658                 return 0;
659
660         reg = readl(pad_lpmd);
661         reg &= ~PGRP_LPMD_MASK;
662         reg |= (lpmd << PGRP_LPMD_SHIFT);
663         writel(reg, pad_lpmd);
664
665         return 0;
666 }
667
668 static int padgrp_set_schmt(enum pdrive_pingrp pad, enum pgrp_schmt schmt)
669 {
670         struct pmux_tri_ctlr *pmt =
671                         (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
672         u32 *pad_schmt = &pmt->pmt_drive[pad];
673         u32 reg;
674
675         /* Error check pad */
676         assert(pmux_padgrp_isvalid(pad));
677
678         /* NONE means unspecified/do not change/use POR value */
679         if (schmt == PGRP_SCHMT_NONE)
680                 return 0;
681
682         reg = readl(pad_schmt);
683         reg &= ~(1 << PGRP_SCHMT_SHIFT);
684         if (schmt == PGRP_SCHMT_ENABLE)
685                 reg |= (0x1 << PGRP_SCHMT_SHIFT);
686         writel(reg, pad_schmt);
687
688         return 0;
689 }
690 static int padgrp_set_hsm(enum pdrive_pingrp pad, enum pgrp_hsm hsm)
691 {
692         struct pmux_tri_ctlr *pmt =
693                         (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
694         u32 *pad_hsm = &pmt->pmt_drive[pad];
695         u32 reg;
696
697         /* Error check pad */
698         assert(pmux_padgrp_isvalid(pad));
699
700         /* NONE means unspecified/do not change/use POR value */
701         if (hsm == PGRP_HSM_NONE)
702                 return 0;
703
704         reg = readl(pad_hsm);
705         reg &= ~(1 << PGRP_HSM_SHIFT);
706         if (hsm == PGRP_HSM_ENABLE)
707                 reg |= (0x1 << PGRP_HSM_SHIFT);
708         writel(reg, pad_hsm);
709
710         return 0;
711 }
712
713 void padctrl_config_pingroup(struct padctrl_config *config)
714 {
715         enum pdrive_pingrp pad = config->padgrp;
716
717         padgrp_set_drvup_slwf(pad, config->slwf);
718         padgrp_set_drvdn_slwr(pad, config->slwr);
719         padgrp_set_drvup(pad, config->drvup);
720         padgrp_set_drvdn(pad, config->drvdn);
721         padgrp_set_lpmd(pad, config->lpmd);
722         padgrp_set_schmt(pad, config->schmt);
723         padgrp_set_hsm(pad, config->hsm);
724 }
725
726 void padgrp_config_table(struct padctrl_config *config, int len)
727 {
728         int i;
729
730         for (i = 0; i < len; i++)
731                 padctrl_config_pingroup(&config[i]);
732 }