Skip to contentSkip to conversation

sf: Tuning spi-flash layer

PATCH Superseded Jagan Teki 3 participants 48 messages Dec 6, 2015 – Dec 11, 2015 Memory technology devices (MTD)

v8 of 10 Superseded Latest is v10 →

lore
Share & tools
lore

Jagan Teki

author
#0 lore raw

v8 cover sf: Tuning spi-flash layer

This series bypasses MTD changes from previous series[1][2] and entire series tunned spi-flash layer for better code handling.

Changes in v8:
- Rebase to master
- PATCH v8 12/14, 13/14, 14/14 added newly.

Changes in v7:
- Rebase to master
- Few patch bisectable separations

Changes in v6, v5, v4, v3, v2:
- One patch bisectable separation
- Rebase to master

Testing:

$ git clone git://git.denx.de/u-boot-spi.git
$ cd u-boot-spi
$ git checkout -b next origin/next

[1] http://permalink.gmane.org/gmane.comp.boot-loaders.u-boot/242397
[2] http://permalink.gmane.org/gmane.comp.boot-loaders.u-boot/233262

thanks!
Jagan.

Jagan Teki (14):
sf: spi_flash_validate_params => spi_flash_scan
sf: Move spi_flash_scan code to sf_ops
sf: Move read_id code to sf_ops
sf: probe: Code cleanup
sf: Use static for file-scope functions
sf: Fix Makefile
sf: Use simple name for register access functions
sf: Flash power up read-only based on idcode0
sf: Remove unneeded header includes
sf: Remove unneeded SST_BP and SST_WP
sf: ops: Fix missing break on spansion read_bar
sf: sf_probe: Remove spi_slave pointer argument
sf: Use static for file-scope functions
sf: Rename sf_ops.c to spi-flash.c

 drivers/mtd/spi/Makefile                  |   6 +-
 drivers/mtd/spi/sf_internal.h             |  38 ++-
 drivers/mtd/spi/sf_probe.c                | 373 +--------------------------
 drivers/mtd/spi/{sf_ops.c => spi-flash.c} | 406 ++++++++++++++++++++++++++++--
 4 files changed, 408 insertions(+), 415 deletions(-)
 rename drivers/mtd/spi/{sf_ops.c => spi-flash.c} (60%)
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH v8 1/14 sf: spi_flash_validate_params => spi_flash_scan

Rename spi_flash_validate_params to spi_flash_scan as this code not only deals with params setup but also configure all spi_flash attributes.

And also moved all flash related code into spi_flash_scan for future functionality addition.

---
 drivers/mtd/spi/sf_probe.c | 145 +++++++++++++++++++++++----------------------
 1 file changed, 75 insertions(+), 70 deletions(-)
drivers/mtd/spi/sf_probe.c +75 -70
index a619182..0e20088 100644
@@ -130,13 +130,42 @@ bank_end:
 }
 #endif
 
-static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
+#if CONFIG_IS_ENABLED(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 = map_sysmem(addr, size);
+
+	return 0;
+}
+#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
+
+static int spi_flash_scan(struct spi_slave *spi, u8 *idcode,
 				     struct spi_flash *flash)
 {
 	const struct spi_flash_params *params;
 	u8 cmd;
 	u16 jedec = idcode[1] << 8 | idcode[2];
 	u16 ext_jedec = idcode[3] << 8 | idcode[4];
+	int ret;
 
 	/* Validate params from spi_flash_params table */
 	params = spi_flash_params_table;
@@ -158,6 +187,13 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
 		return -EPROTONOSUPPORT;
 	}
 
+	/* Flash powers up read-only, so clear BP# bits */
+#if defined(CONFIG_SPI_FLASH_ATMEL) || \
+	defined(CONFIG_SPI_FLASH_MACRONIX) || \
+	defined(CONFIG_SPI_FLASH_SST)
+		spi_flash_cmd_write_status(flash, 0);
+#endif
+
 	/* Assign spi data */
 	flash->spi = spi;
 	flash->name = params->name;
@@ -253,6 +289,17 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
 		/* Go for default supported write cmd */
 		flash->write_cmd = CMD_PAGE_PROGRAM;
 
+	/* Set the quad enable bit - only for quad commands */
+	if ((flash->read_cmd == CMD_READ_QUAD_OUTPUT_FAST) ||
+	    (flash->read_cmd == CMD_READ_QUAD_IO_FAST) ||
+	    (flash->write_cmd == CMD_QUAD_PAGE_PROGRAM)) {
+		ret = spi_flash_set_qeb(flash, idcode[0]);
+		if (ret) {
+			debug("SF: Fail to set QEB for %02x\n", idcode[0]);
+			return -EINVAL;
+		}
+	}
+
 	/* Read dummy_byte: dummy byte is determined based on the
 	 * dummy cycles of a particular command.
 	 * Fast commands - dummy_byte = dummy_cycles/8
@@ -279,48 +326,41 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
 
 	/* Configure the BAR - discover bank cmds and read current bank */
 #ifdef CONFIG_SPI_FLASH_BAR
-	int ret = spi_flash_read_bank(flash, idcode[0]);
+	ret = spi_flash_read_bank(flash, idcode[0]);
 	if (ret < 0)
 		return ret;
 #endif
 
-	/* Flash powers up read-only, so clear BP# bits */
-#if defined(CONFIG_SPI_FLASH_ATMEL) || \
-	defined(CONFIG_SPI_FLASH_MACRONIX) || \
-	defined(CONFIG_SPI_FLASH_SST)
-		spi_flash_cmd_write_status(flash, 0);
-#endif
-
-	return 0;
-}
-
 #if CONFIG_IS_ENABLED(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;
+	ret = spi_flash_decode_fdt(gd->fdt_blob, flash);
+	if (ret) {
+		debug("SF: FDT decode error\n");
+		return -EINVAL;
 	}
+#endif
 
-	if (flash->size != size) {
-		debug("%s: Memory map must cover entire device\n", __func__);
-		return -1;
+#ifndef CONFIG_SPL_BUILD
+	printf("SF: Detected %s with page size ", flash->name);
+	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);
+	puts("\n");
+#endif
+
+#ifndef CONFIG_SPI_FLASH_BAR
+	if (((flash->dual_flash == SF_SINGLE_FLASH) &&
+	     (flash->size > SPI_FLASH_16MB_BOUN)) ||
+	     ((flash->dual_flash > SF_SINGLE_FLASH) &&
+	     (flash->size > SPI_FLASH_16MB_BOUN << 1))) {
+		puts("SF: Warning - Only lower 16MiB accessible,");
+		puts(" Full access #define CONFIG_SPI_FLASH_BAR\n");
 	}
-	flash->memory_map = map_sysmem(addr, size);
+#endif
 
-	return 0;
+	return ret;
 }
-#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
 
 /**
  * spi_flash_probe_slave() - Probe for a SPI flash device on a bus
@@ -359,47 +399,12 @@ int spi_flash_probe_slave(struct spi_slave *spi, struct spi_flash *flash)
 	print_buffer(0, idcode, 1, sizeof(idcode), 0);
 #endif
 
-	if (spi_flash_validate_params(spi, idcode, flash)) {
+	ret = spi_flash_scan(spi, idcode, flash);
+	if (ret) {
 		ret = -EINVAL;
 		goto err_read_id;
 	}
 
-	/* Set the quad enable bit - only for quad commands */
-	if ((flash->read_cmd == CMD_READ_QUAD_OUTPUT_FAST) ||
-	    (flash->read_cmd == CMD_READ_QUAD_IO_FAST) ||
-	    (flash->write_cmd == CMD_QUAD_PAGE_PROGRAM)) {
-		if (spi_flash_set_qeb(flash, idcode[0])) {
-			debug("SF: Fail to set QEB for %02x\n", idcode[0]);
-			ret = -EINVAL;
-			goto err_read_id;
-		}
-	}
-
-#if CONFIG_IS_ENABLED(OF_CONTROL)
-	if (spi_flash_decode_fdt(gd->fdt_blob, flash)) {
-		debug("SF: FDT decode error\n");
-		ret = -EINVAL;
-		goto err_read_id;
-	}
-#endif
-#ifndef CONFIG_SPL_BUILD
-	printf("SF: Detected %s with page size ", flash->name);
-	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);
-	puts("\n");
-#endif
-#ifndef CONFIG_SPI_FLASH_BAR
-	if (((flash->dual_flash == SF_SINGLE_FLASH) &&
-	     (flash->size > SPI_FLASH_16MB_BOUN)) ||
-	     ((flash->dual_flash > SF_SINGLE_FLASH) &&
-	     (flash->size > SPI_FLASH_16MB_BOUN << 1))) {
-		puts("SF: Warning - Only lower 16MiB accessible,");
-		puts(" Full access #define CONFIG_SPI_FLASH_BAR\n");
-	}
-#endif
 #ifdef CONFIG_SPI_FLASH_MTD
 	ret = spi_flash_mtd_register(flash);
 #endif
Signature · 1 line
1.9.1
#2 lore raw

PATCH v8 1/14 sf: spi_flash_validate_params => spi_flash_scan

Quoted 42 lines · Jagan Teki

Rename spi_flash_validate_params to spi_flash_scan as this code not only deals with params setup but also configure all spi_flash attributes.

And also moved all flash related code into spi_flash_scan for future functionality addition.

---
 drivers/mtd/spi/sf_probe.c | 145 +++++++++++++++++++++++----------------------
 1 file changed, 75 insertions(+), 70 deletions(-)
drivers/mtd/spi/sf_probe.c +20 -1
index a619182..0e20088 100644
@@ -130,13 +130,42 @@ bank_end:
 }
 #endif
 
-static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
+#if CONFIG_IS_ENABLED(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__);

drivers/mtd/spi/sf_probe.c bank_end: · line 162

Quoted 10 lines
drivers/mtd/spi/sf_probe.c +9 -0
+               return -1;
+       }
+       flash->memory_map = map_sysmem(addr, size);
+
+       return 0;
+}
+#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
+
+static int spi_flash_scan(struct spi_slave *spi, u8 *idcode,
                                     struct spi_flash *flash)

nits: please align above line to the left (

Quoted 156 lines
drivers/mtd/spi/sf_probe.c +46 -63
 {
        const struct spi_flash_params *params;
        u8 cmd;
        u16 jedec = idcode[1] << 8 | idcode[2];
        u16 ext_jedec = idcode[3] << 8 | idcode[4];
+       int ret;
 
        /* Validate params from spi_flash_params table */
        params = spi_flash_params_table;
@@ -158,6 +187,13 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
                return -EPROTONOSUPPORT;
        }
 
+       /* Flash powers up read-only, so clear BP# bits */
+#if defined(CONFIG_SPI_FLASH_ATMEL) || \
+       defined(CONFIG_SPI_FLASH_MACRONIX) || \
+       defined(CONFIG_SPI_FLASH_SST)
+               spi_flash_cmd_write_status(flash, 0);
+#endif
+
        /* Assign spi data */
        flash->spi = spi;
        flash->name = params->name;
@@ -253,6 +289,17 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
                /* Go for default supported write cmd */
                flash->write_cmd = CMD_PAGE_PROGRAM;
 
+       /* Set the quad enable bit - only for quad commands */
+       if ((flash->read_cmd == CMD_READ_QUAD_OUTPUT_FAST) ||
+           (flash->read_cmd == CMD_READ_QUAD_IO_FAST) ||
+           (flash->write_cmd == CMD_QUAD_PAGE_PROGRAM)) {
+               ret = spi_flash_set_qeb(flash, idcode[0]);
+               if (ret) {
+                       debug("SF: Fail to set QEB for %02x\n", idcode[0]);
+                       return -EINVAL;
+               }
+       }
+
        /* Read dummy_byte: dummy byte is determined based on the
         * dummy cycles of a particular command.
         * Fast commands - dummy_byte = dummy_cycles/8
@@ -279,48 +326,41 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
 
        /* Configure the BAR - discover bank cmds and read current bank */
 #ifdef CONFIG_SPI_FLASH_BAR
-       int ret = spi_flash_read_bank(flash, idcode[0]);
+       ret = spi_flash_read_bank(flash, idcode[0]);
        if (ret < 0)
                return ret;
 #endif
 
-       /* Flash powers up read-only, so clear BP# bits */
-#if defined(CONFIG_SPI_FLASH_ATMEL) || \
-       defined(CONFIG_SPI_FLASH_MACRONIX) || \
-       defined(CONFIG_SPI_FLASH_SST)
-               spi_flash_cmd_write_status(flash, 0);
-#endif
-
-       return 0;
-}
-
 #if CONFIG_IS_ENABLED(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;
