Skip to content

Commit c36581c

Browse files
committed
Merge remote-tracking branches 'spi/topic/dw', 'spi/topic/flash-read', 'spi/topic/fsl-dspi', 'spi/topic/fsl-espi' and 'spi/topic/kconfig' into spi-next
6 parents 4b744af + 3208a1c + 7ba2f27 + c145344 + 6319a68 + 46cb415 commit c36581c

File tree

6 files changed

+39
-11
lines changed

6 files changed

+39
-11
lines changed

Documentation/devicetree/bindings/spi/spi-fsl-dspi.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ Required properties:
1313

1414
Optional property:
1515
- big-endian: If present the dspi device's registers are implemented
16-
in big endian mode, otherwise in native mode(same with CPU), for more
17-
detail please see: Documentation/devicetree/bindings/regmap/regmap.txt.
16+
in big endian mode.
1817

1918
Optional SPI slave node properties:
2019
- fsl,spi-cs-sck-delay: a delay in nanoseconds between activating chip

drivers/spi/Kconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ config SPI_OMAP_UWIRE
410410
config SPI_OMAP24XX
411411
tristate "McSPI driver for OMAP"
412412
depends on HAS_DMA
413-
depends on ARM || ARM64 || AVR32 || HEXAGON || MIPS || SUPERH
414413
depends on ARCH_OMAP2PLUS || COMPILE_TEST
415414
help
416415
SPI master controller for OMAP24XX and later Multichannel SPI
@@ -469,7 +468,6 @@ config SPI_PXA2XX_PCI
469468

470469
config SPI_ROCKCHIP
471470
tristate "Rockchip SPI controller driver"
472-
depends on ARM || ARM64 || AVR32 || HEXAGON || MIPS || SUPERH
473471
help
474472
This selects a driver for Rockchip SPI controller.
475473

drivers/spi/spi-dw-pci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static int spi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
6767
dws->irq = pdev->irq;
6868

6969
/*
70-
* Specific handling for paltforms, like dma setup,
70+
* Specific handling for platforms, like dma setup,
7171
* clock rate, FIFO depth.
7272
*/
7373
if (desc) {

drivers/spi/spi-fsl-dspi.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,22 @@ enum dspi_trans_mode {
121121

122122
struct fsl_dspi_devtype_data {
123123
enum dspi_trans_mode trans_mode;
124+
u8 max_clock_factor;
124125
};
125126

126127
static const struct fsl_dspi_devtype_data vf610_data = {
127128
.trans_mode = DSPI_EOQ_MODE,
129+
.max_clock_factor = 2,
128130
};
129131

130132
static const struct fsl_dspi_devtype_data ls1021a_v1_data = {
131133
.trans_mode = DSPI_TCFQ_MODE,
134+
.max_clock_factor = 8,
132135
};
133136

134137
static const struct fsl_dspi_devtype_data ls2085a_data = {
135138
.trans_mode = DSPI_TCFQ_MODE,
139+
.max_clock_factor = 8,
136140
};
137141

138142
struct fsl_dspi {
@@ -726,6 +730,9 @@ static int dspi_probe(struct platform_device *pdev)
726730
}
727731
clk_prepare_enable(dspi->clk);
728732

733+
master->max_speed_hz =
734+
clk_get_rate(dspi->clk) / dspi->devtype_data->max_clock_factor;
735+
729736
init_waitqueue_head(&dspi->waitq);
730737
platform_set_drvdata(pdev, master);
731738

drivers/spi/spi-fsl-espi.c

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,12 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)
245245
if (ret)
246246
return ret;
247247

248-
wait_for_completion(&mpc8xxx_spi->done);
248+
/* Won't hang up forever, SPI bus sometimes got lost interrupts... */
249+
ret = wait_for_completion_timeout(&mpc8xxx_spi->done, 2 * HZ);
250+
if (ret == 0)
251+
dev_err(mpc8xxx_spi->dev,
252+
"Transaction hanging up (left %d bytes)\n",
253+
mpc8xxx_spi->count);
249254

250255
/* disable rx ints */
251256
mpc8xxx_spi_write_reg(&reg_base->mask, 0);
@@ -539,16 +544,31 @@ void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events)
539544
if (events & SPIE_NE) {
540545
u32 rx_data, tmp;
541546
u8 rx_data_8;
547+
int rx_nr_bytes = 4;
548+
int ret;
542549

543550
/* Spin until RX is done */
544-
while (SPIE_RXCNT(events) < min(4, mspi->len)) {
545-
cpu_relax();
546-
events = mpc8xxx_spi_read_reg(&reg_base->event);
551+
if (SPIE_RXCNT(events) < min(4, mspi->len)) {
552+
ret = spin_event_timeout(
553+
!(SPIE_RXCNT(events =
554+
mpc8xxx_spi_read_reg(&reg_base->event)) <
555+
min(4, mspi->len)),
556+
10000, 0); /* 10 msec */
557+
if (!ret)
558+
dev_err(mspi->dev,
559+
"tired waiting for SPIE_RXCNT\n");
547560
}
548561

549562
if (mspi->len >= 4) {
550563
rx_data = mpc8xxx_spi_read_reg(&reg_base->receive);
564+
} else if (mspi->len <= 0) {
565+
dev_err(mspi->dev,
566+
"unexpected RX(SPIE_NE) interrupt occurred,\n"
567+
"(local rxlen %d bytes, reg rxlen %d bytes)\n",
568+
min(4, mspi->len), SPIE_RXCNT(events));
569+
rx_nr_bytes = 0;
551570
} else {
571+
rx_nr_bytes = mspi->len;
552572
tmp = mspi->len;
553573
rx_data = 0;
554574
while (tmp--) {
@@ -559,7 +579,7 @@ void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events)
559579
rx_data <<= (4 - mspi->len) * 8;
560580
}
561581

562-
mspi->len -= 4;
582+
mspi->len -= rx_nr_bytes;
563583

564584
if (mspi->rx)
565585
mspi->get_rx(rx_data, mspi);

include/linux/spi/spi.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
372372
* @unprepare_message: undo any work done by prepare_message().
373373
* @spi_flash_read: to support spi-controller hardwares that provide
374374
* accelerated interface to read from flash devices.
375+
* @flash_read_supported: spi device supports flash read
375376
* @cs_gpios: Array of GPIOs to use as chip select lines; one per CS
376377
* number. Any individual value may be -ENOENT for CS lines that
377378
* are not GPIOs (driven by the SPI controller itself).
@@ -529,6 +530,7 @@ struct spi_master {
529530
struct spi_message *message);
530531
int (*spi_flash_read)(struct spi_device *spi,
531532
struct spi_flash_read_message *msg);
533+
bool (*flash_read_supported)(struct spi_device *spi);
532534

533535
/*
534536
* These hooks are for drivers that use a generic implementation
@@ -1158,7 +1160,9 @@ struct spi_flash_read_message {
11581160
/* SPI core interface for flash read support */
11591161
static inline bool spi_flash_read_supported(struct spi_device *spi)
11601162
{
1161-
return spi->master->spi_flash_read ? true : false;
1163+
return spi->master->spi_flash_read &&
1164+
(!spi->master->flash_read_supported ||
1165+
spi->master->flash_read_supported(spi));
11621166
}
11631167

11641168
int spi_flash_read(struct spi_device *spi,

0 commit comments

Comments
 (0)