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