+       ret = spi_flash_decode_fdt(gd->fdt_blob, flash);
+       if (ret) {
+               debug("SF: FDT decode error\n");
+               return -EINVAL;
        }
+#endif
 
-       if (flash->size != size) {
-               debug("%s: Memory map must cover entire device\n", __func__);
-               return -1;
+#ifndef CONFIG_SPL_BUILD
+       printf("SF: Detected %s with page size ", flash->name);
+       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);
+       puts("\n");
+#endif
+
+#ifndef CONFIG_SPI_FLASH_BAR
+       if (((flash->dual_flash == SF_SINGLE_FLASH) &&
+            (flash->size > SPI_FLASH_16MB_BOUN)) ||
+            ((flash->dual_flash > SF_SINGLE_FLASH) &&
+            (flash->size > SPI_FLASH_16MB_BOUN << 1))) {
+               puts("SF: Warning - Only lower 16MiB accessible,");
+               puts(" Full access #define CONFIG_SPI_FLASH_BAR\n");
        }
-       flash->memory_map = map_sysmem(addr, size);
+#endif
 
-       return 0;
+       return ret;
 }
-#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
 
 /**
  * spi_flash_probe_slave() - Probe for a SPI flash device on a bus
@@ -359,47 +399,12 @@ int spi_flash_probe_slave(struct spi_slave *spi, struct spi_flash *flash)
        print_buffer(0, idcode, 1, sizeof(idcode), 0);
 #endif
 
-       if (spi_flash_validate_params(spi, idcode, flash)) {
+       ret = spi_flash_scan(spi, idcode, flash);
+       if (ret) {
                ret = -EINVAL;
                goto err_read_id;
        }
 
-       /* Set the quad enable bit - only for quad commands */
-       if ((flash->read_cmd == CMD_READ_QUAD_OUTPUT_FAST) ||
-           (flash->read_cmd == CMD_READ_QUAD_IO_FAST) ||
-           (flash->write_cmd == CMD_QUAD_PAGE_PROGRAM)) {
-               if (spi_flash_set_qeb(flash, idcode[0])) {
-                       debug("SF: Fail to set QEB for %02x\n", idcode[0]);
-                       ret = -EINVAL;
-                       goto err_read_id;
-               }
-       }
-
-#if CONFIG_IS_ENABLED(OF_CONTROL)
-       if (spi_flash_decode_fdt(gd->fdt_blob, flash)) {
-               debug("SF: FDT decode error\n");
-               ret = -EINVAL;
-               goto err_read_id;
-       }
-#endif
-#ifndef CONFIG_SPL_BUILD
-       printf("SF: Detected %s with page size ", flash->name);
-       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);
-       puts("\n");
-#endif
-#ifndef CONFIG_SPI_FLASH_BAR
-       if (((flash->dual_flash == SF_SINGLE_FLASH) &&
-            (flash->size > SPI_FLASH_16MB_BOUN)) ||

drivers/mtd/spi/sf_probe.c int spi_flash_probe_slave(struct spi_slave *spi, struct spi_flash *flash)

Quoted 10 lines
drivers/mtd/spi/sf_probe.c +0 -7
-            ((flash->dual_flash > SF_SINGLE_FLASH) &&
-            (flash->size > SPI_FLASH_16MB_BOUN << 1))) {
-               puts("SF: Warning - Only lower 16MiB accessible,");
-               puts(" Full access #define CONFIG_SPI_FLASH_BAR\n");
-       }
-#endif
 #ifdef CONFIG_SPI_FLASH_MTD
        ret = spi_flash_mtd_register(flash);
 #endif
--

Other than that,

author
#3 lore raw

PATCH v8 1/14 sf: spi_flash_validate_params => spi_flash_scan

Quoted 47 lines · Bin Meng
Quoted 46 lines · Jagan Teki

Rename spi_flash_validate_params to spi_flash_scan as this code not only deals with params setup but also configure all spi_flash attributes.

And also moved all flash related code into spi_flash_scan for future functionality addition.

---
 drivers/mtd/spi/sf_probe.c | 145 +++++++++++++++++++++++----------------------
 1 file changed, 75 insertions(+), 70 deletions(-)
drivers/mtd/spi/sf_probe.c +24 -1
index a619182..0e20088 100644
@@ -130,13 +130,42 @@ bank_end:
 }
 #endif
 
-static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
+#if CONFIG_IS_ENABLED(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 = map_sysmem(addr, size);
+
Quoted 8 lines

drivers/mtd/spi/sf_probe.c bank_end: · line 162

Quoted 6 lines
drivers/mtd/spi/sf_probe.c +5 -0
+       return 0;
+}
+#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
+
+static int spi_flash_scan(struct spi_slave *spi, u8 *idcode,
                                     struct spi_flash *flash)

nits: please align above line to the left (

What is the reason, will it be an alignment issue.

static int spi_flash_scan(struct spi_slave *spi, u8 *idcode,
struct spi_flash *flash)
{

Quoted 170 lines
Quoted 157 lines
drivers/mtd/spi/sf_probe.c +46 -63
 {
        const struct spi_flash_params *params;
        u8 cmd;
        u16 jedec = idcode[1] << 8 | idcode[2];
        u16 ext_jedec = idcode[3] << 8 | idcode[4];
+       int ret;
 
        /* Validate params from spi_flash_params table */
        params = spi_flash_params_table;
@@ -158,6 +187,13 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
                return -EPROTONOSUPPORT;
        }
 
+       /* Flash powers up read-only, so clear BP# bits */
+#if defined(CONFIG_SPI_FLASH_ATMEL) || \
+       defined(CONFIG_SPI_FLASH_MACRONIX) || \
+       defined(CONFIG_SPI_FLASH_SST)
+               spi_flash_cmd_write_status(flash, 0);
+#endif
+
        /* Assign spi data */
        flash->spi = spi;
        flash->name = params->name;
@@ -253,6 +289,17 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
                /* Go for default supported write cmd */
                flash->write_cmd = CMD_PAGE_PROGRAM;
 
+       /* Set the quad enable bit - only for quad commands */
+       if ((flash->read_cmd == CMD_READ_QUAD_OUTPUT_FAST) ||
+           (flash->read_cmd == CMD_READ_QUAD_IO_FAST) ||
+           (flash->write_cmd == CMD_QUAD_PAGE_PROGRAM)) {
+               ret = spi_flash_set_qeb(flash, idcode[0]);
+               if (ret) {
+                       debug("SF: Fail to set QEB for %02x\n", idcode[0]);
+                       return -EINVAL;
+               }
+       }
+
        /* Read dummy_byte: dummy byte is determined based on the
         * dummy cycles of a particular command.
         * Fast commands - dummy_byte = dummy_cycles/8
@@ -279,48 +326,41 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
 
        /* Configure the BAR - discover bank cmds and read current bank */
 #ifdef CONFIG_SPI_FLASH_BAR
-       int ret = spi_flash_read_bank(flash, idcode[0]);
+       ret = spi_flash_read_bank(flash, idcode[0]);
        if (ret < 0)
                return ret;
 #endif
 
-       /* Flash powers up read-only, so clear BP# bits */
-#if defined(CONFIG_SPI_FLASH_ATMEL) || \
-       defined(CONFIG_SPI_FLASH_MACRONIX) || \
-       defined(CONFIG_SPI_FLASH_SST)
-               spi_flash_cmd_write_status(flash, 0);
-#endif
-
-       return 0;
-}
-
 #if CONFIG_IS_ENABLED(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;
+       ret = spi_flash_decode_fdt(gd->fdt_blob, flash);
+       if (ret) {
+               debug("SF: FDT decode error\n");
+               return -EINVAL;
        }
+#endif
 
-       if (flash->size != size) {
-               debug("%s: Memory map must cover entire device\n", __func__);
-               return -1;
+#ifndef CONFIG_SPL_BUILD
+       printf("SF: Detected %s with page size ", flash->name);
+       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);
+       puts("\n");
+#endif
+
+#ifndef CONFIG_SPI_FLASH_BAR
+       if (((flash->dual_flash == SF_SINGLE_FLASH) &&
+            (flash->size > SPI_FLASH_16MB_BOUN)) ||
+            ((flash->dual_flash > SF_SINGLE_FLASH) &&
+            (flash->size > SPI_FLASH_16MB_BOUN << 1))) {
+               puts("SF: Warning - Only lower 16MiB accessible,");
+               puts(" Full access #define CONFIG_SPI_FLASH_BAR\n");
        }
-       flash->memory_map = map_sysmem(addr, size);
+#endif
 
-       return 0;
+       return ret;
 }
-#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
 
 /**
  * spi_flash_probe_slave() - Probe for a SPI flash device on a bus
@@ -359,47 +399,12 @@ int spi_flash_probe_slave(struct spi_slave *spi, struct spi_flash *flash)
        print_buffer(0, idcode, 1, sizeof(idcode), 0);
 #endif
 
-       if (spi_flash_validate_params(spi, idcode, flash)) {
+       ret = spi_flash_scan(spi, idcode, flash);
+       if (ret) {
                ret = -EINVAL;
                goto err_read_id;
        }
 
-       /* Set the quad enable bit - only for quad commands */
-       if ((flash->read_cmd == CMD_READ_QUAD_OUTPUT_FAST) ||
-           (flash->read_cmd == CMD_READ_QUAD_IO_FAST) ||
-           (flash->write_cmd == CMD_QUAD_PAGE_PROGRAM)) {
-               if (spi_flash_set_qeb(flash, idcode[0])) {
-                       debug("SF: Fail to set QEB for %02x\n", idcode[0]);
-                       ret = -EINVAL;
-                       goto err_read_id;
-               }
-       }
-
-#if CONFIG_IS_ENABLED(OF_CONTROL)
-       if (spi_flash_decode_fdt(gd->fdt_blob, flash)) {
-               debug("SF: FDT decode error\n");
-               ret = -EINVAL;
-               goto err_read_id;
-       }
-#endif
-#ifndef CONFIG_SPL_BUILD
-       printf("SF: Detected %s with page size ", flash->name);
-       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);
-       puts("\n");
-#endif
-#ifndef CONFIG_SPI_FLASH_BAR
-       if (((flash->dual_flash == SF_SINGLE_FLASH) &&
-            (flash->size > SPI_FLASH_16MB_BOUN)) ||

drivers/mtd/spi/sf_probe.c int spi_flash_probe_slave(struct spi_slave *spi, struct spi_flash *flash)

Quoted 10 lines
drivers/mtd/spi/sf_probe.c +0 -7
-            ((flash->dual_flash > SF_SINGLE_FLASH) &&
-            (flash->size > SPI_FLASH_16MB_BOUN << 1))) {
-               puts("SF: Warning - Only lower 16MiB accessible,");
-               puts(" Full access #define CONFIG_SPI_FLASH_BAR\n");
-       }
-#endif
 #ifdef CONFIG_SPI_FLASH_MTD
        ret = spi_flash_mtd_register(flash);
 #endif
