* [U-Boot] [PATCH] mtd/cfi_flash: fix write problems for Numonyx P33/30 32 MBit flashs
@ 2012-08-08 14:52 Holger Brunck
2012-08-09 6:09 ` Stefan Roese
2012-08-09 8:22 ` [U-Boot] [PATCH v2] " Holger Brunck
0 siblings, 2 replies; 5+ messages in thread
From: Holger Brunck @ 2012-08-08 14:52 UTC (permalink / raw)
To: u-boot
commit 54652991
Work around bug in Numonyx P33/P30 256-Mbit 65nm flash chips
fixes a problem for Numonyx P33/P30 flashes for 256-Mbit, but this leads
to problems for smaller versions of this chip e.g. the 32Mbit version
with deviceid 0x16 on mgcoge. So move the code for this work around to
an own function and check previously manufacturer id and device id to
not break support for other flashes where this work around is not needed.
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Signed-off-by: Heiko Schocher <hs@denx.de>
cc: Stefan Roese <sr@denx.de>
cc: Philippe De Muyter <phdm@macqel.be>
cc: Gerlando Falauto <gerlando.falauto@keymile.com>
---
drivers/mtd/cfi_flash.c | 70 +++++++++++++++++++++++++++++++---------------
1 files changed, 47 insertions(+), 23 deletions(-)
diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 35294bc..690748d 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -1391,6 +1391,43 @@ int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
*/
#ifdef CONFIG_SYS_FLASH_PROTECTION
+#define INTEL_COMPAT 0x89
+#define DEV_ID_NUMONYX_256MBIT 0x8922
+
+static int cfi_protect_bugfix(flash_info_t *info, long sector, int prot)
+{
+ if ((info->manufacturer_id == INTEL_COMPAT) &&
+ (info->device_id == DEV_ID_NUMONYX_256MBIT)) {
+ /*
+ * see errata called
+ * "Numonyx Axcell P33/P30 Specification Update" :)
+ */
+ flash_write_cmd(info, sector, 0, FLASH_CMD_READ_ID);
+ if (!flash_isequal(info, sector, FLASH_OFFSET_PROTECT,
+ prot)) {
+ /*
+ * cmd must come before FLASH_CMD_PROTECT + 20us
+ * Disable interrupts which might cause a timeout here.
+ */
+ int flag = disable_interrupts();
+ unsigned short cmd;
+
+ if (prot)
+ cmd = FLASH_CMD_PROTECT_SET;
+ else
+ cmd = FLASH_CMD_PROTECT_CLEAR;
+ flash_write_cmd(info, sector, 0,
+ FLASH_CMD_PROTECT);
+ flash_write_cmd(info, sector, 0, cmd);
+ /* re-enable interrupts if necessary */
+ if (flag)
+ enable_interrupts();
+ }
+ return 1;
+ }
+ return 0;
+}
+
int flash_real_protect (flash_info_t * info, long sector, int prot)
{
int retcode = 0;
@@ -1399,31 +1436,18 @@ int flash_real_protect (flash_info_t * info, long sector, int prot)
case CFI_CMDSET_INTEL_PROG_REGIONS:
case CFI_CMDSET_INTEL_STANDARD:
case CFI_CMDSET_INTEL_EXTENDED:
- /*
- * see errata called
- * "Numonyx Axcell P33/P30 Specification Update" :)
- */
- flash_write_cmd (info, sector, 0, FLASH_CMD_READ_ID);
- if (!flash_isequal (info, sector, FLASH_OFFSET_PROTECT,
- prot)) {
- /*
- * cmd must come before FLASH_CMD_PROTECT + 20us
- * Disable interrupts which might cause a timeout here.
- */
- int flag = disable_interrupts ();
- unsigned short cmd;
-
+ if (!cfi_protect_bugfix(info, sector, prot)) {
+ flash_write_cmd(info, sector, 0,
+ FLASH_CMD_CLEAR_STATUS);
+ flash_write_cmd(info, sector, 0,
+ FLASH_CMD_PROTECT);
if (prot)
- cmd = FLASH_CMD_PROTECT_SET;
+ flash_write_cmd(info, sector, 0,
+ FLASH_CMD_PROTECT_SET);
else
- cmd = FLASH_CMD_PROTECT_CLEAR;
-
- flash_write_cmd (info, sector, 0,
- FLASH_CMD_PROTECT);
- flash_write_cmd (info, sector, 0, cmd);
- /* re-enable interrupts if necessary */
- if (flag)
- enable_interrupts ();
+ flash_write_cmd(info, sector, 0,
+ FLASH_CMD_PROTECT_CLEAR);
+
}
break;
case CFI_CMDSET_AMD_EXTENDED:
--
1.7.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH] mtd/cfi_flash: fix write problems for Numonyx P33/30 32 MBit flashs
2012-08-08 14:52 [U-Boot] [PATCH] mtd/cfi_flash: fix write problems for Numonyx P33/30 32 MBit flashs Holger Brunck
@ 2012-08-09 6:09 ` Stefan Roese
2012-08-09 7:57 ` Holger Brunck
2012-08-09 8:22 ` [U-Boot] [PATCH v2] " Holger Brunck
1 sibling, 1 reply; 5+ messages in thread
From: Stefan Roese @ 2012-08-09 6:09 UTC (permalink / raw)
To: u-boot
Hi Holger,
thanks for this patch. I do have a minor comment though below.
On 08/08/2012 04:52 PM, Holger Brunck wrote:
> commit 54652991
> Work around bug in Numonyx P33/P30 256-Mbit 65nm flash chips
>
> fixes a problem for Numonyx P33/P30 flashes for 256-Mbit, but this leads
> to problems for smaller versions of this chip e.g. the 32Mbit version
> with deviceid 0x16 on mgcoge. So move the code for this work around to
> an own function and check previously manufacturer id and device id to
> not break support for other flashes where this work around is not needed.
>
> Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
> Signed-off-by: Heiko Schocher <hs@denx.de>
> cc: Stefan Roese <sr@denx.de>
> cc: Philippe De Muyter <phdm@macqel.be>
> cc: Gerlando Falauto <gerlando.falauto@keymile.com>
> ---
> drivers/mtd/cfi_flash.c | 70 +++++++++++++++++++++++++++++++---------------
> 1 files changed, 47 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
> index 35294bc..690748d 100644
> --- a/drivers/mtd/cfi_flash.c
> +++ b/drivers/mtd/cfi_flash.c
> @@ -1391,6 +1391,43 @@ int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
> */
> #ifdef CONFIG_SYS_FLASH_PROTECTION
>
> +#define INTEL_COMPAT 0x89
> +#define DEV_ID_NUMONYX_256MBIT 0x8922
Adding defines in the middle of the source is frowned upon.
Why don't you use INTEL_MANUFACT from flash.h instead. And add the
device id in this header as well? I would prefer this.
Thanks,
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH] mtd/cfi_flash: fix write problems for Numonyx P33/30 32 MBit flashs
2012-08-09 6:09 ` Stefan Roese
@ 2012-08-09 7:57 ` Holger Brunck
0 siblings, 0 replies; 5+ messages in thread
From: Holger Brunck @ 2012-08-09 7:57 UTC (permalink / raw)
To: u-boot
Hi Stefan,
On 08/09/2012 08:09 AM, Stefan Roese wrote:
> On 08/08/2012 04:52 PM, Holger Brunck wrote:
>> commit 54652991
>> Work around bug in Numonyx P33/P30 256-Mbit 65nm flash chips
>>
>> fixes a problem for Numonyx P33/P30 flashes for 256-Mbit, but this leads
>> to problems for smaller versions of this chip e.g. the 32Mbit version
>> with deviceid 0x16 on mgcoge. So move the code for this work around to
>> an own function and check previously manufacturer id and device id to
>> not break support for other flashes where this work around is not needed.
>>
>> Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
>> Signed-off-by: Heiko Schocher <hs@denx.de>
>> cc: Stefan Roese <sr@denx.de>
>> cc: Philippe De Muyter <phdm@macqel.be>
>> cc: Gerlando Falauto <gerlando.falauto@keymile.com>
>> ---
>> drivers/mtd/cfi_flash.c | 70 +++++++++++++++++++++++++++++++---------------
>> 1 files changed, 47 insertions(+), 23 deletions(-)
>>
>> diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
>> index 35294bc..690748d 100644
>> --- a/drivers/mtd/cfi_flash.c
>> +++ b/drivers/mtd/cfi_flash.c
>> @@ -1391,6 +1391,43 @@ int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
>> */
>> #ifdef CONFIG_SYS_FLASH_PROTECTION
>>
>> +#define INTEL_COMPAT 0x89
>> +#define DEV_ID_NUMONYX_256MBIT 0x8922
>
> Adding defines in the middle of the source is frowned upon.
>
> Why don't you use INTEL_MANUFACT from flash.h instead. And add the
> device id in this header as well? I would prefer this.
>
agreed, I'll prepare a v2. Thanks.
Regards
Holger
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH v2] mtd/cfi_flash: fix write problems for Numonyx P33/30 32 MBit flashs
2012-08-08 14:52 [U-Boot] [PATCH] mtd/cfi_flash: fix write problems for Numonyx P33/30 32 MBit flashs Holger Brunck
2012-08-09 6:09 ` Stefan Roese
@ 2012-08-09 8:22 ` Holger Brunck
2012-08-13 12:47 ` Stefan Roese
1 sibling, 1 reply; 5+ messages in thread
From: Holger Brunck @ 2012-08-09 8:22 UTC (permalink / raw)
To: u-boot
commit 54652991
Work around bug in Numonyx P33/P30 256-Mbit 65nm flash chips
fixes a problem for Numonyx P33/P30 flashes for 256-Mbit, but this leads
to problems for smaller versions of this chip e.g. the 32Mbit version
with deviceid 0x16 on mgcoge. So move the code for this work around to
an own function and check previously manufacturer id and device id to
not break other flashes which don't need this work around.
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Signed-off-by: Heiko Schocher <hs@denx.de>
cc: Stefan Roese <sr@denx.de>
cc: Philippe De Muyter <phdm@macqel.be>
cc: Gerlando Falauto <gerlando.falauto@keymile.com>
---
changes for v2:
- use existing INTEL_MANUFACT from flash.h and add device id for NUMONYX_256MBIT
drivers/mtd/cfi_flash.c | 67 ++++++++++++++++++++++++++++++----------------
include/flash.h | 1 +
2 files changed, 45 insertions(+), 23 deletions(-)
diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 35294bc..75acaf6 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -1391,6 +1391,40 @@ int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
*/
#ifdef CONFIG_SYS_FLASH_PROTECTION
+static int cfi_protect_bugfix(flash_info_t *info, long sector, int prot)
+{
+ if ((info->manufacturer_id == (uchar)INTEL_MANUFACT) &&
+ (info->device_id == NUMONYX_256MBIT)) {
+ /*
+ * see errata called
+ * "Numonyx Axcell P33/P30 Specification Update" :)
+ */
+ flash_write_cmd(info, sector, 0, FLASH_CMD_READ_ID);
+ if (!flash_isequal(info, sector, FLASH_OFFSET_PROTECT,
+ prot)) {
+ /*
+ * cmd must come before FLASH_CMD_PROTECT + 20us
+ * Disable interrupts which might cause a timeout here.
+ */
+ int flag = disable_interrupts();
+ unsigned short cmd;
+
+ if (prot)
+ cmd = FLASH_CMD_PROTECT_SET;
+ else
+ cmd = FLASH_CMD_PROTECT_CLEAR;
+ flash_write_cmd(info, sector, 0,
+ FLASH_CMD_PROTECT);
+ flash_write_cmd(info, sector, 0, cmd);
+ /* re-enable interrupts if necessary */
+ if (flag)
+ enable_interrupts();
+ }
+ return 1;
+ }
+ return 0;
+}
+
int flash_real_protect (flash_info_t * info, long sector, int prot)
{
int retcode = 0;
@@ -1399,31 +1433,18 @@ int flash_real_protect (flash_info_t * info, long sector, int prot)
case CFI_CMDSET_INTEL_PROG_REGIONS:
case CFI_CMDSET_INTEL_STANDARD:
case CFI_CMDSET_INTEL_EXTENDED:
- /*
- * see errata called
- * "Numonyx Axcell P33/P30 Specification Update" :)
- */
- flash_write_cmd (info, sector, 0, FLASH_CMD_READ_ID);
- if (!flash_isequal (info, sector, FLASH_OFFSET_PROTECT,
- prot)) {
- /*
- * cmd must come before FLASH_CMD_PROTECT + 20us
- * Disable interrupts which might cause a timeout here.
- */
- int flag = disable_interrupts ();
- unsigned short cmd;
-
+ if (!cfi_protect_bugfix(info, sector, prot)) {
+ flash_write_cmd(info, sector, 0,
+ FLASH_CMD_CLEAR_STATUS);
+ flash_write_cmd(info, sector, 0,
+ FLASH_CMD_PROTECT);
if (prot)
- cmd = FLASH_CMD_PROTECT_SET;
+ flash_write_cmd(info, sector, 0,
+ FLASH_CMD_PROTECT_SET);
else
- cmd = FLASH_CMD_PROTECT_CLEAR;
-
- flash_write_cmd (info, sector, 0,
- FLASH_CMD_PROTECT);
- flash_write_cmd (info, sector, 0, cmd);
- /* re-enable interrupts if necessary */
- if (flag)
- enable_interrupts ();
+ flash_write_cmd(info, sector, 0,
+ FLASH_CMD_PROTECT_CLEAR);
+
}
break;
case CFI_CMDSET_AMD_EXTENDED:
diff --git a/include/flash.h b/include/flash.h
index 0ca70d9..e614d07 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -348,6 +348,7 @@ extern flash_info_t *flash_get_info(ulong base);
#define TOSH_ID_FVT160 0xC2 /* TC58FVT160 ID (16 M, top ) */
#define TOSH_ID_FVB160 0x43 /* TC58FVT160 ID (16 M, bottom ) */
#define PHILIPS_LPC2292 0x0401FF13 /* LPC2292 internal FLASH */
+#define NUMONYX_256MBIT 0x8922 /* Numonyx P33/30 256MBit 65nm */
/*-----------------------------------------------------------------------
* Internal FLASH identification codes
--
1.7.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH v2] mtd/cfi_flash: fix write problems for Numonyx P33/30 32 MBit flashs
2012-08-09 8:22 ` [U-Boot] [PATCH v2] " Holger Brunck
@ 2012-08-13 12:47 ` Stefan Roese
0 siblings, 0 replies; 5+ messages in thread
From: Stefan Roese @ 2012-08-13 12:47 UTC (permalink / raw)
To: u-boot
On 08/09/2012 10:22 AM, Holger Brunck wrote:
> commit 54652991
> Work around bug in Numonyx P33/P30 256-Mbit 65nm flash chips
>
> fixes a problem for Numonyx P33/P30 flashes for 256-Mbit, but this leads
> to problems for smaller versions of this chip e.g. the 32Mbit version
> with deviceid 0x16 on mgcoge. So move the code for this work around to
> an own function and check previously manufacturer id and device id to
> not break other flashes which don't need this work around.
>
> Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
> Signed-off-by: Heiko Schocher <hs@denx.de>
> cc: Stefan Roese <sr@denx.de>
> cc: Philippe De Muyter <phdm@macqel.be>
> cc: Gerlando Falauto <gerlando.falauto@keymile.com>
Applied to u-boot-cfi-flash/master. Thanks.
Best regards,
Stefan
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-08-13 12:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-08 14:52 [U-Boot] [PATCH] mtd/cfi_flash: fix write problems for Numonyx P33/30 32 MBit flashs Holger Brunck
2012-08-09 6:09 ` Stefan Roese
2012-08-09 7:57 ` Holger Brunck
2012-08-09 8:22 ` [U-Boot] [PATCH v2] " Holger Brunck
2012-08-13 12:47 ` Stefan Roese
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox