Add fixup for AT49BV6416 devices which needs to swap the region info
PATCH 1/1 Add fixup for AT49BV6416 devices which needs to swap the region info
This patch adds a fixup for Atmel AT49BV6416 devices which has the erase region information swapped. The fixup swaps them correct.
--- drivers/mtd/chips/cfi_cmdset_0002.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-)
drivers/mtd/chips/cfi_cmdset_0002.c +13 -0
@@ -167,6 +167,18 @@ static void fixup_use_write_buffers(struct mtd_info *mtd, void *param) } } +/* Atmel AT49BV6416 chips have swapped the boot sectors and normal sectors */ +static void fixup_swap_atmel_sector_info (struct mtd_info *mtd,void *param) +{ +struct map_info *map = mtd->priv; +struct cfi_private *cfi = map->fldrv_priv; +uint32_t erase_region_info_tmp; + + erase_region_info_tmp = cfi->cfiq->EraseRegionInfo[0 ]; + cfi->cfiq->EraseRegionInfo[0 ] = cfi->cfiq->EraseRegionInfo[1 ]; + cfi->cfiq->EraseRegionInfo[1 ] = erase_region_info_tmp; +} +/* Atmel chips don't use the same PRI format as AMD chips */ static void fixup_convert_atmel_pri (struct mtd_info *mtd,void *param) {
@@ -221,6 +233,7 @@ static void fixup_use_atmel_lock(struct mtd_info *mtd, void *param) }static struct cfi_fixup cfi_fixup_table[] = { + {CFI_MFR_ATMEL ,AT49BV6416 , fixup_swap_atmel_sector_info,NULL }, {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 },
Signature · 1 line
1.5.2.5
Quoted 2 lines · Hans-Christian Egtvedt
This patch adds a fixup for Atmel AT49BV6416 devices which has the erase region information swapped. The fixup swaps them correct.
How does this interact with the code in fixup_convert_atmel_pri() which sets extp->TopBottom? Doesn't the code _already_ print "Swapping erase regions for broken CFI table" for _all_ top-boot chips?
Signature · 1 line
dwmw2
Quoted 7 lines · David Woodhouse
Quoted 2 lines · Hans-Christian Egtvedt
This patch adds a fixup for Atmel AT49BV6416 devices which has the erase region information swapped. The fixup swaps them correct.
How does this interact with the code in
fixup_convert_atmel_pri()which setsextp->TopBottom? Doesn't the code _already_ print "Swapping erase regions for broken CFI table" for _all_ top-boot chips?
IIRC the AT49BV6416 got it wrong -- the CFI table indicates top-boot layout, so we need to swap the erase regions for bottom-boot chips and keep them as is for top-boot chips (or swap them twice, of course.)
Other Atmel chips like the AT49BV642D (which is a replacement for the obsolete 6416 chip) gives the top-boot bit a more "traditional" meaning. So I think it's correct to handle the 6416 as a special case.
I haven't checked how many other chips may suffer from this quirk.
Haavard