Skip to content

Commit 9a24cdc

Browse files
committed
spi_nxp_lpspi: Remove mcux branding from tokens
Since these drivers mainly do not use MCUX except for the configure function (which will soon also be changed), change namespace prefix to lpspi_ instead of spi_mcux_ to avoid confusion. Also improve descriptions of kconfigs to clarify what they are for. Not changing the kconfig names for now since they are user-facing. Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
1 parent de409dd commit 9a24cdc

File tree

5 files changed

+98
-90
lines changed

5 files changed

+98
-90
lines changed

drivers/spi/spi_nxp_lpspi/Kconfig

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2018, 2024 NXP
1+
# Copyright 2018, 2024-2025 NXP
22
# SPDX-License-Identifier: Apache-2.0
33

44
config SPI_MCUX_LPSPI
@@ -8,24 +8,32 @@ config SPI_MCUX_LPSPI
88
depends on CLOCK_CONTROL
99
select PINCTRL
1010
help
11-
Enable support for NXP LPSPI.
11+
Enable driver support for NXP LPSPI.
1212

1313
if SPI_MCUX_LPSPI
1414

1515
config SPI_MCUX_LPSPI_DMA
16-
bool "MCUX LPSPI SPI DMA Support"
16+
bool "NXP LPSPI DMA-based Driver"
1717
default y
1818
select DMA
1919
depends on $(dt_compat_any_has_prop,$(DT_COMPAT_NXP_LPSPI),dmas)
2020
help
21-
Enable the SPI DMA mode for SPI instances
22-
that enable dma channels in their device tree node.
21+
Enable DMA-based transfers for LPSPI peripherals
22+
that have a dmas property specified in their DT node.
23+
The DMA based driver prioritizes bandwidth over latency, due to
24+
DMA being more efficient for larger data transfers, to avoid CPU
25+
having to be utilized to do the work. However, setting up a DMA
26+
transfer is more complicated setup than just starting the transfer
27+
immediately with CPU, so there could be more latency between
28+
the point of requesting a transfer and when it actually starts.
2329

2430
config SPI_MCUX_LPSPI_CPU
25-
bool "NXP MCUX LPSPI driver"
31+
bool "NXP LPSPI CPU-based driver"
2632
default y
2733
depends on $(dt_compat_any_not_has_prop,$(DT_COMPAT_NXP_LPSPI),dmas) || !SPI_MCUX_LPSPI_DMA
2834
help
29-
Use the CPU-based LPSPI driver.
35+
Enable "normal" CPU based SPI driver for LPSPI.
36+
This has lower latency than DMA-based driver but over the
37+
longer transfers will likely have less bandwidth and use more CPU time.
3038

3139
endif # SPI_MCUX_LPSPI

drivers/spi/spi_nxp_lpspi/spi_nxp_lpspi.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#define DT_DRV_COMPAT nxp_lpspi
88

99
#include <zephyr/logging/log.h>
10-
LOG_MODULE_REGISTER(spi_mcux_lpspi, CONFIG_SPI_LOG_LEVEL);
10+
LOG_MODULE_REGISTER(spi_lpspi, CONFIG_SPI_LOG_LEVEL);
1111

1212
#include "spi_nxp_lpspi_priv.h"
1313

