162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2022 Linaro Ltd. 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#include <linux/gpio/driver.h> 762306a36Sopenharmony_ci#include <linux/module.h> 862306a36Sopenharmony_ci#include <linux/platform_device.h> 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#include "pinctrl-lpass-lpi.h" 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_cienum lpass_lpi_functions { 1362306a36Sopenharmony_ci LPI_MUX_dmic1_clk, 1462306a36Sopenharmony_ci LPI_MUX_dmic1_data, 1562306a36Sopenharmony_ci LPI_MUX_dmic2_clk, 1662306a36Sopenharmony_ci LPI_MUX_dmic2_data, 1762306a36Sopenharmony_ci LPI_MUX_dmic3_clk, 1862306a36Sopenharmony_ci LPI_MUX_dmic3_data, 1962306a36Sopenharmony_ci LPI_MUX_dmic4_clk, 2062306a36Sopenharmony_ci LPI_MUX_dmic4_data, 2162306a36Sopenharmony_ci LPI_MUX_i2s1_clk, 2262306a36Sopenharmony_ci LPI_MUX_i2s1_data, 2362306a36Sopenharmony_ci LPI_MUX_i2s1_ws, 2462306a36Sopenharmony_ci LPI_MUX_i2s2_clk, 2562306a36Sopenharmony_ci LPI_MUX_i2s2_data, 2662306a36Sopenharmony_ci LPI_MUX_i2s2_ws, 2762306a36Sopenharmony_ci LPI_MUX_i2s3_clk, 2862306a36Sopenharmony_ci LPI_MUX_i2s3_data, 2962306a36Sopenharmony_ci LPI_MUX_i2s3_ws, 3062306a36Sopenharmony_ci LPI_MUX_i2s4_clk, 3162306a36Sopenharmony_ci LPI_MUX_i2s4_data, 3262306a36Sopenharmony_ci LPI_MUX_i2s4_ws, 3362306a36Sopenharmony_ci LPI_MUX_qua_mi2s_data, 3462306a36Sopenharmony_ci LPI_MUX_qua_mi2s_sclk, 3562306a36Sopenharmony_ci LPI_MUX_qua_mi2s_ws, 3662306a36Sopenharmony_ci LPI_MUX_swr_rx_clk, 3762306a36Sopenharmony_ci LPI_MUX_swr_rx_data, 3862306a36Sopenharmony_ci LPI_MUX_swr_tx_clk, 3962306a36Sopenharmony_ci LPI_MUX_swr_tx_data, 4062306a36Sopenharmony_ci LPI_MUX_wsa_swr_clk, 4162306a36Sopenharmony_ci LPI_MUX_wsa_swr_data, 4262306a36Sopenharmony_ci LPI_MUX_wsa2_swr_clk, 4362306a36Sopenharmony_ci LPI_MUX_wsa2_swr_data, 4462306a36Sopenharmony_ci LPI_MUX_slimbus_clk, 4562306a36Sopenharmony_ci LPI_MUX_slimbus_data, 4662306a36Sopenharmony_ci LPI_MUX_ext_mclk1_a, 4762306a36Sopenharmony_ci LPI_MUX_ext_mclk1_b, 4862306a36Sopenharmony_ci LPI_MUX_ext_mclk1_c, 4962306a36Sopenharmony_ci LPI_MUX_ext_mclk1_d, 5062306a36Sopenharmony_ci LPI_MUX_ext_mclk1_e, 5162306a36Sopenharmony_ci LPI_MUX_gpio, 5262306a36Sopenharmony_ci LPI_MUX__, 5362306a36Sopenharmony_ci}; 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_cistatic int gpio0_pins[] = { 0 }; 5662306a36Sopenharmony_cistatic int gpio1_pins[] = { 1 }; 5762306a36Sopenharmony_cistatic int gpio2_pins[] = { 2 }; 5862306a36Sopenharmony_cistatic int gpio3_pins[] = { 3 }; 5962306a36Sopenharmony_cistatic int gpio4_pins[] = { 4 }; 6062306a36Sopenharmony_cistatic int gpio5_pins[] = { 5 }; 6162306a36Sopenharmony_cistatic int gpio6_pins[] = { 6 }; 6262306a36Sopenharmony_cistatic int gpio7_pins[] = { 7 }; 6362306a36Sopenharmony_cistatic int gpio8_pins[] = { 8 }; 6462306a36Sopenharmony_cistatic int gpio9_pins[] = { 9 }; 6562306a36Sopenharmony_cistatic int gpio10_pins[] = { 10 }; 6662306a36Sopenharmony_cistatic int gpio11_pins[] = { 11 }; 6762306a36Sopenharmony_cistatic int gpio12_pins[] = { 12 }; 6862306a36Sopenharmony_cistatic int gpio13_pins[] = { 13 }; 6962306a36Sopenharmony_cistatic int gpio14_pins[] = { 14 }; 7062306a36Sopenharmony_cistatic int gpio15_pins[] = { 15 }; 7162306a36Sopenharmony_cistatic int gpio16_pins[] = { 16 }; 7262306a36Sopenharmony_cistatic int gpio17_pins[] = { 17 }; 7362306a36Sopenharmony_cistatic int gpio18_pins[] = { 18 }; 7462306a36Sopenharmony_cistatic int gpio19_pins[] = { 19 }; 7562306a36Sopenharmony_cistatic int gpio20_pins[] = { 20 }; 7662306a36Sopenharmony_cistatic int gpio21_pins[] = { 21 }; 7762306a36Sopenharmony_cistatic int gpio22_pins[] = { 22 }; 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_cistatic const struct pinctrl_pin_desc sm8450_lpi_pins[] = { 8062306a36Sopenharmony_ci PINCTRL_PIN(0, "gpio0"), 8162306a36Sopenharmony_ci PINCTRL_PIN(1, "gpio1"), 8262306a36Sopenharmony_ci PINCTRL_PIN(2, "gpio2"), 8362306a36Sopenharmony_ci PINCTRL_PIN(3, "gpio3"), 8462306a36Sopenharmony_ci PINCTRL_PIN(4, "gpio4"), 8562306a36Sopenharmony_ci PINCTRL_PIN(5, "gpio5"), 8662306a36Sopenharmony_ci PINCTRL_PIN(6, "gpio6"), 8762306a36Sopenharmony_ci PINCTRL_PIN(7, "gpio7"), 8862306a36Sopenharmony_ci PINCTRL_PIN(8, "gpio8"), 8962306a36Sopenharmony_ci PINCTRL_PIN(9, "gpio9"), 9062306a36Sopenharmony_ci PINCTRL_PIN(10, "gpio10"), 9162306a36Sopenharmony_ci PINCTRL_PIN(11, "gpio11"), 9262306a36Sopenharmony_ci PINCTRL_PIN(12, "gpio12"), 9362306a36Sopenharmony_ci PINCTRL_PIN(13, "gpio13"), 9462306a36Sopenharmony_ci PINCTRL_PIN(14, "gpio14"), 9562306a36Sopenharmony_ci PINCTRL_PIN(15, "gpio15"), 9662306a36Sopenharmony_ci PINCTRL_PIN(16, "gpio16"), 9762306a36Sopenharmony_ci PINCTRL_PIN(17, "gpio17"), 9862306a36Sopenharmony_ci PINCTRL_PIN(18, "gpio18"), 9962306a36Sopenharmony_ci PINCTRL_PIN(19, "gpio19"), 10062306a36Sopenharmony_ci PINCTRL_PIN(20, "gpio20"), 10162306a36Sopenharmony_ci PINCTRL_PIN(21, "gpio21"), 10262306a36Sopenharmony_ci PINCTRL_PIN(22, "gpio22"), 10362306a36Sopenharmony_ci}; 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_cistatic const char * const swr_tx_clk_groups[] = { "gpio0" }; 10662306a36Sopenharmony_cistatic const char * const swr_tx_data_groups[] = { "gpio1", "gpio2", "gpio14" }; 10762306a36Sopenharmony_cistatic const char * const swr_rx_clk_groups[] = { "gpio3" }; 10862306a36Sopenharmony_cistatic const char * const swr_rx_data_groups[] = { "gpio4", "gpio5" }; 10962306a36Sopenharmony_cistatic const char * const dmic1_clk_groups[] = { "gpio6" }; 11062306a36Sopenharmony_cistatic const char * const dmic1_data_groups[] = { "gpio7" }; 11162306a36Sopenharmony_cistatic const char * const dmic2_clk_groups[] = { "gpio8" }; 11262306a36Sopenharmony_cistatic const char * const dmic2_data_groups[] = { "gpio9" }; 11362306a36Sopenharmony_cistatic const char * const dmic4_clk_groups[] = { "gpio17" }; 11462306a36Sopenharmony_cistatic const char * const dmic4_data_groups[] = { "gpio18" }; 11562306a36Sopenharmony_cistatic const char * const i2s2_clk_groups[] = { "gpio10" }; 11662306a36Sopenharmony_cistatic const char * const i2s2_ws_groups[] = { "gpio11" }; 11762306a36Sopenharmony_cistatic const char * const dmic3_clk_groups[] = { "gpio12" }; 11862306a36Sopenharmony_cistatic const char * const dmic3_data_groups[] = { "gpio13" }; 11962306a36Sopenharmony_cistatic const char * const qua_mi2s_sclk_groups[] = { "gpio0" }; 12062306a36Sopenharmony_cistatic const char * const qua_mi2s_ws_groups[] = { "gpio1" }; 12162306a36Sopenharmony_cistatic const char * const qua_mi2s_data_groups[] = { "gpio2", "gpio3", "gpio4", "gpio5" }; 12262306a36Sopenharmony_cistatic const char * const i2s1_clk_groups[] = { "gpio6" }; 12362306a36Sopenharmony_cistatic const char * const i2s1_ws_groups[] = { "gpio7" }; 12462306a36Sopenharmony_cistatic const char * const i2s1_data_groups[] = { "gpio8", "gpio9" }; 12562306a36Sopenharmony_cistatic const char * const wsa_swr_clk_groups[] = { "gpio10" }; 12662306a36Sopenharmony_cistatic const char * const wsa_swr_data_groups[] = { "gpio11" }; 12762306a36Sopenharmony_cistatic const char * const wsa2_swr_clk_groups[] = { "gpio15" }; 12862306a36Sopenharmony_cistatic const char * const wsa2_swr_data_groups[] = { "gpio16" }; 12962306a36Sopenharmony_cistatic const char * const i2s2_data_groups[] = { "gpio15", "gpio16" }; 13062306a36Sopenharmony_cistatic const char * const i2s4_ws_groups[] = { "gpio13" }; 13162306a36Sopenharmony_cistatic const char * const i2s4_clk_groups[] = { "gpio12" }; 13262306a36Sopenharmony_cistatic const char * const i2s4_data_groups[] = { "gpio17", "gpio18" }; 13362306a36Sopenharmony_cistatic const char * const slimbus_clk_groups[] = { "gpio19"}; 13462306a36Sopenharmony_cistatic const char * const i2s3_clk_groups[] = { "gpio19"}; 13562306a36Sopenharmony_cistatic const char * const i2s3_ws_groups[] = { "gpio20"}; 13662306a36Sopenharmony_cistatic const char * const i2s3_data_groups[] = { "gpio21", "gpio22"}; 13762306a36Sopenharmony_cistatic const char * const slimbus_data_groups[] = { "gpio20"}; 13862306a36Sopenharmony_cistatic const char * const ext_mclk1_c_groups[] = { "gpio5" }; 13962306a36Sopenharmony_cistatic const char * const ext_mclk1_b_groups[] = { "gpio9" }; 14062306a36Sopenharmony_cistatic const char * const ext_mclk1_a_groups[] = { "gpio13" }; 14162306a36Sopenharmony_cistatic const char * const ext_mclk1_d_groups[] = { "gpio14" }; 14262306a36Sopenharmony_cistatic const char * const ext_mclk1_e_groups[] = { "gpio22" }; 14362306a36Sopenharmony_ci 14462306a36Sopenharmony_cistatic const struct lpi_pingroup sm8450_groups[] = { 14562306a36Sopenharmony_ci LPI_PINGROUP(0, 0, swr_tx_clk, qua_mi2s_sclk, _, _), 14662306a36Sopenharmony_ci LPI_PINGROUP(1, 2, swr_tx_data, qua_mi2s_ws, _, _), 14762306a36Sopenharmony_ci LPI_PINGROUP(2, 4, swr_tx_data, qua_mi2s_data, _, _), 14862306a36Sopenharmony_ci LPI_PINGROUP(3, 8, swr_rx_clk, qua_mi2s_data, _, _), 14962306a36Sopenharmony_ci LPI_PINGROUP(4, 10, swr_rx_data, qua_mi2s_data, _, _), 15062306a36Sopenharmony_ci LPI_PINGROUP(5, 12, swr_rx_data, ext_mclk1_c, qua_mi2s_data, _), 15162306a36Sopenharmony_ci LPI_PINGROUP(6, LPI_NO_SLEW, dmic1_clk, i2s1_clk, _, _), 15262306a36Sopenharmony_ci LPI_PINGROUP(7, LPI_NO_SLEW, dmic1_data, i2s1_ws, _, _), 15362306a36Sopenharmony_ci LPI_PINGROUP(8, LPI_NO_SLEW, dmic2_clk, i2s1_data, _, _), 15462306a36Sopenharmony_ci LPI_PINGROUP(9, LPI_NO_SLEW, dmic2_data, i2s1_data, ext_mclk1_b, _), 15562306a36Sopenharmony_ci LPI_PINGROUP(10, 16, i2s2_clk, wsa_swr_clk, _, _), 15662306a36Sopenharmony_ci LPI_PINGROUP(11, 18, i2s2_ws, wsa_swr_data, _, _), 15762306a36Sopenharmony_ci LPI_PINGROUP(12, LPI_NO_SLEW, dmic3_clk, i2s4_clk, _, _), 15862306a36Sopenharmony_ci LPI_PINGROUP(13, LPI_NO_SLEW, dmic3_data, i2s4_ws, ext_mclk1_a, _), 15962306a36Sopenharmony_ci LPI_PINGROUP(14, 6, swr_tx_data, ext_mclk1_d, _, _), 16062306a36Sopenharmony_ci LPI_PINGROUP(15, 20, i2s2_data, wsa2_swr_clk, _, _), 16162306a36Sopenharmony_ci LPI_PINGROUP(16, 22, i2s2_data, wsa2_swr_data, _, _), 16262306a36Sopenharmony_ci LPI_PINGROUP(17, LPI_NO_SLEW, dmic4_clk, i2s4_data, _, _), 16362306a36Sopenharmony_ci LPI_PINGROUP(18, LPI_NO_SLEW, dmic4_data, i2s4_data, _, _), 16462306a36Sopenharmony_ci LPI_PINGROUP(19, LPI_NO_SLEW, i2s3_clk, slimbus_clk, _, _), 16562306a36Sopenharmony_ci LPI_PINGROUP(20, LPI_NO_SLEW, i2s3_ws, slimbus_data, _, _), 16662306a36Sopenharmony_ci LPI_PINGROUP(21, LPI_NO_SLEW, i2s3_data, _, _, _), 16762306a36Sopenharmony_ci LPI_PINGROUP(22, LPI_NO_SLEW, i2s3_data, ext_mclk1_e, _, _), 16862306a36Sopenharmony_ci}; 16962306a36Sopenharmony_ci 17062306a36Sopenharmony_cistatic const struct lpi_function sm8450_functions[] = { 17162306a36Sopenharmony_ci LPI_FUNCTION(dmic1_clk), 17262306a36Sopenharmony_ci LPI_FUNCTION(dmic1_data), 17362306a36Sopenharmony_ci LPI_FUNCTION(dmic2_clk), 17462306a36Sopenharmony_ci LPI_FUNCTION(dmic2_data), 17562306a36Sopenharmony_ci LPI_FUNCTION(dmic3_clk), 17662306a36Sopenharmony_ci LPI_FUNCTION(dmic3_data), 17762306a36Sopenharmony_ci LPI_FUNCTION(dmic4_clk), 17862306a36Sopenharmony_ci LPI_FUNCTION(dmic4_data), 17962306a36Sopenharmony_ci LPI_FUNCTION(i2s1_clk), 18062306a36Sopenharmony_ci LPI_FUNCTION(i2s1_data), 18162306a36Sopenharmony_ci LPI_FUNCTION(i2s1_ws), 18262306a36Sopenharmony_ci LPI_FUNCTION(i2s2_clk), 18362306a36Sopenharmony_ci LPI_FUNCTION(i2s2_data), 18462306a36Sopenharmony_ci LPI_FUNCTION(i2s2_ws), 18562306a36Sopenharmony_ci LPI_FUNCTION(i2s3_clk), 18662306a36Sopenharmony_ci LPI_FUNCTION(i2s3_data), 18762306a36Sopenharmony_ci LPI_FUNCTION(i2s3_ws), 18862306a36Sopenharmony_ci LPI_FUNCTION(i2s4_clk), 18962306a36Sopenharmony_ci LPI_FUNCTION(i2s4_data), 19062306a36Sopenharmony_ci LPI_FUNCTION(i2s4_ws), 19162306a36Sopenharmony_ci LPI_FUNCTION(qua_mi2s_data), 19262306a36Sopenharmony_ci LPI_FUNCTION(qua_mi2s_sclk), 19362306a36Sopenharmony_ci LPI_FUNCTION(qua_mi2s_ws), 19462306a36Sopenharmony_ci LPI_FUNCTION(swr_rx_clk), 19562306a36Sopenharmony_ci LPI_FUNCTION(swr_rx_data), 19662306a36Sopenharmony_ci LPI_FUNCTION(swr_tx_clk), 19762306a36Sopenharmony_ci LPI_FUNCTION(swr_tx_data), 19862306a36Sopenharmony_ci LPI_FUNCTION(slimbus_clk), 19962306a36Sopenharmony_ci LPI_FUNCTION(slimbus_data), 20062306a36Sopenharmony_ci LPI_FUNCTION(wsa_swr_clk), 20162306a36Sopenharmony_ci LPI_FUNCTION(wsa_swr_data), 20262306a36Sopenharmony_ci LPI_FUNCTION(wsa2_swr_clk), 20362306a36Sopenharmony_ci LPI_FUNCTION(wsa2_swr_data), 20462306a36Sopenharmony_ci LPI_FUNCTION(ext_mclk1_a), 20562306a36Sopenharmony_ci LPI_FUNCTION(ext_mclk1_b), 20662306a36Sopenharmony_ci LPI_FUNCTION(ext_mclk1_c), 20762306a36Sopenharmony_ci LPI_FUNCTION(ext_mclk1_d), 20862306a36Sopenharmony_ci LPI_FUNCTION(ext_mclk1_e), 20962306a36Sopenharmony_ci}; 21062306a36Sopenharmony_ci 21162306a36Sopenharmony_cistatic const struct lpi_pinctrl_variant_data sm8450_lpi_data = { 21262306a36Sopenharmony_ci .pins = sm8450_lpi_pins, 21362306a36Sopenharmony_ci .npins = ARRAY_SIZE(sm8450_lpi_pins), 21462306a36Sopenharmony_ci .groups = sm8450_groups, 21562306a36Sopenharmony_ci .ngroups = ARRAY_SIZE(sm8450_groups), 21662306a36Sopenharmony_ci .functions = sm8450_functions, 21762306a36Sopenharmony_ci .nfunctions = ARRAY_SIZE(sm8450_functions), 21862306a36Sopenharmony_ci}; 21962306a36Sopenharmony_ci 22062306a36Sopenharmony_cistatic const struct of_device_id lpi_pinctrl_of_match[] = { 22162306a36Sopenharmony_ci { 22262306a36Sopenharmony_ci .compatible = "qcom,sm8450-lpass-lpi-pinctrl", 22362306a36Sopenharmony_ci .data = &sm8450_lpi_data, 22462306a36Sopenharmony_ci }, 22562306a36Sopenharmony_ci { } 22662306a36Sopenharmony_ci}; 22762306a36Sopenharmony_ciMODULE_DEVICE_TABLE(of, lpi_pinctrl_of_match); 22862306a36Sopenharmony_ci 22962306a36Sopenharmony_cistatic struct platform_driver lpi_pinctrl_driver = { 23062306a36Sopenharmony_ci .driver = { 23162306a36Sopenharmony_ci .name = "qcom-sm8450-lpass-lpi-pinctrl", 23262306a36Sopenharmony_ci .of_match_table = lpi_pinctrl_of_match, 23362306a36Sopenharmony_ci }, 23462306a36Sopenharmony_ci .probe = lpi_pinctrl_probe, 23562306a36Sopenharmony_ci .remove = lpi_pinctrl_remove, 23662306a36Sopenharmony_ci}; 23762306a36Sopenharmony_ci 23862306a36Sopenharmony_cimodule_platform_driver(lpi_pinctrl_driver); 23962306a36Sopenharmony_ciMODULE_DESCRIPTION("QTI SM8450 LPI GPIO pin control driver"); 24062306a36Sopenharmony_ciMODULE_LICENSE("GPL"); 241