0005-Workaround-MX25-reliable-operation.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. diff --git a/cli_classic.c b/cli_classic.c
  2. index 0a09cfd..9eeafe1 100644
  3. --- a/cli_classic.c
  4. +++ b/cli_classic.c
  5. @@ -61,6 +61,7 @@ static void cli_classic_usage(const char *name)
  6. " -i | --image <name> only flash image <name> from flash layout\n"
  7. " -o | --output <logfile> log output to <logfile>\n"
  8. " -L | --list-supported print supported devices\n"
  9. + " | --workaround-mx keep flash busy before sending command\n"
  10. #if CONFIG_PRINT_WIKI == 1
  11. " -z | --list-supported-wiki print supported devices in wiki syntax\n"
  12. #endif
  13. @@ -130,6 +131,7 @@ int main(int argc, char *argv[])
  14. {"help", 0, NULL, 'h'},
  15. {"version", 0, NULL, 'R'},
  16. {"output", 1, NULL, 'o'},
  17. + {"workaround-mx", 0, NULL, 0x0101},
  18. {NULL, 0, NULL, 0},
  19. };
  20. @@ -337,6 +339,9 @@ int main(int argc, char *argv[])
  21. }
  22. #endif /* STANDALONE */
  23. break;
  24. + case 0x0101: /* --workaround-mx */
  25. + workaround_mx = 1;
  26. + break;
  27. default:
  28. cli_classic_abort_usage();
  29. break;
  30. diff --git a/programmer.h b/programmer.h
  31. index 1a6216a..6f97cfc 100644
  32. --- a/programmer.h
  33. +++ b/programmer.h
  34. @@ -650,6 +650,7 @@ enum ich_chipset {
  35. CHIPSET_8_SERIES_WELLSBURG,
  36. CHIPSET_9_SERIES_WILDCAT_POINT,
  37. };
  38. +extern int workaround_mx; /* workaround for MX25* chips, makes flash operations more reliable, less failures */
  39. /* ichspi.c */
  40. #if CONFIG_INTERNAL == 1
  41. diff --git a/spi.c b/spi.c
  42. index 894f73f..05aa5d0 100644
  43. --- a/spi.c
  44. +++ b/spi.c
  45. @@ -30,10 +30,19 @@
  46. #include "programmer.h"
  47. #include "spi.h"
  48. +int workaround_mx; /* Make operations with MX25* chips more reliable */
  49. +
  50. int spi_send_command(struct flashctx *flash, unsigned int writecnt,
  51. unsigned int readcnt, const unsigned char *writearr,
  52. unsigned char *readarr)
  53. {
  54. + if (workaround_mx) {
  55. + const unsigned char cmd[JEDEC_READ_OUTSIZE] = {JEDEC_READ, 0, 0, 0};
  56. + unsigned char buf[256];
  57. + /* keep flash busy for some time, keep CS warm before sending actual command */
  58. + flash->mst->spi.command(flash, sizeof(cmd), sizeof(buf), cmd, buf);
  59. + }
  60. + /* actual command */
  61. return flash->mst->spi.command(flash, writecnt, readcnt, writearr,
  62. readarr);
  63. }