Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[MTD] [NOR] AT49BV6416 has swapped erase regions

The CFI information read from AT49BV6416 lists the erase regions in the
wrong order, causing problems when trying to erase or update the first
or last 64KiB block.

Work around this by inverting the "top boot" flag, which will
effectively reverse the order of the erase regions.

This chip is obsolete, but it's used in some existing designs.

Signed-off-by: Håvard Skinnemoen <haavard.skinnemoen@atmel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

authored by

Haavard Skinnemoen and committed by
David Woodhouse
be8f78b8 aaf7ea20

+12 -4
+12 -4
drivers/mtd/chips/cfi_cmdset_0002.c
··· 213 213 if (atmel_pri.Features & 0x02) 214 214 extp->EraseSuspend = 2; 215 215 216 - if (atmel_pri.BottomBoot) 217 - extp->TopBottom = 2; 218 - else 219 - extp->TopBottom = 3; 216 + /* Some chips got it backwards... */ 217 + if (cfi->id == AT49BV6416) { 218 + if (atmel_pri.BottomBoot) 219 + extp->TopBottom = 3; 220 + else 221 + extp->TopBottom = 2; 222 + } else { 223 + if (atmel_pri.BottomBoot) 224 + extp->TopBottom = 2; 225 + else 226 + extp->TopBottom = 3; 227 + } 220 228 221 229 /* burst write mode not supported */ 222 230 cfi->cfiq->BufWriteTimeoutTyp = 0;