pinctrl-tegra.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. /**
  18. * struct tegra_function - Tegra pinctrl mux function
  19. * @name: The name of the function, exported to pinctrl core.
  20. * @groups: An array of pin groups that may select this function.
  21. * @ngroups: The number of entries in @groups.
  22. */
  23. struct tegra_function {
  24. const char *name;
  25. const char * const *groups;
  26. unsigned ngroups;
  27. };
  28. /**
  29. * struct tegra_pingroup - Tegra pin group
  30. * @mux_reg: Mux register offset. -1 if unsupported.
  31. * @mux_bank: Mux register bank. 0 if unsupported.
  32. * @mux_bit: Mux register bit. 0 if unsupported.
  33. * @pupd_reg: Pull-up/down register offset. -1 if unsupported.
  34. * @pupd_bank: Pull-up/down register bank. 0 if unsupported.
  35. * @pupd_bit: Pull-up/down register bit. 0 if unsupported.
  36. * @tri_reg: Tri-state register offset. -1 if unsupported.
  37. * @tri_bank: Tri-state register bank. 0 if unsupported.
  38. * @tri_bit: Tri-state register bit. 0 if unsupported.
  39. * @einput_reg: Enable-input register offset. -1 if unsupported.
  40. * @einput_bank: Enable-input register bank. 0 if unsupported.
  41. * @einput_bit: Enable-input register bit. 0 if unsupported.
  42. * @odrain_reg: Open-drain register offset. -1 if unsupported.
  43. * @odrain_bank: Open-drain register bank. 0 if unsupported.
  44. * @odrain_bit: Open-drain register bit. 0 if unsupported.
  45. * @lock_reg: Lock register offset. -1 if unsupported.
  46. * @lock_bank: Lock register bank. 0 if unsupported.
  47. * @lock_bit: Lock register bit. 0 if unsupported.
  48. * @ioreset_reg: IO reset register offset. -1 if unsupported.
  49. * @ioreset_bank: IO reset register bank. 0 if unsupported.
  50. * @ioreset_bit: IO reset register bit. 0 if unsupported.
  51. * @drv_reg: Drive fields register offset. -1 if unsupported.
  52. * This register contains the hsm, schmitt, lpmd, drvdn,
  53. * drvup, slwr, and slwf parameters.
  54. * @drv_bank: Drive fields register bank. 0 if unsupported.
  55. * @hsm_bit: High Speed Mode register bit. 0 if unsupported.
  56. * @schmitt_bit: Scmitt register bit. 0 if unsupported.
  57. * @lpmd_bit: Low Power Mode register bit. 0 if unsupported.
  58. * @drvdn_bit: Drive Down register bit. 0 if unsupported.
  59. * @drvdn_width: Drive Down field width. 0 if unsupported.
  60. * @drvup_bit: Drive Up register bit. 0 if unsupported.
  61. * @drvup_width: Drive Up field width. 0 if unsupported.
  62. * @slwr_bit: Slew Rising register bit. 0 if unsupported.
  63. * @slwr_width: Slew Rising field width. 0 if unsupported.
  64. * @slwf_bit: Slew Falling register bit. 0 if unsupported.
  65. * @slwf_width: Slew Falling field width. 0 if unsupported.
  66. *
  67. * A representation of a group of pins (possibly just one pin) in the Tegra
  68. * pin controller. Each group allows some parameter or parameters to be
  69. * configured. The most common is mux function selection. Many others exist
  70. * such as pull-up/down, tri-state, etc. Tegra's pin controller is complex;
  71. * certain groups may only support configuring certain parameters, hence
  72. * each parameter is optional, represented by a -1 "reg" value.
  73. */
  74. struct tegra_pingroup {
  75. const char *name;
  76. const unsigned *pins;
  77. unsigned npins;
  78. unsigned funcs[4];
  79. unsigned func_safe;
  80. s16 mux_reg;
  81. s16 pupd_reg;
  82. s16 tri_reg;
  83. s16 einput_reg;
  84. s16 odrain_reg;
  85. s16 lock_reg;
  86. s16 ioreset_reg;
  87. s16 drv_reg;
  88. u32 mux_bank:2;
  89. u32 pupd_bank:2;
  90. u32 tri_bank:2;
  91. u32 einput_bank:2;
  92. u32 odrain_bank:2;
  93. u32 ioreset_bank:2;
  94. u32 lock_bank:2;
  95. u32 drv_bank:2;
  96. u32 mux_bit:5;
  97. u32 pupd_bit:5;
  98. u32 tri_bit:5;
  99. u32 einput_bit:5;
  100. u32 odrain_bit:5;
  101. u32 lock_bit:5;
  102. u32 ioreset_bit:5;
  103. u32 hsm_bit:5;
  104. u32 schmitt_bit:5;
  105. u32 lpmd_bit:5;
  106. u32 drvdn_bit:5;
  107. u32 drvup_bit:5;
  108. u32 slwr_bit:5;
  109. u32 slwf_bit:5;
  110. u32 drvdn_width:6;
  111. u32 drvup_width:6;
  112. u32 slwr_width:6;
  113. u32 slwf_width:6;
  114. };
  115. /**
  116. * struct tegra_pinctrl_soc_data - Tegra pin controller driver configuration
  117. * @ngpios: The number of GPIO pins the pin controller HW affects.
  118. * @pins: An array describing all pins the pin controller affects.
  119. * All pins which are also GPIOs must be listed first within the
  120. * array, and be numbered identically to the GPIO controller's
  121. * numbering.
  122. * @npins: The numbmer of entries in @pins.
  123. * @functions: An array describing all mux functions the SoC supports.
  124. * @nfunctions: The numbmer of entries in @functions.
  125. * @groups: An array describing all pin groups the pin SoC supports.
  126. * @ngroups: The numbmer of entries in @groups.
  127. */
  128. struct tegra_pinctrl_soc_data {
  129. unsigned ngpios;
  130. const struct pinctrl_pin_desc *pins;
  131. unsigned npins;
  132. const struct tegra_function *functions;
  133. unsigned nfunctions;
  134. const struct tegra_pingroup *groups;
  135. unsigned ngroups;
  136. };
  137. /**
  138. * tegra_pinctrl_soc_initf() - Retrieve pin controller details for a SoC.
  139. * @soc_data: This pointer must be updated to point at a struct containing
  140. * details of the SoC.
  141. */
  142. typedef void (*tegra_pinctrl_soc_initf)(
  143. const struct tegra_pinctrl_soc_data **soc_data);
  144. /**
  145. * tegra20_pinctrl_init() - Retrieve pin controller details for Tegra20
  146. * @soc_data: This pointer will be updated to point at a struct containing
  147. * details of Tegra20's pin controller.
  148. */
  149. void tegra20_pinctrl_init(const struct tegra_pinctrl_soc_data **soc_data);
  150. /**
  151. * tegra30_pinctrl_init() - Retrieve pin controller details for Tegra20
  152. * @soc_data: This pointer will be updated to point at a struct containing
  153. * details of Tegra30's pin controller.
  154. */
  155. void tegra30_pinctrl_init(const struct tegra_pinctrl_soc_data **soc_data);
  156. #endif