--- /dev/null
+/***************************************************************************\r
+ * Copyright (C) 2005 by Dominic Rath *\r
+ * Dominic.Rath@gmx.de *\r
+ * *\r
+ * Copyright (C) 2008 by Spencer Oliver *\r
+ * spen@spen-soft.co.uk *\r
+ * *\r
+ * Copyright (C) 2008 by John McCarthy *\r
+ * jgmcc@magma.ca *\r
+ * *\r
+ * This program is free software; you can redistribute it and/or modify *\r
+ * it under the terms of the GNU General Public License as published by *\r
+ * the Free Software Foundation; either version 2 of the License, or *\r
+ * (at your option) any later version. *\r
+ * *\r
+ * This program is distributed in the hope that it will be useful, *\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *\r
+ * GNU General Public License for more details. *\r
+ * *\r
+ * You should have received a copy of the GNU General Public License *\r
+ * along with this program; if not, write to the *\r
+ * Free Software Foundation, Inc., *\r
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *\r
+ ***************************************************************************/\r
+#ifndef PIC32MX_H\r
+#define PIC32MX_H\r
+\r
+#include "flash.h"\r
+#include "target.h"\r
+\r
+typedef struct pic32mx_flash_bank_s\r
+{\r
+ working_area_t *write_algorithm;\r
+ int devid;\r
+ int ppage_size;\r
+ int probed;\r
+} pic32mx_flash_bank_t;\r
+\r
+#define PIC32MX_MANUF_ID 0x029\r
+\r
+/* pic32mx memory locations */\r
+\r
+#define PIC32MX_KUSEG_PGM_FLASH 0x7D000000\r
+#define PIC32MX_KUSEG_RAM 0x7F000000\r
+\r
+#define PIC32MX_KSEG0_RAM 0x80000000\r
+#define PIC32MX_KSEG0_PGM_FLASH 0x9D000000\r
+#define PIC32MX_KSEG0_BOOT_FLASH 0x9FC00000\r
+\r
+#define PIC32MX_KSEG1_RAM 0xA0000000\r
+#define PIC32MX_KSEG1_PGM_FLASH 0xBD000000\r
+#define PIC32MX_KSEG1_PERIPHERAL 0xBF800000\r
+#define PIC32MX_KSEG1_BOOT_FLASH 0xBFC00000\r
+\r
+#define PIC32MX_PHYS_RAM 0x00000000\r
+#define PIC32MX_PHYS_PGM_FLASH 0x1D000000\r
+#define PIC32MX_PHYS_PERIPHERALS 0x1F800000\r
+#define PIC32MX_PHYS_BOOT_FLASH 0x1FC00000\r
+\r
+/* pic32mx configuration register locations */\r
+\r
+#define PIC32MX_DEVCFG0 0xBFC02FFC\r
+#define PIC32MX_DEVCFG1 0xBFC02FF8\r
+#define PIC32MX_DEVCFG2 0xBFC02FF4\r
+#define PIC32MX_DEVCFG3 0XBFC02FF0\r
+#define PIC32MX_DEVID 0xBF80F220\r
+\r
+/* pic32mx flash controller register locations */\r
+\r
+#define PIC32MX_NVMCON 0xBF80F400\r
+#define PIC32MX_NVMCONCLR 0xBF80F404\r
+#define PIC32MX_NVMCONSET 0xBF80F408\r
+#define PIC32MX_NVMCONINV 0xBF80F40C\r
+#define NVMCON_NVMWR (1<<15)\r
+#define NVMCON_NVMWREN (1<<14)\r
+#define NVMCON_NVMERR (1<<13)\r
+#define NVMCON_LVDERR (1<<12)\r
+#define NVMCON_LVDSTAT (1<<11)\r
+#define NVMCON_OP_PFM_ERASE 0x5\r
+#define NVMCON_OP_PAGE_ERASE 0x4\r
+#define NVMCON_OP_ROW_PROG 0x3\r
+#define NVMCON_OP_WORD_PROG 0x1\r
+#define NVMCON_OP_NOP 0x0\r
+\r
+#define PIC32MX_NVMKEY 0xBF80F410\r
+#define PIC32MX_NVMADDR 0xBF80F420\r
+#define PIC32MX_NVMADDRCLR 0xBF80F424\r
+#define PIC32MX_NVMADDRSET 0xBF80F428\r
+#define PIC32MX_NVMADDRINV 0xBF80F42C\r
+#define PIC32MX_NVMDATA 0xBF80F430\r
+#define PIC32MX_NVMSRCADDR 0xBF80F440\r
+\r
+/* flash unlock keys */\r
+\r
+#define NVMKEY1 0xAA996655\r
+#define NVMKEY2 0x556699AA\r
+\r
+typedef struct pic32mx_mem_layout_s {\r
+ u32 sector_start;\r
+ u32 sector_size;\r
+} pic32mx_mem_layout_t;\r
+\r
+#endif /* PIC32MX_H */\r
+\r