diff mbox series

[V4,6/8] remoteproc: imx_rproc: make clk optional

Message ID 1618493261-32606-7-git-send-email-peng.fan@oss.nxp.com
State Superseded
Headers show
Series remoteproc: imx_rproc: support i.MX7ULP/8MN/8MP | expand

Commit Message

Peng Fan (OSS) April 15, 2021, 1:27 p.m. UTC
From: Peng Fan <peng.fan@nxp.com>


To i.MX7ULP, M4 is the master to control everything, no need to provide
clk from Linux side. So make clk optional when method is IMX_RPROC_NONE.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

---
 drivers/remoteproc/imx_rproc.c | 46 ++++++++++++++++++++++++++++--------------
 1 file changed, 31 insertions(+), 15 deletions(-)

-- 
2.7.4

Comments

Mathieu Poirier April 16, 2021, 5:46 p.m. UTC | #1
On Thu, Apr 15, 2021 at 09:27:39PM +0800, peng.fan@oss.nxp.com wrote:
> From: Peng Fan <peng.fan@nxp.com>

> 

> To i.MX7ULP, M4 is the master to control everything, no need to provide

> clk from Linux side. So make clk optional when method is IMX_RPROC_NONE.

> 

> Signed-off-by: Peng Fan <peng.fan@nxp.com>

> ---

>  drivers/remoteproc/imx_rproc.c | 46 ++++++++++++++++++++++++++++--------------

>  1 file changed, 31 insertions(+), 15 deletions(-)

> 

> diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c

> index 2b633fd..56dfcc1 100644

> --- a/drivers/remoteproc/imx_rproc.c

> +++ b/drivers/remoteproc/imx_rproc.c

> @@ -606,6 +606,35 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)

>  	return 0;

>  }

>  

> +static int imx_rproc_clk_enable(struct imx_rproc *priv)

> +{

> +	const struct imx_rproc_dcfg *dcfg = priv->dcfg;

> +	struct device *dev = priv->dev;

> +	int ret;

> +

> +	/* Remote core is not under control of Linux */

> +	if (dcfg->method == IMX_RPROC_NONE)

> +		return 0;

> +

> +	priv->clk = devm_clk_get(dev, NULL);

> +	if (IS_ERR(priv->clk)) {

> +		dev_err(dev, "Failed to get clock\n");

> +		return PTR_ERR(priv->clk);

> +	}

> +

> +	/*

> +	 * clk for M4 block including memory. Should be

> +	 * enabled before .start for FW transfer.

> +	 */

> +	ret = clk_prepare_enable(priv->clk);

> +	if (ret) {

> +		dev_err(dev, "Failed to enable clock\n");

> +		return ret;

> +	}

> +

> +	return 0;

> +}

> +

>  static int imx_rproc_probe(struct platform_device *pdev)

>  {

>  	struct device *dev = &pdev->dev;

> @@ -654,22 +683,9 @@ static int imx_rproc_probe(struct platform_device *pdev)

>  	if (ret)

>  		goto err_put_mbox;

>  

> -	priv->clk = devm_clk_get(dev, NULL);

> -	if (IS_ERR(priv->clk)) {

> -		dev_err(dev, "Failed to get clock\n");

> -		ret = PTR_ERR(priv->clk);

> -		goto err_put_mbox;

> -	}

> -

> -	/*

> -	 * clk for M4 block including memory. Should be

> -	 * enabled before .start for FW transfer.

> -	 */

> -	ret = clk_prepare_enable(priv->clk);

> -	if (ret) {

> -		dev_err(&rproc->dev, "Failed to enable clock\n");

> +	ret = imx_rproc_clk_enable(priv);

> +	if (ret)


Much better

Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>


>  		goto err_put_mbox;

> -	}

>  

>  	INIT_WORK(&priv->rproc_work, imx_rproc_vq_work);

>  

> -- 

> 2.7.4

>
diff mbox series

Patch

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 2b633fd..56dfcc1 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -606,6 +606,35 @@  static int imx_rproc_detect_mode(struct imx_rproc *priv)
 	return 0;
 }
 
+static int imx_rproc_clk_enable(struct imx_rproc *priv)
+{
+	const struct imx_rproc_dcfg *dcfg = priv->dcfg;
+	struct device *dev = priv->dev;
+	int ret;
+
+	/* Remote core is not under control of Linux */
+	if (dcfg->method == IMX_RPROC_NONE)
+		return 0;
+
+	priv->clk = devm_clk_get(dev, NULL);
+	if (IS_ERR(priv->clk)) {
+		dev_err(dev, "Failed to get clock\n");
+		return PTR_ERR(priv->clk);
+	}
+
+	/*
+	 * clk for M4 block including memory. Should be
+	 * enabled before .start for FW transfer.
+	 */
+	ret = clk_prepare_enable(priv->clk);
+	if (ret) {
+		dev_err(dev, "Failed to enable clock\n");
+		return ret;
+	}
+
+	return 0;
+}
+
 static int imx_rproc_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -654,22 +683,9 @@  static int imx_rproc_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_put_mbox;
 
-	priv->clk = devm_clk_get(dev, NULL);
-	if (IS_ERR(priv->clk)) {
-		dev_err(dev, "Failed to get clock\n");
-		ret = PTR_ERR(priv->clk);
-		goto err_put_mbox;
-	}
-
-	/*
-	 * clk for M4 block including memory. Should be
-	 * enabled before .start for FW transfer.
-	 */
-	ret = clk_prepare_enable(priv->clk);
-	if (ret) {
-		dev_err(&rproc->dev, "Failed to enable clock\n");
+	ret = imx_rproc_clk_enable(priv);
+	if (ret)
 		goto err_put_mbox;
-	}
 
 	INIT_WORK(&priv->rproc_work, imx_rproc_vq_work);