target/armv7m_trace: Calculate prescaler for external capture devices
[fw/openocd] / src / jtag / drivers / jlink.c
index 80202ed29cb0bf861148929fab7c4096e7ff9bce..1baf3454e3f3aae3adfaf9e5519e8b82a7dc5995 100644 (file)
@@ -1324,18 +1324,16 @@ static int config_trace(bool enabled, enum tpiu_pin_protocol pin_protocol,
        uint32_t min_freq;
        uint32_t max_freq;
 
+       trace_enabled = enabled;
+
        if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_SWO)) {
-               LOG_ERROR("Trace capturing is not supported by the device.");
-               return ERROR_FAIL;
-       }
+               if (!enabled)
+                       return ERROR_OK;
 
-       if (pin_protocol != TPIU_PIN_PROTOCOL_ASYNC_UART) {
-               LOG_ERROR("Selected pin protocol is not supported.");
+               LOG_ERROR("Trace capturing is not supported by the device.");
                return ERROR_FAIL;
        }
 
-       trace_enabled = enabled;
-
        ret = jaylink_swo_stop(devh);
 
        if (ret != JAYLINK_OK) {
@@ -1354,6 +1352,11 @@ static int config_trace(bool enabled, enum tpiu_pin_protocol pin_protocol,
                return ERROR_OK;
        }
 
+       if (pin_protocol != TPIU_PIN_PROTOCOL_ASYNC_UART) {
+               LOG_ERROR("Selected pin protocol is not supported.");
+               return ERROR_FAIL;
+       }
+
        buffer_size = calculate_trace_buffer_size();
 
        if (!buffer_size) {