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 ***************************************************************************/
26 #include "binarybuffer.h"
32 int arm_jtag_set_instr(arm_jtag_t *jtag_info, u32 new_instr)
34 jtag_device_t *device = jtag_get_device(jtag_info->chain_pos);
36 if (buf_get_u32(device->cur_instr, 0, device->ir_length) != new_instr)
40 field.device = jtag_info->chain_pos;
41 field.num_bits = device->ir_length;
42 field.out_value = calloc(CEIL(field.num_bits, 8), 1);
43 buf_set_u32(field.out_value, 0, field.num_bits, new_instr);
44 field.out_mask = NULL;
45 field.in_value = NULL;
46 field.in_check_value = NULL;
47 field.in_check_mask = NULL;
48 field.in_handler = NULL;
49 field.in_handler_priv = NULL;
51 jtag_add_ir_scan(1, &field, -1);
53 free(field.out_value);
59 int arm_jtag_scann(arm_jtag_t *jtag_info, u32 new_scan_chain)
61 if(jtag_info->cur_scan_chain != new_scan_chain)
65 field.device = jtag_info->chain_pos;
66 field.num_bits = jtag_info->scann_size;
67 field.out_value = calloc(CEIL(field.num_bits, 8), 1);
68 buf_set_u32(field.out_value, 0, field.num_bits, new_scan_chain);
69 field.out_mask = NULL;
70 //field.in_value = &scan_n_capture;
71 field.in_value = NULL;
72 field.in_check_value = NULL;
73 field.in_check_mask = NULL;
74 field.in_handler = NULL;
75 field.in_handler_priv = NULL;
77 arm_jtag_set_instr(jtag_info, jtag_info->scann_instr);
78 jtag_add_dr_scan(1, &field, -1);
80 jtag_info->cur_scan_chain = new_scan_chain;
82 free(field.out_value);
88 int arm_jtag_reset_callback(enum jtag_event event, void *priv)
90 arm_jtag_t *jtag_info = priv;
92 if (event == JTAG_TRST_ASSERTED)
94 jtag_info->cur_scan_chain = 0;
100 int arm_jtag_setup_connection(arm_jtag_t *jtag_info)
102 jtag_info->scann_instr = 0x2;
103 jtag_info->cur_scan_chain = 0;
104 jtag_info->intest_instr = 0xc;
106 jtag_register_event_callback(arm_jtag_reset_callback, jtag_info);
111 int arm_jtag_buf_to_u32_flip(u8 *in_buf, void *priv)
115 *dest = flip_u32(buf_get_u32(in_buf, 0, 32), 32);