1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
4 * Copyright (c) 2020 Linaro Ltd.
7 #include <linux/gpio/driver.h>
8 #include <linux/module.h>
9 #include <linux/platform_device.h>
11 #include "pinctrl-lpass-lpi.h"
13 enum lpass_lpi_functions {
26 LPI_MUX_qua_mi2s_data,
27 LPI_MUX_qua_mi2s_sclk,
39 static int gpio0_pins[] = { 0 };
40 static int gpio1_pins[] = { 1 };
41 static int gpio2_pins[] = { 2 };
42 static int gpio3_pins[] = { 3 };
43 static int gpio4_pins[] = { 4 };
44 static int gpio5_pins[] = { 5 };
45 static int gpio6_pins[] = { 6 };
46 static int gpio7_pins[] = { 7 };
47 static int gpio8_pins[] = { 8 };
48 static int gpio9_pins[] = { 9 };
49 static int gpio10_pins[] = { 10 };
50 static int gpio11_pins[] = { 11 };
51 static int gpio12_pins[] = { 12 };
52 static int gpio13_pins[] = { 13 };
54 static const struct pinctrl_pin_desc sm8250_lpi_pins[] = {
55 PINCTRL_PIN(0, "gpio0"),
56 PINCTRL_PIN(1, "gpio1"),
57 PINCTRL_PIN(2, "gpio2"),
58 PINCTRL_PIN(3, "gpio3"),
59 PINCTRL_PIN(4, "gpio4"),
60 PINCTRL_PIN(5, "gpio5"),
61 PINCTRL_PIN(6, "gpio6"),
62 PINCTRL_PIN(7, "gpio7"),
63 PINCTRL_PIN(8, "gpio8"),
64 PINCTRL_PIN(9, "gpio9"),
65 PINCTRL_PIN(10, "gpio10"),
66 PINCTRL_PIN(11, "gpio11"),
67 PINCTRL_PIN(12, "gpio12"),
68 PINCTRL_PIN(13, "gpio13"),
71 static const char * const swr_tx_clk_groups[] = { "gpio0" };
72 static const char * const swr_tx_data_groups[] = { "gpio1", "gpio2", "gpio5" };
73 static const char * const swr_rx_clk_groups[] = { "gpio3" };
74 static const char * const swr_rx_data_groups[] = { "gpio4", "gpio5" };
75 static const char * const dmic1_clk_groups[] = { "gpio6" };
76 static const char * const dmic1_data_groups[] = { "gpio7" };
77 static const char * const dmic2_clk_groups[] = { "gpio8" };
78 static const char * const dmic2_data_groups[] = { "gpio9" };
79 static const char * const i2s2_clk_groups[] = { "gpio10" };
80 static const char * const i2s2_ws_groups[] = { "gpio11" };
81 static const char * const dmic3_clk_groups[] = { "gpio12" };
82 static const char * const dmic3_data_groups[] = { "gpio13" };
83 static const char * const qua_mi2s_sclk_groups[] = { "gpio0" };
84 static const char * const qua_mi2s_ws_groups[] = { "gpio1" };
85 static const char * const qua_mi2s_data_groups[] = { "gpio2", "gpio3", "gpio4" };
86 static const char * const i2s1_clk_groups[] = { "gpio6" };
87 static const char * const i2s1_ws_groups[] = { "gpio7" };
88 static const char * const i2s1_data_groups[] = { "gpio8", "gpio9" };
89 static const char * const wsa_swr_clk_groups[] = { "gpio10" };
90 static const char * const wsa_swr_data_groups[] = { "gpio11" };
91 static const char * const i2s2_data_groups[] = { "gpio12", "gpio12" };
93 static const struct lpi_pingroup sm8250_groups[] = {
94 LPI_PINGROUP(0, 0, swr_tx_clk, qua_mi2s_sclk, _, _),
95 LPI_PINGROUP(1, 2, swr_tx_data, qua_mi2s_ws, _, _),
96 LPI_PINGROUP(2, 4, swr_tx_data, qua_mi2s_data, _, _),
97 LPI_PINGROUP(3, 8, swr_rx_clk, qua_mi2s_data, _, _),
98 LPI_PINGROUP(4, 10, swr_rx_data, qua_mi2s_data, _, _),
99 LPI_PINGROUP(5, 12, swr_tx_data, swr_rx_data, _, _),
100 LPI_PINGROUP(6, LPI_NO_SLEW, dmic1_clk, i2s1_clk, _, _),
101 LPI_PINGROUP(7, LPI_NO_SLEW, dmic1_data, i2s1_ws, _, _),
102 LPI_PINGROUP(8, LPI_NO_SLEW, dmic2_clk, i2s1_data, _, _),
103 LPI_PINGROUP(9, LPI_NO_SLEW, dmic2_data, i2s1_data, _, _),
104 LPI_PINGROUP(10, 16, i2s2_clk, wsa_swr_clk, _, _),
105 LPI_PINGROUP(11, 18, i2s2_ws, wsa_swr_data, _, _),
106 LPI_PINGROUP(12, LPI_NO_SLEW, dmic3_clk, i2s2_data, _, _),
107 LPI_PINGROUP(13, LPI_NO_SLEW, dmic3_data, i2s2_data, _, _),
110 static const struct lpi_function sm8250_functions[] = {
111 LPI_FUNCTION(dmic1_clk),
112 LPI_FUNCTION(dmic1_data),
113 LPI_FUNCTION(dmic2_clk),
114 LPI_FUNCTION(dmic2_data),
115 LPI_FUNCTION(dmic3_clk),
116 LPI_FUNCTION(dmic3_data),
117 LPI_FUNCTION(i2s1_clk),
118 LPI_FUNCTION(i2s1_data),
119 LPI_FUNCTION(i2s1_ws),
120 LPI_FUNCTION(i2s2_clk),
121 LPI_FUNCTION(i2s2_data),
122 LPI_FUNCTION(i2s2_ws),
123 LPI_FUNCTION(qua_mi2s_data),
124 LPI_FUNCTION(qua_mi2s_sclk),
125 LPI_FUNCTION(qua_mi2s_ws),
126 LPI_FUNCTION(swr_rx_clk),
127 LPI_FUNCTION(swr_rx_data),
128 LPI_FUNCTION(swr_tx_clk),
129 LPI_FUNCTION(swr_tx_data),
130 LPI_FUNCTION(wsa_swr_clk),
131 LPI_FUNCTION(wsa_swr_data),
134 static const struct lpi_pinctrl_variant_data sm8250_lpi_data = {
135 .pins = sm8250_lpi_pins,
136 .npins = ARRAY_SIZE(sm8250_lpi_pins),
137 .groups = sm8250_groups,
138 .ngroups = ARRAY_SIZE(sm8250_groups),
139 .functions = sm8250_functions,
140 .nfunctions = ARRAY_SIZE(sm8250_functions),
143 static const struct of_device_id lpi_pinctrl_of_match[] = {
145 .compatible = "qcom,sm8250-lpass-lpi-pinctrl",
146 .data = &sm8250_lpi_data,
150 MODULE_DEVICE_TABLE(of, lpi_pinctrl_of_match);
152 static struct platform_driver lpi_pinctrl_driver = {
154 .name = "qcom-sm8250-lpass-lpi-pinctrl",
155 .of_match_table = lpi_pinctrl_of_match,
157 .probe = lpi_pinctrl_probe,
158 .remove = lpi_pinctrl_remove,
161 module_platform_driver(lpi_pinctrl_driver);
162 MODULE_DESCRIPTION("QTI SM8250 LPI GPIO pin control driver");
163 MODULE_LICENSE("GPL");