From 02437458a603c112e503abc63ad32b09cfbc23f3 Mon Sep 17 00:00:00 2001 From: Stefan Tauner Date: Mon, 1 Apr 2013 19:34:53 +0000 Subject: Refine granularity handling in preparation of AT45DB series support This adds a number of new granularitie and refines the handling of n-byte granularities by extracting the respective code into a helper function which reduces the pain of the above significantly. Corresponding to flashrom svn r1666. Signed-off-by: Stefan Tauner Acked-by: Carl-Daniel Hailfinger --- flash.h | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'flash.h') diff --git a/flash.h b/flash.h index f73f12e..6ff691a 100644 --- a/flash.h +++ b/flash.h @@ -59,18 +59,22 @@ enum chipbustype { }; /* - * The following write granularities are known: - * - 1 bit: Each bit can be cleared individually. - * - 1 byte: A byte can be written once. Further writes to an already written byte cause its 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. + * The following enum defines possible write granularities of flash chips. These tend to reflect the properties + * of the actual hardware not necesserily the write function(s) defined by the respective struct flashchip. + * The latter might (and should) be more precisely specified, e.g. they might bail out early if their execution + * would result in undefined chip contents. */ enum write_granularity { - write_gran_256bytes = 0, /* We assume 256 byte granularity by default. */ - write_gran_1bit, - write_gran_1byte, + /* We assume 256 byte granularity by default. */ + write_gran_256bytes = 0,/* If less than 256 bytes are written, the unwritten bytes are undefined. */ + write_gran_1bit, /* Each bit can be cleared individually. */ + write_gran_1byte, /* A byte can be written once. Further writes to an already written byte cause + * its contents to be either undefined or to stay unchanged. */ + write_gran_264bytes, /* If less than 264 bytes are written, the unwritten bytes are undefined. */ + write_gran_512bytes, /* If less than 512 bytes are written, the unwritten bytes are undefined. */ + write_gran_528bytes, /* If less than 528 bytes are written, the unwritten bytes are undefined. */ + write_gran_1024bytes, /* If less than 1024 bytes are written, the unwritten bytes are undefined. */ + write_gran_1056bytes, /* If less than 1056 bytes are written, the unwritten bytes are undefined. */ }; /* -- cgit v1.1