ULINK driver: Implement JTAG_PATHMOVE command
[fw/openocd] / src / jtag / drivers / amt_jtagaccel.c
index 974761e75fc511327e6b03c80d2a897501d4c793..a433e81eb6661c30a97888d11d9d325cf53e2a22 100644 (file)
@@ -22,8 +22,6 @@
 #endif
 
 #include <jtag/interface.h>
-#include <jtag/commands.h>
-
 
 #if PARPORT_USE_PPDEV == 1
 #include <linux/parport.h>
 #endif
 #endif
 
+/**
+ * @file
+ * Support the Amontec Chameleon POD with JTAG Accelerator support.
+ * This is a parallel port JTAG adapter with a CPLD between the
+ * parallel port and the JTAG connection.  VHDL code running in the
+ * CPLD significantly accelerates JTAG operations compared to the
+ * bitbanging "Wiggler" style of most parallel port adapters.
+ */
+
 /* configuration */
 static uint16_t amt_jtagaccel_port;
 
@@ -184,7 +191,9 @@ static void amt_jtagaccel_state_move(void)
 
        aw_scan_tms_5 = 0x40 | (tms_scan[0] & 0x1f);
        AMT_AW(aw_scan_tms_5);
-       int jtag_speed = jtag_get_speed();
+        int jtag_speed=0;
+       int retval = jtag_get_speed(&jtag_speed);
+       assert(retval == ERROR_OK);
        if (jtag_speed > 3 || rtck_enabled)
                amt_wait_scan_busy();
 
@@ -242,7 +251,9 @@ static void amt_jtagaccel_scan(bool ir_scan, enum scan_type type, uint8_t *buffe
        uint8_t dr_tdo;
        uint8_t aw_tms_scan;
        uint8_t tms_scan[2];
-       int jtag_speed = jtag_get_speed();
+       int jtag_speed_var;
+       int retval = jtag_get_speed(&jtag_speed_var);
+       assert(retval == ERROR_OK);
 
        if (ir_scan)
                amt_jtagaccel_end_state(TAP_IRSHIFT);
@@ -260,7 +271,7 @@ static void amt_jtagaccel_scan(bool ir_scan, enum scan_type type, uint8_t *buffe
 
                dw_tdi_scan = buf_get_u32(buffer, bit_count, (scan_size - 1) % 8) & 0xff;
                AMT_DW(dw_tdi_scan);
-               if (jtag_speed > 3 || rtck_enabled)
+               if (jtag_speed_var > 3 || rtck_enabled)
                        amt_wait_scan_busy();
 
                if ((type == SCAN_IN) || (type == SCAN_IO))
@@ -278,7 +289,7 @@ static void amt_jtagaccel_scan(bool ir_scan, enum scan_type type, uint8_t *buffe
        {
                dw_tdi_scan = buf_get_u32(buffer, bit_count, 8) & 0xff;
                AMT_DW(dw_tdi_scan);
-               if (jtag_speed > 3 || rtck_enabled)
+               if (jtag_speed_var > 3 || rtck_enabled)
                        amt_wait_scan_busy();
 
                if ((type == SCAN_IN) || (type == SCAN_IO))
@@ -295,7 +306,7 @@ static void amt_jtagaccel_scan(bool ir_scan, enum scan_type type, uint8_t *buffe
        tms_scan[1] = amt_jtagaccel_tap_move[tap_move_ndx(tap_get_state())][tap_move_ndx(tap_get_end_state())][1];
        aw_tms_scan = 0x40 | (tms_scan[0] & 0x1f) | (buf_get_u32(buffer, bit_count, 1) << 5);
        AMT_AW(aw_tms_scan);
-       if (jtag_speed > 3 || rtck_enabled)
+       if (jtag_speed_var > 3 || rtck_enabled)
                amt_wait_scan_busy();
 
        if ((type == SCAN_IN) || (type == SCAN_IO))
@@ -309,7 +320,7 @@ static void amt_jtagaccel_scan(bool ir_scan, enum scan_type type, uint8_t *buffe
        {
                aw_tms_scan = 0x40 | (tms_scan[1] & 0x1f);
                AMT_AW(aw_tms_scan);
-               if (jtag_speed > 3 || rtck_enabled)
+               if (jtag_speed_var > 3 || rtck_enabled)
                        amt_wait_scan_busy();
        }
        tap_set_state(tap_get_end_state());
@@ -349,7 +360,7 @@ static int amt_jtagaccel_execute_queue(void)
                                amt_jtagaccel_end_state(cmd->cmd.runtest->end_state);
                                amt_jtagaccel_runtest(cmd->cmd.runtest->num_cycles);
                                break;
-                       case JTAG_STATEMOVE:
+                       case JTAG_TLR_RESET:
 #ifdef _DEBUG_JTAG_IO_
                                LOG_DEBUG("statemove end in %i", cmd->cmd.statemove->end_state);
 #endif
@@ -495,8 +506,6 @@ static int amt_jtagaccel_init(void)
        aw_control_fsm |= 0x04;
        AMT_AW(aw_control_fsm);
 
-       amt_jtagaccel_speed(jtag_get_speed());
-
        enum reset_types jtag_reset_config = jtag_get_reset_config();
        if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
                aw_control_rst &= ~0x8;
@@ -573,15 +582,21 @@ static const struct command_registration amtjtagaccel_command_handlers[] = {
                .name = "parport_port",
                .handler = &amt_jtagaccel_handle_parport_port_command,
                .mode = COMMAND_CONFIG,
-               .help = "configure the parallel port to use",
-               .usage = "<port_num>",
+               .help = "configure or display the parallel port to use",
+               .usage = "[port_num]",
        },
        {
+               /**
+                * @todo Remove this "rtck" command; just use the standard
+                * mechanism to enable/disable adaptive clocking.  First
+                * implement the standard mechanism and deprecate "rtck";
+                * after a year or so, it'll be safe to remove this.
+                */
                .name = "rtck",
                .handler = &amt_jtagaccel_handle_rtck_command,
                .mode = COMMAND_CONFIG,
-               .help = "enable RTCK",
-               .usage = "<enable|disable>",
+               .help = "configure or display RTCK support",
+               .usage = "[enable|disable]",
        },
        COMMAND_REGISTRATION_DONE
 };