]> git.sur5r.net Git - openocd/blob - src/jtag/drivers/versaloon/versaloon.h
ULINK driver: Properly propagate return values in ulink_execute_queue()
[openocd] / 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, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
18  ***************************************************************************/
19 #ifndef __VERSALOON_H_INCLUDED__
20 #define __VERSALOON_H_INCLUDED__
21
22 struct usart_status_t
23 {
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 struct interface_gpio_t
43 {
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 {
54         RESULT (*delayms)(uint16_t ms);
55         RESULT (*delayus)(uint16_t us);
56 };
57
58 struct interface_swd_t
59 {
60         RESULT (*init)(uint8_t interface_index);
61         RESULT (*fini)(uint8_t interface_index);
62         RESULT (*config)(uint8_t interface_index, uint8_t trn, uint16_t retry,
63                 uint16_t dly);
64         RESULT (*seqout)(uint8_t interface_index, uint8_t *data, uint16_t bitlen);
65         RESULT (*seqin)(uint8_t interface_index, uint8_t *data, uint16_t bitlen);
66         RESULT (*transact)(uint8_t interface_index, uint8_t request,
67                 uint32_t *data, uint8_t *ack);
68 };
69
70 struct interface_jtag_raw_t
71 {
72         RESULT (*init)(uint8_t interface_index);
73         RESULT (*fini)(uint8_t interface_index);
74         RESULT (*config)(uint8_t interface_index, uint32_t kHz);
75         RESULT (*execute)(uint8_t interface_index, uint8_t* tdi, uint8_t* tms,
76                 uint8_t *tdo, uint32_t bitlen);
77 };
78
79 struct interface_target_voltage_t
80 {
81         RESULT (*get)(uint16_t *voltage);
82         RESULT (*set)(uint16_t voltage);
83 };
84
85 struct versaloon_adaptors_t
86 {
87         struct interface_target_voltage_t target_voltage;
88         struct interface_gpio_t gpio;
89         struct interface_delay_t delay;
90         struct interface_swd_t swd;
91         struct interface_jtag_raw_t jtag_raw;
92         RESULT (*peripheral_commit)(void);
93 };
94
95 struct versaloon_usb_setting_t
96 {
97         uint16_t vid;
98         uint16_t pid;
99         uint8_t ep_out;
100         uint8_t ep_in;
101         uint8_t interface;
102         char *serialstring;
103
104         uint16_t buf_size;
105 };
106
107 struct versaloon_interface_t
108 {
109         RESULT (*init)(void);
110         RESULT (*fini)(void);
111         struct versaloon_adaptors_t adaptors;
112         struct versaloon_usb_setting_t usb_setting;
113 };
114
115 extern struct versaloon_interface_t versaloon_interface;
116 extern usb_dev_handle *versaloon_usb_device_handle;
117
118 #endif /* __VERSALOON_H_INCLUDED__ */
119