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