Skip to content

Commit 835d722

Browse files
mikel-armbbgregkh
authored andcommitted
coresight: cti: Initial CoreSight CTI Driver
This introduces a baseline CTI driver and associated configuration files. Uses the platform agnostic naming standard for CoreSight devices, along with a generic platform probing method that currently supports device tree descriptions, but allows for the ACPI bindings to be added once these have been defined for the CTI devices. Driver will probe for the device on the AMBA bus, and load the CTI driver on CoreSight ID match to CTI IDs in tables. Initial sysfs support for enable / disable provided. Default CTI interconnection data is generated based on hardware register signal counts, with no additional connection information. Signed-off-by: Mike Leach <[email protected]> Reviewed-by: Suzuki K Poulose <[email protected]> Signed-off-by: Mathieu Poirier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c23ff2a commit 835d722

File tree

8 files changed

+809
-0
lines changed

8 files changed

+809
-0
lines changed

drivers/hwtracing/coresight/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,16 @@ config CORESIGHT_CPU_DEBUG
110110
properly, please refer Documentation/trace/coresight-cpu-debug.rst
111111
for detailed description and the example for usage.
112112

113+
config CORESIGHT_CTI
114+
bool "CoreSight Cross Trigger Interface (CTI) driver"
115+
depends on ARM || ARM64
116+
help
117+
This driver provides support for CoreSight CTI and CTM components.
118+
These provide hardware triggering events between CoreSight trace
119+
source and sink components. These can be used to halt trace or
120+
inject events into the trace stream. CTI also provides a software
121+
control to trigger the same halt events. This can provide fast trace
122+
halt compared to disabling sources and sinks normally in driver
123+
software.
124+
113125
endif

drivers/hwtracing/coresight/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ obj-$(CONFIG_CORESIGHT_SOURCE_ETM4X) += coresight-etm4x.o \
1717
obj-$(CONFIG_CORESIGHT_STM) += coresight-stm.o
1818
obj-$(CONFIG_CORESIGHT_CPU_DEBUG) += coresight-cpu-debug.o
1919
obj-$(CONFIG_CORESIGHT_CATU) += coresight-catu.o
20+
obj-$(CONFIG_CORESIGHT_CTI) += coresight-cti.o \
21+
coresight-cti-platform.o \
22+
coresight-cti-sysfs.o
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (c) 2019, The Linaro Limited. All rights reserved.
4+
*/
5+
6+
#include <linux/of.h>
7+
8+
#include "coresight-cti.h"
9+
10+
/* get the hardware configuration & connection data. */
11+
int cti_plat_get_hw_data(struct device *dev,
12+
struct cti_drvdata *drvdata)
13+
{
14+
int rc = 0;
15+
struct cti_device *cti_dev = &drvdata->ctidev;
16+
17+
/* if no connections, just add a single default based on max IN-OUT */
18+
if (cti_dev->nr_trig_con == 0)
19+
rc = cti_add_default_connection(dev, drvdata);
20+
return rc;
21+
}
22+
23+
struct coresight_platform_data *
24+
coresight_cti_get_platform_data(struct device *dev)
25+
{
26+
int ret = -ENOENT;
27+
struct coresight_platform_data *pdata = NULL;
28+
struct fwnode_handle *fwnode = dev_fwnode(dev);
29+
struct cti_drvdata *drvdata = dev_get_drvdata(dev);
30+
31+
if (IS_ERR_OR_NULL(fwnode))
32+
goto error;
33+
34+
/*
35+
* Alloc platform data but leave it zero init. CTI does not use the
36+
* same connection infrastructuree as trace path components but an
37+
* empty struct enables us to use the standard coresight component
38+
* registration code.
39+
*/
40+
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
41+
if (!pdata) {
42+
ret = -ENOMEM;
43+
goto error;
44+
}
45+
46+
/* get some CTI specifics */
47+
ret = cti_plat_get_hw_data(dev, drvdata);
48+
49+
if (!ret)
50+
return pdata;
51+
error:
52+
return ERR_PTR(ret);
53+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (c) 2019 Linaro Limited, All rights reserved.
4+
* Author: Mike Leach <[email protected]>
5+
*/
6+
7+
#include <linux/coresight.h>
8+
9+
#include "coresight-cti.h"
10+
11+
/* basic attributes */
12+
static ssize_t enable_show(struct device *dev,
13+
struct device_attribute *attr,
14+
char *buf)
15+
{
16+
int enable_req;
17+
bool enabled, powered;
18+
struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
19+
20+
enable_req = atomic_read(&drvdata->config.enable_req_count);
21+
spin_lock(&drvdata->spinlock);
22+
powered = drvdata->config.hw_powered;
23+
enabled = drvdata->config.hw_enabled;
24+
spin_unlock(&drvdata->spinlock);
25+
26+
if (powered)
27+
return sprintf(buf, "%d\n", enabled);
28+
else
29+
return sprintf(buf, "%d\n", !!enable_req);
30+
}
31+
32+
static ssize_t enable_store(struct device *dev,
33+
struct device_attribute *attr,
34+
const char *buf, size_t size)
35+
{
36+
int ret = 0;
37+
unsigned long val;
38+
struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
39+
40+
ret = kstrtoul(buf, 0, &val);
41+
if (ret)
42+
return ret;
43+
44+
if (val)
45+
ret = cti_enable(drvdata->csdev);
46+
else
47+
ret = cti_disable(drvdata->csdev);
48+
if (ret)
49+
return ret;
50+
return size;
51+
}
52+
static DEVICE_ATTR_RW(enable);
53+
54+
static ssize_t powered_show(struct device *dev,
55+
struct device_attribute *attr,
56+
char *buf)
57+
{
58+
bool powered;
59+
struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
60+
61+
spin_lock(&drvdata->spinlock);
62+
powered = drvdata->config.hw_powered;
63+
spin_unlock(&drvdata->spinlock);
64+
65+
return sprintf(buf, "%d\n", powered);
66+
}
67+
static DEVICE_ATTR_RO(powered);
68+
69+
/* attribute and group sysfs tables. */
70+
static struct attribute *coresight_cti_attrs[] = {
71+
&dev_attr_enable.attr,
72+
&dev_attr_powered.attr,
73+
NULL,
74+
};
75+
76+
static const struct attribute_group coresight_cti_group = {
77+
.attrs = coresight_cti_attrs,
78+
};
79+
80+
const struct attribute_group *coresight_cti_groups[] = {
81+
&coresight_cti_group,
82+
NULL,
83+
};

0 commit comments

Comments
 (0)