Skip to content

Commit 9478a30

Browse files
Pratik Patelmathieupoirier
authored andcommitted
coresight: add CoreSight core layer framework
CoreSight components are compliant with the ARM CoreSight architecture specification and can be connected in various topologies to suit a particular SoC tracing needs. These trace components can generally be classified as sources, links and sinks. Trace data produced by one or more sources flows through the intermediate links connecting the source to the currently selected sink. The CoreSight framework provides an interface for the CoreSight trace drivers to register themselves with. It's intended to build up a topological view of the CoreSight components and configure the correct serie of components on user input via sysfs. For eg., when enabling a source, the framework builds up a path consisting of all the components connecting the source to the currently selected sink(s) and enables all of them. The framework also supports switching between available sinks and provides status information to user space applications through the debugfs interface. Signed-off-by: Pratik Patel <pratikp@codeaurora.org> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit a06ae8609b3dd06b957a6e4e965772a8a14d3af5) Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Conflicts: arch/arm/Kconfig.debug drivers/Makefile
1 parent 8c9f0fc commit 9478a30

File tree

10 files changed

+1272
-1
lines changed

10 files changed

+1272
-1
lines changed

MAINTAINERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,14 @@ M: Hubert Feurstein <hubert.feurstein@contec.at>
918918
S: Maintained
919919
F: arch/arm/mach-ep93xx/micro9.c
920920

921+
ARM/CORESIGHT FRAMEWORK AND DRIVERS
922+
M: Mathieu Poirier <mathieu.poirier@linaro.org>
923+
L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
924+
S: Maintained
925+
F: drivers/coresight/*
926+
F: Documentation/trace/coresight.txt
927+
F: Documentation/devicetree/bindings/arm/coresight.txt
928+
921929
ARM/CORGI MACHINE SUPPORT
922930
M: Richard Purdie <rpurdie@rpsys.net>
923931
S: Maintained

arch/arm/Kconfig.debug

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,4 +1331,13 @@ config DEBUG_SET_MODULE_RONX
13311331
against certain classes of kernel exploits.
13321332
If in doubt, say "N".
13331333

1334+
menuconfig CORESIGHT
1335+
bool "CoreSight Tracing Support"
1336+
select ARM_AMBA
1337+
help
1338+
This framework provides a kernel interface for the CoreSight debug
1339+
and trace drivers to register themselves with. It's intended to build
1340+
a topological view of the CoreSight components based on a DT
1341+
specification and configure the right serie of components when a
1342+
trace source gets enabled.
13341343
endmenu

drivers/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,4 @@ obj-$(CONFIG_POWERCAP) += powercap/
161161
obj-$(CONFIG_MCB) += mcb/
162162
obj-$(CONFIG_RAS) += ras/
163163
obj-$(CONFIG_THUNDERBOLT) += thunderbolt/
164+
obj-$(CONFIG_CORESIGHT) += coresight/

drivers/amba/bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ int amba_device_add(struct amba_device *dev, struct resource *parent)
336336

337337
amba_put_disable_pclk(dev);
338338

339-
if (cid == AMBA_CID)
339+
if (cid == AMBA_CID || cid == CORESIGHT_CID)
340340
dev->periphid = pid;
341341

342342
if (!dev->periphid)

drivers/coresight/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#
2+
# Makefile for CoreSight drivers.
3+
#
4+
obj-$(CONFIG_CORESIGHT) += coresight.o
5+
obj-$(CONFIG_OF) += of_coresight.o

drivers/coresight/coresight-priv.h

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
2+
*
3+
* This program is free software; you can redistribute it and/or modify
4+
* it under the terms of the GNU General Public License version 2 and
5+
* only version 2 as published by the Free Software Foundation.
6+
*
7+
* This program is distributed in the hope that it will be useful,
8+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
* GNU General Public License for more details.
11+
*/
12+
13+
#ifndef _CORESIGHT_PRIV_H
14+
#define _CORESIGHT_PRIV_H
15+
16+
#include <linux/bitops.h>
17+
#include <linux/io.h>
18+
#include <linux/coresight.h>
19+
20+
/*
21+
* Coresight management registers (0xf00-0xfcc)
22+
* 0xfa0 - 0xfa4: Management registers in PFTv1.0
23+
* Trace registers in PFTv1.1
24+
*/
25+
#define CORESIGHT_ITCTRL 0xf00
26+
#define CORESIGHT_CLAIMSET 0xfa0
27+
#define CORESIGHT_CLAIMCLR 0xfa4
28+
#define CORESIGHT_LAR 0xfb0
29+
#define CORESIGHT_LSR 0xfb4
30+
#define CORESIGHT_AUTHSTATUS 0xfb8
31+
#define CORESIGHT_DEVID 0xfc8
32+
#define CORESIGHT_DEVTYPE 0xfcc
33+
34+
#define TIMEOUT_US 100
35+
#define BMVAL(val, lsb, msb) ((val & GENMASK(msb, lsb)) >> lsb)
36+
37+
static inline void CS_LOCK(void __iomem *addr)
38+
{
39+
do {
40+
/* Wait for things to settle */
41+
mb();
42+
writel_relaxed(0x0, addr + CORESIGHT_LAR);
43+
} while (0);
44+
}
45+
46+
static inline void CS_UNLOCK(void __iomem *addr)
47+
{
48+
do {
49+
writel_relaxed(CORESIGHT_UNLOCK, addr + CORESIGHT_LAR);
50+
/* Make sure eveyone has seen this */
51+
mb();
52+
} while (0);
53+
}
54+
55+
#ifdef CONFIG_CORESIGHT_SOURCE_ETM3X
56+
extern int etm_readl_cp14(u32 off, unsigned int *val);
57+
extern int etm_writel_cp14(u32 off, u32 val);
58+
#else
59+
static inline int etm_readl_cp14(u32 off, unsigned int *val) { return 0; }
60+
static inline int etm_writel_cp14(u32 val, u32 off) { return 0; }
61+
#endif
62+
63+
#endif

0 commit comments

Comments
 (0)