[adm5120] restore right patches for 2.6.21.5
[openwrt/svn-archive/archive.git] / target / linux / adm5120-2.6 / patches / 101-cfi-fixup-macronix-bootloc.patch
1 Index: linux-2.6.21.1/drivers/mtd/chips/cfi_cmdset_0002.c
2 ===================================================================
3 --- linux-2.6.21.1.orig/drivers/mtd/chips/cfi_cmdset_0002.c
4 +++ linux-2.6.21.1/drivers/mtd/chips/cfi_cmdset_0002.c
5 @@ -47,12 +47,17 @@
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
15
16 +/* Macronix */
17 +#define MX29LV160B 0x2249 /* MX29LV160 Bottom-boot chip */
18 +#define MX29LV320B 0x22A8 /* MX29LV320 Bottom-boot chip */
19 +
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 *);
23 @@ -217,6 +222,35 @@ static void fixup_use_atmel_lock(struct
24 mtd->flags |= MTD_STUPID_LOCK;
25 }
26
27 +#ifdef CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC
28 +/*
29 + * Some Macronix chips has bad bootblock information in the CFI table
30 + */
31 +static void fixup_macronix_bootloc(struct mtd_info *mtd, void* param)
32 +{
33 + struct map_info *map = mtd->priv;
34 + struct cfi_private *cfi = map->fldrv_priv;
35 + struct cfi_pri_amdstd *extp = cfi->cmdset_priv;
36 + __u8 major = extp->MajorVersion;
37 + __u8 minor = extp->MinorVersion;
38 +
39 + switch (cfi->id) {
40 + /* TODO: put affected chip ids here */
41 + case MX29LV160B:
42 + case MX29LV320B:
43 + if (((major << 8) | minor) != 0x3131)
44 + break;
45 +
46 + if (extp->TopBottom == 2)
47 + break;
48 +
49 + extp->TopBottom = 2; /* Bottom boot */
50 + printk("%s: weird Macronix chip detected, id:0x%04X, boot location "
51 + "forced to bottom\n", map->name, cfi->id);
52 + }
53 +}
54 +#endif /* CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC */
55 +
56 static struct cfi_fixup cfi_fixup_table[] = {
57 #ifdef AMD_BOOTLOC_BUG
58 { CFI_MFR_AMD, CFI_ID_ANY, fixup_amd_bootblock, NULL },
59 @@ -231,6 +265,9 @@ static struct cfi_fixup cfi_fixup_table[
60 { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers, NULL, },
61 #endif
62 { CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL },
63 +#ifdef CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC
64 + { MANUFACTURER_MACRONIX, CFI_ID_ANY, fixup_macronix_bootloc, NULL, },
65 +#endif
66 { 0, 0, NULL, NULL }
67 };
68 static struct cfi_fixup jedec_fixup_table[] = {
69 Index: linux-2.6.21.1/drivers/mtd/chips/Kconfig
70 ===================================================================
71 --- linux-2.6.21.1.orig/drivers/mtd/chips/Kconfig
72 +++ linux-2.6.21.1/drivers/mtd/chips/Kconfig
73 @@ -199,6 +199,14 @@ config MTD_CFI_AMDSTD
74 provides support for one of those command sets, used on chips
75 including the AMD Am29LV320.
76
77 +config MTD_CFI_FIXUP_MACRONIX_BOOTLOC
78 + bool "Force bottom boot for Macronix flash chips"
79 + depends on MTD_CFI_AMDSTD
80 + help
81 + Some Macronix flash chips have wrong boot-block location in the
82 + CFI table, and the driver may detect the type incorrectly. Select
83 + this if your board has such chip.
84 +
85 config MTD_CFI_STAA
86 tristate "Support for ST (Advanced Architecture) flash chips"
87 depends on MTD_GEN_PROBE