de2ca8b9191b1beab3837c77380fefb393eba5f8
[openocd.git] / src / jtag / drivers / versaloon / usbtoxxx / usbtoxxx_internal.h
blobde2ca8b9191b1beab3837c77380fefb393eba5f8
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, write to the *
16 * Free Software Foundation, Inc., *
17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18 ***************************************************************************/
20 #ifndef __USBTOXXX_INTERNAL_H_INCLUDED__
21 #define __USBTOXXX_INTERNAL_H_INCLUDED__
23 /* USB_TO_XXX USB Commands */
24 /* Page0 */
25 #define USB_TO_USART (VERSALOON_USB_TO_XXX_CMD_START + 0x00)
26 #define USB_TO_SPI (VERSALOON_USB_TO_XXX_CMD_START + 0x01)
27 #define USB_TO_I2C (VERSALOON_USB_TO_XXX_CMD_START + 0x02)
28 #define USB_TO_GPIO (VERSALOON_USB_TO_XXX_CMD_START + 0x03)
29 #define USB_TO_CAN (VERSALOON_USB_TO_XXX_CMD_START + 0x04)
30 #define USB_TO_PWM (VERSALOON_USB_TO_XXX_CMD_START + 0x05)
31 #define USB_TO_ADC (VERSALOON_USB_TO_XXX_CMD_START + 0x06)
32 #define USB_TO_DAC (VERSALOON_USB_TO_XXX_CMD_START + 0x07)
33 #define USB_TO_MICROWIRE (VERSALOON_USB_TO_XXX_CMD_START + 0x08)
34 #define USB_TO_SWIM (VERSALOON_USB_TO_XXX_CMD_START + 0x09)
35 #define USB_TO_DUSI (VERSALOON_USB_TO_XXX_CMD_START + 0x0A)
36 /* Page1 */
37 #define USB_TO_JTAG_LL (VERSALOON_USB_TO_XXX_CMD_START + 0x20)
38 #define USB_TO_JTAG_HL (VERSALOON_USB_TO_XXX_CMD_START + 0x21)
39 #define USB_TO_ISSP (VERSALOON_USB_TO_XXX_CMD_START + 0x22)
40 #define USB_TO_C2 (VERSALOON_USB_TO_XXX_CMD_START + 0x23)
41 #define USB_TO_SBW (VERSALOON_USB_TO_XXX_CMD_START + 0x24)
42 #define USB_TO_LPCICP (VERSALOON_USB_TO_XXX_CMD_START + 0x25)
43 #define USB_TO_SWD (VERSALOON_USB_TO_XXX_CMD_START + 0x26)
44 #define USB_TO_JTAG_RAW (VERSALOON_USB_TO_XXX_CMD_START + 0x27)
45 #define USB_TO_BDM (VERSALOON_USB_TO_XXX_CMD_START + 0x28)
46 #define USB_TO_MSP430_JTAG (VERSALOON_USB_TO_XXX_CMD_START + 0x38)
47 /* Page2 */
48 #define USB_TO_POWER (VERSALOON_USB_TO_XXX_CMD_START + 0x40)
49 #define USB_TO_DELAY (VERSALOON_USB_TO_XXX_CMD_START + 0x41)
50 #define USB_TO_POLL (VERSALOON_USB_TO_XXX_CMD_START + 0x42)
51 #define USB_TO_INFO (VERSALOON_USB_TO_XXX_CMD_START + 0x5E)
52 #define USB_TO_ALL (VERSALOON_USB_TO_XXX_CMD_START + 0x5F)
54 /* USB_TO_XXX Masks */
55 #define USB_TO_XXX_CMDMASK 0xF8
56 #define USB_TO_XXX_CMDSHIFT 3
57 #define USB_TO_XXX_IDXMASK 0x07
58 /* USB_TO_XXX Sub Commands */
59 /* Common Sub Commands */
60 #define USB_TO_XXX_INIT (0x00 << USB_TO_XXX_CMDSHIFT)
61 #define USB_TO_XXX_FINI (0x01 << USB_TO_XXX_CMDSHIFT)
62 #define USB_TO_XXX_CONFIG (0x02 << USB_TO_XXX_CMDSHIFT)
63 #define USB_TO_XXX_GETHWINFO (0x03 << USB_TO_XXX_CMDSHIFT)
64 #define USB_TO_XXX_STATUS (0X04 << USB_TO_XXX_CMDSHIFT)
65 #define USB_TO_XXX_IN_OUT (0x05 << USB_TO_XXX_CMDSHIFT)
66 #define USB_TO_XXX_IN (0x06 << USB_TO_XXX_CMDSHIFT)
67 #define USB_TO_XXX_OUT (0x07 << USB_TO_XXX_CMDSHIFT)
68 #define USB_TO_XXX_POLL (0x08 << USB_TO_XXX_CMDSHIFT)
69 #define USB_TO_XXX_SPECIAL (0x09 << USB_TO_XXX_CMDSHIFT)
70 #define USB_TO_XXX_RESET (0x0A << USB_TO_XXX_CMDSHIFT)
71 #define USB_TO_XXX_SYNC (0x0B << USB_TO_XXX_CMDSHIFT)
72 #define USB_TO_XXX_ENABLE (0x0C << USB_TO_XXX_CMDSHIFT)
73 #define USB_TO_XXX_DISABLE (0x0D << USB_TO_XXX_CMDSHIFT)
74 /* USB_TO_POLL */
75 #define USB_TO_POLL_START 0x00
76 #define USB_TO_POLL_END 0x01
77 #define USB_TO_POLL_CHECKOK 0x02
78 #define USB_TO_POLL_CHECKFAIL 0x03
79 #define USB_TO_POLL_VERIFYBUFF 0x04
81 /* USB_TO_XXX Replys */
82 #define USB_TO_XXX_OK 0x00
83 #define USB_TO_XXX_FAILED 0x01
84 #define USB_TO_XXX_TIME_OUT 0x02
85 #define USB_TO_XXX_INVALID_INDEX 0x03
86 #define USB_TO_XXX_INVALID_PARA 0x04
87 #define USB_TO_XXX_INVALID_CMD 0x05
88 #define USB_TO_XXX_CMD_NOT_SUPPORT 0x06
90 /* USB_TO_XXX */
91 RESULT usbtoxxx_add_pending(uint8_t type, uint8_t cmd, uint16_t
92 actual_szie, uint16_t want_pos,
93 uint16_t want_size, uint8_t *buffer);
95 RESULT usbtoxxx_add_command(uint8_t type, uint8_t cmd, uint8_t *cmdbuf,
96 uint16_t cmdlen, uint16_t retlen,
97 uint8_t *wantbuf, uint16_t wantpos,
98 uint16_t wantlen, uint8_t collect);
100 #define usbtoxxx_init_command(type, port) \
101 usbtoxxx_add_command((type), (USB_TO_XXX_INIT | (port)), \
102 NULL, 0, 0, NULL, 0, 0, 0)
103 #define usbtoxxx_fini_command(type, port) \
104 usbtoxxx_add_command((type), (USB_TO_XXX_FINI | (port)), \
105 NULL, 0, 0, NULL, 0, 0, 0)
106 #define usbtoxxx_conf_command(type, port, cmdbuf, cmdlen) \
107 usbtoxxx_add_command((type), (USB_TO_XXX_CONFIG | (port)), \
108 (cmdbuf), (cmdlen), 0, NULL, 0, 0, 0)
109 #define usbtoxxx_inout_command(type, port, cmdbuf, cmdlen, retlen, wantbuf, \
110 wantpos, wantlen, c) \
111 usbtoxxx_add_command((type), (USB_TO_XXX_IN_OUT | (port)), \
112 (cmdbuf), (cmdlen), (retlen), (wantbuf), \
113 (wantpos), (wantlen), (c))
114 #define usbtoxxx_in_command(type, port, cmdbuf, cmdlen, retlen, wantbuf, \
115 wantpos, wantlen, c) \
116 usbtoxxx_add_command((type), (USB_TO_XXX_IN | (port)), (cmdbuf), \
117 (cmdlen), (retlen), (wantbuf), (wantpos), \
118 (wantlen), (c))
119 #define usbtoxxx_out_command(type, port, cmdbuf, cmdlen, c) \
120 usbtoxxx_add_command((type), (USB_TO_XXX_OUT | (port)), (cmdbuf), \
121 (cmdlen), 0, NULL, 0, 0, (c))
122 #define usbtoxxx_poll_command(type, port, cmdbuf, cmdlen, retbuf, retlen) \
123 usbtoxxx_add_command((type), (USB_TO_XXX_POLL | (port)), (cmdbuf), \
124 (cmdlen), (retlen), (retbuf), 0, (retlen), 0)
125 #define usbtoxxx_status_command(type, port, retlen, wantbuf, wantpos, wantlen, c) \
126 usbtoxxx_add_command((type), (USB_TO_XXX_STATUS | (port)), \
127 NULL, 0, (retlen), (wantbuf), (wantpos), \
128 (wantlen), (c))
129 #define usbtoxxx_special_command(type, port, cmdbuf, cmdlen, retlen, wantbuf, \
130 wantpos, wantlen, c) \
131 usbtoxxx_add_command((type), (USB_TO_XXX_SPECIAL | (port)), \
132 (cmdbuf), (cmdlen), retlen, wantbuf, \
133 wantpos, wantlen, (c))
134 #define usbtoxxx_reset_command(type, port, cmdbuf, cmdlen) \
135 usbtoxxx_add_command((type), (USB_TO_XXX_RESET | (port)), \
136 (cmdbuf), (cmdlen), 0, NULL, 0, 0, 0)
137 #define usbtoxxx_sync_command(type, port, cmdbuf, cmdlen, retlen, wantbuf) \
138 usbtoxxx_add_command((type), (USB_TO_XXX_SYNC | (port)), \
139 (cmdbuf), (cmdlen), (retlen), (wantbuf), 0, \
140 (retlen), 0)
141 #define usbtoxxx_enable_command(type, port, cmdbuf, cmdlen) \
142 usbtoxxx_add_command((type), (USB_TO_XXX_ENABLE | (port)), \
143 (cmdbuf), (cmdlen), 0, NULL, 0, 0, 0)
144 #define usbtoxxx_disable_command(type, port, cmdbuf, cmdlen) \
145 usbtoxxx_add_command((type), (USB_TO_XXX_DISABLE | (port)), \
146 (cmdbuf), (cmdlen), 0, NULL, 0, 0, 0)
148 /* USB_TO_SPI */
149 #define USB_TO_SPI_BAUDRATE_MSK 0x1F
150 #define USB_TO_SPI_CPOL_MSK 0x20
151 #define USB_TO_SPI_CPHA_MSK 0x40
152 #define USB_TO_SPI_MSB_FIRST 0x80
154 /* USB_TO_DUSI */
155 #define USB_TO_DUSI_BAUDRATE_MSK 0x1F
156 #define USB_TO_DUSI_CPOL_MSK 0x20
157 #define USB_TO_DUSI_CPHA_MSK 0x40
158 #define USB_TO_DUSI_MSB_FIRST 0x80
160 /* USB_TO_GPIO */
161 #define USB_TO_GPIO_DIR_MSK 0x01
163 #endif /* __USBTOXXX_INTERNAL_H_INCLUDED__ */