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