Skip to content

Commit

Permalink
spi/dw_spi: conditional transfer mode changes
Browse files Browse the repository at this point in the history
This allows the switching between transfer modes between 'transmit only',
'receive only' and 'transmit and receive' modes. Due to the design of the SPI
block, changing transfer modes requires that the block be disabled; in doing
so the chipselect line is inherently deasserted and (usually) the attached
device discards its state. Consequentially, switching modes requires that a
platform-specific chipselect function has been defined so that the chipselect
is not dropped during the change.

Signed-off-by: George Shore <george@georgeshore.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
  • Loading branch information
George Shore authored and Grant Likely committed Jan 21, 2010
1 parent f4aec79 commit 052dc7c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions drivers/spi/dw_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,22 @@ static void pump_transfers(unsigned long data)
}
message->state = RUNNING_STATE;

/*
* Adjust transfer mode if necessary. Requires platform dependent
* chipselect mechanism.
*/
if (dws->cs_control) {
if (dws->rx && dws->tx)
chip->tmode = 0x00;
else if (dws->rx)
chip->tmode = 0x02;
else
chip->tmode = 0x01;

cr0 &= ~(0x3 << SPI_MODE_OFFSET);
cr0 |= (chip->tmode << SPI_TMOD_OFFSET);
}

/* Check if current transfer is a DMA transaction */
dws->dma_mapped = map_dma_buffers(dws);

Expand Down

0 comments on commit 052dc7c

Please sign in to comment.