pinctrl-tegra.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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_HIGH_SPEED_MODE,
  32. /* argument: Boolean */
  33. TEGRA_PINCONF_PARAM_SCHMITT,
  34. /* argument: Boolean */
  35. TEGRA_PINCONF_PARAM_LOW_POWER_MODE,
  36. /* argument: Integer, range is HW-dependant */
  37. TEGRA_PINCONF_PARAM_DRIVE_DOWN_STRENGTH,
  38. /* argument: Integer, range is HW-dependant */
  39. TEGRA_PINCONF_PARAM_DRIVE_UP_STRENGTH,
  40. /* argument: Integer, range is HW-dependant */
  41. TEGRA_PINCONF_PARAM_SLEW_RATE_FALLING,
  42. /* argument: Integer, range is HW-dependant */
  43. TEGRA_PINCONF_PARAM_SLEW_RATE_RISING,
  44. };
  45. enum tegra_pinconf_pull {
  46. TEGRA_PINCONFIG_PULL_NONE,
  47. TEGRA_PINCONFIG_PULL_DOWN,
  48. TEGRA_PINCONFIG_PULL_UP,
  49. };
  50. enum tegra_pinconf_tristate {
  51. TEGRA_PINCONFIG_DRIVEN,
  52. TEGRA_PINCONFIG_TRISTATE,
  53. };
  54. #define TEGRA_PINCONF_PACK(_param_, _arg_) ((_param_) << 16 | (_arg_))
  55. #define TEGRA_PINCONF_UNPACK_PARAM(_conf_) ((_conf_) >> 16)
  56. #define TEGRA_PINCONF_UNPACK_ARG(_conf_) ((_conf_) & 0xffff)
  57. /**
  58. * struct tegra_function - Tegra pinctrl mux function
  59. * @name: The name of the function, exported to pinctrl core.
  60. * @groups: An array of pin groups that may select this function.
  61. * @ngroups: The number of entries in @groups.
  62. */
  63. struct tegra_function {
  64. const char *name;
  65. const char * const *groups;
  66. unsigned ngroups;
  67. };
  68. /**
  69. * struct tegra_pingroup - Tegra pin group
  70. * @mux_reg: Mux register offset. -1 if unsupported.
  71. * @mux_bank: Mux register bank. 0 if unsupported.
  72. * @mux_bit: Mux register bit. 0 if unsupported.
  73. * @pupd_reg: Pull-up/down register offset. -1 if unsupported.
  74. * @pupd_bank: Pull-up/down register bank. 0 if unsupported.
  75. * @pupd_bit: Pull-up/down register bit. 0 if unsupported.
  76. * @tri_reg: Tri-state register offset. -1 if unsupported.
  77. * @tri_bank: Tri-state register bank. 0 if unsupported.
  78. * @tri_bit: Tri-state register bit. 0 if unsupported.
  79. * @einput_reg: Enable-input register offset. -1 if unsupported.
  80. * @einput_bank: Enable-input register bank. 0 if unsupported.
  81. * @einput_bit: Enable-input register bit. 0 if unsupported.
  82. * @odrain_reg: Open-drain register offset. -1 if unsupported.
  83. * @odrain_bank: Open-drain register bank. 0 if unsupported.
  84. * @odrain_bit: Open-drain register bit. 0 if unsupported.
  85. * @lock_reg: Lock register offset. -1 if unsupported.
  86. * @lock_bank: Lock register bank. 0 if unsupported.
  87. * @lock_bit: Lock register bit. 0 if unsupported.
  88. * @ioreset_reg: IO reset register offset. -1 if unsupported.
  89. * @ioreset_bank: IO reset register bank. 0 if unsupported.
  90. * @ioreset_bit: IO reset register bit. 0 if unsupported.
  91. * @drv_reg: Drive fields register offset. -1 if unsupported.
  92. * This register contains the hsm, schmitt, lpmd, drvdn,
  93. * drvup, slwr, and slwf parameters.
  94. * @drv_bank: Drive fields register bank. 0 if unsupported.
  95. * @hsm_bit: High Speed Mode register bit. 0 if unsupported.
  96. * @schmitt_bit: Scmitt register bit. 0 if unsupported.
  97. * @lpmd_bit: Low Power Mode register bit. 0 if unsupported.
  98. * @drvdn_bit: Drive Down register bit. 0 if unsupported.
  99. * @drvdn_width: Drive Down field width. 0 if unsupported.
  100. * @drvup_bit: Drive Up register bit. 0 if unsupported.
  101. * @drvup_width: Drive Up field width. 0 if unsupported.
  102. * @slwr_bit: Slew Rising register bit. 0 if unsupported.
  103. * @slwr_width: Slew Rising field width. 0 if unsupported.
  104. * @slwf_bit: Slew Falling register bit. 0 if unsupported.
  105. * @slwf_width: Slew Falling field width. 0 if unsupported.
  106. *
  107. * A representation of a group of pins (possibly just one pin) in the Tegra
  108. * pin controller. Each group allows some parameter or parameters to be
  109. * configured. The most common is mux function selection. Many others exist
  110. * such as pull-up/down, tri-state, etc. Tegra's pin controller is complex;
  111. * certain groups may only support configuring certain parameters, hence
  112. * each parameter is optional, represented by a -1 "reg" value.
  113. */
  114. struct tegra_pingroup {
  115. const char *name;
  116. const unsigned *pins;
  117. unsigned npins;
  118. unsigned funcs[4];
  119. unsigned func_safe;
  120. s16 mux_reg;
  121. s16 pupd_reg;
  122. s16 tri_reg;
  123. s16 einput_reg;
  124. s16 odrain_reg;
  125. s16 lock_reg;
  126. s16 ioreset_reg;
  127. s16 drv_reg;
  128. u32 mux_bank:2;
  129. u32 pupd_bank:2;
  130. u32 tri_bank:2;
  131. u32 einput_bank:2;
  132. u32 odrain_bank:2;
  133. u32 ioreset_bank:2;
  134. u32 lock_bank:2;
  135. u32 drv_bank:2;
  136. u32 mux_bit:5;
  137. u32 pupd_bit:5;
  138. u32 tri_bit:5;
  139. u32 einput_bit:5;
  140. u32 odrain_bit:5;
  141. u32 lock_bit:5;
  142. u32 ioreset_bit:5;
  143. u32 hsm_bit:5;
  144. u32 schmitt_bit:5;
  145. u32 lpmd_bit:5;
  146. u32 drvdn_bit:5;
  147. u32 drvup_bit:5;
  148. u32 slwr_bit:5;
  149. u32 slwf_bit:5;
  150. u32 drvdn_width:6;
  151. u32 drvup_width:6;
  152. u32 slwr_width:6;
  153. u32 slwf_width:6;
  154. };
  155. /**
  156. * struct tegra_pinctrl_soc_data - Tegra pin controller driver configuration
  157. * @ngpios: The number of GPIO pins the pin controller HW affects.
  158. * @pins: An array describing all pins the pin controller affects.
  159. * All pins which are also GPIOs must be listed first within the
  160. * array, and be numbered identically to the GPIO controller's
  161. * numbering.
  162. * @npins: The numbmer of entries in @pins.
  163. * @functions: An array describing all mux functions the SoC supports.
  164. * @nfunctions: The numbmer of entries in @functions.
  165. * @groups: An array describing all pin groups the pin SoC supports.
  166. * @ngroups: The numbmer of entries in @groups.
  167. */
  168. struct tegra_pinctrl_soc_data {
  169. unsigned ngpios;
  170. const struct pinctrl_pin_desc *pins;
  171. unsigned npins;
  172. const struct tegra_function *functions;
  173. unsigned nfunctions;
  174. const struct tegra_pingroup *groups;
  175. unsigned ngroups;
  176. };
  177. int tegra_pinctrl_probe(struct platform_device *pdev,
  178. const struct tegra_pinctrl_soc_data *soc_data);
  179. int tegra_pinctrl_remove(struct platform_device *pdev);
  180. #endif