diff --git a/drivers/spi/Kconfig.nrfx b/drivers/spi/Kconfig.nrfx index ac0df652ba3..044e3ae09c2 100644 --- a/drivers/spi/Kconfig.nrfx +++ b/drivers/spi/Kconfig.nrfx @@ -117,32 +117,12 @@ config SPI_3_NRF_SPIS Due to hardware limitations the implementation supports only simple buffers (consisting of one part) located in RAM. -config SPI_3_NRF_RX_DELAY - int "SPIM3 MISO sampling delay" - depends on SPI_3_NRF_SPIM && (SOC_NRF52833 || SOC_NRF52840) - range 0 7 - default 2 - help - Number of 64 MHz clock cycles (15.625 ns) delay from the sampling - edge of SCK (leading or trailing, depending on the CPHA setting used) - until the input serial data on MISO is actually sampled. - config SPI_4_NRF_SPIM def_bool HAS_HW_NRF_SPIM4 select NRFX_SPIM4 help Enable nRF SPI Master with EasyDMA on port 4. -config SPI_4_NRF_RX_DELAY - int "SPIM4 MISO sampling delay" - depends on SPI_4_NRF_SPIM && SOC_NRF5340_CPUAPP - range 0 7 - default 2 - help - Number of 64 MHz clock cycles (15.625 ns) delay from the sampling - edge of SCK (leading or trailing, depending on the CPHA setting used) - until the input serial data on MISO is actually sampled. - config SPI_NRFX_RAM_BUFFER_SIZE int "Size of RAM buffers for SPIM peripherals" default 8 diff --git a/drivers/spi/spi_nrfx_spi.c b/drivers/spi/spi_nrfx_spi.c index d8cf39da88f..24003c8f35b 100644 --- a/drivers/spi/spi_nrfx_spi.c +++ b/drivers/spi/spi_nrfx_spi.c @@ -320,7 +320,6 @@ static int spi_nrfx_pm_action(const struct device *dev, * Current factors requiring use of DT_NODELABEL: * * - NRFX_SPI_INSTANCE() requires an SoC instance number - * - soc-instance-numbered kconfig enables */ #define SPI(idx) DT_NODELABEL(spi##idx) diff --git a/drivers/spi/spi_nrfx_spim.c b/drivers/spi/spi_nrfx_spim.c index 3cd0398523e..5ed6107725a 100644 --- a/drivers/spi/spi_nrfx_spim.c +++ b/drivers/spi/spi_nrfx_spim.c @@ -507,8 +507,9 @@ static int spim_nrfx_pm_action(const struct device *dev, #define SPI_NRFX_SPIM_EXTENDED_CONFIG(idx) \ IF_ENABLED(NRFX_SPIM_EXTENDED_ENABLED, \ (.dcx_pin = NRFX_SPIM_PIN_NOT_USED, \ - IF_ENABLED(SPIM##idx##_FEATURE_RXDELAY_PRESENT, \ - (.rx_delay = CONFIG_SPI_##idx##_NRF_RX_DELAY,)) \ + COND_CODE_1(SPIM_PROP(idx, rx_delay_supported), \ + (.rx_delay = SPIM_PROP(idx, rx_delay),), \ + ()) \ )) #define SPI_NRFX_SPIM_PIN_CFG(idx) \ diff --git a/dts/arm/nordic/nrf52833.dtsi b/dts/arm/nordic/nrf52833.dtsi index 9239103fe9c..e59003822b9 100644 --- a/dts/arm/nordic/nrf52833.dtsi +++ b/dts/arm/nordic/nrf52833.dtsi @@ -505,6 +505,8 @@ reg = <0x4002f000 0x1000>; interrupts = <47 NRF_DEFAULT_IRQ_PRIORITY>; max-frequency = ; + rx-delay-supported; + rx-delay = <2>; status = "disabled"; label = "SPI_3"; }; diff --git a/dts/arm/nordic/nrf52840.dtsi b/dts/arm/nordic/nrf52840.dtsi index a3076522fd4..35b1d5b856a 100644 --- a/dts/arm/nordic/nrf52840.dtsi +++ b/dts/arm/nordic/nrf52840.dtsi @@ -511,6 +511,8 @@ reg = <0x4002f000 0x1000>; interrupts = <47 NRF_DEFAULT_IRQ_PRIORITY>; max-frequency = ; + rx-delay-supported; + rx-delay = <2>; status = "disabled"; label = "SPI_3"; }; diff --git a/dts/arm/nordic/nrf5340_cpuapp_peripherals.dtsi b/dts/arm/nordic/nrf5340_cpuapp_peripherals.dtsi index 2896aeb4398..05fac6a70f3 100644 --- a/dts/arm/nordic/nrf5340_cpuapp_peripherals.dtsi +++ b/dts/arm/nordic/nrf5340_cpuapp_peripherals.dtsi @@ -139,6 +139,8 @@ spi4: spi@a000 { reg = <0xa000 0x1000>; interrupts = <10 NRF_DEFAULT_IRQ_PRIORITY>; max-frequency = ; + rx-delay-supported; + rx-delay = <2>; status = "disabled"; label = "SPI_4"; }; diff --git a/dts/bindings/spi/nordic,nrf-spim.yaml b/dts/bindings/spi/nordic,nrf-spim.yaml index 809a4ff16d3..81a0006f0ab 100644 --- a/dts/bindings/spi/nordic,nrf-spim.yaml +++ b/dts/bindings/spi/nordic,nrf-spim.yaml @@ -25,3 +25,28 @@ properties: Enables the workaround for the nRF52832 SoC SPIM PAN 58 anomaly. Must be used in conjunction with CONFIG_SOC_NRF52832_ALLOW_SPIM_DESPITE_PAN_58=y + + rx-delay-supported: + type: boolean + required: false + description: | + Indicates if the SPIM instance has the capability of delaying MISO + sampling. This property needs to be defined at SoC level DTS files. + + rx-delay: + type: int + required: false + enum: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + description: | + Number of 64 MHz clock cycles (15.625 ns) delay from the sampling edge + of SCK (leading or trailing, depending on the CPHA setting used) until + the input serial data on MISO is actually sampled. This property does + not have any effect if the rx-delay-supported property is not set. diff --git a/modules/hal_nordic/nrfx/nrfx_config.h b/modules/hal_nordic/nrfx/nrfx_config.h index 1dcf822e9ca..d6779719d5f 100644 --- a/modules/hal_nordic/nrfx/nrfx_config.h +++ b/modules/hal_nordic/nrfx/nrfx_config.h @@ -7,6 +7,7 @@ #ifndef NRFX_CONFIG_H__ #define NRFX_CONFIG_H__ +#include /* * These are mappings of Kconfig options enabling nrfx drivers and particular @@ -228,7 +229,8 @@ #ifdef CONFIG_NRFX_SPIM4 #define NRFX_SPIM4_ENABLED 1 #endif -#if defined(CONFIG_SPI_3_NRF_RX_DELAY) || defined(CONFIG_SPI_4_NRF_RX_DELAY) +#if (DT_PROP(DT_NODELABEL(spi3), rx_delay_supported) || \ + DT_PROP(DT_NODELABEL(spi4), rx_delay_supported)) #define NRFX_SPIM_EXTENDED_ENABLED 1 #endif diff --git a/tests/drivers/spi/spi_loopback/boards/nrf52840dk_nrf52840.conf b/tests/drivers/spi/spi_loopback/boards/nrf52840dk_nrf52840.conf index 9ba0c218690..560e6a7a8b8 100644 --- a/tests/drivers/spi/spi_loopback/boards/nrf52840dk_nrf52840.conf +++ b/tests/drivers/spi/spi_loopback/boards/nrf52840dk_nrf52840.conf @@ -1,5 +1,3 @@ -CONFIG_SPI_3_NRF_RX_DELAY=1 - CONFIG_SPI_LOOPBACK_DRV_NAME="SPI_3" CONFIG_SPI_LOOPBACK_CS_GPIO=y CONFIG_SPI_LOOPBACK_CS_CTRL_GPIO_DRV_NAME="GPIO_0" diff --git a/tests/drivers/spi/spi_loopback/boards/nrf52840dk_nrf52840.overlay b/tests/drivers/spi/spi_loopback/boards/nrf52840dk_nrf52840.overlay index 9201308c1ce..bc3d06410c0 100644 --- a/tests/drivers/spi/spi_loopback/boards/nrf52840dk_nrf52840.overlay +++ b/tests/drivers/spi/spi_loopback/boards/nrf52840dk_nrf52840.overlay @@ -6,4 +6,5 @@ &spi3 { overrun-character = <0x00>; + rx-delay = <1>; };