X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fjtag%2Fdrivers%2Famt_jtagaccel.c;h=34a4ae784d3a34d0aca47956eede1328d9db71f0;hb=57cb28b484b664c83046e064ac18f4ace4cb9181;hp=d26482a6136703d55b718bbe1f1342ce336882b2;hpb=865efd828a267992db0f2a92a731c5ce23a34236;p=openocd.git diff --git a/src/jtag/drivers/amt_jtagaccel.c b/src/jtag/drivers/amt_jtagaccel.c index d26482a613..34a4ae784d 100644 --- a/src/jtag/drivers/amt_jtagaccel.c +++ b/src/jtag/drivers/amt_jtagaccel.c @@ -21,9 +21,7 @@ #include "config.h" #endif -#include "interface.h" -#include "commands.h" - +#include #if PARPORT_USE_PPDEV == 1 #include @@ -41,6 +39,15 @@ #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; @@ -55,13 +62,49 @@ static int rtck_enabled = 0; #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); \ + assert(__retval >= 0); \ + __retval = write(device_handle, &val, 1); \ + assert(__retval >= 0); \ + } while (0) +#define AMT_AR(val) \ + do { \ + int __retval; \ + \ + __retval = ioctl(device_handle, PPSETMODE, &addr_mode); \ + assert(__retval >= 0); \ + __retval = read(device_handle, &val, 1); \ + assert(__retval >= 0); \ + } 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); \ + assert(__retval >= 0); \ + __retval = write(device_handle, &val, 1); \ + assert(__retval >= 0); \ + } while (0) +#define AMT_DR(val) \ + do { \ + int __retval; \ + \ + __retval = ioctl(device_handle, PPSETMODE, &data_mode); \ + assert(__retval >= 0); \ + __retval = read(device_handle, &val, 1); \ + assert(__retval >= 0); \ + } while (0) #else @@ -156,7 +199,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(); @@ -214,7 +259,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); @@ -232,7 +279,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)) @@ -250,7 +297,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)) @@ -267,7 +314,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)) @@ -281,7 +328,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()); @@ -321,7 +368,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 @@ -467,8 +514,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; @@ -545,24 +590,31 @@ 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 = "", + .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 = "", + .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, +};