From 820a70242f443126b1dad2f94f6c89924321dcb4 Mon Sep 17 00:00:00 2001 From: cyliang tw Date: Wed, 27 Mar 2024 12:09:55 +0800 Subject: [PATCH] drivers: spi: support for Nuvoton numaker m2l31x Update m2l31x.dtsi for spi support and update spi_numaker.c for dummy TX data. Signed-off-by: cyliang tw --- drivers/spi/spi_numaker.c | 10 +++++++++ dts/arm/nuvoton/m2l31x.dtsi | 44 +++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/drivers/spi/spi_numaker.c b/drivers/spi/spi_numaker.c index eda34014eb..104439e9a5 100644 --- a/drivers/spi/spi_numaker.c +++ b/drivers/spi/spi_numaker.c @@ -186,6 +186,16 @@ static int spi_numaker_txrx(const struct device *dev) } LOG_DBG("%s --> TX [0x%x] done", __func__, tx_frame); + } else { + /* Write dummy data to TX register */ + SPI_WRITE_TX(dev_cfg->spi, 0x00U); + time_out_cnt = SystemCoreClock; /* 1 second time-out */ + while (SPI_IS_BUSY(dev_cfg->spi)) { + if (--time_out_cnt == 0) { + LOG_ERR("Wait for SPI time-out"); + return -EIO; + } + } } /* Read received data */ diff --git a/dts/arm/nuvoton/m2l31x.dtsi b/dts/arm/nuvoton/m2l31x.dtsi index 00af64b124..51d38c3ee6 100644 --- a/dts/arm/nuvoton/m2l31x.dtsi +++ b/dts/arm/nuvoton/m2l31x.dtsi @@ -213,6 +213,50 @@ status = "disabled"; interrupts = <21 2>; }; + + spi0: spi@40061000 { + compatible = "nuvoton,numaker-spi"; + reg = <0x40061000 0x6c>; + interrupts = <23 0>; + resets = <&rst NUMAKER_SPI0_RST>; + clocks = <&pcc NUMAKER_SPI0_MODULE NUMAKER_CLK_CLKSEL2_SPI0SEL_HIRC 0>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + spi1: spi@40062000 { + compatible = "nuvoton,numaker-spi"; + reg = <0x40062000 0x6c>; + interrupts = <51 0>; + resets = <&rst NUMAKER_SPI1_RST>; + clocks = <&pcc NUMAKER_SPI1_MODULE NUMAKER_CLK_CLKSEL2_SPI1SEL_HIRC 0>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + spi2: spi@40063000 { + compatible = "nuvoton,numaker-spi"; + reg = <0x40063000 0x6c>; + interrupts = <52 0>; + resets = <&rst NUMAKER_SPI2_RST>; + clocks = <&pcc NUMAKER_SPI2_MODULE NUMAKER_CLK_CLKSEL3_SPI2SEL_HIRC 0>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + spi3: spi@40064000 { + compatible = "nuvoton,numaker-spi"; + reg = <0x40064000 0x6c>; + interrupts = <62 0>; + resets = <&rst NUMAKER_SPI3_RST>; + clocks = <&pcc NUMAKER_SPI3_MODULE NUMAKER_CLK_CLKSEL3_SPI3SEL_HIRC 0>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; }; };