blob: a9b4edaf261b63e3ddb33e0825e2c7da5c8426f7 [file] [log] [blame]
Tom Warren3f82b1d2011-01-27 10:58:05 +00001/*
2 * (C) Copyright 2010,2011
3 * NVIDIA Corporation <www.nvidia.com>
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24#ifndef _PINMUX_H_
25#define _PINMUX_H_
26
Simon Glass20e18e02011-09-21 12:40:06 +000027/*
28 * Pin groups which we adjust. There are three basic attributes of each pin
29 * group which use this enum:
30 *
31 * - function
32 * - pullup / pulldown
33 * - tristate or normal
34 */
Simon Glassc3cf49d2011-09-21 12:40:05 +000035enum pmux_pingrp {
Simon Glass858bd092011-08-30 06:23:14 +000036 /* APB_MISC_PP_TRISTATE_REG_A_0 */
Simon Glassc3cf49d2011-09-21 12:40:05 +000037 PINGRP_ATA,
38 PINGRP_ATB,
39 PINGRP_ATC,
40 PINGRP_ATD,
41 PINGRP_CDEV1,
42 PINGRP_CDEV2,
43 PINGRP_CSUS,
44 PINGRP_DAP1,
Simon Glass858bd092011-08-30 06:23:14 +000045
Simon Glassc3cf49d2011-09-21 12:40:05 +000046 PINGRP_DAP2,
47 PINGRP_DAP3,
48 PINGRP_DAP4,
49 PINGRP_DTA,
50 PINGRP_DTB,
51 PINGRP_DTC,
52 PINGRP_DTD,
53 PINGRP_DTE,
Simon Glass858bd092011-08-30 06:23:14 +000054
Simon Glassc3cf49d2011-09-21 12:40:05 +000055 PINGRP_GPU,
56 PINGRP_GPV,
57 PINGRP_I2CP,
58 PINGRP_IRTX,
59 PINGRP_IRRX,
60 PINGRP_KBCB,
61 PINGRP_KBCA,
62 PINGRP_PMC,
Simon Glass858bd092011-08-30 06:23:14 +000063
Simon Glassc3cf49d2011-09-21 12:40:05 +000064 PINGRP_PTA,
65 PINGRP_RM,
66 PINGRP_KBCE,
67 PINGRP_KBCF,
68 PINGRP_GMA,
69 PINGRP_GMC,
Lucas Stachffec1eb2012-05-16 08:21:01 +000070 PINGRP_SDIO1,
Simon Glassc3cf49d2011-09-21 12:40:05 +000071 PINGRP_OWC,
Simon Glass858bd092011-08-30 06:23:14 +000072
73 /* 32: APB_MISC_PP_TRISTATE_REG_B_0 */
Simon Glassc3cf49d2011-09-21 12:40:05 +000074 PINGRP_GME,
75 PINGRP_SDC,
76 PINGRP_SDD,
77 PINGRP_RESERVED0,
78 PINGRP_SLXA,
79 PINGRP_SLXC,
80 PINGRP_SLXD,
81 PINGRP_SLXK,
Simon Glass858bd092011-08-30 06:23:14 +000082
Simon Glassc3cf49d2011-09-21 12:40:05 +000083 PINGRP_SPDI,
84 PINGRP_SPDO,
85 PINGRP_SPIA,
86 PINGRP_SPIB,
87 PINGRP_SPIC,
88 PINGRP_SPID,
89 PINGRP_SPIE,
90 PINGRP_SPIF,
Simon Glass858bd092011-08-30 06:23:14 +000091
Simon Glassc3cf49d2011-09-21 12:40:05 +000092 PINGRP_SPIG,
93 PINGRP_SPIH,
94 PINGRP_UAA,
95 PINGRP_UAB,
96 PINGRP_UAC,
97 PINGRP_UAD,
98 PINGRP_UCA,
99 PINGRP_UCB,
Simon Glass858bd092011-08-30 06:23:14 +0000100
Simon Glassc3cf49d2011-09-21 12:40:05 +0000101 PINGRP_RESERVED1,
102 PINGRP_ATE,
103 PINGRP_KBCC,
104 PINGRP_RESERVED2,
105 PINGRP_RESERVED3,
106 PINGRP_GMB,
107 PINGRP_GMD,
108 PINGRP_DDC,
Simon Glass858bd092011-08-30 06:23:14 +0000109
110 /* 64: APB_MISC_PP_TRISTATE_REG_C_0 */
Simon Glassc3cf49d2011-09-21 12:40:05 +0000111 PINGRP_LD0,
112 PINGRP_LD1,
113 PINGRP_LD2,
114 PINGRP_LD3,
115 PINGRP_LD4,
116 PINGRP_LD5,
117 PINGRP_LD6,
118 PINGRP_LD7,
Simon Glass858bd092011-08-30 06:23:14 +0000119
Simon Glassc3cf49d2011-09-21 12:40:05 +0000120 PINGRP_LD8,
121 PINGRP_LD9,
122 PINGRP_LD10,
123 PINGRP_LD11,
124 PINGRP_LD12,
125 PINGRP_LD13,
126 PINGRP_LD14,
127 PINGRP_LD15,
Simon Glass858bd092011-08-30 06:23:14 +0000128
Simon Glassc3cf49d2011-09-21 12:40:05 +0000129 PINGRP_LD16,
130 PINGRP_LD17,
131 PINGRP_LHP0,
132 PINGRP_LHP1,
133 PINGRP_LHP2,
134 PINGRP_LVP0,
135 PINGRP_LVP1,
136 PINGRP_HDINT,
Simon Glass858bd092011-08-30 06:23:14 +0000137
Simon Glassc3cf49d2011-09-21 12:40:05 +0000138 PINGRP_LM0,
139 PINGRP_LM1,
140 PINGRP_LVS,
141 PINGRP_LSC0,
142 PINGRP_LSC1,
143 PINGRP_LSCK,
144 PINGRP_LDC,
145 PINGRP_LCSN,
Simon Glass858bd092011-08-30 06:23:14 +0000146
147 /* 96: APB_MISC_PP_TRISTATE_REG_D_0 */
Simon Glassc3cf49d2011-09-21 12:40:05 +0000148 PINGRP_LSPI,
149 PINGRP_LSDA,
150 PINGRP_LSDI,
151 PINGRP_LPW0,
152 PINGRP_LPW1,
153 PINGRP_LPW2,
154 PINGRP_LDI,
155 PINGRP_LHS,
Simon Glass858bd092011-08-30 06:23:14 +0000156
Simon Glassc3cf49d2011-09-21 12:40:05 +0000157 PINGRP_LPP,
158 PINGRP_RESERVED4,
159 PINGRP_KBCD,
160 PINGRP_GPU7,
161 PINGRP_DTF,
162 PINGRP_UDA,
163 PINGRP_CRTP,
164 PINGRP_SDB,
Simon Glass20e18e02011-09-21 12:40:06 +0000165
166 /* these pin groups only have pullup and pull down control */
167 PINGRP_FIRST_NO_MUX,
168 PINGRP_CK32 = PINGRP_FIRST_NO_MUX,
169 PINGRP_DDRC,
170 PINGRP_PMCA,
171 PINGRP_PMCB,
172 PINGRP_PMCC,
173 PINGRP_PMCD,
174 PINGRP_PMCE,
175 PINGRP_XM2C,
176 PINGRP_XM2D,
177
178 PINGRP_COUNT,
Simon Glass858bd092011-08-30 06:23:14 +0000179};
180
Simon Glass20e18e02011-09-21 12:40:06 +0000181/*
182 * Functions which can be assigned to each of the pin groups. The values here
183 * bear no relation to the values programmed into pinmux registers and are
184 * purely a convenience. The translation is done through a table search.
185 */
186enum pmux_func {
187 PMUX_FUNC_AHB_CLK,
188 PMUX_FUNC_APB_CLK,
189 PMUX_FUNC_AUDIO_SYNC,
190 PMUX_FUNC_CRT,
191 PMUX_FUNC_DAP1,
192 PMUX_FUNC_DAP2,
193 PMUX_FUNC_DAP3,
194 PMUX_FUNC_DAP4,
195 PMUX_FUNC_DAP5,
196 PMUX_FUNC_DISPA,
197 PMUX_FUNC_DISPB,
198 PMUX_FUNC_EMC_TEST0_DLL,
199 PMUX_FUNC_EMC_TEST1_DLL,
200 PMUX_FUNC_GMI,
201 PMUX_FUNC_GMI_INT,
202 PMUX_FUNC_HDMI,
203 PMUX_FUNC_I2C,
204 PMUX_FUNC_I2C2,
205 PMUX_FUNC_I2C3,
206 PMUX_FUNC_IDE,
Simon Glass20e18e02011-09-21 12:40:06 +0000207 PMUX_FUNC_KBC,
208 PMUX_FUNC_MIO,
209 PMUX_FUNC_MIPI_HS,
210 PMUX_FUNC_NAND,
211 PMUX_FUNC_OSC,
212 PMUX_FUNC_OWR,
213 PMUX_FUNC_PCIE,
214 PMUX_FUNC_PLLA_OUT,
215 PMUX_FUNC_PLLC_OUT1,
216 PMUX_FUNC_PLLM_OUT1,
217 PMUX_FUNC_PLLP_OUT2,
218 PMUX_FUNC_PLLP_OUT3,
219 PMUX_FUNC_PLLP_OUT4,
220 PMUX_FUNC_PWM,
221 PMUX_FUNC_PWR_INTR,
222 PMUX_FUNC_PWR_ON,
223 PMUX_FUNC_RTCK,
224 PMUX_FUNC_SDIO1,
225 PMUX_FUNC_SDIO2,
226 PMUX_FUNC_SDIO3,
227 PMUX_FUNC_SDIO4,
228 PMUX_FUNC_SFLASH,
229 PMUX_FUNC_SPDIF,
230 PMUX_FUNC_SPI1,
231 PMUX_FUNC_SPI2,
232 PMUX_FUNC_SPI2_ALT,
233 PMUX_FUNC_SPI3,
234 PMUX_FUNC_SPI4,
235 PMUX_FUNC_TRACE,
236 PMUX_FUNC_TWC,
237 PMUX_FUNC_UARTA,
238 PMUX_FUNC_UARTB,
239 PMUX_FUNC_UARTC,
240 PMUX_FUNC_UARTD,
241 PMUX_FUNC_UARTE,
242 PMUX_FUNC_ULPI,
243 PMUX_FUNC_VI,
244 PMUX_FUNC_VI_SENSOR_CLK,
245 PMUX_FUNC_XIO,
246 PMUX_FUNC_SAFE,
Simon Glass858bd092011-08-30 06:23:14 +0000247
Simon Glass20e18e02011-09-21 12:40:06 +0000248 /* These don't have a name, but can be used in the table */
249 PMUX_FUNC_RSVD1,
250 PMUX_FUNC_RSVD2,
251 PMUX_FUNC_RSVD3,
252 PMUX_FUNC_RSVD4,
253 PMUX_FUNC_RSVD, /* Not valid and should not be used */
254
255 PMUX_FUNC_COUNT,
256
257 PMUX_FUNC_NONE = -1,
258};
259
260/* return 1 if a pmux_func is in range */
261#define pmux_func_isvalid(func) ((func) >= 0 && (func) < PMUX_FUNC_COUNT && \
262 (func) != PMUX_FUNC_RSVD)
263
264/* The pullup/pulldown state of a pin group */
265enum pmux_pull {
266 PMUX_PULL_NORMAL = 0,
267 PMUX_PULL_DOWN,
268 PMUX_PULL_UP,
269};
270
271/* Defines whether a pin group is tristated or in normal operation */
272enum pmux_tristate {
273 PMUX_TRI_NORMAL = 0,
274 PMUX_TRI_TRISTATE = 1,
275};
276
277/* Available power domains used by pin groups */
278enum pmux_vddio {
279 PMUX_VDDIO_BB = 0,
280 PMUX_VDDIO_LCD,
281 PMUX_VDDIO_VI,
282 PMUX_VDDIO_UART,
283 PMUX_VDDIO_DDR,
284 PMUX_VDDIO_NAND,
285 PMUX_VDDIO_SYS,
286 PMUX_VDDIO_AUDIO,
287 PMUX_VDDIO_SD,
288
289 PMUX_VDDIO_NONE
290};
291
292enum {
293 PMUX_TRISTATE_REGS = 4,
294 PMUX_MUX_REGS = 7,
295 PMUX_PULL_REGS = 5,
296};
Simon Glass858bd092011-08-30 06:23:14 +0000297
Tom Warren3f82b1d2011-01-27 10:58:05 +0000298/* APB MISC Pin Mux and Tristate (APB_MISC_PP_) registers */
299struct pmux_tri_ctlr {
300 uint pmt_reserved0; /* ABP_MISC_PP_ reserved offset 00 */
301 uint pmt_reserved1; /* ABP_MISC_PP_ reserved offset 04 */
Simon Glass20e18e02011-09-21 12:40:06 +0000302 uint pmt_strap_opt_a; /* _STRAPPING_OPT_A_0, offset 08 */
Tom Warren3f82b1d2011-01-27 10:58:05 +0000303 uint pmt_reserved2; /* ABP_MISC_PP_ reserved offset 0C */
304 uint pmt_reserved3; /* ABP_MISC_PP_ reserved offset 10 */
Simon Glass20e18e02011-09-21 12:40:06 +0000305 uint pmt_tri[PMUX_TRISTATE_REGS];/* _TRI_STATE_REG_A/B/C/D_0 14-20 */
306 uint pmt_cfg_ctl; /* _CONFIG_CTL_0, offset 24 */
Tom Warren3f82b1d2011-01-27 10:58:05 +0000307
308 uint pmt_reserved[22]; /* ABP_MISC_PP_ reserved offs 28-7C */
309
Simon Glass20e18e02011-09-21 12:40:06 +0000310 uint pmt_ctl[PMUX_MUX_REGS]; /* _PIN_MUX_CTL_A-G_0, offset 80 */
311 uint pmt_reserved4; /* ABP_MISC_PP_ reserved offset 9c */
312 uint pmt_pull[PMUX_PULL_REGS]; /* APB_MISC_PP_PULLUPDOWN_REG_A-E */
Tom Warren3f82b1d2011-01-27 10:58:05 +0000313};
314
Simon Glass20e18e02011-09-21 12:40:06 +0000315/*
316 * This defines the configuration for a pin, including the function assigned,
317 * pull up/down settings and tristate settings. Having set up one of these
318 * you can call pinmux_config_pingroup() to configure a pin in one step. Also
319 * available is pinmux_config_table() to configure a list of pins.
320 */
321struct pingroup_config {
322 enum pmux_pingrp pingroup; /* pin group PINGRP_... */
323 enum pmux_func func; /* function to assign FUNC_... */
324 enum pmux_pull pull; /* pull up/down/normal PMUX_PULL_...*/
325 enum pmux_tristate tristate; /* tristate or normal PMUX_TRI_... */
326};
Simon Glass858bd092011-08-30 06:23:14 +0000327
Simon Glassc3cf49d2011-09-21 12:40:05 +0000328/* Set a pin group to tristate */
329void pinmux_tristate_enable(enum pmux_pingrp pin);
Simon Glass858bd092011-08-30 06:23:14 +0000330
Simon Glassc3cf49d2011-09-21 12:40:05 +0000331/* Set a pin group to normal (non tristate) */
332void pinmux_tristate_disable(enum pmux_pingrp pin);
Tom Warren3f82b1d2011-01-27 10:58:05 +0000333
Simon Glass20e18e02011-09-21 12:40:06 +0000334/* Set the pull up/down feature for a pin group */
335void pinmux_set_pullupdown(enum pmux_pingrp pin, enum pmux_pull pupd);
336
337/* Set the mux function for a pin group */
338void pinmux_set_func(enum pmux_pingrp pin, enum pmux_func func);
339
340/* Set the complete configuration for a pin group */
Simon Glass95be58c2012-10-17 13:24:45 +0000341void pinmux_config_pingroup(const struct pingroup_config *config);
Simon Glass20e18e02011-09-21 12:40:06 +0000342
343void pinmux_set_tristate(enum pmux_pingrp pin, int enable);
344
345/**
346 * Configuure a list of pin groups
347 *
348 * @param config List of config items
349 * @param len Number of config items in list
350 */
Simon Glass95be58c2012-10-17 13:24:45 +0000351void pinmux_config_table(const struct pingroup_config *config, int len);
Simon Glass20e18e02011-09-21 12:40:06 +0000352
Tom Warren3f82b1d2011-01-27 10:58:05 +0000353#endif /* PINMUX_H */