pinctrl-intel.h 5.7 KB

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