All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrice Chotard <patrice.chotard@st.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 06/11] spi: stm32_qspi: Update mode management
Date: Thu, 26 Apr 2018 17:05:16 +0200	[thread overview]
Message-ID: <1524755121-2077-7-git-send-email-patrice.chotard@st.com> (raw)
In-Reply-To: <1524755121-2077-1-git-send-email-patrice.chotard@st.com>

From: Christophe Kerello <christophe.kerello@st.com>

We face issue on Macronix/Spansion spi nors due to bad mode management.
We solve these issues using following mode configurations:
 - read_cmd = CMD_READ_QUAD_OUTPUT_FAST => 1-1-4
 - read_cmd = CMD_READ_DUAL_OUTPUT_FAST => 1-1-2
 - write_cmd = CMD_QUAD_PAGE_PROGRAM => 1-1-4
 - others commands => 1-1-1

Signed-off-by: Christophe Kerello <christophe.kerello@st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---

 drivers/spi/stm32_qspi.c | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/spi/stm32_qspi.c b/drivers/spi/stm32_qspi.c
index 6b7232905bc8..46915194f034 100644
--- a/drivers/spi/stm32_qspi.c
+++ b/drivers/spi/stm32_qspi.c
@@ -156,6 +156,10 @@ enum STM32_QSPI_CCR_FMODE {
 /* default SCK frequency, unit: HZ */
 #define STM32_QSPI_DEFAULT_SCK_FREQ 108000000
 
+#define STM32_CMD_READ_DUAL_OUTPUT_FAST	0x3b
+#define STM32_CMD_READ_QUAD_OUTPUT_FAST	0x6b
+#define STM32_CMD_QUAD_PP		0x32
+
 struct stm32_qspi_platdata {
 	u32 base;
 	u32 memory_map;
@@ -217,26 +221,28 @@ static unsigned int _stm32_qspi_gen_ccr(struct stm32_qspi_priv *priv)
 {
 	unsigned int ccr_reg = 0;
 	u8 imode, admode, dmode;
-	u32 mode = priv->mode;
 	u32 cmd = (priv->command & STM32_QSPI_CCR_INSTRUCTION_MASK);
 
 	imode = STM32_QSPI_CCR_IMODE_ONE_LINE;
 	admode = STM32_QSPI_CCR_ADMODE_ONE_LINE;
 
-	if (mode & SPI_RX_QUAD) {
+	/*
+	 * Based on mtd spi framework,
+	 * read_cmd = CMD_READ_QUAD_OUTPUT_FAST if (mode & SPI_RX_QUAD)
+	 * read_cmd = CMD_READ_DUAL_OUTPUT_FAST if (mode & SPI_RX_DUAL)
+	 * write_cmd = CMD_QUAD_PAGE_PROGRAM if (mode & SPI_TX_QUAD)
+	 */
+	switch (cmd) {
+	case STM32_CMD_READ_QUAD_OUTPUT_FAST:
+	case STM32_CMD_QUAD_PP:
 		dmode = STM32_QSPI_CCR_DMODE_FOUR_LINE;
-		if (mode & SPI_TX_QUAD) {
-			imode = STM32_QSPI_CCR_IMODE_FOUR_LINE;
-			admode = STM32_QSPI_CCR_ADMODE_FOUR_LINE;
-		}
-	} else if (mode & SPI_RX_DUAL) {
+		break;
+	case STM32_CMD_READ_DUAL_OUTPUT_FAST:
 		dmode = STM32_QSPI_CCR_DMODE_TWO_LINE;
-		if (mode & SPI_TX_DUAL) {
-			imode = STM32_QSPI_CCR_IMODE_TWO_LINE;
-			admode = STM32_QSPI_CCR_ADMODE_TWO_LINE;
-		}
-	} else {
+		break;
+	default:
 		dmode = STM32_QSPI_CCR_DMODE_ONE_LINE;
+		break;
 	}
 
 	if (priv->command & CMD_HAS_DATA)
-- 
1.9.1

  parent reply	other threads:[~2018-04-26 15:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-26 15:05 [U-Boot] [PATCH v1 00/11] Update STM32 QSPI driver Patrice Chotard
2018-04-26 15:05 ` [U-Boot] [PATCH v1 01/11] spi: stm32_qspi: Remove CONFIG_CLK flag Patrice Chotard
2018-04-26 15:05 ` [U-Boot] [PATCH v1 02/11] spi: stm32_qspi: Solve issue detected by checkpatch Patrice Chotard
2018-04-26 15:05 ` [U-Boot] [PATCH v1 03/11] spi: stm32_qspi: Sort include files alphabetically Patrice Chotard
2018-04-26 15:05 ` [U-Boot] [PATCH v1 04/11] spi: stm32_qspi: Align reg-names with kernel 4.12 RC1 Patrice Chotard
2018-04-26 15:05 ` [U-Boot] [PATCH v1 05/11] spi: stm32_qspi: Add st, stm32f469-qspi compatible string Patrice Chotard
2018-04-26 15:05 ` Patrice Chotard [this message]
2018-05-01  5:31   ` [U-Boot] [PATCH v1 06/11] spi: stm32_qspi: Update mode management Jagan Teki
2018-05-14 13:24     ` Patrice CHOTARD
2018-04-26 15:05 ` [U-Boot] [PATCH v1 07/11] spi: stm32_qspi: Add chip select management Patrice Chotard
2018-04-26 15:05 ` [U-Boot] [PATCH v1 08/11] spi: stm32_qspi: Use dev_read_xxx API Patrice Chotard
2018-04-26 15:05 ` [U-Boot] [PATCH v1 09/11] spi: stm32_qspi: Add reset support Patrice Chotard
2018-04-26 15:05 ` [U-Boot] [PATCH v1 10/11] ARM: dts: stm32: Add quadspi reset for stm32f746 Patrice Chotard
2018-04-26 15:05 ` [U-Boot] [PATCH v1 11/11] ARM: dts: stm32: Update qspi bindings " Patrice Chotard

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=1524755121-2077-7-git-send-email-patrice.chotard@st.com \
    --to=patrice.chotard@st.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.