#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;
#if PARPORT_USE_PPDEV == 1
static int device_handle;
-static int addr_mode = IEEE1284_MODE_EPP | IEEE1284_ADDR ;
-#define AMT_AW(val) do { ioctl(device_handle, PPSETMODE, &addr_mode); write(device_handle, &val, 1); } while (0)
-#define AMT_AR(val) do { ioctl(device_handle, PPSETMODE, &addr_mode); read(device_handle, &val, 1); } while (0)
-
-static int data_mode = IEEE1284_MODE_EPP | IEEE1284_DATA ;
-#define AMT_DW(val) do { ioctl(device_handle, PPSETMODE, &data_mode); write(device_handle, &val, 1); } while (0)
-#define AMT_DR(val) do { ioctl(device_handle, PPSETMODE, &data_mode); read(device_handle, &val, 1); } while (0)
+static const int addr_mode = IEEE1284_MODE_EPP | IEEE1284_ADDR;
+
+/* FIXME do something sane when these ioctl/read/write calls fail. */
+
+#define AMT_AW(val) \
+ do { \
+ int __retval; \
+ \
+ __retval = ioctl(device_handle, PPSETMODE, &addr_mode); \
+ __retval = write(device_handle, &val, 1); \
+ } while (0)
+#define AMT_AR(val) \
+ do { \
+ int __retval; \
+ \
+ __retval = ioctl(device_handle, PPSETMODE, &addr_mode); \
+ __retval = read(device_handle, &val, 1); \
+ } while (0)
+
+static const int data_mode = IEEE1284_MODE_EPP | IEEE1284_DATA;
+
+#define AMT_DW(val) \
+ do { \
+ int __retval; \
+ \
+ __retval = ioctl(device_handle, PPSETMODE, &data_mode); \
+ __retval = write(device_handle, &val, 1); \
+ } while (0)
+#define AMT_DR(val) \
+ do { \
+ int __retval; \
+ \
+ __retval = ioctl(device_handle, PPSETMODE, &data_mode); \
+ __retval = read(device_handle, &val, 1); \
+ } while (0)
#else
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();
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);
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))
{
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))
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))
{
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());
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
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;
.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]",
},
{
- .name = "parport_port",
+ /**
+ * @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
};
struct jtag_interface amt_jtagaccel_interface = {
- .name = "amt_jtagaccel",
- .commands = amtjtagaccel_command_handlers,
- .init = &amt_jtagaccel_init,
- .quit = &amt_jtagaccel_quit,
- .speed = &amt_jtagaccel_speed,
- .execute_queue = &amt_jtagaccel_execute_queue,
- };
+ .name = "amt_jtagaccel",
+ .commands = amtjtagaccel_command_handlers,
+
+ .init = amt_jtagaccel_init,
+ .quit = amt_jtagaccel_quit,
+ .speed = amt_jtagaccel_speed,
+ .execute_queue = amt_jtagaccel_execute_queue,
+};