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