[PATCH] spi: imx: add 16/32 bits per word support for target mode
Marc Kleine-Budde
mkl at pengutronix.de
Fri Oct 24 00:12:36 PDT 2025
On 24.10.2025 13:49:52, carlos.song at nxp.com wrote:
> From: Clark Wang <xiaoning.wang at nxp.com>
>
> Now for ECSPI only support 8 bits per word in target mode.
> Enable 16/32 bits per word support for spi-imx target mode.
>
> Signed-off-by: Carlos Song <carlos.song at nxp.com>
> Signed-off-by: Clark Wang <xiaoning.wang at nxp.com>
> ---
> drivers/spi/spi-imx.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
> index 155ddeb8fcd4..4ffee6c5d5c4 100644
> --- a/drivers/spi/spi-imx.c
> +++ b/drivers/spi/spi-imx.c
> @@ -424,8 +424,12 @@ static void spi_imx_buf_tx_swap(struct spi_imx_data *spi_imx)
>
> static void mx53_ecspi_rx_target(struct spi_imx_data *spi_imx)
> {
> - u32 val = ioread32be(spi_imx->base + MXC_CSPIRXDATA);
> + u32 val = readl(spi_imx->base + MXC_CSPIRXDATA);
>
> + if (spi_imx->bits_per_word <= 8)
> + val = be32_to_cpu(val);
> + else if (spi_imx->bits_per_word <= 16)
> + val = (val << 16) | (val >> 16);
You can use swahw32() here and below.
> if (spi_imx->rx_buf) {
> int n_bytes = spi_imx->target_burst % sizeof(val);
>
> @@ -453,12 +457,16 @@ static void mx53_ecspi_tx_target(struct spi_imx_data *spi_imx)
> if (spi_imx->tx_buf) {
> memcpy(((u8 *)&val) + sizeof(val) - n_bytes,
> spi_imx->tx_buf, n_bytes);
> + if (spi_imx->bits_per_word <= 8)
> + val = cpu_to_be32(val);
> + else if (spi_imx->bits_per_word <= 16)
> + val = (val << 16) | (val >> 16);
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20251024/76f8a5c2/attachment.sig>
More information about the linux-arm-kernel
mailing list