This is an automated email from Gerrit.

Marc Schink ([email protected]) just uploaded a new patch set to 
Gerrit, which you can find at http://openocd.zylin.com/2955

-- gerrit

commit d6630a71e1f77e177d0ac268e0901fed0aa58b58
Author: Marc Schink <[email protected]>
Date:   Mon Sep 21 14:27:49 2015 +0200

    jlink: Retrieve maximum speed from device.
    
    If supported, the maximum transport speed is now retrieved from the
    device.
    
    Change-Id: I614f405ec91cf199c851781785fd26cbd10c37a6
    Signed-off-by: Marc Schink <[email protected]>

diff --git a/src/jtag/drivers/jlink.c b/src/jtag/drivers/jlink.c
index 1db1a71..807bdba 100644
--- a/src/jtag/drivers/jlink.c
+++ b/src/jtag/drivers/jlink.c
@@ -216,11 +216,23 @@ static int jlink_execute_queue(void)
 static int jlink_speed(int speed)
 {
        int ret;
+       uint32_t freq;
+       uint16_t div;
+       int max_speed;
+
+       if (jaylink_has_cap(caps, JAYLINK_DEV_CAP_GET_SPEEDS)) {
+               ret = jaylink_get_speeds(devh, &freq, &div);
 
-       if (speed > JLINK_MAX_SPEED) {
-               LOG_INFO("Reduce speed from %d kHz to %d kHz (maximum).", speed,
-                       JLINK_MAX_SPEED);
-               speed = JLINK_MAX_SPEED;
+               if (ret != JAYLINK_OK) {
+                       LOG_ERROR("jaylink_get_speeds() failed: %s.",
+                               jaylink_strerror_name(ret));
+                       return ERROR_JTAG_DEVICE_ERROR;
+               }
+
+               freq = freq / 1000;
+               max_speed = freq / div;
+       } else {
+               max_speed = JLINK_MAX_SPEED;
        }
 
        if (!speed) {
@@ -230,6 +242,10 @@ static int jlink_speed(int speed)
                }
 
                speed = JAYLINK_SPEED_ADAPTIVE_CLOCKING;
+       } else if (speed > max_speed) {
+               LOG_INFO("Reduced speed from %d kHz to %d kHz (maximum).", 
speed,
+                       max_speed);
+               speed = max_speed;
        }
 
        ret = jaylink_set_speed(devh, speed);

-- 

------------------------------------------------------------------------------
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to