Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2010-2014 |
| 4 | * NVIDIA Corporation <www.nvidia.com> |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef _TEGRA_PINMUX_H_ |
| 8 | #define _TEGRA_PINMUX_H_ |
| 9 | |
Thierry Reding | debf298 | 2015-03-20 13:24:22 +0100 | [diff] [blame] | 10 | #include <linux/types.h> |
| 11 | |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 12 | #include <asm/arch/tegra.h> |
| 13 | |
| 14 | /* The pullup/pulldown state of a pin group */ |
| 15 | enum 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 */ |
| 22 | enum pmux_tristate { |
| 23 | PMUX_TRI_NORMAL = 0, |
| 24 | PMUX_TRI_TRISTATE = 1, |
| 25 | }; |
| 26 | |
Stephen Warren | 22d57fe | 2015-02-24 14:08:24 -0700 | [diff] [blame] | 27 | #ifdef TEGRA_PMX_PINS_HAVE_E_INPUT |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 28 | enum pmux_pin_io { |
| 29 | PMUX_PIN_OUTPUT = 0, |
| 30 | PMUX_PIN_INPUT = 1, |
| 31 | PMUX_PIN_NONE, |
| 32 | }; |
Stephen Warren | 22d57fe | 2015-02-24 14:08:24 -0700 | [diff] [blame] | 33 | #endif |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 34 | |
Stephen Warren | 22d57fe | 2015-02-24 14:08:24 -0700 | [diff] [blame] | 35 | #ifdef TEGRA_PMX_PINS_HAVE_LOCK |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 36 | enum pmux_pin_lock { |
| 37 | PMUX_PIN_LOCK_DEFAULT = 0, |
| 38 | PMUX_PIN_LOCK_DISABLE, |
| 39 | PMUX_PIN_LOCK_ENABLE, |
| 40 | }; |
Stephen Warren | 22d57fe | 2015-02-24 14:08:24 -0700 | [diff] [blame] | 41 | #endif |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 42 | |
Stephen Warren | 22d57fe | 2015-02-24 14:08:24 -0700 | [diff] [blame] | 43 | #ifdef TEGRA_PMX_PINS_HAVE_OD |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 44 | enum pmux_pin_od { |
| 45 | PMUX_PIN_OD_DEFAULT = 0, |
| 46 | PMUX_PIN_OD_DISABLE, |
| 47 | PMUX_PIN_OD_ENABLE, |
| 48 | }; |
Stephen Warren | 22d57fe | 2015-02-24 14:08:24 -0700 | [diff] [blame] | 49 | #endif |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 50 | |
Stephen Warren | 22d57fe | 2015-02-24 14:08:24 -0700 | [diff] [blame] | 51 | #ifdef TEGRA_PMX_PINS_HAVE_IO_RESET |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 52 | enum pmux_pin_ioreset { |
| 53 | PMUX_PIN_IO_RESET_DEFAULT = 0, |
| 54 | PMUX_PIN_IO_RESET_DISABLE, |
| 55 | PMUX_PIN_IO_RESET_ENABLE, |
| 56 | }; |
Stephen Warren | 22d57fe | 2015-02-24 14:08:24 -0700 | [diff] [blame] | 57 | #endif |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 58 | |
Stephen Warren | 22d57fe | 2015-02-24 14:08:24 -0700 | [diff] [blame] | 59 | #ifdef TEGRA_PMX_PINS_HAVE_RCV_SEL |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 60 | enum 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 Warren | 22d57fe | 2015-02-24 14:08:24 -0700 | [diff] [blame] | 65 | #endif |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 66 | |
Stephen Warren | d9f8def | 2015-02-24 14:08:30 -0700 | [diff] [blame] | 67 | #ifdef TEGRA_PMX_PINS_HAVE_E_IO_HV |
| 68 | enum 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 Warren | 899a5cb | 2015-02-24 14:08:26 -0700 | [diff] [blame] | 75 | #ifdef TEGRA_PMX_GRPS_HAVE_LPMD |
| 76 | /* Defines a pin group cfg's low-power mode select */ |
| 77 | enum 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 Warren | 97f9c68 | 2015-02-24 14:08:28 -0700 | [diff] [blame] | 86 | #if defined(TEGRA_PMX_PINS_HAVE_SCHMT) || defined(TEGRA_PMX_GRPS_HAVE_SCHMT) |
Stephen Warren | 899a5cb | 2015-02-24 14:08:26 -0700 | [diff] [blame] | 87 | /* Defines whether a pin group cfg's schmidt is enabled or not */ |
| 88 | enum pmux_schmt { |
| 89 | PMUX_SCHMT_DISABLE = 0, |
| 90 | PMUX_SCHMT_ENABLE = 1, |
| 91 | PMUX_SCHMT_NONE = -1, |
| 92 | }; |
| 93 | #endif |
| 94 | |
Stephen Warren | 97f9c68 | 2015-02-24 14:08:28 -0700 | [diff] [blame] | 95 | #if defined(TEGRA_PMX_PINS_HAVE_HSM) || defined(TEGRA_PMX_GRPS_HAVE_HSM) |
Stephen Warren | 899a5cb | 2015-02-24 14:08:26 -0700 | [diff] [blame] | 96 | /* Defines whether a pin group cfg's high-speed mode is enabled or not */ |
| 97 | enum pmux_hsm { |
| 98 | PMUX_HSM_DISABLE = 0, |
| 99 | PMUX_HSM_ENABLE = 1, |
| 100 | PMUX_HSM_NONE = -1, |
| 101 | }; |
| 102 | #endif |
| 103 | |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 104 | /* |
| 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 Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 110 | struct pmux_pingrp_config { |
Stephen Warren | 70b080f | 2014-03-21 15:58:03 -0600 | [diff] [blame] | 111 | 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 Warren | 22d57fe | 2015-02-24 14:08:24 -0700 | [diff] [blame] | 115 | #ifdef TEGRA_PMX_PINS_HAVE_E_INPUT |
Stephen Warren | 70b080f | 2014-03-21 15:58:03 -0600 | [diff] [blame] | 116 | u32 io:2; /* input or output PMUX_PIN_... */ |
Stephen Warren | 22d57fe | 2015-02-24 14:08:24 -0700 | [diff] [blame] | 117 | #endif |
| 118 | #ifdef TEGRA_PMX_PINS_HAVE_LOCK |
Stephen Warren | 70b080f | 2014-03-21 15:58:03 -0600 | [diff] [blame] | 119 | u32 lock:2; /* lock enable/disable PMUX_PIN... */ |
Stephen Warren | 22d57fe | 2015-02-24 14:08:24 -0700 | [diff] [blame] | 120 | #endif |
| 121 | #ifdef TEGRA_PMX_PINS_HAVE_OD |
Stephen Warren | 70b080f | 2014-03-21 15:58:03 -0600 | [diff] [blame] | 122 | u32 od:2; /* open-drain or push-pull driver */ |
Stephen Warren | 22d57fe | 2015-02-24 14:08:24 -0700 | [diff] [blame] | 123 | #endif |
| 124 | #ifdef TEGRA_PMX_PINS_HAVE_IO_RESET |
Stephen Warren | 70b080f | 2014-03-21 15:58:03 -0600 | [diff] [blame] | 125 | u32 ioreset:2; /* input/output reset PMUX_PIN... */ |
Stephen Warren | 22d57fe | 2015-02-24 14:08:24 -0700 | [diff] [blame] | 126 | #endif |
| 127 | #ifdef TEGRA_PMX_PINS_HAVE_RCV_SEL |
Stephen Warren | 70b080f | 2014-03-21 15:58:03 -0600 | [diff] [blame] | 128 | u32 rcv_sel:2; /* select between High and Normal */ |
| 129 | /* VIL/VIH receivers */ |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 130 | #endif |
Stephen Warren | d9f8def | 2015-02-24 14:08:30 -0700 | [diff] [blame] | 131 | #ifdef TEGRA_PMX_PINS_HAVE_E_IO_HV |
| 132 | u32 e_io_hv:2; /* select 3.3v tolerant receivers */ |
| 133 | #endif |
Stephen Warren | 97f9c68 | 2015-02-24 14:08:28 -0700 | [diff] [blame] | 134 | #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 Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 140 | }; |
| 141 | |
Stephen Warren | 22d57fe | 2015-02-24 14:08:24 -0700 | [diff] [blame] | 142 | #ifdef TEGRA_PMX_SOC_HAS_IO_CLAMPING |
Stephen Warren | db2937f | 2015-02-18 13:27:03 -0700 | [diff] [blame] | 143 | /* Set/clear the pinmux CLAMP_INPUTS_WHEN_TRISTATED bit */ |
Stephen Warren | f53f108 | 2014-04-22 14:37:54 -0600 | [diff] [blame] | 144 | void pinmux_set_tristate_input_clamping(void); |
Stephen Warren | db2937f | 2015-02-18 13:27:03 -0700 | [diff] [blame] | 145 | void pinmux_clear_tristate_input_clamping(void); |
Stephen Warren | f53f108 | 2014-04-22 14:37:54 -0600 | [diff] [blame] | 146 | #endif |
| 147 | |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 148 | /* Set the mux function for a pin group */ |
| 149 | void pinmux_set_func(enum pmux_pingrp pin, enum pmux_func func); |
| 150 | |
| 151 | /* Set the pull up/down feature for a pin group */ |
| 152 | void pinmux_set_pullupdown(enum pmux_pingrp pin, enum pmux_pull pupd); |
| 153 | |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 154 | /* Set a pin group to tristate */ |
| 155 | void pinmux_tristate_enable(enum pmux_pingrp pin); |
| 156 | |
| 157 | /* Set a pin group to normal (non tristate) */ |
| 158 | void pinmux_tristate_disable(enum pmux_pingrp pin); |
| 159 | |
Stephen Warren | 22d57fe | 2015-02-24 14:08:24 -0700 | [diff] [blame] | 160 | #ifdef TEGRA_PMX_PINS_HAVE_E_INPUT |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 161 | /* Set a pin group as input or output */ |
| 162 | void pinmux_set_io(enum pmux_pingrp pin, enum pmux_pin_io io); |
| 163 | #endif |
| 164 | |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 165 | /** |
| 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 Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 171 | void pinmux_config_pingrp_table(const struct pmux_pingrp_config *config, |
| 172 | int len); |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 173 | |
Stephen Warren | 1a1f10f | 2015-03-25 12:04:35 -0600 | [diff] [blame] | 174 | struct 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 | |
| 182 | extern const struct pmux_pingrp_desc *tegra_soc_pingroups; |
| 183 | |
Stephen Warren | 22d57fe | 2015-02-24 14:08:24 -0700 | [diff] [blame] | 184 | #ifdef TEGRA_PMX_SOC_HAS_DRVGRPS |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 185 | |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 186 | #define PMUX_SLWF_MIN 0 |
| 187 | #define PMUX_SLWF_MAX 3 |
| 188 | #define PMUX_SLWF_NONE -1 |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 189 | |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 190 | #define PMUX_SLWR_MIN 0 |
| 191 | #define PMUX_SLWR_MAX 3 |
| 192 | #define PMUX_SLWR_NONE -1 |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 193 | |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 194 | #define PMUX_DRVUP_MIN 0 |
| 195 | #define PMUX_DRVUP_MAX 127 |
| 196 | #define PMUX_DRVUP_NONE -1 |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 197 | |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 198 | #define PMUX_DRVDN_MIN 0 |
| 199 | #define PMUX_DRVDN_MAX 127 |
| 200 | #define PMUX_DRVDN_NONE -1 |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 201 | |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 202 | /* |
| 203 | * This defines the configuration for a pin group's pad control config |
| 204 | */ |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 205 | struct pmux_drvgrp_config { |
Stephen Warren | 70b080f | 2014-03-21 15:58:03 -0600 | [diff] [blame] | 206 | 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 Warren | 3e9fb7b | 2015-02-24 14:08:25 -0700 | [diff] [blame] | 211 | #ifdef TEGRA_PMX_GRPS_HAVE_LPMD |
Stephen Warren | 70b080f | 2014-03-21 15:58:03 -0600 | [diff] [blame] | 212 | u32 lpmd:3; /* low-power mode selection */ |
Stephen Warren | 3e9fb7b | 2015-02-24 14:08:25 -0700 | [diff] [blame] | 213 | #endif |
| 214 | #ifdef TEGRA_PMX_GRPS_HAVE_SCHMT |
Stephen Warren | 70b080f | 2014-03-21 15:58:03 -0600 | [diff] [blame] | 215 | u32 schmt:2; /* schmidt enable */ |
Stephen Warren | 3e9fb7b | 2015-02-24 14:08:25 -0700 | [diff] [blame] | 216 | #endif |
| 217 | #ifdef TEGRA_PMX_GRPS_HAVE_HSM |
Stephen Warren | 70b080f | 2014-03-21 15:58:03 -0600 | [diff] [blame] | 218 | u32 hsm:2; /* high-speed mode enable */ |
Stephen Warren | 3e9fb7b | 2015-02-24 14:08:25 -0700 | [diff] [blame] | 219 | #endif |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 220 | }; |
| 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 Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 228 | void pinmux_config_drvgrp_table(const struct pmux_drvgrp_config *config, |
| 229 | int len); |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 230 | |
Stephen Warren | 22d57fe | 2015-02-24 14:08:24 -0700 | [diff] [blame] | 231 | #endif /* TEGRA_PMX_SOC_HAS_DRVGRPS */ |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 232 | |
Stephen Warren | 8ec1088 | 2015-03-25 12:04:36 -0600 | [diff] [blame] | 233 | #ifdef TEGRA_PMX_SOC_HAS_MIPI_PAD_CTRL_GRPS |
| 234 | struct pmux_mipipadctrlgrp_config { |
| 235 | u32 grp:16; /* pin group PMUX_MIPIPADCTRLGRP_x */ |
| 236 | u32 func:8; /* function to assign PMUX_FUNC_... */ |
| 237 | }; |
| 238 | |
| 239 | void pinmux_config_mipipadctrlgrp_table( |
| 240 | const struct pmux_mipipadctrlgrp_config *config, int len); |
| 241 | |
| 242 | struct pmux_mipipadctrlgrp_desc { |
| 243 | u8 funcs[2]; |
| 244 | }; |
| 245 | |
| 246 | extern const struct pmux_mipipadctrlgrp_desc *tegra_soc_mipipadctrl_groups; |
| 247 | #endif /* TEGRA_PMX_SOC_HAS_MIPI_PAD_CTRL_GRPS */ |
| 248 | |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 249 | #endif /* _TEGRA_PINMUX_H_ */ |