xref: /openbmc/u-boot/arch/arm/include/asm/arch-tegra/pinmux.h (revision 83d290c56fab2d38cd1ab4c4cc7099559c1d5046)
1*83d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */
2e2969957SStephen Warren /*
3e2969957SStephen Warren  * (C) Copyright 2010-2014
4e2969957SStephen Warren  * NVIDIA Corporation <www.nvidia.com>
5e2969957SStephen Warren  */
6e2969957SStephen Warren 
7e2969957SStephen Warren #ifndef _TEGRA_PINMUX_H_
8e2969957SStephen Warren #define _TEGRA_PINMUX_H_
9e2969957SStephen Warren 
1035f590f4SThierry Reding #include <linux/types.h>
1135f590f4SThierry Reding 
12e2969957SStephen Warren #include <asm/arch/tegra.h>
13e2969957SStephen Warren 
14e2969957SStephen Warren /* The pullup/pulldown state of a pin group */
15e2969957SStephen Warren enum pmux_pull {
16e2969957SStephen Warren 	PMUX_PULL_NORMAL = 0,
17e2969957SStephen Warren 	PMUX_PULL_DOWN,
18e2969957SStephen Warren 	PMUX_PULL_UP,
19e2969957SStephen Warren };
20e2969957SStephen Warren 
21e2969957SStephen Warren /* Defines whether a pin group is tristated or in normal operation */
22e2969957SStephen Warren enum pmux_tristate {
23e2969957SStephen Warren 	PMUX_TRI_NORMAL = 0,
24e2969957SStephen Warren 	PMUX_TRI_TRISTATE = 1,
25e2969957SStephen Warren };
26e2969957SStephen Warren 
277a28441fSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_E_INPUT
28e2969957SStephen Warren enum pmux_pin_io {
29e2969957SStephen Warren 	PMUX_PIN_OUTPUT = 0,
30e2969957SStephen Warren 	PMUX_PIN_INPUT = 1,
31e2969957SStephen Warren 	PMUX_PIN_NONE,
32e2969957SStephen Warren };
337a28441fSStephen Warren #endif
34e2969957SStephen Warren 
357a28441fSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_LOCK
36e2969957SStephen Warren enum pmux_pin_lock {
37e2969957SStephen Warren 	PMUX_PIN_LOCK_DEFAULT = 0,
38e2969957SStephen Warren 	PMUX_PIN_LOCK_DISABLE,
39e2969957SStephen Warren 	PMUX_PIN_LOCK_ENABLE,
40e2969957SStephen Warren };
417a28441fSStephen Warren #endif
42e2969957SStephen Warren 
437a28441fSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_OD
44e2969957SStephen Warren enum pmux_pin_od {
45e2969957SStephen Warren 	PMUX_PIN_OD_DEFAULT = 0,
46e2969957SStephen Warren 	PMUX_PIN_OD_DISABLE,
47e2969957SStephen Warren 	PMUX_PIN_OD_ENABLE,
48e2969957SStephen Warren };
497a28441fSStephen Warren #endif
50e2969957SStephen Warren 
517a28441fSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_IO_RESET
52e2969957SStephen Warren enum pmux_pin_ioreset {
53e2969957SStephen Warren 	PMUX_PIN_IO_RESET_DEFAULT = 0,
54e2969957SStephen Warren 	PMUX_PIN_IO_RESET_DISABLE,
55e2969957SStephen Warren 	PMUX_PIN_IO_RESET_ENABLE,
56e2969957SStephen Warren };
577a28441fSStephen Warren #endif
58e2969957SStephen Warren 
597a28441fSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_RCV_SEL
60e2969957SStephen Warren enum pmux_pin_rcv_sel {
61e2969957SStephen Warren 	PMUX_PIN_RCV_SEL_DEFAULT = 0,
62e2969957SStephen Warren 	PMUX_PIN_RCV_SEL_NORMAL,
63e2969957SStephen Warren 	PMUX_PIN_RCV_SEL_HIGH,
64e2969957SStephen Warren };
657a28441fSStephen Warren #endif
66e2969957SStephen Warren 
67f4d7c9ddSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_E_IO_HV
68f4d7c9ddSStephen Warren enum pmux_pin_e_io_hv {
69f4d7c9ddSStephen Warren 	PMUX_PIN_E_IO_HV_DEFAULT = 0,
70f4d7c9ddSStephen Warren 	PMUX_PIN_E_IO_HV_NORMAL,
71f4d7c9ddSStephen Warren 	PMUX_PIN_E_IO_HV_HIGH,
72f4d7c9ddSStephen Warren };
73f4d7c9ddSStephen Warren #endif
74f4d7c9ddSStephen Warren 
75bc134728SStephen Warren #ifdef TEGRA_PMX_GRPS_HAVE_LPMD
76bc134728SStephen Warren /* Defines a pin group cfg's low-power mode select */
77bc134728SStephen Warren enum pmux_lpmd {
78bc134728SStephen Warren 	PMUX_LPMD_X8 = 0,
79bc134728SStephen Warren 	PMUX_LPMD_X4,
80bc134728SStephen Warren 	PMUX_LPMD_X2,
81bc134728SStephen Warren 	PMUX_LPMD_X,
82bc134728SStephen Warren 	PMUX_LPMD_NONE = -1,
83bc134728SStephen Warren };
84bc134728SStephen Warren #endif
85bc134728SStephen Warren 
86f2c60eedSStephen Warren #if defined(TEGRA_PMX_PINS_HAVE_SCHMT) || defined(TEGRA_PMX_GRPS_HAVE_SCHMT)
87bc134728SStephen Warren /* Defines whether a pin group cfg's schmidt is enabled or not */
88bc134728SStephen Warren enum pmux_schmt {
89bc134728SStephen Warren 	PMUX_SCHMT_DISABLE = 0,
90bc134728SStephen Warren 	PMUX_SCHMT_ENABLE = 1,
91bc134728SStephen Warren 	PMUX_SCHMT_NONE = -1,
92bc134728SStephen Warren };
93bc134728SStephen Warren #endif
94bc134728SStephen Warren 
95f2c60eedSStephen Warren #if defined(TEGRA_PMX_PINS_HAVE_HSM) || defined(TEGRA_PMX_GRPS_HAVE_HSM)
96bc134728SStephen Warren /* Defines whether a pin group cfg's high-speed mode is enabled or not */
97bc134728SStephen Warren enum pmux_hsm {
98bc134728SStephen Warren 	PMUX_HSM_DISABLE = 0,
99bc134728SStephen Warren 	PMUX_HSM_ENABLE = 1,
100bc134728SStephen Warren 	PMUX_HSM_NONE = -1,
101bc134728SStephen Warren };
102bc134728SStephen Warren #endif
103bc134728SStephen Warren 
104e2969957SStephen Warren /*
105e2969957SStephen Warren  * This defines the configuration for a pin, including the function assigned,
106e2969957SStephen Warren  * pull up/down settings and tristate settings. Having set up one of these
107e2969957SStephen Warren  * you can call pinmux_config_pingroup() to configure a pin in one step. Also
108e2969957SStephen Warren  * available is pinmux_config_table() to configure a list of pins.
109e2969957SStephen Warren  */
110dfb42fc9SStephen Warren struct pmux_pingrp_config {
111d381294aSStephen Warren 	u32 pingrp:16;		/* pin group PMUX_PINGRP_...        */
112d381294aSStephen Warren 	u32 func:8;		/* function to assign PMUX_FUNC_... */
113d381294aSStephen Warren 	u32 pull:2;		/* pull up/down/normal PMUX_PULL_...*/
114d381294aSStephen Warren 	u32 tristate:2;		/* tristate or normal PMUX_TRI_...  */
1157a28441fSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_E_INPUT
116d381294aSStephen Warren 	u32 io:2;		/* input or output PMUX_PIN_...     */
1177a28441fSStephen Warren #endif
1187a28441fSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_LOCK
119d381294aSStephen Warren 	u32 lock:2;		/* lock enable/disable PMUX_PIN...  */
1207a28441fSStephen Warren #endif
1217a28441fSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_OD
122d381294aSStephen Warren 	u32 od:2;		/* open-drain or push-pull driver   */
1237a28441fSStephen Warren #endif
1247a28441fSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_IO_RESET
125d381294aSStephen Warren 	u32 ioreset:2;		/* input/output reset PMUX_PIN...   */
1267a28441fSStephen Warren #endif
1277a28441fSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_RCV_SEL
128d381294aSStephen Warren 	u32 rcv_sel:2;		/* select between High and Normal  */
129e2969957SStephen Warren 				/* VIL/VIH receivers */
130e2969957SStephen Warren #endif
131f4d7c9ddSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_E_IO_HV
132f4d7c9ddSStephen Warren 	u32 e_io_hv:2;		/* select 3.3v tolerant receivers */
133f4d7c9ddSStephen Warren #endif
134f2c60eedSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_SCHMT
135f2c60eedSStephen Warren 	u32 schmt:2;		/* schmitt enable            */
136f2c60eedSStephen Warren #endif
137f2c60eedSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_HSM
138f2c60eedSStephen Warren 	u32 hsm:2;		/* high-speed mode enable    */
139f2c60eedSStephen Warren #endif
140e2969957SStephen Warren };
141e2969957SStephen Warren 
1427a28441fSStephen Warren #ifdef TEGRA_PMX_SOC_HAS_IO_CLAMPING
143f799b03fSStephen Warren /* Set/clear the pinmux CLAMP_INPUTS_WHEN_TRISTATED bit */
144bb14469aSStephen Warren void pinmux_set_tristate_input_clamping(void);
145f799b03fSStephen Warren void pinmux_clear_tristate_input_clamping(void);
146bb14469aSStephen Warren #endif
147bb14469aSStephen Warren 
148e2969957SStephen Warren /* Set the mux function for a pin group */
149e2969957SStephen Warren void pinmux_set_func(enum pmux_pingrp pin, enum pmux_func func);
150e2969957SStephen Warren 
151e2969957SStephen Warren /* Set the pull up/down feature for a pin group */
152e2969957SStephen Warren void pinmux_set_pullupdown(enum pmux_pingrp pin, enum pmux_pull pupd);
153e2969957SStephen Warren 
154e2969957SStephen Warren /* Set a pin group to tristate */
155e2969957SStephen Warren void pinmux_tristate_enable(enum pmux_pingrp pin);
156e2969957SStephen Warren 
157e2969957SStephen Warren /* Set a pin group to normal (non tristate) */
158e2969957SStephen Warren void pinmux_tristate_disable(enum pmux_pingrp pin);
159e2969957SStephen Warren 
1607a28441fSStephen Warren #ifdef TEGRA_PMX_PINS_HAVE_E_INPUT
161e2969957SStephen Warren /* Set a pin group as input or output */
162e2969957SStephen Warren void pinmux_set_io(enum pmux_pingrp pin, enum pmux_pin_io io);
163e2969957SStephen Warren #endif
164e2969957SStephen Warren 
165e2969957SStephen Warren /**
166e2969957SStephen Warren  * Configure a list of pin groups
167e2969957SStephen Warren  *
168e2969957SStephen Warren  * @param config	List of config items
169e2969957SStephen Warren  * @param len		Number of config items in list
170e2969957SStephen Warren  */
171dfb42fc9SStephen Warren void pinmux_config_pingrp_table(const struct pmux_pingrp_config *config,
172dfb42fc9SStephen Warren 				int len);
173e2969957SStephen Warren 
174c21478bcSStephen Warren struct pmux_pingrp_desc {
175c21478bcSStephen Warren 	u8 funcs[4];
176c21478bcSStephen Warren #if defined(CONFIG_TEGRA20)
177c21478bcSStephen Warren 	u8 ctl_id;
178c21478bcSStephen Warren 	u8 pull_id;
179c21478bcSStephen Warren #endif /* CONFIG_TEGRA20 */
180c21478bcSStephen Warren };
181c21478bcSStephen Warren 
182c21478bcSStephen Warren extern const struct pmux_pingrp_desc *tegra_soc_pingroups;
183c21478bcSStephen Warren 
1847a28441fSStephen Warren #ifdef TEGRA_PMX_SOC_HAS_DRVGRPS
185e2969957SStephen Warren 
186dfb42fc9SStephen Warren #define PMUX_SLWF_MIN	0
187dfb42fc9SStephen Warren #define PMUX_SLWF_MAX	3
188dfb42fc9SStephen Warren #define PMUX_SLWF_NONE	-1
189e2969957SStephen Warren 
190dfb42fc9SStephen Warren #define PMUX_SLWR_MIN	0
191dfb42fc9SStephen Warren #define PMUX_SLWR_MAX	3
192dfb42fc9SStephen Warren #define PMUX_SLWR_NONE	-1
193e2969957SStephen Warren 
194dfb42fc9SStephen Warren #define PMUX_DRVUP_MIN	0
195dfb42fc9SStephen Warren #define PMUX_DRVUP_MAX	127
196dfb42fc9SStephen Warren #define PMUX_DRVUP_NONE	-1
197e2969957SStephen Warren 
198dfb42fc9SStephen Warren #define PMUX_DRVDN_MIN	0
199dfb42fc9SStephen Warren #define PMUX_DRVDN_MAX	127
200dfb42fc9SStephen Warren #define PMUX_DRVDN_NONE	-1
201e2969957SStephen Warren 
202e2969957SStephen Warren /*
203e2969957SStephen Warren  * This defines the configuration for a pin group's pad control config
204e2969957SStephen Warren  */
205dfb42fc9SStephen Warren struct pmux_drvgrp_config {
206d381294aSStephen Warren 	u32 drvgrp:16;	/* pin group PMUX_DRVGRP_x   */
207d381294aSStephen Warren 	u32 slwf:3;		/* falling edge slew         */
208d381294aSStephen Warren 	u32 slwr:3;		/* rising edge slew          */
209d381294aSStephen Warren 	u32 drvup:8;		/* pull-up drive strength    */
210d381294aSStephen Warren 	u32 drvdn:8;		/* pull-down drive strength  */
211439f5768SStephen Warren #ifdef TEGRA_PMX_GRPS_HAVE_LPMD
212d381294aSStephen Warren 	u32 lpmd:3;		/* low-power mode selection  */
213439f5768SStephen Warren #endif
214439f5768SStephen Warren #ifdef TEGRA_PMX_GRPS_HAVE_SCHMT
215d381294aSStephen Warren 	u32 schmt:2;		/* schmidt enable            */
216439f5768SStephen Warren #endif
217439f5768SStephen Warren #ifdef TEGRA_PMX_GRPS_HAVE_HSM
218d381294aSStephen Warren 	u32 hsm:2;		/* high-speed mode enable    */
219439f5768SStephen Warren #endif
220e2969957SStephen Warren };
221e2969957SStephen Warren 
222e2969957SStephen Warren /**
223e2969957SStephen Warren  * Set the GP pad configs
224e2969957SStephen Warren  *
225e2969957SStephen Warren  * @param config	List of config items
226e2969957SStephen Warren  * @param len		Number of config items in list
227e2969957SStephen Warren  */
228dfb42fc9SStephen Warren void pinmux_config_drvgrp_table(const struct pmux_drvgrp_config *config,
229dfb42fc9SStephen Warren 				int len);
230e2969957SStephen Warren 
2317a28441fSStephen Warren #endif /* TEGRA_PMX_SOC_HAS_DRVGRPS */
232e2969957SStephen Warren 
2335ee7ec7bSStephen Warren #ifdef TEGRA_PMX_SOC_HAS_MIPI_PAD_CTRL_GRPS
2345ee7ec7bSStephen Warren struct pmux_mipipadctrlgrp_config {
2355ee7ec7bSStephen Warren 	u32 grp:16;	/* pin group PMUX_MIPIPADCTRLGRP_x   */
2365ee7ec7bSStephen Warren 	u32 func:8;	/* function to assign PMUX_FUNC_... */
2375ee7ec7bSStephen Warren };
2385ee7ec7bSStephen Warren 
2395ee7ec7bSStephen Warren void pinmux_config_mipipadctrlgrp_table(
2405ee7ec7bSStephen Warren 	const struct pmux_mipipadctrlgrp_config *config, int len);
2415ee7ec7bSStephen Warren 
2425ee7ec7bSStephen Warren struct pmux_mipipadctrlgrp_desc {
2435ee7ec7bSStephen Warren 	u8 funcs[2];
2445ee7ec7bSStephen Warren };
2455ee7ec7bSStephen Warren 
2465ee7ec7bSStephen Warren extern const struct pmux_mipipadctrlgrp_desc *tegra_soc_mipipadctrl_groups;
2475ee7ec7bSStephen Warren #endif /* TEGRA_PMX_SOC_HAS_MIPI_PAD_CTRL_GRPS */
2485ee7ec7bSStephen Warren 
249e2969957SStephen Warren #endif /* _TEGRA_PINMUX_H_ */
250