Commit eb6934b5 authored by Suzuki K Poulose's avatar Suzuki K Poulose Committed by Greg Kroah-Hartman

coresight: replicator: Prepare for merging with dynamic-replicator

As a preparatory step to merge the separate drivers for static and
dynamic replicators, annotate the static replicator specific details.
Also refactor the probe routine to make it generic in order to merge
the drivers easily.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ee8146aa
...@@ -56,58 +56,68 @@ static const struct coresight_ops replicator_cs_ops = { ...@@ -56,58 +56,68 @@ static const struct coresight_ops replicator_cs_ops = {
.link_ops = &replicator_link_ops, .link_ops = &replicator_link_ops,
}; };
static int replicator_probe(struct platform_device *pdev) static int replicator_probe(struct device *dev)
{ {
int ret; int ret = 0;
struct device *dev = &pdev->dev;
struct coresight_platform_data *pdata = NULL; struct coresight_platform_data *pdata = NULL;
struct replicator_drvdata *drvdata; struct replicator_drvdata *drvdata;
struct coresight_desc desc = { 0 }; struct coresight_desc desc = { 0 };
struct device_node *np = pdev->dev.of_node; struct device_node *np = dev->of_node;
if (np) { if (np) {
pdata = of_get_coresight_platform_data(dev, np); pdata = of_get_coresight_platform_data(dev, np);
if (IS_ERR(pdata)) if (IS_ERR(pdata))
return PTR_ERR(pdata); return PTR_ERR(pdata);
pdev->dev.platform_data = pdata; dev->platform_data = pdata;
} }
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->dev = &pdev->dev; drvdata->dev = dev;
drvdata->atclk = devm_clk_get(&pdev->dev, "atclk"); /* optional */ drvdata->atclk = devm_clk_get(dev, "atclk"); /* optional */
if (!IS_ERR(drvdata->atclk)) { if (!IS_ERR(drvdata->atclk)) {
ret = clk_prepare_enable(drvdata->atclk); ret = clk_prepare_enable(drvdata->atclk);
if (ret) if (ret)
return ret; return ret;
} }
pm_runtime_get_noresume(&pdev->dev);
pm_runtime_set_active(&pdev->dev); dev_set_drvdata(dev, drvdata);
pm_runtime_enable(&pdev->dev);
platform_set_drvdata(pdev, drvdata);
desc.type = CORESIGHT_DEV_TYPE_LINK; desc.type = CORESIGHT_DEV_TYPE_LINK;
desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_SPLIT; desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_SPLIT;
desc.ops = &replicator_cs_ops; desc.ops = &replicator_cs_ops;
desc.pdata = pdev->dev.platform_data; desc.pdata = dev->platform_data;
desc.dev = &pdev->dev; desc.dev = dev;
drvdata->csdev = coresight_register(&desc); drvdata->csdev = coresight_register(&desc);
if (IS_ERR(drvdata->csdev)) { if (IS_ERR(drvdata->csdev)) {
ret = PTR_ERR(drvdata->csdev); ret = PTR_ERR(drvdata->csdev);
goto out_disable_pm; goto out_disable_clk;
} }
pm_runtime_put(&pdev->dev); pm_runtime_put(dev);
return 0; out_disable_clk:
if (ret && !IS_ERR_OR_NULL(drvdata->atclk))
out_disable_pm:
if (!IS_ERR(drvdata->atclk))
clk_disable_unprepare(drvdata->atclk); clk_disable_unprepare(drvdata->atclk);
pm_runtime_put_noidle(&pdev->dev); return ret;
pm_runtime_disable(&pdev->dev); }
static int static_replicator_probe(struct platform_device *pdev)
{
int ret;
pm_runtime_get_noresume(&pdev->dev);
pm_runtime_set_active(&pdev->dev);
pm_runtime_enable(&pdev->dev);
ret = replicator_probe(&pdev->dev);
if (ret) {
pm_runtime_put_noidle(&pdev->dev);
pm_runtime_disable(&pdev->dev);
}
return ret; return ret;
} }
...@@ -139,18 +149,18 @@ static const struct dev_pm_ops replicator_dev_pm_ops = { ...@@ -139,18 +149,18 @@ static const struct dev_pm_ops replicator_dev_pm_ops = {
replicator_runtime_resume, NULL) replicator_runtime_resume, NULL)
}; };
static const struct of_device_id replicator_match[] = { static const struct of_device_id static_replicator_match[] = {
{.compatible = "arm,coresight-replicator"}, {.compatible = "arm,coresight-replicator"},
{} {}
}; };
static struct platform_driver replicator_driver = { static struct platform_driver static_replicator_driver = {
.probe = replicator_probe, .probe = static_replicator_probe,
.driver = { .driver = {
.name = "coresight-replicator", .name = "coresight-replicator",
.of_match_table = replicator_match, .of_match_table = static_replicator_match,
.pm = &replicator_dev_pm_ops, .pm = &replicator_dev_pm_ops,
.suppress_bind_attrs = true, .suppress_bind_attrs = true,
}, },
}; };
builtin_platform_driver(replicator_driver); builtin_platform_driver(static_replicator_driver);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment