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 <vincent.wan@linaro.org>
This commit is contained in:
Vincent Wan 2019-10-30 14:23:37 -07:00 committed by Kumar Gala
commit 27c035fff4

View file

@ -9,7 +9,6 @@
LOG_MODULE_REGISTER(spi_cc13xx_cc26xx); LOG_MODULE_REGISTER(spi_cc13xx_cc26xx);
#include <drivers/spi.h> #include <drivers/spi.h>
#include <sys_clock.h>
#include <driverlib/prcm.h> #include <driverlib/prcm.h>
#include <driverlib/ssi.h> #include <driverlib/ssi.h>
@ -83,7 +82,7 @@ static int spi_cc13xx_cc26xx_configure(struct device *dev,
return -EINVAL; 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"); LOG_ERR("Frequency greater than supported in master mode");
return -EINVAL; return -EINVAL;
} }
@ -113,7 +112,7 @@ static int spi_cc13xx_cc26xx_configure(struct device *dev,
SSIDisable(cfg->base); SSIDisable(cfg->base);
/* Configure SSI */ /* 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); SSI_MODE_MASTER, config->frequency, 8);
if (SPI_MODE_GET(config->operation) & SPI_MODE_LOOP) { if (SPI_MODE_GET(config->operation) & SPI_MODE_LOOP) {