Carl-Daniel Hailfinger | 7a3bd8f | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 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 | |
| 20 | #include "flash.h" |
| 21 | #include "chipdrivers.h" |
| 22 | #include "spi.h" |
| 23 | |
| 24 | /* Prettyprint the status register. Works for AMIC A25L series. */ |
| 25 | |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 26 | int spi_prettyprint_status_register_amic_a25l05p(struct flashctx *flash) |
Carl-Daniel Hailfinger | 7a3bd8f | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 27 | { |
| 28 | uint8_t status; |
| 29 | |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 30 | status = spi_read_status_register(flash); |
Carl-Daniel Hailfinger | 7a3bd8f | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 31 | msg_cdbg("Chip status register is %02x\n", status); |
| 32 | |
Stefan Tauner | 5609f9d | 2012-09-22 01:38:06 +0000 | [diff] [blame^] | 33 | spi_prettyprint_status_register_srwd(status); |
Carl-Daniel Hailfinger | 7a3bd8f | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 34 | spi_prettyprint_status_register_bit(status, 6); |
| 35 | spi_prettyprint_status_register_bit(status, 5); |
| 36 | spi_prettyprint_status_register_bit(status, 4); |
Stefan Tauner | 1ba08f6 | 2012-08-02 23:51:28 +0000 | [diff] [blame] | 37 | spi_prettyprint_status_register_bp(status, 1); |
Carl-Daniel Hailfinger | 7a3bd8f | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 38 | spi_prettyprint_status_register_welwip(status); |
| 39 | return 0; |
| 40 | } |
| 41 | |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 42 | int spi_prettyprint_status_register_amic_a25l40p(struct flashctx *flash) |
Carl-Daniel Hailfinger | 7a3bd8f | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 43 | { |
| 44 | uint8_t status; |
| 45 | |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 46 | status = spi_read_status_register(flash); |
Carl-Daniel Hailfinger | 7a3bd8f | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 47 | msg_cdbg("Chip status register is %02x\n", status); |
| 48 | |
Stefan Tauner | 5609f9d | 2012-09-22 01:38:06 +0000 | [diff] [blame^] | 49 | spi_prettyprint_status_register_srwd(status); |
Carl-Daniel Hailfinger | 7a3bd8f | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 50 | spi_prettyprint_status_register_bit(status, 6); |
| 51 | spi_prettyprint_status_register_bit(status, 5); |
Stefan Tauner | 1ba08f6 | 2012-08-02 23:51:28 +0000 | [diff] [blame] | 52 | spi_prettyprint_status_register_bp(status, 2); |
Carl-Daniel Hailfinger | 7a3bd8f | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 53 | spi_prettyprint_status_register_welwip(status); |
| 54 | return 0; |
| 55 | } |
| 56 | |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 57 | int spi_prettyprint_status_register_amic_a25l032(struct flashctx *flash) |
Carl-Daniel Hailfinger | 7a3bd8f | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 58 | { |
| 59 | uint8_t status; |
| 60 | |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 61 | status = spi_read_status_register(flash); |
Carl-Daniel Hailfinger | 7a3bd8f | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 62 | msg_cdbg("Chip status register is %02x\n", status); |
| 63 | |
Stefan Tauner | 5609f9d | 2012-09-22 01:38:06 +0000 | [diff] [blame^] | 64 | spi_prettyprint_status_register_srwd(status); |
Carl-Daniel Hailfinger | 7a3bd8f | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 65 | msg_cdbg("Chip status register: Sector Protect Size (SEC) " |
| 66 | "is %i KB\n", (status & (1 << 6)) ? 4 : 64); |
| 67 | msg_cdbg("Chip status register: Top/Bottom (TB) " |
| 68 | "is %s\n", (status & (1 << 5)) ? "bottom" : "top"); |
Stefan Tauner | 1ba08f6 | 2012-08-02 23:51:28 +0000 | [diff] [blame] | 69 | spi_prettyprint_status_register_bp(status, 2); |
Carl-Daniel Hailfinger | 7a3bd8f | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 70 | spi_prettyprint_status_register_welwip(status); |
| 71 | msg_cdbg("Chip status register 2 is NOT decoded!\n"); |
| 72 | return 0; |
| 73 | } |
| 74 | |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 75 | int spi_prettyprint_status_register_amic_a25lq032(struct flashctx *flash) |
Carl-Daniel Hailfinger | 7a3bd8f | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 76 | { |
| 77 | uint8_t status; |
| 78 | |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 79 | status = spi_read_status_register(flash); |
Carl-Daniel Hailfinger | 7a3bd8f | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 80 | msg_cdbg("Chip status register is %02x\n", status); |
| 81 | |
Stefan Tauner | 5609f9d | 2012-09-22 01:38:06 +0000 | [diff] [blame^] | 82 | spi_prettyprint_status_register_srwd(status); |
Carl-Daniel Hailfinger | 7a3bd8f | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 83 | msg_cdbg("Chip status register: Sector Protect Size (SEC) " |
| 84 | "is %i KB\n", (status & (1 << 6)) ? 4 : 64); |
| 85 | msg_cdbg("Chip status register: Top/Bottom (TB) " |
| 86 | "is %s\n", (status & (1 << 5)) ? "bottom" : "top"); |
Stefan Tauner | 1ba08f6 | 2012-08-02 23:51:28 +0000 | [diff] [blame] | 87 | spi_prettyprint_status_register_bp(status, 2); |
Carl-Daniel Hailfinger | 7a3bd8f | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 88 | spi_prettyprint_status_register_welwip(status); |
| 89 | msg_cdbg("Chip status register 2 is NOT decoded!\n"); |
| 90 | return 0; |
| 91 | } |
| 92 | |
| 93 | /* FIXME: spi_disable_blockprotect is incorrect but works fine for chips using |
| 94 | * spi_prettyprint_status_register_amic_a25l05p or |
| 95 | * spi_prettyprint_status_register_amic_a25l40p. |
| 96 | * FIXME: spi_disable_blockprotect is incorrect and will fail for chips using |
| 97 | * spi_prettyprint_status_register_amic_a25l032 or |
| 98 | * spi_prettyprint_status_register_amic_a25lq032 if those have locks controlled |
| 99 | * by the second status register. |
| 100 | */ |