pinctrl-abx500.h 5.9 KB

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