.. | .. |
---|
203 | 203 | return bits_per_word; |
---|
204 | 204 | } |
---|
205 | 205 | |
---|
206 | | -static int mspi_apply_qe_mode_quirks(struct spi_mpc8xxx_cs *cs, |
---|
207 | | - struct spi_device *spi, |
---|
208 | | - int bits_per_word) |
---|
209 | | -{ |
---|
210 | | - /* QE uses Little Endian for words > 8 |
---|
211 | | - * so transform all words > 8 into 8 bits |
---|
212 | | - * Unfortnatly that doesn't work for LSB so |
---|
213 | | - * reject these for now */ |
---|
214 | | - /* Note: 32 bits word, LSB works iff |
---|
215 | | - * tfcr/rfcr is set to CPMFCR_GBL */ |
---|
216 | | - if (spi->mode & SPI_LSB_FIRST && |
---|
217 | | - bits_per_word > 8) |
---|
218 | | - return -EINVAL; |
---|
219 | | - if (bits_per_word > 8) |
---|
220 | | - return 8; /* pretend its 8 bits */ |
---|
221 | | - return bits_per_word; |
---|
222 | | -} |
---|
223 | | - |
---|
224 | 206 | static int fsl_spi_setup_transfer(struct spi_device *spi, |
---|
225 | 207 | struct spi_transfer *t) |
---|
226 | 208 | { |
---|
.. | .. |
---|
248 | 230 | bits_per_word = mspi_apply_cpu_mode_quirks(cs, spi, |
---|
249 | 231 | mpc8xxx_spi, |
---|
250 | 232 | bits_per_word); |
---|
251 | | - else if (mpc8xxx_spi->flags & SPI_QE) |
---|
252 | | - bits_per_word = mspi_apply_qe_mode_quirks(cs, spi, |
---|
253 | | - bits_per_word); |
---|
254 | 233 | |
---|
255 | 234 | if (bits_per_word < 0) |
---|
256 | 235 | return bits_per_word; |
---|
.. | .. |
---|
368 | 347 | * In CPU mode, optimize large byte transfers to use larger |
---|
369 | 348 | * bits_per_word values to reduce number of interrupts taken. |
---|
370 | 349 | */ |
---|
371 | | - if (!(mpc8xxx_spi->flags & SPI_CPM_MODE)) { |
---|
372 | | - list_for_each_entry(t, &m->transfers, transfer_list) { |
---|
| 350 | + list_for_each_entry(t, &m->transfers, transfer_list) { |
---|
| 351 | + if (!(mpc8xxx_spi->flags & SPI_CPM_MODE)) { |
---|
373 | 352 | if (t->len < 256 || t->bits_per_word != 8) |
---|
374 | 353 | continue; |
---|
375 | 354 | if ((t->len & 3) == 0) |
---|
376 | 355 | t->bits_per_word = 32; |
---|
377 | 356 | else if ((t->len & 1) == 0) |
---|
| 357 | + t->bits_per_word = 16; |
---|
| 358 | + } else { |
---|
| 359 | + /* |
---|
| 360 | + * CPM/QE uses Little Endian for words > 8 |
---|
| 361 | + * so transform 16 and 32 bits words into 8 bits |
---|
| 362 | + * Unfortnatly that doesn't work for LSB so |
---|
| 363 | + * reject these for now |
---|
| 364 | + * Note: 32 bits word, LSB works iff |
---|
| 365 | + * tfcr/rfcr is set to CPMFCR_GBL |
---|
| 366 | + */ |
---|
| 367 | + if (m->spi->mode & SPI_LSB_FIRST && t->bits_per_word > 8) |
---|
| 368 | + return -EINVAL; |
---|
| 369 | + if (t->bits_per_word == 16 || t->bits_per_word == 32) |
---|
| 370 | + t->bits_per_word = 8; /* pretend its 8 bits */ |
---|
| 371 | + if (t->bits_per_word == 8 && t->len >= 256 && |
---|
| 372 | + (mpc8xxx_spi->flags & SPI_CPM1)) |
---|
378 | 373 | t->bits_per_word = 16; |
---|
379 | 374 | } |
---|
380 | 375 | } |
---|
.. | .. |
---|
633 | 628 | if (mpc8xxx_spi->type == TYPE_GRLIB) |
---|
634 | 629 | fsl_spi_grlib_probe(dev); |
---|
635 | 630 | |
---|
636 | | - master->bits_per_word_mask = |
---|
637 | | - (SPI_BPW_RANGE_MASK(4, 16) | SPI_BPW_MASK(32)) & |
---|
| 631 | + if (mpc8xxx_spi->flags & SPI_CPM_MODE) |
---|
| 632 | + master->bits_per_word_mask = |
---|
| 633 | + (SPI_BPW_RANGE_MASK(4, 8) | SPI_BPW_MASK(16) | SPI_BPW_MASK(32)); |
---|
| 634 | + else |
---|
| 635 | + master->bits_per_word_mask = |
---|
| 636 | + (SPI_BPW_RANGE_MASK(4, 16) | SPI_BPW_MASK(32)); |
---|
| 637 | + |
---|
| 638 | + master->bits_per_word_mask &= |
---|
638 | 639 | SPI_BPW_RANGE_MASK(1, mpc8xxx_spi->max_bits_per_word); |
---|
639 | 640 | |
---|
640 | 641 | if (mpc8xxx_spi->flags & SPI_QE_CPU_MODE) |
---|