]> git.sur5r.net Git - openocd/commitdiff
adapter speed: require init script setting and centralize activation from drivers...
authorJonas Hörberg <jhorberg@sauer-danfoss.com>
Thu, 28 Apr 2011 07:17:57 +0000 (09:17 +0200)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Sat, 30 Apr 2011 22:38:04 +0000 (00:38 +0200)
Signed-off-by: Jonas Hörberg <jhorberg@sauer-danfoss.com>
src/jtag/core.c
src/jtag/drivers/amt_jtagaccel.c
src/jtag/drivers/ft2232.c
src/jtag/drivers/gw16012.c
src/jtag/drivers/jlink.c
src/jtag/drivers/parport.c
src/jtag/drivers/presto.c
src/jtag/drivers/rlink.c
src/jtag/drivers/usb_blaster.c
src/jtag/zy1000/zy1000.c

index 4c5d37a749b0e7f25e8480f47dc00088d394ebef..0a9d72a846953f52a0361c60f426d47540dd645c 100644 (file)
@@ -124,7 +124,7 @@ static struct jtag_event_callback *jtag_event_callbacks;
 static int speed_khz = 0;
 /* speed to fallback to when RCLK is requested but not supported */
 static int rclk_fallback_speed_khz = 0;
-static enum {CLOCK_MODE_SPEED, CLOCK_MODE_KHZ, CLOCK_MODE_RCLK} clock_mode;
+static enum {CLOCK_MODE_UNSELECTED, CLOCK_MODE_KHZ, CLOCK_MODE_RCLK} clock_mode;
 static int jtag_speed = 0;
 
 static struct jtag_interface *jtag = NULL;
@@ -1389,10 +1389,20 @@ int adapter_init(struct command_context *cmd_ctx)
                        return retval;
        }
 
+       if (CLOCK_MODE_UNSELECTED == clock_mode)
+       {
+               LOG_ERROR("An adapter speed is not selected in the init script."
+                       " Insert a call to adapter_khz or jtag_rclk to proceed.");
+               return ERROR_JTAG_INIT_FAILED;
+       }
+
        int requested_khz = jtag_get_speed_khz();
        int actual_khz = requested_khz;
        int jtag_speed_var;
        retval = jtag_get_speed(&jtag_speed_var);
+       if (retval != ERROR_OK)
+               return retval;
+       retval = jtag->speed(jtag_speed_var);
        if (retval != ERROR_OK)
                return retval;
        retval = jtag_get_speed_readable(&actual_khz);
