/***************************************************************************/
/* AICE commands */
+static int aice_edm_reset(void)
+{
+ if (aice_write_ctrl(AICE_WRITE_CTRL_CLEAR_TIMEOUT_STATUS, 0x1) != ERROR_OK)
+ return ERROR_FAIL;
+
+ /* turn off FASTMODE */
+ uint32_t pin_status;
+ if (aice_read_ctrl(AICE_READ_CTRL_GET_JTAG_PIN_STATUS, &pin_status)
+ != ERROR_OK)
+ return ERROR_FAIL;
+
+ if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_STATUS, pin_status & (~0x2))
+ != ERROR_OK)
+ return ERROR_FAIL;
+
+ return ERROR_OK;
+}
+
static int aice_scan_chain(uint32_t *id_codes, uint8_t *num_of_ids)
{
int result;
return ERROR_FAIL;
/* clear timeout and retry */
- if (aice_write_ctrl(AICE_WRITE_CTRL_CLEAR_TIMEOUT_STATUS, 0x1) != ERROR_OK)
+ if (aice_edm_reset() != ERROR_OK)
return ERROR_FAIL;
retry_times++;
return ERROR_FAIL;
/* clear timeout and retry */
- if (aice_write_ctrl(AICE_WRITE_CTRL_CLEAR_TIMEOUT_STATUS, 0x1) != ERROR_OK)
+ if (aice_edm_reset() != ERROR_OK)
return ERROR_FAIL;
retry_times++;
return ERROR_FAIL;
/* clear timeout and retry */
- if (aice_write_ctrl(AICE_WRITE_CTRL_CLEAR_TIMEOUT_STATUS, 0x1) != ERROR_OK)
+ if (aice_edm_reset() != ERROR_OK)
return ERROR_FAIL;
retry_times++;
return ERROR_FAIL;
/* clear timeout and retry */
- if (aice_write_ctrl(AICE_WRITE_CTRL_CLEAR_TIMEOUT_STATUS, 0x1) != ERROR_OK)
+ if (aice_edm_reset() != ERROR_OK)
return ERROR_FAIL;
retry_times++;
return ERROR_FAIL;
/* clear timeout and retry */
- if (aice_write_ctrl(AICE_WRITE_CTRL_CLEAR_TIMEOUT_STATUS, 0x1) != ERROR_OK)
+ if (aice_edm_reset() != ERROR_OK)
return ERROR_FAIL;
retry_times++;
return ERROR_FAIL;
/* clear timeout and retry */
- if (aice_write_ctrl(AICE_WRITE_CTRL_CLEAR_TIMEOUT_STATUS, 0x1) != ERROR_OK)
+ if (aice_edm_reset() != ERROR_OK)
return ERROR_FAIL;
retry_times++;
return ERROR_FAIL;
/* clear timeout and retry */
- if (aice_write_ctrl(AICE_WRITE_CTRL_CLEAR_TIMEOUT_STATUS, 0x1) != ERROR_OK)
+ if (aice_edm_reset() != ERROR_OK)
return ERROR_FAIL;
retry_times++;
return ERROR_FAIL;
/* clear timeout and retry */
- if (aice_write_ctrl(AICE_WRITE_CTRL_CLEAR_TIMEOUT_STATUS, 0x1) != ERROR_OK)
+ if (aice_edm_reset() != ERROR_OK)
return ERROR_FAIL;
retry_times++;
return ERROR_FAIL;
/* clear timeout and retry */
- if (aice_write_ctrl(AICE_WRITE_CTRL_CLEAR_TIMEOUT_STATUS, 0x1) != ERROR_OK)
+ if (aice_edm_reset() != ERROR_OK)
return ERROR_FAIL;
retry_times++;
return ERROR_FAIL;
/* clear timeout and retry */
- if (aice_write_ctrl(AICE_WRITE_CTRL_CLEAR_TIMEOUT_STATUS, 0x1) != ERROR_OK)
+ if (aice_edm_reset() != ERROR_OK)
return ERROR_FAIL;
retry_times++;
return ERROR_FAIL;
/* clear timeout and retry */
- if (aice_write_ctrl(AICE_WRITE_CTRL_CLEAR_TIMEOUT_STATUS, 0x1) != ERROR_OK)
+ if (aice_edm_reset() != ERROR_OK)
return ERROR_FAIL;
retry_times++;
return ERROR_FAIL;
/* clear timeout and retry */
- if (aice_write_ctrl(AICE_WRITE_CTRL_CLEAR_TIMEOUT_STATUS, 0x1) != ERROR_OK)
+ if (aice_edm_reset() != ERROR_OK)
return ERROR_FAIL;
retry_times++;
return ERROR_FAIL;
/* clear timeout and retry */
- if (aice_write_ctrl(AICE_WRITE_CTRL_CLEAR_TIMEOUT_STATUS, 0x1) != ERROR_OK)
+ if (aice_edm_reset() != ERROR_OK)
return ERROR_FAIL;
retry_times++;
return ERROR_FAIL;
/* clear timeout and retry */
- if (aice_write_ctrl(AICE_WRITE_CTRL_CLEAR_TIMEOUT_STATUS, 0x1) != ERROR_OK)
+ if (aice_edm_reset() != ERROR_OK)
return ERROR_FAIL;
retry_times++;
return ERROR_FAIL;
/* clear timeout and retry */
- if (aice_write_ctrl(AICE_WRITE_CTRL_CLEAR_TIMEOUT_STATUS, 0x1) != ERROR_OK)
+ if (aice_edm_reset() != ERROR_OK)
return ERROR_FAIL;
retry_times++;
return ERROR_FAIL;
/* clear timeout and retry */
- if (aice_write_ctrl(AICE_WRITE_CTRL_CLEAR_TIMEOUT_STATUS, 0x1) != ERROR_OK)
+ if (aice_edm_reset() != ERROR_OK)
return ERROR_FAIL;
retry_times++;
return ERROR_FAIL;
/* clear timeout and retry */
- if (aice_write_ctrl(AICE_WRITE_CTRL_CLEAR_TIMEOUT_STATUS, 0x1) != ERROR_OK)
+ if (aice_edm_reset() != ERROR_OK)
return ERROR_FAIL;
retry_times++;
return ERROR_OK;
}
-static int aice_edm_reset(void)
-{
- if (aice_write_ctrl(AICE_WRITE_CTRL_CLEAR_TIMEOUT_STATUS, 0x1) != ERROR_OK)
- return ERROR_FAIL;
-
- return ERROR_OK;
-}
-
static int aice_usb_set_clock(int set_clock)
{
if (aice_write_ctrl(AICE_WRITE_CTRL_TCK_CONTROL,
static int aice_usb_reset(void)
{
- if (aice_write_ctrl(AICE_WRITE_CTRL_CLEAR_TIMEOUT_STATUS, 0x1) != ERROR_OK)
+ if (aice_edm_reset() != ERROR_OK)
return ERROR_FAIL;
+ /* issue TRST */
if (custom_trst_script == NULL) {
if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL,
AICE_JTAG_PIN_CONTROL_TRST) != ERROR_OK)