aboutsummaryrefslogtreecommitdiff
path: root/src/jtag/drivers/usb_blaster/ublast_access.h
blob: 5bdc2573a23825ccd529c963e95b16d56ea6d8e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 *   Driver for USB-JTAG, Altera USB-Blaster and compatibles
 *
 *   Inspired from original code from Kolja Waschk's USB-JTAG project
 *   (http://www.ixo.de/info/usb_jtag/), and from openocd project.
 *
 *   Copyright (C) 2013 Franck Jullien franck.jullien@gmail.com
 *   Copyright (C) 2012 Robert Jarzmik robert.jarzmik@free.fr
 *   Copyright (C) 2011 Ali Lown ali@lown.me.uk
 *   Copyright (C) 2009 Catalin Patulea cat@vv.carleton.ca
 *   Copyright (C) 2006 Kolja Waschk usbjtag@ixo.de
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 */

#ifndef JTAG_UBLAST_ACCESS_H
#define JTAG_UBLAST_ACCESS_H

#include <libusb_common.h>

/* Low level flags */
#define COPY_TDO_BUFFER		(1 << 0)

struct ublast_lowlevel {
	uint16_t ublast_vid;
	uint16_t ublast_pid;
	uint16_t ublast_vid_uninit;
	uint16_t ublast_pid_uninit;
	char *ublast_device_desc;
	struct jtag_libusb_device_handle *libusb_dev;
	char *firmware_path;

	int (*write)(struct ublast_lowlevel *low, uint8_t *buf, int size,
		     uint32_t *bytes_written);
	int (*read)(struct ublast_lowlevel *low, uint8_t *buf, unsigned size,
		    uint32_t *bytes_read);
	int (*open)(struct ublast_lowlevel *low);
	int (*close)(struct ublast_lowlevel *low);
	int (*speed)(struct ublast_lowlevel *low, int speed);

	void *priv;
	int flags;
};

/**
 * ublast_register_ftdi - get a lowlevel USB Blaster driver
 * ublast_register_ftd2xx - get a lowlevel USB Blaster driver
 * ublast2_register_libusb - get a lowlevel USB Blaster II driver
 *
 * Get a lowlevel USB-Blaster driver. In the current implementation, there are 3
 * possible lowlevel drivers :
 *  - one based on libftdi from ftdichip.com
 *  - one based on libftdxx, the free alternative
 *  - one based on libusb, specific to the USB-Blaster II
 *
 * Returns the lowlevel driver structure.
 */
extern struct ublast_lowlevel *ublast_register_ftdi(void);
extern struct ublast_lowlevel *ublast_register_ftd2xx(void);
extern struct ublast_lowlevel *ublast2_register_libusb(void);

#endif /* JTAG_UBLAST_ACCESS_H */