Skip to content

Commit 31a2b4f

Browse files
decsnykartben
authored andcommitted
drivers: spi_nxp_lpspi: Add tristate output config
Add DT property to configure the LPSPI instance to use tristated output instead of retained output when PCS is negated. Turn on the config on a couple boards for test coverage. Signed-off-by: Declan Snyder <[email protected]>
1 parent 00ccbce commit 31a2b4f

File tree

5 files changed

+13
-0
lines changed

5 files changed

+13
-0
lines changed

boards/nxp/mimxrt1050_evk/mimxrt1050_evk.dtsi

+1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ zephyr_lcdif: &lcdif {
166166
dma-names = "rx", "tx";
167167
pinctrl-0 = <&pinmux_lpspi1>;
168168
pinctrl-names = "default";
169+
tristate-output;
169170
};
170171

171172
&lpspi3 {

boards/nxp/mimxrt1064_evk/mimxrt1064_evk.dts

+1
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ zephyr_udc0: &usb1 {
304304
/* DMA channels 0 and 1, muxed to LPSPI1 RX and TX */
305305
dmas = <&edma0 0 13>, <&edma0 1 14>;
306306
dma-names = "rx", "tx";
307+
tristate-output;
307308
pinctrl-0 = <&pinmux_lpspi1>;
308309
pinctrl-names = "default";
309310
};

drivers/spi/spi_nxp_lpspi/spi_nxp_lpspi_common.c

+2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ int spi_mcux_configure(const struct device *dev, const struct spi_config *spi_cf
8989
master_config.lastSckToPcsDelayInNanoSec = config->sck_pcs_delay;
9090
master_config.betweenTransferDelayInNanoSec = config->transfer_delay;
9191
master_config.pinCfg = config->data_pin_config;
92+
master_config.dataOutConfig = config->output_config ? kLpspiDataOutTristate :
93+
kLpspiDataOutRetained;
9294

9395
LPSPI_MasterInit(base, &master_config, clock_freq);
9496
LPSPI_SetDummyData(base, 0);

drivers/spi/spi_nxp_lpspi/spi_nxp_lpspi_priv.h

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ struct spi_mcux_config {
4141
uint32_t transfer_delay;
4242
const struct pinctrl_dev_config *pincfg;
4343
lpspi_pin_config_t data_pin_config;
44+
bool output_config;
4445
};
4546

4647
#ifdef CONFIG_SPI_MCUX_LPSPI_DMA
@@ -118,6 +119,7 @@ int spi_mcux_release(const struct device *dev, const struct spi_config *spi_cfg)
118119
DT_INST_PROP(n, transfer_delay)), \
119120
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
120121
.data_pin_config = DT_INST_ENUM_IDX(n, data_pin_config), \
122+
.output_config = DT_INST_PROP(n, tristate_output), \
121123
};
122124

123125
#define SPI_NXP_LPSPI_COMMON_INIT(n) \

dts/bindings/spi/nxp,lpspi.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,10 @@ properties:
4343
description: |
4444
Configures which pins (SDO and SDI) are used for input and output data
4545
during single bit transfers.
46+
47+
tristate-output:
48+
type: boolean
49+
description:
50+
Configures whether or not the output data is tristated between accesses
51+
(when PCS is negated). If set, the output will be tristated when PCS is negated,
52+
otherwise the output line retains the last value when PCS is negated.

0 commit comments

Comments
 (0)