diff mbox

[5/5] spi/dw_spi.c: conditional transfer mode changes

Message ID 1264074052-2214-5-git-send-email-george@georgeshore.com (mailing list archive)
State Accepted
Headers show

Commit Message

George Shore Jan. 21, 2010, 11:40 a.m. UTC
None
diff mbox

Patch

diff --git a/drivers/spi/dw_spi.c b/drivers/spi/dw_spi.c
index 4f91554..a1c195f 100644
--- a/drivers/spi/dw_spi.c
+++ b/drivers/spi/dw_spi.c
@@ -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);