blob: a7469e49fdad5d59572fde8372e92162ea3cd20a [file] [log] [blame]
David Hendricks23cd7782010-08-25 12:42:38 -07001/*
2 * This file is part of the flashrom project.
3 *
4 * Copyright (C) 2010 Google Inc.
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; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef __WRITEPROTECT_H__
22#define __WRITEPROTECT_H__ 1
23
24struct wp {
25 int (*list_ranges)(struct flashchip *flash);
26 int (*set_range)(struct flashchip *flash,
27 unsigned int start, unsigned int len);
28 int (*enable)(struct flashchip *flash);
Louis Yung-Chieh Loc19d3c52010-10-08 11:59:16 +080029 int (*disable)(struct flashchip *flash);
Louis Yung-Chieh Loa92e8b22010-10-08 13:31:27 +080030 int (*wp_status)(struct flashchip *flash);
David Hendricks23cd7782010-08-25 12:42:38 -070031};
32
33/* winbond w25-series */
34extern struct wp wp_w25;
35extern struct wp wp_wpce775x;
36
37struct w25q_status {
38 /* this maps to register layout -- do not change ordering */
39 unsigned char busy : 1;
40 unsigned char wel : 1;
41 unsigned char bp0 : 1;
42 unsigned char bp1 : 1;
43 unsigned char bp2 : 1;
44 unsigned char tb : 1;
45 unsigned char sec : 1;
46 unsigned char srp0 : 1;
47 /* FIXME: what about the second status register? */
48// unsigned char srp1 : 1;
49// unsigned char qe : 1;
50} __attribute__ ((packed));
51
Louis Yung-Chieh Loa92e8b22010-10-08 13:31:27 +080052int w25_range_to_status(const struct flashchip *flash,
53 unsigned int start, unsigned int len,
54 struct w25q_status *status);
55int w25_status_to_range(const struct flashchip *flash,
56 const struct w25q_status *status,
57 unsigned int *start, unsigned int *len);
David Hendricks23cd7782010-08-25 12:42:38 -070058
59#endif /* !__WRITEPROTECT_H__ */