-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <mike.leach@linaro.org> Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Link: https://lore.kernel.org/r/20200320165303.13681-2-mathieu.poirier@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
- Loading branch information
Mike Leach
authored and
Greg Kroah-Hartman
committed
Mar 21, 2020
1 parent
c23ff2a
commit 835d722
Showing
8 changed files
with
809 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* Copyright (c) 2019, The Linaro Limited. All rights reserved. | ||
*/ | ||
|
||
#include <linux/of.h> | ||
|
||
#include "coresight-cti.h" | ||
|
||
/* get the hardware configuration & connection data. */ | ||
int cti_plat_get_hw_data(struct device *dev, | ||
struct cti_drvdata *drvdata) | ||
{ | ||
int rc = 0; | ||
struct cti_device *cti_dev = &drvdata->ctidev; | ||
|
||
/* if no connections, just add a single default based on max IN-OUT */ | ||
if (cti_dev->nr_trig_con == 0) | ||
rc = cti_add_default_connection(dev, drvdata); | ||
return rc; | ||
} | ||
|
||
struct coresight_platform_data * | ||
coresight_cti_get_platform_data(struct device *dev) | ||
{ | ||
int ret = -ENOENT; | ||
struct coresight_platform_data *pdata = NULL; | ||
struct fwnode_handle *fwnode = dev_fwnode(dev); | ||
struct cti_drvdata *drvdata = dev_get_drvdata(dev); | ||
|
||
if (IS_ERR_OR_NULL(fwnode)) | ||
goto error; | ||
|
||
/* | ||
* Alloc platform data but leave it zero init. CTI does not use the | ||
* same connection infrastructuree as trace path components but an | ||
* empty struct enables us to use the standard coresight component | ||
* registration code. | ||
*/ | ||
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); | ||
if (!pdata) { | ||
ret = -ENOMEM; | ||
goto error; | ||
} | ||
|
||
/* get some CTI specifics */ | ||
ret = cti_plat_get_hw_data(dev, drvdata); | ||
|
||
if (!ret) | ||
return pdata; | ||
error: | ||
return ERR_PTR(ret); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* Copyright (c) 2019 Linaro Limited, All rights reserved. | ||
* Author: Mike Leach <mike.leach@linaro.org> | ||
*/ | ||
|
||
#include <linux/coresight.h> | ||
|
||
#include "coresight-cti.h" | ||
|
||
/* basic attributes */ | ||
static ssize_t enable_show(struct device *dev, | ||
struct device_attribute *attr, | ||
char *buf) | ||
{ | ||
int enable_req; | ||
bool enabled, powered; | ||
struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); | ||
|
||
enable_req = atomic_read(&drvdata->config.enable_req_count); | ||
spin_lock(&drvdata->spinlock); | ||
powered = drvdata->config.hw_powered; | ||
enabled = drvdata->config.hw_enabled; | ||
spin_unlock(&drvdata->spinlock); | ||
|
||
if (powered) | ||
return sprintf(buf, "%d\n", enabled); | ||
else | ||
return sprintf(buf, "%d\n", !!enable_req); | ||
} | ||
|
||
static ssize_t enable_store(struct device *dev, | ||
struct device_attribute *attr, | ||
const char *buf, size_t size) | ||
{ | ||
int ret = 0; | ||
unsigned long val; | ||
struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); | ||
|
||
ret = kstrtoul(buf, 0, &val); | ||
if (ret) | ||
return ret; | ||
|
||
if (val) | ||
ret = cti_enable(drvdata->csdev); | ||
else | ||
ret = cti_disable(drvdata->csdev); | ||
if (ret) | ||
return ret; | ||
return size; | ||
} | ||
static DEVICE_ATTR_RW(enable); | ||
|
||
static ssize_t powered_show(struct device *dev, | ||
struct device_attribute *attr, | ||
char *buf) | ||
{ | ||
bool powered; | ||
struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); | ||
|
||
spin_lock(&drvdata->spinlock); | ||
powered = drvdata->config.hw_powered; | ||
spin_unlock(&drvdata->spinlock); | ||
|
||
return sprintf(buf, "%d\n", powered); | ||
} | ||
static DEVICE_ATTR_RO(powered); | ||
|
||
/* attribute and group sysfs tables. */ | ||
static struct attribute *coresight_cti_attrs[] = { | ||
&dev_attr_enable.attr, | ||
&dev_attr_powered.attr, | ||
NULL, | ||
}; | ||
|
||
static const struct attribute_group coresight_cti_group = { | ||
.attrs = coresight_cti_attrs, | ||
}; | ||
|
||
const struct attribute_group *coresight_cti_groups[] = { | ||
&coresight_cti_group, | ||
NULL, | ||
}; |
Oops, something went wrong.