pinctrl-intel.h 5.9 KB

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