All of lore.kernel.org
 help / color / mirror / Atom feed
From: Akash Gajjar <gajjar04akash@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/3] spi: sh_qspi: full DM conversion
Date: Wed,  9 May 2018 12:06:37 +0530	[thread overview]
Message-ID: <1525847797-29055-1-git-send-email-akash@openedev.com> (raw)
In-Reply-To: <akash@openedev.com>

v1->v2
New in v2
update Kconfig
replace __sh_qspi_setup to sh_qspi_setup
add missing memeber of platform data

Signed-off-by: Akash Gajjar <akash@openedev.com>
---
 drivers/spi/Kconfig                | 12 +++++-----
 drivers/spi/sh_qspi.c              | 49 +++++++++++++++++++-------------------
 include/dm/platform_data/qspi_sh.h |  4 ----
 3 files changed, 31 insertions(+), 34 deletions(-)

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index ec92b84..81079c5 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -155,6 +155,12 @@ config SANDBOX_SPI
 		};
 	  };
 
+config SH_QSPI
+	bool "Renesas Quad SPI driver"
+	help
+	  Enable the Renesas Quad SPI controller driver. This driver can be
+	  used on Renesas SoCs.
+
 config STM32_QSPI
 	bool "STM32F7 QSPI driver"
 	depends on STM32F7
@@ -259,12 +265,6 @@ config SH_SPI
 	  Enable the SuperH SPI controller driver. This driver can be used
 	  on various SuperH SoCs, such as SH7757.
 
-config SH_QSPI
-	bool "Renesas Quad SPI driver"
-	help
-	  Enable the Renesas Quad SPI controller driver. This driver can be
-	  used on Renesas SoCs.
-
 config TI_QSPI
 	bool "TI QSPI driver"
 	help
diff --git a/drivers/spi/sh_qspi.c b/drivers/spi/sh_qspi.c
index 5fdd52e..b81cee5 100644
--- a/drivers/spi/sh_qspi.c
+++ b/drivers/spi/sh_qspi.c
@@ -77,49 +77,48 @@ struct sh_qspi_priv {
 	struct sh_qspi_regs *regs;
 };
 
-static int __sh_qspi_setup(struct sh_qspi_priv *priv)
+static void sh_qspi_setup(struct sh_qspi_priv *priv)
 {
-	/* QSPI initialize */
-	priv->regs = (struct sh_qspi_regs *)SH_QSPI_BASE;
+	struct sh_qspi_regs *regs = priv->regs;
 
 	/* Set master mode only */
-	writeb(SPCR_MSTR, &priv->regs->spcr);
+	writeb(SPCR_MSTR, &regs->spcr);
 
 	/* Set SSL signal level */
-	writeb(0x00, &priv->regs->sslp);
+	writeb(0x00, &regs->sslp);
 
 	/* Set MOSI signal value when transfer is in idle state */
-	writeb(SPPCR_IO3FV | SPPCR_IO2FV, &priv->regs->sppcr);
+	writeb(SPPCR_IO3FV | SPPCR_IO2FV, &regs->sppcr);
 
 	/* Set bit rate. See 58.3.8 Quad Serial Peripheral Interface */
-	writeb(0x01, &priv->regs->spbr);
+	writeb(0x01, &regs->spbr);
 
 	/* Disable Dummy Data Transmission */
-	writeb(0x00, &priv->regs->spdcr);
+	writeb(0x00, &regs->spdcr);
 
 	/* Set clock delay value */
-	writeb(0x00, &priv->regs->spckd);
+	writeb(0x00, &regs->spckd);
 
 	/* Set SSL negation delay value */
-	writeb(0x00, &priv->regs->sslnd);
+	writeb(0x00, &regs->sslnd);
 
 	/* Set next-access delay value */
-	writeb(0x00, &priv->regs->spnd);
+	writeb(0x00, &regs->spnd);
 
 	/* Set equence command */
-	writew(SPCMD_INIT2, &priv->regs->spcmd0);
+	writew(SPCMD_INIT2, &regs->spcmd0);
 
 	/* Reset transfer and receive Buffer */
-	setbits_8(&priv->regs->spbfcr, SPBFCR_TXRST | SPBFCR_RXRST);
+	setbits_8(&regs->spbfcr, SPBFCR_TXRST | SPBFCR_RXRST);
 
 	/* Clear transfer and receive Buffer control bit */
-	clrbits_8(&priv->regs->spbfcr, SPBFCR_TXRST | SPBFCR_RXRST);
+	clrbits_8(&regs->spbfcr, SPBFCR_TXRST | SPBFCR_RXRST);
 
 	/* Set equence control method. Use equence0 only */
-	writeb(0x00, &priv->regs->spscr);
+	writeb(0x00, &regs->spscr);
 
 	/* Enable SPI function */
-	setbits_8(&priv->regs->spcr, SPCR_SPE);
+	setbits_8(&regs->spcr, SPCR_SPE);
 }
 
 static int sh_qspi_set_speed(struct udevice *bus, uint hz)
