diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index d74ec46..40818d4 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -152,39 +152,28 @@ static void fixup_amd_bootblock(struct mtd_info *mtd, void* param) "%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 */ - } - + switch ((cfi->mfr << 16) | (cfi->id & 0xffff)) { + case (MANUFACTURER_MACRONIX << 16) | 0x00ba: /* Macronix MX29LV400C */ + case (MANUFACTURER_MACRONIX << 16) | 0x22ba: /* Macronix MX29LV400C */ + extp->TopBottom = 2; /* bottom-boot */ + break; + case (MANUFACTURER_MACRONIX << 16) | 0x00b9: /* Macronix MX29LV400C */ + case (MANUFACTURER_MACRONIX << 16) | 0x22b9: /* Macronix MX29LV400C */ + extp->TopBottom = 3; /* top-boot */ + break; + default: + /* Default case, use bit 7 of the ID to detect + * that we have a top-boot device. AFAICT, + * there isn't any proof that this is a valid + * test, but the code has been working this + * way since 2001. */ + extp->TopBottom = (cfi->id & 0x80) ? 3 /* top-boot */ : 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"); + "%s: AMD/Spansion CFI PRI V%c.%c has no boot block field;" + " deduced %s from Manufacturer/Device ID %0x/%0x\n", map->name, major, minor, + extp->TopBottom == 2 ? "bottom" : "top", + cfi->mfr, cfi->id); } } #endif