From: Chris Packham <judge.packham@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC PATCH 1/1] sf: support chips using 4-byte addressing
Date: Mon, 17 Oct 2016 13:51:45 +1300 [thread overview]
Message-ID: <20161017005145.21956-2-judge.packham@gmail.com> (raw)
In-Reply-To: <20161017005145.21956-1-judge.packham@gmail.com>
Signed-off-by: Chris Packham <judge.packham@gmail.com>
---
drivers/mtd/spi/Kconfig | 7 +++++++
drivers/mtd/spi/sf_internal.h | 5 +++++
drivers/mtd/spi/spi_flash.c | 7 +++++++
3 files changed, 19 insertions(+)
diff --git a/drivers/mtd/spi/Kconfig b/drivers/mtd/spi/Kconfig
index 1f23c8e34e6f..f5020f799d78 100644
--- a/drivers/mtd/spi/Kconfig
+++ b/drivers/mtd/spi/Kconfig
@@ -42,6 +42,13 @@ config SPI_FLASH_BAR
Bank/Extended address registers are used to access the flash
which has size > 16MiB in 3-byte addressing.
+config SPI_FLASH_4B_ADDR
+ bool "SPI flash use 4-byte addressing"
+ depends on SPI_FLASH
+ help
+ Enable 4-byte addressing for SPI flash. This allows use of SPI flash
+ chips which use 4-byte addressing.
+
if SPI_FLASH
config SPI_FLASH_ATMEL
diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h
index cde4cfbf2e32..fef8d1ecc89e 100644
--- a/drivers/mtd/spi/sf_internal.h
+++ b/drivers/mtd/spi/sf_internal.h
@@ -26,7 +26,12 @@ enum spi_nor_option_flags {
};
#define SPI_FLASH_3B_ADDR_LEN 3
+#define SPI_FLASH_4B_ADDR_LEN 4
+#ifdef CONFIG_SPI_FLASH_4B_ADDR
+#define SPI_FLASH_CMD_LEN (1 + SPI_FLASH_4B_ADDR_LEN)
+#else
#define SPI_FLASH_CMD_LEN (1 + SPI_FLASH_3B_ADDR_LEN)
+#endif
#define SPI_FLASH_16MB_BOUN 0x1000000
/* CFI Manufacture ID's */
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 7f6e9ae23ea8..bed3ab4762cf 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -25,9 +25,16 @@ DECLARE_GLOBAL_DATA_PTR;
static void spi_flash_addr(u32 addr, u8 *cmd)
{
/* cmd[0] is actual command */
+#ifdef CONFIG_SPI_FLASH_4B_ADDR
+ cmd[1] = addr >> 24;
+ cmd[2] = addr >> 16;
+ cmd[3] = addr >> 8;
+ cmd[4] = addr;
+#else
cmd[1] = addr >> 16;
cmd[2] = addr >> 8;
cmd[3] = addr >> 0;
+#endif
}
static int read_sr(struct spi_flash *flash, u8 *rs)
--
2.10.0.479.g7c56b16
next prev parent reply other threads:[~2016-10-17 0:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-17 0:51 [U-Boot] [RFC PATCH 0/1] 4-byte SPI flash addressing Chris Packham
2016-10-17 0:51 ` Chris Packham [this message]
2016-10-19 8:36 ` [U-Boot] [RFC PATCH v2] sf: support chips using 4-byte addressing Chris Packham
2016-10-19 11:50 ` Siva Durga Prasad Paladugu
2016-10-20 4:35 ` Vignesh R
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=20161017005145.21956-2-judge.packham@gmail.com \
--to=judge.packham@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.