pinctrl-sc7280-lpass-lpi.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
  4. * ALSA SoC platform-machine driver for QTi LPASS
  5. */
  6. #include <linux/gpio/driver.h>
  7. #include <linux/module.h>
  8. #include <linux/platform_device.h>
  9. #include "pinctrl-lpass-lpi.h"
  10. enum lpass_lpi_functions {
  11. LPI_MUX_dmic1_clk,
  12. LPI_MUX_dmic1_data,
  13. LPI_MUX_dmic2_clk,
  14. LPI_MUX_dmic2_data,
  15. LPI_MUX_dmic3_clk,
  16. LPI_MUX_dmic3_data,
  17. LPI_MUX_i2s1_clk,
  18. LPI_MUX_i2s1_data,
  19. LPI_MUX_i2s1_ws,
  20. LPI_MUX_i2s2_clk,
  21. LPI_MUX_i2s2_data,
  22. LPI_MUX_i2s2_ws,
  23. LPI_MUX_qua_mi2s_data,
  24. LPI_MUX_qua_mi2s_sclk,
  25. LPI_MUX_qua_mi2s_ws,
  26. LPI_MUX_swr_rx_clk,
  27. LPI_MUX_swr_rx_data,
  28. LPI_MUX_swr_tx_clk,
  29. LPI_MUX_swr_tx_data,
  30. LPI_MUX_wsa_swr_clk,
  31. LPI_MUX_wsa_swr_data,
  32. LPI_MUX_gpio,
  33. LPI_MUX__,
  34. };
  35. static int gpio0_pins[] = { 0 };
  36. static int gpio1_pins[] = { 1 };
  37. static int gpio2_pins[] = { 2 };
  38. static int gpio3_pins[] = { 3 };
  39. static int gpio4_pins[] = { 4 };
  40. static int gpio5_pins[] = { 5 };
  41. static int gpio6_pins[] = { 6 };
  42. static int gpio7_pins[] = { 7 };
  43. static int gpio8_pins[] = { 8 };
  44. static int gpio9_pins[] = { 9 };
  45. static int gpio10_pins[] = { 10 };
  46. static int gpio11_pins[] = { 11 };
  47. static int gpio12_pins[] = { 12 };
  48. static int gpio13_pins[] = { 13 };
  49. static int gpio14_pins[] = { 14 };
  50. static const struct pinctrl_pin_desc sc7280_lpi_pins[] = {
  51. PINCTRL_PIN(0, "gpio0"),
  52. PINCTRL_PIN(1, "gpio1"),
  53. PINCTRL_PIN(2, "gpio2"),
  54. PINCTRL_PIN(3, "gpio3"),
  55. PINCTRL_PIN(4, "gpio4"),
  56. PINCTRL_PIN(5, "gpio5"),
  57. PINCTRL_PIN(6, "gpio6"),
  58. PINCTRL_PIN(7, "gpio7"),
  59. PINCTRL_PIN(8, "gpio8"),
  60. PINCTRL_PIN(9, "gpio9"),
  61. PINCTRL_PIN(10, "gpio10"),
  62. PINCTRL_PIN(11, "gpio11"),
  63. PINCTRL_PIN(12, "gpio12"),
  64. PINCTRL_PIN(13, "gpio13"),
  65. PINCTRL_PIN(14, "gpio14"),
  66. };
  67. static const char * const swr_tx_clk_groups[] = { "gpio0" };
  68. static const char * const swr_tx_data_groups[] = { "gpio1", "gpio2", "gpio14" };
  69. static const char * const swr_rx_clk_groups[] = { "gpio3" };
  70. static const char * const swr_rx_data_groups[] = { "gpio4", "gpio5" };
  71. static const char * const dmic1_clk_groups[] = { "gpio6" };
  72. static const char * const dmic1_data_groups[] = { "gpio7" };
  73. static const char * const dmic2_clk_groups[] = { "gpio8" };
  74. static const char * const dmic2_data_groups[] = { "gpio9" };
  75. static const char * const i2s2_clk_groups[] = { "gpio10" };
  76. static const char * const i2s2_ws_groups[] = { "gpio11" };
  77. static const char * const dmic3_clk_groups[] = { "gpio12" };
  78. static const char * const dmic3_data_groups[] = { "gpio13" };
  79. static const char * const qua_mi2s_sclk_groups[] = { "gpio0" };
  80. static const char * const qua_mi2s_ws_groups[] = { "gpio1" };
  81. static const char * const qua_mi2s_data_groups[] = { "gpio2", "gpio3", "gpio4" };
  82. static const char * const i2s1_clk_groups[] = { "gpio6" };
  83. static const char * const i2s1_ws_groups[] = { "gpio7" };
  84. static const char * const i2s1_data_groups[] = { "gpio8", "gpio9" };
  85. static const char * const wsa_swr_clk_groups[] = { "gpio10" };
  86. static const char * const wsa_swr_data_groups[] = { "gpio11" };
  87. static const char * const i2s2_data_groups[] = { "gpio12", "gpio13" };
  88. static const struct lpi_pingroup sc7280_groups[] = {
  89. LPI_PINGROUP(0, 0, swr_tx_clk, qua_mi2s_sclk, _, _),
  90. LPI_PINGROUP(1, 2, swr_tx_data, qua_mi2s_ws, _, _),
  91. LPI_PINGROUP(2, 4, swr_tx_data, qua_mi2s_data, _, _),
  92. LPI_PINGROUP(3, 8, swr_rx_clk, qua_mi2s_data, _, _),
  93. LPI_PINGROUP(4, 10, swr_rx_data, qua_mi2s_data, _, _),
  94. LPI_PINGROUP(5, 12, swr_rx_data, _, _, _),
  95. LPI_PINGROUP(6, LPI_NO_SLEW, dmic1_clk, i2s1_clk, _, _),
  96. LPI_PINGROUP(7, LPI_NO_SLEW, dmic1_data, i2s1_ws, _, _),
  97. LPI_PINGROUP(8, LPI_NO_SLEW, dmic2_clk, i2s1_data, _, _),
  98. LPI_PINGROUP(9, LPI_NO_SLEW, dmic2_data, i2s1_data, _, _),
  99. LPI_PINGROUP(10, 16, i2s2_clk, wsa_swr_clk, _, _),
  100. LPI_PINGROUP(11, 18, i2s2_ws, wsa_swr_data, _, _),
  101. LPI_PINGROUP(12, LPI_NO_SLEW, dmic3_clk, i2s2_data, _, _),
  102. LPI_PINGROUP(13, LPI_NO_SLEW, dmic3_data, i2s2_data, _, _),
  103. LPI_PINGROUP(14, 6, swr_tx_data, _, _, _),
  104. };
  105. static const struct lpi_function sc7280_functions[] = {
  106. LPI_FUNCTION(dmic1_clk),
  107. LPI_FUNCTION(dmic1_data),
  108. LPI_FUNCTION(dmic2_clk),
  109. LPI_FUNCTION(dmic2_data),
  110. LPI_FUNCTION(dmic3_clk),
  111. LPI_FUNCTION(dmic3_data),
  112. LPI_FUNCTION(i2s1_clk),
  113. LPI_FUNCTION(i2s1_data),
  114. LPI_FUNCTION(i2s1_ws),
  115. LPI_FUNCTION(i2s2_clk),
  116. LPI_FUNCTION(i2s2_data),
  117. LPI_FUNCTION(i2s2_ws),
  118. LPI_FUNCTION(qua_mi2s_data),
  119. LPI_FUNCTION(qua_mi2s_sclk),
  120. LPI_FUNCTION(qua_mi2s_ws),
  121. LPI_FUNCTION(swr_rx_clk),
  122. LPI_FUNCTION(swr_rx_data),
  123. LPI_FUNCTION(swr_tx_clk),
  124. LPI_FUNCTION(swr_tx_data),
  125. LPI_FUNCTION(wsa_swr_clk),
  126. LPI_FUNCTION(wsa_swr_data),
  127. };
  128. static const struct lpi_pinctrl_variant_data sc7280_lpi_data = {
  129. .pins = sc7280_lpi_pins,
  130. .npins = ARRAY_SIZE(sc7280_lpi_pins),
  131. .groups = sc7280_groups,
  132. .ngroups = ARRAY_SIZE(sc7280_groups),
  133. .functions = sc7280_functions,
  134. .nfunctions = ARRAY_SIZE(sc7280_functions),
  135. };
  136. static const struct of_device_id lpi_pinctrl_of_match[] = {
  137. {
  138. .compatible = "qcom,sc7280-lpass-lpi-pinctrl",
  139. .data = &sc7280_lpi_data,
  140. },
  141. { }
  142. };
  143. MODULE_DEVICE_TABLE(of, lpi_pinctrl_of_match);
  144. static struct platform_driver lpi_pinctrl_driver = {
  145. .driver = {
  146. .name = "qcom-sc7280-lpass-lpi-pinctrl",
  147. .of_match_table = lpi_pinctrl_of_match,
  148. },
  149. .probe = lpi_pinctrl_probe,
  150. .remove = lpi_pinctrl_remove,
  151. };
  152. module_platform_driver(lpi_pinctrl_driver);
  153. MODULE_DESCRIPTION("QTI SC7280 LPI GPIO pin control driver");
  154. MODULE_LICENSE("GPL");