Changed SAM4S Erase for effective Sector erase
[openocd.git] / src / target / avr32_jtag.h
blobd04ddda53120bd2296428dedc4ed301d40c2cc33
1 /***************************************************************************
2 * Copyright (C) 2010 by Oleksandr Tymoshenko <gonzo@bluezbox.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18 ***************************************************************************/
20 #ifndef AVR32_JTAG
21 #define AVR32_JTAG
23 #define AVR32NUMCOREREGS 17
25 /* tap instructions */
26 #define AVR32_INST_IDCODE 0x01
27 #define AVR32_INST_NEXUS_ACCESS 0x10
28 #define AVR32_INST_MW_ACCESS 0x11
29 #define AVR32_INST_MB_ACCESS 0x12
31 #define SLAVE_OCD 0x01
32 #define SLAVE_HSB_CACHED 0x04
33 #define SLAVE_HSB_UNCACHED 0x05
36 * Registers
39 #define AVR32_OCDREG_DID 0x00
40 #define AVR32_OCDREG_DC 0x02
41 #define OCDREG_DC_SS (1 << 8)
42 #define OCDREG_DC_DBR (1 << 12)
43 #define OCDREG_DC_DBE (1 << 13)
44 #define OCDREG_DC_SQA (1 << 22)
45 #define OCDREG_DC_RES (1 << 30)
46 #define OCDREG_DC_ABORT (1 << 31)
47 #define AVR32_OCDREG_DS 0x04
48 #define OCDREG_DS_SSS (1 << 0)
49 #define OCDREG_DS_SWB (1 << 1)
50 #define OCDREG_DS_HWB (1 << 2)
51 #define OCDREG_DS_STP (1 << 4)
52 #define OCDREG_DS_DBS (1 << 5)
53 #define OCDREG_DS_BP_SHIFT 8
54 #define OCDREG_DS_BP_MASK 0xff
55 #define OCDREG_DS_INC (1 << 24)
56 #define OCDREG_DS_BOZ (1 << 25)
57 #define OCDREG_DS_DBA (1 << 26)
58 #define OCDREG_DS_EXB (1 << 27)
59 #define OCDREG_DS_NTBF (1 << 28)
61 #define AVR32_OCDREG_DINST 0x41
62 #define AVR32_OCDREG_DPC 0x42
63 #define AVR32_OCDREG_DCCPU 0x44
64 #define AVR32_OCDREG_DCEMU 0x45
65 #define AVR32_OCDREG_DCSR 0x46
66 #define OCDREG_DCSR_CPUD (1 << 0)
67 #define OCDREG_DCSR_EMUD (1 << 1)
70 * Direction bit
72 #define MODE_WRITE 0x00
73 #define MODE_READ 0x01
76 * Some instructions
79 #define RETD 0xd703d623
80 #define MTDR(dreg, reg) (0xe7b00044 | ((reg) << 16) | dreg)
81 #define MFDR(reg, dreg) (0xe5b00044 | ((reg) << 16) | dreg)
82 #define MTSR(sysreg, reg) (0xe3b00002 | ((reg) << 16) | sysreg)
83 #define MFSR(reg, sysreg) (0xe1b00002 | ((reg) << 16) | sysreg)
85 struct avr32_jtag {
86 struct jtag_tap *tap;
87 uint32_t dpc; /* Debug PC value */
90 int avr32_jtag_nexus_read(struct avr32_jtag *jtag_info,
91 uint32_t addr, uint32_t *value);
92 int avr32_jtag_nexus_write(struct avr32_jtag *jtag_info,
93 uint32_t addr, uint32_t value);
95 int avr32_jtag_mwa_read(struct avr32_jtag *jtag_info, int slave,
96 uint32_t addr, uint32_t *value);
97 int avr32_jtag_mwa_write(struct avr32_jtag *jtag_info, int slave,
98 uint32_t addr, uint32_t value);
100 int avr32_ocd_setbits(struct avr32_jtag *jtag, int reg, uint32_t bits);
101 int avr32_ocd_clearbits(struct avr32_jtag *jtag, int reg, uint32_t bits);
103 int avr32_jtag_exec(struct avr32_jtag *jtag_info, uint32_t inst);
105 #endif /* AVR32_JTAG */