* [PATCH][MTD] cfi_cmdset_0002.c: Add Macronix CFI V1.0 TopBottom detection
@ 2008-10-09 21:55 Christopher Moore
2008-10-14 10:09 ` David Woodhouse
0 siblings, 1 reply; 5+ messages in thread
From: Christopher Moore @ 2008-10-09 21:55 UTC (permalink / raw)
To: linux-mtd
This patch adds TopBottom detection for most Macronix chips with CFI
V1.0.
The main purpose of this patch is to add detection of the MX29LV400C B
used on the LaCie Ethernet Disk mini V2 NAS.
It detects the following parts correctly:-
MX28F640C3B T
MX29LV002C B
MX29LV002NC B
MX29LV004C T
MX29LV400C T/B
MX29LV800C T/B
MX29LV160C T/B
MX29SL800C T/B
MX29SL802C T/B
It detects the following uniform part as bottom but it should work
correctly:-
MX29LV040C
For T parts it correctly reverses the erase block table.
For other parts it avoids the bogus "Assuming top." message.
It does not detect the following correctly:-
MX28F640C3B B
MX29LV002C T
MX29LV002NC T
MX29LV004C B
MX29SL400C T/B
MX29SL402C T/B
If desired I could supply a more complicated patch to handle these as
well.
Only the MX29LV400C B has been physically tested; others were checked
against their data sheets.
Signed-off-by: Christopher Moore <moore@free.fr>
---
drivers/mtd/chips/cfi_cmdset_0002.c | 36
+++++++++++++++++++++++++++++++++++
1 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c
b/drivers/mtd/chips/cfi_cmdset_0002.c
index a972cc6..db16b7b 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -13,6 +13,8 @@
* XIP support hooks by Vitaly Wool (based on code for Intel flash
* by Nicolas Pitre)
*
+ * 25/09/2008 Christopher Moore: TopBottom fixup for many Macronix with
CFI V1.0
+ *
* Occasionally maintained by Thayne Harbaugh tharbaugh at lnxi dot com
*
* This code is GPL
@@ -43,6 +45,7 @@
#define MANUFACTURER_AMD 0x0001
#define MANUFACTURER_ATMEL 0x001F
+#define MANUFACTURER_MACRONIX 0x00C2
#define MANUFACTURER_SST 0x00BF
#define SST49LF004B 0x0060
#define SST49LF040B 0x0050
@@ -144,12 +147,44 @@ static void fixup_amd_bootblock(struct mtd_info
*mtd, void* param)
if (((major << 8) | minor) < 0x3131) {
/* CFI version 1.0 => don't trust bootloc */
+
+ DEBUG(MTD_DEBUG_LEVEL1,
+ "%s: JEDEC Vendor ID is 0x%02X Device ID is 0x%02X\n",
+ map->name, cfi->mfr, cfi->id);
+
+ /* AFAICS all 29LV400 with a bottom boot block have a device ID
+ * of 0x22BA in 16-bit mode and 0xBA in 8-bit mode.
+ * These were badly detected as they have the 0x80 bit set
+ * so treat them as a special case.
+ */
+ if (((cfi->id == 0xBA) || (cfi->id == 0x22BA)) &&
+
+ /* Macronix added CFI to their 2nd generation
+ * MX29LV400C B/T but AFAICS no other 29LV400 (AMD,
+ * Fujitsu, Spansion, EON, ESI and older Macronix)
+ * has CFI.
+ *
+ * Therefore also check the manufacturer.
+ * This reduces the risk of false detection due to
+ * the 8-bit device ID.
+ */
+ (cfi->mfr == MANUFACTURER_MACRONIX)) {
+ DEBUG(MTD_DEBUG_LEVEL1,
+ "%s: Macronix MX29LV400C with bottom boot block"
+ " detected\n", map->name);
+ extp->TopBottom = 2; /* bottom boot */
+ } else
if (cfi->id & 0x80) {
printk(KERN_WARNING "%s: JEDEC Device ID is 0x%02X. Assuming broken
CFI table.\n", map->name, cfi->id);
extp->TopBottom = 3; /* top boot */
} else {
extp->TopBottom = 2; /* bottom boot */
}
+
+ DEBUG(MTD_DEBUG_LEVEL1,
+ "%s: AMD CFI PRI V%c.%c has no boot block field;"
+ " deduced %s from Device ID\n", map->name, major, minor,
+ extp->TopBottom == 2 ? "bottom" : "top");
}
}
#endif
@@ -243,6 +278,7 @@ static struct cfi_fixup cfi_fixup_table[] = {
{ CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL },
#ifdef AMD_BOOTLOC_BUG
{ CFI_MFR_AMD, CFI_ID_ANY, fixup_amd_bootblock, NULL },
+ { MANUFACTURER_MACRONIX, CFI_ID_ANY, fixup_amd_bootblock, NULL },
#endif
{ CFI_MFR_AMD, 0x0050, fixup_use_secsi, NULL, },
{ CFI_MFR_AMD, 0x0053, fixup_use_secsi, NULL, },
--
1.5.2.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH][MTD] cfi_cmdset_0002.c: Add Macronix CFI V1.0 TopBottom detection
2008-10-09 21:55 [PATCH][MTD] cfi_cmdset_0002.c: Add Macronix CFI V1.0 TopBottom detection Christopher Moore
@ 2008-10-14 10:09 ` David Woodhouse
2008-10-17 2:39 ` Chris Moore
0 siblings, 1 reply; 5+ messages in thread
From: David Woodhouse @ 2008-10-14 10:09 UTC (permalink / raw)
To: Christopher Moore; +Cc: linux-mtd
On Thu, 2008-10-09 at 23:55 +0200, Christopher Moore wrote:
> This patch adds TopBottom detection for most Macronix chips with CFI
> V1.0.
patching file drivers/mtd/chips/cfi_cmdset_0002.c
patch: **** malformed patch at line 101: CFI V1.0
Did you not test this after you received it back from the list?
--
David Woodhouse Open Source Technology Centre
David.Woodhouse@intel.com Intel Corporation
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH][MTD] cfi_cmdset_0002.c: Add Macronix CFI V1.0 TopBottom detection
2008-10-14 10:09 ` David Woodhouse
@ 2008-10-17 2:39 ` Chris Moore
2008-10-17 3:32 ` [PATCH] [MTD] [NOR] " Christopher Moore
0 siblings, 1 reply; 5+ messages in thread
From: Chris Moore @ 2008-10-17 2:39 UTC (permalink / raw)
To: David Woodhouse; +Cc: linux-mtd
David Woodhouse a écrit :
> On Thu, 2008-10-09 at 23:55 +0200, Christopher Moore wrote:
>
>> This patch adds TopBottom detection for most Macronix chips with CFI
>> V1.0.
>>
>
> patching file drivers/mtd/chips/cfi_cmdset_0002.c
> patch: **** malformed patch at line 101: CFI V1.0
>
> Did you not test this after you received it back from the list?
>
(Wiping egg off face) Please accept my apologies; I am afraid that the
line must have been wrapped by the mailer I used :(
I ran checkpatch.pl on the patch before sending it.
I even sent the patch to myself first.
The worst is that I did notice that some lines were wrapped to about 72
columns.
However as I had previously used the same mailer to send patches to
other people and to the LAK mailing list without problems, I figured
that the wrapping was happening at the receiving end.
With the intention of improving the presentation for others using the
same mailer, I even modified the commit comment part, which I had
written in 80 columns, down to 72 columns and tried again.
I have now experimented with "git send-email" and the result seems clean
so I shall use this in the future. The only thing that I am now worried
about is getting the headers right so that I do not break the thread.
I shall try sending the patch again later and I apologize in advance in
case it breaks the thread :(
Sorry again for wasting your time.
Cheers,
Chris
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] [MTD] [NOR] cfi_cmdset_0002.c: Add Macronix CFI V1.0 TopBottom detection
2008-10-17 2:39 ` Chris Moore
@ 2008-10-17 3:32 ` Christopher Moore
2008-10-18 11:42 ` David Woodhouse
0 siblings, 1 reply; 5+ messages in thread
From: Christopher Moore @ 2008-10-17 3:32 UTC (permalink / raw)
To: linux-mtd; +Cc: Christopher Moore
This patch adds TopBottom detection for most Macronix chips with CFI
V1.0.
The main purpose of this patch is to add detection of the MX29LV400C B
used on the LaCie Ethernet Disk mini V2 NAS.
It detects the following parts correctly:-
MX28F640C3B T
MX29LV002C B
MX29LV002NC B
MX29LV004C T
MX29LV400C T/B
MX29LV800C T/B
MX29LV160C T/B
MX29SL800C T/B
MX29SL802C T/B
It detects the following uniform part as bottom but it should work
correctly:-
MX29LV040C
For T parts it causes the erase block table to be reversed correctly.
For other parts it avoids the bogus "Assuming top" message.
It does not detect the following correctly:-
MX28F640C3B B
MX29LV002C T
MX29LV002NC T
MX29LV004C B
MX29SL400C T/B
MX29SL402C T/B
If desired I could supply a more complicated patch to handle these as
well.
Only the MX29LV400C B has been physically tested; others were checked
against their data sheets.
Signed-off-by: Christopher Moore <moore@free.fr>
---
drivers/mtd/chips/cfi_cmdset_0002.c | 36 +++++++++++++++++++++++++++++++++++
1 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
index a972cc6..db16b7b 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -13,6 +13,8 @@
* XIP support hooks by Vitaly Wool (based on code for Intel flash
* by Nicolas Pitre)
*
+ * 25/09/2008 Christopher Moore: TopBottom fixup for many Macronix with CFI V1.0
+ *
* Occasionally maintained by Thayne Harbaugh tharbaugh at lnxi dot com
*
* This code is GPL
@@ -43,6 +45,7 @@
#define MANUFACTURER_AMD 0x0001
#define MANUFACTURER_ATMEL 0x001F
+#define MANUFACTURER_MACRONIX 0x00C2
#define MANUFACTURER_SST 0x00BF
#define SST49LF004B 0x0060
#define SST49LF040B 0x0050
@@ -144,12 +147,44 @@ static void fixup_amd_bootblock(struct mtd_info *mtd, void* param)
if (((major << 8) | minor) < 0x3131) {
/* CFI version 1.0 => don't trust bootloc */
+
+ DEBUG(MTD_DEBUG_LEVEL1,
+ "%s: JEDEC Vendor ID is 0x%02X Device ID is 0x%02X\n",
+ map->name, cfi->mfr, cfi->id);
+
+ /* AFAICS all 29LV400 with a bottom boot block have a device ID
+ * of 0x22BA in 16-bit mode and 0xBA in 8-bit mode.
+ * These were badly detected as they have the 0x80 bit set
+ * so treat them as a special case.
+ */
+ if (((cfi->id == 0xBA) || (cfi->id == 0x22BA)) &&
+
+ /* Macronix added CFI to their 2nd generation
+ * MX29LV400C B/T but AFAICS no other 29LV400 (AMD,
+ * Fujitsu, Spansion, EON, ESI and older Macronix)
+ * has CFI.
+ *
+ * Therefore also check the manufacturer.
+ * This reduces the risk of false detection due to
+ * the 8-bit device ID.
+ */
+ (cfi->mfr == MANUFACTURER_MACRONIX)) {
+ DEBUG(MTD_DEBUG_LEVEL1,
+ "%s: Macronix MX29LV400C with bottom boot block"
+ " detected\n", map->name);
+ extp->TopBottom = 2; /* bottom boot */
+ } else
if (cfi->id & 0x80) {
printk(KERN_WARNING "%s: JEDEC Device ID is 0x%02X. Assuming broken CFI table.\n", map->name, cfi->id);
extp->TopBottom = 3; /* top boot */
} else {
extp->TopBottom = 2; /* bottom boot */
}
+
+ DEBUG(MTD_DEBUG_LEVEL1,
+ "%s: AMD CFI PRI V%c.%c has no boot block field;"
+ " deduced %s from Device ID\n", map->name, major, minor,
+ extp->TopBottom == 2 ? "bottom" : "top");
}
}
#endif
@@ -243,6 +278,7 @@ static struct cfi_fixup cfi_fixup_table[] = {
{ CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL },
#ifdef AMD_BOOTLOC_BUG
{ CFI_MFR_AMD, CFI_ID_ANY, fixup_amd_bootblock, NULL },
+ { MANUFACTURER_MACRONIX, CFI_ID_ANY, fixup_amd_bootblock, NULL },
#endif
{ CFI_MFR_AMD, 0x0050, fixup_use_secsi, NULL, },
{ CFI_MFR_AMD, 0x0053, fixup_use_secsi, NULL, },
--
1.5.2.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] [MTD] [NOR] cfi_cmdset_0002.c: Add Macronix CFI V1.0 TopBottom detection
2008-10-17 3:32 ` [PATCH] [MTD] [NOR] " Christopher Moore
@ 2008-10-18 11:42 ` David Woodhouse
0 siblings, 0 replies; 5+ messages in thread
From: David Woodhouse @ 2008-10-18 11:42 UTC (permalink / raw)
To: Christopher Moore; +Cc: linux-mtd
On Fri, 2008-10-17 at 05:32 +0200, Christopher Moore wrote:
> It does not detect the following correctly:-
> MX28F640C3B B
> MX29LV002C T
> MX29LV002NC T
> MX29LV004C B
> MX29SL400C T/B
> MX29SL402C T/B
>
> If desired I could supply a more complicated patch to handle these as
> well.
If you could, that would be very much appreciated. Thanks.
I've applied the first patch.
--
David Woodhouse Open Source Technology Centre
David.Woodhouse@intel.com Intel Corporation
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-10-18 11:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-09 21:55 [PATCH][MTD] cfi_cmdset_0002.c: Add Macronix CFI V1.0 TopBottom detection Christopher Moore
2008-10-14 10:09 ` David Woodhouse
2008-10-17 2:39 ` Chris Moore
2008-10-17 3:32 ` [PATCH] [MTD] [NOR] " Christopher Moore
2008-10-18 11:42 ` David Woodhouse
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox