Merge tag 'spi-fix-v6.10-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi

Pull spi fixes from Mark Brown:
"A number of fixes that have built up for SPI, a bunch of driver
specific ones including an unfortunate revert of an optimisation for
the i.MX driver which was causing issues with some configurations,
plus a couple of core fixes for the rarely used octal mode and for a
bad interaction between multi-CS support and target mode"

* tag 'spi-fix-v6.10-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi:
spi: spi-imx: imx51: revert burst length calculation back to bits_per_word
spi: Fix SPI slave probe failure
spi: Fix OCTAL mode support
spi: stm32: qspi: Clamp stm32_qspi_get_mode() output to CCR_BUSWIDTH_4
spi: stm32: qspi: Fix dual flash mode sanity test in stm32_qspi_setup()
spi: cs42l43: Drop cs35l56 SPI speed down to 11MHz
spi: cs42l43: Correct SPI root clock speed

+23 -30
+3 -3
drivers/spi/spi-cs42l43.c
··· 26 26 #include <linux/units.h> 27 27 28 28 #define CS42L43_FIFO_SIZE 16 29 - #define CS42L43_SPI_ROOT_HZ (40 * HZ_PER_MHZ) 29 + #define CS42L43_SPI_ROOT_HZ 49152000 30 30 #define CS42L43_SPI_MAX_LENGTH 65532 31 31 32 32 enum cs42l43_spi_cmd { ··· 54 54 55 55 static struct spi_board_info ampl_info = { 56 56 .modalias = "cs35l56", 57 - .max_speed_hz = 20 * HZ_PER_MHZ, 57 + .max_speed_hz = 11 * HZ_PER_MHZ, 58 58 .chip_select = 0, 59 59 .mode = SPI_MODE_0, 60 60 .swnode = &ampl, ··· 62 62 63 63 static struct spi_board_info ampr_info = { 64 64 .modalias = "cs35l56", 65 - .max_speed_hz = 20 * HZ_PER_MHZ, 65 + .max_speed_hz = 11 * HZ_PER_MHZ, 66 66 .chip_select = 1, 67 67 .mode = SPI_MODE_0, 68 68 .swnode = &ampr,
+2 -12
drivers/spi/spi-imx.c
··· 660 660 ctrl |= (spi_imx->target_burst * 8 - 1) 661 661 << MX51_ECSPI_CTRL_BL_OFFSET; 662 662 else { 663 - if (spi_imx->usedma) { 664 - ctrl |= (spi_imx->bits_per_word - 1) 665 - << MX51_ECSPI_CTRL_BL_OFFSET; 666 - } else { 667 - if (spi_imx->count >= MX51_ECSPI_CTRL_MAX_BURST) 668 - ctrl |= (MX51_ECSPI_CTRL_MAX_BURST * BITS_PER_BYTE - 1) 669 - << MX51_ECSPI_CTRL_BL_OFFSET; 670 - else 671 - ctrl |= (spi_imx->count / DIV_ROUND_UP(spi_imx->bits_per_word, 672 - BITS_PER_BYTE) * spi_imx->bits_per_word - 1) 673 - << MX51_ECSPI_CTRL_BL_OFFSET; 674 - } 663 + ctrl |= (spi_imx->bits_per_word - 1) 664 + << MX51_ECSPI_CTRL_BL_OFFSET; 675 665 } 676 666 677 667 /* set clock speed */
+5 -7
drivers/spi/spi-stm32-qspi.c
··· 349 349 350 350 static int stm32_qspi_get_mode(u8 buswidth) 351 351 { 352 - if (buswidth == 4) 352 + if (buswidth >= 4) 353 353 return CCR_BUSWIDTH_4; 354 354 355 355 return buswidth; ··· 653 653 return -EINVAL; 654 654 655 655 mode = spi->mode & (SPI_TX_OCTAL | SPI_RX_OCTAL); 656 - if ((mode == SPI_TX_OCTAL || mode == SPI_RX_OCTAL) || 657 - ((mode == (SPI_TX_OCTAL | SPI_RX_OCTAL)) && 658 - gpiod_count(qspi->dev, "cs") == -ENOENT)) { 656 + if (mode && gpiod_count(qspi->dev, "cs") == -ENOENT) { 659 657 dev_err(qspi->dev, "spi-rx-bus-width\\/spi-tx-bus-width\\/cs-gpios\n"); 660 658 dev_err(qspi->dev, "configuration not supported\n"); 661 659 ··· 674 676 qspi->cr_reg = CR_APMS | 3 << CR_FTHRES_SHIFT | CR_SSHIFT | CR_EN; 675 677 676 678 /* 677 - * Dual flash mode is only enable in case SPI_TX_OCTAL and SPI_TX_OCTAL 678 - * are both set in spi->mode and "cs-gpios" properties is found in DT 679 + * Dual flash mode is only enable in case SPI_TX_OCTAL or SPI_RX_OCTAL 680 + * is set in spi->mode and "cs-gpios" properties is found in DT 679 681 */ 680 - if (mode == (SPI_TX_OCTAL | SPI_RX_OCTAL)) { 682 + if (mode) { 681 683 qspi->cr_reg |= CR_DFM; 682 684 dev_dbg(qspi->dev, "Dual flash mode enable"); 683 685 }
+10 -6
drivers/spi/spi.c
··· 689 689 * Make sure that multiple logical CS doesn't map to the same physical CS. 690 690 * For example, spi->chip_select[0] != spi->chip_select[1] and so on. 691 691 */ 692 - for (idx = 0; idx < SPI_CS_CNT_MAX; idx++) { 693 - status = spi_dev_check_cs(dev, spi, idx, spi, idx + 1); 694 - if (status) 695 - return status; 692 + if (!spi_controller_is_target(ctlr)) { 693 + for (idx = 0; idx < SPI_CS_CNT_MAX; idx++) { 694 + status = spi_dev_check_cs(dev, spi, idx, spi, idx + 1); 695 + if (status) 696 + return status; 697 + } 696 698 } 697 699 698 700 /* Set the bus ID string */ ··· 4158 4156 return -EINVAL; 4159 4157 if (xfer->tx_nbits != SPI_NBITS_SINGLE && 4160 4158 xfer->tx_nbits != SPI_NBITS_DUAL && 4161 - xfer->tx_nbits != SPI_NBITS_QUAD) 4159 + xfer->tx_nbits != SPI_NBITS_QUAD && 4160 + xfer->tx_nbits != SPI_NBITS_OCTAL) 4162 4161 return -EINVAL; 4163 4162 if ((xfer->tx_nbits == SPI_NBITS_DUAL) && 4164 4163 !(spi->mode & (SPI_TX_DUAL | SPI_TX_QUAD))) ··· 4174 4171 return -EINVAL; 4175 4172 if (xfer->rx_nbits != SPI_NBITS_SINGLE && 4176 4173 xfer->rx_nbits != SPI_NBITS_DUAL && 4177 - xfer->rx_nbits != SPI_NBITS_QUAD) 4174 + xfer->rx_nbits != SPI_NBITS_QUAD && 4175 + xfer->rx_nbits != SPI_NBITS_OCTAL) 4178 4176 return -EINVAL; 4179 4177 if ((xfer->rx_nbits == SPI_NBITS_DUAL) && 4180 4178 !(spi->mode & (SPI_RX_DUAL | SPI_RX_QUAD)))
+3 -2
include/linux/spi/spi.h
··· 1085 1085 unsigned dummy_data:1; 1086 1086 unsigned cs_off:1; 1087 1087 unsigned cs_change:1; 1088 - unsigned tx_nbits:3; 1089 - unsigned rx_nbits:3; 1088 + unsigned tx_nbits:4; 1089 + unsigned rx_nbits:4; 1090 1090 unsigned timestamped:1; 1091 1091 #define SPI_NBITS_SINGLE 0x01 /* 1-bit transfer */ 1092 1092 #define SPI_NBITS_DUAL 0x02 /* 2-bit transfer */ 1093 1093 #define SPI_NBITS_QUAD 0x04 /* 4-bit transfer */ 1094 + #define SPI_NBITS_OCTAL 0x08 /* 8-bit transfer */ 1094 1095 u8 bits_per_word; 1095 1096 struct spi_delay delay; 1096 1097 struct spi_delay cs_change_delay;