All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v4 01/36] sf: Divide spi_flash into multiple parts
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
@ 2013-09-24 18:19 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 02/36] sf: probe: Add new spi_flash_probe support Jagannadha Sutradharudu Teki
                   ` (34 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:19 UTC (permalink / raw)
  To: u-boot

Divided the spi_flash framework into mutiple parts for
- spi_flash.c:
        spi flash core file, interaction for spi/qspi driver to
        spi_flash framework.
- spi_flash_ops.c
        spi flash preffered operations, erase,write and read.
- spi_flash_probe.c
        spi flash probing, easy to extend probing functionality.

This change will support to extend the functionality in a
proper manner.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 drivers/mtd/spi/Makefile          |   2 +-
 drivers/mtd/spi/spi_flash.c       | 571 +-------------------------------------
 drivers/mtd/spi/spi_flash_ops.c   | 314 +++++++++++++++++++++
 drivers/mtd/spi/spi_flash_probe.c | 276 ++++++++++++++++++
 4 files changed, 596 insertions(+), 567 deletions(-)
 create mode 100644 drivers/mtd/spi/spi_flash_ops.c
 create mode 100644 drivers/mtd/spi/spi_flash_probe.c

diff --git a/drivers/mtd/spi/Makefile b/drivers/mtd/spi/Makefile
index 191138a..193cb5d 100644
--- a/drivers/mtd/spi/Makefile
+++ b/drivers/mtd/spi/Makefile
@@ -14,7 +14,7 @@ COBJS-$(CONFIG_SPL_SPI_LOAD)	+= spi_spl_load.o
 COBJS-$(CONFIG_SPL_SPI_BOOT)	+= fsl_espi_spl.o
 endif
 
-COBJS-$(CONFIG_SPI_FLASH)	+= spi_flash.o
+COBJS-$(CONFIG_SPI_FLASH)	+= spi_flash_probe.o spi_flash_ops.o spi_flash.o
 COBJS-$(CONFIG_SPI_FLASH_ATMEL)	+= atmel.o
 COBJS-$(CONFIG_SPI_FLASH_EON)	+= eon.o
 COBJS-$(CONFIG_SPI_FLASH_GIGADEVICE)	+= gigadevice.o
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 5d5055f..ddbdda0 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -8,23 +8,7 @@
  */
 
 #include <common.h>
-#include <fdtdec.h>
-#include <malloc.h>
 #include <spi.h>
-#include <spi_flash.h>
-#include <watchdog.h>
-
-#include "spi_flash_internal.h"
-
-DECLARE_GLOBAL_DATA_PTR;
-
-static void spi_flash_addr(u32 addr, u8 *cmd)
-{
-	/* cmd[0] is actual command */
-	cmd[1] = addr >> 16;
-	cmd[2] = addr >> 8;
-	cmd[3] = addr >> 0;
-}
 
 static int spi_flash_read_write(struct spi_slave *spi,
 				const u8 *cmd, size_t cmd_len,
@@ -52,564 +36,19 @@ static int spi_flash_read_write(struct spi_slave *spi,
 	return ret;
 }
 
-int spi_flash_cmd(struct spi_slave *spi, u8 cmd, void *response, size_t len)
-{
-	return spi_flash_cmd_read(spi, &cmd, 1, response, len);
-}
-
 int spi_flash_cmd_read(struct spi_slave *spi, const u8 *cmd,
 		size_t cmd_len, void *data, size_t data_len)
 {
 	return spi_flash_read_write(spi, cmd, cmd_len, NULL, data, data_len);
 }
 
-int spi_flash_cmd_write(struct spi_slave *spi, const u8 *cmd, size_t cmd_len,
-		const void *data, size_t data_len)
-{
-	return spi_flash_read_write(spi, cmd, cmd_len, data, NULL, data_len);
-}
-
-int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout)
-{
-	struct spi_slave *spi = flash->spi;
-	unsigned long timebase;
-	int ret;
-	u8 status;
-	u8 check_status = 0x0;
-	u8 poll_bit = STATUS_WIP;
-	u8 cmd = flash->poll_cmd;
-
-	if (cmd == CMD_FLAG_STATUS) {
-		poll_bit = STATUS_PEC;
-		check_status = poll_bit;
-	}
-
-	ret = spi_xfer(spi, 8, &cmd, NULL, SPI_XFER_BEGIN);
-	if (ret) {
-		debug("SF: fail to read %s status register\n",
-		      cmd == CMD_READ_STATUS ? "read" : "flag");
-		return ret;
-	}
-
-	timebase = get_timer(0);
-	do {
-		WATCHDOG_RESET();
-
-		ret = spi_xfer(spi, 8, NULL, &status, 0);
-		if (ret)
-			return -1;
-
-		if ((status & poll_bit) == check_status)
-			break;
-
-	} while (get_timer(timebase) < timeout);
-
-	spi_xfer(spi, 0, NULL, NULL, SPI_XFER_END);
-
-	if ((status & poll_bit) == check_status)
-		return 0;
-
-	/* Timed out */
-	debug("SF: time out!\n");
-	return -1;
-}
-
-int spi_flash_write_common(struct spi_flash *flash, const u8 *cmd,
-		size_t cmd_len, const void *buf, size_t buf_len)
-{
-	struct spi_slave *spi = flash->spi;
-	unsigned long timeout = SPI_FLASH_PROG_TIMEOUT;
-	int ret;
-
-	if (buf == NULL)
-		timeout = SPI_FLASH_PAGE_ERASE_TIMEOUT;
-
-	ret = spi_claim_bus(flash->spi);
-	if (ret) {
-		debug("SF: unable to claim SPI bus\n");
-		return ret;
-	}
-
-	ret = spi_flash_cmd_write_enable(flash);
-	if (ret < 0) {
-		debug("SF: enabling write failed\n");
-		return ret;
-	}
-
-	ret = spi_flash_cmd_write(spi, cmd, cmd_len, buf, buf_len);
-	if (ret < 0) {
-		debug("SF: write cmd failed\n");
-		return ret;
-	}
-
-	ret = spi_flash_cmd_wait_ready(flash, timeout);
-	if (ret < 0) {
-		debug("SF: write %s timed out\n",
-		      timeout == SPI_FLASH_PROG_TIMEOUT ?
-			"program" : "page erase");
-		return ret;
-	}
-
-	spi_release_bus(spi);
-
-	return ret;
-}
-
-int spi_flash_cmd_erase(struct spi_flash *flash, u32 offset, size_t len)
-{
-	u32 erase_size;
-	u8 cmd[4];
-	int ret = -1;
-
-	erase_size = flash->sector_size;
-	if (offset % erase_size || len % erase_size) {
-		debug("SF: Erase offset/length not multiple of erase size\n");
-		return -1;
-	}
-
-	if (erase_size == 4096)
-		cmd[0] = CMD_ERASE_4K;
-	else
-		cmd[0] = CMD_ERASE_64K;
-
-	while (len) {
-#ifdef CONFIG_SPI_FLASH_BAR
-		u8 bank_sel;
-
-		bank_sel = offset / SPI_FLASH_16MB_BOUN;
-
-		ret = spi_flash_cmd_bankaddr_write(flash, bank_sel);
-		if (ret) {
-			debug("SF: fail to set bank%d\n", bank_sel);
-			return ret;
-		}
-#endif
-		spi_flash_addr(offset, cmd);
-
-		debug("SF: erase %2x %2x %2x %2x (%x)\n", cmd[0], cmd[1],
-		      cmd[2], cmd[3], offset);
-
-		ret = spi_flash_write_common(flash, cmd, sizeof(cmd), NULL, 0);
-		if (ret < 0) {
-			debug("SF: erase failed\n");
-			break;
-		}
-
-		offset += erase_size;
-		len -= erase_size;
-	}
-
-	return ret;
-}
-
-int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,
-		size_t len, const void *buf)
-{
-	unsigned long byte_addr, page_size;
-	size_t chunk_len, actual;
-	u8 cmd[4];
-	int ret = -1;
-
-	page_size = flash->page_size;
-
-	cmd[0] = CMD_PAGE_PROGRAM;
-	for (actual = 0; actual < len; actual += chunk_len) {
-#ifdef CONFIG_SPI_FLASH_BAR
-		u8 bank_sel;
-
-		bank_sel = offset / SPI_FLASH_16MB_BOUN;
-
-		ret = spi_flash_cmd_bankaddr_write(flash, bank_sel);
-		if (ret) {
-			debug("SF: fail to set bank%d\n", bank_sel);
-			return ret;
-		}
-#endif
-		byte_addr = offset % page_size;
-		chunk_len = min(len - actual, page_size - byte_addr);
-
-		if (flash->spi->max_write_size)
-			chunk_len = min(chunk_len, flash->spi->max_write_size);
-
-		spi_flash_addr(offset, cmd);
-
-		debug("PP: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x } chunk_len = %zu\n",
-		      buf + actual, cmd[0], cmd[1], cmd[2], cmd[3], chunk_len);
-
-		ret = spi_flash_write_common(flash, cmd, sizeof(cmd),
-					buf + actual, chunk_len);
-		if (ret < 0) {
-			debug("SF: write failed\n");
-			break;
-		}
-
-		offset += chunk_len;
-	}
-
-	return ret;
-}
-
-int spi_flash_read_common(struct spi_flash *flash, const u8 *cmd,
-		size_t cmd_len, void *data, size_t data_len)
-{
-	struct spi_slave *spi = flash->spi;
-	int ret;
-
-	ret = spi_claim_bus(flash->spi);
-	if (ret) {
-		debug("SF: unable to claim SPI bus\n");
-		return ret;
-	}
-
-	ret = spi_flash_cmd_read(spi, cmd, cmd_len, data, data_len);
-	if (ret < 0) {
-		debug("SF: read cmd failed\n");
-		return ret;
-	}
-
-	spi_release_bus(spi);
-
-	return ret;
-}
-
-int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset,
-		size_t len, void *data)
-{
-	u8 cmd[5], bank_sel = 0;
-	u32 remain_len, read_len;
-	int ret = -1;
-
-	/* Handle memory-mapped SPI */
-	if (flash->memory_map) {
-		memcpy(data, flash->memory_map + offset, len);
-		return 0;
-	}
-
-	cmd[0] = CMD_READ_ARRAY_FAST;
-	cmd[4] = 0x00;
-
-	while (len) {
-#ifdef CONFIG_SPI_FLASH_BAR
-		bank_sel = offset / SPI_FLASH_16MB_BOUN;
-
-		ret = spi_flash_cmd_bankaddr_write(flash, bank_sel);
-		if (ret) {
-			debug("SF: fail to set bank%d\n", bank_sel);
-			return ret;
-		}
-#endif
-		remain_len = (SPI_FLASH_16MB_BOUN * (bank_sel + 1) - offset);
-		if (len < remain_len)
-			read_len = len;
-		else
-			read_len = remain_len;
-
-		spi_flash_addr(offset, cmd);
-
-		ret = spi_flash_read_common(flash, cmd, sizeof(cmd),
-							data, read_len);
-		if (ret < 0) {
-			debug("SF: read failed\n");
-			break;
-		}
-
-		offset += read_len;
-		len -= read_len;
-		data += read_len;
-	}
-
-	return ret;
-}
-
-int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr)
-{
-	u8 cmd;
-	int ret;
-
-	cmd = CMD_WRITE_STATUS;
-	ret = spi_flash_write_common(flash, &cmd, 1, &sr, 1);
-	if (ret < 0) {
-		debug("SF: fail to write status register\n");
-		return ret;
-	}
-
-	return 0;
-}
-
-#ifdef CONFIG_SPI_FLASH_BAR
-int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel)
-{
-	u8 cmd;
-	int ret;
-
-	if (flash->bank_curr == bank_sel) {
-		debug("SF: not require to enable bank%d\n", bank_sel);
-		return 0;
-	}
-
-	cmd = flash->bank_write_cmd;
-	ret = spi_flash_write_common(flash, &cmd, 1, &bank_sel, 1);
-	if (ret < 0) {
-		debug("SF: fail to write bank register\n");
-		return ret;
-	}
-	flash->bank_curr = bank_sel;
-
-	return 0;
-}
-
-int spi_flash_bank_config(struct spi_flash *flash, u8 idcode0)
-{
-	u8 cmd;
-	u8 curr_bank = 0;
-
-	/* discover bank cmds */
-	switch (idcode0) {
-	case SPI_FLASH_SPANSION_IDCODE0:
-		flash->bank_read_cmd = CMD_BANKADDR_BRRD;
-		flash->bank_write_cmd = CMD_BANKADDR_BRWR;
-		break;
-	case SPI_FLASH_STMICRO_IDCODE0:
-	case SPI_FLASH_WINBOND_IDCODE0:
-		flash->bank_read_cmd = CMD_EXTNADDR_RDEAR;
-		flash->bank_write_cmd = CMD_EXTNADDR_WREAR;
-		break;
-	default:
-		printf("SF: Unsupported bank commands %02x\n", idcode0);
-		return -1;
-	}
-
-	/* read the bank reg - on which bank the flash is in currently */
-	cmd = flash->bank_read_cmd;
-	if (flash->size > SPI_FLASH_16MB_BOUN) {
-		if (spi_flash_read_common(flash, &cmd, 1, &curr_bank, 1)) {
-			debug("SF: fail to read bank addr register\n");
-			return -1;
-		}
-		flash->bank_curr = curr_bank;
-	} else {
-		flash->bank_curr = curr_bank;
-	}
-
-	return 0;
-}
-#endif
-
-#ifdef CONFIG_OF_CONTROL
-int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash)
-{
-	fdt_addr_t addr;
-	fdt_size_t size;
-	int node;
-
-	/* If there is no node, do nothing */
-	node = fdtdec_next_compatible(blob, 0, COMPAT_GENERIC_SPI_FLASH);
-	if (node < 0)
-		return 0;
-
-	addr = fdtdec_get_addr_size(blob, node, "memory-map", &size);
-	if (addr == FDT_ADDR_T_NONE) {
-		debug("%s: Cannot decode address\n", __func__);
-		return 0;
-	}
-
-	if (flash->size != size) {
-		debug("%s: Memory map must cover entire device\n", __func__);
-		return -1;
-	}
-	flash->memory_map = (void *)addr;
-
-	return 0;
-}
-#endif /* CONFIG_OF_CONTROL */
-
-/*
- * The following table holds all device probe functions
- *
- * shift:  number of continuation bytes before the ID
- * idcode: the expected IDCODE or 0xff for non JEDEC devices
- * probe:  the function to call
- *
- * Non JEDEC devices should be ordered in the table such that
- * the probe functions with best detection algorithms come first.
- *
- * Several matching entries are permitted, they will be tried
- * in sequence until a probe function returns non NULL.
- *
- * IDCODE_CONT_LEN may be redefined if a device needs to declare a
- * larger "shift" value.  IDCODE_PART_LEN generally shouldn't be
- * changed.  This is the max number of bytes probe functions may
- * examine when looking up part-specific identification info.
- *
- * Probe functions will be given the idcode buffer starting at their
- * manu id byte (the "idcode" in the table below).  In other words,
- * all of the continuation bytes will be skipped (the "shift" below).
- */
-#define IDCODE_CONT_LEN 0
-#define IDCODE_PART_LEN 5
-static const struct {
-	const u8 shift;
-	const u8 idcode;
-	struct spi_flash *(*probe) (struct spi_slave *spi, u8 *idcode);
-} flashes[] = {
-	/* Keep it sorted by define name */
-#ifdef CONFIG_SPI_FLASH_ATMEL
-	{ 0, 0x1f, spi_flash_probe_atmel, },
-#endif
-#ifdef CONFIG_SPI_FLASH_EON
-	{ 0, 0x1c, spi_flash_probe_eon, },
-#endif
-#ifdef CONFIG_SPI_FLASH_GIGADEVICE
-	{ 0, 0xc8, spi_flash_probe_gigadevice, },
-#endif
-#ifdef CONFIG_SPI_FLASH_MACRONIX
-	{ 0, 0xc2, spi_flash_probe_macronix, },
-#endif
-#ifdef CONFIG_SPI_FLASH_SPANSION
-	{ 0, 0x01, spi_flash_probe_spansion, },
-#endif
-#ifdef CONFIG_SPI_FLASH_SST
-	{ 0, 0xbf, spi_flash_probe_sst, },
-#endif
-#ifdef CONFIG_SPI_FLASH_STMICRO
-	{ 0, 0x20, spi_flash_probe_stmicro, },
-#endif
-#ifdef CONFIG_SPI_FLASH_WINBOND
-	{ 0, 0xef, spi_flash_probe_winbond, },
-#endif
-#ifdef CONFIG_SPI_FRAM_RAMTRON
-	{ 6, 0xc2, spi_fram_probe_ramtron, },
-# undef IDCODE_CONT_LEN
-# define IDCODE_CONT_LEN 6
-#endif
-	/* Keep it sorted by best detection */
-#ifdef CONFIG_SPI_FLASH_STMICRO
-	{ 0, 0xff, spi_flash_probe_stmicro, },
-#endif
-#ifdef CONFIG_SPI_FRAM_RAMTRON_NON_JEDEC
-	{ 0, 0xff, spi_fram_probe_ramtron, },
-#endif
-};
-#define IDCODE_LEN (IDCODE_CONT_LEN + IDCODE_PART_LEN)
-
-struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
-		unsigned int max_hz, unsigned int spi_mode)
-{
-	struct spi_slave *spi;
-	struct spi_flash *flash = NULL;
-	int ret, i, shift;
-	u8 idcode[IDCODE_LEN], *idp;
-
-	spi = spi_setup_slave(bus, cs, max_hz, spi_mode);
-	if (!spi) {
-		printf("SF: Failed to set up slave\n");
-		return NULL;
-	}
-
-	ret = spi_claim_bus(spi);
-	if (ret) {
-		debug("SF: Failed to claim SPI bus: %d\n", ret);
-		goto err_claim_bus;
-	}
-
-	/* Read the ID codes */
-	ret = spi_flash_cmd(spi, CMD_READ_ID, idcode, sizeof(idcode));
-	if (ret)
-		goto err_read_id;
-
-#ifdef DEBUG
-	printf("SF: Got idcodes\n");
-	print_buffer(0, idcode, 1, sizeof(idcode), 0);
-#endif
-
-	/* count the number of continuation bytes */
-	for (shift = 0, idp = idcode;
-	     shift < IDCODE_CONT_LEN && *idp == 0x7f;
-	     ++shift, ++idp)
-		continue;
-
-	/* search the table for matches in shift and id */
-	for (i = 0; i < ARRAY_SIZE(flashes); ++i)
-		if (flashes[i].shift == shift && flashes[i].idcode == *idp) {
-			/* we have a match, call probe */
-			flash = flashes[i].probe(spi, idp);
-			if (flash)
-				break;
-		}
-
-	if (!flash) {
-		printf("SF: Unsupported manufacturer %02x\n", *idp);
-		goto err_manufacturer_probe;
-	}
-
-#ifdef CONFIG_SPI_FLASH_BAR
-	/* Configure the BAR - disover bank cmds and read current bank  */
-	ret = spi_flash_bank_config(flash, *idp);
-	if (ret < 0)
-		goto err_manufacturer_probe;
-#endif
-
-#ifdef CONFIG_OF_CONTROL
-	if (spi_flash_decode_fdt(gd->fdt_blob, flash)) {
-		debug("SF: FDT decode error\n");
-		goto err_manufacturer_probe;
-	}
-#endif
-#ifndef CONFIG_SPL_BUILD
-	printf("SF: Detected %s with page size ", flash->name);
-	print_size(flash->sector_size, ", total ");
-	print_size(flash->size, "");
-	if (flash->memory_map)
-		printf(", mapped at %p", flash->memory_map);
-	puts("\n");
-#endif
-#ifndef CONFIG_SPI_FLASH_BAR
-	if (flash->size > SPI_FLASH_16MB_BOUN) {
-		puts("SF: Warning - Only lower 16MiB accessible,");
-		puts(" Full access #define CONFIG_SPI_FLASH_BAR\n");
-	}
-#endif
-
-	spi_release_bus(spi);
-
-	return flash;
-
-err_manufacturer_probe:
-err_read_id:
-	spi_release_bus(spi);
-err_claim_bus:
-	spi_free_slave(spi);
-	return NULL;
-}
-
-void *spi_flash_do_alloc(int offset, int size, struct spi_slave *spi,
-			 const char *name)
+int spi_flash_cmd(struct spi_slave *spi, u8 cmd, void *response, size_t len)
 {
-	struct spi_flash *flash;
-	void *ptr;
-
-	ptr = malloc(size);
-	if (!ptr) {
-		debug("SF: Failed to allocate memory\n");
-		return NULL;
-	}
-	memset(ptr, '\0', size);
-	flash = (struct spi_flash *)(ptr + offset);
-
-	/* Set up some basic fields - caller will sort out sizes */
-	flash->spi = spi;
-	flash->name = name;
-	flash->poll_cmd = CMD_READ_STATUS;
-
-	flash->read = spi_flash_cmd_read_fast;
-	flash->write = spi_flash_cmd_write_multi;
-	flash->erase = spi_flash_cmd_erase;
-
-	return flash;
+	return spi_flash_cmd_read(spi, &cmd, 1, response, len);
 }
 
-void spi_flash_free(struct spi_flash *flash)
+int spi_flash_cmd_write(struct spi_slave *spi, const u8 *cmd, size_t cmd_len,
+		const void *data, size_t data_len)
 {
-	spi_free_slave(flash->spi);
-	free(flash);
+	return spi_flash_read_write(spi, cmd, cmd_len, data, NULL, data_len);
 }
diff --git a/drivers/mtd/spi/spi_flash_ops.c b/drivers/mtd/spi/spi_flash_ops.c
new file mode 100644
index 0000000..6133363
--- /dev/null
+++ b/drivers/mtd/spi/spi_flash_ops.c
@@ -0,0 +1,314 @@
+/*
+ * SPI flash operations
+ *
+ * Copyright (C) 2008 Atmel Corporation
+ * Copyright (C) 2010 Reinhard Meyer, EMK Elektronik
+ * Copyright (C) 2013 Jagannadha Sutradharudu Teki, Xilinx Inc.
+ *
+ * Licensed under the GPL-2 or later.
+ */
+
+#include <common.h>
+#include <spi.h>
+#include <spi_flash.h>
+#include <watchdog.h>
+
+#include "spi_flash_internal.h"
+
+static void spi_flash_addr(u32 addr, u8 *cmd)
+{
+	/* cmd[0] is actual command */
+	cmd[1] = addr >> 16;
+	cmd[2] = addr >> 8;
+	cmd[3] = addr >> 0;
+}
+
+int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr)
+{
+	u8 cmd;
+	int ret;
+
+	cmd = CMD_WRITE_STATUS;
+	ret = spi_flash_write_common(flash, &cmd, 1, &sr, 1);
+	if (ret < 0) {
+		debug("SF: fail to write status register\n");
+		return ret;
+	}
+
+	return 0;
+}
+
+#ifdef CONFIG_SPI_FLASH_BAR
+int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel)
+{
+	u8 cmd;
+	int ret;
+
+	if (flash->bank_curr == bank_sel) {
+		debug("SF: not require to enable bank%d\n", bank_sel);
+		return 0;
+	}
+
+	cmd = flash->bank_write_cmd;
+	ret = spi_flash_write_common(flash, &cmd, 1, &bank_sel, 1);
+	if (ret < 0) {
+		debug("SF: fail to write bank register\n");
+		return ret;
+	}
+	flash->bank_curr = bank_sel;
+
+	return 0;
+}
+#endif
+
+int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout)
+{
+	struct spi_slave *spi = flash->spi;
+	unsigned long timebase;
+	int ret;
+	u8 status;
+	u8 check_status = 0x0;
+	u8 poll_bit = STATUS_WIP;
+	u8 cmd = flash->poll_cmd;
+
+	if (cmd == CMD_FLAG_STATUS) {
+		poll_bit = STATUS_PEC;
+		check_status = poll_bit;
+	}
+
+	ret = spi_xfer(spi, 8, &cmd, NULL, SPI_XFER_BEGIN);
+	if (ret) {
+		debug("SF: fail to read %s status register\n",
+		      cmd == CMD_READ_STATUS ? "read" : "flag");
+		return ret;
+	}
+
+	timebase = get_timer(0);
+	do {
+		WATCHDOG_RESET();
+
+		ret = spi_xfer(spi, 8, NULL, &status, 0);
+		if (ret)
+			return -1;
+
+		if ((status & poll_bit) == check_status)
+			break;
+
+	} while (get_timer(timebase) < timeout);
+
+	spi_xfer(spi, 0, NULL, NULL, SPI_XFER_END);
+
+	if ((status & poll_bit) == check_status)
+		return 0;
+
+	/* Timed out */
+	debug("SF: time out!\n");
+	return -1;
+}
+
+int spi_flash_write_common(struct spi_flash *flash, const u8 *cmd,
+		size_t cmd_len, const void *buf, size_t buf_len)
+{
+	struct spi_slave *spi = flash->spi;
+	unsigned long timeout = SPI_FLASH_PROG_TIMEOUT;
+	int ret;
+
+	if (buf == NULL)
+		timeout = SPI_FLASH_PAGE_ERASE_TIMEOUT;
+
+	ret = spi_claim_bus(flash->spi);
+	if (ret) {
+		debug("SF: unable to claim SPI bus\n");
+		return ret;
+	}
+
+	ret = spi_flash_cmd_write_enable(flash);
+	if (ret < 0) {
+		debug("SF: enabling write failed\n");
+		return ret;
+	}
+
+	ret = spi_flash_cmd_write(spi, cmd, cmd_len, buf, buf_len);
+	if (ret < 0) {
+		debug("SF: write cmd failed\n");
+		return ret;
+	}
+
+	ret = spi_flash_cmd_wait_ready(flash, timeout);
+	if (ret < 0) {
+		debug("SF: write %s timed out\n",
+		      timeout == SPI_FLASH_PROG_TIMEOUT ?
+			"program" : "page erase");
+		return ret;
+	}
+
+	spi_release_bus(spi);
+
+	return ret;
+}
+
+int spi_flash_cmd_erase(struct spi_flash *flash, u32 offset, size_t len)
+{
+	u32 erase_size;
+	u8 cmd[4];
+	int ret = -1;
+
+	erase_size = flash->sector_size;
+	if (offset % erase_size || len % erase_size) {
+		debug("SF: Erase offset/length not multiple of erase size\n");
+		return -1;
+	}
+
+	if (erase_size == 4096)
+		cmd[0] = CMD_ERASE_4K;
+	else
+		cmd[0] = CMD_ERASE_64K;
+
+	while (len) {
+#ifdef CONFIG_SPI_FLASH_BAR
+		u8 bank_sel;
+
+		bank_sel = offset / SPI_FLASH_16MB_BOUN;
+
+		ret = spi_flash_cmd_bankaddr_write(flash, bank_sel);
+		if (ret) {
+			debug("SF: fail to set bank%d\n", bank_sel);
+			return ret;
+		}
+#endif
+		spi_flash_addr(offset, cmd);
+
+		debug("SF: erase %2x %2x %2x %2x (%x)\n", cmd[0], cmd[1],
+		      cmd[2], cmd[3], offset);
+
+		ret = spi_flash_write_common(flash, cmd, sizeof(cmd), NULL, 0);
+		if (ret < 0) {
+			debug("SF: erase failed\n");
+			break;
+		}
+
+		offset += erase_size;
+		len -= erase_size;
+	}
+
+	return ret;
+}
+
+int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,
+		size_t len, const void *buf)
+{
+	unsigned long byte_addr, page_size;
+	size_t chunk_len, actual;
+	u8 cmd[4];
+	int ret = -1;
+
+	page_size = flash->page_size;
+
+	cmd[0] = CMD_PAGE_PROGRAM;
+	for (actual = 0; actual < len; actual += chunk_len) {
+#ifdef CONFIG_SPI_FLASH_BAR
+		u8 bank_sel;
+
+		bank_sel = offset / SPI_FLASH_16MB_BOUN;
+
+		ret = spi_flash_cmd_bankaddr_write(flash, bank_sel);
+		if (ret) {
+			debug("SF: fail to set bank%d\n", bank_sel);
+			return ret;
+		}
+#endif
+		byte_addr = offset % page_size;
+		chunk_len = min(len - actual, page_size - byte_addr);
+
+		if (flash->spi->max_write_size)
+			chunk_len = min(chunk_len, flash->spi->max_write_size);
+
+		spi_flash_addr(offset, cmd);
+
+		debug("PP: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x } chunk_len = %zu\n",
+		      buf + actual, cmd[0], cmd[1], cmd[2], cmd[3], chunk_len);
+
+		ret = spi_flash_write_common(flash, cmd, sizeof(cmd),
+					buf + actual, chunk_len);
+		if (ret < 0) {
+			debug("SF: write failed\n");
+			break;
+		}
+
+		offset += chunk_len;
+	}
+
+	return ret;
+}
+
+int spi_flash_read_common(struct spi_flash *flash, const u8 *cmd,
+		size_t cmd_len, void *data, size_t data_len)
+{
+	struct spi_slave *spi = flash->spi;
+	int ret;
+
+	ret = spi_claim_bus(flash->spi);
+	if (ret) {
+		debug("SF: unable to claim SPI bus\n");
+		return ret;
+	}
+
+	ret = spi_flash_cmd_read(spi, cmd, cmd_len, data, data_len);
+	if (ret < 0) {
+		debug("SF: read cmd failed\n");
+		return ret;
+	}
+
+	spi_release_bus(spi);
+
+	return ret;
+}
+
+int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset,
+		size_t len, void *data)
+{
+	u8 cmd[5], bank_sel = 0;
+	u32 remain_len, read_len;
+	int ret = -1;
+
+	/* Handle memory-mapped SPI */
+	if (flash->memory_map) {
+		memcpy(data, flash->memory_map + offset, len);
+		return 0;
+	}
+
+	cmd[0] = CMD_READ_ARRAY_FAST;
+	cmd[4] = 0x00;
+
+	while (len) {
+#ifdef CONFIG_SPI_FLASH_BAR
+		bank_sel = offset / SPI_FLASH_16MB_BOUN;
+
+		ret = spi_flash_cmd_bankaddr_write(flash, bank_sel);
+		if (ret) {
+			debug("SF: fail to set bank%d\n", bank_sel);
+			return ret;
+		}
+#endif
+		remain_len = (SPI_FLASH_16MB_BOUN * (bank_sel + 1) - offset);
+		if (len < remain_len)
+			read_len = len;
+		else
+			read_len = remain_len;
+
+		spi_flash_addr(offset, cmd);
+
+		ret = spi_flash_read_common(flash, cmd, sizeof(cmd),
+							data, read_len);
+		if (ret < 0) {
+			debug("SF: read failed\n");
+			break;
+		}
+
+		offset += read_len;
+		len -= read_len;
+		data += read_len;
+	}
+
+	return ret;
+}
diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
new file mode 100644
index 0000000..32ec578
--- /dev/null
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -0,0 +1,276 @@
+/*
+ * SPI flash probing
+ *
+ * Copyright (C) 2008 Atmel Corporation
+ * Copyright (C) 2010 Reinhard Meyer, EMK Elektronik
+ * Copyright (C) 2013 Jagannadha Sutradharudu Teki, Xilinx Inc.
+ *
+ * Licensed under the GPL-2 or later.
+ */
+
+#include <common.h>
+#include <fdtdec.h>
+#include <malloc.h>
+#include <spi.h>
+#include <spi_flash.h>
+
+#include "spi_flash_internal.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#ifdef CONFIG_SPI_FLASH_BAR
+int spi_flash_bank_config(struct spi_flash *flash, u8 idcode0)
+{
+	u8 cmd;
+	u8 curr_bank = 0;
+
+	/* discover bank cmds */
+	switch (idcode0) {
+	case SPI_FLASH_SPANSION_IDCODE0:
+		flash->bank_read_cmd = CMD_BANKADDR_BRRD;
+		flash->bank_write_cmd = CMD_BANKADDR_BRWR;
+		break;
+	case SPI_FLASH_STMICRO_IDCODE0:
+	case SPI_FLASH_WINBOND_IDCODE0:
+		flash->bank_read_cmd = CMD_EXTNADDR_RDEAR;
+		flash->bank_write_cmd = CMD_EXTNADDR_WREAR;
+		break;
+	default:
+		printf("SF: Unsupported bank commands %02x\n", idcode0);
+		return -1;
+	}
+
+	/* read the bank reg - on which bank the flash is in currently */
+	cmd = flash->bank_read_cmd;
+	if (flash->size > SPI_FLASH_16MB_BOUN) {
+		if (spi_flash_read_common(flash, &cmd, 1, &curr_bank, 1)) {
+			debug("SF: fail to read bank addr register\n");
+			return -1;
+		}
+		flash->bank_curr = curr_bank;
+	} else {
+		flash->bank_curr = curr_bank;
+	}
+
+	return 0;
+}
+#endif
+
+#ifdef CONFIG_OF_CONTROL
+int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash)
+{
+	fdt_addr_t addr;
+	fdt_size_t size;
+	int node;
+
+	/* If there is no node, do nothing */
+	node = fdtdec_next_compatible(blob, 0, COMPAT_GENERIC_SPI_FLASH);
+	if (node < 0)
+		return 0;
+
+	addr = fdtdec_get_addr_size(blob, node, "memory-map", &size);
+	if (addr == FDT_ADDR_T_NONE) {
+		debug("%s: Cannot decode address\n", __func__);
+		return 0;
+	}
+
+	if (flash->size != size) {
+		debug("%s: Memory map must cover entire device\n", __func__);
+		return -1;
+	}
+	flash->memory_map = (void *)addr;
+
+	return 0;
+}
+#endif /* CONFIG_OF_CONTROL */
+
+/*
+ * The following table holds all device probe functions
+ *
+ * shift:  number of continuation bytes before the ID
+ * idcode: the expected IDCODE or 0xff for non JEDEC devices
+ * probe:  the function to call
+ *
+ * Non JEDEC devices should be ordered in the table such that
+ * the probe functions with best detection algorithms come first.
+ *
+ * Several matching entries are permitted, they will be tried
+ * in sequence until a probe function returns non NULL.
+ *
+ * IDCODE_CONT_LEN may be redefined if a device needs to declare a
+ * larger "shift" value.  IDCODE_PART_LEN generally shouldn't be
+ * changed.  This is the max number of bytes probe functions may
+ * examine when looking up part-specific identification info.
+ *
+ * Probe functions will be given the idcode buffer starting at their
+ * manu id byte (the "idcode" in the table below).  In other words,
+ * all of the continuation bytes will be skipped (the "shift" below).
+ */
+#define IDCODE_CONT_LEN 0
+#define IDCODE_PART_LEN 5
+static const struct {
+	const u8 shift;
+	const u8 idcode;
+	struct spi_flash *(*probe) (struct spi_slave *spi, u8 *idcode);
+} flashes[] = {
+	/* Keep it sorted by define name */
+#ifdef CONFIG_SPI_FLASH_ATMEL
+	{ 0, 0x1f, spi_flash_probe_atmel, },
+#endif
+#ifdef CONFIG_SPI_FLASH_EON
+	{ 0, 0x1c, spi_flash_probe_eon, },
+#endif
+#ifdef CONFIG_SPI_FLASH_GIGADEVICE
+	{ 0, 0xc8, spi_flash_probe_gigadevice, },
+#endif
+#ifdef CONFIG_SPI_FLASH_MACRONIX
+	{ 0, 0xc2, spi_flash_probe_macronix, },
+#endif
+#ifdef CONFIG_SPI_FLASH_SPANSION
+	{ 0, 0x01, spi_flash_probe_spansion, },
+#endif
+#ifdef CONFIG_SPI_FLASH_SST
+	{ 0, 0xbf, spi_flash_probe_sst, },
+#endif
+#ifdef CONFIG_SPI_FLASH_STMICRO
+	{ 0, 0x20, spi_flash_probe_stmicro, },
+#endif
+#ifdef CONFIG_SPI_FLASH_WINBOND
+	{ 0, 0xef, spi_flash_probe_winbond, },
+#endif
+#ifdef CONFIG_SPI_FRAM_RAMTRON
+	{ 6, 0xc2, spi_fram_probe_ramtron, },
+# undef IDCODE_CONT_LEN
+# define IDCODE_CONT_LEN 6
+#endif
+	/* Keep it sorted by best detection */
+#ifdef CONFIG_SPI_FLASH_STMICRO
+	{ 0, 0xff, spi_flash_probe_stmicro, },
+#endif
+#ifdef CONFIG_SPI_FRAM_RAMTRON_NON_JEDEC
+	{ 0, 0xff, spi_fram_probe_ramtron, },
+#endif
+};
+#define IDCODE_LEN (IDCODE_CONT_LEN + IDCODE_PART_LEN)
+
+struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
+		unsigned int max_hz, unsigned int spi_mode)
+{
+	struct spi_slave *spi;
+	struct spi_flash *flash = NULL;
+	int ret, i, shift;
+	u8 idcode[IDCODE_LEN], *idp;
+
+	spi = spi_setup_slave(bus, cs, max_hz, spi_mode);
+	if (!spi) {
+		printf("SF: Failed to set up slave\n");
+		return NULL;
+	}
+
+	ret = spi_claim_bus(spi);
+	if (ret) {
+		debug("SF: Failed to claim SPI bus: %d\n", ret);
+		goto err_claim_bus;
+	}
+
+	/* Read the ID codes */
+	ret = spi_flash_cmd(spi, CMD_READ_ID, idcode, sizeof(idcode));
+	if (ret)
+		goto err_read_id;
+
+#ifdef DEBUG
+	printf("SF: Got idcodes\n");
+	print_buffer(0, idcode, 1, sizeof(idcode), 0);
+#endif
+
+	/* count the number of continuation bytes */
+	for (shift = 0, idp = idcode;
+	     shift < IDCODE_CONT_LEN && *idp == 0x7f;
+	     ++shift, ++idp)
+		continue;
+
+	/* search the table for matches in shift and id */
+	for (i = 0; i < ARRAY_SIZE(flashes); ++i)
+		if (flashes[i].shift == shift && flashes[i].idcode == *idp) {
+			/* we have a match, call probe */
+			flash = flashes[i].probe(spi, idp);
+			if (flash)
+				break;
+		}
+
+	if (!flash) {
+		printf("SF: Unsupported manufacturer %02x\n", *idp);
+		goto err_manufacturer_probe;
+	}
+
+#ifdef CONFIG_SPI_FLASH_BAR
+	/* Configure the BAR - disover bank cmds and read current bank  */
+	ret = spi_flash_bank_config(flash, *idp);
+	if (ret < 0)
+		goto err_manufacturer_probe;
+#endif
+
+#ifdef CONFIG_OF_CONTROL
+	if (spi_flash_decode_fdt(gd->fdt_blob, flash)) {
+		debug("SF: FDT decode error\n");
+		goto err_manufacturer_probe;
+	}
+#endif
+#ifndef CONFIG_SPL_BUILD
+	printf("SF: Detected %s with page size ", flash->name);
+	print_size(flash->sector_size, ", total ");
+	print_size(flash->size, "");
+	if (flash->memory_map)
+		printf(", mapped at %p", flash->memory_map);
+	puts("\n");
+#endif
+#ifndef CONFIG_SPI_FLASH_BAR
+	if (flash->size > SPI_FLASH_16MB_BOUN) {
+		puts("SF: Warning - Only lower 16MiB accessible,");
+		puts(" Full access #define CONFIG_SPI_FLASH_BAR\n");
+	}
+#endif
+
+	spi_release_bus(spi);
+
+	return flash;
+
+err_manufacturer_probe:
+err_read_id:
+	spi_release_bus(spi);
+err_claim_bus:
+	spi_free_slave(spi);
+	return NULL;
+}
+
+void *spi_flash_do_alloc(int offset, int size, struct spi_slave *spi,
+			 const char *name)
+{
+	struct spi_flash *flash;
+	void *ptr;
+
+	ptr = malloc(size);
+	if (!ptr) {
+		debug("SF: Failed to allocate memory\n");
+		return NULL;
+	}
+	memset(ptr, '\0', size);
+	flash = (struct spi_flash *)(ptr + offset);
+
+	/* Set up some basic fields - caller will sort out sizes */
+	flash->spi = spi;
+	flash->name = name;
+	flash->poll_cmd = CMD_READ_STATUS;
+
+	flash->read = spi_flash_cmd_read_fast;
+	flash->write = spi_flash_cmd_write_multi;
+	flash->erase = spi_flash_cmd_erase;
+
+	return flash;
+}
+
+void spi_flash_free(struct spi_flash *flash)
+{
+	spi_free_slave(flash->spi);
+	free(flash);
+}
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 02/36] sf: probe: Add new spi_flash_probe support
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 01/36] sf: Divide spi_flash into multiple parts Jagannadha Sutradharudu Teki
@ 2013-09-24 18:19 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 03/36] sf: probe: Add support for M25P* flash parts Jagannadha Sutradharudu Teki
                   ` (33 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:19 UTC (permalink / raw)
  To: u-boot

Added new spi_flash_probe support, currently added N25Q*
flash part attributes support.

Updated the sector_size attributes as per the flash parts.
Looks fine for with this sector_size for computing the size
of flash.

Defined CONFIG_SPI_FLASH_LEGACY for old probing style
which is available on spi_flash_probe_legacy.c, this will
removed soon once all flashes are supported in new spi_flash_probe.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - Removed CONFIG_SPI_FLASH_LEGACY
Changes for v3:
        - Fix warning issue.
Changes for v2:
	- Removed CONFIG_SPI_FLASH_NEW, add CONFIG_SPI_FLASH_LEGACY
        - Enable CONFIG_SPI_FLASH_STMICRO in spi_flash_params table
        - Updated few structure members

 drivers/mtd/spi/Makefile                 |   2 +-
 drivers/mtd/spi/spi_flash_probe.c        | 229 ++++++++++++-------------
 drivers/mtd/spi/spi_flash_probe_legacy.c | 276 +++++++++++++++++++++++++++++++
 3 files changed, 385 insertions(+), 122 deletions(-)
 create mode 100644 drivers/mtd/spi/spi_flash_probe_legacy.c

diff --git a/drivers/mtd/spi/Makefile b/drivers/mtd/spi/Makefile
index 193cb5d..a10c850 100644
--- a/drivers/mtd/spi/Makefile
+++ b/drivers/mtd/spi/Makefile
@@ -14,7 +14,7 @@ COBJS-$(CONFIG_SPL_SPI_LOAD)	+= spi_spl_load.o
 COBJS-$(CONFIG_SPL_SPI_BOOT)	+= fsl_espi_spl.o
 endif
 
-COBJS-$(CONFIG_SPI_FLASH)	+= spi_flash_probe.o spi_flash_ops.o spi_flash.o
+COBJS-$(CONFIG_SPI_FLASH) += spi_flash_probe_legacy.o spi_flash_ops.o spi_flash.o
 COBJS-$(CONFIG_SPI_FLASH_ATMEL)	+= atmel.o
 COBJS-$(CONFIG_SPI_FLASH_EON)	+= eon.o
 COBJS-$(CONFIG_SPI_FLASH_GIGADEVICE)	+= gigadevice.o
diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index 32ec578..620e41b 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -18,6 +18,98 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+/*
+ * struct spi_flash_params - SPI/QSPI flash device params structure
+ *
+ * @name:		Device name ([MANUFLETTER][DEVTYPE][DENSITY][EXTRAINFO])
+ * @jedec:		Device jedec ID (0x[1byte_manuf_id][2byte_dev_id])
+ * @ext_jedec:		Device ext_jedec ID
+ * @sector_size:	Sector size of this device
+ * @nr_sectors:		No.of sectors on this device
+ */
+struct spi_flash_params {
+	const char *name;
+	u32 jedec;
+	u16 ext_jedec;
+	u32 sector_size;
+	u32 nr_sectors;
+};
+
+static const struct spi_flash_params spi_flash_params_table[] = {
+#ifdef CONFIG_SPI_FLASH_STMICRO		/* STMICRO */
+	{"N25Q32",		0x20ba16, 0x0,     64 * 1024,	  64},
+	{"N25Q32A",		0x20bb16, 0x0,     64 * 1024,	  64},
+	{"N25Q64",		0x20ba17, 0x0,     64 * 1024,	 128},
+	{"N25Q64A",		0x20bb17, 0x0,     64 * 1024,	 128},
+	{"N25Q128",		0x20ba18, 0x0,     64 * 1024,	 256},
+	{"N25Q128A",		0x20bb18, 0x0,     64 * 1024,	 256},
+	{"N25Q256",		0x20ba19, 0x0,     64 * 1024,	 512},
+	{"N25Q256A",		0x20bb19, 0x0,     64 * 1024,	 512},
+	{"N25Q512",		0x20ba20, 0x0,     64 * 1024,	1024},
+	{"N25Q512A",		0x20bb20, 0x0,     64 * 1024,	1024},
+	{"N25Q1024",		0x20ba21, 0x0,     64 * 1024,	2048},
+	{"N25Q1024A",		0x20bb21, 0x0,     64 * 1024,	2048},
+#endif
+	/*
+	 * TODO:
+	 * ATMEL
+	 * EON
+	 * GIGADEVICE
+	 * MACRONIX
+	 * RAMTRON
+	 * SPANSION
+	 * SST
+	 * STMICRO (M25*)
+	 * WINBOND
+	 */
+};
+
+struct spi_flash *spi_flash_validate_ids(struct spi_slave *spi, u8 *idcode)
+{
+	const struct spi_flash_params *params;
+	struct spi_flash *flash;
+	int i;
+	u16 jedec = idcode[1] << 8 | idcode[2];
+
+	/* Get the flash id (jedec = manuf_id + dev_id) */
+	for (i = 0; i < ARRAY_SIZE(spi_flash_params_table); i++) {
+		params = &spi_flash_params_table[i];
+		if ((params->jedec >> 16) == idcode[0]) {
+			if ((params->jedec & 0xFFFF) == jedec)
+				break;
+		}
+	}
+
+	if (i == ARRAY_SIZE(spi_flash_params_table)) {
+		printf("SF: Unsupported flash ID: manuf %02x, jedec %04x\n",
+		       idcode[0], jedec);
+		return NULL;
+	}
+
+	flash = malloc(sizeof(*flash));
+	if (!flash) {
+		debug("SF: Failed to allocate spi_flash\n");
+		return NULL;
+	}
+	memset(flash, '\0', sizeof(*flash));
+
+	flash->spi = spi;
+	flash->name = params->name;
+	flash->poll_cmd = CMD_READ_STATUS;
+
+	/* Assign spi_flash ops */
+	flash->write = spi_flash_cmd_write_multi;
+	flash->erase = spi_flash_cmd_erase;
+	flash->read = spi_flash_cmd_read_fast;
+
+	/* Compute the flash size */
+	flash->page_size = 256;
+	flash->sector_size = params->sector_size;
+	flash->size = flash->sector_size * params->nr_sectors;
+
+	return flash;
+}
+
 #ifdef CONFIG_SPI_FLASH_BAR
 int spi_flash_bank_config(struct spi_flash *flash, u8 idcode0)
 {
@@ -84,89 +176,22 @@ int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash)
 }
 #endif /* CONFIG_OF_CONTROL */
 
-/*
- * The following table holds all device probe functions
- *
- * shift:  number of continuation bytes before the ID
- * idcode: the expected IDCODE or 0xff for non JEDEC devices
- * probe:  the function to call
- *
- * Non JEDEC devices should be ordered in the table such that
- * the probe functions with best detection algorithms come first.
- *
- * Several matching entries are permitted, they will be tried
- * in sequence until a probe function returns non NULL.
- *
- * IDCODE_CONT_LEN may be redefined if a device needs to declare a
- * larger "shift" value.  IDCODE_PART_LEN generally shouldn't be
- * changed.  This is the max number of bytes probe functions may
- * examine when looking up part-specific identification info.
- *
- * Probe functions will be given the idcode buffer starting at their
- * manu id byte (the "idcode" in the table below).  In other words,
- * all of the continuation bytes will be skipped (the "shift" below).
- */
-#define IDCODE_CONT_LEN 0
-#define IDCODE_PART_LEN 5
-static const struct {
-	const u8 shift;
-	const u8 idcode;
-	struct spi_flash *(*probe) (struct spi_slave *spi, u8 *idcode);
-} flashes[] = {
-	/* Keep it sorted by define name */
-#ifdef CONFIG_SPI_FLASH_ATMEL
-	{ 0, 0x1f, spi_flash_probe_atmel, },
-#endif
-#ifdef CONFIG_SPI_FLASH_EON
-	{ 0, 0x1c, spi_flash_probe_eon, },
-#endif
-#ifdef CONFIG_SPI_FLASH_GIGADEVICE
-	{ 0, 0xc8, spi_flash_probe_gigadevice, },
-#endif
-#ifdef CONFIG_SPI_FLASH_MACRONIX
-	{ 0, 0xc2, spi_flash_probe_macronix, },
-#endif
-#ifdef CONFIG_SPI_FLASH_SPANSION
-	{ 0, 0x01, spi_flash_probe_spansion, },
-#endif
-#ifdef CONFIG_SPI_FLASH_SST
-	{ 0, 0xbf, spi_flash_probe_sst, },
-#endif
-#ifdef CONFIG_SPI_FLASH_STMICRO
-	{ 0, 0x20, spi_flash_probe_stmicro, },
-#endif
-#ifdef CONFIG_SPI_FLASH_WINBOND
-	{ 0, 0xef, spi_flash_probe_winbond, },
-#endif
-#ifdef CONFIG_SPI_FRAM_RAMTRON
-	{ 6, 0xc2, spi_fram_probe_ramtron, },
-# undef IDCODE_CONT_LEN
-# define IDCODE_CONT_LEN 6
-#endif
-	/* Keep it sorted by best detection */
-#ifdef CONFIG_SPI_FLASH_STMICRO
-	{ 0, 0xff, spi_flash_probe_stmicro, },
-#endif
-#ifdef CONFIG_SPI_FRAM_RAMTRON_NON_JEDEC
-	{ 0, 0xff, spi_fram_probe_ramtron, },
-#endif
-};
-#define IDCODE_LEN (IDCODE_CONT_LEN + IDCODE_PART_LEN)
-
 struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
 		unsigned int max_hz, unsigned int spi_mode)
 {
 	struct spi_slave *spi;
 	struct spi_flash *flash = NULL;
-	int ret, i, shift;
-	u8 idcode[IDCODE_LEN], *idp;
+	u8 idcode[5], *idp;
+	int ret;
 
+	/* Setup spi_slave */
 	spi = spi_setup_slave(bus, cs, max_hz, spi_mode);
 	if (!spi) {
 		printf("SF: Failed to set up slave\n");
 		return NULL;
 	}
 
+	/* Claim spi bus */
 	ret = spi_claim_bus(spi);
 	if (ret) {
 		debug("SF: Failed to claim SPI bus: %d\n", ret);
@@ -175,45 +200,33 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
 
 	/* Read the ID codes */
 	ret = spi_flash_cmd(spi, CMD_READ_ID, idcode, sizeof(idcode));
-	if (ret)
+	if (ret) {
+		printf("SF: Failed to get idcodes\n");
 		goto err_read_id;
+	}
 
 #ifdef DEBUG
 	printf("SF: Got idcodes\n");
 	print_buffer(0, idcode, 1, sizeof(idcode), 0);
 #endif
 
-	/* count the number of continuation bytes */
-	for (shift = 0, idp = idcode;
-	     shift < IDCODE_CONT_LEN && *idp == 0x7f;
-	     ++shift, ++idp)
-		continue;
-
-	/* search the table for matches in shift and id */
-	for (i = 0; i < ARRAY_SIZE(flashes); ++i)
-		if (flashes[i].shift == shift && flashes[i].idcode == *idp) {
-			/* we have a match, call probe */
-			flash = flashes[i].probe(spi, idp);
-			if (flash)
-				break;
-		}
-
-	if (!flash) {
-		printf("SF: Unsupported manufacturer %02x\n", *idp);
-		goto err_manufacturer_probe;
-	}
+	/* Validate ID's from flash dev table */
+	idp = idcode;
+	flash = spi_flash_validate_ids(spi, idp);
+	if (!flash)
+		goto err_read_id;
 
 #ifdef CONFIG_SPI_FLASH_BAR
-	/* Configure the BAR - disover bank cmds and read current bank  */
+	/* Configure the BAR - discover bank cmds and read current bank  */
 	ret = spi_flash_bank_config(flash, *idp);
 	if (ret < 0)
-		goto err_manufacturer_probe;
+		goto err_read_id;
 #endif
 
 #ifdef CONFIG_OF_CONTROL
 	if (spi_flash_decode_fdt(gd->fdt_blob, flash)) {
 		debug("SF: FDT decode error\n");
-		goto err_manufacturer_probe;
+		goto err_read_id;
 	}
 #endif
 #ifndef CONFIG_SPL_BUILD
@@ -231,11 +244,11 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
 	}
 #endif
 
+	/* Release spi bus */
 	spi_release_bus(spi);
 
 	return flash;
 
-err_manufacturer_probe:
 err_read_id:
 	spi_release_bus(spi);
 err_claim_bus:
@@ -243,32 +256,6 @@ err_claim_bus:
 	return NULL;
 }
 
-void *spi_flash_do_alloc(int offset, int size, struct spi_slave *spi,
-			 const char *name)
-{
-	struct spi_flash *flash;
-	void *ptr;
-
-	ptr = malloc(size);
-	if (!ptr) {
-		debug("SF: Failed to allocate memory\n");
-		return NULL;
-	}
-	memset(ptr, '\0', size);
-	flash = (struct spi_flash *)(ptr + offset);
-
-	/* Set up some basic fields - caller will sort out sizes */
-	flash->spi = spi;
-	flash->name = name;
-	flash->poll_cmd = CMD_READ_STATUS;
-
-	flash->read = spi_flash_cmd_read_fast;
-	flash->write = spi_flash_cmd_write_multi;
-	flash->erase = spi_flash_cmd_erase;
-
-	return flash;
-}
-
 void spi_flash_free(struct spi_flash *flash)
 {
 	spi_free_slave(flash->spi);
diff --git a/drivers/mtd/spi/spi_flash_probe_legacy.c b/drivers/mtd/spi/spi_flash_probe_legacy.c
new file mode 100644
index 0000000..32ec578
--- /dev/null
+++ b/drivers/mtd/spi/spi_flash_probe_legacy.c
@@ -0,0 +1,276 @@
+/*
+ * SPI flash probing
+ *
+ * Copyright (C) 2008 Atmel Corporation
+ * Copyright (C) 2010 Reinhard Meyer, EMK Elektronik
+ * Copyright (C) 2013 Jagannadha Sutradharudu Teki, Xilinx Inc.
+ *
+ * Licensed under the GPL-2 or later.
+ */
+
+#include <common.h>
+#include <fdtdec.h>
+#include <malloc.h>
+#include <spi.h>
+#include <spi_flash.h>
+
+#include "spi_flash_internal.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#ifdef CONFIG_SPI_FLASH_BAR
+int spi_flash_bank_config(struct spi_flash *flash, u8 idcode0)
+{
+	u8 cmd;
+	u8 curr_bank = 0;
+
+	/* discover bank cmds */
+	switch (idcode0) {
+	case SPI_FLASH_SPANSION_IDCODE0:
+		flash->bank_read_cmd = CMD_BANKADDR_BRRD;
+		flash->bank_write_cmd = CMD_BANKADDR_BRWR;
+		break;
+	case SPI_FLASH_STMICRO_IDCODE0:
+	case SPI_FLASH_WINBOND_IDCODE0:
+		flash->bank_read_cmd = CMD_EXTNADDR_RDEAR;
+		flash->bank_write_cmd = CMD_EXTNADDR_WREAR;
+		break;
+	default:
+		printf("SF: Unsupported bank commands %02x\n", idcode0);
+		return -1;
+	}
+
+	/* read the bank reg - on which bank the flash is in currently */
+	cmd = flash->bank_read_cmd;
+	if (flash->size > SPI_FLASH_16MB_BOUN) {
+		if (spi_flash_read_common(flash, &cmd, 1, &curr_bank, 1)) {
+			debug("SF: fail to read bank addr register\n");
+			return -1;
+		}
+		flash->bank_curr = curr_bank;
+	} else {
+		flash->bank_curr = curr_bank;
+	}
+
+	return 0;
+}
+#endif
+
+#ifdef CONFIG_OF_CONTROL
+int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash)
+{
+	fdt_addr_t addr;
+	fdt_size_t size;
+	int node;
+
+	/* If there is no node, do nothing */
+	node = fdtdec_next_compatible(blob, 0, COMPAT_GENERIC_SPI_FLASH);
+	if (node < 0)
+		return 0;
+
+	addr = fdtdec_get_addr_size(blob, node, "memory-map", &size);
+	if (addr == FDT_ADDR_T_NONE) {
+		debug("%s: Cannot decode address\n", __func__);
+		return 0;
+	}
+
+	if (flash->size != size) {
+		debug("%s: Memory map must cover entire device\n", __func__);
+		return -1;
+	}
+	flash->memory_map = (void *)addr;
+
+	return 0;
+}
+#endif /* CONFIG_OF_CONTROL */
+
+/*
+ * The following table holds all device probe functions
+ *
+ * shift:  number of continuation bytes before the ID
+ * idcode: the expected IDCODE or 0xff for non JEDEC devices
+ * probe:  the function to call
+ *
+ * Non JEDEC devices should be ordered in the table such that
+ * the probe functions with best detection algorithms come first.
+ *
+ * Several matching entries are permitted, they will be tried
+ * in sequence until a probe function returns non NULL.
+ *
+ * IDCODE_CONT_LEN may be redefined if a device needs to declare a
+ * larger "shift" value.  IDCODE_PART_LEN generally shouldn't be
+ * changed.  This is the max number of bytes probe functions may
+ * examine when looking up part-specific identification info.
+ *
+ * Probe functions will be given the idcode buffer starting at their
+ * manu id byte (the "idcode" in the table below).  In other words,
+ * all of the continuation bytes will be skipped (the "shift" below).
+ */
+#define IDCODE_CONT_LEN 0
+#define IDCODE_PART_LEN 5
+static const struct {
+	const u8 shift;
+	const u8 idcode;
+	struct spi_flash *(*probe) (struct spi_slave *spi, u8 *idcode);
+} flashes[] = {
+	/* Keep it sorted by define name */
+#ifdef CONFIG_SPI_FLASH_ATMEL
+	{ 0, 0x1f, spi_flash_probe_atmel, },
+#endif
+#ifdef CONFIG_SPI_FLASH_EON
+	{ 0, 0x1c, spi_flash_probe_eon, },
+#endif
+#ifdef CONFIG_SPI_FLASH_GIGADEVICE
+	{ 0, 0xc8, spi_flash_probe_gigadevice, },
+#endif
+#ifdef CONFIG_SPI_FLASH_MACRONIX
+	{ 0, 0xc2, spi_flash_probe_macronix, },
+#endif
+#ifdef CONFIG_SPI_FLASH_SPANSION
+	{ 0, 0x01, spi_flash_probe_spansion, },
+#endif
+#ifdef CONFIG_SPI_FLASH_SST
+	{ 0, 0xbf, spi_flash_probe_sst, },
+#endif
+#ifdef CONFIG_SPI_FLASH_STMICRO
+	{ 0, 0x20, spi_flash_probe_stmicro, },
+#endif
+#ifdef CONFIG_SPI_FLASH_WINBOND
+	{ 0, 0xef, spi_flash_probe_winbond, },
+#endif
+#ifdef CONFIG_SPI_FRAM_RAMTRON
+	{ 6, 0xc2, spi_fram_probe_ramtron, },
+# undef IDCODE_CONT_LEN
+# define IDCODE_CONT_LEN 6
+#endif
+	/* Keep it sorted by best detection */
+#ifdef CONFIG_SPI_FLASH_STMICRO
+	{ 0, 0xff, spi_flash_probe_stmicro, },
+#endif
+#ifdef CONFIG_SPI_FRAM_RAMTRON_NON_JEDEC
+	{ 0, 0xff, spi_fram_probe_ramtron, },
+#endif
+};
+#define IDCODE_LEN (IDCODE_CONT_LEN + IDCODE_PART_LEN)
+
+struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
+		unsigned int max_hz, unsigned int spi_mode)
+{
+	struct spi_slave *spi;
+	struct spi_flash *flash = NULL;
+	int ret, i, shift;
+	u8 idcode[IDCODE_LEN], *idp;
+
+	spi = spi_setup_slave(bus, cs, max_hz, spi_mode);
+	if (!spi) {
+		printf("SF: Failed to set up slave\n");
+		return NULL;
+	}
+
+	ret = spi_claim_bus(spi);
+	if (ret) {
+		debug("SF: Failed to claim SPI bus: %d\n", ret);
+		goto err_claim_bus;
+	}
+
+	/* Read the ID codes */
+	ret = spi_flash_cmd(spi, CMD_READ_ID, idcode, sizeof(idcode));
+	if (ret)
+		goto err_read_id;
+
+#ifdef DEBUG
+	printf("SF: Got idcodes\n");
+	print_buffer(0, idcode, 1, sizeof(idcode), 0);
+#endif
+
+	/* count the number of continuation bytes */
+	for (shift = 0, idp = idcode;
+	     shift < IDCODE_CONT_LEN && *idp == 0x7f;
+	     ++shift, ++idp)
+		continue;
+
+	/* search the table for matches in shift and id */
+	for (i = 0; i < ARRAY_SIZE(flashes); ++i)
+		if (flashes[i].shift == shift && flashes[i].idcode == *idp) {
+			/* we have a match, call probe */
+			flash = flashes[i].probe(spi, idp);
+			if (flash)
+				break;
+		}
+
+	if (!flash) {
+		printf("SF: Unsupported manufacturer %02x\n", *idp);
+		goto err_manufacturer_probe;
+	}
+
+#ifdef CONFIG_SPI_FLASH_BAR
+	/* Configure the BAR - disover bank cmds and read current bank  */
+	ret = spi_flash_bank_config(flash, *idp);
+	if (ret < 0)
+		goto err_manufacturer_probe;
+#endif
+
+#ifdef CONFIG_OF_CONTROL
+	if (spi_flash_decode_fdt(gd->fdt_blob, flash)) {
+		debug("SF: FDT decode error\n");
+		goto err_manufacturer_probe;
+	}
+#endif
+#ifndef CONFIG_SPL_BUILD
+	printf("SF: Detected %s with page size ", flash->name);
+	print_size(flash->sector_size, ", total ");
+	print_size(flash->size, "");
+	if (flash->memory_map)
+		printf(", mapped at %p", flash->memory_map);
+	puts("\n");
+#endif
+#ifndef CONFIG_SPI_FLASH_BAR
+	if (flash->size > SPI_FLASH_16MB_BOUN) {
+		puts("SF: Warning - Only lower 16MiB accessible,");
+		puts(" Full access #define CONFIG_SPI_FLASH_BAR\n");
+	}
+#endif
+
+	spi_release_bus(spi);
+
+	return flash;
+
+err_manufacturer_probe:
+err_read_id:
+	spi_release_bus(spi);
+err_claim_bus:
+	spi_free_slave(spi);
+	return NULL;
+}
+
+void *spi_flash_do_alloc(int offset, int size, struct spi_slave *spi,
+			 const char *name)
+{
+	struct spi_flash *flash;
+	void *ptr;
+
+	ptr = malloc(size);
+	if (!ptr) {
+		debug("SF: Failed to allocate memory\n");
+		return NULL;
+	}
+	memset(ptr, '\0', size);
+	flash = (struct spi_flash *)(ptr + offset);
+
+	/* Set up some basic fields - caller will sort out sizes */
+	flash->spi = spi;
+	flash->name = name;
+	flash->poll_cmd = CMD_READ_STATUS;
+
+	flash->read = spi_flash_cmd_read_fast;
+	flash->write = spi_flash_cmd_write_multi;
+	flash->erase = spi_flash_cmd_erase;
+
+	return flash;
+}
+
+void spi_flash_free(struct spi_flash *flash)
+{
+	spi_free_slave(flash->spi);
+	free(flash);
+}
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 03/36] sf: probe: Add support for M25P* flash parts
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 01/36] sf: Divide spi_flash into multiple parts Jagannadha Sutradharudu Teki
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 02/36] sf: probe: Add new spi_flash_probe support Jagannadha Sutradharudu Teki
@ 2013-09-24 18:19 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 04/36] sf: probe: Add support for EN25Q* " Jagannadha Sutradharudu Teki
                   ` (32 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:19 UTC (permalink / raw)
  To: u-boot

Added M25P* parts are which are avilable in spi_flash_probe_legacy.c.

Updated the sector_size attributes as per the flash parts.
Looks fine for with this sector_size for computing the size of flash.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 drivers/mtd/spi/spi_flash_probe.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index 620e41b..08a3ab2 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -37,6 +37,14 @@ struct spi_flash_params {
 
 static const struct spi_flash_params spi_flash_params_table[] = {
 #ifdef CONFIG_SPI_FLASH_STMICRO		/* STMICRO */
+	{"M25P10",		0x202011, 0x0,     32 * 1024,	   4},
+	{"M25P20",		0x202012, 0x0,     64 * 1024,	   4},
+	{"M25P40",		0x202013, 0x0,     64 * 1024,	   8},
+	{"M25P80",		0x202014, 0x0,     64 * 1024,	  16},
+	{"M25P16",		0x202015, 0x0,     64 * 1024,	  32},
+	{"M25P32",		0x202016, 0x0,     64 * 1024,	  64},
+	{"M25P64",		0x202017, 0x0,     64 * 1024,	 128},
+	{"M25P128",		0x202018, 0x0,    256 * 1024,	  64},
 	{"N25Q32",		0x20ba16, 0x0,     64 * 1024,	  64},
 	{"N25Q32A",		0x20bb16, 0x0,     64 * 1024,	  64},
 	{"N25Q64",		0x20ba17, 0x0,     64 * 1024,	 128},
@@ -59,7 +67,6 @@ static const struct spi_flash_params spi_flash_params_table[] = {
 	 * RAMTRON
 	 * SPANSION
 	 * SST
-	 * STMICRO (M25*)
 	 * WINBOND
 	 */
 };
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 04/36] sf: probe: Add support for EN25Q* flash parts
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (2 preceding siblings ...)
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 03/36] sf: probe: Add support for M25P* flash parts Jagannadha Sutradharudu Teki
@ 2013-09-24 18:19 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 05/36] sf: probe: Add support for GD25* " Jagannadha Sutradharudu Teki
                   ` (31 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:19 UTC (permalink / raw)
  To: u-boot

Added EN25Q* parts are which are avilable in spi_flash_probe_legacy.c.

Updated the sector_size attributes as per the flash parts.
Looks fine for with this sector_size for computing the size
of flash.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - Enable CONFIG_SPI_FLASH_EON

 drivers/mtd/spi/spi_flash_probe.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index 08a3ab2..12baf41 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -36,6 +36,10 @@ struct spi_flash_params {
 };
 
 static const struct spi_flash_params spi_flash_params_table[] = {
+#ifdef CONFIG_SPI_FLASH_EON		/* EON */
+	{"EN25Q32B",		0x1c3016, 0x0,	   64 * 1024,	  64},
+	{"EN25Q128B",		0x1c3018, 0x0,     64 * 1024,	 256},
+#endif
 #ifdef CONFIG_SPI_FLASH_STMICRO		/* STMICRO */
 	{"M25P10",		0x202011, 0x0,     32 * 1024,	   4},
 	{"M25P20",		0x202012, 0x0,     64 * 1024,	   4},
@@ -61,7 +65,6 @@ static const struct spi_flash_params spi_flash_params_table[] = {
 	/*
 	 * TODO:
 	 * ATMEL
-	 * EON
 	 * GIGADEVICE
 	 * MACRONIX
 	 * RAMTRON
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 05/36] sf: probe: Add support for GD25* flash parts
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (3 preceding siblings ...)
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 04/36] sf: probe: Add support for EN25Q* " Jagannadha Sutradharudu Teki
@ 2013-09-24 18:19 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 06/36] sf: probe: Add support for MX25L* " Jagannadha Sutradharudu Teki
                   ` (30 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:19 UTC (permalink / raw)
  To: u-boot

Added GD25* parts are which are avilable in spi_flash_probe_legacy.c.

Updated the sector_size attributes as per the flash parts.
Looks fine for with this sector_size for computing the size
of flash.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - Enable CONFIG_SPI_FLASH_GIGADEVICE

 drivers/mtd/spi/spi_flash_probe.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index 12baf41..dcb6929 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -40,6 +40,10 @@ static const struct spi_flash_params spi_flash_params_table[] = {
 	{"EN25Q32B",		0x1c3016, 0x0,	   64 * 1024,	  64},
 	{"EN25Q128B",		0x1c3018, 0x0,     64 * 1024,	 256},
 #endif
+#ifdef CONFIG_SPI_FLASH_GIGADEVICE	/* GIGADEVICE */
+	{"GD25Q64B",		0xc84017, 0x0,	   64 * 1024,	 128},
+	{"GD25LQ32",		0xc86016, 0x0,	   64 * 1024,	  64},
+#endif
 #ifdef CONFIG_SPI_FLASH_STMICRO		/* STMICRO */
 	{"M25P10",		0x202011, 0x0,     32 * 1024,	   4},
 	{"M25P20",		0x202012, 0x0,     64 * 1024,	   4},
@@ -65,7 +69,6 @@ static const struct spi_flash_params spi_flash_params_table[] = {
 	/*
 	 * TODO:
 	 * ATMEL
-	 * GIGADEVICE
 	 * MACRONIX
 	 * RAMTRON
 	 * SPANSION
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 06/36] sf: probe: Add support for MX25L* flash parts
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (4 preceding siblings ...)
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 05/36] sf: probe: Add support for GD25* " Jagannadha Sutradharudu Teki
@ 2013-09-24 18:19 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 07/36] sf: probe: Add support for W25* " Jagannadha Sutradharudu Teki
                   ` (29 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:19 UTC (permalink / raw)
  To: u-boot

Added MX25L* parts are which are avilable in spi_flash_probe_legacy.c.

Updated the sector_size attributes as per the flash parts.
Looks fine for with this sector_size for computing the size
of flash.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - Enable CONFIG_SPI_FLASH_MACRONIX

 drivers/mtd/spi/spi_flash_probe.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index dcb6929..af38da1 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -44,6 +44,15 @@ static const struct spi_flash_params spi_flash_params_table[] = {
 	{"GD25Q64B",		0xc84017, 0x0,	   64 * 1024,	 128},
 	{"GD25LQ32",		0xc86016, 0x0,	   64 * 1024,	  64},
 #endif
+#ifdef CONFIG_SPI_FLASH_MACRONIX	/* MACRONIX */
+	{"MX25L4005",		0xc22013, 0x0,	   64 * 1024,	   8},
+	{"MX25L8005",		0xc22014, 0x0,	   64 * 1024,	  16},
+	{"MX25L1605D",		0xc22015, 0x0,	   64 * 1024,	  32},
+	{"MX25L3205D",		0xc22016, 0x0,	   64 * 1024,	  64},
+	{"MX25L6405D",		0xc22017, 0x0,	   64 * 1024,	 128},
+	{"MX25L12805",		0xc22018, 0x0,	   64 * 1024,	 256},
+	{"MX25L12855E",		0xc22618, 0x0,	   64 * 1024,	 256},
+#endif
 #ifdef CONFIG_SPI_FLASH_STMICRO		/* STMICRO */
 	{"M25P10",		0x202011, 0x0,     32 * 1024,	   4},
 	{"M25P20",		0x202012, 0x0,     64 * 1024,	   4},
@@ -69,7 +78,6 @@ static const struct spi_flash_params spi_flash_params_table[] = {
 	/*
 	 * TODO:
 	 * ATMEL
-	 * MACRONIX
 	 * RAMTRON
 	 * SPANSION
 	 * SST
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 07/36] sf: probe: Add support for W25* flash parts
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (5 preceding siblings ...)
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 06/36] sf: probe: Add support for MX25L* " Jagannadha Sutradharudu Teki
@ 2013-09-24 18:19 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:19 ` [U-Boot] [PATCH v4] sf: probe: Add support for S25FL* " Jagannadha Sutradharudu Teki
                   ` (28 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:19 UTC (permalink / raw)
  To: u-boot

Added W25* parts are which are avilable in spi_flash_probe_legacy.c.

Updated the sector_size attributes as per the flash parts.
Looks fine for with this sector_size for computing the size
of flash.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - Correct the sector sizes
Changes for v3:
        - none
Changes for v2:
        - Enable CONFIG_SPI_FLASH_WINBOND

 drivers/mtd/spi/spi_flash_probe.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index af38da1..a8ce358 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -75,13 +75,44 @@ static const struct spi_flash_params spi_flash_params_table[] = {
 	{"N25Q1024",		0x20ba21, 0x0,     64 * 1024,	2048},
 	{"N25Q1024A",		0x20bb21, 0x0,     64 * 1024,	2048},
 #endif
+#ifdef CONFIG_SPI_FLASH_WINBOND		/* WINBOND */
+	{"W25P80",		0xef2014, 0x0,	   64 * 1024,	  16},
+	{"W25P16",		0xef2015, 0x0,	   64 * 1024,	  32},
+	{"W25P32",		0xef2016, 0x0,	   64 * 1024,	  64},
+	{"W25X40",		0xef3013, 0x0,	    4 * 1024,	 128},
+	{"W25X16",		0xef3015, 0x0,	    4 * 1024,	 512},
+	{"W25X32",		0xef3016, 0x0,	    4 * 1024,	1024},
+	{"W25X64",		0xef3017, 0x0,	    4 * 1024,	2048},
+	{"W25Q80BL",		0xef4014, 0x0,	    4 * 1024,	 256},
+	{"W25Q16CL",		0xef4015, 0x0,	    4 * 1024,	 512},
+	{"W25Q32BV",		0xef4016, 0x0,	    4 * 1024,	1024},
+	{"W25Q64CV",		0xef4017, 0x0,	    4 * 1024,	2048},
+	{"W25Q128BV",		0xef4018, 0x0,	    4 * 1024,	4096},
+	{"W25Q256",		0xef4019, 0x0,	    4 * 1024,	8192},
+	{"W25Q80BW",		0xef5014, 0x0,	    4 * 1024,	 256},
+	{"W25Q16DW",		0xef6015, 0x0,	    4 * 1024,	 512},
+	{"W25Q32DW",		0xef6016, 0x0,	    4 * 1024,	1024},
+	{"W25Q64DW",		0xef6017, 0x0,	    4 * 1024,	2048},
+	{"W25Q128FW",		0xef6018, 0x0,	    4 * 1024,	4096},
+#endif
+	/*
+	 * Note:
+	 * Below paired flash devices has similar spi_flash_params params.
+	 * (W25Q80BL, W25Q80BV)
+	 * (W25Q16CL, W25Q16DV)
+	 * (W25Q32BV, W25Q32FV_SPI)
+	 * (W25Q64CV, W25Q64FV_SPI)
+	 * (W25Q128BV, W25Q128FV_SPI)
+	 * (W25Q32DW, W25Q32FV_QPI)
+	 * (W25Q64DW, W25Q64FV_QPI)
+	 * (W25Q128FW, W25Q128FV_QPI)
+	 */
 	/*
 	 * TODO:
 	 * ATMEL
 	 * RAMTRON
 	 * SPANSION
 	 * SST
-	 * WINBOND
 	 */
 };
 
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4] sf: probe: Add support for S25FL* flash parts
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (6 preceding siblings ...)
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 07/36] sf: probe: Add support for W25* " Jagannadha Sutradharudu Teki
@ 2013-09-24 18:19 ` Jagannadha Sutradharudu Teki
  2013-09-26 23:16   ` Simon Glass
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 09/36] sf: probe: Add support for SST25* " Jagannadha Sutradharudu Teki
                   ` (27 subsequent siblings)
  35 siblings, 1 reply; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:19 UTC (permalink / raw)
  To: u-boot

Added S25FL* parts are which are avilable in spi_flash_probe_legacy.c.

Updated the sector_size attributes as per the flash parts.
Looks fine for with this sector_size for computing the size
of flash.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - Update the ext_jedec detection
Changes for v3:
        - none
Changes for v2:
        - Enable CONFIG_SPI_FLASH_SPANSION

 drivers/mtd/spi/spi_flash_probe.c |   31 +-
 dump                              | 1182 +++++++++++++++++++++++++++++++++++++
 2 files changed, 1207 insertions(+), 6 deletions(-)
 create mode 100644 dump

diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index a8ce358..283e3ea 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -53,6 +53,19 @@ static const struct spi_flash_params spi_flash_params_table[] = {
 	{"MX25L12805",		0xc22018, 0x0,	   64 * 1024,	 256},
 	{"MX25L12855E",		0xc22618, 0x0,	   64 * 1024,	 256},
 #endif
+#ifdef CONFIG_SPI_FLASH_SPANSION	/* SPANSION */
+	{"S25FL008A",		0x010213, 0x0,	   64 * 1024,	  16},
+	{"S25FL016A",		0x010214, 0x0,	   64 * 1024,	  32},
+	{"S25FL032A",		0x010215, 0x0,	   64 * 1024,	  64},
+	{"S25FL064A",		0x010216, 0x0,	   64 * 1024,	 128},
+	{"S25FL128P_256K",	0x012018, 0x0300, 256 * 1024,	  64},
+	{"S25FL128P_64K",	0x012018, 0x0301,  64 * 1024,	 256},
+	{"S25FL032P",		0x010215, 0x4d00,  64 * 1024,	  64},
+	{"S25FL064P",		0x010216, 0x4d00,  64 * 1024,	 128},
+	{"S25FL128S_64K",	0x012018, 0x4d01,  64 * 1024,	 256},
+	{"S25FL256S_64K",	0x010219, 0x4d01,  64 * 1024,	 512},
+	{"S25FL512S_64K",	0x010220, 0x4d01,  64 * 1024,	1024},
+#endif
 #ifdef CONFIG_SPI_FLASH_STMICRO		/* STMICRO */
 	{"M25P10",		0x202011, 0x0,     32 * 1024,	   4},
 	{"M25P20",		0x202012, 0x0,     64 * 1024,	   4},
@@ -98,6 +111,7 @@ static const struct spi_flash_params spi_flash_params_table[] = {
 	/*
 	 * Note:
 	 * Below paired flash devices has similar spi_flash_params params.
+	 * (S25FL129P_64K, S25FL128S_64K)
 	 * (W25Q80BL, W25Q80BV)
 	 * (W25Q16CL, W25Q16DV)
 	 * (W25Q32BV, W25Q32FV_SPI)
@@ -111,7 +125,6 @@ static const struct spi_flash_params spi_flash_params_table[] = {
 	 * TODO:
 	 * ATMEL
 	 * RAMTRON
-	 * SPANSION
 	 * SST
 	 */
 };
@@ -122,19 +135,25 @@ struct spi_flash *spi_flash_validate_ids(struct spi_slave *spi, u8 *idcode)
 	struct spi_flash *flash;
 	int i;
 	u16 jedec = idcode[1] << 8 | idcode[2];
+	u16 ext_jedec = idcode[3] << 8 | idcode[4];
 
-	/* Get the flash id (jedec = manuf_id + dev_id) */
+	/* Get the flash id (jedec = manuf_id + dev_id, ext_jedec) */
 	for (i = 0; i < ARRAY_SIZE(spi_flash_params_table); i++) {
 		params = &spi_flash_params_table[i];
 		if ((params->jedec >> 16) == idcode[0]) {
-			if ((params->jedec & 0xFFFF) == jedec)
-				break;
+			if ((params->jedec & 0xFFFF) == jedec) {
+				if (params->ext_jedec == 0)
+					break;
+				else if (params->ext_jedec == ext_jedec)
+					break;
+			}
 		}
 	}
 
 	if (i == ARRAY_SIZE(spi_flash_params_table)) {
-		printf("SF: Unsupported flash ID: manuf %02x, jedec %04x\n",
-		       idcode[0], jedec);
+		printf("SF: Unsupported flash IDs: ");
+		printf("manuf %02x, jedec %04x, ext_jedec %04x\n",
+		       idcode[0], jedec, ext_jedec);
 		return NULL;
 	}
 
diff --git a/dump b/dump
new file mode 100644
index 0000000..fb4ac4f
--- /dev/null
+++ b/dump
@@ -0,0 +1,1182 @@
+WARNING: line over 80 characters
+#872: FILE: drivers/mtd/spi/spi_flash_ops.c:228:
++		debug("PP: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x } chunk_len = %zu\n",
+
+total: 0 errors, 1 warnings, 0 checks, 1190 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0001-sf-Divide-spi_flash-into-multiple-parts.patch has style problems, please review.
+
+If any of these errors are false positives, please report
+them to the maintainer, see CHECKPATCH in MAINTAINERS.
+total: 0 errors, 0 warnings, 0 checks, 575 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0002-sf-probe-Add-new-spi_flash_probe-support.patch has no obvious style problems and is ready for submission.
+total: 0 errors, 0 warnings, 0 checks, 21 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0003-sf-probe-Add-support-for-M25P-flash-parts.patch has no obvious style problems and is ready for submission.
+total: 0 errors, 0 warnings, 0 checks, 17 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0004-sf-probe-Add-support-for-EN25Q-flash-parts.patch has no obvious style problems and is ready for submission.
+total: 0 errors, 0 warnings, 0 checks, 17 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0005-sf-probe-Add-support-for-GD25-flash-parts.patch has no obvious style problems and is ready for submission.
+total: 0 errors, 0 warnings, 0 checks, 22 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0006-sf-probe-Add-support-for-MX25L-flash-parts.patch has no obvious style problems and is ready for submission.
+total: 0 errors, 0 warnings, 0 checks, 45 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0007-sf-probe-Add-support-for-W25-flash-parts.patch has no obvious style problems and is ready for submission.
+total: 0 errors, 0 warnings, 0 checks, 62 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0008-sf-probe-Add-support-for-S25FL-flash-parts.patch has no obvious style problems and is ready for submission.
+total: 0 errors, 0 warnings, 0 checks, 25 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0009-sf-probe-Add-support-for-SST25-flash-parts.patch has no obvious style problems and is ready for submission.
+total: 0 errors, 0 warnings, 0 checks, 22 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0010-sf-probe-Add-support-for-AT45DB-flash-parts.patch has no obvious style problems and is ready for submission.
+total: 0 errors, 0 warnings, 0 checks, 174 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0011-sf-probe-Give-proper-spacing-on-flash-table-params.patch has no obvious style problems and is ready for submission.
+total: 0 errors, 0 warnings, 0 checks, 316 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0012-sf-probe-Add-support-for-SST_WP.patch has no obvious style problems and is ready for submission.
+total: 0 errors, 0 warnings, 0 checks, 23 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0013-sf-probe-Add-support-to-clear-flash-BP-bits.patch has no obvious style problems and is ready for submission.
+WARNING: line over 80 characters
+#56: FILE: drivers/mtd/spi/spi_flash_probe.c:42:
++	{"AT45DB011D",	   0x1f2200, 0x0,	64 * 1024,     4,	       SECT_4K},
+
+WARNING: line over 80 characters
+#57: FILE: drivers/mtd/spi/spi_flash_probe.c:43:
++	{"AT45DB021D",	   0x1f2300, 0x0,	64 * 1024,     8,	       SECT_4K},
+
+WARNING: line over 80 characters
+#58: FILE: drivers/mtd/spi/spi_flash_probe.c:44:
++	{"AT45DB041D",	   0x1f2400, 0x0,	64 * 1024,     8,	       SECT_4K},
+
+WARNING: line over 80 characters
+#59: FILE: drivers/mtd/spi/spi_flash_probe.c:45:
++	{"AT45DB081D",	   0x1f2500, 0x0,	64 * 1024,    16,	       SECT_4K},
+
+WARNING: line over 80 characters
+#60: FILE: drivers/mtd/spi/spi_flash_probe.c:46:
++	{"AT45DB161D",	   0x1f2600, 0x0,	64 * 1024,    32,	       SECT_4K},
+
+WARNING: line over 80 characters
+#61: FILE: drivers/mtd/spi/spi_flash_probe.c:47:
++	{"AT45DB321D",	   0x1f2700, 0x0,	64 * 1024,    64,	       SECT_4K},
+
+WARNING: line over 80 characters
+#62: FILE: drivers/mtd/spi/spi_flash_probe.c:48:
++	{"AT45DB641D",	   0x1f2800, 0x0,	64 * 1024,   128,	       SECT_4K},
+
+WARNING: line over 80 characters
+#67: FILE: drivers/mtd/spi/spi_flash_probe.c:51:
++	{"EN25Q32B",	   0x1c3016, 0x0,	64 * 1024,    64,	             0},
+
+WARNING: line over 80 characters
+#68: FILE: drivers/mtd/spi/spi_flash_probe.c:52:
++	{"EN25Q128B",	   0x1c3018, 0x0,       64 * 1024,   256,	             0},
+
+WARNING: line over 80 characters
+#73: FILE: drivers/mtd/spi/spi_flash_probe.c:55:
++	{"GD25Q64B",	   0xc84017, 0x0,	64 * 1024,   128,	       SECT_4K},
+
+WARNING: line over 80 characters
+#74: FILE: drivers/mtd/spi/spi_flash_probe.c:56:
++	{"GD25LQ32",	   0xc86016, 0x0,	64 * 1024,    64,	       SECT_4K},
+
+WARNING: line over 80 characters
+#84: FILE: drivers/mtd/spi/spi_flash_probe.c:59:
++	{"MX25L4005",	   0xc22013, 0x0,	64 * 1024,     8,	             0},
+
+WARNING: line over 80 characters
+#85: FILE: drivers/mtd/spi/spi_flash_probe.c:60:
++	{"MX25L8005",	   0xc22014, 0x0,	64 * 1024,    16,	             0},
+
+WARNING: line over 80 characters
+#86: FILE: drivers/mtd/spi/spi_flash_probe.c:61:
++	{"MX25L1605D",	   0xc22015, 0x0,	64 * 1024,    32,	             0},
+
+WARNING: line over 80 characters
+#87: FILE: drivers/mtd/spi/spi_flash_probe.c:62:
++	{"MX25L3205D",	   0xc22016, 0x0,	64 * 1024,    64,	             0},
+
+WARNING: line over 80 characters
+#88: FILE: drivers/mtd/spi/spi_flash_probe.c:63:
++	{"MX25L6405D",	   0xc22017, 0x0,	64 * 1024,   128,	             0},
+
+WARNING: line over 80 characters
+#89: FILE: drivers/mtd/spi/spi_flash_probe.c:64:
++	{"MX25L12805",	   0xc22018, 0x0,	64 * 1024,   256,	             0},
+
+WARNING: line over 80 characters
+#90: FILE: drivers/mtd/spi/spi_flash_probe.c:65:
++	{"MX25L12855E",	   0xc22618, 0x0,	64 * 1024,   256,	             0},
+
+WARNING: line over 80 characters
+#104: FILE: drivers/mtd/spi/spi_flash_probe.c:68:
++	{"S25FL008A",	   0x010213, 0x0,	64 * 1024,    16,	             0},
+
+WARNING: line over 80 characters
+#105: FILE: drivers/mtd/spi/spi_flash_probe.c:69:
++	{"S25FL016A",	   0x010214, 0x0,	64 * 1024,    32,	             0},
+
+WARNING: line over 80 characters
+#106: FILE: drivers/mtd/spi/spi_flash_probe.c:70:
++	{"S25FL032A",	   0x010215, 0x0,	64 * 1024,    64,	             0},
+
+WARNING: line over 80 characters
+#107: FILE: drivers/mtd/spi/spi_flash_probe.c:71:
++	{"S25FL064A",	   0x010216, 0x0,	64 * 1024,   128,	             0},
+
+WARNING: line over 80 characters
+#108: FILE: drivers/mtd/spi/spi_flash_probe.c:72:
++	{"S25FL128P_256K", 0x012018, 0x0300,   256 * 1024,    64,	             0},
+
+WARNING: line over 80 characters
+#109: FILE: drivers/mtd/spi/spi_flash_probe.c:73:
++	{"S25FL128P_64K",  0x012018, 0x0301,    64 * 1024,   256,	             0},
+
+WARNING: line over 80 characters
+#110: FILE: drivers/mtd/spi/spi_flash_probe.c:74:
++	{"S25FL032P",	   0x010215, 0x4d00,    64 * 1024,    64,	             0},
+
+WARNING: line over 80 characters
+#111: FILE: drivers/mtd/spi/spi_flash_probe.c:75:
++	{"S25FL064P",	   0x010216, 0x4d00,    64 * 1024,   128,	             0},
+
+WARNING: line over 80 characters
+#112: FILE: drivers/mtd/spi/spi_flash_probe.c:76:
++	{"S25FL128S_64K",  0x012018, 0x4d01,    64 * 1024,   256,		     0},
+
+WARNING: line over 80 characters
+#113: FILE: drivers/mtd/spi/spi_flash_probe.c:77:
++	{"S25FL256S_64K",  0x010219, 0x4d01,    64 * 1024,   512,	             0},
+
+WARNING: line over 80 characters
+#114: FILE: drivers/mtd/spi/spi_flash_probe.c:78:
++	{"S25FL512S_64K",  0x010220, 0x4d01,    64 * 1024,  1024,	             0},
+
+WARNING: line over 80 characters
+#137: FILE: drivers/mtd/spi/spi_flash_probe.c:81:
++	{"M25P10",	   0x202011, 0x0,       32 * 1024,     4,	             0},
+
+WARNING: line over 80 characters
+#138: FILE: drivers/mtd/spi/spi_flash_probe.c:82:
++	{"M25P20",	   0x202012, 0x0,       64 * 1024,     4,	             0},
+
+WARNING: line over 80 characters
+#139: FILE: drivers/mtd/spi/spi_flash_probe.c:83:
++	{"M25P40",	   0x202013, 0x0,       64 * 1024,     8,	             0},
+
+WARNING: line over 80 characters
+#140: FILE: drivers/mtd/spi/spi_flash_probe.c:84:
++	{"M25P80",	   0x202014, 0x0,       64 * 1024,    16,	             0},
+
+WARNING: line over 80 characters
+#141: FILE: drivers/mtd/spi/spi_flash_probe.c:85:
++	{"M25P16",	   0x202015, 0x0,       64 * 1024,    32,	             0},
+
+WARNING: line over 80 characters
+#142: FILE: drivers/mtd/spi/spi_flash_probe.c:86:
++	{"M25P32",	   0x202016, 0x0,       64 * 1024,    64,	             0},
+
+WARNING: line over 80 characters
+#143: FILE: drivers/mtd/spi/spi_flash_probe.c:87:
++	{"M25P64",	   0x202017, 0x0,       64 * 1024,   128,	             0},
+
+WARNING: line over 80 characters
+#144: FILE: drivers/mtd/spi/spi_flash_probe.c:88:
++	{"M25P128",	   0x202018, 0x0,      256 * 1024,    64,	             0},
+
+WARNING: line over 80 characters
+#145: FILE: drivers/mtd/spi/spi_flash_probe.c:89:
++	{"N25Q32",	   0x20ba16, 0x0,       64 * 1024,    64,	       SECT_4K},
+
+WARNING: line over 80 characters
+#146: FILE: drivers/mtd/spi/spi_flash_probe.c:90:
++	{"N25Q32A",	   0x20bb16, 0x0,       64 * 1024,    64,	       SECT_4K},
+
+WARNING: line over 80 characters
+#147: FILE: drivers/mtd/spi/spi_flash_probe.c:91:
++	{"N25Q64",	   0x20ba17, 0x0,       64 * 1024,   128,	       SECT_4K},
+
+WARNING: line over 80 characters
+#148: FILE: drivers/mtd/spi/spi_flash_probe.c:92:
++	{"N25Q64A",	   0x20bb17, 0x0,       64 * 1024,   128,	       SECT_4K},
+
+WARNING: line over 80 characters
+#149: FILE: drivers/mtd/spi/spi_flash_probe.c:93:
++	{"N25Q128",	   0x20ba18, 0x0,       64 * 1024,   256,	       SECT_4K},
+
+WARNING: line over 80 characters
+#150: FILE: drivers/mtd/spi/spi_flash_probe.c:94:
++	{"N25Q128A",	   0x20bb18, 0x0,       64 * 1024,   256,	       SECT_4K},
+
+WARNING: line over 80 characters
+#151: FILE: drivers/mtd/spi/spi_flash_probe.c:95:
++	{"N25Q256",	   0x20ba19, 0x0,       64 * 1024,   512,	       SECT_4K},
+
+WARNING: line over 80 characters
+#152: FILE: drivers/mtd/spi/spi_flash_probe.c:96:
++	{"N25Q256A",	   0x20bb19, 0x0,       64 * 1024,   512,	       SECT_4K},
+
+WARNING: line over 80 characters
+#153: FILE: drivers/mtd/spi/spi_flash_probe.c:97:
++	{"N25Q512",	   0x20ba20, 0x0,       64 * 1024,  1024,	       SECT_4K},
+
+WARNING: line over 80 characters
+#154: FILE: drivers/mtd/spi/spi_flash_probe.c:98:
++	{"N25Q512A",	   0x20bb20, 0x0,       64 * 1024,  1024,	       SECT_4K},
+
+WARNING: line over 80 characters
+#155: FILE: drivers/mtd/spi/spi_flash_probe.c:99:
++	{"N25Q1024",	   0x20ba21, 0x0,       64 * 1024,  2048,	       SECT_4K},
+
+WARNING: line over 80 characters
+#156: FILE: drivers/mtd/spi/spi_flash_probe.c:100:
++	{"N25Q1024A",	   0x20bb21, 0x0,       64 * 1024,  2048,	       SECT_4K},
+
+WARNING: line over 80 characters
+#169: FILE: drivers/mtd/spi/spi_flash_probe.c:103:
++	{"SST25VF040B",	   0xbf258d, 0x0,	64 * 1024,     8,     SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#170: FILE: drivers/mtd/spi/spi_flash_probe.c:104:
++	{"SST25VF080B",	   0xbf258e, 0x0,	64 * 1024,    16,     SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#171: FILE: drivers/mtd/spi/spi_flash_probe.c:105:
++	{"SST25VF016B",	   0xbf2541, 0x0,	64 * 1024,    32,     SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#172: FILE: drivers/mtd/spi/spi_flash_probe.c:106:
++	{"SST25VF032B",	   0xbf254a, 0x0,	64 * 1024,    64,     SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#173: FILE: drivers/mtd/spi/spi_flash_probe.c:107:
++	{"SST25VF064C",	   0xbf254b, 0x0,	64 * 1024,   128,	       SECT_4K},
+
+WARNING: line over 80 characters
+#174: FILE: drivers/mtd/spi/spi_flash_probe.c:108:
++	{"SST25WF512",	   0xbf2501, 0x0,	64 * 1024,     1,     SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#175: FILE: drivers/mtd/spi/spi_flash_probe.c:109:
++	{"SST25WF010",	   0xbf2502, 0x0,	64 * 1024,     2,     SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#176: FILE: drivers/mtd/spi/spi_flash_probe.c:110:
++	{"SST25WF020",	   0xbf2503, 0x0,	64 * 1024,     4,     SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#177: FILE: drivers/mtd/spi/spi_flash_probe.c:111:
++	{"SST25WF040",	   0xbf2504, 0x0,	64 * 1024,     8,     SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#178: FILE: drivers/mtd/spi/spi_flash_probe.c:112:
++	{"SST25WF080",	   0xbf2505, 0x0,	64 * 1024,    16,     SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#199: FILE: drivers/mtd/spi/spi_flash_probe.c:115:
++	{"W25P80",	   0xef2014, 0x0,	64 * 1024,    16,		     0},
+
+WARNING: line over 80 characters
+#200: FILE: drivers/mtd/spi/spi_flash_probe.c:116:
++	{"W25P16",	   0xef2015, 0x0,	64 * 1024,    32,		     0},
+
+WARNING: line over 80 characters
+#201: FILE: drivers/mtd/spi/spi_flash_probe.c:117:
++	{"W25P32",	   0xef2016, 0x0,	64 * 1024,    64,		     0},
+
+WARNING: line over 80 characters
+#202: FILE: drivers/mtd/spi/spi_flash_probe.c:118:
++	{"W25X40",	   0xef3013, 0x0,	 4 * 1024,   128,	       SECT_4K},
+
+WARNING: line over 80 characters
+#203: FILE: drivers/mtd/spi/spi_flash_probe.c:119:
++	{"W25X16",	   0xef3015, 0x0,	 4 * 1024,   512,	       SECT_4K},
+
+WARNING: line over 80 characters
+#204: FILE: drivers/mtd/spi/spi_flash_probe.c:120:
++	{"W25X32",	   0xef3016, 0x0,	 4 * 1024,  1024,	       SECT_4K},
+
+WARNING: line over 80 characters
+#205: FILE: drivers/mtd/spi/spi_flash_probe.c:121:
++	{"W25X64",	   0xef3017, 0x0,	 4 * 1024,  2048,	       SECT_4K},
+
+WARNING: line over 80 characters
+#206: FILE: drivers/mtd/spi/spi_flash_probe.c:122:
++	{"W25Q80BL",	   0xef4014, 0x0,	 4 * 1024,   256,	       SECT_4K},
+
+WARNING: line over 80 characters
+#207: FILE: drivers/mtd/spi/spi_flash_probe.c:123:
++	{"W25Q16CL",	   0xef4015, 0x0,	 4 * 1024,   512,	       SECT_4K},
+
+WARNING: line over 80 characters
+#208: FILE: drivers/mtd/spi/spi_flash_probe.c:124:
++	{"W25Q32BV",	   0xef4016, 0x0,	 4 * 1024,  1024,	       SECT_4K},
+
+WARNING: line over 80 characters
+#209: FILE: drivers/mtd/spi/spi_flash_probe.c:125:
++	{"W25Q64CV",	   0xef4017, 0x0,	 4 * 1024,  2048,	       SECT_4K},
+
+WARNING: line over 80 characters
+#210: FILE: drivers/mtd/spi/spi_flash_probe.c:126:
++	{"W25Q128BV",	   0xef4018, 0x0,	 4 * 1024,  4096,	       SECT_4K},
+
+WARNING: line over 80 characters
+#211: FILE: drivers/mtd/spi/spi_flash_probe.c:127:
++	{"W25Q256",	   0xef4019, 0x0,	 4 * 1024,  8192,	       SECT_4K},
+
+WARNING: line over 80 characters
+#212: FILE: drivers/mtd/spi/spi_flash_probe.c:128:
++	{"W25Q80BW",	   0xef5014, 0x0,	 4 * 1024,   256,	       SECT_4K},
+
+WARNING: line over 80 characters
+#213: FILE: drivers/mtd/spi/spi_flash_probe.c:129:
++	{"W25Q16DW",	   0xef6015, 0x0,	 4 * 1024,   512,	       SECT_4K},
+
+WARNING: line over 80 characters
+#214: FILE: drivers/mtd/spi/spi_flash_probe.c:130:
++	{"W25Q32DW",	   0xef6016, 0x0,	 4 * 1024,  1024,	       SECT_4K},
+
+WARNING: line over 80 characters
+#215: FILE: drivers/mtd/spi/spi_flash_probe.c:131:
++	{"W25Q64DW",	   0xef6017, 0x0,	 4 * 1024,  2048,	       SECT_4K},
+
+WARNING: line over 80 characters
+#216: FILE: drivers/mtd/spi/spi_flash_probe.c:132:
++	{"W25Q128FW",	   0xef6018, 0x0,	 4 * 1024,  4096,	       SECT_4K},
+
+total: 0 errors, 77 warnings, 0 checks, 240 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0014-sf-probe-Add-support-for-erase-sector-selection-flag.patch has style problems, please review.
+
+If any of these errors are false positives, please report
+them to the maintainer, see CHECKPATCH in MAINTAINERS.
+WARNING: line over 80 characters
+#28: FILE: drivers/mtd/spi/spi_flash_probe.c:97:
++	{"N25Q512",	   0x20ba20, 0x0,       64 * 1024,  1024,      E_FSR | SECT_4K},
+
+WARNING: line over 80 characters
+#29: FILE: drivers/mtd/spi/spi_flash_probe.c:98:
++	{"N25Q512A",	   0x20bb20, 0x0,       64 * 1024,  1024,      E_FSR | SECT_4K},
+
+WARNING: line over 80 characters
+#30: FILE: drivers/mtd/spi/spi_flash_probe.c:99:
++	{"N25Q1024",	   0x20ba21, 0x0,       64 * 1024,  2048,      E_FSR | SECT_4K},
+
+WARNING: line over 80 characters
+#31: FILE: drivers/mtd/spi/spi_flash_probe.c:100:
++	{"N25Q1024A",	   0x20bb21, 0x0,       64 * 1024,  2048,      E_FSR | SECT_4K},
+
+total: 0 errors, 4 warnings, 0 checks, 39 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0015-sf-probe-Add-support-for-flag-status-polling.patch has style problems, please review.
+
+If any of these errors are false positives, please report
+them to the maintainer, see CHECKPATCH in MAINTAINERS.
+total: 0 errors, 0 warnings, 0 checks, 75 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0016-sf-probe-Move-BAR-config-to-spi_flash_validate_ids.patch has no obvious style problems and is ready for submission.
+total: 0 errors, 0 warnings, 0 checks, 74 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0017-sf-Add-proper-comment-style-on-spi_flash-structure.patch has no obvious style problems and is ready for submission.
+total: 0 errors, 0 warnings, 0 checks, 166 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0018-sf-ramtron-Add-support-for-separate-flash-driver.patch has no obvious style problems and is ready for submission.
+total: 0 errors, 0 warnings, 0 checks, 17 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0019-sf-Remove-unneeded-flash-drivers-files.patch has no obvious style problems and is ready for submission.
+WARNING: line over 80 characters
+#21: FILE: drivers/mtd/spi/spi_flash_probe.c:52:
++	{"EN25Q64",	   0x1c3017, 0x0,	64 * 1024,   128,	       SECT_4K},
+
+total: 0 errors, 1 warnings, 0 checks, 7 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0020-sf-probe-Add-support-for-EN25Q64.patch has style problems, please review.
+
+If any of these errors are false positives, please report
+them to the maintainer, see CHECKPATCH in MAINTAINERS.
+WARNING: line over 80 characters
+#21: FILE: drivers/mtd/spi/spi_flash_probe.c:78:
++	{"S25FL256S_256K", 0x010219, 0x4d00,    64 * 1024,   512,	             0},
+
+total: 0 errors, 1 warnings, 0 checks, 15 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0021-sf-probe-Add-support-for-S25FL256S_256K.patch has style problems, please review.
+
+If any of these errors are false positives, please report
+them to the maintainer, see CHECKPATCH in MAINTAINERS.
+WARNING: line over 80 characters
+#21: FILE: drivers/mtd/spi/spi_flash_probe.c:80:
++	{"S25FL512S_256K", 0x010220, 0x4d00,    64 * 1024,  1024,	             0},
+
+total: 0 errors, 1 warnings, 0 checks, 7 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0022-sf-probe-Add-support-for-S25FL512S_256K.patch has style problems, please review.
+
+If any of these errors are false positives, please report
+them to the maintainer, see CHECKPATCH in MAINTAINERS.
+total: 0 errors, 0 warnings, 0 checks, 8 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0023-sf-probe-Use-print_size-arg-as-page_size.patch has no obvious style problems and is ready for submission.
+total: 0 errors, 0 warnings, 0 checks, 9 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0024-sf-probe-Print-erase_size-while-printing-flash-detai.patch has no obvious style problems and is ready for submission.
+total: 0 errors, 0 warnings, 0 checks, 91 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0025-sf-probe-Simply-the-BAR-configuration-logic.patch has no obvious style problems and is ready for submission.
+total: 0 errors, 0 warnings, 0 checks, 19 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0026-sf-ops-Add-static-qualifier-to-spi_flash_cmd_bankadd.patch has no obvious style problems and is ready for submission.
+WARNING: line over 80 characters
+#21: FILE: drivers/mtd/spi/spi_flash_probe.c:66:
++	{"MX25L25635F",	   0xc22019, 0x0,	64 * 1024,   512,	             0},
+
+total: 0 errors, 1 warnings, 0 checks, 7 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0027-sf-probe-Add-support-for-MX25L25635F.patch has style problems, please review.
+
+If any of these errors are false positives, please report
+them to the maintainer, see CHECKPATCH in MAINTAINERS.
+WARNING: line over 80 characters
+#21: FILE: drivers/mtd/spi/spi_flash_probe.c:67:
++	{"MX25L51235F",	   0xc2201A, 0x0,	64 * 1024,  1024,	             0},
+
+total: 0 errors, 1 warnings, 0 checks, 7 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0028-sf-probe-Add-support-for-MX25L51235F.patch has style problems, please review.
+
+If any of these errors are false positives, please report
+them to the maintainer, see CHECKPATCH in MAINTAINERS.
+total: 0 errors, 0 warnings, 0 checks, 44 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0029-sf-Remove-spi_flash_do_alloc-references.patch has no obvious style problems and is ready for submission.
+total: 0 errors, 0 warnings, 0 checks, 27 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0030-doc-SPI-Add-status.txt-for-tracking-SPI-subsys-statu.patch has no obvious style problems and is ready for submission.
+WARNING: line over 80 characters
+#97: FILE: drivers/mtd/spi/spi_flash_probe.c:51:
++	{"AT45DB011D",	   0x1f2200, 0x0,	64 * 1024,     4,	    0,		SECT_4K},
+
+WARNING: line over 80 characters
+#98: FILE: drivers/mtd/spi/spi_flash_probe.c:52:
++	{"AT45DB021D",	   0x1f2300, 0x0,	64 * 1024,     8,	    0,		SECT_4K},
+
+WARNING: line over 80 characters
+#99: FILE: drivers/mtd/spi/spi_flash_probe.c:53:
++	{"AT45DB041D",	   0x1f2400, 0x0,	64 * 1024,     8,	    0,		SECT_4K},
+
+WARNING: line over 80 characters
+#100: FILE: drivers/mtd/spi/spi_flash_probe.c:54:
++	{"AT45DB081D",	   0x1f2500, 0x0,	64 * 1024,    16,	    0,		SECT_4K},
+
+WARNING: line over 80 characters
+#101: FILE: drivers/mtd/spi/spi_flash_probe.c:55:
++	{"AT45DB161D",	   0x1f2600, 0x0,	64 * 1024,    32,	    0,		SECT_4K},
+
+WARNING: line over 80 characters
+#102: FILE: drivers/mtd/spi/spi_flash_probe.c:56:
++	{"AT45DB321D",	   0x1f2700, 0x0,	64 * 1024,    64,	    0,		SECT_4K},
+
+WARNING: line over 80 characters
+#103: FILE: drivers/mtd/spi/spi_flash_probe.c:57:
++	{"AT45DB641D",	   0x1f2800, 0x0,	64 * 1024,   128,	    0,		SECT_4K},
+
+WARNING: line over 80 characters
+#109: FILE: drivers/mtd/spi/spi_flash_probe.c:60:
++	{"EN25Q32B",	   0x1c3016, 0x0,	64 * 1024,    64,	    0,		      0},
+
+WARNING: line over 80 characters
+#110: FILE: drivers/mtd/spi/spi_flash_probe.c:61:
++	{"EN25Q64",	   0x1c3017, 0x0,	64 * 1024,   128,	    0,		SECT_4K},
+
+WARNING: line over 80 characters
+#111: FILE: drivers/mtd/spi/spi_flash_probe.c:62:
++	{"EN25Q128B",	   0x1c3018, 0x0,       64 * 1024,   256,	    0,		      0},
+
+WARNING: line over 80 characters
+#116: FILE: drivers/mtd/spi/spi_flash_probe.c:65:
++	{"GD25Q64B",	   0xc84017, 0x0,	64 * 1024,   128,	    0,		SECT_4K},
+
+WARNING: line over 80 characters
+#117: FILE: drivers/mtd/spi/spi_flash_probe.c:66:
++	{"GD25LQ32",	   0xc86016, 0x0,	64 * 1024,    64,	    0,		SECT_4K},
+
+WARNING: line over 80 characters
+#129: FILE: drivers/mtd/spi/spi_flash_probe.c:69:
++	{"MX25L4005",	   0xc22013, 0x0,	64 * 1024,     8,	    0,		      0},
+
+WARNING: line over 80 characters
+#130: FILE: drivers/mtd/spi/spi_flash_probe.c:70:
++	{"MX25L8005",	   0xc22014, 0x0,	64 * 1024,    16,	    0,		      0},
+
+WARNING: line over 80 characters
+#131: FILE: drivers/mtd/spi/spi_flash_probe.c:71:
++	{"MX25L1605D",	   0xc22015, 0x0,	64 * 1024,    32,	    0,		      0},
+
+WARNING: line over 80 characters
+#132: FILE: drivers/mtd/spi/spi_flash_probe.c:72:
++	{"MX25L3205D",	   0xc22016, 0x0,	64 * 1024,    64,	    0,		      0},
+
+WARNING: line over 80 characters
+#133: FILE: drivers/mtd/spi/spi_flash_probe.c:73:
++	{"MX25L6405D",	   0xc22017, 0x0,	64 * 1024,   128,	    0,		      0},
+
+WARNING: line over 80 characters
+#134: FILE: drivers/mtd/spi/spi_flash_probe.c:74:
++	{"MX25L12805",	   0xc22018, 0x0,	64 * 1024,   256,	    0,		      0},
+
+WARNING: line over 80 characters
+#135: FILE: drivers/mtd/spi/spi_flash_probe.c:75:
++	{"MX25L12855E",	   0xc22618, 0x0,	64 * 1024,   256,	    0,		      0},
+
+WARNING: line over 80 characters
+#151: FILE: drivers/mtd/spi/spi_flash_probe.c:78:
++	{"S25FL008A",	   0x010213, 0x0,	64 * 1024,    16,	    0,		      0},
+
+WARNING: line over 80 characters
+#152: FILE: drivers/mtd/spi/spi_flash_probe.c:79:
++	{"S25FL016A",	   0x010214, 0x0,	64 * 1024,    32,	    0,		      0},
+
+WARNING: line over 80 characters
+#153: FILE: drivers/mtd/spi/spi_flash_probe.c:80:
++	{"S25FL032A",	   0x010215, 0x0,	64 * 1024,    64,	    0,		      0},
+
+WARNING: line over 80 characters
+#154: FILE: drivers/mtd/spi/spi_flash_probe.c:81:
++	{"S25FL064A",	   0x010216, 0x0,	64 * 1024,   128,	    0,		      0},
+
+WARNING: line over 80 characters
+#155: FILE: drivers/mtd/spi/spi_flash_probe.c:82:
++	{"S25FL128P_256K", 0x012018, 0x0300,   256 * 1024,    64, RD_CMD_FULL,		      0},
+
+WARNING: line over 80 characters
+#156: FILE: drivers/mtd/spi/spi_flash_probe.c:83:
++	{"S25FL128P_64K",  0x012018, 0x0301,    64 * 1024,   256, RD_CMD_FULL,		      0},
+
+WARNING: line over 80 characters
+#157: FILE: drivers/mtd/spi/spi_flash_probe.c:84:
++	{"S25FL032P",	   0x010215, 0x4d00,    64 * 1024,    64, RD_CMD_FULL,		      0},
+
+WARNING: line over 80 characters
+#158: FILE: drivers/mtd/spi/spi_flash_probe.c:85:
++	{"S25FL064P",	   0x010216, 0x4d00,    64 * 1024,   128, RD_CMD_FULL,		      0},
+
+WARNING: line over 80 characters
+#159: FILE: drivers/mtd/spi/spi_flash_probe.c:86:
++	{"S25FL128S_64K",  0x012018, 0x4d01,    64 * 1024,   256, RD_CMD_FULL,		      0},
+
+WARNING: line over 80 characters
+#160: FILE: drivers/mtd/spi/spi_flash_probe.c:87:
++	{"S25FL256S_64K",  0x010219, 0x4d01,    64 * 1024,   512, RD_CMD_FULL,		      0},
+
+WARNING: line over 80 characters
+#161: FILE: drivers/mtd/spi/spi_flash_probe.c:88:
++	{"S25FL512S_64K",  0x010220, 0x4d01,    64 * 1024,  1024, RD_CMD_FULL,		      0},
+
+WARNING: line over 80 characters
+#184: FILE: drivers/mtd/spi/spi_flash_probe.c:91:
++	{"M25P10",	   0x202011, 0x0,       32 * 1024,     4,	    0,		      0},
+
+WARNING: line over 80 characters
+#185: FILE: drivers/mtd/spi/spi_flash_probe.c:92:
++	{"M25P20",	   0x202012, 0x0,       64 * 1024,     4,	    0,		      0},
+
+WARNING: line over 80 characters
+#186: FILE: drivers/mtd/spi/spi_flash_probe.c:93:
++	{"M25P40",	   0x202013, 0x0,       64 * 1024,     8,	    0,		      0},
+
+WARNING: line over 80 characters
+#187: FILE: drivers/mtd/spi/spi_flash_probe.c:94:
++	{"M25P80",	   0x202014, 0x0,       64 * 1024,    16,	    0,		      0},
+
+WARNING: line over 80 characters
+#188: FILE: drivers/mtd/spi/spi_flash_probe.c:95:
++	{"M25P16",	   0x202015, 0x0,       64 * 1024,    32,	    0,		      0},
+
+WARNING: line over 80 characters
+#189: FILE: drivers/mtd/spi/spi_flash_probe.c:96:
++	{"M25P32",	   0x202016, 0x0,       64 * 1024,    64,	    0,		      0},
+
+WARNING: line over 80 characters
+#190: FILE: drivers/mtd/spi/spi_flash_probe.c:97:
++	{"M25P64",	   0x202017, 0x0,       64 * 1024,   128,	    0,		      0},
+
+WARNING: line over 80 characters
+#191: FILE: drivers/mtd/spi/spi_flash_probe.c:98:
++	{"M25P128",	   0x202018, 0x0,      256 * 1024,    64,	    0,		      0},
+
+WARNING: line over 80 characters
+#192: FILE: drivers/mtd/spi/spi_flash_probe.c:99:
++	{"N25Q32",	   0x20ba16, 0x0,       64 * 1024,    64, RD_CMD_FULL,		SECT_4K},
+
+WARNING: line over 80 characters
+#193: FILE: drivers/mtd/spi/spi_flash_probe.c:100:
++	{"N25Q32A",	   0x20bb16, 0x0,       64 * 1024,    64, RD_CMD_FULL,		SECT_4K},
+
+WARNING: line over 80 characters
+#194: FILE: drivers/mtd/spi/spi_flash_probe.c:101:
++	{"N25Q64",	   0x20ba17, 0x0,       64 * 1024,   128, RD_CMD_FULL,		SECT_4K},
+
+WARNING: line over 80 characters
+#195: FILE: drivers/mtd/spi/spi_flash_probe.c:102:
++	{"N25Q64A",	   0x20bb17, 0x0,       64 * 1024,   128, RD_CMD_FULL,		SECT_4K},
+
+WARNING: line over 80 characters
+#196: FILE: drivers/mtd/spi/spi_flash_probe.c:103:
++	{"N25Q128",	   0x20ba18, 0x0,       64 * 1024,   256, RD_CMD_FULL,		SECT_4K},
+
+WARNING: line over 80 characters
+#197: FILE: drivers/mtd/spi/spi_flash_probe.c:104:
++	{"N25Q128A",	   0x20bb18, 0x0,       64 * 1024,   256, RD_CMD_FULL,		SECT_4K},
+
+WARNING: line over 80 characters
+#198: FILE: drivers/mtd/spi/spi_flash_probe.c:105:
++	{"N25Q256",	   0x20ba19, 0x0,       64 * 1024,   512, RD_CMD_FULL,		SECT_4K},
+
+WARNING: line over 80 characters
+#199: FILE: drivers/mtd/spi/spi_flash_probe.c:106:
++	{"N25Q256A",	   0x20bb19, 0x0,       64 * 1024,   512, RD_CMD_FULL,		SECT_4K},
+
+WARNING: line over 80 characters
+#200: FILE: drivers/mtd/spi/spi_flash_probe.c:107:
++	{"N25Q512",	   0x20ba20, 0x0,       64 * 1024,  1024, RD_CMD_FULL,	E_FSR | SECT_4K},
+
+WARNING: line over 80 characters
+#201: FILE: drivers/mtd/spi/spi_flash_probe.c:108:
++	{"N25Q512A",	   0x20bb20, 0x0,       64 * 1024,  1024, RD_CMD_FULL,	E_FSR | SECT_4K},
+
+WARNING: line over 80 characters
+#202: FILE: drivers/mtd/spi/spi_flash_probe.c:109:
++	{"N25Q1024",	   0x20ba21, 0x0,       64 * 1024,  2048, RD_CMD_FULL,	E_FSR | SECT_4K},
+
+WARNING: line over 80 characters
+#203: FILE: drivers/mtd/spi/spi_flash_probe.c:110:
++	{"N25Q1024A",	   0x20bb21, 0x0,       64 * 1024,  2048, RD_CMD_FULL,	E_FSR | SECT_4K},
+
+WARNING: line over 80 characters
+#216: FILE: drivers/mtd/spi/spi_flash_probe.c:113:
++	{"SST25VF040B",	   0xbf258d, 0x0,	64 * 1024,     8,	    0, SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#217: FILE: drivers/mtd/spi/spi_flash_probe.c:114:
++	{"SST25VF080B",	   0xbf258e, 0x0,	64 * 1024,    16,	    0, SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#218: FILE: drivers/mtd/spi/spi_flash_probe.c:115:
++	{"SST25VF016B",	   0xbf2541, 0x0,	64 * 1024,    32,	    0, SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#219: FILE: drivers/mtd/spi/spi_flash_probe.c:116:
++	{"SST25VF032B",	   0xbf254a, 0x0,	64 * 1024,    64,	    0, SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#220: FILE: drivers/mtd/spi/spi_flash_probe.c:117:
++	{"SST25VF064C",	   0xbf254b, 0x0,	64 * 1024,   128,	    0		SECT_4K},
+
+WARNING: line over 80 characters
+#221: FILE: drivers/mtd/spi/spi_flash_probe.c:118:
++	{"SST25WF512",	   0xbf2501, 0x0,	64 * 1024,     1,	    0, SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#222: FILE: drivers/mtd/spi/spi_flash_probe.c:119:
++	{"SST25WF010",	   0xbf2502, 0x0,	64 * 1024,     2,	    0, SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#223: FILE: drivers/mtd/spi/spi_flash_probe.c:120:
++	{"SST25WF020",	   0xbf2503, 0x0,	64 * 1024,     4,	    0, SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#224: FILE: drivers/mtd/spi/spi_flash_probe.c:121:
++	{"SST25WF040",	   0xbf2504, 0x0,	64 * 1024,     8,	    0, SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#225: FILE: drivers/mtd/spi/spi_flash_probe.c:122:
++	{"SST25WF080",	   0xbf2505, 0x0,	64 * 1024,    16,	    0, SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#246: FILE: drivers/mtd/spi/spi_flash_probe.c:125:
++	{"W25P80",	   0xef2014, 0x0,	64 * 1024,    16,	    0,		      0},
+
+WARNING: line over 80 characters
+#247: FILE: drivers/mtd/spi/spi_flash_probe.c:126:
++	{"W25P16",	   0xef2015, 0x0,	64 * 1024,    32,	    0,		      0},
+
+WARNING: line over 80 characters
+#248: FILE: drivers/mtd/spi/spi_flash_probe.c:127:
++	{"W25P32",	   0xef2016, 0x0,	64 * 1024,    64,	    0,		      0},
+
+WARNING: line over 80 characters
+#249: FILE: drivers/mtd/spi/spi_flash_probe.c:128:
++	{"W25X40",	   0xef3013, 0x0,	 4 * 1024,   128,	    0,		SECT_4K},
+
+WARNING: line over 80 characters
+#250: FILE: drivers/mtd/spi/spi_flash_probe.c:129:
++	{"W25X16",	   0xef3015, 0x0,	 4 * 1024,   512,	    0,		SECT_4K},
+
+WARNING: line over 80 characters
+#251: FILE: drivers/mtd/spi/spi_flash_probe.c:130:
++	{"W25X32",	   0xef3016, 0x0,	 4 * 1024,  1024,	    0,		SECT_4K},
+
+WARNING: line over 80 characters
+#252: FILE: drivers/mtd/spi/spi_flash_probe.c:131:
++	{"W25X64",	   0xef3017, 0x0,	 4 * 1024,  2048,	    0,		SECT_4K},
+
+WARNING: line over 80 characters
+#253: FILE: drivers/mtd/spi/spi_flash_probe.c:132:
++	{"W25Q80BL",	   0xef4014, 0x0,	 4 * 1024,   256, RD_CMD_FULL,		SECT_4K},
+
+WARNING: line over 80 characters
+#254: FILE: drivers/mtd/spi/spi_flash_probe.c:133:
++	{"W25Q16CL",	   0xef4015, 0x0,	 4 * 1024,   512, RD_CMD_FULL,		SECT_4K},
+
+WARNING: line over 80 characters
+#255: FILE: drivers/mtd/spi/spi_flash_probe.c:134:
++	{"W25Q32BV",	   0xef4016, 0x0,	 4 * 1024,  1024, RD_CMD_FULL,		SECT_4K},
+
+WARNING: line over 80 characters
+#256: FILE: drivers/mtd/spi/spi_flash_probe.c:135:
++	{"W25Q64CV",	   0xef4017, 0x0,	 4 * 1024,  2048, RD_CMD_FULL,		SECT_4K},
+
+WARNING: line over 80 characters
+#257: FILE: drivers/mtd/spi/spi_flash_probe.c:136:
++	{"W25Q128BV",	   0xef4018, 0x0,	 4 * 1024,  4096, RD_CMD_FULL,		SECT_4K},
+
+WARNING: line over 80 characters
+#258: FILE: drivers/mtd/spi/spi_flash_probe.c:137:
++	{"W25Q256",	   0xef4019, 0x0,	 4 * 1024,  8192, RD_CMD_FULL,		SECT_4K},
+
+WARNING: line over 80 characters
+#259: FILE: drivers/mtd/spi/spi_flash_probe.c:138:
++	{"W25Q80BW",	   0xef5014, 0x0,	 4 * 1024,   256, RD_CMD_FULL,		SECT_4K},
+
+WARNING: line over 80 characters
+#260: FILE: drivers/mtd/spi/spi_flash_probe.c:139:
++	{"W25Q16DW",	   0xef6015, 0x0,	 4 * 1024,   512, RD_CMD_FULL,		SECT_4K},
+
+WARNING: line over 80 characters
+#261: FILE: drivers/mtd/spi/spi_flash_probe.c:140:
++	{"W25Q32DW",	   0xef6016, 0x0,	 4 * 1024,  1024, RD_CMD_FULL,		SECT_4K},
+
+WARNING: line over 80 characters
+#262: FILE: drivers/mtd/spi/spi_flash_probe.c:141:
++	{"W25Q64DW",	   0xef6017, 0x0,	 4 * 1024,  2048, RD_CMD_FULL,		SECT_4K},
+
+WARNING: line over 80 characters
+#263: FILE: drivers/mtd/spi/spi_flash_probe.c:142:
++	{"W25Q128FW",	   0xef6018, 0x0,	 4 * 1024,  4096, RD_CMD_FULL,		SECT_4K},
+
+total: 0 errors, 78 warnings, 0 checks, 313 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0031-sf-Add-extended-read-commands-support.patch has style problems, please review.
+
+If any of these errors are false positives, please report
+them to the maintainer, see CHECKPATCH in MAINTAINERS.
+WARNING: line over 80 characters
+#98: FILE: drivers/mtd/spi/spi_flash_probe.c:59:
++	{"AT45DB011D",	   0x1f2200, 0x0,	64 * 1024,     4,	    0,		 0,	     SECT_4K},
+
+WARNING: line over 80 characters
+#99: FILE: drivers/mtd/spi/spi_flash_probe.c:60:
++	{"AT45DB021D",	   0x1f2300, 0x0,	64 * 1024,     8,	    0,		 0,	     SECT_4K},
+
+WARNING: line over 80 characters
+#100: FILE: drivers/mtd/spi/spi_flash_probe.c:61:
++	{"AT45DB041D",	   0x1f2400, 0x0,	64 * 1024,     8,	    0,		 0,	     SECT_4K},
+
+WARNING: line over 80 characters
+#101: FILE: drivers/mtd/spi/spi_flash_probe.c:62:
++	{"AT45DB081D",	   0x1f2500, 0x0,	64 * 1024,    16,	    0,		 0,	     SECT_4K},
+
+WARNING: line over 80 characters
+#102: FILE: drivers/mtd/spi/spi_flash_probe.c:63:
++	{"AT45DB161D",	   0x1f2600, 0x0,	64 * 1024,    32,	    0,		 0,	     SECT_4K},
+
+WARNING: line over 80 characters
+#103: FILE: drivers/mtd/spi/spi_flash_probe.c:64:
++	{"AT45DB321D",	   0x1f2700, 0x0,	64 * 1024,    64,	    0,		 0,	     SECT_4K},
+
+WARNING: line over 80 characters
+#104: FILE: drivers/mtd/spi/spi_flash_probe.c:65:
++	{"AT45DB641D",	   0x1f2800, 0x0,	64 * 1024,   128,	    0,		 0,	     SECT_4K},
+
+WARNING: line over 80 characters
+#110: FILE: drivers/mtd/spi/spi_flash_probe.c:68:
++	{"EN25Q32B",	   0x1c3016, 0x0,	64 * 1024,    64,	    0,		 0,		   0},
+
+WARNING: line over 80 characters
+#111: FILE: drivers/mtd/spi/spi_flash_probe.c:69:
++	{"EN25Q64",	   0x1c3017, 0x0,	64 * 1024,   128,	    0,		 0,	     SECT_4K},
+
+WARNING: line over 80 characters
+#112: FILE: drivers/mtd/spi/spi_flash_probe.c:70:
++	{"EN25Q128B",	   0x1c3018, 0x0,       64 * 1024,   256,	    0,		 0,		   0},
+
+WARNING: line over 80 characters
+#117: FILE: drivers/mtd/spi/spi_flash_probe.c:73:
++	{"GD25Q64B",	   0xc84017, 0x0,	64 * 1024,   128,	    0,		 0,	     SECT_4K},
+
+WARNING: line over 80 characters
+#118: FILE: drivers/mtd/spi/spi_flash_probe.c:74:
++	{"GD25LQ32",	   0xc86016, 0x0,	64 * 1024,    64,	    0,		 0,	     SECT_4K},
+
+WARNING: line over 80 characters
+#128: FILE: drivers/mtd/spi/spi_flash_probe.c:77:
++	{"MX25L4005",	   0xc22013, 0x0,	64 * 1024,     8,	    0,		 0,		   0},
+
+WARNING: line over 80 characters
+#129: FILE: drivers/mtd/spi/spi_flash_probe.c:78:
++	{"MX25L8005",	   0xc22014, 0x0,	64 * 1024,    16,	    0,		 0,		   0},
+
+WARNING: line over 80 characters
+#130: FILE: drivers/mtd/spi/spi_flash_probe.c:79:
++	{"MX25L1605D",	   0xc22015, 0x0,	64 * 1024,    32,	    0,		 0,		   0},
+
+WARNING: line over 80 characters
+#131: FILE: drivers/mtd/spi/spi_flash_probe.c:80:
++	{"MX25L3205D",	   0xc22016, 0x0,	64 * 1024,    64,	    0,		 0,		   0},
+
+WARNING: line over 80 characters
+#132: FILE: drivers/mtd/spi/spi_flash_probe.c:81:
++	{"MX25L6405D",	   0xc22017, 0x0,	64 * 1024,   128,	    0,		 0,		   0},
+
+WARNING: line over 80 characters
+#133: FILE: drivers/mtd/spi/spi_flash_probe.c:82:
++	{"MX25L12805",	   0xc22018, 0x0,	64 * 1024,   256,	    0,		 0,		   0},
+
+WARNING: line over 80 characters
+#134: FILE: drivers/mtd/spi/spi_flash_probe.c:83:
++	{"MX25L12855E",	   0xc22618, 0x0,	64 * 1024,   256,	    0,		 0,		   0},
+
+WARNING: line over 80 characters
+#148: FILE: drivers/mtd/spi/spi_flash_probe.c:86:
++	{"S25FL008A",	   0x010213, 0x0,	64 * 1024,    16,	    0,		 0,		   0},
+
+WARNING: line over 80 characters
+#149: FILE: drivers/mtd/spi/spi_flash_probe.c:87:
++	{"S25FL016A",	   0x010214, 0x0,	64 * 1024,    32,	    0,		 0,		   0},
+
+WARNING: line over 80 characters
+#150: FILE: drivers/mtd/spi/spi_flash_probe.c:88:
++	{"S25FL032A",	   0x010215, 0x0,	64 * 1024,    64,	    0,		 0,		   0},
+
+WARNING: line over 80 characters
+#151: FILE: drivers/mtd/spi/spi_flash_probe.c:89:
++	{"S25FL064A",	   0x010216, 0x0,	64 * 1024,   128,	    0,		 0,		   0},
+
+WARNING: line over 80 characters
+#152: FILE: drivers/mtd/spi/spi_flash_probe.c:90:
++	{"S25FL128P_256K", 0x012018, 0x0300,   256 * 1024,    64, RD_CMD_FULL, WR_CMD_FULL,		   0},
+
+WARNING: line over 80 characters
+#153: FILE: drivers/mtd/spi/spi_flash_probe.c:91:
++	{"S25FL128P_64K",  0x012018, 0x0301,    64 * 1024,   256, RD_CMD_FULL, WR_CMD_FULL,		   0},
+
+WARNING: line over 80 characters
+#154: FILE: drivers/mtd/spi/spi_flash_probe.c:92:
++	{"S25FL032P",	   0x010215, 0x4d00,    64 * 1024,    64, RD_CMD_FULL, WR_CMD_FULL,		   0},
+
+WARNING: line over 80 characters
+#155: FILE: drivers/mtd/spi/spi_flash_probe.c:93:
++	{"S25FL064P",	   0x010216, 0x4d00,    64 * 1024,   128, RD_CMD_FULL, WR_CMD_FULL,		   0},
+
+WARNING: line over 80 characters
+#156: FILE: drivers/mtd/spi/spi_flash_probe.c:94:
++	{"S25FL128S_64K",  0x012018, 0x4d01,    64 * 1024,   256, RD_CMD_FULL, WR_CMD_FULL,		   0},
+
+WARNING: line over 80 characters
+#157: FILE: drivers/mtd/spi/spi_flash_probe.c:95:
++	{"S25FL256S_64K",  0x010219, 0x4d01,    64 * 1024,   512, RD_CMD_FULL, WR_CMD_FULL,		   0},
+
+WARNING: line over 80 characters
+#158: FILE: drivers/mtd/spi/spi_flash_probe.c:96:
++	{"S25FL512S_64K",  0x010220, 0x4d01,    64 * 1024,  1024, RD_CMD_FULL, WR_CMD_FULL,		   0},
+
+WARNING: line over 80 characters
+#181: FILE: drivers/mtd/spi/spi_flash_probe.c:99:
++	{"M25P10",	   0x202011, 0x0,       32 * 1024,     4,	    0,		 0,		   0},
+
+WARNING: line over 80 characters
+#182: FILE: drivers/mtd/spi/spi_flash_probe.c:100:
++	{"M25P20",	   0x202012, 0x0,       64 * 1024,     4,	    0,		 0,		   0},
+
+WARNING: line over 80 characters
+#183: FILE: drivers/mtd/spi/spi_flash_probe.c:101:
++	{"M25P40",	   0x202013, 0x0,       64 * 1024,     8,	    0,		 0,		   0},
+
+WARNING: line over 80 characters
+#184: FILE: drivers/mtd/spi/spi_flash_probe.c:102:
++	{"M25P80",	   0x202014, 0x0,       64 * 1024,    16,	    0,		 0,		   0},
+
+WARNING: line over 80 characters
+#185: FILE: drivers/mtd/spi/spi_flash_probe.c:103:
++	{"M25P16",	   0x202015, 0x0,       64 * 1024,    32,	    0,		 0,		   0},
+
+WARNING: line over 80 characters
+#186: FILE: drivers/mtd/spi/spi_flash_probe.c:104:
++	{"M25P32",	   0x202016, 0x0,       64 * 1024,    64,	    0,		 0,		   0},
+
+WARNING: line over 80 characters
+#187: FILE: drivers/mtd/spi/spi_flash_probe.c:105:
++	{"M25P64",	   0x202017, 0x0,       64 * 1024,   128,	    0,		 0,		   0},
+
+WARNING: line over 80 characters
+#188: FILE: drivers/mtd/spi/spi_flash_probe.c:106:
++	{"M25P128",	   0x202018, 0x0,      256 * 1024,    64,	    0,		 0,		   0},
+
+WARNING: line over 80 characters
+#189: FILE: drivers/mtd/spi/spi_flash_probe.c:107:
++	{"N25Q32",	   0x20ba16, 0x0,       64 * 1024,    64, RD_CMD_FULL, WR_CMD_FULL,	     SECT_4K},
+
+WARNING: line over 80 characters
+#190: FILE: drivers/mtd/spi/spi_flash_probe.c:108:
++	{"N25Q32A",	   0x20bb16, 0x0,       64 * 1024,    64, RD_CMD_FULL, WR_CMD_FULL,	     SECT_4K},
+
+WARNING: line over 80 characters
+#191: FILE: drivers/mtd/spi/spi_flash_probe.c:109:
++	{"N25Q64",	   0x20ba17, 0x0,       64 * 1024,   128, RD_CMD_FULL, WR_CMD_FULL,          SECT_4K},
+
+WARNING: line over 80 characters
+#192: FILE: drivers/mtd/spi/spi_flash_probe.c:110:
++	{"N25Q64A",	   0x20bb17, 0x0,       64 * 1024,   128, RD_CMD_FULL, WR_CMD_FULL,	     SECT_4K},
+
+WARNING: line over 80 characters
+#193: FILE: drivers/mtd/spi/spi_flash_probe.c:111:
++	{"N25Q128",	   0x20ba18, 0x0,       64 * 1024,   256, RD_CMD_FULL, WR_CMD_FULL,	     SECT_4K},
+
+WARNING: line over 80 characters
+#194: FILE: drivers/mtd/spi/spi_flash_probe.c:112:
++	{"N25Q128A",	   0x20bb18, 0x0,       64 * 1024,   256, RD_CMD_FULL, WR_CMD_FULL,	     SECT_4K},
+
+WARNING: line over 80 characters
+#195: FILE: drivers/mtd/spi/spi_flash_probe.c:113:
++	{"N25Q256",	   0x20ba19, 0x0,       64 * 1024,   512, RD_CMD_FULL, WR_CMD_FULL,	     SECT_4K},
+
+WARNING: line over 80 characters
+#196: FILE: drivers/mtd/spi/spi_flash_probe.c:114:
++	{"N25Q256A",	   0x20bb19, 0x0,       64 * 1024,   512, RD_CMD_FULL, WR_CMD_FULL,	     SECT_4K},
+
+WARNING: line over 80 characters
+#197: FILE: drivers/mtd/spi/spi_flash_probe.c:115:
++	{"N25Q512",	   0x20ba20, 0x0,       64 * 1024,  1024, RD_CMD_FULL, WR_CMD_FULL,  E_FSR | SECT_4K},
+
+WARNING: line over 80 characters
+#198: FILE: drivers/mtd/spi/spi_flash_probe.c:116:
++	{"N25Q512A",	   0x20bb20, 0x0,       64 * 1024,  1024, RD_CMD_FULL, WR_CMD_FULL,  E_FSR | SECT_4K},
+
+WARNING: line over 80 characters
+#199: FILE: drivers/mtd/spi/spi_flash_probe.c:117:
++	{"N25Q1024",	   0x20ba21, 0x0,       64 * 1024,  2048, RD_CMD_FULL, WR_CMD_FULL,  E_FSR | SECT_4K},
+
+WARNING: line over 80 characters
+#200: FILE: drivers/mtd/spi/spi_flash_probe.c:118:
++	{"N25Q1024A",	   0x20bb21, 0x0,       64 * 1024,  2048, RD_CMD_FULL, WR_CMD_FULL,  E_FSR | SECT_4K},
+
+WARNING: line over 80 characters
+#213: FILE: drivers/mtd/spi/spi_flash_probe.c:121:
++	{"SST25VF040B",	   0xbf258d, 0x0,	64 * 1024,     8,	    0,		 0, SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#214: FILE: drivers/mtd/spi/spi_flash_probe.c:122:
++	{"SST25VF080B",	   0xbf258e, 0x0,	64 * 1024,    16,	    0,		 0, SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#215: FILE: drivers/mtd/spi/spi_flash_probe.c:123:
++	{"SST25VF016B",	   0xbf2541, 0x0,	64 * 1024,    32,	    0,		 0, SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#216: FILE: drivers/mtd/spi/spi_flash_probe.c:124:
++	{"SST25VF032B",	   0xbf254a, 0x0,	64 * 1024,    64,	    0,		 0, SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#217: FILE: drivers/mtd/spi/spi_flash_probe.c:125:
++	{"SST25VF064C",	   0xbf254b, 0x0,	64 * 1024,   128,	    0,		 0,	     SECT_4K},
+
+WARNING: line over 80 characters
+#218: FILE: drivers/mtd/spi/spi_flash_probe.c:126:
++	{"SST25WF512",	   0xbf2501, 0x0,	64 * 1024,     1,	    0,		 0, SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#219: FILE: drivers/mtd/spi/spi_flash_probe.c:127:
++	{"SST25WF010",	   0xbf2502, 0x0,	64 * 1024,     2,	    0,		 0, SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#220: FILE: drivers/mtd/spi/spi_flash_probe.c:128:
++	{"SST25WF020",	   0xbf2503, 0x0,	64 * 1024,     4,	    0,		 0, SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#221: FILE: drivers/mtd/spi/spi_flash_probe.c:129:
++	{"SST25WF040",	   0xbf2504, 0x0,	64 * 1024,     8,	    0,		 0, SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#222: FILE: drivers/mtd/spi/spi_flash_probe.c:130:
++	{"SST25WF080",	   0xbf2505, 0x0,	64 * 1024,    16,	    0,		 0, SECT_4K | SST_WP},
+
+WARNING: line over 80 characters
+#243: FILE: drivers/mtd/spi/spi_flash_probe.c:133:
++	{"W25P80",	   0xef2014, 0x0,	64 * 1024,    16,	    0,		 0,		  0},
+
+WARNING: line over 80 characters
+#244: FILE: drivers/mtd/spi/spi_flash_probe.c:134:
++	{"W25P16",	   0xef2015, 0x0,	64 * 1024,    32,	    0,		 0,		  0},
+
+WARNING: line over 80 characters
+#245: FILE: drivers/mtd/spi/spi_flash_probe.c:135:
++	{"W25P32",	   0xef2016, 0x0,	64 * 1024,    64,	    0,		 0,		  0},
+
+WARNING: line over 80 characters
+#246: FILE: drivers/mtd/spi/spi_flash_probe.c:136:
++	{"W25X40",	   0xef3013, 0x0,	 4 * 1024,   128,	    0,		 0,	    SECT_4K},
+
+WARNING: line over 80 characters
+#247: FILE: drivers/mtd/spi/spi_flash_probe.c:137:
++	{"W25X16",	   0xef3015, 0x0,	 4 * 1024,   512,	    0,		 0,	    SECT_4K},
+
+WARNING: line over 80 characters
+#248: FILE: drivers/mtd/spi/spi_flash_probe.c:138:
++	{"W25X32",	   0xef3016, 0x0,	 4 * 1024,  1024,	    0,		 0,	    SECT_4K},
+
+WARNING: line over 80 characters
+#249: FILE: drivers/mtd/spi/spi_flash_probe.c:139:
++	{"W25X64",	   0xef3017, 0x0,	 4 * 1024,  2048,	    0,		 0,	    SECT_4K},
+
+WARNING: line over 80 characters
+#250: FILE: drivers/mtd/spi/spi_flash_probe.c:140:
++	{"W25Q80BL",	   0xef4014, 0x0,	 4 * 1024,   256, RD_CMD_FULL, WR_CMD_FULL,	    SECT_4K},
+
+WARNING: line over 80 characters
+#251: FILE: drivers/mtd/spi/spi_flash_probe.c:141:
++	{"W25Q16CL",	   0xef4015, 0x0,	 4 * 1024,   512, RD_CMD_FULL, WR_CMD_FULL,	    SECT_4K},
+
+WARNING: line over 80 characters
+#252: FILE: drivers/mtd/spi/spi_flash_probe.c:142:
++	{"W25Q32BV",	   0xef4016, 0x0,	 4 * 1024,  1024, RD_CMD_FULL, WR_CMD_FULL,	    SECT_4K},
+
+WARNING: line over 80 characters
+#253: FILE: drivers/mtd/spi/spi_flash_probe.c:143:
++	{"W25Q64CV",	   0xef4017, 0x0,	 4 * 1024,  2048, RD_CMD_FULL, WR_CMD_FULL,	    SECT_4K},
+
+WARNING: line over 80 characters
+#254: FILE: drivers/mtd/spi/spi_flash_probe.c:144:
++	{"W25Q128BV",	   0xef4018, 0x0,	 4 * 1024,  4096, RD_CMD_FULL, WR_CMD_FULL,	    SECT_4K},
+
+WARNING: line over 80 characters
+#255: FILE: drivers/mtd/spi/spi_flash_probe.c:145:
++	{"W25Q256",	   0xef4019, 0x0,	 4 * 1024,  8192, RD_CMD_FULL, WR_CMD_FULL,	    SECT_4K},
+
+WARNING: line over 80 characters
+#256: FILE: drivers/mtd/spi/spi_flash_probe.c:146:
++	{"W25Q80BW",	   0xef5014, 0x0,	 4 * 1024,   256, RD_CMD_FULL, WR_CMD_FULL,	    SECT_4K},
+
+WARNING: line over 80 characters
+#257: FILE: drivers/mtd/spi/spi_flash_probe.c:147:
++	{"W25Q16DW",	   0xef6015, 0x0,	 4 * 1024,   512, RD_CMD_FULL, WR_CMD_FULL,	    SECT_4K},
+
+WARNING: line over 80 characters
+#258: FILE: drivers/mtd/spi/spi_flash_probe.c:148:
++	{"W25Q32DW",	   0xef6016, 0x0,	 4 * 1024,  1024, RD_CMD_FULL, WR_CMD_FULL,	    SECT_4K},
+
+WARNING: line over 80 characters
+#259: FILE: drivers/mtd/spi/spi_flash_probe.c:149:
++	{"W25Q64DW",	   0xef6017, 0x0,	 4 * 1024,  2048, RD_CMD_FULL, WR_CMD_FULL,	    SECT_4K},
+
+WARNING: line over 80 characters
+#260: FILE: drivers/mtd/spi/spi_flash_probe.c:150:
++	{"W25Q128FW",	   0xef6018, 0x0,	 4 * 1024,  4096, RD_CMD_FULL, WR_CMD_FULL,	    SECT_4K},
+
+total: 0 errors, 78 warnings, 0 checks, 311 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0032-sf-Add-quad-read-write-commands-support.patch has style problems, please review.
+
+If any of these errors are false positives, please report
+them to the maintainer, see CHECKPATCH in MAINTAINERS.
+total: 0 errors, 0 warnings, 0 checks, 30 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0033-sf-ops-Add-configuration-register-writing-support.patch has no obvious style problems and is ready for submission.
+total: 0 errors, 0 warnings, 0 checks, 68 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0034-sf-Set-quad-enable-bit-support.patch has no obvious style problems and is ready for submission.
+total: 0 errors, 0 warnings, 0 checks, 332 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0035-sf-spi_flash-cleanups.patch has no obvious style problems and is ready for submission.
+total: 0 errors, 0 warnings, 0 checks, 212 lines checked
+
+NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
+
+0036-spi-spi-cleanups.patch has no obvious style problems and is ready for submission.
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 09/36] sf: probe: Add support for SST25* flash parts
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (7 preceding siblings ...)
  2013-09-24 18:19 ` [U-Boot] [PATCH v4] sf: probe: Add support for S25FL* " Jagannadha Sutradharudu Teki
@ 2013-09-24 18:19 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 10/36] sf: probe: Add support for AT45DB* " Jagannadha Sutradharudu Teki
                   ` (26 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:19 UTC (permalink / raw)
  To: u-boot

Added SST25* parts are which are avilable in spi_flash_probe_legacy.c.

Updated the sector_size attributes as per the flash parts.
Looks fine for with this sector_size for computing the size
of flash.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
Tested-by: Eric Nelson <eric.nelson@boundarydevices.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - Enable CONFIG_SPI_FLASH_SST

 drivers/mtd/spi/spi_flash_probe.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index d24b2d6..543369a 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -88,6 +88,18 @@ static const struct spi_flash_params spi_flash_params_table[] = {
 	{"N25Q1024",		0x20ba21, 0x0,     64 * 1024,	2048},
 	{"N25Q1024A",		0x20bb21, 0x0,     64 * 1024,	2048},
 #endif
+#ifdef CONFIG_SPI_FLASH_SST		/* SST */
+	{"SST25VF040B",		0xbf258d, 0x0,	   64 * 1024,	   8},
+	{"SST25VF080B",		0xbf258e, 0x0,	   64 * 1024,	  16},
+	{"SST25VF016B",		0xbf2541, 0x0,	   64 * 1024,	  32},
+	{"SST25VF032B",		0xbf254a, 0x0,	   64 * 1024,	  64},
+	{"SST25VF064C",		0xbf254b, 0x0,	   64 * 1024,	 128},
+	{"SST25WF512",		0xbf2501, 0x0,	   64 * 1024,	   1},
+	{"SST25WF010",		0xbf2502, 0x0,	   64 * 1024,	   2},
+	{"SST25WF020",		0xbf2503, 0x0,	   64 * 1024,	   4},
+	{"SST25WF040",		0xbf2504, 0x0,	   64 * 1024,	   8},
+	{"SST25WF080",		0xbf2505, 0x0,	   64 * 1024,	  16},
+#endif
 #ifdef CONFIG_SPI_FLASH_WINBOND		/* WINBOND */
 	{"W25P80",		0xef2014, 0x0,	   64 * 1024,	  16},
 	{"W25P16",		0xef2015, 0x0,	   64 * 1024,	  32},
@@ -125,7 +137,6 @@ static const struct spi_flash_params spi_flash_params_table[] = {
 	 * TODO:
 	 * ATMEL
 	 * RAMTRON
-	 * SST
 	 */
 };
 
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 10/36] sf: probe: Add support for AT45DB* flash parts
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (8 preceding siblings ...)
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 09/36] sf: probe: Add support for SST25* " Jagannadha Sutradharudu Teki
@ 2013-09-24 18:19 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 11/36] sf: probe: Give proper spacing on flash table params Jagannadha Sutradharudu Teki
                   ` (25 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:19 UTC (permalink / raw)
  To: u-boot

Added AT45DB* parts are which are avilable in spi_flash_probe_legacy.c.

Updated the sector_size attributes as per the flash parts.
Looks fine for with this sector_size for computing the size
of flash.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - Enable CONFIG_SPI_FLASH_ATMEL

 drivers/mtd/spi/spi_flash_probe.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index 543369a..b305c3d 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -36,6 +36,15 @@ struct spi_flash_params {
 };
 
 static const struct spi_flash_params spi_flash_params_table[] = {
+#ifdef CONFIG_SPI_FLASH_ATMEL		/* ATMEL */
+	{"AT45DB011D",		0x1f2200, 0x0,	   64 * 1024,	   4},
+	{"AT45DB021D",		0x1f2300, 0x0,	   64 * 1024,	   8},
+	{"AT45DB041D",		0x1f2400, 0x0,	   64 * 1024,	   8},
+	{"AT45DB081D",		0x1f2500, 0x0,	   64 * 1024,	  16},
+	{"AT45DB161D",		0x1f2600, 0x0,	   64 * 1024,	  32},
+	{"AT45DB321D",		0x1f2700, 0x0,	   64 * 1024,	  64},
+	{"AT45DB641D",		0x1f2800, 0x0,	   64 * 1024,	 128},
+#endif
 #ifdef CONFIG_SPI_FLASH_EON		/* EON */
 	{"EN25Q32B",		0x1c3016, 0x0,	   64 * 1024,	  64},
 	{"EN25Q128B",		0x1c3018, 0x0,     64 * 1024,	 256},
@@ -135,7 +144,6 @@ static const struct spi_flash_params spi_flash_params_table[] = {
 	 */
 	/*
 	 * TODO:
-	 * ATMEL
 	 * RAMTRON
 	 */
 };
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 11/36] sf: probe: Give proper spacing on flash table params
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (9 preceding siblings ...)
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 10/36] sf: probe: Add support for AT45DB* " Jagannadha Sutradharudu Teki
@ 2013-09-24 18:19 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 12/36] sf: probe: Add support for SST_WP Jagannadha Sutradharudu Teki
                   ` (24 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:19 UTC (permalink / raw)
  To: u-boot

Given proper spacing between flash table params.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 drivers/mtd/spi/spi_flash_probe.c | 154 +++++++++++++++++++-------------------
 1 file changed, 77 insertions(+), 77 deletions(-)

diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index b305c3d..f4aa446 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -37,97 +37,97 @@ struct spi_flash_params {
 
 static const struct spi_flash_params spi_flash_params_table[] = {
 #ifdef CONFIG_SPI_FLASH_ATMEL		/* ATMEL */
-	{"AT45DB011D",		0x1f2200, 0x0,	   64 * 1024,	   4},
-	{"AT45DB021D",		0x1f2300, 0x0,	   64 * 1024,	   8},
-	{"AT45DB041D",		0x1f2400, 0x0,	   64 * 1024,	   8},
-	{"AT45DB081D",		0x1f2500, 0x0,	   64 * 1024,	  16},
-	{"AT45DB161D",		0x1f2600, 0x0,	   64 * 1024,	  32},
-	{"AT45DB321D",		0x1f2700, 0x0,	   64 * 1024,	  64},
-	{"AT45DB641D",		0x1f2800, 0x0,	   64 * 1024,	 128},
+	{"AT45DB011D",	   0x1f2200, 0x0,	64 * 1024,     4},
+	{"AT45DB021D",	   0x1f2300, 0x0,	64 * 1024,     8},
+	{"AT45DB041D",	   0x1f2400, 0x0,	64 * 1024,     8},
+	{"AT45DB081D",	   0x1f2500, 0x0,	64 * 1024,    16},
+	{"AT45DB161D",	   0x1f2600, 0x0,	64 * 1024,    32},
+	{"AT45DB321D",	   0x1f2700, 0x0,	64 * 1024,    64},
+	{"AT45DB641D",	   0x1f2800, 0x0,	64 * 1024,   128},
 #endif
 #ifdef CONFIG_SPI_FLASH_EON		/* EON */
-	{"EN25Q32B",		0x1c3016, 0x0,	   64 * 1024,	  64},
-	{"EN25Q128B",		0x1c3018, 0x0,     64 * 1024,	 256},
+	{"EN25Q32B",	   0x1c3016, 0x0,	64 * 1024,    64},
+	{"EN25Q128B",	   0x1c3018, 0x0,       64 * 1024,   256},
 #endif
 #ifdef CONFIG_SPI_FLASH_GIGADEVICE	/* GIGADEVICE */
-	{"GD25Q64B",		0xc84017, 0x0,	   64 * 1024,	 128},
-	{"GD25LQ32",		0xc86016, 0x0,	   64 * 1024,	  64},
+	{"GD25Q64B",	   0xc84017, 0x0,	64 * 1024,   128},
+	{"GD25LQ32",	   0xc86016, 0x0,	64 * 1024,    64},
 #endif
 #ifdef CONFIG_SPI_FLASH_MACRONIX	/* MACRONIX */
-	{"MX25L4005",		0xc22013, 0x0,	   64 * 1024,	   8},
-	{"MX25L8005",		0xc22014, 0x0,	   64 * 1024,	  16},
-	{"MX25L1605D",		0xc22015, 0x0,	   64 * 1024,	  32},
-	{"MX25L3205D",		0xc22016, 0x0,	   64 * 1024,	  64},
-	{"MX25L6405D",		0xc22017, 0x0,	   64 * 1024,	 128},
-	{"MX25L12805",		0xc22018, 0x0,	   64 * 1024,	 256},
-	{"MX25L12855E",		0xc22618, 0x0,	   64 * 1024,	 256},
+	{"MX25L4005",	   0xc22013, 0x0,	64 * 1024,     8},
+	{"MX25L8005",	   0xc22014, 0x0,	64 * 1024,    16},
+	{"MX25L1605D",	   0xc22015, 0x0,	64 * 1024,    32},
+	{"MX25L3205D",	   0xc22016, 0x0,	64 * 1024,    64},
+	{"MX25L6405D",	   0xc22017, 0x0,	64 * 1024,   128},
+	{"MX25L12805",	   0xc22018, 0x0,	64 * 1024,   256},
+	{"MX25L12855E",	   0xc22618, 0x0,	64 * 1024,   256},
 #endif
 #ifdef CONFIG_SPI_FLASH_SPANSION	/* SPANSION */
-	{"S25FL008A",		0x010213, 0x0,	   64 * 1024,	  16},
-	{"S25FL016A",		0x010214, 0x0,	   64 * 1024,	  32},
-	{"S25FL032A",		0x010215, 0x0,	   64 * 1024,	  64},
-	{"S25FL064A",		0x010216, 0x0,	   64 * 1024,	 128},
-	{"S25FL128P_256K",	0x012018, 0x0300, 256 * 1024,	  64},
-	{"S25FL128P_64K",	0x012018, 0x0301,  64 * 1024,	 256},
-	{"S25FL032P",		0x010215, 0x4d00,  64 * 1024,	  64},
-	{"S25FL064P",		0x010216, 0x4d00,  64 * 1024,	 128},
-	{"S25FL128S_64K",	0x012018, 0x4d01,  64 * 1024,	 256},
-	{"S25FL256S_64K",	0x010219, 0x4d01,  64 * 1024,	 512},
-	{"S25FL512S_64K",	0x010220, 0x4d01,  64 * 1024,	1024},
+	{"S25FL008A",	   0x010213, 0x0,	64 * 1024,    16},
+	{"S25FL016A",	   0x010214, 0x0,	64 * 1024,    32},
+	{"S25FL032A",	   0x010215, 0x0,	64 * 1024,    64},
+	{"S25FL064A",	   0x010216, 0x0,	64 * 1024,   128},
+	{"S25FL128P_256K", 0x012018, 0x0300,   256 * 1024,    64},
+	{"S25FL128P_64K",  0x012018, 0x0301,    64 * 1024,   256},
+	{"S25FL032P",	   0x010215, 0x4d00,    64 * 1024,    64},
+	{"S25FL064P",	   0x010216, 0x4d00,    64 * 1024,   128},
+	{"S25FL128S_64K",  0x012018, 0x4d01,    64 * 1024,   256},
+	{"S25FL256S_64K",  0x010219, 0x4d01,    64 * 1024,   512},
+	{"S25FL512S_64K",  0x010220, 0x4d01,    64 * 1024,  1024},
 #endif
 #ifdef CONFIG_SPI_FLASH_STMICRO		/* STMICRO */
-	{"M25P10",		0x202011, 0x0,     32 * 1024,	   4},
-	{"M25P20",		0x202012, 0x0,     64 * 1024,	   4},
-	{"M25P40",		0x202013, 0x0,     64 * 1024,	   8},
-	{"M25P80",		0x202014, 0x0,     64 * 1024,	  16},
-	{"M25P16",		0x202015, 0x0,     64 * 1024,	  32},
-	{"M25P32",		0x202016, 0x0,     64 * 1024,	  64},
-	{"M25P64",		0x202017, 0x0,     64 * 1024,	 128},
-	{"M25P128",		0x202018, 0x0,    256 * 1024,	  64},
-	{"N25Q32",		0x20ba16, 0x0,     64 * 1024,	  64},
-	{"N25Q32A",		0x20bb16, 0x0,     64 * 1024,	  64},
-	{"N25Q64",		0x20ba17, 0x0,     64 * 1024,	 128},
-	{"N25Q64A",		0x20bb17, 0x0,     64 * 1024,	 128},
-	{"N25Q128",		0x20ba18, 0x0,     64 * 1024,	 256},
-	{"N25Q128A",		0x20bb18, 0x0,     64 * 1024,	 256},
-	{"N25Q256",		0x20ba19, 0x0,     64 * 1024,	 512},
-	{"N25Q256A",		0x20bb19, 0x0,     64 * 1024,	 512},
-	{"N25Q512",		0x20ba20, 0x0,     64 * 1024,	1024},
-	{"N25Q512A",		0x20bb20, 0x0,     64 * 1024,	1024},
-	{"N25Q1024",		0x20ba21, 0x0,     64 * 1024,	2048},
-	{"N25Q1024A",		0x20bb21, 0x0,     64 * 1024,	2048},
+	{"M25P10",	   0x202011, 0x0,       32 * 1024,     4},
+	{"M25P20",	   0x202012, 0x0,       64 * 1024,     4},
+	{"M25P40",	   0x202013, 0x0,       64 * 1024,     8},
+	{"M25P80",	   0x202014, 0x0,       64 * 1024,    16},
+	{"M25P16",	   0x202015, 0x0,       64 * 1024,    32},
+	{"M25P32",	   0x202016, 0x0,       64 * 1024,    64},
+	{"M25P64",	   0x202017, 0x0,       64 * 1024,   128},
+	{"M25P128",	   0x202018, 0x0,      256 * 1024,    64},
+	{"N25Q32",	   0x20ba16, 0x0,       64 * 1024,    64},
+	{"N25Q32A",	   0x20bb16, 0x0,       64 * 1024,    64},
+	{"N25Q64",	   0x20ba17, 0x0,       64 * 1024,   128},
+	{"N25Q64A",	   0x20bb17, 0x0,       64 * 1024,   128},
+	{"N25Q128",	   0x20ba18, 0x0,       64 * 1024,   256},
+	{"N25Q128A",	   0x20bb18, 0x0,       64 * 1024,   256},
+	{"N25Q256",	   0x20ba19, 0x0,       64 * 1024,   512},
+	{"N25Q256A",	   0x20bb19, 0x0,       64 * 1024,   512},
+	{"N25Q512",	   0x20ba20, 0x0,       64 * 1024,  1024},
+	{"N25Q512A",	   0x20bb20, 0x0,       64 * 1024,  1024},
+	{"N25Q1024",	   0x20ba21, 0x0,       64 * 1024,  2048},
+	{"N25Q1024A",	   0x20bb21, 0x0,       64 * 1024,  2048},
 #endif
 #ifdef CONFIG_SPI_FLASH_SST		/* SST */
-	{"SST25VF040B",		0xbf258d, 0x0,	   64 * 1024,	   8},
-	{"SST25VF080B",		0xbf258e, 0x0,	   64 * 1024,	  16},
-	{"SST25VF016B",		0xbf2541, 0x0,	   64 * 1024,	  32},
-	{"SST25VF032B",		0xbf254a, 0x0,	   64 * 1024,	  64},
-	{"SST25VF064C",		0xbf254b, 0x0,	   64 * 1024,	 128},
-	{"SST25WF512",		0xbf2501, 0x0,	   64 * 1024,	   1},
-	{"SST25WF010",		0xbf2502, 0x0,	   64 * 1024,	   2},
-	{"SST25WF020",		0xbf2503, 0x0,	   64 * 1024,	   4},
-	{"SST25WF040",		0xbf2504, 0x0,	   64 * 1024,	   8},
-	{"SST25WF080",		0xbf2505, 0x0,	   64 * 1024,	  16},
+	{"SST25VF040B",	   0xbf258d, 0x0,	64 * 1024,     8},
+	{"SST25VF080B",	   0xbf258e, 0x0,	64 * 1024,    16},
+	{"SST25VF016B",	   0xbf2541, 0x0,	64 * 1024,    32},
+	{"SST25VF032B",	   0xbf254a, 0x0,	64 * 1024,    64},
+	{"SST25VF064C",	   0xbf254b, 0x0,	64 * 1024,   128},
+	{"SST25WF512",	   0xbf2501, 0x0,	64 * 1024,     1},
+	{"SST25WF010",	   0xbf2502, 0x0,	64 * 1024,     2},
+	{"SST25WF020",	   0xbf2503, 0x0,	64 * 1024,     4},
+	{"SST25WF040",	   0xbf2504, 0x0,	64 * 1024,     8},
+	{"SST25WF080",	   0xbf2505, 0x0,	64 * 1024,    16},
 #endif
 #ifdef CONFIG_SPI_FLASH_WINBOND		/* WINBOND */
-	{"W25P80",		0xef2014, 0x0,	   64 * 1024,	  16},
-	{"W25P16",		0xef2015, 0x0,	   64 * 1024,	  32},
-	{"W25P32",		0xef2016, 0x0,	   64 * 1024,	  64},
-	{"W25X40",		0xef3013, 0x0,	    4 * 1024,	 128},
-	{"W25X16",		0xef3015, 0x0,	    4 * 1024,	 512},
-	{"W25X32",		0xef3016, 0x0,	    4 * 1024,	1024},
-	{"W25X64",		0xef3017, 0x0,	    4 * 1024,	2048},
-	{"W25Q80BL",		0xef4014, 0x0,	    4 * 1024,	 256},
-	{"W25Q16CL",		0xef4015, 0x0,	    4 * 1024,	 512},
-	{"W25Q32BV",		0xef4016, 0x0,	    4 * 1024,	1024},
-	{"W25Q64CV",		0xef4017, 0x0,	    4 * 1024,	2048},
-	{"W25Q128BV",		0xef4018, 0x0,	    4 * 1024,	4096},
-	{"W25Q256",		0xef4019, 0x0,	    4 * 1024,	8192},
-	{"W25Q80BW",		0xef5014, 0x0,	    4 * 1024,	 256},
-	{"W25Q16DW",		0xef6015, 0x0,	    4 * 1024,	 512},
-	{"W25Q32DW",		0xef6016, 0x0,	    4 * 1024,	1024},
-	{"W25Q64DW",		0xef6017, 0x0,	    4 * 1024,	2048},
-	{"W25Q128FW",		0xef6018, 0x0,	    4 * 1024,	4096},
+	{"W25P80",	   0xef2014, 0x0,	64 * 1024,    16},
+	{"W25P16",	   0xef2015, 0x0,	64 * 1024,    32},
+	{"W25P32",	   0xef2016, 0x0,	64 * 1024,    64},
+	{"W25X40",	   0xef3013, 0x0,	 4 * 1024,   128},
+	{"W25X16",	   0xef3015, 0x0,	 4 * 1024,   512},
+	{"W25X32",	   0xef3016, 0x0,	 4 * 1024,  1024},
+	{"W25X64",	   0xef3017, 0x0,	 4 * 1024,  2048},
+	{"W25Q80BL",	   0xef4014, 0x0,	 4 * 1024,   256},
+	{"W25Q16CL",	   0xef4015, 0x0,	 4 * 1024,   512},
+	{"W25Q32BV",	   0xef4016, 0x0,	 4 * 1024,  1024},
+	{"W25Q64CV",	   0xef4017, 0x0,	 4 * 1024,  2048},
+	{"W25Q128BV",	   0xef4018, 0x0,	 4 * 1024,  4096},
+	{"W25Q256",	   0xef4019, 0x0,	 4 * 1024,  8192},
+	{"W25Q80BW",	   0xef5014, 0x0,	 4 * 1024,   256},
+	{"W25Q16DW",	   0xef6015, 0x0,	 4 * 1024,   512},
+	{"W25Q32DW",	   0xef6016, 0x0,	 4 * 1024,  1024},
+	{"W25Q64DW",	   0xef6017, 0x0,	 4 * 1024,  2048},
+	{"W25Q128FW",	   0xef6018, 0x0,	 4 * 1024,  4096},
 #endif
 	/*
 	 * Note:
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 12/36] sf: probe: Add support for SST_WP
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (10 preceding siblings ...)
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 11/36] sf: probe: Give proper spacing on flash table params Jagannadha Sutradharudu Teki
@ 2013-09-24 18:19 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 13/36] sf: probe: Add support to clear flash BP# bits Jagannadha Sutradharudu Teki
                   ` (23 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:19 UTC (permalink / raw)
  To: u-boot

Most of the SST flashes needs to write up using SST_WP, AAI
Word Program, so added a flag param on spi_flash_params table.

SST flashes, which supports SST_WP need to use a WP write
sst_write_wp instead of common flash write.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 drivers/mtd/spi/spi_flash_internal.h |   5 ++
 drivers/mtd/spi/spi_flash_ops.c      |  93 ++++++++++++++++++++
 drivers/mtd/spi/spi_flash_probe.c    | 160 ++++++++++++++++++-----------------
 include/spi_flash.h                  |   7 ++
 4 files changed, 188 insertions(+), 77 deletions(-)

diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h
index af1afa9..ce34ce0 100644
--- a/drivers/mtd/spi/spi_flash_internal.h
+++ b/drivers/mtd/spi/spi_flash_internal.h
@@ -75,6 +75,11 @@ int spi_flash_cmd_write(struct spi_slave *spi, const u8 *cmd, size_t cmd_len,
 int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,
 		size_t len, const void *buf);
 
+#ifdef CONFIG_SPI_FLASH_SST
+int sst_write_wp(struct spi_flash *flash, u32 offset, size_t len,
+		const void *buf);
+#endif
+
 /*
  * Enable writing on the SPI flash.
  */
diff --git a/drivers/mtd/spi/spi_flash_ops.c b/drivers/mtd/spi/spi_flash_ops.c
index 6133363..79381b1 100644
--- a/drivers/mtd/spi/spi_flash_ops.c
+++ b/drivers/mtd/spi/spi_flash_ops.c
@@ -312,3 +312,96 @@ int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset,
 
 	return ret;
 }
+
+#ifdef CONFIG_SPI_FLASH_SST
+static int sst_byte_write(struct spi_flash *flash, u32 offset, const void *buf)
+{
+	int ret;
+	u8 cmd[4] = {
+		CMD_SST_BP,
+		offset >> 16,
+		offset >> 8,
+		offset,
+	};
+
+	debug("BP[%02x]: 0x%p => cmd = { 0x%02x 0x%06x }\n",
+	      spi_w8r8(flash->spi, CMD_READ_STATUS), buf, cmd[0], offset);
+
+	ret = spi_flash_cmd_write_enable(flash);
+	if (ret)
+		return ret;
+
+	ret = spi_flash_cmd_write(flash->spi, cmd, sizeof(cmd), buf, 1);
+	if (ret)
+		return ret;
+
+	return spi_flash_cmd_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT);
+}
+
+int sst_write_wp(struct spi_flash *flash, u32 offset, size_t len,
+		const void *buf)
+{
+	size_t actual, cmd_len;
+	int ret;
+	u8 cmd[4];
+
+	ret = spi_claim_bus(flash->spi);
+	if (ret) {
+		debug("SF: Unable to claim SPI bus\n");
+		return ret;
+	}
+
+	/* If the data is not word aligned, write out leading single byte */
+	actual = offset % 2;
+	if (actual) {
+		ret = sst_byte_write(flash, offset, buf);
+		if (ret)
+			goto done;
+	}
+	offset += actual;
+
+	ret = spi_flash_cmd_write_enable(flash);
+	if (ret)
+		goto done;
+
+	cmd_len = 4;
+	cmd[0] = CMD_SST_AAI_WP;
+	cmd[1] = offset >> 16;
+	cmd[2] = offset >> 8;
+	cmd[3] = offset;
+
+	for (; actual < len - 1; actual += 2) {
+		debug("WP[%02x]: 0x%p => cmd = { 0x%02x 0x%06x }\n",
+		      spi_w8r8(flash->spi, CMD_READ_STATUS), buf + actual,
+		      cmd[0], offset);
+
+		ret = spi_flash_cmd_write(flash->spi, cmd, cmd_len,
+					buf + actual, 2);
+		if (ret) {
+			debug("SF: sst word program failed\n");
+			break;
+		}
+
+		ret = spi_flash_cmd_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT);
+		if (ret)
+			break;
+
+		cmd_len = 1;
+		offset += 2;
+	}
+
+	if (!ret)
+		ret = spi_flash_cmd_write_disable(flash);
+
+	/* If there is a single trailing byte, write it out */
+	if (!ret && actual != len)
+		ret = sst_byte_write(flash, offset, buf + actual);
+
+ done:
+	debug("SF: sst: program %s %zu bytes @ 0x%zx\n",
+	      ret ? "failure" : "success", len, offset - actual);
+
+	spi_release_bus(flash->spi);
+	return ret;
+}
+#endif
diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index f4aa446..da43fda 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -26,6 +26,7 @@ DECLARE_GLOBAL_DATA_PTR;
  * @ext_jedec:		Device ext_jedec ID
  * @sector_size:	Sector size of this device
  * @nr_sectors:		No.of sectors on this device
+ * @flags:		Importent param, for flash specific behaviour
  */
 struct spi_flash_params {
 	const char *name;
@@ -33,101 +34,102 @@ struct spi_flash_params {
 	u16 ext_jedec;
 	u32 sector_size;
 	u32 nr_sectors;
+	u16 flags;
 };
 
 static const struct spi_flash_params spi_flash_params_table[] = {
 #ifdef CONFIG_SPI_FLASH_ATMEL		/* ATMEL */
-	{"AT45DB011D",	   0x1f2200, 0x0,	64 * 1024,     4},
-	{"AT45DB021D",	   0x1f2300, 0x0,	64 * 1024,     8},
-	{"AT45DB041D",	   0x1f2400, 0x0,	64 * 1024,     8},
-	{"AT45DB081D",	   0x1f2500, 0x0,	64 * 1024,    16},
-	{"AT45DB161D",	   0x1f2600, 0x0,	64 * 1024,    32},
-	{"AT45DB321D",	   0x1f2700, 0x0,	64 * 1024,    64},
-	{"AT45DB641D",	   0x1f2800, 0x0,	64 * 1024,   128},
+	{"AT45DB011D",	   0x1f2200, 0x0,	64 * 1024,     4,	     0},
+	{"AT45DB021D",	   0x1f2300, 0x0,	64 * 1024,     8,	     0},
+	{"AT45DB041D",	   0x1f2400, 0x0,	64 * 1024,     8,	     0},
+	{"AT45DB081D",	   0x1f2500, 0x0,	64 * 1024,    16,	     0},
+	{"AT45DB161D",	   0x1f2600, 0x0,	64 * 1024,    32,	     0},
+	{"AT45DB321D",	   0x1f2700, 0x0,	64 * 1024,    64,	     0},
+	{"AT45DB641D",	   0x1f2800, 0x0,	64 * 1024,   128,	     0},
 #endif
 #ifdef CONFIG_SPI_FLASH_EON		/* EON */
-	{"EN25Q32B",	   0x1c3016, 0x0,	64 * 1024,    64},
-	{"EN25Q128B",	   0x1c3018, 0x0,       64 * 1024,   256},
+	{"EN25Q32B",	   0x1c3016, 0x0,	64 * 1024,    64,	     0},
+	{"EN25Q128B",	   0x1c3018, 0x0,       64 * 1024,   256,	     0},
 #endif
 #ifdef CONFIG_SPI_FLASH_GIGADEVICE	/* GIGADEVICE */
-	{"GD25Q64B",	   0xc84017, 0x0,	64 * 1024,   128},
-	{"GD25LQ32",	   0xc86016, 0x0,	64 * 1024,    64},
+	{"GD25Q64B",	   0xc84017, 0x0,	64 * 1024,   128,	     0},
+	{"GD25LQ32",	   0xc86016, 0x0,	64 * 1024,    64,	     0},
 #endif
 #ifdef CONFIG_SPI_FLASH_MACRONIX	/* MACRONIX */
-	{"MX25L4005",	   0xc22013, 0x0,	64 * 1024,     8},
-	{"MX25L8005",	   0xc22014, 0x0,	64 * 1024,    16},
-	{"MX25L1605D",	   0xc22015, 0x0,	64 * 1024,    32},
-	{"MX25L3205D",	   0xc22016, 0x0,	64 * 1024,    64},
-	{"MX25L6405D",	   0xc22017, 0x0,	64 * 1024,   128},
-	{"MX25L12805",	   0xc22018, 0x0,	64 * 1024,   256},
-	{"MX25L12855E",	   0xc22618, 0x0,	64 * 1024,   256},
+	{"MX25L4005",	   0xc22013, 0x0,	64 * 1024,     8,	     0},
+	{"MX25L8005",	   0xc22014, 0x0,	64 * 1024,    16,	     0},
+	{"MX25L1605D",	   0xc22015, 0x0,	64 * 1024,    32,	     0},
+	{"MX25L3205D",	   0xc22016, 0x0,	64 * 1024,    64,	     0},
+	{"MX25L6405D",	   0xc22017, 0x0,	64 * 1024,   128,	     0},
+	{"MX25L12805",	   0xc22018, 0x0,	64 * 1024,   256,	     0},
+	{"MX25L12855E",	   0xc22618, 0x0,	64 * 1024,   256,	     0},
 #endif
 #ifdef CONFIG_SPI_FLASH_SPANSION	/* SPANSION */
-	{"S25FL008A",	   0x010213, 0x0,	64 * 1024,    16},
-	{"S25FL016A",	   0x010214, 0x0,	64 * 1024,    32},
-	{"S25FL032A",	   0x010215, 0x0,	64 * 1024,    64},
-	{"S25FL064A",	   0x010216, 0x0,	64 * 1024,   128},
-	{"S25FL128P_256K", 0x012018, 0x0300,   256 * 1024,    64},
-	{"S25FL128P_64K",  0x012018, 0x0301,    64 * 1024,   256},
-	{"S25FL032P",	   0x010215, 0x4d00,    64 * 1024,    64},
-	{"S25FL064P",	   0x010216, 0x4d00,    64 * 1024,   128},
-	{"S25FL128S_64K",  0x012018, 0x4d01,    64 * 1024,   256},
-	{"S25FL256S_64K",  0x010219, 0x4d01,    64 * 1024,   512},
-	{"S25FL512S_64K",  0x010220, 0x4d01,    64 * 1024,  1024},
+	{"S25FL008A",	   0x010213, 0x0,	64 * 1024,    16,	     0},
+	{"S25FL016A",	   0x010214, 0x0,	64 * 1024,    32,	     0},
+	{"S25FL032A",	   0x010215, 0x0,	64 * 1024,    64,	     0},
+	{"S25FL064A",	   0x010216, 0x0,	64 * 1024,   128,	     0},
+	{"S25FL128P_256K", 0x012018, 0x0300,   256 * 1024,    64,	     0},
+	{"S25FL128P_64K",  0x012018, 0x0301,    64 * 1024,   256,	     0},
+	{"S25FL032P",	   0x010215, 0x4d00,    64 * 1024,    64,	     0},
+	{"S25FL064P",	   0x010216, 0x4d00,    64 * 1024,   128,	     0},
+	{"S25FL128S_64K",  0x012018, 0x4d01,    64 * 1024,   256,	     0},
+	{"S25FL256S_64K",  0x010219, 0x4d01,    64 * 1024,   512,	     0},
+	{"S25FL512S_64K",  0x010220, 0x4d01,    64 * 1024,  1024,	     0},
 #endif
 #ifdef CONFIG_SPI_FLASH_STMICRO		/* STMICRO */
-	{"M25P10",	   0x202011, 0x0,       32 * 1024,     4},
-	{"M25P20",	   0x202012, 0x0,       64 * 1024,     4},
-	{"M25P40",	   0x202013, 0x0,       64 * 1024,     8},
-	{"M25P80",	   0x202014, 0x0,       64 * 1024,    16},
-	{"M25P16",	   0x202015, 0x0,       64 * 1024,    32},
-	{"M25P32",	   0x202016, 0x0,       64 * 1024,    64},
-	{"M25P64",	   0x202017, 0x0,       64 * 1024,   128},
-	{"M25P128",	   0x202018, 0x0,      256 * 1024,    64},
-	{"N25Q32",	   0x20ba16, 0x0,       64 * 1024,    64},
-	{"N25Q32A",	   0x20bb16, 0x0,       64 * 1024,    64},
-	{"N25Q64",	   0x20ba17, 0x0,       64 * 1024,   128},
-	{"N25Q64A",	   0x20bb17, 0x0,       64 * 1024,   128},
-	{"N25Q128",	   0x20ba18, 0x0,       64 * 1024,   256},
-	{"N25Q128A",	   0x20bb18, 0x0,       64 * 1024,   256},
-	{"N25Q256",	   0x20ba19, 0x0,       64 * 1024,   512},
-	{"N25Q256A",	   0x20bb19, 0x0,       64 * 1024,   512},
-	{"N25Q512",	   0x20ba20, 0x0,       64 * 1024,  1024},
-	{"N25Q512A",	   0x20bb20, 0x0,       64 * 1024,  1024},
-	{"N25Q1024",	   0x20ba21, 0x0,       64 * 1024,  2048},
-	{"N25Q1024A",	   0x20bb21, 0x0,       64 * 1024,  2048},
+	{"M25P10",	   0x202011, 0x0,       32 * 1024,     4,	     0},
+	{"M25P20",	   0x202012, 0x0,       64 * 1024,     4,	     0},
+	{"M25P40",	   0x202013, 0x0,       64 * 1024,     8,	     0},
+	{"M25P80",	   0x202014, 0x0,       64 * 1024,    16,	     0},
+	{"M25P16",	   0x202015, 0x0,       64 * 1024,    32,	     0},
+	{"M25P32",	   0x202016, 0x0,       64 * 1024,    64,	     0},
+	{"M25P64",	   0x202017, 0x0,       64 * 1024,   128,	     0},
+	{"M25P128",	   0x202018, 0x0,      256 * 1024,    64,	     0},
+	{"N25Q32",	   0x20ba16, 0x0,       64 * 1024,    64,	     0},
+	{"N25Q32A",	   0x20bb16, 0x0,       64 * 1024,    64,	     0},
+	{"N25Q64",	   0x20ba17, 0x0,       64 * 1024,   128,	     0},
+	{"N25Q64A",	   0x20bb17, 0x0,       64 * 1024,   128,	     0},
+	{"N25Q128",	   0x20ba18, 0x0,       64 * 1024,   256,	     0},
+	{"N25Q128A",	   0x20bb18, 0x0,       64 * 1024,   256,	     0},
+	{"N25Q256",	   0x20ba19, 0x0,       64 * 1024,   512,	     0},
+	{"N25Q256A",	   0x20bb19, 0x0,       64 * 1024,   512,	     0},
+	{"N25Q512",	   0x20ba20, 0x0,       64 * 1024,  1024,	     0},
+	{"N25Q512A",	   0x20bb20, 0x0,       64 * 1024,  1024,	     0},
+	{"N25Q1024",	   0x20ba21, 0x0,       64 * 1024,  2048,	     0},
+	{"N25Q1024A",	   0x20bb21, 0x0,       64 * 1024,  2048,	     0},
 #endif
 #ifdef CONFIG_SPI_FLASH_SST		/* SST */
-	{"SST25VF040B",	   0xbf258d, 0x0,	64 * 1024,     8},
-	{"SST25VF080B",	   0xbf258e, 0x0,	64 * 1024,    16},
-	{"SST25VF016B",	   0xbf2541, 0x0,	64 * 1024,    32},
-	{"SST25VF032B",	   0xbf254a, 0x0,	64 * 1024,    64},
-	{"SST25VF064C",	   0xbf254b, 0x0,	64 * 1024,   128},
-	{"SST25WF512",	   0xbf2501, 0x0,	64 * 1024,     1},
-	{"SST25WF010",	   0xbf2502, 0x0,	64 * 1024,     2},
-	{"SST25WF020",	   0xbf2503, 0x0,	64 * 1024,     4},
-	{"SST25WF040",	   0xbf2504, 0x0,	64 * 1024,     8},
-	{"SST25WF080",	   0xbf2505, 0x0,	64 * 1024,    16},
+	{"SST25VF040B",	   0xbf258d, 0x0,	64 * 1024,     8,	SST_WP},
+	{"SST25VF080B",	   0xbf258e, 0x0,	64 * 1024,    16,	SST_WP},
+	{"SST25VF016B",	   0xbf2541, 0x0,	64 * 1024,    32,	SST_WP},
+	{"SST25VF032B",	   0xbf254a, 0x0,	64 * 1024,    64,	SST_WP},
+	{"SST25VF064C",	   0xbf254b, 0x0,	64 * 1024,   128,	     0},
+	{"SST25WF512",	   0xbf2501, 0x0,	64 * 1024,     1,	SST_WP},
+	{"SST25WF010",	   0xbf2502, 0x0,	64 * 1024,     2,	SST_WP},
+	{"SST25WF020",	   0xbf2503, 0x0,	64 * 1024,     4,	SST_WP},
+	{"SST25WF040",	   0xbf2504, 0x0,	64 * 1024,     8,	SST_WP},
+	{"SST25WF080",	   0xbf2505, 0x0,	64 * 1024,    16,	SST_WP},
 #endif
 #ifdef CONFIG_SPI_FLASH_WINBOND		/* WINBOND */
-	{"W25P80",	   0xef2014, 0x0,	64 * 1024,    16},
-	{"W25P16",	   0xef2015, 0x0,	64 * 1024,    32},
-	{"W25P32",	   0xef2016, 0x0,	64 * 1024,    64},
-	{"W25X40",	   0xef3013, 0x0,	 4 * 1024,   128},
-	{"W25X16",	   0xef3015, 0x0,	 4 * 1024,   512},
-	{"W25X32",	   0xef3016, 0x0,	 4 * 1024,  1024},
-	{"W25X64",	   0xef3017, 0x0,	 4 * 1024,  2048},
-	{"W25Q80BL",	   0xef4014, 0x0,	 4 * 1024,   256},
-	{"W25Q16CL",	   0xef4015, 0x0,	 4 * 1024,   512},
-	{"W25Q32BV",	   0xef4016, 0x0,	 4 * 1024,  1024},
-	{"W25Q64CV",	   0xef4017, 0x0,	 4 * 1024,  2048},
-	{"W25Q128BV",	   0xef4018, 0x0,	 4 * 1024,  4096},
-	{"W25Q256",	   0xef4019, 0x0,	 4 * 1024,  8192},
-	{"W25Q80BW",	   0xef5014, 0x0,	 4 * 1024,   256},
-	{"W25Q16DW",	   0xef6015, 0x0,	 4 * 1024,   512},
-	{"W25Q32DW",	   0xef6016, 0x0,	 4 * 1024,  1024},
-	{"W25Q64DW",	   0xef6017, 0x0,	 4 * 1024,  2048},
-	{"W25Q128FW",	   0xef6018, 0x0,	 4 * 1024,  4096},
+	{"W25P80",	   0xef2014, 0x0,	64 * 1024,    16,	     0},
+	{"W25P16",	   0xef2015, 0x0,	64 * 1024,    32,	     0},
+	{"W25P32",	   0xef2016, 0x0,	64 * 1024,    64,	     0},
+	{"W25X40",	   0xef3013, 0x0,	 4 * 1024,   128,	     0},
+	{"W25X16",	   0xef3015, 0x0,	 4 * 1024,   512,	     0},
+	{"W25X32",	   0xef3016, 0x0,	 4 * 1024,  1024,	     0},
+	{"W25X64",	   0xef3017, 0x0,	 4 * 1024,  2048,	     0},
+	{"W25Q80BL",	   0xef4014, 0x0,	 4 * 1024,   256,	     0},
+	{"W25Q16CL",	   0xef4015, 0x0,	 4 * 1024,   512,	     0},
+	{"W25Q32BV",	   0xef4016, 0x0,	 4 * 1024,  1024,	     0},
+	{"W25Q64CV",	   0xef4017, 0x0,	 4 * 1024,  2048,	     0},
+	{"W25Q128BV",	   0xef4018, 0x0,	 4 * 1024,  4096,	     0},
+	{"W25Q256",	   0xef4019, 0x0,	 4 * 1024,  8192,	     0},
+	{"W25Q80BW",	   0xef5014, 0x0,	 4 * 1024,   256,	     0},
+	{"W25Q16DW",	   0xef6015, 0x0,	 4 * 1024,   512,	     0},
+	{"W25Q32DW",	   0xef6016, 0x0,	 4 * 1024,  1024,	     0},
+	{"W25Q64DW",	   0xef6017, 0x0,	 4 * 1024,  2048,	     0},
+	{"W25Q128FW",	   0xef6018, 0x0,	 4 * 1024,  4096,	     0},
 #endif
 	/*
 	 * Note:
@@ -189,6 +191,10 @@ struct spi_flash *spi_flash_validate_ids(struct spi_slave *spi, u8 *idcode)
 
 	/* Assign spi_flash ops */
 	flash->write = spi_flash_cmd_write_multi;
+#ifdef CONFIG_SPI_FLASH_SST
+	if (params->flags & SST_WP)
+		flash->write = sst_write_wp;
+#endif
 	flash->erase = spi_flash_cmd_erase;
 	flash->read = spi_flash_cmd_read_fast;
 
diff --git a/include/spi_flash.h b/include/spi_flash.h
index bfc59aa..4f35c30 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -17,6 +17,13 @@
 #include <linux/types.h>
 #include <linux/compiler.h>
 
+/* SST specific macros */
+#ifdef CONFIG_SPI_FLASH_SST
+# define SST_WP			0x01	/* Supports AAI word program */
+# define CMD_SST_BP		0x02    /* Byte Program */
+# define CMD_SST_AAI_WP		0xAD	/* Auto Address Incr Word Program */
+#endif
+
 struct spi_flash {
 	struct spi_slave *spi;
 
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 13/36] sf: probe: Add support to clear flash BP# bits
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (11 preceding siblings ...)
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 12/36] sf: probe: Add support for SST_WP Jagannadha Sutradharudu Teki
@ 2013-09-24 18:19 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 14/36] sf: probe: Add support for erase sector selection flag Jagannadha Sutradharudu Teki
                   ` (22 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:19 UTC (permalink / raw)
  To: u-boot

Few of the flashes(Atmel, Macronix and SST) require to
clear BP# bits in flash power ups.

So clear these BP# bits at probe time, so-that the flash
is ready for user operations.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 drivers/mtd/spi/spi_flash_probe.c | 6 ++++++
 include/spi_flash.h               | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index da43fda..14c2222 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -203,6 +203,12 @@ struct spi_flash *spi_flash_validate_ids(struct spi_slave *spi, u8 *idcode)
 	flash->sector_size = params->sector_size;
 	flash->size = flash->sector_size * params->nr_sectors;
 
+	/* Flash powers up read-only, so clear BP# bits */
+	if (((params->jedec >> 16) == SPI_FLASH_CFI_MFR_ATMEL) ||
+	    ((params->jedec >> 16) == SPI_FLASH_CFI_MFR_MACRONIX) ||
+	    ((params->jedec >> 16) == SPI_FLASH_CFI_MFR_SST))
+		spi_flash_cmd_write_status(flash, 0);
+
 	return flash;
 }
 
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 4f35c30..8de4e8d 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -17,6 +17,11 @@
 #include <linux/types.h>
 #include <linux/compiler.h>
 
+/* SPI flash CFI Manufacture ID's */
+#define SPI_FLASH_CFI_MFR_ATMEL			0x1f
+#define SPI_FLASH_CFI_MFR_MACRONIX		0xc2
+#define SPI_FLASH_CFI_MFR_SST			0xbf
+
 /* SST specific macros */
 #ifdef CONFIG_SPI_FLASH_SST
 # define SST_WP			0x01	/* Supports AAI word program */
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 14/36] sf: probe: Add support for erase sector selection flag
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (12 preceding siblings ...)
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 13/36] sf: probe: Add support to clear flash BP# bits Jagannadha Sutradharudu Teki
@ 2013-09-24 18:19 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 15/36] sf: probe: Add support for flag status polling Jagannadha Sutradharudu Teki
                   ` (21 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:19 UTC (permalink / raw)
  To: u-boot

SECT_4K, SECT_32K and SECT_64K opeartions are performed to
to specific flash by adding a SECT* flag on respective
spi_flash_params.flag param.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 drivers/mtd/spi/spi_flash_ops.c   |   8 +-
 drivers/mtd/spi/spi_flash_probe.c | 166 ++++++++++++++++++++------------------
 include/spi_flash.h               |  10 ++-
 3 files changed, 100 insertions(+), 84 deletions(-)

diff --git a/drivers/mtd/spi/spi_flash_ops.c b/drivers/mtd/spi/spi_flash_ops.c
index 79381b1..c408e27 100644
--- a/drivers/mtd/spi/spi_flash_ops.c
+++ b/drivers/mtd/spi/spi_flash_ops.c
@@ -153,17 +153,13 @@ int spi_flash_cmd_erase(struct spi_flash *flash, u32 offset, size_t len)
 	u8 cmd[4];
 	int ret = -1;
 
-	erase_size = flash->sector_size;
+	erase_size = flash->erase_size;
 	if (offset % erase_size || len % erase_size) {
 		debug("SF: Erase offset/length not multiple of erase size\n");
 		return -1;
 	}
 
-	if (erase_size == 4096)
-		cmd[0] = CMD_ERASE_4K;
-	else
-		cmd[0] = CMD_ERASE_64K;
-
+	cmd[0] = flash->erase_cmd;
 	while (len) {
 #ifdef CONFIG_SPI_FLASH_BAR
 		u8 bank_sel;
diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index 14c2222..9b5a055 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -39,97 +39,97 @@ struct spi_flash_params {
 
 static const struct spi_flash_params spi_flash_params_table[] = {
 #ifdef CONFIG_SPI_FLASH_ATMEL		/* ATMEL */
-	{"AT45DB011D",	   0x1f2200, 0x0,	64 * 1024,     4,	     0},
-	{"AT45DB021D",	   0x1f2300, 0x0,	64 * 1024,     8,	     0},
-	{"AT45DB041D",	   0x1f2400, 0x0,	64 * 1024,     8,	     0},
-	{"AT45DB081D",	   0x1f2500, 0x0,	64 * 1024,    16,	     0},
-	{"AT45DB161D",	   0x1f2600, 0x0,	64 * 1024,    32,	     0},
-	{"AT45DB321D",	   0x1f2700, 0x0,	64 * 1024,    64,	     0},
-	{"AT45DB641D",	   0x1f2800, 0x0,	64 * 1024,   128,	     0},
+	{"AT45DB011D",	   0x1f2200, 0x0,	64 * 1024,     4,	       SECT_4K},
+	{"AT45DB021D",	   0x1f2300, 0x0,	64 * 1024,     8,	       SECT_4K},
+	{"AT45DB041D",	   0x1f2400, 0x0,	64 * 1024,     8,	       SECT_4K},
+	{"AT45DB081D",	   0x1f2500, 0x0,	64 * 1024,    16,	       SECT_4K},
+	{"AT45DB161D",	   0x1f2600, 0x0,	64 * 1024,    32,	       SECT_4K},
+	{"AT45DB321D",	   0x1f2700, 0x0,	64 * 1024,    64,	       SECT_4K},
+	{"AT45DB641D",	   0x1f2800, 0x0,	64 * 1024,   128,	       SECT_4K},
 #endif
 #ifdef CONFIG_SPI_FLASH_EON		/* EON */
-	{"EN25Q32B",	   0x1c3016, 0x0,	64 * 1024,    64,	     0},
-	{"EN25Q128B",	   0x1c3018, 0x0,       64 * 1024,   256,	     0},
+	{"EN25Q32B",	   0x1c3016, 0x0,	64 * 1024,    64,	             0},
+	{"EN25Q128B",	   0x1c3018, 0x0,       64 * 1024,   256,	             0},
 #endif
 #ifdef CONFIG_SPI_FLASH_GIGADEVICE	/* GIGADEVICE */
-	{"GD25Q64B",	   0xc84017, 0x0,	64 * 1024,   128,	     0},
-	{"GD25LQ32",	   0xc86016, 0x0,	64 * 1024,    64,	     0},
+	{"GD25Q64B",	   0xc84017, 0x0,	64 * 1024,   128,	       SECT_4K},
+	{"GD25LQ32",	   0xc86016, 0x0,	64 * 1024,    64,	       SECT_4K},
 #endif
 #ifdef CONFIG_SPI_FLASH_MACRONIX	/* MACRONIX */
-	{"MX25L4005",	   0xc22013, 0x0,	64 * 1024,     8,	     0},
-	{"MX25L8005",	   0xc22014, 0x0,	64 * 1024,    16,	     0},
-	{"MX25L1605D",	   0xc22015, 0x0,	64 * 1024,    32,	     0},
-	{"MX25L3205D",	   0xc22016, 0x0,	64 * 1024,    64,	     0},
-	{"MX25L6405D",	   0xc22017, 0x0,	64 * 1024,   128,	     0},
-	{"MX25L12805",	   0xc22018, 0x0,	64 * 1024,   256,	     0},
-	{"MX25L12855E",	   0xc22618, 0x0,	64 * 1024,   256,	     0},
+	{"MX25L4005",	   0xc22013, 0x0,	64 * 1024,     8,	             0},
+	{"MX25L8005",	   0xc22014, 0x0,	64 * 1024,    16,	             0},
+	{"MX25L1605D",	   0xc22015, 0x0,	64 * 1024,    32,	             0},
+	{"MX25L3205D",	   0xc22016, 0x0,	64 * 1024,    64,	             0},
+	{"MX25L6405D",	   0xc22017, 0x0,	64 * 1024,   128,	             0},
+	{"MX25L12805",	   0xc22018, 0x0,	64 * 1024,   256,	             0},
+	{"MX25L12855E",	   0xc22618, 0x0,	64 * 1024,   256,	             0},
 #endif
 #ifdef CONFIG_SPI_FLASH_SPANSION	/* SPANSION */
-	{"S25FL008A",	   0x010213, 0x0,	64 * 1024,    16,	     0},
-	{"S25FL016A",	   0x010214, 0x0,	64 * 1024,    32,	     0},
-	{"S25FL032A",	   0x010215, 0x0,	64 * 1024,    64,	     0},
-	{"S25FL064A",	   0x010216, 0x0,	64 * 1024,   128,	     0},
-	{"S25FL128P_256K", 0x012018, 0x0300,   256 * 1024,    64,	     0},
-	{"S25FL128P_64K",  0x012018, 0x0301,    64 * 1024,   256,	     0},
-	{"S25FL032P",	   0x010215, 0x4d00,    64 * 1024,    64,	     0},
-	{"S25FL064P",	   0x010216, 0x4d00,    64 * 1024,   128,	     0},
-	{"S25FL128S_64K",  0x012018, 0x4d01,    64 * 1024,   256,	     0},
-	{"S25FL256S_64K",  0x010219, 0x4d01,    64 * 1024,   512,	     0},
-	{"S25FL512S_64K",  0x010220, 0x4d01,    64 * 1024,  1024,	     0},
+	{"S25FL008A",	   0x010213, 0x0,	64 * 1024,    16,	             0},
+	{"S25FL016A",	   0x010214, 0x0,	64 * 1024,    32,	             0},
+	{"S25FL032A",	   0x010215, 0x0,	64 * 1024,    64,	             0},
+	{"S25FL064A",	   0x010216, 0x0,	64 * 1024,   128,	             0},
+	{"S25FL128P_256K", 0x012018, 0x0300,   256 * 1024,    64,	             0},
+	{"S25FL128P_64K",  0x012018, 0x0301,    64 * 1024,   256,	             0},
+	{"S25FL032P",	   0x010215, 0x4d00,    64 * 1024,    64,	             0},
+	{"S25FL064P",	   0x010216, 0x4d00,    64 * 1024,   128,	             0},
+	{"S25FL128S_64K",  0x012018, 0x4d01,    64 * 1024,   256,		     0},
+	{"S25FL256S_64K",  0x010219, 0x4d01,    64 * 1024,   512,	             0},
+	{"S25FL512S_64K",  0x010220, 0x4d01,    64 * 1024,  1024,	             0},
 #endif
 #ifdef CONFIG_SPI_FLASH_STMICRO		/* STMICRO */
-	{"M25P10",	   0x202011, 0x0,       32 * 1024,     4,	     0},
-	{"M25P20",	   0x202012, 0x0,       64 * 1024,     4,	     0},
-	{"M25P40",	   0x202013, 0x0,       64 * 1024,     8,	     0},
-	{"M25P80",	   0x202014, 0x0,       64 * 1024,    16,	     0},
-	{"M25P16",	   0x202015, 0x0,       64 * 1024,    32,	     0},
-	{"M25P32",	   0x202016, 0x0,       64 * 1024,    64,	     0},
-	{"M25P64",	   0x202017, 0x0,       64 * 1024,   128,	     0},
-	{"M25P128",	   0x202018, 0x0,      256 * 1024,    64,	     0},
-	{"N25Q32",	   0x20ba16, 0x0,       64 * 1024,    64,	     0},
-	{"N25Q32A",	   0x20bb16, 0x0,       64 * 1024,    64,	     0},
-	{"N25Q64",	   0x20ba17, 0x0,       64 * 1024,   128,	     0},
-	{"N25Q64A",	   0x20bb17, 0x0,       64 * 1024,   128,	     0},
-	{"N25Q128",	   0x20ba18, 0x0,       64 * 1024,   256,	     0},
-	{"N25Q128A",	   0x20bb18, 0x0,       64 * 1024,   256,	     0},
-	{"N25Q256",	   0x20ba19, 0x0,       64 * 1024,   512,	     0},
-	{"N25Q256A",	   0x20bb19, 0x0,       64 * 1024,   512,	     0},
-	{"N25Q512",	   0x20ba20, 0x0,       64 * 1024,  1024,	     0},
-	{"N25Q512A",	   0x20bb20, 0x0,       64 * 1024,  1024,	     0},
-	{"N25Q1024",	   0x20ba21, 0x0,       64 * 1024,  2048,	     0},
-	{"N25Q1024A",	   0x20bb21, 0x0,       64 * 1024,  2048,	     0},
+	{"M25P10",	   0x202011, 0x0,       32 * 1024,     4,	             0},
+	{"M25P20",	   0x202012, 0x0,       64 * 1024,     4,	             0},
+	{"M25P40",	   0x202013, 0x0,       64 * 1024,     8,	             0},
+	{"M25P80",	   0x202014, 0x0,       64 * 1024,    16,	             0},
+	{"M25P16",	   0x202015, 0x0,       64 * 1024,    32,	             0},
+	{"M25P32",	   0x202016, 0x0,       64 * 1024,    64,	             0},
+	{"M25P64",	   0x202017, 0x0,       64 * 1024,   128,	             0},
+	{"M25P128",	   0x202018, 0x0,      256 * 1024,    64,	             0},
+	{"N25Q32",	   0x20ba16, 0x0,       64 * 1024,    64,	       SECT_4K},
+	{"N25Q32A",	   0x20bb16, 0x0,       64 * 1024,    64,	       SECT_4K},
+	{"N25Q64",	   0x20ba17, 0x0,       64 * 1024,   128,	       SECT_4K},
+	{"N25Q64A",	   0x20bb17, 0x0,       64 * 1024,   128,	       SECT_4K},
+	{"N25Q128",	   0x20ba18, 0x0,       64 * 1024,   256,	       SECT_4K},
+	{"N25Q128A",	   0x20bb18, 0x0,       64 * 1024,   256,	       SECT_4K},
+	{"N25Q256",	   0x20ba19, 0x0,       64 * 1024,   512,	       SECT_4K},
+	{"N25Q256A",	   0x20bb19, 0x0,       64 * 1024,   512,	       SECT_4K},
+	{"N25Q512",	   0x20ba20, 0x0,       64 * 1024,  1024,	       SECT_4K},
+	{"N25Q512A",	   0x20bb20, 0x0,       64 * 1024,  1024,	       SECT_4K},
+	{"N25Q1024",	   0x20ba21, 0x0,       64 * 1024,  2048,	       SECT_4K},
+	{"N25Q1024A",	   0x20bb21, 0x0,       64 * 1024,  2048,	       SECT_4K},
 #endif
 #ifdef CONFIG_SPI_FLASH_SST		/* SST */
-	{"SST25VF040B",	   0xbf258d, 0x0,	64 * 1024,     8,	SST_WP},
-	{"SST25VF080B",	   0xbf258e, 0x0,	64 * 1024,    16,	SST_WP},
-	{"SST25VF016B",	   0xbf2541, 0x0,	64 * 1024,    32,	SST_WP},
-	{"SST25VF032B",	   0xbf254a, 0x0,	64 * 1024,    64,	SST_WP},
-	{"SST25VF064C",	   0xbf254b, 0x0,	64 * 1024,   128,	     0},
-	{"SST25WF512",	   0xbf2501, 0x0,	64 * 1024,     1,	SST_WP},
-	{"SST25WF010",	   0xbf2502, 0x0,	64 * 1024,     2,	SST_WP},
-	{"SST25WF020",	   0xbf2503, 0x0,	64 * 1024,     4,	SST_WP},
-	{"SST25WF040",	   0xbf2504, 0x0,	64 * 1024,     8,	SST_WP},
-	{"SST25WF080",	   0xbf2505, 0x0,	64 * 1024,    16,	SST_WP},
+	{"SST25VF040B",	   0xbf258d, 0x0,	64 * 1024,     8,     SECT_4K | SST_WP},
+	{"SST25VF080B",	   0xbf258e, 0x0,	64 * 1024,    16,     SECT_4K | SST_WP},
+	{"SST25VF016B",	   0xbf2541, 0x0,	64 * 1024,    32,     SECT_4K | SST_WP},
+	{"SST25VF032B",	   0xbf254a, 0x0,	64 * 1024,    64,     SECT_4K | SST_WP},
+	{"SST25VF064C",	   0xbf254b, 0x0,	64 * 1024,   128,	       SECT_4K},
+	{"SST25WF512",	   0xbf2501, 0x0,	64 * 1024,     1,     SECT_4K | SST_WP},
+	{"SST25WF010",	   0xbf2502, 0x0,	64 * 1024,     2,     SECT_4K | SST_WP},
+	{"SST25WF020",	   0xbf2503, 0x0,	64 * 1024,     4,     SECT_4K | SST_WP},
+	{"SST25WF040",	   0xbf2504, 0x0,	64 * 1024,     8,     SECT_4K | SST_WP},
+	{"SST25WF080",	   0xbf2505, 0x0,	64 * 1024,    16,     SECT_4K | SST_WP},
 #endif
 #ifdef CONFIG_SPI_FLASH_WINBOND		/* WINBOND */
-	{"W25P80",	   0xef2014, 0x0,	64 * 1024,    16,	     0},
-	{"W25P16",	   0xef2015, 0x0,	64 * 1024,    32,	     0},
-	{"W25P32",	   0xef2016, 0x0,	64 * 1024,    64,	     0},
-	{"W25X40",	   0xef3013, 0x0,	 4 * 1024,   128,	     0},
-	{"W25X16",	   0xef3015, 0x0,	 4 * 1024,   512,	     0},
-	{"W25X32",	   0xef3016, 0x0,	 4 * 1024,  1024,	     0},
-	{"W25X64",	   0xef3017, 0x0,	 4 * 1024,  2048,	     0},
-	{"W25Q80BL",	   0xef4014, 0x0,	 4 * 1024,   256,	     0},
-	{"W25Q16CL",	   0xef4015, 0x0,	 4 * 1024,   512,	     0},
-	{"W25Q32BV",	   0xef4016, 0x0,	 4 * 1024,  1024,	     0},
-	{"W25Q64CV",	   0xef4017, 0x0,	 4 * 1024,  2048,	     0},
-	{"W25Q128BV",	   0xef4018, 0x0,	 4 * 1024,  4096,	     0},
-	{"W25Q256",	   0xef4019, 0x0,	 4 * 1024,  8192,	     0},
-	{"W25Q80BW",	   0xef5014, 0x0,	 4 * 1024,   256,	     0},
-	{"W25Q16DW",	   0xef6015, 0x0,	 4 * 1024,   512,	     0},
-	{"W25Q32DW",	   0xef6016, 0x0,	 4 * 1024,  1024,	     0},
-	{"W25Q64DW",	   0xef6017, 0x0,	 4 * 1024,  2048,	     0},
-	{"W25Q128FW",	   0xef6018, 0x0,	 4 * 1024,  4096,	     0},
+	{"W25P80",	   0xef2014, 0x0,	64 * 1024,    16,		     0},
+	{"W25P16",	   0xef2015, 0x0,	64 * 1024,    32,		     0},
+	{"W25P32",	   0xef2016, 0x0,	64 * 1024,    64,		     0},
+	{"W25X40",	   0xef3013, 0x0,	 4 * 1024,   128,	       SECT_4K},
+	{"W25X16",	   0xef3015, 0x0,	 4 * 1024,   512,	       SECT_4K},
+	{"W25X32",	   0xef3016, 0x0,	 4 * 1024,  1024,	       SECT_4K},
+	{"W25X64",	   0xef3017, 0x0,	 4 * 1024,  2048,	       SECT_4K},
+	{"W25Q80BL",	   0xef4014, 0x0,	 4 * 1024,   256,	       SECT_4K},
+	{"W25Q16CL",	   0xef4015, 0x0,	 4 * 1024,   512,	       SECT_4K},
+	{"W25Q32BV",	   0xef4016, 0x0,	 4 * 1024,  1024,	       SECT_4K},
+	{"W25Q64CV",	   0xef4017, 0x0,	 4 * 1024,  2048,	       SECT_4K},
+	{"W25Q128BV",	   0xef4018, 0x0,	 4 * 1024,  4096,	       SECT_4K},
+	{"W25Q256",	   0xef4019, 0x0,	 4 * 1024,  8192,	       SECT_4K},
+	{"W25Q80BW",	   0xef5014, 0x0,	 4 * 1024,   256,	       SECT_4K},
+	{"W25Q16DW",	   0xef6015, 0x0,	 4 * 1024,   512,	       SECT_4K},
+	{"W25Q32DW",	   0xef6016, 0x0,	 4 * 1024,  1024,	       SECT_4K},
+	{"W25Q64DW",	   0xef6017, 0x0,	 4 * 1024,  2048,	       SECT_4K},
+	{"W25Q128FW",	   0xef6018, 0x0,	 4 * 1024,  4096,	       SECT_4K},
 #endif
 	/*
 	 * Note:
@@ -203,6 +203,18 @@ struct spi_flash *spi_flash_validate_ids(struct spi_slave *spi, u8 *idcode)
 	flash->sector_size = params->sector_size;
 	flash->size = flash->sector_size * params->nr_sectors;
 
+	/* Compute erase sector and command */
+	if (params->flags & SECT_4K) {
+		flash->erase_cmd = CMD_ERASE_4K;
+		flash->erase_size = 4096;
+	} else if (params->flags & SECT_32K) {
+		flash->erase_cmd = CMD_ERASE_32K;
+		flash->erase_size = 32768;
+	} else {
+		flash->erase_cmd = CMD_ERASE_64K;
+		flash->erase_size = flash->sector_size;
+	}
+
 	/* Flash powers up read-only, so clear BP# bits */
 	if (((params->jedec >> 16) == SPI_FLASH_CFI_MFR_ATMEL) ||
 	    ((params->jedec >> 16) == SPI_FLASH_CFI_MFR_MACRONIX) ||
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 8de4e8d..387af86 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -22,6 +22,10 @@
 #define SPI_FLASH_CFI_MFR_MACRONIX		0xc2
 #define SPI_FLASH_CFI_MFR_SST			0xbf
 
+/* SECT flags */
+#define SECT_4K			(1 << 0)
+#define SECT_32K		(1 << 1)
+
 /* SST specific macros */
 #ifdef CONFIG_SPI_FLASH_SST
 # define SST_WP			0x01	/* Supports AAI word program */
@@ -38,8 +42,10 @@ struct spi_flash {
 	u32		size;
 	/* Write (page) size */
 	u32		page_size;
-	/* Erase (sector) size */
+	/* Sector size */
 	u32		sector_size;
+	/* Erase size */
+	u32		erase_size;
 #ifdef CONFIG_SPI_FLASH_BAR
 	/* Bank read cmd */
 	u8		bank_read_cmd;
@@ -50,6 +56,8 @@ struct spi_flash {
 #endif
 	/* Poll cmd - for flash erase/program */
 	u8		poll_cmd;
+	/* Erase cmd 4K, 32K, 64K */
+	u8		erase_cmd;
 
 	void *memory_map;	/* Address of read-only SPI flash access */
 	int		(*read)(struct spi_flash *flash, u32 offset,
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 15/36] sf: probe: Add support for flag status polling
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (13 preceding siblings ...)
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 14/36] sf: probe: Add support for erase sector selection flag Jagannadha Sutradharudu Teki
@ 2013-09-24 18:19 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 16/36] sf: probe: Move BAR config to spi_flash_validate_ids Jagannadha Sutradharudu Teki
                   ` (20 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:19 UTC (permalink / raw)
  To: u-boot



^ permalink raw reply	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 16/36] sf: probe: Move BAR config to spi_flash_validate_ids
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (14 preceding siblings ...)
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 15/36] sf: probe: Add support for flag status polling Jagannadha Sutradharudu Teki
@ 2013-09-24 18:19 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 17/36] sf: Add proper comment style on spi_flash structure Jagannadha Sutradharudu Teki
                   ` (19 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:19 UTC (permalink / raw)
  To: u-boot

Moved BAR config to spi_flash_validate_ids, so its
better to have all flash initalization at once.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 drivers/mtd/spi/spi_flash_internal.h |  5 -----
 drivers/mtd/spi/spi_flash_probe.c    | 24 +++++++++++-------------
 include/spi_flash.h                  |  3 +++
 3 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h
index ce34ce0..6227d2e 100644
--- a/drivers/mtd/spi/spi_flash_internal.h
+++ b/drivers/mtd/spi/spi_flash_internal.h
@@ -31,11 +31,6 @@
 
 #define SPI_FLASH_16MB_BOUN		0x1000000
 
-/* Manufacture ID's */
-#define SPI_FLASH_SPANSION_IDCODE0	0x01
-#define SPI_FLASH_STMICRO_IDCODE0	0x20
-#define SPI_FLASH_WINBOND_IDCODE0	0xef
-
 #ifdef CONFIG_SPI_FLASH_BAR
 /* Bank addr access commands */
 # define CMD_BANKADDR_BRWR		0x17
diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index c62a1ee..b62ec54 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -219,6 +219,12 @@ struct spi_flash *spi_flash_validate_ids(struct spi_slave *spi, u8 *idcode)
 	if (params->flags & E_FSR)
 		flash->poll_cmd = CMD_FLAG_STATUS;
 
+#ifdef CONFIG_SPI_FLASH_BAR
+	/* Configure the BAR - discover bank cmds and read current bank  */
+	if (spi_flash_bank_config(flash, idcode[0]) < 0)
+		return NULL;
+#endif
+
 	/* Flash powers up read-only, so clear BP# bits */
 	if (((params->jedec >> 16) == SPI_FLASH_CFI_MFR_ATMEL) ||
 	    ((params->jedec >> 16) == SPI_FLASH_CFI_MFR_MACRONIX) ||
@@ -236,12 +242,12 @@ int spi_flash_bank_config(struct spi_flash *flash, u8 idcode0)
 
 	/* discover bank cmds */
 	switch (idcode0) {
-	case SPI_FLASH_SPANSION_IDCODE0:
+	case SPI_FLASH_CFI_MFR_SPANSION:
 		flash->bank_read_cmd = CMD_BANKADDR_BRRD;
 		flash->bank_write_cmd = CMD_BANKADDR_BRWR;
 		break;
-	case SPI_FLASH_STMICRO_IDCODE0:
-	case SPI_FLASH_WINBOND_IDCODE0:
+	case SPI_FLASH_CFI_MFR_STMICRO:
+	case SPI_FLASH_CFI_MFR_WINBOND:
 		flash->bank_read_cmd = CMD_EXTNADDR_RDEAR;
 		flash->bank_write_cmd = CMD_EXTNADDR_WREAR;
 		break;
@@ -299,7 +305,7 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
 {
 	struct spi_slave *spi;
 	struct spi_flash *flash = NULL;
-	u8 idcode[5], *idp;
+	u8 idcode[5];
 	int ret;
 
 	/* Setup spi_slave */
@@ -329,18 +335,10 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
 #endif
 
 	/* Validate ID's from flash dev table */
-	idp = idcode;
-	flash = spi_flash_validate_ids(spi, idp);
+	flash = spi_flash_validate_ids(spi, idcode);
 	if (!flash)
 		goto err_read_id;
 
-#ifdef CONFIG_SPI_FLASH_BAR
-	/* Configure the BAR - discover bank cmds and read current bank  */
-	ret = spi_flash_bank_config(flash, *idp);
-	if (ret < 0)
-		goto err_read_id;
-#endif
-
 #ifdef CONFIG_OF_CONTROL
 	if (spi_flash_decode_fdt(gd->fdt_blob, flash)) {
 		debug("SF: FDT decode error\n");
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 3e60fdc..14e4ae2 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -20,7 +20,10 @@
 /* SPI flash CFI Manufacture ID's */
 #define SPI_FLASH_CFI_MFR_ATMEL			0x1f
 #define SPI_FLASH_CFI_MFR_MACRONIX		0xc2
+#define SPI_FLASH_CFI_MFR_SPANSION		0x01
 #define SPI_FLASH_CFI_MFR_SST			0xbf
+#define SPI_FLASH_CFI_MFR_STMICRO		0x20
+#define SPI_FLASH_CFI_MFR_WINBOND		0xef
 
 /* SECT flags */
 #define SECT_4K			(1 << 0)
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 17/36] sf: Add proper comment style on spi_flash structure
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (15 preceding siblings ...)
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 16/36] sf: probe: Move BAR config to spi_flash_validate_ids Jagannadha Sutradharudu Teki
@ 2013-09-24 18:19 ` Jagannadha Sutradharudu Teki
  2013-09-26 23:10   ` Simon Glass
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 18/36] sf: ramtron: Add support for separate flash driver Jagannadha Sutradharudu Teki
                   ` (18 subsequent siblings)
  35 siblings, 1 reply; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:19 UTC (permalink / raw)
  To: u-boot

Added proper comment style on spi_flash structure to make
more readable.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 include/spi_flash.h | 63 +++++++++++++++++++++++++++++------------------------
 1 file changed, 35 insertions(+), 28 deletions(-)

diff --git a/include/spi_flash.h b/include/spi_flash.h
index 14e4ae2..34a167b 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -37,39 +37,46 @@
 # define CMD_SST_AAI_WP		0xAD	/* Auto Address Incr Word Program */
 #endif
 
+/**
+ * struct spi_flash - SPI flash structure
+ *
+ * @spi:		SPI slave
+ * @name:		Name of SPI flash
+ * @size:		Total flash size
+ * @page_size:		Write (page) size
+ * @sector_size:	Sector size
+ * @erase_size:		Erase size
+ * @bank_read_cmd:	Bank read cmd
+ * @bank_write_cmd:	Bank write cmd
+ * @bank_curr:		Current flash bank
+ * @poll_cmd:		Poll cmd - for flash erase/program
+ * @erase_cmd:		Erase cmd 4K, 32K, 64K
+ * @memory_map:		Address of read-only SPI flash access
+ * @read:		Flash read ops
+ * @write:		Flash write ops
+ * @erase:		Flash erase ops
+ */
 struct spi_flash {
 	struct spi_slave *spi;
+	const char *name;
 
-	const char	*name;
-
-	/* Total flash size */
-	u32		size;
-	/* Write (page) size */
-	u32		page_size;
-	/* Sector size */
-	u32		sector_size;
-	/* Erase size */
-	u32		erase_size;
+	u32 size;
+	u32 page_size;
+	u32 sector_size;
+	u32 erase_size;
 #ifdef CONFIG_SPI_FLASH_BAR
-	/* Bank read cmd */
-	u8		bank_read_cmd;
-	/* Bank write cmd */
-	u8		bank_write_cmd;
-	/* Current flash bank */
-	u8		bank_curr;
+	u8 bank_read_cmd;
+	u8 bank_write_cmd;
+	u8 bank_curr;
 #endif
-	/* Poll cmd - for flash erase/program */
-	u8		poll_cmd;
-	/* Erase cmd 4K, 32K, 64K */
-	u8		erase_cmd;
-
-	void *memory_map;	/* Address of read-only SPI flash access */
-	int		(*read)(struct spi_flash *flash, u32 offset,
-				size_t len, void *buf);
-	int		(*write)(struct spi_flash *flash, u32 offset,
-				size_t len, const void *buf);
-	int		(*erase)(struct spi_flash *flash, u32 offset,
-				size_t len);
+	u8 poll_cmd;
+	u8 erase_cmd;
+
+	void *memory_map;
+	int (*read)(struct spi_flash *flash, u32 offset, size_t len, void *buf);
+	int (*write)(struct spi_flash *flash, u32 offset, size_t len,
+			const void *buf);
+	int (*erase)(struct spi_flash *flash, u32 offset, size_t len);
 };
 
 /**
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 18/36] sf: ramtron: Add support for separate flash driver
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (16 preceding siblings ...)
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 17/36] sf: Add proper comment style on spi_flash structure Jagannadha Sutradharudu Teki
@ 2013-09-24 18:19 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 19/36] sf: Remove unneeded flash drivers files Jagannadha Sutradharudu Teki
                   ` (17 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:19 UTC (permalink / raw)
  To: u-boot

Compared to other spi flashes, ramtron has a different
probing and implementation on flash ops, hence moved
ramtron probe code into ramtron driver.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 drivers/mtd/spi/Makefile                 |   5 +-
 drivers/mtd/spi/ramtron.c                | 123 +++++++++++++-
 drivers/mtd/spi/spi_flash_probe.c        |   4 -
 drivers/mtd/spi/spi_flash_probe_legacy.c | 276 -------------------------------
 include/configs/top9000.h                |   1 -
 5 files changed, 125 insertions(+), 284 deletions(-)
 delete mode 100644 drivers/mtd/spi/spi_flash_probe_legacy.c

diff --git a/drivers/mtd/spi/Makefile b/drivers/mtd/spi/Makefile
index a10c850..2605e57 100644
--- a/drivers/mtd/spi/Makefile
+++ b/drivers/mtd/spi/Makefile
@@ -14,7 +14,10 @@ COBJS-$(CONFIG_SPL_SPI_LOAD)	+= spi_spl_load.o
 COBJS-$(CONFIG_SPL_SPI_BOOT)	+= fsl_espi_spl.o
 endif
 
-COBJS-$(CONFIG_SPI_FLASH) += spi_flash_probe_legacy.o spi_flash_ops.o spi_flash.o
+ifdef CONFIG_CMD_SF
+COBJS-y        += spi_flash.o
+endif
+COBJS-$(CONFIG_SPI_FLASH)	+= spi_flash_probe.o spi_flash_ops.o
 COBJS-$(CONFIG_SPI_FLASH_ATMEL)	+= atmel.o
 COBJS-$(CONFIG_SPI_FLASH_EON)	+= eon.o
 COBJS-$(CONFIG_SPI_FLASH_GIGADEVICE)	+= gigadevice.o
diff --git a/drivers/mtd/spi/ramtron.c b/drivers/mtd/spi/ramtron.c
index 38f9d69..c9701d0 100644
--- a/drivers/mtd/spi/ramtron.c
+++ b/drivers/mtd/spi/ramtron.c
@@ -214,7 +214,8 @@ static int ramtron_erase(struct spi_flash *flash, u32 offset, size_t len)
  * nore: we are called here with idcode pointing to the first non-0x7f byte
  * already!
  */
-struct spi_flash *spi_fram_probe_ramtron(struct spi_slave *spi, u8 *idcode)
+static struct spi_flash *spi_fram_probe_ramtron(struct spi_slave *spi,
+		u8 *idcode)
 {
 	const struct ramtron_spi_fram_params *params;
 	struct ramtron_spi_fram *sn;
@@ -270,7 +271,7 @@ struct spi_flash *spi_fram_probe_ramtron(struct spi_slave *spi, u8 *idcode)
 	return NULL;
 
 found:
-	sn = spi_flash_alloc(struct ramtron_spi_fram, spi, params->name);
+	sn = malloc(sizeof(*sn));
 	if (!sn) {
 		debug("SF: Failed to allocate memory\n");
 		return NULL;
@@ -285,3 +286,121 @@ found:
 
 	return &sn->flash;
 }
+
+/*
+ * The following table holds all device probe functions
+ * (All flashes are removed and implemented a common probe at
+ *  spi_flash_probe.c)
+ *
+ * shift:  number of continuation bytes before the ID
+ * idcode: the expected IDCODE or 0xff for non JEDEC devices
+ * probe:  the function to call
+ *
+ * Non JEDEC devices should be ordered in the table such that
+ * the probe functions with best detection algorithms come first.
+ *
+ * Several matching entries are permitted, they will be tried
+ * in sequence until a probe function returns non NULL.
+ *
+ * IDCODE_CONT_LEN may be redefined if a device needs to declare a
+ * larger "shift" value.  IDCODE_PART_LEN generally shouldn't be
+ * changed.  This is the max number of bytes probe functions may
+ * examine when looking up part-specific identification info.
+ *
+ * Probe functions will be given the idcode buffer starting at their
+ * manu id byte (the "idcode" in the table below).  In other words,
+ * all of the continuation bytes will be skipped (the "shift" below).
+ */
+#define IDCODE_CONT_LEN 0
+#define IDCODE_PART_LEN 5
+static const struct {
+	const u8 shift;
+	const u8 idcode;
+	struct spi_flash *(*probe) (struct spi_slave *spi, u8 *idcode);
+} flashes[] = {
+	/* Keep it sorted by define name */
+#ifdef CONFIG_SPI_FRAM_RAMTRON
+	{ 6, 0xc2, spi_fram_probe_ramtron, },
+# undef IDCODE_CONT_LEN
+# define IDCODE_CONT_LEN 6
+#endif
+#ifdef CONFIG_SPI_FRAM_RAMTRON_NON_JEDEC
+	{ 0, 0xff, spi_fram_probe_ramtron, },
+#endif
+};
+#define IDCODE_LEN (IDCODE_CONT_LEN + IDCODE_PART_LEN)
+
+struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
+		unsigned int max_hz, unsigned int spi_mode)
+{
+	struct spi_slave *spi;
+	struct spi_flash *flash = NULL;
+	int ret, i, shift;
+	u8 idcode[IDCODE_LEN], *idp;
+
+	spi = spi_setup_slave(bus, cs, max_hz, spi_mode);
+	if (!spi) {
+		printf("SF: Failed to set up slave\n");
+		return NULL;
+	}
+
+	ret = spi_claim_bus(spi);
+	if (ret) {
+		debug("SF: Failed to claim SPI bus: %d\n", ret);
+		goto err_claim_bus;
+	}
+
+	/* Read the ID codes */
+	ret = spi_flash_cmd(spi, CMD_READ_ID, idcode, sizeof(idcode));
+	if (ret)
+		goto err_read_id;
+
+#ifdef DEBUG
+	printf("SF: Got idcodes\n");
+	print_buffer(0, idcode, 1, sizeof(idcode), 0);
+#endif
+
+	/* count the number of continuation bytes */
+	for (shift = 0, idp = idcode;
+	     shift < IDCODE_CONT_LEN && *idp == 0x7f;
+	     ++shift, ++idp)
+		continue;
+
+	/* search the table for matches in shift and id */
+	for (i = 0; i < ARRAY_SIZE(flashes); ++i)
+		if (flashes[i].shift == shift && flashes[i].idcode == *idp) {
+			/* we have a match, call probe */
+			flash = flashes[i].probe(spi, idp);
+			if (flash)
+				break;
+		}
+
+	if (!flash) {
+		printf("SF: Unsupported manufacturer %02x\n", *idp);
+		goto err_manufacturer_probe;
+	}
+
+	printf("SF: Detected %s with page size ", flash->name);
+	print_size(flash->sector_size, ", total ");
+	print_size(flash->size, "");
+	if (flash->memory_map)
+		printf(", mapped at %p", flash->memory_map);
+	puts("\n");
+
+	spi_release_bus(spi);
+
+	return flash;
+
+err_manufacturer_probe:
+err_read_id:
+	spi_release_bus(spi);
+err_claim_bus:
+	spi_free_slave(spi);
+	return NULL;
+}
+
+void spi_flash_free(struct spi_flash *flash)
+{
+	spi_free_slave(flash->spi);
+	free(flash);
+}
diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index b62ec54..ed5b938 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -144,10 +144,6 @@ static const struct spi_flash_params spi_flash_params_table[] = {
 	 * (W25Q64DW, W25Q64FV_QPI)
 	 * (W25Q128FW, W25Q128FV_QPI)
 	 */
-	/*
-	 * TODO:
-	 * RAMTRON
-	 */
 };
 
 struct spi_flash *spi_flash_validate_ids(struct spi_slave *spi, u8 *idcode)
diff --git a/drivers/mtd/spi/spi_flash_probe_legacy.c b/drivers/mtd/spi/spi_flash_probe_legacy.c
deleted file mode 100644
index 32ec578..0000000
--- a/drivers/mtd/spi/spi_flash_probe_legacy.c
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * SPI flash probing
- *
- * Copyright (C) 2008 Atmel Corporation
- * Copyright (C) 2010 Reinhard Meyer, EMK Elektronik
- * Copyright (C) 2013 Jagannadha Sutradharudu Teki, Xilinx Inc.
- *
- * Licensed under the GPL-2 or later.
- */
-
-#include <common.h>
-#include <fdtdec.h>
-#include <malloc.h>
-#include <spi.h>
-#include <spi_flash.h>
-
-#include "spi_flash_internal.h"
-
-DECLARE_GLOBAL_DATA_PTR;
-
-#ifdef CONFIG_SPI_FLASH_BAR
-int spi_flash_bank_config(struct spi_flash *flash, u8 idcode0)
-{
-	u8 cmd;
-	u8 curr_bank = 0;
-
-	/* discover bank cmds */
-	switch (idcode0) {
-	case SPI_FLASH_SPANSION_IDCODE0:
-		flash->bank_read_cmd = CMD_BANKADDR_BRRD;
-		flash->bank_write_cmd = CMD_BANKADDR_BRWR;
-		break;
-	case SPI_FLASH_STMICRO_IDCODE0:
-	case SPI_FLASH_WINBOND_IDCODE0:
-		flash->bank_read_cmd = CMD_EXTNADDR_RDEAR;
-		flash->bank_write_cmd = CMD_EXTNADDR_WREAR;
-		break;
-	default:
-		printf("SF: Unsupported bank commands %02x\n", idcode0);
-		return -1;
-	}
-
-	/* read the bank reg - on which bank the flash is in currently */
-	cmd = flash->bank_read_cmd;
-	if (flash->size > SPI_FLASH_16MB_BOUN) {
-		if (spi_flash_read_common(flash, &cmd, 1, &curr_bank, 1)) {
-			debug("SF: fail to read bank addr register\n");
-			return -1;
-		}
-		flash->bank_curr = curr_bank;
-	} else {
-		flash->bank_curr = curr_bank;
-	}
-
-	return 0;
-}
-#endif
-
-#ifdef CONFIG_OF_CONTROL
-int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash)
-{
-	fdt_addr_t addr;
-	fdt_size_t size;
-	int node;
-
-	/* If there is no node, do nothing */
-	node = fdtdec_next_compatible(blob, 0, COMPAT_GENERIC_SPI_FLASH);
-	if (node < 0)
-		return 0;
-
-	addr = fdtdec_get_addr_size(blob, node, "memory-map", &size);
-	if (addr == FDT_ADDR_T_NONE) {
-		debug("%s: Cannot decode address\n", __func__);
-		return 0;
-	}
-
-	if (flash->size != size) {
-		debug("%s: Memory map must cover entire device\n", __func__);
-		return -1;
-	}
-	flash->memory_map = (void *)addr;
-
-	return 0;
-}
-#endif /* CONFIG_OF_CONTROL */
-
-/*
- * The following table holds all device probe functions
- *
- * shift:  number of continuation bytes before the ID
- * idcode: the expected IDCODE or 0xff for non JEDEC devices
- * probe:  the function to call
- *
- * Non JEDEC devices should be ordered in the table such that
- * the probe functions with best detection algorithms come first.
- *
- * Several matching entries are permitted, they will be tried
- * in sequence until a probe function returns non NULL.
- *
- * IDCODE_CONT_LEN may be redefined if a device needs to declare a
- * larger "shift" value.  IDCODE_PART_LEN generally shouldn't be
- * changed.  This is the max number of bytes probe functions may
- * examine when looking up part-specific identification info.
- *
- * Probe functions will be given the idcode buffer starting at their
- * manu id byte (the "idcode" in the table below).  In other words,
- * all of the continuation bytes will be skipped (the "shift" below).
- */
-#define IDCODE_CONT_LEN 0
-#define IDCODE_PART_LEN 5
-static const struct {
-	const u8 shift;
-	const u8 idcode;
-	struct spi_flash *(*probe) (struct spi_slave *spi, u8 *idcode);
-} flashes[] = {
-	/* Keep it sorted by define name */
-#ifdef CONFIG_SPI_FLASH_ATMEL
-	{ 0, 0x1f, spi_flash_probe_atmel, },
-#endif
-#ifdef CONFIG_SPI_FLASH_EON
-	{ 0, 0x1c, spi_flash_probe_eon, },
-#endif
-#ifdef CONFIG_SPI_FLASH_GIGADEVICE
-	{ 0, 0xc8, spi_flash_probe_gigadevice, },
-#endif
-#ifdef CONFIG_SPI_FLASH_MACRONIX
-	{ 0, 0xc2, spi_flash_probe_macronix, },
-#endif
-#ifdef CONFIG_SPI_FLASH_SPANSION
-	{ 0, 0x01, spi_flash_probe_spansion, },
-#endif
-#ifdef CONFIG_SPI_FLASH_SST
-	{ 0, 0xbf, spi_flash_probe_sst, },
-#endif
-#ifdef CONFIG_SPI_FLASH_STMICRO
-	{ 0, 0x20, spi_flash_probe_stmicro, },
-#endif
-#ifdef CONFIG_SPI_FLASH_WINBOND
-	{ 0, 0xef, spi_flash_probe_winbond, },
-#endif
-#ifdef CONFIG_SPI_FRAM_RAMTRON
-	{ 6, 0xc2, spi_fram_probe_ramtron, },
-# undef IDCODE_CONT_LEN
-# define IDCODE_CONT_LEN 6
-#endif
-	/* Keep it sorted by best detection */
-#ifdef CONFIG_SPI_FLASH_STMICRO
-	{ 0, 0xff, spi_flash_probe_stmicro, },
-#endif
-#ifdef CONFIG_SPI_FRAM_RAMTRON_NON_JEDEC
-	{ 0, 0xff, spi_fram_probe_ramtron, },
-#endif
-};
-#define IDCODE_LEN (IDCODE_CONT_LEN + IDCODE_PART_LEN)
-
-struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
-		unsigned int max_hz, unsigned int spi_mode)
-{
-	struct spi_slave *spi;
-	struct spi_flash *flash = NULL;
-	int ret, i, shift;
-	u8 idcode[IDCODE_LEN], *idp;
-
-	spi = spi_setup_slave(bus, cs, max_hz, spi_mode);
-	if (!spi) {
-		printf("SF: Failed to set up slave\n");
-		return NULL;
-	}
-
-	ret = spi_claim_bus(spi);
-	if (ret) {
-		debug("SF: Failed to claim SPI bus: %d\n", ret);
-		goto err_claim_bus;
-	}
-
-	/* Read the ID codes */
-	ret = spi_flash_cmd(spi, CMD_READ_ID, idcode, sizeof(idcode));
-	if (ret)
-		goto err_read_id;
-
-#ifdef DEBUG
-	printf("SF: Got idcodes\n");
-	print_buffer(0, idcode, 1, sizeof(idcode), 0);
-#endif
-
-	/* count the number of continuation bytes */
-	for (shift = 0, idp = idcode;
-	     shift < IDCODE_CONT_LEN && *idp == 0x7f;
-	     ++shift, ++idp)
-		continue;
-
-	/* search the table for matches in shift and id */
-	for (i = 0; i < ARRAY_SIZE(flashes); ++i)
-		if (flashes[i].shift == shift && flashes[i].idcode == *idp) {
-			/* we have a match, call probe */
-			flash = flashes[i].probe(spi, idp);
-			if (flash)
-				break;
-		}
-
-	if (!flash) {
-		printf("SF: Unsupported manufacturer %02x\n", *idp);
-		goto err_manufacturer_probe;
-	}
-
-#ifdef CONFIG_SPI_FLASH_BAR
-	/* Configure the BAR - disover bank cmds and read current bank  */
-	ret = spi_flash_bank_config(flash, *idp);
-	if (ret < 0)
-		goto err_manufacturer_probe;
-#endif
-
-#ifdef CONFIG_OF_CONTROL
-	if (spi_flash_decode_fdt(gd->fdt_blob, flash)) {
-		debug("SF: FDT decode error\n");
-		goto err_manufacturer_probe;
-	}
-#endif
-#ifndef CONFIG_SPL_BUILD
-	printf("SF: Detected %s with page size ", flash->name);
-	print_size(flash->sector_size, ", total ");
-	print_size(flash->size, "");
-	if (flash->memory_map)
-		printf(", mapped at %p", flash->memory_map);
-	puts("\n");
-#endif
-#ifndef CONFIG_SPI_FLASH_BAR
-	if (flash->size > SPI_FLASH_16MB_BOUN) {
-		puts("SF: Warning - Only lower 16MiB accessible,");
-		puts(" Full access #define CONFIG_SPI_FLASH_BAR\n");
-	}
-#endif
-
-	spi_release_bus(spi);
-
-	return flash;
-
-err_manufacturer_probe:
-err_read_id:
-	spi_release_bus(spi);
-err_claim_bus:
-	spi_free_slave(spi);
-	return NULL;
-}
-
-void *spi_flash_do_alloc(int offset, int size, struct spi_slave *spi,
-			 const char *name)
-{
-	struct spi_flash *flash;
-	void *ptr;
-
-	ptr = malloc(size);
-	if (!ptr) {
-		debug("SF: Failed to allocate memory\n");
-		return NULL;
-	}
-	memset(ptr, '\0', size);
-	flash = (struct spi_flash *)(ptr + offset);
-
-	/* Set up some basic fields - caller will sort out sizes */
-	flash->spi = spi;
-	flash->name = name;
-	flash->poll_cmd = CMD_READ_STATUS;
-
-	flash->read = spi_flash_cmd_read_fast;
-	flash->write = spi_flash_cmd_write_multi;
-	flash->erase = spi_flash_cmd_erase;
-
-	return flash;
-}
-
-void spi_flash_free(struct spi_flash *flash)
-{
-	spi_free_slave(flash->spi);
-	free(flash);
-}
diff --git a/include/configs/top9000.h b/include/configs/top9000.h
index 65dabde..a6d6928 100644
--- a/include/configs/top9000.h
+++ b/include/configs/top9000.h
@@ -120,7 +120,6 @@
 #define CONFIG_ATMEL_SPI0		/* SPI used for FRAM is SPI0 */
 #define FRAM_SPI_BUS		0
 #define FRAM_CS_NUM		0
-#define CONFIG_SPI_FLASH		/* RAMTRON FRAM on SPI bus */
 #define CONFIG_SPI_FRAM_RAMTRON
 #define CONFIG_SF_DEFAULT_SPEED	1000000	/* be conservative here... */
 #define CONFIG_SF_DEFAULT_MODE	SPI_MODE_0
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 19/36] sf: Remove unneeded flash drivers files
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (17 preceding siblings ...)
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 18/36] sf: ramtron: Add support for separate flash driver Jagannadha Sutradharudu Teki
@ 2013-09-24 18:19 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 20/36] sf: probe: Add support for EN25Q64 Jagannadha Sutradharudu Teki
                   ` (16 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:19 UTC (permalink / raw)
  To: u-boot

Now the common probing is handled in spi_flash_probe.c
hence removed the unneeded flash drivers.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 drivers/mtd/spi/Makefile             |   8 -
 drivers/mtd/spi/atmel.c              | 544 -----------------------------------
 drivers/mtd/spi/eon.c                |  60 ----
 drivers/mtd/spi/gigadevice.c         |  65 -----
 drivers/mtd/spi/macronix.c           |  98 -------
 drivers/mtd/spi/spansion.c           | 141 ---------
 drivers/mtd/spi/spi_flash_internal.h |  11 -
 drivers/mtd/spi/sst.c                | 238 ---------------
 drivers/mtd/spi/stmicro.c            | 202 -------------
 drivers/mtd/spi/winbond.c            | 141 ---------
 10 files changed, 1508 deletions(-)
 delete mode 100644 drivers/mtd/spi/atmel.c
 delete mode 100644 drivers/mtd/spi/eon.c
 delete mode 100644 drivers/mtd/spi/gigadevice.c
 delete mode 100644 drivers/mtd/spi/macronix.c
 delete mode 100644 drivers/mtd/spi/spansion.c
 delete mode 100644 drivers/mtd/spi/sst.c
 delete mode 100644 drivers/mtd/spi/stmicro.c
 delete mode 100644 drivers/mtd/spi/winbond.c

diff --git a/drivers/mtd/spi/Makefile b/drivers/mtd/spi/Makefile
index 2605e57..5678134 100644
--- a/drivers/mtd/spi/Makefile
+++ b/drivers/mtd/spi/Makefile
@@ -18,14 +18,6 @@ ifdef CONFIG_CMD_SF
 COBJS-y        += spi_flash.o
 endif
 COBJS-$(CONFIG_SPI_FLASH)	+= spi_flash_probe.o spi_flash_ops.o
-COBJS-$(CONFIG_SPI_FLASH_ATMEL)	+= atmel.o
-COBJS-$(CONFIG_SPI_FLASH_EON)	+= eon.o
-COBJS-$(CONFIG_SPI_FLASH_GIGADEVICE)	+= gigadevice.o
-COBJS-$(CONFIG_SPI_FLASH_MACRONIX)	+= macronix.o
-COBJS-$(CONFIG_SPI_FLASH_SPANSION)	+= spansion.o
-COBJS-$(CONFIG_SPI_FLASH_SST)	+= sst.o
-COBJS-$(CONFIG_SPI_FLASH_STMICRO)	+= stmicro.o
-COBJS-$(CONFIG_SPI_FLASH_WINBOND)	+= winbond.o
 COBJS-$(CONFIG_SPI_FRAM_RAMTRON)	+= ramtron.o
 COBJS-$(CONFIG_SPI_M95XXX) += eeprom_m95xxx.o
 
diff --git a/drivers/mtd/spi/atmel.c b/drivers/mtd/spi/atmel.c
deleted file mode 100644
index f34df43..0000000
--- a/drivers/mtd/spi/atmel.c
+++ /dev/null
@@ -1,544 +0,0 @@
-/*
- * Atmel SPI DataFlash support
- *
- * Copyright (C) 2008 Atmel Corporation
- * Licensed under the GPL-2 or later.
- */
-
-#include <common.h>
-#include <malloc.h>
-#include <spi_flash.h>
-
-#include "spi_flash_internal.h"
-
-/* AT45-specific commands */
-#define CMD_AT45_READ_STATUS		0xd7
-#define CMD_AT45_ERASE_PAGE		0x81
-#define CMD_AT45_LOAD_PROG_BUF1		0x82
-#define CMD_AT45_LOAD_BUF1		0x84
-#define CMD_AT45_LOAD_PROG_BUF2		0x85
-#define CMD_AT45_LOAD_BUF2		0x87
-#define CMD_AT45_PROG_BUF1		0x88
-#define CMD_AT45_PROG_BUF2		0x89
-
-/* AT45 status register bits */
-#define AT45_STATUS_P2_PAGE_SIZE	(1 << 0)
-#define AT45_STATUS_READY		(1 << 7)
-
-/* DataFlash family IDs, as obtained from the second idcode byte */
-#define DF_FAMILY_AT26F			0
-#define DF_FAMILY_AT45			1
-#define DF_FAMILY_AT26DF		2	/* AT25DF and AT26DF */
-
-struct atmel_spi_flash_params {
-	u8		idcode1;
-	/* Log2 of page size in power-of-two mode */
-	u8		l2_page_size;
-	u8		pages_per_block;
-	u8		blocks_per_sector;
-	u8		nr_sectors;
-	const char	*name;
-};
-
-/* spi_flash needs to be first so upper layers can free() it */
-struct atmel_spi_flash {
-	struct spi_flash flash;
-	const struct atmel_spi_flash_params *params;
-};
-
-static inline struct atmel_spi_flash *
-to_atmel_spi_flash(struct spi_flash *flash)
-{
-	return container_of(flash, struct atmel_spi_flash, flash);
-}
-
-static const struct atmel_spi_flash_params atmel_spi_flash_table[] = {
-	{
-		.idcode1		= 0x22,
-		.l2_page_size		= 8,
-		.pages_per_block	= 8,
-		.blocks_per_sector	= 16,
-		.nr_sectors		= 4,
-		.name			= "AT45DB011D",
-	},
-	{
-		.idcode1		= 0x23,
-		.l2_page_size		= 8,
-		.pages_per_block	= 8,
-		.blocks_per_sector	= 16,
-		.nr_sectors		= 8,
-		.name			= "AT45DB021D",
-	},
-	{
-		.idcode1		= 0x24,
-		.l2_page_size		= 8,
-		.pages_per_block	= 8,
-		.blocks_per_sector	= 32,
-		.nr_sectors		= 8,
-		.name			= "AT45DB041D",
-	},
-	{
-		.idcode1		= 0x25,
-		.l2_page_size		= 8,
-		.pages_per_block	= 8,
-		.blocks_per_sector	= 32,
-		.nr_sectors		= 16,
-		.name			= "AT45DB081D",
-	},
-	{
-		.idcode1		= 0x26,
-		.l2_page_size		= 9,
-		.pages_per_block	= 8,
-		.blocks_per_sector	= 32,
-		.nr_sectors		= 16,
-		.name			= "AT45DB161D",
-	},
-	{
-		.idcode1		= 0x27,
-		.l2_page_size		= 9,
-		.pages_per_block	= 8,
-		.blocks_per_sector	= 64,
-		.nr_sectors		= 64,
-		.name			= "AT45DB321D",
-	},
-	{
-		.idcode1		= 0x28,
-		.l2_page_size		= 10,
-		.pages_per_block	= 8,
-		.blocks_per_sector	= 32,
-		.nr_sectors		= 32,
-		.name			= "AT45DB642D",
-	},
-	{
-		.idcode1		= 0x47,
-		.l2_page_size		= 8,
-		.pages_per_block	= 16,
-		.blocks_per_sector	= 16,
-		.nr_sectors		= 64,
-		.name			= "AT25DF321",
-	},
-};
-
-static int at45_wait_ready(struct spi_flash *flash, unsigned long timeout)
-{
-	struct spi_slave *spi = flash->spi;
-	unsigned long timebase;
-	int ret;
-	u8 cmd = CMD_AT45_READ_STATUS;
-	u8 status;
-
-	timebase = get_timer(0);
-
-	ret = spi_xfer(spi, 8, &cmd, NULL, SPI_XFER_BEGIN);
-	if (ret)
-		return -1;
-
-	do {
-		ret = spi_xfer(spi, 8, NULL, &status, 0);
-		if (ret)
-			return -1;
-
-		if (status & AT45_STATUS_READY)
-			break;
-	} while (get_timer(timebase) < timeout);
-
-	/* Deactivate CS */
-	spi_xfer(spi, 0, NULL, NULL, SPI_XFER_END);
-
-	if (status & AT45_STATUS_READY)
-		return 0;
-
-	/* Timed out */
-	return -1;
-}
-
-/*
- * Assemble the address part of a command for AT45 devices in
- * non-power-of-two page size mode.
- */
-static void at45_build_address(struct atmel_spi_flash *asf, u8 *cmd, u32 offset)
-{
-	unsigned long page_addr;
-	unsigned long byte_addr;
-	unsigned long page_size;
-	unsigned int page_shift;
-
-	/*
-	 * The "extra" space per page is the power-of-two page size
-	 * divided by 32.
-	 */
-	page_shift = asf->params->l2_page_size;
-	page_size = (1 << page_shift) + (1 << (page_shift - 5));
-	page_shift++;
-	page_addr = offset / page_size;
-	byte_addr = offset % page_size;
-
-	cmd[0] = page_addr >> (16 - page_shift);
-	cmd[1] = page_addr << (page_shift - 8) | (byte_addr >> 8);
-	cmd[2] = byte_addr;
-}
-
-static int dataflash_read_fast_at45(struct spi_flash *flash,
-		u32 offset, size_t len, void *buf)
-{
-	struct atmel_spi_flash *asf = to_atmel_spi_flash(flash);
-	u8 cmd[5];
-
-	cmd[0] = CMD_READ_ARRAY_FAST;
-	at45_build_address(asf, cmd + 1, offset);
-	cmd[4] = 0x00;
-
-	return spi_flash_read_common(flash, cmd, sizeof(cmd), buf, len);
-}
-
-/*
- * TODO: the two write funcs (_p2/_at45) should get unified ...
- */
-static int dataflash_write_p2(struct spi_flash *flash,
-		u32 offset, size_t len, const void *buf)
-{
-	struct atmel_spi_flash *asf = to_atmel_spi_flash(flash);
-	unsigned long page_size;
-	u32 addr = offset;
-	size_t chunk_len;
-	size_t actual;
-	int ret;
-	u8 cmd[4];
-
-	/*
-	 * TODO: This function currently uses only page buffer #1.  We can
-	 * speed this up by using both buffers and loading one buffer while
-	 * the other is being programmed into main memory.
-	 */
-
-	page_size = (1 << asf->params->l2_page_size);
-
-	ret = spi_claim_bus(flash->spi);
-	if (ret) {
-		debug("SF: Unable to claim SPI bus\n");
-		return ret;
-	}
-
-	for (actual = 0; actual < len; actual += chunk_len) {
-		chunk_len = min(len - actual, page_size - (addr % page_size));
-
-		/* Use the same address bits for both commands */
-		cmd[0] = CMD_AT45_LOAD_BUF1;
-		cmd[1] = addr >> 16;
-		cmd[2] = addr >> 8;
-		cmd[3] = addr;
-
-		ret = spi_flash_cmd_write(flash->spi, cmd, 4,
-				buf + actual, chunk_len);
-		if (ret < 0) {
-			debug("SF: Loading AT45 buffer failed\n");
-			goto out;
-		}
-
-		cmd[0] = CMD_AT45_PROG_BUF1;
-		ret = spi_flash_cmd_write(flash->spi, cmd, 4, NULL, 0);
-		if (ret < 0) {
-			debug("SF: AT45 page programming failed\n");
-			goto out;
-		}
-
-		ret = at45_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT);
-		if (ret < 0) {
-			debug("SF: AT45 page programming timed out\n");
-			goto out;
-		}
-
-		addr += chunk_len;
-	}
-
-	debug("SF: AT45: Successfully programmed %zu bytes @ 0x%x\n",
-	      len, offset);
-	ret = 0;
-
-out:
-	spi_release_bus(flash->spi);
-	return ret;
-}
-
-static int dataflash_write_at45(struct spi_flash *flash,
-		u32 offset, size_t len, const void *buf)
-{
-	struct atmel_spi_flash *asf = to_atmel_spi_flash(flash);
-	unsigned long page_addr;
-	unsigned long byte_addr;
-	unsigned long page_size;
-	unsigned int page_shift;
-	size_t chunk_len;
-	size_t actual;
-	int ret;
-	u8 cmd[4];
-
-	/*
-	 * TODO: This function currently uses only page buffer #1.  We can
-	 * speed this up by using both buffers and loading one buffer while
-	 * the other is being programmed into main memory.
-	 */
-
-	page_shift = asf->params->l2_page_size;
-	page_size = (1 << page_shift) + (1 << (page_shift - 5));
-	page_shift++;
-	page_addr = offset / page_size;
-	byte_addr = offset % page_size;
-
-	ret = spi_claim_bus(flash->spi);
-	if (ret) {
-		debug("SF: Unable to claim SPI bus\n");
-		return ret;
-	}
-
-	for (actual = 0; actual < len; actual += chunk_len) {
-		chunk_len = min(len - actual, page_size - byte_addr);
-
-		/* Use the same address bits for both commands */
-		cmd[0] = CMD_AT45_LOAD_BUF1;
-		cmd[1] = page_addr >> (16 - page_shift);
-		cmd[2] = page_addr << (page_shift - 8) | (byte_addr >> 8);
-		cmd[3] = byte_addr;
-
-		ret = spi_flash_cmd_write(flash->spi, cmd, 4,
-				buf + actual, chunk_len);
-		if (ret < 0) {
-			debug("SF: Loading AT45 buffer failed\n");
-			goto out;
-		}
-
-		cmd[0] = CMD_AT45_PROG_BUF1;
-		ret = spi_flash_cmd_write(flash->spi, cmd, 4, NULL, 0);
-		if (ret < 0) {
-			debug("SF: AT45 page programming failed\n");
-			goto out;
-		}
-
-		ret = at45_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT);
-		if (ret < 0) {
-			debug("SF: AT45 page programming timed out\n");
-			goto out;
-		}
-
-		page_addr++;
-		byte_addr = 0;
-	}
-
-	debug("SF: AT45: Successfully programmed %zu bytes @ 0x%x\n",
-	      len, offset);
-	ret = 0;
-
-out:
-	spi_release_bus(flash->spi);
-	return ret;
-}
-
-/*
- * TODO: the two erase funcs (_p2/_at45) should get unified ...
- */
-static int dataflash_erase_p2(struct spi_flash *flash, u32 offset, size_t len)
-{
-	struct atmel_spi_flash *asf = to_atmel_spi_flash(flash);
-	unsigned long page_size;
-
-	size_t actual;
-	int ret;
-	u8 cmd[4];
-
-	/*
-	 * TODO: This function currently uses page erase only. We can
-	 * probably speed things up by using block and/or sector erase
-	 * when possible.
-	 */
-
-	page_size = (1 << asf->params->l2_page_size);
-
-	if (offset % page_size || len % page_size) {
-		debug("SF: Erase offset/length not multiple of page size\n");
-		return -1;
-	}
-
-	cmd[0] = CMD_AT45_ERASE_PAGE;
-	cmd[3] = 0x00;
-
-	ret = spi_claim_bus(flash->spi);
-	if (ret) {
-		debug("SF: Unable to claim SPI bus\n");
-		return ret;
-	}
-
-	for (actual = 0; actual < len; actual += page_size) {
-		cmd[1] = offset >> 16;
-		cmd[2] = offset >> 8;
-
-		ret = spi_flash_cmd_write(flash->spi, cmd, 4, NULL, 0);
-		if (ret < 0) {
-			debug("SF: AT45 page erase failed\n");
-			goto out;
-		}
-
-		ret = at45_wait_ready(flash, SPI_FLASH_PAGE_ERASE_TIMEOUT);
-		if (ret < 0) {
-			debug("SF: AT45 page erase timed out\n");
-			goto out;
-		}
-
-		offset += page_size;
-	}
-
-	debug("SF: AT45: Successfully erased %zu bytes @ 0x%x\n",
-	      len, offset);
-	ret = 0;
-
-out:
-	spi_release_bus(flash->spi);
-	return ret;
-}
-
-static int dataflash_erase_at45(struct spi_flash *flash, u32 offset, size_t len)
-{
-	struct atmel_spi_flash *asf = to_atmel_spi_flash(flash);
-	unsigned long page_addr;
-	unsigned long page_size;
-	unsigned int page_shift;
-	size_t actual;
-	int ret;
-	u8 cmd[4];
-
-	/*
-	 * TODO: This function currently uses page erase only. We can
-	 * probably speed things up by using block and/or sector erase
-	 * when possible.
-	 */
-
-	page_shift = asf->params->l2_page_size;
-	page_size = (1 << page_shift) + (1 << (page_shift - 5));
-	page_shift++;
-	page_addr = offset / page_size;
-
-	if (offset % page_size || len % page_size) {
-		debug("SF: Erase offset/length not multiple of page size\n");
-		return -1;
-	}
-
-	cmd[0] = CMD_AT45_ERASE_PAGE;
-	cmd[3] = 0x00;
-
-	ret = spi_claim_bus(flash->spi);
-	if (ret) {
-		debug("SF: Unable to claim SPI bus\n");
-		return ret;
-	}
-
-	for (actual = 0; actual < len; actual += page_size) {
-		cmd[1] = page_addr >> (16 - page_shift);
-		cmd[2] = page_addr << (page_shift - 8);
-
-		ret = spi_flash_cmd_write(flash->spi, cmd, 4, NULL, 0);
-		if (ret < 0) {
-			debug("SF: AT45 page erase failed\n");
-			goto out;
-		}
-
-		ret = at45_wait_ready(flash, SPI_FLASH_PAGE_ERASE_TIMEOUT);
-		if (ret < 0) {
-			debug("SF: AT45 page erase timed out\n");
-			goto out;
-		}
-
-		page_addr++;
-	}
-
-	debug("SF: AT45: Successfully erased %zu bytes @ 0x%x\n",
-	      len, offset);
-	ret = 0;
-
-out:
-	spi_release_bus(flash->spi);
-	return ret;
-}
-
-struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode)
-{
-	const struct atmel_spi_flash_params *params;
-	unsigned page_size;
-	unsigned int family;
-	struct atmel_spi_flash *asf;
-	unsigned int i;
-	int ret;
-	u8 status;
-
-	for (i = 0; i < ARRAY_SIZE(atmel_spi_flash_table); i++) {
-		params = &atmel_spi_flash_table[i];
-		if (params->idcode1 == idcode[1])
-			break;
-	}
-
-	if (i == ARRAY_SIZE(atmel_spi_flash_table)) {
-		debug("SF: Unsupported DataFlash ID %02x\n",
-		      idcode[1]);
-		return NULL;
-	}
-
-	asf = spi_flash_alloc(struct atmel_spi_flash, spi, params->name);
-	if (!asf) {
-		debug("SF: Failed to allocate memory\n");
-		return NULL;
-	}
-
-	asf->params = params;
-
-	/* Assuming power-of-two page size initially. */
-	page_size = 1 << params->l2_page_size;
-
-	family = idcode[1] >> 5;
-
-	switch (family) {
-	case DF_FAMILY_AT45:
-		/*
-		 * AT45 chips have configurable page size. The status
-		 * register indicates which configuration is active.
-		 */
-		ret = spi_flash_cmd(spi, CMD_AT45_READ_STATUS, &status, 1);
-		if (ret)
-			goto err;
-
-		debug("SF: AT45 status register: %02x\n", status);
-
-		if (!(status & AT45_STATUS_P2_PAGE_SIZE)) {
-			asf->flash.read = dataflash_read_fast_at45;
-			asf->flash.write = dataflash_write_at45;
-			asf->flash.erase = dataflash_erase_at45;
-			page_size += 1 << (params->l2_page_size - 5);
-		} else {
-			asf->flash.write = dataflash_write_p2;
-			asf->flash.erase = dataflash_erase_p2;
-		}
-
-		asf->flash.page_size = page_size;
-		asf->flash.sector_size = page_size;
-		break;
-
-	case DF_FAMILY_AT26F:
-	case DF_FAMILY_AT26DF:
-		asf->flash.page_size = page_size;
-		asf->flash.sector_size = 4096;
-		/* clear SPRL# bit for locked flash */
-		spi_flash_cmd_write_status(&asf->flash, 0);
-		break;
-
-	default:
-		debug("SF: Unsupported DataFlash family %u\n", family);
-		goto err;
-	}
-
-	asf->flash.size = page_size * params->pages_per_block
-				* params->blocks_per_sector
-				* params->nr_sectors;
-
-	return &asf->flash;
-
-err:
-	free(asf);
-	return NULL;
-}
diff --git a/drivers/mtd/spi/eon.c b/drivers/mtd/spi/eon.c
deleted file mode 100644
index 25cfc12..0000000
--- a/drivers/mtd/spi/eon.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * (C) Copyright 2010, ucRobotics Inc.
- * Author: Chong Huang <chuang@ucrobotics.com>
- * Licensed under the GPL-2 or later.
- */
-
-#include <common.h>
-#include <malloc.h>
-#include <spi_flash.h>
-
-#include "spi_flash_internal.h"
-
-struct eon_spi_flash_params {
-	u8 idcode1;
-	u16 nr_sectors;
-	const char *name;
-};
-
-static const struct eon_spi_flash_params eon_spi_flash_table[] = {
-	{
-		.idcode1 = 0x16,
-		.nr_sectors = 1024,
-		.name = "EN25Q32B",
-	},
-	{
-		.idcode1 = 0x18,
-		.nr_sectors = 4096,
-		.name = "EN25Q128",
-	},
-};
-
-struct spi_flash *spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode)
-{
-	const struct eon_spi_flash_params *params;
-	struct spi_flash *flash;
-	unsigned int i;
-
-	for (i = 0; i < ARRAY_SIZE(eon_spi_flash_table); ++i) {
-		params = &eon_spi_flash_table[i];
-		if (params->idcode1 == idcode[2])
-			break;
-	}
-
-	if (i == ARRAY_SIZE(eon_spi_flash_table)) {
-		debug("SF: Unsupported EON ID %02x\n", idcode[1]);
-		return NULL;
-	}
-
-	flash = spi_flash_alloc_base(spi, params->name);
-	if (!flash) {
-		debug("SF: Failed to allocate memory\n");
-		return NULL;
-	}
-
-	flash->page_size = 256;
-	flash->sector_size = 256 * 16 * 16;
-	flash->size = 256 * 16 * params->nr_sectors;
-
-	return flash;
-}
diff --git a/drivers/mtd/spi/gigadevice.c b/drivers/mtd/spi/gigadevice.c
deleted file mode 100644
index b42581a..0000000
--- a/drivers/mtd/spi/gigadevice.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Gigadevice SPI flash driver
- * Copyright 2013, Samsung Electronics Co., Ltd.
- * Author: Banajit Goswami <banajit.g@samsung.com>
- *
- * SPDX-License-Identifier:	GPL-2.0+
- */
-
-#include <common.h>
-#include <malloc.h>
-#include <spi_flash.h>
-
-#include "spi_flash_internal.h"
-
-struct gigadevice_spi_flash_params {
-	uint16_t	id;
-	uint16_t	nr_blocks;
-	const char	*name;
-};
-
-static const struct gigadevice_spi_flash_params gigadevice_spi_flash_table[] = {
-	{
-		.id			= 0x6016,
-		.nr_blocks		= 64,
-		.name			= "GD25LQ",
-	},
-	{
-		.id			= 0x4017,
-		.nr_blocks		= 128,
-		.name			= "GD25Q64B",
-	},
-};
-
-struct spi_flash *spi_flash_probe_gigadevice(struct spi_slave *spi, u8 *idcode)
-{
-	const struct gigadevice_spi_flash_params *params;
-	struct spi_flash *flash;
-	unsigned int i;
-
-	for (i = 0; i < ARRAY_SIZE(gigadevice_spi_flash_table); i++) {
-		params = &gigadevice_spi_flash_table[i];
-		if (params->id == ((idcode[1] << 8) | idcode[2]))
-			break;
-	}
-
-	if (i == ARRAY_SIZE(gigadevice_spi_flash_table)) {
-		debug("SF: Unsupported Gigadevice ID %02x%02x\n",
-		      idcode[1], idcode[2]);
-		return NULL;
-	}
-
-	flash = spi_flash_alloc_base(spi, params->name);
-	if (!flash) {
-		debug("SF: Failed to allocate memory\n");
-		return NULL;
-	}
-	/* page_size */
-	flash->page_size = 256;
-	/* sector_size = page_size * pages_per_sector */
-	flash->sector_size = flash->page_size * 16;
-	/* size = sector_size * sector_per_block * number of blocks */
-	flash->size = flash->sector_size * 16 * params->nr_blocks;
-
-	return flash;
-}
diff --git a/drivers/mtd/spi/macronix.c b/drivers/mtd/spi/macronix.c
deleted file mode 100644
index 70435eb..0000000
--- a/drivers/mtd/spi/macronix.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2009(C) Marvell International Ltd. and its affiliates
- * Prafulla Wadaskar <prafulla@marvell.com>
- *
- * Based on drivers/mtd/spi/stmicro.c
- *
- * Copyright 2008, Network Appliance Inc.
- * Jason McMullan <mcmullan@netapp.com>
- *
- * Copyright (C) 2004-2007 Freescale Semiconductor, Inc.
- * TsiChung Liew (Tsi-Chung.Liew at freescale.com)
- *
- * SPDX-License-Identifier:	GPL-2.0+
- */
-
-#include <common.h>
-#include <malloc.h>
-#include <spi_flash.h>
-
-#include "spi_flash_internal.h"
-
-struct macronix_spi_flash_params {
-	u16 idcode;
-	u16 nr_blocks;
-	const char *name;
-};
-
-static const struct macronix_spi_flash_params macronix_spi_flash_table[] = {
-	{
-		.idcode = 0x2013,
-		.nr_blocks = 8,
-		.name = "MX25L4005",
-	},
-	{
-		.idcode = 0x2014,
-		.nr_blocks = 16,
-		.name = "MX25L8005",
-	},
-	{
-		.idcode = 0x2015,
-		.nr_blocks = 32,
-		.name = "MX25L1605D",
-	},
-	{
-		.idcode = 0x2016,
-		.nr_blocks = 64,
-		.name = "MX25L3205D",
-	},
-	{
-		.idcode = 0x2017,
-		.nr_blocks = 128,
-		.name = "MX25L6405D",
-	},
-	{
-		.idcode = 0x2018,
-		.nr_blocks = 256,
-		.name = "MX25L12805D",
-	},
-	{
-		.idcode = 0x2618,
-		.nr_blocks = 256,
-		.name = "MX25L12855E",
-	},
-};
-
-struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode)
-{
-	const struct macronix_spi_flash_params *params;
-	struct spi_flash *flash;
-	unsigned int i;
-	u16 id = idcode[2] | idcode[1] << 8;
-
-	for (i = 0; i < ARRAY_SIZE(macronix_spi_flash_table); i++) {
-		params = &macronix_spi_flash_table[i];
-		if (params->idcode == id)
-			break;
-	}
-
-	if (i == ARRAY_SIZE(macronix_spi_flash_table)) {
-		debug("SF: Unsupported Macronix ID %04x\n", id);
-		return NULL;
-	}
-
-	flash = spi_flash_alloc_base(spi, params->name);
-	if (!flash) {
-		debug("SF: Failed to allocate memory\n");
-		return NULL;
-	}
-
-	flash->page_size = 256;
-	flash->sector_size = 256 * 16 * 16;
-	flash->size = flash->sector_size * params->nr_blocks;
-
-	/* Clear BP# bits for read-only flash */
-	spi_flash_cmd_write_status(flash, 0);
-
-	return flash;
-}
diff --git a/drivers/mtd/spi/spansion.c b/drivers/mtd/spi/spansion.c
deleted file mode 100644
index fa7ac8c..0000000
--- a/drivers/mtd/spi/spansion.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (C) 2009 Freescale Semiconductor, Inc.
- *
- * Author: Mingkai Hu (Mingkai.hu at freescale.com)
- * Based on stmicro.c by Wolfgang Denk (wd at denx.de),
- * TsiChung Liew (Tsi-Chung.Liew at freescale.com),
- * and  Jason McMullan (mcmullan at netapp.com)
- *
- * SPDX-License-Identifier:	GPL-2.0+
- */
-
-#include <common.h>
-#include <malloc.h>
-#include <spi_flash.h>
-
-#include "spi_flash_internal.h"
-
-struct spansion_spi_flash_params {
-	u16 idcode1;
-	u16 idcode2;
-	u16 pages_per_sector;
-	u16 nr_sectors;
-	const char *name;
-};
-
-static const struct spansion_spi_flash_params spansion_spi_flash_table[] = {
-	{
-		.idcode1 = 0x0213,
-		.idcode2 = 0,
-		.pages_per_sector = 256,
-		.nr_sectors = 16,
-		.name = "S25FL008A",
-	},
-	{
-		.idcode1 = 0x0214,
-		.idcode2 = 0,
-		.pages_per_sector = 256,
-		.nr_sectors = 32,
-		.name = "S25FL016A",
-	},
-	{
-		.idcode1 = 0x0215,
-		.idcode2 = 0,
-		.pages_per_sector = 256,
-		.nr_sectors = 64,
-		.name = "S25FL032A",
-	},
-	{
-		.idcode1 = 0x0216,
-		.idcode2 = 0,
-		.pages_per_sector = 256,
-		.nr_sectors = 128,
-		.name = "S25FL064A",
-	},
-	{
-		.idcode1 = 0x2018,
-		.idcode2 = 0x0301,
-		.pages_per_sector = 256,
-		.nr_sectors = 256,
-		.name = "S25FL128P_64K",
-	},
-	{
-		.idcode1 = 0x2018,
-		.idcode2 = 0x0300,
-		.pages_per_sector = 1024,
-		.nr_sectors = 64,
-		.name = "S25FL128P_256K",
-	},
-	{
-		.idcode1 = 0x0215,
-		.idcode2 = 0x4d00,
-		.pages_per_sector = 256,
-		.nr_sectors = 64,
-		.name = "S25FL032P",
-	},
-	{
-		.idcode1 = 0x0216,
-		.idcode2 = 0x4d00,
-		.pages_per_sector = 256,
-		.nr_sectors = 128,
-		.name = "S25FL064P",
-	},
-	{
-		.idcode1 = 0x2018,
-		.idcode2 = 0x4d01,
-		.pages_per_sector = 256,
-		.nr_sectors = 256,
-		.name = "S25FL129P_64K/S25FL128S_64K",
-	},
-	{
-		.idcode1 = 0x0219,
-		.idcode2 = 0x4d01,
-		.pages_per_sector = 256,
-		.nr_sectors = 512,
-		.name = "S25FL256S_64K",
-	},
-	{
-		.idcode1 = 0x0220,
-		.idcode2 = 0x4d01,
-		.pages_per_sector = 256,
-		.nr_sectors = 1024,
-		.name = "S25FL512S_64K",
-	},
-};
-
-struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode)
-{
-	const struct spansion_spi_flash_params *params;
-	struct spi_flash *flash;
-	unsigned int i;
-	unsigned short jedec, ext_jedec;
-
-	jedec = idcode[1] << 8 | idcode[2];
-	ext_jedec = idcode[3] << 8 | idcode[4];
-
-	for (i = 0; i < ARRAY_SIZE(spansion_spi_flash_table); i++) {
-		params = &spansion_spi_flash_table[i];
-		if (params->idcode1 == jedec) {
-			if (params->idcode2 == ext_jedec)
-				break;
-		}
-	}
-
-	if (i == ARRAY_SIZE(spansion_spi_flash_table)) {
-		debug("SF: Unsupported SPANSION ID %04x %04x\n",
-		      jedec, ext_jedec);
-		return NULL;
-	}
-
-	flash = spi_flash_alloc_base(spi, params->name);
-	if (!flash) {
-		debug("SF: Failed to allocate memory\n");
-		return NULL;
-	}
-
-	flash->page_size = 256;
-	flash->sector_size = 256 * params->pages_per_sector;
-	flash->size = flash->sector_size * params->nr_sectors;
-
-	return flash;
-}
diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h
index 6227d2e..286082a 100644
--- a/drivers/mtd/spi/spi_flash_internal.h
+++ b/drivers/mtd/spi/spi_flash_internal.h
@@ -127,14 +127,3 @@ int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout);
 
 /* Erase sectors. */
 int spi_flash_cmd_erase(struct spi_flash *flash, u32 offset, size_t len);
-
-/* Manufacturer-specific probe functions */
-struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode);
-struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode);
-struct spi_flash *spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode);
-struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode);
-struct spi_flash *spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode);
-struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 *idcode);
-struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode);
-struct spi_flash *spi_fram_probe_ramtron(struct spi_slave *spi, u8 *idcode);
-struct spi_flash *spi_flash_probe_gigadevice(struct spi_slave *spi, u8 *idcode);
diff --git a/drivers/mtd/spi/sst.c b/drivers/mtd/spi/sst.c
deleted file mode 100644
index 256867c..0000000
--- a/drivers/mtd/spi/sst.c
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Driver for SST serial flashes
- *
- * (C) Copyright 2000-2002
- * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
- * Copyright 2008, Network Appliance Inc.
- * Jason McMullan <mcmullan@netapp.com>
- * Copyright (C) 2004-2007 Freescale Semiconductor, Inc.
- * TsiChung Liew (Tsi-Chung.Liew at freescale.com)
- * Copyright (c) 2008-2009 Analog Devices Inc.
- *
- * Licensed under the GPL-2 or later.
- */
-
-#include <common.h>
-#include <malloc.h>
-#include <spi_flash.h>
-
-#include "spi_flash_internal.h"
-
-#define CMD_SST_BP		0x02	/* Byte Program */
-#define CMD_SST_AAI_WP		0xAD	/* Auto Address Incr Word Program */
-
-#define SST_SR_WIP		(1 << 0)	/* Write-in-Progress */
-#define SST_SR_WEL		(1 << 1)	/* Write enable */
-#define SST_SR_BP0		(1 << 2)	/* Block Protection 0 */
-#define SST_SR_BP1		(1 << 3)	/* Block Protection 1 */
-#define SST_SR_BP2		(1 << 4)	/* Block Protection 2 */
-#define SST_SR_AAI		(1 << 6)	/* Addressing mode */
-#define SST_SR_BPL		(1 << 7)	/* BP bits lock */
-
-#define SST_FEAT_WP		(1 << 0)	/* Supports AAI word program */
-#define SST_FEAT_MBP		(1 << 1)	/* Supports multibyte program */
-
-struct sst_spi_flash_params {
-	u8 idcode1;
-	u8 flags;
-	u16 nr_sectors;
-	const char *name;
-};
-
-struct sst_spi_flash {
-	struct spi_flash flash;
-	const struct sst_spi_flash_params *params;
-};
-
-static const struct sst_spi_flash_params sst_spi_flash_table[] = {
-	{
-		.idcode1 = 0x8d,
-		.flags = SST_FEAT_WP,
-		.nr_sectors = 128,
-		.name = "SST25VF040B",
-	},
-	{
-		.idcode1 = 0x8e,
-		.flags = SST_FEAT_WP,
-		.nr_sectors = 256,
-		.name = "SST25VF080B",
-	},
-	{
-		.idcode1 = 0x41,
-		.flags = SST_FEAT_WP,
-		.nr_sectors = 512,
-		.name = "SST25VF016B",
-	},
-	{
-		.idcode1 = 0x4a,
-		.flags = SST_FEAT_WP,
-		.nr_sectors = 1024,
-		.name = "SST25VF032B",
-	},
-	{
-		.idcode1 = 0x4b,
-		.flags = SST_FEAT_MBP,
-		.nr_sectors = 2048,
-		.name = "SST25VF064C",
-	},
-	{
-		.idcode1 = 0x01,
-		.flags = SST_FEAT_WP,
-		.nr_sectors = 16,
-		.name = "SST25WF512",
-	},
-	{
-		.idcode1 = 0x02,
-		.flags = SST_FEAT_WP,
-		.nr_sectors = 32,
-		.name = "SST25WF010",
-	},
-	{
-		.idcode1 = 0x03,
-		.flags = SST_FEAT_WP,
-		.nr_sectors = 64,
-		.name = "SST25WF020",
-	},
-	{
-		.idcode1 = 0x04,
-		.flags = SST_FEAT_WP,
-		.nr_sectors = 128,
-		.name = "SST25WF040",
-	},
-	{
-		.idcode1 = 0x05,
-		.flags = SST_FEAT_WP,
-		.nr_sectors = 256,
-		.name = "SST25WF080",
-	},
-};
-
-static int
-sst_byte_write(struct spi_flash *flash, u32 offset, const void *buf)
-{
-	int ret;
-	u8 cmd[4] = {
-		CMD_SST_BP,
-		offset >> 16,
-		offset >> 8,
-		offset,
-	};
-
-	debug("BP[%02x]: 0x%p => cmd = { 0x%02x 0x%06x }\n",
-	      spi_w8r8(flash->spi, CMD_READ_STATUS), buf, cmd[0], offset);
-
-	ret = spi_flash_cmd_write_enable(flash);
-	if (ret)
-		return ret;
-
-	ret = spi_flash_cmd_write(flash->spi, cmd, sizeof(cmd), buf, 1);
-	if (ret)
-		return ret;
-
-	return spi_flash_cmd_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT);
-}
-
-static int
-sst_write_wp(struct spi_flash *flash, u32 offset, size_t len, const void *buf)
-{
-	size_t actual, cmd_len;
-	int ret;
-	u8 cmd[4];
-
-	ret = spi_claim_bus(flash->spi);
-	if (ret) {
-		debug("SF: Unable to claim SPI bus\n");
-		return ret;
-	}
-
-	/* If the data is not word aligned, write out leading single byte */
-	actual = offset % 2;
-	if (actual) {
-		ret = sst_byte_write(flash, offset, buf);
-		if (ret)
-			goto done;
-	}
-	offset += actual;
-
-	ret = spi_flash_cmd_write_enable(flash);
-	if (ret)
-		goto done;
-
-	cmd_len = 4;
-	cmd[0] = CMD_SST_AAI_WP;
-	cmd[1] = offset >> 16;
-	cmd[2] = offset >> 8;
-	cmd[3] = offset;
-
-	for (; actual < len - 1; actual += 2) {
-		debug("WP[%02x]: 0x%p => cmd = { 0x%02x 0x%06x }\n",
-		      spi_w8r8(flash->spi, CMD_READ_STATUS), buf + actual,
-		      cmd[0], offset);
-
-		ret = spi_flash_cmd_write(flash->spi, cmd, cmd_len,
-					buf + actual, 2);
-		if (ret) {
-			debug("SF: sst word program failed\n");
-			break;
-		}
-
-		ret = spi_flash_cmd_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT);
-		if (ret)
-			break;
-
-		cmd_len = 1;
-		offset += 2;
-	}
-
-	if (!ret)
-		ret = spi_flash_cmd_write_disable(flash);
-
-	/* If there is a single trailing byte, write it out */
-	if (!ret && actual != len)
-		ret = sst_byte_write(flash, offset, buf + actual);
-
- done:
-	debug("SF: sst: program %s %zu bytes @ 0x%zx\n",
-	      ret ? "failure" : "success", len, offset - actual);
-
-	spi_release_bus(flash->spi);
-	return ret;
-}
-
-struct spi_flash *
-spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode)
-{
-	const struct sst_spi_flash_params *params;
-	struct sst_spi_flash *stm;
-	size_t i;
-
-	for (i = 0; i < ARRAY_SIZE(sst_spi_flash_table); ++i) {
-		params = &sst_spi_flash_table[i];
-		if (params->idcode1 == idcode[2])
-			break;
-	}
-
-	if (i == ARRAY_SIZE(sst_spi_flash_table)) {
-		debug("SF: Unsupported SST ID %02x\n", idcode[1]);
-		return NULL;
-	}
-
-	stm = spi_flash_alloc(struct sst_spi_flash, spi, params->name);
-	if (!stm) {
-		debug("SF: Failed to allocate memory\n");
-		return NULL;
-	}
-
-	stm->params = params;
-
-	if (stm->params->flags & SST_FEAT_WP)
-		stm->flash.write = sst_write_wp;
-	stm->flash.page_size = 256;
-	stm->flash.sector_size = 4096;
-	stm->flash.size = stm->flash.sector_size * params->nr_sectors;
-
-	/* Flash powers up read-only, so clear BP# bits */
-	spi_flash_cmd_write_status(&stm->flash, 0);
-
-	return &stm->flash;
-}
diff --git a/drivers/mtd/spi/stmicro.c b/drivers/mtd/spi/stmicro.c
deleted file mode 100644
index c5fa64e..0000000
--- a/drivers/mtd/spi/stmicro.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * (C) Copyright 2000-2002
- * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
- *
- * Copyright 2008, Network Appliance Inc.
- * Jason McMullan <mcmullan@netapp.com>
- *
- * Copyright (C) 2004-2007 Freescale Semiconductor, Inc.
- * TsiChung Liew (Tsi-Chung.Liew at freescale.com)
- *
- * SPDX-License-Identifier:	GPL-2.0+
- */
-
-#include <common.h>
-#include <malloc.h>
-#include <spi_flash.h>
-
-#include "spi_flash_internal.h"
-
-/* M25Pxx-specific commands */
-#define CMD_M25PXX_RES	0xab	/* Release from DP, and Read Signature */
-
-struct stmicro_spi_flash_params {
-	u16 id;
-	u16 pages_per_sector;
-	u16 nr_sectors;
-	const char *name;
-};
-
-static const struct stmicro_spi_flash_params stmicro_spi_flash_table[] = {
-	{
-		.id = 0x2011,
-		.pages_per_sector = 128,
-		.nr_sectors = 4,
-		.name = "M25P10",
-	},
-	{
-		.id = 0x2015,
-		.pages_per_sector = 256,
-		.nr_sectors = 32,
-		.name = "M25P16",
-	},
-	{
-		.id = 0x2012,
-		.pages_per_sector = 256,
-		.nr_sectors = 4,
-		.name = "M25P20",
-	},
-	{
-		.id = 0x2016,
-		.pages_per_sector = 256,
-		.nr_sectors = 64,
-		.name = "M25P32",
-	},
-	{
-		.id = 0x2013,
-		.pages_per_sector = 256,
-		.nr_sectors = 8,
-		.name = "M25P40",
-	},
-	{
-		.id = 0x2017,
-		.pages_per_sector = 256,
-		.nr_sectors = 128,
-		.name = "M25P64",
-	},
-	{
-		.id = 0x2014,
-		.pages_per_sector = 256,
-		.nr_sectors = 16,
-		.name = "M25P80",
-	},
-	{
-		.id = 0x2018,
-		.pages_per_sector = 1024,
-		.nr_sectors = 64,
-		.name = "M25P128",
-	},
-	{
-		.id = 0xba16,
-		.pages_per_sector = 256,
-		.nr_sectors = 64,
-		.name = "N25Q32",
-	},
-	{
-		.id = 0xbb16,
-		.pages_per_sector = 256,
-		.nr_sectors = 64,
-		.name = "N25Q32A",
-	},
-	{
-		.id = 0xba17,
-		.pages_per_sector = 256,
-		.nr_sectors = 128,
-		.name = "N25Q064",
-	},
-	{
-		.id = 0xbb17,
-		.pages_per_sector = 256,
-		.nr_sectors = 128,
-		.name = "N25Q64A",
-	},
-	{
-		.id = 0xba18,
-		.pages_per_sector = 256,
-		.nr_sectors = 256,
-		.name = "N25Q128",
-	},
-	{
-		.id = 0xbb18,
-		.pages_per_sector = 256,
-		.nr_sectors = 256,
-		.name = "N25Q128A",
-	},
-	{
-		.id = 0xba19,
-		.pages_per_sector = 256,
-		.nr_sectors = 512,
-		.name = "N25Q256",
-	},
-	{
-		.id = 0xbb19,
-		.pages_per_sector = 256,
-		.nr_sectors = 512,
-		.name = "N25Q256A",
-	},
-	{
-		.id = 0xba20,
-		.pages_per_sector = 256,
-		.nr_sectors = 1024,
-		.name = "N25Q512",
-	},
-	{
-		.id = 0xbb20,
-		.pages_per_sector = 256,
-		.nr_sectors = 1024,
-		.name = "N25Q512A",
-	},
-	{
-		.id = 0xba21,
-		.pages_per_sector = 256,
-		.nr_sectors = 2048,
-		.name = "N25Q1024",
-	},
-	{
-		.id = 0xbb21,
-		.pages_per_sector = 256,
-		.nr_sectors = 2048,
-		.name = "N25Q1024A",
-	},
-};
-
-struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 *idcode)
-{
-	const struct stmicro_spi_flash_params *params;
-	struct spi_flash *flash;
-	unsigned int i;
-	u16 id;
-
-	if (idcode[0] == 0xff) {
-		i = spi_flash_cmd(spi, CMD_M25PXX_RES,
-				  idcode, 4);
-		if (i)
-			return NULL;
-		if ((idcode[3] & 0xf0) == 0x10) {
-			idcode[0] = 0x20;
-			idcode[1] = 0x20;
-			idcode[2] = idcode[3] + 1;
-		} else {
-			return NULL;
-		}
-	}
-
-	id = ((idcode[1] << 8) | idcode[2]);
-
-	for (i = 0; i < ARRAY_SIZE(stmicro_spi_flash_table); i++) {
-		params = &stmicro_spi_flash_table[i];
-		if (params->id == id)
-			break;
-	}
-
-	if (i == ARRAY_SIZE(stmicro_spi_flash_table)) {
-		debug("SF: Unsupported STMicro ID %04x\n", id);
-		return NULL;
-	}
-
-	flash = spi_flash_alloc_base(spi, params->name);
-	if (!flash) {
-		debug("SF: Failed to allocate memory\n");
-		return NULL;
-	}
-
-	flash->page_size = 256;
-	flash->sector_size = 256 * params->pages_per_sector;
-	flash->size = flash->sector_size * params->nr_sectors;
-
-	/* for >= 512MiB flashes, use flag status instead of read_status */
-	if (flash->size >= 0x4000000)
-		flash->poll_cmd = CMD_FLAG_STATUS;
-
-	return flash;
-}
diff --git a/drivers/mtd/spi/winbond.c b/drivers/mtd/spi/winbond.c
deleted file mode 100644
index b31911a..0000000
--- a/drivers/mtd/spi/winbond.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright 2008, Network Appliance Inc.
- * Author: Jason McMullan <mcmullan <at> netapp.com>
- * Licensed under the GPL-2 or later.
- */
-
-#include <common.h>
-#include <malloc.h>
-#include <spi_flash.h>
-
-#include "spi_flash_internal.h"
-
-struct winbond_spi_flash_params {
-	uint16_t	id;
-	uint16_t	nr_blocks;
-	const char	*name;
-};
-
-static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
-	{
-		.id			= 0x2014,
-		.nr_blocks		= 16,
-		.name			= "W25P80",
-	},
-	{
-		.id			= 0x2015,
-		.nr_blocks		= 32,
-		.name			= "W25P16",
-	},
-	{
-		.id			= 0x2016,
-		.nr_blocks		= 64,
-		.name			= "W25P32",
-	},
-	{
-		.id			= 0x3013,
-		.nr_blocks		= 8,
-		.name			= "W25X40",
-	},
-	{
-		.id			= 0x3015,
-		.nr_blocks		= 32,
-		.name			= "W25X16",
-	},
-	{
-		.id			= 0x3016,
-		.nr_blocks		= 64,
-		.name			= "W25X32",
-	},
-	{
-		.id			= 0x3017,
-		.nr_blocks		= 128,
-		.name			= "W25X64",
-	},
-	{
-		.id			= 0x4014,
-		.nr_blocks		= 16,
-		.name			= "W25Q80BL/W25Q80BV",
-	},
-	{
-		.id			= 0x4015,
-		.nr_blocks		= 32,
-		.name			= "W25Q16CL/W25Q16DV",
-	},
-	{
-		.id			= 0x4016,
-		.nr_blocks		= 64,
-		.name			= "W25Q32BV/W25Q32FV_SPI",
-	},
-	{
-		.id			= 0x4017,
-		.nr_blocks		= 128,
-		.name			= "W25Q64CV/W25Q64FV_SPI",
-	},
-	{
-		.id			= 0x4018,
-		.nr_blocks		= 256,
-		.name			= "W25Q128BV/W25Q128FV_SPI",
-	},
-	{
-		.id			= 0x4019,
-		.nr_blocks		= 512,
-		.name			= "W25Q256",
-	},
-	{
-		.id			= 0x5014,
-		.nr_blocks		= 16,
-		.name			= "W25Q80BW",
-	},
-	{
-		.id			= 0x6015,
-		.nr_blocks		= 32,
-		.name			= "W25Q16DW",
-	},
-	{
-		.id			= 0x6016,
-		.nr_blocks		= 64,
-		.name			= "W25Q32DW/W25Q32FV_QPI",
-	},
-	{
-		.id			= 0x6017,
-		.nr_blocks		= 128,
-		.name			= "W25Q64DW/W25Q64FV_QPI",
-	},
-	{
-		.id			= 0x6018,
-		.nr_blocks		= 256,
-		.name			= "W25Q128FW/W25Q128FV_QPI",
-	},
-};
-
-struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode)
-{
-	const struct winbond_spi_flash_params *params;
-	struct spi_flash *flash;
-	unsigned int i;
-
-	for (i = 0; i < ARRAY_SIZE(winbond_spi_flash_table); i++) {
-		params = &winbond_spi_flash_table[i];
-		if (params->id == ((idcode[1] << 8) | idcode[2]))
-			break;
-	}
-
-	if (i == ARRAY_SIZE(winbond_spi_flash_table)) {
-		debug("SF: Unsupported Winbond ID %02x%02x\n",
-		      idcode[1], idcode[2]);
-		return NULL;
-	}
-
-	flash = spi_flash_alloc_base(spi, params->name);
-	if (!flash) {
-		debug("SF: Failed to allocate memory\n");
-		return NULL;
-	}
-
-	flash->page_size = 256;
-	flash->sector_size = (idcode[1] == 0x20) ? 65536 : 4096;
-	flash->size = 4096 * 16 * params->nr_blocks;
-
-	return flash;
-}
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 20/36] sf: probe: Add support for EN25Q64
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (18 preceding siblings ...)
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 19/36] sf: Remove unneeded flash drivers files Jagannadha Sutradharudu Teki
@ 2013-09-24 18:19 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 21/36] sf: probe: Add support for S25FL256S_256K Jagannadha Sutradharudu Teki
                   ` (15 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:19 UTC (permalink / raw)
  To: u-boot

Add support for EON EN25Q64 SPI flash.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 drivers/mtd/spi/spi_flash_probe.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index ed5b938..9b2c755 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -49,6 +49,7 @@ static const struct spi_flash_params spi_flash_params_table[] = {
 #endif
 #ifdef CONFIG_SPI_FLASH_EON		/* EON */
 	{"EN25Q32B",	   0x1c3016, 0x0,	64 * 1024,    64,	             0},
+	{"EN25Q64",	   0x1c3017, 0x0,	64 * 1024,   128,	       SECT_4K},
 	{"EN25Q128B",	   0x1c3018, 0x0,       64 * 1024,   256,	             0},
 #endif
 #ifdef CONFIG_SPI_FLASH_GIGADEVICE	/* GIGADEVICE */
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 21/36] sf: probe: Add support for S25FL256S_256K
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (19 preceding siblings ...)
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 20/36] sf: probe: Add support for EN25Q64 Jagannadha Sutradharudu Teki
@ 2013-09-24 18:19 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 22/36] sf: probe: Add support for S25FL512S_256K Jagannadha Sutradharudu Teki
                   ` (14 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:19 UTC (permalink / raw)
  To: u-boot

Add support for Spansion S25FL256S_256K SPI flash.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 drivers/mtd/spi/spi_flash_probe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index 9b2c755..b206c37 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -75,6 +75,7 @@ static const struct spi_flash_params spi_flash_params_table[] = {
 	{"S25FL032P",	   0x010215, 0x4d00,    64 * 1024,    64,	             0},
 	{"S25FL064P",	   0x010216, 0x4d00,    64 * 1024,   128,	             0},
 	{"S25FL128S_64K",  0x012018, 0x4d01,    64 * 1024,   256,		     0},
+	{"S25FL256S_256K", 0x010219, 0x4d00,    64 * 1024,   512,	             0},
 	{"S25FL256S_64K",  0x010219, 0x4d01,    64 * 1024,   512,	             0},
 	{"S25FL512S_64K",  0x010220, 0x4d01,    64 * 1024,  1024,	             0},
 #endif
@@ -195,7 +196,7 @@ struct spi_flash *spi_flash_validate_ids(struct spi_slave *spi, u8 *idcode)
 	flash->read = spi_flash_cmd_read_fast;
 
 	/* Compute the flash size */
-	flash->page_size = 256;
+	flash->page_size = (ext_jedec == 0x4d00) ? 512 : 256;
 	flash->sector_size = params->sector_size;
 	flash->size = flash->sector_size * params->nr_sectors;
 
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 22/36] sf: probe: Add support for S25FL512S_256K
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (20 preceding siblings ...)
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 21/36] sf: probe: Add support for S25FL256S_256K Jagannadha Sutradharudu Teki
@ 2013-09-24 18:19 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 23/36] sf: probe: Use print_size arg as page_size Jagannadha Sutradharudu Teki
                   ` (13 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:19 UTC (permalink / raw)
  To: u-boot

Add support for Spansion S25FL512S_256K SPI flash.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 drivers/mtd/spi/spi_flash_probe.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index b206c37..aa56b68 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -77,6 +77,7 @@ static const struct spi_flash_params spi_flash_params_table[] = {
 	{"S25FL128S_64K",  0x012018, 0x4d01,    64 * 1024,   256,		     0},
 	{"S25FL256S_256K", 0x010219, 0x4d00,    64 * 1024,   512,	             0},
 	{"S25FL256S_64K",  0x010219, 0x4d01,    64 * 1024,   512,	             0},
+	{"S25FL512S_256K", 0x010220, 0x4d00,    64 * 1024,  1024,	             0},
 	{"S25FL512S_64K",  0x010220, 0x4d01,    64 * 1024,  1024,	             0},
 #endif
 #ifdef CONFIG_SPI_FLASH_STMICRO		/* STMICRO */
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 23/36] sf: probe: Use print_size arg as page_size
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (21 preceding siblings ...)
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 22/36] sf: probe: Add support for S25FL512S_256K Jagannadha Sutradharudu Teki
@ 2013-09-24 18:20 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 24/36] sf: probe: Print erase_size while printing flash details Jagannadha Sutradharudu Teki
                   ` (12 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:20 UTC (permalink / raw)
  To: u-boot

Use flash->page_size arg in print_size() instead of
flash->sector_size while printing detected flas part details.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 drivers/mtd/spi/spi_flash_probe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index aa56b68..b370a1a 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -346,7 +346,7 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
 #endif
 #ifndef CONFIG_SPL_BUILD
 	printf("SF: Detected %s with page size ", flash->name);
-	print_size(flash->sector_size, ", total ");
+	print_size(flash->page_size, ", total ");
 	print_size(flash->size, "");
 	if (flash->memory_map)
 		printf(", mapped at %p", flash->memory_map);
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 24/36] sf: probe: Print erase_size while printing flash details
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (22 preceding siblings ...)
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 23/36] sf: probe: Use print_size arg as page_size Jagannadha Sutradharudu Teki
@ 2013-09-24 18:20 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 25/36] sf: probe: Simply the BAR configuration logic Jagannadha Sutradharudu Teki
                   ` (11 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:20 UTC (permalink / raw)
  To: u-boot

Included erase_size while printing probed flash details.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 drivers/mtd/spi/spi_flash_probe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index b370a1a..8462195 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -346,7 +346,8 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
 #endif
 #ifndef CONFIG_SPL_BUILD
 	printf("SF: Detected %s with page size ", flash->name);
-	print_size(flash->page_size, ", total ");
+	print_size(flash->page_size, ", erase size ");
+	print_size(flash->erase_size, ", total ");
 	print_size(flash->size, "");
 	if (flash->memory_map)
 		printf(", mapped at %p", flash->memory_map);
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 25/36] sf: probe: Simply the BAR configuration logic
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (23 preceding siblings ...)
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 24/36] sf: probe: Print erase_size while printing flash details Jagannadha Sutradharudu Teki
@ 2013-09-24 18:20 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 26/36] sf: ops: Add static qualifier to spi_flash_cmd_bankaddr_write Jagannadha Sutradharudu Teki
                   ` (10 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:20 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 drivers/mtd/spi/spi_flash_internal.h |  3 --
 drivers/mtd/spi/spi_flash_probe.c    | 56 +++++++++++-------------------------
 include/spi_flash.h                  |  3 --
 3 files changed, 16 insertions(+), 46 deletions(-)

diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h
index 286082a..86966f6 100644
--- a/drivers/mtd/spi/spi_flash_internal.h
+++ b/drivers/mtd/spi/spi_flash_internal.h
@@ -97,9 +97,6 @@ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr);
 #ifdef CONFIG_SPI_FLASH_BAR
 /* Program the bank address register */
 int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel);
-
-/* Configure the BAR - discover the bank cmds */
-int spi_flash_bank_config(struct spi_flash *flash, u8 idcode0);
 #endif
 
 /*
diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index 8462195..2978480 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -220,56 +220,32 @@ struct spi_flash *spi_flash_validate_ids(struct spi_slave *spi, u8 *idcode)
 
 #ifdef CONFIG_SPI_FLASH_BAR
 	/* Configure the BAR - discover bank cmds and read current bank  */
-	if (spi_flash_bank_config(flash, idcode[0]) < 0)
-		return NULL;
-#endif
-
-	/* Flash powers up read-only, so clear BP# bits */
-	if (((params->jedec >> 16) == SPI_FLASH_CFI_MFR_ATMEL) ||
-	    ((params->jedec >> 16) == SPI_FLASH_CFI_MFR_MACRONIX) ||
-	    ((params->jedec >> 16) == SPI_FLASH_CFI_MFR_SST))
-		spi_flash_cmd_write_status(flash, 0);
-
-	return flash;
-}
-
-#ifdef CONFIG_SPI_FLASH_BAR
-int spi_flash_bank_config(struct spi_flash *flash, u8 idcode0)
-{
-	u8 cmd;
 	u8 curr_bank = 0;
-
-	/* discover bank cmds */
-	switch (idcode0) {
-	case SPI_FLASH_CFI_MFR_SPANSION:
-		flash->bank_read_cmd = CMD_BANKADDR_BRRD;
-		flash->bank_write_cmd = CMD_BANKADDR_BRWR;
-		break;
-	case SPI_FLASH_CFI_MFR_STMICRO:
-	case SPI_FLASH_CFI_MFR_WINBOND:
-		flash->bank_read_cmd = CMD_EXTNADDR_RDEAR;
-		flash->bank_write_cmd = CMD_EXTNADDR_WREAR;
-		break;
-	default:
-		printf("SF: Unsupported bank commands %02x\n", idcode0);
-		return -1;
-	}
-
-	/* read the bank reg - on which bank the flash is in currently */
-	cmd = flash->bank_read_cmd;
 	if (flash->size > SPI_FLASH_16MB_BOUN) {
-		if (spi_flash_read_common(flash, &cmd, 1, &curr_bank, 1)) {
+		flash->bank_read_cmd = (idcode[0] == 0x01) ?
+					CMD_BANKADDR_BRRD : CMD_EXTNADDR_RDEAR;
+		flash->bank_write_cmd = (idcode[0] == 0x01) ?
+					CMD_BANKADDR_BRWR : CMD_EXTNADDR_WREAR;
+
+		if (spi_flash_read_common(flash, &flash->bank_read_cmd, 1,
+					  &curr_bank, 1)) {
 			debug("SF: fail to read bank addr register\n");
-			return -1;
+			return NULL;
 		}
 		flash->bank_curr = curr_bank;
 	} else {
 		flash->bank_curr = curr_bank;
 	}
+#endif
 
-	return 0;
+	/* Flash powers up read-only, so clear BP# bits */
+	if (((params->jedec >> 16) == SPI_FLASH_CFI_MFR_ATMEL) ||
+	    ((params->jedec >> 16) == SPI_FLASH_CFI_MFR_MACRONIX) ||
+	    ((params->jedec >> 16) == SPI_FLASH_CFI_MFR_SST))
+		spi_flash_cmd_write_status(flash, 0);
+
+	return flash;
 }
-#endif
 
 #ifdef CONFIG_OF_CONTROL
 int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash)
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 34a167b..939da05 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -20,10 +20,7 @@
 /* SPI flash CFI Manufacture ID's */
 #define SPI_FLASH_CFI_MFR_ATMEL			0x1f
 #define SPI_FLASH_CFI_MFR_MACRONIX		0xc2
-#define SPI_FLASH_CFI_MFR_SPANSION		0x01
 #define SPI_FLASH_CFI_MFR_SST			0xbf
-#define SPI_FLASH_CFI_MFR_STMICRO		0x20
-#define SPI_FLASH_CFI_MFR_WINBOND		0xef
 
 /* SECT flags */
 #define SECT_4K			(1 << 0)
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 26/36] sf: ops: Add static qualifier to spi_flash_cmd_bankaddr_write
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (24 preceding siblings ...)
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 25/36] sf: probe: Simply the BAR configuration logic Jagannadha Sutradharudu Teki
@ 2013-09-24 18:20 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 27/36] sf: probe: Add support for MX25L25635F Jagannadha Sutradharudu Teki
                   ` (9 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:20 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 drivers/mtd/spi/spi_flash_internal.h | 5 -----
 drivers/mtd/spi/spi_flash_ops.c      | 2 +-
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h
index 86966f6..1f9f170 100644
--- a/drivers/mtd/spi/spi_flash_internal.h
+++ b/drivers/mtd/spi/spi_flash_internal.h
@@ -94,11 +94,6 @@ static inline int spi_flash_cmd_write_disable(struct spi_flash *flash)
 /* Program the status register. */
 int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr);
 
-#ifdef CONFIG_SPI_FLASH_BAR
-/* Program the bank address register */
-int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel);
-#endif
-
 /*
  * Same as spi_flash_cmd_read() except it also claims/releases the SPI
  * bus. Used as common part of the ->read() operation.
diff --git a/drivers/mtd/spi/spi_flash_ops.c b/drivers/mtd/spi/spi_flash_ops.c
index c408e27..b4e1c40 100644
--- a/drivers/mtd/spi/spi_flash_ops.c
+++ b/drivers/mtd/spi/spi_flash_ops.c
@@ -39,7 +39,7 @@ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr)
 }
 
 #ifdef CONFIG_SPI_FLASH_BAR
-int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel)
+static int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel)
 {
 	u8 cmd;
 	int ret;
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 27/36] sf: probe: Add support for MX25L25635F
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (25 preceding siblings ...)
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 26/36] sf: ops: Add static qualifier to spi_flash_cmd_bankaddr_write Jagannadha Sutradharudu Teki
@ 2013-09-24 18:20 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 28/36] sf: probe: Add support for MX25L51235F Jagannadha Sutradharudu Teki
                   ` (8 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:20 UTC (permalink / raw)
  To: u-boot

Add support for Macronix MX25L25635F SPI flash.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 drivers/mtd/spi/spi_flash_probe.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index 2978480..e84dfda 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -63,6 +63,7 @@ static const struct spi_flash_params spi_flash_params_table[] = {
 	{"MX25L3205D",	   0xc22016, 0x0,	64 * 1024,    64,	             0},
 	{"MX25L6405D",	   0xc22017, 0x0,	64 * 1024,   128,	             0},
 	{"MX25L12805",	   0xc22018, 0x0,	64 * 1024,   256,	             0},
+	{"MX25L25635F",	   0xc22019, 0x0,	64 * 1024,   512,	             0},
 	{"MX25L12855E",	   0xc22618, 0x0,	64 * 1024,   256,	             0},
 #endif
 #ifdef CONFIG_SPI_FLASH_SPANSION	/* SPANSION */
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 28/36] sf: probe: Add support for MX25L51235F
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (26 preceding siblings ...)
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 27/36] sf: probe: Add support for MX25L25635F Jagannadha Sutradharudu Teki
@ 2013-09-24 18:20 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 29/36] sf: Remove spi_flash_do_alloc references Jagannadha Sutradharudu Teki
                   ` (7 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:20 UTC (permalink / raw)
  To: u-boot

Add support for Macronix MX25L51235F SPI flash.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 drivers/mtd/spi/spi_flash_probe.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index e84dfda..daf53ac 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -64,6 +64,7 @@ static const struct spi_flash_params spi_flash_params_table[] = {
 	{"MX25L6405D",	   0xc22017, 0x0,	64 * 1024,   128,	             0},
 	{"MX25L12805",	   0xc22018, 0x0,	64 * 1024,   256,	             0},
 	{"MX25L25635F",	   0xc22019, 0x0,	64 * 1024,   512,	             0},
+	{"MX25L51235F",	   0xc2201A, 0x0,	64 * 1024,  1024,	             0},
 	{"MX25L12855E",	   0xc22618, 0x0,	64 * 1024,   256,	             0},
 #endif
 #ifdef CONFIG_SPI_FLASH_SPANSION	/* SPANSION */
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 29/36] sf: Remove spi_flash_do_alloc references
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (27 preceding siblings ...)
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 28/36] sf: probe: Add support for MX25L51235F Jagannadha Sutradharudu Teki
@ 2013-09-24 18:20 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 30/36] doc: SPI: Add status.txt for tracking SPI subsys status Jagannadha Sutradharudu Teki
                   ` (6 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:20 UTC (permalink / raw)
  To: u-boot

Added a support for common probe, hence removed removed
spi_flash_do_alloc reference.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 include/spi_flash.h | 38 --------------------------------------
 1 file changed, 38 deletions(-)

diff --git a/include/spi_flash.h b/include/spi_flash.h
index 939da05..2b1151d 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -76,44 +76,6 @@ struct spi_flash {
 	int (*erase)(struct spi_flash *flash, u32 offset, size_t len);
 };
 
-/**
- * spi_flash_do_alloc - Allocate a new spi flash structure
- *
- * The structure is allocated and cleared with default values for
- * read, write and erase, which the caller can modify. The caller must set
- * up size, page_size and sector_size.
- *
- * Use the helper macro spi_flash_alloc() to call this.
- *
- * @offset: Offset of struct spi_slave within slave structure
- * @size: Size of slave structure
- * @spi: SPI slave
- * @name: Name of SPI flash device
- */
-void *spi_flash_do_alloc(int offset, int size, struct spi_slave *spi,
-			 const char *name);
-
-/**
- * spi_flash_alloc - Allocate a new SPI flash structure
- *
- * @_struct: Name of structure to allocate (e.g. struct ramtron_spi_fram). This
- *	structure must contain a member 'struct spi_flash *flash'.
- * @spi: SPI slave
- * @name: Name of SPI flash device
- */
-#define spi_flash_alloc(_struct, spi, name) \
-	spi_flash_do_alloc(offsetof(_struct, flash), sizeof(_struct), \
-				spi, name)
-
-/**
- * spi_flash_alloc_base - Allocate a new SPI flash structure with no private data
- *
- * @spi: SPI slave
- * @name: Name of SPI flash device
- */
-#define spi_flash_alloc_base(spi, name) \
-	spi_flash_do_alloc(0, sizeof(struct spi_flash), spi, name)
-
 struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
 		unsigned int max_hz, unsigned int spi_mode);
 void spi_flash_free(struct spi_flash *flash);
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 30/36] doc: SPI: Add status.txt for tracking SPI subsys status
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (28 preceding siblings ...)
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 29/36] sf: Remove spi_flash_do_alloc references Jagannadha Sutradharudu Teki
@ 2013-09-24 18:20 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 31/36] sf: Add extended read commands support Jagannadha Sutradharudu Teki
                   ` (5 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:20 UTC (permalink / raw)
  To: u-boot

doc/SPI/status.txt added to track the u-boot SPI subsystem status.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 doc/SPI/status.txt | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 doc/SPI/status.txt

diff --git a/doc/SPI/status.txt b/doc/SPI/status.txt
new file mode 100644
index 0000000..be5aebd
--- /dev/null
+++ b/doc/SPI/status.txt
@@ -0,0 +1,27 @@
+Status on SPI subsystem:
+=======================
+
+SPI COMMAND (common/cmd_sf, cmd_spi):
+-
+
+SPI FLASH (drivers/mtd/spi):
+- Bank Address Register (Accessing flashes > 16Mbytes in 3-byte addressing)
+- spi_flash_probe.c: SPI flash probing code.
+- spi_flash_ops.c: SPI flash operations code.
+- spi_flash.c: SPI flash interface, which interacts controller driver.
+- Common probe support for all supported flash vendors except, ramtron.
+
+SPI DRIVERS (drivers/spi):
+-
+
+TODO:
+- Extended read commands support(dual read, dual IO read)
+- Quad Page Program support.
+- Quad Read support(quad fast read, quad IO read)
+- Dual flash connection topology support(accessing two spi flash memories with single cs)
+- Banking support on dual flash connection topology.
+- Need proper cleanups on spi_flash and drivers.
+
+--
+Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
+18-09-2013.
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 31/36] sf: Add extended read commands support
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (29 preceding siblings ...)
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 30/36] doc: SPI: Add status.txt for tracking SPI subsys status Jagannadha Sutradharudu Teki
@ 2013-09-24 18:20 ` Jagannadha Sutradharudu Teki
  2013-09-24 20:10   ` thomas.langer at lantiq.com
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 32/36] sf: Add quad read/write " Jagannadha Sutradharudu Teki
                   ` (4 subsequent siblings)
  35 siblings, 1 reply; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:20 UTC (permalink / raw)
  To: u-boot

Current sf uses FAST_READ command, this patch adds support to
use the different/extended read command.

This implementation will determine the fastest command by taking
the supported commands from the flash and the controller,
controller is always been a priority.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 doc/SPI/status.txt                |   2 +-
 drivers/mtd/spi/spi_flash_ops.c   |   2 +-
 drivers/mtd/spi/spi_flash_probe.c | 180 +++++++++++++++++++++-----------------
 drivers/spi/spi.c                 |   2 +
 include/spi.h                     |   2 +
 include/spi_flash.h               |  18 ++++
 6 files changed, 122 insertions(+), 84 deletions(-)

diff --git a/doc/SPI/status.txt b/doc/SPI/status.txt
index be5aebd..cca3ae4 100644
--- a/doc/SPI/status.txt
+++ b/doc/SPI/status.txt
@@ -10,12 +10,12 @@ SPI FLASH (drivers/mtd/spi):
 - spi_flash_ops.c: SPI flash operations code.
 - spi_flash.c: SPI flash interface, which interacts controller driver.
 - Common probe support for all supported flash vendors except, ramtron.
+- Extended read commands support(Array slow/fast, dual output fast, dual IO fast)
 
 SPI DRIVERS (drivers/spi):
 -
 
 TODO:
-- Extended read commands support(dual read, dual IO read)
 - Quad Page Program support.
 - Quad Read support(quad fast read, quad IO read)
 - Dual flash connection topology support(accessing two spi flash memories with single cs)
diff --git a/drivers/mtd/spi/spi_flash_ops.c b/drivers/mtd/spi/spi_flash_ops.c
index b4e1c40..9fd1d6b 100644
--- a/drivers/mtd/spi/spi_flash_ops.c
+++ b/drivers/mtd/spi/spi_flash_ops.c
@@ -273,7 +273,7 @@ int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset,
 		return 0;
 	}
 
-	cmd[0] = CMD_READ_ARRAY_FAST;
+	cmd[0] = flash->read_cmd;
 	cmd[4] = 0x00;
 
 	while (len) {
diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index daf53ac..e08d66e 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -18,6 +18,13 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+static const u32 spi_read_cmds_array[] = {
+	CMD_READ_ARRAY_SLOW,
+	CMD_READ_ARRAY_FAST,
+	CMD_READ_DUAL_OUTPUT_FAST,
+	CMD_READ_DUAL_IO_FAST,
+};
+
 /*
  * struct spi_flash_params - SPI/QSPI flash device params structure
  *
@@ -26,6 +33,7 @@ DECLARE_GLOBAL_DATA_PTR;
  * @ext_jedec:		Device ext_jedec ID
  * @sector_size:	Sector size of this device
  * @nr_sectors:		No.of sectors on this device
+ * @rd_cmd:		Read command
  * @flags:		Importent param, for flash specific behaviour
  */
 struct spi_flash_params {
@@ -34,107 +42,104 @@ struct spi_flash_params {
 	u16 ext_jedec;
 	u32 sector_size;
 	u32 nr_sectors;
+	u8 rd_cmd;
 	u16 flags;
 };
 
 static const struct spi_flash_params spi_flash_params_table[] = {
 #ifdef CONFIG_SPI_FLASH_ATMEL		/* ATMEL */
-	{"AT45DB011D",	   0x1f2200, 0x0,	64 * 1024,     4,	       SECT_4K},
-	{"AT45DB021D",	   0x1f2300, 0x0,	64 * 1024,     8,	       SECT_4K},
-	{"AT45DB041D",	   0x1f2400, 0x0,	64 * 1024,     8,	       SECT_4K},
-	{"AT45DB081D",	   0x1f2500, 0x0,	64 * 1024,    16,	       SECT_4K},
-	{"AT45DB161D",	   0x1f2600, 0x0,	64 * 1024,    32,	       SECT_4K},
-	{"AT45DB321D",	   0x1f2700, 0x0,	64 * 1024,    64,	       SECT_4K},
-	{"AT45DB641D",	   0x1f2800, 0x0,	64 * 1024,   128,	       SECT_4K},
+	{"AT45DB011D",	   0x1f2200, 0x0,	64 * 1024,     4,	    0,		SECT_4K},
+	{"AT45DB021D",	   0x1f2300, 0x0,	64 * 1024,     8,	    0,		SECT_4K},
+	{"AT45DB041D",	   0x1f2400, 0x0,	64 * 1024,     8,	    0,		SECT_4K},
+	{"AT45DB081D",	   0x1f2500, 0x0,	64 * 1024,    16,	    0,		SECT_4K},
+	{"AT45DB161D",	   0x1f2600, 0x0,	64 * 1024,    32,	    0,		SECT_4K},
+	{"AT45DB321D",	   0x1f2700, 0x0,	64 * 1024,    64,	    0,		SECT_4K},
+	{"AT45DB641D",	   0x1f2800, 0x0,	64 * 1024,   128,	    0,		SECT_4K},
 #endif
 #ifdef CONFIG_SPI_FLASH_EON		/* EON */
-	{"EN25Q32B",	   0x1c3016, 0x0,	64 * 1024,    64,	             0},
-	{"EN25Q64",	   0x1c3017, 0x0,	64 * 1024,   128,	       SECT_4K},
-	{"EN25Q128B",	   0x1c3018, 0x0,       64 * 1024,   256,	             0},
+	{"EN25Q32B",	   0x1c3016, 0x0,	64 * 1024,    64,	    0,		      0},
+	{"EN25Q64",	   0x1c3017, 0x0,	64 * 1024,   128,	    0,		SECT_4K},
+	{"EN25Q128B",	   0x1c3018, 0x0,       64 * 1024,   256,	    0,		      0},
 #endif
 #ifdef CONFIG_SPI_FLASH_GIGADEVICE	/* GIGADEVICE */
-	{"GD25Q64B",	   0xc84017, 0x0,	64 * 1024,   128,	       SECT_4K},
-	{"GD25LQ32",	   0xc86016, 0x0,	64 * 1024,    64,	       SECT_4K},
+	{"GD25Q64B",	   0xc84017, 0x0,	64 * 1024,   128,	    0,		SECT_4K},
+	{"GD25LQ32",	   0xc86016, 0x0,	64 * 1024,    64,	    0,		SECT_4K},
 #endif
 #ifdef CONFIG_SPI_FLASH_MACRONIX	/* MACRONIX */
-	{"MX25L4005",	   0xc22013, 0x0,	64 * 1024,     8,	             0},
-	{"MX25L8005",	   0xc22014, 0x0,	64 * 1024,    16,	             0},
-	{"MX25L1605D",	   0xc22015, 0x0,	64 * 1024,    32,	             0},
-	{"MX25L3205D",	   0xc22016, 0x0,	64 * 1024,    64,	             0},
-	{"MX25L6405D",	   0xc22017, 0x0,	64 * 1024,   128,	             0},
-	{"MX25L12805",	   0xc22018, 0x0,	64 * 1024,   256,	             0},
-	{"MX25L25635F",	   0xc22019, 0x0,	64 * 1024,   512,	             0},
-	{"MX25L51235F",	   0xc2201A, 0x0,	64 * 1024,  1024,	             0},
-	{"MX25L12855E",	   0xc22618, 0x0,	64 * 1024,   256,	             0},
+	{"MX25L4005",	   0xc22013, 0x0,	64 * 1024,     8,	    0,		      0},
+	{"MX25L8005",	   0xc22014, 0x0,	64 * 1024,    16,	    0,		      0},
+	{"MX25L1605D",	   0xc22015, 0x0,	64 * 1024,    32,	    0,		      0},
+	{"MX25L3205D",	   0xc22016, 0x0,	64 * 1024,    64,	    0,		      0},
+	{"MX25L6405D",	   0xc22017, 0x0,	64 * 1024,   128,	    0,		      0},
+	{"MX25L12805",	   0xc22018, 0x0,	64 * 1024,   256,	    0,		      0},
+	{"MX25L12855E",	   0xc22618, 0x0,	64 * 1024,   256,	    0,		      0},
 #endif
 #ifdef CONFIG_SPI_FLASH_SPANSION	/* SPANSION */
-	{"S25FL008A",	   0x010213, 0x0,	64 * 1024,    16,	             0},
-	{"S25FL016A",	   0x010214, 0x0,	64 * 1024,    32,	             0},
-	{"S25FL032A",	   0x010215, 0x0,	64 * 1024,    64,	             0},
-	{"S25FL064A",	   0x010216, 0x0,	64 * 1024,   128,	             0},
-	{"S25FL128P_256K", 0x012018, 0x0300,   256 * 1024,    64,	             0},
-	{"S25FL128P_64K",  0x012018, 0x0301,    64 * 1024,   256,	             0},
-	{"S25FL032P",	   0x010215, 0x4d00,    64 * 1024,    64,	             0},
-	{"S25FL064P",	   0x010216, 0x4d00,    64 * 1024,   128,	             0},
-	{"S25FL128S_64K",  0x012018, 0x4d01,    64 * 1024,   256,		     0},
-	{"S25FL256S_256K", 0x010219, 0x4d00,    64 * 1024,   512,	             0},
-	{"S25FL256S_64K",  0x010219, 0x4d01,    64 * 1024,   512,	             0},
-	{"S25FL512S_256K", 0x010220, 0x4d00,    64 * 1024,  1024,	             0},
-	{"S25FL512S_64K",  0x010220, 0x4d01,    64 * 1024,  1024,	             0},
+	{"S25FL008A",	   0x010213, 0x0,	64 * 1024,    16,	    0,		      0},
+	{"S25FL016A",	   0x010214, 0x0,	64 * 1024,    32,	    0,		      0},
+	{"S25FL032A",	   0x010215, 0x0,	64 * 1024,    64,	    0,		      0},
+	{"S25FL064A",	   0x010216, 0x0,	64 * 1024,   128,	    0,		      0},
+	{"S25FL128P_256K", 0x012018, 0x0300,   256 * 1024,    64, RD_CMD_FULL,		      0},
+	{"S25FL128P_64K",  0x012018, 0x0301,    64 * 1024,   256, RD_CMD_FULL,		      0},
+	{"S25FL032P",	   0x010215, 0x4d00,    64 * 1024,    64, RD_CMD_FULL,		      0},
+	{"S25FL064P",	   0x010216, 0x4d00,    64 * 1024,   128, RD_CMD_FULL,		      0},
+	{"S25FL128S_64K",  0x012018, 0x4d01,    64 * 1024,   256, RD_CMD_FULL,		      0},
+	{"S25FL256S_64K",  0x010219, 0x4d01,    64 * 1024,   512, RD_CMD_FULL,		      0},
+	{"S25FL512S_64K",  0x010220, 0x4d01,    64 * 1024,  1024, RD_CMD_FULL,		      0},
 #endif
 #ifdef CONFIG_SPI_FLASH_STMICRO		/* STMICRO */
-	{"M25P10",	   0x202011, 0x0,       32 * 1024,     4,	             0},
-	{"M25P20",	   0x202012, 0x0,       64 * 1024,     4,	             0},
-	{"M25P40",	   0x202013, 0x0,       64 * 1024,     8,	             0},
-	{"M25P80",	   0x202014, 0x0,       64 * 1024,    16,	             0},
-	{"M25P16",	   0x202015, 0x0,       64 * 1024,    32,	             0},
-	{"M25P32",	   0x202016, 0x0,       64 * 1024,    64,	             0},
-	{"M25P64",	   0x202017, 0x0,       64 * 1024,   128,	             0},
-	{"M25P128",	   0x202018, 0x0,      256 * 1024,    64,	             0},
-	{"N25Q32",	   0x20ba16, 0x0,       64 * 1024,    64,	       SECT_4K},
-	{"N25Q32A",	   0x20bb16, 0x0,       64 * 1024,    64,	       SECT_4K},
-	{"N25Q64",	   0x20ba17, 0x0,       64 * 1024,   128,	       SECT_4K},
-	{"N25Q64A",	   0x20bb17, 0x0,       64 * 1024,   128,	       SECT_4K},
-	{"N25Q128",	   0x20ba18, 0x0,       64 * 1024,   256,	       SECT_4K},
-	{"N25Q128A",	   0x20bb18, 0x0,       64 * 1024,   256,	       SECT_4K},
-	{"N25Q256",	   0x20ba19, 0x0,       64 * 1024,   512,	       SECT_4K},
-	{"N25Q256A",	   0x20bb19, 0x0,       64 * 1024,   512,	       SECT_4K},
-	{"N25Q512",	   0x20ba20, 0x0,       64 * 1024,  1024,      E_FSR | SECT_4K},
-	{"N25Q512A",	   0x20bb20, 0x0,       64 * 1024,  1024,      E_FSR | SECT_4K},
-	{"N25Q1024",	   0x20ba21, 0x0,       64 * 1024,  2048,      E_FSR | SECT_4K},
-	{"N25Q1024A",	   0x20bb21, 0x0,       64 * 1024,  2048,      E_FSR | SECT_4K},
+	{"M25P10",	   0x202011, 0x0,       32 * 1024,     4,	    0,		      0},
+	{"M25P20",	   0x202012, 0x0,       64 * 1024,     4,	    0,		      0},
+	{"M25P40",	   0x202013, 0x0,       64 * 1024,     8,	    0,		      0},
+	{"M25P80",	   0x202014, 0x0,       64 * 1024,    16,	    0,		      0},
+	{"M25P16",	   0x202015, 0x0,       64 * 1024,    32,	    0,		      0},
+	{"M25P32",	   0x202016, 0x0,       64 * 1024,    64,	    0,		      0},
+	{"M25P64",	   0x202017, 0x0,       64 * 1024,   128,	    0,		      0},
+	{"M25P128",	   0x202018, 0x0,      256 * 1024,    64,	    0,		      0},
+	{"N25Q32",	   0x20ba16, 0x0,       64 * 1024,    64, RD_CMD_FULL,		SECT_4K},
+	{"N25Q32A",	   0x20bb16, 0x0,       64 * 1024,    64, RD_CMD_FULL,		SECT_4K},
+	{"N25Q64",	   0x20ba17, 0x0,       64 * 1024,   128, RD_CMD_FULL,		SECT_4K},
+	{"N25Q64A",	   0x20bb17, 0x0,       64 * 1024,   128, RD_CMD_FULL,		SECT_4K},
+	{"N25Q128",	   0x20ba18, 0x0,       64 * 1024,   256, RD_CMD_FULL,		SECT_4K},
+	{"N25Q128A",	   0x20bb18, 0x0,       64 * 1024,   256, RD_CMD_FULL,		SECT_4K},
+	{"N25Q256",	   0x20ba19, 0x0,       64 * 1024,   512, RD_CMD_FULL,		SECT_4K},
+	{"N25Q256A",	   0x20bb19, 0x0,       64 * 1024,   512, RD_CMD_FULL,		SECT_4K},
+	{"N25Q512",	   0x20ba20, 0x0,       64 * 1024,  1024, RD_CMD_FULL,	E_FSR | SECT_4K},
+	{"N25Q512A",	   0x20bb20, 0x0,       64 * 1024,  1024, RD_CMD_FULL,	E_FSR | SECT_4K},
+	{"N25Q1024",	   0x20ba21, 0x0,       64 * 1024,  2048, RD_CMD_FULL,	E_FSR | SECT_4K},
+	{"N25Q1024A",	   0x20bb21, 0x0,       64 * 1024,  2048, RD_CMD_FULL,	E_FSR | SECT_4K},
 #endif
 #ifdef CONFIG_SPI_FLASH_SST		/* SST */
-	{"SST25VF040B",	   0xbf258d, 0x0,	64 * 1024,     8,     SECT_4K | SST_WP},
-	{"SST25VF080B",	   0xbf258e, 0x0,	64 * 1024,    16,     SECT_4K | SST_WP},
-	{"SST25VF016B",	   0xbf2541, 0x0,	64 * 1024,    32,     SECT_4K | SST_WP},
-	{"SST25VF032B",	   0xbf254a, 0x0,	64 * 1024,    64,     SECT_4K | SST_WP},
-	{"SST25VF064C",	   0xbf254b, 0x0,	64 * 1024,   128,	       SECT_4K},
-	{"SST25WF512",	   0xbf2501, 0x0,	64 * 1024,     1,     SECT_4K | SST_WP},
-	{"SST25WF010",	   0xbf2502, 0x0,	64 * 1024,     2,     SECT_4K | SST_WP},
-	{"SST25WF020",	   0xbf2503, 0x0,	64 * 1024,     4,     SECT_4K | SST_WP},
-	{"SST25WF040",	   0xbf2504, 0x0,	64 * 1024,     8,     SECT_4K | SST_WP},
-	{"SST25WF080",	   0xbf2505, 0x0,	64 * 1024,    16,     SECT_4K | SST_WP},
+	{"SST25VF040B",	   0xbf258d, 0x0,	64 * 1024,     8,	    0, SECT_4K | SST_WP},
+	{"SST25VF080B",	   0xbf258e, 0x0,	64 * 1024,    16,	    0, SECT_4K | SST_WP},
+	{"SST25VF016B",	   0xbf2541, 0x0,	64 * 1024,    32,	    0, SECT_4K | SST_WP},
+	{"SST25VF032B",	   0xbf254a, 0x0,	64 * 1024,    64,	    0, SECT_4K | SST_WP},
+	{"SST25VF064C",	   0xbf254b, 0x0,	64 * 1024,   128,	    0		SECT_4K},
+	{"SST25WF512",	   0xbf2501, 0x0,	64 * 1024,     1,	    0, SECT_4K | SST_WP},
+	{"SST25WF010",	   0xbf2502, 0x0,	64 * 1024,     2,	    0, SECT_4K | SST_WP},
+	{"SST25WF020",	   0xbf2503, 0x0,	64 * 1024,     4,	    0, SECT_4K | SST_WP},
+	{"SST25WF040",	   0xbf2504, 0x0,	64 * 1024,     8,	    0, SECT_4K | SST_WP},
+	{"SST25WF080",	   0xbf2505, 0x0,	64 * 1024,    16,	    0, SECT_4K | SST_WP},
 #endif
 #ifdef CONFIG_SPI_FLASH_WINBOND		/* WINBOND */
-	{"W25P80",	   0xef2014, 0x0,	64 * 1024,    16,		     0},
-	{"W25P16",	   0xef2015, 0x0,	64 * 1024,    32,		     0},
-	{"W25P32",	   0xef2016, 0x0,	64 * 1024,    64,		     0},
-	{"W25X40",	   0xef3013, 0x0,	 4 * 1024,   128,	       SECT_4K},
-	{"W25X16",	   0xef3015, 0x0,	 4 * 1024,   512,	       SECT_4K},
-	{"W25X32",	   0xef3016, 0x0,	 4 * 1024,  1024,	       SECT_4K},
-	{"W25X64",	   0xef3017, 0x0,	 4 * 1024,  2048,	       SECT_4K},
-	{"W25Q80BL",	   0xef4014, 0x0,	 4 * 1024,   256,	       SECT_4K},
-	{"W25Q16CL",	   0xef4015, 0x0,	 4 * 1024,   512,	       SECT_4K},
-	{"W25Q32BV",	   0xef4016, 0x0,	 4 * 1024,  1024,	       SECT_4K},
-	{"W25Q64CV",	   0xef4017, 0x0,	 4 * 1024,  2048,	       SECT_4K},
-	{"W25Q128BV",	   0xef4018, 0x0,	 4 * 1024,  4096,	       SECT_4K},
-	{"W25Q256",	   0xef4019, 0x0,	 4 * 1024,  8192,	       SECT_4K},
-	{"W25Q80BW",	   0xef5014, 0x0,	 4 * 1024,   256,	       SECT_4K},
-	{"W25Q16DW",	   0xef6015, 0x0,	 4 * 1024,   512,	       SECT_4K},
-	{"W25Q32DW",	   0xef6016, 0x0,	 4 * 1024,  1024,	       SECT_4K},
-	{"W25Q64DW",	   0xef6017, 0x0,	 4 * 1024,  2048,	       SECT_4K},
-	{"W25Q128FW",	   0xef6018, 0x0,	 4 * 1024,  4096,	       SECT_4K},
+	{"W25P80",	   0xef2014, 0x0,	64 * 1024,    16,	    0,		      0},
+	{"W25P16",	   0xef2015, 0x0,	64 * 1024,    32,	    0,		      0},
+	{"W25P32",	   0xef2016, 0x0,	64 * 1024,    64,	    0,		      0},
+	{"W25X40",	   0xef3013, 0x0,	 4 * 1024,   128,	    0,		SECT_4K},
+	{"W25X16",	   0xef3015, 0x0,	 4 * 1024,   512,	    0,		SECT_4K},
+	{"W25X32",	   0xef3016, 0x0,	 4 * 1024,  1024,	    0,		SECT_4K},
+	{"W25X64",	   0xef3017, 0x0,	 4 * 1024,  2048,	    0,		SECT_4K},
+	{"W25Q80BL",	   0xef4014, 0x0,	 4 * 1024,   256, RD_CMD_FULL,		SECT_4K},
+	{"W25Q16CL",	   0xef4015, 0x0,	 4 * 1024,   512, RD_CMD_FULL,		SECT_4K},
+	{"W25Q32BV",	   0xef4016, 0x0,	 4 * 1024,  1024, RD_CMD_FULL,		SECT_4K},
+	{"W25Q64CV",	   0xef4017, 0x0,	 4 * 1024,  2048, RD_CMD_FULL,		SECT_4K},
+	{"W25Q128BV",	   0xef4018, 0x0,	 4 * 1024,  4096, RD_CMD_FULL,		SECT_4K},
+	{"W25Q256",	   0xef4019, 0x0,	 4 * 1024,  8192, RD_CMD_FULL,		SECT_4K},
+	{"W25Q80BW",	   0xef5014, 0x0,	 4 * 1024,   256, RD_CMD_FULL,		SECT_4K},
+	{"W25Q16DW",	   0xef6015, 0x0,	 4 * 1024,   512, RD_CMD_FULL,		SECT_4K},
+	{"W25Q32DW",	   0xef6016, 0x0,	 4 * 1024,  1024, RD_CMD_FULL,		SECT_4K},
+	{"W25Q64DW",	   0xef6017, 0x0,	 4 * 1024,  2048, RD_CMD_FULL,		SECT_4K},
+	{"W25Q128FW",	   0xef6018, 0x0,	 4 * 1024,  4096, RD_CMD_FULL,		SECT_4K},
 #endif
 	/*
 	 * Note:
@@ -158,6 +163,7 @@ struct spi_flash *spi_flash_validate_ids(struct spi_slave *spi, u8 *idcode)
 	int i;
 	u16 jedec = idcode[1] << 8 | idcode[2];
 	u16 ext_jedec = idcode[3] << 8 | idcode[4];
+	u8 cmd;
 
 	/* Get the flash id (jedec = manuf_id + dev_id, ext_jedec) */
 	for (i = 0; i < ARRAY_SIZE(spi_flash_params_table); i++) {
@@ -203,6 +209,16 @@ struct spi_flash *spi_flash_validate_ids(struct spi_slave *spi, u8 *idcode)
 	flash->sector_size = params->sector_size;
 	flash->size = flash->sector_size * params->nr_sectors;
 
+	/* Look for the fastest read cmd */
+	cmd = fls(params->rd_cmd & flash->spi->rd_cmd);
+	if (cmd) {
+		cmd = spi_read_cmds_array[cmd - 1];
+		flash->read_cmd = cmd;
+	} else {
+		/* Go for controller supported command */
+		flash->read_cmd = flash->spi->rd_cmd;
+	}
+
 	/* Compute erase sector and command */
 	if (params->flags & SECT_4K) {
 		flash->erase_cmd = CMD_ERASE_4K;
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index ea39d1a..0ac9fab 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <malloc.h>
 #include <spi.h>
+#include <spi_flash.h>
 
 void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
 			 unsigned int cs)
@@ -20,6 +21,7 @@ void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
 		slave = (struct spi_slave *)(ptr + offset);
 		slave->bus = bus;
 		slave->cs = cs;
+		slave->rd_cmd = CMD_READ_ARRAY_FAST;
 	}
 
 	return ptr;
diff --git a/include/spi.h b/include/spi.h
index c0dab57..093847e 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -40,11 +40,13 @@
  *   cs:	ID of the chip select connected to the slave.
  *   max_write_size:	If non-zero, the maximum number of bytes which can
  *		be written at once, excluding command bytes.
+ *   rd_cmd:	Read command.
  */
 struct spi_slave {
 	unsigned int	bus;
 	unsigned int	cs;
 	unsigned int max_write_size;
+	u8 rd_cmd;
 };
 
 /*-----------------------------------------------------------------------
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 2b1151d..e630913 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -27,6 +27,22 @@
 #define SECT_32K		(1 << 1)
 #define E_FSR			(1 << 2)
 
+/* Read commands */
+#define CMD_READ_ARRAY_SLOW		0x03
+#define CMD_READ_ARRAY_FAST		0x0b
+#define CMD_READ_DUAL_OUTPUT_FAST	0x3b
+#define CMD_READ_DUAL_IO_FAST		0xbb
+
+enum spi_read_cmds {
+	ARRAY_SLOW = 1 << 0,
+	ARRAY_FAST = 1 << 1,
+	DUAL_OUTPUT_FAST = 1 << 2,
+	DUAL_IO_FAST = 1 << 3,
+};
+
+#define RD_CMD_FULL	ARRAY_SLOW | ARRAY_FAST | DUAL_OUTPUT_FAST | \
+			DUAL_IO_FAST
+
 /* SST specific macros */
 #ifdef CONFIG_SPI_FLASH_SST
 # define SST_WP			0x01	/* Supports AAI word program */
@@ -48,6 +64,7 @@
  * @bank_curr:		Current flash bank
  * @poll_cmd:		Poll cmd - for flash erase/program
  * @erase_cmd:		Erase cmd 4K, 32K, 64K
+ * @read_cmd:		Read cmd SA, FA, DOF, DIOF
  * @memory_map:		Address of read-only SPI flash access
  * @read:		Flash read ops
  * @write:		Flash write ops
@@ -68,6 +85,7 @@ struct spi_flash {
 #endif
 	u8 poll_cmd;
 	u8 erase_cmd;
+	u8 read_cmd;
 
 	void *memory_map;
 	int (*read)(struct spi_flash *flash, u32 offset, size_t len, void *buf);
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 32/36] sf: Add quad read/write commands support
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (30 preceding siblings ...)
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 31/36] sf: Add extended read commands support Jagannadha Sutradharudu Teki
@ 2013-09-24 18:20 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 33/36] sf: ops: Add configuration register writing support Jagannadha Sutradharudu Teki
                   ` (3 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:20 UTC (permalink / raw)
  To: u-boot

Current sf uses PAGE_PROGRAM command for write and FAST_READ,
SLOW_READ, DUAL_READ and DUAL_IO_READ commands for read this
patch adds support to use the quad read/write commands.
- QUAD_PAGE_PROGRAM
- QUAD_OUTPUT_FAST

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 doc/SPI/status.txt                |   5 +-
 drivers/mtd/spi/spi_flash_ops.c   |   2 +-
 drivers/mtd/spi/spi_flash_probe.c | 174 +++++++++++++++++++++-----------------
 drivers/spi/spi.c                 |   1 +
 include/spi.h                     |   2 +
 include/spi_flash.h               |  17 +++-
 6 files changed, 119 insertions(+), 82 deletions(-)

diff --git a/doc/SPI/status.txt b/doc/SPI/status.txt
index cca3ae4..e84911d 100644
--- a/doc/SPI/status.txt
+++ b/doc/SPI/status.txt
@@ -11,13 +11,14 @@ SPI FLASH (drivers/mtd/spi):
 - spi_flash.c: SPI flash interface, which interacts controller driver.
 - Common probe support for all supported flash vendors except, ramtron.
 - Extended read commands support(Array slow/fast, dual output fast, dual IO fast)
+- Quad Page Program support.
+- Quad Read support(quad fast read, quad IO read)
 
 SPI DRIVERS (drivers/spi):
 -
 
 TODO:
-- Quad Page Program support.
-- Quad Read support(quad fast read, quad IO read)
+- Quad Read support(quad IO read)
 - Dual flash connection topology support(accessing two spi flash memories with single cs)
 - Banking support on dual flash connection topology.
 - Need proper cleanups on spi_flash and drivers.
diff --git a/drivers/mtd/spi/spi_flash_ops.c b/drivers/mtd/spi/spi_flash_ops.c
index 9fd1d6b..59127f8 100644
--- a/drivers/mtd/spi/spi_flash_ops.c
+++ b/drivers/mtd/spi/spi_flash_ops.c
@@ -200,7 +200,7 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,
 
 	page_size = flash->page_size;
 
-	cmd[0] = CMD_PAGE_PROGRAM;
+	cmd[0] = flash->write_cmd;
 	for (actual = 0; actual < len; actual += chunk_len) {
 #ifdef CONFIG_SPI_FLASH_BAR
 		u8 bank_sel;
diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index e08d66e..30ef85c 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -23,6 +23,12 @@ static const u32 spi_read_cmds_array[] = {
 	CMD_READ_ARRAY_FAST,
 	CMD_READ_DUAL_OUTPUT_FAST,
 	CMD_READ_DUAL_IO_FAST,
+	CMD_READ_QUAD_OUTPUT_FAST,
+};
+
+static const u32 spi_write_cmds_array[] = {
+	CMD_PAGE_PROGRAM,
+	CMD_QUAD_PAGE_PROGRAM,
 };
 
 /*
@@ -34,6 +40,7 @@ static const u32 spi_read_cmds_array[] = {
  * @sector_size:	Sector size of this device
  * @nr_sectors:		No.of sectors on this device
  * @rd_cmd:		Read command
+ * @wr_cmd:		Write command
  * @flags:		Importent param, for flash specific behaviour
  */
 struct spi_flash_params {
@@ -43,103 +50,104 @@ struct spi_flash_params {
 	u32 sector_size;
 	u32 nr_sectors;
 	u8 rd_cmd;
+	u8 wr_cmd;
 	u16 flags;
 };
 
 static const struct spi_flash_params spi_flash_params_table[] = {
 #ifdef CONFIG_SPI_FLASH_ATMEL		/* ATMEL */
-	{"AT45DB011D",	   0x1f2200, 0x0,	64 * 1024,     4,	    0,		SECT_4K},
-	{"AT45DB021D",	   0x1f2300, 0x0,	64 * 1024,     8,	    0,		SECT_4K},
-	{"AT45DB041D",	   0x1f2400, 0x0,	64 * 1024,     8,	    0,		SECT_4K},
-	{"AT45DB081D",	   0x1f2500, 0x0,	64 * 1024,    16,	    0,		SECT_4K},
-	{"AT45DB161D",	   0x1f2600, 0x0,	64 * 1024,    32,	    0,		SECT_4K},
-	{"AT45DB321D",	   0x1f2700, 0x0,	64 * 1024,    64,	    0,		SECT_4K},
-	{"AT45DB641D",	   0x1f2800, 0x0,	64 * 1024,   128,	    0,		SECT_4K},
+	{"AT45DB011D",	   0x1f2200, 0x0,	64 * 1024,     4,	    0,		 0,	     SECT_4K},
+	{"AT45DB021D",	   0x1f2300, 0x0,	64 * 1024,     8,	    0,		 0,	     SECT_4K},
+	{"AT45DB041D",	   0x1f2400, 0x0,	64 * 1024,     8,	    0,		 0,	     SECT_4K},
+	{"AT45DB081D",	   0x1f2500, 0x0,	64 * 1024,    16,	    0,		 0,	     SECT_4K},
+	{"AT45DB161D",	   0x1f2600, 0x0,	64 * 1024,    32,	    0,		 0,	     SECT_4K},
+	{"AT45DB321D",	   0x1f2700, 0x0,	64 * 1024,    64,	    0,		 0,	     SECT_4K},
+	{"AT45DB641D",	   0x1f2800, 0x0,	64 * 1024,   128,	    0,		 0,	     SECT_4K},
 #endif
 #ifdef CONFIG_SPI_FLASH_EON		/* EON */
-	{"EN25Q32B",	   0x1c3016, 0x0,	64 * 1024,    64,	    0,		      0},
-	{"EN25Q64",	   0x1c3017, 0x0,	64 * 1024,   128,	    0,		SECT_4K},
-	{"EN25Q128B",	   0x1c3018, 0x0,       64 * 1024,   256,	    0,		      0},
+	{"EN25Q32B",	   0x1c3016, 0x0,	64 * 1024,    64,	    0,		 0,		   0},
+	{"EN25Q64",	   0x1c3017, 0x0,	64 * 1024,   128,	    0,		 0,	     SECT_4K},
+	{"EN25Q128B",	   0x1c3018, 0x0,       64 * 1024,   256,	    0,		 0,		   0},
 #endif
 #ifdef CONFIG_SPI_FLASH_GIGADEVICE	/* GIGADEVICE */
-	{"GD25Q64B",	   0xc84017, 0x0,	64 * 1024,   128,	    0,		SECT_4K},
-	{"GD25LQ32",	   0xc86016, 0x0,	64 * 1024,    64,	    0,		SECT_4K},
+	{"GD25Q64B",	   0xc84017, 0x0,	64 * 1024,   128,	    0,		 0,	     SECT_4K},
+	{"GD25LQ32",	   0xc86016, 0x0,	64 * 1024,    64,	    0,		 0,	     SECT_4K},
 #endif
 #ifdef CONFIG_SPI_FLASH_MACRONIX	/* MACRONIX */
-	{"MX25L4005",	   0xc22013, 0x0,	64 * 1024,     8,	    0,		      0},
-	{"MX25L8005",	   0xc22014, 0x0,	64 * 1024,    16,	    0,		      0},
-	{"MX25L1605D",	   0xc22015, 0x0,	64 * 1024,    32,	    0,		      0},
-	{"MX25L3205D",	   0xc22016, 0x0,	64 * 1024,    64,	    0,		      0},
-	{"MX25L6405D",	   0xc22017, 0x0,	64 * 1024,   128,	    0,		      0},
-	{"MX25L12805",	   0xc22018, 0x0,	64 * 1024,   256,	    0,		      0},
-	{"MX25L12855E",	   0xc22618, 0x0,	64 * 1024,   256,	    0,		      0},
+	{"MX25L4005",	   0xc22013, 0x0,	64 * 1024,     8,	    0,		 0,		   0},
+	{"MX25L8005",	   0xc22014, 0x0,	64 * 1024,    16,	    0,		 0,		   0},
+	{"MX25L1605D",	   0xc22015, 0x0,	64 * 1024,    32,	    0,		 0,		   0},
+	{"MX25L3205D",	   0xc22016, 0x0,	64 * 1024,    64,	    0,		 0,		   0},
+	{"MX25L6405D",	   0xc22017, 0x0,	64 * 1024,   128,	    0,		 0,		   0},
+	{"MX25L12805",	   0xc22018, 0x0,	64 * 1024,   256,	    0,		 0,		   0},
+	{"MX25L12855E",	   0xc22618, 0x0,	64 * 1024,   256,	    0,		 0,		   0},
 #endif
 #ifdef CONFIG_SPI_FLASH_SPANSION	/* SPANSION */
-	{"S25FL008A",	   0x010213, 0x0,	64 * 1024,    16,	    0,		      0},
-	{"S25FL016A",	   0x010214, 0x0,	64 * 1024,    32,	    0,		      0},
-	{"S25FL032A",	   0x010215, 0x0,	64 * 1024,    64,	    0,		      0},
-	{"S25FL064A",	   0x010216, 0x0,	64 * 1024,   128,	    0,		      0},
-	{"S25FL128P_256K", 0x012018, 0x0300,   256 * 1024,    64, RD_CMD_FULL,		      0},
-	{"S25FL128P_64K",  0x012018, 0x0301,    64 * 1024,   256, RD_CMD_FULL,		      0},
-	{"S25FL032P",	   0x010215, 0x4d00,    64 * 1024,    64, RD_CMD_FULL,		      0},
-	{"S25FL064P",	   0x010216, 0x4d00,    64 * 1024,   128, RD_CMD_FULL,		      0},
-	{"S25FL128S_64K",  0x012018, 0x4d01,    64 * 1024,   256, RD_CMD_FULL,		      0},
-	{"S25FL256S_64K",  0x010219, 0x4d01,    64 * 1024,   512, RD_CMD_FULL,		      0},
-	{"S25FL512S_64K",  0x010220, 0x4d01,    64 * 1024,  1024, RD_CMD_FULL,		      0},
+	{"S25FL008A",	   0x010213, 0x0,	64 * 1024,    16,	    0,		 0,		   0},
+	{"S25FL016A",	   0x010214, 0x0,	64 * 1024,    32,	    0,		 0,		   0},
+	{"S25FL032A",	   0x010215, 0x0,	64 * 1024,    64,	    0,		 0,		   0},
+	{"S25FL064A",	   0x010216, 0x0,	64 * 1024,   128,	    0,		 0,		   0},
+	{"S25FL128P_256K", 0x012018, 0x0300,   256 * 1024,    64, RD_CMD_FULL, WR_CMD_FULL,		   0},
+	{"S25FL128P_64K",  0x012018, 0x0301,    64 * 1024,   256, RD_CMD_FULL, WR_CMD_FULL,		   0},
+	{"S25FL032P",	   0x010215, 0x4d00,    64 * 1024,    64, RD_CMD_FULL, WR_CMD_FULL,		   0},
+	{"S25FL064P",	   0x010216, 0x4d00,    64 * 1024,   128, RD_CMD_FULL, WR_CMD_FULL,		   0},
+	{"S25FL128S_64K",  0x012018, 0x4d01,    64 * 1024,   256, RD_CMD_FULL, WR_CMD_FULL,		   0},
+	{"S25FL256S_64K",  0x010219, 0x4d01,    64 * 1024,   512, RD_CMD_FULL, WR_CMD_FULL,		   0},
+	{"S25FL512S_64K",  0x010220, 0x4d01,    64 * 1024,  1024, RD_CMD_FULL, WR_CMD_FULL,		   0},
 #endif
 #ifdef CONFIG_SPI_FLASH_STMICRO		/* STMICRO */
-	{"M25P10",	   0x202011, 0x0,       32 * 1024,     4,	    0,		      0},
-	{"M25P20",	   0x202012, 0x0,       64 * 1024,     4,	    0,		      0},
-	{"M25P40",	   0x202013, 0x0,       64 * 1024,     8,	    0,		      0},
-	{"M25P80",	   0x202014, 0x0,       64 * 1024,    16,	    0,		      0},
-	{"M25P16",	   0x202015, 0x0,       64 * 1024,    32,	    0,		      0},
-	{"M25P32",	   0x202016, 0x0,       64 * 1024,    64,	    0,		      0},
-	{"M25P64",	   0x202017, 0x0,       64 * 1024,   128,	    0,		      0},
-	{"M25P128",	   0x202018, 0x0,      256 * 1024,    64,	    0,		      0},
-	{"N25Q32",	   0x20ba16, 0x0,       64 * 1024,    64, RD_CMD_FULL,		SECT_4K},
-	{"N25Q32A",	   0x20bb16, 0x0,       64 * 1024,    64, RD_CMD_FULL,		SECT_4K},
-	{"N25Q64",	   0x20ba17, 0x0,       64 * 1024,   128, RD_CMD_FULL,		SECT_4K},
-	{"N25Q64A",	   0x20bb17, 0x0,       64 * 1024,   128, RD_CMD_FULL,		SECT_4K},
-	{"N25Q128",	   0x20ba18, 0x0,       64 * 1024,   256, RD_CMD_FULL,		SECT_4K},
-	{"N25Q128A",	   0x20bb18, 0x0,       64 * 1024,   256, RD_CMD_FULL,		SECT_4K},
-	{"N25Q256",	   0x20ba19, 0x0,       64 * 1024,   512, RD_CMD_FULL,		SECT_4K},
-	{"N25Q256A",	   0x20bb19, 0x0,       64 * 1024,   512, RD_CMD_FULL,		SECT_4K},
-	{"N25Q512",	   0x20ba20, 0x0,       64 * 1024,  1024, RD_CMD_FULL,	E_FSR | SECT_4K},
-	{"N25Q512A",	   0x20bb20, 0x0,       64 * 1024,  1024, RD_CMD_FULL,	E_FSR | SECT_4K},
-	{"N25Q1024",	   0x20ba21, 0x0,       64 * 1024,  2048, RD_CMD_FULL,	E_FSR | SECT_4K},
-	{"N25Q1024A",	   0x20bb21, 0x0,       64 * 1024,  2048, RD_CMD_FULL,	E_FSR | SECT_4K},
+	{"M25P10",	   0x202011, 0x0,       32 * 1024,     4,	    0,		 0,		   0},
+	{"M25P20",	   0x202012, 0x0,       64 * 1024,     4,	    0,		 0,		   0},
+	{"M25P40",	   0x202013, 0x0,       64 * 1024,     8,	    0,		 0,		   0},
+	{"M25P80",	   0x202014, 0x0,       64 * 1024,    16,	    0,		 0,		   0},
+	{"M25P16",	   0x202015, 0x0,       64 * 1024,    32,	    0,		 0,		   0},
+	{"M25P32",	   0x202016, 0x0,       64 * 1024,    64,	    0,		 0,		   0},
+	{"M25P64",	   0x202017, 0x0,       64 * 1024,   128,	    0,		 0,		   0},
+	{"M25P128",	   0x202018, 0x0,      256 * 1024,    64,	    0,		 0,		   0},
+	{"N25Q32",	   0x20ba16, 0x0,       64 * 1024,    64, RD_CMD_FULL, WR_CMD_FULL,	     SECT_4K},
+	{"N25Q32A",	   0x20bb16, 0x0,       64 * 1024,    64, RD_CMD_FULL, WR_CMD_FULL,	     SECT_4K},
+	{"N25Q64",	   0x20ba17, 0x0,       64 * 1024,   128, RD_CMD_FULL, WR_CMD_FULL,          SECT_4K},
+	{"N25Q64A",	   0x20bb17, 0x0,       64 * 1024,   128, RD_CMD_FULL, WR_CMD_FULL,	     SECT_4K},
+	{"N25Q128",	   0x20ba18, 0x0,       64 * 1024,   256, RD_CMD_FULL, WR_CMD_FULL,	     SECT_4K},
+	{"N25Q128A",	   0x20bb18, 0x0,       64 * 1024,   256, RD_CMD_FULL, WR_CMD_FULL,	     SECT_4K},
+	{"N25Q256",	   0x20ba19, 0x0,       64 * 1024,   512, RD_CMD_FULL, WR_CMD_FULL,	     SECT_4K},
+	{"N25Q256A",	   0x20bb19, 0x0,       64 * 1024,   512, RD_CMD_FULL, WR_CMD_FULL,	     SECT_4K},
+	{"N25Q512",	   0x20ba20, 0x0,       64 * 1024,  1024, RD_CMD_FULL, WR_CMD_FULL,  E_FSR | SECT_4K},
+	{"N25Q512A",	   0x20bb20, 0x0,       64 * 1024,  1024, RD_CMD_FULL, WR_CMD_FULL,  E_FSR | SECT_4K},
+	{"N25Q1024",	   0x20ba21, 0x0,       64 * 1024,  2048, RD_CMD_FULL, WR_CMD_FULL,  E_FSR | SECT_4K},
+	{"N25Q1024A",	   0x20bb21, 0x0,       64 * 1024,  2048, RD_CMD_FULL, WR_CMD_FULL,  E_FSR | SECT_4K},
 #endif
 #ifdef CONFIG_SPI_FLASH_SST		/* SST */
-	{"SST25VF040B",	   0xbf258d, 0x0,	64 * 1024,     8,	    0, SECT_4K | SST_WP},
-	{"SST25VF080B",	   0xbf258e, 0x0,	64 * 1024,    16,	    0, SECT_4K | SST_WP},
-	{"SST25VF016B",	   0xbf2541, 0x0,	64 * 1024,    32,	    0, SECT_4K | SST_WP},
-	{"SST25VF032B",	   0xbf254a, 0x0,	64 * 1024,    64,	    0, SECT_4K | SST_WP},
-	{"SST25VF064C",	   0xbf254b, 0x0,	64 * 1024,   128,	    0		SECT_4K},
-	{"SST25WF512",	   0xbf2501, 0x0,	64 * 1024,     1,	    0, SECT_4K | SST_WP},
-	{"SST25WF010",	   0xbf2502, 0x0,	64 * 1024,     2,	    0, SECT_4K | SST_WP},
-	{"SST25WF020",	   0xbf2503, 0x0,	64 * 1024,     4,	    0, SECT_4K | SST_WP},
-	{"SST25WF040",	   0xbf2504, 0x0,	64 * 1024,     8,	    0, SECT_4K | SST_WP},
-	{"SST25WF080",	   0xbf2505, 0x0,	64 * 1024,    16,	    0, SECT_4K | SST_WP},
+	{"SST25VF040B",	   0xbf258d, 0x0,	64 * 1024,     8,	    0,		 0, SECT_4K | SST_WP},
+	{"SST25VF080B",	   0xbf258e, 0x0,	64 * 1024,    16,	    0,		 0, SECT_4K | SST_WP},
+	{"SST25VF016B",	   0xbf2541, 0x0,	64 * 1024,    32,	    0,		 0, SECT_4K | SST_WP},
+	{"SST25VF032B",	   0xbf254a, 0x0,	64 * 1024,    64,	    0,		 0, SECT_4K | SST_WP},
+	{"SST25VF064C",	   0xbf254b, 0x0,	64 * 1024,   128,	    0,		 0,	     SECT_4K},
+	{"SST25WF512",	   0xbf2501, 0x0,	64 * 1024,     1,	    0,		 0, SECT_4K | SST_WP},
+	{"SST25WF010",	   0xbf2502, 0x0,	64 * 1024,     2,	    0,		 0, SECT_4K | SST_WP},
+	{"SST25WF020",	   0xbf2503, 0x0,	64 * 1024,     4,	    0,		 0, SECT_4K | SST_WP},
+	{"SST25WF040",	   0xbf2504, 0x0,	64 * 1024,     8,	    0,		 0, SECT_4K | SST_WP},
+	{"SST25WF080",	   0xbf2505, 0x0,	64 * 1024,    16,	    0,		 0, SECT_4K | SST_WP},
 #endif
 #ifdef CONFIG_SPI_FLASH_WINBOND		/* WINBOND */
-	{"W25P80",	   0xef2014, 0x0,	64 * 1024,    16,	    0,		      0},
-	{"W25P16",	   0xef2015, 0x0,	64 * 1024,    32,	    0,		      0},
-	{"W25P32",	   0xef2016, 0x0,	64 * 1024,    64,	    0,		      0},
-	{"W25X40",	   0xef3013, 0x0,	 4 * 1024,   128,	    0,		SECT_4K},
-	{"W25X16",	   0xef3015, 0x0,	 4 * 1024,   512,	    0,		SECT_4K},
-	{"W25X32",	   0xef3016, 0x0,	 4 * 1024,  1024,	    0,		SECT_4K},
-	{"W25X64",	   0xef3017, 0x0,	 4 * 1024,  2048,	    0,		SECT_4K},
-	{"W25Q80BL",	   0xef4014, 0x0,	 4 * 1024,   256, RD_CMD_FULL,		SECT_4K},
-	{"W25Q16CL",	   0xef4015, 0x0,	 4 * 1024,   512, RD_CMD_FULL,		SECT_4K},
-	{"W25Q32BV",	   0xef4016, 0x0,	 4 * 1024,  1024, RD_CMD_FULL,		SECT_4K},
-	{"W25Q64CV",	   0xef4017, 0x0,	 4 * 1024,  2048, RD_CMD_FULL,		SECT_4K},
-	{"W25Q128BV",	   0xef4018, 0x0,	 4 * 1024,  4096, RD_CMD_FULL,		SECT_4K},
-	{"W25Q256",	   0xef4019, 0x0,	 4 * 1024,  8192, RD_CMD_FULL,		SECT_4K},
-	{"W25Q80BW",	   0xef5014, 0x0,	 4 * 1024,   256, RD_CMD_FULL,		SECT_4K},
-	{"W25Q16DW",	   0xef6015, 0x0,	 4 * 1024,   512, RD_CMD_FULL,		SECT_4K},
-	{"W25Q32DW",	   0xef6016, 0x0,	 4 * 1024,  1024, RD_CMD_FULL,		SECT_4K},
-	{"W25Q64DW",	   0xef6017, 0x0,	 4 * 1024,  2048, RD_CMD_FULL,		SECT_4K},
-	{"W25Q128FW",	   0xef6018, 0x0,	 4 * 1024,  4096, RD_CMD_FULL,		SECT_4K},
+	{"W25P80",	   0xef2014, 0x0,	64 * 1024,    16,	    0,		 0,		  0},
+	{"W25P16",	   0xef2015, 0x0,	64 * 1024,    32,	    0,		 0,		  0},
+	{"W25P32",	   0xef2016, 0x0,	64 * 1024,    64,	    0,		 0,		  0},
+	{"W25X40",	   0xef3013, 0x0,	 4 * 1024,   128,	    0,		 0,	    SECT_4K},
+	{"W25X16",	   0xef3015, 0x0,	 4 * 1024,   512,	    0,		 0,	    SECT_4K},
+	{"W25X32",	   0xef3016, 0x0,	 4 * 1024,  1024,	    0,		 0,	    SECT_4K},
+	{"W25X64",	   0xef3017, 0x0,	 4 * 1024,  2048,	    0,		 0,	    SECT_4K},
+	{"W25Q80BL",	   0xef4014, 0x0,	 4 * 1024,   256, RD_CMD_FULL, WR_CMD_FULL,	    SECT_4K},
+	{"W25Q16CL",	   0xef4015, 0x0,	 4 * 1024,   512, RD_CMD_FULL, WR_CMD_FULL,	    SECT_4K},
+	{"W25Q32BV",	   0xef4016, 0x0,	 4 * 1024,  1024, RD_CMD_FULL, WR_CMD_FULL,	    SECT_4K},
+	{"W25Q64CV",	   0xef4017, 0x0,	 4 * 1024,  2048, RD_CMD_FULL, WR_CMD_FULL,	    SECT_4K},
+	{"W25Q128BV",	   0xef4018, 0x0,	 4 * 1024,  4096, RD_CMD_FULL, WR_CMD_FULL,	    SECT_4K},
+	{"W25Q256",	   0xef4019, 0x0,	 4 * 1024,  8192, RD_CMD_FULL, WR_CMD_FULL,	    SECT_4K},
+	{"W25Q80BW",	   0xef5014, 0x0,	 4 * 1024,   256, RD_CMD_FULL, WR_CMD_FULL,	    SECT_4K},
+	{"W25Q16DW",	   0xef6015, 0x0,	 4 * 1024,   512, RD_CMD_FULL, WR_CMD_FULL,	    SECT_4K},
+	{"W25Q32DW",	   0xef6016, 0x0,	 4 * 1024,  1024, RD_CMD_FULL, WR_CMD_FULL,	    SECT_4K},
+	{"W25Q64DW",	   0xef6017, 0x0,	 4 * 1024,  2048, RD_CMD_FULL, WR_CMD_FULL,	    SECT_4K},
+	{"W25Q128FW",	   0xef6018, 0x0,	 4 * 1024,  4096, RD_CMD_FULL, WR_CMD_FULL,	    SECT_4K},
 #endif
 	/*
 	 * Note:
@@ -219,6 +227,16 @@ struct spi_flash *spi_flash_validate_ids(struct spi_slave *spi, u8 *idcode)
 		flash->read_cmd = flash->spi->rd_cmd;
 	}
 
+	/* Look for the fastest write cmd */
+	cmd = fls(params->wr_cmd & flash->spi->wr_cmd);
+	if (cmd) {
+		cmd = spi_write_cmds_array[cmd - 1];
+		flash->write_cmd = cmd;
+	} else {
+		/* Go for controller supported command */
+		flash->write_cmd = flash->spi->wr_cmd;
+	}
+
 	/* Compute erase sector and command */
 	if (params->flags & SECT_4K) {
 		flash->erase_cmd = CMD_ERASE_4K;
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 0ac9fab..d7bd144 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -22,6 +22,7 @@ void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
 		slave->bus = bus;
 		slave->cs = cs;
 		slave->rd_cmd = CMD_READ_ARRAY_FAST;
+		slave->wr_cmd = CMD_PAGE_PROGRAM;
 	}
 
 	return ptr;
diff --git a/include/spi.h b/include/spi.h
index 093847e..e1a5ce8 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -41,12 +41,14 @@
  *   max_write_size:	If non-zero, the maximum number of bytes which can
  *		be written at once, excluding command bytes.
  *   rd_cmd:	Read command.
+ *   wr_cmd:	Write command.
  */
 struct spi_slave {
 	unsigned int	bus;
 	unsigned int	cs;
 	unsigned int max_write_size;
 	u8 rd_cmd;
+	u8 wr_cmd;
 };
 
 /*-----------------------------------------------------------------------
diff --git a/include/spi_flash.h b/include/spi_flash.h
index e630913..4724eee 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -27,21 +27,34 @@
 #define SECT_32K		(1 << 1)
 #define E_FSR			(1 << 2)
 
+/* Write commands */
+#define CMD_PAGE_PROGRAM		0x02
+#define CMD_QUAD_PAGE_PROGRAM		0x32
+
+enum spi_write_cmds {
+	PAGE_PROGRAM = 1 << 0,
+	QUAD_PAGE_PROGRAM = 1 << 1,
+};
+
+#define WR_CMD_FULL		PAGE_PROGRAM | QUAD_PAGE_PROGRAM
+
 /* Read commands */
 #define CMD_READ_ARRAY_SLOW		0x03
 #define CMD_READ_ARRAY_FAST		0x0b
 #define CMD_READ_DUAL_OUTPUT_FAST	0x3b
 #define CMD_READ_DUAL_IO_FAST		0xbb
+#define CMD_READ_QUAD_OUTPUT_FAST	0x6b
 
 enum spi_read_cmds {
 	ARRAY_SLOW = 1 << 0,
 	ARRAY_FAST = 1 << 1,
 	DUAL_OUTPUT_FAST = 1 << 2,
 	DUAL_IO_FAST = 1 << 3,
+	QUAD_OUTPUT_FAST = 1 << 4,
 };
 
 #define RD_CMD_FULL	ARRAY_SLOW | ARRAY_FAST | DUAL_OUTPUT_FAST | \
-			DUAL_IO_FAST
+			DUAL_IO_FAST | QUAD_OUTPUT_FAST
 
 /* SST specific macros */
 #ifdef CONFIG_SPI_FLASH_SST
@@ -65,6 +78,7 @@ enum spi_read_cmds {
  * @poll_cmd:		Poll cmd - for flash erase/program
  * @erase_cmd:		Erase cmd 4K, 32K, 64K
  * @read_cmd:		Read cmd SA, FA, DOF, DIOF
+ * @write_cmd:		Write cmd PP, QPP
  * @memory_map:		Address of read-only SPI flash access
  * @read:		Flash read ops
  * @write:		Flash write ops
@@ -86,6 +100,7 @@ struct spi_flash {
 	u8 poll_cmd;
 	u8 erase_cmd;
 	u8 read_cmd;
+	u8 write_cmd;
 
 	void *memory_map;
 	int (*read)(struct spi_flash *flash, u32 offset, size_t len, void *buf);
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 33/36] sf: ops: Add configuration register writing support
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (31 preceding siblings ...)
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 32/36] sf: Add quad read/write " Jagannadha Sutradharudu Teki
@ 2013-09-24 18:20 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 34/36] sf: Set quad enable bit support Jagannadha Sutradharudu Teki
                   ` (2 subsequent siblings)
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:20 UTC (permalink / raw)
  To: u-boot

This patch provides support to program a flash config register.

Configuration register contains the control bits used to configure
the different configurations and security features of a device.

User need to set these bits through spi_flash_cmd_write_config()
based on their usage.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 drivers/mtd/spi/spi_flash_ops.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/mtd/spi/spi_flash_ops.c b/drivers/mtd/spi/spi_flash_ops.c
index 59127f8..2f87801 100644
--- a/drivers/mtd/spi/spi_flash_ops.c
+++ b/drivers/mtd/spi/spi_flash_ops.c
@@ -38,6 +38,30 @@ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr)
 	return 0;
 }
 
+static int spi_flash_cmd_write_config(struct spi_flash *flash, u8 cr)
+{
+	u8 data[2];
+	u8 cmd;
+	int ret;
+
+	cmd = CMD_READ_STATUS;
+	ret = spi_flash_read_common(flash, &cmd, 1, &data[0], 1);
+	if (ret < 0) {
+		debug("SF: fail to read status register\n");
+		return ret;
+	}
+
+	cmd = CMD_WRITE_STATUS;
+	data[1] = cr;
+	ret = spi_flash_write_common(flash, &cmd, 1, &data, 2);
+	if (ret) {
+		debug("SF: fail to write config register\n");
+		return ret;
+	}
+
+	return 0;
+}
+
 #ifdef CONFIG_SPI_FLASH_BAR
 static int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel)
 {
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 34/36] sf: Set quad enable bit support
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (32 preceding siblings ...)
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 33/36] sf: ops: Add configuration register writing support Jagannadha Sutradharudu Teki
@ 2013-09-24 18:20 ` Jagannadha Sutradharudu Teki
  2013-09-26 23:01   ` Simon Glass
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 35/36] sf: spi_flash cleanups Jagannadha Sutradharudu Teki
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 36/36] spi: spi cleanups Jagannadha Sutradharudu Teki
  35 siblings, 1 reply; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:20 UTC (permalink / raw)
  To: u-boot

This patch provides support to set the quad enable bit on flash.

quad enable bit needs to set before performing any quad IO
operations on respective SPI flashes.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 drivers/mtd/spi/spi_flash_internal.h |  5 +++++
 drivers/mtd/spi/spi_flash_ops.c      | 24 ++++++++++++++++++++++++
 drivers/mtd/spi/spi_flash_probe.c    |  9 +++++++++
 3 files changed, 38 insertions(+)

diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h
index 1f9f170..a346ae6 100644
--- a/drivers/mtd/spi/spi_flash_internal.h
+++ b/drivers/mtd/spi/spi_flash_internal.h
@@ -22,6 +22,7 @@
 #define CMD_PAGE_PROGRAM		0x02
 #define CMD_WRITE_DISABLE		0x04
 #define CMD_READ_STATUS			0x05
+#define CMD_READ_CONFIG			0x35
 #define CMD_FLAG_STATUS			0x70
 #define CMD_WRITE_ENABLE		0x06
 #define CMD_ERASE_4K			0x20
@@ -41,6 +42,7 @@
 
 /* Common status */
 #define STATUS_WIP			0x01
+#define STATUS_QEB			0x02
 #define STATUS_PEC			0x80
 
 /* Send a single-byte command to the device and read the response */
@@ -94,6 +96,9 @@ static inline int spi_flash_cmd_write_disable(struct spi_flash *flash)
 /* Program the status register. */
 int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr);
 
+/* Set quad enbale bit */
+int spi_flash_set_qeb(struct spi_flash *flash);
+
 /*
  * Same as spi_flash_cmd_read() except it also claims/releases the SPI
  * bus. Used as common part of the ->read() operation.
diff --git a/drivers/mtd/spi/spi_flash_ops.c b/drivers/mtd/spi/spi_flash_ops.c
index 2f87801..439490e 100644
--- a/drivers/mtd/spi/spi_flash_ops.c
+++ b/drivers/mtd/spi/spi_flash_ops.c
@@ -62,6 +62,30 @@ static int spi_flash_cmd_write_config(struct spi_flash *flash, u8 cr)
 	return 0;
 }
 
+int spi_flash_set_qeb(struct spi_flash *flash)
+{
+	u8 qeb_status;
+	u8 cmd;
+	int ret;
+
+	cmd = CMD_READ_CONFIG;
+	ret = spi_flash_read_common(flash, &cmd, 1, &qeb_status, 1);
+	if (ret < 0) {
+		debug("SF: fail to read config register\n");
+		return ret;
+	}
+
+	if (qeb_status & STATUS_QEB) {
+		debug("SF: Quad enable bit is already set\n");
+	} else {
+		ret = spi_flash_cmd_write_config(flash, STATUS_QEB);
+		if (ret < 0)
+			return ret;
+	}
+
+	return ret;
+}
+
 #ifdef CONFIG_SPI_FLASH_BAR
 static int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel)
 {
diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index 30ef85c..995af14 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -237,6 +237,15 @@ struct spi_flash *spi_flash_validate_ids(struct spi_slave *spi, u8 *idcode)
 		flash->write_cmd = flash->spi->wr_cmd;
 	}
 
+	/* Set the quad enable bit - only for quad commands */
+	if ((flash->read_cmd == CMD_READ_QUAD_OUTPUT_FAST) ||
+	    (flash->write_cmd == CMD_QUAD_PAGE_PROGRAM)) {
+		if (spi_flash_set_qeb(flash)) {
+			debug("SF: Fail to set quad enable bit\n");
+			return NULL;
+		}
+	}
+
 	/* Compute erase sector and command */
 	if (params->flags & SECT_4K) {
 		flash->erase_cmd = CMD_ERASE_4K;
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 35/36] sf: spi_flash cleanups
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (33 preceding siblings ...)
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 34/36] sf: Set quad enable bit support Jagannadha Sutradharudu Teki
@ 2013-09-24 18:20 ` Jagannadha Sutradharudu Teki
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 36/36] spi: spi cleanups Jagannadha Sutradharudu Teki
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:20 UTC (permalink / raw)
  To: u-boot

More cleanups on spi_flash side:
- Removed unneeded comments.
- Rearranged macros in proper location.
- Rearranged func declerations
- Renamed few function names.
- Added License headers.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 drivers/mtd/spi/Makefile             |   4 +-
 drivers/mtd/spi/spi_flash_internal.h | 131 +++++++++++++++++++++--------------
 drivers/mtd/spi/spi_flash_ops.c      |   6 +-
 drivers/mtd/spi/spi_flash_probe.c    |  14 ++--
 include/spi_flash.h                  |  34 ++-------
 5 files changed, 95 insertions(+), 94 deletions(-)

diff --git a/drivers/mtd/spi/Makefile b/drivers/mtd/spi/Makefile
index 5678134..0fa867d 100644
--- a/drivers/mtd/spi/Makefile
+++ b/drivers/mtd/spi/Makefile
@@ -17,8 +17,8 @@ endif
 ifdef CONFIG_CMD_SF
 COBJS-y        += spi_flash.o
 endif
-COBJS-$(CONFIG_SPI_FLASH)	+= spi_flash_probe.o spi_flash_ops.o
-COBJS-$(CONFIG_SPI_FRAM_RAMTRON)	+= ramtron.o
+COBJS-$(CONFIG_SPI_FLASH) += spi_flash_probe.o spi_flash_ops.o
+COBJS-$(CONFIG_SPI_FRAM_RAMTRON) += ramtron.o
 COBJS-$(CONFIG_SPI_M95XXX) += eeprom_m95xxx.o
 
 COBJS	:= $(COBJS-y)
diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h
index a346ae6..dcf54fa 100644
--- a/drivers/mtd/spi/spi_flash_internal.h
+++ b/drivers/mtd/spi/spi_flash_internal.h
@@ -2,38 +2,51 @@
  * SPI flash internal definitions
  *
  * Copyright (C) 2008 Atmel Corporation
+ * Copyright (C) 2013 Jagannadha Sutradharudu Teki, Xilinx Inc.
+ *
+ * Licensed under the GPL-2 or later.
  */
 
-/* Common parameters -- kind of high, but they should only occur when there
- * is a problem (and well your system already is broken), so err on the side
- * of caution in case we're dealing with slower SPI buses and/or processors.
- */
-#define SPI_FLASH_PROG_TIMEOUT		(2 * CONFIG_SYS_HZ)
-#define SPI_FLASH_PAGE_ERASE_TIMEOUT	(5 * CONFIG_SYS_HZ)
-#define SPI_FLASH_SECTOR_ERASE_TIMEOUT	(10 * CONFIG_SYS_HZ)
+#ifndef _SPI_FLASH_INTERNAL_H_
+#define _SPI_FLASH_INTERNAL_H_
 
-/* Common commands */
-#define CMD_READ_ID			0x9f
+/* SPI flash CFI Manufacture ID's */
+#define SPI_FLASH_CFI_MFR_SPANSION	0x01
+#define SPI_FLASH_CFI_MFR_ATMEL		0x1f
+#define SPI_FLASH_CFI_MFR_SST		0xbf
+#define SPI_FLASH_CFI_MFR_MACRONIX	0xc2
 
-#define CMD_READ_ARRAY_SLOW		0x03
-#define CMD_READ_ARRAY_FAST		0x0b
+#define SPI_FLASH_16MB_BOUN		0x1000000
+
+/* SECT flags */
+#define SECT_4K				(1 << 0)
+#define SECT_32K			(1 << 1)
+#define E_FSR				(1 << 2)
 
+/* Erase commands */
+#define CMD_ERASE_4K			0x20
+#define CMD_ERASE_32K			0x52
+#define CMD_ERASE_CHIP			0xc7
+#define CMD_ERASE_64K			0xd8
+
+/* Write commands */
 #define CMD_WRITE_STATUS		0x01
-#define CMD_PAGE_PROGRAM		0x02
 #define CMD_WRITE_DISABLE		0x04
 #define CMD_READ_STATUS			0x05
+#define CMD_WRITE_ENABLE		0x06
+#define CMD_QUAD_PAGE_PROGRAM		0x32
 #define CMD_READ_CONFIG			0x35
 #define CMD_FLAG_STATUS			0x70
-#define CMD_WRITE_ENABLE		0x06
-#define CMD_ERASE_4K			0x20
-#define CMD_ERASE_32K			0x52
-#define CMD_ERASE_64K			0xd8
-#define CMD_ERASE_CHIP			0xc7
 
-#define SPI_FLASH_16MB_BOUN		0x1000000
+/* Read commands */
+#define CMD_READ_ARRAY_SLOW		0x03
+#define CMD_READ_DUAL_OUTPUT_FAST	0x3b
+#define CMD_READ_QUAD_OUTPUT_FAST	0x6b
+#define CMD_READ_DUAL_IO_FAST		0xbb
+#define CMD_READ_ID			0x9f
 
-#ifdef CONFIG_SPI_FLASH_BAR
 /* Bank addr access commands */
+#ifdef CONFIG_SPI_FLASH_BAR
 # define CMD_BANKADDR_BRWR		0x17
 # define CMD_BANKADDR_BRRD		0x16
 # define CMD_EXTNADDR_WREAR		0xC5
@@ -45,6 +58,21 @@
 #define STATUS_QEB			0x02
 #define STATUS_PEC			0x80
 
+/* Flash timeout values */
+#define SPI_FLASH_PROG_TIMEOUT		(2 * CONFIG_SYS_HZ)
+#define SPI_FLASH_PAGE_ERASE_TIMEOUT	(5 * CONFIG_SYS_HZ)
+#define SPI_FLASH_SECTOR_ERASE_TIMEOUT	(10 * CONFIG_SYS_HZ)
+
+/* SST specific */
+#ifdef CONFIG_SPI_FLASH_SST
+# define SST_WP			0x01	/* Supports AAI word program */
+# define CMD_SST_BP		0x02    /* Byte Program */
+# define CMD_SST_AAI_WP		0xAD	/* Auto Address Incr Word Program */
+
+int sst_write_wp(struct spi_flash *flash, u32 offset, size_t len,
+		const void *buf);
+#endif
+
 /* Send a single-byte command to the device and read the response */
 int spi_flash_cmd(struct spi_slave *spi, u8 cmd, void *response, size_t len);
 
@@ -55,9 +83,6 @@ int spi_flash_cmd(struct spi_slave *spi, u8 cmd, void *response, size_t len);
 int spi_flash_cmd_read(struct spi_slave *spi, const u8 *cmd,
 		size_t cmd_len, void *data, size_t data_len);
 
-int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset,
-		size_t len, void *data);
-
 /*
  * Send a multi-byte command to the device followed by (optional)
  * data. Used for programming the flash array, etc.
@@ -65,46 +90,34 @@ int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset,
 int spi_flash_cmd_write(struct spi_slave *spi, const u8 *cmd, size_t cmd_len,
 		const void *data, size_t data_len);
 
-/*
- * Write the requested data out breaking it up into multiple write
- * commands as needed per the write size.
- */
-int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,
-		size_t len, const void *buf);
 
-#ifdef CONFIG_SPI_FLASH_SST
-int sst_write_wp(struct spi_flash *flash, u32 offset, size_t len,
-		const void *buf);
-#endif
+/* Flash erase(sectors) operation, support all possible erase commands */
+int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset, size_t len);
 
-/*
- * Enable writing on the SPI flash.
- */
+/* Program the status register */
+int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr);
+
+/* Set quad enbale bit */
+int spi_flash_set_qeb(struct spi_flash *flash);
+
+/* Enable writing on the SPI flash */
 static inline int spi_flash_cmd_write_enable(struct spi_flash *flash)
 {
 	return spi_flash_cmd(flash->spi, CMD_WRITE_ENABLE, NULL, 0);
 }
 
-/*
- * Disable writing on the SPI flash.
- */
+/* Disable writing on the SPI flash */
 static inline int spi_flash_cmd_write_disable(struct spi_flash *flash)
 {
 	return spi_flash_cmd(flash->spi, CMD_WRITE_DISABLE, NULL, 0);
 }
 
-/* Program the status register. */
-int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr);
-
-/* Set quad enbale bit */
-int spi_flash_set_qeb(struct spi_flash *flash);
-
 /*
- * Same as spi_flash_cmd_read() except it also claims/releases the SPI
- * bus. Used as common part of the ->read() operation.
+ * Send the read status command to the device and wait for the wip
+ * (write-in-progress) bit to clear itself.
  */
-int spi_flash_read_common(struct spi_flash *flash, const u8 *cmd,
-		size_t cmd_len, void *data, size_t data_len);
+int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout);
+
 /*
  * Used for spi_flash write operation
  * - SPI claim
@@ -117,10 +130,22 @@ int spi_flash_write_common(struct spi_flash *flash, const u8 *cmd,
 		size_t cmd_len, const void *buf, size_t buf_len);
 
 /*
- * Send the read status command to the device and wait for the wip
- * (write-in-progress) bit to clear itself.
+ * Flash write operation, support all possible write commands.
+ * Write the requested data out breaking it up into multiple write
+ * commands as needed per the write size.
  */
-int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout);
+int spi_flash_cmd_write_ops(struct spi_flash *flash, u32 offset,
+		size_t len, const void *buf);
+
+/*
+ * Same as spi_flash_cmd_read() except it also claims/releases the SPI
+ * bus. Used as common part of the ->read() operation.
+ */
+int spi_flash_read_common(struct spi_flash *flash, const u8 *cmd,
+		size_t cmd_len, void *data, size_t data_len);
+
+/* Flash read operation, support all possible read commands */
+int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
+		size_t len, void *data);
 
-/* Erase sectors. */
-int spi_flash_cmd_erase(struct spi_flash *flash, u32 offset, size_t len);
+#endif /* _SPI_FLASH_INTERNAL_H_ */
diff --git a/drivers/mtd/spi/spi_flash_ops.c b/drivers/mtd/spi/spi_flash_ops.c
index 439490e..fecd5b8 100644
--- a/drivers/mtd/spi/spi_flash_ops.c
+++ b/drivers/mtd/spi/spi_flash_ops.c
@@ -195,7 +195,7 @@ int spi_flash_write_common(struct spi_flash *flash, const u8 *cmd,
 	return ret;
 }
 
-int spi_flash_cmd_erase(struct spi_flash *flash, u32 offset, size_t len)
+int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset, size_t len)
 {
 	u32 erase_size;
 	u8 cmd[4];
@@ -238,7 +238,7 @@ int spi_flash_cmd_erase(struct spi_flash *flash, u32 offset, size_t len)
 	return ret;
 }
 
-int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset,
+int spi_flash_cmd_write_ops(struct spi_flash *flash, u32 offset,
 		size_t len, const void *buf)
 {
 	unsigned long byte_addr, page_size;
@@ -308,7 +308,7 @@ int spi_flash_read_common(struct spi_flash *flash, const u8 *cmd,
 	return ret;
 }
 
-int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset,
+int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
 		size_t len, void *data)
 {
 	u8 cmd[5], bank_sel = 0;
diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c
index 995af14..61e9823 100644
--- a/drivers/mtd/spi/spi_flash_probe.c
+++ b/drivers/mtd/spi/spi_flash_probe.c
@@ -31,7 +31,7 @@ static const u32 spi_write_cmds_array[] = {
 	CMD_QUAD_PAGE_PROGRAM,
 };
 
-/*
+/**
  * struct spi_flash_params - SPI/QSPI flash device params structure
  *
  * @name:		Device name ([MANUFLETTER][DEVTYPE][DENSITY][EXTRAINFO])
@@ -164,7 +164,7 @@ static const struct spi_flash_params spi_flash_params_table[] = {
 	 */
 };
 
-struct spi_flash *spi_flash_validate_ids(struct spi_slave *spi, u8 *idcode)
+struct spi_flash *spi_flash_validate_params(struct spi_slave *spi, u8 *idcode)
 {
 	const struct spi_flash_params *params;
 	struct spi_flash *flash;
@@ -204,13 +204,13 @@ struct spi_flash *spi_flash_validate_ids(struct spi_slave *spi, u8 *idcode)
 	flash->name = params->name;
 
 	/* Assign spi_flash ops */
-	flash->write = spi_flash_cmd_write_multi;
+	flash->write = spi_flash_cmd_write_ops;
 #ifdef CONFIG_SPI_FLASH_SST
 	if (params->flags & SST_WP)
 		flash->write = sst_write_wp;
 #endif
-	flash->erase = spi_flash_cmd_erase;
-	flash->read = spi_flash_cmd_read_fast;
+	flash->erase = spi_flash_cmd_erase_ops;
+	flash->read = spi_flash_cmd_read_ops;
 
 	/* Compute the flash size */
 	flash->page_size = (ext_jedec == 0x4d00) ? 512 : 256;
@@ -354,8 +354,8 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
 	print_buffer(0, idcode, 1, sizeof(idcode), 0);
 #endif
 
-	/* Validate ID's from flash dev table */
-	flash = spi_flash_validate_ids(spi, idcode);
+	/* Validate params from spi_flash_params table */
+	flash = spi_flash_validate_params(spi, idcode);
 	if (!flash)
 		goto err_read_id;
 
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 4724eee..a46a0ab 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -1,7 +1,8 @@
 /*
- * Interface to SPI flash
+ * Common SPI flash Interface
  *
  * Copyright (C) 2008 Atmel Corporation
+ * Copyright (C) 2013 Jagannadha Sutradharudu Teki, Xilinx Inc.
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -10,6 +11,7 @@
  * modify it under the terms of the GNU General Public License
  * version 2 as published by the Free Software Foundation. 
  */
+
 #ifndef _SPI_FLASH_H_
 #define _SPI_FLASH_H_
 
@@ -17,34 +19,16 @@
 #include <linux/types.h>
 #include <linux/compiler.h>
 
-/* SPI flash CFI Manufacture ID's */
-#define SPI_FLASH_CFI_MFR_ATMEL			0x1f
-#define SPI_FLASH_CFI_MFR_MACRONIX		0xc2
-#define SPI_FLASH_CFI_MFR_SST			0xbf
-
-/* SECT flags */
-#define SECT_4K			(1 << 0)
-#define SECT_32K		(1 << 1)
-#define E_FSR			(1 << 2)
-
-/* Write commands */
+/* Default read and write commands */
+#define CMD_READ_ARRAY_FAST		0x0b
 #define CMD_PAGE_PROGRAM		0x02
-#define CMD_QUAD_PAGE_PROGRAM		0x32
 
 enum spi_write_cmds {
 	PAGE_PROGRAM = 1 << 0,
 	QUAD_PAGE_PROGRAM = 1 << 1,
 };
-
 #define WR_CMD_FULL		PAGE_PROGRAM | QUAD_PAGE_PROGRAM
 
-/* Read commands */
-#define CMD_READ_ARRAY_SLOW		0x03
-#define CMD_READ_ARRAY_FAST		0x0b
-#define CMD_READ_DUAL_OUTPUT_FAST	0x3b
-#define CMD_READ_DUAL_IO_FAST		0xbb
-#define CMD_READ_QUAD_OUTPUT_FAST	0x6b
-
 enum spi_read_cmds {
 	ARRAY_SLOW = 1 << 0,
 	ARRAY_FAST = 1 << 1,
@@ -52,17 +36,9 @@ enum spi_read_cmds {
 	DUAL_IO_FAST = 1 << 3,
 	QUAD_OUTPUT_FAST = 1 << 4,
 };
-
 #define RD_CMD_FULL	ARRAY_SLOW | ARRAY_FAST | DUAL_OUTPUT_FAST | \
 			DUAL_IO_FAST | QUAD_OUTPUT_FAST
 
-/* SST specific macros */
-#ifdef CONFIG_SPI_FLASH_SST
-# define SST_WP			0x01	/* Supports AAI word program */
-# define CMD_SST_BP		0x02    /* Byte Program */
-# define CMD_SST_AAI_WP		0xAD	/* Auto Address Incr Word Program */
-#endif
-
 /**
  * struct spi_flash - SPI flash structure
  *
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 36/36] spi: spi cleanups
       [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
                   ` (34 preceding siblings ...)
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 35/36] sf: spi_flash cleanups Jagannadha Sutradharudu Teki
@ 2013-09-24 18:20 ` Jagannadha Sutradharudu Teki
  35 siblings, 0 replies; 47+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2013-09-24 18:20 UTC (permalink / raw)
  To: u-boot

- Rearranged multi-line comment style.
- Add tabs.
- Add spaces.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v4:
        - none
Changes for v3:
        - none
Changes for v2:
        - none

 include/spi.h | 99 ++++++++++++++++++++++++++++++-----------------------------
 1 file changed, 50 insertions(+), 49 deletions(-)

diff --git a/include/spi.h b/include/spi.h
index e1a5ce8..c0dca4a 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -29,29 +29,30 @@
 #define SPI_XFER_END	0x02			/* Deassert CS after transfer */
 
 /* Header byte that marks the start of the message */
-#define SPI_PREAMBLE_END_BYTE	0xec
+#define SPI_PREAMBLE_END_BYTE		0xec
 
-/*-----------------------------------------------------------------------
- * Representation of a SPI slave, i.e. what we're communicating with.
+/**
+ * struct spi_slave: Representation of a SPI slave,
+ *		      i.e. what we're communicating with.
  *
  * Drivers are expected to extend this with controller-specific data.
  *
- *   bus:	ID of the bus that the slave is attached to.
- *   cs:	ID of the chip select connected to the slave.
- *   max_write_size:	If non-zero, the maximum number of bytes which can
- *		be written at once, excluding command bytes.
- *   rd_cmd:	Read command.
- *   wr_cmd:	Write command.
+ * @bus:		ID of the bus that the slave is attached to.
+ * @cs:			ID of the chip select connected to the slave.
+ * @max_write_size:	If non-zero, the maximum number of bytes which can
+ *			be written at once, excluding command bytes.
+ * @rd_cmd:		Read command.
+ * @wr_cmd:		Write command.
  */
 struct spi_slave {
-	unsigned int	bus;
-	unsigned int	cs;
+	unsigned int bus;
+	unsigned int cs;
 	unsigned int max_write_size;
 	u8 rd_cmd;
 	u8 wr_cmd;
 };
 
-/*-----------------------------------------------------------------------
+/**
  * Initialization, must be called once on start up.
  *
  * TODO: I don't think we really need this.
@@ -64,10 +65,10 @@ void spi_init(void);
  * Allocate and zero all fields in the spi slave, and set the bus/chip
  * select. Use the helper macro spi_alloc_slave() to call this.
  *
- * @offset: Offset of struct spi_slave within slave structure
- * @size: Size of slave structure
- * @bus: Bus ID of the slave chip.
- * @cs: Chip select ID of the slave chip on the specified bus.
+ * @offset:	Offset of struct spi_slave within slave structure.
+ * @size:	Size of slave structure.
+ * @bus:	Bus ID of the slave chip.
+ * @cs:		Chip select ID of the slave chip on the specified bus.
  */
 void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
 			 unsigned int cs);
@@ -78,10 +79,10 @@ void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
  * Allocate and zero all fields in the spi slave, and set the bus/chip
  * select.
  *
- * @_struct: Name of structure to allocate (e.g. struct tegra_spi). This
- *	structure must contain a member 'struct spi_slave *slave'.
- * @bus: Bus ID of the slave chip.
- * @cs: Chip select ID of the slave chip on the specified bus.
+ * @_struct:	Name of structure to allocate (e.g. struct tegra_spi).
+ *		This structure must contain a member 'struct spi_slave *slave'.
+ * @bus:	Bus ID of the slave chip.
+ * @cs:		Chip select ID of the slave chip on the specified bus.
  */
 #define spi_alloc_slave(_struct, bus, cs) \
 	spi_do_alloc_slave(offsetof(_struct, slave), \
@@ -93,13 +94,13 @@ void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
  * Allocate and zero all fields in the spi slave, and set the bus/chip
  * select.
  *
- * @bus: Bus ID of the slave chip.
- * @cs: Chip select ID of the slave chip on the specified bus.
+ * @bus:	Bus ID of the slave chip.
+ * @cs:		Chip select ID of the slave chip on the specified bus.
  */
 #define spi_alloc_slave_base(bus, cs) \
 	spi_do_alloc_slave(0, sizeof(struct spi_slave), bus, cs)
 
-/*-----------------------------------------------------------------------
+/**
  * Set up communications parameters for a SPI slave.
  *
  * This must be called once for each slave. Note that this function
@@ -107,10 +108,10 @@ void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
  * contents of spi_slave so that the hardware can be easily
  * initialized later.
  *
- *   bus:     Bus ID of the slave chip.
- *   cs:      Chip select ID of the slave chip on the specified bus.
- *   max_hz:  Maximum SCK rate in Hz.
- *   mode:    Clock polarity, clock phase and other parameters.
+ * @bus:	Bus ID of the slave chip.
+ * @cs:		Chip select ID of the slave chip on the specified bus.
+ * @max_hz:	Maximum SCK rate in Hz.
+ * @mode:	Clock polarity, clock phase and other parameters.
  *
  * Returns: A spi_slave reference that can be used in subsequent SPI
  * calls, or NULL if one or more of the parameters are not supported.
@@ -118,14 +119,14 @@ void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
 struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 		unsigned int max_hz, unsigned int mode);
 
-/*-----------------------------------------------------------------------
+/**
  * Free any memory associated with a SPI slave.
  *
- *   slave:	The SPI slave
+ * @slave:	The SPI slave
  */
 void spi_free_slave(struct spi_slave *slave);
 
-/*-----------------------------------------------------------------------
+/**
  * Claim the bus and prepare it for communication with a given slave.
  *
  * This must be called before doing any transfers with a SPI slave. It
@@ -134,25 +135,25 @@ void spi_free_slave(struct spi_slave *slave);
  * allowed to claim the same bus for several slaves without releasing
  * the bus in between.
  *
- *   slave:	The SPI slave
+ * @slave:	The SPI slave
  *
  * Returns: 0 if the bus was claimed successfully, or a negative value
  * if it wasn't.
  */
 int spi_claim_bus(struct spi_slave *slave);
 
-/*-----------------------------------------------------------------------
+/**
  * Release the SPI bus
  *
  * This must be called once for every call to spi_claim_bus() after
  * all transfers have finished. It may disable any SPI hardware as
  * appropriate.
  *
- *   slave:	The SPI slave
+ * @slave:	The SPI slave
  */
 void spi_release_bus(struct spi_slave *slave);
 
-/*-----------------------------------------------------------------------
+/**
  * SPI transfer
  *
  * This writes "bitlen" bits out the SPI MOSI port and simultaneously clocks
@@ -165,19 +166,19 @@ void spi_release_bus(struct spi_slave *slave);
  * temporary variables, this is OK).
  *
  * spi_xfer() interface:
- *   slave:	The SPI slave which will be sending/receiving the data.
- *   bitlen:	How many bits to write and read.
- *   dout:	Pointer to a string of bits to send out.  The bits are
+ * @slave:	The SPI slave which will be sending/receiving the data.
+ * @bitlen:	How many bits to write and read.
+ * @dout:	Pointer to a string of bits to send out.  The bits are
  *		held in a byte array and are sent MSB first.
- *   din:	Pointer to a string of bits that will be filled in.
- *   flags:	A bitwise combination of SPI_XFER_* flags.
+ * @din:	Pointer to a string of bits that will be filled in.
+ * @flags:	A bitwise combination of SPI_XFER_* flags.
  *
- *   Returns: 0 on success, not 0 on failure
+ * Returns: 0 on success, not 0 on failure
  */
 int  spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
 		void *din, unsigned long flags);
 
-/*-----------------------------------------------------------------------
+/**
  * Determine if a SPI chipselect is valid.
  * This function is provided by the board if the low-level SPI driver
  * needs it to determine if a given chipselect is actually valid.
@@ -187,7 +188,7 @@ int  spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
  */
 int  spi_cs_is_valid(unsigned int bus, unsigned int cs);
 
-/*-----------------------------------------------------------------------
+/**
  * Activate a SPI chipselect.
  * This function is provided by the board code when using a driver
  * that can't control its chipselects automatically (e.g.
@@ -196,7 +197,7 @@ int  spi_cs_is_valid(unsigned int bus, unsigned int cs);
  */
 void spi_cs_activate(struct spi_slave *slave);
 
-/*-----------------------------------------------------------------------
+/**
  * Deactivate a SPI chipselect.
  * This function is provided by the board code when using a driver
  * that can't control its chipselects automatically (e.g.
@@ -205,18 +206,18 @@ void spi_cs_activate(struct spi_slave *slave);
  */
 void spi_cs_deactivate(struct spi_slave *slave);
 
-/*-----------------------------------------------------------------------
+/**
  * Set transfer speed.
  * This sets a new speed to be applied for next spi_xfer().
- *   slave:	The SPI slave
- *   hz:	The transfer speed
+ * @slave:	The SPI slave
+ * @hz:		The transfer speed
  */
 void spi_set_speed(struct spi_slave *slave, uint hz);
 
-/*-----------------------------------------------------------------------
+/**
  * Write 8 bits, then read 8 bits.
- *   slave:	The SPI slave we're communicating with
- *   byte:	Byte to be written
+ * @slave:	The SPI slave we're communicating with
+ * @byte:	Byte to be written
  *
  * Returns: The value that was read, or a negative value on error.
  *
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 31/36] sf: Add extended read commands support
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 31/36] sf: Add extended read commands support Jagannadha Sutradharudu Teki
@ 2013-09-24 20:10   ` thomas.langer at lantiq.com
  2013-09-25  9:35     ` Jagan Teki
  0 siblings, 1 reply; 47+ messages in thread
From: thomas.langer at lantiq.com @ 2013-09-24 20:10 UTC (permalink / raw)
  To: u-boot

Hello Jagan,

Am 24.09.2013 20:36, schrieb Jagannadha Sutradharudu Teki:
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index ea39d1a..0ac9fab 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -7,6 +7,7 @@
>  #include <common.h>
>  #include <malloc.h>
>  #include <spi.h>
> +#include <spi_flash.h>
>  
>  void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
>  			 unsigned int cs)
> @@ -20,6 +21,7 @@ void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
>  		slave = (struct spi_slave *)(ptr + offset);
>  		slave->bus = bus;
>  		slave->cs = cs;
> +		slave->rd_cmd = CMD_READ_ARRAY_FAST;

This is SPI code, not SF! The spi layer should not know such details of
the slave!
What about EEPROMs or other SPI slaves, which are NOT spi_flash???
Examples (just searched for includes of "spi.h"):
board/bf527-ezkit/video.c
drivers/net/enc28j60.c

Please ensure that the layers are not mixed up!
SPI is an interface type and SF is ONLY ONE user of this interface!

>  	}
>  
>  	return ptr;
> diff --git a/include/spi.h b/include/spi.h
> index c0dab57..093847e 100644
> --- a/include/spi.h
> +++ b/include/spi.h
> @@ -40,11 +40,13 @@
>   *   cs:	ID of the chip select connected to the slave.
>   *   max_write_size:	If non-zero, the maximum number of bytes which can
>   *		be written at once, excluding command bytes.
> + *   rd_cmd:	Read command.
>   */
>  struct spi_slave {
>  	unsigned int	bus;
>  	unsigned int	cs;
>  	unsigned int max_write_size;
> +	u8 rd_cmd;
>  };
>  
>  /*-----------------------------------------------------------------------

Best Regards,
Thomas

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 31/36] sf: Add extended read commands support
  2013-09-24 20:10   ` thomas.langer at lantiq.com
@ 2013-09-25  9:35     ` Jagan Teki
  2013-09-25  9:44       ` thomas.langer at lantiq.com
  0 siblings, 1 reply; 47+ messages in thread
From: Jagan Teki @ 2013-09-25  9:35 UTC (permalink / raw)
  To: u-boot

On Wed, Sep 25, 2013 at 1:40 AM,  <thomas.langer@lantiq.com> wrote:
> Hello Jagan,
>
> Am 24.09.2013 20:36, schrieb Jagannadha Sutradharudu Teki:
>> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
>> index ea39d1a..0ac9fab 100644
>> --- a/drivers/spi/spi.c
>> +++ b/drivers/spi/spi.c
>> @@ -7,6 +7,7 @@
>>  #include <common.h>
>>  #include <malloc.h>
>>  #include <spi.h>
>> +#include <spi_flash.h>
>>
>>  void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
>>                        unsigned int cs)
>> @@ -20,6 +21,7 @@ void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
>>               slave = (struct spi_slave *)(ptr + offset);
>>               slave->bus = bus;
>>               slave->cs = cs;
>> +             slave->rd_cmd = CMD_READ_ARRAY_FAST;
>
> This is SPI code, not SF! The spi layer should not know such details of
> the slave!
> What about EEPROMs or other SPI slaves, which are NOT spi_flash???
> Examples (just searched for includes of "spi.h"):
> board/bf527-ezkit/video.c
> drivers/net/enc28j60.c
>
> Please ensure that the layers are not mixed up!
> SPI is an interface type and SF is ONLY ONE user of this interface!

I understand your concern, but here the point is for discovering the
command set.
slave->rd_cmd = CMD_READ_ARRAY_FAST;
is a default controller supported fast read.

spi_flash layer will discover the respective rd_cmd based slave and flash, if
slave doesn't have any commands to list, means not support
extended/quad then these fields are filled in spi.c

there is nothing harm for respective drivers or code.
>
>>       }
>>
>>       return ptr;
>> diff --git a/include/spi.h b/include/spi.h
>> index c0dab57..093847e 100644
>> --- a/include/spi.h
>> +++ b/include/spi.h
>> @@ -40,11 +40,13 @@
>>   *   cs:     ID of the chip select connected to the slave.
>>   *   max_write_size: If non-zero, the maximum number of bytes which can
>>   *           be written at once, excluding command bytes.
>> + *   rd_cmd: Read command.
>>   */
>>  struct spi_slave {
>>       unsigned int    bus;
>>       unsigned int    cs;
>>       unsigned int max_write_size;
>> +     u8 rd_cmd;
>>  };
>>
>>  /*-----------------------------------------------------------------------
>
> Best Regards,
> Thomas
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

-- 
Thanks,
Jagan.
--------
Jagannadha Sutradharudu Teki,
E: jagannadh.teki at gmail.com, P: +91-9676773388
Engineer - System Software Hacker
U-boot - SPI Custodian and Zynq APSOC
Ln: http://www.linkedin.com/in/jaganteki

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 31/36] sf: Add extended read commands support
  2013-09-25  9:35     ` Jagan Teki
@ 2013-09-25  9:44       ` thomas.langer at lantiq.com
  2013-09-25  9:49         ` Jagan Teki
  0 siblings, 1 reply; 47+ messages in thread
From: thomas.langer at lantiq.com @ 2013-09-25  9:44 UTC (permalink / raw)
  To: u-boot

Hello Jagan,

> From: Jagan Teki [mailto:jagannadh.teki at gmail.com]
> Sent: Wednesday, September 25, 2013 11:36 AM
> To: Langer Thomas (LQDE RD ST PON SW)
> Cc: Jagannadha Sutradharudu Teki; Tom Rini; jaganna; u-boot at lists.denx.de;
> Todd Legler (tlegler); Willis Max; Syed Hussain; Sascha Silbe
> Subject: Re: [U-Boot] [PATCH v4 31/36] sf: Add extended read commands
> support
> 
> On Wed, Sep 25, 2013 at 1:40 AM,  <thomas.langer@lantiq.com> wrote:
> > Hello Jagan,
> >
> > Am 24.09.2013 20:36, schrieb Jagannadha Sutradharudu Teki:
> >> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> >> index ea39d1a..0ac9fab 100644
> >> --- a/drivers/spi/spi.c
> >> +++ b/drivers/spi/spi.c
> >> @@ -7,6 +7,7 @@
> >>  #include <common.h>
> >>  #include <malloc.h>
> >>  #include <spi.h>
> >> +#include <spi_flash.h>
> >>
> >>  void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
> >>                        unsigned int cs)
> >> @@ -20,6 +21,7 @@ void *spi_do_alloc_slave(int offset, int size,
> unsigned int bus,
> >>               slave = (struct spi_slave *)(ptr + offset);
> >>               slave->bus = bus;
> >>               slave->cs = cs;
> >> +             slave->rd_cmd = CMD_READ_ARRAY_FAST;
> >
> > This is SPI code, not SF! The spi layer should not know such details of
> > the slave!
> > What about EEPROMs or other SPI slaves, which are NOT spi_flash???
> > Examples (just searched for includes of "spi.h"):
> > board/bf527-ezkit/video.c
> > drivers/net/enc28j60.c
> >
> > Please ensure that the layers are not mixed up!
> > SPI is an interface type and SF is ONLY ONE user of this interface!
> 
> I understand your concern, but here the point is for discovering the
> command set.
> slave->rd_cmd = CMD_READ_ARRAY_FAST;
> is a default controller supported fast read.
> 
> spi_flash layer will discover the respective rd_cmd based slave and flash, if
> slave doesn't have any commands to list, means not support
> extended/quad then these fields are filled in spi.c
> 
> there is nothing harm for respective drivers or code.

But I think this is the wrong approach!
Why should the spi controller care about, what devices type is connected?
And the "CMD" is a SF specific thing!
I agree, that the controller should provide information about his "features",
but this should only be something like "tx_width=4" and "rx_width=4",
which would tell the SF layer that quad-io is possible!

No details of serial-flashes are necessary for this!

Please look up similar discussions on the linux-mtd and linux-spi mailing lists!

> --
> Thanks,
> Jagan.

Best Regards,
Thomas

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 31/36] sf: Add extended read commands support
  2013-09-25  9:44       ` thomas.langer at lantiq.com
@ 2013-09-25  9:49         ` Jagan Teki
  2013-09-25 10:04           ` thomas.langer at lantiq.com
  0 siblings, 1 reply; 47+ messages in thread
From: Jagan Teki @ 2013-09-25  9:49 UTC (permalink / raw)
  To: u-boot

On Wed, Sep 25, 2013 at 3:14 PM,  <thomas.langer@lantiq.com> wrote:
> Hello Jagan,
>
>> From: Jagan Teki [mailto:jagannadh.teki at gmail.com]
>> Sent: Wednesday, September 25, 2013 11:36 AM
>> To: Langer Thomas (LQDE RD ST PON SW)
>> Cc: Jagannadha Sutradharudu Teki; Tom Rini; jaganna; u-boot at lists.denx.de;
>> Todd Legler (tlegler); Willis Max; Syed Hussain; Sascha Silbe
>> Subject: Re: [U-Boot] [PATCH v4 31/36] sf: Add extended read commands
>> support
>>
>> On Wed, Sep 25, 2013 at 1:40 AM,  <thomas.langer@lantiq.com> wrote:
>> > Hello Jagan,
>> >
>> > Am 24.09.2013 20:36, schrieb Jagannadha Sutradharudu Teki:
>> >> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
>> >> index ea39d1a..0ac9fab 100644
>> >> --- a/drivers/spi/spi.c
>> >> +++ b/drivers/spi/spi.c
>> >> @@ -7,6 +7,7 @@
>> >>  #include <common.h>
>> >>  #include <malloc.h>
>> >>  #include <spi.h>
>> >> +#include <spi_flash.h>
>> >>
>> >>  void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
>> >>                        unsigned int cs)
>> >> @@ -20,6 +21,7 @@ void *spi_do_alloc_slave(int offset, int size,
>> unsigned int bus,
>> >>               slave = (struct spi_slave *)(ptr + offset);
>> >>               slave->bus = bus;
>> >>               slave->cs = cs;
>> >> +             slave->rd_cmd = CMD_READ_ARRAY_FAST;
>> >
>> > This is SPI code, not SF! The spi layer should not know such details of
>> > the slave!
>> > What about EEPROMs or other SPI slaves, which are NOT spi_flash???
>> > Examples (just searched for includes of "spi.h"):
>> > board/bf527-ezkit/video.c
>> > drivers/net/enc28j60.c
>> >
>> > Please ensure that the layers are not mixed up!
>> > SPI is an interface type and SF is ONLY ONE user of this interface!
>>
>> I understand your concern, but here the point is for discovering the
>> command set.
>> slave->rd_cmd = CMD_READ_ARRAY_FAST;
>> is a default controller supported fast read.
>>
>> spi_flash layer will discover the respective rd_cmd based slave and flash, if
>> slave doesn't have any commands to list, means not support
>> extended/quad then these fields are filled in spi.c
>>
>> there is nothing harm for respective drivers or code.
>
> But I think this is the wrong approach!
> Why should the spi controller care about, what devices type is connected?
> And the "CMD" is a SF specific thing!
> I agree, that the controller should provide information about his "features",
> but this should only be something like "tx_width=4" and "rx_width=4",
> which would tell the SF layer that quad-io is possible!
>
> No details of serial-flashes are necessary for this!
Yes, no issues.
I can directly assign to flash side while discovering commends.

-- 
Thanks,
Jagan.
--------
Jagannadha Sutradharudu Teki,
E: jagannadh.teki at gmail.com, P: +91-9676773388
Engineer - System Software Hacker
U-boot - SPI Custodian and Zynq APSOC
Ln: http://www.linkedin.com/in/jaganteki

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 31/36] sf: Add extended read commands support
  2013-09-25  9:49         ` Jagan Teki
@ 2013-09-25 10:04           ` thomas.langer at lantiq.com
  2013-09-25 10:34             ` Jagan Teki
  0 siblings, 1 reply; 47+ messages in thread
From: thomas.langer at lantiq.com @ 2013-09-25 10:04 UTC (permalink / raw)
  To: u-boot

Hello Jagan,

Jagan Teki wrote on?2013-09-25:
> On Wed, Sep 25, 2013 at 3:14 PM,  <thomas.langer@lantiq.com> wrote:
>> Hello Jagan,
>> 
>>> From: Jagan Teki [mailto:jagannadh.teki at gmail.com] Sent: Wednesday,
>>> September 25, 2013 11:36 AM To: Langer Thomas (LQDE RD ST PON SW) Cc:
>>> Jagannadha Sutradharudu Teki; Tom Rini; jaganna; u-
>>> boot at lists.denx.de; Todd Legler (tlegler); Willis Max; Syed Hussain;
>>> Sascha Silbe Subject: Re: [U-Boot] [PATCH v4 31/36] sf: Add extended
>>> read commands support
>>> 
>>> On Wed, Sep 25, 2013 at 1:40 AM,  <thomas.langer@lantiq.com> wrote:
>>>> Hello Jagan,
>>>> 
>>>> Am 24.09.2013 20:36, schrieb Jagannadha Sutradharudu Teki:
>>>>> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
>>>>> index ea39d1a..0ac9fab 100644
>>>>> --- a/drivers/spi/spi.c
>>>>> +++ b/drivers/spi/spi.c
>>>>> @@ -7,6 +7,7 @@
>>>>>  #include <common.h>
>>>>>  #include <malloc.h>
>>>>>  #include <spi.h>
>>>>> +#include <spi_flash.h>
>>>>> 
>>>>>  void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
>>>>>                        unsigned int cs)
>>>>> @@ -20,6 +21,7 @@ void *spi_do_alloc_slave(int offset, int size,
>>> unsigned int bus,
>>>>>               slave = (struct spi_slave *)(ptr + offset);
>>>>>               slave->bus = bus;
>>>>>               slave->cs = cs;
>>>>> +             slave->rd_cmd = CMD_READ_ARRAY_FAST;
>>>> 
>>>> This is SPI code, not SF! The spi layer should not know such details of
>>>> the slave!
>>>> What about EEPROMs or other SPI slaves, which are NOT spi_flash???
>>>> Examples (just searched for includes of "spi.h"):
>>>> board/bf527-ezkit/video.c
>>>> drivers/net/enc28j60.c
>>>> 
>>>> Please ensure that the layers are not mixed up!
>>>> SPI is an interface type and SF is ONLY ONE user of this interface!
>>> 
>>> I understand your concern, but here the point is for discovering the
>>> command set.
>>> slave->rd_cmd = CMD_READ_ARRAY_FAST;
>>> is a default controller supported fast read.
>>> 
>>> spi_flash layer will discover the respective rd_cmd based slave and
>>> flash, if slave doesn't have any commands to list, means not support
>>> extended/quad then these fields are filled in spi.c
>>> 
>>> there is nothing harm for respective drivers or code.
>> 
>> But I think this is the wrong approach!
>> Why should the spi controller care about, what devices type is connected?
>> And the "CMD" is a SF specific thing!
>> I agree, that the controller should provide information about his "features",
>> but this should only be something like "tx_width=4" and "rx_width=4",
>> which would tell the SF layer that quad-io is possible!
>> 
>> No details of serial-flashes are necessary for this!
> Yes, no issues.
> I can directly assign to flash side while discovering commends.

I don't understand this sentence. Do you mean "commands"?
Who will "discover" the commands?

The SPI controller does not know about the meaning of commands!
The controller only knows "I must send this block of data and split it on 1/2/4 lines"
(or similar for other transfers).

Maybe your specific controller behaves in another way, but this is not the standard
and you should not force this into the interface.

And another doubt: The might be different commands for dual/quad read/write,
depending on the flash manufacturer. With your solution, the controller drivers
would need these details in advance! Or at least need to be updated on each new
command, which needs to be supported.

> --
> Thanks,
> Jagan.

Best Regards,
Thomas

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 31/36] sf: Add extended read commands support
  2013-09-25 10:04           ` thomas.langer at lantiq.com
@ 2013-09-25 10:34             ` Jagan Teki
  2013-09-25 21:40               ` thomas.langer at lantiq.com
  2013-09-26 12:23               ` thomas.langer at lantiq.com
  0 siblings, 2 replies; 47+ messages in thread
From: Jagan Teki @ 2013-09-25 10:34 UTC (permalink / raw)
  To: u-boot

On Wed, Sep 25, 2013 at 3:34 PM,  <thomas.langer@lantiq.com> wrote:
> Hello Jagan,
>
> Jagan Teki wrote on 2013-09-25:
>> On Wed, Sep 25, 2013 at 3:14 PM,  <thomas.langer@lantiq.com> wrote:
>>> Hello Jagan,
>>>
>>>> From: Jagan Teki [mailto:jagannadh.teki at gmail.com] Sent: Wednesday,
>>>> September 25, 2013 11:36 AM To: Langer Thomas (LQDE RD ST PON SW) Cc:
>>>> Jagannadha Sutradharudu Teki; Tom Rini; jaganna; u-
>>>> boot at lists.denx.de; Todd Legler (tlegler); Willis Max; Syed Hussain;
>>>> Sascha Silbe Subject: Re: [U-Boot] [PATCH v4 31/36] sf: Add extended
>>>> read commands support
>>>>
>>>> On Wed, Sep 25, 2013 at 1:40 AM,  <thomas.langer@lantiq.com> wrote:
>>>>> Hello Jagan,
>>>>>
>>>>> Am 24.09.2013 20:36, schrieb Jagannadha Sutradharudu Teki:
>>>>>> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
>>>>>> index ea39d1a..0ac9fab 100644
>>>>>> --- a/drivers/spi/spi.c
>>>>>> +++ b/drivers/spi/spi.c
>>>>>> @@ -7,6 +7,7 @@
>>>>>>  #include <common.h>
>>>>>>  #include <malloc.h>
>>>>>>  #include <spi.h>
>>>>>> +#include <spi_flash.h>
>>>>>>
>>>>>>  void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
>>>>>>                        unsigned int cs)
>>>>>> @@ -20,6 +21,7 @@ void *spi_do_alloc_slave(int offset, int size,
>>>> unsigned int bus,
>>>>>>               slave = (struct spi_slave *)(ptr + offset);
>>>>>>               slave->bus = bus;
>>>>>>               slave->cs = cs;
>>>>>> +             slave->rd_cmd = CMD_READ_ARRAY_FAST;
>>>>>
>>>>> This is SPI code, not SF! The spi layer should not know such details of
>>>>> the slave!
>>>>> What about EEPROMs or other SPI slaves, which are NOT spi_flash???
>>>>> Examples (just searched for includes of "spi.h"):
>>>>> board/bf527-ezkit/video.c
>>>>> drivers/net/enc28j60.c
>>>>>
>>>>> Please ensure that the layers are not mixed up!
>>>>> SPI is an interface type and SF is ONLY ONE user of this interface!
>>>>
>>>> I understand your concern, but here the point is for discovering the
>>>> command set.
>>>> slave->rd_cmd = CMD_READ_ARRAY_FAST;
>>>> is a default controller supported fast read.
>>>>
>>>> spi_flash layer will discover the respective rd_cmd based slave and
>>>> flash, if slave doesn't have any commands to list, means not support
>>>> extended/quad then these fields are filled in spi.c
>>>>
>>>> there is nothing harm for respective drivers or code.
>>>
>>> But I think this is the wrong approach!
>>> Why should the spi controller care about, what devices type is connected?
>>> And the "CMD" is a SF specific thing!
>>> I agree, that the controller should provide information about his "features",
>>> but this should only be something like "tx_width=4" and "rx_width=4",
>>> which would tell the SF layer that quad-io is possible!
>>>
>>> No details of serial-flashes are necessary for this!
>> Yes, no issues.
>> I can directly assign to flash side while discovering commends.
>
> I don't understand this sentence. Do you mean "commands"?
> Who will "discover" the commands?
>
> The SPI controller does not know about the meaning of commands!
> The controller only knows "I must send this block of data and split it on 1/2/4 lines"
> (or similar for other transfers).

"implementation will discover the fastest command by taking the supported
commands from flash and a controller. Controller supported commands
will always been a priority."

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 31/36] sf: Add extended read commands support
  2013-09-25 10:34             ` Jagan Teki
@ 2013-09-25 21:40               ` thomas.langer at lantiq.com
  2013-09-26 12:23               ` thomas.langer at lantiq.com
  1 sibling, 0 replies; 47+ messages in thread
From: thomas.langer at lantiq.com @ 2013-09-25 21:40 UTC (permalink / raw)
  To: u-boot

Hello Jagan,

Jagan Teki wrote on 2013-09-25:
> On Wed, Sep 25, 2013 at 3:34 PM,  <thomas.langer@lantiq.com> wrote:
>> Hello Jagan,
>>
>> Jagan Teki wrote on 2013-09-25:
>>> On Wed, Sep 25, 2013 at 3:14 PM,  <thomas.langer@lantiq.com> wrote:
>>>> Hello Jagan,
>>>>
>>>>> From: Jagan Teki [mailto:jagannadh.teki at gmail.com] Sent: Wednesday,
>>>>> September 25, 2013 11:36 AM To: Langer Thomas (LQDE RD ST PON SW)
>>>>> Cc: Jagannadha Sutradharudu Teki; Tom Rini; jaganna; u-
>>>>> boot at lists.denx.de; Todd Legler (tlegler); Willis Max; Syed Hussain;
>>>>> Sascha Silbe Subject: Re: [U-Boot] [PATCH v4 31/36] sf: Add extended
>>>>> read commands support
>>>>>
>>>>> On Wed, Sep 25, 2013 at 1:40 AM,  <thomas.langer@lantiq.com> wrote:
>>>>>> Hello Jagan,
>>>>>>
>>>>>> Am 24.09.2013 20:36, schrieb Jagannadha Sutradharudu Teki:
>>>>>>> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
>>>>>>> index ea39d1a..0ac9fab 100644
>>>>>>> --- a/drivers/spi/spi.c
>>>>>>> +++ b/drivers/spi/spi.c
>>>>>>> @@ -7,6 +7,7 @@
>>>>>>>  #include <common.h>
>>>>>>>  #include <malloc.h>
>>>>>>>  #include <spi.h>
>>>>>>> +#include <spi_flash.h>
>>>>>>>
>>>>>>>  void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
>>>>>>>                        unsigned int cs)
>>>>>>> @@ -20,6 +21,7 @@ void *spi_do_alloc_slave(int offset, int size,
>>>>> unsigned int bus,
>>>>>>>               slave = (struct spi_slave *)(ptr + offset);
>>>>>>>               slave->bus = bus;
>>>>>>>               slave->cs = cs;
>>>>>>> +             slave->rd_cmd = CMD_READ_ARRAY_FAST;
>>>>>>
>>>>>> This is SPI code, not SF! The spi layer should not know such details of
>>>>>> the slave!
>>>>>> What about EEPROMs or other SPI slaves, which are NOT spi_flash???
>>>>>> Examples (just searched for includes of "spi.h"):
>>>>>> board/bf527-ezkit/video.c
>>>>>> drivers/net/enc28j60.c
>>>>>>
>>>>>> Please ensure that the layers are not mixed up!
>>>>>> SPI is an interface type and SF is ONLY ONE user of this interface!
>>>>>
>>>>> I understand your concern, but here the point is for discovering the
>>>>> command set.
>>>>> slave->rd_cmd = CMD_READ_ARRAY_FAST;
>>>>> is a default controller supported fast read.
>>>>>
>>>>> spi_flash layer will discover the respective rd_cmd based slave and
>>>>> flash, if slave doesn't have any commands to list, means not support
>>>>> extended/quad then these fields are filled in spi.c
>>>>>
>>>>> there is nothing harm for respective drivers or code.
>>>>
>>>> But I think this is the wrong approach! Why should the spi controller
>>>> care about, what devices type is connected? And the "CMD" is a SF
>>>> specific thing! I agree, that the controller should provide
>>>> information about his "features", but this should only be something
>>>> like "tx_width=4" and "rx_width=4", which would tell the SF layer
>>>> that quad-io is possible!
>>>>
>>>> No details of serial-flashes are necessary for this!
>>> Yes, no issues.
>>> I can directly assign to flash side while discovering commends.
>>
>> I don't understand this sentence. Do you mean "commands"?
>> Who will "discover" the commands?
>>
>> The SPI controller does not know about the meaning of commands! The
>> controller only knows "I must send this block of data and split it on
>> 1/2/4 lines" (or similar for other transfers).
>
> "implementation will discover the fastest command by taking the supported
> commands from flash and a controller. Controller supported commands
> will always been a priority."

>
> From SPI controller:
> ----------------------------
> spi_setup_slave() {
>         spi = spi_alloc_slave(struct zynq_spi_slave, bus, cs);
>
>         spi->slave.rd_cmd = RD_CMD_FULL;
>         spi->slave.wr_cmd = WR_CMD_FULL;
> }
These are already FLASH definitions!

Please define it the other way round:
Add properties for number of rx and tx lines to the spi-slave.
(Do you notice the different naming?)

>
>
> From SPI FLASH: (drivers/mtd/spi/spi_flash_probe.c)
> -----------------------------------------------------------------------------
>         /* Look for the fastest read cmd */
>         cmd = fls(params->rd_cmd & flash->spi->rd_cmd);
>         if (cmd) {
>                 cmd = spi_read_cmds_array[cmd - 1]; flash->read_cmd =
>                 cmd; } else { /* Go for controller supported command */
>                 flash->read_cmd = CMD_READ_ARRAY_FAST;
>         }
>
>         /* Look for the fastest write cmd */
>         cmd = fls(params->wr_cmd & flash->spi->wr_cmd);
>         if (cmd) {
>                 cmd = spi_write_cmds_array[cmd - 1]; flash->write_cmd =
>                 cmd; } else { /* Go for controller supported command */
>                 flash->write_cmd = CMD_PAGE_PROGRAM;
>         }
> include/spi_flash.h:
> ---------------------------
> /* Supported write cmds enum list */
> enum spi_write_cmds {
>         PAGE_PROGRAM = 1 << 0,
>         QUAD_PAGE_PROGRAM = 1 << 1,
> };
> #define WR_CMD_FULL             PAGE_PROGRAM | QUAD_PAGE_PROGRAM
>
> /* Supported read cmds enum list */
> enum spi_read_cmds {
>         ARRAY_SLOW = 1 << 0,
>         ARRAY_FAST = 1 << 1,
>         DUAL_OUTPUT_FAST = 1 << 2,
>         DUAL_IO_FAST = 1 << 3,
>         QUAD_OUTPUT_FAST = 1 << 4,
> };
> #define RD_CMD_FULL     ARRAY_SLOW | ARRAY_FAST |
> DUAL_OUTPUT_FAST | \
>                         DUAL_IO_FAST | QUAD_OUTPUT_FAST
>
> If the controller is not filling slave.rd_cmd and slave.wr_cmd if it's
> not supporting even if connected flash
> supports, fill the read/write commands to default ones.
>
> Controller is a master to decide which command is to use, and flash is
> slave to transfer the discovered command through spi_xfer(), so the
> controller will take care of the command processing.
>
> This is well detailed explanation, I hope you understand.

I understand, but need to repeat:
All this is flash specific and should not be part of the generic spi 
interface layer!
For spi, you have number of data lines, which is independent of the cmd
to transfer!
And what I am missing is the information about the lines to use when calling
spi_xfer(). In your implementation, the controller itself needs to know
this from decoding the opcodes.

How do you intend to handle this in the future?
Let's assume you want to add support for a new flash, which needs
a different opcode and/or has different requirements for dummy cycles.
Then you add this to the spi_flash driver and to ALL controller driver, 
which have been integrated until then?
I think, all this should be handled only in one place, which is the 
spi_flash!

If you rely on a table with flash opcodes in the controller driver, you 
have a too strong dependency!

I want to avoid this from the beginning, that's why I am so persistent 
on this topic!

Please try to do a step back and ignore the internal details of your 
zync spi controller.
Then think about the details the spi_flash should provide to the spi 
controller
for a specific transfer:
Example read for S25FL129P (no preference, just the first I found):
For QOR (Quad Output Read Mode)
- send opcode, address and dummy byte on SI / IO0 only
- receive data on IO0-IO3 in parallel

and for QIOR (Quad I/O High Performance Read Mode)
- send opcode on SI / IO0
- send address and dummy byte on IO0-IO3 in parallel
- receive data on IO0-IO3
With your approach, the controller needs to know both opcodes and the
details, when to switch from single to quad mode.

I suggest this:
- spi_xfer for cmd with SPI_XFER_BEGIN
- spi_xfer for addr and dummy with 0 or "SPI_XFER_QUAD", depending on 
opcode above
- spi_xfer for data with SPI_XFER_QUAD (and maybe SPI_XFER_END)

The same new flags (SPI_XFER_QUAD, SPI_XFER_DUAL) could be used to 
indicate the features of the spi controller.
This allows to provide every information of the transfer from spi_flash
and don't rely on additional information in the controller part.

>
>>
>> Maybe your specific controller behaves in another way, but this is not
>> the standard and you should not force this into the interface.
>>
>> And another doubt: The might be different commands for dual/quad
>> read/write, depending on the flash manufacturer. With your solution,
>> the controller drivers would need these details in advance! Or at least
>> need to be updated on each new command, which needs to be supported.
>>
> --
> Thanks,
> Jagan.

Best Regards,
Thomas

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 31/36] sf: Add extended read commands support
  2013-09-25 10:34             ` Jagan Teki
  2013-09-25 21:40               ` thomas.langer at lantiq.com
@ 2013-09-26 12:23               ` thomas.langer at lantiq.com
  1 sibling, 0 replies; 47+ messages in thread
From: thomas.langer at lantiq.com @ 2013-09-26 12:23 UTC (permalink / raw)
  To: u-boot

Hello Jagan,

it seems an almost ready patch for m25p80 driver in the kernel was posted today:
"[PATCHv2] drivers: mtd: devices: Add quad read support."
http://thread.gmane.org/gmane.linux.drivers.mtd/48552/focus=48557

Please see how there in the function "m25p80_quad_read"
the "rx_nbits" in the transfer structure is set.

Best Regards,
Thomas

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 34/36] sf: Set quad enable bit support
  2013-09-24 18:20 ` [U-Boot] [PATCH v4 34/36] sf: Set quad enable bit support Jagannadha Sutradharudu Teki
@ 2013-09-26 23:01   ` Simon Glass
  0 siblings, 0 replies; 47+ messages in thread
From: Simon Glass @ 2013-09-26 23:01 UTC (permalink / raw)
  To: u-boot

Hi Jagan,

On Tue, Sep 24, 2013 at 12:20 PM, Jagannadha Sutradharudu Teki
<jagannadha.sutradharudu-teki@xilinx.com> wrote:
> This patch provides support to set the quad enable bit on flash.
>
> quad enable bit needs to set before performing any quad IO
> operations on respective SPI flashes.
>
> Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
> ---
> Changes for v4:
>         - none
> Changes for v3:
>         - none
> Changes for v2:
>         - none
>
>  drivers/mtd/spi/spi_flash_internal.h |  5 +++++
>  drivers/mtd/spi/spi_flash_ops.c      | 24 ++++++++++++++++++++++++
>  drivers/mtd/spi/spi_flash_probe.c    |  9 +++++++++
>  3 files changed, 38 insertions(+)

This patch introduces a warning for snow, fixed on the next commit.

34: sf: ops: Add configuration register writing support
       arm: +   snow
+spi_flash_ops.c:41:12: warning: ?spi_flash_cmd_write_config? defined
but not used [-Wunused-function]

Regards,
Simon

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4 17/36] sf: Add proper comment style on spi_flash structure
  2013-09-24 18:19 ` [U-Boot] [PATCH v4 17/36] sf: Add proper comment style on spi_flash structure Jagannadha Sutradharudu Teki
@ 2013-09-26 23:10   ` Simon Glass
  0 siblings, 0 replies; 47+ messages in thread
From: Simon Glass @ 2013-09-26 23:10 UTC (permalink / raw)
  To: u-boot

Hi Jagan,

On Tue, Sep 24, 2013 at 12:19 PM, Jagannadha Sutradharudu Teki
<jagannadha.sutradharudu-teki@xilinx.com> wrote:
> Added proper comment style on spi_flash structure to make
> more readable.
>
> Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
> ---
> Changes for v4:
>         - none
> Changes for v3:
>         - none
> Changes for v2:
>         - none
>
>  include/spi_flash.h | 63 +++++++++++++++++++++++++++++------------------------
>  1 file changed, 35 insertions(+), 28 deletions(-)
>
> diff --git a/include/spi_flash.h b/include/spi_flash.h
> index 14e4ae2..34a167b 100644
> --- a/include/spi_flash.h
> +++ b/include/spi_flash.h
> @@ -37,39 +37,46 @@
>  # define CMD_SST_AAI_WP                0xAD    /* Auto Address Incr Word Program */
>  #endif
>
> +/**
> + * struct spi_flash - SPI flash structure
> + *
> + * @spi:               SPI slave
> + * @name:              Name of SPI flash
> + * @size:              Total flash size
> + * @page_size:         Write (page) size
> + * @sector_size:       Sector size
> + * @erase_size:                Erase size
> + * @bank_read_cmd:     Bank read cmd
> + * @bank_write_cmd:    Bank write cmd
> + * @bank_curr:         Current flash bank
> + * @poll_cmd:          Poll cmd - for flash erase/program
> + * @erase_cmd:         Erase cmd 4K, 32K, 64K
> + * @memory_map:                Address of read-only SPI flash access
> + * @read:              Flash read ops
> + * @write:             Flash write ops
> + * @erase:             Flash erase ops

Should probably add full documentation for these functions (arguments
and return value)

Regards,
Simon

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [U-Boot] [PATCH v4] sf: probe: Add support for S25FL* flash parts
  2013-09-24 18:19 ` [U-Boot] [PATCH v4] sf: probe: Add support for S25FL* " Jagannadha Sutradharudu Teki
@ 2013-09-26 23:16   ` Simon Glass
  0 siblings, 0 replies; 47+ messages in thread
From: Simon Glass @ 2013-09-26 23:16 UTC (permalink / raw)
  To: u-boot

Hi Jagan,

On Tue, Sep 24, 2013 at 12:19 PM, Jagannadha Sutradharudu Teki
<jagannadha.sutradharudu-teki@xilinx.com> wrote:
> Added S25FL* parts are which are avilable in spi_flash_probe_legacy.c.
>
> Updated the sector_size attributes as per the flash parts.
> Looks fine for with this sector_size for computing the size
> of flash.
>
> Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>

For some reason this patch (only) is missing the version number in the
subject, and also has a 'dump' file. Is this a bug in patman maybe?

> ---
> Changes for v4:
>         - Update the ext_jedec detection
> Changes for v3:
>         - none
> Changes for v2:
>         - Enable CONFIG_SPI_FLASH_SPANSION
>
>  drivers/mtd/spi/spi_flash_probe.c |   31 +-
>  dump                              | 1182 +++++++++++++++++++++++++++++++++++++
>  2 files changed, 1207 insertions(+), 6 deletions(-)
>  create mode 100644 dump
>

Regards,
Simon

^ permalink raw reply	[flat|nested] 47+ messages in thread

end of thread, other threads:[~2013-09-26 23:16 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1380046813-12174-1-git-send-email-jaganna@xilinx.com>
2013-09-24 18:19 ` [U-Boot] [PATCH v4 01/36] sf: Divide spi_flash into multiple parts Jagannadha Sutradharudu Teki
2013-09-24 18:19 ` [U-Boot] [PATCH v4 02/36] sf: probe: Add new spi_flash_probe support Jagannadha Sutradharudu Teki
2013-09-24 18:19 ` [U-Boot] [PATCH v4 03/36] sf: probe: Add support for M25P* flash parts Jagannadha Sutradharudu Teki
2013-09-24 18:19 ` [U-Boot] [PATCH v4 04/36] sf: probe: Add support for EN25Q* " Jagannadha Sutradharudu Teki
2013-09-24 18:19 ` [U-Boot] [PATCH v4 05/36] sf: probe: Add support for GD25* " Jagannadha Sutradharudu Teki
2013-09-24 18:19 ` [U-Boot] [PATCH v4 06/36] sf: probe: Add support for MX25L* " Jagannadha Sutradharudu Teki
2013-09-24 18:19 ` [U-Boot] [PATCH v4 07/36] sf: probe: Add support for W25* " Jagannadha Sutradharudu Teki
2013-09-24 18:19 ` [U-Boot] [PATCH v4] sf: probe: Add support for S25FL* " Jagannadha Sutradharudu Teki
2013-09-26 23:16   ` Simon Glass
2013-09-24 18:19 ` [U-Boot] [PATCH v4 09/36] sf: probe: Add support for SST25* " Jagannadha Sutradharudu Teki
2013-09-24 18:19 ` [U-Boot] [PATCH v4 10/36] sf: probe: Add support for AT45DB* " Jagannadha Sutradharudu Teki
2013-09-24 18:19 ` [U-Boot] [PATCH v4 11/36] sf: probe: Give proper spacing on flash table params Jagannadha Sutradharudu Teki
2013-09-24 18:19 ` [U-Boot] [PATCH v4 12/36] sf: probe: Add support for SST_WP Jagannadha Sutradharudu Teki
2013-09-24 18:19 ` [U-Boot] [PATCH v4 13/36] sf: probe: Add support to clear flash BP# bits Jagannadha Sutradharudu Teki
2013-09-24 18:19 ` [U-Boot] [PATCH v4 14/36] sf: probe: Add support for erase sector selection flag Jagannadha Sutradharudu Teki
2013-09-24 18:19 ` [U-Boot] [PATCH v4 15/36] sf: probe: Add support for flag status polling Jagannadha Sutradharudu Teki
2013-09-24 18:19 ` [U-Boot] [PATCH v4 16/36] sf: probe: Move BAR config to spi_flash_validate_ids Jagannadha Sutradharudu Teki
2013-09-24 18:19 ` [U-Boot] [PATCH v4 17/36] sf: Add proper comment style on spi_flash structure Jagannadha Sutradharudu Teki
2013-09-26 23:10   ` Simon Glass
2013-09-24 18:19 ` [U-Boot] [PATCH v4 18/36] sf: ramtron: Add support for separate flash driver Jagannadha Sutradharudu Teki
2013-09-24 18:19 ` [U-Boot] [PATCH v4 19/36] sf: Remove unneeded flash drivers files Jagannadha Sutradharudu Teki
2013-09-24 18:19 ` [U-Boot] [PATCH v4 20/36] sf: probe: Add support for EN25Q64 Jagannadha Sutradharudu Teki
2013-09-24 18:19 ` [U-Boot] [PATCH v4 21/36] sf: probe: Add support for S25FL256S_256K Jagannadha Sutradharudu Teki
2013-09-24 18:19 ` [U-Boot] [PATCH v4 22/36] sf: probe: Add support for S25FL512S_256K Jagannadha Sutradharudu Teki
2013-09-24 18:20 ` [U-Boot] [PATCH v4 23/36] sf: probe: Use print_size arg as page_size Jagannadha Sutradharudu Teki
2013-09-24 18:20 ` [U-Boot] [PATCH v4 24/36] sf: probe: Print erase_size while printing flash details Jagannadha Sutradharudu Teki
2013-09-24 18:20 ` [U-Boot] [PATCH v4 25/36] sf: probe: Simply the BAR configuration logic Jagannadha Sutradharudu Teki
2013-09-24 18:20 ` [U-Boot] [PATCH v4 26/36] sf: ops: Add static qualifier to spi_flash_cmd_bankaddr_write Jagannadha Sutradharudu Teki
2013-09-24 18:20 ` [U-Boot] [PATCH v4 27/36] sf: probe: Add support for MX25L25635F Jagannadha Sutradharudu Teki
2013-09-24 18:20 ` [U-Boot] [PATCH v4 28/36] sf: probe: Add support for MX25L51235F Jagannadha Sutradharudu Teki
2013-09-24 18:20 ` [U-Boot] [PATCH v4 29/36] sf: Remove spi_flash_do_alloc references Jagannadha Sutradharudu Teki
2013-09-24 18:20 ` [U-Boot] [PATCH v4 30/36] doc: SPI: Add status.txt for tracking SPI subsys status Jagannadha Sutradharudu Teki
2013-09-24 18:20 ` [U-Boot] [PATCH v4 31/36] sf: Add extended read commands support Jagannadha Sutradharudu Teki
2013-09-24 20:10   ` thomas.langer at lantiq.com
2013-09-25  9:35     ` Jagan Teki
2013-09-25  9:44       ` thomas.langer at lantiq.com
2013-09-25  9:49         ` Jagan Teki
2013-09-25 10:04           ` thomas.langer at lantiq.com
2013-09-25 10:34             ` Jagan Teki
2013-09-25 21:40               ` thomas.langer at lantiq.com
2013-09-26 12:23               ` thomas.langer at lantiq.com
2013-09-24 18:20 ` [U-Boot] [PATCH v4 32/36] sf: Add quad read/write " Jagannadha Sutradharudu Teki
2013-09-24 18:20 ` [U-Boot] [PATCH v4 33/36] sf: ops: Add configuration register writing support Jagannadha Sutradharudu Teki
2013-09-24 18:20 ` [U-Boot] [PATCH v4 34/36] sf: Set quad enable bit support Jagannadha Sutradharudu Teki
2013-09-26 23:01   ` Simon Glass
2013-09-24 18:20 ` [U-Boot] [PATCH v4 35/36] sf: spi_flash cleanups Jagannadha Sutradharudu Teki
2013-09-24 18:20 ` [U-Boot] [PATCH v4 36/36] spi: spi cleanups Jagannadha Sutradharudu Teki

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.