* [PATCH] [MTD] CHIPS: buffer size adjustment for M29EW Numonyx devices @ 2009-08-27 10:13 massimo cirillo 2009-08-28 8:05 ` massimo cirillo 0 siblings, 1 reply; 4+ messages in thread From: massimo cirillo @ 2009-08-27 10:13 UTC (permalink / raw) To: linux-mtd From: Massimo Cirillo <maxcir@gmail.com> The buffer size fot M29EW Numonyx flash devices used in 8bit configuration is 256 bytes sized, while the CFI contains a wrong value (1024 bytes). The following patch fixes this hardware bug. The following patch applies to 2.6.30 kernel. Signed-off-by: Massimo Cirillo <maxcir@gmail.com> --- diff --git a/drivers/mtd/chips/cfi_probe.c b/drivers/mtd/chips/cfi_probe.c old mode 100644 new mode 100755 index e63e674..1281920 --- a/drivers/mtd/chips/cfi_probe.c +++ b/drivers/mtd/chips/cfi_probe.c @@ -158,6 +158,9 @@ static int __xipram cfi_chip_setup(struct map_info *map, __u32 base = 0; int num_erase_regions = cfi_read_query(map, base + (0x10 + 28)*ofs_factor); int i; + int extendedId1 = 0; + int extendedId2 = 0; + int extendedId3 = 0; xip_enable(base, map, cfi); #ifdef DEBUG_CFI @@ -196,23 +199,39 @@ static int __xipram cfi_chip_setup(struct map_info *map, cfi->id = cfi_read_query16(map, base + ofs_factor); /* Get AMD/Spansion extended JEDEC ID */ - if (cfi->mfr == CFI_MFR_AMD && (cfi->id & 0xff) == 0x7e) - cfi->id = cfi_read_query(map, base + 0xe * ofs_factor) << 8 | + if ((cfi->mfr == CFI_MFR_NMX || cfi->mfr == CFI_MFR_ST || + cfi->mfr == CFI_MFR_AMD) && ((cfi->id & 0xff) == 0x7e) + && (le16_to_cpu(cfi->cfiq->P_ID) == 0x0002)) { + extendedId1 = cfi_read_query16(map, base + 0x1 * ofs_factor); + extendedId2 = cfi_read_query16(map, base + 0xe * ofs_factor); + extendedId3 = cfi_read_query16(map, base + 0xf * ofs_factor); + /* compatibility with previous versions */ + cfi->id = cfi_read_query(map, base + 0xe * ofs_factor) << 8 | cfi_read_query(map, base + 0xf * ofs_factor); + } /* Put it back into Read Mode */ cfi_qry_mode_off(base, map, cfi); xip_allowed(base, map); - - /* Do any necessary byteswapping */ + + /* Do any necessary byteswapping */ cfi->cfiq->P_ID = le16_to_cpu(cfi->cfiq->P_ID); - cfi->cfiq->P_ADR = le16_to_cpu(cfi->cfiq->P_ADR); cfi->cfiq->A_ID = le16_to_cpu(cfi->cfiq->A_ID); cfi->cfiq->A_ADR = le16_to_cpu(cfi->cfiq->A_ADR); cfi->cfiq->InterfaceDesc = le16_to_cpu(cfi->cfiq->InterfaceDesc); cfi->cfiq->MaxBufWriteSize = le16_to_cpu(cfi->cfiq->MaxBufWriteSize); + /* If the device is a M29EW used in 8-bit mode, adjust buffer size */ + if ((cfi->cfiq->MaxBufWriteSize > 0x8) && (cfi->mfr == CFI_MFR_NMX || + cfi->mfr == CFI_MFR_ST) && (extendedId1 == 0x7E) && + (extendedId2 == 0x22 || extendedId2 == 0x23 || extendedId2 == 0x28) && + (extendedId3 == 0x01)) { + cfi->cfiq->MaxBufWriteSize = 0x8; + pr_warning("Adjusted buffer size on Numonyx flash M29EW family"); + pr_warning(" in 8 bit mode\n"); + } + #ifdef DEBUG_CFI /* Dump the information therein */ print_cfi_ident(cfi->cfiq); @@ -228,6 +247,8 @@ static int __xipram cfi_chip_setup(struct map_info *map, #endif } + + printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank\n", map->name, cfi->interleave, cfi->device_type*8, base, map->bankwidth*8); diff --git a/include/linux/mtd/cfi.h b/include/linux/mtd/cfi.h old mode 100644 new mode 100755 index 88d3d8f..43d6a77 --- a/include/linux/mtd/cfi.h +++ b/include/linux/mtd/cfi.h @@ -522,6 +522,7 @@ struct cfi_fixup { #define CFI_MFR_ATMEL 0x001F #define CFI_MFR_SAMSUNG 0x00EC #define CFI_MFR_ST 0x0020 /* STMicroelectronics */ +#define CFI_MFR_NMX 0x0089 /* Numonyx */ void cfi_fixup(struct mtd_info *mtd, struct cfi_fixup* fixups); ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] [MTD] CHIPS: buffer size adjustment for M29EW Numonyx devices 2009-08-27 10:13 [PATCH] [MTD] CHIPS: buffer size adjustment for M29EW Numonyx devices massimo cirillo @ 2009-08-28 8:05 ` massimo cirillo 2009-09-01 9:03 ` Artem Bityutskiy 0 siblings, 1 reply; 4+ messages in thread From: massimo cirillo @ 2009-08-28 8:05 UTC (permalink / raw) To: linux-mtd From: Massimo Cirillo <maxcir@gmail.com> Please, consider this new version of the patch, that leaves unchanged the cfi->id value for AMD devices. Signed-off-by: Massimo Cirillo <maxcir@gmail.com> --- diff --git a/drivers/mtd/chips/cfi_probe.c b/drivers/mtd/chips/cfi_probe.c old mode 100644 new mode 100755 index e63e674..e4c5790 --- a/drivers/mtd/chips/cfi_probe.c +++ b/drivers/mtd/chips/cfi_probe.c @@ -158,6 +158,9 @@ static int __xipram cfi_chip_setup(struct map_info *map, __u32 base = 0; int num_erase_regions = cfi_read_query(map, base + (0x10 + 28)*ofs_factor); int i; + int extendedId1 = 0; + int extendedId2 = 0; + int extendedId3 = 0; xip_enable(base, map, cfi); #ifdef DEBUG_CFI @@ -195,6 +198,15 @@ static int __xipram cfi_chip_setup(struct map_info *map, cfi->mfr = cfi_read_query16(map, base); cfi->id = cfi_read_query16(map, base + ofs_factor); + /* Get device ID cycle 1,2,3 for Numonyx/ST devices */ + if ((cfi->mfr == CFI_MFR_NMX || cfi->mfr == CFI_MFR_ST) + && ((cfi->id & 0xff) == 0x7e) + && (le16_to_cpu(cfi->cfiq->P_ID) == 0x0002)) { + extendedId1 = cfi_read_query16(map, base + 0x1 * ofs_factor); + extendedId2 = cfi_read_query16(map, base + 0xe * ofs_factor); + extendedId3 = cfi_read_query16(map, base + 0xf * ofs_factor); + } + /* Get AMD/Spansion extended JEDEC ID */ if (cfi->mfr == CFI_MFR_AMD && (cfi->id & 0xff) == 0x7e) cfi->id = cfi_read_query(map, base + 0xe * ofs_factor) << 8 | @@ -203,16 +215,25 @@ static int __xipram cfi_chip_setup(struct map_info *map, /* Put it back into Read Mode */ cfi_qry_mode_off(base, map, cfi); xip_allowed(base, map); - - /* Do any necessary byteswapping */ + + /* Do any necessary byteswapping */ cfi->cfiq->P_ID = le16_to_cpu(cfi->cfiq->P_ID); - cfi->cfiq->P_ADR = le16_to_cpu(cfi->cfiq->P_ADR); cfi->cfiq->A_ID = le16_to_cpu(cfi->cfiq->A_ID); cfi->cfiq->A_ADR = le16_to_cpu(cfi->cfiq->A_ADR); cfi->cfiq->InterfaceDesc = le16_to_cpu(cfi->cfiq->InterfaceDesc); cfi->cfiq->MaxBufWriteSize = le16_to_cpu(cfi->cfiq->MaxBufWriteSize); + /* If the device is a M29EW used in 8-bit mode, adjust buffer size */ + if ((cfi->cfiq->MaxBufWriteSize > 0x8) && (cfi->mfr == CFI_MFR_NMX || + cfi->mfr == CFI_MFR_ST) && (extendedId1 == 0x7E) && + (extendedId2 == 0x22 || extendedId2 == 0x23 || extendedId2 == 0x28) && + (extendedId3 == 0x01)) { + cfi->cfiq->MaxBufWriteSize = 0x8; + pr_warning("Adjusted buffer size on Numonyx flash M29EW family"); + pr_warning("in 8 bit mode\n"); + } + #ifdef DEBUG_CFI /* Dump the information therein */ print_cfi_ident(cfi->cfiq); @@ -228,6 +249,8 @@ static int __xipram cfi_chip_setup(struct map_info *map, #endif } + + printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank\n", map->name, cfi->interleave, cfi->device_type*8, base, map->bankwidth*8); diff --git a/include/linux/mtd/cfi.h b/include/linux/mtd/cfi.h old mode 100644 new mode 100755 index 88d3d8f..43d6a77 --- a/include/linux/mtd/cfi.h +++ b/include/linux/mtd/cfi.h @@ -522,6 +522,7 @@ struct cfi_fixup { #define CFI_MFR_ATMEL 0x001F #define CFI_MFR_SAMSUNG 0x00EC #define CFI_MFR_ST 0x0020 /* STMicroelectronics */ +#define CFI_MFR_NMX 0x0089 /* Numonyx */ void cfi_fixup(struct mtd_info *mtd, struct cfi_fixup* fixups); -- 2009/8/27 massimo cirillo <maxcir@gmail.com>: > From: Massimo Cirillo <maxcir@gmail.com> > > The buffer size fot M29EW Numonyx flash devices used in 8bit configuration > is 256 bytes sized, while the CFI contains a wrong value (1024 bytes). > The following patch fixes this hardware bug. > The following patch applies to 2.6.30 kernel. > > Signed-off-by: Massimo Cirillo <maxcir@gmail.com> > --- > diff --git a/drivers/mtd/chips/cfi_probe.c b/drivers/mtd/chips/cfi_probe.c > old mode 100644 > new mode 100755 > index e63e674..1281920 > --- a/drivers/mtd/chips/cfi_probe.c > +++ b/drivers/mtd/chips/cfi_probe.c > @@ -158,6 +158,9 @@ static int __xipram cfi_chip_setup(struct map_info *map, > __u32 base = 0; > int num_erase_regions = cfi_read_query(map, base + (0x10 + 28)*ofs_factor); > int i; > + int extendedId1 = 0; > + int extendedId2 = 0; > + int extendedId3 = 0; > > xip_enable(base, map, cfi); > #ifdef DEBUG_CFI > @@ -196,23 +199,39 @@ static int __xipram cfi_chip_setup(struct map_info *map, > cfi->id = cfi_read_query16(map, base + ofs_factor); > > /* Get AMD/Spansion extended JEDEC ID */ > - if (cfi->mfr == CFI_MFR_AMD && (cfi->id & 0xff) == 0x7e) > - cfi->id = cfi_read_query(map, base + 0xe * ofs_factor) << 8 | > + if ((cfi->mfr == CFI_MFR_NMX || cfi->mfr == CFI_MFR_ST || > + cfi->mfr == CFI_MFR_AMD) && ((cfi->id & 0xff) == 0x7e) > + && (le16_to_cpu(cfi->cfiq->P_ID) == 0x0002)) { > + extendedId1 = cfi_read_query16(map, base + 0x1 * ofs_factor); > + extendedId2 = cfi_read_query16(map, base + 0xe * ofs_factor); > + extendedId3 = cfi_read_query16(map, base + 0xf * ofs_factor); > + /* compatibility with previous versions */ > + cfi->id = cfi_read_query(map, base + 0xe * ofs_factor) << 8 | > cfi_read_query(map, base + 0xf * ofs_factor); > + } > > /* Put it back into Read Mode */ > cfi_qry_mode_off(base, map, cfi); > xip_allowed(base, map); > - > - /* Do any necessary byteswapping */ > + > + /* Do any necessary byteswapping */ > cfi->cfiq->P_ID = le16_to_cpu(cfi->cfiq->P_ID); > - > cfi->cfiq->P_ADR = le16_to_cpu(cfi->cfiq->P_ADR); > cfi->cfiq->A_ID = le16_to_cpu(cfi->cfiq->A_ID); > cfi->cfiq->A_ADR = le16_to_cpu(cfi->cfiq->A_ADR); > cfi->cfiq->InterfaceDesc = le16_to_cpu(cfi->cfiq->InterfaceDesc); > cfi->cfiq->MaxBufWriteSize = le16_to_cpu(cfi->cfiq->MaxBufWriteSize); > > + /* If the device is a M29EW used in 8-bit mode, adjust buffer size */ > + if ((cfi->cfiq->MaxBufWriteSize > 0x8) && (cfi->mfr == CFI_MFR_NMX || > + cfi->mfr == CFI_MFR_ST) && (extendedId1 == 0x7E) && > + (extendedId2 == 0x22 || extendedId2 == 0x23 || extendedId2 == 0x28) && > + (extendedId3 == 0x01)) { > + cfi->cfiq->MaxBufWriteSize = 0x8; > + pr_warning("Adjusted buffer size on Numonyx flash M29EW family"); > + pr_warning(" in 8 bit mode\n"); > + } > + > #ifdef DEBUG_CFI > /* Dump the information therein */ > print_cfi_ident(cfi->cfiq); > @@ -228,6 +247,8 @@ static int __xipram cfi_chip_setup(struct map_info *map, > #endif > } > > + > + > printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank\n", > map->name, cfi->interleave, cfi->device_type*8, base, > map->bankwidth*8); > diff --git a/include/linux/mtd/cfi.h b/include/linux/mtd/cfi.h > old mode 100644 > new mode 100755 > index 88d3d8f..43d6a77 > --- a/include/linux/mtd/cfi.h > +++ b/include/linux/mtd/cfi.h > @@ -522,6 +522,7 @@ struct cfi_fixup { > #define CFI_MFR_ATMEL 0x001F > #define CFI_MFR_SAMSUNG 0x00EC > #define CFI_MFR_ST 0x0020 /* STMicroelectronics */ > +#define CFI_MFR_NMX 0x0089 /* Numonyx */ > > void cfi_fixup(struct mtd_info *mtd, struct cfi_fixup* fixups); > ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] [MTD] CHIPS: buffer size adjustment for M29EW Numonyx devices 2009-08-28 8:05 ` massimo cirillo @ 2009-09-01 9:03 ` Artem Bityutskiy 2009-09-01 12:59 ` massimo cirillo 0 siblings, 1 reply; 4+ messages in thread From: Artem Bityutskiy @ 2009-09-01 9:03 UTC (permalink / raw) To: massimo cirillo; +Cc: linux-mtd On Fri, 2009-08-28 at 10:05 +0200, massimo cirillo wrote: > From: Massimo Cirillo <maxcir@gmail.com> > > Please, consider this new version of the patch, that leaves unchanged > the cfi->id value for AMD devices. > > Signed-off-by: Massimo Cirillo <maxcir@gmail.com> Please, resend a patch with proper descriptions, without indentation problems (see int extendedId1) and without adding junk \n lines: > + > + -- Best Regards, Artem Bityutskiy (Артём Битюцкий) ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] [MTD] CHIPS: buffer size adjustment for M29EW Numonyx devices 2009-09-01 9:03 ` Artem Bityutskiy @ 2009-09-01 12:59 ` massimo cirillo 0 siblings, 0 replies; 4+ messages in thread From: massimo cirillo @ 2009-09-01 12:59 UTC (permalink / raw) To: dedekind1; +Cc: linux-mtd 2009/9/1 Artem Bityutskiy <dedekind1@gmail.com>: > On Fri, 2009-08-28 at 10:05 +0200, massimo cirillo wrote: >> From: Massimo Cirillo <maxcir@gmail.com> >> >> Please, consider this new version of the patch, that leaves unchanged >> the cfi->id value for AMD devices. >> >> Signed-off-by: Massimo Cirillo <maxcir@gmail.com> > > Please, resend a patch with proper descriptions, without indentation > problems (see int extendedId1) and without adding junk \n lines: > >> + >> + > > -- > Best Regards, > Artem Bityutskiy (Артём Битюцкий) > > From: Massimo Cirillo <maxcir@gmail.com> This patch fixes a problem related to an incorrect value contained in the CFI of M29EW devices family. The incorrect CFI field is MaxBufWriteSize that should be 0x8 if the device is used in 8bit mode, whereas the value read out from CFI is 0xA. Signed-off-by: Massimo Cirillo <maxcir@gmail.com> --- diff --git a/drivers/mtd/chips/cfi_probe.c b/drivers/mtd/chips/cfi_probe.c old mode 100644 new mode 100755 index e63e674..5730201 --- a/drivers/mtd/chips/cfi_probe.c +++ b/drivers/mtd/chips/cfi_probe.c @@ -158,6 +158,9 @@ static int __xipram cfi_chip_setup(struct map_info *map, __u32 base = 0; int num_erase_regions = cfi_read_query(map, base + (0x10 + 28)*ofs_factor); int i; + int extendedId1 = 0; + int extendedId2 = 0; + int extendedId3 = 0; xip_enable(base, map, cfi); #ifdef DEBUG_CFI @@ -195,6 +198,15 @@ static int __xipram cfi_chip_setup(struct map_info *map, cfi->mfr = cfi_read_query16(map, base); cfi->id = cfi_read_query16(map, base + ofs_factor); + /* Get device ID cycle 1,2,3 for Numonyx/ST devices */ + if ((cfi->mfr == CFI_MFR_NMX || cfi->mfr == CFI_MFR_ST) + && ((cfi->id & 0xff) == 0x7e) + && (le16_to_cpu(cfi->cfiq->P_ID) == 0x0002)) { + extendedId1 = cfi_read_query16(map, base + 0x1 * ofs_factor); + extendedId2 = cfi_read_query16(map, base + 0xe * ofs_factor); + extendedId3 = cfi_read_query16(map, base + 0xf * ofs_factor); + } + /* Get AMD/Spansion extended JEDEC ID */ if (cfi->mfr == CFI_MFR_AMD && (cfi->id & 0xff) == 0x7e) cfi->id = cfi_read_query(map, base + 0xe * ofs_factor) << 8 | @@ -213,6 +225,16 @@ static int __xipram cfi_chip_setup(struct map_info *map, cfi->cfiq->InterfaceDesc = le16_to_cpu(cfi->cfiq->InterfaceDesc); cfi->cfiq->MaxBufWriteSize = le16_to_cpu(cfi->cfiq->MaxBufWriteSize); + /* If the device is a M29EW used in 8-bit mode, adjust buffer size */ + if ((cfi->cfiq->MaxBufWriteSize > 0x8) && (cfi->mfr == CFI_MFR_NMX || + cfi->mfr == CFI_MFR_ST) && (extendedId1 == 0x7E) && + (extendedId2 == 0x22 || extendedId2 == 0x23 || extendedId2 == 0x28) && + (extendedId3 == 0x01)) { + cfi->cfiq->MaxBufWriteSize = 0x8; + pr_warning("Adjusted buffer size on Numonyx flash M29EW family"); + pr_warning("in 8 bit mode\n"); + } + #ifdef DEBUG_CFI /* Dump the information therein */ print_cfi_ident(cfi->cfiq); diff --git a/include/linux/mtd/cfi.h b/include/linux/mtd/cfi.h old mode 100644 new mode 100755 index 88d3d8f..43d6a77 --- a/include/linux/mtd/cfi.h +++ b/include/linux/mtd/cfi.h @@ -522,6 +522,7 @@ struct cfi_fixup { #define CFI_MFR_ATMEL 0x001F #define CFI_MFR_SAMSUNG 0x00EC #define CFI_MFR_ST 0x0020 /* STMicroelectronics */ +#define CFI_MFR_NMX 0x0089 /* Numonyx */ void cfi_fixup(struct mtd_info *mtd, struct cfi_fixup* fixups); -- Best Regards, Massimo Cirillo <maxcir@gmail.com> ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-09-01 12:59 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-08-27 10:13 [PATCH] [MTD] CHIPS: buffer size adjustment for M29EW Numonyx devices massimo cirillo 2009-08-28 8:05 ` massimo cirillo 2009-09-01 9:03 ` Artem Bityutskiy 2009-09-01 12:59 ` massimo cirillo
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox