diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index 0e07ab7b..785e2cd7 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -1,3 +1,14 @@ +2011-02-09 Mike Frysinger + + * include/urjtag/usbconn.h (urj_usbconn_cable_t): Add an "interface" member. + * include/urjtag/cable.h (URJ_CABLE_PARAM_KEY_INTERFACE): New key for ftdi. + * src/tap/cable.c (cable_param): Handle new "interface" key. + * src/tap/cable/generic_usbconn.c (urj_tap_cable_generic_usbconn_connect): + Parse new "interface" cable parameter. + * src/tap/usbconn/libftd2xx.c: Use new "interface" selection. + * src/tap/usbconn/libftdi.c: Likewise. + * sysdep.h: Auto undefine "interface" for Windows. + 2011-02-06 Mike Frysinger * src/tap/cable_list.h: Add usbjtagrs232. diff --git a/urjtag/include/urjtag/cable.h b/urjtag/include/urjtag/cable.h index dd791875..08ff218d 100644 --- a/urjtag/include/urjtag/cable.h +++ b/urjtag/include/urjtag/cable.h @@ -63,6 +63,7 @@ typedef enum URJ_CABLE_PARAM_KEY URJ_CABLE_PARAM_KEY_TDO, /* lu gpio used as TDO */ URJ_CABLE_PARAM_KEY_TMS, /* lu gpio used as TMS */ URJ_CABLE_PARAM_KEY_TCK, /* lu gpio used as TCK */ + URJ_CABLE_PARAM_KEY_INTERFACE, /* lu ftdi */ } urj_cable_param_key_t; diff --git a/urjtag/include/urjtag/usbconn.h b/urjtag/include/urjtag/usbconn.h index c938dc67..e232db2f 100644 --- a/urjtag/include/urjtag/usbconn.h +++ b/urjtag/include/urjtag/usbconn.h @@ -38,6 +38,7 @@ typedef struct const char *driver; int32_t vid; int32_t pid; + int32_t interface; } urj_usbconn_cable_t; diff --git a/urjtag/src/tap/cable.c b/urjtag/src/tap/cable.c index 282a3d2b..ea2e8c02 100644 --- a/urjtag/src/tap/cable.c +++ b/urjtag/src/tap/cable.c @@ -672,6 +672,7 @@ static const urj_param_descr_t cable_param[] = { URJ_CABLE_PARAM_KEY_TDO, URJ_PARAM_TYPE_LU, "tdo", }, { URJ_CABLE_PARAM_KEY_TMS, URJ_PARAM_TYPE_LU, "tms", }, { URJ_CABLE_PARAM_KEY_TCK, URJ_PARAM_TYPE_LU, "tck", }, + { URJ_CABLE_PARAM_KEY_INTERFACE, URJ_PARAM_TYPE_LU, "interface", }, }; const urj_param_list_t urj_cable_param_list = diff --git a/urjtag/src/tap/cable/generic_usbconn.c b/urjtag/src/tap/cable/generic_usbconn.c index 98161744..db53df7a 100644 --- a/urjtag/src/tap/cable/generic_usbconn.c +++ b/urjtag/src/tap/cable/generic_usbconn.c @@ -51,6 +51,7 @@ urj_tap_cable_generic_usbconn_connect (urj_cable_t *cable, NULL, /* no specific driver */ -1, /* no VID */ -1, /* no PID */ + 0, /* default interface */ }; urj_tap_cable_generic_params_t *cable_params; @@ -80,6 +81,9 @@ urj_tap_cable_generic_usbconn_connect (urj_cable_t *cable, case URJ_CABLE_PARAM_KEY_DRIVER: user_specified.driver = params[i]->value.string; break; + case URJ_CABLE_PARAM_KEY_INTERFACE: + user_specified.interface = params[i]->value.lu; + break; default: // hand these to the driver connect() break; @@ -114,6 +118,8 @@ urj_tap_cable_generic_usbconn_connect (urj_cable_t *cable, cable_try.pid = user_specified.pid; if (user_specified.desc != 0) cable_try.desc = user_specified.desc; + if (user_specified.interface != 0) + cable_try.interface = user_specified.interface; conn = urj_tap_usbconn_drivers[i]->connect (&cable_try, params); diff --git a/urjtag/src/tap/usbconn/libftd2xx.c b/urjtag/src/tap/usbconn/libftd2xx.c index b79eefd6..dad17e1d 100644 --- a/urjtag/src/tap/usbconn/libftd2xx.c +++ b/urjtag/src/tap/usbconn/libftd2xx.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "libftdx.h" #include "../usbconn.h" @@ -50,6 +51,7 @@ typedef struct unsigned int pid; FT_HANDLE fc; char *serial; + unsigned int interface; /* send and receive buffer handling */ uint32_t send_buf_len; uint32_t send_buffered; @@ -331,6 +333,7 @@ usbconn_ftd2xx_connect (urj_usbconn_cable_t *template, p->fc = NULL; p->pid = template->pid; p->vid = template->vid; + p->interface = template->interface; /* @@@@ RFHH check strdup result */ p->serial = template->desc ? strdup (template->desc) : NULL; @@ -395,7 +398,7 @@ usbconn_ftd2xx_common_open (urj_usbconn_t *conn, urj_log_level_t ll) } else /* give it a plain try */ - status = FT_Open (0, &p->fc); + status = FT_Open (p->interface, &p->fc); if (status != FT_OK) { diff --git a/urjtag/src/tap/usbconn/libftdi.c b/urjtag/src/tap/usbconn/libftdi.c index a23de05a..5232452a 100644 --- a/urjtag/src/tap/usbconn/libftdi.c +++ b/urjtag/src/tap/usbconn/libftdi.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "libftdx.h" #include "../usbconn.h" @@ -46,6 +47,8 @@ typedef struct unsigned int pid; struct ftdi_context *fc; char *serial; + /* ftdi interface selection */ + unsigned int interface; /* send and receive buffer handling */ uint32_t send_buf_len; uint32_t send_buffered; @@ -310,6 +313,7 @@ usbconn_ftdi_connect (urj_usbconn_cable_t *template, p->fc = fc; p->pid = template->pid; p->vid = template->vid; + p->interface = template->interface; /* @@@@ RFHH check strdup result */ p->serial = template->desc ? strdup (template->desc) : NULL; diff --git a/urjtag/sysdep.h b/urjtag/sysdep.h index bf3429c9..9be009a0 100644 --- a/urjtag/sysdep.h +++ b/urjtag/sysdep.h @@ -56,6 +56,11 @@ #define mkdir(path, mode) mkdir(path) #endif +/* Some Windows code likes to define this, so undo it here */ +#ifdef interface +#undef interface +#endif + #ifndef HAVE_GETEUID #define geteuid() 0 #endif