Skip to content

Commit df957c5

Browse files
author
stefanct
committed
serprog: add opcode to control the programmer's output drivers.
This allowed me to let the clips remain attached on my D946GZIS while playing with coreboot/serialice. Signed-off-by: Stefan Tauner <[email protected]> Acked-by: Stefan Tauner <[email protected]>
1 parent e750c91 commit df957c5

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

Documentation/serprog-protocol.txt

+7
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ COMMAND Description Parameters Return Value
3434
0x13 Perform SPI operation 24-bit slen + 24-bit rlen ACK + rlen bytes of data / NAK
3535
+ slen bytes of data
3636
0x14 Set SPI clock frequency in Hz 32-bit requested frequency ACK + 32-bit set frequency / NAK
37+
0x15 Toggle flash chip pin drivers 8-bit (0 disable, else enable) ACK / NAK
3738
0x?? unimplemented command - invalid.
3839

3940

@@ -82,6 +83,12 @@ Additional information of the above commands:
8283
lower than the one requested. If there is no lower frequency
8384
available the lowest possible should be used. The value
8485
chosen is sent back in the reply with an ACK.
86+
0x15 (S_CMD_S_PIN_STATE):
87+
Sets the state of the pin drivers connected to the flash chip. Disabling them allows other
88+
devices (e.g. a mainboard's chipset) to access the chip. This way the serprog controller can
89+
remain attached to the flash chip even when the board is running. The user is responsible to
90+
NOT connect VCC and other permanently externally driven signals to the programmer as needed.
91+
If the value is 0, then the drivers should be disabled, otherwise they should be enabled.
8592
About mandatory commands:
8693
The only truly mandatory commands for any device are 0x00, 0x01, 0x02 and 0x10,
8794
but one can't really do anything with these commands.

serprog.c

+16-1
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,15 @@ int serprog_init(void)
664664
sp_device_opbuf_size);
665665
}
666666

667+
if (sp_check_commandavail(S_CMD_S_PIN_STATE)) {
668+
uint8_t en = 1;
669+
if (sp_docommand(S_CMD_S_PIN_STATE, 1, &en, 0, NULL) != 0) {
670+
msg_perr("Error: could not enable output buffers\n");
671+
return 1;
672+
} else
673+
msg_pdbg(MSGHEADER "Output drivers enabled\n");
674+
} else
675+
msg_pdbg(MSGHEADER "Warning: Programmer does not support toggling its output drivers\n");
667676
sp_prev_was_write = 0;
668677
sp_streamed_transmit_ops = 0;
669678
sp_streamed_transmit_bytes = 0;
@@ -736,9 +745,15 @@ static void sp_execute_opbuf(void)
736745

737746
static int serprog_shutdown(void *data)
738747
{
739-
msg_pspew("%s\n", __func__);
740748
if ((sp_opbuf_usage) || (sp_max_write_n && sp_write_n_bytes))
741749
sp_execute_opbuf();
750+
if (sp_check_commandavail(S_CMD_S_PIN_STATE)) {
751+
uint8_t dis = 0;
752+
if (sp_docommand(S_CMD_S_PIN_STATE, 1, &dis, 0, NULL) == 0)
753+
msg_pdbg(MSGHEADER "Output drivers disabled\n");
754+
else
755+
msg_perr(MSGHEADER "%s: Warning: could not disable output buffers\n", __func__);
756+
}
742757
/* FIXME: fix sockets on windows(?), especially closing */
743758
serialport_shutdown(&sp_fd);
744759
if (sp_max_write_n)

serprog.h

+1
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@
2222
#define S_CMD_S_BUSTYPE 0x12 /* Set used bustype(s). */
2323
#define S_CMD_O_SPIOP 0x13 /* Perform SPI operation. */
2424
#define S_CMD_S_SPI_FREQ 0x14 /* Set SPI clock frequency */
25+
#define S_CMD_S_PIN_STATE 0x15 /* Enable/disable output drivers */

0 commit comments

Comments
 (0)