1*be9f6d56SKrzysztof Kozlowski // SPDX-License-Identifier: GPL-2.0-only 2*be9f6d56SKrzysztof Kozlowski /* 3*be9f6d56SKrzysztof Kozlowski * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. 4*be9f6d56SKrzysztof Kozlowski * Copyright (c) 2020-2023 Linaro Ltd. 5*be9f6d56SKrzysztof Kozlowski */ 6*be9f6d56SKrzysztof Kozlowski 7*be9f6d56SKrzysztof Kozlowski #include <linux/gpio/driver.h> 8*be9f6d56SKrzysztof Kozlowski #include <linux/module.h> 9*be9f6d56SKrzysztof Kozlowski #include <linux/platform_device.h> 10*be9f6d56SKrzysztof Kozlowski 11*be9f6d56SKrzysztof Kozlowski #include "pinctrl-lpass-lpi.h" 12*be9f6d56SKrzysztof Kozlowski 13*be9f6d56SKrzysztof Kozlowski enum lpass_lpi_functions { 14*be9f6d56SKrzysztof Kozlowski LPI_MUX_dmic1_clk, 15*be9f6d56SKrzysztof Kozlowski LPI_MUX_dmic1_data, 16*be9f6d56SKrzysztof Kozlowski LPI_MUX_dmic2_clk, 17*be9f6d56SKrzysztof Kozlowski LPI_MUX_dmic2_data, 18*be9f6d56SKrzysztof Kozlowski LPI_MUX_dmic3_clk, 19*be9f6d56SKrzysztof Kozlowski LPI_MUX_dmic3_data, 20*be9f6d56SKrzysztof Kozlowski LPI_MUX_i2s1_clk, 21*be9f6d56SKrzysztof Kozlowski LPI_MUX_i2s1_data, 22*be9f6d56SKrzysztof Kozlowski LPI_MUX_i2s1_ws, 23*be9f6d56SKrzysztof Kozlowski LPI_MUX_i2s2_clk, 24*be9f6d56SKrzysztof Kozlowski LPI_MUX_i2s2_data, 25*be9f6d56SKrzysztof Kozlowski LPI_MUX_i2s2_ws, 26*be9f6d56SKrzysztof Kozlowski LPI_MUX_qua_mi2s_data, 27*be9f6d56SKrzysztof Kozlowski LPI_MUX_qua_mi2s_sclk, 28*be9f6d56SKrzysztof Kozlowski LPI_MUX_qua_mi2s_ws, 29*be9f6d56SKrzysztof Kozlowski LPI_MUX_swr_rx_clk, 30*be9f6d56SKrzysztof Kozlowski LPI_MUX_swr_rx_data, 31*be9f6d56SKrzysztof Kozlowski LPI_MUX_swr_tx_clk, 32*be9f6d56SKrzysztof Kozlowski LPI_MUX_swr_tx_data, 33*be9f6d56SKrzysztof Kozlowski LPI_MUX_wsa_swr_clk, 34*be9f6d56SKrzysztof Kozlowski LPI_MUX_wsa_swr_data, 35*be9f6d56SKrzysztof Kozlowski LPI_MUX_gpio, 36*be9f6d56SKrzysztof Kozlowski LPI_MUX__, 37*be9f6d56SKrzysztof Kozlowski }; 38*be9f6d56SKrzysztof Kozlowski 39*be9f6d56SKrzysztof Kozlowski static int gpio0_pins[] = { 0 }; 40*be9f6d56SKrzysztof Kozlowski static int gpio1_pins[] = { 1 }; 41*be9f6d56SKrzysztof Kozlowski static int gpio2_pins[] = { 2 }; 42*be9f6d56SKrzysztof Kozlowski static int gpio3_pins[] = { 3 }; 43*be9f6d56SKrzysztof Kozlowski static int gpio4_pins[] = { 4 }; 44*be9f6d56SKrzysztof Kozlowski static int gpio5_pins[] = { 5 }; 45*be9f6d56SKrzysztof Kozlowski static int gpio6_pins[] = { 6 }; 46*be9f6d56SKrzysztof Kozlowski static int gpio7_pins[] = { 7 }; 47*be9f6d56SKrzysztof Kozlowski static int gpio8_pins[] = { 8 }; 48*be9f6d56SKrzysztof Kozlowski static int gpio9_pins[] = { 9 }; 49*be9f6d56SKrzysztof Kozlowski static int gpio10_pins[] = { 10 }; 50*be9f6d56SKrzysztof Kozlowski static int gpio11_pins[] = { 11 }; 51*be9f6d56SKrzysztof Kozlowski static int gpio12_pins[] = { 12 }; 52*be9f6d56SKrzysztof Kozlowski static int gpio13_pins[] = { 13 }; 53*be9f6d56SKrzysztof Kozlowski static int gpio14_pins[] = { 14 }; 54*be9f6d56SKrzysztof Kozlowski 55*be9f6d56SKrzysztof Kozlowski static const struct pinctrl_pin_desc sm8350_lpi_pins[] = { 56*be9f6d56SKrzysztof Kozlowski PINCTRL_PIN(0, "gpio0"), 57*be9f6d56SKrzysztof Kozlowski PINCTRL_PIN(1, "gpio1"), 58*be9f6d56SKrzysztof Kozlowski PINCTRL_PIN(2, "gpio2"), 59*be9f6d56SKrzysztof Kozlowski PINCTRL_PIN(3, "gpio3"), 60*be9f6d56SKrzysztof Kozlowski PINCTRL_PIN(4, "gpio4"), 61*be9f6d56SKrzysztof Kozlowski PINCTRL_PIN(5, "gpio5"), 62*be9f6d56SKrzysztof Kozlowski PINCTRL_PIN(6, "gpio6"), 63*be9f6d56SKrzysztof Kozlowski PINCTRL_PIN(7, "gpio7"), 64*be9f6d56SKrzysztof Kozlowski PINCTRL_PIN(8, "gpio8"), 65*be9f6d56SKrzysztof Kozlowski PINCTRL_PIN(9, "gpio9"), 66*be9f6d56SKrzysztof Kozlowski PINCTRL_PIN(10, "gpio10"), 67*be9f6d56SKrzysztof Kozlowski PINCTRL_PIN(11, "gpio11"), 68*be9f6d56SKrzysztof Kozlowski PINCTRL_PIN(12, "gpio12"), 69*be9f6d56SKrzysztof Kozlowski PINCTRL_PIN(13, "gpio13"), 70*be9f6d56SKrzysztof Kozlowski PINCTRL_PIN(14, "gpio14"), 71*be9f6d56SKrzysztof Kozlowski }; 72*be9f6d56SKrzysztof Kozlowski 73*be9f6d56SKrzysztof Kozlowski static const char * const swr_tx_clk_groups[] = { "gpio0" }; 74*be9f6d56SKrzysztof Kozlowski static const char * const swr_tx_data_groups[] = { "gpio1", "gpio2", "gpio5", "gpio14" }; 75*be9f6d56SKrzysztof Kozlowski static const char * const swr_rx_clk_groups[] = { "gpio3" }; 76*be9f6d56SKrzysztof Kozlowski static const char * const swr_rx_data_groups[] = { "gpio4", "gpio5" }; 77*be9f6d56SKrzysztof Kozlowski static const char * const dmic1_clk_groups[] = { "gpio6" }; 78*be9f6d56SKrzysztof Kozlowski static const char * const dmic1_data_groups[] = { "gpio7" }; 79*be9f6d56SKrzysztof Kozlowski static const char * const dmic2_clk_groups[] = { "gpio8" }; 80*be9f6d56SKrzysztof Kozlowski static const char * const dmic2_data_groups[] = { "gpio9" }; 81*be9f6d56SKrzysztof Kozlowski static const char * const i2s2_clk_groups[] = { "gpio10" }; 82*be9f6d56SKrzysztof Kozlowski static const char * const i2s2_ws_groups[] = { "gpio11" }; 83*be9f6d56SKrzysztof Kozlowski static const char * const dmic3_clk_groups[] = { "gpio12" }; 84*be9f6d56SKrzysztof Kozlowski static const char * const dmic3_data_groups[] = { "gpio13" }; 85*be9f6d56SKrzysztof Kozlowski static const char * const qua_mi2s_sclk_groups[] = { "gpio0" }; 86*be9f6d56SKrzysztof Kozlowski static const char * const qua_mi2s_ws_groups[] = { "gpio1" }; 87*be9f6d56SKrzysztof Kozlowski static const char * const qua_mi2s_data_groups[] = { "gpio2", "gpio3", "gpio4" }; 88*be9f6d56SKrzysztof Kozlowski static const char * const i2s1_clk_groups[] = { "gpio6" }; 89*be9f6d56SKrzysztof Kozlowski static const char * const i2s1_ws_groups[] = { "gpio7" }; 90*be9f6d56SKrzysztof Kozlowski static const char * const i2s1_data_groups[] = { "gpio8", "gpio9" }; 91*be9f6d56SKrzysztof Kozlowski static const char * const wsa_swr_clk_groups[] = { "gpio10" }; 92*be9f6d56SKrzysztof Kozlowski static const char * const wsa_swr_data_groups[] = { "gpio11" }; 93*be9f6d56SKrzysztof Kozlowski static const char * const i2s2_data_groups[] = { "gpio12", "gpio12" }; 94*be9f6d56SKrzysztof Kozlowski 95*be9f6d56SKrzysztof Kozlowski static const struct lpi_pingroup sm8350_groups[] = { 96*be9f6d56SKrzysztof Kozlowski LPI_PINGROUP(0, 0, swr_tx_clk, qua_mi2s_sclk, _, _), 97*be9f6d56SKrzysztof Kozlowski LPI_PINGROUP(1, 2, swr_tx_data, qua_mi2s_ws, _, _), 98*be9f6d56SKrzysztof Kozlowski LPI_PINGROUP(2, 4, swr_tx_data, qua_mi2s_data, _, _), 99*be9f6d56SKrzysztof Kozlowski LPI_PINGROUP(3, 8, swr_rx_clk, qua_mi2s_data, _, _), 100*be9f6d56SKrzysztof Kozlowski LPI_PINGROUP(4, 10, swr_rx_data, qua_mi2s_data, _, _), 101*be9f6d56SKrzysztof Kozlowski LPI_PINGROUP(5, 12, swr_tx_data, swr_rx_data, _, _), 102*be9f6d56SKrzysztof Kozlowski LPI_PINGROUP(6, LPI_NO_SLEW, dmic1_clk, i2s1_clk, _, _), 103*be9f6d56SKrzysztof Kozlowski LPI_PINGROUP(7, LPI_NO_SLEW, dmic1_data, i2s1_ws, _, _), 104*be9f6d56SKrzysztof Kozlowski LPI_PINGROUP(8, LPI_NO_SLEW, dmic2_clk, i2s1_data, _, _), 105*be9f6d56SKrzysztof Kozlowski LPI_PINGROUP(9, LPI_NO_SLEW, dmic2_data, i2s1_data, _, _), 106*be9f6d56SKrzysztof Kozlowski LPI_PINGROUP(10, 16, i2s2_clk, wsa_swr_clk, _, _), 107*be9f6d56SKrzysztof Kozlowski LPI_PINGROUP(11, 18, i2s2_ws, wsa_swr_data, _, _), 108*be9f6d56SKrzysztof Kozlowski LPI_PINGROUP(12, LPI_NO_SLEW, dmic3_clk, i2s2_data, _, _), 109*be9f6d56SKrzysztof Kozlowski LPI_PINGROUP(13, LPI_NO_SLEW, dmic3_data, i2s2_data, _, _), 110*be9f6d56SKrzysztof Kozlowski LPI_PINGROUP(14, 6, swr_tx_data, _, _, _), 111*be9f6d56SKrzysztof Kozlowski }; 112*be9f6d56SKrzysztof Kozlowski 113*be9f6d56SKrzysztof Kozlowski static const struct lpi_function sm8350_functions[] = { 114*be9f6d56SKrzysztof Kozlowski LPI_FUNCTION(dmic1_clk), 115*be9f6d56SKrzysztof Kozlowski LPI_FUNCTION(dmic1_data), 116*be9f6d56SKrzysztof Kozlowski LPI_FUNCTION(dmic2_clk), 117*be9f6d56SKrzysztof Kozlowski LPI_FUNCTION(dmic2_data), 118*be9f6d56SKrzysztof Kozlowski LPI_FUNCTION(dmic3_clk), 119*be9f6d56SKrzysztof Kozlowski LPI_FUNCTION(dmic3_data), 120*be9f6d56SKrzysztof Kozlowski LPI_FUNCTION(i2s1_clk), 121*be9f6d56SKrzysztof Kozlowski LPI_FUNCTION(i2s1_data), 122*be9f6d56SKrzysztof Kozlowski LPI_FUNCTION(i2s1_ws), 123*be9f6d56SKrzysztof Kozlowski LPI_FUNCTION(i2s2_clk), 124*be9f6d56SKrzysztof Kozlowski LPI_FUNCTION(i2s2_data), 125*be9f6d56SKrzysztof Kozlowski LPI_FUNCTION(i2s2_ws), 126*be9f6d56SKrzysztof Kozlowski LPI_FUNCTION(qua_mi2s_data), 127*be9f6d56SKrzysztof Kozlowski LPI_FUNCTION(qua_mi2s_sclk), 128*be9f6d56SKrzysztof Kozlowski LPI_FUNCTION(qua_mi2s_ws), 129*be9f6d56SKrzysztof Kozlowski LPI_FUNCTION(swr_rx_clk), 130*be9f6d56SKrzysztof Kozlowski LPI_FUNCTION(swr_rx_data), 131*be9f6d56SKrzysztof Kozlowski LPI_FUNCTION(swr_tx_clk), 132*be9f6d56SKrzysztof Kozlowski LPI_FUNCTION(swr_tx_data), 133*be9f6d56SKrzysztof Kozlowski LPI_FUNCTION(wsa_swr_clk), 134*be9f6d56SKrzysztof Kozlowski LPI_FUNCTION(wsa_swr_data), 135*be9f6d56SKrzysztof Kozlowski }; 136*be9f6d56SKrzysztof Kozlowski 137*be9f6d56SKrzysztof Kozlowski static const struct lpi_pinctrl_variant_data sm8350_lpi_data = { 138*be9f6d56SKrzysztof Kozlowski .pins = sm8350_lpi_pins, 139*be9f6d56SKrzysztof Kozlowski .npins = ARRAY_SIZE(sm8350_lpi_pins), 140*be9f6d56SKrzysztof Kozlowski .groups = sm8350_groups, 141*be9f6d56SKrzysztof Kozlowski .ngroups = ARRAY_SIZE(sm8350_groups), 142*be9f6d56SKrzysztof Kozlowski .functions = sm8350_functions, 143*be9f6d56SKrzysztof Kozlowski .nfunctions = ARRAY_SIZE(sm8350_functions), 144*be9f6d56SKrzysztof Kozlowski }; 145*be9f6d56SKrzysztof Kozlowski 146*be9f6d56SKrzysztof Kozlowski static const struct of_device_id lpi_pinctrl_of_match[] = { 147*be9f6d56SKrzysztof Kozlowski { 148*be9f6d56SKrzysztof Kozlowski .compatible = "qcom,sm8350-lpass-lpi-pinctrl", 149*be9f6d56SKrzysztof Kozlowski .data = &sm8350_lpi_data, 150*be9f6d56SKrzysztof Kozlowski }, 151*be9f6d56SKrzysztof Kozlowski { } 152*be9f6d56SKrzysztof Kozlowski }; 153*be9f6d56SKrzysztof Kozlowski MODULE_DEVICE_TABLE(of, lpi_pinctrl_of_match); 154*be9f6d56SKrzysztof Kozlowski 155*be9f6d56SKrzysztof Kozlowski static struct platform_driver lpi_pinctrl_driver = { 156*be9f6d56SKrzysztof Kozlowski .driver = { 157*be9f6d56SKrzysztof Kozlowski .name = "qcom-sm8350-lpass-lpi-pinctrl", 158*be9f6d56SKrzysztof Kozlowski .of_match_table = lpi_pinctrl_of_match, 159*be9f6d56SKrzysztof Kozlowski }, 160*be9f6d56SKrzysztof Kozlowski .probe = lpi_pinctrl_probe, 161*be9f6d56SKrzysztof Kozlowski .remove = lpi_pinctrl_remove, 162*be9f6d56SKrzysztof Kozlowski }; 163*be9f6d56SKrzysztof Kozlowski module_platform_driver(lpi_pinctrl_driver); 164*be9f6d56SKrzysztof Kozlowski 165*be9f6d56SKrzysztof Kozlowski MODULE_AUTHOR("Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>"); 166*be9f6d56SKrzysztof Kozlowski MODULE_DESCRIPTION("QTI SM8350 LPI GPIO pin control driver"); 167*be9f6d56SKrzysztof Kozlowski MODULE_LICENSE("GPL"); 168