--

Other than that,

Quoted 2 lines

thanks!

Signature · 1 line
Jagan.
#4 lore raw

PATCH v8 1/14 sf: spi_flash_validate_params => spi_flash_scan

Hi Jagan,

Quoted 57 lines · Jagan Teki
Quoted 47 lines · Bin Meng
Quoted 46 lines · Jagan Teki

Rename spi_flash_validate_params to spi_flash_scan as this code not only deals with params setup but also configure all spi_flash attributes.

And also moved all flash related code into spi_flash_scan for future functionality addition.

---
 drivers/mtd/spi/sf_probe.c | 145 +++++++++++++++++++++++----------------------
 1 file changed, 75 insertions(+), 70 deletions(-)
drivers/mtd/spi/sf_probe.c +24 -1
index a619182..0e20088 100644
@@ -130,13 +130,42 @@ bank_end:
 }
 #endif
 
-static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
+#if CONFIG_IS_ENABLED(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 = map_sysmem(addr, size);
+
Quoted 8 lines

drivers/mtd/spi/sf_probe.c bank_end: · line 162

Quoted 6 lines
drivers/mtd/spi/sf_probe.c +5 -0
+       return 0;
+}
+#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
+
+static int spi_flash_scan(struct spi_slave *spi, u8 *idcode,
                                     struct spi_flash *flash)

nits: please align above line to the left (

Quoted 1 line

What is the reason, will it be an alignment issue.

checkpatch.pl will report such warnings.

[snip]

Regards,
Bin

author
#5 lore raw

PATCH v8 1/14 sf: spi_flash_validate_params => spi_flash_scan

Quoted 60 lines · Bin Meng

Hi Jagan,

Quoted 57 lines · Jagan Teki
Quoted 55 lines · Bin Meng
Quoted 42 lines · Jagan Teki

Rename spi_flash_validate_params to spi_flash_scan as this code not only deals with params setup but also configure all spi_flash attributes.

And also moved all flash related code into spi_flash_scan for future functionality addition.

---
  drivers/mtd/spi/sf_probe.c | 145 +++++++++++++++++++++++----------------------
  1 file changed, 75 insertions(+), 70 deletions(-)
drivers/mtd/spi/sf_probe.c +20 -1
index a619182..0e20088 100644
@@ -130,13 +130,42 @@ bank_end:
  }
  #endif
 
-static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
+#if CONFIG_IS_ENABLED(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__);

drivers/mtd/spi/sf_probe.c bank_end: · line 162

Quoted 10 lines
drivers/mtd/spi/sf_probe.c +9 -0
+               return -1;
+       }
+       flash->memory_map = map_sysmem(addr, size);
+
+       return 0;
+}
+#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
+
+static int spi_flash_scan(struct spi_slave *spi, u8 *idcode,
                                      struct spi_flash *flash)

nits: please align above line to the left (

Quoted 6 lines
Quoted 1 line

What is the reason, will it be an alignment issue.

checkpatch.pl will report such warnings.

[snip]

$> ./scripts/checkpatch.pl 0001-sf-spi_flash_validate_params-spi_flash_scan.patch
total: 0 errors, 0 warnings, 0 checks, 195 lines checked

NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE

0001-sf-spi_flash_validate_params-spi_flash_scan.patch has no obvious style problems and is ready for submission.

Signature · 1 line
Jagan
#6 lore raw

PATCH v8 1/14 sf: spi_flash_validate_params => spi_flash_scan

Hi Jagan,

Quoted 83 lines · Jagan Teki
Quoted 70 lines · Bin Meng

Hi Jagan,

Quoted 66 lines · Jagan Teki
Quoted 62 lines · Bin Meng
Quoted 47 lines · Jagan Teki

Rename spi_flash_validate_params to spi_flash_scan as this code not only deals with params setup but also configure all spi_flash attributes.

And also moved all flash related code into spi_flash_scan for future functionality addition.

---
  drivers/mtd/spi/sf_probe.c | 145
+++++++++++++++++++++++----------------------
  1 file changed, 75 insertions(+), 70 deletions(-)
drivers/mtd/spi/sf_probe.c +20 -1
index a619182..0e20088 100644
@@ -130,13 +130,42 @@ bank_end:
  }
  #endif
 
-static int spi_flash_validate_params(struct spi_slave *spi, u8
 *idcode,
+#if CONFIG_IS_ENABLED(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__);

drivers/mtd/spi/sf_probe.c bank_end: · line 165

Quoted 10 lines
drivers/mtd/spi/sf_probe.c +9 -0
+               return -1;
+       }
+       flash->memory_map = map_sysmem(addr, size);
+
+       return 0;
+}
+#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
+
+static int spi_flash_scan(struct spi_slave *spi, u8 *idcode,
                                      struct spi_flash *flash)

nits: please align above line to the left (

Quoted 7 lines
Quoted 1 line

What is the reason, will it be an alignment issue.

checkpatch.pl will report such warnings.

[snip]

$> ./scripts/checkpatch.pl 0001-sf-spi_flash_validate_params-spi_flash_scan.patch
total: 0 errors, 0 warnings, 0 checks, 195 lines checked

Quoted 7 lines

NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE

0001-sf-spi_flash_validate_params-spi_flash_scan.patch has no obvious style problems and is ready for submission.

This is because your patch did not touch the second line. checkpatch.pl only reports issues with modified lines.

The alignment was correct before, because the function name is spi_flash_validate_params(). Now you have renamed it to spi_flash_scan(), the alignment is wrong.

Regards,
Bin

author
#7 lore raw

PATCH v8 2/14 sf: Move spi_flash_scan code to sf_ops

In reply to Jagan Teki

Intension is that sf_ops should deals all spi_flash related stuff and sf_probe (which should renamed future) should be an interface layer for spi_flash versus spi drivers.

sf_ops => spi_flash interface
sf_probe => interface layer vs spi_flash(sf_probe) to spi drivers

---
 drivers/mtd/spi/sf_internal.h |  14 ++
 drivers/mtd/spi/sf_ops.c      | 343 ++++++++++++++++++++++++++++++++++++++++++
 drivers/mtd/spi/sf_probe.c    | 342 -----------------------------------------
 3 files changed, 357 insertions(+), 342 deletions(-)
drivers/mtd/spi/sf_internal.h +14 -0
index 85c8a89..f3eb6f3 100644
@@ -245,4 +245,18 @@ int spi_flash_mtd_register(struct spi_flash *flash);
 void spi_flash_mtd_unregister(void);
 #endif
 
+/**
+ * spi_flash_scan - scan the SPI FLASH
+ * @spi:	the spi slave structure
+ * @idcode:	idcode of spi flash
+ * @flash:	the spi flash structure
+ *
+ * The drivers can use this fuction to scan the SPI FLASH.
+ * In the scanning, it will try to get all the necessary information to
+ * fill the spi_flash{}.
+ *
+ * Return: 0 for success, others for failure.
+ */
+int spi_flash_scan(struct spi_slave *spi, u8 *idcode, struct spi_flash *flash);
+
 #endif /* _SF_INTERNAL_H_ */
drivers/mtd/spi/sf_ops.c +343 -0

358 lines not on this page · raw message

drivers/mtd/spi/sf_probe.c +0 -342

348 lines not on this page · raw message

Signature · 1 line
1.9.1
#8 lore raw

PATCH v8 2/14 sf: Move spi_flash_scan code to sf_ops

Quoted 7 lines · Jagan Teki

Intension is that sf_ops should deals all spi_flash related stuff and sf_probe (which should renamed future) should be an interface layer for spi_flash versus spi drivers.

sf_ops => spi_flash interface
sf_probe => interface layer vs spi_flash(sf_probe) to spi drivers

Quoted 8 lines
---
 drivers/mtd/spi/sf_internal.h |  14 ++
 drivers/mtd/spi/sf_ops.c      | 343 ++++++++++++++++++++++++++++++++++++++++++
 drivers/mtd/spi/sf_probe.c    | 342 -----------------------------------------
 3 files changed, 357 insertions(+), 342 deletions(-)
author
#9 lore raw

PATCH v8 3/14 sf: Move read_id code to sf_ops

In reply to Jagan Teki

read_id code is related to spi_flash stuff
hence moved to sf_ops.

---
 drivers/mtd/spi/sf_internal.h |  3 +--
 drivers/mtd/spi/sf_ops.c      | 21 ++++++++++++++++++---
 drivers/mtd/spi/sf_probe.c    | 15 +--------------
 3 files changed, 20 insertions(+), 19 deletions(-)
drivers/mtd/spi/sf_internal.h +1 -2
index f3eb6f3..670429f 100644
@@ -248,7 +248,6 @@ void spi_flash_mtd_unregister(void);
 /**
  * spi_flash_scan - scan the SPI FLASH
  * @spi:	the spi slave structure
- * @idcode:	idcode of spi flash
  * @flash:	the spi flash structure
  *
  * The drivers can use this fuction to scan the SPI FLASH.
@@ -257,6 +256,6 @@ void spi_flash_mtd_unregister(void);
  *
  * Return: 0 for success, others for failure.
  */
-int spi_flash_scan(struct spi_slave *spi, u8 *idcode, struct spi_flash *flash);
+int spi_flash_scan(struct spi_slave *spi, struct spi_flash *flash);
 
 #endif /* _SF_INTERNAL_H_ */
drivers/mtd/spi/sf_ops.c +18 -3
index 306db8f..54c6468 100644
@@ -898,14 +898,29 @@ int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash)
 }
 #endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
 
