pinctrl-tegra.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Driver for the NVIDIA Tegra pinmux
  4. *
  5. * Copyright (c) 2011, NVIDIA CORPORATION. All rights reserved.
  6. */
  7. #ifndef __PINMUX_TEGRA_H__
  8. #define __PINMUX_TEGRA_H__
  9. struct tegra_pmx {
  10. struct device *dev;
  11. struct pinctrl_dev *pctl;
  12. const struct tegra_pinctrl_soc_data *soc;
  13. const char **group_pins;
  14. int nbanks;
  15. void __iomem **regs;
  16. u32 *backup_regs;
  17. };
  18. enum tegra_pinconf_param {
  19. /* argument: tegra_pinconf_pull */
  20. TEGRA_PINCONF_PARAM_PULL,
  21. /* argument: tegra_pinconf_tristate */
  22. TEGRA_PINCONF_PARAM_TRISTATE,
  23. /* argument: Boolean */
  24. TEGRA_PINCONF_PARAM_ENABLE_INPUT,
  25. /* argument: Boolean */
  26. TEGRA_PINCONF_PARAM_OPEN_DRAIN,
  27. /* argument: Boolean */
  28. TEGRA_PINCONF_PARAM_LOCK,
  29. /* argument: Boolean */
  30. TEGRA_PINCONF_PARAM_IORESET,
  31. /* argument: Boolean */
  32. TEGRA_PINCONF_PARAM_RCV_SEL,
  33. /* argument: Boolean */
  34. TEGRA_PINCONF_PARAM_HIGH_SPEED_MODE,
  35. /* argument: Boolean */
  36. TEGRA_PINCONF_PARAM_SCHMITT,
  37. /* argument: Boolean */
  38. TEGRA_PINCONF_PARAM_LOW_POWER_MODE,
  39. /* argument: Integer, range is HW-dependant */
  40. TEGRA_PINCONF_PARAM_DRIVE_DOWN_STRENGTH,
  41. /* argument: Integer, range is HW-dependant */
  42. TEGRA_PINCONF_PARAM_DRIVE_UP_STRENGTH,
  43. /* argument: Integer, range is HW-dependant */
  44. TEGRA_PINCONF_PARAM_SLEW_RATE_FALLING,
  45. /* argument: Integer, range is HW-dependant */
  46. TEGRA_PINCONF_PARAM_SLEW_RATE_RISING,
  47. /* argument: Integer, range is HW-dependant */
  48. TEGRA_PINCONF_PARAM_DRIVE_TYPE,
  49. };
  50. enum tegra_pinconf_pull {
  51. TEGRA_PINCONFIG_PULL_NONE,
  52. TEGRA_PINCONFIG_PULL_DOWN,
  53. TEGRA_PINCONFIG_PULL_UP,
  54. };
  55. enum tegra_pinconf_tristate {
  56. TEGRA_PINCONFIG_DRIVEN,
  57. TEGRA_PINCONFIG_TRISTATE,
  58. };
  59. #define TEGRA_PINCONF_PACK(_param_, _arg_) ((_param_) << 16 | (_arg_))
  60. #define TEGRA_PINCONF_UNPACK_PARAM(_conf_) ((_conf_) >> 16)
  61. #define TEGRA_PINCONF_UNPACK_ARG(_conf_) ((_conf_) & 0xffff)
  62. /**
  63. * struct tegra_function - Tegra pinctrl mux function
  64. * @name: The name of the function, exported to pinctrl core.
  65. * @groups: An array of pin groups that may select this function.
  66. * @ngroups: The number of entries in @groups.
  67. */
  68. struct tegra_function {
  69. const char *name;
  70. const char **groups;
  71. unsigned ngroups;
  72. };
  73. /**
  74. * struct tegra_pingroup - Tegra pin group
  75. * @name The name of the pin group.
  76. * @pins An array of pin IDs included in this pin group.
  77. * @npins The number of entries in @pins.
  78. * @funcs The mux functions which can be muxed onto this group.
  79. * @mux_reg: Mux register offset.
  80. * This register contains the mux, einput, odrain, lock,
  81. * ioreset, rcv_sel parameters.
  82. * @mux_bank: Mux register bank.
  83. * @mux_bit: Mux register bit.
  84. * @pupd_reg: Pull-up/down register offset.
  85. * @pupd_bank: Pull-up/down register bank.
  86. * @pupd_bit: Pull-up/down register bit.
  87. * @tri_reg: Tri-state register offset.
  88. * @tri_bank: Tri-state register bank.
  89. * @tri_bit: Tri-state register bit.
  90. * @einput_bit: Enable-input register bit.
  91. * @odrain_bit: Open-drain register bit.
  92. * @lock_bit: Lock register bit.
  93. * @ioreset_bit: IO reset register bit.
  94. * @rcv_sel_bit: Receiver select bit.
  95. * @drv_reg: Drive fields register offset.
  96. * This register contains hsm, schmitt, lpmd, drvdn,
  97. * drvup, slwr, slwf, and drvtype parameters.
  98. * @drv_bank: Drive fields register bank.
  99. * @hsm_bit: High Speed Mode register bit.
  100. * @sfsel_bit: GPIO/SFIO selection register bit.
  101. * @schmitt_bit: Schmitt register bit.
  102. * @lpmd_bit: Low Power Mode register bit.
  103. * @drvdn_bit: Drive Down register bit.
  104. * @drvdn_width: Drive Down field width.
  105. * @drvup_bit: Drive Up register bit.
  106. * @drvup_width: Drive Up field width.
  107. * @slwr_bit: Slew Rising register bit.
  108. * @slwr_width: Slew Rising field width.
  109. * @slwf_bit: Slew Falling register bit.
  110. * @slwf_width: Slew Falling field width.
  111. * @lpdr_bit: Base driver enabling bit.
  112. * @drvtype_bit: Drive type register bit.
  113. * @parked_bitmask: Parked register mask. 0 if unsupported.
  114. *
  115. * -1 in a *_reg field means that feature is unsupported for this group.
  116. * *_bank and *_reg values are irrelevant when *_reg is -1.
  117. * When *_reg is valid, *_bit may be -1 to indicate an unsupported feature.
  118. *
  119. * A representation of a group of pins (possibly just one pin) in the Tegra
  120. * pin controller. Each group allows some parameter or parameters to be
  121. * configured. The most common is mux function selection. Many others exist
  122. * such as pull-up/down, tri-state, etc. Tegra's pin controller is complex;
  123. * certain groups may only support configuring certain parameters, hence
  124. * each parameter is optional.
  125. */
  126. struct tegra_pingroup {
  127. const char *name;
  128. const unsigned *pins;
  129. u8 npins;
  130. u8 funcs[4];
  131. s32 mux_reg;
  132. s32 pupd_reg;
  133. s32 tri_reg;
  134. s32 drv_reg;
  135. u32 mux_bank:2;
  136. u32 pupd_bank:2;
  137. u32 tri_bank:2;
  138. u32 drv_bank:2;
  139. s32 mux_bit:6;
  140. s32 pupd_bit:6;
  141. s32 tri_bit:6;
  142. s32 einput_bit:6;
  143. s32 odrain_bit:6;
  144. s32 lock_bit:6;
  145. s32 ioreset_bit:6;
  146. s32 rcv_sel_bit:6;
  147. s32 hsm_bit:6;
  148. s32 sfsel_bit:6;
  149. s32 schmitt_bit:6;
  150. s32 lpmd_bit:6;
  151. s32 drvdn_bit:6;
  152. s32 drvup_bit:6;
  153. s32 slwr_bit:6;
  154. s32 slwf_bit:6;
  155. s32 lpdr_bit:6;
  156. s32 drvtype_bit:6;
  157. s32 drvdn_width:6;
  158. s32 drvup_width:6;
  159. s32 slwr_width:6;
  160. s32 slwf_width:6;
  161. u32 parked_bitmask;
  162. };
  163. /**
  164. * struct tegra_pinctrl_soc_data - Tegra pin controller driver configuration
  165. * @ngpios: The number of GPIO pins the pin controller HW affects.
  166. * @pins: An array describing all pins the pin controller affects.
  167. * All pins which are also GPIOs must be listed first within the
  168. * array, and be numbered identically to the GPIO controller's
  169. * numbering.
  170. * @npins: The numbmer of entries in @pins.
  171. * @functions: An array describing all mux functions the SoC supports.
  172. * @nfunctions: The numbmer of entries in @functions.
  173. * @groups: An array describing all pin groups the pin SoC supports.
  174. * @ngroups: The numbmer of entries in @groups.
  175. */
  176. struct tegra_pinctrl_soc_data {
  177. unsigned ngpios;
  178. const char *gpio_compatible;
  179. const struct pinctrl_pin_desc *pins;
  180. unsigned npins;
  181. struct tegra_function *functions;
  182. unsigned nfunctions;
  183. const struct tegra_pingroup *groups;
  184. unsigned ngroups;
  185. bool hsm_in_mux;
  186. bool schmitt_in_mux;
  187. bool drvtype_in_mux;
  188. bool sfsel_in_mux;
  189. };
  190. extern const struct dev_pm_ops tegra_pinctrl_pm;
  191. int tegra_pinctrl_probe(struct platform_device *pdev,
  192. const struct tegra_pinctrl_soc_data *soc_data);
  193. #endif