blob: cb61aa1fa185af15dadc43984670d08b64e927f1 [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
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 Warren22d57fe2015-02-24 14:08:24 -070026#ifdef TEGRA_PMX_PINS_HAVE_E_INPUT
Stephen Warren9026dfd2014-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 Warren22d57fe2015-02-24 14:08:24 -070032#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -060033
Stephen Warren22d57fe2015-02-24 14:08:24 -070034#ifdef TEGRA_PMX_PINS_HAVE_LOCK
Stephen Warren9026dfd2014-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 Warren22d57fe2015-02-24 14:08:24 -070040#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -060041
Stephen Warren22d57fe2015-02-24 14:08:24 -070042#ifdef TEGRA_PMX_PINS_HAVE_OD
Stephen Warren9026dfd2014-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 Warren22d57fe2015-02-24 14:08:24 -070048#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -060049
Stephen Warren22d57fe2015-02-24 14:08:24 -070050#ifdef TEGRA_PMX_PINS_HAVE_IO_RESET
Stephen Warren9026dfd2014-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 Warren22d57fe2015-02-24 14:08:24 -070056#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -060057
Stephen Warren22d57fe2015-02-24 14:08:24 -070058#ifdef TEGRA_PMX_PINS_HAVE_RCV_SEL
Stephen Warren9026dfd2014-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 Warren22d57fe2015-02-24 14:08:24 -070064#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -060065
66/*
67 * This defines the configuration for a pin, including the function assigned,
68 * pull up/down settings and tristate settings. Having set up one of these
69 * you can call pinmux_config_pingroup() to configure a pin in one step. Also
70 * available is pinmux_config_table() to configure a list of pins.
71 */
Stephen Warrenf4df6052014-03-21 12:28:56 -060072struct pmux_pingrp_config {
Stephen Warren70b080f2014-03-21 15:58:03 -060073 u32 pingrp:16; /* pin group PMUX_PINGRP_... */
74 u32 func:8; /* function to assign PMUX_FUNC_... */
75 u32 pull:2; /* pull up/down/normal PMUX_PULL_...*/
76 u32 tristate:2; /* tristate or normal PMUX_TRI_... */
Stephen Warren22d57fe2015-02-24 14:08:24 -070077#ifdef TEGRA_PMX_PINS_HAVE_E_INPUT
Stephen Warren70b080f2014-03-21 15:58:03 -060078 u32 io:2; /* input or output PMUX_PIN_... */
Stephen Warren22d57fe2015-02-24 14:08:24 -070079#endif
80#ifdef TEGRA_PMX_PINS_HAVE_LOCK
Stephen Warren70b080f2014-03-21 15:58:03 -060081 u32 lock:2; /* lock enable/disable PMUX_PIN... */
Stephen Warren22d57fe2015-02-24 14:08:24 -070082#endif
83#ifdef TEGRA_PMX_PINS_HAVE_OD
Stephen Warren70b080f2014-03-21 15:58:03 -060084 u32 od:2; /* open-drain or push-pull driver */
Stephen Warren22d57fe2015-02-24 14:08:24 -070085#endif
86#ifdef TEGRA_PMX_PINS_HAVE_IO_RESET
Stephen Warren70b080f2014-03-21 15:58:03 -060087 u32 ioreset:2; /* input/output reset PMUX_PIN... */
Stephen Warren22d57fe2015-02-24 14:08:24 -070088#endif
89#ifdef TEGRA_PMX_PINS_HAVE_RCV_SEL
Stephen Warren70b080f2014-03-21 15:58:03 -060090 u32 rcv_sel:2; /* select between High and Normal */
91 /* VIL/VIH receivers */
Stephen Warren9026dfd2014-03-21 12:28:54 -060092#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -060093};
94
Stephen Warren22d57fe2015-02-24 14:08:24 -070095#ifdef TEGRA_PMX_SOC_HAS_IO_CLAMPING
Stephen Warrendb2937f2015-02-18 13:27:03 -070096/* Set/clear the pinmux CLAMP_INPUTS_WHEN_TRISTATED bit */
Stephen Warrenf53f1082014-04-22 14:37:54 -060097void pinmux_set_tristate_input_clamping(void);
Stephen Warrendb2937f2015-02-18 13:27:03 -070098void pinmux_clear_tristate_input_clamping(void);
Stephen Warrenf53f1082014-04-22 14:37:54 -060099#endif
100
Stephen Warren9026dfd2014-03-21 12:28:54 -0600101/* Set the mux function for a pin group */
102void pinmux_set_func(enum pmux_pingrp pin, enum pmux_func func);
103
104/* Set the pull up/down feature for a pin group */
105void pinmux_set_pullupdown(enum pmux_pingrp pin, enum pmux_pull pupd);
106
Stephen Warren9026dfd2014-03-21 12:28:54 -0600107/* Set a pin group to tristate */
108void pinmux_tristate_enable(enum pmux_pingrp pin);
109
110/* Set a pin group to normal (non tristate) */
111void pinmux_tristate_disable(enum pmux_pingrp pin);
112
Stephen Warren22d57fe2015-02-24 14:08:24 -0700113#ifdef TEGRA_PMX_PINS_HAVE_E_INPUT
Stephen Warren9026dfd2014-03-21 12:28:54 -0600114/* Set a pin group as input or output */
115void pinmux_set_io(enum pmux_pingrp pin, enum pmux_pin_io io);
116#endif
117
Stephen Warren9026dfd2014-03-21 12:28:54 -0600118/**
119 * Configure a list of pin groups
120 *
121 * @param config List of config items
122 * @param len Number of config items in list
123 */
Stephen Warrenf4df6052014-03-21 12:28:56 -0600124void pinmux_config_pingrp_table(const struct pmux_pingrp_config *config,
125 int len);
Stephen Warren9026dfd2014-03-21 12:28:54 -0600126
Stephen Warren22d57fe2015-02-24 14:08:24 -0700127#ifdef TEGRA_PMX_SOC_HAS_DRVGRPS
Stephen Warren9026dfd2014-03-21 12:28:54 -0600128
Stephen Warrenf4df6052014-03-21 12:28:56 -0600129#define PMUX_SLWF_MIN 0
130#define PMUX_SLWF_MAX 3
131#define PMUX_SLWF_NONE -1
Stephen Warren9026dfd2014-03-21 12:28:54 -0600132
Stephen Warrenf4df6052014-03-21 12:28:56 -0600133#define PMUX_SLWR_MIN 0
134#define PMUX_SLWR_MAX 3
135#define PMUX_SLWR_NONE -1
Stephen Warren9026dfd2014-03-21 12:28:54 -0600136
Stephen Warrenf4df6052014-03-21 12:28:56 -0600137#define PMUX_DRVUP_MIN 0
138#define PMUX_DRVUP_MAX 127
139#define PMUX_DRVUP_NONE -1
Stephen Warren9026dfd2014-03-21 12:28:54 -0600140
Stephen Warrenf4df6052014-03-21 12:28:56 -0600141#define PMUX_DRVDN_MIN 0
142#define PMUX_DRVDN_MAX 127
143#define PMUX_DRVDN_NONE -1
Stephen Warren9026dfd2014-03-21 12:28:54 -0600144
Stephen Warren3e9fb7b2015-02-24 14:08:25 -0700145#ifdef TEGRA_PMX_GRPS_HAVE_LPMD
Stephen Warren9026dfd2014-03-21 12:28:54 -0600146/* Defines a pin group cfg's low-power mode select */
Stephen Warrenf4df6052014-03-21 12:28:56 -0600147enum pmux_lpmd {
148 PMUX_LPMD_X8 = 0,
149 PMUX_LPMD_X4,
150 PMUX_LPMD_X2,
151 PMUX_LPMD_X,
152 PMUX_LPMD_NONE = -1,
Stephen Warren9026dfd2014-03-21 12:28:54 -0600153};
Stephen Warren3e9fb7b2015-02-24 14:08:25 -0700154#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -0600155
Stephen Warren3e9fb7b2015-02-24 14:08:25 -0700156#ifdef TEGRA_PMX_GRPS_HAVE_SCHMT
Stephen Warren9026dfd2014-03-21 12:28:54 -0600157/* Defines whether a pin group cfg's schmidt is enabled or not */
Stephen Warrenf4df6052014-03-21 12:28:56 -0600158enum pmux_schmt {
159 PMUX_SCHMT_DISABLE = 0,
160 PMUX_SCHMT_ENABLE = 1,
161 PMUX_SCHMT_NONE = -1,
Stephen Warren9026dfd2014-03-21 12:28:54 -0600162};
Stephen Warren3e9fb7b2015-02-24 14:08:25 -0700163#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -0600164
Stephen Warren3e9fb7b2015-02-24 14:08:25 -0700165#ifdef TEGRA_PMX_GRPS_HAVE_HSM
Stephen Warren9026dfd2014-03-21 12:28:54 -0600166/* Defines whether a pin group cfg's high-speed mode is enabled or not */
Stephen Warrenf4df6052014-03-21 12:28:56 -0600167enum pmux_hsm {
168 PMUX_HSM_DISABLE = 0,
169 PMUX_HSM_ENABLE = 1,
170 PMUX_HSM_NONE = -1,
Stephen Warren9026dfd2014-03-21 12:28:54 -0600171};
Stephen Warren3e9fb7b2015-02-24 14:08:25 -0700172#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -0600173
174/*
175 * This defines the configuration for a pin group's pad control config
176 */
Stephen Warrenf4df6052014-03-21 12:28:56 -0600177struct pmux_drvgrp_config {
Stephen Warren70b080f2014-03-21 15:58:03 -0600178 u32 drvgrp:16; /* pin group PMUX_DRVGRP_x */
179 u32 slwf:3; /* falling edge slew */
180 u32 slwr:3; /* rising edge slew */
181 u32 drvup:8; /* pull-up drive strength */
182 u32 drvdn:8; /* pull-down drive strength */
Stephen Warren3e9fb7b2015-02-24 14:08:25 -0700183#ifdef TEGRA_PMX_GRPS_HAVE_LPMD
Stephen Warren70b080f2014-03-21 15:58:03 -0600184 u32 lpmd:3; /* low-power mode selection */
Stephen Warren3e9fb7b2015-02-24 14:08:25 -0700185#endif
186#ifdef TEGRA_PMX_GRPS_HAVE_SCHMT
Stephen Warren70b080f2014-03-21 15:58:03 -0600187 u32 schmt:2; /* schmidt enable */
Stephen Warren3e9fb7b2015-02-24 14:08:25 -0700188#endif
189#ifdef TEGRA_PMX_GRPS_HAVE_HSM
Stephen Warren70b080f2014-03-21 15:58:03 -0600190 u32 hsm:2; /* high-speed mode enable */
Stephen Warren3e9fb7b2015-02-24 14:08:25 -0700191#endif
Stephen Warren9026dfd2014-03-21 12:28:54 -0600192};
193
194/**
195 * Set the GP pad configs
196 *
197 * @param config List of config items
198 * @param len Number of config items in list
199 */
Stephen Warrenf4df6052014-03-21 12:28:56 -0600200void pinmux_config_drvgrp_table(const struct pmux_drvgrp_config *config,
201 int len);
Stephen Warren9026dfd2014-03-21 12:28:54 -0600202
Stephen Warren22d57fe2015-02-24 14:08:24 -0700203#endif /* TEGRA_PMX_SOC_HAS_DRVGRPS */
Stephen Warren9026dfd2014-03-21 12:28:54 -0600204
Stephen Warrenf4df6052014-03-21 12:28:56 -0600205struct pmux_pingrp_desc {
Stephen Warren70b080f2014-03-21 15:58:03 -0600206 u8 funcs[4];
Stephen Warren9026dfd2014-03-21 12:28:54 -0600207#if defined(CONFIG_TEGRA20)
Stephen Warren70b080f2014-03-21 15:58:03 -0600208 u8 ctl_id;
209 u8 pull_id;
Stephen Warren9026dfd2014-03-21 12:28:54 -0600210#endif /* CONFIG_TEGRA20 */
211};
212
Stephen Warrenf4df6052014-03-21 12:28:56 -0600213extern const struct pmux_pingrp_desc *tegra_soc_pingroups;
Stephen Warren9026dfd2014-03-21 12:28:54 -0600214
215#endif /* _TEGRA_PINMUX_H_ */