Add new target type: OpenRISC
[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  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24
25 #include "or1k_tap.h"
26 #include "or1k.h"
27
28 #include <jtag/jtag.h>
29
30 #define OR1K_TAP_INST_DEBUG     0x8
31
32 static int or1k_tap_mohor_init(struct or1k_jtag *jtag_info)
33 {
34         LOG_DEBUG("Initialising OpenCores JTAG TAP");
35
36         /* Put TAP into state where it can talk to the debug interface
37          * by shifting in correct value to IR.
38          */
39
40         /* Ensure TAP is reset - maybe not necessary*/
41         jtag_add_tlr();
42
43         struct jtag_tap *tap = jtag_info->tap;
44         struct scan_field field;
45         uint8_t ir_value = OR1K_TAP_INST_DEBUG;
46
47         field.num_bits = tap->ir_length;
48         field.out_value = &ir_value;
49         field.in_value = NULL;
50
51         jtag_add_ir_scan(tap, &field, TAP_IDLE);
52
53         return jtag_execute_queue();
54 }
55
56 static struct or1k_tap_ip mohor_tap = {
57         .name = "mohor",
58         .init = or1k_tap_mohor_init,
59 };
60
61 int or1k_tap_mohor_register(void)
62 {
63         list_add_tail(&mohor_tap.list, &tap_list);
64         return 0;
65 }