[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231228093321.5522-1-quic_jinlmao@quicinc.com>
Date: Thu, 28 Dec 2023 01:33:19 -0800
From: Mao Jinlong <quic_jinlmao@...cinc.com>
To: Suzuki K Poulose <suzuki.poulose@....com>,
Mike Leach
<mike.leach@...aro.org>, James Clark <james.clark@....com>,
Leo Yan
<leo.yan@...aro.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>
CC: Mao Jinlong <quic_jinlmao@...cinc.com>, <coresight@...ts.linaro.org>,
<linux-arm-kernel@...ts.infradead.org>, <linux-kernel@...r.kernel.org>,
<linux-arm-msm@...r.kernel.org>,
Tingwei Zhang <quic_tingweiz@...cinc.com>,
Yuanfang Zhang <quic_yuanfang@...cinc.com>,
Tao Zhang
<quic_taozha@...cinc.com>
Subject: [PATCH] coresight: Add coresight name support
Add coresight name support for custom names which will be
easy to identify the device by the name.
Signed-off-by: Mao Jinlong <quic_jinlmao@...cinc.com>
---
.../hwtracing/coresight/coresight-cti-core.c | 20 ++++++++------
drivers/hwtracing/coresight/coresight-dummy.c | 10 ++++---
.../hwtracing/coresight/coresight-platform.c | 27 +++++++++++++++++++
drivers/hwtracing/coresight/coresight-tpdm.c | 10 ++++---
include/linux/coresight.h | 1 +
5 files changed, 53 insertions(+), 15 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-cti-core.c b/drivers/hwtracing/coresight/coresight-cti-core.c
index 3999d0a2cb60..60a1e76064a9 100644
--- a/drivers/hwtracing/coresight/coresight-cti-core.c
+++ b/drivers/hwtracing/coresight/coresight-cti-core.c
@@ -902,14 +902,18 @@ static int cti_probe(struct amba_device *adev, const struct amba_id *id)
/* default to powered - could change on PM notifications */
drvdata->config.hw_powered = true;
- /* set up device name - will depend if cpu bound or otherwise */
- if (drvdata->ctidev.cpu >= 0)
- cti_desc.name = devm_kasprintf(dev, GFP_KERNEL, "cti_cpu%d",
- drvdata->ctidev.cpu);
- else
- cti_desc.name = coresight_alloc_device_name(&cti_sys_devs, dev);
- if (!cti_desc.name)
- return -ENOMEM;
+ cti_desc.name = coresight_get_device_name(dev);
+ if (!cti_desc.name) {
+ /* set up device name - will depend if cpu bound or otherwise */
+ if (drvdata->ctidev.cpu >= 0)
+ cti_desc.name = devm_kasprintf(dev, GFP_KERNEL, "cti_cpu%d",
+ drvdata->ctidev.cpu);
+ else {
+ cti_desc.name = coresight_alloc_device_name(&cti_sys_devs, dev);
+ if (!cti_desc.name)
+ return -ENOMEM;
+ }
+ }
/* setup CPU power management handling for CPU bound CTI devices. */
ret = cti_pm_setup(drvdata);
diff --git a/drivers/hwtracing/coresight/coresight-dummy.c b/drivers/hwtracing/coresight/coresight-dummy.c
index e4deafae7bc2..b19cd400df79 100644
--- a/drivers/hwtracing/coresight/coresight-dummy.c
+++ b/drivers/hwtracing/coresight/coresight-dummy.c
@@ -76,10 +76,12 @@ static int dummy_probe(struct platform_device *pdev)
struct coresight_desc desc = { 0 };
if (of_device_is_compatible(node, "arm,coresight-dummy-source")) {
-
- desc.name = coresight_alloc_device_name(&source_devs, dev);
- if (!desc.name)
- return -ENOMEM;
+ desc.name = coresight_get_device_name(dev);
+ if (!desc.name) {
+ desc.name = coresight_alloc_device_name(&source_devs, dev);
+ if (!desc.name)
+ return -ENOMEM;
+ }
desc.type = CORESIGHT_DEV_TYPE_SOURCE;
desc.subtype.source_subtype =
diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c
index 9d550f5697fa..284aa22a06b7 100644
--- a/drivers/hwtracing/coresight/coresight-platform.c
+++ b/drivers/hwtracing/coresight/coresight-platform.c
@@ -183,6 +183,18 @@ static int of_coresight_get_cpu(struct device *dev)
return cpu;
}
+static const char *of_coresight_get_device_name(struct device *dev)
+{
+ const char *name = NULL;
+
+ if (!dev->of_node)
+ return NULL;
+
+ of_property_read_string(dev->of_node, "coresight-name", &name);
+
+ return name;
+}
+
/*
* of_coresight_parse_endpoint : Parse the given output endpoint @ep
* and fill the connection information in @pdata->out_conns
@@ -315,6 +327,12 @@ static inline int of_coresight_get_cpu(struct device *dev)
{
return -ENODEV;
}
+
+static inline const char *of_coresight_get_device_name(struct device *dev)
+{
+ return NULL;
+}
+
#endif
#ifdef CONFIG_ACPI
@@ -794,6 +812,15 @@ int coresight_get_cpu(struct device *dev)
}
EXPORT_SYMBOL_GPL(coresight_get_cpu);
+const char *coresight_get_device_name(struct device *dev)
+{
+ if (is_of_node(dev->fwnode))
+ return of_coresight_get_device_name(dev);
+ else
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(coresight_get_device_name);
+
struct coresight_platform_data *
coresight_get_platform_data(struct device *dev)
{
diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtracing/coresight/coresight-tpdm.c
index f4854af0431e..7735ff18c48e 100644
--- a/drivers/hwtracing/coresight/coresight-tpdm.c
+++ b/drivers/hwtracing/coresight/coresight-tpdm.c
@@ -201,9 +201,13 @@ static int tpdm_probe(struct amba_device *adev, const struct amba_id *id)
drvdata->base = base;
/* Set up coresight component description */
- desc.name = coresight_alloc_device_name(&tpdm_devs, dev);
- if (!desc.name)
- return -ENOMEM;
+ desc.name = coresight_get_device_name(dev);
+ if (!desc.name) {
+ desc.name = coresight_alloc_device_name(&tpdm_devs, dev);
+ if (!desc.name)
+ return -ENOMEM;
+ }
+
desc.type = CORESIGHT_DEV_TYPE_SOURCE;
desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_OTHERS;
desc.ops = &tpdm_cs_ops;
diff --git a/include/linux/coresight.h b/include/linux/coresight.h
index a269fffaf991..caa17c8af865 100644
--- a/include/linux/coresight.h
+++ b/include/linux/coresight.h
@@ -675,6 +675,7 @@ static inline void coresight_write64(struct coresight_device *csdev, u64 val, u3
#endif /* IS_ENABLED(CONFIG_CORESIGHT) */
extern int coresight_get_cpu(struct device *dev);
+extern const char *coresight_get_device_name(struct device *dev);
struct coresight_platform_data *coresight_get_platform_data(struct device *dev);
struct coresight_connection *
--
2.41.0
Powered by blists - more mailing lists