]> git.sur5r.net Git - openocd/commitdiff
nds32: Avoid detected JTAG clock
authorHellosun Wu <wujiheng.tw@gmail.com>
Wed, 8 Nov 2017 09:04:11 +0000 (17:04 +0800)
committerTomas Vanek <vanekt@fbl.cz>
Wed, 18 Jul 2018 20:06:51 +0000 (21:06 +0100)
AICE2 doesn't support scan for the maximum clock frequency of
JTAG chain. It will cause USB command timeout.

Change-Id: I41d1e3be387b6ed5a4dd0be663385a5f053fbcf9
Signed-off-by: Hellosun Wu <wujiheng.tw@gmail.com>
Reviewed-on: http://openocd.zylin.com/4292
Tested-by: jenkins
Reviewed-by: Hsiangkai Wang <hsiangkai@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
src/jtag/aice/aice_usb.c
src/jtag/aice/aice_usb.h

index 50468f375aea977003abe6dca26a4d009d77035f..d77b26b17473d19fe08b967ae6985ff62cf87387 100644 (file)
@@ -2289,37 +2289,39 @@ get_delay:
 
 static int aice_usb_set_clock(int set_clock)
 {
-       if (aice_write_ctrl(AICE_WRITE_CTRL_TCK_CONTROL,
-                               AICE_TCK_CONTROL_TCK_SCAN) != ERROR_OK)
-               return ERROR_FAIL;
+       if (set_clock & AICE_TCK_CONTROL_TCK_SCAN) {
+               if (aice_write_ctrl(AICE_WRITE_CTRL_TCK_CONTROL,
+                                       AICE_TCK_CONTROL_TCK_SCAN) != ERROR_OK)
+                       return ERROR_FAIL;
 
-       /* Read out TCK_SCAN clock value */
-       uint32_t scan_clock;
-       if (aice_read_ctrl(AICE_READ_CTRL_GET_ICE_STATE, &scan_clock) != ERROR_OK)
-               return ERROR_FAIL;
+               /* Read out TCK_SCAN clock value */
+               uint32_t scan_clock;
+               if (aice_read_ctrl(AICE_READ_CTRL_GET_ICE_STATE, &scan_clock) != ERROR_OK)
+                       return ERROR_FAIL;
 
-       scan_clock &= 0x0F;
+               scan_clock &= 0x0F;
 
-       uint32_t scan_base_freq;
-       if (scan_clock & 0x8)
-               scan_base_freq = 48000; /* 48 MHz */
-       else
-               scan_base_freq = 30000; /* 30 MHz */
+               uint32_t scan_base_freq;
+               if (scan_clock & 0x8)
+                       scan_base_freq = 48000; /* 48 MHz */
+               else
+                       scan_base_freq = 30000; /* 30 MHz */
 
-       uint32_t set_base_freq;
-       if (set_clock & 0x8)
-               set_base_freq = 48000;
-       else
-               set_base_freq = 30000;
+               uint32_t set_base_freq;
+               if (set_clock & 0x8)
+                       set_base_freq = 48000;
+               else
+                       set_base_freq = 30000;
 
-       uint32_t set_freq;
-       uint32_t scan_freq;
-       set_freq = set_base_freq >> (set_clock & 0x7);
-       scan_freq = scan_base_freq >> (scan_clock & 0x7);
+               uint32_t set_freq;
+               uint32_t scan_freq;
+               set_freq = set_base_freq >> (set_clock & 0x7);
+               scan_freq = scan_base_freq >> (scan_clock & 0x7);
 
-       if (scan_freq < set_freq) {
-               LOG_ERROR("User specifies higher jtag clock than TCK_SCAN clock");
-               return ERROR_FAIL;
+               if (scan_freq < set_freq) {
+                       LOG_ERROR("User specifies higher jtag clock than TCK_SCAN clock");
+                       return ERROR_FAIL;
+               }
        }
 
        if (aice_write_ctrl(AICE_WRITE_CTRL_TCK_CONTROL, set_clock) != ERROR_OK)
index 2911ae56bd87876332bd5608883bfdbd1454912a..15cc1f60d2b3280839ec45f7f2663965ec3f97b5 100644 (file)
@@ -71,6 +71,7 @@
 
 /* Constants for AICE command WRITE_CTRL:TCK_CONTROL */
 #define AICE_TCK_CONTROL_TCK3048               0x08
+#define AICE_TCK_CONTROL_TCK_SCAN              0x10
 
 /* Constants for AICE command WRITE_CTRL:JTAG_PIN_CONTROL */
 #define AICE_JTAG_PIN_CONTROL_SRST             0x01