1 /***************************************************************************
2 * Copyright (C) 2005 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
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. *
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. *
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 ***************************************************************************/
24 #include "binarybuffer.h"
30 int arm_jtag_set_instr(arm_jtag_t *jtag_info, u32 new_instr)
32 jtag_device_t *device = jtag_get_device(jtag_info->chain_pos);
34 if (buf_get_u32(device->cur_instr, 0, device->ir_length) != new_instr)
38 field.device = jtag_info->chain_pos;
39 field.num_bits = device->ir_length;
40 field.out_value = calloc(CEIL(field.num_bits, 8), 1);
41 buf_set_u32(field.out_value, 0, field.num_bits, new_instr);
42 field.out_mask = NULL;
43 field.in_value = NULL;
44 field.in_check_value = NULL;
45 field.in_check_mask = NULL;
46 field.in_handler = NULL;
47 field.in_handler_priv = NULL;
49 jtag_add_ir_scan(1, &field, -1);
51 free(field.out_value);
57 int arm_jtag_scann(arm_jtag_t *jtag_info, u32 new_scan_chain)
59 if(jtag_info->cur_scan_chain != new_scan_chain)
63 field.device = jtag_info->chain_pos;
64 field.num_bits = jtag_info->scann_size;
65 field.out_value = calloc(CEIL(field.num_bits, 8), 1);
66 buf_set_u32(field.out_value, 0, field.num_bits, new_scan_chain);
67 field.out_mask = NULL;
68 //field.in_value = &scan_n_capture;
69 field.in_value = NULL;
70 field.in_check_value = NULL;
71 field.in_check_mask = NULL;
72 field.in_handler = NULL;
73 field.in_handler_priv = NULL;
75 arm_jtag_set_instr(jtag_info, jtag_info->scann_instr);
76 jtag_add_dr_scan(1, &field, -1);
78 jtag_info->cur_scan_chain = new_scan_chain;
80 free(field.out_value);
86 int arm_jtag_reset_callback(enum jtag_event event, void *priv)
88 arm_jtag_t *jtag_info = priv;
90 if (event == JTAG_TRST_ASSERTED)
92 jtag_info->cur_scan_chain = 0;
98 int arm_jtag_setup_connection(arm_jtag_t *jtag_info)
100 jtag_info->scann_instr = 0x2;
101 jtag_info->cur_scan_chain = 0;
102 jtag_info->intest_instr = 0xc;
104 jtag_register_event_callback(arm_jtag_reset_callback, jtag_info);
109 int arm_jtag_buf_to_u32_flip(u8 *in_buf, void *priv)
113 *dest = flip_u32(buf_get_u32(in_buf, 0, 32), 32);