David Hendricks | 23cd778 | 2010-08-25 12:42:38 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 24 | struct 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 Lo | c19d3c5 | 2010-10-08 11:59:16 +0800 | [diff] [blame] | 29 | int (*disable)(struct flashchip *flash); |
Louis Yung-Chieh Lo | a92e8b2 | 2010-10-08 13:31:27 +0800 | [diff] [blame] | 30 | int (*wp_status)(struct flashchip *flash); |
David Hendricks | 23cd778 | 2010-08-25 12:42:38 -0700 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | /* winbond w25-series */ |
| 34 | extern struct wp wp_w25; |
| 35 | extern struct wp wp_wpce775x; |
| 36 | |
| 37 | struct 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 Lo | a92e8b2 | 2010-10-08 13:31:27 +0800 | [diff] [blame] | 52 | int w25_range_to_status(const struct flashchip *flash, |
| 53 | unsigned int start, unsigned int len, |
| 54 | struct w25q_status *status); |
| 55 | int w25_status_to_range(const struct flashchip *flash, |
| 56 | const struct w25q_status *status, |
| 57 | unsigned int *start, unsigned int *len); |
David Hendricks | 23cd778 | 2010-08-25 12:42:38 -0700 | [diff] [blame] | 58 | |
| 59 | #endif /* !__WRITEPROTECT_H__ */ |