jtagspi/pld: add support from gatemate driver 38/7838/11
authorDaniel Anselmi <danselmi@gmx.ch>
Sat, 17 Dec 2022 12:11:30 +0000 (13:11 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 23 Sep 2023 14:35:51 +0000 (14:35 +0000)
Provide jtagspi with specific procedures to be able to
use jtagspi for programming spi-flash devices on cologne
chip gatemate devices.

Change-Id: Ifa1c4ca6e215d7f49bd21620898991af213812e9
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7838
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
src/pld/gatemate.c
tcl/board/gatemate_eval.cfg

index 4ad2665c6a80854f78c69b126c2b79cb4acd52ee..f35b39ad214c1e7015e27a59e37eea6fa956cade 100644 (file)
@@ -15,6 +15,8 @@
 #include "raw_bit.h"
 
 #define JTAG_CONFIGURE  0x06
+#define JTAG_SPI_BYPASS 0x05
+#define BYPASS          0x3F
 
 struct gatemate_pld_device {
        struct jtag_tap *tap;
@@ -209,6 +211,66 @@ static int gatemate_load(struct pld_device *pld_device, const char *filename)
        return retval;
 }
 
+static int gatemate_has_jtagspi_instruction(struct pld_device *device, bool *has_instruction)
+{
+       *has_instruction = true;
+       return ERROR_OK;
+}
+
+static int gatemate_connect_spi_to_jtag(struct pld_device *pld_device)
+{
+       if (!pld_device)
+               return ERROR_FAIL;
+
+       struct gatemate_pld_device *pld_device_info = pld_device->driver_priv;
+       if (!pld_device_info)
+               return ERROR_FAIL;
+
+       struct jtag_tap *tap = pld_device_info->tap;
+       if (!tap)
+               return ERROR_FAIL;
+
+       if (buf_get_u32(tap->cur_instr, 0, tap->ir_length) == JTAG_SPI_BYPASS)
+               return ERROR_OK;
+
+       gatemate_set_instr(tap, JTAG_SPI_BYPASS);
+
+       return jtag_execute_queue();
+}
+
+static int gatemate_disconnect_spi_from_jtag(struct pld_device *pld_device)
+{
+       if (!pld_device)
+               return ERROR_FAIL;
+
+       struct gatemate_pld_device *pld_device_info = pld_device->driver_priv;
+       if (!pld_device_info)
+               return ERROR_FAIL;
+
+       struct jtag_tap *tap = pld_device_info->tap;
+       if (!tap)
+               return ERROR_FAIL;
+
+       if (buf_get_u32(tap->cur_instr, 0, tap->ir_length) != JTAG_SPI_BYPASS)
+               return ERROR_OK;
+
+       gatemate_set_instr(tap, BYPASS);
+
+       return jtag_execute_queue();
+}
+
+static int gatemate_get_stuff_bits(struct pld_device *pld_device, unsigned int *facing_read_bits,
+                                                                       unsigned int *trailing_write_bits)
+{
+       if (!pld_device)
+               return ERROR_FAIL;
+
+       *facing_read_bits = 1;
+       *trailing_write_bits = 1;
+
+       return ERROR_OK;
+}
+
 PLD_CREATE_COMMAND_HANDLER(gatemate_pld_create_command)
 {
        if (CMD_ARGC != 4)
@@ -239,4 +301,8 @@ struct pld_driver gatemate_pld = {
        .name = "gatemate",
        .pld_create_command = &gatemate_pld_create_command,
        .load = &gatemate_load,
+       .has_jtagspi_instruction = gatemate_has_jtagspi_instruction,
+       .connect_spi_to_jtag = gatemate_connect_spi_to_jtag,
+       .disconnect_spi_from_jtag = gatemate_disconnect_spi_from_jtag,
+       .get_stuff_bits = gatemate_get_stuff_bits,
 };
index cc078a0e303556f40d69b4e284dbfee32d3fe256..c4d3f3dfdabc884a1c7496819d7172884a49d47d 100644 (file)
@@ -14,3 +14,9 @@ transport select jtag
 adapter speed 6000
 
 source [find fpga/gatemate.cfg]
+
+set JTAGSPI_CHAIN_ID gatemate.pld
+source [find cpld/jtagspi.cfg]
+
+#jtagspi_init gatemate.pld "" -1
+#jtagspi_program workspace/blink/blink_slow.cfg.bit 0

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)