1 /***************************************************************************
2  *   Copyright (C) 2011 by Martin Schmoelzer                               *
3  *   <martin.schmoelzer@student.tuwien.ac.at>                              *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
17  ***************************************************************************/
18 
19 /**
20  * @file
21  * Definition of the commands supported by the OpenULINK firmware.
22  *
23  * Basically, two types of commands can be distinguished:
24  *  - Commands with fixed payload size
25  *  - Commands with variable payload size
26  *
27  * SCAN commands (in all variations) carry payloads of variable size, all
28  * other commands carry payloads of fixed size.
29  *
30  * In the case of SCAN commands, the payload size (n) is calculated by
31  * dividing the scan_size_bits variable by 8, rounding up the result.
32  *
33  * Offset zero always contains the command ID.
34  *
35  ****************************************************************************
36  * CMD_SCAN_IN, CMD_SLOW_SCAN_IN:                                           *
37  *                                                                          *
38  * OUT:                                                                     *
39  * offset 1: scan_size_bytes                                                *
40  * offset 2: bits_last_byte                                                 *
41  * offset 3: tms_count_start + tms_count_end                                *
42  * offset 4: tms_sequence_start                                             *
43  * offset 5: tms_sequence_end                                               *
44  *                                                                          *
45  * IN:                                                                      *
46  * offset 0..n: TDO data                                                    *
47  ****************************************************************************
48  * CMD_SCAN_OUT, CMD_SLOW_SCAN_OUT:                                         *
49  *                                                                          *
50  * OUT:                                                                     *
51  * offset 1: scan_size_bytes                                                *
52  * offset 2: bits_last_byte                                                 *
53  * offset 3: tms_count_start + tms_count_end                                *
54  * offset 4: tms_sequence_start                                             *
55  * offset 5: tms_sequence_end                                               *
56  * offset 6..x: TDI data                                                    *
57  ****************************************************************************
58  * CMD_SCAN_IO, CMD_SLOW_SCAN_IO:                                           *
59  *                                                                          *
60  * OUT:                                                                     *
61  * offset 1: scan_size_bytes                                                *
62  * offset 2: bits_last_byte                                                 *
63  * offset 3: tms_count_start + tms_count_end                                *
64  * offset 4: tms_sequence_start                                             *
65  * offset 5: tms_sequence_end                                               *
66  * offset 6..x: TDI data                                                    *
67  *                                                                          *
68  * IN:                                                                      *
69  * offset 0..n: TDO data                                                    *
70  ****************************************************************************
71  * CMD_CLOCK_TMS, CMD_SLOW_CLOCK_TMS:                                       *
72  *                                                                          *
73  * OUT:                                                                     *
74  * offset 1: tms_count                                                      *
75  * offset 2: tms_sequence                                                   *
76  ****************************************************************************
77  * CMD_CLOCK_TCK, CMD_SLOW_CLOCK_TCK:                                       *
78  *                                                                          *
79  * OUT:                                                                     *
80  * offset 1: low byte of tck_count                                          *
81  * offset 2: high byte of tck_count                                         *
82  ****************************************************************************
83  * CMD_CLOCK_SLEEP_US:                                                      *
84  *                                                                          *
85  * OUT:                                                                     *
86  * offset 1: low byte of sleep_us                                           *
87  * offset 2: high byte of sleep_us                                          *
88  ****************************************************************************
89  * CMD_CLOCK_SLEEP_MS:                                                      *
90  *                                                                          *
91  * OUT:                                                                     *
92  * offset 1: low byte of sleep_ms                                           *
93  * offset 2: high byte of sleep_ms                                          *
94  ****************************************************************************
95  * CMD_GET_SIGNALS:                                                         *
96  *                                                                          *
97  * IN:                                                                      *
98  * offset 0: current state of input signals                                 *
99  * offset 1: current state of output signals                                *
100  ****************************************************************************
101  * CMD_SET_SIGNALS:                                                         *
102  *                                                                          *
103  * OUT:                                                                     *
104  * offset 1: signals that should be de-asserted                             *
105  * offset 2: signals that should be asserted                                *
106  ****************************************************************************
107  * CMD_CONFIGURE_TCK_FREQ:                                                  *
108  *                                                                          *
109  * OUT:                                                                     *
110  * offset 1: delay value for scan_in function                               *
111  * offset 2: delay value for scan_out function                              *
112  * offset 3: delay value for scan_io function                               *
113  * offset 4: delay value for clock_tck function                             *
114  * offset 5: delay value for clock_tms function                             *
115  ****************************************************************************
116  * CMD_SET_LEDS:                                                            *
117  *                                                                          *
118  * OUT:                                                                     *
119  * offset 1: LED states:                                                    *
120  *           Bit 0: turn COM LED on                                         *
121  *           Bit 1: turn RUN LED on                                         *
122  *           Bit 2: turn COM LED off                                        *
123  *           Bit 3: turn RUN LED off                                        *
124  *           Bits 7..4: Reserved                                            *
125  ****************************************************************************
126  * CMD_TEST:                                                                *
127  *                                                                          *
128  * OUT:                                                                     *
129  * offset 1: unused dummy value                                             *
130  ****************************************************************************
131  */
132 
133 #ifndef __MSGTYPES_H
134 #define __MSGTYPES_H
135 
136 /*
137  * Command IDs:
138  *
139  * Bits 7..6: Reserved, should always be zero
140  * Bits 5..0: Command ID. There are 62 usable IDs. Of this 63 available IDs,
141  *            the IDs 0x00..0x1F are commands with variable payload size,
142  *            the IDs 0x20..0x3F are commands with fixed payload size.
143  */
144 
145 #define CMD_ID_MASK             0x3F
146 
147 /* Commands with variable payload size */
148 #define CMD_SCAN_IN             0x00
149 #define CMD_SLOW_SCAN_IN        0x01
150 #define CMD_SCAN_OUT            0x02
151 #define CMD_SLOW_SCAN_OUT       0x03
152 #define CMD_SCAN_IO             0x04
153 #define CMD_SLOW_SCAN_IO        0x05
154 
155 /* Commands with fixed payload size */
156 #define CMD_CLOCK_TMS           0x20
157 #define CMD_SLOW_CLOCK_TMS      0x21
158 #define CMD_CLOCK_TCK           0x22
159 #define CMD_SLOW_CLOCK_TCK      0x23
160 #define CMD_SLEEP_US            0x24
161 #define CMD_SLEEP_MS            0x25
162 #define CMD_GET_SIGNALS         0x26
163 #define CMD_SET_SIGNALS         0x27
164 #define CMD_CONFIGURE_TCK_FREQ  0x28
165 #define CMD_SET_LEDS            0x29
166 #define CMD_TEST                0x2A
167 
168 /* JTAG signal definition for jtag_get_signals() -- Input signals! */
169 #define SIGNAL_TDO      (1<<0)
170 #define SIGNAL_BRKOUT   (1<<1)
171 #define SIGNAL_TRAP     (1<<2)
172 #define SIGNAL_RTCK     (1<<3)
173 
174 /* JTAG signal definition for jtag_get_signals() -- Output signals! */
175 #define SIGNAL_TDI      (1<<0)
176 #define SIGNAL_TMS      (1<<1)
177 #define SIGNAL_TCK      (1<<2)
178 #define SIGNAL_TRST     (1<<3)
179 #define SIGNAL_BRKIN    (1<<4)
180 #define SIGNAL_RESET    (1<<5)
181 #define SIGNAL_OCDSE    (1<<6)
182 
183 /* LED definitions for CMD_SET_LEDS and CMD_CLEAR_LEDS commands */
184 #define COM_LED_ON      (1<<0)
185 #define RUN_LED_ON      (1<<1)
186 #define COM_LED_OFF     (1<<2)
187 #define RUN_LED_OFF     (1<<3)
188 
189 #endif
190