blob: 40301e13c29df3019da84e858aff5f645bb87046 [file] [log] [blame]
Simon Glass858bd092011-08-30 06:23:14 +00001/*
2 * Copyright (c) 2011 The Chromium OS Authors.
Simon Glass858bd092011-08-30 06:23:14 +00003 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Simon Glass858bd092011-08-30 06:23:14 +00005 */
6
Allen Martin00a27492012-08-31 08:30:00 +00007/* Tegra20 pin multiplexing functions */
Simon Glass858bd092011-08-30 06:23:14 +00008
Simon Glass858bd092011-08-30 06:23:14 +00009#include <common.h>
Tom Warren150c2492012-09-19 15:50:56 -070010#include <asm/io.h>
11#include <asm/arch/tegra.h>
12#include <asm/arch/pinmux.h>
Simon Glass858bd092011-08-30 06:23:14 +000013
14
Simon Glass20e18e02011-09-21 12:40:06 +000015/*
16 * This defines the order of the pin mux control bits in the registers. For
17 * some reason there is no correspendence between the tristate, pin mux and
18 * pullup/pulldown registers.
19 */
20enum pmux_ctlid {
21 /* 0: APB_MISC_PP_PIN_MUX_CTL_A_0 */
22 MUXCTL_UAA,
23 MUXCTL_UAB,
24 MUXCTL_UAC,
25 MUXCTL_UAD,
26 MUXCTL_UDA,
27 MUXCTL_RESERVED5,
28 MUXCTL_ATE,
29 MUXCTL_RM,
30
31 MUXCTL_ATB,
32 MUXCTL_RESERVED9,
33 MUXCTL_ATD,
34 MUXCTL_ATC,
35 MUXCTL_ATA,
36 MUXCTL_KBCF,
37 MUXCTL_KBCE,
38 MUXCTL_SDMMC1,
39
40 /* 16: APB_MISC_PP_PIN_MUX_CTL_B_0 */
41 MUXCTL_GMA,
42 MUXCTL_GMC,
43 MUXCTL_HDINT,
44 MUXCTL_SLXA,
45 MUXCTL_OWC,
46 MUXCTL_SLXC,
47 MUXCTL_SLXD,
48 MUXCTL_SLXK,
49
50 MUXCTL_UCA,
51 MUXCTL_UCB,
52 MUXCTL_DTA,
53 MUXCTL_DTB,
54 MUXCTL_RESERVED28,
55 MUXCTL_DTC,
56 MUXCTL_DTD,
57 MUXCTL_DTE,
58
59 /* 32: APB_MISC_PP_PIN_MUX_CTL_C_0 */
60 MUXCTL_DDC,
61 MUXCTL_CDEV1,
62 MUXCTL_CDEV2,
63 MUXCTL_CSUS,
64 MUXCTL_I2CP,
65 MUXCTL_KBCA,
66 MUXCTL_KBCB,
67 MUXCTL_KBCC,
68
69 MUXCTL_IRTX,
70 MUXCTL_IRRX,
71 MUXCTL_DAP1,
72 MUXCTL_DAP2,
73 MUXCTL_DAP3,
74 MUXCTL_DAP4,
75 MUXCTL_GMB,
76 MUXCTL_GMD,
77
78 /* 48: APB_MISC_PP_PIN_MUX_CTL_D_0 */
79 MUXCTL_GME,
80 MUXCTL_GPV,
81 MUXCTL_GPU,
82 MUXCTL_SPDO,
83 MUXCTL_SPDI,
84 MUXCTL_SDB,
85 MUXCTL_SDC,
86 MUXCTL_SDD,
87
88 MUXCTL_SPIH,
89 MUXCTL_SPIG,
90 MUXCTL_SPIF,
91 MUXCTL_SPIE,
92 MUXCTL_SPID,
93 MUXCTL_SPIC,
94 MUXCTL_SPIB,
95 MUXCTL_SPIA,
96
97 /* 64: APB_MISC_PP_PIN_MUX_CTL_E_0 */
98 MUXCTL_LPW0,
99 MUXCTL_LPW1,
100 MUXCTL_LPW2,
101 MUXCTL_LSDI,
102 MUXCTL_LSDA,
103 MUXCTL_LSPI,
104 MUXCTL_LCSN,
105 MUXCTL_LDC,
106
107 MUXCTL_LSCK,
108 MUXCTL_LSC0,
109 MUXCTL_LSC1,
110 MUXCTL_LHS,
111 MUXCTL_LVS,
112 MUXCTL_LM0,
113 MUXCTL_LM1,
114 MUXCTL_LVP0,
115
116 /* 80: APB_MISC_PP_PIN_MUX_CTL_F_0 */
117 MUXCTL_LD0,
118 MUXCTL_LD1,
119 MUXCTL_LD2,
120 MUXCTL_LD3,
121 MUXCTL_LD4,
122 MUXCTL_LD5,
123 MUXCTL_LD6,
124 MUXCTL_LD7,
125
126 MUXCTL_LD8,
127 MUXCTL_LD9,
128 MUXCTL_LD10,
129 MUXCTL_LD11,
130 MUXCTL_LD12,
131 MUXCTL_LD13,
132 MUXCTL_LD14,
133 MUXCTL_LD15,
134
135 /* 96: APB_MISC_PP_PIN_MUX_CTL_G_0 */
136 MUXCTL_LD16,
137 MUXCTL_LD17,
138 MUXCTL_LHP1,
139 MUXCTL_LHP2,
140 MUXCTL_LVP1,
141 MUXCTL_LHP0,
142 MUXCTL_RESERVED102,
143 MUXCTL_LPP,
144
145 MUXCTL_LDI,
146 MUXCTL_PMC,
147 MUXCTL_CRTP,
148 MUXCTL_PTA,
149 MUXCTL_RESERVED108,
150 MUXCTL_KBCD,
151 MUXCTL_GPU7,
152 MUXCTL_DTF,
153
154 MUXCTL_NONE = -1,
155};
156
157/*
158 * And this defines the order of the pullup/pulldown controls which are again
159 * in a different order
160 */
161enum pmux_pullid {
162 /* 0: APB_MISC_PP_PULLUPDOWN_REG_A_0 */
163 PUCTL_ATA,
164 PUCTL_ATB,
165 PUCTL_ATC,
166 PUCTL_ATD,
167 PUCTL_ATE,
168 PUCTL_DAP1,
169 PUCTL_DAP2,
170 PUCTL_DAP3,
171
172 PUCTL_DAP4,
173 PUCTL_DTA,
174 PUCTL_DTB,
175 PUCTL_DTC,
176 PUCTL_DTD,
177 PUCTL_DTE,
178 PUCTL_DTF,
179 PUCTL_GPV,
180
181 /* 16: APB_MISC_PP_PULLUPDOWN_REG_B_0 */
182 PUCTL_RM,
183 PUCTL_I2CP,
184 PUCTL_PTA,
185 PUCTL_GPU7,
186 PUCTL_KBCA,
187 PUCTL_KBCB,
188 PUCTL_KBCC,
189 PUCTL_KBCD,
190
191 PUCTL_SPDI,
192 PUCTL_SPDO,
193 PUCTL_GPSLXAU,
194 PUCTL_CRTP,
195 PUCTL_SLXC,
196 PUCTL_SLXD,
197 PUCTL_SLXK,
198
199 /* 32: APB_MISC_PP_PULLUPDOWN_REG_C_0 */
200 PUCTL_CDEV1,
201 PUCTL_CDEV2,
202 PUCTL_SPIA,
203 PUCTL_SPIB,
204 PUCTL_SPIC,
205 PUCTL_SPID,
206 PUCTL_SPIE,
207 PUCTL_SPIF,
208
209 PUCTL_SPIG,
210 PUCTL_SPIH,
211 PUCTL_IRTX,
212 PUCTL_IRRX,
213 PUCTL_GME,
214 PUCTL_RESERVED45,
215 PUCTL_XM2D,
216 PUCTL_XM2C,
217
218 /* 48: APB_MISC_PP_PULLUPDOWN_REG_D_0 */
219 PUCTL_UAA,
220 PUCTL_UAB,
221 PUCTL_UAC,
222 PUCTL_UAD,
223 PUCTL_UCA,
224 PUCTL_UCB,
225 PUCTL_LD17,
226 PUCTL_LD19_18,
227
228 PUCTL_LD21_20,
229 PUCTL_LD23_22,
230 PUCTL_LS,
231 PUCTL_LC,
232 PUCTL_CSUS,
233 PUCTL_DDRC,
234 PUCTL_SDC,
235 PUCTL_SDD,
236
237 /* 64: APB_MISC_PP_PULLUPDOWN_REG_E_0 */
238 PUCTL_KBCF,
239 PUCTL_KBCE,
240 PUCTL_PMCA,
241 PUCTL_PMCB,
242 PUCTL_PMCC,
243 PUCTL_PMCD,
244 PUCTL_PMCE,
245 PUCTL_CK32,
246
247 PUCTL_UDA,
248 PUCTL_SDMMC1,
249 PUCTL_GMA,
250 PUCTL_GMB,
251 PUCTL_GMC,
252 PUCTL_GMD,
253 PUCTL_DDC,
254 PUCTL_OWC,
255
256 PUCTL_NONE = -1
257};
258
259struct tegra_pingroup_desc {
260 const char *name;
261 enum pmux_func funcs[4];
Simon Glass20e18e02011-09-21 12:40:06 +0000262 enum pmux_ctlid ctl_id;
263 enum pmux_pullid pull_id;
264};
265
266
267/* Converts a pmux_pingrp number to a tristate register: 0=A, 1=B, 2=C, 3=D */
268#define TRISTATE_REG(pmux_pingrp) ((pmux_pingrp) >> 5)
269
270/* Mask value for a tristate (within TRISTATE_REG(id)) */
271#define TRISTATE_MASK(pmux_pingrp) (1 << ((pmux_pingrp) & 0x1f))
272
273/* Converts a PUCTL id to a pull register: 0=A, 1=B...4=E */
274#define PULL_REG(pmux_pullid) ((pmux_pullid) >> 4)
275
276/* Converts a PUCTL id to a shift position */
277#define PULL_SHIFT(pmux_pullid) ((pmux_pullid << 1) & 0x1f)
278
279/* Converts a MUXCTL id to a ctl register: 0=A, 1=B...6=G */
280#define MUXCTL_REG(pmux_ctlid) ((pmux_ctlid) >> 4)
281
282/* Converts a MUXCTL id to a shift position */
283#define MUXCTL_SHIFT(pmux_ctlid) ((pmux_ctlid << 1) & 0x1f)
284
285/* Convenient macro for defining pin group properties */
286#define PINALL(pg_name, vdd, f0, f1, f2, f3, f_safe, mux, pupd) \
287 { \
Simon Glass20e18e02011-09-21 12:40:06 +0000288 .funcs = { \
289 PMUX_FUNC_ ## f0, \
290 PMUX_FUNC_ ## f1, \
291 PMUX_FUNC_ ## f2, \
292 PMUX_FUNC_ ## f3, \
293 }, \
Simon Glass20e18e02011-09-21 12:40:06 +0000294 .ctl_id = mux, \
295 .pull_id = pupd \
296 }
297
298/* A normal pin group where the mux name and pull-up name match */
299#define PIN(pg_name, vdd, f0, f1, f2, f3, f_safe) \
300 PINALL(pg_name, vdd, f0, f1, f2, f3, f_safe, \
301 MUXCTL_ ## pg_name, PUCTL_ ## pg_name)
302
303/* A pin group where the pull-up name doesn't have a 1-1 mapping */
304#define PINP(pg_name, vdd, f0, f1, f2, f3, f_safe, pupd) \
305 PINALL(pg_name, vdd, f0, f1, f2, f3, f_safe, \
306 MUXCTL_ ## pg_name, PUCTL_ ## pupd)
307
308/* A pin group number which is not used */
309#define PIN_RESERVED \
310 PIN(NONE, NONE, NONE, NONE, NONE, NONE, NONE)
311
312const struct tegra_pingroup_desc tegra_soc_pingroups[PINGRP_COUNT] = {
313 PIN(ATA, NAND, IDE, NAND, GMI, RSVD, IDE),
314 PIN(ATB, NAND, IDE, NAND, GMI, SDIO4, IDE),
315 PIN(ATC, NAND, IDE, NAND, GMI, SDIO4, IDE),
316 PIN(ATD, NAND, IDE, NAND, GMI, SDIO4, IDE),
317 PIN(CDEV1, AUDIO, OSC, PLLA_OUT, PLLM_OUT1, AUDIO_SYNC, OSC),
318 PIN(CDEV2, AUDIO, OSC, AHB_CLK, APB_CLK, PLLP_OUT4, OSC),
319 PIN(CSUS, VI, PLLC_OUT1, PLLP_OUT2, PLLP_OUT3, VI_SENSOR_CLK,
320 PLLC_OUT1),
321 PIN(DAP1, AUDIO, DAP1, RSVD, GMI, SDIO2, DAP1),
322
323 PIN(DAP2, AUDIO, DAP2, TWC, RSVD, GMI, DAP2),
324 PIN(DAP3, BB, DAP3, RSVD, RSVD, RSVD, DAP3),
325 PIN(DAP4, UART, DAP4, RSVD, GMI, RSVD, DAP4),
326 PIN(DTA, VI, RSVD, SDIO2, VI, RSVD, RSVD4),
327 PIN(DTB, VI, RSVD, RSVD, VI, SPI1, RSVD1),
328 PIN(DTC, VI, RSVD, RSVD, VI, RSVD, RSVD1),
329 PIN(DTD, VI, RSVD, SDIO2, VI, RSVD, RSVD1),
330 PIN(DTE, VI, RSVD, RSVD, VI, SPI1, RSVD1),
331
332 PINP(GPU, UART, PWM, UARTA, GMI, RSVD, RSVD4,
333 GPSLXAU),
334 PIN(GPV, SD, PCIE, RSVD, RSVD, RSVD, PCIE),
335 PIN(I2CP, SYS, I2C, RSVD, RSVD, RSVD, RSVD4),
336 PIN(IRTX, UART, UARTA, UARTB, GMI, SPI4, UARTB),
337 PIN(IRRX, UART, UARTA, UARTB, GMI, SPI4, UARTB),
338 PIN(KBCB, SYS, KBC, NAND, SDIO2, MIO, KBC),
339 PIN(KBCA, SYS, KBC, NAND, SDIO2, EMC_TEST0_DLL, KBC),
340 PINP(PMC, SYS, PWR_ON, PWR_INTR, RSVD, RSVD, PWR_ON, NONE),
341
342 PIN(PTA, NAND, I2C2, HDMI, GMI, RSVD, RSVD4),
343 PIN(RM, UART, I2C, RSVD, RSVD, RSVD, RSVD4),
344 PIN(KBCE, SYS, KBC, NAND, OWR, RSVD, KBC),
345 PIN(KBCF, SYS, KBC, NAND, TRACE, MIO, KBC),
346 PIN(GMA, NAND, UARTE, SPI3, GMI, SDIO4, SPI3),
347 PIN(GMC, NAND, UARTD, SPI4, GMI, SFLASH, SPI4),
348 PIN(SDMMC1, BB, SDIO1, RSVD, UARTE, UARTA, RSVD2),
349 PIN(OWC, SYS, OWR, RSVD, RSVD, RSVD, OWR),
350
351 PIN(GME, NAND, RSVD, DAP5, GMI, SDIO4, GMI),
352 PIN(SDC, SD, PWM, TWC, SDIO3, SPI3, TWC),
353 PIN(SDD, SD, UARTA, PWM, SDIO3, SPI3, PWM),
354 PIN_RESERVED,
355 PINP(SLXA, SD, PCIE, SPI4, SDIO3, SPI2, PCIE, CRTP),
356 PIN(SLXC, SD, SPDIF, SPI4, SDIO3, SPI2, SPI4),
357 PIN(SLXD, SD, SPDIF, SPI4, SDIO3, SPI2, SPI4),
358 PIN(SLXK, SD, PCIE, SPI4, SDIO3, SPI2, PCIE),
359
360 PIN(SPDI, AUDIO, SPDIF, RSVD, I2C, SDIO2, RSVD2),
361 PIN(SPDO, AUDIO, SPDIF, RSVD, I2C, SDIO2, RSVD2),
362 PIN(SPIA, AUDIO, SPI1, SPI2, SPI3, GMI, GMI),
363 PIN(SPIB, AUDIO, SPI1, SPI2, SPI3, GMI, GMI),
364 PIN(SPIC, AUDIO, SPI1, SPI2, SPI3, GMI, GMI),
365 PIN(SPID, AUDIO, SPI2, SPI1, SPI2_ALT, GMI, GMI),
366 PIN(SPIE, AUDIO, SPI2, SPI1, SPI2_ALT, GMI, GMI),
367 PIN(SPIF, AUDIO, SPI3, SPI1, SPI2, RSVD, RSVD4),
368
369 PIN(SPIG, AUDIO, SPI3, SPI2, SPI2_ALT, I2C, SPI2_ALT),
370 PIN(SPIH, AUDIO, SPI3, SPI2, SPI2_ALT, I2C, SPI2_ALT),
371 PIN(UAA, BB, SPI3, MIPI_HS, UARTA, ULPI, MIPI_HS),
372 PIN(UAB, BB, SPI2, MIPI_HS, UARTA, ULPI, MIPI_HS),
373 PIN(UAC, BB, OWR, RSVD, RSVD, RSVD, RSVD4),
Allen Martind08b9e92013-01-09 10:52:23 +0000374 PIN(UAD, UART, UARTB, SPDIF, UARTA, SPI4, SPDIF),
Simon Glass20e18e02011-09-21 12:40:06 +0000375 PIN(UCA, UART, UARTC, RSVD, GMI, RSVD, RSVD4),
376 PIN(UCB, UART, UARTC, PWM, GMI, RSVD, RSVD4),
377
378 PIN_RESERVED,
379 PIN(ATE, NAND, IDE, NAND, GMI, RSVD, IDE),
380 PIN(KBCC, SYS, KBC, NAND, TRACE, EMC_TEST1_DLL, KBC),
381 PIN_RESERVED,
382 PIN_RESERVED,
383 PIN(GMB, NAND, IDE, NAND, GMI, GMI_INT, GMI),
384 PIN(GMD, NAND, RSVD, NAND, GMI, SFLASH, GMI),
385 PIN(DDC, LCD, I2C2, RSVD, RSVD, RSVD, RSVD4),
386
387 /* 64 */
388 PINP(LD0, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
389 PINP(LD1, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
390 PINP(LD2, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
391 PINP(LD3, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
392 PINP(LD4, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
393 PINP(LD5, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
394 PINP(LD6, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
395 PINP(LD7, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
396
397 PINP(LD8, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
398 PINP(LD9, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
399 PINP(LD10, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
400 PINP(LD11, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
401 PINP(LD12, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
402 PINP(LD13, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
403 PINP(LD14, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
404 PINP(LD15, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
405
406 PINP(LD16, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LD17),
407 PINP(LD17, LCD, DISPA, DISPB, RSVD, RSVD, RSVD4, LD17),
408 PINP(LHP0, LCD, DISPA, DISPB, RSVD, RSVD, RSVD4, LD21_20),
409 PINP(LHP1, LCD, DISPA, DISPB, RSVD, RSVD, RSVD4, LD19_18),
410 PINP(LHP2, LCD, DISPA, DISPB, RSVD, RSVD, RSVD4, LD19_18),
411 PINP(LVP0, LCD, DISPA, DISPB, RSVD, RSVD, RSVD4, LC),
412 PINP(LVP1, LCD, DISPA, DISPB, RSVD, RSVD, RSVD4, LD21_20),
413 PINP(HDINT, LCD, HDMI, RSVD, RSVD, RSVD, HDMI , LC),
414
415 PINP(LM0, LCD, DISPA, DISPB, SPI3, RSVD, RSVD4, LC),
416 PINP(LM1, LCD, DISPA, DISPB, RSVD, CRT, RSVD3, LC),
417 PINP(LVS, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LC),
418 PINP(LSC0, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LC),
419 PINP(LSC1, LCD, DISPA, DISPB, SPI3, HDMI, DISPA, LS),
420 PINP(LSCK, LCD, DISPA, DISPB, SPI3, HDMI, DISPA, LS),
421 PINP(LDC, LCD, DISPA, DISPB, RSVD, RSVD, RSVD4, LS),
422 PINP(LCSN, LCD, DISPA, DISPB, SPI3, RSVD, RSVD4, LS),
423
424 /* 96 */
425 PINP(LSPI, LCD, DISPA, DISPB, XIO, HDMI, DISPA, LC),
426 PINP(LSDA, LCD, DISPA, DISPB, SPI3, HDMI, DISPA, LS),
427 PINP(LSDI, LCD, DISPA, DISPB, SPI3, RSVD, DISPA, LS),
428 PINP(LPW0, LCD, DISPA, DISPB, SPI3, HDMI, DISPA, LS),
429 PINP(LPW1, LCD, DISPA, DISPB, RSVD, RSVD, RSVD4, LS),
430 PINP(LPW2, LCD, DISPA, DISPB, SPI3, HDMI, DISPA, LS),
431 PINP(LDI, LCD, DISPA, DISPB, RSVD, RSVD, RSVD4, LD23_22),
432 PINP(LHS, LCD, DISPA, DISPB, XIO, RSVD, RSVD4, LC),
433
434 PINP(LPP, LCD, DISPA, DISPB, RSVD, RSVD, RSVD4, LD23_22),
435 PIN_RESERVED,
436 PIN(KBCD, SYS, KBC, NAND, SDIO2, MIO, KBC),
437 PIN(GPU7, SYS, RTCK, RSVD, RSVD, RSVD, RTCK),
438 PIN(DTF, VI, I2C3, RSVD, VI, RSVD, RSVD4),
439 PIN(UDA, BB, SPI1, RSVD, UARTD, ULPI, RSVD2),
440 PIN(CRTP, LCD, CRT, RSVD, RSVD, RSVD, RSVD),
441 PINP(SDB, SD, UARTA, PWM, SDIO3, SPI2, PWM, NONE),
442
443 /* these pin groups only have pullup and pull down control */
444 PINALL(CK32, SYS, RSVD, RSVD, RSVD, RSVD, RSVD, MUXCTL_NONE,
445 PUCTL_NONE),
446 PINALL(DDRC, DDR, RSVD, RSVD, RSVD, RSVD, RSVD, MUXCTL_NONE,
447 PUCTL_NONE),
448 PINALL(PMCA, SYS, RSVD, RSVD, RSVD, RSVD, RSVD, MUXCTL_NONE,
449 PUCTL_NONE),
450 PINALL(PMCB, SYS, RSVD, RSVD, RSVD, RSVD, RSVD, MUXCTL_NONE,
451 PUCTL_NONE),
452 PINALL(PMCC, SYS, RSVD, RSVD, RSVD, RSVD, RSVD, MUXCTL_NONE,
453 PUCTL_NONE),
454 PINALL(PMCD, SYS, RSVD, RSVD, RSVD, RSVD, RSVD, MUXCTL_NONE,
455 PUCTL_NONE),
456 PINALL(PMCE, SYS, RSVD, RSVD, RSVD, RSVD, RSVD, MUXCTL_NONE,
457 PUCTL_NONE),
458 PINALL(XM2C, DDR, RSVD, RSVD, RSVD, RSVD, RSVD, MUXCTL_NONE,
459 PUCTL_NONE),
460 PINALL(XM2D, DDR, RSVD, RSVD, RSVD, RSVD, RSVD, MUXCTL_NONE,
461 PUCTL_NONE),
462};
463
Simon Glassc3cf49d2011-09-21 12:40:05 +0000464void pinmux_set_tristate(enum pmux_pingrp pin, int enable)
Simon Glass858bd092011-08-30 06:23:14 +0000465{
Simon Glass20e18e02011-09-21 12:40:06 +0000466 struct pmux_tri_ctlr *pmt =
467 (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
Simon Glass858bd092011-08-30 06:23:14 +0000468 u32 *tri = &pmt->pmt_tri[TRISTATE_REG(pin)];
469 u32 reg;
470
471 reg = readl(tri);
472 if (enable)
473 reg |= TRISTATE_MASK(pin);
474 else
475 reg &= ~TRISTATE_MASK(pin);
476 writel(reg, tri);
477}
478
Simon Glassc3cf49d2011-09-21 12:40:05 +0000479void pinmux_tristate_enable(enum pmux_pingrp pin)
Simon Glass858bd092011-08-30 06:23:14 +0000480{
481 pinmux_set_tristate(pin, 1);
482}
483
Simon Glassc3cf49d2011-09-21 12:40:05 +0000484void pinmux_tristate_disable(enum pmux_pingrp pin)
Simon Glass858bd092011-08-30 06:23:14 +0000485{
486 pinmux_set_tristate(pin, 0);
487}
Simon Glass20e18e02011-09-21 12:40:06 +0000488
489void pinmux_set_pullupdown(enum pmux_pingrp pin, enum pmux_pull pupd)
490{
491 struct pmux_tri_ctlr *pmt =
492 (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
493 enum pmux_pullid pull_id = tegra_soc_pingroups[pin].pull_id;
494 u32 *pull = &pmt->pmt_pull[PULL_REG(pull_id)];
495 u32 mask_bit;
496 u32 reg;
497 mask_bit = PULL_SHIFT(pull_id);
498
499 reg = readl(pull);
500 reg &= ~(0x3 << mask_bit);
501 reg |= pupd << mask_bit;
502 writel(reg, pull);
503}
504
505void pinmux_set_func(enum pmux_pingrp pin, enum pmux_func func)
506{
507 struct pmux_tri_ctlr *pmt =
508 (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
509 enum pmux_ctlid mux_id = tegra_soc_pingroups[pin].ctl_id;
510 u32 *muxctl = &pmt->pmt_ctl[MUXCTL_REG(mux_id)];
511 u32 mask_bit;
512 int i, mux = -1;
513 u32 reg;
514
515 assert(pmux_func_isvalid(func));
516
517 /* Handle special values */
518 if (func >= PMUX_FUNC_RSVD1) {
519 mux = (func - PMUX_FUNC_RSVD1) & 0x3;
520 } else {
521 /* Search for the appropriate function */
522 for (i = 0; i < 4; i++) {
523 if (tegra_soc_pingroups[pin].funcs[i] == func) {
524 mux = i;
525 break;
526 }
527 }
528 }
529 assert(mux != -1);
530
531 mask_bit = MUXCTL_SHIFT(mux_id);
532 reg = readl(muxctl);
533 reg &= ~(0x3 << mask_bit);
534 reg |= mux << mask_bit;
535 writel(reg, muxctl);
536}
537
Simon Glass95be58c2012-10-17 13:24:45 +0000538void pinmux_config_pingroup(const struct pingroup_config *config)
Simon Glass20e18e02011-09-21 12:40:06 +0000539{
540 enum pmux_pingrp pin = config->pingroup;
541
542 pinmux_set_func(pin, config->func);
543 pinmux_set_pullupdown(pin, config->pull);
544 pinmux_set_tristate(pin, config->tristate);
545}
546
Simon Glass95be58c2012-10-17 13:24:45 +0000547void pinmux_config_table(const struct pingroup_config *config, int len)
Simon Glass20e18e02011-09-21 12:40:06 +0000548{
549 int i;
550
551 for (i = 0; i < len; i++)
552 pinmux_config_pingroup(&config[i]);
553}