Skip to content

Commit 70d6027

Browse files
David Brownelltorvalds
authored andcommitted
spi: add spi_master flag word
Add a new spi_master.flags word listing constraints relevant to that controller. Define the first constraint bit: a half duplex restriction. Include that constraint in the OMAP1 MicroWire controller driver. Have the mmc_spi host be the first customer of this flag. Its coding relies heavily on full duplex transfers, so it must fail when the underlying controller driver won't perform them. (The spi_write_then_read routine could use it too: use the temporarily-withdrawn full-duplex speedup unless this flag is set, in which case the existing code applies. Similarly, any spi_master implementing only SPI_3WIRE should set the flag.) Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Cc: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent b55f627 commit 70d6027

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎drivers/mmc/host/mmc_spi.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,12 @@ static int mmc_spi_probe(struct spi_device *spi)
13131313
struct mmc_spi_host *host;
13141314
int status;
13151315

1316+
/* We rely on full duplex transfers, mostly to reduce
1317+
* per-transfer overheads (by making fewer transfers).
1318+
*/
1319+
if (spi->master->flags & SPI_MASTER_HALF_DUPLEX)
1320+
return -EINVAL;
1321+
13161322
/* MMC and SD specs only seem to care that sampling is on the
13171323
* rising edge ... meaning SPI modes 0 or 3. So either SPI mode
13181324
* should be legit. We'll use mode 0 since the steady state is 0,

‎drivers/spi/omap_uwire.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,8 @@ static int __init uwire_probe(struct platform_device *pdev)
514514
/* the spi->mode bits understood by this driver: */
515515
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
516516

517+
master->flags = SPI_MASTER_HALF_DUPLEX;
518+
517519
master->bus_num = 2; /* "official" */
518520
master->num_chipselect = 4;
519521
master->setup = uwire_setup;

‎include/linux/spi/spi.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ struct spi_master {
250250
/* spi_device.mode flags understood by this controller driver */
251251
u16 mode_bits;
252252

253+
/* other constraints relevant to this driver */
254+
u16 flags;
255+
#define SPI_MASTER_HALF_DUPLEX BIT(0) /* can't do full duplex */
256+
253257
/* Setup mode and clock, etc (spi driver may call many times).
254258
*
255259
* IMPORTANT: this may be called when transfers to another

0 commit comments

Comments
 (0)