Flashrom

Flashrom Svn Source Tree

Root/trunk/a25.c

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
26static void spi_prettyprint_status_register_amic_a25_srwd(uint8_t status)
27{
28msg_cdbg("Chip status register: Status Register Write Disable "
29 "(SRWD) is %sset\n", (status & (1 << 7)) ? "" : "not ");
30}
31
32int spi_prettyprint_status_register_amic_a25l05p(struct flashctx *flash)
33{
34uint8_t status;
35
36status = spi_read_status_register(flash);
37msg_cdbg("Chip status register is %02x\n", status);
38
39spi_prettyprint_status_register_amic_a25_srwd(status);
40spi_prettyprint_status_register_bit(status, 6);
41spi_prettyprint_status_register_bit(status, 5);
42spi_prettyprint_status_register_bit(status, 4);
43spi_prettyprint_status_register_bp3210(status, 1);
44spi_prettyprint_status_register_welwip(status);
45return 0;
46}
47
48int spi_prettyprint_status_register_amic_a25l40p(struct flashctx *flash)
49{
50uint8_t status;
51
52status = spi_read_status_register(flash);
53msg_cdbg("Chip status register is %02x\n", status);
54
55spi_prettyprint_status_register_amic_a25_srwd(status);
56spi_prettyprint_status_register_bit(status, 6);
57spi_prettyprint_status_register_bit(status, 5);
58spi_prettyprint_status_register_bp3210(status, 2);
59spi_prettyprint_status_register_welwip(status);
60return 0;
61}
62
63int spi_prettyprint_status_register_amic_a25l032(struct flashctx *flash)
64{
65uint8_t status;
66
67status = spi_read_status_register(flash);
68msg_cdbg("Chip status register is %02x\n", status);
69
70spi_prettyprint_status_register_amic_a25_srwd(status);
71msg_cdbg("Chip status register: Sector Protect Size (SEC) "
72 "is %i KB\n", (status & (1 << 6)) ? 4 : 64);
73msg_cdbg("Chip status register: Top/Bottom (TB) "
74 "is %s\n", (status & (1 << 5)) ? "bottom" : "top");
75spi_prettyprint_status_register_bp3210(status, 2);
76spi_prettyprint_status_register_welwip(status);
77msg_cdbg("Chip status register 2 is NOT decoded!\n");
78return 0;
79}
80
81int spi_prettyprint_status_register_amic_a25lq032(struct flashctx *flash)
82{
83uint8_t status;
84
85status = spi_read_status_register(flash);
86msg_cdbg("Chip status register is %02x\n", status);
87
88spi_prettyprint_status_register_amic_a25_srwd(status);
89msg_cdbg("Chip status register: Sector Protect Size (SEC) "
90 "is %i KB\n", (status & (1 << 6)) ? 4 : 64);
91msg_cdbg("Chip status register: Top/Bottom (TB) "
92 "is %s\n", (status & (1 << 5)) ? "bottom" : "top");
93spi_prettyprint_status_register_bp3210(status, 2);
94spi_prettyprint_status_register_welwip(status);
95msg_cdbg("Chip status register 2 is NOT decoded!\n");
96return 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 */
107

Archive Download this file

Revision: HEAD