pinctrl-nomadik.h 4.7 KB

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