blob: 65eb37334e952a44e37e1ac577975f2924386c78 [file] [log] [blame]
Stephen Warren9026dfd2014-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
Thierry Redingdebf2982015-03-20 13:24:22 +010011#include <linux/types.h>
12
Stephen Warren9026dfd2014-03-21 12:28:54 -060013#include <asm/arch/tegra.h>
14
15/* The pullup/pulldown state of a pin group */
16enum pmux_pull {
17 PMUX_PULL_NORMAL = 0,
18 PMUX_PULL_DOWN,
19 PMUX_PULL_UP,
20};
21
22/* Defines whether a pin group is tristated or in normal operation */
23enum pmux_tristate {
24 PMUX_TRI_NORMAL = 0,
25 PMUX_TRI_TRISTATE = 1,
26};
27
Stephen Warren22d57fe2015-02-24 14:08:24 -070028#ifdef TEGRA_PMX_PINS_HAVE_E_INPUT
Stephen Warren9026dfd2014-03-21 12:28:54 -060029enum pmux_pin_io {
30 PMUX_PIN_OUTPUT = 0,
31 PMUX_PIN_INPUT = 1,
32 PMUX_PIN_NONE,
33};
Stephen Warren22d57fe2015-02-24 14:08:24 -070034#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -060035
Stephen Warren22d57fe2015-02-24 14:08:24 -070036#ifdef TEGRA_PMX_PINS_HAVE_LOCK
Stephen Warren9026dfd2014-03-21 12:28:54 -060037enum pmux_pin_lock {
38 PMUX_PIN_LOCK_DEFAULT = 0,
39 PMUX_PIN_LOCK_DISABLE,
40 PMUX_PIN_LOCK_ENABLE,
41};
Stephen Warren22d57fe2015-02-24 14:08:24 -070042#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -060043
Stephen Warren22d57fe2015-02-24 14:08:24 -070044#ifdef TEGRA_PMX_PINS_HAVE_OD
Stephen Warren9026dfd2014-03-21 12:28:54 -060045enum pmux_pin_od {
46 PMUX_PIN_OD_DEFAULT = 0,
47 PMUX_PIN_OD_DISABLE,
48 PMUX_PIN_OD_ENABLE,
49};
Stephen Warren22d57fe2015-02-24 14:08:24 -070050#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -060051
Stephen Warren22d57fe2015-02-24 14:08:24 -070052#ifdef TEGRA_PMX_PINS_HAVE_IO_RESET
Stephen Warren9026dfd2014-03-21 12:28:54 -060053enum pmux_pin_ioreset {
54 PMUX_PIN_IO_RESET_DEFAULT = 0,
55 PMUX_PIN_IO_RESET_DISABLE,
56 PMUX_PIN_IO_RESET_ENABLE,
57};
Stephen Warren22d57fe2015-02-24 14:08:24 -070058#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -060059
Stephen Warren22d57fe2015-02-24 14:08:24 -070060#ifdef TEGRA_PMX_PINS_HAVE_RCV_SEL
Stephen Warren9026dfd2014-03-21 12:28:54 -060061enum pmux_pin_rcv_sel {
62 PMUX_PIN_RCV_SEL_DEFAULT = 0,
63 PMUX_PIN_RCV_SEL_NORMAL,
64 PMUX_PIN_RCV_SEL_HIGH,
65};
Stephen Warren22d57fe2015-02-24 14:08:24 -070066#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -060067
Stephen Warrend9f8def2015-02-24 14:08:30 -070068#ifdef TEGRA_PMX_PINS_HAVE_E_IO_HV
69enum pmux_pin_e_io_hv {
70 PMUX_PIN_E_IO_HV_DEFAULT = 0,
71 PMUX_PIN_E_IO_HV_NORMAL,
72 PMUX_PIN_E_IO_HV_HIGH,
73};
74#endif
75
Stephen Warren899a5cb2015-02-24 14:08:26 -070076#ifdef TEGRA_PMX_GRPS_HAVE_LPMD
77/* Defines a pin group cfg's low-power mode select */
78enum pmux_lpmd {
79 PMUX_LPMD_X8 = 0,
80 PMUX_LPMD_X4,
81 PMUX_LPMD_X2,
82 PMUX_LPMD_X,
83 PMUX_LPMD_NONE = -1,
84};
85#endif
86
Stephen Warren97f9c682015-02-24 14:08:28 -070087#if defined(TEGRA_PMX_PINS_HAVE_SCHMT) || defined(TEGRA_PMX_GRPS_HAVE_SCHMT)
Stephen Warren899a5cb2015-02-24 14:08:26 -070088/* Defines whether a pin group cfg's schmidt is enabled or not */
89enum pmux_schmt {
90 PMUX_SCHMT_DISABLE = 0,
91 PMUX_SCHMT_ENABLE = 1,
92 PMUX_SCHMT_NONE = -1,
93};
94#endif
95
Stephen Warren97f9c682015-02-24 14:08:28 -070096#if defined(TEGRA_PMX_PINS_HAVE_HSM) || defined(TEGRA_PMX_GRPS_HAVE_HSM)
Stephen Warren899a5cb2015-02-24 14:08:26 -070097/* Defines whether a pin group cfg's high-speed mode is enabled or not */
98enum pmux_hsm {
99 PMUX_HSM_DISABLE = 0,
100 PMUX_HSM_ENABLE = 1,
101 PMUX_HSM_NONE = -1,
102};
103#endif
104
Stephen Warren9026dfd2014-03-21 12:28:54 -0600105/*
106 * This defines the configuration for a pin, including the function assigned,
107 * pull up/down settings and tristate settings. Having set up one of these
108 * you can call pinmux_config_pingroup() to configure a pin in one step. Also
109 * available is pinmux_config_table() to configure a list of pins.
110 */
Stephen Warrenf4df6052014-03-21 12:28:56 -0600111struct pmux_pingrp_config {
Stephen Warren70b080f2014-03-21 15:58:03 -0600112 u32 pingrp:16; /* pin group PMUX_PINGRP_... */
113 u32 func:8; /* function to assign PMUX_FUNC_... */
114 u32 pull:2; /* pull up/down/normal PMUX_PULL_...*/
115 u32 tristate:2; /* tristate or normal PMUX_TRI_... */
Stephen Warren22d57fe2015-02-24 14:08:24 -0700116#ifdef TEGRA_PMX_PINS_HAVE_E_INPUT
Stephen Warren70b080f2014-03-21 15:58:03 -0600117 u32 io:2; /* input or output PMUX_PIN_... */
Stephen Warren22d57fe2015-02-24 14:08:24 -0700118#endif
119#ifdef TEGRA_PMX_PINS_HAVE_LOCK
Stephen Warren70b080f2014-03-21 15:58:03 -0600120 u32 lock:2; /* lock enable/disable PMUX_PIN... */
Stephen Warren22d57fe2015-02-24 14:08:24 -0700121#endif
122#ifdef TEGRA_PMX_PINS_HAVE_OD
Stephen Warren70b080f2014-03-21 15:58:03 -0600123 u32 od:2; /* open-drain or push-pull driver */
Stephen Warren22d57fe2015-02-24 14:08:24 -0700124#endif
125#ifdef TEGRA_PMX_PINS_HAVE_IO_RESET
Stephen Warren70b080f2014-03-21 15:58:03 -0600126 u32 ioreset:2; /* input/output reset PMUX_PIN... */
Stephen Warren22d57fe2015-02-24 14:08:24 -0700127#endif
128#ifdef TEGRA_PMX_PINS_HAVE_RCV_SEL
Stephen Warren70b080f2014-03-21 15:58:03 -0600129 u32 rcv_sel:2; /* select between High and Normal */
130 /* VIL/VIH receivers */
Stephen Warren9026dfd2014-03-21 12:28:54 -0600131#endif
Stephen Warrend9f8def2015-02-24 14:08:30 -0700132#ifdef TEGRA_PMX_PINS_HAVE_E_IO_HV
133 u32 e_io_hv:2; /* select 3.3v tolerant receivers */
134#endif
Stephen Warren97f9c682015-02-24 14:08:28 -0700135#ifdef TEGRA_PMX_PINS_HAVE_SCHMT
136 u32 schmt:2; /* schmitt enable */
137#endif
138#ifdef TEGRA_PMX_PINS_HAVE_HSM
139 u32 hsm:2; /* high-speed mode enable */
140#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -0600141};
142
Stephen Warren22d57fe2015-02-24 14:08:24 -0700143#ifdef TEGRA_PMX_SOC_HAS_IO_CLAMPING
Stephen Warrendb2937f2015-02-18 13:27:03 -0700144/* Set/clear the pinmux CLAMP_INPUTS_WHEN_TRISTATED bit */
Stephen Warrenf53f1082014-04-22 14:37:54 -0600145void pinmux_set_tristate_input_clamping(void);
Stephen Warrendb2937f2015-02-18 13:27:03 -0700146void pinmux_clear_tristate_input_clamping(void);
Stephen Warrenf53f1082014-04-22 14:37:54 -0600147#endif
148
Stephen Warren9026dfd2014-03-21 12:28:54 -0600149/* Set the mux function for a pin group */
150void pinmux_set_func(enum pmux_pingrp pin, enum pmux_func func);
151
152/* Set the pull up/down feature for a pin group */
153void pinmux_set_pullupdown(enum pmux_pingrp pin, enum pmux_pull pupd);
154
Stephen Warren9026dfd2014-03-21 12:28:54 -0600155/* Set a pin group to tristate */
156void pinmux_tristate_enable(enum pmux_pingrp pin);
157
158/* Set a pin group to normal (non tristate) */
159void pinmux_tristate_disable(enum pmux_pingrp pin);
160
Stephen Warren22d57fe2015-02-24 14:08:24 -0700161#ifdef TEGRA_PMX_PINS_HAVE_E_INPUT
Stephen Warren9026dfd2014-03-21 12:28:54 -0600162/* Set a pin group as input or output */
163void pinmux_set_io(enum pmux_pingrp pin, enum pmux_pin_io io);
164#endif
165
Stephen Warren9026dfd2014-03-21 12:28:54 -0600166/**
167 * Configure a list of pin groups
168 *
169 * @param config List of config items
170 * @param len Number of config items in list
171 */
Stephen Warrenf4df6052014-03-21 12:28:56 -0600172void pinmux_config_pingrp_table(const struct pmux_pingrp_config *config,
173 int len);
Stephen Warren9026dfd2014-03-21 12:28:54 -0600174
Stephen Warren1a1f10f2015-03-25 12:04:35 -0600175struct pmux_pingrp_desc {
176 u8 funcs[4];
177#if defined(CONFIG_TEGRA20)
178 u8 ctl_id;
179 u8 pull_id;
180#endif /* CONFIG_TEGRA20 */
181};
182
183extern const struct pmux_pingrp_desc *tegra_soc_pingroups;
184
Stephen Warren22d57fe2015-02-24 14:08:24 -0700185#ifdef TEGRA_PMX_SOC_HAS_DRVGRPS
Stephen Warren9026dfd2014-03-21 12:28:54 -0600186
Stephen Warrenf4df6052014-03-21 12:28:56 -0600187#define PMUX_SLWF_MIN 0
188#define PMUX_SLWF_MAX 3
189#define PMUX_SLWF_NONE -1
Stephen Warren9026dfd2014-03-21 12:28:54 -0600190
Stephen Warrenf4df6052014-03-21 12:28:56 -0600191#define PMUX_SLWR_MIN 0
192#define PMUX_SLWR_MAX 3
193#define PMUX_SLWR_NONE -1
Stephen Warren9026dfd2014-03-21 12:28:54 -0600194
Stephen Warrenf4df6052014-03-21 12:28:56 -0600195#define PMUX_DRVUP_MIN 0
196#define PMUX_DRVUP_MAX 127
197#define PMUX_DRVUP_NONE -1
Stephen Warren9026dfd2014-03-21 12:28:54 -0600198
Stephen Warrenf4df6052014-03-21 12:28:56 -0600199#define PMUX_DRVDN_MIN 0
200#define PMUX_DRVDN_MAX 127
201#define PMUX_DRVDN_NONE -1
Stephen Warren9026dfd2014-03-21 12:28:54 -0600202
Stephen Warren9026dfd2014-03-21 12:28:54 -0600203/*
204 * This defines the configuration for a pin group's pad control config
205 */
Stephen Warrenf4df6052014-03-21 12:28:56 -0600206struct pmux_drvgrp_config {
Stephen Warren70b080f2014-03-21 15:58:03 -0600207 u32 drvgrp:16; /* pin group PMUX_DRVGRP_x */
208 u32 slwf:3; /* falling edge slew */
209 u32 slwr:3; /* rising edge slew */
210 u32 drvup:8; /* pull-up drive strength */
211 u32 drvdn:8; /* pull-down drive strength */
Stephen Warren3e9fb7b2015-02-24 14:08:25 -0700212#ifdef TEGRA_PMX_GRPS_HAVE_LPMD
Stephen Warren70b080f2014-03-21 15:58:03 -0600213 u32 lpmd:3; /* low-power mode selection */
Stephen Warren3e9fb7b2015-02-24 14:08:25 -0700214#endif
215#ifdef TEGRA_PMX_GRPS_HAVE_SCHMT
Stephen Warren70b080f2014-03-21 15:58:03 -0600216 u32 schmt:2; /* schmidt enable */
Stephen Warren3e9fb7b2015-02-24 14:08:25 -0700217#endif
218#ifdef TEGRA_PMX_GRPS_HAVE_HSM
Stephen Warren70b080f2014-03-21 15:58:03 -0600219 u32 hsm:2; /* high-speed mode enable */
Stephen Warren3e9fb7b2015-02-24 14:08:25 -0700220#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -0600221};
222
223/**
224 * Set the GP pad configs
225 *
226 * @param config List of config items
227 * @param len Number of config items in list
228 */
Stephen Warrenf4df6052014-03-21 12:28:56 -0600229void pinmux_config_drvgrp_table(const struct pmux_drvgrp_config *config,
230 int len);
Stephen Warren9026dfd2014-03-21 12:28:54 -0600231
Stephen Warren22d57fe2015-02-24 14:08:24 -0700232#endif /* TEGRA_PMX_SOC_HAS_DRVGRPS */
Stephen Warren9026dfd2014-03-21 12:28:54 -0600233
Stephen Warren8ec10882015-03-25 12:04:36 -0600234#ifdef TEGRA_PMX_SOC_HAS_MIPI_PAD_CTRL_GRPS
235struct pmux_mipipadctrlgrp_config {
236 u32 grp:16; /* pin group PMUX_MIPIPADCTRLGRP_x */
237 u32 func:8; /* function to assign PMUX_FUNC_... */
238};
239
240void pinmux_config_mipipadctrlgrp_table(
241 const struct pmux_mipipadctrlgrp_config *config, int len);
242
243struct pmux_mipipadctrlgrp_desc {
244 u8 funcs[2];
245};
246
247extern const struct pmux_mipipadctrlgrp_desc *tegra_soc_mipipadctrl_groups;
248#endif /* TEGRA_PMX_SOC_HAS_MIPI_PAD_CTRL_GRPS */
249
Stephen Warren9026dfd2014-03-21 12:28:54 -0600250#endif /* _TEGRA_PINMUX_H_ */