@@ -30,7 +30,7 @@ static inline uint8_t tx_fifo_cur_len(LPSPI_Type *base)
3030
static inline void lpspi_rx_word_write_bytes(const struct device *dev, size_t offset)
3131
{
3232
LPSPI_Type *base = (LPSPI_Type *)DEVICE_MMIO_NAMED_GET(dev, reg_base);
33-
struct spi_mcux_data *data = dev->data;
33+
struct lpspi_data *data = dev->data;
3434
struct lpspi_driver_data *lpspi_data = (struct lpspi_driver_data *)data->driver_data;
3535
struct spi_context *ctx = &data->ctx;
3636
uint8_t num_bytes = MIN(lpspi_data->word_size_bytes, ctx->rx_len);
@@ -50,7 +50,7 @@ static inline void lpspi_rx_word_write_bytes(const struct device *dev, size_t of
5050
/* Reads a maximum number of words from RX fifo and writes them to the remainder of the RX buf */
5151
static inline size_t lpspi_rx_buf_write_words(const struct device *dev, uint8_t max_read)
5252
{
53-
struct spi_mcux_data *data = dev->data;
53+
struct lpspi_data *data = dev->data;
5454
struct lpspi_driver_data *lpspi_data = (struct lpspi_driver_data *)data->driver_data;
5555
struct spi_context *ctx = &data->ctx;
5656
size_t buf_len = DIV_ROUND_UP(ctx->rx_len, lpspi_data->word_size_bytes);
@@ -69,7 +69,7 @@ static inline size_t lpspi_rx_buf_write_words(const struct device *dev, uint8_t
6969
static inline void lpspi_handle_rx_irq(const struct device *dev)
7070
{
7171
LPSPI_Type *base = (LPSPI_Type *)DEVICE_MMIO_NAMED_GET(dev, reg_base);
72-
struct spi_mcux_data *data = dev->data;
72+
struct lpspi_data *data = dev->data;
7373
struct lpspi_driver_data *lpspi_data = (struct lpspi_driver_data *)data->driver_data;
7474
struct spi_context *ctx = &data->ctx;
7575
uint8_t rx_fsr = rx_fifo_cur_len(base);
@@ -98,7 +98,7 @@ static inline void lpspi_handle_rx_irq(const struct device *dev)
9898

9999
static inline uint32_t lpspi_next_tx_word(const struct device *dev, int offset)
100100
{
101-
struct spi_mcux_data *data = dev->data;
101+
struct lpspi_data *data = dev->data;
102102
struct lpspi_driver_data *lpspi_data = (struct lpspi_driver_data *)data->driver_data;
103103
struct spi_context *ctx = &data->ctx;
104104
const uint8_t *byte = ctx->tx_buf + offset;
@@ -115,7 +115,7 @@ static inline uint32_t lpspi_next_tx_word(const struct device *dev, int offset)
115115
static inline void lpspi_fill_tx_fifo(const struct device *dev)
116116
{
117117
LPSPI_Type *base = (LPSPI_Type *)DEVICE_MMIO_NAMED_GET(dev, reg_base);
118-
struct spi_mcux_data *data = dev->data;
118+
struct lpspi_data *data = dev->data;
119119
struct lpspi_driver_data *lpspi_data = (struct lpspi_driver_data *)data->driver_data;
120120
size_t bytes_in_xfer = lpspi_data->fill_len * lpspi_data->word_size_bytes;
121121
size_t offset;
@@ -130,7 +130,7 @@ static inline void lpspi_fill_tx_fifo(const struct device *dev)
130130
static void lpspi_fill_tx_fifo_nop(const struct device *dev)
131131
{
132132
LPSPI_Type *base = (LPSPI_Type *)DEVICE_MMIO_NAMED_GET(dev, reg_base);
133-
struct spi_mcux_data *data = dev->data;
133+
struct lpspi_data *data = dev->data;
134134
struct lpspi_driver_data *lpspi_data = (struct lpspi_driver_data *)data->driver_data;
135135

136136
for (int i = 0; i < lpspi_data->fill_len; i++) {
@@ -142,8 +142,8 @@ static void lpspi_fill_tx_fifo_nop(const struct device *dev)
142142

143143
static void lpspi_next_tx_fill(const struct device *dev)
144144
{
145-
const struct spi_mcux_config *config = dev->config;
146-
struct spi_mcux_data *data = dev->data;
145+
const struct lpspi_config *config = dev->config;
146+
struct lpspi_data *data = dev->data;
147147
struct lpspi_driver_data *lpspi_data = (struct lpspi_driver_data *)data->driver_data;
148148
struct spi_context *ctx = &data->ctx;
149149
size_t max_chunk;
@@ -163,7 +163,7 @@ static void lpspi_next_tx_fill(const struct device *dev)
163163
static inline void lpspi_handle_tx_irq(const struct device *dev)
164164
{
165165
LPSPI_Type *base = (LPSPI_Type *)DEVICE_MMIO_NAMED_GET(dev, reg_base);
166-
struct spi_mcux_data *data = dev->data;
166+
struct lpspi_data *data = dev->data;
167167
struct lpspi_driver_data *lpspi_data = (struct lpspi_driver_data *)data->driver_data;
168168
struct spi_context *ctx = &data->ctx;
169169

@@ -182,8 +182,8 @@ static inline void lpspi_handle_tx_irq(const struct device *dev)
182182
static void lpspi_isr(const struct device *dev)
183183
{
184184
LPSPI_Type *base = (LPSPI_Type *)DEVICE_MMIO_NAMED_GET(dev, reg_base);
185-
const struct spi_mcux_config *config = dev->config;
186-
struct spi_mcux_data *data = dev->data;
185+
const struct lpspi_config *config = dev->config;
186+
struct lpspi_data *data = dev->data;
187187
struct lpspi_driver_data *lpspi_data = (struct lpspi_driver_data *)data->driver_data;
188188
struct spi_context *ctx = &data->ctx;
189189
uint32_t status_flags = base->SR;
@@ -229,7 +229,7 @@ static int transceive(const struct device *dev, const struct spi_config *spi_cfg
229229
bool asynchronous, spi_callback_t cb, void *userdata)
230230
{
231231
LPSPI_Type *base = (LPSPI_Type *)DEVICE_MMIO_NAMED_GET(dev, reg_base);
232-
struct spi_mcux_data *data = dev->data;
232+
struct lpspi_data *data = dev->data;
233233
struct lpspi_driver_data *lpspi_data = (struct lpspi_driver_data *)data->driver_data;
234234
struct spi_context *ctx = &data->ctx;
235235
int ret = 0;
@@ -280,15 +280,15 @@ static int transceive(const struct device *dev, const struct spi_config *spi_cfg
280280
return ret;
281281
}
282282

283-
static int spi_mcux_transceive_sync(const struct device *dev, const struct spi_config *spi_cfg,
283+
static int lpspi_transceive_sync(const struct device *dev, const struct spi_config *spi_cfg,
284284
const struct spi_buf_set *tx_bufs,
285285
const struct spi_buf_set *rx_bufs)
286286
{
287287
return transceive(dev, spi_cfg, tx_bufs, rx_bufs, false, NULL, NULL);
288288
}
289289

290290
#ifdef CONFIG_SPI_ASYNC
291-
static int spi_mcux_transceive_async(const struct device *dev, const struct spi_config *spi_cfg,
291+
static int lpspi_transceive_async(const struct device *dev, const struct spi_config *spi_cfg,
292292
const struct spi_buf_set *tx_bufs,
293293
const struct spi_buf_set *rx_bufs, spi_callback_t cb,
294294
void *userdata)
@@ -297,20 +297,20 @@ static int spi_mcux_transceive_async(const struct device *dev, const struct spi_
297297
}
298298
#endif /* CONFIG_SPI_ASYNC */
299299

300-
static DEVICE_API(spi, spi_mcux_driver_api) = {
301-
.transceive = spi_mcux_transceive_sync,
300+
static DEVICE_API(spi, lpspi_driver_api) = {
301+
.transceive = lpspi_transceive_sync,
302302
#ifdef CONFIG_SPI_ASYNC
303-
.transceive_async = spi_mcux_transceive_async,
303+
.transceive_async = lpspi_transceive_async,
304304
#endif
305305
#ifdef CONFIG_SPI_RTIO
306306
.iodev_submit = spi_rtio_iodev_default_submit,
307307
#endif
308-
.release = spi_mcux_release,
308+
.release = spi_lpspi_release,
309309
};
310310

311-
static int spi_mcux_init(const struct device *dev)
311+
static int lpspi_init(const struct device *dev)
312312
{
313-
struct spi_mcux_data *data = dev->data;
313+
struct lpspi_data *data = dev->data;
314314
int err = 0;
315315

316316
err = spi_nxp_init_common(dev);
@@ -325,23 +325,23 @@ static int spi_mcux_init(const struct device *dev)
325325

326326
#define LPSPI_INIT(n) \
327327
SPI_NXP_LPSPI_COMMON_INIT(n) \
328-
SPI_MCUX_LPSPI_CONFIG_INIT(n) \
328+
SPI_LPSPI_CONFIG_INIT(n) \
329329
\
330330
static struct lpspi_driver_data lpspi_##n##_driver_data; \
331331
\
332-
static struct spi_mcux_data spi_mcux_data_##n = { \
332+
static struct lpspi_data lpspi_data_##n = { \
333333
SPI_NXP_LPSPI_COMMON_DATA_INIT(n) \
334334
.driver_data = &lpspi_##n##_driver_data, \
335335
}; \
336336
\
337-
SPI_DEVICE_DT_INST_DEFINE(n, spi_mcux_init, NULL, &spi_mcux_data_##n, \
338-
&spi_mcux_config_##n, POST_KERNEL, CONFIG_SPI_INIT_PRIORITY, \
339-
&spi_mcux_driver_api);
337+
SPI_DEVICE_DT_INST_DEFINE(n, lpspi_init, NULL, &lpspi_data_##n, \
338+
&lpspi_config_##n, POST_KERNEL, CONFIG_SPI_INIT_PRIORITY, \
339+
&lpspi_driver_api);
340340

341-
#define SPI_MCUX_LPSPI_INIT_IF_DMA(n) IF_DISABLED(SPI_NXP_LPSPI_HAS_DMAS(n), (LPSPI_INIT(n)))
341+
#define SPI_LPSPI_INIT_IF_DMA(n) IF_DISABLED(SPI_NXP_LPSPI_HAS_DMAS(n), (LPSPI_INIT(n)))
342342

343-
#define SPI_MCUX_LPSPI_INIT(n) \
343+
#define SPI_LPSPI_INIT(n) \
344344
COND_CODE_1(CONFIG_SPI_MCUX_LPSPI_DMA, \
345-
(SPI_MCUX_LPSPI_INIT_IF_DMA(n)), (LPSPI_INIT(n)))
345+
(SPI_LPSPI_INIT_IF_DMA(n)), (LPSPI_INIT(n)))
346346

347-
DT_INST_FOREACH_STATUS_OKAY(SPI_MCUX_LPSPI_INIT)
347+
DT_INST_FOREACH_STATUS_OKAY(SPI_LPSPI_INIT)

drivers/spi/spi_nxp_lpspi/spi_nxp_lpspi_common.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
#include <zephyr/logging/log.h>
8-
LOG_MODULE_REGISTER(spi_mcux_lpspi_common, CONFIG_SPI_LOG_LEVEL);
8+
LOG_MODULE_REGISTER(spi_lpspi_common, CONFIG_SPI_LOG_LEVEL);
99

1010
#include "spi_nxp_lpspi_priv.h"
1111
#include <fsl_lpspi.h>
@@ -61,9 +61,9 @@ void lpspi_wait_tx_fifo_empty(const struct device *dev)
6161
}
6262
}
6363

64-
int spi_mcux_release(const struct device *dev, const struct spi_config *spi_cfg)
64+
int spi_lpspi_release(const struct device *dev, const struct spi_config *spi_cfg)
6565
{
66-
struct spi_mcux_data *data = dev->data;
66+
struct lpspi_data *data = dev->data;
6767

6868
spi_context_unlock_unconditionally(&data->ctx);
6969

@@ -103,8 +103,8 @@ static inline int lpspi_validate_xfer_args(const struct spi_config *spi_cfg)
103103

104104
int spi_mcux_configure(const struct device *dev, const struct spi_config *spi_cfg)
105105
{
106-
const struct spi_mcux_config *config = dev->config;
107-
struct spi_mcux_data *data = dev->data;
106+
const struct lpspi_config *config = dev->config;
107+
struct lpspi_data *data = dev->data;
108108
struct spi_context *ctx = &data->ctx;
109109
bool already_configured = spi_context_configured(ctx, spi_cfg);
110110
LPSPI_Type *base = (LPSPI_Type *)DEVICE_MMIO_NAMED_GET(dev, reg_base);
@@ -198,8 +198,8 @@ static void lpspi_module_system_init(LPSPI_Type *base)
198198
int spi_nxp_init_common(const struct device *dev)
199199
{
200200
LPSPI_Type *base = (LPSPI_Type *)DEVICE_MMIO_NAMED_GET(dev, reg_base);
201-
const struct spi_mcux_config *config = dev->config;
202-
struct spi_mcux_data *data = dev->data;
201+
const struct lpspi_config *config = dev->config;
202+
struct lpspi_data *data = dev->data;
203203
int err = 0;
204204

205205
DEVICE_MMIO_NAMED_MAP(dev, reg_base, K_MEM_CACHE_NONE | K_MEM_DIRECT_MAP);

0 commit comments

Comments
 (0)