diff options
author | Maxime Chevallier <maxime.chevallier@bootlin.com> | 2018-07-17 10:31:51 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2018-07-24 10:58:24 -0400 |
commit | 2801b2f5fad3d1e9ea0ac8484584051071065645 (patch) | |
tree | effe1241e2060a52a32396847b4dddb5a2005515 | |
parent | a021cac420f8a3bd1c36c91af9dd3143c44101d7 (diff) |
spi: imx: Use dynamic bursts only when bits_per_word is 8, 16 or 32
The dynamic bursts mode allows to group together multiple words into a
single burst. To do so, it's necessary that words can be packed into the
32-bits FIFO entries, so we can't allow using this mode with bit_per_words
different to 8, 16 or 32.
This prevents shitfing out extra clock ticks for transfers with
bit_per_word values not aligned on 8 bits.
With that , we are sure that only the correct number of bits is
shifted out at each transfer, so we don't need to mask out the remaining
parts of the words.
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/spi/spi-imx.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index d75153c995af..ecafbda5ec94 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c | |||
@@ -95,7 +95,6 @@ struct spi_imx_data { | |||
95 | const void *tx_buf; | 95 | const void *tx_buf; |
96 | unsigned int txfifo; /* number of words pushed in tx FIFO */ | 96 | unsigned int txfifo; /* number of words pushed in tx FIFO */ |
97 | unsigned int dynamic_burst, read_u32; | 97 | unsigned int dynamic_burst, read_u32; |
98 | unsigned int word_mask; | ||
99 | 98 | ||
100 | /* Slave mode */ | 99 | /* Slave mode */ |
101 | bool slave_mode; | 100 | bool slave_mode; |
@@ -291,7 +290,6 @@ static void spi_imx_buf_rx_swap_u32(struct spi_imx_data *spi_imx) | |||
291 | else if (bytes_per_word == 2) | 290 | else if (bytes_per_word == 2) |
292 | val = (val << 16) | (val >> 16); | 291 | val = (val << 16) | (val >> 16); |
293 | #endif | 292 | #endif |
294 | val &= spi_imx->word_mask; | ||
295 | *(u32 *)spi_imx->rx_buf = val; | 293 | *(u32 *)spi_imx->rx_buf = val; |
296 | spi_imx->rx_buf += sizeof(u32); | 294 | spi_imx->rx_buf += sizeof(u32); |
297 | } | 295 | } |
@@ -322,7 +320,6 @@ static void spi_imx_buf_tx_swap_u32(struct spi_imx_data *spi_imx) | |||
322 | 320 | ||
323 | if (spi_imx->tx_buf) { | 321 | if (spi_imx->tx_buf) { |
324 | val = *(u32 *)spi_imx->tx_buf; | 322 | val = *(u32 *)spi_imx->tx_buf; |
325 | val &= spi_imx->word_mask; | ||
326 | spi_imx->tx_buf += sizeof(u32); | 323 | spi_imx->tx_buf += sizeof(u32); |
327 | } | 324 | } |
328 | 325 | ||
@@ -1102,25 +1099,23 @@ static int spi_imx_setupxfer(struct spi_device *spi, | |||
1102 | spi_imx->bits_per_word = t->bits_per_word; | 1099 | spi_imx->bits_per_word = t->bits_per_word; |
1103 | spi_imx->speed_hz = t->speed_hz; | 1100 | spi_imx->speed_hz = t->speed_hz; |
1104 | 1101 | ||
1105 | /* Initialize the functions for transfer */ | 1102 | /* |
1106 | if (spi_imx->devtype_data->dynamic_burst && !spi_imx->slave_mode) { | 1103 | * Initialize the functions for transfer. To transfer non byte-aligned |
1107 | u32 mask; | 1104 | * words, we have to use multiple word-size bursts, we can't use |
1105 | * dynamic_burst in that case. | ||
1106 | */ | ||
1107 | if (spi_imx->devtype_data->dynamic_burst && !spi_imx->slave_mode && | ||
1108 | (spi_imx->bits_per_word == 8 || | ||
1109 | spi_imx->bits_per_word == 16 || | ||
1110 | spi_imx->bits_per_word == 32)) { | ||
1108 | 1111 | ||
1109 | spi_imx->read_u32 = 1; | 1112 | spi_imx->read_u32 = 1; |
1110 | 1113 | ||
1111 | mask = (1 << spi_imx->bits_per_word) - 1; | ||
1112 | spi_imx->rx = spi_imx_buf_rx_swap; | 1114 | spi_imx->rx = spi_imx_buf_rx_swap; |
1113 | spi_imx->tx = spi_imx_buf_tx_swap; | 1115 | spi_imx->tx = spi_imx_buf_tx_swap; |
1114 | spi_imx->dynamic_burst = 1; | 1116 | spi_imx->dynamic_burst = 1; |
1115 | spi_imx->remainder = t->len; | 1117 | spi_imx->remainder = t->len; |
1116 | 1118 | ||
1117 | if (spi_imx->bits_per_word <= 8) | ||
1118 | spi_imx->word_mask = mask << 24 | mask << 16 | ||
1119 | | mask << 8 | mask; | ||
1120 | else if (spi_imx->bits_per_word <= 16) | ||
1121 | spi_imx->word_mask = mask << 16 | mask; | ||
1122 | else | ||
1123 | spi_imx->word_mask = mask; | ||
1124 | } else { | 1119 | } else { |
1125 | if (spi_imx->bits_per_word <= 8) { | 1120 | if (spi_imx->bits_per_word <= 8) { |
1126 | spi_imx->rx = spi_imx_buf_rx_u8; | 1121 | spi_imx->rx = spi_imx_buf_rx_u8; |