Remove FSF address from GPL notices
[fw/openocd] / src / jtag / drivers / versaloon / versaloon_internal.h
1 /***************************************************************************
2  *   Copyright (C) 2009 - 2010 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_INTERNAL_H_INCLUDED__
19 #define __VERSALOON_INTERNAL_H_INCLUDED__
20
21 #define VERSALOON_PRODUCTSTRING_INDEX   2
22 #define VERSALOON_SERIALSTRING_INDEX    3
23
24 #define VERSALOON_PRODUCTSTRING                 "Versaloon"
25
26 #define VERSALOON_VID                                   0x0483
27 #define VERSALOON_PID                                   0xA038
28 #define VERSALOON_INP                                   0x82
29 #define VERSALOON_OUTP                                  0x03
30 #define VERSALOON_IFACE                                 0x00
31
32 #define VERSALOON_FULL                                  1
33 #define VERSALOON_MINI                                  2
34 #define VERSALOON_NANO                                  3
35
36 #define VERSALOON_TIMEOUT                               5000
37 #define VERSALOON_TIMEOUT_LONG                  60000
38
39 /* USB Commands */
40 /* Common Commands */
41 #define VERSALOON_COMMON_CMD_START              0x00
42 #define VERSALOON_COMMON_CMD_END                0x0F
43
44 #define VERSALOON_GET_INFO                              0x00
45 #define VERSALOON_GET_TVCC                              0x01
46 #define VERSALOON_GET_HARDWARE                  0x02
47 #define VERSALOON_GET_OFFLINE_SIZE              0x08
48 #define VERSALOON_ERASE_OFFLINE_DATA    0x09
49 #define VERSALOON_WRITE_OFFLINE_DATA    0x0A
50 #define VERSALOON_GET_OFFLINE_CHECKSUM  0x0B
51 #define VERSALOON_FW_UPDATE                             0x0F
52 #define VERSALOON_FW_UPDATE_KEY                 0xAA
53
54 /* MCU Command */
55 #define VERSALOON_MCU_CMD_START                 0x10
56 #define VERSALOON_MCU_CMD_END                   0x1F
57
58 /* USB_TO_XXX Command */
59 #define VERSALOON_USB_TO_XXX_CMD_START  0x20
60 #define VERSALOON_USB_TO_XXX_CMD_END    0x7F
61
62 /* VSLLink Command */
63 #define VERSALOON_VSLLINK_CMD_START             0x80
64 #define VERSALOON_VSLLINK_CMD_END               0xFF
65
66 /* Mass-product */
67 #define MP_OK                                                   0x00
68 #define MP_FAIL                                                 0x01
69
70 #define MP_ISSP                                                 0x11
71
72 /* pending struct */
73 #define VERSALOON_MAX_PENDING_NUMBER    4096
74 typedef RESULT(*versaloon_callback_t)(void *, uint8_t *, uint8_t *);
75 struct versaloon_want_pos_t {
76         uint16_t offset;
77         uint16_t size;
78         uint8_t *buff;
79         struct versaloon_want_pos_t *next;
80 };
81 struct versaloon_pending_t {
82         uint8_t type;
83         uint8_t cmd;
84         uint16_t want_data_pos;
85         uint16_t want_data_size;
86         uint16_t actual_data_size;
87         uint8_t *data_buffer;
88         uint8_t collect;
89         uint32_t id;
90         struct versaloon_want_pos_t *pos;
91         void *extra_data;
92         versaloon_callback_t callback;
93 };
94 extern struct versaloon_pending_t \
95         versaloon_pending[VERSALOON_MAX_PENDING_NUMBER];
96 extern uint16_t versaloon_pending_idx;
97 void versaloon_set_pending_id(uint32_t id);
98 void versaloon_set_callback(versaloon_callback_t callback);
99 void versaloon_set_extra_data(void *p);
100 RESULT versaloon_add_want_pos(uint16_t offset, uint16_t size, uint8_t *buff);
101 RESULT versaloon_add_pending(uint8_t type, uint8_t cmd, uint16_t actual_szie,
102                 uint16_t want_pos, uint16_t want_size, uint8_t *buffer, uint8_t collect);
103 void versaloon_free_want_pos(void);
104
105 RESULT versaloon_send_command(uint16_t out_len, uint16_t *inlen);
106 extern uint8_t *versaloon_buf;
107 extern uint8_t *versaloon_cmd_buf;
108 extern uint16_t versaloon_buf_size;
109
110 #endif /* __VERSALOON_INTERNAL_H_INCLUDED__ */