Patch "spi: spi-ti-qspi: Fix FLEN and WLEN settings if bits_per_word is overridden" has been added to the 4.4-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
spi: spi-ti-qspi: Fix FLEN and WLEN settings if bits_per_word is overridden
to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
spi-spi-ti-qspi-fix-flen-and-wlen-settings-if-bits_per_word-is-overridden.patch
and it can be found in the queue-4.4 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
ea1b60fb085839a9544cb3a0069992991beabb7fMon Sep 17 00:00:00 2001
From: Ben Hutchings <[email protected]>
Date: Tue, 12 Apr 2016 12:56:25 +0100
Subject: spi: spi-ti-qspi: Fix FLEN and WLEN settings if bits_per_word is overridden
From: Ben Hutchings <[email protected]>
commit ea1b60fb085839a9544cb3a0069992991beabb7f upstream.
Each transfer can specify 8, 16 or 32 bits per word independently of the default for the device being addressed. However, currently we calculate the number of words in the frame assuming that the word size is the device default.
If multiple transfers in the same message have differing bits_per_word, we bitwise-or the different values in the WLEN register field.
Fix both of these. Also rename 'frame_length' to 'frame_len_words' to make clear that it's not a byte count like spi_message::frame_length.
--- drivers/spi/spi-ti-qspi.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/spi/spi-ti-qspi.c +9 -6
@@ -94,6 +94,7 @@ struct ti_qspi {#define QSPI_FLEN (n) ((n - 1) << 0)#define QSPI_WLEN_MAX_BITS 128#define QSPI_WLEN_MAX_BYTES 16 +#define QSPI_WLEN_MASK QSPI_WLEN(QSPI_WLEN_MAX_BITS)/* STATUS REGISTER */ #define BUSY 0x01
@@ -373,7 +374,7 @@ static int ti_qspi_start_transfer_one(ststruct spi_device *spi = m->spi;struct spi_transfer *t;int status =0 , ret; -int frame_length; +unsigned int frame_len_words;/* setup device control reg */ qspi->dc =0 ;
@@ -385,21 +386,23 @@ static int ti_qspi_start_transfer_one(stif (spi->mode &SPI_CS_HIGH ) qspi->dc |=QSPI_CSPOL (spi->chip_select); - frame_length = (m->frame_length <<3 ) / spi->bits_per_word; - - frame_length =clamp (frame_length,0 ,QSPI_FRAME ); + frame_len_words =0 ; +list_for_each_entry (t, &m->transfers, transfer_list) + frame_len_words += t->len / (t->bits_per_word >>3 ); + frame_len_words = min_t(unsigned int, frame_len_words, QSPI_FRAME);/* setup command reg */ qspi->cmd =0 ; qspi->cmd |=QSPI_EN_CS (spi->chip_select); - qspi->cmd |=QSPI_FLEN (frame_length); + qspi->cmd |=QSPI_FLEN (frame_len_words);ti_qspi_write (qspi, qspi->dc,QSPI_SPI_DC_REG );mutex_lock (&qspi->list_lock);list_for_each_entry (t, &m->transfers, transfer_list) { - qspi->cmd |=QSPI_WLEN (t->bits_per_word); + qspi->cmd = ((qspi->cmd & ~QSPI_WLEN_MASK ) | +QSPI_WLEN (t->bits_per_word)); ret =qspi_transfer_msg (qspi, t);if (ret) {
Patches currently in stable-queue which might be from [email protected] are
queue-4.4/spi-spi-ti-qspi-handle-truncated-frames-properly.patch queue-4.4/spi-spi-ti-qspi-fix-flen-and-wlen-settings-if-bits_per_word-is-overridden.patch