pinctrl-nomadik.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef PINCTRL_PINCTRL_NOMADIK_H
  3. #define PINCTRL_PINCTRL_NOMADIK_H
  4. /* Package definitions */
  5. #define PINCTRL_NMK_STN8815 0
  6. #define PINCTRL_NMK_DB8500 1
  7. #define PINCTRL_NMK_DB8540 2
  8. /* Alternate functions: function C is set in hw by setting both A and B */
  9. #define NMK_GPIO_ALT_GPIO 0
  10. #define NMK_GPIO_ALT_A 1
  11. #define NMK_GPIO_ALT_B 2
  12. #define NMK_GPIO_ALT_C (NMK_GPIO_ALT_A | NMK_GPIO_ALT_B)
  13. #define NMK_GPIO_ALT_CX_SHIFT 2
  14. #define NMK_GPIO_ALT_C1 ((1<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
  15. #define NMK_GPIO_ALT_C2 ((2<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
  16. #define NMK_GPIO_ALT_C3 ((3<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
  17. #define NMK_GPIO_ALT_C4 ((4<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
  18. #define PRCM_GPIOCR_ALTCX(pin_num,\
  19. altc1_used, altc1_ri, altc1_cb,\
  20. altc2_used, altc2_ri, altc2_cb,\
  21. altc3_used, altc3_ri, altc3_cb,\
  22. altc4_used, altc4_ri, altc4_cb)\
  23. {\
  24. .pin = pin_num,\
  25. .altcx[PRCM_IDX_GPIOCR_ALTC1] = {\
  26. .used = altc1_used,\
  27. .reg_index = altc1_ri,\
  28. .control_bit = altc1_cb\
  29. },\
  30. .altcx[PRCM_IDX_GPIOCR_ALTC2] = {\
  31. .used = altc2_used,\
  32. .reg_index = altc2_ri,\
  33. .control_bit = altc2_cb\
  34. },\
  35. .altcx[PRCM_IDX_GPIOCR_ALTC3] = {\
  36. .used = altc3_used,\
  37. .reg_index = altc3_ri,\
  38. .control_bit = altc3_cb\
  39. },\
  40. .altcx[PRCM_IDX_GPIOCR_ALTC4] = {\
  41. .used = altc4_used,\
  42. .reg_index = altc4_ri,\
  43. .control_bit = altc4_cb\
  44. },\
  45. }
  46. /**
  47. * enum prcm_gpiocr_reg_index
  48. * Used to reference an PRCM GPIOCR register address.
  49. */
  50. enum prcm_gpiocr_reg_index {
  51. PRCM_IDX_GPIOCR1,
  52. PRCM_IDX_GPIOCR2,
  53. PRCM_IDX_GPIOCR3
  54. };
  55. /**
  56. * enum prcm_gpiocr_altcx_index
  57. * Used to reference an Other alternate-C function.
  58. */
  59. enum prcm_gpiocr_altcx_index {
  60. PRCM_IDX_GPIOCR_ALTC1,
  61. PRCM_IDX_GPIOCR_ALTC2,
  62. PRCM_IDX_GPIOCR_ALTC3,
  63. PRCM_IDX_GPIOCR_ALTC4,
  64. PRCM_IDX_GPIOCR_ALTC_MAX,
  65. };
  66. /**
  67. * struct prcm_gpio_altcx - Other alternate-C function
  68. * @used: other alternate-C function availability
  69. * @reg_index: PRCM GPIOCR register index used to control the function
  70. * @control_bit: PRCM GPIOCR bit used to control the function
  71. */
  72. struct prcm_gpiocr_altcx {
  73. bool used:1;
  74. u8 reg_index:2;
  75. u8 control_bit:5;
  76. } __packed;
  77. /**
  78. * struct prcm_gpio_altcx_pin_desc - Other alternate-C pin
  79. * @pin: The pin number
  80. * @altcx: array of other alternate-C[1-4] functions
  81. */
  82. struct prcm_gpiocr_altcx_pin_desc {
  83. unsigned short pin;
  84. struct prcm_gpiocr_altcx altcx[PRCM_IDX_GPIOCR_ALTC_MAX];
  85. };
  86. /**
  87. * struct nmk_function - Nomadik pinctrl mux function
  88. * @name: The name of the function, exported to pinctrl core.
  89. * @groups: An array of pin groups that may select this function.
  90. * @ngroups: The number of entries in @groups.
  91. */
  92. struct nmk_function {
  93. const char *name;
  94. const char * const *groups;
  95. unsigned ngroups;
  96. };
  97. /**
  98. * struct nmk_pingroup - describes a Nomadik pin group
  99. * @name: the name of this specific pin group
  100. * @pins: an array of discrete physical pins used in this group, taken
  101. * from the driver-local pin enumeration space
  102. * @num_pins: the number of pins in this group array, i.e. the number of
  103. * elements in .pins so we can iterate over that array
  104. * @altsetting: the altsetting to apply to all pins in this group to
  105. * configure them to be used by a function
  106. */
  107. struct nmk_pingroup {
  108. const char *name;
  109. const unsigned int *pins;
  110. const unsigned npins;
  111. int altsetting;
  112. };
  113. /**
  114. * struct nmk_pinctrl_soc_data - Nomadik pin controller per-SoC configuration
  115. * @pins: An array describing all pins the pin controller affects.
  116. * All pins which are also GPIOs must be listed first within the
  117. * array, and be numbered identically to the GPIO controller's
  118. * numbering.
  119. * @npins: The number of entries in @pins.
  120. * @functions: The functions supported on this SoC.
  121. * @nfunction: The number of entries in @functions.
  122. * @groups: An array describing all pin groups the pin SoC supports.
  123. * @ngroups: The number of entries in @groups.
  124. * @altcx_pins: The pins that support Other alternate-C function on this SoC
  125. * @npins_altcx: The number of Other alternate-C pins
  126. * @prcm_gpiocr_registers: The array of PRCM GPIOCR registers on this SoC
  127. */
  128. struct nmk_pinctrl_soc_data {
  129. const struct pinctrl_pin_desc *pins;
  130. unsigned npins;
  131. const struct nmk_function *functions;
  132. unsigned nfunctions;
  133. const struct nmk_pingroup *groups;
  134. unsigned ngroups;
  135. const struct prcm_gpiocr_altcx_pin_desc *altcx_pins;
  136. unsigned npins_altcx;
  137. const u16 *prcm_gpiocr_registers;
  138. };
  139. #ifdef CONFIG_PINCTRL_STN8815
  140. void nmk_pinctrl_stn8815_init(const struct nmk_pinctrl_soc_data **soc);
  141. #else
  142. static inline void
  143. nmk_pinctrl_stn8815_init(const struct nmk_pinctrl_soc_data **soc)
  144. {
  145. }
  146. #endif
  147. #ifdef CONFIG_PINCTRL_DB8500
  148. void nmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data **soc);
  149. #else
  150. static inline void
  151. nmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data **soc)
  152. {
  153. }
  154. #endif
  155. #ifdef CONFIG_PINCTRL_DB8540
  156. void nmk_pinctrl_db8540_init(const struct nmk_pinctrl_soc_data **soc);
  157. #else
  158. static inline void
  159. nmk_pinctrl_db8540_init(const struct nmk_pinctrl_soc_data **soc)
  160. {
  161. }
  162. #endif
  163. #endif /* PINCTRL_PINCTRL_NOMADIK_H */