jtagspi/pld: add interface to get support from pld drivers
[openocd.git] / src / pld / pld.c
index c375418a9d040833a7adf5ee2ffc826db5bb8dfb..81fb0c46321708673864ae591df9822b968c1943 100644 (file)
@@ -69,8 +69,95 @@ struct pld_device *get_pld_device_by_name_or_numstr(const char *str)
        return get_pld_device_by_num(dev_num);
 }
 
-/* @deffn {Config Command} {pld create} pld_name driver -chain-position tap_name [options]
-*/
+
+int pld_has_jtagspi_instruction(struct pld_device *pld_device, bool *has_instruction)
+{
+       *has_instruction = false; /* default is using a proxy bitstream */
+
+       if (!pld_device)
+               return ERROR_FAIL;
+
+       struct pld_driver *pld_driver = pld_device->driver;
+       if (!pld_driver) {
+               LOG_ERROR("pld device has no associated driver");
+               return ERROR_FAIL;
+       }
+
+       if (pld_driver->has_jtagspi_instruction)
+               return pld_driver->has_jtagspi_instruction(pld_device, has_instruction);
+    /* else, take the default (proxy bitstream) */
+       return ERROR_OK;
+}
+
+int pld_get_jtagspi_userircode(struct pld_device *pld_device, unsigned int *ir)
+{
+       if (!pld_device)
+               return ERROR_FAIL;
+
+       struct pld_driver *pld_driver = pld_device->driver;
+       if (!pld_driver) {
+               LOG_ERROR("pld device has no associated driver");
+               return ERROR_FAIL;
+       }
+
+       if (pld_driver->get_jtagspi_userircode)
+               return pld_driver->get_jtagspi_userircode(pld_device, ir);
+
+       return ERROR_FAIL;
+}
+
+int pld_get_jtagspi_stuff_bits(struct pld_device *pld_device, unsigned int *facing_read_bits,
+                                                       unsigned int *trailing_write_bits)
+{
+       if (!pld_device)
+               return ERROR_FAIL;
+
+       struct pld_driver *pld_driver = pld_device->driver;
+       if (!pld_driver) {
+               LOG_ERROR("pld device has no associated driver");
+               return ERROR_FAIL;
+       }
+
+       if (pld_driver->get_stuff_bits)
+               return pld_driver->get_stuff_bits(pld_device, facing_read_bits, trailing_write_bits);
+
+       return ERROR_OK;
+}
+
+int pld_connect_spi_to_jtag(struct pld_device *pld_device)
+{
+       if (!pld_device)
+               return ERROR_FAIL;
+
+       struct pld_driver *pld_driver = pld_device->driver;
+       if (!pld_driver) {
+               LOG_ERROR("pld device has no associated driver");
+               return ERROR_FAIL;
+       }
+
+       if (pld_driver->connect_spi_to_jtag)
+               return pld_driver->connect_spi_to_jtag(pld_device);
+
+       return ERROR_FAIL;
+}
+
+int pld_disconnect_spi_from_jtag(struct pld_device *pld_device)
+{
+       if (!pld_device)
+               return ERROR_FAIL;
+
+       struct pld_driver *pld_driver = pld_device->driver;
+       if (!pld_driver) {
+               LOG_ERROR("pld device has no associated driver");
+               return ERROR_FAIL;
+       }
+
+       if (pld_driver->disconnect_spi_from_jtag)
+               return pld_driver->disconnect_spi_from_jtag(pld_device);
+
+       return ERROR_FAIL;
+}
+
 COMMAND_HANDLER(handle_pld_create_command)
 {
        if (CMD_ARGC < 2)

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)