237 lines · c
1// SPDX-License-Identifier: GPL-2.0-only2/*3 * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.4 * Copyright (c) 2020, 2023 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 13enum lpass_lpi_functions {14 LPI_MUX_dmic01_clk,15 LPI_MUX_dmic01_data,16 LPI_MUX_dmic23_clk,17 LPI_MUX_dmic23_data,18 LPI_MUX_dmic4_clk,19 LPI_MUX_dmic4_data,20 LPI_MUX_ext_mclk0_a,21 LPI_MUX_ext_mclk0_b,22 LPI_MUX_ext_mclk1_a,23 LPI_MUX_ext_mclk1_b,24 LPI_MUX_ext_mclk1_c,25 LPI_MUX_i2s1_clk,26 LPI_MUX_i2s1_data,27 LPI_MUX_i2s1_ws,28 LPI_MUX_i2s2_clk,29 LPI_MUX_i2s2_data,30 LPI_MUX_i2s2_ws,31 LPI_MUX_i2s3_clk,32 LPI_MUX_i2s3_data,33 LPI_MUX_i2s3_ws,34 LPI_MUX_qup_io_00,35 LPI_MUX_qup_io_01,36 LPI_MUX_qup_io_05,37 LPI_MUX_qup_io_10,38 LPI_MUX_qup_io_11,39 LPI_MUX_qup_io_25,40 LPI_MUX_qup_io_21,41 LPI_MUX_qup_io_26,42 LPI_MUX_qup_io_31,43 LPI_MUX_qup_io_36,44 LPI_MUX_qua_mi2s_data,45 LPI_MUX_qua_mi2s_sclk,46 LPI_MUX_qua_mi2s_ws,47 LPI_MUX_slim_clk,48 LPI_MUX_slim_data,49 LPI_MUX_sync_out,50 LPI_MUX_swr_rx_clk,51 LPI_MUX_swr_rx_data,52 LPI_MUX_swr_tx_clk,53 LPI_MUX_swr_tx_data,54 LPI_MUX_swr_wsa_clk,55 LPI_MUX_swr_wsa_data,56 LPI_MUX_gpio,57 LPI_MUX__,58};59 60static const struct pinctrl_pin_desc sm4250_lpi_pins[] = {61 PINCTRL_PIN(0, "gpio0"),62 PINCTRL_PIN(1, "gpio1"),63 PINCTRL_PIN(2, "gpio2"),64 PINCTRL_PIN(3, "gpio3"),65 PINCTRL_PIN(4, "gpio4"),66 PINCTRL_PIN(5, "gpio5"),67 PINCTRL_PIN(6, "gpio6"),68 PINCTRL_PIN(7, "gpio7"),69 PINCTRL_PIN(8, "gpio8"),70 PINCTRL_PIN(9, "gpio9"),71 PINCTRL_PIN(10, "gpio10"),72 PINCTRL_PIN(11, "gpio11"),73 PINCTRL_PIN(12, "gpio12"),74 PINCTRL_PIN(13, "gpio13"),75 PINCTRL_PIN(14, "gpio14"),76 PINCTRL_PIN(15, "gpio15"),77 PINCTRL_PIN(16, "gpio16"),78 PINCTRL_PIN(17, "gpio17"),79 PINCTRL_PIN(18, "gpio18"),80 PINCTRL_PIN(19, "gpio19"),81 PINCTRL_PIN(20, "gpio20"),82 PINCTRL_PIN(21, "gpio21"),83 PINCTRL_PIN(22, "gpio22"),84 PINCTRL_PIN(23, "gpio23"),85 PINCTRL_PIN(24, "gpio24"),86 PINCTRL_PIN(25, "gpio25"),87 PINCTRL_PIN(26, "gpio26"),88};89 90static const char * const dmic01_clk_groups[] = { "gpio6" };91static const char * const dmic01_data_groups[] = { "gpio7" };92static const char * const dmic23_clk_groups[] = { "gpio8" };93static const char * const dmic23_data_groups[] = { "gpio9" };94static const char * const dmic4_clk_groups[] = { "gpio10" };95static const char * const dmic4_data_groups[] = { "gpio11" };96static const char * const ext_mclk0_a_groups[] = { "gpio13" };97static const char * const ext_mclk0_b_groups[] = { "gpio5" };98static const char * const ext_mclk1_a_groups[] = { "gpio18" };99static const char * const ext_mclk1_b_groups[] = { "gpio9" };100static const char * const ext_mclk1_c_groups[] = { "gpio17" };101static const char * const slim_clk_groups[] = { "gpio14" };102static const char * const slim_data_groups[] = { "gpio15" };103static const char * const i2s1_clk_groups[] = { "gpio6" };104static const char * const i2s1_data_groups[] = { "gpio8", "gpio9" };105static const char * const i2s1_ws_groups[] = { "gpio7" };106static const char * const i2s2_clk_groups[] = { "gpio10" };107static const char * const i2s2_data_groups[] = { "gpio12", "gpio13" };108static const char * const i2s2_ws_groups[] = { "gpio11" };109static const char * const i2s3_clk_groups[] = { "gpio14" };110static const char * const i2s3_data_groups[] = { "gpio16", "gpio17" };111static const char * const i2s3_ws_groups[] = { "gpio15" };112static const char * const qup_io_00_groups[] = { "gpio19" };113static const char * const qup_io_01_groups[] = { "gpio21" };114static const char * const qup_io_05_groups[] = { "gpio23" };115static const char * const qup_io_10_groups[] = { "gpio20" };116static const char * const qup_io_11_groups[] = { "gpio22" };117static const char * const qup_io_25_groups[] = { "gpio23" };118static const char * const qup_io_21_groups[] = { "gpio25" };119static const char * const qup_io_26_groups[] = { "gpio25" };120static const char * const qup_io_31_groups[] = { "gpio26" };121static const char * const qup_io_36_groups[] = { "gpio26" };122static const char * const qua_mi2s_data_groups[] = { "gpio2", "gpio3", "gpio4", "gpio5" };123static const char * const qua_mi2s_sclk_groups[] = { "gpio0" };124static const char * const qua_mi2s_ws_groups[] = { "gpio1" };125static const char * const sync_out_groups[] = { "gpio19", "gpio20", "gpio21", "gpio22",126 "gpio23", "gpio24", "gpio25", "gpio26"};127static const char * const swr_rx_clk_groups[] = { "gpio3" };128static const char * const swr_rx_data_groups[] = { "gpio4", "gpio5" };129static const char * const swr_tx_clk_groups[] = { "gpio0" };130static const char * const swr_tx_data_groups[] = { "gpio1", "gpio2" };131static const char * const swr_wsa_clk_groups[] = { "gpio10" };132static const char * const swr_wsa_data_groups[] = { "gpio11" };133 134 135static const struct lpi_pingroup sm4250_groups[] = {136 LPI_PINGROUP(0, 0, swr_tx_clk, qua_mi2s_sclk, _, _),137 LPI_PINGROUP(1, 2, swr_tx_data, qua_mi2s_ws, _, _),138 LPI_PINGROUP(2, 4, swr_tx_data, qua_mi2s_data, _, _),139 LPI_PINGROUP(3, 8, swr_rx_clk, qua_mi2s_data, _, _),140 LPI_PINGROUP(4, 10, swr_rx_data, qua_mi2s_data, _, _),141 LPI_PINGROUP(5, 12, swr_rx_data, ext_mclk0_b, qua_mi2s_data, _),142 LPI_PINGROUP(6, LPI_NO_SLEW, dmic01_clk, i2s1_clk, _, _),143 LPI_PINGROUP(7, LPI_NO_SLEW, dmic01_data, i2s1_ws, _, _),144 LPI_PINGROUP(8, LPI_NO_SLEW, dmic23_clk, i2s1_data, _, _),145 LPI_PINGROUP(9, LPI_NO_SLEW, dmic23_data, i2s1_data, ext_mclk1_b, _),146 LPI_PINGROUP(10, 16, i2s2_clk, swr_wsa_clk, dmic4_clk, _),147 LPI_PINGROUP(11, 18, i2s2_ws, swr_wsa_data, dmic4_data, _),148 LPI_PINGROUP(12, LPI_NO_SLEW, dmic23_clk, i2s2_data, _, _),149 LPI_PINGROUP(13, LPI_NO_SLEW, dmic23_data, i2s2_data, ext_mclk0_a, _),150 LPI_PINGROUP(14, LPI_NO_SLEW, i2s3_clk, slim_clk, _, _),151 LPI_PINGROUP(15, LPI_NO_SLEW, i2s3_ws, slim_data, _, _),152 LPI_PINGROUP(16, LPI_NO_SLEW, i2s3_data, _, _, _),153 LPI_PINGROUP(17, LPI_NO_SLEW, i2s3_data, ext_mclk1_c, _, _),154 LPI_PINGROUP(18, 20, ext_mclk1_a, swr_rx_data, _, _),155 LPI_PINGROUP(19, LPI_NO_SLEW, qup_io_00, sync_out, _, _),156 LPI_PINGROUP(20, LPI_NO_SLEW, qup_io_10, sync_out, _, _),157 LPI_PINGROUP(21, LPI_NO_SLEW, qup_io_01, sync_out, _, _),158 LPI_PINGROUP(22, LPI_NO_SLEW, qup_io_11, sync_out, _, _),159 LPI_PINGROUP(23, LPI_NO_SLEW, qup_io_25, qup_io_05, sync_out, _),160 LPI_PINGROUP(25, LPI_NO_SLEW, qup_io_26, qup_io_21, sync_out, _),161 LPI_PINGROUP(26, LPI_NO_SLEW, qup_io_36, qup_io_31, sync_out, _),162};163 164static const struct lpi_function sm4250_functions[] = {165 LPI_FUNCTION(dmic01_clk),166 LPI_FUNCTION(dmic01_data),167 LPI_FUNCTION(dmic23_clk),168 LPI_FUNCTION(dmic23_data),169 LPI_FUNCTION(dmic4_clk),170 LPI_FUNCTION(dmic4_data),171 LPI_FUNCTION(ext_mclk0_a),172 LPI_FUNCTION(ext_mclk0_b),173 LPI_FUNCTION(ext_mclk1_a),174 LPI_FUNCTION(ext_mclk1_b),175 LPI_FUNCTION(ext_mclk1_c),176 LPI_FUNCTION(i2s1_clk),177 LPI_FUNCTION(i2s1_data),178 LPI_FUNCTION(i2s1_ws),179 LPI_FUNCTION(i2s2_clk),180 LPI_FUNCTION(i2s2_data),181 LPI_FUNCTION(i2s2_ws),182 LPI_FUNCTION(i2s3_clk),183 LPI_FUNCTION(i2s3_data),184 LPI_FUNCTION(i2s3_ws),185 LPI_FUNCTION(qup_io_00),186 LPI_FUNCTION(qup_io_01),187 LPI_FUNCTION(qup_io_05),188 LPI_FUNCTION(qup_io_10),189 LPI_FUNCTION(qup_io_11),190 LPI_FUNCTION(qup_io_25),191 LPI_FUNCTION(qup_io_21),192 LPI_FUNCTION(qup_io_26),193 LPI_FUNCTION(qup_io_31),194 LPI_FUNCTION(qup_io_36),195 LPI_FUNCTION(qua_mi2s_data),196 LPI_FUNCTION(qua_mi2s_sclk),197 LPI_FUNCTION(qua_mi2s_ws),198 LPI_FUNCTION(slim_clk),199 LPI_FUNCTION(slim_data),200 LPI_FUNCTION(sync_out),201 LPI_FUNCTION(swr_rx_clk),202 LPI_FUNCTION(swr_rx_data),203 LPI_FUNCTION(swr_tx_clk),204 LPI_FUNCTION(swr_tx_data),205 LPI_FUNCTION(swr_wsa_clk),206 LPI_FUNCTION(swr_wsa_data),207};208 209static const struct lpi_pinctrl_variant_data sm4250_lpi_data = {210 .pins = sm4250_lpi_pins,211 .npins = ARRAY_SIZE(sm4250_lpi_pins),212 .groups = sm4250_groups,213 .ngroups = ARRAY_SIZE(sm4250_groups),214 .functions = sm4250_functions,215 .nfunctions = ARRAY_SIZE(sm4250_functions),216};217 218static const struct of_device_id lpi_pinctrl_of_match[] = {219 { .compatible = "qcom,sm4250-lpass-lpi-pinctrl", .data = &sm4250_lpi_data },220 { }221};222MODULE_DEVICE_TABLE(of, lpi_pinctrl_of_match);223 224static struct platform_driver lpi_pinctrl_driver = {225 .driver = {226 .name = "qcom-sm4250-lpass-lpi-pinctrl",227 .of_match_table = lpi_pinctrl_of_match,228 },229 .probe = lpi_pinctrl_probe,230 .remove_new = lpi_pinctrl_remove,231};232 233module_platform_driver(lpi_pinctrl_driver);234MODULE_DESCRIPTION("QTI SM4250 LPI GPIO pin control driver");235MODULE_AUTHOR("Srinivas Kandagatla <srinivas.kandagatla@linaro.org>");236MODULE_LICENSE("GPL");237