spi: Don't cross 16MiB boundaries with long writes

The 16MiB issue still bites us.  Originally, the core of flashprog never
sent more than an erase block at once to write. Now that we write bigger
chunks at once, after all necessary erasure, it can happen that we cross
16MiB boundaries. This is an issue with programmer drivers that can only
send 3-byte addresses.  We use the extended address register with these,
to select which 16MiB area is currently accessed. Should we try to write
across a 16MiB boundary, we'd write with stale extended-address register
contents (basically wrapping around).

This once more troubles old, V1 Dediprog SF100's. Where we can send huge
chunks at once and leave the sequencing to the programmer.  The program-
mer, however,  is unaware of the state of the extended-address register.
Other programmer drivers do the sequencing with  spi_write_chunked() and
shouldn't be affected.

To settle this issue,  copy the loop logic that we already used to avoid
the problem for long reads.

Tested with Dediprog "SF100   V:5.1.9".

Change-Id: I5b9d6779eff5224fb9981fd478dbc94262cd3262
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/115
Reviewed-by: Urja Rannikko <urjaman@gmail.com>
1 file changed