@@ -1647,9 +1657,6 @@ int jtag_get_speed(int *speed)
 {
        switch(clock_mode)
        {
-               case CLOCK_MODE_SPEED:
-                       *speed = jtag_speed;
-                       break;
                case CLOCK_MODE_KHZ:
                        adapter_khz_to_speed(jtag_get_speed_khz(), speed);
                        break;
index ee44a2b69a73865a3c61976d9a9abf9d5e1dc7a7..a433e81eb6661c30a97888d11d9d325cf53e2a22 100644 (file)
@@ -506,12 +506,6 @@ static int amt_jtagaccel_init(void)
        aw_control_fsm |= 0x04;
        AMT_AW(aw_control_fsm);
 
-       int jtag_speed_var;
-       int retval = jtag_get_speed(&jtag_speed_var);
-       if (retval != ERROR_OK)
-          return retval;
-       amt_jtagaccel_speed(jtag_speed_var);
-
        enum reset_types jtag_reset_config = jtag_get_reset_config();
        if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
                aw_control_rst &= ~0x8;
index fdabb64eda93a52f040fd870b22cfd048eebb37b..8c2382a15ebb3b5251a1710ea52f31ca811242ae 100644 (file)
@@ -2485,12 +2485,6 @@ static int ft2232_init(void)
                        return ERROR_JTAG_INIT_FAILED;
        }
 
-       int jtag_speed_var;
-       retval = jtag_get_speed(&jtag_speed_var);
-       if (retval != ERROR_OK)
-               return retval;
-       ft2232_speed(jtag_speed_var);
-
        buf[0] = 0x85; /* Disconnect TDI/DO to TDO/DI for Loopback */
        if ((retval = ft2232_write(buf, 1, &bytes_written)) != ERROR_OK)
        {
index 172929943c9d8c5dda14f168cf3a7359f1ea9c64..22a37ac84f20af48c8160972d84b4d26630e3ae3 100644 (file)
@@ -529,11 +529,6 @@ static int gw16012_init(void)
        gw16012_input(&status_port);
        gw16012_msb = (status_port & 0x80) ^ 0x80;
 
-       int jtag_speed_var;
-       int retval = jtag_get_speed(&jtag_speed_var);
-       if (retval != ERROR_OK)
-               return retval;
-       gw16012_speed(jtag_speed_var);
        gw16012_reset(0, 0);
 
        return ERROR_OK;
index 6eb707a1a2282cf307387bc9cee190736a058f75..adaa64090353e53d1ea7aceffd46275d2029e550 100644 (file)
@@ -439,11 +439,6 @@ static int jlink_init(void)
        jlink_reset(0, 0);
        jtag_sleep(3000);
        jlink_tap_init();
-       int jtag_speed_var;
-       int retval = jtag_get_speed(&jtag_speed_var);
-       if (retval != ERROR_OK)
-               return retval;
-       jlink_speed(jtag_speed_var);
 
        /* v5/6 jlink seems to have an issue if the first tap move
         * is not divisible by 8, so we send a TLR on first power up */
index b61f2f15e46c0695b33ec65234b2c2c992b21f2d..ad07791de3dc691ca5365c93208d37576a10ded6 100644 (file)
@@ -384,10 +384,6 @@ static int parport_init(void)
 
        bitbang_interface = &parport_bitbang;
 
-       int retval = jtag_get_speed(&wait_states);
-       if (retval != ERROR_OK)
-               return retval;
-
        return ERROR_OK;
 }
 
index ca6e9d50a169d850406f4cd480ea7bf3620596ee..2328c26b593c4eeb30087023763c864816bd5a7f 100644 (file)
@@ -769,13 +769,6 @@ static int presto_jtag_init(void)
        }
        LOG_INFO("PRESTO open, serial number '%s'", presto->serial);
 
-       /* use JTAG speed setting from configuration file */
-       int jtag_speed_var;
-       int retval = jtag_get_speed(&jtag_speed_var);
-       if (retval != ERROR_OK)
-               return retval;
-       presto_jtag_speed(jtag_speed_var);
-
        bitq_interface = &presto_bitq;
        return ERROR_OK;
 }
index 4b3e2ae8385bae94ee00e47070e0d3ce3045cf80..5f53dbceab3c02887651addfe3a2522e8b698208 100644 (file)
@@ -1771,11 +1771,6 @@ int rlink_init(void)
 
        tap_state_queue_init();
        dtc_queue_init();
-       int jtag_speed_var;
-       int retval = jtag_get_speed(&jtag_speed_var);
-       if (retval != ERROR_OK)
-               return retval;
-       rlink_speed(jtag_speed_var);
        rlink_reset(0, 0);
 
        return ERROR_OK;
index 68867adf9e81da09dcfafb7aafc72ae4405b158b..b046b715cd6a615b8b8a99cd5f396fefe9ad2fc8 100644 (file)
@@ -474,12 +474,6 @@ static int usb_blaster_init(void)
 
        bitbang_interface = &usb_blaster_bitbang;
 
-       int jtag_speed_var;
-       int retval = jtag_get_speed(&jtag_speed_var);
-       if (retval != ERROR_OK)
-               return retval;
-       usb_blaster_speed(jtag_speed_var);
-
 #if 0
 #if BUILD_USB_BLASTER_FTD2XX == 1
        if ((status = FT_Purge(ftdih, FT_PURGE_RX | FT_PURGE_TX)) != FT_OK)
index 8c3766656aaa222075be9611d903856c97b4fd8d..7a3a0f2eacc416a52ca016205b54d13afa21e658 100644 (file)
@@ -1505,11 +1505,6 @@ int zy1000_init(void)
 
         /* deassert resets. Important to avoid infinite loop waiting for SRST to deassert */
        zy1000_reset(0, 0);
-       int jtag_speed_var;
-       int retval = jtag_get_speed(&jtag_speed_var);
-       if (retval != ERROR_OK)
-               return retval;
-       zy1000_speed(jtag_speed_var);
 
 #if BUILD_ZY1000_MASTER
 #if BUILD_ECOSBOARD