pinmux.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2010-2014
  4. * NVIDIA Corporation <www.nvidia.com>
  5. */
  6. #ifndef _TEGRA_PINMUX_H_
  7. #define _TEGRA_PINMUX_H_
  8. #include <linux/types.h>
  9. #include <asm/arch/tegra.h>
  10. /* The pullup/pulldown state of a pin group */
  11. enum pmux_pull {
  12. PMUX_PULL_NORMAL = 0,
  13. PMUX_PULL_DOWN,
  14. PMUX_PULL_UP,
  15. };
  16. /* Defines whether a pin group is tristated or in normal operation */
  17. enum pmux_tristate {
  18. PMUX_TRI_NORMAL = 0,
  19. PMUX_TRI_TRISTATE = 1,
  20. };
  21. #ifdef TEGRA_PMX_PINS_HAVE_E_INPUT
  22. enum pmux_pin_io {
  23. PMUX_PIN_OUTPUT = 0,
  24. PMUX_PIN_INPUT = 1,
  25. PMUX_PIN_NONE,
  26. };
  27. #endif
  28. #ifdef TEGRA_PMX_PINS_HAVE_LOCK
  29. enum pmux_pin_lock {
  30. PMUX_PIN_LOCK_DEFAULT = 0,
  31. PMUX_PIN_LOCK_DISABLE,
  32. PMUX_PIN_LOCK_ENABLE,
  33. };
  34. #endif
  35. #ifdef TEGRA_PMX_PINS_HAVE_OD
  36. enum pmux_pin_od {
  37. PMUX_PIN_OD_DEFAULT = 0,
  38. PMUX_PIN_OD_DISABLE,
  39. PMUX_PIN_OD_ENABLE,
  40. };
  41. #endif
  42. #ifdef TEGRA_PMX_PINS_HAVE_IO_RESET
  43. enum pmux_pin_ioreset {
  44. PMUX_PIN_IO_RESET_DEFAULT = 0,
  45. PMUX_PIN_IO_RESET_DISABLE,
  46. PMUX_PIN_IO_RESET_ENABLE,
  47. };
  48. #endif
  49. #ifdef TEGRA_PMX_PINS_HAVE_RCV_SEL
  50. enum pmux_pin_rcv_sel {
  51. PMUX_PIN_RCV_SEL_DEFAULT = 0,
  52. PMUX_PIN_RCV_SEL_NORMAL,
  53. PMUX_PIN_RCV_SEL_HIGH,
  54. };
  55. #endif
  56. #ifdef TEGRA_PMX_PINS_HAVE_E_IO_HV
  57. enum pmux_pin_e_io_hv {
  58. PMUX_PIN_E_IO_HV_DEFAULT = 0,
  59. PMUX_PIN_E_IO_HV_NORMAL,
  60. PMUX_PIN_E_IO_HV_HIGH,
  61. };
  62. #endif
  63. #ifdef TEGRA_PMX_GRPS_HAVE_LPMD
  64. /* Defines a pin group cfg's low-power mode select */
  65. enum pmux_lpmd {
  66. PMUX_LPMD_X8 = 0,
  67. PMUX_LPMD_X4,
  68. PMUX_LPMD_X2,
  69. PMUX_LPMD_X,
  70. PMUX_LPMD_NONE = -1,
  71. };
  72. #endif
  73. #if defined(TEGRA_PMX_PINS_HAVE_SCHMT) || defined(TEGRA_PMX_GRPS_HAVE_SCHMT)
  74. /* Defines whether a pin group cfg's schmidt is enabled or not */
  75. enum pmux_schmt {
  76. PMUX_SCHMT_DISABLE = 0,
  77. PMUX_SCHMT_ENABLE = 1,
  78. PMUX_SCHMT_NONE = -1,
  79. };
  80. #endif
  81. #if defined(TEGRA_PMX_PINS_HAVE_HSM) || defined(TEGRA_PMX_GRPS_HAVE_HSM)
  82. /* Defines whether a pin group cfg's high-speed mode is enabled or not */
  83. enum pmux_hsm {
  84. PMUX_HSM_DISABLE = 0,
  85. PMUX_HSM_ENABLE = 1,
  86. PMUX_HSM_NONE = -1,
  87. };
  88. #endif
  89. /*
  90. * This defines the configuration for a pin, including the function assigned,
  91. * pull up/down settings and tristate settings. Having set up one of these
  92. * you can call pinmux_config_pingroup() to configure a pin in one step. Also
  93. * available is pinmux_config_table() to configure a list of pins.
  94. */
  95. struct pmux_pingrp_config {
  96. u32 pingrp:16; /* pin group PMUX_PINGRP_... */
  97. u32 func:8; /* function to assign PMUX_FUNC_... */
  98. u32 pull:2; /* pull up/down/normal PMUX_PULL_...*/
  99. u32 tristate:2; /* tristate or normal PMUX_TRI_... */
  100. #ifdef TEGRA_PMX_PINS_HAVE_E_INPUT
  101. u32 io:2; /* input or output PMUX_PIN_... */
  102. #endif
  103. #ifdef TEGRA_PMX_PINS_HAVE_LOCK
  104. u32 lock:2; /* lock enable/disable PMUX_PIN... */
  105. #endif
  106. #ifdef TEGRA_PMX_PINS_HAVE_OD
  107. u32 od:2; /* open-drain or push-pull driver */
  108. #endif
  109. #ifdef TEGRA_PMX_PINS_HAVE_IO_RESET
  110. u32 ioreset:2; /* input/output reset PMUX_PIN... */
  111. #endif
  112. #ifdef TEGRA_PMX_PINS_HAVE_RCV_SEL
  113. u32 rcv_sel:2; /* select between High and Normal */
  114. /* VIL/VIH receivers */
  115. #endif
  116. #ifdef TEGRA_PMX_PINS_HAVE_E_IO_HV
  117. u32 e_io_hv:2; /* select 3.3v tolerant receivers */
  118. #endif
  119. #ifdef TEGRA_PMX_PINS_HAVE_SCHMT
  120. u32 schmt:2; /* schmitt enable */
  121. #endif
  122. #ifdef TEGRA_PMX_PINS_HAVE_HSM
  123. u32 hsm:2; /* high-speed mode enable */
  124. #endif
  125. };
  126. #ifdef TEGRA_PMX_SOC_HAS_IO_CLAMPING
  127. /* Set/clear the pinmux CLAMP_INPUTS_WHEN_TRISTATED bit */
  128. void pinmux_set_tristate_input_clamping(void);
  129. void pinmux_clear_tristate_input_clamping(void);
  130. #endif
  131. /* Set the mux function for a pin group */
  132. void pinmux_set_func(enum pmux_pingrp pin, enum pmux_func func);
  133. /* Set the pull up/down feature for a pin group */
  134. void pinmux_set_pullupdown(enum pmux_pingrp pin, enum pmux_pull pupd);
  135. /* Set a pin group to tristate */
  136. void pinmux_tristate_enable(enum pmux_pingrp pin);
  137. /* Set a pin group to normal (non tristate) */
  138. void pinmux_tristate_disable(enum pmux_pingrp pin);
  139. #ifdef TEGRA_PMX_PINS_HAVE_E_INPUT
  140. /* Set a pin group as input or output */
  141. void pinmux_set_io(enum pmux_pingrp pin, enum pmux_pin_io io);
  142. #endif
  143. /**
  144. * Configure a list of pin groups
  145. *
  146. * @param config List of config items
  147. * @param len Number of config items in list
  148. */
  149. void pinmux_config_pingrp_table(const struct pmux_pingrp_config *config,
  150. int len);
  151. struct pmux_pingrp_desc {
  152. u8 funcs[4];
  153. #if defined(CONFIG_TEGRA20)
  154. u8 ctl_id;
  155. u8 pull_id;
  156. #endif /* CONFIG_TEGRA20 */
  157. };
  158. extern const struct pmux_pingrp_desc *tegra_soc_pingroups;
  159. #ifdef TEGRA_PMX_SOC_HAS_DRVGRPS
  160. #define PMUX_SLWF_MIN 0
  161. #define PMUX_SLWF_MAX 3
  162. #define PMUX_SLWF_NONE -1
  163. #define PMUX_SLWR_MIN 0
  164. #define PMUX_SLWR_MAX 3
  165. #define PMUX_SLWR_NONE -1
  166. #define PMUX_DRVUP_MIN 0
  167. #define PMUX_DRVUP_MAX 127
  168. #define PMUX_DRVUP_NONE -1
  169. #define PMUX_DRVDN_MIN 0
  170. #define PMUX_DRVDN_MAX 127
  171. #define PMUX_DRVDN_NONE -1
  172. /*
  173. * This defines the configuration for a pin group's pad control config
  174. */
  175. struct pmux_drvgrp_config {
  176. u32 drvgrp:16; /* pin group PMUX_DRVGRP_x */
  177. u32 slwf:3; /* falling edge slew */
  178. u32 slwr:3; /* rising edge slew */
  179. u32 drvup:8; /* pull-up drive strength */
  180. u32 drvdn:8; /* pull-down drive strength */
  181. #ifdef TEGRA_PMX_GRPS_HAVE_LPMD
  182. u32 lpmd:3; /* low-power mode selection */
  183. #endif
  184. #ifdef TEGRA_PMX_GRPS_HAVE_SCHMT
  185. u32 schmt:2; /* schmidt enable */
  186. #endif
  187. #ifdef TEGRA_PMX_GRPS_HAVE_HSM
  188. u32 hsm:2; /* high-speed mode enable */
  189. #endif
  190. };
  191. /**
  192. * Set the GP pad configs
  193. *
  194. * @param config List of config items
  195. * @param len Number of config items in list
  196. */
  197. void pinmux_config_drvgrp_table(const struct pmux_drvgrp_config *config,
  198. int len);
  199. #endif /* TEGRA_PMX_SOC_HAS_DRVGRPS */
  200. #ifdef TEGRA_PMX_SOC_HAS_MIPI_PAD_CTRL_GRPS
  201. struct pmux_mipipadctrlgrp_config {
  202. u32 grp:16; /* pin group PMUX_MIPIPADCTRLGRP_x */
  203. u32 func:8; /* function to assign PMUX_FUNC_... */
  204. };
  205. void pinmux_config_mipipadctrlgrp_table(
  206. const struct pmux_mipipadctrlgrp_config *config, int len);
  207. struct pmux_mipipadctrlgrp_desc {
  208. u8 funcs[2];
  209. };
  210. extern const struct pmux_mipipadctrlgrp_desc *tegra_soc_mipipadctrl_groups;
  211. #endif /* TEGRA_PMX_SOC_HAS_MIPI_PAD_CTRL_GRPS */
  212. #endif /* _TEGRA_PINMUX_H_ */