]> git.sur5r.net Git - openocd/blob - src/flash/pic32mx.h
eol-style native
[openocd] / src / flash / pic32mx.h
1 /***************************************************************************
2  *   Copyright (C) 2005 by Dominic Rath                                    *
3  *   Dominic.Rath@gmx.de                                                   *
4  *                                                                         *
5  *   Copyright (C) 2008 by Spencer Oliver                                  *
6  *   spen@spen-soft.co.uk                                                  *
7  *                                                                         *
8  *   Copyright (C) 2008 by John McCarthy                                   *
9  *   jgmcc@magma.ca                                                        *
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  *   This program is distributed in the hope that it will be useful,       *
17  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
18  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
19  *   GNU General Public License for more details.                          *
20  *                                                                         *
21  *   You should have received a copy of the GNU General Public License     *
22  *   along with this program; if not, write to the                         *
23  *   Free Software Foundation, Inc.,                                       *
24  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
25  ***************************************************************************/
26 #ifndef PIC32MX_H
27 #define PIC32MX_H
28
29 #include "flash.h"
30 #include "target.h"
31
32 typedef struct pic32mx_flash_bank_s
33 {
34         working_area_t *write_algorithm;
35         int devid;
36         int ppage_size;
37         int probed;
38 } pic32mx_flash_bank_t;
39
40 #define PIC32MX_MANUF_ID        0x029
41
42 /* pic32mx memory locations */
43
44 #define PIC32MX_KUSEG_PGM_FLASH         0x7D000000
45 #define PIC32MX_KUSEG_RAM               0x7F000000
46
47 #define PIC32MX_KSEG0_RAM               0x80000000
48 #define PIC32MX_KSEG0_PGM_FLASH         0x9D000000
49 #define PIC32MX_KSEG0_BOOT_FLASH        0x9FC00000
50
51 #define PIC32MX_KSEG1_RAM               0xA0000000
52 #define PIC32MX_KSEG1_PGM_FLASH         0xBD000000
53 #define PIC32MX_KSEG1_PERIPHERAL        0xBF800000
54 #define PIC32MX_KSEG1_BOOT_FLASH        0xBFC00000
55
56 #define PIC32MX_PHYS_RAM                0x00000000
57 #define PIC32MX_PHYS_PGM_FLASH          0x1D000000
58 #define PIC32MX_PHYS_PERIPHERALS        0x1F800000
59 #define PIC32MX_PHYS_BOOT_FLASH         0x1FC00000
60
61 /* pic32mx configuration register locations */
62
63 #define PIC32MX_DEVCFG0         0xBFC02FFC
64 #define PIC32MX_DEVCFG1         0xBFC02FF8
65 #define PIC32MX_DEVCFG2         0xBFC02FF4
66 #define PIC32MX_DEVCFG3         0XBFC02FF0
67 #define PIC32MX_DEVID           0xBF80F220
68
69 /* pic32mx flash controller register locations */
70
71 #define PIC32MX_NVMCON          0xBF80F400
72 #define PIC32MX_NVMCONCLR       0xBF80F404
73 #define PIC32MX_NVMCONSET       0xBF80F408
74 #define PIC32MX_NVMCONINV       0xBF80F40C
75 #define NVMCON_NVMWR            (1<<15)
76 #define NVMCON_NVMWREN          (1<<14)
77 #define NVMCON_NVMERR           (1<<13)
78 #define NVMCON_LVDERR           (1<<12)
79 #define NVMCON_LVDSTAT          (1<<11)
80 #define NVMCON_OP_PFM_ERASE     0x5
81 #define NVMCON_OP_PAGE_ERASE    0x4
82 #define NVMCON_OP_ROW_PROG      0x3
83 #define NVMCON_OP_WORD_PROG     0x1
84 #define NVMCON_OP_NOP           0x0
85
86 #define PIC32MX_NVMKEY          0xBF80F410
87 #define PIC32MX_NVMADDR         0xBF80F420
88 #define PIC32MX_NVMADDRCLR      0xBF80F424
89 #define PIC32MX_NVMADDRSET      0xBF80F428
90 #define PIC32MX_NVMADDRINV      0xBF80F42C
91 #define PIC32MX_NVMDATA         0xBF80F430
92 #define PIC32MX_NVMSRCADDR      0xBF80F440
93
94 /* flash unlock keys */
95
96 #define NVMKEY1                 0xAA996655
97 #define NVMKEY2                 0x556699AA
98
99 typedef struct pic32mx_mem_layout_s {
100         u32 sector_start;
101         u32 sector_size;
102 } pic32mx_mem_layout_t;
103
104 #endif /* PIC32MX_H */
105