1 Index: linux-2.6.25.4/drivers/mtd/chips/cfi_cmdset_0002.c
2 ===================================================================
3 --- linux-2.6.25.4.orig/drivers/mtd/chips/cfi_cmdset_0002.c
4 +++ linux-2.6.25.4/drivers/mtd/chips/cfi_cmdset_0002.c
6 #define MANUFACTURER_AMD 0x0001
7 #define MANUFACTURER_ATMEL 0x001F
8 #define MANUFACTURER_SST 0x00BF
9 +#define MANUFACTURER_MACRONIX 0x00C2
10 #define SST49LF004B 0x0060
11 #define SST49LF040B 0x0050
12 #define SST49LF008A 0x005a
13 #define AT49BV6416 0x00d6
14 #define MANUFACTURER_SAMSUNG 0x00ec
17 +#define MX29LV160B 0x2249 /* MX29LV160 Bottom-boot chip */
18 +#define MX29LV160T 0x22C4 /* MX29LV160 Top-boot chip */
19 +#define MX29LV320B 0x22A8 /* MX29LV320 Bottom-boot chip */
20 +#define MX29LV320T 0x22A7 /* MX29LV320 Top-boot chip */
22 static int cfi_amdstd_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
23 static int cfi_amdstd_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
24 static int cfi_amdstd_write_buffers(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
25 @@ -221,6 +228,41 @@ static void fixup_use_atmel_lock(struct
26 mtd->flags |= MTD_POWERUP_LOCK;
29 +#ifdef CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC
31 + * Some Macronix chips has no/bad bootblock information in the CFI table
33 +static void fixup_macronix_bootloc(struct mtd_info *mtd, void* param)
35 + struct map_info *map = mtd->priv;
36 + struct cfi_private *cfi = map->fldrv_priv;
37 + struct cfi_pri_amdstd *extp = cfi->cmdset_priv;
41 + /* TODO: put affected chip ids here */
44 + t = 2; /* Bottom boot */
48 + t = 3; /* Top boot */
54 + if (extp->TopBottom == t)
55 + /* boot location detected by the CFI layer is correct */
58 + extp->TopBottom = t;
59 + printk("%s: Macronix chip detected, id:0x%04X, boot location forced "
60 + "to %s\n", map->name, cfi->id, (t == 2) ? "bottom" : "top");
62 +#endif /* CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC */
64 static struct cfi_fixup cfi_fixup_table[] = {
65 { CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL },
66 #ifdef AMD_BOOTLOC_BUG
67 @@ -252,6 +294,9 @@ static struct cfi_fixup fixup_table[] =
69 { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_erase_chip, NULL },
70 { CFI_MFR_ATMEL, AT49BV6416, fixup_use_atmel_lock, NULL },
71 +#ifdef CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC
72 + { MANUFACTURER_MACRONIX, CFI_ID_ANY, fixup_macronix_bootloc, NULL, },
77 Index: linux-2.6.25.4/drivers/mtd/chips/Kconfig
78 ===================================================================
79 --- linux-2.6.25.4.orig/drivers/mtd/chips/Kconfig
80 +++ linux-2.6.25.4/drivers/mtd/chips/Kconfig
81 @@ -196,6 +196,14 @@ config MTD_CFI_AMDSTD
82 provides support for one of those command sets, used on chips
83 including the AMD Am29LV320.
85 +config MTD_CFI_FIXUP_MACRONIX_BOOTLOC
86 + bool "Fix boot-block location for Macronix flash chips"
87 + depends on MTD_CFI_AMDSTD
89 + Some Macronix flash chips have no/wrong boot-block location in the
90 + CFI table, and the driver may detect the type incorrectly. Select
91 + this if your board has such chip.
94 tristate "Support for ST (Advanced Architecture) flash chips"
95 depends on MTD_GEN_PROBE