+static int hl_interface_khz(int khz, int *jtag_speed)
+{
+ if (hl_if.layout->api->speed == NULL)
+ return ERROR_OK;
+
+ *jtag_speed = hl_if.layout->api->speed(hl_if.handle, khz, true);
+ return ERROR_OK;
+}
+
+static int hl_interface_speed_div(int speed, int *khz)
+{
+ *khz = speed;
+ return ERROR_OK;
+}
+
+static int hl_interface_speed(int speed)
+{
+ if (hl_if.layout->api->speed == NULL)
+ return ERROR_OK;
+
+ if (hl_if.handle == NULL) {
+ /* pass speed as initial param as interface not open yet */
+ hl_if.param.initial_interface_speed = speed;
+ return ERROR_OK;
+ }
+
+ hl_if.layout->api->speed(hl_if.handle, speed, false);
+
+ return ERROR_OK;
+}
+
+int hl_interface_override_target(const char **targetname)
+{
+ if (hl_if.layout->api->override_target) {
+ if (hl_if.layout->api->override_target(*targetname)) {
+ *targetname = "hla_target";
+ return ERROR_OK;
+ } else
+ return ERROR_FAIL;
+ }
+ return ERROR_FAIL;
+}
+
+int hl_interface_config_trace(bool enabled, enum tpio_pin_protocol pin_protocol,
+ uint32_t port_size, unsigned int *trace_freq)
+{
+ if (hl_if.layout->api->config_trace)
+ return hl_if.layout->api->config_trace(hl_if.handle, enabled, pin_protocol,
+ port_size, trace_freq);
+ else if (enabled) {
+ LOG_ERROR("The selected interface does not support tracing");
+ return ERROR_FAIL;
+ }
+
+ return ERROR_OK;
+}
+
+int hl_interface_poll_trace(uint8_t *buf, size_t *size)
+{
+ if (hl_if.layout->api->poll_trace)
+ return hl_if.layout->api->poll_trace(hl_if.handle, buf, size);
+
+ return ERROR_FAIL;
+}
+