blob: 3cc52dd7731aaca4992a05583aa639217e3fa53d [file] [log] [blame]
Stephen Warrene2969952014-03-21 12:28:54 -06001/*
2 * (C) Copyright 2010-2014
3 * NVIDIA Corporation <www.nvidia.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#ifndef _TEGRA_PINMUX_H_
9#define _TEGRA_PINMUX_H_
10
11#include <asm/arch/tegra.h>
12
13/* The pullup/pulldown state of a pin group */
14enum pmux_pull {
15 PMUX_PULL_NORMAL = 0,
16 PMUX_PULL_DOWN,
17 PMUX_PULL_UP,
18};
19
20/* Defines whether a pin group is tristated or in normal operation */
21enum pmux_tristate {
22 PMUX_TRI_NORMAL = 0,
23 PMUX_TRI_TRISTATE = 1,
24};
25
Stephen Warren7a284412015-02-24 14:08:24 -070026#ifdef TEGRA_PMX_PINS_HAVE_E_INPUT
Stephen Warrene2969952014-03-21 12:28:54 -060027enum pmux_pin_io {
28 PMUX_PIN_OUTPUT = 0,
29 PMUX_PIN_INPUT = 1,
30 PMUX_PIN_NONE,
31};
Stephen Warren7a284412015-02-24 14:08:24 -070032#endif
Stephen Warrene2969952014-03-21 12:28:54 -060033
Stephen Warren7a284412015-02-24 14:08:24 -070034#ifdef TEGRA_PMX_PINS_HAVE_LOCK
Stephen Warrene2969952014-03-21 12:28:54 -060035enum pmux_pin_lock {
36 PMUX_PIN_LOCK_DEFAULT = 0,
37 PMUX_PIN_LOCK_DISABLE,
38 PMUX_PIN_LOCK_ENABLE,
39};
Stephen Warren7a284412015-02-24 14:08:24 -070040#endif
Stephen Warrene2969952014-03-21 12:28:54 -060041
Stephen Warren7a284412015-02-24 14:08:24 -070042#ifdef TEGRA_PMX_PINS_HAVE_OD
Stephen Warrene2969952014-03-21 12:28:54 -060043enum pmux_pin_od {
44 PMUX_PIN_OD_DEFAULT = 0,
45 PMUX_PIN_OD_DISABLE,
46 PMUX_PIN_OD_ENABLE,
47};
Stephen Warren7a284412015-02-24 14:08:24 -070048#endif
Stephen Warrene2969952014-03-21 12:28:54 -060049
Stephen Warren7a284412015-02-24 14:08:24 -070050#ifdef TEGRA_PMX_PINS_HAVE_IO_RESET
Stephen Warrene2969952014-03-21 12:28:54 -060051enum pmux_pin_ioreset {
52 PMUX_PIN_IO_RESET_DEFAULT = 0,
53 PMUX_PIN_IO_RESET_DISABLE,
54 PMUX_PIN_IO_RESET_ENABLE,
55};
Stephen Warren7a284412015-02-24 14:08:24 -070056#endif
Stephen Warrene2969952014-03-21 12:28:54 -060057
Stephen Warren7a284412015-02-24 14:08:24 -070058#ifdef TEGRA_PMX_PINS_HAVE_RCV_SEL
Stephen Warrene2969952014-03-21 12:28:54 -060059enum pmux_pin_rcv_sel {
60 PMUX_PIN_RCV_SEL_DEFAULT = 0,
61 PMUX_PIN_RCV_SEL_NORMAL,
62 PMUX_PIN_RCV_SEL_HIGH,
63};
Stephen Warren7a284412015-02-24 14:08:24 -070064#endif
Stephen Warrene2969952014-03-21 12:28:54 -060065
Stephen Warrenf4d7c9d2015-02-24 14:08:30 -070066#ifdef TEGRA_PMX_PINS_HAVE_E_IO_HV
67enum pmux_pin_e_io_hv {
68 PMUX_PIN_E_IO_HV_DEFAULT = 0,
69 PMUX_PIN_E_IO_HV_NORMAL,
70 PMUX_PIN_E_IO_HV_HIGH,
71};
72#endif
73
Stephen Warrenbc134722015-02-24 14:08:26 -070074#ifdef TEGRA_PMX_GRPS_HAVE_LPMD
75/* Defines a pin group cfg's low-power mode select */
76enum pmux_lpmd {
77 PMUX_LPMD_X8 = 0,
78 PMUX_LPMD_X4,
79 PMUX_LPMD_X2,
80 PMUX_LPMD_X,
81 PMUX_LPMD_NONE = -1,
82};
83#endif
84
Stephen Warrenf2c60ee2015-02-24 14:08:28 -070085#if defined(TEGRA_PMX_PINS_HAVE_SCHMT) || defined(TEGRA_PMX_GRPS_HAVE_SCHMT)
Stephen Warrenbc134722015-02-24 14:08:26 -070086/* Defines whether a pin group cfg's schmidt is enabled or not */
87enum pmux_schmt {
88 PMUX_SCHMT_DISABLE = 0,
89 PMUX_SCHMT_ENABLE = 1,
90 PMUX_SCHMT_NONE = -1,
91};
92#endif
93
Stephen Warrenf2c60ee2015-02-24 14:08:28 -070094#if defined(TEGRA_PMX_PINS_HAVE_HSM) || defined(TEGRA_PMX_GRPS_HAVE_HSM)
Stephen Warrenbc134722015-02-24 14:08:26 -070095/* Defines whether a pin group cfg's high-speed mode is enabled or not */
96enum pmux_hsm {
97 PMUX_HSM_DISABLE = 0,
98 PMUX_HSM_ENABLE = 1,
99 PMUX_HSM_NONE = -1,
100};
101#endif
102
Stephen Warrene2969952014-03-21 12:28:54 -0600103/*
104 * This defines the configuration for a pin, including the function assigned,
105 * pull up/down settings and tristate settings. Having set up one of these
106 * you can call pinmux_config_pingroup() to configure a pin in one step. Also
107 * available is pinmux_config_table() to configure a list of pins.
108 */
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600109struct pmux_pingrp_config {
Stephen Warrend3812942014-03-21 15:58:03 -0600110 u32 pingrp:16; /* pin group PMUX_PINGRP_... */
111 u32 func:8; /* function to assign PMUX_FUNC_... */
112 u32 pull:2; /* pull up/down/normal PMUX_PULL_...*/
113 u32 tristate:2; /* tristate or normal PMUX_TRI_... */
Stephen Warren7a284412015-02-24 14:08:24 -0700114#ifdef TEGRA_PMX_PINS_HAVE_E_INPUT
Stephen Warrend3812942014-03-21 15:58:03 -0600115 u32 io:2; /* input or output PMUX_PIN_... */
Stephen Warren7a284412015-02-24 14:08:24 -0700116#endif
117#ifdef TEGRA_PMX_PINS_HAVE_LOCK
Stephen Warrend3812942014-03-21 15:58:03 -0600118 u32 lock:2; /* lock enable/disable PMUX_PIN... */
Stephen Warren7a284412015-02-24 14:08:24 -0700119#endif
120#ifdef TEGRA_PMX_PINS_HAVE_OD
Stephen Warrend3812942014-03-21 15:58:03 -0600121 u32 od:2; /* open-drain or push-pull driver */
Stephen Warren7a284412015-02-24 14:08:24 -0700122#endif
123#ifdef TEGRA_PMX_PINS_HAVE_IO_RESET
Stephen Warrend3812942014-03-21 15:58:03 -0600124 u32 ioreset:2; /* input/output reset PMUX_PIN... */
Stephen Warren7a284412015-02-24 14:08:24 -0700125#endif
126#ifdef TEGRA_PMX_PINS_HAVE_RCV_SEL
Stephen Warrend3812942014-03-21 15:58:03 -0600127 u32 rcv_sel:2; /* select between High and Normal */
128 /* VIL/VIH receivers */
Stephen Warrene2969952014-03-21 12:28:54 -0600129#endif
Stephen Warrenf4d7c9d2015-02-24 14:08:30 -0700130#ifdef TEGRA_PMX_PINS_HAVE_E_IO_HV
131 u32 e_io_hv:2; /* select 3.3v tolerant receivers */
132#endif
Stephen Warrenf2c60ee2015-02-24 14:08:28 -0700133#ifdef TEGRA_PMX_PINS_HAVE_SCHMT
134 u32 schmt:2; /* schmitt enable */
135#endif
136#ifdef TEGRA_PMX_PINS_HAVE_HSM
137 u32 hsm:2; /* high-speed mode enable */
138#endif
Stephen Warrene2969952014-03-21 12:28:54 -0600139};
140
Stephen Warren7a284412015-02-24 14:08:24 -0700141#ifdef TEGRA_PMX_SOC_HAS_IO_CLAMPING
Stephen Warrenf799b032015-02-18 13:27:03 -0700142/* Set/clear the pinmux CLAMP_INPUTS_WHEN_TRISTATED bit */
Stephen Warrenbb144692014-04-22 14:37:54 -0600143void pinmux_set_tristate_input_clamping(void);
Stephen Warrenf799b032015-02-18 13:27:03 -0700144void pinmux_clear_tristate_input_clamping(void);
Stephen Warrenbb144692014-04-22 14:37:54 -0600145#endif
146
Stephen Warrene2969952014-03-21 12:28:54 -0600147/* Set the mux function for a pin group */
148void pinmux_set_func(enum pmux_pingrp pin, enum pmux_func func);
149
150/* Set the pull up/down feature for a pin group */
151void pinmux_set_pullupdown(enum pmux_pingrp pin, enum pmux_pull pupd);
152
Stephen Warrene2969952014-03-21 12:28:54 -0600153/* Set a pin group to tristate */
154void pinmux_tristate_enable(enum pmux_pingrp pin);
155
156/* Set a pin group to normal (non tristate) */
157void pinmux_tristate_disable(enum pmux_pingrp pin);
158
Stephen Warren7a284412015-02-24 14:08:24 -0700159#ifdef TEGRA_PMX_PINS_HAVE_E_INPUT
Stephen Warrene2969952014-03-21 12:28:54 -0600160/* Set a pin group as input or output */
161void pinmux_set_io(enum pmux_pingrp pin, enum pmux_pin_io io);
162#endif
163
Stephen Warrene2969952014-03-21 12:28:54 -0600164/**
165 * Configure a list of pin groups
166 *
167 * @param config List of config items
168 * @param len Number of config items in list
169 */
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600170void pinmux_config_pingrp_table(const struct pmux_pingrp_config *config,
171 int len);
Stephen Warrene2969952014-03-21 12:28:54 -0600172
Stephen Warrenc21478b2015-03-25 12:04:35 -0600173struct pmux_pingrp_desc {
174 u8 funcs[4];
175#if defined(CONFIG_TEGRA20)
176 u8 ctl_id;
177 u8 pull_id;
178#endif /* CONFIG_TEGRA20 */
179};
180
181extern const struct pmux_pingrp_desc *tegra_soc_pingroups;
182
Stephen Warren7a284412015-02-24 14:08:24 -0700183#ifdef TEGRA_PMX_SOC_HAS_DRVGRPS
Stephen Warrene2969952014-03-21 12:28:54 -0600184
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600185#define PMUX_SLWF_MIN 0
186#define PMUX_SLWF_MAX 3
187#define PMUX_SLWF_NONE -1
Stephen Warrene2969952014-03-21 12:28:54 -0600188
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600189#define PMUX_SLWR_MIN 0
190#define PMUX_SLWR_MAX 3
191#define PMUX_SLWR_NONE -1
Stephen Warrene2969952014-03-21 12:28:54 -0600192
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600193#define PMUX_DRVUP_MIN 0
194#define PMUX_DRVUP_MAX 127
195#define PMUX_DRVUP_NONE -1
Stephen Warrene2969952014-03-21 12:28:54 -0600196
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600197#define PMUX_DRVDN_MIN 0
198#define PMUX_DRVDN_MAX 127
199#define PMUX_DRVDN_NONE -1
Stephen Warrene2969952014-03-21 12:28:54 -0600200
Stephen Warrene2969952014-03-21 12:28:54 -0600201/*
202 * This defines the configuration for a pin group's pad control config
203 */
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600204struct pmux_drvgrp_config {
Stephen Warrend3812942014-03-21 15:58:03 -0600205 u32 drvgrp:16; /* pin group PMUX_DRVGRP_x */
206 u32 slwf:3; /* falling edge slew */
207 u32 slwr:3; /* rising edge slew */
208 u32 drvup:8; /* pull-up drive strength */
209 u32 drvdn:8; /* pull-down drive strength */
Stephen Warren439f5762015-02-24 14:08:25 -0700210#ifdef TEGRA_PMX_GRPS_HAVE_LPMD
Stephen Warrend3812942014-03-21 15:58:03 -0600211 u32 lpmd:3; /* low-power mode selection */
Stephen Warren439f5762015-02-24 14:08:25 -0700212#endif
213#ifdef TEGRA_PMX_GRPS_HAVE_SCHMT
Stephen Warrend3812942014-03-21 15:58:03 -0600214 u32 schmt:2; /* schmidt enable */
Stephen Warren439f5762015-02-24 14:08:25 -0700215#endif
216#ifdef TEGRA_PMX_GRPS_HAVE_HSM
Stephen Warrend3812942014-03-21 15:58:03 -0600217 u32 hsm:2; /* high-speed mode enable */
Stephen Warren439f5762015-02-24 14:08:25 -0700218#endif
Stephen Warrene2969952014-03-21 12:28:54 -0600219};
220
221/**
222 * Set the GP pad configs
223 *
224 * @param config List of config items
225 * @param len Number of config items in list
226 */
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600227void pinmux_config_drvgrp_table(const struct pmux_drvgrp_config *config,
228 int len);
Stephen Warrene2969952014-03-21 12:28:54 -0600229
Stephen Warren7a284412015-02-24 14:08:24 -0700230#endif /* TEGRA_PMX_SOC_HAS_DRVGRPS */
Stephen Warrene2969952014-03-21 12:28:54 -0600231
Stephen Warren5ee7ec72015-03-25 12:04:36 -0600232#ifdef TEGRA_PMX_SOC_HAS_MIPI_PAD_CTRL_GRPS
233struct pmux_mipipadctrlgrp_config {
234 u32 grp:16; /* pin group PMUX_MIPIPADCTRLGRP_x */
235 u32 func:8; /* function to assign PMUX_FUNC_... */
236};
237
238void pinmux_config_mipipadctrlgrp_table(
239 const struct pmux_mipipadctrlgrp_config *config, int len);
240
241struct pmux_mipipadctrlgrp_desc {
242 u8 funcs[2];
243};
244
245extern const struct pmux_mipipadctrlgrp_desc *tegra_soc_mipipadctrl_groups;
246#endif /* TEGRA_PMX_SOC_HAS_MIPI_PAD_CTRL_GRPS */
247
Stephen Warrene2969952014-03-21 12:28:54 -0600248#endif /* _TEGRA_PINMUX_H_ */