Anastasia Klimchuk submitted this change.

View Change

Approvals: Anastasia Klimchuk: Looks good to me, approved build bot (Jenkins): Verified
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
will be sent to flashprog to prevent diverging specs.

Change-Id: Idb5a9a3710fede322def5191d68b7fba0e135292
Signed-off-by: Funkeleinhorn <git@funkeleinhorn.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/81428
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
---
M Documentation/serprog-protocol.txt
1 file changed, 17 insertions(+), 0 deletions(-)

diff --git a/Documentation/serprog-protocol.txt b/Documentation/serprog-protocol.txt
index 3d4aa1a..d001ceb 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.

To view, visit change 81428. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: main
Gerrit-Change-Id: Idb5a9a3710fede322def5191d68b7fba0e135292
Gerrit-Change-Number: 81428
Gerrit-PatchSet: 2
Gerrit-Owner: Funkeleinhorn <git@funkeleinhorn.com>
Gerrit-Reviewer: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-Reviewer: Urja Rannikko <urjaman@gmail.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-MessageType: merged