[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250814-james-nxp-lpspi-v1-6-9586d7815d14@linaro.org>
Date: Thu, 14 Aug 2025 17:06:46 +0100
From: James Clark <james.clark@...aro.org>
To: Frank Li <Frank.Li@....com>, Mark Brown <broonie@...nel.org>,
Clark Wang <xiaoning.wang@....com>, Fugang Duan <B38611@...escale.com>,
Gao Pan <pandy.gao@....com>, Fugang Duan <fugang.duan@....com>,
Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, Shawn Guo <shawnguo@...nel.org>,
Sascha Hauer <s.hauer@...gutronix.de>, Fabio Estevam <festevam@...il.com>,
Larisa Grigore <larisa.grigore@....nxp.com>,
Larisa Grigore <larisa.grigore@....com>,
Ghennadi Procopciuc <ghennadi.procopciuc@....com>,
Ciprianmarian Costea <ciprianmarian.costea@....com>, s32@....com
Cc: James Clark <james.clark@...aro.org>, linux-spi@...r.kernel.org,
imx@...ts.linux.dev, linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org
Subject: [PATCH 06/13] spi: spi-fsl-lpspi: Add DT property to override
default pin config
This allows the SIN and SOUT pins to be flipped. Use an enum instead of
a bool even though we only support 2 modes so that the other two half
duplex modes can also be used in the future, if the driver ever supports
them.
If no property is specified, continue with the old defaults.
Signed-off-by: James Clark <james.clark@...aro.org>
---
drivers/spi/spi-fsl-lpspi.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
index 816e48bbc810..98da6a5d7013 100644
--- a/drivers/spi/spi-fsl-lpspi.c
+++ b/drivers/spi/spi-fsl-lpspi.c
@@ -88,6 +88,13 @@
#define SR_CLEAR_MASK GENMASK(13, 8)
+static const char * const pincfgs[] = {
+ [CFGR1_PINCFG_SIN_IN_SOUT_OUT] = "sin-in-sout-out",
+ [CFGR1_PINCFG_SIN_ONLY] = "sin-only",
+ [CFGR1_PINCFG_SOUT_ONLY] = "sout-only",
+ [CFGR1_PINCFG_SOUT_IN_SIN_OUT] = "sout-in-sin-out",
+};
+
struct fsl_lpspi_devtype_data {
u8 prescale_max;
};
@@ -417,18 +424,27 @@ static int fsl_lpspi_config(struct fsl_lpspi_data *fsl_lpspi)
{
u32 temp = 0;
int ret;
+ const char *pincfg_str;
u8 pincfg;
if (!fsl_lpspi->is_target) {
ret = fsl_lpspi_set_bitrate(fsl_lpspi);
if (ret)
return ret;
+
+ temp |= CFGR1_HOST;
}
fsl_lpspi_set_watermark(fsl_lpspi);
- if (!fsl_lpspi->is_target) {
- temp |= CFGR1_HOST;
+ if (!of_property_read_string(fsl_lpspi->dev->of_node,
+ "nxp,lpspi-pincfg", &pincfg_str)) {
+ pincfg = match_string(pincfgs, ARRAY_SIZE(pincfgs), pincfg_str);
+
+ if (pincfg < 0 || pincfg == CFGR1_PINCFG_SOUT_ONLY ||
+ pincfg == CFGR1_PINCFG_SIN_ONLY)
+ return -EINVAL;
+ } else if (!fsl_lpspi->is_target) {
pincfg = CFGR1_PINCFG_SIN_IN_SOUT_OUT;
} else {
pincfg = CFGR1_PINCFG_SOUT_IN_SIN_OUT;
--
2.34.1
Powered by blists - more mailing lists