-int spi_flash_scan(struct spi_slave *spi, u8 *idcode, struct spi_flash *flash)
+int spi_flash_scan(struct spi_slave *spi, struct spi_flash *flash)
 {
 	const struct spi_flash_params *params;
+	u16 jedec, ext_jedec;
+	u8 idcode[5];
 	u8 cmd;
-	u16 jedec = idcode[1] << 8 | idcode[2];
-	u16 ext_jedec = idcode[3] << 8 | idcode[4];
 	int ret;
 
+	/* Read the ID codes */
+	ret = spi_flash_cmd(spi, CMD_READ_ID, idcode, sizeof(idcode));
+	if (ret) {
+		printf("SF: Failed to get idcodes\n");
+		return -EINVAL;
+	}
+
+#ifdef DEBUG
+	printf("SF: Got idcodes\n");
+	print_buffer(0, idcode, 1, sizeof(idcode), 0);
+#endif
+
+	jedec = idcode[1] << 8 | idcode[2];
+	ext_jedec = idcode[3] << 8 | idcode[4];
+
 	/* Validate params from spi_flash_params table */
 	params = spi_flash_params_table;
 	for (; params->name != NULL; params++) {
drivers/mtd/spi/sf_probe.c +1 -14
index 994559d..e35b917 100644
@@ -29,7 +29,6 @@
  */
 int spi_flash_probe_slave(struct spi_slave *spi, struct spi_flash *flash)
 {
-	u8 idcode[5];
 	int ret;
 
 	/* Setup spi_slave */
@@ -45,19 +44,7 @@ int spi_flash_probe_slave(struct spi_slave *spi, struct spi_flash *flash)
 		return ret;
 	}
 
-	/* Read the ID codes */
-	ret = spi_flash_cmd(spi, CMD_READ_ID, idcode, sizeof(idcode));
-	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
-
-	ret = spi_flash_scan(spi, idcode, flash);
+	ret = spi_flash_scan(spi, flash);
 	if (ret) {
 		ret = -EINVAL;
 		goto err_read_id;
Signature · 1 line
1.9.1
#10 lore raw

PATCH v8 3/14 sf: Move read_id code to sf_ops

Quoted 11 lines · Jagan Teki

read_id code is related to spi_flash stuff
hence moved to sf_ops.

---
 drivers/mtd/spi/sf_internal.h |  3 +--
 drivers/mtd/spi/sf_ops.c      | 21 ++++++++++++++++++---
 drivers/mtd/spi/sf_probe.c    | 15 +--------------
 3 files changed, 20 insertions(+), 19 deletions(-)
author
#11 lore raw

PATCH v8 4/14 sf: probe: Code cleanup

In reply to Jagan Teki

- Move bar read code below the bar write hance both at once place, hence it easy for #ifdef macro only once and readable.
- Move read_cmd_array at top

---
 drivers/mtd/spi/sf_ops.c | 80 +++++++++++++++++++++++-------------------------
 1 file changed, 39 insertions(+), 41 deletions(-)
drivers/mtd/spi/sf_ops.c +39 -41
index 54c6468..8d6040e 100644
@@ -30,6 +30,16 @@ static void spi_flash_addr(u32 addr, u8 *cmd)
 	cmd[3] = addr >> 0;
 }
 
+/* Read commands array */
+static u8 spi_read_cmds_array[] = {
+	CMD_READ_ARRAY_SLOW,
+	CMD_READ_ARRAY_FAST,
+	CMD_READ_DUAL_OUTPUT_FAST,
+	CMD_READ_DUAL_IO_FAST,
+	CMD_READ_QUAD_OUTPUT_FAST,
+	CMD_READ_QUAD_IO_FAST,
+};
+
 int spi_flash_cmd_read_status(struct spi_flash *flash, u8 *rs)
 {
 	int ret;
@@ -133,6 +143,35 @@ bar_end:
 	flash->bank_curr = bank_sel;
 	return flash->bank_curr;
 }
+
+static int spi_flash_read_bank(struct spi_flash *flash, u8 idcode0)
+{
+	u8 curr_bank = 0;
+	int ret;
+
+	if (flash->size <= SPI_FLASH_16MB_BOUN)
+		goto bank_end;
+
+	switch (idcode0) {
+	case SPI_FLASH_CFI_MFR_SPANSION:
+		flash->bank_read_cmd = CMD_BANKADDR_BRRD;
+		flash->bank_write_cmd = CMD_BANKADDR_BRWR;
+	default:
+		flash->bank_read_cmd = CMD_EXTNADDR_RDEAR;
+		flash->bank_write_cmd = CMD_EXTNADDR_WREAR;
+	}
+
+	ret = spi_flash_read_common(flash, &flash->bank_read_cmd, 1,
+				    &curr_bank, 1);
+	if (ret) {
+		debug("SF: fail to read bank addr register\n");
+		return ret;
+	}
+
+bank_end:
+	flash->bank_curr = curr_bank;
+	return 0;
+}
 #endif
 
 #ifdef CONFIG_SF_DUAL_FLASH
@@ -762,16 +801,6 @@ int stm_unlock(struct spi_flash *flash, u32 ofs, size_t len)
 #endif
 
 
-/* Read commands array */
-static u8 spi_read_cmds_array[] = {
-	CMD_READ_ARRAY_SLOW,
-	CMD_READ_ARRAY_FAST,
-	CMD_READ_DUAL_OUTPUT_FAST,
-	CMD_READ_DUAL_IO_FAST,
-	CMD_READ_QUAD_OUTPUT_FAST,
-	CMD_READ_QUAD_IO_FAST,
-};
-
 #ifdef CONFIG_SPI_FLASH_MACRONIX
 static int spi_flash_set_qeb_mxic(struct spi_flash *flash)
 {
@@ -839,37 +868,6 @@ static int spi_flash_set_qeb(struct spi_flash *flash, u8 idcode0)
 	}
 }
 
-#ifdef CONFIG_SPI_FLASH_BAR
-static int spi_flash_read_bank(struct spi_flash *flash, u8 idcode0)
-{
-	u8 curr_bank = 0;
-	int ret;
-
-	if (flash->size <= SPI_FLASH_16MB_BOUN)
-		goto bank_end;
-
-	switch (idcode0) {
-	case SPI_FLASH_CFI_MFR_SPANSION:
-		flash->bank_read_cmd = CMD_BANKADDR_BRRD;
-		flash->bank_write_cmd = CMD_BANKADDR_BRWR;
-	default:
-		flash->bank_read_cmd = CMD_EXTNADDR_RDEAR;
-		flash->bank_write_cmd = CMD_EXTNADDR_WREAR;
-	}
-
-	ret = spi_flash_read_common(flash, &flash->bank_read_cmd, 1,
-				    &curr_bank, 1);
-	if (ret) {
-		debug("SF: fail to read bank addr register\n");
-		return ret;
-	}
-
-bank_end:
-	flash->bank_curr = curr_bank;
-	return 0;
-}
-#endif
-
 #if CONFIG_IS_ENABLED(OF_CONTROL)
 int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash)
 {
Signature · 1 line
1.9.1
#12 lore raw

PATCH v8 4/14 sf: probe: Code cleanup

Quoted 11 lines · Jagan Teki

- Move bar read code below the bar write hance both at once place, hence it easy for #ifdef macro only once and readable.
- Move read_cmd_array at top

---
 drivers/mtd/spi/sf_ops.c | 80 +++++++++++++++++++++++-------------------------
 1 file changed, 39 insertions(+), 41 deletions(-)
author
#13 lore raw

PATCH v8 5/14 sf: Use static for file-scope functions

In reply to Jagan Teki

Use static for file-scope functions and removed
them from header files.

---
 drivers/mtd/spi/sf_internal.h | 18 ------------------
 drivers/mtd/spi/sf_ops.c      | 11 ++++++-----
 2 files changed, 6 insertions(+), 23 deletions(-)
drivers/mtd/spi/sf_internal.h +0 -18
index 670429f..8f586ee 100644
@@ -171,12 +171,6 @@ int spi_flash_cmd_write(struct spi_slave *spi, const u8 *cmd, size_t cmd_len,
 /* Flash erase(sectors) operation, support all possible erase commands */
 int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset, size_t len);
 
-/* Read the status register */
-int spi_flash_cmd_read_status(struct spi_flash *flash, u8 *rs);
-
-/* Program the status register */
-int spi_flash_cmd_write_status(struct spi_flash *flash, u8 ws);
-
 /* Lock stmicro spi flash region */
 int stm_lock(struct spi_flash *flash, u32 ofs, size_t len);
 
@@ -186,12 +180,6 @@ int stm_unlock(struct spi_flash *flash, u32 ofs, size_t len);
 /* Check if a stmicro spi flash region is completely locked */
 int stm_is_locked(struct spi_flash *flash, u32 ofs, size_t len);
 
-/* Read the config register */
-int spi_flash_cmd_read_config(struct spi_flash *flash, u8 *rc);
-
-/* Program the config register */
-int spi_flash_cmd_write_config(struct spi_flash *flash, u8 wc);
-
 /* Enable writing on the SPI flash */
 static inline int spi_flash_cmd_write_enable(struct spi_flash *flash)
 {
@@ -205,12 +193,6 @@ static inline int spi_flash_cmd_write_disable(struct spi_flash *flash)
 }
 
 /*
- * Send the read status command to the device and wait for the wip
- * (write-in-progress) bit to clear itself.
- */
-int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout);
-
-/*
  * Used for spi_flash write operation
  * - SPI claim
  * - spi_flash_cmd_write_enable
drivers/mtd/spi/sf_ops.c +6 -5
index 8d6040e..23a6adb 100644
@@ -40,7 +40,7 @@ static u8 spi_read_cmds_array[] = {
 	CMD_READ_QUAD_IO_FAST,
 };
 
-int spi_flash_cmd_read_status(struct spi_flash *flash, u8 *rs)
+static int spi_flash_cmd_read_status(struct spi_flash *flash, u8 *rs)
 {
 	int ret;
 	u8 cmd;
@@ -69,7 +69,7 @@ static int read_fsr(struct spi_flash *flash, u8 *fsr)
 	return 0;
 }
 
-int spi_flash_cmd_write_status(struct spi_flash *flash, u8 ws)
+static int spi_flash_cmd_write_status(struct spi_flash *flash, u8 ws)
 {
 	u8 cmd;
 	int ret;
@@ -85,7 +85,7 @@ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 ws)
 }
 
 #if defined(CONFIG_SPI_FLASH_SPANSION) || defined(CONFIG_SPI_FLASH_WINBOND)
-int spi_flash_cmd_read_config(struct spi_flash *flash, u8 *rc)
+static int spi_flash_cmd_read_config(struct spi_flash *flash, u8 *rc)
 {
 	int ret;
 	u8 cmd;
@@ -100,7 +100,7 @@ int spi_flash_cmd_read_config(struct spi_flash *flash, u8 *rc)
 	return 0;
 }
 
-int spi_flash_cmd_write_config(struct spi_flash *flash, u8 wc)
+static int spi_flash_cmd_write_config(struct spi_flash *flash, u8 wc)
 {
 	u8 data[2];
 	u8 cmd;
@@ -238,7 +238,8 @@ static int spi_flash_ready(struct spi_flash *flash)
 	return sr && fsr;
 }
 
-int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout)
+static int spi_flash_cmd_wait_ready(struct spi_flash *flash,
+					unsigned long timeout)
 {
 	int timebase, ret;
 
Signature · 1 line
1.9.1
#14 lore raw

PATCH v8 5/14 sf: Use static for file-scope functions

Quoted 9 lines · Jagan Teki

Use static for file-scope functions and removed
them from header files.

---
 drivers/mtd/spi/sf_internal.h | 18 ------------------
 drivers/mtd/spi/sf_ops.c      | 11 ++++++-----
 2 files changed, 6 insertions(+), 23 deletions(-)
author
#15 lore raw

PATCH v8 6/14 sf: Fix Makefile

In reply to Jagan Teki

This patch removes unneeded ifdef and fixed accordingly.

---
 drivers/mtd/spi/Makefile | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/mtd/spi/Makefile +1 -5
index cf4e7e1..a24f761 100644
@@ -12,11 +12,7 @@ obj-$(CONFIG_SPL_SPI_LOAD)	+= spi_spl_load.o
 obj-$(CONFIG_SPL_SPI_BOOT)	+= fsl_espi_spl.o
 endif
 
-#ifndef CONFIG_DM_SPI
-obj-$(CONFIG_SPI_FLASH) += sf_probe.o
-#endif
-obj-$(CONFIG_CMD_SF) += sf.o
-obj-$(CONFIG_SPI_FLASH) += sf_ops.o sf_params.o
+obj-$(CONFIG_SPI_FLASH) += sf_probe.o sf_ops.o sf_params.o sf.o
 obj-$(CONFIG_SPI_FLASH_DATAFLASH) += sf_dataflash.o
 obj-$(CONFIG_SPI_FLASH_MTD) += sf_mtd.o
 obj-$(CONFIG_SPI_FLASH_SANDBOX) += sandbox.o
Signature · 1 line
1.9.1
author
#16 lore raw

PATCH v8 7/14 sf: Use simple name for register access functions

In reply to Jagan Teki

Most of the register access function are static,
so used simple name to represent each.

---
 drivers/mtd/spi/sf_ops.c | 52 ++++++++++++++++++++++++------------------------
 1 file changed, 26 insertions(+), 26 deletions(-)
drivers/mtd/spi/sf_ops.c +26 -26
index 23a6adb..853759e 100644
@@ -40,7 +40,7 @@ static u8 spi_read_cmds_array[] = {
 	CMD_READ_QUAD_IO_FAST,
 };
 
-static int spi_flash_cmd_read_status(struct spi_flash *flash, u8 *rs)
+static int read_sr(struct spi_flash *flash, u8 *rs)
 {
 	int ret;
 	u8 cmd;
@@ -69,7 +69,7 @@ static int read_fsr(struct spi_flash *flash, u8 *fsr)
 	return 0;
 }
 
-static int spi_flash_cmd_write_status(struct spi_flash *flash, u8 ws)
+static int write_sr(struct spi_flash *flash, u8 ws)
 {
 	u8 cmd;
 	int ret;
@@ -85,7 +85,7 @@ static int spi_flash_cmd_write_status(struct spi_flash *flash, u8 ws)
 }
 
 #if defined(CONFIG_SPI_FLASH_SPANSION) || defined(CONFIG_SPI_FLASH_WINBOND)
-static int spi_flash_cmd_read_config(struct spi_flash *flash, u8 *rc)
+static int read_cr(struct spi_flash *flash, u8 *rc)
 {
 	int ret;
 	u8 cmd;
@@ -100,13 +100,13 @@ static int spi_flash_cmd_read_config(struct spi_flash *flash, u8 *rc)
 	return 0;
 }
 
-static int spi_flash_cmd_write_config(struct spi_flash *flash, u8 wc)
+static int write_cr(struct spi_flash *flash, u8 wc)
 {
 	u8 data[2];
 	u8 cmd;
 	int ret;
 
-	ret = spi_flash_cmd_read_status(flash, &data[0]);
+	ret = read_sr(flash, &data[0]);
 	if (ret < 0)
 		return ret;
 
@@ -123,7 +123,7 @@ static int spi_flash_cmd_write_config(struct spi_flash *flash, u8 wc)
 #endif
 
 #ifdef CONFIG_SPI_FLASH_BAR
-static int spi_flash_write_bank(struct spi_flash *flash, u32 offset)
+static int spi_flash_write_bar(struct spi_flash *flash, u32 offset)
 {
 	u8 cmd, bank_sel;
 	int ret;
@@ -144,7 +144,7 @@ bar_end:
 	return flash->bank_curr;
 }
 
-static int spi_flash_read_bank(struct spi_flash *flash, u8 idcode0)
+static int spi_flash_read_bar(struct spi_flash *flash, u8 idcode0)
 {
 	u8 curr_bank = 0;
 	int ret;
@@ -175,7 +175,7 @@ bank_end:
 #endif
 
 #ifdef CONFIG_SF_DUAL_FLASH
-static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr)
+static void spi_flash_dual(struct spi_flash *flash, u32 *addr)
 {
 	switch (flash->dual_flash) {
 	case SF_DUAL_STACKED_FLASH:
@@ -201,7 +201,7 @@ static int spi_flash_sr_ready(struct spi_flash *flash)
 	u8 sr;
 	int ret;
 
-	ret = spi_flash_cmd_read_status(flash, &sr);
+	ret = read_sr(flash, &sr);
 	if (ret < 0)
 		return ret;
 
@@ -325,10 +325,10 @@ int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset, size_t len)
 
 #ifdef CONFIG_SF_DUAL_FLASH
 		if (flash->dual_flash > SF_SINGLE_FLASH)
-			spi_flash_dual_flash(flash, &erase_addr);
+			spi_flash_dual(flash, &erase_addr);
 #endif
 #ifdef CONFIG_SPI_FLASH_BAR
-		ret = spi_flash_write_bank(flash, erase_addr);
+		ret = spi_flash_write_bar(flash, erase_addr);
 		if (ret < 0)
 			return ret;
 #endif
@@ -375,10 +375,10 @@ int spi_flash_cmd_write_ops(struct spi_flash *flash, u32 offset,
 
 #ifdef CONFIG_SF_DUAL_FLASH
 		if (flash->dual_flash > SF_SINGLE_FLASH)
-			spi_flash_dual_flash(flash, &write_addr);
+			spi_flash_dual(flash, &write_addr);
 #endif
 #ifdef CONFIG_SPI_FLASH_BAR
-		ret = spi_flash_write_bank(flash, write_addr);
+		ret = spi_flash_write_bar(flash, write_addr);
 		if (ret < 0)
 			return ret;
 #endif
@@ -470,10 +470,10 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
 
 #ifdef CONFIG_SF_DUAL_FLASH
 		if (flash->dual_flash > SF_SINGLE_FLASH)
-			spi_flash_dual_flash(flash, &read_addr);
+			spi_flash_dual(flash, &read_addr);
 #endif
 #ifdef CONFIG_SPI_FLASH_BAR
-		ret = spi_flash_write_bank(flash, read_addr);
+		ret = spi_flash_write_bar(flash, read_addr);
 		if (ret < 0)
 			return ret;
 		bank_sel = flash->bank_curr;
@@ -671,7 +671,7 @@ int stm_is_locked(struct spi_flash *flash, u32 ofs, size_t len)
 	int status;
 	u8 sr;
 
-	status = spi_flash_cmd_read_status(flash, &sr);
+	status = read_sr(flash, &sr);
 	if (status < 0)
 		return status;
 
@@ -708,7 +708,7 @@ int stm_lock(struct spi_flash *flash, u32 ofs, size_t len)
 	u8 shift = ffs(mask) - 1, pow, val;
 	int ret;
 
-	ret = spi_flash_cmd_read_status(flash, &status_old);
+	ret = read_sr(flash, &status_old);
 	if (ret < 0)
 		return ret;
 
@@ -745,7 +745,7 @@ int stm_lock(struct spi_flash *flash, u32 ofs, size_t len)
 	if ((status_new & mask) <= (status_old & mask))
 		return -EINVAL;
 
-	spi_flash_cmd_write_status(flash, status_new);
+	write_sr(flash, status_new);
 
 	return 0;
 }
@@ -762,7 +762,7 @@ int stm_unlock(struct spi_flash *flash, u32 ofs, size_t len)
 	u8 shift = ffs(mask) - 1, pow, val;
 	int ret;
 
-	ret = spi_flash_cmd_read_status(flash, &status_old);
+	ret = read_sr(flash, &status_old);
 	if (ret < 0)
 		return ret;
 
@@ -795,7 +795,7 @@ int stm_unlock(struct spi_flash *flash, u32 ofs, size_t len)
 	if ((status_new & mask) >= (status_old & mask))
 		return -EINVAL;
 
-	spi_flash_cmd_write_status(flash, status_new);
+	write_sr(flash, status_new);
 
 	return 0;
 }
@@ -808,14 +808,14 @@ static int spi_flash_set_qeb_mxic(struct spi_flash *flash)
 	u8 qeb_status;
 	int ret;
 
-	ret = spi_flash_cmd_read_status(flash, &qeb_status);
+	ret = read_sr(flash, &qeb_status);
 	if (ret < 0)
 		return ret;
 
 	if (qeb_status & STATUS_QEB_MXIC) {
 		debug("SF: mxic: QEB is already set\n");
 	} else {
-		ret = spi_flash_cmd_write_status(flash, STATUS_QEB_MXIC);
+		ret = write_sr(flash, STATUS_QEB_MXIC);
 		if (ret < 0)
 			return ret;
 	}
@@ -830,14 +830,14 @@ static int spi_flash_set_qeb_winspan(struct spi_flash *flash)
 	u8 qeb_status;
 	int ret;
 
-	ret = spi_flash_cmd_read_config(flash, &qeb_status);
+	ret = read_cr(flash, &qeb_status);
 	if (ret < 0)
 		return ret;
 
 	if (qeb_status & STATUS_QEB_WINSPAN) {
 		debug("SF: winspan: QEB is already set\n");
 	} else {
-		ret = spi_flash_cmd_write_config(flash, STATUS_QEB_WINSPAN);
+		ret = write_cr(flash, STATUS_QEB_WINSPAN);
 		if (ret < 0)
 			return ret;
 	}
@@ -944,7 +944,7 @@ int spi_flash_scan(struct spi_slave *spi, struct spi_flash *flash)
 #if defined(CONFIG_SPI_FLASH_ATMEL) || \
 	defined(CONFIG_SPI_FLASH_MACRONIX) || \
 	defined(CONFIG_SPI_FLASH_SST)
-		spi_flash_cmd_write_status(flash, 0);
+		write_sr(flash, 0);
 #endif
 
 	/* Assign spi data */
