coresight: Make device to CPU mapping generic
The CoreSight components ETM and CPU-Debug are always associated with CPUs. Replace the of_coresight_get_cpu() with a platform agnostic helper, in preparation to add ACPI support. Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
f03631da4b
commit
91824db2ea
|
@ -572,14 +572,13 @@ static int debug_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
struct device *dev = &adev->dev;
|
struct device *dev = &adev->dev;
|
||||||
struct debug_drvdata *drvdata;
|
struct debug_drvdata *drvdata;
|
||||||
struct resource *res = &adev->res;
|
struct resource *res = &adev->res;
|
||||||
struct device_node *np = adev->dev.of_node;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
|
drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
|
||||||
if (!drvdata)
|
if (!drvdata)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
drvdata->cpu = np ? of_coresight_get_cpu(np) : 0;
|
drvdata->cpu = coresight_get_cpu(dev);
|
||||||
if (per_cpu(debug_drvdata, drvdata->cpu)) {
|
if (per_cpu(debug_drvdata, drvdata->cpu)) {
|
||||||
dev_err(dev, "CPU%d drvdata has already been initialized\n",
|
dev_err(dev, "CPU%d drvdata has already been initialized\n",
|
||||||
drvdata->cpu);
|
drvdata->cpu);
|
||||||
|
|
|
@ -151,12 +151,14 @@ static void of_coresight_get_ports(const struct device_node *node,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int of_coresight_get_cpu(const struct device_node *node)
|
static int of_coresight_get_cpu(struct device *dev)
|
||||||
{
|
{
|
||||||
int cpu;
|
int cpu;
|
||||||
struct device_node *dn;
|
struct device_node *dn;
|
||||||
|
|
||||||
dn = of_parse_phandle(node, "cpu", 0);
|
if (!dev->of_node)
|
||||||
|
return 0;
|
||||||
|
dn = of_parse_phandle(dev->of_node, "cpu", 0);
|
||||||
/* Affinity defaults to CPU0 */
|
/* Affinity defaults to CPU0 */
|
||||||
if (!dn)
|
if (!dn)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -166,7 +168,6 @@ int of_coresight_get_cpu(const struct device_node *node)
|
||||||
/* Affinity to CPU0 if no cpu nodes are found */
|
/* Affinity to CPU0 if no cpu nodes are found */
|
||||||
return (cpu < 0) ? 0 : cpu;
|
return (cpu < 0) ? 0 : cpu;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(of_coresight_get_cpu);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* of_coresight_parse_endpoint : Parse the given output endpoint @ep
|
* of_coresight_parse_endpoint : Parse the given output endpoint @ep
|
||||||
|
@ -240,8 +241,6 @@ static int of_get_coresight_platform_data(struct device *dev,
|
||||||
bool legacy_binding = false;
|
bool legacy_binding = false;
|
||||||
struct device_node *node = dev->of_node;
|
struct device_node *node = dev->of_node;
|
||||||
|
|
||||||
pdata->cpu = of_coresight_get_cpu(node);
|
|
||||||
|
|
||||||
/* Get the number of input and output port for this component */
|
/* Get the number of input and output port for this component */
|
||||||
of_coresight_get_ports(node, &pdata->nr_inport, &pdata->nr_outport);
|
of_coresight_get_ports(node, &pdata->nr_inport, &pdata->nr_outport);
|
||||||
|
|
||||||
|
@ -300,6 +299,14 @@ of_get_coresight_platform_data(struct device *dev,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int coresight_get_cpu(struct device *dev)
|
||||||
|
{
|
||||||
|
if (is_of_node(dev->fwnode))
|
||||||
|
return of_coresight_get_cpu(dev);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(coresight_get_cpu);
|
||||||
|
|
||||||
struct coresight_platform_data *
|
struct coresight_platform_data *
|
||||||
coresight_get_platform_data(struct device *dev)
|
coresight_get_platform_data(struct device *dev)
|
||||||
{
|
{
|
||||||
|
@ -318,6 +325,7 @@ coresight_get_platform_data(struct device *dev)
|
||||||
|
|
||||||
/* Use device name as sysfs handle */
|
/* Use device name as sysfs handle */
|
||||||
pdata->name = dev_name(dev);
|
pdata->name = dev_name(dev);
|
||||||
|
pdata->cpu = coresight_get_cpu(dev);
|
||||||
|
|
||||||
if (is_of_node(fwnode))
|
if (is_of_node(fwnode))
|
||||||
ret = of_get_coresight_platform_data(dev, pdata);
|
ret = of_get_coresight_platform_data(dev, pdata);
|
||||||
|
|
|
@ -292,12 +292,7 @@ static inline void coresight_disclaim_device_unlocked(void __iomem *base) {}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_OF
|
extern int coresight_get_cpu(struct device *dev);
|
||||||
extern int of_coresight_get_cpu(const struct device_node *node);
|
|
||||||
#else
|
|
||||||
static inline int of_coresight_get_cpu(const struct device_node *node)
|
|
||||||
{ return 0; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct coresight_platform_data *coresight_get_platform_data(struct device *dev);
|
struct coresight_platform_data *coresight_get_platform_data(struct device *dev);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue