Skip to contentSkip to conversation

spi: s3c64xx: Enable Word transfer

PATCH Superseded Rajeshwari S Shinde 2 participants 2 messages Oct 11, 2013

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 spi: s3c64xx: Enable Word transfer

This patch enables word transfer for s3c64xx spi driver. User can set bits_per_word to 32 before calling spi_setup, which would enable the word transfer mode.

---
Changes in V2
- Reduced the call for s3c64xx_spi_config.
Changes in V3:
- Corrected the coding style nits.

 drivers/spi/spi-s3c64xx.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)
drivers/spi/spi-s3c64xx.c +18 -7
index 512b889..cbbeff3 100644
@@ -498,6 +498,18 @@ static void enable_datapath(struct s3c64xx_spi_driver_data *sdd,
 	chcfg = readl(regs + S3C64XX_SPI_CH_CFG);
 	chcfg &= ~S3C64XX_SPI_CH_TXCH_ON;
 
+	if(sdd->cur_bpw == 32) {
+		/* For word transfer we need to swap bytes */
+		u32 swapcfg = (S3C64XX_SPI_SWAP_TX_EN | S3C64XX_SPI_SWAP_TX_BYTE |
+				S3C64XX_SPI_SWAP_TX_HALF_WORD |
+				S3C64XX_SPI_SWAP_RX_EN |
+				S3C64XX_SPI_SWAP_RX_BYTE |
+				S3C64XX_SPI_SWAP_RX_HALF_WORD);
+		writel(swapcfg, regs + S3C64XX_SPI_SWAP_CFG);
+	} else {
+		writel(0, regs + S3C64XX_SPI_SWAP_CFG);
+	}
+
 	if (dma_mode) {
 		chcfg &= ~S3C64XX_SPI_CH_RXCH_ON;
 	} else {
@@ -905,13 +917,12 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master,
 		bpw = xfer->bits_per_word;
 		speed = xfer->speed_hz ? : spi->max_speed_hz;
 
-		if (xfer->len % (bpw / 8)) {
-			dev_err(&spi->dev,
-				"Xfer length(%u) not a multiple of word size(%u)\n",
-				xfer->len, bpw / 8);
-			status = -EIO;
-			goto out;
-		}
+		/*
+		 * Enable byte transfer if transfer length not a multiple of
+		 * word size
+		 */
+		if (xfer->len % (bpw / 8))
+			bpw = 8;
 
 		if (bpw != sdd->cur_bpw || speed != sdd->cur_speed) {
 			sdd->cur_bpw = bpw;
Signature · 1 line
1.7.12.4
maintainer
#1 lore raw
Quoted 3 lines · Rajeshwari S Shinde

This patch enables word transfer for s3c64xx spi driver. User can set bits_per_word to 32 before calling spi_setup, which would enable the word transfer mode.

As someone mentioned on previous reviews there's nothing in this patch which sets bits_per_word_mask, you should be doing that.

Quoted 2 lines

Changes in V3:
- Corrected the coding style nits.

Not all of them:

drivers/spi/spi-s3c64xx.c static void enable_datapath(struct s3c64xx_spi_driver_data *sdd, · line 501

Quoted 1 line
drivers/spi/spi-s3c64xx.c +1 -0
+	if(sdd->cur_bpw == 32) {

checkpatch should've told you about this... I'd also expect this to be a switch statement with a case for 16 bit words too?

drivers/spi/spi-s3c64xx.c static int s3c64xx_spi_transfer_one_message(struct spi_master *master, · line 925

Quoted 6 lines
drivers/spi/spi-s3c64xx.c +6 -0
+		/*
+		 * Enable byte transfer if transfer length not a multiple of
+		 * word size
+		 */
+		if (xfer->len % (bpw / 8))
+			bpw = 8;

This check is redundant, the core will validate bits per word.