From: Jagan Teki <jagan@openedev.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v9 16/21] mtd: spi-nor: Add 4-byte addresswidth support
Date: Sun, 30 Oct 2016 23:53:48 +0530 [thread overview]
Message-ID: <1477851833-23960-17-git-send-email-jagan@openedev.com> (raw)
In-Reply-To: <1477851833-23960-1-git-send-email-jagan@openedev.com>
Add 4-byte address supports, so-that SPI-NOR chips
has > 16MiB should accessible.
Signed-off-by: Jagan Teki <jagan@openedev.com>
---
drivers/mtd/spi-nor/m25p80.c | 1 +
drivers/mtd/spi-nor/spi-nor.c | 36 ++++++++++++++++++++++++++++++++++++
include/linux/mtd/spi-nor.h | 6 +++++-
3 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/spi-nor/m25p80.c b/drivers/mtd/spi-nor/m25p80.c
index 740d3f6..285fae5 100644
--- a/drivers/mtd/spi-nor/m25p80.c
+++ b/drivers/mtd/spi-nor/m25p80.c
@@ -31,6 +31,7 @@ static void m25p_addr2cmd(struct spi_nor *nor, unsigned int addr, u8 *cmd)
cmd[1] = addr >> (nor->addr_width * 8 - 8);
cmd[2] = addr >> (nor->addr_width * 8 - 16);
cmd[3] = addr >> (nor->addr_width * 8 - 24);
+ cmd[4] = addr >> (nor->addr_width * 8 - 32);
}
static int m25p_cmdsz(struct spi_nor *nor)
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 12e7cfe..103b68b 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -378,6 +378,36 @@ static int sst_write_bp(struct udevice *dev, loff_t to, size_t len,
}
#endif
+/* Enable/disable 4-byte addressing mode. */
+static int set_4byte(struct spi_nor *nor, const struct spi_nor_info *info,
+ int enable)
+{
+ int status;
+ bool need_wren = false;
+ u8 cmd;
+
+ switch (JEDEC_MFR(info)) {
+ case SNOR_MFR_MICRON:
+ /* Some Micron need WREN command; all will accept it */
+ need_wren = true;
+ case SNOR_MFR_MACRONIX:
+ case SNOR_MFR_WINBOND:
+ if (need_wren)
+ write_enable(nor);
+
+ cmd = enable ? SNOR_OP_EN4B : SNOR_OP_EX4B;
+ status = nor->write_reg(nor, cmd, NULL, 0);
+ if (need_wren)
+ write_disable(nor);
+
+ return status;
+ default:
+ /* Spansion style */
+ nor->cmd_buf[0] = enable << 7;
+ return nor->write_reg(nor, SNOR_OP_BRWR, nor->cmd_buf, 1);
+ }
+}
+
#ifdef CONFIG_SPI_NOR_MACRONIX
static int macronix_quad_enable(struct spi_nor *nor)
{
@@ -613,6 +643,12 @@ int spi_nor_scan(struct udevice *dev)
}
nor->addr_width = 3;
+ if (mtd->size > SNOR_16MB_BOUN) {
+ nor->addr_width = 4;
+ ret = set_4byte(nor, info, true);
+ if (ret)
+ return ret;
+ }
/* Dummy cycles for read */
switch (nor->read_opcode) {
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 4e5b3ba..ad573db 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -62,6 +62,10 @@
#define SNOR_OP_BP 0x02 /* Byte program */
#define SNOR_OP_AAI_WP 0xad /* Auto addr increment word program */
+/* Used for Macronix and Winbond flashes. */
+#define SNOR_OP_EN4B 0xb7 /* Enter 4-byte mode */
+#define SNOR_OP_EX4B 0xe9 /* Exit 4-byte mode */
+
/* Status Register bits. */
#define SR_WIP BIT(0) /* Write in progress */
#define SR_WEL BIT(1) /* Write enable latch */
@@ -83,7 +87,7 @@
/* Flash timeout values */
#define SNOR_READY_WAIT_PROG (2 * CONFIG_SYS_HZ)
#define SNOR_READY_WAIT_ERASE (5 * CONFIG_SYS_HZ)
-#define SNOR_MAX_CMD_SIZE 4
+#define SNOR_MAX_CMD_SIZE 6
#define SNOR_16MB_BOUN 0x1000000
enum snor_option_flags {
--
2.7.4
next prev parent reply other threads:[~2016-10-30 18:23 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-30 18:23 [U-Boot] [PATCH v9 00/21] dm: Generic MTD Subsystem/SPI-NOR Jagan Teki
2016-10-30 18:23 ` [U-Boot] [PATCH v9 01/21] dm: mtd: Add dm mtd core ops Jagan Teki
2016-11-05 16:07 ` Simon Glass
2016-10-30 18:23 ` [U-Boot] [PATCH v9 02/21] mtd: Add SPI-NOR core support Jagan Teki
2016-11-05 16:10 ` Simon Glass
2016-10-30 18:23 ` [U-Boot] [PATCH v9 03/21] mtd: spi-nor: Kconfig: Add MTD_SPI_NOR entry Jagan Teki
2016-11-05 16:09 ` Simon Glass
2016-10-30 18:23 ` [U-Boot] [PATCH v9 04/21] mtd: spi-nor: Kconfig: Add MTD_SPI_NOR_USE_4K_SECTORS Jagan Teki
2016-11-05 16:09 ` Simon Glass
2016-10-30 18:23 ` [U-Boot] [PATCH v9 05/21] mtd: spi-nor: Kconfig: Add SPI_NOR_MISC entry Jagan Teki
2016-11-05 16:09 ` Simon Glass
2016-10-30 18:23 ` [U-Boot] [PATCH v9 06/21] mtd: spi-nor: Kconfig: Add SPI_NOR_MACRONIX entry Jagan Teki
2016-11-05 16:09 ` Simon Glass
2016-10-30 18:23 ` [U-Boot] [PATCH v9 07/21] mtd: spi-nor: Kconfig: Add SPI_NOR_SPANSION entry Jagan Teki
2016-11-05 16:09 ` Simon Glass
2016-10-30 18:23 ` [U-Boot] [PATCH v9 08/21] mtd: spi-nor: Kconfig: Add SPI_NOR_STMICRO entry Jagan Teki
2016-11-05 16:09 ` Simon Glass
2016-10-30 18:23 ` [U-Boot] [PATCH v9 09/21] mtd: spi-nor: Kconfig: Add SPI_NOR_SST entry Jagan Teki
2016-11-05 16:09 ` Simon Glass
2016-10-30 18:23 ` [U-Boot] [PATCH v9 10/21] mtd: spi-nor: Kconfig: Add SPI_NOR_WINBOND entry Jagan Teki
2016-11-05 16:09 ` Simon Glass
2016-10-30 18:23 ` [U-Boot] [PATCH v9 11/21] spi: Add spi_write_then_read Jagan Teki
2016-11-05 16:09 ` Simon Glass
2016-10-30 18:23 ` [U-Boot] [PATCH v9 12/21] mtd: spi-nor: Add m25p80 driver Jagan Teki
2016-11-05 16:10 ` Simon Glass
2016-10-30 18:23 ` [U-Boot] [PATCH v9 13/21] mtd: spi-nor: Kconfig: Add MTD_M25P80 entry Jagan Teki
2016-11-05 16:09 ` Simon Glass
2016-10-30 18:23 ` [U-Boot] [PATCH v9 14/21] mtd: spi-nor: Add zynq qspinor driver Jagan Teki
2016-10-30 18:23 ` [U-Boot] [PATCH v9 15/21] mtd: spi-nor: zynq_qspi: Kconfig: Add MTD_ZYNQ Jagan Teki
2016-10-30 18:23 ` Jagan Teki [this message]
2016-10-30 18:23 ` [U-Boot] [PATCH v9 17/21] dm: mtd: Add uclass_driver.flags Jagan Teki
2016-11-05 16:10 ` Simon Glass
2016-10-30 18:23 ` [U-Boot] [PATCH v9 18/21] dm: mtd: Add post_bind Jagan Teki
2016-11-05 16:10 ` Simon Glass
2016-10-30 18:23 ` [U-Boot] [PATCH v9 19/21] cmd: Add mtd command support Jagan Teki
2016-11-05 16:10 ` Simon Glass
2016-10-30 18:23 ` [U-Boot] [PATCH v9 20/21] arm: dts: zynq: Add zynq-qspinor node Jagan Teki
2016-10-30 18:23 ` [U-Boot] [PATCH v9 21/21] dm: zynq: microzed: Enable MTD/SPI-NOR Jagan Teki
2016-11-05 16:07 ` [U-Boot] [PATCH v9 00/21] dm: Generic MTD Subsystem/SPI-NOR Simon Glass
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=1477851833-23960-17-git-send-email-jagan@openedev.com \
--to=jagan@openedev.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