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