aboutsummaryrefslogtreecommitdiff
path: root/src/lpc43xx.c
blob: ca1b351767f8d0aaa5094ed99fa813b1652838de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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

bool 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 true;
	}

	return false;
}