serprog: Add SPI Mode and CS Mode commands
This commit adds two new commands to the serprog protocol which allow
more fine grained control over the SPI bus. This enables more
applications over serprog like e.g. flashing AVR microcontrollers.
This can be tried with my forks of pico-serprog:
https://github.com/funkeleinhorn/pico-serprog/tree/spimode
and avrdude:
https://github.com/funkeleinhorn/avrgirl/tree/serprog-programmer
I announced this change in flashrom and flashprog IRC channels and got
overall positive feedback in the flashprog channel. The same changes
have been sent to flashrom to prevent diverging specs.
Change-Id: Ib2d2e7ca343f6433028bdc00390ba0980cca98a1
Signed-off-by: Funkeleinhorn <git@funkeleinhorn.com>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/107
Tested-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Nico Huber <nico.h@gmx.de>
diff --git a/Documentation/serprog-protocol.txt b/Documentation/serprog-protocol.txt
index 47e1071..f4e68a5 100644
--- a/Documentation/serprog-protocol.txt
+++ b/Documentation/serprog-protocol.txt
@@ -36,6 +36,8 @@
0x14 Set SPI clock frequency in Hz 32-bit requested frequency ACK + 32-bit set frequency / NAK
0x15 Toggle flash chip pin drivers 8-bit (0 disable, else enable) ACK / NAK
0x16 Set SPI Chip Select 8-bit ACK / NAK
+0x17 Set SPI Mode 8-bit ACK / NAK
+0x18 Set CS Mode 8-bit ACK / NAK
0x?? unimplemented command - invalid.
@@ -93,6 +95,21 @@
0x16 (S_SPI_CS):
Set which SPI Chip Select pin to use. This operation is immediate,
meaning it doesn't use the operation buffer.
+ 0x17 (S_SPI_MODE):
+ Set which SPI Mode to use for 0x13 O_SPIOP commands.
+ This operation is immediate, meaning it doesn't use the operation buffer.
+ The current defined modes are:
+ 0x00: SPI Half Duplex (default)
+ 0x01: SPI Full Duplex
+ 0x18 (S_CS_MODE):
+ Set which CS Mode to use. The CS Mode determines the CS behaviour.
+ This allows manual control over the CS.
+ This operation is immediate, meaning it doesn't use the operation buffer.
+ The current defined modes are:
+ 0x00: CS Auto Mode. The CS gets selected before 0x13 O_SPIOP commands and
+ deselected afterwards. (default)
+ 0x01: CS Selected. The CS will be selected until another mode is set.
+ 0x02: CS Deselected. The CS will be deselected until another mode is set.
About mandatory commands:
The only truly mandatory commands for any device are 0x00, 0x01, 0x02 and 0x10,
but one can't really do anything with these commands.