a25.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * This file is part of the flashrom project.
  3. *
  4. * Copyright (C) 2010 Carl-Daniel Hailfinger
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; version 2 of the License.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  18. */
  19. #include "flash.h"
  20. #include "chipdrivers.h"
  21. #include "spi.h"
  22. /* Prettyprint the status register. Works for AMIC A25L series. */
  23. static void spi_prettyprint_status_register_amic_a25_srwd(uint8_t status)
  24. {
  25. msg_cdbg("Chip status register: Status Register Write Disable "
  26. "(SRWD) is %sset\n", (status & (1 << 7)) ? "" : "not ");
  27. }
  28. int spi_prettyprint_status_register_amic_a25l05p(struct flashctx *flash)
  29. {
  30. uint8_t status;
  31. status = spi_read_status_register(flash);
  32. msg_cdbg("Chip status register is %02x\n", status);
  33. spi_prettyprint_status_register_amic_a25_srwd(status);
  34. spi_prettyprint_status_register_bit(status, 6);
  35. spi_prettyprint_status_register_bit(status, 5);
  36. spi_prettyprint_status_register_bit(status, 4);
  37. spi_prettyprint_status_register_bp3210(status, 1);
  38. spi_prettyprint_status_register_welwip(status);
  39. return 0;
  40. }
  41. int spi_prettyprint_status_register_amic_a25l40p(struct flashctx *flash)
  42. {
  43. uint8_t status;
  44. status = spi_read_status_register(flash);
  45. msg_cdbg("Chip status register is %02x\n", status);
  46. spi_prettyprint_status_register_amic_a25_srwd(status);
  47. spi_prettyprint_status_register_bit(status, 6);
  48. spi_prettyprint_status_register_bit(status, 5);
  49. spi_prettyprint_status_register_bp3210(status, 2);
  50. spi_prettyprint_status_register_welwip(status);
  51. return 0;
  52. }
  53. int spi_prettyprint_status_register_amic_a25l032(struct flashctx *flash)
  54. {
  55. uint8_t status;
  56. status = spi_read_status_register(flash);
  57. msg_cdbg("Chip status register is %02x\n", status);
  58. spi_prettyprint_status_register_amic_a25_srwd(status);
  59. msg_cdbg("Chip status register: Sector Protect Size (SEC) "
  60. "is %i KB\n", (status & (1 << 6)) ? 4 : 64);
  61. msg_cdbg("Chip status register: Top/Bottom (TB) "
  62. "is %s\n", (status & (1 << 5)) ? "bottom" : "top");
  63. spi_prettyprint_status_register_bp3210(status, 2);
  64. spi_prettyprint_status_register_welwip(status);
  65. msg_cdbg("Chip status register 2 is NOT decoded!\n");
  66. return 0;
  67. }
  68. int spi_prettyprint_status_register_amic_a25lq032(struct flashctx *flash)
  69. {
  70. uint8_t status;
  71. status = spi_read_status_register(flash);
  72. msg_cdbg("Chip status register is %02x\n", status);
  73. spi_prettyprint_status_register_amic_a25_srwd(status);
  74. msg_cdbg("Chip status register: Sector Protect Size (SEC) "
  75. "is %i KB\n", (status & (1 << 6)) ? 4 : 64);
  76. msg_cdbg("Chip status register: Top/Bottom (TB) "
  77. "is %s\n", (status & (1 << 5)) ? "bottom" : "top");
  78. spi_prettyprint_status_register_bp3210(status, 2);
  79. spi_prettyprint_status_register_welwip(status);
  80. msg_cdbg("Chip status register 2 is NOT decoded!\n");
  81. return 0;
  82. }
  83. /* FIXME: spi_disable_blockprotect is incorrect but works fine for chips using
  84. * spi_prettyprint_status_register_amic_a25l05p or
  85. * spi_prettyprint_status_register_amic_a25l40p.
  86. * FIXME: spi_disable_blockprotect is incorrect and will fail for chips using
  87. * spi_prettyprint_status_register_amic_a25l032 or
  88. * spi_prettyprint_status_register_amic_a25lq032 if those have locks controlled
  89. * by the second status register.
  90. */