pinctrl-sc8280xp-lpass-lpi.c 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2022 Linaro Ltd.
  4. */
  5. #include <linux/gpio/driver.h>
  6. #include <linux/module.h>
  7. #include <linux/platform_device.h>
  8. #include "pinctrl-lpass-lpi.h"
  9. enum lpass_lpi_functions {
  10. LPI_MUX_dmic1_clk,
  11. LPI_MUX_dmic1_data,
  12. LPI_MUX_dmic2_clk,
  13. LPI_MUX_dmic2_data,
  14. LPI_MUX_dmic3_clk,
  15. LPI_MUX_dmic3_data,
  16. LPI_MUX_dmic4_clk,
  17. LPI_MUX_dmic4_data,
  18. LPI_MUX_i2s1_clk,
  19. LPI_MUX_i2s1_data,
  20. LPI_MUX_i2s1_ws,
  21. LPI_MUX_i2s2_clk,
  22. LPI_MUX_i2s2_data,
  23. LPI_MUX_i2s2_ws,
  24. LPI_MUX_i2s3_clk,
  25. LPI_MUX_i2s3_data,
  26. LPI_MUX_i2s3_ws,
  27. LPI_MUX_qua_mi2s_data,
  28. LPI_MUX_qua_mi2s_sclk,
  29. LPI_MUX_qua_mi2s_ws,
  30. LPI_MUX_swr_rx_clk,
  31. LPI_MUX_swr_rx_data,
  32. LPI_MUX_swr_tx_clk,
  33. LPI_MUX_swr_tx_data,
  34. LPI_MUX_wsa_swr_clk,
  35. LPI_MUX_wsa_swr_data,
  36. LPI_MUX_wsa2_swr_clk,
  37. LPI_MUX_wsa2_swr_data,
  38. LPI_MUX_ext_mclk1_a,
  39. LPI_MUX_ext_mclk1_b,
  40. LPI_MUX_ext_mclk1_c,
  41. LPI_MUX_gpio,
  42. LPI_MUX__,
  43. };
  44. static int gpio0_pins[] = { 0 };
  45. static int gpio1_pins[] = { 1 };
  46. static int gpio2_pins[] = { 2 };
  47. static int gpio3_pins[] = { 3 };
  48. static int gpio4_pins[] = { 4 };
  49. static int gpio5_pins[] = { 5 };
  50. static int gpio6_pins[] = { 6 };
  51. static int gpio7_pins[] = { 7 };
  52. static int gpio8_pins[] = { 8 };
  53. static int gpio9_pins[] = { 9 };
  54. static int gpio10_pins[] = { 10 };
  55. static int gpio11_pins[] = { 11 };
  56. static int gpio12_pins[] = { 12 };
  57. static int gpio13_pins[] = { 13 };
  58. static int gpio14_pins[] = { 14 };
  59. static int gpio15_pins[] = { 15 };
  60. static int gpio16_pins[] = { 16 };
  61. static int gpio17_pins[] = { 17 };
  62. static int gpio18_pins[] = { 18 };
  63. static const struct pinctrl_pin_desc sc8280xp_lpi_pins[] = {
  64. PINCTRL_PIN(0, "gpio0"),
  65. PINCTRL_PIN(1, "gpio1"),
  66. PINCTRL_PIN(2, "gpio2"),
  67. PINCTRL_PIN(3, "gpio3"),
  68. PINCTRL_PIN(4, "gpio4"),
  69. PINCTRL_PIN(5, "gpio5"),
  70. PINCTRL_PIN(6, "gpio6"),
  71. PINCTRL_PIN(7, "gpio7"),
  72. PINCTRL_PIN(8, "gpio8"),
  73. PINCTRL_PIN(9, "gpio9"),
  74. PINCTRL_PIN(10, "gpio10"),
  75. PINCTRL_PIN(11, "gpio11"),
  76. PINCTRL_PIN(12, "gpio12"),
  77. PINCTRL_PIN(13, "gpio13"),
  78. PINCTRL_PIN(14, "gpio14"),
  79. PINCTRL_PIN(15, "gpio15"),
  80. PINCTRL_PIN(16, "gpio16"),
  81. PINCTRL_PIN(17, "gpio17"),
  82. PINCTRL_PIN(18, "gpio18"),
  83. };
  84. static const char * const swr_tx_clk_groups[] = { "gpio0" };
  85. static const char * const swr_tx_data_groups[] = { "gpio1", "gpio2", "gpio14" };
  86. static const char * const swr_rx_clk_groups[] = { "gpio3" };
  87. static const char * const swr_rx_data_groups[] = { "gpio4", "gpio5" };
  88. static const char * const dmic1_clk_groups[] = { "gpio6" };
  89. static const char * const dmic1_data_groups[] = { "gpio7" };
  90. static const char * const dmic2_clk_groups[] = { "gpio8" };
  91. static const char * const dmic2_data_groups[] = { "gpio9" };
  92. static const char * const dmic4_clk_groups[] = { "gpio17" };
  93. static const char * const dmic4_data_groups[] = { "gpio18" };
  94. static const char * const i2s2_clk_groups[] = { "gpio10" };
  95. static const char * const i2s2_ws_groups[] = { "gpio11" };
  96. static const char * const dmic3_clk_groups[] = { "gpio12" };
  97. static const char * const dmic3_data_groups[] = { "gpio13" };
  98. static const char * const qua_mi2s_sclk_groups[] = { "gpio0" };
  99. static const char * const qua_mi2s_ws_groups[] = { "gpio1" };
  100. static const char * const qua_mi2s_data_groups[] = { "gpio2", "gpio3", "gpio4", "gpio5" };
  101. static const char * const i2s1_clk_groups[] = { "gpio6" };
  102. static const char * const i2s1_ws_groups[] = { "gpio7" };
  103. static const char * const i2s1_data_groups[] = { "gpio8", "gpio9" };
  104. static const char * const wsa_swr_clk_groups[] = { "gpio10" };
  105. static const char * const wsa_swr_data_groups[] = { "gpio11" };
  106. static const char * const wsa2_swr_clk_groups[] = { "gpio15" };
  107. static const char * const wsa2_swr_data_groups[] = { "gpio16" };
  108. static const char * const i2s2_data_groups[] = { "gpio15", "gpio16" };
  109. static const char * const i2s3_clk_groups[] = { "gpio12"};
  110. static const char * const i2s3_ws_groups[] = { "gpio13"};
  111. static const char * const i2s3_data_groups[] = { "gpio17", "gpio18"};
  112. static const char * const ext_mclk1_c_groups[] = { "gpio5" };
  113. static const char * const ext_mclk1_b_groups[] = { "gpio9" };
  114. static const char * const ext_mclk1_a_groups[] = { "gpio13" };
  115. static const struct lpi_pingroup sc8280xp_groups[] = {
  116. LPI_PINGROUP(0, 0, swr_tx_clk, qua_mi2s_sclk, _, _),
  117. LPI_PINGROUP(1, 2, swr_tx_data, qua_mi2s_ws, _, _),
  118. LPI_PINGROUP(2, 4, swr_tx_data, qua_mi2s_data, _, _),
  119. LPI_PINGROUP(3, 8, swr_rx_clk, qua_mi2s_data, _, _),
  120. LPI_PINGROUP(4, 10, swr_rx_data, qua_mi2s_data, _, _),
  121. LPI_PINGROUP(5, 12, swr_rx_data, ext_mclk1_c, qua_mi2s_data, _),
  122. LPI_PINGROUP(6, LPI_NO_SLEW, dmic1_clk, i2s1_clk, _, _),
  123. LPI_PINGROUP(7, LPI_NO_SLEW, dmic1_data, i2s1_ws, _, _),
  124. LPI_PINGROUP(8, LPI_NO_SLEW, dmic2_clk, i2s1_data, _, _),
  125. LPI_PINGROUP(9, LPI_NO_SLEW, dmic2_data, i2s1_data, ext_mclk1_b, _),
  126. LPI_PINGROUP(10, 16, i2s2_clk, wsa_swr_clk, _, _),
  127. LPI_PINGROUP(11, 18, i2s2_ws, wsa_swr_data, _, _),
  128. LPI_PINGROUP(12, LPI_NO_SLEW, dmic3_clk, i2s3_clk, _, _),
  129. LPI_PINGROUP(13, LPI_NO_SLEW, dmic3_data, i2s3_ws, ext_mclk1_a, _),
  130. LPI_PINGROUP(14, 6, swr_tx_data, _, _, _),
  131. LPI_PINGROUP(15, 20, i2s2_data, wsa2_swr_clk, _, _),
  132. LPI_PINGROUP(16, 22, i2s2_data, wsa2_swr_data, _, _),
  133. LPI_PINGROUP(17, LPI_NO_SLEW, dmic4_clk, i2s3_data, _, _),
  134. LPI_PINGROUP(18, LPI_NO_SLEW, dmic4_data, i2s3_data, _, _),
  135. };
  136. static const struct lpi_function sc8280xp_functions[] = {
  137. LPI_FUNCTION(dmic1_clk),
  138. LPI_FUNCTION(dmic1_data),
  139. LPI_FUNCTION(dmic2_clk),
  140. LPI_FUNCTION(dmic2_data),
  141. LPI_FUNCTION(dmic3_clk),
  142. LPI_FUNCTION(dmic3_data),
  143. LPI_FUNCTION(dmic4_clk),
  144. LPI_FUNCTION(dmic4_data),
  145. LPI_FUNCTION(i2s1_clk),
  146. LPI_FUNCTION(i2s1_data),
  147. LPI_FUNCTION(i2s1_ws),
  148. LPI_FUNCTION(i2s2_clk),
  149. LPI_FUNCTION(i2s2_data),
  150. LPI_FUNCTION(i2s2_ws),
  151. LPI_FUNCTION(i2s3_clk),
  152. LPI_FUNCTION(i2s3_data),
  153. LPI_FUNCTION(i2s3_ws),
  154. LPI_FUNCTION(qua_mi2s_data),
  155. LPI_FUNCTION(qua_mi2s_sclk),
  156. LPI_FUNCTION(qua_mi2s_ws),
  157. LPI_FUNCTION(swr_rx_clk),
  158. LPI_FUNCTION(swr_rx_data),
  159. LPI_FUNCTION(swr_tx_clk),
  160. LPI_FUNCTION(swr_tx_data),
  161. LPI_FUNCTION(wsa_swr_clk),
  162. LPI_FUNCTION(wsa_swr_data),
  163. LPI_FUNCTION(wsa2_swr_clk),
  164. LPI_FUNCTION(wsa2_swr_data),
  165. LPI_FUNCTION(ext_mclk1_a),
  166. LPI_FUNCTION(ext_mclk1_b),
  167. LPI_FUNCTION(ext_mclk1_c),
  168. };
  169. static const struct lpi_pinctrl_variant_data sc8280xp_lpi_data = {
  170. .pins = sc8280xp_lpi_pins,
  171. .npins = ARRAY_SIZE(sc8280xp_lpi_pins),
  172. .groups = sc8280xp_groups,
  173. .ngroups = ARRAY_SIZE(sc8280xp_groups),
  174. .functions = sc8280xp_functions,
  175. .nfunctions = ARRAY_SIZE(sc8280xp_functions),
  176. };
  177. static const struct of_device_id lpi_pinctrl_of_match[] = {
  178. {
  179. .compatible = "qcom,sc8280xp-lpass-lpi-pinctrl",
  180. .data = &sc8280xp_lpi_data,
  181. },
  182. { }
  183. };
  184. MODULE_DEVICE_TABLE(of, lpi_pinctrl_of_match);
  185. static struct platform_driver lpi_pinctrl_driver = {
  186. .driver = {
  187. .name = "qcom-sc8280xp-lpass-lpi-pinctrl",
  188. .of_match_table = lpi_pinctrl_of_match,
  189. },
  190. .probe = lpi_pinctrl_probe,
  191. .remove = lpi_pinctrl_remove,
  192. };
  193. module_platform_driver(lpi_pinctrl_driver);
  194. MODULE_DESCRIPTION("QTI SC8280XP LPI GPIO pin control driver");
  195. MODULE_LICENSE("GPL");