-
Notifications
You must be signed in to change notification settings - Fork 8.3k
drivers: Clean up NXP MCUX LPSPI driver #78789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
21ac4a8
56c3a7f
3993e44
f7733ee
d6d2cfa
3caf9ee
a383f36
086dd02
0503400
6c3db02
588f749
ff946d3
debbf3b
b006783
a04e110
ba49546
700ef5e
bcb563b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -272,7 +272,10 @@ static int spi_mcux_configure(const struct device *dev, const struct spi_config | |
| } | ||
|
|
||
| #ifdef CONFIG_SPI_MCUX_LPSPI_DMA | ||
| static int spi_mcux_dma_rxtx_load(const struct device *dev, size_t *dma_size); | ||
| static bool lpspi_inst_has_dma(const struct spi_mcux_data *data) | ||
| { | ||
| return (data->dma_tx.dma_dev && data->dma_rx.dma_dev); | ||
| } | ||
|
||
|
|
||
| /* This function is executed in the interrupt context */ | ||
| static void spi_mcux_dma_callback(const struct device *dev, void *arg, uint32_t channel, int status) | ||
|
|
@@ -550,7 +553,9 @@ static int transceive_dma(const struct device *dev, const struct spi_config *spi | |
|
|
||
| return ret; | ||
| } | ||
| #endif | ||
| #else | ||
| #define lpspi_inst_has_dma(arg) arg != arg | ||
danieldegrasse marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #endif /* CONFIG_SPI_MCUX_LPSPI_DMA */ | ||
|
|
||
| #ifdef CONFIG_SPI_RTIO | ||
|
|
||
|
|
@@ -613,7 +618,7 @@ static int spi_mcux_transceive(const struct device *dev, const struct spi_config | |
| #ifdef CONFIG_SPI_MCUX_LPSPI_DMA | ||
| const struct spi_mcux_data *data = dev->data; | ||
|
|
||
| if (data->dma_rx.dma_dev && data->dma_tx.dma_dev) { | ||
| if (lpspi_inst_has_dma(data)) { | ||
EmilioCBen marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return transceive_dma(dev, spi_cfg, tx_bufs, rx_bufs, false, NULL, NULL); | ||
| } | ||
| #endif /* CONFIG_SPI_MCUX_LPSPI_DMA */ | ||
|
|
@@ -630,7 +635,7 @@ static int spi_mcux_transceive_async(const struct device *dev, const struct spi_ | |
| #ifdef CONFIG_SPI_MCUX_LPSPI_DMA | ||
| struct spi_mcux_data *data = dev->data; | ||
|
|
||
| if (data->dma_rx.dma_dev && data->dma_tx.dma_dev) { | ||
| if (lpspi_inst_has_dma(data)) { | ||
| spi_context_buffers_setup(&data->ctx, tx_bufs, rx_bufs, 1); | ||
| } | ||
|
|
||
|
|
@@ -749,29 +754,42 @@ static void spi_mcux_iodev_complete(const struct device *dev, int status) | |
|
|
||
| #endif | ||
|
|
||
| #if defined(CONFIG_SPI_MCUX_LPSPI_DMA) | ||
| static int lpspi_dma_dev_ready(const struct device *dma_dev) | ||
| { | ||
| if (!device_is_ready(dma_dev)) { | ||
| LOG_ERR("%s device is not ready", dma_dev->name); | ||
| return -ENODEV; | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| static int lpspi_dma_devs_ready(struct spi_mcux_data *data) | ||
| { | ||
| return lpspi_dma_dev_ready(data->dma_tx.dma_dev) | | ||
danieldegrasse marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| lpspi_dma_dev_ready(data->dma_rx.dma_dev); | ||
| } | ||
| #else | ||
| #define lpspi_dma_devs_ready(...) 0 | ||
| #endif /* CONFIG_SPI_MCUX_LPSPI_DMA */ | ||
|
|
||
| static int spi_mcux_init(const struct device *dev) | ||
| { | ||
| const struct spi_mcux_config *config = dev->config; | ||
| struct spi_mcux_data *data = dev->data; | ||
| int err; | ||
| int err = 0; | ||
|
|
||
| DEVICE_MMIO_NAMED_MAP(dev, reg_base, K_MEM_CACHE_NONE | K_MEM_DIRECT_MAP); | ||
|
|
||
| data->dev = dev; | ||
|
|
||
| #ifdef CONFIG_SPI_MCUX_LPSPI_DMA | ||
| if (data->dma_tx.dma_dev && data->dma_rx.dma_dev) { | ||
| if (!device_is_ready(data->dma_tx.dma_dev)) { | ||
| LOG_ERR("%s device is not ready", data->dma_tx.dma_dev->name); | ||
| return -ENODEV; | ||
| } | ||
|
|
||
| if (!device_is_ready(data->dma_rx.dma_dev)) { | ||
| LOG_ERR("%s device is not ready", data->dma_rx.dma_dev->name); | ||
| return -ENODEV; | ||
| } | ||
| if (IS_ENABLED(CONFIG_SPI_MCUX_LPSPI_DMA) && lpspi_inst_has_dma(data)) { | ||
| err = lpspi_dma_devs_ready(data); | ||
| } | ||
| if (err < 0) { | ||
| return err; | ||
| } | ||
| #endif /* CONFIG_SPI_MCUX_LPSPI_DMA */ | ||
|
|
||
| err = spi_context_cs_configure_all(&data->ctx); | ||
| if (err < 0) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c6a1daedbf91aea031a58bf9882ab508ef863cc5: please fix the typo in your git commit message - 'definitin'
4fa061e6ff0bcd89edbb3388a20322f54c18b844: suggest to change your summary line to better reflect what the commit is about
41ed57c60a8c8889620be4743804b425613f969e: make the summary line a complete sentence. Bottom of what?
fd1daae6326d5ae4b0308051fb928c4298df52d4: please clarify one liner, wrap?
b3de6553518bfde70ccb01732c6c2e0a148988b9: summary line is not clear, make it a sentence.
04f52cac07a9bff4ca3457e3dd24ad4a24ebacff: please add func or function to the summary line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i only get 50 characters to work with here , I changed it but i dont know what else to say, i used the maximum number of characters in the new revision
there are not enough characters left to say "bottom of file" , so i put "end" of file, even though the commit message says already "bottom of file" , so im not sure why someone would be confused, now it uses the maximum number of characters
there are not enough characters left to type the full word "wrappers", so i changed it to "calls", which is the maximum number of characters
there are not enough characters for a sentence, so i changed it to "ErrLog dev in iodev_start" which is using the maximum number of characters
I cannot do that because the commit title already is using the maximum number of characters allowed, it should be obvious that prepare_start is a function name, especially if one reads the commit message that says "remove unneeded prepare_start function" in the first line