pinctrl-tegra.h 6.1 KB

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