On Tue, 15 Jan 2019 at 18:57, Mathieu Poirier mathieu.poirier@linaro.org wrote:
On Wed, Jan 09, 2019 at 10:54:37PM +0000, Mike Leach wrote:
Adds in functions to allow CTI devices to extract standard Coresight information from device trees.
Adds in function to allow location of a registered Coresight device given the device tree node data.
Signed-off-by: Mike Leach mike.leach@linaro.org
drivers/hwtracing/coresight/of_coresight.c | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+)
diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c index 89092f83567e..1d6adfc0057c 100644 --- a/drivers/hwtracing/coresight/of_coresight.c +++ b/drivers/hwtracing/coresight/of_coresight.c @@ -295,3 +295,68 @@ of_get_coresight_platform_data(struct device *dev, return pdata; } EXPORT_SYMBOL_GPL(of_get_coresight_platform_data);
+struct coresight_platform_data * +of_get_coresight_ect_platform_data(struct device *dev,
const struct device_node *node)
+{
struct coresight_platform_data *pdata;
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return ERR_PTR(-ENOMEM);
/* Use device name as sysfs handle */
pdata->name = dev_name(dev);
The above is already done in of_get_coresight_platform_data() and as such I wonder why it needs to be replicated here.
The other function goes on to look for in-ports and out-ports - which throws a warning if they are not there. CTI not using these as it is possible to be connected to no-CS devices or simply external IO pins. (there's a fuller explanation of this in my response to suzuki).
return pdata;
+} +EXPORT_SYMBOL_GPL(of_get_coresight_ect_platform_data);
+int of_coresight_ect_get_cpu(const struct device_node *node) +{
int cpu;
struct device_node *dn;
dn = of_parse_phandle(node, "cpu", 0);
/* CTI Affinity defaults to no cpu */
if (!dn)
return -1;
cpu = of_cpu_node_to_id(dn);
of_node_put(dn);
/* No Affinity if no cpu nodes are found */
return (cpu < 0) ? -1 : cpu;
+} +EXPORT_SYMBOL_GPL(of_coresight_ect_get_cpu);
+/*
- Find a registered coresight device from the device_node.
- The node info is associated with the AMBA parent, so we
- search this first to find a name, and use the name to find
- the device on the coresight bus as they are always named the same.
- */
+struct coresight_device * +of_coresight_get_cs_device_by_node(struct device_node *node) +{
struct device *dev, *adev;
struct coresight_device *csdev = NULL;
const char *amba_dev_name = NULL;
if (!node)
return NULL;
adev = bus_find_device(&amba_bustype, NULL, node, of_dev_node_match);
if (adev) {
amba_dev_name = dev_name(adev);
dev = bus_find_device_by_name(&coresight_bustype, NULL,
amba_dev_name);
if (dev) {
csdev = to_coresight_device(dev);
put_device(dev);
}
put_device(adev);
}
return csdev;
Humm... This means the @csdev associated with @node has already been scanned and added to the coresight_bus, which may not always be true. For now I can't say more since I don't know how it will be used.
This is true - it will fail to find a cs-device if not yet registered, or if the associated device is not in fact a coresight component. As we cannot predict the order of registration, the CTI driver does this search on its own registration, with other CS devices looking for matching CTIs when they are registered - there is a complementary function provided as part of the driver - cti_add_assoc_to_csdev(), called just after the existing functions that fixup orphan connections.
Thanks
Mike.
+}
+EXPORT_SYMBOL_GPL(of_coresight_get_cs_device_by_node);
2.19.1
CoreSight mailing list CoreSight@lists.linaro.org https://lists.linaro.org/mailman/listinfo/coresight