162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. 462306a36Sopenharmony_ci * Copyright (c) 2020, 2023 Linaro Ltd. 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#include <linux/gpio/driver.h> 862306a36Sopenharmony_ci#include <linux/module.h> 962306a36Sopenharmony_ci#include <linux/platform_device.h> 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#include "pinctrl-lpass-lpi.h" 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_cienum lpass_lpi_functions { 1462306a36Sopenharmony_ci LPI_MUX_dmic01_clk, 1562306a36Sopenharmony_ci LPI_MUX_dmic01_data, 1662306a36Sopenharmony_ci LPI_MUX_dmic23_clk, 1762306a36Sopenharmony_ci LPI_MUX_dmic23_data, 1862306a36Sopenharmony_ci LPI_MUX_i2s1_clk, 1962306a36Sopenharmony_ci LPI_MUX_i2s1_data, 2062306a36Sopenharmony_ci LPI_MUX_i2s1_ws, 2162306a36Sopenharmony_ci LPI_MUX_i2s2_clk, 2262306a36Sopenharmony_ci LPI_MUX_i2s2_data, 2362306a36Sopenharmony_ci LPI_MUX_i2s2_ws, 2462306a36Sopenharmony_ci LPI_MUX_i2s3_clk, 2562306a36Sopenharmony_ci LPI_MUX_i2s3_data, 2662306a36Sopenharmony_ci LPI_MUX_i2s3_ws, 2762306a36Sopenharmony_ci LPI_MUX_qua_mi2s_data, 2862306a36Sopenharmony_ci LPI_MUX_qua_mi2s_sclk, 2962306a36Sopenharmony_ci LPI_MUX_qua_mi2s_ws, 3062306a36Sopenharmony_ci LPI_MUX_swr_rx_clk, 3162306a36Sopenharmony_ci LPI_MUX_swr_rx_data, 3262306a36Sopenharmony_ci LPI_MUX_swr_tx_clk, 3362306a36Sopenharmony_ci LPI_MUX_swr_tx_data, 3462306a36Sopenharmony_ci LPI_MUX_wsa_mclk, 3562306a36Sopenharmony_ci LPI_MUX_gpio, 3662306a36Sopenharmony_ci LPI_MUX__, 3762306a36Sopenharmony_ci}; 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_cistatic int gpio0_pins[] = { 0 }; 4062306a36Sopenharmony_cistatic int gpio1_pins[] = { 1 }; 4162306a36Sopenharmony_cistatic int gpio2_pins[] = { 2 }; 4262306a36Sopenharmony_cistatic int gpio3_pins[] = { 3 }; 4362306a36Sopenharmony_cistatic int gpio4_pins[] = { 4 }; 4462306a36Sopenharmony_cistatic int gpio5_pins[] = { 5 }; 4562306a36Sopenharmony_cistatic int gpio6_pins[] = { 6 }; 4662306a36Sopenharmony_cistatic int gpio7_pins[] = { 7 }; 4762306a36Sopenharmony_cistatic int gpio8_pins[] = { 8 }; 4862306a36Sopenharmony_cistatic int gpio9_pins[] = { 9 }; 4962306a36Sopenharmony_cistatic int gpio10_pins[] = { 10 }; 5062306a36Sopenharmony_cistatic int gpio11_pins[] = { 11 }; 5162306a36Sopenharmony_cistatic int gpio12_pins[] = { 12 }; 5262306a36Sopenharmony_cistatic int gpio13_pins[] = { 13 }; 5362306a36Sopenharmony_cistatic int gpio14_pins[] = { 14 }; 5462306a36Sopenharmony_cistatic int gpio15_pins[] = { 15 }; 5562306a36Sopenharmony_cistatic int gpio16_pins[] = { 16 }; 5662306a36Sopenharmony_cistatic int gpio17_pins[] = { 17 }; 5762306a36Sopenharmony_cistatic int gpio18_pins[] = { 18 }; 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_cistatic const struct pinctrl_pin_desc sm6115_lpi_pins[] = { 6062306a36Sopenharmony_ci PINCTRL_PIN(0, "gpio0"), 6162306a36Sopenharmony_ci PINCTRL_PIN(1, "gpio1"), 6262306a36Sopenharmony_ci PINCTRL_PIN(2, "gpio2"), 6362306a36Sopenharmony_ci PINCTRL_PIN(3, "gpio3"), 6462306a36Sopenharmony_ci PINCTRL_PIN(4, "gpio4"), 6562306a36Sopenharmony_ci PINCTRL_PIN(5, "gpio5"), 6662306a36Sopenharmony_ci PINCTRL_PIN(6, "gpio6"), 6762306a36Sopenharmony_ci PINCTRL_PIN(7, "gpio7"), 6862306a36Sopenharmony_ci PINCTRL_PIN(8, "gpio8"), 6962306a36Sopenharmony_ci PINCTRL_PIN(9, "gpio9"), 7062306a36Sopenharmony_ci PINCTRL_PIN(10, "gpio10"), 7162306a36Sopenharmony_ci PINCTRL_PIN(11, "gpio11"), 7262306a36Sopenharmony_ci PINCTRL_PIN(12, "gpio12"), 7362306a36Sopenharmony_ci PINCTRL_PIN(13, "gpio13"), 7462306a36Sopenharmony_ci PINCTRL_PIN(14, "gpio14"), 7562306a36Sopenharmony_ci PINCTRL_PIN(15, "gpio15"), 7662306a36Sopenharmony_ci PINCTRL_PIN(16, "gpio16"), 7762306a36Sopenharmony_ci PINCTRL_PIN(17, "gpio17"), 7862306a36Sopenharmony_ci PINCTRL_PIN(18, "gpio18"), 7962306a36Sopenharmony_ci}; 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_cistatic const char * const dmic01_clk_groups[] = { "gpio6" }; 8262306a36Sopenharmony_cistatic const char * const dmic01_data_groups[] = { "gpio7" }; 8362306a36Sopenharmony_cistatic const char * const dmic23_clk_groups[] = { "gpio8" }; 8462306a36Sopenharmony_cistatic const char * const dmic23_data_groups[] = { "gpio9" }; 8562306a36Sopenharmony_cistatic const char * const i2s1_clk_groups[] = { "gpio6" }; 8662306a36Sopenharmony_cistatic const char * const i2s1_data_groups[] = { "gpio8", "gpio9" }; 8762306a36Sopenharmony_cistatic const char * const i2s1_ws_groups[] = { "gpio7" }; 8862306a36Sopenharmony_cistatic const char * const i2s2_clk_groups[] = { "gpio10" }; 8962306a36Sopenharmony_cistatic const char * const i2s2_data_groups[] = { "gpio12", "gpio13" }; 9062306a36Sopenharmony_cistatic const char * const i2s2_ws_groups[] = { "gpio11" }; 9162306a36Sopenharmony_cistatic const char * const i2s3_clk_groups[] = { "gpio14" }; 9262306a36Sopenharmony_cistatic const char * const i2s3_data_groups[] = { "gpio16", "gpio17" }; 9362306a36Sopenharmony_cistatic const char * const i2s3_ws_groups[] = { "gpio15" }; 9462306a36Sopenharmony_cistatic const char * const qua_mi2s_data_groups[] = { "gpio2", "gpio3", "gpio4", "gpio5" }; 9562306a36Sopenharmony_cistatic const char * const qua_mi2s_sclk_groups[] = { "gpio0" }; 9662306a36Sopenharmony_cistatic const char * const qua_mi2s_ws_groups[] = { "gpio1" }; 9762306a36Sopenharmony_cistatic const char * const swr_rx_clk_groups[] = { "gpio3" }; 9862306a36Sopenharmony_cistatic const char * const swr_rx_data_groups[] = { "gpio4", "gpio5" }; 9962306a36Sopenharmony_cistatic const char * const swr_tx_clk_groups[] = { "gpio0" }; 10062306a36Sopenharmony_cistatic const char * const swr_tx_data_groups[] = { "gpio1", "gpio2" }; 10162306a36Sopenharmony_cistatic const char * const wsa_mclk_groups[] = { "gpio18" }; 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_cistatic const struct lpi_pingroup sm6115_groups[] = { 10462306a36Sopenharmony_ci LPI_PINGROUP(0, 0, swr_tx_clk, qua_mi2s_sclk, _, _), 10562306a36Sopenharmony_ci LPI_PINGROUP(1, 2, swr_tx_data, qua_mi2s_ws, _, _), 10662306a36Sopenharmony_ci LPI_PINGROUP(2, 4, swr_tx_data, qua_mi2s_data, _, _), 10762306a36Sopenharmony_ci LPI_PINGROUP(3, 8, swr_rx_clk, qua_mi2s_data, _, _), 10862306a36Sopenharmony_ci LPI_PINGROUP(4, 10, swr_rx_data, qua_mi2s_data, _, _), 10962306a36Sopenharmony_ci LPI_PINGROUP(5, 12, swr_rx_data, _, qua_mi2s_data, _), 11062306a36Sopenharmony_ci LPI_PINGROUP(6, LPI_NO_SLEW, dmic01_clk, i2s1_clk, _, _), 11162306a36Sopenharmony_ci LPI_PINGROUP(7, LPI_NO_SLEW, dmic01_data, i2s1_ws, _, _), 11262306a36Sopenharmony_ci LPI_PINGROUP(8, LPI_NO_SLEW, dmic23_clk, i2s1_data, _, _), 11362306a36Sopenharmony_ci LPI_PINGROUP(9, LPI_NO_SLEW, dmic23_data, i2s1_data, _, _), 11462306a36Sopenharmony_ci LPI_PINGROUP(10, LPI_NO_SLEW, i2s2_clk, _, _, _), 11562306a36Sopenharmony_ci LPI_PINGROUP(11, LPI_NO_SLEW, i2s2_ws, _, _, _), 11662306a36Sopenharmony_ci LPI_PINGROUP(12, LPI_NO_SLEW, _, i2s2_data, _, _), 11762306a36Sopenharmony_ci LPI_PINGROUP(13, LPI_NO_SLEW, _, i2s2_data, _, _), 11862306a36Sopenharmony_ci LPI_PINGROUP(14, LPI_NO_SLEW, i2s3_clk, _, _, _), 11962306a36Sopenharmony_ci LPI_PINGROUP(15, LPI_NO_SLEW, i2s3_ws, _, _, _), 12062306a36Sopenharmony_ci LPI_PINGROUP(16, LPI_NO_SLEW, i2s3_data, _, _, _), 12162306a36Sopenharmony_ci LPI_PINGROUP(17, LPI_NO_SLEW, i2s3_data, _, _, _), 12262306a36Sopenharmony_ci LPI_PINGROUP(18, 14, wsa_mclk, _, _, _), 12362306a36Sopenharmony_ci}; 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_cistatic const struct lpi_function sm6115_functions[] = { 12662306a36Sopenharmony_ci LPI_FUNCTION(dmic01_clk), 12762306a36Sopenharmony_ci LPI_FUNCTION(dmic01_data), 12862306a36Sopenharmony_ci LPI_FUNCTION(dmic23_clk), 12962306a36Sopenharmony_ci LPI_FUNCTION(dmic23_data), 13062306a36Sopenharmony_ci LPI_FUNCTION(i2s1_clk), 13162306a36Sopenharmony_ci LPI_FUNCTION(i2s1_data), 13262306a36Sopenharmony_ci LPI_FUNCTION(i2s1_ws), 13362306a36Sopenharmony_ci LPI_FUNCTION(i2s2_clk), 13462306a36Sopenharmony_ci LPI_FUNCTION(i2s2_data), 13562306a36Sopenharmony_ci LPI_FUNCTION(i2s2_ws), 13662306a36Sopenharmony_ci LPI_FUNCTION(i2s3_clk), 13762306a36Sopenharmony_ci LPI_FUNCTION(i2s3_data), 13862306a36Sopenharmony_ci LPI_FUNCTION(i2s3_ws), 13962306a36Sopenharmony_ci LPI_FUNCTION(qua_mi2s_data), 14062306a36Sopenharmony_ci LPI_FUNCTION(qua_mi2s_sclk), 14162306a36Sopenharmony_ci LPI_FUNCTION(qua_mi2s_ws), 14262306a36Sopenharmony_ci LPI_FUNCTION(swr_rx_clk), 14362306a36Sopenharmony_ci LPI_FUNCTION(swr_rx_data), 14462306a36Sopenharmony_ci LPI_FUNCTION(swr_tx_clk), 14562306a36Sopenharmony_ci LPI_FUNCTION(swr_tx_data), 14662306a36Sopenharmony_ci LPI_FUNCTION(wsa_mclk), 14762306a36Sopenharmony_ci}; 14862306a36Sopenharmony_ci 14962306a36Sopenharmony_cistatic const struct lpi_pinctrl_variant_data sm6115_lpi_data = { 15062306a36Sopenharmony_ci .pins = sm6115_lpi_pins, 15162306a36Sopenharmony_ci .npins = ARRAY_SIZE(sm6115_lpi_pins), 15262306a36Sopenharmony_ci .groups = sm6115_groups, 15362306a36Sopenharmony_ci .ngroups = ARRAY_SIZE(sm6115_groups), 15462306a36Sopenharmony_ci .functions = sm6115_functions, 15562306a36Sopenharmony_ci .nfunctions = ARRAY_SIZE(sm6115_functions), 15662306a36Sopenharmony_ci}; 15762306a36Sopenharmony_ci 15862306a36Sopenharmony_cistatic const struct of_device_id lpi_pinctrl_of_match[] = { 15962306a36Sopenharmony_ci { .compatible = "qcom,sm6115-lpass-lpi-pinctrl", .data = &sm6115_lpi_data }, 16062306a36Sopenharmony_ci { } 16162306a36Sopenharmony_ci}; 16262306a36Sopenharmony_ciMODULE_DEVICE_TABLE(of, lpi_pinctrl_of_match); 16362306a36Sopenharmony_ci 16462306a36Sopenharmony_cistatic struct platform_driver lpi_pinctrl_driver = { 16562306a36Sopenharmony_ci .driver = { 16662306a36Sopenharmony_ci .name = "qcom-sm6115-lpass-lpi-pinctrl", 16762306a36Sopenharmony_ci .of_match_table = lpi_pinctrl_of_match, 16862306a36Sopenharmony_ci }, 16962306a36Sopenharmony_ci .probe = lpi_pinctrl_probe, 17062306a36Sopenharmony_ci .remove = lpi_pinctrl_remove, 17162306a36Sopenharmony_ci}; 17262306a36Sopenharmony_ci 17362306a36Sopenharmony_cimodule_platform_driver(lpi_pinctrl_driver); 17462306a36Sopenharmony_ciMODULE_DESCRIPTION("QTI SM6115 LPI GPIO pin control driver"); 17562306a36Sopenharmony_ciMODULE_LICENSE("GPL"); 176