Commit 60ccb351 authored by Alain Volmat's avatar Alain Volmat Committed by Mark Brown

spi: stm32: always perform registers configuration prior to transfer

SPI registers content may have been lost upon suspend/resume sequence.
So, always compute and apply the necessary configuration in
stm32_spi_transfer_one_setup routine.
Signed-off-by: default avatarAlain Volmat <alain.volmat@st.com>
Link: https://lore.kernel.org/r/1597043558-29668-6-git-send-email-alain.volmat@st.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent db96bf97
...@@ -1597,18 +1597,14 @@ static int stm32_spi_transfer_one_setup(struct stm32_spi *spi, ...@@ -1597,18 +1597,14 @@ static int stm32_spi_transfer_one_setup(struct stm32_spi *spi,
unsigned long flags; unsigned long flags;
unsigned int comm_type; unsigned int comm_type;
int nb_words, ret = 0; int nb_words, ret = 0;
int mbr;
spin_lock_irqsave(&spi->lock, flags); spin_lock_irqsave(&spi->lock, flags);
spi->cur_xferlen = transfer->len; spi->cur_xferlen = transfer->len;
if (spi->cur_bpw != transfer->bits_per_word) {
spi->cur_bpw = transfer->bits_per_word; spi->cur_bpw = transfer->bits_per_word;
spi->cfg->set_bpw(spi); spi->cfg->set_bpw(spi);
}
if (spi->cur_speed != transfer->speed_hz) {
int mbr;
/* Update spi->cur_speed with real clock speed */ /* Update spi->cur_speed with real clock speed */
mbr = stm32_spi_prepare_mbr(spi, transfer->speed_hz, mbr = stm32_spi_prepare_mbr(spi, transfer->speed_hz,
...@@ -1621,17 +1617,13 @@ static int stm32_spi_transfer_one_setup(struct stm32_spi *spi, ...@@ -1621,17 +1617,13 @@ static int stm32_spi_transfer_one_setup(struct stm32_spi *spi,
transfer->speed_hz = spi->cur_speed; transfer->speed_hz = spi->cur_speed;
stm32_spi_set_mbr(spi, mbr); stm32_spi_set_mbr(spi, mbr);
}
comm_type = stm32_spi_communication_type(spi_dev, transfer); comm_type = stm32_spi_communication_type(spi_dev, transfer);
if (spi->cur_comm != comm_type) {
ret = spi->cfg->set_mode(spi, comm_type); ret = spi->cfg->set_mode(spi, comm_type);
if (ret < 0) if (ret < 0)
goto out; goto out;
spi->cur_comm = comm_type; spi->cur_comm = comm_type;
}
if (spi->cfg->set_data_idleness) if (spi->cfg->set_data_idleness)
spi->cfg->set_data_idleness(spi, transfer->len); spi->cfg->set_data_idleness(spi, transfer->len);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment