From ed934ca8316716aea72e8aa900b210cb93f3e287 Mon Sep 17 00:00:00 2001 From: Michal Frankiewicz Date: Thu, 10 Jul 2025 09:16:30 +0200 Subject: [PATCH 1/2] [nrf fromlist] drivers: spi: nrfx_spim: Add support for non standard frequencies Disabled frequency set approximation algorithm for spim's with prescaler. Upstream PR #: 92436 Signed-off-by: Michal Frankiewicz --- drivers/spi/spi_nrfx_spim.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi_nrfx_spim.c b/drivers/spi/spi_nrfx_spim.c index a5c4e30f190..0646c67b4a3 100644 --- a/drivers/spi/spi_nrfx_spim.c +++ b/drivers/spi/spi_nrfx_spim.c @@ -170,11 +170,14 @@ static inline void finalize_spi_transaction(const struct device *dev, bool deact static inline uint32_t get_nrf_spim_frequency(uint32_t frequency) { + if (NRF_SPIM_HAS_PRESCALER) { + return frequency; + } /* Get the highest supported frequency not exceeding the requested one. */ - if (frequency >= MHZ(32) && (NRF_SPIM_HAS_32_MHZ_FREQ || NRF_SPIM_HAS_PRESCALER)) { + if (frequency >= MHZ(32) && NRF_SPIM_HAS_32_MHZ_FREQ) { return MHZ(32); - } else if (frequency >= MHZ(16) && (NRF_SPIM_HAS_16_MHZ_FREQ || NRF_SPIM_HAS_PRESCALER)) { + } else if (frequency >= MHZ(16) && NRF_SPIM_HAS_16_MHZ_FREQ) { return MHZ(16); } else if (frequency >= MHZ(8)) { return MHZ(8); From c866e731bc42d4b22e79700d9c3179388f5c160a Mon Sep 17 00:00:00 2001 From: Michal Frankiewicz Date: Tue, 15 Jul 2025 11:30:28 +0200 Subject: [PATCH 2/2] [nrf fromlist] tests: drivers: spi: Add test cases for non standard frequencies. Added test cases for nrf chips for non standard frequencies. Upstream PR #: 92436 Signed-off-by: Michal Frankiewicz --- .../boards/1m333333hz.overlay | 9 +++++++++ .../boards/2m666666hz.overlay | 9 +++++++++ .../spi/spi_controller_peripheral/testcase.yaml | 16 ++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 tests/drivers/spi/spi_controller_peripheral/boards/1m333333hz.overlay create mode 100644 tests/drivers/spi/spi_controller_peripheral/boards/2m666666hz.overlay diff --git a/tests/drivers/spi/spi_controller_peripheral/boards/1m333333hz.overlay b/tests/drivers/spi/spi_controller_peripheral/boards/1m333333hz.overlay new file mode 100644 index 00000000000..5a35648b752 --- /dev/null +++ b/tests/drivers/spi/spi_controller_peripheral/boards/1m333333hz.overlay @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&dut_spi_dt { + spi-max-frequency = <1333333>; +}; diff --git a/tests/drivers/spi/spi_controller_peripheral/boards/2m666666hz.overlay b/tests/drivers/spi/spi_controller_peripheral/boards/2m666666hz.overlay new file mode 100644 index 00000000000..642a3e18e95 --- /dev/null +++ b/tests/drivers/spi/spi_controller_peripheral/boards/2m666666hz.overlay @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&dut_spi_dt { + spi-max-frequency = <2666666>; +}; diff --git a/tests/drivers/spi/spi_controller_peripheral/testcase.yaml b/tests/drivers/spi/spi_controller_peripheral/testcase.yaml index 56f3545235e..cfcf7c149f0 100644 --- a/tests/drivers/spi/spi_controller_peripheral/testcase.yaml +++ b/tests/drivers/spi/spi_controller_peripheral/testcase.yaml @@ -45,6 +45,22 @@ tests: integration_platforms: - nrf52840dk/nrf52840 + drivers.spi.spi_1M333333Hz: + extra_configs: + - CONFIG_TESTED_SPI_MODE=0 + extra_args: EXTRA_DTC_OVERLAY_FILE="boards/1m333333hz.overlay" + integration_platforms: + - nrf54l15dk/nrf54l15/cpuapp + - nrf54h20dk/nrf54h20/cpuapp + + drivers.spi.spi_2M666666Hz: + extra_configs: + - CONFIG_TESTED_SPI_MODE=0 + extra_args: EXTRA_DTC_OVERLAY_FILE="boards/2m666666hz.overlay" + integration_platforms: + - nrf54l15dk/nrf54l15/cpuapp + - nrf54h20dk/nrf54h20/cpuapp + drivers.spi.spi_4MHz: extra_configs: - CONFIG_TESTED_SPI_MODE=2