Remove FSF address from GPL notices
[openocd.git] / src / jtag / drivers / versaloon / versaloon.h
1 /***************************************************************************
2 * Copyright (C) 2009 by Simon Qian <SimonQian@SimonQian.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
16 ***************************************************************************/
17
18 #ifndef __VERSALOON_H_INCLUDED__
19 #define __VERSALOON_H_INCLUDED__
20
21 #include <libusb.h>
22
23 struct usart_status_t {
24 uint32_t tx_buff_avail;
25 uint32_t tx_buff_size;
26 uint32_t rx_buff_avail;
27 uint32_t rx_buff_size;
28 };
29
30 #include "usbtoxxx/usbtoxxx.h"
31
32 /* GPIO pins */
33 #define GPIO_SRST (1 << 0)
34 #define GPIO_TRST (1 << 1)
35 #define GPIO_USR1 (1 << 2)
36 #define GPIO_USR2 (1 << 3)
37 #define GPIO_TCK (1 << 4)
38 #define GPIO_TDO (1 << 5)
39 #define GPIO_TDI (1 << 6)
40 #define GPIO_RTCK (1 << 7)
41 #define GPIO_TMS (1 << 8)
42
43 struct interface_gpio_t {
44 RESULT(*init)(uint8_t interface_index);
45 RESULT(*fini)(uint8_t interface_index);
46 RESULT(*config)(uint8_t interface_index, uint32_t pin_mask, uint32_t io,
47 uint32_t pull_en_mask, uint32_t input_pull_mask);
48 RESULT(*out)(uint8_t interface_index, uint32_t pin_mask, uint32_t value);
49 RESULT(*in)(uint8_t interface_index, uint32_t pin_mask, uint32_t *value);
50 };
51
52 struct interface_delay_t {
53 RESULT(*delayms)(uint16_t ms);
54 RESULT(*delayus)(uint16_t us);
55 };
56
57 struct interface_swd_t {
58 RESULT(*init)(uint8_t interface_index);
59 RESULT(*fini)(uint8_t interface_index);
60 RESULT(*config)(uint8_t interface_index, uint8_t trn, uint16_t retry,
61 uint16_t dly);
62 RESULT(*seqout)(uint8_t interface_index, const uint8_t *data,
63 uint16_t bitlen);
64 RESULT(*seqin)(uint8_t interface_index, uint8_t *data, uint16_t bitlen);
65 RESULT(*transact)(uint8_t interface_index, uint8_t request,
66 uint32_t *data, uint8_t *ack);
67 };
68
69 struct interface_jtag_raw_t {
70 RESULT(*init)(uint8_t interface_index);
71 RESULT(*fini)(uint8_t interface_index);
72 RESULT(*config)(uint8_t interface_index, uint32_t kHz);
73 RESULT(*execute)(uint8_t interface_index, uint8_t *tdi, uint8_t *tms,
74 uint8_t *tdo, uint32_t bitlen);
75 };
76
77 struct interface_target_voltage_t {
78 RESULT(*get)(uint16_t *voltage);
79 RESULT(*set)(uint16_t voltage);
80 };
81
82 struct versaloon_adaptors_t {
83 struct interface_target_voltage_t target_voltage;
84 struct interface_gpio_t gpio;
85 struct interface_delay_t delay;
86 struct interface_swd_t swd;
87 struct interface_jtag_raw_t jtag_raw;
88 RESULT(*peripheral_commit)(void);
89 };
90
91 struct versaloon_usb_setting_t {
92 uint16_t vid;
93 uint16_t pid;
94 uint8_t ep_out;
95 uint8_t ep_in;
96 uint8_t interface;
97 char *serialstring;
98
99 uint16_t buf_size;
100 };
101
102 struct versaloon_interface_t {
103 RESULT(*init)(void);
104 RESULT(*fini)(void);
105 struct versaloon_adaptors_t adaptors;
106 struct versaloon_usb_setting_t usb_setting;
107 };
108
109 extern struct versaloon_interface_t versaloon_interface;
110 extern libusb_device_handle *versaloon_usb_device_handle;
111
112 #endif /* __VERSALOON_H_INCLUDED__ */
113