From e8e369fcc38b374e8385e3415335bfcb87deb55f Mon Sep 17 00:00:00 2001 From: Carl-Daniel Hailfinger Date: Mon, 8 Mar 2010 00:42:32 +0000 Subject: Write granularity is chip specific The following write granularities exist according to my datasheet survey: - 1 bit. Each bit can be cleared individually. - 1 byte. A byte can be written once. Further writes to an already written byte cause the contents to be either undefined or to stay unchanged. - 128 bytes. If less than 128 bytes are written, the rest will be erased. Each write to a 128-byte region will trigger an automatic erase before anything is written. Very uncommon behaviour. - 256 bytes. If less than 256 bytes are written, the contents of the unwritten bytes are undefined. Note that chips with default 256-byte writes, which keep the original contents for unwritten bytes, have a granularity of 1 byte. Handle 1-bit, 1-byte and 256-byte write granularity. Corresponding to flashrom svn r927. Signed-off-by: Carl-Daniel Hailfinger Acked-by: Sean Nelson Acked-by: David Hendricks --- flash.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'flash.h') diff --git a/flash.h b/flash.h index 2065b3a..34b04e6 100644 --- a/flash.h +++ b/flash.h @@ -512,6 +512,11 @@ int dediprog_spi_send_command(unsigned int writecnt, unsigned int readcnt, const int dediprog_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); /* flashrom.c */ +enum write_granularity { + write_gran_1bit, + write_gran_1byte, + write_gran_256bytes, +}; extern enum chipbustype buses_supported; struct decode_sizes { uint32_t parallel; @@ -538,6 +543,7 @@ int max(int a, int b); char *extract_param(char **haystack, char *needle, char *delim); int check_erased_range(struct flashchip *flash, int start, int len); int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len, char *message); +int need_erase(uint8_t *have, uint8_t *want, int len, enum write_granularity gran); char *strcat_realloc(char *dest, const char *src); void print_version(void); int selfcheck(void); -- cgit v1.1