From 27c035fff45e6b3bbcf5733ef0218bf11775b855 Mon Sep 17 00:00:00 2001 From: Vincent Wan Date: Wed, 30 Oct 2019 14:23:37 -0700 Subject: [PATCH] drivers: spi: use CPU clock frequency in configuration on CC13XX/CC26XX The SPI peripheral should be configured using the CPU clock speed and not the system clock speed. This used to be fine because they were the same before #19232, but now that the system clock is RTC-based (which has a different frequency), we can no longer make that assumption. Signed-off-by: Vincent Wan --- drivers/spi/spi_cc13xx_cc26xx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi_cc13xx_cc26xx.c b/drivers/spi/spi_cc13xx_cc26xx.c index 9496ba95211..9c1398d3996 100644 --- a/drivers/spi/spi_cc13xx_cc26xx.c +++ b/drivers/spi/spi_cc13xx_cc26xx.c @@ -9,7 +9,6 @@ LOG_MODULE_REGISTER(spi_cc13xx_cc26xx); #include -#include #include #include @@ -83,7 +82,7 @@ static int spi_cc13xx_cc26xx_configure(struct device *dev, return -EINVAL; } - if (2 * config->frequency > sys_clock_hw_cycles_per_sec()) { + if (2 * config->frequency > DT_CPU_CLOCK_FREQUENCY) { LOG_ERR("Frequency greater than supported in master mode"); return -EINVAL; } @@ -113,7 +112,7 @@ static int spi_cc13xx_cc26xx_configure(struct device *dev, SSIDisable(cfg->base); /* Configure SSI */ - SSIConfigSetExpClk(cfg->base, sys_clock_hw_cycles_per_sec(), prot, + SSIConfigSetExpClk(cfg->base, DT_CPU_CLOCK_FREQUENCY, prot, SSI_MODE_MASTER, config->frequency, 8); if (SPI_MODE_GET(config->operation) & SPI_MODE_LOOP) {