diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index f91b8a27..d0f14d2d 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -1,3 +1,9 @@ +2010-10-26 Mike Frysinger + + * src/tap/cable_list.h, src/tap/cable/generic_usbconn_list.h, + src/tap/cable/ft2232.c: Add support for the Milkymist FTDI USB cable by + Michael Walle. + 2010-10-19 Mike Frysinger * src/tap/cable.c, src/tap/detect.c, src/tap/cable/ft2232.c, diff --git a/urjtag/src/tap/cable/ft2232.c b/urjtag/src/tap/cable/ft2232.c index 16316d4d..b7d7eece 100644 --- a/urjtag/src/tap/cable/ft2232.c +++ b/urjtag/src/tap/cable/ft2232.c @@ -191,6 +191,9 @@ #define BITMASK_USBSCARAB2_nSRST (1 << BIT_USBSCARAB2_nSRST) #define BITMASK_USBSCARAB2_nCONNECTED (1 << BIT_USBSCARAB2_nCONNECTED) +/* bit and bitmask definitions for Milkymist JTAG/serial daughterboard */ +#define BIT_MILKYMIST_VREF 4 +#define BITMASK_MILKYMIST_VREF (1 << BIT_MILKYMIST_VREF) typedef struct @@ -830,6 +833,56 @@ ft2232_usbscarab2_init (urj_cable_t *cable) return URJ_STATUS_OK; } +static int +ft2232_milkymist_init (urj_cable_t *cable) +{ + params_t *params = cable->params; + urj_tap_cable_cx_cmd_root_t *cmd_root = ¶ms->cmd_root; + + if (urj_tap_usbconn_open (cable->link.usb) != URJ_STATUS_OK) + return URJ_STATUS_FAIL; + + /* Check if cable is connected to the target and the target is powered on */ + urj_tap_cable_cx_cmd_queue (cmd_root, 1); + urj_tap_cable_cx_cmd_push (cmd_root, GET_BITS_LOW); + urj_tap_cable_cx_xfer (¶ms->cmd_root, &imm_cmd, cable, + URJ_TAP_CABLE_COMPLETELY); + if ((urj_tap_cable_cx_xfer_recv (cable) & BITMASK_MILKYMIST_VREF) == 0) + { + urj_error_set (URJ_ERROR_ILLEGAL_STATE, + _("Vref not detected. Please power on Milkymist One")); + return URJ_STATUS_FAIL; + } + + params->low_byte_value = 0; + params->low_byte_dir = 0; + + /* Set Data Bits Low Byte + TCK = 0, TMS = 1, TDI = 0 */ + urj_tap_cable_cx_cmd_queue (cmd_root, 0); + urj_tap_cable_cx_cmd_push (cmd_root, SET_BITS_LOW); + urj_tap_cable_cx_cmd_push (cmd_root, params->low_byte_value | BITMASK_TMS); + urj_tap_cable_cx_cmd_push (cmd_root, params->low_byte_dir | BITMASK_TCK | + BITMASK_TDI | BITMASK_TMS); + + /* Set Data Bits High Byte */ + params->high_byte_value = 0; + params->high_byte_value = 0; + params->high_byte_dir = 0; + urj_tap_cable_cx_cmd_push (cmd_root, SET_BITS_HIGH); + urj_tap_cable_cx_cmd_push (cmd_root, params->high_byte_value); + urj_tap_cable_cx_cmd_push (cmd_root, params->high_byte_dir); + + ft2232h_set_frequency (cable, FT2232H_MAX_TCK_FREQ); + + params->bit_trst = -1; /* not used */ + params->bit_reset = -1; /* not used */ + + params->last_tdo_valid = 0; + params->signals = 0; + + return URJ_STATUS_OK; +} static void ft2232_generic_done (urj_cable_t *cable) @@ -1204,6 +1257,29 @@ ft2232_usbscarab2_done (urj_cable_t *cable) urj_tap_cable_generic_usbconn_done (cable); } +static void +ft2232_milkymist_done (urj_cable_t *cable) +{ + params_t *params = cable->params; + urj_tap_cable_cx_cmd_root_t *cmd_root = ¶ms->cmd_root; + + /* Set Data Bits Low Byte + set all to input */ + urj_tap_cable_cx_cmd_queue (cmd_root, 0); + urj_tap_cable_cx_cmd_push (cmd_root, SET_BITS_LOW); + urj_tap_cable_cx_cmd_push (cmd_root, 0); + urj_tap_cable_cx_cmd_push (cmd_root, 0); + + /* Set Data Bits High Byte + set all to input */ + urj_tap_cable_cx_cmd_push (cmd_root, SET_BITS_HIGH); + urj_tap_cable_cx_cmd_push (cmd_root, 0); + urj_tap_cable_cx_cmd_push (cmd_root, 0); + urj_tap_cable_cx_xfer (cmd_root, &imm_cmd, cable, + URJ_TAP_CABLE_COMPLETELY); + + urj_tap_cable_generic_usbconn_done (cable); +} static void ft2232_clock_schedule (urj_cable_t *cable, int tms, int tdi, int n) @@ -2177,6 +2253,25 @@ const urj_cable_driver_t urj_tap_cable_ft2232_usbscarab2_driver = { }; URJ_DECLARE_FTDX_CABLE(0x0403, 0xbbe0, "-mpsse", "usbScarab2", usbscarab2) +const urj_cable_driver_t urj_tap_cable_ft2232_milkymist_driver = { + "milkymist", + N_("Milkymist JTAG/serial (FT2232) Cable"), + URJ_CABLE_DEVICE_USB, + { .usb = ft2232_connect, }, + urj_tap_cable_generic_disconnect, + ft2232_cable_free, + ft2232_milkymist_init, + ft2232_milkymist_done, + ft2232h_set_frequency, + ft2232_clock, + ft2232_get_tdo, + ft2232_transfer, + ft2232_set_signal, + urj_tap_cable_generic_get_signal, + ft2232_flush, + ftdx_usbcable_help +}; +URJ_DECLARE_FTDX_CABLE(0x20b7, 0x0713, "-mpsse", "milkymist", milkymist) /* Local Variables: diff --git a/urjtag/src/tap/cable/generic_usbconn_list.h b/urjtag/src/tap/cable/generic_usbconn_list.h index e3a6d030..1ff89e6d 100644 --- a/urjtag/src/tap/cable/generic_usbconn_list.h +++ b/urjtag/src/tap/cable/generic_usbconn_list.h @@ -48,15 +48,16 @@ _URJ_USB_FTDX(ft2232) _URJ_USB_FTDX(armusbocd) _URJ_USB_FTDX(armusbocdtiny) _URJ_USB_FTDX(armusbtiny_h) +_URJ_USB_FTDX(flyswatter) _URJ_USB_FTDX(gnice) _URJ_USB_FTDX(gniceplus) _URJ_USB_FTDX(jtagkey) +_URJ_USB_FTDX(milkymist) _URJ_USB_FTDX(oocdlinks) -_URJ_USB_FTDX(turtelizer2) -_URJ_USB_FTDX(usbtojtagif) _URJ_USB_FTDX(signalyzer) -_URJ_USB_FTDX(flyswatter) +_URJ_USB_FTDX(turtelizer2) _URJ_USB_FTDX(usbscarab2) +_URJ_USB_FTDX(usbtojtagif) #endif #ifdef ENABLE_CABLE_USBBLASTER _URJ_USB_FTDX(usbblaster) diff --git a/urjtag/src/tap/cable_list.h b/urjtag/src/tap/cable_list.h index b7f5523c..5675215e 100644 --- a/urjtag/src/tap/cable_list.h +++ b/urjtag/src/tap/cable_list.h @@ -53,6 +53,7 @@ _URJ_CABLE(ft2232_flyswatter) _URJ_CABLE(ft2232_gnice) _URJ_CABLE(ft2232_gniceplus) _URJ_CABLE(ft2232_jtagkey) +_URJ_CABLE(ft2232_milkymist) _URJ_CABLE(ft2232_oocdlinks) _URJ_CABLE(ft2232_signalyzer) _URJ_CABLE(ft2232_turtelizer2)