pinctrl-abx500.h 6.4 KB

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