Add prepare/finish_access() hooks for chip drivers

Some of the arrangements we perform in prepare_flash_access()
are actually specific to the flash chip. Allow to clean that
up by adding respective hooks into `struct flashchip`.

Change-Id: Iff79ba3d190dba04ecf58c5c53faa428bf592bdf
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/72516
diff --git a/include/flash.h b/include/flash.h
index 31d9a1c..7afdf32 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -210,6 +210,10 @@
 
 struct wp_bits;
 
+enum preparation_steps {
+	PREPARE_FULL,
+};
+
 struct flashchip {
 	const char *vendor;
 	const char *name;
@@ -324,6 +328,9 @@
 	/* Function that takes a set of WP config bits (e.g. BP, SEC, TB, etc) */
 	/* and determines what protection range they select. */
 	void (*decode_range)(size_t *start, size_t *len, const struct wp_bits *, size_t chip_len);
+
+	int (*prepare_access)(struct flashctx *, enum preparation_steps);
+	void (*finish_access)(struct flashctx *);
 };
 
 typedef int (*chip_restore_fn_cb_t)(struct flashctx *flash, uint8_t status);