b654b1b53a12d123c55d698de5e669c4af797271
[fw/openocd] / src / target / openrisc / or1k_tap_mohor.c
1 /***************************************************************************
2  *   Copyright (C) 2013 by Franck Jullien                                  *
3  *   elec4fun@gmail.com                                                    *
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
16 #ifdef HAVE_CONFIG_H
17 #include "config.h"
18 #endif
19
20 #include "or1k_tap.h"
21 #include "or1k.h"
22
23 #include <jtag/jtag.h>
24
25 #define OR1K_TAP_INST_DEBUG     0x8
26
27 static int or1k_tap_mohor_init(struct or1k_jtag *jtag_info)
28 {
29         LOG_DEBUG("Initialising OpenCores JTAG TAP");
30
31         /* Put TAP into state where it can talk to the debug interface
32          * by shifting in correct value to IR.
33          */
34
35         /* Ensure TAP is reset - maybe not necessary*/
36         jtag_add_tlr();
37
38         struct jtag_tap *tap = jtag_info->tap;
39         struct scan_field field;
40         uint8_t ir_value = OR1K_TAP_INST_DEBUG;
41
42         field.num_bits = tap->ir_length;
43         field.out_value = &ir_value;
44         field.in_value = NULL;
45
46         jtag_add_ir_scan(tap, &field, TAP_IDLE);
47
48         return jtag_execute_queue();
49 }
50
51 static struct or1k_tap_ip mohor_tap = {
52         .name = "mohor",
53         .init = or1k_tap_mohor_init,
54 };
55
56 int or1k_tap_mohor_register(void)
57 {
58         list_add_tail(&mohor_tap.list, &tap_list);
59         return 0;
60 }