pinctrl-intel.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Core pinctrl/GPIO driver for Intel GPIO controllers
  4. *
  5. * Copyright (C) 2015, Intel Corporation
  6. * Authors: Mathias Nyman <mathias.nyman@linux.intel.com>
  7. * Mika Westerberg <mika.westerberg@linux.intel.com>
  8. */
  9. #ifndef PINCTRL_INTEL_H
  10. #define PINCTRL_INTEL_H
  11. struct pinctrl_pin_desc;
  12. struct platform_device;
  13. struct device;
  14. /**
  15. * struct intel_pingroup - Description about group of pins
  16. * @name: Name of the groups
  17. * @pins: All pins in this group
  18. * @npins: Number of pins in this groups
  19. * @mode: Native mode in which the group is muxed out @pins. Used if @modes
  20. * is %NULL.
  21. * @modes: If not %NULL this will hold mode for each pin in @pins
  22. */
  23. struct intel_pingroup {
  24. const char *name;
  25. const unsigned *pins;
  26. size_t npins;
  27. unsigned short mode;
  28. const unsigned *modes;
  29. };
  30. /**
  31. * struct intel_function - Description about a function
  32. * @name: Name of the function
  33. * @groups: An array of groups for this function
  34. * @ngroups: Number of groups in @groups
  35. */
  36. struct intel_function {
  37. const char *name;
  38. const char * const *groups;
  39. size_t ngroups;
  40. };
  41. /**
  42. * struct intel_padgroup - Hardware pad group information
  43. * @reg_num: GPI_IS register number
  44. * @base: Starting pin of this group
  45. * @size: Size of this group (maximum is 32).
  46. * @gpio_base: Starting GPIO base of this group (%0 if matches with @base,
  47. * and %-1 if no GPIO mapping should be created)
  48. * @padown_num: PAD_OWN register number (assigned by the core driver)
  49. *
  50. * If pad groups of a community are not the same size, use this structure
  51. * to specify them.
  52. */
  53. struct intel_padgroup {
  54. unsigned reg_num;
  55. unsigned base;
  56. unsigned size;
  57. int gpio_base;
  58. unsigned padown_num;
  59. };
  60. /**
  61. * struct intel_community - Intel pin community description
  62. * @barno: MMIO BAR number where registers for this community reside
  63. * @padown_offset: Register offset of PAD_OWN register from @regs. If %0
  64. * then there is no support for owner.
  65. * @padcfglock_offset: Register offset of PADCFGLOCK from @regs. If %0 then
  66. * locking is not supported.
  67. * @hostown_offset: Register offset of HOSTSW_OWN from @regs. If %0 then it
  68. * is assumed that the host owns the pin (rather than
  69. * ACPI).
  70. * @is_offset: Register offset of GPI_IS from @regs. If %0 then uses the
  71. * default (%0x100).
  72. * @ie_offset: Register offset of GPI_IE from @regs.
  73. * @pin_base: Starting pin of pins in this community
  74. * @gpp_size: Maximum number of pads in each group, such as PADCFGLOCK,
  75. * HOSTSW_OWN, GPI_IS, GPI_IE, etc. Used when @gpps is %NULL.
  76. * @gpp_num_padown_regs: Number of pad registers each pad group consumes at
  77. * minimum. Use %0 if the number of registers can be
  78. * determined by the size of the group.
  79. * @npins: Number of pins in this community
  80. * @features: Additional features supported by the hardware
  81. * @gpps: Pad groups if the controller has variable size pad groups
  82. * @ngpps: Number of pad groups in this community
  83. * @regs: Community specific common registers (reserved for core driver)
  84. * @pad_regs: Community specific pad registers (reserved for core driver)
  85. *
  86. * Most Intel GPIO host controllers this driver supports each pad group is
  87. * of equal size (except the last one). In that case the driver can just
  88. * fill in @gpp_size field and let the core driver to handle the rest. If
  89. * the controller has pad groups of variable size the client driver can
  90. * pass custom @gpps and @ngpps instead.
  91. */
  92. struct intel_community {
  93. unsigned barno;
  94. unsigned padown_offset;
  95. unsigned padcfglock_offset;
  96. unsigned hostown_offset;
  97. unsigned is_offset;
  98. unsigned ie_offset;
  99. unsigned pin_base;
  100. unsigned gpp_size;
  101. unsigned gpp_num_padown_regs;
  102. size_t npins;
  103. unsigned features;
  104. const struct intel_padgroup *gpps;
  105. size_t ngpps;
  106. /* Reserved for the core driver */
  107. void __iomem *regs;
  108. void __iomem *pad_regs;
  109. };
  110. /* Additional features supported by the hardware */
  111. #define PINCTRL_FEATURE_DEBOUNCE BIT(0)
  112. #define PINCTRL_FEATURE_1K_PD BIT(1)
  113. /**
  114. * PIN_GROUP - Declare a pin group
  115. * @n: Name of the group
  116. * @p: An array of pins this group consists
  117. * @m: Mode which the pins are put when this group is active. Can be either
  118. * a single integer or an array of integers in which case mode is per
  119. * pin.
  120. */
  121. #define PIN_GROUP(n, p, m) \
  122. { \
  123. .name = (n), \
  124. .pins = (p), \
  125. .npins = ARRAY_SIZE((p)), \
  126. .mode = __builtin_choose_expr( \
  127. __builtin_constant_p((m)), (m), 0), \
  128. .modes = __builtin_choose_expr( \
  129. __builtin_constant_p((m)), NULL, (m)), \
  130. }
  131. #define FUNCTION(n, g) \
  132. { \
  133. .name = (n), \
  134. .groups = (g), \
  135. .ngroups = ARRAY_SIZE((g)), \
  136. }
  137. /**
  138. * struct intel_pinctrl_soc_data - Intel pin controller per-SoC configuration
  139. * @uid: ACPI _UID for the probe driver use if needed
  140. * @pins: Array if pins this pinctrl controls
  141. * @npins: Number of pins in the array
  142. * @groups: Array of pin groups
  143. * @ngroups: Number of groups in the array
  144. * @functions: Array of functions
  145. * @nfunctions: Number of functions in the array
  146. * @communities: Array of communities this pinctrl handles
  147. * @ncommunities: Number of communities in the array
  148. *
  149. * The @communities is used as a template by the core driver. It will make
  150. * copy of all communities and fill in rest of the information.
  151. */
  152. struct intel_pinctrl_soc_data {
  153. const char *uid;
  154. const struct pinctrl_pin_desc *pins;
  155. size_t npins;
  156. const struct intel_pingroup *groups;
  157. size_t ngroups;
  158. const struct intel_function *functions;
  159. size_t nfunctions;
  160. const struct intel_community *communities;
  161. size_t ncommunities;
  162. };
  163. int intel_pinctrl_probe(struct platform_device *pdev,
  164. const struct intel_pinctrl_soc_data *soc_data);
  165. #ifdef CONFIG_PM_SLEEP
  166. int intel_pinctrl_suspend(struct device *dev);
  167. int intel_pinctrl_resume(struct device *dev);
  168. #endif
  169. #endif /* PINCTRL_INTEL_H */