devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: Mark Brown <broonie@kernel.org>
Cc: Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	linux-spi@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, Lukasz Majewski <lukma@denx.de>
Subject: [PATCH 2/3] ARM: dspi: Provide per DSPI instance of the MCR register (SLAVE mode)
Date: Tue, 18 Sep 2018 11:34:36 +0200	[thread overview]
Message-ID: <20180918093437.26799-3-lukma@denx.de> (raw)
In-Reply-To: <20180918093437.26799-1-lukma@denx.de>

The vf610 Vybryd can work in two DSPI modes - namely master and slave.
Already we do support master mode.
This commit serves as a prerequisite to add support for slave mode. For
slave mode we do need to preserve the MCR register value to change its
"mode" bit (31) according to the supported state.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
 drivers/spi/spi-fsl-dspi.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index 7cb3ab0a35a0..472385f0a842 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -126,6 +126,7 @@
 #define DMA_COMPLETION_TIMEOUT	msecs_to_jiffies(3000)
 
 struct chip_data {
+	u32 mcr_val;
 	u32 ctar_val;
 	u16 void_write_data;
 };
@@ -696,9 +697,9 @@ static int dspi_transfer_one_message(struct spi_master *master,
 		else
 			dspi->bytes_per_word = 4;
 
-		regmap_update_bits(dspi->regmap, SPI_MCR,
-				   SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF,
-				   SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF);
+		regmap_write(dspi->regmap, SPI_MCR, dspi->cur_chip->mcr_val |
+			     SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF);
+
 		regmap_write(dspi->regmap, SPI_CTAR(0),
 			     dspi->cur_chip->ctar_val |
 			     SPI_FRAME_BITS(transfer->bits_per_word));
@@ -767,6 +768,11 @@ static int dspi_setup(struct spi_device *spi)
 			return -ENOMEM;
 	}
 
+	chip->mcr_val = SPI_MCR_MASTER | SPI_MCR_PCSIS;
+
+	if (dspi->devtype_data->xspi_mode)
+		chip->mcr_val |= SPI_MCR_XSPI;
+
 	pdata = dev_get_platdata(&dspi->pdev->dev);
 
 	if (!pdata) {
@@ -964,8 +970,6 @@ static const struct regmap_config dspi_xspi_regmap_config[] = {
 
 static void dspi_init(struct fsl_dspi *dspi)
 {
-	regmap_write(dspi->regmap, SPI_MCR, SPI_MCR_MASTER | SPI_MCR_PCSIS |
-		     (dspi->devtype_data->xspi_mode ? SPI_MCR_XSPI : 0));
 	regmap_write(dspi->regmap, SPI_SR, SPI_SR_CLEAR);
 	if (dspi->devtype_data->xspi_mode)
 		regmap_write(dspi->regmap, SPI_CTARE(0),
-- 
2.11.0

  parent reply	other threads:[~2018-09-18  9:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-18  9:34 [PATCH 0/3] ARM: dspi: Provide slave mode support for Vybryd vf610 Lukasz Majewski
2018-09-18  9:34 ` [PATCH 1/3] dt-bindings: spi: Provide bindings for fsl dspi working in slave mode Lukasz Majewski
2018-09-24 21:25   ` Rob Herring
2018-09-26 14:32     ` Lukasz Majewski
2018-09-26 15:37       ` Geert Uytterhoeven
2018-09-26 21:33         ` Lukasz Majewski
2018-09-18  9:34 ` Lukasz Majewski [this message]
2018-09-18  9:34 ` [PATCH 3/3] ARM: dspi: Provide support for DSPI slave more operation (Vybryd vf610) Lukasz Majewski
2018-09-18  9:42 ` [PATCH 0/3] ARM: dspi: Provide slave mode support for Vybryd vf610 Lukasz Majewski

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=20180918093437.26799-3-lukma@denx.de \
    --to=lukma@denx.de \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@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).