spi25_statusreg: Allow to write (non-)volatile bits specifically

There's a subtle difference between prepending a write-status-register
command with a write enable (WREN)  or an enable write status register
(EWSR): The former targets non-volatile bits, while the latter targets
volatile bits, i.e. register bits that do not survive a reset.

Sometimes bits are implemented as both volatile and non-volatile. Then,
the non-volatile state is loaded into the volatile registers after chip
reset, and writes with a WREN target both.  So far, we simply used WREN
when possible.  This can, however, lead to unnecessary wear of the non-
volatile bits. Flash datasheets do not mention any maximum write cycles
for them. However, it is unclear if this is an academic issue, i.e. the
manufacturers account for the wear and implement redundancy, or if they
simply don't expect that many configuration changes.

For a start, allow to specify explicitly which kind of register bits we
want to write. We keep the current behavior. However, the logic to dis-
able block protections automatically should be revised  to prefer vola-
tile writes.

Change-Id: I807a2c48f4eaa85d5a10b37362e71818359a4c93
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/190
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/writeprotect.c b/writeprotect.c
index 5424518..302451b 100644
--- a/writeprotect.c
+++ b/writeprotect.c
@@ -169,7 +169,7 @@
 
 		value = (value & ~write_masks[reg]) | expected;
 
-		if (spi_write_register(flash, reg, value))
+		if (spi_write_register(flash, reg, value, WRSR_EITHER))
 			return FLASHPROG_WP_ERR_WRITE_FAILED;
 	}