Commit 57df7e37 authored by Tony Lindgren's avatar Tony Lindgren

remoteproc/wkup_m3: Use reset control driver if available

In order to move wkup_m3 to probe without platform data, let's add
support for using optional reset control driver if configured in the
dts. With this change and the related dts change, we can start
dropping the platform data for am335x.

And once wkup_m3 no longer needs platform data, we can simply drop the
related legacy reset platform data callbacks from wkup_m3 driver later
on after also am437x no longer depends on it.

Cc: linux-remoteproc@vger.kernel.org
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Dave Gerlach <d-gerlach@ti.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Suman Anna <s-anna@ti.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 74033131
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/remoteproc.h> #include <linux/remoteproc.h>
#include <linux/reset.h>
#include <linux/platform_data/wkup_m3.h> #include <linux/platform_data/wkup_m3.h>
...@@ -43,11 +44,13 @@ struct wkup_m3_mem { ...@@ -43,11 +44,13 @@ struct wkup_m3_mem {
* @rproc: rproc handle * @rproc: rproc handle
* @pdev: pointer to platform device * @pdev: pointer to platform device
* @mem: WkupM3 memory information * @mem: WkupM3 memory information
* @rsts: reset control
*/ */
struct wkup_m3_rproc { struct wkup_m3_rproc {
struct rproc *rproc; struct rproc *rproc;
struct platform_device *pdev; struct platform_device *pdev;
struct wkup_m3_mem mem[WKUPM3_MEM_MAX]; struct wkup_m3_mem mem[WKUPM3_MEM_MAX];
struct reset_control *rsts;
}; };
static int wkup_m3_rproc_start(struct rproc *rproc) static int wkup_m3_rproc_start(struct rproc *rproc)
...@@ -56,13 +59,16 @@ static int wkup_m3_rproc_start(struct rproc *rproc) ...@@ -56,13 +59,16 @@ static int wkup_m3_rproc_start(struct rproc *rproc)
struct platform_device *pdev = wkupm3->pdev; struct platform_device *pdev = wkupm3->pdev;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct wkup_m3_platform_data *pdata = dev_get_platdata(dev); struct wkup_m3_platform_data *pdata = dev_get_platdata(dev);
int error = 0;
if (pdata->deassert_reset(pdev, pdata->reset_name)) { error = reset_control_deassert(wkupm3->rsts);
if (!wkupm3->rsts && pdata->deassert_reset(pdev, pdata->reset_name)) {
dev_err(dev, "Unable to reset wkup_m3!\n"); dev_err(dev, "Unable to reset wkup_m3!\n");
return -ENODEV; error = -ENODEV;
} }
return 0; return error;
} }
static int wkup_m3_rproc_stop(struct rproc *rproc) static int wkup_m3_rproc_stop(struct rproc *rproc)
...@@ -71,13 +77,16 @@ static int wkup_m3_rproc_stop(struct rproc *rproc) ...@@ -71,13 +77,16 @@ static int wkup_m3_rproc_stop(struct rproc *rproc)
struct platform_device *pdev = wkupm3->pdev; struct platform_device *pdev = wkupm3->pdev;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct wkup_m3_platform_data *pdata = dev_get_platdata(dev); struct wkup_m3_platform_data *pdata = dev_get_platdata(dev);
int error = 0;
if (pdata->assert_reset(pdev, pdata->reset_name)) { error = reset_control_assert(wkupm3->rsts);
if (!wkupm3->rsts && pdata->assert_reset(pdev, pdata->reset_name)) {
dev_err(dev, "Unable to assert reset of wkup_m3!\n"); dev_err(dev, "Unable to assert reset of wkup_m3!\n");
return -ENODEV; error = -ENODEV;
} }
return 0; return error;
} }
static void *wkup_m3_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len) static void *wkup_m3_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len)
...@@ -132,12 +141,6 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev) ...@@ -132,12 +141,6 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
int ret; int ret;
int i; int i;
if (!(pdata && pdata->deassert_reset && pdata->assert_reset &&
pdata->reset_name)) {
dev_err(dev, "Platform data missing!\n");
return -ENODEV;
}
ret = of_property_read_string(dev->of_node, "ti,pm-firmware", ret = of_property_read_string(dev->of_node, "ti,pm-firmware",
&fw_name); &fw_name);
if (ret) { if (ret) {
...@@ -165,6 +168,18 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev) ...@@ -165,6 +168,18 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
wkupm3->rproc = rproc; wkupm3->rproc = rproc;
wkupm3->pdev = pdev; wkupm3->pdev = pdev;
wkupm3->rsts = devm_reset_control_get_optional_shared(dev, "rstctrl");
if (IS_ERR(wkupm3->rsts))
return PTR_ERR(wkupm3->rsts);
if (!wkupm3->rsts) {
if (!(pdata && pdata->deassert_reset && pdata->assert_reset &&
pdata->reset_name)) {
dev_err(dev, "Platform data missing!\n");
ret = -ENODEV;
goto err_put_rproc;
}
}
for (i = 0; i < ARRAY_SIZE(mem_names); i++) { for (i = 0; i < ARRAY_SIZE(mem_names); i++) {
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
mem_names[i]); mem_names[i]);
...@@ -173,7 +188,7 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev) ...@@ -173,7 +188,7 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "devm_ioremap_resource failed for resource %d\n", dev_err(&pdev->dev, "devm_ioremap_resource failed for resource %d\n",
i); i);
ret = PTR_ERR(wkupm3->mem[i].cpu_addr); ret = PTR_ERR(wkupm3->mem[i].cpu_addr);
goto err; goto err_put_rproc;
} }
wkupm3->mem[i].bus_addr = res->start; wkupm3->mem[i].bus_addr = res->start;
wkupm3->mem[i].size = resource_size(res); wkupm3->mem[i].size = resource_size(res);
......
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