@@ -1079,7 +1079,7 @@ int spi_flash_scan(struct spi_slave *spi, struct spi_flash *flash)
 
 	/* Configure the BAR - discover bank cmds and read current bank */
 #ifdef CONFIG_SPI_FLASH_BAR
-	ret = spi_flash_read_bank(flash, idcode[0]);
+	ret = spi_flash_read_bar(flash, idcode[0]);
 	if (ret < 0)
 		return ret;
 #endif
Signature · 1 line
1.9.1
author
#18 lore raw

PATCH v8 8/14 sf: Flash power up read-only based on idcode0

In reply to Jagan Teki

Using macro's for flash power up read-only access code leads wrong behaviour hence use idcode0 for runtime detection, hence the flash which require this functionality gets detected at runtime.

---
 drivers/mtd/spi/sf_internal.h | 1 +
 drivers/mtd/spi/sf_ops.c      | 7 +++----
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/mtd/spi/sf_internal.h +1 -0
index 8f586ee..b8692c6 100644
@@ -66,6 +66,7 @@ enum spi_nor_option_flags {
 #define SPI_FLASH_CFI_MFR_MACRONIX	0xc2
 #define SPI_FLASH_CFI_MFR_SST		0xbf
 #define SPI_FLASH_CFI_MFR_WINBOND	0xef
+#define SPI_FLASH_CFI_MFR_ATMEL		0x1f
 
 /* Erase commands */
 #define CMD_ERASE_4K			0x20
drivers/mtd/spi/sf_ops.c +3 -4
index 853759e..e5514ab 100644
@@ -941,11 +941,10 @@ int spi_flash_scan(struct spi_slave *spi, struct spi_flash *flash)
 	}
 
 	/* Flash powers up read-only, so clear BP# bits */
-#if defined(CONFIG_SPI_FLASH_ATMEL) || \
-	defined(CONFIG_SPI_FLASH_MACRONIX) || \
-	defined(CONFIG_SPI_FLASH_SST)
+	if (idcode[0] == SPI_FLASH_CFI_MFR_ATMEL ||
+	    idcode[0] == SPI_FLASH_CFI_MFR_MACRONIX ||
+	    idcode[0] == SPI_FLASH_CFI_MFR_SST)
 		write_sr(flash, 0);
-#endif
 
 	/* Assign spi data */
 	flash->spi = spi;
Signature · 1 line
1.9.1
#19 lore raw

PATCH v8 8/14 sf: Flash power up read-only based on idcode0

Quoted 5 lines · Jagan Teki

Using macro's for flash power up read-only access code leads wrong behaviour hence use idcode0 for runtime detection, hence the flash which require this functionality gets detected at runtime.

Quoted 7 lines
---
 drivers/mtd/spi/sf_internal.h | 1 +
 drivers/mtd/spi/sf_ops.c      | 7 +++----
 2 files changed, 4 insertions(+), 4 deletions(-)
author
#20 lore raw

PATCH v8 9/14 sf: Remove unneeded header includes

In reply to Jagan Teki

Removed unneeded header includes in sf_ops and sf_probe

---
 drivers/mtd/spi/sf_ops.c   | 2 --
 drivers/mtd/spi/sf_probe.c | 3 ---
 2 files changed, 5 deletions(-)
drivers/mtd/spi/sf_ops.c +0 -2
index e5514ab..ef45fc1 100644
@@ -14,8 +14,6 @@
 #include <mapmem.h>
 #include <spi.h>
 #include <spi_flash.h>
-#include <watchdog.h>
-#include <linux/compiler.h>
 #include <linux/log2.h>
 
 #include "sf_internal.h"
