pinctrl-tegra.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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 * const *groups;
  70. unsigned ngroups;
  71. };
  72. /**
  73. * struct tegra_pingroup - Tegra pin group
  74. * @mux_reg: Mux register offset. -1 if unsupported.
  75. * @mux_bank: Mux register bank. 0 if unsupported.
  76. * @mux_bit: Mux register bit. 0 if unsupported.
  77. * @pupd_reg: Pull-up/down register offset. -1 if unsupported.
  78. * @pupd_bank: Pull-up/down register bank. 0 if unsupported.
  79. * @pupd_bit: Pull-up/down register bit. 0 if unsupported.
  80. * @tri_reg: Tri-state register offset. -1 if unsupported.
  81. * @tri_bank: Tri-state register bank. 0 if unsupported.
  82. * @tri_bit: Tri-state register bit. 0 if unsupported.
  83. * @einput_reg: Enable-input register offset. -1 if unsupported.
  84. * @einput_bank: Enable-input register bank. 0 if unsupported.
  85. * @einput_bit: Enable-input register bit. 0 if unsupported.
  86. * @odrain_reg: Open-drain register offset. -1 if unsupported.
  87. * @odrain_bank: Open-drain register bank. 0 if unsupported.
  88. * @odrain_bit: Open-drain register bit. 0 if unsupported.
  89. * @lock_reg: Lock register offset. -1 if unsupported.
  90. * @lock_bank: Lock register bank. 0 if unsupported.
  91. * @lock_bit: Lock register bit. 0 if unsupported.
  92. * @ioreset_reg: IO reset register offset. -1 if unsupported.
  93. * @ioreset_bank: IO reset register bank. 0 if unsupported.
  94. * @ioreset_bit: IO reset register bit. 0 if unsupported.
  95. * @rcv_sel_reg: Receiver select offset. -1 if unsupported.
  96. * @rcv_sel_bank: Receiver select bank. 0 if unsupported.
  97. * @rcv_sel_bit: Receiver select bit. 0 if unsupported.
  98. * @drv_reg: Drive fields register offset. -1 if unsupported.
  99. * This register contains the hsm, schmitt, lpmd, drvdn,
  100. * drvup, slwr, and slwf parameters.
  101. * @drv_bank: Drive fields register bank. 0 if unsupported.
  102. * @hsm_bit: High Speed Mode register bit. 0 if unsupported.
  103. * @schmitt_bit: Scmitt register bit. 0 if unsupported.
  104. * @lpmd_bit: Low Power Mode register bit. 0 if unsupported.
  105. * @drvdn_bit: Drive Down register bit. 0 if unsupported.
  106. * @drvdn_width: Drive Down field width. 0 if unsupported.
  107. * @drvup_bit: Drive Up register bit. 0 if unsupported.
  108. * @drvup_width: Drive Up field width. 0 if unsupported.
  109. * @slwr_bit: Slew Rising register bit. 0 if unsupported.
  110. * @slwr_width: Slew Rising field width. 0 if unsupported.
  111. * @slwf_bit: Slew Falling register bit. 0 if unsupported.
  112. * @slwf_width: Slew Falling field width. 0 if unsupported.
  113. * @drvtype_reg: Drive type fields register offset. -1 if unsupported.
  114. * @drvtype_bank: Drive type fields register bank. 0 if unsupported.
  115. * @drvtype_bit: Drive type register bit. 0 if unsupported.
  116. *
  117. * A representation of a group of pins (possibly just one pin) in the Tegra
  118. * pin controller. Each group allows some parameter or parameters to be
  119. * configured. The most common is mux function selection. Many others exist
  120. * such as pull-up/down, tri-state, etc. Tegra's pin controller is complex;
  121. * certain groups may only support configuring certain parameters, hence
  122. * each parameter is optional, represented by a -1 "reg" value.
  123. */
  124. struct tegra_pingroup {
  125. const char *name;
  126. const unsigned *pins;
  127. unsigned npins;
  128. unsigned funcs[4];
  129. unsigned func_safe;
  130. s16 mux_reg;
  131. s16 pupd_reg;
  132. s16 tri_reg;
  133. s16 einput_reg;
  134. s16 odrain_reg;
  135. s16 lock_reg;
  136. s16 ioreset_reg;
  137. s16 rcv_sel_reg;
  138. s16 drv_reg;
  139. s16 drvtype_reg;
  140. u32 mux_bank:2;
  141. u32 pupd_bank:2;
  142. u32 tri_bank:2;
  143. u32 einput_bank:2;
  144. u32 odrain_bank:2;
  145. u32 ioreset_bank:2;
  146. u32 rcv_sel_bank:2;
  147. u32 lock_bank:2;
  148. u32 drv_bank:2;
  149. u32 drvtype_bank:2;
  150. u32 mux_bit:5;
  151. u32 pupd_bit:5;
  152. u32 tri_bit:5;
  153. u32 einput_bit:5;
  154. u32 odrain_bit:5;
  155. u32 lock_bit:5;
  156. u32 ioreset_bit:5;
  157. u32 rcv_sel_bit:5;
  158. u32 hsm_bit:5;
  159. u32 schmitt_bit:5;
  160. u32 lpmd_bit:5;
  161. u32 drvdn_bit:5;
  162. u32 drvup_bit:5;
  163. u32 slwr_bit:5;
  164. u32 slwf_bit:5;
  165. u32 drvtype_bit:5;
  166. u32 drvdn_width:6;
  167. u32 drvup_width:6;
  168. u32 slwr_width:6;
  169. u32 slwf_width:6;
  170. };
  171. /**
  172. * struct tegra_pinctrl_soc_data - Tegra pin controller driver configuration
  173. * @ngpios: The number of GPIO pins the pin controller HW affects.
  174. * @pins: An array describing all pins the pin controller affects.
  175. * All pins which are also GPIOs must be listed first within the
  176. * array, and be numbered identically to the GPIO controller's
  177. * numbering.
  178. * @npins: The numbmer of entries in @pins.
  179. * @functions: An array describing all mux functions the SoC supports.
  180. * @nfunctions: The numbmer of entries in @functions.
  181. * @groups: An array describing all pin groups the pin SoC supports.
  182. * @ngroups: The numbmer of entries in @groups.
  183. */
  184. struct tegra_pinctrl_soc_data {
  185. unsigned ngpios;
  186. const struct pinctrl_pin_desc *pins;
  187. unsigned npins;
  188. const struct tegra_function *functions;
  189. unsigned nfunctions;
  190. const struct tegra_pingroup *groups;
  191. unsigned ngroups;
  192. };
  193. int tegra_pinctrl_probe(struct platform_device *pdev,
  194. const struct tegra_pinctrl_soc_data *soc_data);
  195. int tegra_pinctrl_remove(struct platform_device *pdev);
  196. #endif