pinctrl-abx500.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef PINCTRL_PINCTRL_ABx500_H
  3. #define PINCTRL_PINCTRL_ABx500_H
  4. #include <linux/types.h>
  5. struct pinctrl_pin_desc;
  6. /* Package definitions */
  7. #define PINCTRL_AB8500 0
  8. #define PINCTRL_AB8505 1
  9. /* pins alternate function */
  10. enum abx500_pin_func {
  11. ABX500_DEFAULT,
  12. ABX500_ALT_A,
  13. ABX500_ALT_B,
  14. ABX500_ALT_C,
  15. };
  16. enum abx500_gpio_pull_updown {
  17. ABX500_GPIO_PULL_DOWN = 0x0,
  18. ABX500_GPIO_PULL_NONE = 0x1,
  19. ABX500_GPIO_PULL_UP = 0x3,
  20. };
  21. enum abx500_gpio_vinsel {
  22. ABX500_GPIO_VINSEL_VBAT = 0x0,
  23. ABX500_GPIO_VINSEL_VIN_1V8 = 0x1,
  24. ABX500_GPIO_VINSEL_VDD_BIF = 0x2,
  25. };
  26. /**
  27. * struct abx500_function - ABx500 pinctrl mux function
  28. * @name: The name of the function, exported to pinctrl core.
  29. * @groups: An array of pin groups that may select this function.
  30. * @ngroups: The number of entries in @groups.
  31. */
  32. struct abx500_function {
  33. const char *name;
  34. const char * const *groups;
  35. unsigned ngroups;
  36. };
  37. /**
  38. * struct abx500_pingroup - describes a ABx500 pin group
  39. * @name: the name of this specific pin group
  40. * @pins: an array of discrete physical pins used in this group, taken
  41. * from the driver-local pin enumeration space
  42. * @num_pins: the number of pins in this group array, i.e. the number of
  43. * elements in .pins so we can iterate over that array
  44. * @altsetting: the altsetting to apply to all pins in this group to
  45. * configure them to be used by a function
  46. */
  47. struct abx500_pingroup {
  48. const char *name;
  49. const unsigned int *pins;
  50. const unsigned npins;
  51. int altsetting;
  52. };
  53. #define ALTERNATE_FUNCTIONS(pin, sel_bit, alt1, alt2, alta, altb, altc) \
  54. { \
  55. .pin_number = pin, \
  56. .gpiosel_bit = sel_bit, \
  57. .alt_bit1 = alt1, \
  58. .alt_bit2 = alt2, \
  59. .alta_val = alta, \
  60. .altb_val = altb, \
  61. .altc_val = altc, \
  62. }
  63. #define UNUSED -1
  64. /**
  65. * struct alternate_functions
  66. * @pin_number: The pin number
  67. * @gpiosel_bit: Control bit in GPIOSEL register,
  68. * @alt_bit1: First AlternateFunction bit used to select the
  69. * alternate function
  70. * @alt_bit2: Second AlternateFunction bit used to select the
  71. * alternate function
  72. *
  73. * these 3 following fields are necessary due to none
  74. * coherency on how to select the altA, altB and altC
  75. * function between the ABx500 SOC family when using
  76. * alternatfunc register.
  77. * @alta_val: value to write in alternatfunc to select altA function
  78. * @altb_val: value to write in alternatfunc to select altB function
  79. * @altc_val: value to write in alternatfunc to select altC function
  80. */
  81. struct alternate_functions {
  82. unsigned pin_number;
  83. s8 gpiosel_bit;
  84. s8 alt_bit1;
  85. s8 alt_bit2;
  86. u8 alta_val;
  87. u8 altb_val;
  88. u8 altc_val;
  89. };
  90. #define GPIO_IRQ_CLUSTER(a, b, c) \
  91. { \
  92. .start = a, \
  93. .end = b, \
  94. .to_irq = c, \
  95. }
  96. /**
  97. * struct abx500_gpio_irq_cluster - indicates GPIOs which are interrupt
  98. * capable
  99. * @start: The pin number of the first pin interrupt capable
  100. * @end: The pin number of the last pin interrupt capable
  101. * @to_irq: The ABx500 GPIO's associated IRQs are clustered
  102. * together throughout the interrupt numbers at irregular
  103. * intervals. To solve this quandary, we will place the
  104. * read-in values into the cluster information table
  105. */
  106. struct abx500_gpio_irq_cluster {
  107. int start;
  108. int end;
  109. int to_irq;
  110. };
  111. /**
  112. * struct abx500_pinrange - map pin numbers to GPIO offsets
  113. * @offset: offset into the GPIO local numberspace, incidentally
  114. * identical to the offset into the local pin numberspace
  115. * @npins: number of pins to map from both offsets
  116. * @altfunc: altfunc setting to be used to enable GPIO on a pin in
  117. * this range (may vary)
  118. */
  119. struct abx500_pinrange {
  120. unsigned int offset;
  121. unsigned int npins;
  122. int altfunc;
  123. };
  124. #define ABX500_PINRANGE(a, b, c) { .offset = a, .npins = b, .altfunc = c }
  125. /**
  126. * struct abx500_pinctrl_soc_data - ABx500 pin controller per-SoC configuration
  127. * @gpio_ranges: An array of GPIO ranges for this SoC
  128. * @gpio_num_ranges: The number of GPIO ranges for this SoC
  129. * @pins: An array describing all pins the pin controller affects.
  130. * All pins which are also GPIOs must be listed first within the
  131. * array, and be numbered identically to the GPIO controller's
  132. * numbering.
  133. * @npins: The number of entries in @pins.
  134. * @functions: The functions supported on this SoC.
  135. * @nfunction: The number of entries in @functions.
  136. * @groups: An array describing all pin groups the pin SoC supports.
  137. * @ngroups: The number of entries in @groups.
  138. * @alternate_functions: array describing pins which supports alternate and
  139. * how to set it.
  140. * @gpio_irq_cluster: An array of GPIO interrupt capable for this SoC
  141. * @ngpio_irq_cluster: The number of GPIO inetrrupt capable for this SoC
  142. * @irq_gpio_rising_offset: Interrupt offset used as base to compute specific
  143. * setting strategy of the rising interrupt line
  144. * @irq_gpio_falling_offset: Interrupt offset used as base to compute specific
  145. * setting strategy of the falling interrupt line
  146. * @irq_gpio_factor: Factor used to compute specific setting strategy of
  147. * the interrupt line
  148. */
  149. struct abx500_pinctrl_soc_data {
  150. const struct abx500_pinrange *gpio_ranges;
  151. unsigned gpio_num_ranges;
  152. const struct pinctrl_pin_desc *pins;
  153. unsigned npins;
  154. const struct abx500_function *functions;
  155. unsigned nfunctions;
  156. const struct abx500_pingroup *groups;
  157. unsigned ngroups;
  158. struct alternate_functions *alternate_functions;
  159. struct abx500_gpio_irq_cluster *gpio_irq_cluster;
  160. unsigned ngpio_irq_cluster;
  161. int irq_gpio_rising_offset;
  162. int irq_gpio_falling_offset;
  163. int irq_gpio_factor;
  164. };
  165. #ifdef CONFIG_PINCTRL_AB8500
  166. void abx500_pinctrl_ab8500_init(struct abx500_pinctrl_soc_data **soc);
  167. #else
  168. static inline void
  169. abx500_pinctrl_ab8500_init(struct abx500_pinctrl_soc_data **soc)
  170. {
  171. }
  172. #endif
  173. #ifdef CONFIG_PINCTRL_AB8505
  174. void abx500_pinctrl_ab8505_init(struct abx500_pinctrl_soc_data **soc);
  175. #else
  176. static inline void
  177. abx500_pinctrl_ab8505_init(struct abx500_pinctrl_soc_data **soc)
  178. {
  179. }
  180. #endif
  181. #endif /* PINCTRL_PINCTRL_ABx500_H */