0002-Workaround-for-MX25-chips.patch 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. From 886f1db7edbfc9ef4c9727b4f564c1e7e35d6565 Mon Sep 17 00:00:00 2001
  2. From: consts <grudnevkv@gmail.com>
  3. Date: Fri, 2 Mar 2018 07:03:37 +0000
  4. Subject: [PATCH] Workaround for MX25 chips
  5. https://notabug.org/libreboot/libreboot/issues/193
  6. ---
  7. cli_classic.c | 5 +++++
  8. programmer.h | 1 +
  9. spi.c | 9 +++++++++
  10. 3 files changed, 15 insertions(+)
  11. diff --git a/cli_classic.c b/cli_classic.c
  12. index 31f7394..c60168c 100644
  13. --- a/cli_classic.c
  14. +++ b/cli_classic.c
  15. @@ -62,6 +62,7 @@ static void cli_classic_usage(const char *name)
  16. " -o | --output <logfile> log output to <logfile>\n"
  17. " --flash-contents <ref-file> assume flash contents to be <ref-file>\n"
  18. " -L | --list-supported print supported devices\n"
  19. + " -m | --workaround-mx keep flash busy before sending command\n"
  20. #if CONFIG_PRINT_WIKI == 1
  21. " -z | --list-supported-wiki print supported devices in wiki syntax\n"
  22. #endif
  23. @@ -136,6 +137,7 @@ int main(int argc, char *argv[])
  24. {"help", 0, NULL, 'h'},
  25. {"version", 0, NULL, 'R'},
  26. {"output", 1, NULL, 'o'},
  27. + {"workaround-mx", 0, NULL, 'm'},
  28. {NULL, 0, NULL, 0},
  29. };
  30. @@ -347,6 +349,9 @@ int main(int argc, char *argv[])
  31. }
  32. #endif /* STANDALONE */
  33. break;
  34. + case 'm': /* --workaround-mx */
  35. + workaround_mx = 1;
  36. + break;
  37. default:
  38. cli_classic_abort_usage();
  39. break;
  40. diff --git a/programmer.h b/programmer.h
  41. index 139f4fa..f54e690 100644
  42. --- a/programmer.h
  43. +++ b/programmer.h
  44. @@ -664,6 +664,7 @@ enum ich_chipset {
  45. CHIPSET_100_SERIES_SUNRISE_POINT, /* also 6th/7th gen Core i/o (LP) variants */
  46. CHIPSET_C620_SERIES_LEWISBURG,
  47. };
  48. +extern int workaround_mx; /* workaround for MX25* chips, makes flash operations more reliable, less failures */
  49. /* ichspi.c */
  50. #if CONFIG_INTERNAL == 1
  51. diff --git a/spi.c b/spi.c
  52. index 56f1fdf..4e61d88 100644
  53. --- a/spi.c
  54. +++ b/spi.c
  55. @@ -30,10 +30,19 @@
  56. #include "programmer.h"
  57. #include "spi.h"
  58. +int workaround_mx; /* Make operations with MX25* chips more reliable */
  59. +
  60. int spi_send_command(struct flashctx *flash, unsigned int writecnt,
  61. unsigned int readcnt, const unsigned char *writearr,
  62. unsigned char *readarr)
  63. {
  64. + if (workaround_mx) {
  65. + const unsigned char cmd[JEDEC_READ_OUTSIZE] = {JEDEC_READ, 0, 0, 0};
  66. + unsigned char buf[256];
  67. + /* keep flash busy for some time, keep CS warm before sending actual command */
  68. + flash->mst->spi.command(flash, sizeof(cmd), sizeof(buf), cmd, buf);
  69. + }
  70. + /* actual command */
  71. return flash->mst->spi.command(flash, writecnt, readcnt, writearr,
  72. readarr);
  73. }
  74. --
  75. 1.9.1