Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+25 -146
+5 -4
drivers/spi/spi-imx.c
··· 2 2 // Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. 3 3 // Copyright (C) 2008 Juergen Beisert 4 4 5 + #include <linux/bits.h> 5 6 #include <linux/clk.h> 6 7 #include <linux/completion.h> 7 8 #include <linux/delay.h> ··· 661 660 << MX51_ECSPI_CTRL_BL_OFFSET; 662 661 else { 663 662 if (spi_imx->usedma) { 664 - ctrl |= (spi_imx->bits_per_word * 665 - spi_imx_bytes_per_word(spi_imx->bits_per_word) - 1) 663 + ctrl |= (spi_imx->bits_per_word - 1) 666 664 << MX51_ECSPI_CTRL_BL_OFFSET; 667 665 } else { 668 666 if (spi_imx->count >= MX51_ECSPI_CTRL_MAX_BURST) 669 - ctrl |= (MX51_ECSPI_CTRL_MAX_BURST - 1) 667 + ctrl |= (MX51_ECSPI_CTRL_MAX_BURST * BITS_PER_BYTE - 1) 670 668 << MX51_ECSPI_CTRL_BL_OFFSET; 671 669 else 672 - ctrl |= (spi_imx->count * spi_imx->bits_per_word - 1) 670 + ctrl |= spi_imx->count / DIV_ROUND_UP(spi_imx->bits_per_word, 671 + BITS_PER_BYTE) * spi_imx->bits_per_word 673 672 << MX51_ECSPI_CTRL_BL_OFFSET; 674 673 } 675 674 }
+1
drivers/spi/spi-intel-pci.c
··· 85 85 { PCI_VDEVICE(INTEL, 0xa2a4), (unsigned long)&cnl_info }, 86 86 { PCI_VDEVICE(INTEL, 0xa324), (unsigned long)&cnl_info }, 87 87 { PCI_VDEVICE(INTEL, 0xa3a4), (unsigned long)&cnl_info }, 88 + { PCI_VDEVICE(INTEL, 0xa823), (unsigned long)&cnl_info }, 88 89 { }, 89 90 }; 90 91 MODULE_DEVICE_TABLE(pci, intel_spi_pci_ids);
+2 -1
drivers/spi/spi-mxs.c
··· 39 39 #include <linux/spi/spi.h> 40 40 #include <linux/spi/mxs-spi.h> 41 41 #include <trace/events/spi.h> 42 + #include <linux/dma/mxs-dma.h> 42 43 43 44 #define DRIVER_NAME "mxs-spi" 44 45 ··· 253 252 desc = dmaengine_prep_slave_sg(ssp->dmach, 254 253 &dma_xfer[sg_count].sg, 1, 255 254 (flags & TXRX_WRITE) ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM, 256 - DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 255 + DMA_PREP_INTERRUPT | MXS_DMA_CTRL_WAIT4END); 257 256 258 257 if (!desc) { 259 258 dev_err(ssp->dev,
+8 -129
drivers/spi/spi-omap2-mcspi.c
··· 53 53 54 54 /* per-register bitmasks: */ 55 55 #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) 58 56 59 57 #define OMAP2_MCSPI_MODULCTRL_SINGLE BIT(0) 60 58 #define OMAP2_MCSPI_MODULCTRL_MS BIT(2) ··· 291 293 } 292 294 293 295 static void omap2_mcspi_set_fifo(const struct spi_device *spi, 294 - struct spi_transfer *t, int enable, int dma_enabled) 296 + struct spi_transfer *t, int enable) 295 297 { 296 298 struct spi_controller *ctlr = spi->controller; 297 299 struct omap2_mcspi_cs *cs = spi->controller_state; ··· 312 314 max_fifo_depth = OMAP2_MCSPI_MAX_FIFODEPTH / 2; 313 315 else 314 316 max_fifo_depth = OMAP2_MCSPI_MAX_FIFODEPTH; 315 - if (dma_enabled) 316 - wcnt = t->len / bytes_per_word; 317 - else 318 - wcnt = 0; 317 + 318 + wcnt = t->len / bytes_per_word; 319 319 if (wcnt > OMAP2_MCSPI_MAX_FIFOWCNT) 320 320 goto disable_fifo; 321 321 322 322 xferlevel = wcnt << 16; 323 323 if (t->rx_buf != NULL) { 324 324 chconf |= OMAP2_MCSPI_CHCONF_FFER; 325 - if (dma_enabled) 326 - xferlevel |= (bytes_per_word - 1) << 8; 327 - else 328 - xferlevel |= (max_fifo_depth - 1) << 8; 325 + xferlevel |= (bytes_per_word - 1) << 8; 329 326 } 330 327 331 328 if (t->tx_buf != NULL) { 332 329 chconf |= OMAP2_MCSPI_CHCONF_FFET; 333 - if (dma_enabled) 334 - xferlevel |= bytes_per_word - 1; 335 - else 336 - xferlevel |= (max_fifo_depth - 1); 330 + xferlevel |= bytes_per_word - 1; 337 331 } 338 332 339 333 mcspi_write_reg(ctlr, OMAP2_MCSPI_XFERLEVEL, xferlevel); ··· 882 892 return count - c; 883 893 } 884 894 885 - static unsigned 886 - omap2_mcspi_txrx_piofifo(struct spi_device *spi, struct spi_transfer *xfer) 887 - { 888 - struct omap2_mcspi_cs *cs = spi->controller_state; 889 - struct omap2_mcspi *mcspi; 890 - unsigned int count, c; 891 - unsigned int iter, cwc; 892 - int last_request; 893 - void __iomem *base = cs->base; 894 - void __iomem *tx_reg; 895 - void __iomem *rx_reg; 896 - void __iomem *chstat_reg; 897 - void __iomem *irqstat_reg; 898 - int word_len, bytes_per_word; 899 - u8 *rx; 900 - const u8 *tx; 901 - 902 - mcspi = spi_controller_get_devdata(spi->controller); 903 - count = xfer->len; 904 - c = count; 905 - word_len = cs->word_len; 906 - bytes_per_word = mcspi_bytes_per_word(word_len); 907 - 908 - /* 909 - * We store the pre-calculated register addresses on stack to speed 910 - * up the transfer loop. 911 - */ 912 - tx_reg = base + OMAP2_MCSPI_TX0; 913 - rx_reg = base + OMAP2_MCSPI_RX0; 914 - chstat_reg = base + OMAP2_MCSPI_CHSTAT0; 915 - irqstat_reg = base + OMAP2_MCSPI_IRQSTATUS; 916 - 917 - if (c < (word_len >> 3)) 918 - return 0; 919 - 920 - rx = xfer->rx_buf; 921 - tx = xfer->tx_buf; 922 - 923 - do { 924 - /* calculate number of words in current iteration */ 925 - cwc = min((unsigned int)mcspi->fifo_depth / bytes_per_word, 926 - c / bytes_per_word); 927 - last_request = cwc != (mcspi->fifo_depth / bytes_per_word); 928 - if (tx) { 929 - if (mcspi_wait_for_reg_bit(irqstat_reg, 930 - OMAP2_MCSPI_IRQSTATUS_TX0_EMPTY) < 0) { 931 - dev_err(&spi->dev, "TX Empty timed out\n"); 932 - goto out; 933 - } 934 - writel_relaxed(OMAP2_MCSPI_IRQSTATUS_TX0_EMPTY, irqstat_reg); 935 - 936 - for (iter = 0; iter < cwc; iter++, tx += bytes_per_word) { 937 - if (bytes_per_word == 1) 938 - writel_relaxed(*tx, tx_reg); 939 - else if (bytes_per_word == 2) 940 - writel_relaxed(*((u16 *)tx), tx_reg); 941 - else if (bytes_per_word == 4) 942 - writel_relaxed(*((u32 *)tx), tx_reg); 943 - } 944 - } 945 - 946 - if (rx) { 947 - if (!last_request && 948 - mcspi_wait_for_reg_bit(irqstat_reg, 949 - OMAP2_MCSPI_IRQSTATUS_RX0_FULL) < 0) { 950 - dev_err(&spi->dev, "RX_FULL timed out\n"); 951 - goto out; 952 - } 953 - writel_relaxed(OMAP2_MCSPI_IRQSTATUS_RX0_FULL, irqstat_reg); 954 - 955 - for (iter = 0; iter < cwc; iter++, rx += bytes_per_word) { 956 - if (last_request && 957 - mcspi_wait_for_reg_bit(chstat_reg, 958 - OMAP2_MCSPI_CHSTAT_RXS) < 0) { 959 - dev_err(&spi->dev, "RXS timed out\n"); 960 - goto out; 961 - } 962 - if (bytes_per_word == 1) 963 - *rx = readl_relaxed(rx_reg); 964 - else if (bytes_per_word == 2) 965 - *((u16 *)rx) = readl_relaxed(rx_reg); 966 - else if (bytes_per_word == 4) 967 - *((u32 *)rx) = readl_relaxed(rx_reg); 968 - } 969 - } 970 - 971 - if (last_request) { 972 - if (mcspi_wait_for_reg_bit(chstat_reg, 973 - OMAP2_MCSPI_CHSTAT_EOT) < 0) { 974 - dev_err(&spi->dev, "EOT timed out\n"); 975 - goto out; 976 - } 977 - if (mcspi_wait_for_reg_bit(chstat_reg, 978 - OMAP2_MCSPI_CHSTAT_TXFFE) < 0) { 979 - dev_err(&spi->dev, "TXFFE timed out\n"); 980 - goto out; 981 - } 982 - omap2_mcspi_set_enable(spi, 0); 983 - } 984 - c -= cwc * bytes_per_word; 985 - } while (c >= bytes_per_word); 986 - 987 - out: 988 - omap2_mcspi_set_enable(spi, 1); 989 - return count - c; 990 - } 991 - 992 895 static u32 omap2_mcspi_calc_divisor(u32 speed_hz, u32 ref_clk_hz) 993 896 { 994 897 u32 div; ··· 1206 1323 if ((mcspi_dma->dma_rx && mcspi_dma->dma_tx) && 1207 1324 ctlr->cur_msg_mapped && 1208 1325 ctlr->can_dma(ctlr, spi, t)) 1209 - omap2_mcspi_set_fifo(spi, t, 1, 1); 1210 - else if (t->len > OMAP2_MCSPI_MAX_FIFODEPTH) 1211 - omap2_mcspi_set_fifo(spi, t, 1, 0); 1326 + omap2_mcspi_set_fifo(spi, t, 1); 1212 1327 1213 1328 omap2_mcspi_set_enable(spi, 1); 1214 1329 ··· 1219 1338 ctlr->cur_msg_mapped && 1220 1339 ctlr->can_dma(ctlr, spi, t)) 1221 1340 count = omap2_mcspi_txrx_dma(spi, t); 1222 - else if (mcspi->fifo_depth > 0) 1223 - count = omap2_mcspi_txrx_piofifo(spi, t); 1224 1341 else 1225 1342 count = omap2_mcspi_txrx_pio(spi, t); 1226 1343 ··· 1231 1352 omap2_mcspi_set_enable(spi, 0); 1232 1353 1233 1354 if (mcspi->fifo_depth > 0) 1234 - omap2_mcspi_set_fifo(spi, t, 0, 0); 1355 + omap2_mcspi_set_fifo(spi, t, 0); 1235 1356 1236 1357 out: 1237 1358 /* Restore defaults if they were overriden */ ··· 1254 1375 omap2_mcspi_set_cs(spi, !(spi->mode & SPI_CS_HIGH)); 1255 1376 1256 1377 if (mcspi->fifo_depth > 0 && t) 1257 - omap2_mcspi_set_fifo(spi, t, 0, 0); 1378 + omap2_mcspi_set_fifo(spi, t, 0); 1258 1379 1259 1380 return status; 1260 1381 }
+9 -12
drivers/spi/spi-ppc4xx.c
··· 25 25 #include <linux/slab.h> 26 26 #include <linux/errno.h> 27 27 #include <linux/wait.h> 28 + #include <linux/platform_device.h> 28 29 #include <linux/of_address.h> 29 30 #include <linux/of_irq.h> 30 31 #include <linux/of_platform.h> 31 32 #include <linux/interrupt.h> 32 33 #include <linux/delay.h> 34 + #include <linux/platform_device.h> 33 35 34 36 #include <linux/spi/spi.h> 35 37 #include <linux/spi/spi_bitbang.h> ··· 168 166 int scr; 169 167 u8 cdm = 0; 170 168 u32 speed; 171 - u8 bits_per_word; 172 169 173 170 /* Start with the generic configuration for this device. */ 174 - bits_per_word = spi->bits_per_word; 175 171 speed = spi->max_speed_hz; 176 172 177 173 /* ··· 177 177 * the transfer to overwrite the generic configuration with zeros. 178 178 */ 179 179 if (t) { 180 - if (t->bits_per_word) 181 - bits_per_word = t->bits_per_word; 182 - 183 180 if (t->speed_hz) 184 181 speed = min(t->speed_hz, spi->max_speed_hz); 185 182 } ··· 359 362 360 363 /* Setup the state for the bitbang driver */ 361 364 bbp = &hw->bitbang; 362 - bbp->master = hw->host; 365 + bbp->ctlr = hw->host; 363 366 bbp->setup_transfer = spi_ppc4xx_setupxfer; 364 367 bbp->txrx_bufs = spi_ppc4xx_txrx; 365 368 bbp->use_dma = 0; 366 - bbp->master->setup = spi_ppc4xx_setup; 367 - bbp->master->cleanup = spi_ppc4xx_cleanup; 368 - bbp->master->bits_per_word_mask = SPI_BPW_MASK(8); 369 - bbp->master->use_gpio_descriptors = true; 369 + bbp->ctlr->setup = spi_ppc4xx_setup; 370 + bbp->ctlr->cleanup = spi_ppc4xx_cleanup; 371 + bbp->ctlr->bits_per_word_mask = SPI_BPW_MASK(8); 372 + bbp->ctlr->use_gpio_descriptors = true; 370 373 /* 371 374 * The SPI core will count the number of GPIO descriptors to figure 372 375 * out the number of chip selects available on the platform. 373 376 */ 374 - bbp->master->num_chipselect = 0; 377 + bbp->ctlr->num_chipselect = 0; 375 378 376 379 /* the spi->mode bits understood by this driver: */ 377 - bbp->master->mode_bits = 380 + bbp->ctlr->mode_bits = 378 381 SPI_CPHA | SPI_CPOL | SPI_CS_HIGH | SPI_LSB_FIRST; 379 382 380 383 /* Get the clock for the OPB */