pinctrl-intel.h 6.1 KB

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