Skip to content

[nrf fromlist] Spim custom frequencies downstream #3012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions drivers/spi/spi_nrfx_spim.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright (c) 2025 Nordic Semiconductor
*
* SPDX-License-Identifier: Apache-2.0
*/

&dut_spi_dt {
spi-max-frequency = <1333333>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright (c) 2025 Nordic Semiconductor
*
* SPDX-License-Identifier: Apache-2.0
*/

&dut_spi_dt {
spi-max-frequency = <2666666>;
};
16 changes: 16 additions & 0 deletions tests/drivers/spi/spi_controller_peripheral/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down