Use block instead of sector erase for some SST chips
From: Guillaume LECERF <glecerf@gmail.com>
Use block erase size and block erase command for SST chips, making JFFS happy
with a 64KiB sector size instead of 4/8 KiB
Signed-off-by: Guillaume LECERF <glecerf@gmail.com>
---
drivers/mtd/chips/cfi_cmdset_0002.c | 38 ++++++++++++++---------------------
1 files changed, 15 insertions(+), 23 deletions(-)
@@ -261,10 +261,14 @@ static void fixup_old_sst_eraseregion(struct mtd_info *mtd)
/*
* These flashes report two separate eraseblock regions based on the
- * sector_erase-size and block_erase-size, although they both operate on the
- * same memory. This is not allowed according to CFI, so we just pick the
- * sector_erase-size.
+ * sector_erase-size and block_erase-size, although they both operate on
+ * the same memory.
+ * This is not allowed according to CFI, so we should pick the
+ * sector_erase-size (4KiB). But the sector_erase-size is not adapted to
+ * JFFS2 for whom 4 KiB is too small.
+ * So just pick the block_erase-size (64KiB).
*/
+ cfi->cfiq->EraseRegionInfo[0] = cfi->cfiq->EraseRegionInfo[1];
cfi->cfiq->NumEraseRegions = 1;
}
@@ -277,6 +281,9 @@ static void fixup_sst39vf(struct mtd_info *mtd)
cfi->addr_unlock1 = 0x5555;
cfi->addr_unlock2 = 0x2AAA;
+
+ /* use block_erase_cmd (0x50) */
+ cfi->sector_erase_cmd = CMD(0x50);
}
static void fixup_sst39vf_rev_b(struct mtd_info *mtd)
@@ -289,22 +296,7 @@ static void fixup_sst39vf_rev_b(struct mtd_info *mtd)
cfi->addr_unlock1 = 0x555;
cfi->addr_unlock2 = 0x2AA;
- cfi->sector_erase_cmd = CMD(0x50);
-}
-
-static void fixup_sst38vf640x_sectorsize(struct mtd_info *mtd)
-{
- struct map_info *map = mtd->priv;
- struct cfi_private *cfi = map->fldrv_priv;
-
- fixup_sst39vf_rev_b(mtd);
-
- /*
- * CFI reports 1024 sectors (0x03ff+1) of 64KBytes (0x0100*256) where
- * it should report a size of 8KBytes (0x0020*256).
- */
- cfi->cfiq->EraseRegionInfo[0] = 0x002003ff;
- pr_warning("%s: Bad 38VF640x CFI data; adjusting sector size from 64 to 8KiB\n", mtd->name);
+ /* sector_erase_cmd is already equals to block_erase_cmd (0x30) */
}
static void fixup_s29gl064n_sectors(struct mtd_info *mtd)
@@ -359,10 +351,10 @@ static struct cfi_fixup cfi_fixup_table[] = {
{ CFI_MFR_AMD, 0x1301, fixup_s29gl064n_sectors },
{ CFI_MFR_AMD, 0x1a00, fixup_s29gl032n_sectors },
{ CFI_MFR_AMD, 0x1a01, fixup_s29gl032n_sectors },
- { CFI_MFR_SST, 0x536a, fixup_sst38vf640x_sectorsize }, /* SST38VF6402 */
- { CFI_MFR_SST, 0x536b, fixup_sst38vf640x_sectorsize }, /* SST38VF6401 */
- { CFI_MFR_SST, 0x536c, fixup_sst38vf640x_sectorsize }, /* SST38VF6404 */
- { CFI_MFR_SST, 0x536d, fixup_sst38vf640x_sectorsize }, /* SST38VF6403 */
+ { CFI_MFR_SST, 0x536a, fixup_sst39vf_rev_b }, /* SST38VF6402 */
+ { CFI_MFR_SST, 0x536b, fixup_sst39vf_rev_b }, /* SST38VF6401 */
+ { CFI_MFR_SST, 0x536c, fixup_sst39vf_rev_b }, /* SST38VF6404 */
+ { CFI_MFR_SST, 0x536d, fixup_sst39vf_rev_b }, /* SST38VF6403 */
#if !FORCE_WORD_WRITE
{ CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers },
#endif