101-cfi_fixup_macronix_bootloc.patch 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. --- a/drivers/mtd/chips/cfi_cmdset_0002.c
  2. +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
  3. @@ -49,6 +49,12 @@
  4. #define SST49LF008A 0x005a
  5. #define AT49BV6416 0x00d6
  6. +/* Macronix */
  7. +#define MX29LV160B 0x2249 /* MX29LV160 Bottom-boot chip */
  8. +#define MX29LV160T 0x22C4 /* MX29LV160 Top-boot chip */
  9. +#define MX29LV320B 0x22A8 /* MX29LV320 Bottom-boot chip */
  10. +#define MX29LV320T 0x22A7 /* MX29LV320 Top-boot chip */
  11. +
  12. static int cfi_amdstd_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
  13. static int cfi_amdstd_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
  14. static int cfi_amdstd_write_buffers(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
  15. @@ -374,6 +380,41 @@ static struct cfi_fixup cfi_nopri_fixup_
  16. { 0, 0, NULL }
  17. };
  18. +#ifdef CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC
  19. +/*
  20. + * Some Macronix chips has no/bad bootblock information in the CFI table
  21. + */
  22. +static void fixup_macronix_bootloc(struct mtd_info *mtd)
  23. +{
  24. + struct map_info *map = mtd->priv;
  25. + struct cfi_private *cfi = map->fldrv_priv;
  26. + struct cfi_pri_amdstd *extp = cfi->cmdset_priv;
  27. + __u8 t;
  28. +
  29. + switch (cfi->id) {
  30. + /* TODO: put affected chip ids here */
  31. + case MX29LV160B:
  32. + case MX29LV320B:
  33. + t = 2; /* Bottom boot */
  34. + break;
  35. + case MX29LV160T:
  36. + case MX29LV320T:
  37. + t = 3; /* Top boot */
  38. + break;
  39. + default:
  40. + return;
  41. + }
  42. +
  43. + if (extp->TopBottom == t)
  44. + /* boot location detected by the CFI layer is correct */
  45. + return;
  46. +
  47. + extp->TopBottom = t;
  48. + printk("%s: Macronix chip detected, id:0x%04X, boot location forced "
  49. + "to %s\n", map->name, cfi->id, (t == 2) ? "bottom" : "top");
  50. +}
  51. +#endif /* CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC */
  52. +
  53. static struct cfi_fixup cfi_fixup_table[] = {
  54. { CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri },
  55. #ifdef AMD_BOOTLOC_BUG
  56. @@ -416,6 +457,9 @@ static struct cfi_fixup fixup_table[] =
  57. */
  58. { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_erase_chip },
  59. { CFI_MFR_ATMEL, AT49BV6416, fixup_use_atmel_lock },
  60. +#ifdef CONFIG_MTD_CFI_FIXUP_MACRONIX_BOOTLOC
  61. + { CFI_MFR_MACRONIX, CFI_ID_ANY, fixup_macronix_bootloc },
  62. +#endif
  63. { 0, 0, NULL }
  64. };
  65. --- a/drivers/mtd/chips/Kconfig
  66. +++ b/drivers/mtd/chips/Kconfig
  67. @@ -188,6 +188,14 @@ config MTD_CFI_AMDSTD
  68. provides support for command set 0002, used on chips including
  69. the AMD Am29LV320.
  70. +config MTD_CFI_FIXUP_MACRONIX_BOOTLOC
  71. + bool "Fix boot-block location for Macronix flash chips"
  72. + depends on MTD_CFI_AMDSTD
  73. + help
  74. + Some Macronix flash chips have no/wrong boot-block location in the
  75. + CFI table, and the driver may detect the type incorrectly. Select
  76. + this if your board has such chip.
  77. +
  78. config MTD_CFI_STAA
  79. tristate "Support for CFI command set 0020 (ST (Advanced Architecture) chips)"
  80. depends on MTD_GEN_PROBE