| 1 |
// SPDX-License-Identifier: GPL-2.0-only |
| 2 |
/* |
| 3 |
* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. |
| 4 |
* Copyright (c) 2020, 2023 Linaro Ltd. |
| 5 |
*/ |
| 6 |
|
| 7 |
#include <linux/gpio/driver.h> |
| 8 |
#include <linux/module.h> |
| 9 |
#include <linux/platform_device.h> |
| 10 |
|
| 11 |
#include "pinctrl-lpass-lpi.h" |
| 12 |
|
| 13 |
enum lpass_lpi_functions { |
| 14 |
LPI_MUX_dmic01_clk, |
| 15 |
LPI_MUX_dmic01_data, |
| 16 |
LPI_MUX_dmic23_clk, |
| 17 |
LPI_MUX_dmic23_data, |
| 18 |
LPI_MUX_i2s1_clk, |
| 19 |
LPI_MUX_i2s1_data, |
| 20 |
LPI_MUX_i2s1_ws, |
| 21 |
LPI_MUX_i2s2_clk, |
| 22 |
LPI_MUX_i2s2_data, |
| 23 |
LPI_MUX_i2s2_ws, |
| 24 |
LPI_MUX_i2s3_clk, |
| 25 |
LPI_MUX_i2s3_data, |
| 26 |
LPI_MUX_i2s3_ws, |
| 27 |
LPI_MUX_qua_mi2s_data, |
| 28 |
LPI_MUX_qua_mi2s_sclk, |
| 29 |
LPI_MUX_qua_mi2s_ws, |
| 30 |
LPI_MUX_swr_rx_clk, |
| 31 |
LPI_MUX_swr_rx_data, |
| 32 |
LPI_MUX_swr_tx_clk, |
| 33 |
LPI_MUX_swr_tx_data, |
| 34 |
LPI_MUX_wsa_mclk, |
| 35 |
LPI_MUX_gpio, |
| 36 |
LPI_MUX__, |
| 37 |
}; |
| 38 |
|
| 39 |
static const struct pinctrl_pin_desc sm6115_lpi_pins[] = { |
| 40 |
PINCTRL_PIN(0, "gpio0"), |
| 41 |
PINCTRL_PIN(1, "gpio1"), |
| 42 |
PINCTRL_PIN(2, "gpio2"), |
| 43 |
PINCTRL_PIN(3, "gpio3"), |
| 44 |
PINCTRL_PIN(4, "gpio4"), |
| 45 |
PINCTRL_PIN(5, "gpio5"), |
| 46 |
PINCTRL_PIN(6, "gpio6"), |
| 47 |
PINCTRL_PIN(7, "gpio7"), |
| 48 |
PINCTRL_PIN(8, "gpio8"), |
| 49 |
PINCTRL_PIN(9, "gpio9"), |
| 50 |
PINCTRL_PIN(10, "gpio10"), |
| 51 |
PINCTRL_PIN(11, "gpio11"), |
| 52 |
PINCTRL_PIN(12, "gpio12"), |
| 53 |
PINCTRL_PIN(13, "gpio13"), |
| 54 |
PINCTRL_PIN(14, "gpio14"), |
| 55 |
PINCTRL_PIN(15, "gpio15"), |
| 56 |
PINCTRL_PIN(16, "gpio16"), |
| 57 |
PINCTRL_PIN(17, "gpio17"), |
| 58 |
PINCTRL_PIN(18, "gpio18"), |
| 59 |
}; |
| 60 |
|
| 61 |
static const char * const dmic01_clk_groups[] = { "gpio6" }; |
| 62 |
static const char * const dmic01_data_groups[] = { "gpio7" }; |
| 63 |
static const char * const dmic23_clk_groups[] = { "gpio8" }; |
| 64 |
static const char * const dmic23_data_groups[] = { "gpio9" }; |
| 65 |
static const char * const i2s1_clk_groups[] = { "gpio6" }; |
| 66 |
static const char * const i2s1_data_groups[] = { "gpio8", "gpio9" }; |
| 67 |
static const char * const i2s1_ws_groups[] = { "gpio7" }; |
| 68 |
static const char * const i2s2_clk_groups[] = { "gpio10" }; |
| 69 |
static const char * const i2s2_data_groups[] = { "gpio12", "gpio13" }; |
| 70 |
static const char * const i2s2_ws_groups[] = { "gpio11" }; |
| 71 |
static const char * const i2s3_clk_groups[] = { "gpio14" }; |
| 72 |
static const char * const i2s3_data_groups[] = { "gpio16", "gpio17" }; |
| 73 |
static const char * const i2s3_ws_groups[] = { "gpio15" }; |
| 74 |
static const char * const qua_mi2s_data_groups[] = { "gpio2", "gpio3", "gpio4", "gpio5" }; |
| 75 |
static const char * const qua_mi2s_sclk_groups[] = { "gpio0" }; |
| 76 |
static const char * const qua_mi2s_ws_groups[] = { "gpio1" }; |
| 77 |
static const char * const swr_rx_clk_groups[] = { "gpio3" }; |
| 78 |
static const char * const swr_rx_data_groups[] = { "gpio4", "gpio5" }; |
| 79 |
static const char * const swr_tx_clk_groups[] = { "gpio0" }; |
| 80 |
static const char * const swr_tx_data_groups[] = { "gpio1", "gpio2" }; |
| 81 |
static const char * const wsa_mclk_groups[] = { "gpio18" }; |
| 82 |
|
| 83 |
static const struct lpi_pingroup sm6115_groups[] = { |
| 84 |
LPI_PINGROUP(0, 0, swr_tx_clk, qua_mi2s_sclk, _, _), |
| 85 |
LPI_PINGROUP(1, 2, swr_tx_data, qua_mi2s_ws, _, _), |
| 86 |
LPI_PINGROUP(2, 4, swr_tx_data, qua_mi2s_data, _, _), |
| 87 |
LPI_PINGROUP(3, 8, swr_rx_clk, qua_mi2s_data, _, _), |
| 88 |
LPI_PINGROUP(4, 10, swr_rx_data, qua_mi2s_data, _, _), |
| 89 |
LPI_PINGROUP(5, 12, swr_rx_data, _, qua_mi2s_data, _), |
| 90 |
LPI_PINGROUP(6, LPI_NO_SLEW, dmic01_clk, i2s1_clk, _, _), |
| 91 |
LPI_PINGROUP(7, LPI_NO_SLEW, dmic01_data, i2s1_ws, _, _), |
| 92 |
LPI_PINGROUP(8, LPI_NO_SLEW, dmic23_clk, i2s1_data, _, _), |
| 93 |
LPI_PINGROUP(9, LPI_NO_SLEW, dmic23_data, i2s1_data, _, _), |
| 94 |
LPI_PINGROUP(10, LPI_NO_SLEW, i2s2_clk, _, _, _), |
| 95 |
LPI_PINGROUP(11, LPI_NO_SLEW, i2s2_ws, _, _, _), |
| 96 |
LPI_PINGROUP(12, LPI_NO_SLEW, _, i2s2_data, _, _), |
| 97 |
LPI_PINGROUP(13, LPI_NO_SLEW, _, i2s2_data, _, _), |
| 98 |
LPI_PINGROUP(14, LPI_NO_SLEW, i2s3_clk, _, _, _), |
| 99 |
LPI_PINGROUP(15, LPI_NO_SLEW, i2s3_ws, _, _, _), |
| 100 |
LPI_PINGROUP(16, LPI_NO_SLEW, i2s3_data, _, _, _), |
| 101 |
LPI_PINGROUP(17, LPI_NO_SLEW, i2s3_data, _, _, _), |
| 102 |
LPI_PINGROUP(18, 14, wsa_mclk, _, _, _), |
| 103 |
}; |
| 104 |
|
| 105 |
static const struct lpi_function sm6115_functions[] = { |
| 106 |
LPI_FUNCTION(dmic01_clk), |
| 107 |
LPI_FUNCTION(dmic01_data), |
| 108 |
LPI_FUNCTION(dmic23_clk), |
| 109 |
LPI_FUNCTION(dmic23_data), |
| 110 |
LPI_FUNCTION(i2s1_clk), |
| 111 |
LPI_FUNCTION(i2s1_data), |
| 112 |
LPI_FUNCTION(i2s1_ws), |
| 113 |
LPI_FUNCTION(i2s2_clk), |
| 114 |
LPI_FUNCTION(i2s2_data), |
| 115 |
LPI_FUNCTION(i2s2_ws), |
| 116 |
LPI_FUNCTION(i2s3_clk), |
| 117 |
LPI_FUNCTION(i2s3_data), |
| 118 |
LPI_FUNCTION(i2s3_ws), |
| 119 |
LPI_FUNCTION(qua_mi2s_data), |
| 120 |
LPI_FUNCTION(qua_mi2s_sclk), |
| 121 |
LPI_FUNCTION(qua_mi2s_ws), |
| 122 |
LPI_FUNCTION(swr_rx_clk), |
| 123 |
LPI_FUNCTION(swr_rx_data), |
| 124 |
LPI_FUNCTION(swr_tx_clk), |
| 125 |
LPI_FUNCTION(swr_tx_data), |
| 126 |
LPI_FUNCTION(wsa_mclk), |
| 127 |
}; |
| 128 |
|
| 129 |
static const struct lpi_pinctrl_variant_data sm6115_lpi_data = { |
| 130 |
.pins = sm6115_lpi_pins, |
| 131 |
.npins = ARRAY_SIZE(sm6115_lpi_pins), |
| 132 |
.groups = sm6115_groups, |
| 133 |
.ngroups = ARRAY_SIZE(sm6115_groups), |
| 134 |
.functions = sm6115_functions, |
| 135 |
.nfunctions = ARRAY_SIZE(sm6115_functions), |
| 136 |
}; |
| 137 |
|
| 138 |
static const struct of_device_id lpi_pinctrl_of_match[] = { |
| 139 |
{ .compatible = "qcom,sm6115-lpass-lpi-pinctrl", .data = &sm6115_lpi_data }, |
| 140 |
{ } |
| 141 |
}; |
| 142 |
MODULE_DEVICE_TABLE(of, lpi_pinctrl_of_match); |
| 143 |
|
| 144 |
static struct platform_driver lpi_pinctrl_driver = { |
| 145 |
.driver = { |
| 146 |
.name = "qcom-sm6115-lpass-lpi-pinctrl", |
| 147 |
.of_match_table = lpi_pinctrl_of_match, |
| 148 |
}, |
| 149 |
.probe = lpi_pinctrl_probe, |
| 150 |
.remove = lpi_pinctrl_remove, |
| 151 |
}; |
| 152 |
|
| 153 |
module_platform_driver(lpi_pinctrl_driver); |
| 154 |
MODULE_DESCRIPTION("QTI SM6115 LPI GPIO pin control driver"); |
| 155 |
MODULE_LICENSE("GPL"); |