162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. 462306a36Sopenharmony_ci * ALSA SoC platform-machine driver for QTi LPASS 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_dmic1_clk, 1562306a36Sopenharmony_ci LPI_MUX_dmic1_data, 1662306a36Sopenharmony_ci LPI_MUX_dmic2_clk, 1762306a36Sopenharmony_ci LPI_MUX_dmic2_data, 1862306a36Sopenharmony_ci LPI_MUX_dmic3_clk, 1962306a36Sopenharmony_ci LPI_MUX_dmic3_data, 2062306a36Sopenharmony_ci LPI_MUX_i2s1_clk, 2162306a36Sopenharmony_ci LPI_MUX_i2s1_data, 2262306a36Sopenharmony_ci LPI_MUX_i2s1_ws, 2362306a36Sopenharmony_ci LPI_MUX_i2s2_clk, 2462306a36Sopenharmony_ci LPI_MUX_i2s2_data, 2562306a36Sopenharmony_ci LPI_MUX_i2s2_ws, 2662306a36Sopenharmony_ci LPI_MUX_qua_mi2s_data, 2762306a36Sopenharmony_ci LPI_MUX_qua_mi2s_sclk, 2862306a36Sopenharmony_ci LPI_MUX_qua_mi2s_ws, 2962306a36Sopenharmony_ci LPI_MUX_swr_rx_clk, 3062306a36Sopenharmony_ci LPI_MUX_swr_rx_data, 3162306a36Sopenharmony_ci LPI_MUX_swr_tx_clk, 3262306a36Sopenharmony_ci LPI_MUX_swr_tx_data, 3362306a36Sopenharmony_ci LPI_MUX_wsa_swr_clk, 3462306a36Sopenharmony_ci LPI_MUX_wsa_swr_data, 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_ci 5562306a36Sopenharmony_cistatic const struct pinctrl_pin_desc sc7280_lpi_pins[] = { 5662306a36Sopenharmony_ci PINCTRL_PIN(0, "gpio0"), 5762306a36Sopenharmony_ci PINCTRL_PIN(1, "gpio1"), 5862306a36Sopenharmony_ci PINCTRL_PIN(2, "gpio2"), 5962306a36Sopenharmony_ci PINCTRL_PIN(3, "gpio3"), 6062306a36Sopenharmony_ci PINCTRL_PIN(4, "gpio4"), 6162306a36Sopenharmony_ci PINCTRL_PIN(5, "gpio5"), 6262306a36Sopenharmony_ci PINCTRL_PIN(6, "gpio6"), 6362306a36Sopenharmony_ci PINCTRL_PIN(7, "gpio7"), 6462306a36Sopenharmony_ci PINCTRL_PIN(8, "gpio8"), 6562306a36Sopenharmony_ci PINCTRL_PIN(9, "gpio9"), 6662306a36Sopenharmony_ci PINCTRL_PIN(10, "gpio10"), 6762306a36Sopenharmony_ci PINCTRL_PIN(11, "gpio11"), 6862306a36Sopenharmony_ci PINCTRL_PIN(12, "gpio12"), 6962306a36Sopenharmony_ci PINCTRL_PIN(13, "gpio13"), 7062306a36Sopenharmony_ci PINCTRL_PIN(14, "gpio14"), 7162306a36Sopenharmony_ci}; 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_cistatic const char * const swr_tx_clk_groups[] = { "gpio0" }; 7462306a36Sopenharmony_cistatic const char * const swr_tx_data_groups[] = { "gpio1", "gpio2", "gpio14" }; 7562306a36Sopenharmony_cistatic const char * const swr_rx_clk_groups[] = { "gpio3" }; 7662306a36Sopenharmony_cistatic const char * const swr_rx_data_groups[] = { "gpio4", "gpio5" }; 7762306a36Sopenharmony_cistatic const char * const dmic1_clk_groups[] = { "gpio6" }; 7862306a36Sopenharmony_cistatic const char * const dmic1_data_groups[] = { "gpio7" }; 7962306a36Sopenharmony_cistatic const char * const dmic2_clk_groups[] = { "gpio8" }; 8062306a36Sopenharmony_cistatic const char * const dmic2_data_groups[] = { "gpio9" }; 8162306a36Sopenharmony_cistatic const char * const i2s2_clk_groups[] = { "gpio10" }; 8262306a36Sopenharmony_cistatic const char * const i2s2_ws_groups[] = { "gpio11" }; 8362306a36Sopenharmony_cistatic const char * const dmic3_clk_groups[] = { "gpio12" }; 8462306a36Sopenharmony_cistatic const char * const dmic3_data_groups[] = { "gpio13" }; 8562306a36Sopenharmony_cistatic const char * const qua_mi2s_sclk_groups[] = { "gpio0" }; 8662306a36Sopenharmony_cistatic const char * const qua_mi2s_ws_groups[] = { "gpio1" }; 8762306a36Sopenharmony_cistatic const char * const qua_mi2s_data_groups[] = { "gpio2", "gpio3", "gpio4" }; 8862306a36Sopenharmony_cistatic const char * const i2s1_clk_groups[] = { "gpio6" }; 8962306a36Sopenharmony_cistatic const char * const i2s1_ws_groups[] = { "gpio7" }; 9062306a36Sopenharmony_cistatic const char * const i2s1_data_groups[] = { "gpio8", "gpio9" }; 9162306a36Sopenharmony_cistatic const char * const wsa_swr_clk_groups[] = { "gpio10" }; 9262306a36Sopenharmony_cistatic const char * const wsa_swr_data_groups[] = { "gpio11" }; 9362306a36Sopenharmony_cistatic const char * const i2s2_data_groups[] = { "gpio12", "gpio13" }; 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_cistatic const struct lpi_pingroup sc7280_groups[] = { 9662306a36Sopenharmony_ci LPI_PINGROUP(0, 0, swr_tx_clk, qua_mi2s_sclk, _, _), 9762306a36Sopenharmony_ci LPI_PINGROUP(1, 2, swr_tx_data, qua_mi2s_ws, _, _), 9862306a36Sopenharmony_ci LPI_PINGROUP(2, 4, swr_tx_data, qua_mi2s_data, _, _), 9962306a36Sopenharmony_ci LPI_PINGROUP(3, 8, swr_rx_clk, qua_mi2s_data, _, _), 10062306a36Sopenharmony_ci LPI_PINGROUP(4, 10, swr_rx_data, qua_mi2s_data, _, _), 10162306a36Sopenharmony_ci LPI_PINGROUP(5, 12, swr_rx_data, _, _, _), 10262306a36Sopenharmony_ci LPI_PINGROUP(6, LPI_NO_SLEW, dmic1_clk, i2s1_clk, _, _), 10362306a36Sopenharmony_ci LPI_PINGROUP(7, LPI_NO_SLEW, dmic1_data, i2s1_ws, _, _), 10462306a36Sopenharmony_ci LPI_PINGROUP(8, LPI_NO_SLEW, dmic2_clk, i2s1_data, _, _), 10562306a36Sopenharmony_ci LPI_PINGROUP(9, LPI_NO_SLEW, dmic2_data, i2s1_data, _, _), 10662306a36Sopenharmony_ci LPI_PINGROUP(10, 16, i2s2_clk, wsa_swr_clk, _, _), 10762306a36Sopenharmony_ci LPI_PINGROUP(11, 18, i2s2_ws, wsa_swr_data, _, _), 10862306a36Sopenharmony_ci LPI_PINGROUP(12, LPI_NO_SLEW, dmic3_clk, i2s2_data, _, _), 10962306a36Sopenharmony_ci LPI_PINGROUP(13, LPI_NO_SLEW, dmic3_data, i2s2_data, _, _), 11062306a36Sopenharmony_ci LPI_PINGROUP(14, 6, swr_tx_data, _, _, _), 11162306a36Sopenharmony_ci}; 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_cistatic const struct lpi_function sc7280_functions[] = { 11462306a36Sopenharmony_ci LPI_FUNCTION(dmic1_clk), 11562306a36Sopenharmony_ci LPI_FUNCTION(dmic1_data), 11662306a36Sopenharmony_ci LPI_FUNCTION(dmic2_clk), 11762306a36Sopenharmony_ci LPI_FUNCTION(dmic2_data), 11862306a36Sopenharmony_ci LPI_FUNCTION(dmic3_clk), 11962306a36Sopenharmony_ci LPI_FUNCTION(dmic3_data), 12062306a36Sopenharmony_ci LPI_FUNCTION(i2s1_clk), 12162306a36Sopenharmony_ci LPI_FUNCTION(i2s1_data), 12262306a36Sopenharmony_ci LPI_FUNCTION(i2s1_ws), 12362306a36Sopenharmony_ci LPI_FUNCTION(i2s2_clk), 12462306a36Sopenharmony_ci LPI_FUNCTION(i2s2_data), 12562306a36Sopenharmony_ci LPI_FUNCTION(i2s2_ws), 12662306a36Sopenharmony_ci LPI_FUNCTION(qua_mi2s_data), 12762306a36Sopenharmony_ci LPI_FUNCTION(qua_mi2s_sclk), 12862306a36Sopenharmony_ci LPI_FUNCTION(qua_mi2s_ws), 12962306a36Sopenharmony_ci LPI_FUNCTION(swr_rx_clk), 13062306a36Sopenharmony_ci LPI_FUNCTION(swr_rx_data), 13162306a36Sopenharmony_ci LPI_FUNCTION(swr_tx_clk), 13262306a36Sopenharmony_ci LPI_FUNCTION(swr_tx_data), 13362306a36Sopenharmony_ci LPI_FUNCTION(wsa_swr_clk), 13462306a36Sopenharmony_ci LPI_FUNCTION(wsa_swr_data), 13562306a36Sopenharmony_ci}; 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_cistatic const struct lpi_pinctrl_variant_data sc7280_lpi_data = { 13862306a36Sopenharmony_ci .pins = sc7280_lpi_pins, 13962306a36Sopenharmony_ci .npins = ARRAY_SIZE(sc7280_lpi_pins), 14062306a36Sopenharmony_ci .groups = sc7280_groups, 14162306a36Sopenharmony_ci .ngroups = ARRAY_SIZE(sc7280_groups), 14262306a36Sopenharmony_ci .functions = sc7280_functions, 14362306a36Sopenharmony_ci .nfunctions = ARRAY_SIZE(sc7280_functions), 14462306a36Sopenharmony_ci}; 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_cistatic const struct of_device_id lpi_pinctrl_of_match[] = { 14762306a36Sopenharmony_ci { 14862306a36Sopenharmony_ci .compatible = "qcom,sc7280-lpass-lpi-pinctrl", 14962306a36Sopenharmony_ci .data = &sc7280_lpi_data, 15062306a36Sopenharmony_ci }, 15162306a36Sopenharmony_ci { } 15262306a36Sopenharmony_ci}; 15362306a36Sopenharmony_ciMODULE_DEVICE_TABLE(of, lpi_pinctrl_of_match); 15462306a36Sopenharmony_ci 15562306a36Sopenharmony_cistatic struct platform_driver lpi_pinctrl_driver = { 15662306a36Sopenharmony_ci .driver = { 15762306a36Sopenharmony_ci .name = "qcom-sc7280-lpass-lpi-pinctrl", 15862306a36Sopenharmony_ci .of_match_table = lpi_pinctrl_of_match, 15962306a36Sopenharmony_ci }, 16062306a36Sopenharmony_ci .probe = lpi_pinctrl_probe, 16162306a36Sopenharmony_ci .remove = lpi_pinctrl_remove, 16262306a36Sopenharmony_ci}; 16362306a36Sopenharmony_ci 16462306a36Sopenharmony_cimodule_platform_driver(lpi_pinctrl_driver); 16562306a36Sopenharmony_ciMODULE_DESCRIPTION("QTI SC7280 LPI GPIO pin control driver"); 16662306a36Sopenharmony_ciMODULE_LICENSE("GPL"); 167