linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Mark Brown <broonie@kernel.org>
Cc: linux-spi@vger.kernel.org, linux-sh@vger.kernel.org,
	Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Subject: [PATCH V2 6/8] spi: rspi: Add support for missing SPCR2 register
Date: Sun, 12 Jan 2014 11:27:42 +0100	[thread overview]
Message-ID: <1389522464-1569-7-git-send-email-geert@linux-m68k.org> (raw)
In-Reply-To: <1389522464-1569-1-git-send-email-geert@linux-m68k.org>

From: Geert Uytterhoeven <geert+renesas@linux-m68k.org>

Add support for RSPI variants lacking the RSPI Control Register 2, based on
the SDK reference code. This is needed for RZ/A1H.

The availability of this register is passed using platform data, defaulting
to true for legacy RSPI. QSPI never has this register.

If the register is not available, it should not be touched.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
V2:
  - Add Acked-by

 drivers/spi/spi-rspi.c   |   17 ++++++++++++-----
 include/linux/spi/rspi.h |    1 +
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index e507c2d6c710..18c56d1feb8e 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -201,6 +201,7 @@ struct rspi_data {
 	unsigned dma_width_16bit:1;
 	unsigned dma_callbacked:1;
 	unsigned txmode:1;
+	unsigned spcr2:1;
 };
 
 static void rspi_write8(const struct rspi_data *rspi, u8 data, u16 offset)
@@ -298,10 +299,14 @@ static int rspi_parse_platform_data(struct rspi_data *rspi,
 		rspi->spdcr = 0;
 	}
 
-	if (rspi_pd)
+	if (rspi_pd) {
 		rspi->txmode = rspi_pd->txmode;
-	else
-		rspi->txmode = 1;	/* legacy RSPI defaults to true */
+		rspi->spcr2 = rspi_pd->spcr2;
+	} else {
+		/* legacy RSPI defaults to true */
+		rspi->txmode = 1;
+		rspi->spcr2 = 1;
+	}
 
 	return 0;
 }
@@ -327,7 +332,8 @@ static int rspi_set_config_register(const struct rspi_data *rspi,
 	rspi_write8(rspi, 0x00, RSPI_SPND);
 
 	/* Sets parity, interrupt mask */
-	rspi_write8(rspi, 0x00, RSPI_SPCR2);
+	if (rspi->spcr2)
+		rspi_write8(rspi, 0x00, RSPI_SPCR2);
 
 	/* Sets SPCMD */
 	rspi_write16(rspi, SPCMD_SPB_8_TO_16(access_size) | SPCMD_SSLKP,
@@ -349,8 +355,9 @@ static int qspi_parse_platform_data(struct rspi_data *rspi,
 	rspi->data_width = 8;
 	rspi->spdcr = 0;
 
-	/* No TX only mode */
+	/* No TX only mode, no parity register */
 	rspi->txmode = 0;
+	rspi->spcr2 = 0;
 
 	return 0;
 }
diff --git a/include/linux/spi/rspi.h b/include/linux/spi/rspi.h
index 0f5f612f0092..08d217f25413 100644
--- a/include/linux/spi/rspi.h
+++ b/include/linux/spi/rspi.h
@@ -29,6 +29,7 @@ struct rspi_plat_data {
 
 	unsigned dma_width_16bit:1;	/* DMAC read/write width = 16-bit */
 	unsigned txmode:1;		/* TX only mode */
+	unsigned spcr2:1;		/* Set parity register */
 
 	u16 num_chipselect;
 };
-- 
1.7.9.5


  parent reply	other threads:[~2014-01-12 10:27 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-12 10:27 [PATCH V2 0/8] spi: rspi: Add support for RZ/A1H Geert Uytterhoeven
     [not found] ` <1389522464-1569-1-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2014-01-12 10:27   ` [PATCH V2 1/8] spi: rspi: Add more RSPI register documentation Geert Uytterhoeven
2014-01-13 12:10     ` Mark Brown
2014-01-12 10:27   ` [PATCH V2 2/8] spi: rspi: Add more QSPI " Geert Uytterhoeven
     [not found]     ` <1389522464-1569-3-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2014-01-13 12:10       ` Mark Brown
2014-01-12 10:27   ` [PATCH V2 3/8] spi: rspi: Add support for more than one interrupt Geert Uytterhoeven
     [not found]     ` <1389522464-1569-4-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2014-01-13 12:16       ` Mark Brown
2014-01-12 10:27   ` [PATCH V2 4/8] spi: rspi: Add support for 8-bit Data Register access Geert Uytterhoeven
     [not found]     ` <1389522464-1569-5-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2014-01-13 12:29       ` Mark Brown
     [not found]         ` <20140113122912.GT29039-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-01-13 13:29           ` Geert Uytterhoeven
     [not found]             ` <CAMuHMdViLJD9O4gnovR6x7RTWor9GYPBZuzP5X7JmVw5g=o4kw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-01-13 15:55               ` Mark Brown
2014-01-13 19:05                 ` Geert Uytterhoeven
2014-01-12 10:27   ` [PATCH V2 7/8] spi: rspi: Add support for specifying CPHA/CPOL Geert Uytterhoeven
2014-01-13 17:23     ` Mark Brown
2014-01-12 10:27   ` [PATCH V2 8/8] spi: rspi: Add support for loopback mode Geert Uytterhoeven
2014-01-12 10:27 ` [PATCH V2 5/8] spi: rspi: Add support for no TX only mode Geert Uytterhoeven
2014-01-12 10:27 ` Geert Uytterhoeven [this message]
     [not found]   ` <1389522464-1569-7-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2014-01-13 12:36     ` [PATCH V2 6/8] spi: rspi: Add support for missing SPCR2 register Sergei Shtylyov
     [not found]       ` <52D3DDDB.309-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2014-01-19 11:39         ` Geert Uytterhoeven

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=1389522464-1569-7-git-send-email-geert@linux-m68k.org \
    --to=geert@linux-m68k.org \
    --cc=broonie@kernel.org \
    --cc=geert+renesas@linux-m68k.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).