linux-remoteproc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: peng.fan@oss.nxp.com
Cc: ohad@wizery.com, bjorn.andersson@linaro.org,
	o.rempel@pengutronix.de, robh+dt@kernel.org,
	devicetree@vger.kernel.org, shawnguo@kernel.org,
	s.hauer@pengutronix.de, kernel@pengutronix.de,
	festevam@gmail.com, linux-remoteproc@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com>
Subject: Re: [PATCH V4 5/8] remoteproc: imx_rproc: initial support for mutilple start/stop method
Date: Fri, 16 Apr 2021 11:44:20 -0600	[thread overview]
Message-ID: <20210416174420.GB1050209@xps15> (raw)
In-Reply-To: <1618493261-32606-6-git-send-email-peng.fan@oss.nxp.com>

On Thu, Apr 15, 2021 at 09:27:38PM +0800, peng.fan@oss.nxp.com wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> Add three methods IMX_RPROC_NONE(no need start/stop), IMX_RPROC_MMIO
> (start/stop through mmio) and IMX_RPROC_SMC(start/stop through ARM SMCCC).
> 
> The current SoCs supported are all using IMX_RPROC_MMIO, add a restrict
> in imx_rproc_detect_mode that only SoCs using IMX_RPROC_MMIO needs syscon
> regmap to access registers.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/remoteproc/imx_rproc.c | 51 +++++++++++++++++++++++++++++-------------
>  1 file changed, 35 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
> index 06dac92..2b633fd 100644
> --- a/drivers/remoteproc/imx_rproc.c
> +++ b/drivers/remoteproc/imx_rproc.c
> @@ -74,6 +74,15 @@ struct imx_rproc_att {
>  	int flags;
>  };
>  
> +/* Remote core start/stop method */
> +enum imx_rproc_method {
> +	IMX_RPROC_NONE,
> +	/* Through syscon regmap */
> +	IMX_RPROC_MMIO,
> +	/* Through ARM SMCCC */
> +	IMX_RPROC_SMC,
> +};
> +
>  struct imx_rproc_dcfg {
>  	u32				src_reg;
>  	u32				src_mask;
> @@ -81,6 +90,7 @@ struct imx_rproc_dcfg {
>  	u32				src_stop;
>  	const struct imx_rproc_att	*att;
>  	size_t				att_size;
> +	enum imx_rproc_method		method;
>  };
>  
>  struct imx_rproc {
> @@ -183,6 +193,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mq = {
>  	.src_stop	= IMX7D_M4_STOP,
>  	.att		= imx_rproc_att_imx8mq,
>  	.att_size	= ARRAY_SIZE(imx_rproc_att_imx8mq),
> +	.method		= IMX_RPROC_MMIO,
>  };
>  
>  static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = {
> @@ -192,6 +203,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = {
>  	.src_stop	= IMX7D_M4_STOP,
>  	.att		= imx_rproc_att_imx7d,
>  	.att_size	= ARRAY_SIZE(imx_rproc_att_imx7d),
> +	.method		= IMX_RPROC_MMIO,
>  };
>  
>  static const struct imx_rproc_dcfg imx_rproc_cfg_imx6sx = {
> @@ -201,6 +213,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx6sx = {
>  	.src_stop	= IMX6SX_M4_STOP,
>  	.att		= imx_rproc_att_imx6sx,
>  	.att_size	= ARRAY_SIZE(imx_rproc_att_imx6sx),
> +	.method		= IMX_RPROC_MMIO,
>  };
>  
>  static int imx_rproc_start(struct rproc *rproc)
> @@ -560,19 +573,35 @@ static void imx_rproc_free_mbox(struct rproc *rproc)
>  
>  static int imx_rproc_detect_mode(struct imx_rproc *priv)
>  {
> +	struct regmap_config config = { .name = "imx-rproc" };
>  	const struct imx_rproc_dcfg *dcfg = priv->dcfg;
>  	struct device *dev = priv->dev;
> +	struct regmap *regmap;
>  	int ret;
>  	u32 val;
>  
> -	ret = regmap_read(priv->regmap, dcfg->src_reg, &val);
> -	if (ret) {
> -		dev_err(dev, "Failed to read src\n");
> -		return ret;
> +	if (dcfg->method != IMX_RPROC_MMIO)
> +		return 0;
> +
> +	regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "syscon");
> +	if (IS_ERR(regmap)) {
> +		dev_err(dev, "failed to find syscon\n");
> +		return PTR_ERR(regmap);
>  	}
>  
> -	if (!(val & dcfg->src_stop))
> -		priv->rproc->state = RPROC_DETACHED;
> +	priv->regmap = regmap;
> +	regmap_attach_dev(dev, regmap, &config);
> +
> +	if (regmap) {

This if() statement is not needed.  Moreover all the modifications in this
function should go under a IMX_RPROC_MMIO case statement in patch 7.

> +		ret = regmap_read(regmap, dcfg->src_reg, &val);
> +		if (ret) {
> +			dev_err(dev, "Failed to read src\n");
> +			return ret;
> +		}
> +
> +		if (!(val & dcfg->src_stop))
> +			priv->rproc->state = RPROC_DETACHED;
> +	}
>  
>  	return 0;
>  }
> @@ -583,18 +612,9 @@ static int imx_rproc_probe(struct platform_device *pdev)
>  	struct device_node *np = dev->of_node;
>  	struct imx_rproc *priv;
>  	struct rproc *rproc;
> -	struct regmap_config config = { .name = "imx-rproc" };
>  	const struct imx_rproc_dcfg *dcfg;
> -	struct regmap *regmap;
>  	int ret;
>  
> -	regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
> -	if (IS_ERR(regmap)) {
> -		dev_err(dev, "failed to find syscon\n");
> -		return PTR_ERR(regmap);
> -	}
> -	regmap_attach_dev(dev, regmap, &config);
> -
>  	/* set some other name then imx */
>  	rproc = rproc_alloc(dev, "imx-rproc", &imx_rproc_ops,
>  			    NULL, sizeof(*priv));
> @@ -609,7 +629,6 @@ static int imx_rproc_probe(struct platform_device *pdev)
>  
>  	priv = rproc->priv;
>  	priv->rproc = rproc;
> -	priv->regmap = regmap;
>  	priv->dcfg = dcfg;
>  	priv->dev = dev;
>  
> -- 
> 2.7.4
> 

  reply	other threads:[~2021-04-16 17:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-15 13:27 [PATCH V4 0/8] remoteproc: imx_rproc: support i.MX7ULP/8MN/8MP peng.fan
2021-04-15 13:27 ` [PATCH V4 1/8] dt-bindings: remoteproc: imx_rproc: add fsl,auto-boot property peng.fan
2021-04-15 13:27 ` [PATCH V4 2/8] dt-bindings: remoteproc: imx_rproc: add i.MX7ULP support peng.fan
2021-04-15 13:27 ` [PATCH V4 3/8] dt-bindings: remoteproc: imx_rproc: support i.MX8MN/P peng.fan
2021-04-15 13:27 ` [PATCH V4 4/8] remoteproc: imx_rproc: parse fsl,auto-boot peng.fan
2021-04-16 17:41   ` Mathieu Poirier
2021-04-15 13:27 ` [PATCH V4 5/8] remoteproc: imx_rproc: initial support for mutilple start/stop method peng.fan
2021-04-16 17:44   ` Mathieu Poirier [this message]
2021-04-15 13:27 ` [PATCH V4 6/8] remoteproc: imx_rproc: make clk optional peng.fan
2021-04-16 17:46   ` Mathieu Poirier
2021-04-15 13:27 ` [PATCH V4 7/8] remoteproc: imx_rproc: support i.MX7ULP peng.fan
2021-04-16 17:47   ` Mathieu Poirier
2021-04-15 13:27 ` [PATCH V4 8/8] remoteproc: imx_rproc: support i.MX8MN/P peng.fan
2021-04-16 17:58 ` [PATCH V4 0/8] remoteproc: imx_rproc: support i.MX7ULP/8MN/8MP Mathieu Poirier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210416174420.GB1050209@xps15 \
    --to=mathieu.poirier@linaro.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=ohad@wizery.com \
    --cc=peng.fan@nxp.com \
    --cc=peng.fan@oss.nxp.com \
    --cc=robh+dt@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).