Build the root fs.
[openwrt.git] / target / linux / adm5120 / patches-2.6.27 / 101-cfi_fixup_macronix_bootloc.patch
1 --- a/drivers/mtd/chips/cfi_cmdset_0002.c
2 +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
3 @@ -44,12 +44,19 @@
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
13
14 +/* Macronix */
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 */
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 @@ -240,6 +247,41 @@ static void fixup_s29gl032n_sectors(stru
24 }
25 }
26
27 +#ifdef CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC
28 +/*
29 + * Some Macronix chips has no/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 t;
37 +
38 + switch (cfi->id) {
39 + /* TODO: put affected chip ids here */
40 + case MX29LV160B:
41 + case MX29LV320B:
42 + t = 2; /* Bottom boot */
43 + break;
44 + case MX29LV160T:
45 + case MX29LV320T:
46 + t = 3; /* Top boot */
47 + break;
48 + default:
49 + return;
50 + }
51 +
52 + if (extp->TopBottom == t)
53 + /* boot location detected by the CFI layer is correct */
54 + return;
55 +
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");
59 +}
60 +#endif /* CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC */
61 +
62 static struct cfi_fixup cfi_fixup_table[] = {
63 { CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL },
64 #ifdef AMD_BOOTLOC_BUG
65 @@ -275,6 +317,9 @@ static struct cfi_fixup fixup_table[] =
66 */
67 { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_erase_chip, NULL },
68 { CFI_MFR_ATMEL, AT49BV6416, fixup_use_atmel_lock, NULL },
69 +#ifdef CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC
70 + { MANUFACTURER_MACRONIX, CFI_ID_ANY, fixup_macronix_bootloc, NULL, },
71 +#endif
72 { 0, 0, NULL, NULL }
73 };
74
75 --- a/drivers/mtd/chips/Kconfig
76 +++ b/drivers/mtd/chips/Kconfig
77 @@ -196,6 +196,14 @@ config MTD_CFI_AMDSTD
78 provides support for one of those command sets, used on chips
79 including the AMD Am29LV320.
80
81 +config MTD_CFI_FIXUP_MACRONIX_BOOTLOC
82 + bool "Fix boot-block location for Macronix flash chips"
83 + depends on MTD_CFI_AMDSTD
84 + help
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.
88 +
89 config MTD_CFI_STAA
90 tristate "Support for ST (Advanced Architecture) flash chips"
91 depends on MTD_GEN_PROBE
This page took 0.049624 seconds and 5 git commands to generate.