Skip to content

Commit a00cf19

Browse files
committed
Merge tag 'spi-fix-v6.8-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
Pull spi fixes from Mark Brown: "A smallish collection of fixes for SPI, all driver specific, plus one device ID addition for a new Intel part. The ppc4xx isn't routinely covered by most of the automated testing so there were some errors that were missed in some of the recent API conversions, otherwise there's nothing super remarkable here" * tag 'spi-fix-v6.8-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: spi-mxs: Fix chipselect glitch spi: intel-pci: Add support for Lunar Lake-M SPI serial flash spi: omap2-mcspi: Revert FIFO support without DMA spi: ppc4xx: Drop write-only variable spi: ppc4xx: Fix fallout from rename in struct spi_bitbang spi: ppc4xx: Fix fallout from include cleanup spi: spi-ppc4xx: include missing platform_device.h spi: imx: fix the burst length at DMA mode and CPU mode
2 parents 2c46083 + 269e31a commit a00cf19

File tree

5 files changed

+25
-146
lines changed

5 files changed

+25
-146
lines changed

drivers/spi/spi-imx.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
33
// Copyright (C) 2008 Juergen Beisert
44

5+
#include <linux/bits.h>
56
#include <linux/clk.h>
67
#include <linux/completion.h>
78
#include <linux/delay.h>
@@ -660,15 +661,15 @@ static int mx51_ecspi_prepare_transfer(struct spi_imx_data *spi_imx,
660661
<< MX51_ECSPI_CTRL_BL_OFFSET;
661662
else {
662663
if (spi_imx->usedma) {
663-
ctrl |= (spi_imx->bits_per_word *
664-
spi_imx_bytes_per_word(spi_imx->bits_per_word) - 1)
664+
ctrl |= (spi_imx->bits_per_word - 1)
665665
<< MX51_ECSPI_CTRL_BL_OFFSET;
666666
} else {
667667
if (spi_imx->count >= MX51_ECSPI_CTRL_MAX_BURST)
668-
ctrl |= (MX51_ECSPI_CTRL_MAX_BURST - 1)
668+
ctrl |= (MX51_ECSPI_CTRL_MAX_BURST * BITS_PER_BYTE - 1)
669669
<< MX51_ECSPI_CTRL_BL_OFFSET;
670670
else
671-
ctrl |= (spi_imx->count * spi_imx->bits_per_word - 1)
671+
ctrl |= spi_imx->count / DIV_ROUND_UP(spi_imx->bits_per_word,
672+
BITS_PER_BYTE) * spi_imx->bits_per_word
672673
<< MX51_ECSPI_CTRL_BL_OFFSET;
673674
}
674675
}

drivers/spi/spi-intel-pci.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ static const struct pci_device_id intel_spi_pci_ids[] = {
8585
{ PCI_VDEVICE(INTEL, 0xa2a4), (unsigned long)&cnl_info },
8686
{ PCI_VDEVICE(INTEL, 0xa324), (unsigned long)&cnl_info },
8787
{ PCI_VDEVICE(INTEL, 0xa3a4), (unsigned long)&cnl_info },
88+
{ PCI_VDEVICE(INTEL, 0xa823), (unsigned long)&cnl_info },
8889
{ },
8990
};
9091
MODULE_DEVICE_TABLE(pci, intel_spi_pci_ids);

drivers/spi/spi-mxs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include <linux/spi/spi.h>
4040
#include <linux/spi/mxs-spi.h>
4141
#include <trace/events/spi.h>
42+
#include <linux/dma/mxs-dma.h>
4243

4344
#define DRIVER_NAME "mxs-spi"
4445

@@ -252,7 +253,7 @@ static int mxs_spi_txrx_dma(struct mxs_spi *spi,
252253
desc = dmaengine_prep_slave_sg(ssp->dmach,
253254
&dma_xfer[sg_count].sg, 1,
254255
(flags & TXRX_WRITE) ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM,
255-
DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
256+
DMA_PREP_INTERRUPT | MXS_DMA_CTRL_WAIT4END);
256257

257258
if (!desc) {
258259
dev_err(ssp->dev,

drivers/spi/spi-omap2-mcspi.c

Lines changed: 8 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@
5353

5454
/* per-register bitmasks: */
5555
#define OMAP2_MCSPI_IRQSTATUS_EOW BIT(17)
56-
#define OMAP2_MCSPI_IRQSTATUS_TX0_EMPTY BIT(0)
57-
#define OMAP2_MCSPI_IRQSTATUS_RX0_FULL BIT(2)
5856

5957
#define OMAP2_MCSPI_MODULCTRL_SINGLE BIT(0)
6058
#define OMAP2_MCSPI_MODULCTRL_MS BIT(2)
@@ -293,7 +291,7 @@ static void omap2_mcspi_set_mode(struct spi_controller *ctlr)
293291
}
294292

295293
static void omap2_mcspi_set_fifo(const struct spi_device *spi,
296-
struct spi_transfer *t, int enable, int dma_enabled)
294+
struct spi_transfer *t, int enable)
297295
{
298296
struct spi_controller *ctlr = spi->controller;
299297
struct omap2_mcspi_cs *cs = spi->controller_state;
@@ -314,28 +312,20 @@ static void omap2_mcspi_set_fifo(const struct spi_device *spi,
314312
max_fifo_depth = OMAP2_MCSPI_MAX_FIFODEPTH / 2;
315313
else
316314
max_fifo_depth = OMAP2_MCSPI_MAX_FIFODEPTH;
317-
if (dma_enabled)
318-
wcnt = t->len / bytes_per_word;
319-
else
320-
wcnt = 0;
315+
316+
wcnt = t->len / bytes_per_word;
321317
if (wcnt > OMAP2_MCSPI_MAX_FIFOWCNT)
322318
goto disable_fifo;
323319

324320
xferlevel = wcnt << 16;
325321
if (t->rx_buf != NULL) {
326322
chconf |= OMAP2_MCSPI_CHCONF_FFER;
327-
if (dma_enabled)
328-
xferlevel |= (bytes_per_word - 1) << 8;
329-
else
330-
xferlevel |= (max_fifo_depth - 1) << 8;
323+
xferlevel |= (bytes_per_word - 1) << 8;
331324
}
332325

333326
if (t->tx_buf != NULL) {
334327
chconf |= OMAP2_MCSPI_CHCONF_FFET;
335-
if (dma_enabled)
336-
xferlevel |= bytes_per_word - 1;
337-
else
338-
xferlevel |= (max_fifo_depth - 1);
328+
xferlevel |= bytes_per_word - 1;
339329
}
340330

341331
mcspi_write_reg(ctlr, OMAP2_MCSPI_XFERLEVEL, xferlevel);
@@ -892,113 +882,6 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
892882
return count - c;
893883
}
894884

895-
static unsigned
896-
omap2_mcspi_txrx_piofifo(struct spi_device *spi, struct spi_transfer *xfer)
897-
{
898-
struct omap2_mcspi_cs *cs = spi->controller_state;
899-
struct omap2_mcspi *mcspi;
900-
unsigned int count, c;
901-
unsigned int iter, cwc;
902-
int last_request;
903-
void __iomem *base = cs->base;
904-
void __iomem *tx_reg;
905-
void __iomem *rx_reg;
906-
void __iomem *chstat_reg;
907-
void __iomem *irqstat_reg;
908-
int word_len, bytes_per_word;
909-
u8 *rx;
910-
const u8 *tx;
911-
912-
mcspi = spi_controller_get_devdata(spi->controller);
913-
count = xfer->len;
914-
c = count;
915-
word_len = cs->word_len;
916-
bytes_per_word = mcspi_bytes_per_word(word_len);
917-
918-
/*
919-
* We store the pre-calculated register addresses on stack to speed
920-
* up the transfer loop.
921-
*/
922-
tx_reg = base + OMAP2_MCSPI_TX0;
923-
rx_reg = base + OMAP2_MCSPI_RX0;
924-
chstat_reg = base + OMAP2_MCSPI_CHSTAT0;
925-
irqstat_reg = base + OMAP2_MCSPI_IRQSTATUS;
926-
927-
if (c < (word_len >> 3))
928-
return 0;
929-
930-
rx = xfer->rx_buf;
931-
tx = xfer->tx_buf;
932-
933-
do {
934-
/* calculate number of words in current iteration */
935-
cwc = min((unsigned int)mcspi->fifo_depth / bytes_per_word,
936-
c / bytes_per_word);
937-
last_request = cwc != (mcspi->fifo_depth / bytes_per_word);
938-
if (tx) {
939-
if (mcspi_wait_for_reg_bit(irqstat_reg,
940-
OMAP2_MCSPI_IRQSTATUS_TX0_EMPTY) < 0) {
941-
dev_err(&spi->dev, "TX Empty timed out\n");
942-
goto out;
943-
}
944-
writel_relaxed(OMAP2_MCSPI_IRQSTATUS_TX0_EMPTY, irqstat_reg);
945-
946-
for (iter = 0; iter < cwc; iter++, tx += bytes_per_word) {
947-
if (bytes_per_word == 1)
948-
writel_relaxed(*tx, tx_reg);
949-
else if (bytes_per_word == 2)
950-
writel_relaxed(*((u16 *)tx), tx_reg);
951-
else if (bytes_per_word == 4)
952-
writel_relaxed(*((u32 *)tx), tx_reg);
953-
}
954-
}
955-
956-
if (rx) {
957-
if (!last_request &&
958-
mcspi_wait_for_reg_bit(irqstat_reg,
959-
OMAP2_MCSPI_IRQSTATUS_RX0_FULL) < 0) {
960-
dev_err(&spi->dev, "RX_FULL timed out\n");
961-
goto out;
962-
}
963-
writel_relaxed(OMAP2_MCSPI_IRQSTATUS_RX0_FULL, irqstat_reg);
964-
965-
for (iter = 0; iter < cwc; iter++, rx += bytes_per_word) {
966-
if (last_request &&
967-
mcspi_wait_for_reg_bit(chstat_reg,
968-
OMAP2_MCSPI_CHSTAT_RXS) < 0) {
969-
dev_err(&spi->dev, "RXS timed out\n");
970-
goto out;
971-
}
972-
if (bytes_per_word == 1)
973-
*rx = readl_relaxed(rx_reg);
974-
else if (bytes_per_word == 2)
975-
*((u16 *)rx) = readl_relaxed(rx_reg);
976-
else if (bytes_per_word == 4)
977-
*((u32 *)rx) = readl_relaxed(rx_reg);
978-
}
979-
}
980-
981-
if (last_request) {
982-
if (mcspi_wait_for_reg_bit(chstat_reg,
983-
OMAP2_MCSPI_CHSTAT_EOT) < 0) {
984-
dev_err(&spi->dev, "EOT timed out\n");
985-
goto out;
986-
}
987-
if (mcspi_wait_for_reg_bit(chstat_reg,
988-
OMAP2_MCSPI_CHSTAT_TXFFE) < 0) {
989-
dev_err(&spi->dev, "TXFFE timed out\n");
990-
goto out;
991-
}
992-
omap2_mcspi_set_enable(spi, 0);
993-
}
994-
c -= cwc * bytes_per_word;
995-
} while (c >= bytes_per_word);
996-
997-
out:
998-
omap2_mcspi_set_enable(spi, 1);
999-
return count - c;
1000-
}
1001-
1002885
static u32 omap2_mcspi_calc_divisor(u32 speed_hz, u32 ref_clk_hz)
1003886
{
1004887
u32 div;
@@ -1323,9 +1206,7 @@ static int omap2_mcspi_transfer_one(struct spi_controller *ctlr,
13231206
if ((mcspi_dma->dma_rx && mcspi_dma->dma_tx) &&
13241207
ctlr->cur_msg_mapped &&
13251208
ctlr->can_dma(ctlr, spi, t))
1326-
omap2_mcspi_set_fifo(spi, t, 1, 1);
1327-
else if (t->len > OMAP2_MCSPI_MAX_FIFODEPTH)
1328-
omap2_mcspi_set_fifo(spi, t, 1, 0);
1209+
omap2_mcspi_set_fifo(spi, t, 1);
13291210

13301211
omap2_mcspi_set_enable(spi, 1);
13311212

@@ -1338,8 +1219,6 @@ static int omap2_mcspi_transfer_one(struct spi_controller *ctlr,
13381219
ctlr->cur_msg_mapped &&
13391220
ctlr->can_dma(ctlr, spi, t))
13401221
count = omap2_mcspi_txrx_dma(spi, t);
1341-
else if (mcspi->fifo_depth > 0)
1342-
count = omap2_mcspi_txrx_piofifo(spi, t);
13431222
else
13441223
count = omap2_mcspi_txrx_pio(spi, t);
13451224

@@ -1352,7 +1231,7 @@ static int omap2_mcspi_transfer_one(struct spi_controller *ctlr,
13521231
omap2_mcspi_set_enable(spi, 0);
13531232

13541233
if (mcspi->fifo_depth > 0)
1355-
omap2_mcspi_set_fifo(spi, t, 0, 0);
1234+
omap2_mcspi_set_fifo(spi, t, 0);
13561235

13571236
out:
13581237
/* Restore defaults if they were overriden */
@@ -1375,7 +1254,7 @@ static int omap2_mcspi_transfer_one(struct spi_controller *ctlr,
13751254
omap2_mcspi_set_cs(spi, !(spi->mode & SPI_CS_HIGH));
13761255

13771256
if (mcspi->fifo_depth > 0 && t)
1378-
omap2_mcspi_set_fifo(spi, t, 0, 0);
1257+
omap2_mcspi_set_fifo(spi, t, 0);
13791258

13801259
return status;
13811260
}

drivers/spi/spi-ppc4xx.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@
2525
#include <linux/slab.h>
2626
#include <linux/errno.h>
2727
#include <linux/wait.h>
28+
#include <linux/platform_device.h>
2829
#include <linux/of_address.h>
2930
#include <linux/of_irq.h>
3031
#include <linux/of_platform.h>
3132
#include <linux/interrupt.h>
3233
#include <linux/delay.h>
34+
#include <linux/platform_device.h>
3335

3436
#include <linux/spi/spi.h>
3537
#include <linux/spi/spi_bitbang.h>
@@ -166,20 +168,15 @@ static int spi_ppc4xx_setupxfer(struct spi_device *spi, struct spi_transfer *t)
166168
int scr;
167169
u8 cdm = 0;
168170
u32 speed;
169-
u8 bits_per_word;
170171

171172
/* Start with the generic configuration for this device. */
172-
bits_per_word = spi->bits_per_word;
173173
speed = spi->max_speed_hz;
174174

175175
/*
176176
* Modify the configuration if the transfer overrides it. Do not allow
177177
* the transfer to overwrite the generic configuration with zeros.
178178
*/
179179
if (t) {
180-
if (t->bits_per_word)
181-
bits_per_word = t->bits_per_word;
182-
183180
if (t->speed_hz)
184181
speed = min(t->speed_hz, spi->max_speed_hz);
185182
}
@@ -362,22 +359,22 @@ static int spi_ppc4xx_of_probe(struct platform_device *op)
362359

363360
/* Setup the state for the bitbang driver */
364361
bbp = &hw->bitbang;
365-
bbp->master = hw->host;
362+
bbp->ctlr = hw->host;
366363
bbp->setup_transfer = spi_ppc4xx_setupxfer;
367364
bbp->txrx_bufs = spi_ppc4xx_txrx;
368365
bbp->use_dma = 0;
369-
bbp->master->setup = spi_ppc4xx_setup;
370-
bbp->master->cleanup = spi_ppc4xx_cleanup;
371-
bbp->master->bits_per_word_mask = SPI_BPW_MASK(8);
372-
bbp->master->use_gpio_descriptors = true;
366+
bbp->ctlr->setup = spi_ppc4xx_setup;
367+
bbp->ctlr->cleanup = spi_ppc4xx_cleanup;
368+
bbp->ctlr->bits_per_word_mask = SPI_BPW_MASK(8);
369+
bbp->ctlr->use_gpio_descriptors = true;
373370
/*
374371
* The SPI core will count the number of GPIO descriptors to figure
375372
* out the number of chip selects available on the platform.
376373
*/
377-
bbp->master->num_chipselect = 0;
374+
bbp->ctlr->num_chipselect = 0;
378375

379376
/* the spi->mode bits understood by this driver: */
380-
bbp->master->mode_bits =
377+
bbp->ctlr->mode_bits =
381378
SPI_CPHA | SPI_CPOL | SPI_CS_HIGH | SPI_LSB_FIRST;
382379

383380
/* Get the clock for the OPB */

0 commit comments

Comments
 (0)