public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jagan Teki <jagan@amarulasolutions.com>
To: u-boot@lists.denx.de
Subject: [PATCH 3/3] spi: sifive: Fix format register proto field
Date: Mon, 20 Apr 2020 17:39:21 +0530	[thread overview]
Message-ID: <20200420120921.12840-4-jagan@amarulasolutions.com> (raw)
In-Reply-To: <20200420120921.12840-1-jagan@amarulasolutions.com>

SiFive SPI controller has a proto bit field in frame format
register which would be used to configure the SPI I/O protocol
lines used on specific transfer.?

Right now the driver is configuring this proto using slave->mode
which is used for data transfer and opcode, address vary depending
on the particular transfer at runtime.

Now the SPI framework supports per transfer I/O protocol lines,
so use spi->proto instead of slave-mode.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/spi/spi-sifive.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-sifive.c b/drivers/spi/spi-sifive.c
index 8f5efb51a3..336b683476 100644
--- a/drivers/spi/spi-sifive.c
+++ b/drivers/spi/spi-sifive.c
@@ -146,12 +146,17 @@ static void sifive_spi_prep_transfer(struct sifive_spi *spi,
 
 	/* Number of wires ? */
 	cr &= ~SIFIVE_SPI_FMT_PROTO_MASK;
-	if ((slave_plat->mode & SPI_TX_QUAD) || (slave_plat->mode & SPI_RX_QUAD))
+	switch (slave_plat->proto) {
+	case SPI_PROTO_QUAD:
 		cr |= SIFIVE_SPI_FMT_PROTO_QUAD;
-	else if ((slave_plat->mode & SPI_TX_DUAL) || (slave_plat->mode & SPI_RX_DUAL))
+		break;
+	case SPI_PROTO_DUAL:
 		cr |= SIFIVE_SPI_FMT_PROTO_DUAL;
-	else
+		break;
+	default:
 		cr |= SIFIVE_SPI_FMT_PROTO_SINGLE;
+		break;
+	}
 
 	/* SPI direction in/out ? */
 	cr &= ~SIFIVE_SPI_FMT_DIR;
-- 
2.17.1

  parent reply	other threads:[~2020-04-20 12:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-20 12:09 [PATCH 0/3] spi: Support SPI I/O protocol lines Jagan Teki
2020-04-20 12:09 ` [PATCH 1/3] spi: spi-mem: Xfer opcode alone for non spi-mem Jagan Teki
2020-04-20 12:09 ` [PATCH 2/3] spi: Support SPI I/O protocol lines Jagan Teki
2020-04-20 12:09 ` Jagan Teki [this message]
2020-04-20 23:14   ` [PATCH 3/3] spi: sifive: Fix format register proto field Bin Meng
2020-04-21 15:47     ` Sagar Kadam
2020-04-23 17:05       ` Jagan Teki
2020-04-21  7:19 ` [PATCH 0/3] spi: Support SPI I/O protocol lines Vignesh Raghavendra
2020-04-21  8:08   ` Jagan Teki

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=20200420120921.12840-4-jagan@amarulasolutions.com \
    --to=jagan@amarulasolutions.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox