All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] Fixing spi erase for S25FL128P_256K
@ 2010-08-10 13:02 Marc-André Hébert
  2010-08-10 13:14 ` Sergei Shtylyov
  2010-08-23 21:37 ` [U-Boot] [PATCH] " Mike Frysinger
  0 siblings, 2 replies; 8+ messages in thread
From: Marc-André Hébert @ 2010-08-10 13:02 UTC (permalink / raw)
  To: u-boot

The spansion_erase currently only works when the sector size is 64KB.
cmd[1] should contain the higher 8 bit of the 24 bit address of the
sector to be erased. Currently it is holding the sector index to be
erased which happens to be the same thing when the sector size is
64KB.

Signed-off-by: Marc-Andre Hebert <marc-andre.hebert@humanware.com>
---
 drivers/mtd/spi/spansion.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/spi/spansion.c b/drivers/mtd/spi/spansion.c
index d6c1a5f..94489af 100644
--- a/drivers/mtd/spi/spansion.c
+++ b/drivers/mtd/spi/spansion.c
@@ -262,7 +262,6 @@ int spansion_erase(struct spi_flash *flash, u32
offset, size_t len)
 		return -1;
 	}

-	len /= sector_size;
 	cmd[0] = CMD_S25FLXX_SE;
 	cmd[2] = 0x00;
 	cmd[3] = 0x00;
@@ -274,8 +273,8 @@ int spansion_erase(struct spi_flash *flash, u32
offset, size_t len)
 	}

 	ret = 0;
-	for (actual = 0; actual < len; actual++) {
-		cmd[1] = (offset / sector_size) + actual;
+	for (actual = 0; actual < len; actual+=sector_size) {
+		cmd[1] = (offset + actual) >> 16;

 		ret = spi_flash_cmd(flash->spi, CMD_S25FLXX_WREN, NULL, 0);
 		if (ret < 0) {
@@ -298,7 +297,7 @@ int spansion_erase(struct spi_flash *flash, u32
offset, size_t len)
 	}

 	debug("SF: SPANSION: Successfully erased %u bytes @ 0x%x\n",
-	      len * sector_size, offset);
+	      len, offset);

 	spi_release_bus(flash->spi);
 	return ret;
-- 
1.6.0.4

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

* [U-Boot] [PATCH] Fixing spi erase for S25FL128P_256K
  2010-08-10 13:02 [U-Boot] [PATCH] Fixing spi erase for S25FL128P_256K Marc-André Hébert
@ 2010-08-10 13:14 ` Sergei Shtylyov
  2010-08-10 13:35   ` [U-Boot] [PATCH v2] " Marc-André Hébert
  2010-08-23 21:37 ` [U-Boot] [PATCH] " Mike Frysinger
  1 sibling, 1 reply; 8+ messages in thread
From: Sergei Shtylyov @ 2010-08-10 13:14 UTC (permalink / raw)
  To: u-boot

Hello.

Marc-Andr? H?bert wrote:

> The spansion_erase currently only works when the sector size is 64KB.
> cmd[1] should contain the higher 8 bit of the 24 bit address of the
> sector to be erased. Currently it is holding the sector index to be
> erased which happens to be the same thing when the sector size is
> 64KB.

> Signed-off-by: Marc-Andre Hebert <marc-andre.hebert@humanware.com>
> ---
>  drivers/mtd/spi/spansion.c |    7 +++----
>  1 files changed, 3 insertions(+), 4 deletions(-)

> diff --git a/drivers/mtd/spi/spansion.c b/drivers/mtd/spi/spansion.c
> index d6c1a5f..94489af 100644
> --- a/drivers/mtd/spi/spansion.c
> +++ b/drivers/mtd/spi/spansion.c
[...]
> @@ -274,8 +273,8 @@ int spansion_erase(struct spi_flash *flash, u32
> offset, size_t len)
>  	}
> 
>  	ret = 0;
> -	for (actual = 0; actual < len; actual++) {
> -		cmd[1] = (offset / sector_size) + actual;
> +	for (actual = 0; actual < len; actual+=sector_size) {

    Keep the  coding style consistent please -- add spaces around +=.

WBR, Sergei

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

* [U-Boot] [PATCH v2] Fixing spi erase for S25FL128P_256K
  2010-08-10 13:14 ` Sergei Shtylyov
@ 2010-08-10 13:35   ` Marc-André Hébert
  2010-08-10 20:55     ` Mike Frysinger
  0 siblings, 1 reply; 8+ messages in thread
From: Marc-André Hébert @ 2010-08-10 13:35 UTC (permalink / raw)
  To: u-boot

The spansion_erase currently only works when the sector size is 64KB.
cmd[1] should contain the higher 8 bit of the 24 bit address of the
sector to be erased. Currently it is holding the sector index to be
erased which happens to be the same thing when the sector size is
64KB.

Signed-off-by: Marc-Andre Hebert <marc-andre.hebert@humanware.com>
---
 drivers/mtd/spi/spansion.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/spi/spansion.c b/drivers/mtd/spi/spansion.c
index d6c1a5f..94489af 100644
--- a/drivers/mtd/spi/spansion.c
+++ b/drivers/mtd/spi/spansion.c
@@ -262,7 +262,6 @@ int spansion_erase(struct spi_flash *flash, u32
offset, size_t len)
 		return -1;
 	}

-	len /= sector_size;
 	cmd[0] = CMD_S25FLXX_SE;
 	cmd[2] = 0x00;
 	cmd[3] = 0x00;
@@ -274,8 +273,8 @@ int spansion_erase(struct spi_flash *flash, u32
offset, size_t len)
 	}

 	ret = 0;
-	for (actual = 0; actual < len; actual++) {
-		cmd[1] = (offset / sector_size) + actual;
+	for (actual = 0; actual < len; actual += sector_size) {
+		cmd[1] = (offset + actual) >> 16;

 		ret = spi_flash_cmd(flash->spi, CMD_S25FLXX_WREN, NULL, 0);
 		if (ret < 0) {
@@ -298,7 +297,7 @@ int spansion_erase(struct spi_flash *flash, u32
offset, size_t len)
 	}

 	debug("SF: SPANSION: Successfully erased %u bytes @ 0x%x\n",
-	      len * sector_size, offset);
+	      len, offset);

 	spi_release_bus(flash->spi);
 	return ret;
-- 
1.6.0.4

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

* [U-Boot] [PATCH v2] Fixing spi erase for S25FL128P_256K
  2010-08-10 13:35   ` [U-Boot] [PATCH v2] " Marc-André Hébert
@ 2010-08-10 20:55     ` Mike Frysinger
  2010-08-11 11:23       ` Marc-André Hébert
  0 siblings, 1 reply; 8+ messages in thread
From: Mike Frysinger @ 2010-08-10 20:55 UTC (permalink / raw)
  To: u-boot

2010/8/10 Marc-Andr? H?bert:
> The spansion_erase currently only works when the sector size is 64KB.
> cmd[1] should contain the higher 8 bit of the 24 bit address of the
> sector to be erased. Currently it is holding the sector index to be
> erased which happens to be the same thing when the sector size is
> 64KB.

ugh, this is why the current sf framework annoys me.  so much
duplication across drivers including bugs.

> --- a/drivers/mtd/spi/spansion.c
> +++ b/drivers/mtd/spi/spansion.c
> @@ -274,8 +273,8 @@ int spansion_erase(struct spi_flash *flash, u32
> offset, size_t len)
> ? ? ? ?}
>
> ? ? ? ?ret = 0;
> - ? ? ? for (actual = 0; actual < len; actual++) {
> - ? ? ? ? ? ? ? cmd[1] = (offset / sector_size) + actual;
> + ? ? ? for (actual = 0; actual < len; actual += sector_size) {
> + ? ? ? ? ? ? ? cmd[1] = (offset + actual) >> 16;

how about the bug fix that went into stmicro:
-       cmd[1] = (offset / sector_size) + actual;
+       cmd[1] = offset >> 16;
+       offset += sector_size;
-mike

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

* [U-Boot] [PATCH v2] Fixing spi erase for S25FL128P_256K
  2010-08-10 20:55     ` Mike Frysinger
@ 2010-08-11 11:23       ` Marc-André Hébert
  2010-08-11 17:01         ` Mike Frysinger
  0 siblings, 1 reply; 8+ messages in thread
From: Marc-André Hébert @ 2010-08-11 11:23 UTC (permalink / raw)
  To: u-boot

2010/8/10 Mike Frysinger <vapier@gentoo.org>:
> 2010/8/10 Marc-Andr? H?bert:
>> The spansion_erase currently only works when the sector size is 64KB.
>> cmd[1] should contain the higher 8 bit of the 24 bit address of the
>> sector to be erased. Currently it is holding the sector index to be
>> erased which happens to be the same thing when the sector size is
>> 64KB.
>
> ugh, this is why the current sf framework annoys me. ?so much
> duplication across drivers including bugs.
>
>> --- a/drivers/mtd/spi/spansion.c
>> +++ b/drivers/mtd/spi/spansion.c
>> @@ -274,8 +273,8 @@ int spansion_erase(struct spi_flash *flash, u32
>> offset, size_t len)
>> ? ? ? ?}
>>
>> ? ? ? ?ret = 0;
>> - ? ? ? for (actual = 0; actual < len; actual++) {
>> - ? ? ? ? ? ? ? cmd[1] = (offset / sector_size) + actual;
>> + ? ? ? for (actual = 0; actual < len; actual += sector_size) {
>> + ? ? ? ? ? ? ? cmd[1] = (offset + actual) >> 16;
>
> how about the bug fix that went into stmicro:
> - ? ? ? cmd[1] = (offset / sector_size) + actual;
> + ? ? ? cmd[1] = offset >> 16;
> + ? ? ? offset += sector_size;
> -mike
>
Yeah I saw how stmicro did it, but I didn't do it that way simply
because modifying the offset invalidates the debug statement
afterwards:

debug("SF: SPANSION: Successfully erased %u bytes @ 0x%x\n",
	      len, offset);
Marc

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

* [U-Boot] [PATCH v2] Fixing spi erase for S25FL128P_256K
  2010-08-11 11:23       ` Marc-André Hébert
@ 2010-08-11 17:01         ` Mike Frysinger
  0 siblings, 0 replies; 8+ messages in thread
From: Mike Frysinger @ 2010-08-11 17:01 UTC (permalink / raw)
  To: u-boot

2010/8/11 Marc-Andr? H?bert :
> 2010/8/10 Mike Frysinger:
>> 2010/8/10 Marc-Andr? H?bert:
>>> The spansion_erase currently only works when the sector size is 64KB.
>>> cmd[1] should contain the higher 8 bit of the 24 bit address of the
>>> sector to be erased. Currently it is holding the sector index to be
>>> erased which happens to be the same thing when the sector size is
>>> 64KB.
>>
>> ugh, this is why the current sf framework annoys me. ?so much
>> duplication across drivers including bugs.
>>
>>> --- a/drivers/mtd/spi/spansion.c
>>> +++ b/drivers/mtd/spi/spansion.c
>>> @@ -274,8 +273,8 @@ int spansion_erase(struct spi_flash *flash, u32
>>> offset, size_t len)
>>> ? ? ? ?}
>>>
>>> ? ? ? ?ret = 0;
>>> - ? ? ? for (actual = 0; actual < len; actual++) {
>>> - ? ? ? ? ? ? ? cmd[1] = (offset / sector_size) + actual;
>>> + ? ? ? for (actual = 0; actual < len; actual += sector_size) {
>>> + ? ? ? ? ? ? ? cmd[1] = (offset + actual) >> 16;
>>
>> how about the bug fix that went into stmicro:
>> - ? ? ? cmd[1] = (offset / sector_size) + actual;
>> + ? ? ? cmd[1] = offset >> 16;
>> + ? ? ? offset += sector_size;
>
> Yeah I saw how stmicro did it, but I didn't do it that way simply
> because modifying the offset invalidates the debug statement
> afterwards:
>
> debug("SF: SPANSION: Successfully erased %u bytes @ 0x%x\n",
> ? ? ? ? ? ? ?len, offset);

and this just reinforces my point.  you're basically saying the
stmicro flash code has a broken debug() statement now.
-mike

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

* [U-Boot] [PATCH] Fixing spi erase for S25FL128P_256K
  2010-08-10 13:02 [U-Boot] [PATCH] Fixing spi erase for S25FL128P_256K Marc-André Hébert
  2010-08-10 13:14 ` Sergei Shtylyov
@ 2010-08-23 21:37 ` Mike Frysinger
  2010-08-23 22:08   ` Mike Frysinger
  1 sibling, 1 reply; 8+ messages in thread
From: Mike Frysinger @ 2010-08-23 21:37 UTC (permalink / raw)
  To: u-boot

On Tuesday, August 10, 2010 09:02:09 Marc-Andr? H?bert wrote:
> @@ -262,7 +262,6 @@ int spansion_erase(struct spi_flash *flash, u32
> offset, size_t len)
>  		return -1;

seems your mailer too is broken.  please use `git send-email` when posting 
patches so they dont get screwed up.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100823/3e3a828e/attachment.pgp 

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

* [U-Boot] [PATCH] Fixing spi erase for S25FL128P_256K
  2010-08-23 21:37 ` [U-Boot] [PATCH] " Mike Frysinger
@ 2010-08-23 22:08   ` Mike Frysinger
  0 siblings, 0 replies; 8+ messages in thread
From: Mike Frysinger @ 2010-08-23 22:08 UTC (permalink / raw)
  To: u-boot

On Monday, August 23, 2010 17:37:44 Mike Frysinger wrote:
> On Tuesday, August 10, 2010 09:02:09 Marc-Andr? H?bert wrote:
> > @@ -262,7 +262,6 @@ int spansion_erase(struct spi_flash *flash, u32
> > offset, size_t len)
> > 
> >  		return -1;
> 
> seems your mailer too is broken.  please use `git send-email` when posting
> patches so they dont get screwed up.

although i fixed up the commit and merged it manually.  but you only get one 
pass, so next time i'll wait for a proper resend :P.

this is in my sf branch so it wont get lost
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100823/ea213bad/attachment.pgp 

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

end of thread, other threads:[~2010-08-23 22:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-10 13:02 [U-Boot] [PATCH] Fixing spi erase for S25FL128P_256K Marc-André Hébert
2010-08-10 13:14 ` Sergei Shtylyov
2010-08-10 13:35   ` [U-Boot] [PATCH v2] " Marc-André Hébert
2010-08-10 20:55     ` Mike Frysinger
2010-08-11 11:23       ` Marc-André Hébert
2010-08-11 17:01         ` Mike Frysinger
2010-08-23 21:37 ` [U-Boot] [PATCH] " Mike Frysinger
2010-08-23 22:08   ` Mike Frysinger

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.