blob: 8c38f87204c7cc58ba8c684e481f16e293e2182e [file] [log] [blame]
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +00001/*
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
Stefan Taunere9ccad52011-07-29 12:06:04 +000026static void spi_prettyprint_status_register_amic_a25_srwd(uint8_t status)
27{
28 msg_cdbg("Chip status register: Status Register Write Disable "
29 "(SRWD) is %sset\n", (status & (1 << 7)) ? "" : "not ");
30}
31
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000032int spi_prettyprint_status_register_amic_a25l05p(struct flashctx *flash)
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000033{
34 uint8_t status;
35
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +000036 status = spi_read_status_register(flash);
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000037 msg_cdbg("Chip status register is %02x\n", status);
38
Stefan Taunere9ccad52011-07-29 12:06:04 +000039 spi_prettyprint_status_register_amic_a25_srwd(status);
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000040 spi_prettyprint_status_register_bit(status, 6);
41 spi_prettyprint_status_register_bit(status, 5);
42 spi_prettyprint_status_register_bit(status, 4);
Stefan Tauner1ba08f62012-08-02 23:51:28 +000043 spi_prettyprint_status_register_bp(status, 1);
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000044 spi_prettyprint_status_register_welwip(status);
45 return 0;
46}
47
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000048int spi_prettyprint_status_register_amic_a25l40p(struct flashctx *flash)
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000049{
50 uint8_t status;
51
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +000052 status = spi_read_status_register(flash);
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000053 msg_cdbg("Chip status register is %02x\n", status);
54
Stefan Taunere9ccad52011-07-29 12:06:04 +000055 spi_prettyprint_status_register_amic_a25_srwd(status);
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000056 spi_prettyprint_status_register_bit(status, 6);
57 spi_prettyprint_status_register_bit(status, 5);
Stefan Tauner1ba08f62012-08-02 23:51:28 +000058 spi_prettyprint_status_register_bp(status, 2);
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000059 spi_prettyprint_status_register_welwip(status);
60 return 0;
61}
62
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000063int spi_prettyprint_status_register_amic_a25l032(struct flashctx *flash)
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000064{
65 uint8_t status;
66
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +000067 status = spi_read_status_register(flash);
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000068 msg_cdbg("Chip status register is %02x\n", status);
69
Stefan Taunere9ccad52011-07-29 12:06:04 +000070 spi_prettyprint_status_register_amic_a25_srwd(status);
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000071 msg_cdbg("Chip status register: Sector Protect Size (SEC) "
72 "is %i KB\n", (status & (1 << 6)) ? 4 : 64);
73 msg_cdbg("Chip status register: Top/Bottom (TB) "
74 "is %s\n", (status & (1 << 5)) ? "bottom" : "top");
Stefan Tauner1ba08f62012-08-02 23:51:28 +000075 spi_prettyprint_status_register_bp(status, 2);
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000076 spi_prettyprint_status_register_welwip(status);
77 msg_cdbg("Chip status register 2 is NOT decoded!\n");
78 return 0;
79}
80
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000081int spi_prettyprint_status_register_amic_a25lq032(struct flashctx *flash)
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000082{
83 uint8_t status;
84
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +000085 status = spi_read_status_register(flash);
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000086 msg_cdbg("Chip status register is %02x\n", status);
87
Stefan Taunere9ccad52011-07-29 12:06:04 +000088 spi_prettyprint_status_register_amic_a25_srwd(status);
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000089 msg_cdbg("Chip status register: Sector Protect Size (SEC) "
90 "is %i KB\n", (status & (1 << 6)) ? 4 : 64);
91 msg_cdbg("Chip status register: Top/Bottom (TB) "
92 "is %s\n", (status & (1 << 5)) ? "bottom" : "top");
Stefan Tauner1ba08f62012-08-02 23:51:28 +000093 spi_prettyprint_status_register_bp(status, 2);
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000094 spi_prettyprint_status_register_welwip(status);
95 msg_cdbg("Chip status register 2 is NOT decoded!\n");
96 return 0;
97}
98
99/* FIXME: spi_disable_blockprotect is incorrect but works fine for chips using
100 * spi_prettyprint_status_register_amic_a25l05p or
101 * spi_prettyprint_status_register_amic_a25l40p.
102 * FIXME: spi_disable_blockprotect is incorrect and will fail for chips using
103 * spi_prettyprint_status_register_amic_a25l032 or
104 * spi_prettyprint_status_register_amic_a25lq032 if those have locks controlled
105 * by the second status register.
106 */