pinctrl-abx500.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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_AB8540 1
  7. #define PINCTRL_AB9540 2
  8. #define PINCTRL_AB8505 3
  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. /**
  91. * struct pullud - specific pull up/down feature
  92. * @first_pin: The pin number of the first pins which support
  93. * specific pull up/down
  94. * @last_pin: The pin number of the last pins
  95. */
  96. struct pullud {
  97. unsigned first_pin;
  98. unsigned last_pin;
  99. };
  100. #define GPIO_IRQ_CLUSTER(a, b, c) \
  101. { \
  102. .start = a, \
  103. .end = b, \
  104. .to_irq = c, \
  105. }
  106. /**
  107. * struct abx500_gpio_irq_cluster - indicates GPIOs which are interrupt
  108. * capable
  109. * @start: The pin number of the first pin interrupt capable
  110. * @end: The pin number of the last pin interrupt capable
  111. * @to_irq: The ABx500 GPIO's associated IRQs are clustered
  112. * together throughout the interrupt numbers at irregular
  113. * intervals. To solve this quandary, we will place the
  114. * read-in values into the cluster information table
  115. */
  116. struct abx500_gpio_irq_cluster {
  117. int start;
  118. int end;
  119. int to_irq;
  120. };
  121. /**
  122. * struct abx500_pinrange - map pin numbers to GPIO offsets
  123. * @offset: offset into the GPIO local numberspace, incidentally
  124. * identical to the offset into the local pin numberspace
  125. * @npins: number of pins to map from both offsets
  126. * @altfunc: altfunc setting to be used to enable GPIO on a pin in
  127. * this range (may vary)
  128. */
  129. struct abx500_pinrange {
  130. unsigned int offset;
  131. unsigned int npins;
  132. int altfunc;
  133. };
  134. #define ABX500_PINRANGE(a, b, c) { .offset = a, .npins = b, .altfunc = c }
  135. /**
  136. * struct abx500_pinctrl_soc_data - ABx500 pin controller per-SoC configuration
  137. * @gpio_ranges: An array of GPIO ranges for this SoC
  138. * @gpio_num_ranges: The number of GPIO ranges for this SoC
  139. * @pins: An array describing all pins the pin controller affects.
  140. * All pins which are also GPIOs must be listed first within the
  141. * array, and be numbered identically to the GPIO controller's
  142. * numbering.
  143. * @npins: The number of entries in @pins.
  144. * @functions: The functions supported on this SoC.
  145. * @nfunction: The number of entries in @functions.
  146. * @groups: An array describing all pin groups the pin SoC supports.
  147. * @ngroups: The number of entries in @groups.
  148. * @alternate_functions: array describing pins which supports alternate and
  149. * how to set it.
  150. * @pullud: array describing pins which supports pull up/down
  151. * specific registers.
  152. * @gpio_irq_cluster: An array of GPIO interrupt capable for this SoC
  153. * @ngpio_irq_cluster: The number of GPIO inetrrupt capable for this SoC
  154. * @irq_gpio_rising_offset: Interrupt offset used as base to compute specific
  155. * setting strategy of the rising interrupt line
  156. * @irq_gpio_falling_offset: Interrupt offset used as base to compute specific
  157. * setting strategy of the falling interrupt line
  158. * @irq_gpio_factor: Factor used to compute specific setting strategy of
  159. * the interrupt line
  160. */
  161. struct abx500_pinctrl_soc_data {
  162. const struct abx500_pinrange *gpio_ranges;
  163. unsigned gpio_num_ranges;
  164. const struct pinctrl_pin_desc *pins;
  165. unsigned npins;
  166. const struct abx500_function *functions;
  167. unsigned nfunctions;
  168. const struct abx500_pingroup *groups;
  169. unsigned ngroups;
  170. struct alternate_functions *alternate_functions;
  171. struct pullud *pullud;
  172. struct abx500_gpio_irq_cluster *gpio_irq_cluster;
  173. unsigned ngpio_irq_cluster;
  174. int irq_gpio_rising_offset;
  175. int irq_gpio_falling_offset;
  176. int irq_gpio_factor;
  177. };
  178. #ifdef CONFIG_PINCTRL_AB8500
  179. void abx500_pinctrl_ab8500_init(struct abx500_pinctrl_soc_data **soc);
  180. #else
  181. static inline void
  182. abx500_pinctrl_ab8500_init(struct abx500_pinctrl_soc_data **soc)
  183. {
  184. }
  185. #endif
  186. #ifdef CONFIG_PINCTRL_AB8540
  187. void abx500_pinctrl_ab8540_init(struct abx500_pinctrl_soc_data **soc);
  188. #else
  189. static inline void
  190. abx500_pinctrl_ab8540_init(struct abx500_pinctrl_soc_data **soc)
  191. {
  192. }
  193. #endif
  194. #ifdef CONFIG_PINCTRL_AB9540
  195. void abx500_pinctrl_ab9540_init(struct abx500_pinctrl_soc_data **soc);
  196. #else
  197. static inline void
  198. abx500_pinctrl_ab9540_init(struct abx500_pinctrl_soc_data **soc)
  199. {
  200. }
  201. #endif
  202. #ifdef CONFIG_PINCTRL_AB8505
  203. void abx500_pinctrl_ab8505_init(struct abx500_pinctrl_soc_data **soc);
  204. #else
  205. static inline void
  206. abx500_pinctrl_ab8505_init(struct abx500_pinctrl_soc_data **soc)
  207. {
  208. }
  209. #endif
  210. #endif /* PINCTRL_PINCTRL_ABx500_H */