From 2a5d2920d8817f1bc7e479a2ed868a6e2a46dcbe Mon Sep 17 00:00:00 2001 From: Funkeleinhorn Date: Sat, 23 Mar 2024 04:41:55 +0100 Subject: [PATCH] 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 Reviewed-on: https://review.coreboot.org/c/flashrom/+/81428 Reviewed-by: Anastasia Klimchuk Tested-by: build bot (Jenkins) --- Documentation/serprog-protocol.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Documentation/serprog-protocol.txt b/Documentation/serprog-protocol.txt index 3d4aa1a9c..d001cebb1 100644 --- a/Documentation/serprog-protocol.txt +++ b/Documentation/serprog-protocol.txt @@ -36,6 +36,8 @@ COMMAND Description Parameters Return Value 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 @@ Additional information of the above commands: 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.