mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2025-01-26 05:51:05 +02:00
[adm5120] more generic handling of Macronix flash chips, fix #2008
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@7863 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
c61315874e
commit
f791c43be8
@ -2,7 +2,7 @@ Index: linux-2.6.22-rc6/drivers/mtd/chips/cfi_cmdset_0002.c
|
|||||||
===================================================================
|
===================================================================
|
||||||
--- linux-2.6.22-rc6.orig/drivers/mtd/chips/cfi_cmdset_0002.c
|
--- linux-2.6.22-rc6.orig/drivers/mtd/chips/cfi_cmdset_0002.c
|
||||||
+++ linux-2.6.22-rc6/drivers/mtd/chips/cfi_cmdset_0002.c
|
+++ linux-2.6.22-rc6/drivers/mtd/chips/cfi_cmdset_0002.c
|
||||||
@@ -47,12 +47,17 @@
|
@@ -47,12 +47,19 @@
|
||||||
#define MANUFACTURER_AMD 0x0001
|
#define MANUFACTURER_AMD 0x0001
|
||||||
#define MANUFACTURER_ATMEL 0x001F
|
#define MANUFACTURER_ATMEL 0x001F
|
||||||
#define MANUFACTURER_SST 0x00BF
|
#define MANUFACTURER_SST 0x00BF
|
||||||
@ -15,48 +15,56 @@ Index: linux-2.6.22-rc6/drivers/mtd/chips/cfi_cmdset_0002.c
|
|||||||
|
|
||||||
+/* Macronix */
|
+/* Macronix */
|
||||||
+#define MX29LV160B 0x2249 /* MX29LV160 Bottom-boot chip */
|
+#define MX29LV160B 0x2249 /* MX29LV160 Bottom-boot chip */
|
||||||
|
+#define MX29LV160T 0x22C4 /* MX29LV160 Top-boot chip */
|
||||||
+#define MX29LV320B 0x22A8 /* MX29LV320 Bottom-boot chip */
|
+#define MX29LV320B 0x22A8 /* MX29LV320 Bottom-boot chip */
|
||||||
|
+#define MX29LV320T 0x22A7 /* MX29LV320 Top-boot chip */
|
||||||
+
|
+
|
||||||
static int cfi_amdstd_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
|
static int cfi_amdstd_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
|
||||||
static int cfi_amdstd_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
|
static int cfi_amdstd_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
|
||||||
static int cfi_amdstd_write_buffers(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
|
static int cfi_amdstd_write_buffers(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
|
||||||
@@ -217,6 +222,35 @@ static void fixup_use_atmel_lock(struct
|
@@ -217,6 +224,41 @@ static void fixup_use_atmel_lock(struct
|
||||||
mtd->flags |= MTD_STUPID_LOCK;
|
mtd->flags |= MTD_STUPID_LOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
+#ifdef CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC
|
+#ifdef CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC
|
||||||
+/*
|
+/*
|
||||||
+ * Some Macronix chips has bad bootblock information in the CFI table
|
+ * Some Macronix chips has no/bad bootblock information in the CFI table
|
||||||
+ */
|
+ */
|
||||||
+static void fixup_macronix_bootloc(struct mtd_info *mtd, void* param)
|
+static void fixup_macronix_bootloc(struct mtd_info *mtd, void* param)
|
||||||
+{
|
+{
|
||||||
+ struct map_info *map = mtd->priv;
|
+ struct map_info *map = mtd->priv;
|
||||||
+ struct cfi_private *cfi = map->fldrv_priv;
|
+ struct cfi_private *cfi = map->fldrv_priv;
|
||||||
+ struct cfi_pri_amdstd *extp = cfi->cmdset_priv;
|
+ struct cfi_pri_amdstd *extp = cfi->cmdset_priv;
|
||||||
+ __u8 major = extp->MajorVersion;
|
+ __u8 t;
|
||||||
+ __u8 minor = extp->MinorVersion;
|
|
||||||
+
|
+
|
||||||
+ switch (cfi->id) {
|
+ switch (cfi->id) {
|
||||||
+ /* TODO: put affected chip ids here */
|
+ /* TODO: put affected chip ids here */
|
||||||
+ case MX29LV160B:
|
+ case MX29LV160B:
|
||||||
+ case MX29LV320B:
|
+ case MX29LV320B:
|
||||||
+ if (((major << 8) | minor) != 0x3131)
|
+ t = 2; /* Bottom boot */
|
||||||
+ break;
|
+ break;
|
||||||
+
|
+ case MX29LV160T:
|
||||||
+ if (extp->TopBottom == 2)
|
+ case MX29LV320T:
|
||||||
+ break;
|
+ t = 3; /* Top boot */
|
||||||
+
|
+ break;
|
||||||
+ extp->TopBottom = 2; /* Bottom boot */
|
+ default:
|
||||||
+ printk("%s: weird Macronix chip detected, id:0x%04X, boot location "
|
+ return;
|
||||||
+ "forced to bottom\n", map->name, cfi->id);
|
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
|
+ if (extp->TopBottom == t)
|
||||||
|
+ /* boot location detected by the CFI layer is correct */
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ extp->TopBottom = t;
|
||||||
|
+ printk("%s: Macronix chip detected, id:0x%04X, boot location forced "
|
||||||
|
+ "to %s\n", map->name, cfi->id, (t == 2) ? "bottom" : "top");
|
||||||
+}
|
+}
|
||||||
+#endif /* CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC */
|
+#endif /* CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC */
|
||||||
+
|
+
|
||||||
static struct cfi_fixup cfi_fixup_table[] = {
|
static struct cfi_fixup cfi_fixup_table[] = {
|
||||||
#ifdef AMD_BOOTLOC_BUG
|
#ifdef AMD_BOOTLOC_BUG
|
||||||
{ CFI_MFR_AMD, CFI_ID_ANY, fixup_amd_bootblock, NULL },
|
{ CFI_MFR_AMD, CFI_ID_ANY, fixup_amd_bootblock, NULL },
|
||||||
@@ -231,6 +265,9 @@ static struct cfi_fixup cfi_fixup_table[
|
@@ -231,6 +273,9 @@ static struct cfi_fixup cfi_fixup_table[
|
||||||
{ CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers, NULL, },
|
{ CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers, NULL, },
|
||||||
#endif
|
#endif
|
||||||
{ CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL },
|
{ CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL },
|
||||||
@ -78,8 +86,8 @@ Index: linux-2.6.22-rc6/drivers/mtd/chips/Kconfig
|
|||||||
+ bool "Force bottom boot for Macronix flash chips"
|
+ bool "Force bottom boot for Macronix flash chips"
|
||||||
+ depends on MTD_CFI_AMDSTD
|
+ depends on MTD_CFI_AMDSTD
|
||||||
+ help
|
+ help
|
||||||
+ Some Macronix flash chips have wrong boot-block location in the
|
+ Some Macronix flash chips have no/wrong boot-block location in the
|
||||||
+ CFI table, and the driver may detect the type incorrectly. Select
|
+ CFI table, and the driver may detect the type incorrectly. Select
|
||||||
+ this if your board has such chip.
|
+ this if your board has such chip.
|
||||||
+
|
+
|
||||||
config MTD_CFI_STAA
|
config MTD_CFI_STAA
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
Index: linux-2.6.21.1/drivers/mtd/chips/cfi_cmdset_0002.c
|
Index: linux-2.6.21.5/drivers/mtd/chips/cfi_cmdset_0002.c
|
||||||
===================================================================
|
===================================================================
|
||||||
--- linux-2.6.21.1.orig/drivers/mtd/chips/cfi_cmdset_0002.c
|
--- linux-2.6.21.5.orig/drivers/mtd/chips/cfi_cmdset_0002.c
|
||||||
+++ linux-2.6.21.1/drivers/mtd/chips/cfi_cmdset_0002.c
|
+++ linux-2.6.21.5/drivers/mtd/chips/cfi_cmdset_0002.c
|
||||||
@@ -47,12 +47,17 @@
|
@@ -47,12 +47,19 @@
|
||||||
#define MANUFACTURER_AMD 0x0001
|
#define MANUFACTURER_AMD 0x0001
|
||||||
#define MANUFACTURER_ATMEL 0x001F
|
#define MANUFACTURER_ATMEL 0x001F
|
||||||
#define MANUFACTURER_SST 0x00BF
|
#define MANUFACTURER_SST 0x00BF
|
||||||
@ -15,48 +15,56 @@ Index: linux-2.6.21.1/drivers/mtd/chips/cfi_cmdset_0002.c
|
|||||||
|
|
||||||
+/* Macronix */
|
+/* Macronix */
|
||||||
+#define MX29LV160B 0x2249 /* MX29LV160 Bottom-boot chip */
|
+#define MX29LV160B 0x2249 /* MX29LV160 Bottom-boot chip */
|
||||||
|
+#define MX29LV160T 0x22C4 /* MX29LV160 Top-boot chip */
|
||||||
+#define MX29LV320B 0x22A8 /* MX29LV320 Bottom-boot chip */
|
+#define MX29LV320B 0x22A8 /* MX29LV320 Bottom-boot chip */
|
||||||
|
+#define MX29LV320T 0x22A7 /* MX29LV320 Top-boot chip */
|
||||||
+
|
+
|
||||||
static int cfi_amdstd_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
|
static int cfi_amdstd_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
|
||||||
static int cfi_amdstd_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
|
static int cfi_amdstd_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
|
||||||
static int cfi_amdstd_write_buffers(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
|
static int cfi_amdstd_write_buffers(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
|
||||||
@@ -217,6 +222,35 @@ static void fixup_use_atmel_lock(struct
|
@@ -217,6 +224,41 @@ static void fixup_use_atmel_lock(struct
|
||||||
mtd->flags |= MTD_STUPID_LOCK;
|
mtd->flags |= MTD_STUPID_LOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
+#ifdef CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC
|
+#ifdef CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC
|
||||||
+/*
|
+/*
|
||||||
+ * Some Macronix chips has bad bootblock information in the CFI table
|
+ * Some Macronix chips has no/bad bootblock information in the CFI table
|
||||||
+ */
|
+ */
|
||||||
+static void fixup_macronix_bootloc(struct mtd_info *mtd, void* param)
|
+static void fixup_macronix_bootloc(struct mtd_info *mtd, void* param)
|
||||||
+{
|
+{
|
||||||
+ struct map_info *map = mtd->priv;
|
+ struct map_info *map = mtd->priv;
|
||||||
+ struct cfi_private *cfi = map->fldrv_priv;
|
+ struct cfi_private *cfi = map->fldrv_priv;
|
||||||
+ struct cfi_pri_amdstd *extp = cfi->cmdset_priv;
|
+ struct cfi_pri_amdstd *extp = cfi->cmdset_priv;
|
||||||
+ __u8 major = extp->MajorVersion;
|
+ __u8 t;
|
||||||
+ __u8 minor = extp->MinorVersion;
|
|
||||||
+
|
+
|
||||||
+ switch (cfi->id) {
|
+ switch (cfi->id) {
|
||||||
+ /* TODO: put affected chip ids here */
|
+ /* TODO: put affected chip ids here */
|
||||||
+ case MX29LV160B:
|
+ case MX29LV160B:
|
||||||
+ case MX29LV320B:
|
+ case MX29LV320B:
|
||||||
+ if (((major << 8) | minor) != 0x3131)
|
+ t = 2; /* Bottom boot */
|
||||||
+ break;
|
+ break;
|
||||||
+
|
+ case MX29LV160T:
|
||||||
+ if (extp->TopBottom == 2)
|
+ case MX29LV320T:
|
||||||
+ break;
|
+ t = 3; /* Top boot */
|
||||||
+
|
+ break;
|
||||||
+ extp->TopBottom = 2; /* Bottom boot */
|
+ default:
|
||||||
+ printk("%s: weird Macronix chip detected, id:0x%04X, boot location "
|
+ return;
|
||||||
+ "forced to bottom\n", map->name, cfi->id);
|
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
|
+ if (extp->TopBottom == t)
|
||||||
|
+ /* boot location detected by the CFI layer is correct */
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ extp->TopBottom = t;
|
||||||
|
+ printk("%s: Macronix chip detected, id:0x%04X, boot location forced "
|
||||||
|
+ "to %s\n", map->name, cfi->id, (t == 2) ? "bottom" : "top");
|
||||||
+}
|
+}
|
||||||
+#endif /* CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC */
|
+#endif /* CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC */
|
||||||
+
|
+
|
||||||
static struct cfi_fixup cfi_fixup_table[] = {
|
static struct cfi_fixup cfi_fixup_table[] = {
|
||||||
#ifdef AMD_BOOTLOC_BUG
|
#ifdef AMD_BOOTLOC_BUG
|
||||||
{ CFI_MFR_AMD, CFI_ID_ANY, fixup_amd_bootblock, NULL },
|
{ CFI_MFR_AMD, CFI_ID_ANY, fixup_amd_bootblock, NULL },
|
||||||
@@ -231,6 +265,9 @@ static struct cfi_fixup cfi_fixup_table[
|
@@ -231,6 +273,9 @@ static struct cfi_fixup cfi_fixup_table[
|
||||||
{ CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers, NULL, },
|
{ CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers, NULL, },
|
||||||
#endif
|
#endif
|
||||||
{ CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL },
|
{ CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL },
|
||||||
@ -66,10 +74,10 @@ Index: linux-2.6.21.1/drivers/mtd/chips/cfi_cmdset_0002.c
|
|||||||
{ 0, 0, NULL, NULL }
|
{ 0, 0, NULL, NULL }
|
||||||
};
|
};
|
||||||
static struct cfi_fixup jedec_fixup_table[] = {
|
static struct cfi_fixup jedec_fixup_table[] = {
|
||||||
Index: linux-2.6.21.1/drivers/mtd/chips/Kconfig
|
Index: linux-2.6.21.5/drivers/mtd/chips/Kconfig
|
||||||
===================================================================
|
===================================================================
|
||||||
--- linux-2.6.21.1.orig/drivers/mtd/chips/Kconfig
|
--- linux-2.6.21.5.orig/drivers/mtd/chips/Kconfig
|
||||||
+++ linux-2.6.21.1/drivers/mtd/chips/Kconfig
|
+++ linux-2.6.21.5/drivers/mtd/chips/Kconfig
|
||||||
@@ -199,6 +199,14 @@ config MTD_CFI_AMDSTD
|
@@ -199,6 +199,14 @@ config MTD_CFI_AMDSTD
|
||||||
provides support for one of those command sets, used on chips
|
provides support for one of those command sets, used on chips
|
||||||
including the AMD Am29LV320.
|
including the AMD Am29LV320.
|
||||||
@ -78,8 +86,8 @@ Index: linux-2.6.21.1/drivers/mtd/chips/Kconfig
|
|||||||
+ bool "Force bottom boot for Macronix flash chips"
|
+ bool "Force bottom boot for Macronix flash chips"
|
||||||
+ depends on MTD_CFI_AMDSTD
|
+ depends on MTD_CFI_AMDSTD
|
||||||
+ help
|
+ help
|
||||||
+ Some Macronix flash chips have wrong boot-block location in the
|
+ Some Macronix flash chips have no/wrong boot-block location in the
|
||||||
+ CFI table, and the driver may detect the type incorrectly. Select
|
+ CFI table, and the driver may detect the type incorrectly. Select
|
||||||
+ this if your board has such chip.
|
+ this if your board has such chip.
|
||||||
+
|
+
|
||||||
config MTD_CFI_STAA
|
config MTD_CFI_STAA
|
||||||
|
Loading…
x
Reference in New Issue
Block a user