Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 1 | /* |
| 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 */ |
| 14 | enum 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 */ |
| 21 | enum pmux_tristate { |
| 22 | PMUX_TRI_NORMAL = 0, |
| 23 | PMUX_TRI_TRISTATE = 1, |
| 24 | }; |
| 25 | |
| 26 | #ifdef TEGRA_PMX_HAS_PIN_IO_BIT_ETC |
| 27 | enum pmux_pin_io { |
| 28 | PMUX_PIN_OUTPUT = 0, |
| 29 | PMUX_PIN_INPUT = 1, |
| 30 | PMUX_PIN_NONE, |
| 31 | }; |
| 32 | |
| 33 | enum pmux_pin_lock { |
| 34 | PMUX_PIN_LOCK_DEFAULT = 0, |
| 35 | PMUX_PIN_LOCK_DISABLE, |
| 36 | PMUX_PIN_LOCK_ENABLE, |
| 37 | }; |
| 38 | |
| 39 | enum pmux_pin_od { |
| 40 | PMUX_PIN_OD_DEFAULT = 0, |
| 41 | PMUX_PIN_OD_DISABLE, |
| 42 | PMUX_PIN_OD_ENABLE, |
| 43 | }; |
| 44 | |
| 45 | enum pmux_pin_ioreset { |
| 46 | PMUX_PIN_IO_RESET_DEFAULT = 0, |
| 47 | PMUX_PIN_IO_RESET_DISABLE, |
| 48 | PMUX_PIN_IO_RESET_ENABLE, |
| 49 | }; |
| 50 | |
| 51 | #ifdef TEGRA_PMX_HAS_RCV_SEL |
| 52 | enum pmux_pin_rcv_sel { |
| 53 | PMUX_PIN_RCV_SEL_DEFAULT = 0, |
| 54 | PMUX_PIN_RCV_SEL_NORMAL, |
| 55 | PMUX_PIN_RCV_SEL_HIGH, |
| 56 | }; |
| 57 | #endif /* TEGRA_PMX_HAS_RCV_SEL */ |
| 58 | #endif /* TEGRA_PMX_HAS_PIN_IO_BIT_ETC */ |
| 59 | |
| 60 | /* |
| 61 | * This defines the configuration for a pin, including the function assigned, |
| 62 | * pull up/down settings and tristate settings. Having set up one of these |
| 63 | * you can call pinmux_config_pingroup() to configure a pin in one step. Also |
| 64 | * available is pinmux_config_table() to configure a list of pins. |
| 65 | */ |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 66 | struct pmux_pingrp_config { |
Stephen Warren | 70b080f | 2014-03-21 15:58:03 -0600 | [diff] [blame] | 67 | u32 pingrp:16; /* pin group PMUX_PINGRP_... */ |
| 68 | u32 func:8; /* function to assign PMUX_FUNC_... */ |
| 69 | u32 pull:2; /* pull up/down/normal PMUX_PULL_...*/ |
| 70 | u32 tristate:2; /* tristate or normal PMUX_TRI_... */ |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 71 | #ifdef TEGRA_PMX_HAS_PIN_IO_BIT_ETC |
Stephen Warren | 70b080f | 2014-03-21 15:58:03 -0600 | [diff] [blame] | 72 | u32 io:2; /* input or output PMUX_PIN_... */ |
| 73 | u32 lock:2; /* lock enable/disable PMUX_PIN... */ |
| 74 | u32 od:2; /* open-drain or push-pull driver */ |
| 75 | u32 ioreset:2; /* input/output reset PMUX_PIN... */ |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 76 | #ifdef TEGRA_PMX_HAS_RCV_SEL |
Stephen Warren | 70b080f | 2014-03-21 15:58:03 -0600 | [diff] [blame] | 77 | u32 rcv_sel:2; /* select between High and Normal */ |
| 78 | /* VIL/VIH receivers */ |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 79 | #endif |
| 80 | #endif |
| 81 | }; |
| 82 | |
Stephen Warren | f53f108 | 2014-04-22 14:37:54 -0600 | [diff] [blame] | 83 | #if !defined(CONFIG_TEGRA20) && !defined(CONFIG_TEGRA30) |
Stephen Warren | db2937f | 2015-02-18 13:27:03 -0700 | [diff] [blame] | 84 | /* Set/clear the pinmux CLAMP_INPUTS_WHEN_TRISTATED bit */ |
Stephen Warren | f53f108 | 2014-04-22 14:37:54 -0600 | [diff] [blame] | 85 | void pinmux_set_tristate_input_clamping(void); |
Stephen Warren | db2937f | 2015-02-18 13:27:03 -0700 | [diff] [blame] | 86 | void pinmux_clear_tristate_input_clamping(void); |
Stephen Warren | f53f108 | 2014-04-22 14:37:54 -0600 | [diff] [blame] | 87 | #endif |
| 88 | |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 89 | /* Set the mux function for a pin group */ |
| 90 | void pinmux_set_func(enum pmux_pingrp pin, enum pmux_func func); |
| 91 | |
| 92 | /* Set the pull up/down feature for a pin group */ |
| 93 | void pinmux_set_pullupdown(enum pmux_pingrp pin, enum pmux_pull pupd); |
| 94 | |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 95 | /* Set a pin group to tristate */ |
| 96 | void pinmux_tristate_enable(enum pmux_pingrp pin); |
| 97 | |
| 98 | /* Set a pin group to normal (non tristate) */ |
| 99 | void pinmux_tristate_disable(enum pmux_pingrp pin); |
| 100 | |
| 101 | #ifdef TEGRA_PMX_HAS_PIN_IO_BIT_ETC |
| 102 | /* Set a pin group as input or output */ |
| 103 | void pinmux_set_io(enum pmux_pingrp pin, enum pmux_pin_io io); |
| 104 | #endif |
| 105 | |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 106 | /** |
| 107 | * Configure a list of pin groups |
| 108 | * |
| 109 | * @param config List of config items |
| 110 | * @param len Number of config items in list |
| 111 | */ |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 112 | void pinmux_config_pingrp_table(const struct pmux_pingrp_config *config, |
| 113 | int len); |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 114 | |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 115 | #ifdef TEGRA_PMX_HAS_DRVGRPS |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 116 | |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 117 | #define PMUX_SLWF_MIN 0 |
| 118 | #define PMUX_SLWF_MAX 3 |
| 119 | #define PMUX_SLWF_NONE -1 |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 120 | |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 121 | #define PMUX_SLWR_MIN 0 |
| 122 | #define PMUX_SLWR_MAX 3 |
| 123 | #define PMUX_SLWR_NONE -1 |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 124 | |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 125 | #define PMUX_DRVUP_MIN 0 |
| 126 | #define PMUX_DRVUP_MAX 127 |
| 127 | #define PMUX_DRVUP_NONE -1 |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 128 | |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 129 | #define PMUX_DRVDN_MIN 0 |
| 130 | #define PMUX_DRVDN_MAX 127 |
| 131 | #define PMUX_DRVDN_NONE -1 |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 132 | |
| 133 | /* Defines a pin group cfg's low-power mode select */ |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 134 | enum pmux_lpmd { |
| 135 | PMUX_LPMD_X8 = 0, |
| 136 | PMUX_LPMD_X4, |
| 137 | PMUX_LPMD_X2, |
| 138 | PMUX_LPMD_X, |
| 139 | PMUX_LPMD_NONE = -1, |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 140 | }; |
| 141 | |
| 142 | /* Defines whether a pin group cfg's schmidt is enabled or not */ |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 143 | enum pmux_schmt { |
| 144 | PMUX_SCHMT_DISABLE = 0, |
| 145 | PMUX_SCHMT_ENABLE = 1, |
| 146 | PMUX_SCHMT_NONE = -1, |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 147 | }; |
| 148 | |
| 149 | /* Defines whether a pin group cfg's high-speed mode is enabled or not */ |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 150 | enum pmux_hsm { |
| 151 | PMUX_HSM_DISABLE = 0, |
| 152 | PMUX_HSM_ENABLE = 1, |
| 153 | PMUX_HSM_NONE = -1, |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 154 | }; |
| 155 | |
| 156 | /* |
| 157 | * This defines the configuration for a pin group's pad control config |
| 158 | */ |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 159 | struct pmux_drvgrp_config { |
Stephen Warren | 70b080f | 2014-03-21 15:58:03 -0600 | [diff] [blame] | 160 | u32 drvgrp:16; /* pin group PMUX_DRVGRP_x */ |
| 161 | u32 slwf:3; /* falling edge slew */ |
| 162 | u32 slwr:3; /* rising edge slew */ |
| 163 | u32 drvup:8; /* pull-up drive strength */ |
| 164 | u32 drvdn:8; /* pull-down drive strength */ |
| 165 | u32 lpmd:3; /* low-power mode selection */ |
| 166 | u32 schmt:2; /* schmidt enable */ |
| 167 | u32 hsm:2; /* high-speed mode enable */ |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 168 | }; |
| 169 | |
| 170 | /** |
| 171 | * Set the GP pad configs |
| 172 | * |
| 173 | * @param config List of config items |
| 174 | * @param len Number of config items in list |
| 175 | */ |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 176 | void pinmux_config_drvgrp_table(const struct pmux_drvgrp_config *config, |
| 177 | int len); |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 178 | |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 179 | #endif /* TEGRA_PMX_HAS_DRVGRPS */ |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 180 | |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 181 | struct pmux_pingrp_desc { |
Stephen Warren | 70b080f | 2014-03-21 15:58:03 -0600 | [diff] [blame] | 182 | u8 funcs[4]; |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 183 | #if defined(CONFIG_TEGRA20) |
Stephen Warren | 70b080f | 2014-03-21 15:58:03 -0600 | [diff] [blame] | 184 | u8 ctl_id; |
| 185 | u8 pull_id; |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 186 | #endif /* CONFIG_TEGRA20 */ |
| 187 | }; |
| 188 | |
Stephen Warren | f4df605 | 2014-03-21 12:28:56 -0600 | [diff] [blame] | 189 | extern const struct pmux_pingrp_desc *tegra_soc_pingroups; |
Stephen Warren | 9026dfd | 2014-03-21 12:28:54 -0600 | [diff] [blame] | 190 | |
| 191 | #endif /* _TEGRA_PINMUX_H_ */ |