Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
0004  * ALSA SoC platform-machine driver for QTi LPASS
0005  */
0006 
0007 #include <linux/gpio/driver.h>
0008 #include <linux/module.h>
0009 #include <linux/platform_device.h>
0010 
0011 #include "pinctrl-lpass-lpi.h"
0012 
0013 enum lpass_lpi_functions {
0014     LPI_MUX_dmic1_clk,
0015     LPI_MUX_dmic1_data,
0016     LPI_MUX_dmic2_clk,
0017     LPI_MUX_dmic2_data,
0018     LPI_MUX_dmic3_clk,
0019     LPI_MUX_dmic3_data,
0020     LPI_MUX_i2s1_clk,
0021     LPI_MUX_i2s1_data,
0022     LPI_MUX_i2s1_ws,
0023     LPI_MUX_i2s2_clk,
0024     LPI_MUX_i2s2_data,
0025     LPI_MUX_i2s2_ws,
0026     LPI_MUX_qua_mi2s_data,
0027     LPI_MUX_qua_mi2s_sclk,
0028     LPI_MUX_qua_mi2s_ws,
0029     LPI_MUX_swr_rx_clk,
0030     LPI_MUX_swr_rx_data,
0031     LPI_MUX_swr_tx_clk,
0032     LPI_MUX_swr_tx_data,
0033     LPI_MUX_wsa_swr_clk,
0034     LPI_MUX_wsa_swr_data,
0035     LPI_MUX_gpio,
0036     LPI_MUX__,
0037 };
0038 
0039 static int gpio0_pins[] = { 0 };
0040 static int gpio1_pins[] = { 1 };
0041 static int gpio2_pins[] = { 2 };
0042 static int gpio3_pins[] = { 3 };
0043 static int gpio4_pins[] = { 4 };
0044 static int gpio5_pins[] = { 5 };
0045 static int gpio6_pins[] = { 6 };
0046 static int gpio7_pins[] = { 7 };
0047 static int gpio8_pins[] = { 8 };
0048 static int gpio9_pins[] = { 9 };
0049 static int gpio10_pins[] = { 10 };
0050 static int gpio11_pins[] = { 11 };
0051 static int gpio12_pins[] = { 12 };
0052 static int gpio13_pins[] = { 13 };
0053 static int gpio14_pins[] = { 14 };
0054 
0055 static const struct pinctrl_pin_desc sc7280_lpi_pins[] = {
0056     PINCTRL_PIN(0, "gpio0"),
0057     PINCTRL_PIN(1, "gpio1"),
0058     PINCTRL_PIN(2, "gpio2"),
0059     PINCTRL_PIN(3, "gpio3"),
0060     PINCTRL_PIN(4, "gpio4"),
0061     PINCTRL_PIN(5, "gpio5"),
0062     PINCTRL_PIN(6, "gpio6"),
0063     PINCTRL_PIN(7, "gpio7"),
0064     PINCTRL_PIN(8, "gpio8"),
0065     PINCTRL_PIN(9, "gpio9"),
0066     PINCTRL_PIN(10, "gpio10"),
0067     PINCTRL_PIN(11, "gpio11"),
0068     PINCTRL_PIN(12, "gpio12"),
0069     PINCTRL_PIN(13, "gpio13"),
0070     PINCTRL_PIN(14, "gpio14"),
0071 };
0072 
0073 static const char * const swr_tx_clk_groups[] = { "gpio0" };
0074 static const char * const swr_tx_data_groups[] = { "gpio1", "gpio2", "gpio14" };
0075 static const char * const swr_rx_clk_groups[] = { "gpio3" };
0076 static const char * const swr_rx_data_groups[] = { "gpio4", "gpio5" };
0077 static const char * const dmic1_clk_groups[] = { "gpio6" };
0078 static const char * const dmic1_data_groups[] = { "gpio7" };
0079 static const char * const dmic2_clk_groups[] = { "gpio8" };
0080 static const char * const dmic2_data_groups[] = { "gpio9" };
0081 static const char * const i2s2_clk_groups[] = { "gpio10" };
0082 static const char * const i2s2_ws_groups[] = { "gpio11" };
0083 static const char * const dmic3_clk_groups[] = { "gpio12" };
0084 static const char * const dmic3_data_groups[] = { "gpio13" };
0085 static const char * const qua_mi2s_sclk_groups[] = { "gpio0" };
0086 static const char * const qua_mi2s_ws_groups[] = { "gpio1" };
0087 static const char * const qua_mi2s_data_groups[] = { "gpio2", "gpio3", "gpio4" };
0088 static const char * const i2s1_clk_groups[] = { "gpio6" };
0089 static const char * const i2s1_ws_groups[] = { "gpio7" };
0090 static const char * const i2s1_data_groups[] = { "gpio8", "gpio9" };
0091 static const char * const wsa_swr_clk_groups[] = { "gpio10" };
0092 static const char * const wsa_swr_data_groups[] = { "gpio11" };
0093 static const char * const i2s2_data_groups[] = { "gpio12", "gpio13" };
0094 
0095 static const struct lpi_pingroup sc7280_groups[] = {
0096     LPI_PINGROUP(0, 0, swr_tx_clk, qua_mi2s_sclk, _, _),
0097     LPI_PINGROUP(1, 2, swr_tx_data, qua_mi2s_ws, _, _),
0098     LPI_PINGROUP(2, 4, swr_tx_data, qua_mi2s_data, _, _),
0099     LPI_PINGROUP(3, 8, swr_rx_clk, qua_mi2s_data, _, _),
0100     LPI_PINGROUP(4, 10, swr_rx_data, qua_mi2s_data, _, _),
0101     LPI_PINGROUP(5, 12, swr_rx_data, _, _, _),
0102     LPI_PINGROUP(6, LPI_NO_SLEW, dmic1_clk, i2s1_clk, _,  _),
0103     LPI_PINGROUP(7, LPI_NO_SLEW, dmic1_data, i2s1_ws, _, _),
0104     LPI_PINGROUP(8, LPI_NO_SLEW, dmic2_clk, i2s1_data, _, _),
0105     LPI_PINGROUP(9, LPI_NO_SLEW, dmic2_data, i2s1_data, _, _),
0106     LPI_PINGROUP(10, 16, i2s2_clk, wsa_swr_clk, _, _),
0107     LPI_PINGROUP(11, 18, i2s2_ws, wsa_swr_data, _, _),
0108     LPI_PINGROUP(12, LPI_NO_SLEW, dmic3_clk, i2s2_data, _, _),
0109     LPI_PINGROUP(13, LPI_NO_SLEW, dmic3_data, i2s2_data, _, _),
0110     LPI_PINGROUP(14, 6, swr_tx_data, _, _, _),
0111 };
0112 
0113 static const struct lpi_function sc7280_functions[] = {
0114     LPI_FUNCTION(dmic1_clk),
0115     LPI_FUNCTION(dmic1_data),
0116     LPI_FUNCTION(dmic2_clk),
0117     LPI_FUNCTION(dmic2_data),
0118     LPI_FUNCTION(dmic3_clk),
0119     LPI_FUNCTION(dmic3_data),
0120     LPI_FUNCTION(i2s1_clk),
0121     LPI_FUNCTION(i2s1_data),
0122     LPI_FUNCTION(i2s1_ws),
0123     LPI_FUNCTION(i2s2_clk),
0124     LPI_FUNCTION(i2s2_data),
0125     LPI_FUNCTION(i2s2_ws),
0126     LPI_FUNCTION(qua_mi2s_data),
0127     LPI_FUNCTION(qua_mi2s_sclk),
0128     LPI_FUNCTION(qua_mi2s_ws),
0129     LPI_FUNCTION(swr_rx_clk),
0130     LPI_FUNCTION(swr_rx_data),
0131     LPI_FUNCTION(swr_tx_clk),
0132     LPI_FUNCTION(swr_tx_data),
0133     LPI_FUNCTION(wsa_swr_clk),
0134     LPI_FUNCTION(wsa_swr_data),
0135 };
0136 
0137 static const struct lpi_pinctrl_variant_data sc7280_lpi_data = {
0138     .pins = sc7280_lpi_pins,
0139     .npins = ARRAY_SIZE(sc7280_lpi_pins),
0140     .groups = sc7280_groups,
0141     .ngroups = ARRAY_SIZE(sc7280_groups),
0142     .functions = sc7280_functions,
0143     .nfunctions = ARRAY_SIZE(sc7280_functions),
0144 };
0145 
0146 static const struct of_device_id lpi_pinctrl_of_match[] = {
0147     {
0148            .compatible = "qcom,sc7280-lpass-lpi-pinctrl",
0149            .data = &sc7280_lpi_data,
0150     },
0151     { }
0152 };
0153 MODULE_DEVICE_TABLE(of, lpi_pinctrl_of_match);
0154 
0155 static struct platform_driver lpi_pinctrl_driver = {
0156     .driver = {
0157            .name = "qcom-sc7280-lpass-lpi-pinctrl",
0158            .of_match_table = lpi_pinctrl_of_match,
0159     },
0160     .probe = lpi_pinctrl_probe,
0161     .remove = lpi_pinctrl_remove,
0162 };
0163 
0164 module_platform_driver(lpi_pinctrl_driver);
0165 MODULE_DESCRIPTION("QTI SC7280 LPI GPIO pin control driver");
0166 MODULE_LICENSE("GPL");