7
7
#define DT_DRV_COMPAT nxp_lpspi
8
8
9
9
#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 );
11
11
12
12
#include "spi_nxp_lpspi_priv.h"
13
13
@@ -30,7 +30,7 @@ static inline uint8_t tx_fifo_cur_len(LPSPI_Type *base)
30
30
static inline void lpspi_rx_word_write_bytes (const struct device * dev , size_t offset )
31
31
{
32
32
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 ;
34
34
struct lpspi_driver_data * lpspi_data = (struct lpspi_driver_data * )data -> driver_data ;
35
35
struct spi_context * ctx = & data -> ctx ;
36
36
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
50
50
/* Reads a maximum number of words from RX fifo and writes them to the remainder of the RX buf */
51
51
static inline size_t lpspi_rx_buf_write_words (const struct device * dev , uint8_t max_read )
52
52
{
53
- struct spi_mcux_data * data = dev -> data ;
53
+ struct lpspi_data * data = dev -> data ;
54
54
struct lpspi_driver_data * lpspi_data = (struct lpspi_driver_data * )data -> driver_data ;
55
55
struct spi_context * ctx = & data -> ctx ;
56
56
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
69
69
static inline void lpspi_handle_rx_irq (const struct device * dev )
70
70
{
71
71
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 ;
73
73
struct lpspi_driver_data * lpspi_data = (struct lpspi_driver_data * )data -> driver_data ;
74
74
struct spi_context * ctx = & data -> ctx ;
75
75
uint8_t rx_fsr = rx_fifo_cur_len (base );
@@ -98,7 +98,7 @@ static inline void lpspi_handle_rx_irq(const struct device *dev)
98
98
99
99
static inline uint32_t lpspi_next_tx_word (const struct device * dev , int offset )
100
100
{
101
- struct spi_mcux_data * data = dev -> data ;
101
+ struct lpspi_data * data = dev -> data ;
102
102
struct lpspi_driver_data * lpspi_data = (struct lpspi_driver_data * )data -> driver_data ;
103
103
struct spi_context * ctx = & data -> ctx ;
104
104
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)
115
115
static inline void lpspi_fill_tx_fifo (const struct device * dev )
116
116
{
117
117
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 ;
119
119
struct lpspi_driver_data * lpspi_data = (struct lpspi_driver_data * )data -> driver_data ;
120
120
size_t bytes_in_xfer = lpspi_data -> fill_len * lpspi_data -> word_size_bytes ;
121
121
size_t offset ;
@@ -130,7 +130,7 @@ static inline void lpspi_fill_tx_fifo(const struct device *dev)
130
130
static void lpspi_fill_tx_fifo_nop (const struct device * dev )
131
131
{
132
132
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 ;
134
134
struct lpspi_driver_data * lpspi_data = (struct lpspi_driver_data * )data -> driver_data ;
135
135
136
136
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)
142
142
143
143
static void lpspi_next_tx_fill (const struct device * dev )
144
144
{
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 ;
147
147
struct lpspi_driver_data * lpspi_data = (struct lpspi_driver_data * )data -> driver_data ;
148
148
struct spi_context * ctx = & data -> ctx ;
149
149
size_t max_chunk ;
@@ -163,7 +163,7 @@ static void lpspi_next_tx_fill(const struct device *dev)
163
163
static inline void lpspi_handle_tx_irq (const struct device * dev )
164
164
{
165
165
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 ;
167
167
struct lpspi_driver_data * lpspi_data = (struct lpspi_driver_data * )data -> driver_data ;
168
168
struct spi_context * ctx = & data -> ctx ;
169
169
@@ -182,8 +182,8 @@ static inline void lpspi_handle_tx_irq(const struct device *dev)
182
182
static void lpspi_isr (const struct device * dev )
183
183
{
184
184
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 ;
187
187
struct lpspi_driver_data * lpspi_data = (struct lpspi_driver_data * )data -> driver_data ;
188
188
struct spi_context * ctx = & data -> ctx ;
189
189
uint32_t status_flags = base -> SR ;
@@ -229,7 +229,7 @@ static int transceive(const struct device *dev, const struct spi_config *spi_cfg
229
229
bool asynchronous , spi_callback_t cb , void * userdata )
230
230
{
231
231
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 ;
233
233
struct lpspi_driver_data * lpspi_data = (struct lpspi_driver_data * )data -> driver_data ;
234
234
struct spi_context * ctx = & data -> ctx ;
235
235
int ret = 0 ;
@@ -280,15 +280,15 @@ static int transceive(const struct device *dev, const struct spi_config *spi_cfg
280
280
return ret ;
281
281
}
282
282
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 ,
284
284
const struct spi_buf_set * tx_bufs ,
285
285
const struct spi_buf_set * rx_bufs )
286
286
{
287
287
return transceive (dev , spi_cfg , tx_bufs , rx_bufs , false, NULL , NULL );
288
288
}
289
289
290
290
#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 ,
292
292
const struct spi_buf_set * tx_bufs ,
293
293
const struct spi_buf_set * rx_bufs , spi_callback_t cb ,
294
294
void * userdata )
@@ -297,20 +297,20 @@ static int spi_mcux_transceive_async(const struct device *dev, const struct spi_
297
297
}
298
298
#endif /* CONFIG_SPI_ASYNC */
299
299
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 ,
302
302
#ifdef CONFIG_SPI_ASYNC
303
- .transceive_async = spi_mcux_transceive_async ,
303
+ .transceive_async = lpspi_transceive_async ,
304
304
#endif
305
305
#ifdef CONFIG_SPI_RTIO
306
306
.iodev_submit = spi_rtio_iodev_default_submit ,
307
307
#endif
308
- .release = spi_mcux_release ,
308
+ .release = spi_lpspi_release ,
309
309
};
310
310
311
- static int spi_mcux_init (const struct device * dev )
311
+ static int lpspi_init (const struct device * dev )
312
312
{
313
- struct spi_mcux_data * data = dev -> data ;
313
+ struct lpspi_data * data = dev -> data ;
314
314
int err = 0 ;
315
315
316
316
err = spi_nxp_init_common (dev );
@@ -325,23 +325,23 @@ static int spi_mcux_init(const struct device *dev)
325
325
326
326
#define LPSPI_INIT (n ) \
327
327
SPI_NXP_LPSPI_COMMON_INIT(n) \
328
- SPI_MCUX_LPSPI_CONFIG_INIT (n) \
328
+ SPI_LPSPI_CONFIG_INIT (n) \
329
329
\
330
330
static struct lpspi_driver_data lpspi_##n##_driver_data; \
331
331
\
332
- static struct spi_mcux_data spi_mcux_data_ ##n = { \
332
+ static struct lpspi_data lpspi_data_ ##n = { \
333
333
SPI_NXP_LPSPI_COMMON_DATA_INIT(n) \
334
334
.driver_data = &lpspi_##n##_driver_data, \
335
335
}; \
336
336
\
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 );
340
340
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)))
342
342
343
- #define SPI_MCUX_LPSPI_INIT (n ) \
343
+ #define SPI_LPSPI_INIT (n ) \
344
344
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)))
346
346
347
- DT_INST_FOREACH_STATUS_OKAY (SPI_MCUX_LPSPI_INIT )
347
+ DT_INST_FOREACH_STATUS_OKAY (SPI_LPSPI_INIT )
0 commit comments