All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/2] Disable hybrid mode for SPANSION S25FS-S family
@ 2017-10-16  7:24 Rajat Srivastava
  2017-10-16  7:24 ` [U-Boot] [PATCH 1/2] sf: " Rajat Srivastava
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Rajat Srivastava @ 2017-10-16  7:24 UTC (permalink / raw)
  To: u-boot

The S25FS-S family physical sectors may be configured as a hybrid
combination of eight 4-kB parameter sectors at the top or bottom
of the address space with all but one of the remaining sectors
being uniform size. The default status of the flash is the hybrid
architecture.

Since the parameter sectors and the uniform sectors have different
erase commands, it is a problem to implement erase functionality for
hybrid mode in current U-boot code. Also, enabling hybrid mode doesn't
provide any significant benefit.

There is a configuration option to disable the hybrid mode so that all
sectors are of uniform size (256 kbytes). This set of patches disables
the above mentioned hybrid mode in Spansion S25FS-S family of flashes.

Rajat Srivastava (2):
  sf: Disable hybrid mode for SPANSION S25FS-S family
  sf: Fix s25fs512s erase size and remove SECT_4K flag

 drivers/mtd/spi/sf_internal.h   |  7 +++++
 drivers/mtd/spi/spi_flash.c     | 65 +++++++++++++++++++++++++++++++++++++++++
 drivers/mtd/spi/spi_flash_ids.c |  2 +-
 3 files changed, 73 insertions(+), 1 deletion(-)

-- 
2.7.4

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

* [U-Boot] [PATCH 1/2] sf: Disable hybrid mode for SPANSION S25FS-S family
  2017-10-16  7:24 [U-Boot] [PATCH 0/2] Disable hybrid mode for SPANSION S25FS-S family Rajat Srivastava
@ 2017-10-16  7:24 ` Rajat Srivastava
  2017-10-16  7:24 ` [U-Boot] [PATCH 2/2] sf: Fix s25fs512s erase size and remove SECT_4K flag Rajat Srivastava
  2017-10-30  6:22 ` [U-Boot] [PATCH 0/2] Disable hybrid mode for SPANSION S25FS-S family Jagan Teki
  2 siblings, 0 replies; 8+ messages in thread
From: Rajat Srivastava @ 2017-10-16  7:24 UTC (permalink / raw)
  To: u-boot

The S25FS-S family physical sectors may be configured as a hybrid
combination of eight 4-kB parameter sectors at the top or bottom
of the address space with all but one of the remaining sectors
being uniform size.
The default status of the flash is the hybrid architecture.
The parameter sectors and the uniform sectors have different erase
commands.

This patch disables the hybrid sector architecture. The flash will
have uniform sector size and uniform erase command.
This configuration is temporary and the flash will revert to hybrid
architecture after power on reset.

Signed-off-by: Yuan Yao <yao.yuan@nxp.com>
Signed-off-by: Suresh Gupta <suresh.gupta@nxp.com>
Signed-off-by: Rajat Srivastava <rajat.srivastava@nxp.com>
---
 drivers/mtd/spi/sf_internal.h |  7 +++++
 drivers/mtd/spi/spi_flash.c   | 65 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+)

diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h
index 839cdbe..228960c 100644
--- a/drivers/mtd/spi/sf_internal.h
+++ b/drivers/mtd/spi/sf_internal.h
@@ -63,6 +63,12 @@ enum spi_nor_option_flags {
 #define CMD_READ_CONFIG			0x35
 #define CMD_FLAG_STATUS			0x70
 
+/* Spansion specific commands */
+#ifdef CONFIG_SPI_FLASH_SPANSION
+#define CMD_SPANSION_RDAR		0x65
+#define CMD_SPANSION_WRAR		0x71
+#endif
+
 /* Bank addr access commands */
 #ifdef CONFIG_SPI_FLASH_BAR
 # define CMD_BANKADDR_BRWR		0x17
@@ -99,6 +105,7 @@ int sst_write_bp(struct spi_flash *flash, u32 offset, size_t len,
 #define JEDEC_MFR(info)		((info)->id[0])
 #define JEDEC_ID(info)		(((info)->id[1]) << 8 | ((info)->id[2]))
 #define JEDEC_EXT(info)		(((info)->id[3]) << 8 | ((info)->id[4]))
+#define JEDEC_FAM_ID(info)	((info)->id[5])
 #define SPI_FLASH_MAX_ID_LEN	6
 
 struct spi_flash_info {
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 34f6888..5152afd 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -937,6 +937,45 @@ int spi_flash_decode_fdt(struct spi_flash *flash)
 }
 #endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
 
+#ifdef CONFIG_SPI_FLASH_SPANSION
+static int spansion_s25fss_disable_hybrid_mode(struct spi_slave *spi)
+{
+	u8 cmd[4];
+	u32 offset = 0x800004; /* CR3V register offset */
+	u8 cr3v;
+	int ret;
+
+	cmd[0] = CMD_SPANSION_RDAR;
+	cmd[1] = offset >> 16;
+	cmd[2] = offset >> 8;
+	cmd[3] = offset >> 0;
+
+	ret = spi_flash_cmd_read(spi, cmd, 4, &cr3v, 1);
+	if (ret)
+		return -EIO;
+
+	/* CR3V bit3: 4-KB Erase */
+	if (cr3v & 0x8)
+		return 0;
+
+	cmd[0] = CMD_SPANSION_WRAR;
+	cr3v |= 0x8;
+	ret = spi_flash_cmd_write(spi, cmd, 4, &cr3v, 1);
+	if (ret)
+		return -EIO;
+
+	cmd[0] = CMD_SPANSION_RDAR;
+	ret = spi_flash_cmd_read(spi, cmd, 4, &cr3v, 1);
+	if (ret)
+		return -EIO;
+
+	if (!(cr3v & 0x8))
+		return -EFAULT;
+
+	return 0;
+}
+#endif
+
 int spi_flash_scan(struct spi_flash *flash)
 {
 	struct spi_slave *spi = flash->spi;
@@ -1034,6 +1073,32 @@ int spi_flash_scan(struct spi_flash *flash)
 	/* Now erase size becomes valid sector size */
 	flash->sector_size = flash->erase_size;
 
+#ifdef CONFIG_SPI_FLASH_SPANSION
+	/*
+	 * The S25FS-S family physical sectors may be configured as a
+	 * hybrid combination of eight 4-kB parameter sectors
+	 * at the top or bottom of the address space with all
+	 * but one of the remaining sectors being uniform size.
+	 * The Parameter Sector Erase commands (20h or 21h) must
+	 * be used to erase the 4-kB parameter sectors individually.
+	 * The Sector (uniform sector) Erase commands (D8h or DCh)
+	 * must be used to erase any of the remaining
+	 * sectors, including the portion of highest or lowest address
+	 * sector that is not overlaid by the parameter sectors.
+	 * The uniform sector erase command has no effect on parameter sectors.
+	 * The following code removes the 4-kB parameter sectors from the
+	 * address map i.e. it disables the hybrid mode so that all sectors are
+	 * uniform size.
+	 */
+
+	if ((JEDEC_ID(info) == 0x0219 || JEDEC_ID(info) == 0x0220) &&
+	    (JEDEC_EXT(info) & 0xff00) == 0x4d00 &&
+	    JEDEC_FAM_ID(info) == 0x81) {
+		ret = spansion_s25fss_disable_hybrid_mode(spi);
+		if (ret)
+			return ret;
+	}
+#endif
 	/* Look for read commands */
 	flash->read_cmd = CMD_READ_ARRAY_FAST;
 	if (spi->mode & SPI_RX_SLOW)
-- 
2.7.4

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

* [U-Boot] [PATCH 2/2] sf: Fix s25fs512s erase size and remove SECT_4K flag
  2017-10-16  7:24 [U-Boot] [PATCH 0/2] Disable hybrid mode for SPANSION S25FS-S family Rajat Srivastava
  2017-10-16  7:24 ` [U-Boot] [PATCH 1/2] sf: " Rajat Srivastava
@ 2017-10-16  7:24 ` Rajat Srivastava
  2017-10-30  6:22 ` [U-Boot] [PATCH 0/2] Disable hybrid mode for SPANSION S25FS-S family Jagan Teki
  2 siblings, 0 replies; 8+ messages in thread
From: Rajat Srivastava @ 2017-10-16  7:24 UTC (permalink / raw)
  To: u-boot

As per data sheet, S25FS512S support uniform sector option
or erase size of 256 kbytes and Page Programming buffer of
256 or 512 Bytes. So, flag SECT_4K has no significance for
this flash.

Signed-off-by: Suresh Gupta <suresh.gupta@nxp.com>
Signed-off-by: Rajat Srivastava <rajat.srivastava@nxp.com>
---
 drivers/mtd/spi/spi_flash_ids.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/spi/spi_flash_ids.c b/drivers/mtd/spi/spi_flash_ids.c
index 13f64e7..f47f96c 100644
--- a/drivers/mtd/spi/spi_flash_ids.c
+++ b/drivers/mtd/spi/spi_flash_ids.c
@@ -103,7 +103,7 @@ const struct spi_flash_info spi_flash_ids[] = {
 	{"s25fl256s_256k", INFO(0x010219, 0x4d00, 256 * 1024,   128, RD_FULL | WR_QPP) },
 	{"s25fs256s_64k",  INFO6(0x010219, 0x4d0181, 64 * 1024, 512, RD_FULL | WR_QPP | SECT_4K) },
 	{"s25fl256s_64k",  INFO(0x010219, 0x4d01,  64 * 1024,   512, RD_FULL | WR_QPP) },
-	{"s25fs512s",      INFO6(0x010220, 0x4d0081, 128 * 1024, 512, RD_FULL | WR_QPP | SECT_4K) },
+	{"s25fs512s",      INFO6(0x010220, 0x4d0081, 256 * 1024, 256, RD_FULL | WR_QPP) },
 	{"s25fl512s_256k", INFO(0x010220, 0x4d00, 256 * 1024,   256, RD_FULL | WR_QPP) },
 	{"s25fl512s_64k",  INFO(0x010220, 0x4d01,  64 * 1024,  1024, RD_FULL | WR_QPP) },
 	{"s25fl512s_512k", INFO(0x010220, 0x4f00, 256 * 1024,   256, RD_FULL | WR_QPP) },
-- 
2.7.4

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

* [U-Boot] [PATCH 0/2] Disable hybrid mode for SPANSION S25FS-S family
  2017-10-16  7:24 [U-Boot] [PATCH 0/2] Disable hybrid mode for SPANSION S25FS-S family Rajat Srivastava
  2017-10-16  7:24 ` [U-Boot] [PATCH 1/2] sf: " Rajat Srivastava
  2017-10-16  7:24 ` [U-Boot] [PATCH 2/2] sf: Fix s25fs512s erase size and remove SECT_4K flag Rajat Srivastava
@ 2017-10-30  6:22 ` Jagan Teki
  2017-10-30  7:15   ` Jagan Teki
  2 siblings, 1 reply; 8+ messages in thread
From: Jagan Teki @ 2017-10-30  6:22 UTC (permalink / raw)
  To: u-boot

On Mon, Oct 16, 2017 at 12:54 PM, Rajat Srivastava
<rajat.srivastava@nxp.com> wrote:
> The S25FS-S family physical sectors may be configured as a hybrid
> combination of eight 4-kB parameter sectors at the top or bottom
> of the address space with all but one of the remaining sectors
> being uniform size. The default status of the flash is the hybrid
> architecture.
>
> Since the parameter sectors and the uniform sectors have different
> erase commands, it is a problem to implement erase functionality for
> hybrid mode in current U-boot code. Also, enabling hybrid mode doesn't
> provide any significant benefit.

I think I've asked this question before, keeping the state of the
flash remains same. Can't erase parameter and uniform sectors
individually during operations like
- parameter sectors with erase commands (20h or 21h)
- uniform sectors with erase commands (D8h or DCh)

thanks!
-- 
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.

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

* [U-Boot] [PATCH 0/2] Disable hybrid mode for SPANSION S25FS-S family
  2017-10-30  6:22 ` [U-Boot] [PATCH 0/2] Disable hybrid mode for SPANSION S25FS-S family Jagan Teki
@ 2017-10-30  7:15   ` Jagan Teki
  2017-10-30 11:53     ` Rajat Srivastava
  0 siblings, 1 reply; 8+ messages in thread
From: Jagan Teki @ 2017-10-30  7:15 UTC (permalink / raw)
  To: u-boot

On Mon, Oct 30, 2017 at 11:52 AM, Jagan Teki <jagannadh.teki@gmail.com> wrote:
> On Mon, Oct 16, 2017 at 12:54 PM, Rajat Srivastava
> <rajat.srivastava@nxp.com> wrote:
>> The S25FS-S family physical sectors may be configured as a hybrid
>> combination of eight 4-kB parameter sectors at the top or bottom
>> of the address space with all but one of the remaining sectors
>> being uniform size. The default status of the flash is the hybrid
>> architecture.
>>
>> Since the parameter sectors and the uniform sectors have different
>> erase commands, it is a problem to implement erase functionality for
>> hybrid mode in current U-boot code. Also, enabling hybrid mode doesn't
>> provide any significant benefit.
>
> I think I've asked this question before, keeping the state of the
> flash remains same. Can't erase parameter and uniform sectors
> individually during operations like
> - parameter sectors with erase commands (20h or 21h)
> - uniform sectors with erase commands (D8h or DCh)

I understand that even we can do parameter and uniform sectors
individually with the help of offsets we still have 224. Any idea why
we need hybrid mode with this off 244 sector size? if require we can
even write cypress on this case.

thanks!
-- 
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.

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

* [U-Boot] [PATCH 0/2] Disable hybrid mode for SPANSION S25FS-S family
  2017-10-30  7:15   ` Jagan Teki
@ 2017-10-30 11:53     ` Rajat Srivastava
  2017-10-31  8:01       ` Jagan Teki
  0 siblings, 1 reply; 8+ messages in thread
From: Rajat Srivastava @ 2017-10-30 11:53 UTC (permalink / raw)
  To: u-boot

> On Mon, Oct 30, 2017 at 11:52 AM, Jagan Teki <jagannadh.teki@gmail.com>
> wrote:
> > On Mon, Oct 16, 2017 at 12:54 PM, Rajat Srivastava
> > <rajat.srivastava@nxp.com> wrote:
> >> The S25FS-S family physical sectors may be configured as a hybrid
> >> combination of eight 4-kB parameter sectors at the top or bottom of
> >> the address space with all but one of the remaining sectors being
> >> uniform size. The default status of the flash is the hybrid
> >> architecture.
> >>
> >> Since the parameter sectors and the uniform sectors have different
> >> erase commands, it is a problem to implement erase functionality for
> >> hybrid mode in current U-boot code. Also, enabling hybrid mode
> >> doesn't provide any significant benefit.
> >
> > I think I've asked this question before, keeping the state of the
> > flash remains same. Can't erase parameter and uniform sectors
> > individually during operations like
> > - parameter sectors with erase commands (20h or 21h)
> > - uniform sectors with erase commands (D8h or DCh)
> 
> I understand that even we can do parameter and uniform sectors individually
> with the help of offsets we still have 224. Any idea why we need hybrid mode
> with this off 244 sector size? if require we can even write cypress on this case.
> 
Hi Jagan

I am not aware of usage of the remaining 244 sector area. We will discuss this with Cypress.

Moreover, do you have any idea where we apply offset based checks in code? And if we do apply checks, will that look good with current Uboot code?
I think no one is going to use hybrid mode and even if someone wants to, they can modify the code.

Thanks
Rajat

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

* [U-Boot] [PATCH 0/2] Disable hybrid mode for SPANSION S25FS-S family
  2017-10-30 11:53     ` Rajat Srivastava
@ 2017-10-31  8:01       ` Jagan Teki
  2017-11-02 12:08         ` Rajat Srivastava
  0 siblings, 1 reply; 8+ messages in thread
From: Jagan Teki @ 2017-10-31  8:01 UTC (permalink / raw)
  To: u-boot

On Mon, Oct 30, 2017 at 5:23 PM, Rajat Srivastava
<rajat.srivastava@nxp.com> wrote:
>> On Mon, Oct 30, 2017 at 11:52 AM, Jagan Teki <jagannadh.teki@gmail.com>
>> wrote:
>> > On Mon, Oct 16, 2017 at 12:54 PM, Rajat Srivastava
>> > <rajat.srivastava@nxp.com> wrote:
>> >> The S25FS-S family physical sectors may be configured as a hybrid
>> >> combination of eight 4-kB parameter sectors at the top or bottom of
>> >> the address space with all but one of the remaining sectors being
>> >> uniform size. The default status of the flash is the hybrid
>> >> architecture.
>> >>
>> >> Since the parameter sectors and the uniform sectors have different
>> >> erase commands, it is a problem to implement erase functionality for
>> >> hybrid mode in current U-boot code. Also, enabling hybrid mode
>> >> doesn't provide any significant benefit.
>> >
>> > I think I've asked this question before, keeping the state of the
>> > flash remains same. Can't erase parameter and uniform sectors
>> > individually during operations like
>> > - parameter sectors with erase commands (20h or 21h)
>> > - uniform sectors with erase commands (D8h or DCh)
>>
>> I understand that even we can do parameter and uniform sectors individually
>> with the help of offsets we still have 224. Any idea why we need hybrid mode
>> with this off 244 sector size? if require we can even write cypress on this case.
>>
> Hi Jagan
>
> I am not aware of usage of the remaining 244 sector area. We will discuss this with Cypress.
>
> Moreover, do you have any idea where we apply offset based checks in code? And if we do apply checks, will that look good with current Uboot code?
> I think no one is going to use hybrid mode and even if someone wants to, they can modify the code.

We can change the erase opcode based on the offsets in erase ops,
since if we disable hybrid now, if someone want to re-enable for
another reason (say some kind of protection PB, not sure) will end-up
conflict. Better we can ask Cypress about this and mean while we can
post this change on spi-nor Linux for further discussion.

thanks!
-- 
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.

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

* [U-Boot] [PATCH 0/2] Disable hybrid mode for SPANSION S25FS-S family
  2017-10-31  8:01       ` Jagan Teki
@ 2017-11-02 12:08         ` Rajat Srivastava
  0 siblings, 0 replies; 8+ messages in thread
From: Rajat Srivastava @ 2017-11-02 12:08 UTC (permalink / raw)
  To: u-boot



> -----Original Message-----
> From: Jagan Teki [mailto:jagannadh.teki at gmail.com]
> Sent: Tuesday, October 31, 2017 1:32 PM
> To: Rajat Srivastava <rajat.srivastava@nxp.com>
> Cc: u-boot at lists.denx.de; York Sun <york.sun@nxp.com>; Suresh Gupta
> <suresh.gupta@nxp.com>
> Subject: Re: [PATCH 0/2] Disable hybrid mode for SPANSION S25FS-S family
> 
> On Mon, Oct 30, 2017 at 5:23 PM, Rajat Srivastava <rajat.srivastava@nxp.com>
> wrote:
> >> On Mon, Oct 30, 2017 at 11:52 AM, Jagan Teki
> >> <jagannadh.teki@gmail.com>
> >> wrote:
> >> > On Mon, Oct 16, 2017 at 12:54 PM, Rajat Srivastava
> >> > <rajat.srivastava@nxp.com> wrote:
> >> >> The S25FS-S family physical sectors may be configured as a hybrid
> >> >> combination of eight 4-kB parameter sectors at the top or bottom
> >> >> of the address space with all but one of the remaining sectors
> >> >> being uniform size. The default status of the flash is the hybrid
> >> >> architecture.
> >> >>
> >> >> Since the parameter sectors and the uniform sectors have different
> >> >> erase commands, it is a problem to implement erase functionality
> >> >> for hybrid mode in current U-boot code. Also, enabling hybrid mode
> >> >> doesn't provide any significant benefit.
> >> >
> >> > I think I've asked this question before, keeping the state of the
> >> > flash remains same. Can't erase parameter and uniform sectors
> >> > individually during operations like
> >> > - parameter sectors with erase commands (20h or 21h)
> >> > - uniform sectors with erase commands (D8h or DCh)
> >>
> >> I understand that even we can do parameter and uniform sectors
> >> individually with the help of offsets we still have 224. Any idea why
> >> we need hybrid mode with this off 244 sector size? if require we can even
> write cypress on this case.
> >>
> > Hi Jagan
> >
> > I am not aware of usage of the remaining 244 sector area. We will discuss this
> with Cypress.
> >
> > Moreover, do you have any idea where we apply offset based checks in code?
> And if we do apply checks, will that look good with current Uboot code?
> > I think no one is going to use hybrid mode and even if someone wants to, they
> can modify the code.
> 
> We can change the erase opcode based on the offsets in erase ops, since if we
> disable hybrid now, if someone want to re-enable for another reason (say some
> kind of protection PB, not sure) will end-up conflict. Better we can ask Cypress
> about this and mean while we can post this change on spi-nor Linux for further
> discussion.
> 
Thanks Jagan. I am working on creating a similar patch in Linux.

Best regards
Rajat

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

end of thread, other threads:[~2017-11-02 12:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-16  7:24 [U-Boot] [PATCH 0/2] Disable hybrid mode for SPANSION S25FS-S family Rajat Srivastava
2017-10-16  7:24 ` [U-Boot] [PATCH 1/2] sf: " Rajat Srivastava
2017-10-16  7:24 ` [U-Boot] [PATCH 2/2] sf: Fix s25fs512s erase size and remove SECT_4K flag Rajat Srivastava
2017-10-30  6:22 ` [U-Boot] [PATCH 0/2] Disable hybrid mode for SPANSION S25FS-S family Jagan Teki
2017-10-30  7:15   ` Jagan Teki
2017-10-30 11:53     ` Rajat Srivastava
2017-10-31  8:01       ` Jagan Teki
2017-11-02 12:08         ` Rajat Srivastava

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.