aboutsummaryrefslogtreecommitdiff
path: root/src/lpc43xx.c
diff options
context:
space:
mode:
authorGareth McMullin2012-11-03 21:33:28 +1300
committerGareth McMullin2012-11-03 21:33:28 +1300
commite1c1162a1a666387133780efa31935e5b6dcc5c7 (patch)
treeba1f9445dd10fea1fa6242cf80b0dd7a082158ef /src/lpc43xx.c
parentf526a82773abdb7c4d4c2122758d6adbc8a9519e (diff)
Recognise LPC43xx dual core devices.
Diffstat (limited to 'src/lpc43xx.c')
-rw-r--r--src/lpc43xx.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/lpc43xx.c b/src/lpc43xx.c
new file mode 100644
index 0000000..2652b42
--- /dev/null
+++ b/src/lpc43xx.c
@@ -0,0 +1,53 @@
+/*
+ * This file is part of the Black Magic Debug project.
+ *
+ * Copyright (C) 2012 Gareth McMullin <gareth@blacksphere.co.nz>
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "general.h"
+#include "adiv5.h"
+#include "target.h"
+
+#define LPC43XX_CHIPID 0x40043200
+#define ARM_CPUID 0xE000ED00
+
+int lpc43xx_probe(struct target_s *target)
+{
+ uint32_t chipid, cpuid;
+
+ chipid = adiv5_ap_mem_read(adiv5_target_ap(target), LPC43XX_CHIPID);
+ cpuid = adiv5_ap_mem_read(adiv5_target_ap(target), ARM_CPUID);
+
+ switch(chipid) {
+ case 0x4906002B: /* Parts with on-chip flash */
+ case 0x5906002B: /* Flashless parts */
+ case 0x6906002B:
+ switch (cpuid & 0xFF00FFF0) {
+ case 0x4100C240:
+ target->driver = "LPC43xx Cortex-M4";
+ break;
+ case 0x4100C200:
+ target->driver = "LPC43xx Cortex-M0";
+ break;
+ default:
+ target->driver = "LPC43xx <Unknown>";
+ }
+ return 0;
+ }
+
+ return -1;
+}
+