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