From ff76ce5d3e9604815723a8fb1e74a9167de3e545 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Wed, 13 Jun 2007 18:10:25 +0000 Subject: [PATCH] Better macronix bottom boot handling, thanks Gabor ! SVN-Revision: 7618 --- target/linux/adm5120-2.6/config/default | 2 +- .../files/drivers/usb/host/adm5120-hcd.c | 8 +- .../101-cfi-fixup-macronix-bootloc.patch | 87 +++++++++++++++++++ .../adm5120-2.6/patches/101-mtd-mxflash.patch | 31 ------- target/linux/adm5120eb-2.6/config/default | 2 +- 5 files changed, 95 insertions(+), 35 deletions(-) create mode 100644 target/linux/adm5120-2.6/patches/101-cfi-fixup-macronix-bootloc.patch diff --git a/target/linux/adm5120-2.6/config/default b/target/linux/adm5120-2.6/config/default index aa6640cedd..2ba65db742 100644 --- a/target/linux/adm5120-2.6/config/default +++ b/target/linux/adm5120-2.6/config/default @@ -144,7 +144,7 @@ CONFIG_MTD_BLOCK2MTD=y CONFIG_MTD_CFI=y # CONFIG_MTD_CFI_ADV_OPTIONS is not set CONFIG_MTD_CFI_AMDSTD=y -CONFIG_MTD_CFI_AMDSTD_FORCE_BOTTOM_BOOT=y +CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC=y CONFIG_MTD_CFI_I1=y CONFIG_MTD_CFI_I2=y # CONFIG_MTD_CFI_I4 is not set diff --git a/target/linux/adm5120-2.6/files/drivers/usb/host/adm5120-hcd.c b/target/linux/adm5120-2.6/files/drivers/usb/host/adm5120-hcd.c index a0ccaefd55..a9d0071dfa 100644 --- a/target/linux/adm5120-2.6/files/drivers/usb/host/adm5120-hcd.c +++ b/target/linux/adm5120-2.6/files/drivers/usb/host/adm5120-hcd.c @@ -30,6 +30,8 @@ MODULE_DESCRIPTION("ADM5120 USB Host Controller Driver"); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Jeroen Vreeken (pe1rxq@amsat.org)"); +#define PFX "adm5120-hcd: " + #define ADMHCD_REG_CONTROL 0x00 #define ADMHCD_REG_INTSTATUS 0x04 #define ADMHCD_REG_INTENABLE 0x08 @@ -826,11 +828,13 @@ static struct platform_driver adm5120hcd_driver = { static int __init adm5120hcd_init(void) { - if (usb_disabled()) + if (usb_disabled()) return -ENODEV; - if (!adm5120_board.has_usb) + if (!adm5120_board.has_usb) { + printk(KERN_DEBUG PFX "this board does not have USB\n"); return -ENODEV; + printk(KERN_INFO PFX "registered\n"); return platform_driver_register(&adm5120hcd_driver); } diff --git a/target/linux/adm5120-2.6/patches/101-cfi-fixup-macronix-bootloc.patch b/target/linux/adm5120-2.6/patches/101-cfi-fixup-macronix-bootloc.patch new file mode 100644 index 0000000000..58b6dff1f2 --- /dev/null +++ b/target/linux/adm5120-2.6/patches/101-cfi-fixup-macronix-bootloc.patch @@ -0,0 +1,87 @@ +Index: linux-2.6.21.1/drivers/mtd/chips/cfi_cmdset_0002.c +=================================================================== +--- linux-2.6.21.1.orig/drivers/mtd/chips/cfi_cmdset_0002.c ++++ linux-2.6.21.1/drivers/mtd/chips/cfi_cmdset_0002.c +@@ -47,12 +47,17 @@ + #define MANUFACTURER_AMD 0x0001 + #define MANUFACTURER_ATMEL 0x001F + #define MANUFACTURER_SST 0x00BF ++#define MANUFACTURER_MACRONIX 0x00C2 + #define SST49LF004B 0x0060 + #define SST49LF040B 0x0050 + #define SST49LF008A 0x005a + #define AT49BV6416 0x00d6 + #define MANUFACTURER_SAMSUNG 0x00ec + ++/* Macronix */ ++#define MX29LV160B 0x2249 /* MX29LV160 Bottom-boot chip */ ++#define MX29LV320B 0x22A8 /* MX29LV320 Bottom-boot chip */ ++ + 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_buffers(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); +@@ -217,6 +222,35 @@ static void fixup_use_atmel_lock(struct + mtd->flags |= MTD_STUPID_LOCK; + } + ++#ifdef CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC ++/* ++ * Some Macronix chips has bad bootblock information in the CFI table ++ */ ++static void fixup_macronix_bootloc(struct mtd_info *mtd, void* param) ++{ ++ struct map_info *map = mtd->priv; ++ struct cfi_private *cfi = map->fldrv_priv; ++ struct cfi_pri_amdstd *extp = cfi->cmdset_priv; ++ __u8 major = extp->MajorVersion; ++ __u8 minor = extp->MinorVersion; ++ ++ switch (cfi->id) { ++ /* TODO: put affected chip ids here */ ++ case MX29LV160B: ++ case MX29LV320B: ++ if (((major << 8) | minor) != 0x3131) ++ break; ++ ++ if (extp->TopBottom == 2) ++ break; ++ ++ extp->TopBottom = 2; /* Bottom boot */ ++ printk("%s: weird Macronix chip detected, id:0x%04X, boot location " ++ "forced to bottom\n", map->name, cfi->id); ++ } ++} ++#endif /* CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC */ ++ + static struct cfi_fixup cfi_fixup_table[] = { + #ifdef AMD_BOOTLOC_BUG + { CFI_MFR_AMD, CFI_ID_ANY, fixup_amd_bootblock, NULL }, +@@ -231,6 +265,9 @@ static struct cfi_fixup cfi_fixup_table[ + { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers, NULL, }, + #endif + { CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL }, ++#ifdef CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC ++ { MANUFACTURER_MACRONIX, CFI_ID_ANY, fixup_macronix_bootloc, NULL, }, ++#endif + { 0, 0, NULL, NULL } + }; + static struct cfi_fixup jedec_fixup_table[] = { +Index: linux-2.6.21.1/drivers/mtd/chips/Kconfig +=================================================================== +--- linux-2.6.21.1.orig/drivers/mtd/chips/Kconfig ++++ linux-2.6.21.1/drivers/mtd/chips/Kconfig +@@ -199,6 +199,14 @@ config MTD_CFI_AMDSTD + provides support for one of those command sets, used on chips + including the AMD Am29LV320. + ++config MTD_CFI_FIXUP_MACRONIX_BOOTLOC ++ bool "Force bottom boot for Macronix flash chips" ++ depends on MTD_CFI_AMDSTD ++ help ++ Some Macronix flash chips have wrong boot-block location in the ++ CFI table, and the driver may detect the type incorrectly. Select ++ this if your board has such chip. ++ + config MTD_CFI_STAA + tristate "Support for ST (Advanced Architecture) flash chips" + depends on MTD_GEN_PROBE diff --git a/target/linux/adm5120-2.6/patches/101-mtd-mxflash.patch b/target/linux/adm5120-2.6/patches/101-mtd-mxflash.patch index 754a91e09f..e69de29bb2 100755 --- a/target/linux/adm5120-2.6/patches/101-mtd-mxflash.patch +++ b/target/linux/adm5120-2.6/patches/101-mtd-mxflash.patch @@ -1,31 +0,0 @@ ---- linux-2.6.19.2/drivers/mtd/chips/Kconfig.old 2007-01-11 03:10:36.000000000 +0800 -+++ linux-2.6.19.2/drivers/mtd/chips/Kconfig 2007-03-29 14:43:32.000000000 +0800 -@@ -199,6 +199,14 @@ - provides support for one of those command sets, used on chips - including the AMD Am29LV320. - -+config MTD_CFI_AMDSTD_FORCE_BOTTOM_BOOT -+ bool "Force bottom boot for Macronix flash chips" -+ depends on MTD_CFI_AMDSTD -+ help -+ Some Macronix flash chips have wrong CFI info, and the driver may -+ detect the type incorrectly. Select this if the chip part number -+ ends with BTC. -+ - config MTD_CFI_STAA - tristate "Support for ST (Advanced Architecture) flash chips" - depends on MTD_GEN_PROBE ---- linux-2.6.19.2/drivers/mtd/chips/cfi_cmdset_0002.c.old 2007-03-22 16:14:56.000000000 +0800 -+++ linux-2.6.19.2/drivers/mtd/chips/cfi_cmdset_0002.c 2007-03-29 14:07:28.000000000 +0800 -@@ -320,6 +320,11 @@ - cfi_tell_features(extp); - #endif - -+#ifdef CONFIG_MTD_CFI_AMDSTD_FORCE_BOTTOM_BOOT -+ extp->TopBottom = 2; -+ bootloc = extp->TopBottom; -+#endif -+ - bootloc = extp->TopBottom; - if ((bootloc != 2) && (bootloc != 3)) { - printk(KERN_WARNING "%s: CFI does not contain boot " diff --git a/target/linux/adm5120eb-2.6/config/default b/target/linux/adm5120eb-2.6/config/default index cbc96639eb..8a8fd9afe3 100644 --- a/target/linux/adm5120eb-2.6/config/default +++ b/target/linux/adm5120eb-2.6/config/default @@ -144,7 +144,7 @@ CONFIG_MTD_BLOCK2MTD=y CONFIG_MTD_CFI=y # CONFIG_MTD_CFI_ADV_OPTIONS is not set CONFIG_MTD_CFI_AMDSTD=y -CONFIG_MTD_CFI_AMDSTD_FORCE_BOTTOM_BOOT=y +CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC=y CONFIG_MTD_CFI_I1=y CONFIG_MTD_CFI_I2=y # CONFIG_MTD_CFI_I4 is not set -- 2.25.1