xref: /openbmc/u-boot/arch/arm/include/asm/arch-tegra/pinmux.h (revision f2c60eed513ecc142e0a39373d5c16a14f976d6d)
1e2969957SStephen Warren /*
2e2969957SStephen Warren  * (C) Copyright 2010-2014
3e2969957SStephen Warren  * NVIDIA Corporation <www.nvidia.com>
4e2969957SStephen Warren  *
5e2969957SStephen Warren  * SPDX-License-Identifier:     GPL-2.0+
6e2969957SStephen Warren  */
7e2969957SStephen Warren 
8e2969957SStephen Warren #ifndef _TEGRA_PINMUX_H_
9e2969957SStephen Warren #define _TEGRA_PINMUX_H_
10e2969957SStephen Warren 
11e2969957SStephen Warren #include <asm/arch/tegra.h>
12e2969957SStephen Warren 
13e2969957SStephen Warren /* The pullup/pulldown state of a pin group */
14e2969957SStephen Warren enum pmux_pull {
15e2969957SStephen Warren 	PMUX_PULL_NORMAL = 0,
16e2969957SStephen Warren 	PMUX_PULL_DOWN,
17e2969957SStephen Warren 	PMUX_PULL_UP,
18e2969957SStephen Warren };
19e2969957SStephen Warren 
20e2969957SStephen Warren /* Defines whether a pin group is tristated or in normal operation */
21e2969957SStephen Warren enum pmux_tristate {
22e2969957SStephen Warren 	PMUX_TRI_NORMAL = 0,
23e2969957SStephen Warren 	PMUX_TRI_TRISTATE = 1,
24e2969957SStephen Warren };
25e2969957SStephen Warren 
267a28441fSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_E_INPUT
27e2969957SStephen Warren enum pmux_pin_io {
28e2969957SStephen Warren 	PMUX_PIN_OUTPUT = 0,
29e2969957SStephen Warren 	PMUX_PIN_INPUT = 1,
30e2969957SStephen Warren 	PMUX_PIN_NONE,
31e2969957SStephen Warren };
327a28441fSStephen Warren #endif
33e2969957SStephen Warren 
347a28441fSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_LOCK
35e2969957SStephen Warren enum pmux_pin_lock {
36e2969957SStephen Warren 	PMUX_PIN_LOCK_DEFAULT = 0,
37e2969957SStephen Warren 	PMUX_PIN_LOCK_DISABLE,
38e2969957SStephen Warren 	PMUX_PIN_LOCK_ENABLE,
39e2969957SStephen Warren };
407a28441fSStephen Warren #endif
41e2969957SStephen Warren 
427a28441fSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_OD
43e2969957SStephen Warren enum pmux_pin_od {
44e2969957SStephen Warren 	PMUX_PIN_OD_DEFAULT = 0,
45e2969957SStephen Warren 	PMUX_PIN_OD_DISABLE,
46e2969957SStephen Warren 	PMUX_PIN_OD_ENABLE,
47e2969957SStephen Warren };
487a28441fSStephen Warren #endif
49e2969957SStephen Warren 
507a28441fSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_IO_RESET
51e2969957SStephen Warren enum pmux_pin_ioreset {
52e2969957SStephen Warren 	PMUX_PIN_IO_RESET_DEFAULT = 0,
53e2969957SStephen Warren 	PMUX_PIN_IO_RESET_DISABLE,
54e2969957SStephen Warren 	PMUX_PIN_IO_RESET_ENABLE,
55e2969957SStephen Warren };
567a28441fSStephen Warren #endif
57e2969957SStephen Warren 
587a28441fSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_RCV_SEL
59e2969957SStephen Warren enum pmux_pin_rcv_sel {
60e2969957SStephen Warren 	PMUX_PIN_RCV_SEL_DEFAULT = 0,
61e2969957SStephen Warren 	PMUX_PIN_RCV_SEL_NORMAL,
62e2969957SStephen Warren 	PMUX_PIN_RCV_SEL_HIGH,
63e2969957SStephen Warren };
647a28441fSStephen Warren #endif
65e2969957SStephen Warren 
66bc134728SStephen Warren #ifdef TEGRA_PMX_GRPS_HAVE_LPMD
67bc134728SStephen Warren /* Defines a pin group cfg's low-power mode select */
68bc134728SStephen Warren enum pmux_lpmd {
69bc134728SStephen Warren 	PMUX_LPMD_X8 = 0,
70bc134728SStephen Warren 	PMUX_LPMD_X4,
71bc134728SStephen Warren 	PMUX_LPMD_X2,
72bc134728SStephen Warren 	PMUX_LPMD_X,
73bc134728SStephen Warren 	PMUX_LPMD_NONE = -1,
74bc134728SStephen Warren };
75bc134728SStephen Warren #endif
76bc134728SStephen Warren 
77*f2c60eedSStephen Warren #if defined(TEGRA_PMX_PINS_HAVE_SCHMT) || defined(TEGRA_PMX_GRPS_HAVE_SCHMT)
78bc134728SStephen Warren /* Defines whether a pin group cfg's schmidt is enabled or not */
79bc134728SStephen Warren enum pmux_schmt {
80bc134728SStephen Warren 	PMUX_SCHMT_DISABLE = 0,
81bc134728SStephen Warren 	PMUX_SCHMT_ENABLE = 1,
82bc134728SStephen Warren 	PMUX_SCHMT_NONE = -1,
83bc134728SStephen Warren };
84bc134728SStephen Warren #endif
85bc134728SStephen Warren 
86*f2c60eedSStephen Warren #if defined(TEGRA_PMX_PINS_HAVE_HSM) || defined(TEGRA_PMX_GRPS_HAVE_HSM)
87bc134728SStephen Warren /* Defines whether a pin group cfg's high-speed mode is enabled or not */
88bc134728SStephen Warren enum pmux_hsm {
89bc134728SStephen Warren 	PMUX_HSM_DISABLE = 0,
90bc134728SStephen Warren 	PMUX_HSM_ENABLE = 1,
91bc134728SStephen Warren 	PMUX_HSM_NONE = -1,
92bc134728SStephen Warren };
93bc134728SStephen Warren #endif
94bc134728SStephen Warren 
95e2969957SStephen Warren /*
96e2969957SStephen Warren  * This defines the configuration for a pin, including the function assigned,
97e2969957SStephen Warren  * pull up/down settings and tristate settings. Having set up one of these
98e2969957SStephen Warren  * you can call pinmux_config_pingroup() to configure a pin in one step. Also
99e2969957SStephen Warren  * available is pinmux_config_table() to configure a list of pins.
100e2969957SStephen Warren  */
101dfb42fc9SStephen Warren struct pmux_pingrp_config {
102d381294aSStephen Warren 	u32 pingrp:16;		/* pin group PMUX_PINGRP_...        */
103d381294aSStephen Warren 	u32 func:8;		/* function to assign PMUX_FUNC_... */
104d381294aSStephen Warren 	u32 pull:2;		/* pull up/down/normal PMUX_PULL_...*/
105d381294aSStephen Warren 	u32 tristate:2;		/* tristate or normal PMUX_TRI_...  */
1067a28441fSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_E_INPUT
107d381294aSStephen Warren 	u32 io:2;		/* input or output PMUX_PIN_...     */
1087a28441fSStephen Warren #endif
1097a28441fSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_LOCK
110d381294aSStephen Warren 	u32 lock:2;		/* lock enable/disable PMUX_PIN...  */
1117a28441fSStephen Warren #endif
1127a28441fSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_OD
113d381294aSStephen Warren 	u32 od:2;		/* open-drain or push-pull driver   */
1147a28441fSStephen Warren #endif
1157a28441fSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_IO_RESET
116d381294aSStephen Warren 	u32 ioreset:2;		/* input/output reset PMUX_PIN...   */
1177a28441fSStephen Warren #endif
1187a28441fSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_RCV_SEL
119d381294aSStephen Warren 	u32 rcv_sel:2;		/* select between High and Normal  */
120e2969957SStephen Warren 				/* VIL/VIH receivers */
121e2969957SStephen Warren #endif
122*f2c60eedSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_SCHMT
123*f2c60eedSStephen Warren 	u32 schmt:2;		/* schmitt enable            */
124*f2c60eedSStephen Warren #endif
125*f2c60eedSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_HSM
126*f2c60eedSStephen Warren 	u32 hsm:2;		/* high-speed mode enable    */
127*f2c60eedSStephen Warren #endif
128e2969957SStephen Warren };
129e2969957SStephen Warren 
1307a28441fSStephen Warren #ifdef TEGRA_PMX_SOC_HAS_IO_CLAMPING
131f799b03fSStephen Warren /* Set/clear the pinmux CLAMP_INPUTS_WHEN_TRISTATED bit */
132bb14469aSStephen Warren void pinmux_set_tristate_input_clamping(void);
133f799b03fSStephen Warren void pinmux_clear_tristate_input_clamping(void);
134bb14469aSStephen Warren #endif
135bb14469aSStephen Warren 
136e2969957SStephen Warren /* Set the mux function for a pin group */
137e2969957SStephen Warren void pinmux_set_func(enum pmux_pingrp pin, enum pmux_func func);
138e2969957SStephen Warren 
139e2969957SStephen Warren /* Set the pull up/down feature for a pin group */
140e2969957SStephen Warren void pinmux_set_pullupdown(enum pmux_pingrp pin, enum pmux_pull pupd);
141e2969957SStephen Warren 
142e2969957SStephen Warren /* Set a pin group to tristate */
143e2969957SStephen Warren void pinmux_tristate_enable(enum pmux_pingrp pin);
144e2969957SStephen Warren 
145e2969957SStephen Warren /* Set a pin group to normal (non tristate) */
146e2969957SStephen Warren void pinmux_tristate_disable(enum pmux_pingrp pin);
147e2969957SStephen Warren 
1487a28441fSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_E_INPUT
149e2969957SStephen Warren /* Set a pin group as input or output */
150e2969957SStephen Warren void pinmux_set_io(enum pmux_pingrp pin, enum pmux_pin_io io);
151e2969957SStephen Warren #endif
152e2969957SStephen Warren 
153e2969957SStephen Warren /**
154e2969957SStephen Warren  * Configure a list of pin groups
155e2969957SStephen Warren  *
156e2969957SStephen Warren  * @param config	List of config items
157e2969957SStephen Warren  * @param len		Number of config items in list
158e2969957SStephen Warren  */
159dfb42fc9SStephen Warren void pinmux_config_pingrp_table(const struct pmux_pingrp_config *config,
160dfb42fc9SStephen Warren 				int len);
161e2969957SStephen Warren 
1627a28441fSStephen Warren #ifdef TEGRA_PMX_SOC_HAS_DRVGRPS
163e2969957SStephen Warren 
164dfb42fc9SStephen Warren #define PMUX_SLWF_MIN	0
165dfb42fc9SStephen Warren #define PMUX_SLWF_MAX	3
166dfb42fc9SStephen Warren #define PMUX_SLWF_NONE	-1
167e2969957SStephen Warren 
168dfb42fc9SStephen Warren #define PMUX_SLWR_MIN	0
169dfb42fc9SStephen Warren #define PMUX_SLWR_MAX	3
170dfb42fc9SStephen Warren #define PMUX_SLWR_NONE	-1
171e2969957SStephen Warren 
172dfb42fc9SStephen Warren #define PMUX_DRVUP_MIN	0
173dfb42fc9SStephen Warren #define PMUX_DRVUP_MAX	127
174dfb42fc9SStephen Warren #define PMUX_DRVUP_NONE	-1
175e2969957SStephen Warren 
176dfb42fc9SStephen Warren #define PMUX_DRVDN_MIN	0
177dfb42fc9SStephen Warren #define PMUX_DRVDN_MAX	127
178dfb42fc9SStephen Warren #define PMUX_DRVDN_NONE	-1
179e2969957SStephen Warren 
180e2969957SStephen Warren /*
181e2969957SStephen Warren  * This defines the configuration for a pin group's pad control config
182e2969957SStephen Warren  */
183dfb42fc9SStephen Warren struct pmux_drvgrp_config {
184d381294aSStephen Warren 	u32 drvgrp:16;	/* pin group PMUX_DRVGRP_x   */
185d381294aSStephen Warren 	u32 slwf:3;		/* falling edge slew         */
186d381294aSStephen Warren 	u32 slwr:3;		/* rising edge slew          */
187d381294aSStephen Warren 	u32 drvup:8;		/* pull-up drive strength    */
188d381294aSStephen Warren 	u32 drvdn:8;		/* pull-down drive strength  */
189439f5768SStephen Warren #ifdef TEGRA_PMX_GRPS_HAVE_LPMD
190d381294aSStephen Warren 	u32 lpmd:3;		/* low-power mode selection  */
191439f5768SStephen Warren #endif
192439f5768SStephen Warren #ifdef TEGRA_PMX_GRPS_HAVE_SCHMT
193d381294aSStephen Warren 	u32 schmt:2;		/* schmidt enable            */
194439f5768SStephen Warren #endif
195439f5768SStephen Warren #ifdef TEGRA_PMX_GRPS_HAVE_HSM
196d381294aSStephen Warren 	u32 hsm:2;		/* high-speed mode enable    */
197439f5768SStephen Warren #endif
198e2969957SStephen Warren };
199e2969957SStephen Warren 
200e2969957SStephen Warren /**
201e2969957SStephen Warren  * Set the GP pad configs
202e2969957SStephen Warren  *
203e2969957SStephen Warren  * @param config	List of config items
204e2969957SStephen Warren  * @param len		Number of config items in list
205e2969957SStephen Warren  */
206dfb42fc9SStephen Warren void pinmux_config_drvgrp_table(const struct pmux_drvgrp_config *config,
207dfb42fc9SStephen Warren 				int len);
208e2969957SStephen Warren 
2097a28441fSStephen Warren #endif /* TEGRA_PMX_SOC_HAS_DRVGRPS */
210e2969957SStephen Warren 
211dfb42fc9SStephen Warren struct pmux_pingrp_desc {
212d381294aSStephen Warren 	u8 funcs[4];
213e2969957SStephen Warren #if defined(CONFIG_TEGRA20)
214d381294aSStephen Warren 	u8 ctl_id;
215d381294aSStephen Warren 	u8 pull_id;
216e2969957SStephen Warren #endif /* CONFIG_TEGRA20 */
217e2969957SStephen Warren };
218e2969957SStephen Warren 
219dfb42fc9SStephen Warren extern const struct pmux_pingrp_desc *tegra_soc_pingroups;
220e2969957SStephen Warren 
221e2969957SStephen Warren #endif /* _TEGRA_PINMUX_H_ */
222