Skip to content

Commit e24638a

Browse files
committed
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
2 parents c2fc946 + df75470 commit e24638a

File tree

5 files changed

+23
-30
lines changed

5 files changed

+23
-30
lines changed

drivers/spi/spi-cs42l43.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <linux/units.h>
2727

2828
#define CS42L43_FIFO_SIZE 16
29-
#define CS42L43_SPI_ROOT_HZ (40 * HZ_PER_MHZ)
29+
#define CS42L43_SPI_ROOT_HZ 49152000
3030
#define CS42L43_SPI_MAX_LENGTH 65532
3131

3232
enum cs42l43_spi_cmd {
@@ -54,15 +54,15 @@ static const struct software_node ampr = {
5454

5555
static struct spi_board_info ampl_info = {
5656
.modalias = "cs35l56",
57-
.max_speed_hz = 20 * HZ_PER_MHZ,
57+
.max_speed_hz = 11 * HZ_PER_MHZ,
5858
.chip_select = 0,
5959
.mode = SPI_MODE_0,
6060
.swnode = &ampl,
6161
};
6262

6363
static struct spi_board_info ampr_info = {
6464
.modalias = "cs35l56",
65-
.max_speed_hz = 20 * HZ_PER_MHZ,
65+
.max_speed_hz = 11 * HZ_PER_MHZ,
6666
.chip_select = 1,
6767
.mode = SPI_MODE_0,
6868
.swnode = &ampr,

drivers/spi/spi-imx.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -660,18 +660,8 @@ static int mx51_ecspi_prepare_transfer(struct spi_imx_data *spi_imx,
660660
ctrl |= (spi_imx->target_burst * 8 - 1)
661661
<< MX51_ECSPI_CTRL_BL_OFFSET;
662662
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;
675665
}
676666

677667
/* set clock speed */

drivers/spi/spi-stm32-qspi.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ static int stm32_qspi_wait_poll_status(struct stm32_qspi *qspi)
349349

350350
static int stm32_qspi_get_mode(u8 buswidth)
351351
{
352-
if (buswidth == 4)
352+
if (buswidth >= 4)
353353
return CCR_BUSWIDTH_4;
354354

355355
return buswidth;
@@ -653,9 +653,7 @@ static int stm32_qspi_setup(struct spi_device *spi)
653653
return -EINVAL;
654654

655655
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) {
659657
dev_err(qspi->dev, "spi-rx-bus-width\\/spi-tx-bus-width\\/cs-gpios\n");
660658
dev_err(qspi->dev, "configuration not supported\n");
661659

@@ -676,10 +674,10 @@ static int stm32_qspi_setup(struct spi_device *spi)
676674
qspi->cr_reg = CR_APMS | 3 << CR_FTHRES_SHIFT | CR_SSHIFT | CR_EN;
677675

678676
/*
679-
* Dual flash mode is only enable in case SPI_TX_OCTAL and SPI_TX_OCTAL
680-
* are both set in spi->mode and "cs-gpios" properties is found in DT
677+
* Dual flash mode is only enable in case SPI_TX_OCTAL or SPI_RX_OCTAL
678+
* is set in spi->mode and "cs-gpios" properties is found in DT
681679
*/
682-
if (mode == (SPI_TX_OCTAL | SPI_RX_OCTAL)) {
680+
if (mode) {
683681
qspi->cr_reg |= CR_DFM;
684682
dev_dbg(qspi->dev, "Dual flash mode enable");
685683
}

drivers/spi/spi.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -689,10 +689,12 @@ static int __spi_add_device(struct spi_device *spi)
689689
* Make sure that multiple logical CS doesn't map to the same physical CS.
690690
* For example, spi->chip_select[0] != spi->chip_select[1] and so on.
691691
*/
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+
}
696698
}
697699

698700
/* Set the bus ID string */
@@ -4156,7 +4158,8 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
41564158
return -EINVAL;
41574159
if (xfer->tx_nbits != SPI_NBITS_SINGLE &&
41584160
xfer->tx_nbits != SPI_NBITS_DUAL &&
4159-
xfer->tx_nbits != SPI_NBITS_QUAD)
4161+
xfer->tx_nbits != SPI_NBITS_QUAD &&
4162+
xfer->tx_nbits != SPI_NBITS_OCTAL)
41604163
return -EINVAL;
41614164
if ((xfer->tx_nbits == SPI_NBITS_DUAL) &&
41624165
!(spi->mode & (SPI_TX_DUAL | SPI_TX_QUAD)))
@@ -4171,7 +4174,8 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
41714174
return -EINVAL;
41724175
if (xfer->rx_nbits != SPI_NBITS_SINGLE &&
41734176
xfer->rx_nbits != SPI_NBITS_DUAL &&
4174-
xfer->rx_nbits != SPI_NBITS_QUAD)
4177+
xfer->rx_nbits != SPI_NBITS_QUAD &&
4178+
xfer->rx_nbits != SPI_NBITS_OCTAL)
41754179
return -EINVAL;
41764180
if ((xfer->rx_nbits == SPI_NBITS_DUAL) &&
41774181
!(spi->mode & (SPI_RX_DUAL | SPI_RX_QUAD)))

include/linux/spi/spi.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,12 +1085,13 @@ struct spi_transfer {
10851085
unsigned dummy_data:1;
10861086
unsigned cs_off:1;
10871087
unsigned cs_change:1;
1088-
unsigned tx_nbits:3;
1089-
unsigned rx_nbits:3;
1088+
unsigned tx_nbits:4;
1089+
unsigned rx_nbits:4;
10901090
unsigned timestamped:1;
10911091
#define SPI_NBITS_SINGLE 0x01 /* 1-bit transfer */
10921092
#define SPI_NBITS_DUAL 0x02 /* 2-bit transfer */
10931093
#define SPI_NBITS_QUAD 0x04 /* 4-bit transfer */
1094+
#define SPI_NBITS_OCTAL 0x08 /* 8-bit transfer */
10941095
u8 bits_per_word;
10951096
struct spi_delay delay;
10961097
struct spi_delay cs_change_delay;

0 commit comments

Comments
 (0)