drivers/mtd/spi/sf_probe.c +0 -3
index e35b917..f8aad56 100644
@@ -11,12 +11,9 @@
 #include <common.h>
 #include <dm.h>
 #include <errno.h>
-#include <fdtdec.h>
 #include <malloc.h>
-#include <mapmem.h>
 #include <spi.h>
 #include <spi_flash.h>
-#include <asm/io.h>
 
 #include "sf_internal.h"
 
Signature · 1 line
1.9.1
author
#22 lore raw

PATCH v8 10/14 sf: Remove unneeded SST_BP and SST_WP

In reply to Jagan Teki

SST parts added on sf_params.c supports both SST_WR which consits of both BP and WP and there is a spi controller ich which supports only BP so the relevent _write hook set based on "slave->op_mode_tx" hence there is no respective change required from flash side hance removed these.

---
 drivers/mtd/spi/sf_internal.h | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/mtd/spi/sf_internal.h +2 -5
index b8692c6..16dd45b 100644
@@ -44,13 +44,10 @@ enum {
 #endif
 	SECT_32K	= 1 << 1,
 	E_FSR		= 1 << 2,
-	SST_BP		= 1 << 3,
-	SST_WP		= 1 << 4,
-	WR_QPP		= 1 << 5,
+	SST_WR		= 1 << 3,
+	WR_QPP		= 1 << 4,
 };
 
-#define SST_WR		(SST_BP | SST_WP)
-
 enum spi_nor_option_flags {
 	SNOR_F_SST_WR		= (1 << 0),
 	SNOR_F_USE_FSR		= (1 << 1),
Signature · 1 line
1.9.1
#23 lore raw

PATCH v8 10/14 sf: Remove unneeded SST_BP and SST_WP

Quoted 6 lines · Jagan Teki

SST parts added on sf_params.c supports both SST_WR which consits of both BP and WP and there is a spi controller ich which supports only BP so the relevent _write hook set based on "slave->op_mode_tx" hence there is no respective change required from flash side hance removed these.

Quoted 6 lines
---
 drivers/mtd/spi/sf_internal.h | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
author
#24 lore raw

PATCH v8 11/14 sf: ops: Fix missing break on spansion read_bar

In reply to Jagan Teki

For assigning read_bar commands in spansion case, break is missing this patch add that break.

---
 drivers/mtd/spi/sf_ops.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/spi/sf_ops.c +1 -0
index ef45fc1..68f191b 100644
@@ -154,6 +154,7 @@ static int spi_flash_read_bar(struct spi_flash *flash, u8 idcode0)
 	case SPI_FLASH_CFI_MFR_SPANSION:
 		flash->bank_read_cmd = CMD_BANKADDR_BRRD;
 		flash->bank_write_cmd = CMD_BANKADDR_BRWR;
+		break;
 	default:
 		flash->bank_read_cmd = CMD_EXTNADDR_RDEAR;
 		flash->bank_write_cmd = CMD_EXTNADDR_WREAR;
Signature · 1 line
1.9.1
author
#26 lore raw

PATCH v8 12/14 sf: sf_probe: Remove spi_slave pointer argument

In reply to Jagan Teki

Since spi_slave is a spi pointer in spi_flash{} then assign spi_slave{} pointer to flash->spi and remove spi_slave pointer argument to
- spi_flash_probe_slave
- spi_flash_scan

---
 drivers/mtd/spi/sf_internal.h |  3 +--
 drivers/mtd/spi/sf_ops.c      |  4 ++--
 drivers/mtd/spi/sf_probe.c    | 12 +++++++-----
 3 files changed, 10 insertions(+), 9 deletions(-)
drivers/mtd/spi/sf_internal.h +1 -2
index 16dd45b..ed5c391 100644
@@ -227,7 +227,6 @@ void spi_flash_mtd_unregister(void);
 
 /**
  * spi_flash_scan - scan the SPI FLASH
- * @spi:	the spi slave structure
  * @flash:	the spi flash structure
  *
  * The drivers can use this fuction to scan the SPI FLASH.
@@ -236,6 +235,6 @@ void spi_flash_mtd_unregister(void);
  *
  * Return: 0 for success, others for failure.
  */
-int spi_flash_scan(struct spi_slave *spi, struct spi_flash *flash);
+int spi_flash_scan(struct spi_flash *flash);
 
 #endif /* _SF_INTERNAL_H_ */
drivers/mtd/spi/sf_ops.c +2 -2
index 68f191b..c065858 100644
@@ -896,8 +896,9 @@ int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash)
 }
 #endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
 
