drivers: spi: Fix Ambiq apollo4p SPI reconfiguration.

The configured SPI should not be configured again.
Otherwise it would cause SPI transmission failure.

Signed-off-by: Aaron Ye <aye@ambiq.com>
This commit is contained in:
Aaron Ye 2023-09-06 23:07:17 +08:00 committed by Fabio Baltieri
parent 4e7d1b0f74
commit 7cf21d1080

View file

@ -46,11 +46,17 @@ static int spi_config(const struct device *dev, const struct spi_config *config)
{
struct spi_ambiq_data *data = dev->data;
const struct spi_ambiq_config *cfg = dev->config;
struct spi_context *ctx = &(data->ctx);
data->iom_cfg.eInterfaceMode = AM_HAL_IOM_SPI_MODE;
int ret = 0;
if (spi_context_configured(ctx, config)) {
/* Already configured. No need to do it again. */
return 0;
}
if (config->operation & SPI_HALF_DUPLEX) {
LOG_ERR("Half-duplex not supported");
return -ENOTSUP;
@ -105,6 +111,7 @@ static int spi_config(const struct device *dev, const struct spi_config *config)
}
data->iom_cfg.ui32ClockFreq = cfg->clock_freq;
ctx->config = config;
/* Disable IOM instance as it cannot be configured when enabled*/
ret = am_hal_iom_disable(data->IOMHandle);