@@ -156,7 +155,7 @@ static int sh_qspi_xfer(struct udevice *dev, unsigned int bitlen,
 
 	if (dout == NULL && din == NULL) {
 		if (flags & SPI_XFER_END)
-			spi_cs_deactivate(regs);
+			spi_cs_deactivate(regs);	/* TODO */
 		return 0;
 	}
 
@@ -168,7 +167,7 @@ static int sh_qspi_xfer(struct udevice *dev, unsigned int bitlen,
 	nbyte = bitlen / 8;
 
 	if (flags & SPI_XFER_BEGIN) {
-		spi_cs_activate(regs);
+		spi_cs_activate(regs);			/* TODO */
 
 		/* Set 1048576 byte */
 		writel(0x100000, spbmul0);
@@ -219,7 +218,7 @@ static int sh_qspi_xfer(struct udevice *dev, unsigned int bitlen,
 	}
 
 	if (flags & SPI_XFER_END)
-		spi_cs_deactivate(regs);
+		spi_cs_deactivate(regs);		/* TODO */
 
 	return ret;
 }
@@ -229,7 +228,9 @@ static int sh_qspi_probe(struct udevice *bus)
 	struct sh_qspi_platdata *plat = bus->platdata;
 	struct sh_qspi_priv *priv = dev_get_priv(bus);
 
-	__sh_qspi_setup(priv);
+	priv->regs = plat->regs;
+
+	sh_qspi_setup(priv);
 
 	return 0;
 }
@@ -252,14 +253,14 @@ static int sh_qspi_ofdata_to_platadata(struct udevice *bus)
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
-	plat->cs = fdtdec_get_int(gd->fdt_blob, dev_of_offset(bus),
-			"num-cs", 4);
+	plat->regs = (struct sh_qspi_regs *regs)addr;
 
 	return 0;
 }
 
-static const struct udevice_id davinci_spi_ids[] = {
-	{ .compatible = "sh,sh-qspi" },
+/* TODO: update comptaible device tree binding */
+static const struct udevice_id sh_qspi_ids[] = {
+	{ .compatible = " " },
 	{ }
 };
 #endif
diff --git a/include/dm/platform_data/qspi_sh.h b/include/dm/platform_data/qspi_sh.h
index 1a8529c..14479ad 100644
--- a/include/dm/platform_data/qspi_sh.h
+++ b/include/dm/platform_data/qspi_sh.h
@@ -7,10 +7,6 @@
 #ifndef __qspi_sh_h
 #define __qspi_sh_h
 
-/*
- * struct sh_qspi_platdata - information about a sh qspi module
- *
- */
 struct sh_qspi_platdata {
 	struct sh_qspi_regs *regs;
 	uint cs;
-- 
2.7.4

  parent reply	other threads:[~2018-05-09  6:36 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <akash@openedev.com>
2018-04-26 16:46 ` [U-Boot] [PATCH v1 1/3] spi: sh_qspi: DM conversion Akash Gajjar
2018-04-27  6:06   ` Jagan Teki
2018-04-26 16:48 ` [U-Boot] [PATCH v1 2/3] spi: sh_spi: " Akash Gajjar
2018-04-27  6:22   ` Jagan Teki
2018-04-26 16:50 ` [U-Boot] [PATCH v1 3/3] spi: mxs_spi: " Akash Gajjar
2018-04-27  6:40   ` Jagan Teki
2018-05-09  6:36 ` Akash Gajjar [this message]
2018-05-09 11:21   ` [U-Boot] [PATCH v2 1/3] spi: sh_qspi: full " Jagan Teki
2018-05-09  6:57 ` [U-Boot] [PATCH v2 2/3] spi: sh_spi: " Akash Gajjar
2018-05-09  7:04 ` [U-Boot] [PATCH v2 3/3] spi: mxs_spi: full dm conversion Akash Gajjar
2018-05-09  7:07 ` [U-Boot] [PATCH v1 1/1] spi: lpc32xx_ssp: DM conversion Akash Gajjar
2018-09-04  6:33   ` Jagan Teki
2018-09-19 11:32     ` Vladimir Zapolskiy
2018-11-05 10:09       ` Jagan Teki
2018-05-10 14:13 ` [U-Boot] [PATCH v3 1/3] spi: sh_qspi: " Akash Gajjar
2018-05-10 14:15 ` [U-Boot] [PATCH v3 2/3] spi: sh_spi: " Akash Gajjar
2018-05-10 14:17 ` [U-Boot] [PATCH v3 3/3] spi: mxs_spi: " Akash Gajjar
2018-05-10 14:30   ` Marek Vasut
2018-05-11 10:08     ` Gajjar Akash
2018-05-11 10:39       ` Marek Vasut
2018-05-11 11:09         ` Akash Gajjar
2018-05-11 11:31           ` Marek Vasut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1525847797-29055-1-git-send-email-akash@openedev.com \
    --to=gajjar04akash@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.