31 #define FT_DEVICE_NAME_LEN 64
32 #define FT_DEVICE_SERNUM_LEN 64
34 #define PRESTO_VID_PID 0x0403f1a0
35 #define PRESTO_VID (0x0403)
36 #define PRESTO_PID (0xf1a0)
38 #define BUFFER_SIZE (64*62)
41 struct ftdi_context
ftdic;
71 0x80, 0xA0, 0xA8, 0xB0, 0xC0, 0xE0
84 if (ftbytes !=
size) {
85 LOG_ERROR(
"couldn't write the requested number of bytes to PRESTO (%u < %u)",
86 (
unsigned)ftbytes, (
unsigned)
size);
101 while (ftbytes <
size) {
114 if (ftbytes !=
size) {
117 LOG_WARNING(
"couldn't read the requested number of bytes from PRESTO (%u < %u)",
118 (
unsigned)ftbytes, (
unsigned)
size);
129 LOG_DEBUG(
"searching for PRESTO using libftdi");
144 LOG_ERROR(
"unable to reset PRESTO device");
148 if (ftdi_set_latency_timer(&
presto->
ftdic, 1) < 0) {
149 LOG_ERROR(
"unable to set latency timer");
154 LOG_ERROR(
"unable to flush PRESTO buffers");
165 LOG_DEBUG(
"no response from PRESTO, retrying");
175 LOG_ERROR(
"no response from PRESTO, giving up");
181 LOG_ERROR(
"error writing PRESTO init sequence");
237 LOG_DEBUG(
"error in previous communication, canceling I/O operation");
274 if (((data & 0xC0) == 0x40) || ((data & 0xD0) == 0xD0))
288 static int presto_getbyte(
void)
314 LOG_ERROR(
"BUG: unexpected TAP condition, TCK low");
356 cmd = tdi ? 0xCB : 0xCA;
419 waits = us / 170 + 2;
462 *jtag_speed = (1000 + khz-1)/khz;
469 if ((speed < 0) || (speed > 1000)) {
492 LOG_INFO(
"setting speed to %d, max. TCK freq. is %d MHz", speed, khz/1000);
494 LOG_INFO(
"setting speed to %d, max. TCK freq. is %d kHz", speed, khz);
506 LOG_ERROR(
"Cannot open PRESTO, serial number '%s'", presto_serial);
const char * adapter_get_required_serial(void)
Retrieves the serial number set with command 'adapter serial'.
const char *const jtag_only[]
int bitq_execute_queue(struct jtag_command *cmd_queue)
#define ERROR_COMMAND_SYNTAX_ERROR
void jtag_sleep(uint32_t us)
#define ERROR_JTAG_DEVICE_ERROR
#define ERROR_JTAG_INIT_FAILED
static int ftdi_tcioflush(struct ftdi_context *ftdi)
#define LOG_WARNING(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_INFO(expr ...)
#define LOG_DEBUG(expr ...)
static int presto_bitq_reset(int trst, int srst)
static struct jtag_interface presto_interface
static uint8_t presto_init_seq[]
static int presto_jtag_speed_div(int speed, int *khz)
static int presto_adapter_khz(int khz, int *jtag_speed)
static struct presto presto_state
static int presto_bitq_flush(void)
static int presto_bitq_in(void)
static int presto_bitq_sleep(unsigned long us)
static int presto_open(const char *req_serial)
static int presto_tdi_flush(void)
static int presto_jtag_quit(void)
static int presto_flush(void)
static int presto_tck_idle(void)
static int presto_jtag_init(void)
struct adapter_driver presto_adapter_driver
static int presto_jtag_speed(int speed)
static int presto_bitq_out(int tms, int tdi, int tdo_req)
static int presto_sendbyte(int data)
static struct bitq_interface presto_bitq
static int presto_bitq_in_rdy(void)
static int presto_write(uint8_t *buf, uint32_t size)
static int presto_read(uint8_t *buf, uint32_t size)
static int presto_open_libftdi(const char *req_serial)
#define FT_DEVICE_SERNUM_LEN
static int presto_close(void)
int gettimeofday(struct timeval *tv, struct timezone *tz)
size_t size
Size of the control block search area.
Represents a driver for a debugging interface.
const char *const name
The name of the interface driver.
int(* out)(int tms, int tdi, int tdo_req)
Represents a driver for a debugging interface.
int(* execute_queue)(struct jtag_command *cmd_queue)
Execute commands in the supplied queue.
uint8_t buff_out[BUFFER_SIZE]
uint8_t buff_in[BUFFER_SIZE]
struct ftdi_context ftdic
char serial[FT_DEVICE_SERNUM_LEN]
int timeval_compare(const struct timeval *x, const struct timeval *y)
int timeval_add_time(struct timeval *result, long sec, long usec)