pinmux.h 6.1 KB

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