aboutsummaryrefslogtreecommitdiff
path: root/src/target/dsp563xx_once.c
blob: 416cb6b598087aa71b5d0797960a037751f747b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/***************************************************************************
 *   Copyright (C) 2009 by Mathias Kuester                                 *
 *   mkdorg@users.sourceforge.net                                          *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <helper/jim.h>

#include "target.h"
#include "target_type.h"
#include "register.h"
#include "dsp563xx.h"
#include "dsp563xx_once.h"

/** single word instruction */
static int dsp563xx_once_ir_exec(struct jtag_tap *tap, uint8_t instr, uint8_t rw,
			  uint8_t go, uint8_t ex)
{
	dsp563xx_write_dr_u8(tap, 0,
			     instr | (ex << 5) | (go << 6) | (rw << 7), 8, 0);
	dsp563xx_execute_queue();

	return ERROR_OK;
}

/** single word instruction */
static int dsp563xx_once_ir_exec_nq(struct jtag_tap *tap, uint8_t instr, uint8_t rw,
			     uint8_t go, uint8_t ex)
{
	dsp563xx_write_dr_u8(tap, 0,
			     instr | (ex << 5) | (go << 6) | (rw << 7), 8, 0);

	return ERROR_OK;
}

/** once read register */
int dsp563xx_once_reg_read(struct jtag_tap *tap, uint8_t reg, uint32_t * data)
{
	uint32_t dr_in;

	dr_in = 0;

	dsp563xx_once_ir_exec(tap, reg, 1, 0, 0);
	dsp563xx_write_dr_u32(tap, &dr_in, 0x00, 24, 0);
	dsp563xx_execute_queue();

	*data = dr_in;

	return ERROR_OK;
}

/** once write register */
int dsp563xx_once_reg_write(struct jtag_tap *tap, uint8_t reg, uint32_t data)
{
	dsp563xx_once_ir_exec(tap, reg, 0, 0, 0);
	dsp563xx_write_dr_u32(tap, 0x00, data, 24, 0);
	dsp563xx_execute_queue();

	return ERROR_OK;
}

/** single word instruction */
int dsp563xx_once_execute_sw_ir(struct jtag_tap *tap, uint32_t opcode)
{
	dsp563xx_once_ir_exec(tap, DSP563XX_ONCE_OPDBR, 0, 1, 0);
	dsp563xx_write_dr_u32(tap, 0, opcode, 24, 0);
	dsp563xx_execute_queue();

	return ERROR_OK;
}

/** double word instruction */
int dsp563xx_once_execute_dw_ir(struct jtag_tap *tap, uint32_t opcode,
				uint32_t operand)
{
	dsp563xx_once_ir_exec(tap, DSP563XX_ONCE_OPDBR, 0, 0, 0);
	dsp563xx_write_dr_u32(tap, 0, opcode, 24, 0);
	dsp563xx_execute_queue();

	dsp563xx_once_ir_exec(tap, DSP563XX_ONCE_OPDBR, 0, 1, 0);
	dsp563xx_write_dr_u32(tap, 0, operand, 24, 0);
	dsp563xx_execute_queue();

	return ERROR_OK;
}

/** single word instruction */
int dsp563xx_once_execute_sw_ir_nq(struct jtag_tap *tap, uint32_t opcode)
{
	dsp563xx_once_ir_exec_nq(tap, DSP563XX_ONCE_OPDBR, 0, 1, 0);
	dsp563xx_write_dr_u32(tap, 0, opcode, 24, 0);

	return ERROR_OK;
}

/** double word instruction */
int dsp563xx_once_execute_dw_ir_nq(struct jtag_tap *tap, uint32_t opcode,
				   uint32_t operand)
{
	dsp563xx_once_ir_exec_nq(tap, DSP563XX_ONCE_OPDBR, 0, 0, 0);
	dsp563xx_write_dr_u32(tap, 0, opcode, 24, 0);

	dsp563xx_once_ir_exec_nq(tap, DSP563XX_ONCE_OPDBR, 0, 1, 0);
	dsp563xx_write_dr_u32(tap, 0, operand, 24, 0);

	return ERROR_OK;
}