blob: 4b6e8419504a2848c37cef9ac4572a8075155f41 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Stephen Warren9026dfd2014-03-21 12:28:54 -06002/*
3 * (C) Copyright 2010-2014
4 * NVIDIA Corporation <www.nvidia.com>
Stephen Warren9026dfd2014-03-21 12:28:54 -06005 */
6
7#ifndef _TEGRA_PINMUX_H_
8#define _TEGRA_PINMUX_H_
9
Thierry Redingdebf2982015-03-20 13:24:22 +010010#include <linux/types.h>
11
Stephen Warren9026dfd2014-03-21 12:28:54 -060012#include <asm/arch/tegra.h>
13
14/* The pullup/pulldown state of a pin group */
15enum pmux_pull {
16 PMUX_PULL_NORMAL = 0,
17 PMUX_PULL_DOWN,
18 PMUX_PULL_UP,
19};
20
21/* Defines whether a pin group is tristated or in normal operation */
22enum pmux_tristate {
23 PMUX_TRI_NORMAL = 0,
24 PMUX_TRI_TRISTATE = 1,
25};
26
Stephen Warren22d57fe2015-02-24 14:08:24 -070027#ifdef TEGRA_PMX_PINS_HAVE_E_INPUT
Stephen Warren9026dfd2014-03-21 12:28:54 -060028enum pmux_pin_io {
29 PMUX_PIN_OUTPUT = 0,
30 PMUX_PIN_INPUT = 1,
31 PMUX_PIN_NONE,
32};
Stephen Warren22d57fe2015-02-24 14:08:24 -070033#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -060034
Stephen Warren22d57fe2015-02-24 14:08:24 -070035#ifdef TEGRA_PMX_PINS_HAVE_LOCK
Stephen Warren9026dfd2014-03-21 12:28:54 -060036enum pmux_pin_lock {
37 PMUX_PIN_LOCK_DEFAULT = 0,
38 PMUX_PIN_LOCK_DISABLE,
39 PMUX_PIN_LOCK_ENABLE,
40};
Stephen Warren22d57fe2015-02-24 14:08:24 -070041#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -060042
Stephen Warren22d57fe2015-02-24 14:08:24 -070043#ifdef TEGRA_PMX_PINS_HAVE_OD
Stephen Warren9026dfd2014-03-21 12:28:54 -060044enum pmux_pin_od {
45 PMUX_PIN_OD_DEFAULT = 0,
46 PMUX_PIN_OD_DISABLE,
47 PMUX_PIN_OD_ENABLE,
48};
Stephen Warren22d57fe2015-02-24 14:08:24 -070049#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -060050
Stephen Warren22d57fe2015-02-24 14:08:24 -070051#ifdef TEGRA_PMX_PINS_HAVE_IO_RESET
Stephen Warren9026dfd2014-03-21 12:28:54 -060052enum pmux_pin_ioreset {
53 PMUX_PIN_IO_RESET_DEFAULT = 0,
54 PMUX_PIN_IO_RESET_DISABLE,
55 PMUX_PIN_IO_RESET_ENABLE,
56};
Stephen Warren22d57fe2015-02-24 14:08:24 -070057#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -060058
Stephen Warren22d57fe2015-02-24 14:08:24 -070059#ifdef TEGRA_PMX_PINS_HAVE_RCV_SEL
Stephen Warren9026dfd2014-03-21 12:28:54 -060060enum pmux_pin_rcv_sel {
61 PMUX_PIN_RCV_SEL_DEFAULT = 0,
62 PMUX_PIN_RCV_SEL_NORMAL,
63 PMUX_PIN_RCV_SEL_HIGH,
64};
Stephen Warren22d57fe2015-02-24 14:08:24 -070065#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -060066
Stephen Warrend9f8def2015-02-24 14:08:30 -070067#ifdef TEGRA_PMX_PINS_HAVE_E_IO_HV
68enum pmux_pin_e_io_hv {
69 PMUX_PIN_E_IO_HV_DEFAULT = 0,
70 PMUX_PIN_E_IO_HV_NORMAL,
71 PMUX_PIN_E_IO_HV_HIGH,
72};
73#endif
74
Stephen Warren899a5cb2015-02-24 14:08:26 -070075#ifdef TEGRA_PMX_GRPS_HAVE_LPMD
76/* Defines a pin group cfg's low-power mode select */
77enum pmux_lpmd {
78 PMUX_LPMD_X8 = 0,
79 PMUX_LPMD_X4,
80 PMUX_LPMD_X2,
81 PMUX_LPMD_X,
82 PMUX_LPMD_NONE = -1,
83};
84#endif
85
Stephen Warren97f9c682015-02-24 14:08:28 -070086#if defined(TEGRA_PMX_PINS_HAVE_SCHMT) || defined(TEGRA_PMX_GRPS_HAVE_SCHMT)
Stephen Warren899a5cb2015-02-24 14:08:26 -070087/* Defines whether a pin group cfg's schmidt is enabled or not */
88enum pmux_schmt {
89 PMUX_SCHMT_DISABLE = 0,
90 PMUX_SCHMT_ENABLE = 1,
91 PMUX_SCHMT_NONE = -1,
92};
93#endif
94
Stephen Warren97f9c682015-02-24 14:08:28 -070095#if defined(TEGRA_PMX_PINS_HAVE_HSM) || defined(TEGRA_PMX_GRPS_HAVE_HSM)
Stephen Warren899a5cb2015-02-24 14:08:26 -070096/* Defines whether a pin group cfg's high-speed mode is enabled or not */
97enum pmux_hsm {
98 PMUX_HSM_DISABLE = 0,
99 PMUX_HSM_ENABLE = 1,
100 PMUX_HSM_NONE = -1,
101};
102#endif
103
Stephen Warren9026dfd2014-03-21 12:28:54 -0600104/*
105 * This defines the configuration for a pin, including the function assigned,
106 * pull up/down settings and tristate settings. Having set up one of these
107 * you can call pinmux_config_pingroup() to configure a pin in one step. Also
108 * available is pinmux_config_table() to configure a list of pins.
109 */
Stephen Warrenf4df6052014-03-21 12:28:56 -0600110struct pmux_pingrp_config {
Stephen Warren70b080f2014-03-21 15:58:03 -0600111 u32 pingrp:16; /* pin group PMUX_PINGRP_... */
112 u32 func:8; /* function to assign PMUX_FUNC_... */
113 u32 pull:2; /* pull up/down/normal PMUX_PULL_...*/
114 u32 tristate:2; /* tristate or normal PMUX_TRI_... */
Stephen Warren22d57fe2015-02-24 14:08:24 -0700115#ifdef TEGRA_PMX_PINS_HAVE_E_INPUT
Stephen Warren70b080f2014-03-21 15:58:03 -0600116 u32 io:2; /* input or output PMUX_PIN_... */
Stephen Warren22d57fe2015-02-24 14:08:24 -0700117#endif
118#ifdef TEGRA_PMX_PINS_HAVE_LOCK
Stephen Warren70b080f2014-03-21 15:58:03 -0600119 u32 lock:2; /* lock enable/disable PMUX_PIN... */
Stephen Warren22d57fe2015-02-24 14:08:24 -0700120#endif
121#ifdef TEGRA_PMX_PINS_HAVE_OD
Stephen Warren70b080f2014-03-21 15:58:03 -0600122 u32 od:2; /* open-drain or push-pull driver */
Stephen Warren22d57fe2015-02-24 14:08:24 -0700123#endif
124#ifdef TEGRA_PMX_PINS_HAVE_IO_RESET
Stephen Warren70b080f2014-03-21 15:58:03 -0600125 u32 ioreset:2; /* input/output reset PMUX_PIN... */
Stephen Warren22d57fe2015-02-24 14:08:24 -0700126#endif
127#ifdef TEGRA_PMX_PINS_HAVE_RCV_SEL
Stephen Warren70b080f2014-03-21 15:58:03 -0600128 u32 rcv_sel:2; /* select between High and Normal */
129 /* VIL/VIH receivers */
Stephen Warren9026dfd2014-03-21 12:28:54 -0600130#endif
Stephen Warrend9f8def2015-02-24 14:08:30 -0700131#ifdef TEGRA_PMX_PINS_HAVE_E_IO_HV
132 u32 e_io_hv:2; /* select 3.3v tolerant receivers */
133#endif
Stephen Warren97f9c682015-02-24 14:08:28 -0700134#ifdef TEGRA_PMX_PINS_HAVE_SCHMT
135 u32 schmt:2; /* schmitt enable */
136#endif
137#ifdef TEGRA_PMX_PINS_HAVE_HSM
138 u32 hsm:2; /* high-speed mode enable */
139#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -0600140};
141
Stephen Warren22d57fe2015-02-24 14:08:24 -0700142#ifdef TEGRA_PMX_SOC_HAS_IO_CLAMPING
Stephen Warrendb2937f2015-02-18 13:27:03 -0700143/* Set/clear the pinmux CLAMP_INPUTS_WHEN_TRISTATED bit */
Stephen Warrenf53f1082014-04-22 14:37:54 -0600144void pinmux_set_tristate_input_clamping(void);
Stephen Warrendb2937f2015-02-18 13:27:03 -0700145void pinmux_clear_tristate_input_clamping(void);
Stephen Warrenf53f1082014-04-22 14:37:54 -0600146#endif
147
Stephen Warren9026dfd2014-03-21 12:28:54 -0600148/* Set the mux function for a pin group */
149void pinmux_set_func(enum pmux_pingrp pin, enum pmux_func func);
150
151/* Set the pull up/down feature for a pin group */
152void pinmux_set_pullupdown(enum pmux_pingrp pin, enum pmux_pull pupd);
153
Stephen Warren9026dfd2014-03-21 12:28:54 -0600154/* Set a pin group to tristate */
155void pinmux_tristate_enable(enum pmux_pingrp pin);
156
157/* Set a pin group to normal (non tristate) */
158void pinmux_tristate_disable(enum pmux_pingrp pin);
159
Stephen Warren22d57fe2015-02-24 14:08:24 -0700160#ifdef TEGRA_PMX_PINS_HAVE_E_INPUT
Stephen Warren9026dfd2014-03-21 12:28:54 -0600161/* Set a pin group as input or output */
162void pinmux_set_io(enum pmux_pingrp pin, enum pmux_pin_io io);
163#endif
164
Stephen Warren9026dfd2014-03-21 12:28:54 -0600165/**
166 * Configure a list of pin groups
167 *
168 * @param config List of config items
169 * @param len Number of config items in list
170 */
Stephen Warrenf4df6052014-03-21 12:28:56 -0600171void pinmux_config_pingrp_table(const struct pmux_pingrp_config *config,
172 int len);
Stephen Warren9026dfd2014-03-21 12:28:54 -0600173
Stephen Warren1a1f10f2015-03-25 12:04:35 -0600174struct pmux_pingrp_desc {
175 u8 funcs[4];
176#if defined(CONFIG_TEGRA20)
177 u8 ctl_id;
178 u8 pull_id;
179#endif /* CONFIG_TEGRA20 */
180};
181
182extern const struct pmux_pingrp_desc *tegra_soc_pingroups;
183
Stephen Warren22d57fe2015-02-24 14:08:24 -0700184#ifdef TEGRA_PMX_SOC_HAS_DRVGRPS
Stephen Warren9026dfd2014-03-21 12:28:54 -0600185
Stephen Warrenf4df6052014-03-21 12:28:56 -0600186#define PMUX_SLWF_MIN 0
187#define PMUX_SLWF_MAX 3
188#define PMUX_SLWF_NONE -1
Stephen Warren9026dfd2014-03-21 12:28:54 -0600189
Stephen Warrenf4df6052014-03-21 12:28:56 -0600190#define PMUX_SLWR_MIN 0
191#define PMUX_SLWR_MAX 3
192#define PMUX_SLWR_NONE -1
Stephen Warren9026dfd2014-03-21 12:28:54 -0600193
Stephen Warrenf4df6052014-03-21 12:28:56 -0600194#define PMUX_DRVUP_MIN 0
195#define PMUX_DRVUP_MAX 127
196#define PMUX_DRVUP_NONE -1
Stephen Warren9026dfd2014-03-21 12:28:54 -0600197
Stephen Warrenf4df6052014-03-21 12:28:56 -0600198#define PMUX_DRVDN_MIN 0
199#define PMUX_DRVDN_MAX 127
200#define PMUX_DRVDN_NONE -1
Stephen Warren9026dfd2014-03-21 12:28:54 -0600201
Stephen Warren9026dfd2014-03-21 12:28:54 -0600202/*
203 * This defines the configuration for a pin group's pad control config
204 */
Stephen Warrenf4df6052014-03-21 12:28:56 -0600205struct pmux_drvgrp_config {
Stephen Warren70b080f2014-03-21 15:58:03 -0600206 u32 drvgrp:16; /* pin group PMUX_DRVGRP_x */
207 u32 slwf:3; /* falling edge slew */
208 u32 slwr:3; /* rising edge slew */
209 u32 drvup:8; /* pull-up drive strength */
210 u32 drvdn:8; /* pull-down drive strength */
Stephen Warren3e9fb7b2015-02-24 14:08:25 -0700211#ifdef TEGRA_PMX_GRPS_HAVE_LPMD
Stephen Warren70b080f2014-03-21 15:58:03 -0600212 u32 lpmd:3; /* low-power mode selection */
Stephen Warren3e9fb7b2015-02-24 14:08:25 -0700213#endif
214#ifdef TEGRA_PMX_GRPS_HAVE_SCHMT
Stephen Warren70b080f2014-03-21 15:58:03 -0600215 u32 schmt:2; /* schmidt enable */
Stephen Warren3e9fb7b2015-02-24 14:08:25 -0700216#endif
217#ifdef TEGRA_PMX_GRPS_HAVE_HSM
Stephen Warren70b080f2014-03-21 15:58:03 -0600218 u32 hsm:2; /* high-speed mode enable */
Stephen Warren3e9fb7b2015-02-24 14:08:25 -0700219#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -0600220};
221
222/**
223 * Set the GP pad configs
224 *
225 * @param config List of config items
226 * @param len Number of config items in list
227 */
Stephen Warrenf4df6052014-03-21 12:28:56 -0600228void pinmux_config_drvgrp_table(const struct pmux_drvgrp_config *config,
229 int len);
Stephen Warren9026dfd2014-03-21 12:28:54 -0600230
Stephen Warren22d57fe2015-02-24 14:08:24 -0700231#endif /* TEGRA_PMX_SOC_HAS_DRVGRPS */
Stephen Warren9026dfd2014-03-21 12:28:54 -0600232
Stephen Warren8ec10882015-03-25 12:04:36 -0600233#ifdef TEGRA_PMX_SOC_HAS_MIPI_PAD_CTRL_GRPS
234struct pmux_mipipadctrlgrp_config {
235 u32 grp:16; /* pin group PMUX_MIPIPADCTRLGRP_x */
236 u32 func:8; /* function to assign PMUX_FUNC_... */
237};
238
239void pinmux_config_mipipadctrlgrp_table(
240 const struct pmux_mipipadctrlgrp_config *config, int len);
241
242struct pmux_mipipadctrlgrp_desc {
243 u8 funcs[2];
244};
245
246extern const struct pmux_mipipadctrlgrp_desc *tegra_soc_mipipadctrl_groups;
247#endif /* TEGRA_PMX_SOC_HAS_MIPI_PAD_CTRL_GRPS */
248
Stephen Warren9026dfd2014-03-21 12:28:54 -0600249#endif /* _TEGRA_PINMUX_H_ */