Skip to content

Commit 741b31d

Browse files
committed
spi: Merge up fixes
We need the fixes to apply new changes to the Cirrus drivers.
2 parents 78b0517 + df75470 commit 741b31d

5 files changed

Lines changed: 23 additions & 30 deletions

File tree

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 */
@@ -4132,7 +4134,8 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
41324134
return -EINVAL;
41334135
if (xfer->tx_nbits != SPI_NBITS_SINGLE &&
41344136
xfer->tx_nbits != SPI_NBITS_DUAL &&
4135-
xfer->tx_nbits != SPI_NBITS_QUAD)
4137+
xfer->tx_nbits != SPI_NBITS_QUAD &&
4138+
xfer->tx_nbits != SPI_NBITS_OCTAL)
41364139
return -EINVAL;
41374140
if ((xfer->tx_nbits == SPI_NBITS_DUAL) &&
41384141
!(spi->mode & (SPI_TX_DUAL | SPI_TX_QUAD)))
@@ -4147,7 +4150,8 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
41474150
return -EINVAL;
41484151
if (xfer->rx_nbits != SPI_NBITS_SINGLE &&
41494152
xfer->rx_nbits != SPI_NBITS_DUAL &&
4150-
xfer->rx_nbits != SPI_NBITS_QUAD)
4153+
xfer->rx_nbits != SPI_NBITS_QUAD &&
4154+
xfer->rx_nbits != SPI_NBITS_OCTAL)
41514155
return -EINVAL;
41524156
if ((xfer->rx_nbits == SPI_NBITS_DUAL) &&
41534157
!(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
@@ -1088,12 +1088,13 @@ struct spi_transfer {
10881088
unsigned dummy_data:1;
10891089
unsigned cs_off:1;
10901090
unsigned cs_change:1;
1091-
unsigned tx_nbits:3;
1092-
unsigned rx_nbits:3;
1091+
unsigned tx_nbits:4;
1092+
unsigned rx_nbits:4;
10931093
unsigned timestamped:1;
10941094
#define SPI_NBITS_SINGLE 0x01 /* 1-bit transfer */
10951095
#define SPI_NBITS_DUAL 0x02 /* 2-bit transfer */
10961096
#define SPI_NBITS_QUAD 0x04 /* 4-bit transfer */
1097+
#define SPI_NBITS_OCTAL 0x08 /* 8-bit transfer */
10971098
u8 bits_per_word;
10981099
struct spi_delay delay;
10991100
struct spi_delay cs_change_delay;

0 commit comments

Comments
 (0)