1 --- a/drivers/mtd/chips/cfi_cmdset_0002.c
2 +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
4 #define MANUFACTURER_AMD 0x0001
5 #define MANUFACTURER_ATMEL 0x001F
6 #define MANUFACTURER_SST 0x00BF
7 +#define MANUFACTURER_MACRONIX 0x00C2
8 #define SST49LF004B 0x0060
9 #define SST49LF040B 0x0050
10 #define SST49LF008A 0x005a
11 #define AT49BV6416 0x00d6
12 #define MANUFACTURER_SAMSUNG 0x00ec
15 +#define MX29LV160B 0x2249 /* MX29LV160 Bottom-boot chip */
16 +#define MX29LV160T 0x22C4 /* MX29LV160 Top-boot chip */
17 +#define MX29LV320B 0x22A8 /* MX29LV320 Bottom-boot chip */
18 +#define MX29LV320T 0x22A7 /* MX29LV320 Top-boot chip */
20 static int cfi_amdstd_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
21 static int cfi_amdstd_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
22 static int cfi_amdstd_write_buffers(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
24 mtd->flags |= MTD_STUPID_LOCK;
27 +#ifdef CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC
29 + * Some Macronix chips has no/bad bootblock information in the CFI table
31 +static void fixup_macronix_bootloc(struct mtd_info *mtd, void* param)
33 + struct map_info *map = mtd->priv;
34 + struct cfi_private *cfi = map->fldrv_priv;
35 + struct cfi_pri_amdstd *extp = cfi->cmdset_priv;
39 + /* TODO: put affected chip ids here */
42 + t = 2; /* Bottom boot */
46 + t = 3; /* Top boot */
52 + if (extp->TopBottom == t)
53 + /* boot location detected by the CFI layer is correct */
56 + extp->TopBottom = t;
57 + printk("%s: Macronix chip detected, id:0x%04X, boot location forced "
58 + "to %s\n", map->name, cfi->id, (t == 2) ? "bottom" : "top");
60 +#endif /* CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC */
62 static struct cfi_fixup cfi_fixup_table[] = {
63 #ifdef AMD_BOOTLOC_BUG
64 { CFI_MFR_AMD, CFI_ID_ANY, fixup_amd_bootblock, NULL },
66 { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers, NULL, },
68 { CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL },
69 +#ifdef CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC
70 + { MANUFACTURER_MACRONIX, CFI_ID_ANY, fixup_macronix_bootloc, NULL, },
74 static struct cfi_fixup jedec_fixup_table[] = {
75 --- a/drivers/mtd/chips/Kconfig
76 +++ b/drivers/mtd/chips/Kconfig
78 provides support for one of those command sets, used on chips
79 including the AMD Am29LV320.
81 +config MTD_CFI_FIXUP_MACRONIX_BOOTLOC
82 + bool "Fix boot-block location for Macronix flash chips"
83 + depends on MTD_CFI_AMDSTD
85 + Some Macronix flash chips have no/wrong boot-block location in the
86 + CFI table, and the driver may detect the type incorrectly. Select
87 + this if your board has such chip.
90 tristate "Support for ST (Advanced Architecture) flash chips"
91 depends on MTD_GEN_PROBE