* [PATCH] spi: imx: support SPI target PIO mode for IMX51_ECSPI
@ 2025-10-24 5:52 carlos.song
2025-10-24 15:30 ` Frank Li
0 siblings, 1 reply; 2+ messages in thread
From: carlos.song @ 2025-10-24 5:52 UTC (permalink / raw)
To: frank.li, broonie, shawnguo, s.hauer, kernel, festevam
Cc: linux-spi, imx, linux-arm-kernel, linux-kernel
From: Carlos Song <carlos.song@nxp.com>
IMX51_ECSPI and IMX53_ECSPI both has target mode, but now PIO target mode
is only supported for IMX53_ECSPI.
Support target PIO mode for IMX51_ECSPI. It can share the same functions
for data transmission and reception in target mode with IMX53_ECSPI. So
remove target mode restriction only for IMX53_ECSPI and move target max
transfer len to devtype_data of IMX53_ECSPI and IMX51_ECSPI to improve
readability.
Signed-off-by: Carlos Song <carlos.song@nxp.com>
---
drivers/spi/spi-imx.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 6eb4bfb7be4a..cd40db61d8d1 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -85,6 +85,7 @@ struct spi_imx_devtype_data {
void (*disable)(struct spi_imx_data *spi_imx);
bool has_dmamode;
bool has_targetmode;
+ int target_max_transfer_bytes;
unsigned int fifo_size;
bool dynamic_burst;
/*
@@ -594,7 +595,7 @@ static int mx51_ecspi_prepare_message(struct spi_imx_data *spi_imx,
* is not functional for imx53 Soc, config SPI burst completed when
* BURST_LENGTH + 1 bits are received
*/
- if (spi_imx->target_mode && is_imx53_ecspi(spi_imx))
+ if (spi_imx->target_mode)
cfg &= ~MX51_ECSPI_CONFIG_SBBCTRL(channel);
else
cfg |= MX51_ECSPI_CONFIG_SBBCTRL(channel);
@@ -682,7 +683,7 @@ static int mx51_ecspi_prepare_transfer(struct spi_imx_data *spi_imx,
/* Clear BL field and set the right value */
ctrl &= ~MX51_ECSPI_CTRL_BL_MASK;
- if (spi_imx->target_mode && is_imx53_ecspi(spi_imx))
+ if (spi_imx->target_mode)
ctrl |= (spi_imx->target_burst * 8 - 1)
<< MX51_ECSPI_CTRL_BL_OFFSET;
else {
@@ -1140,6 +1141,7 @@ static struct spi_imx_devtype_data imx51_ecspi_devtype_data = {
.has_dmamode = true,
.dynamic_burst = true,
.has_targetmode = true,
+ .target_max_transfer_bytes = MX53_MAX_TRANSFER_BYTES,
.disable = mx51_ecspi_disable,
.devtype = IMX51_ECSPI,
};
@@ -1154,6 +1156,7 @@ static struct spi_imx_devtype_data imx53_ecspi_devtype_data = {
.fifo_size = 64,
.has_dmamode = true,
.has_targetmode = true,
+ .target_max_transfer_bytes = MX53_MAX_TRANSFER_BYTES,
.disable = mx51_ecspi_disable,
.devtype = IMX53_ECSPI,
};
@@ -1170,6 +1173,7 @@ static struct spi_imx_devtype_data imx6ul_ecspi_devtype_data = {
.has_dmamode = true,
.dynamic_burst = true,
.has_targetmode = true,
+ .target_max_transfer_bytes = MX53_MAX_TRANSFER_BYTES,
.tx_glitch_fixed = true,
.disable = mx51_ecspi_disable,
.devtype = IMX51_ECSPI,
@@ -1375,7 +1379,7 @@ static int spi_imx_setupxfer(struct spi_device *spi,
spi_imx->rx_only = ((t->tx_buf == NULL)
|| (t->tx_buf == spi->controller->dummy_tx));
- if (is_imx53_ecspi(spi_imx) && spi_imx->target_mode) {
+ if (spi_imx->target_mode) {
spi_imx->rx = mx53_ecspi_rx_target;
spi_imx->tx = mx53_ecspi_tx_target;
spi_imx->target_burst = t->len;
@@ -1649,8 +1653,7 @@ static int spi_imx_pio_transfer_target(struct spi_device *spi,
struct spi_imx_data *spi_imx = spi_controller_get_devdata(spi->controller);
int ret = 0;
- if (is_imx53_ecspi(spi_imx) &&
- transfer->len > MX53_MAX_TRANSFER_BYTES) {
+ if (transfer->len > spi_imx->devtype_data->target_max_transfer_bytes) {
dev_err(&spi->dev, "Transaction too big, max size is %d bytes\n",
MX53_MAX_TRANSFER_BYTES);
return -EMSGSIZE;
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] spi: imx: support SPI target PIO mode for IMX51_ECSPI
2025-10-24 5:52 [PATCH] spi: imx: support SPI target PIO mode for IMX51_ECSPI carlos.song
@ 2025-10-24 15:30 ` Frank Li
0 siblings, 0 replies; 2+ messages in thread
From: Frank Li @ 2025-10-24 15:30 UTC (permalink / raw)
To: carlos.song
Cc: broonie, shawnguo, s.hauer, kernel, festevam, linux-spi, imx,
linux-arm-kernel, linux-kernel
On Fri, Oct 24, 2025 at 01:52:43PM +0800, carlos.song@nxp.com wrote:
> From: Carlos Song <carlos.song@nxp.com>
>
> IMX51_ECSPI and IMX53_ECSPI both has target mode, but now PIO target mode
> is only supported for IMX53_ECSPI.
>
> Support target PIO mode for IMX51_ECSPI. It can share the same functions
> for data transmission and reception in target mode with IMX53_ECSPI. So
> remove target mode restriction only for IMX53_ECSPI and move target max
> transfer len to devtype_data of IMX53_ECSPI and IMX51_ECSPI to improve
> readability.
Look like whole patch have not touch PIO mode and DMA mode at all.
spi: imx: add i.MX51 ECSPI target mode support.
ECSPI in i.MX51 and i.MX53 support target mode. Current code only support
i.MX53. Remove is_imx53_ecspi() check for target mode to support i.MX51.
Add target_max_transfer_bytes should be new patch. Any difference between
SoCs? if all the same, needn't this movement.
Frank
>
> Signed-off-by: Carlos Song <carlos.song@nxp.com>
> ---
> drivers/spi/spi-imx.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
> index 6eb4bfb7be4a..cd40db61d8d1 100644
> --- a/drivers/spi/spi-imx.c
> +++ b/drivers/spi/spi-imx.c
> @@ -85,6 +85,7 @@ struct spi_imx_devtype_data {
> void (*disable)(struct spi_imx_data *spi_imx);
> bool has_dmamode;
> bool has_targetmode;
> + int target_max_transfer_bytes;
> unsigned int fifo_size;
> bool dynamic_burst;
> /*
> @@ -594,7 +595,7 @@ static int mx51_ecspi_prepare_message(struct spi_imx_data *spi_imx,
> * is not functional for imx53 Soc, config SPI burst completed when
> * BURST_LENGTH + 1 bits are received
> */
> - if (spi_imx->target_mode && is_imx53_ecspi(spi_imx))
> + if (spi_imx->target_mode)
> cfg &= ~MX51_ECSPI_CONFIG_SBBCTRL(channel);
> else
> cfg |= MX51_ECSPI_CONFIG_SBBCTRL(channel);
> @@ -682,7 +683,7 @@ static int mx51_ecspi_prepare_transfer(struct spi_imx_data *spi_imx,
>
> /* Clear BL field and set the right value */
> ctrl &= ~MX51_ECSPI_CTRL_BL_MASK;
> - if (spi_imx->target_mode && is_imx53_ecspi(spi_imx))
> + if (spi_imx->target_mode)
> ctrl |= (spi_imx->target_burst * 8 - 1)
> << MX51_ECSPI_CTRL_BL_OFFSET;
> else {
> @@ -1140,6 +1141,7 @@ static struct spi_imx_devtype_data imx51_ecspi_devtype_data = {
> .has_dmamode = true,
> .dynamic_burst = true,
> .has_targetmode = true,
> + .target_max_transfer_bytes = MX53_MAX_TRANSFER_BYTES,
> .disable = mx51_ecspi_disable,
> .devtype = IMX51_ECSPI,
> };
> @@ -1154,6 +1156,7 @@ static struct spi_imx_devtype_data imx53_ecspi_devtype_data = {
> .fifo_size = 64,
> .has_dmamode = true,
> .has_targetmode = true,
> + .target_max_transfer_bytes = MX53_MAX_TRANSFER_BYTES,
> .disable = mx51_ecspi_disable,
> .devtype = IMX53_ECSPI,
> };
> @@ -1170,6 +1173,7 @@ static struct spi_imx_devtype_data imx6ul_ecspi_devtype_data = {
> .has_dmamode = true,
> .dynamic_burst = true,
> .has_targetmode = true,
> + .target_max_transfer_bytes = MX53_MAX_TRANSFER_BYTES,
> .tx_glitch_fixed = true,
> .disable = mx51_ecspi_disable,
> .devtype = IMX51_ECSPI,
> @@ -1375,7 +1379,7 @@ static int spi_imx_setupxfer(struct spi_device *spi,
> spi_imx->rx_only = ((t->tx_buf == NULL)
> || (t->tx_buf == spi->controller->dummy_tx));
>
> - if (is_imx53_ecspi(spi_imx) && spi_imx->target_mode) {
> + if (spi_imx->target_mode) {
> spi_imx->rx = mx53_ecspi_rx_target;
> spi_imx->tx = mx53_ecspi_tx_target;
> spi_imx->target_burst = t->len;
> @@ -1649,8 +1653,7 @@ static int spi_imx_pio_transfer_target(struct spi_device *spi,
> struct spi_imx_data *spi_imx = spi_controller_get_devdata(spi->controller);
> int ret = 0;
>
> - if (is_imx53_ecspi(spi_imx) &&
> - transfer->len > MX53_MAX_TRANSFER_BYTES) {
> + if (transfer->len > spi_imx->devtype_data->target_max_transfer_bytes) {
> dev_err(&spi->dev, "Transaction too big, max size is %d bytes\n",
> MX53_MAX_TRANSFER_BYTES);
> return -EMSGSIZE;
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-10-24 15:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-24 5:52 [PATCH] spi: imx: support SPI target PIO mode for IMX51_ECSPI carlos.song
2025-10-24 15:30 ` Frank Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).