diff mbox

[RFC/PATCH,3/3] driver: spi: Add quad spi read support

Message ID 1373290980-17883-4-git-send-email-sourav.poddar@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Poddar, Sourav July 8, 2013, 1:43 p.m. UTC
Since, qspi controller uses quad read.

Configuring the command register, if the transfer of data needs
quad lines.

This patch has been done on top of the following patch[1], which is still
under review/comments.
This patch will also go changes, as the parent patch[1] does.

[1]: http://comments.gmane.org/gmane.linux.kernel.spi.devel/14047

Signed-off-by: Sourav Poddar <sourav.poddar@ti.com>
---
 drivers/spi/spi-ti-qspi.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

Comments

Felipe Balbi July 8, 2013, 2:36 p.m. UTC | #1
On Mon, Jul 08, 2013 at 07:13:00PM +0530, Sourav Poddar wrote:
> Since, qspi controller uses quad read.
> 
> Configuring the command register, if the transfer of data needs
> quad lines.
> 
> This patch has been done on top of the following patch[1], which is still
> under review/comments.
> This patch will also go changes, as the parent patch[1] does.
> 
> [1]: http://comments.gmane.org/gmane.linux.kernel.spi.devel/14047
> 
> Signed-off-by: Sourav Poddar <sourav.poddar@ti.com>
> ---
>  drivers/spi/spi-ti-qspi.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/spi/spi-ti-qspi.c b/drivers/spi/spi-ti-qspi.c
> index 430de9c..307cbed 100644
> --- a/drivers/spi/spi-ti-qspi.c
> +++ b/drivers/spi/spi-ti-qspi.c
> @@ -258,8 +258,12 @@ static int qspi_read_msg(struct dra7xxx_qspi *qspi, struct spi_transfer *t)
>  			qspi->cmd | QSPI_RD_SNGL, qspi->dc);
>  		dra7xxx_writel(qspi, QSPI_WC_INT_EN, QSPI_INTR_ENABLE_SET_REG);
>  		dra7xxx_writel(qspi, qspi->dc, QSPI_SPI_DC_REG);
> -		dra7xxx_writel(qspi, qspi->cmd | QSPI_RD_SNGL,
> -			QSPI_SPI_CMD_REG);
> +		if (t->bitwidth == SPI_BITWIDTH_QUAD)
> +			dra7xxx_writel(qspi, qspi->cmd | QSPI_RD_QUAD,
> +				QSPI_SPI_CMD_REG);
> +		else
> +			dra7xxx_writel(qspi, qspi->cmd | QSPI_RD_SNGL,
> +				QSPI_SPI_CMD_REG);

we also have read dual, in order to make this code a little better you
could:

	unsigned cmd = qspi->cmd;

	switch (t->bitwidth)
	case SPI_BITWIDTH_QUAD:
		cmd |= QSPI_RD_QUAD;
		break;
	case SPI_BITWIDTH_DUAL:
		cmd |= QSPI_RD_DUAL;
		break;
	case SPI_BITWIDTH_SINGLE:
	default:
		cmd |= QSPI_RD_SNGL;
	}

	dra7xx_writel(qspi, cmd, QSPI_SPI_CMD_REG);
diff mbox

Patch

diff --git a/drivers/spi/spi-ti-qspi.c b/drivers/spi/spi-ti-qspi.c
index 430de9c..307cbed 100644
--- a/drivers/spi/spi-ti-qspi.c
+++ b/drivers/spi/spi-ti-qspi.c
@@ -258,8 +258,12 @@  static int qspi_read_msg(struct dra7xxx_qspi *qspi, struct spi_transfer *t)
 			qspi->cmd | QSPI_RD_SNGL, qspi->dc);
 		dra7xxx_writel(qspi, QSPI_WC_INT_EN, QSPI_INTR_ENABLE_SET_REG);
 		dra7xxx_writel(qspi, qspi->dc, QSPI_SPI_DC_REG);
-		dra7xxx_writel(qspi, qspi->cmd | QSPI_RD_SNGL,
-			QSPI_SPI_CMD_REG);
+		if (t->bitwidth == SPI_BITWIDTH_QUAD)
+			dra7xxx_writel(qspi, qspi->cmd | QSPI_RD_QUAD,
+				QSPI_SPI_CMD_REG);
+		else
+			dra7xxx_writel(qspi, qspi->cmd | QSPI_RD_SNGL,
+				QSPI_SPI_CMD_REG);
 		wait_for_completion(&qspi->word_complete);
 		*rxbuf++ = dra7xxx_readl_data(qspi, QSPI_SPI_DATA_REG, wlen);
 		dev_dbg(qspi->dev, "rx done, read %02x\n", *(rxbuf-1));