pinctrl-nomadik.h 4.9 KB

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