-int spi_flash_scan(struct spi_slave *spi, struct spi_flash *flash)
+int spi_flash_scan(struct spi_flash *flash)
 {
+	struct spi_slave *spi = flash->spi;
 	const struct spi_flash_params *params;
 	u16 jedec, ext_jedec;
 	u8 idcode[5];
@@ -946,7 +947,6 @@ int spi_flash_scan(struct spi_slave *spi, struct spi_flash *flash)
 		write_sr(flash, 0);
 
 	/* Assign spi data */
-	flash->spi = spi;
 	flash->name = params->name;
 	flash->memory_map = spi->memory_map;
 	flash->dual_flash = flash->spi->option;
drivers/mtd/spi/sf_probe.c +7 -5
index f8aad56..bf53eef 100644
@@ -20,12 +20,12 @@
 /**
  * spi_flash_probe_slave() - Probe for a SPI flash device on a bus
  *
- * @spi: Bus to probe
  * @flashp: Pointer to place to put flash info, which may be NULL if the
  * space should be allocated
  */
-int spi_flash_probe_slave(struct spi_slave *spi, struct spi_flash *flash)
+int spi_flash_probe_slave(struct spi_flash *flash)
 {
+	struct spi_slave *spi = flash->spi;
 	int ret;
 
 	/* Setup spi_slave */
@@ -41,7 +41,7 @@ int spi_flash_probe_slave(struct spi_slave *spi, struct spi_flash *flash)
 		return ret;
 	}
 
-	ret = spi_flash_scan(spi, flash);
+	ret = spi_flash_scan(flash);
 	if (ret) {
 		ret = -EINVAL;
 		goto err_read_id;
@@ -68,7 +68,8 @@ struct spi_flash *spi_flash_probe_tail(struct spi_slave *bus)
 		return NULL;
 	}
 
-	if (spi_flash_probe_slave(bus, flash)) {
+	flash->spi = bus;
+	if (spi_flash_probe_slave(flash)) {
 		spi_free_slave(bus);
 		free(flash);
 		return NULL;
@@ -152,8 +153,9 @@ int spi_flash_std_probe(struct udevice *dev)
 
 	flash = dev_get_uclass_priv(dev);
 	flash->dev = dev;
+	flash->spi = slave;
 	debug("%s: slave=%p, cs=%d\n", __func__, slave, plat->cs);
-	return spi_flash_probe_slave(slave, flash);
+	return spi_flash_probe_slave(flash);
 }
 
 static const struct dm_spi_flash_ops spi_flash_std_ops = {
Signature · 1 line
1.9.1
#27 lore raw

PATCH v8 12/14 sf: sf_probe: Remove spi_slave pointer argument

Quoted 6 lines · Jagan Teki

Since spi_slave is a spi pointer in spi_flash{} then assign spi_slave{} pointer to flash->spi and remove spi_slave pointer argument to
- spi_flash_probe_slave
- spi_flash_scan

Quoted 7 lines
---
 drivers/mtd/spi/sf_internal.h |  3 +--
 drivers/mtd/spi/sf_ops.c      |  4 ++--
 drivers/mtd/spi/sf_probe.c    | 12 +++++++-----
 3 files changed, 10 insertions(+), 9 deletions(-)
#28 lore raw

PATCH v8 12/14 sf: sf_probe: Remove spi_slave pointer argument

In reply to Jagan Teki
Quoted 6 lines · Jagan Teki

Since spi_slave is a spi pointer in spi_flash{} then assign spi_slave{} pointer to flash->spi and remove spi_slave pointer argument to
- spi_flash_probe_slave
- spi_flash_scan

Quoted 8 lines
---
 drivers/mtd/spi/sf_internal.h |  3 +--
 drivers/mtd/spi/sf_ops.c      |  4 ++--
 drivers/mtd/spi/sf_probe.c    | 12 +++++++-----
 3 files changed, 10 insertions(+), 9 deletions(-)
author
#29 lore raw

PATCH v8 13/14 sf: Use static for file-scope functions

In reply to Jagan Teki

Used static for file-scope functions in sf_probe.c

---
 drivers/mtd/spi/sf_probe.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/mtd/spi/sf_probe.c +5 -5
index bf53eef..0cafc29 100644
@@ -23,7 +23,7 @@
  * @flashp: Pointer to place to put flash info, which may be NULL if the
  * space should be allocated
  */
-int spi_flash_probe_slave(struct spi_flash *flash)
+static int spi_flash_probe_slave(struct spi_flash *flash)
 {
 	struct spi_slave *spi = flash->spi;
 	int ret;
@@ -57,7 +57,7 @@ err_read_id:
 }
 
 #ifndef CONFIG_DM_SPI_FLASH
-struct spi_flash *spi_flash_probe_tail(struct spi_slave *bus)
+static struct spi_flash *spi_flash_probe_tail(struct spi_slave *bus)
 {
 	struct spi_flash *flash;
 
@@ -121,7 +121,7 @@ static int spi_flash_std_read(struct udevice *dev, u32 offset, size_t len,
 	return spi_flash_cmd_read_ops(flash, offset, len, buf);
 }
 
-int spi_flash_std_write(struct udevice *dev, u32 offset, size_t len,
+static int spi_flash_std_write(struct udevice *dev, u32 offset, size_t len,
 			const void *buf)
 {
 	struct spi_flash *flash = dev_get_uclass_priv(dev);
@@ -138,14 +138,14 @@ int spi_flash_std_write(struct udevice *dev, u32 offset, size_t len,
 	return spi_flash_cmd_write_ops(flash, offset, len, buf);
 }
 
-int spi_flash_std_erase(struct udevice *dev, u32 offset, size_t len)
+static int spi_flash_std_erase(struct udevice *dev, u32 offset, size_t len)
 {
 	struct spi_flash *flash = dev_get_uclass_priv(dev);
 
 	return spi_flash_cmd_erase_ops(flash, offset, len);
 }
 
-int spi_flash_std_probe(struct udevice *dev)
+static int spi_flash_std_probe(struct udevice *dev)
 {
 	struct spi_slave *slave = dev_get_parent_priv(dev);
 	struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev);
Signature · 1 line
1.9.1
author
#32 lore raw

PATCH v8 14/14 sf: Rename sf_ops.c to spi-flash.c

In reply to Jagan Teki

Since all spi-flash core operations are moved into sf_ops.c then it's better to renamed as spi-flash.c

---
 drivers/mtd/spi/Makefile                  | 2 +-
 drivers/mtd/spi/{sf_ops.c => spi-flash.c} | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)
 rename drivers/mtd/spi/{sf_ops.c => spi-flash.c} (99%)
drivers/mtd/spi/Makefile +1 -1
index a24f761..7bc76a2 100644
@@ -12,7 +12,7 @@ obj-$(CONFIG_SPL_SPI_LOAD)	+= spi_spl_load.o
 obj-$(CONFIG_SPL_SPI_BOOT)	+= fsl_espi_spl.o
 endif
 
-obj-$(CONFIG_SPI_FLASH) += sf_probe.o sf_ops.o sf_params.o sf.o
+obj-$(CONFIG_SPI_FLASH) += sf_probe.o spi-flash.o sf_params.o sf.o
 obj-$(CONFIG_SPI_FLASH_DATAFLASH) += sf_dataflash.o
 obj-$(CONFIG_SPI_FLASH_MTD) += sf_mtd.o
 obj-$(CONFIG_SPI_FLASH_SANDBOX) += sandbox.o
drivers/mtd/spi/spi-flash.c renamed from drivers/mtd/spi/sf_ops.c +4 -3
similarity index 99%
rename from drivers/mtd/spi/sf_ops.c
rename to drivers/mtd/spi/spi-flash.c
index c065858..7ffa136 100644
@@ -1,9 +1,10 @@
 /*
- * SPI flash operations
+ * SPI Flash Core
  *
- * Copyright (C) 2008 Atmel Corporation
- * Copyright (C) 2010 Reinhard Meyer, EMK Elektronik
+ * Copyright (C) 2015 Jagan Teki <[email protected]>
  * Copyright (C) 2013 Jagannadha Sutradharudu Teki, Xilinx Inc.
+ * Copyright (C) 2010 Reinhard Meyer, EMK Elektronik
+ * Copyright (C) 2008 Atmel Corporation
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
Signature · 1 line
1.9.1
#33 lore raw

PATCH v8 14/14 sf: Rename sf_ops.c to spi-flash.c

Quoted 9 lines · Jagan Teki

Since all spi-flash core operations are moved into sf_ops.c then it's better to renamed as spi-flash.c

---
 drivers/mtd/spi/Makefile                  | 2 +-
 drivers/mtd/spi/{sf_ops.c => spi-flash.c} | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)
 rename drivers/mtd/spi/{sf_ops.c => spi-flash.c} (99%)

(but I suggest spi_flash.c is better as it fits with the other files)

author
#34 lore raw

PATCH v8 14/14 sf: Rename sf_ops.c to spi-flash.c

Quoted 11 lines · Simon Glass
Quoted 9 lines · Jagan Teki

Since all spi-flash core operations are moved into sf_ops.c then it's better to renamed as spi-flash.c

---
 drivers/mtd/spi/Makefile                  | 2 +-
 drivers/mtd/spi/{sf_ops.c => spi-flash.c} | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)
 rename drivers/mtd/spi/{sf_ops.c => spi-flash.c} (99%)
Quoted 3 lines

(but I suggest spi_flash.c is better as it fits with the other files)

I too thought the same, but will rename the remaining to proper have a plan for the same.

thanks!

Signature · 1 line
Jagan.
#35 lore raw

PATCH v8 14/14 sf: Rename sf_ops.c to spi-flash.c

In reply to Simon Glass
Quoted 11 lines · Simon Glass
Quoted 9 lines · Jagan Teki

Since all spi-flash core operations are moved into sf_ops.c then it's better to renamed as spi-flash.c

---
 drivers/mtd/spi/Makefile                  | 2 +-
 drivers/mtd/spi/{sf_ops.c => spi-flash.c} | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)
 rename drivers/mtd/spi/{sf_ops.c => spi-flash.c} (99%)
Quoted 3 lines

(but I suggest spi_flash.c is better as it fits with the other files)

Agreed. spi_flash.c makes more sense. So far it looks that only driver model uclass driver is using - in the file name, others are using _.

Other than this,

author
#36 lore raw

PATCH v8 14/14 sf: Rename sf_ops.c to spi-flash.c

Quoted 12 lines · Bin Meng
Quoted 11 lines · Simon Glass
Quoted 9 lines · Jagan Teki

Since all spi-flash core operations are moved into sf_ops.c then it's better to renamed as spi-flash.c

---
 drivers/mtd/spi/Makefile                  | 2 +-
 drivers/mtd/spi/{sf_ops.c => spi-flash.c} | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)
 rename drivers/mtd/spi/{sf_ops.c => spi-flash.c} (99%)
Quoted 6 lines
Quoted 3 lines

(but I suggest spi_flash.c is better as it fits with the other files)

Agreed. spi_flash.c makes more sense. So far it looks that only driver model uclass driver is using - in the file name, others are using _.

Clear, but this file will handle common spi-flash core functionalities it shouldn't be dm even now or later and more over underlying sf_probe which is calling this through spi_flash_scan has a driver model on it.

Quoted 4 lines

Other than this,

thanks!

Signature · 1 line
Jagan.
#37 lore raw

PATCH v8 14/14 sf: Rename sf_ops.c to spi-flash.c

Hi Jagan,

Quoted 15 lines · Jagan Teki
Quoted 14 lines · Bin Meng
Quoted 13 lines · Simon Glass
Quoted 9 lines · Jagan Teki

Since all spi-flash core operations are moved into sf_ops.c then it's better to renamed as spi-flash.c

---
 drivers/mtd/spi/Makefile                  | 2 +-
 drivers/mtd/spi/{sf_ops.c => spi-flash.c} | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)
 rename drivers/mtd/spi/{sf_ops.c => spi-flash.c} (99%)
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

(but I suggest spi_flash.c is better as it fits with the other files)

Agreed. spi_flash.c makes more sense. So far it looks that only driver model uclass driver is using - in the file name, others are using _.

Clear, but this file will handle common spi-flash core functionalities it shouldn't be dm even now or later and more over underlying sf_probe which is calling this through spi_flash_scan has a driver model on it.

Sorry, I don't quite understand what you mean. But my comment is to rename sf_ops.c to sf_flash.c, not sf-flash.c.

Quoted 8 lines
Quoted 5 lines

Other than this,

thanks!
--

Regards,
Bin

author
#38 lore raw

PATCH v8 14/14 sf: Rename sf_ops.c to spi-flash.c

Quoted 23 lines · Bin Meng

Hi Jagan,

Quoted 20 lines · Jagan Teki
Quoted 18 lines · Bin Meng
Quoted 11 lines · Simon Glass
Quoted 9 lines · Jagan Teki

Since all spi-flash core operations are moved into sf_ops.c then it's better to renamed as spi-flash.c

---
  drivers/mtd/spi/Makefile                  | 2 +-
  drivers/mtd/spi/{sf_ops.c => spi-flash.c} | 7 ++++---
  2 files changed, 5 insertions(+), 4 deletions(-)

rename drivers/mtd/spi/{sf_ops.c => spi-flash.c} (99%)

Quoted 3 lines

(but I suggest spi_flash.c is better as it fits with the other files)

Agreed. spi_flash.c makes more sense. So far it looks that only driver model uclass driver is using - in the file name, others are using _.

Quoted 6 lines
Quoted 3 lines

Clear, but this file will handle common spi-flash core functionalities it shouldn't be dm even now or later and more over underlying sf_probe which is calling this through spi_flash_scan has a driver model on it.

Sorry, I don't quite understand what you mean. But my comment is to rename sf_ops.c to sf_flash.c, not sf-flash.c.

spi-flash.c (the function spi_flash_scan from sf_probe, so this never be a dm driver and it handles all core functionalities
======================================================================
sf_probe.c (this has dm support)
=================================

Since you're saying dm has - and ie the reason I'm saying spi-flash.c should technically a dm supported core.

Let me know if you're not clear though.

thanks!

Signature · 1 line
Jagan
#39 lore raw

PATCH v8 14/14 sf: Rename sf_ops.c to spi-flash.c

Hi Jagan,

Quoted 44 lines · Jagan Teki
Quoted 31 lines · Bin Meng

Hi Jagan,

Quoted 27 lines · Jagan Teki
Quoted 23 lines · Bin Meng
Quoted 14 lines · Simon Glass
Quoted 10 lines · Jagan Teki

Since all spi-flash core operations are moved into sf_ops.c then it's better to renamed as spi-flash.c

---
  drivers/mtd/spi/Makefile                  | 2 +-
  drivers/mtd/spi/{sf_ops.c => spi-flash.c} | 7 ++++---
  2 files changed, 5 insertions(+), 4 deletions(-)

rename drivers/mtd/spi/{sf_ops.c => spi-flash.c} (99%)

Quoted 3 lines

(but I suggest spi_flash.c is better as it fits with the other files)

Agreed. spi_flash.c makes more sense. So far it looks that only driver model uclass driver is using - in the file name, others are using _.

Quoted 7 lines
Quoted 3 lines

Clear, but this file will handle common spi-flash core functionalities it shouldn't be dm even now or later and more over underlying sf_probe which is calling this through spi_flash_scan has a driver model on it.

Sorry, I don't quite understand what you mean. But my comment is to rename sf_ops.c to sf_flash.c, not sf-flash.c.

Quoted 9 lines

spi-flash.c (the function spi_flash_scan from sf_probe, so this never be a dm driver and it handles all core functionalities
======================================================================
sf_probe.c (this has dm support)
=================================

Since you're saying dm has - and ie the reason I'm saying spi-flash.c should technically a dm supported core.

I was saying it looks to me that only dm uclass driver is allowed to have -, like sf-uclass.c or pci-uclass.c. Other files we should use _.

Quoted 2 lines

Let me know if you're not clear though.

Regards,
Bin

author
#40 lore raw

PATCH v8 14/14 sf: Rename sf_ops.c to spi-flash.c

Quoted 53 lines · Bin Meng

Hi Jagan,

Quoted 50 lines · Jagan Teki
Quoted 31 lines · Bin Meng

Hi Jagan,

Quoted 27 lines · Jagan Teki
Quoted 23 lines · Bin Meng
Quoted 14 lines · Simon Glass
Quoted 10 lines · Jagan Teki

Since all spi-flash core operations are moved into sf_ops.c then it's better to renamed as spi-flash.c

---
   drivers/mtd/spi/Makefile                  | 2 +-
   drivers/mtd/spi/{sf_ops.c => spi-flash.c} | 7 ++++---
   2 files changed, 5 insertions(+), 4 deletions(-)

rename drivers/mtd/spi/{sf_ops.c => spi-flash.c} (99%)

Quoted 3 lines

(but I suggest spi_flash.c is better as it fits with the other files)

Agreed. spi_flash.c makes more sense. So far it looks that only driver model uclass driver is using - in the file name, others are using _.

Quoted 7 lines
Quoted 3 lines

Clear, but this file will handle common spi-flash core functionalities it shouldn't be dm even now or later and more over underlying sf_probe which is calling this through spi_flash_scan has a driver model on it.

Sorry, I don't quite understand what you mean. But my comment is to rename sf_ops.c to sf_flash.c, not sf-flash.c.

spi-flash.c (the function spi_flash_scan from sf_probe, so this never be a dm driver and it handles all core functionalities
======================================================================
sf_probe.c (this has dm support)
=================================

Quoted 6 lines
Quoted 3 lines

Since you're saying dm has - and ie the reason I'm saying spi-flash.c should technically a dm supported core.

I was saying it looks to me that only dm uclass driver is allowed to have -, like sf-uclass.c or pci-uclass.c. Other files we should use _.

sf_probe.c is a dm driver - agree?
If ie the case probably this is the first file has a code moved from dm driver into different file which is spi-flash in this case.

thanks!

Signature · 1 line
Jagan
#41 lore raw

PATCH v8 14/14 sf: Rename sf_ops.c to spi-flash.c

Hi Jagan,

Quoted 72 lines · Jagan Teki
Quoted 71 lines · Bin Meng

Hi Jagan,

Quoted 66 lines · Jagan Teki
Quoted 39 lines · Bin Meng

Hi Jagan,

Quoted 34 lines · Jagan Teki
Quoted 28 lines · Bin Meng
Quoted 17 lines · Simon Glass
Quoted 11 lines · Jagan Teki

Since all spi-flash core operations are moved into sf_ops.c then it's better to renamed as spi-flash.c

---
   drivers/mtd/spi/Makefile                  | 2 +-
   drivers/mtd/spi/{sf_ops.c => spi-flash.c} | 7 ++++---
   2 files changed, 5 insertions(+), 4 deletions(-)

rename drivers/mtd/spi/{sf_ops.c => spi-flash.c} (99%)

Quoted 3 lines

(but I suggest spi_flash.c is better as it fits with the other files)

Agreed. spi_flash.c makes more sense. So far it looks that only driver model uclass driver is using - in the file name, others are using _.

Quoted 8 lines
Quoted 3 lines

Clear, but this file will handle common spi-flash core functionalities it shouldn't be dm even now or later and more over underlying sf_probe which is calling this through spi_flash_scan has a driver model on it.

Sorry, I don't quite understand what you mean. But my comment is to rename sf_ops.c to sf_flash.c, not sf-flash.c.

spi-flash.c (the function spi_flash_scan from sf_probe, so this never be a
dm driver and it handles all core functionalities
======================================================================
sf_probe.c (this has dm support)
=================================

Since you're saying dm has - and ie the reason I'm saying spi-flash.c should
technically a dm supported core.

Quoted 7 lines
Quoted 2 lines

I was saying it looks to me that only dm uclass driver is allowed to have -, like sf-uclass.c or pci-uclass.c. Other files we should use _.

sf_probe.c is a dm driver - agree?
If ie the case probably this is the first file has a code moved from dm driver into different file which is spi-flash in this case.

The current convention is that the uclass driver has a hyphen. There is a different between the *single* uclass driver for a uclass, and all the 'normal' drivers that use it. Also all the uclass drivers have UCLASS_DRIVER() defined in then, and end in '-uclass.c'. Please can you rename the file to spi_flash.c?

Regards,
Simon

author
#42 lore raw

v8 cover sf: Tuning spi-flash layer

In reply to Jagan Teki

Hi Bin,

Quoted 11 lines · Jagan Teki

This series bypasses MTD changes from previous series[1][2] and entire series tunned spi-flash layer for better code handling.

Changes in v8:
- Rebase to master
- PATCH v8 12/14, 13/14, 14/14 added newly.

Changes in v7:
- Rebase to master
- Few patch bisectable separations

Quoted 8 lines

Changes in v6, v5, v4, v3, v2:
- One patch bisectable separation
- Rebase to master

Testing:

$ git clone git://git.denx.de/u-boot-spi.git
$ cd u-boot-spi
$ git checkout -b next origin/next

Please test this.

Quoted 30 lines

[1] http://permalink.gmane.org/gmane.comp.boot-loaders.u-boot/242397
[2] http://permalink.gmane.org/gmane.comp.boot-loaders.u-boot/233262

thanks!
Jagan.

Jagan Teki (14):
sf: spi_flash_validate_params => spi_flash_scan
sf: Move spi_flash_scan code to sf_ops
sf: Move read_id code to sf_ops
sf: probe: Code cleanup
sf: Use static for file-scope functions
sf: Fix Makefile
sf: Use simple name for register access functions
sf: Flash power up read-only based on idcode0
sf: Remove unneeded header includes
sf: Remove unneeded SST_BP and SST_WP
sf: ops: Fix missing break on spansion read_bar
sf: sf_probe: Remove spi_slave pointer argument
sf: Use static for file-scope functions
sf: Rename sf_ops.c to spi-flash.c

 drivers/mtd/spi/Makefile                  |   6 +-
 drivers/mtd/spi/sf_internal.h             |  38 ++-
 drivers/mtd/spi/sf_probe.c                | 373 +--------------------------
 drivers/mtd/spi/{sf_ops.c => spi-flash.c} | 406 ++++++++++++++++++++++++++++--
 4 files changed, 408 insertions(+), 415 deletions(-)
 rename drivers/mtd/spi/{sf_ops.c => spi-flash.c} (60%)
Quoted 3 lines

--
1.9.1

thanks!

Signature · 1 line
Jagan.
#43 lore raw

v8 cover sf: Tuning spi-flash layer

Hi Jagan,

Quoted 18 lines · Jagan Teki

Hi Bin,

Quoted 15 lines · Jagan Teki

This series bypasses MTD changes from previous series[1][2] and entire series tunned spi-flash layer for better code handling.

Changes in v8:
- Rebase to master
- PATCH v8 12/14, 13/14, 14/14 added newly.

Changes in v7:
- Rebase to master
- Few patch bisectable separations

Changes in v6, v5, v4, v3, v2:
- One patch bisectable separation
- Rebase to master

Quoted 7 lines
Quoted 4 lines

Testing:

$ git clone git://git.denx.de/u-boot-spi.git
$ cd u-boot-spi
$ git checkout -b next origin/next

Please test this.

Will do this week.

Quoted 23 lines
Quoted 23 lines

[1] http://permalink.gmane.org/gmane.comp.boot-loaders.u-boot/242397
[2] http://permalink.gmane.org/gmane.comp.boot-loaders.u-boot/233262

thanks!
Jagan.

Jagan Teki (14):
sf: spi_flash_validate_params => spi_flash_scan
sf: Move spi_flash_scan code to sf_ops
sf: Move read_id code to sf_ops
sf: probe: Code cleanup
sf: Use static for file-scope functions
sf: Fix Makefile
sf: Use simple name for register access functions
sf: Flash power up read-only based on idcode0
sf: Remove unneeded header includes
sf: Remove unneeded SST_BP and SST_WP
sf: ops: Fix missing break on spansion read_bar
sf: sf_probe: Remove spi_slave pointer argument
sf: Use static for file-scope functions
sf: Rename sf_ops.c to spi-flash.c

Quoted 7 lines
Quoted 7 lines
 drivers/mtd/spi/Makefile                  |   6 +-
 drivers/mtd/spi/sf_internal.h             |  38 ++-
 drivers/mtd/spi/sf_probe.c                | 373 +--------------------------
 drivers/mtd/spi/{sf_ops.c => spi-flash.c} | 406 ++++++++++++++++++++++++++++--
 4 files changed, 408 insertions(+), 415 deletions(-)
 rename drivers/mtd/spi/{sf_ops.c => spi-flash.c} (60%)

Regards,
Bin

author
#44 lore raw

v8 cover sf: Tuning spi-flash layer

In reply to Jagan Teki

Hi Tom/Wolfgang,

"Need a separate repo for spi-nor and related subsystem."

Why?
- Currently I'm using u-boot-spi for both spi and spi-flash - some flash stuff been added to spi area which is hard for adding/maintaining new features.
- Both are two separate(not different) Subsystems one is generic SPI drivers/spi and another one is flash slave device drivers/mtd/spi
- Development is going on for SPI-NOR Subsystem similar like mtd nand, cfi-flash etc.

Quoted 15 lines · Jagan Teki

This series bypasses MTD changes from previous series[1][2] and entire series tunned spi-flash layer for better code handling.

Changes in v8:
- Rebase to master
- PATCH v8 12/14, 13/14, 14/14 added newly.

Changes in v7:
- Rebase to master
- Few patch bisectable separations

Changes in v6, v5, v4, v3, v2:
- One patch bisectable separation
- Rebase to master

Quoted 7 lines

Testing:

$ git clone git://git.denx.de/u-boot-spi.git
$ cd u-boot-spi
$ git checkout -b next origin/next

[1] http://permalink.gmane.org/gmane.comp.boot-loaders.u-boot/242397
[2] http://permalink.gmane.org/gmane.comp.boot-loaders.u-boot/233262

thanks!

Signature · 1 line
Jagan.
author
#45 lore raw

v8 cover sf: Tuning spi-flash layer

Quoted 4 lines · Jagan Teki

Hi Tom/Wolfgang,

"Need a separate repo for spi-nor and related subsystem."

Quoted 8 lines

Why?
- Currently I'm using u-boot-spi for both spi and spi-flash - some flash stuff been added to spi area which is hard for adding/maintaining new features.
- Both are two separate(not different) Subsystems one is generic SPI drivers/spi and another one is flash slave device drivers/mtd/spi
- Development is going on for SPI-NOR Subsystem similar like mtd nand, cfi-flash etc.

Any inputs on this or am I unclear?

Quoted 17 lines · Jagan Teki
Quoted 15 lines

This series bypasses MTD changes from previous series[1][2] and entire series tunned spi-flash layer for better code handling.

Changes in v8:
- Rebase to master
- PATCH v8 12/14, 13/14, 14/14 added newly.

Changes in v7:
- Rebase to master
- Few patch bisectable separations

Changes in v6, v5, v4, v3, v2:
- One patch bisectable separation
- Rebase to master

Quoted 7 lines
Quoted 7 lines

Testing:

$ git clone git://git.denx.de/u-boot-spi.git
$ cd u-boot-spi
$ git checkout -b next origin/next

[1] http://permalink.gmane.org/gmane.comp.boot-loaders.u-boot/242397
[2] http://permalink.gmane.org/gmane.comp.boot-loaders.u-boot/233262

thanks!

Signature · 1 line
Jagan.
author
#46 lore raw

v8 cover sf: Tuning spi-flash layer

In reply to Jagan Teki
Quoted 15 lines · Jagan Teki

This series bypasses MTD changes from previous series[1][2] and entire series tunned spi-flash layer for better code handling.

Changes in v8:
- Rebase to master
- PATCH v8 12/14, 13/14, 14/14 added newly.

Changes in v7:
- Rebase to master
- Few patch bisectable separations

Changes in v6, v5, v4, v3, v2:
- One patch bisectable separation
- Rebase to master

Quoted 7 lines

Testing:

$ git clone git://git.denx.de/u-boot-spi.git
$ cd u-boot-spi
$ git checkout -b next origin/next

[1] http://permalink.gmane.org/gmane.comp.boot-loaders.u-boot/242397
[2] http://permalink.gmane.org/gmane.comp.boot-loaders.u-boot/233262

Tested whole series on Microzed board.

thanks!

Signature · 1 line
Jagan.
author
#47 lore raw

v8 cover sf: Tuning spi-flash layer

In reply to Jagan Teki
Quoted 49 lines · Jagan Teki

This series bypasses MTD changes from previous series[1][2] and entire series tunned spi-flash layer for better code handling.

Changes in v8:
- Rebase to master
- PATCH v8 12/14, 13/14, 14/14 added newly.

Changes in v7:
- Rebase to master
- Few patch bisectable separations

Changes in v6, v5, v4, v3, v2:
- One patch bisectable separation
- Rebase to master

Testing:

$ git clone git://git.denx.de/u-boot-spi.git
$ cd u-boot-spi
$ git checkout -b next origin/next

[1] http://permalink.gmane.org/gmane.comp.boot-loaders.u-boot/242397
[2] http://permalink.gmane.org/gmane.comp.boot-loaders.u-boot/233262

thanks!
Jagan.

Jagan Teki (14):
sf: spi_flash_validate_params => spi_flash_scan
sf: Move spi_flash_scan code to sf_ops
sf: Move read_id code to sf_ops
sf: probe: Code cleanup
sf: Use static for file-scope functions
sf: Fix Makefile
sf: Use simple name for register access functions
sf: Flash power up read-only based on idcode0
sf: Remove unneeded header includes
sf: Remove unneeded SST_BP and SST_WP
sf: ops: Fix missing break on spansion read_bar
sf: sf_probe: Remove spi_slave pointer argument
sf: Use static for file-scope functions
sf: Rename sf_ops.c to spi-flash.c

 drivers/mtd/spi/Makefile                  |   6 +-
 drivers/mtd/spi/sf_internal.h             |  38 ++-
 drivers/mtd/spi/sf_probe.c                | 373 +--------------------------
 drivers/mtd/spi/{sf_ops.c => spi-flash.c} | 406 ++++++++++++++++++++++++++++--
 4 files changed, 408 insertions(+), 415 deletions(-)
 rename drivers/mtd/spi/{sf_ops.c => spi-flash.c} (60%)
Quoted 3 lines

--
1.9.1

Applied to u-boot-spi/master

thanks!

Signature · 1 line
Jagan.