I have committed this patch to set default wait clocks for ICE-100B cable.

Jie
  * src/tap/cable/ice100.c (ice100b_set_freq): Set cable->frequency.
  * src/bfin/bfin-part-bfin.c (bfin_wait_ready): Set default wait clocks
    for ICE-100B cable.

Index: src/tap/cable/ice100.c
===================================================================
--- src/tap/cable/ice100.c	(revision 1977)
+++ src/tap/cable/ice100.c	(working copy)
@@ -272,6 +272,7 @@ static void ice100b_set_freq (urj_cable_
              * the defined settings, but ends up there */
             params->cur_freq = freq;
             do_single_reg_value (cable, REG_FREQ, 1, 1, freq_set[idx]);
+            cable->frequency = params->cur_freq;
         }
     }
 }
Index: src/bfin/bfin-part-bfin.c
===================================================================
--- src/bfin/bfin-part-bfin.c	(revision 1977)
+++ src/bfin/bfin-part-bfin.c	(working copy)
@@ -202,18 +202,19 @@ bfin_wait_ready (void *data)
 {
     urj_chain_t *chain = (urj_chain_t *) data;
 
-    /* When CCLK is 62MHz and SCLK is 31MHz, which is the lowest frequency I
-       can set in bf537 stamp linux kernel, set the gnICE+ cable frequency to
-       15MHz (current default), --wait-clocks >= 12 is required.
+    /* The following default numbers of wait clock for various cables are
+       tested on a BF537 stamp board, on which U-Boot is running.
+       CCLK is set to 62MHz and SCLK is set to 31MHz, which is the lowest
+       frequency I can set in BF537 stamp Linux kernel.
 
-       When CCLK is 62MHz and SCLK is 31MHz, set the gnICE+ cable frequency to
-       30MHz, --wait-clocks >= 21 is required.
+       The test is done by dumping memory from 0x20000000 to 0x20000010 using
+       GDB and gdbproxy:
 
-       When CCLK is 62MHz and SCLK is 31MHz, set the gnICE+ cable frequency to
-       6MHz (default), --wait-clocks >= 5 is required.
+       (gdb) dump memory u-boot.bin 0x20000000 0x20000010
+       (gdb) shell hexdump -C u-boot.bin
 
-       When CCLK is 62MHz and SCLK is 31MHz, set the gnICE cable frequency to
-       6MHz (default), --wait-clocks >= 2 is required.  */
+       With an incorrect number of wait clocks, the first 4 bytes will be
+       duplicated by the second 4 bytes.  */
 
     if (bfin_wait_clocks == -1)
     {
@@ -221,18 +222,34 @@ bfin_wait_ready (void *data)
         uint32_t frequency = cable->frequency;
         const char *name = cable->driver->name;
 
-        if (strcmp (name, "gnICE+") == 0 && frequency == 15000000)
-            bfin_wait_clocks = 12;
-        else if (strcmp (name, "gnICE+") == 0 && frequency == 30000000)
-            bfin_wait_clocks = 21;
-        else if (strcmp (name, "gnICE+") == 0 && frequency == 6000000)
-            bfin_wait_clocks = 5;
-        else if (strcmp (name, "gnICE") == 0 && frequency == 6000000)
+        if (strcmp (name, "gnICE+") == 0)
+        {
+            if (frequency <= 6000000)
+                bfin_wait_clocks = 5;
+            else if (frequency <= 15000000)
+                bfin_wait_clocks = 12;
+            else /* <= 30MHz */
+                bfin_wait_clocks = 21;
+        }
+        else if (strcmp (name, "gnICE") == 0)
             bfin_wait_clocks = 2;
-        else
+        else if (strcmp (name, "ICE-100B") == 0)
+        {
+            if (frequency <= 5000000)
+                bfin_wait_clocks = 5;
+            else if (frequency <= 10000000)
+                bfin_wait_clocks = 11;
+            else if (frequency <= 17000000)
+                bfin_wait_clocks = 19;
+            else /* <= 25MHz */
+                bfin_wait_clocks = 30;
+        }
+
+        if (bfin_wait_clocks == -1)
         {
-            bfin_wait_clocks = 21;
-            urj_warning (_("untested cable or frequency, set wait_clocks to %d\n"), bfin_wait_clocks);
+            bfin_wait_clocks = 30;
+            urj_warning (_("%s: untested cable, set wait_clocks to %d\n"),
+                         name, bfin_wait_clocks);
         }
     }
 
------------------------------------------------------------------------------
Got Input?   Slashdot Needs You.
Take our quick survey online.  Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
UrJTAG-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/urjtag-development

Reply via email to