linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>,
	linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/5] soc/tegra: pmc: Implement acquire/release for resets
Date: Tue, 19 Mar 2019 17:45:08 +0100	[thread overview]
Message-ID: <1553013908.6482.10.camel@pengutronix.de> (raw)
In-Reply-To: <20190221152557.8534-4-thierry.reding@gmail.com>

On Thu, 2019-02-21 at 16:25 +0100, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> By implementing the acquire/release protocol, the resets can be shared
> with other drivers that also adhere to this protocol. This will be used
> for example by the SOR driver to put hardware into a known good state,
> irrespective of whether or not the power domain can be reset.
> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  drivers/soc/tegra/pmc.c | 39 +++++++++++++++++++++++++++++++++------
>  1 file changed, 33 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
> index 0df258518693..0c5f79528e5f 100644
> --- a/drivers/soc/tegra/pmc.c
> +++ b/drivers/soc/tegra/pmc.c
> @@ -656,10 +656,15 @@ static int tegra_genpd_power_on(struct generic_pm_domain *domain)
>  	int err;
>  
>  	err = tegra_powergate_power_up(pg, true);
> -	if (err)
> +	if (err) {
>  		dev_err(dev, "failed to turn on PM domain %s: %d\n",
>  			pg->genpd.name, err);
> +		goto out;
> +	}
>  
> +	reset_control_release(pg->reset);
> +
> +out:
>  	return err;
>  }
>  
> @@ -669,10 +674,18 @@ static int tegra_genpd_power_off(struct generic_pm_domain *domain)
>  	struct device *dev = pg->pmc->dev;
>  	int err;
>  
> +	err = reset_control_acquire(pg->reset);
> +	if (err < 0) {
> +		pr_err("failed to acquire resets: %d\n", err);
> +		return err;
> +	}
> +
>  	err = tegra_powergate_power_down(pg);
> -	if (err)
> +	if (err) {
>  		dev_err(dev, "failed to turn off PM domain %s: %d\n",
>  			pg->genpd.name, err);
> +		reset_control_release(pg->reset);
> +	}
>  
>  	return err;
>  }
> @@ -937,20 +950,34 @@ static int tegra_powergate_of_get_resets(struct tegra_powergate *pg,
>  	struct device *dev = pg->pmc->dev;
>  	int err;
>  
> -	pg->reset = of_reset_control_array_get_exclusive(np);
> +	pg->reset = of_reset_control_array_get_exclusive_released(np);
>  	if (IS_ERR(pg->reset)) {
>  		err = PTR_ERR(pg->reset);
>  		dev_err(dev, "failed to get device resets: %d\n", err);
>  		return err;
>  	}
>  
> -	if (off)
> +	err = reset_control_acquire(pg->reset);
> +	if (err < 0) {
> +		pr_err("failed to acquire resets: %d\n", err);
> +		goto out;
> +	}
> +
> +	if (off) {
>  		err = reset_control_assert(pg->reset);
> -	else
> +	} else {
>  		err = reset_control_deassert(pg->reset);
> +		if (err < 0)
> +			goto out;
>  
> -	if (err)
> +		reset_control_release(pg->reset);
> +	}
> +
> +out:
> +	if (err) {
> +		reset_control_release(pg->reset);
>  		reset_control_put(pg->reset);
> +	}
>  
>  	return err;
>  }

Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>

regards
Philipp

  reply	other threads:[~2019-03-19 16:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-21 15:25 [PATCH 1/5] reset: add acquired/released state for exclusive reset controls Thierry Reding
2019-02-21 15:25 ` [PATCH 2/5] reset: Add acquired flag to of_reset_control_array_get() Thierry Reding
2019-03-19 16:37   ` Philipp Zabel
2019-03-20  6:51     ` Felipe Balbi
2019-03-20 10:27       ` Philipp Zabel
2019-02-21 15:25 ` [PATCH 3/5] reset: Add acquire/release support for arrays Thierry Reding
2019-03-19 16:43   ` Philipp Zabel
2019-02-21 15:25 ` [PATCH 4/5] soc/tegra: pmc: Implement acquire/release for resets Thierry Reding
2019-03-19 16:45   ` Philipp Zabel [this message]
2019-02-21 15:25 ` [PATCH 5/5] drm/tegra: sor: Implement acquire/release for reset Thierry Reding
2019-03-19 16:45   ` Philipp Zabel
2019-02-21 15:28 ` [PATCH 1/5] reset: add acquired/released state for exclusive reset controls Thierry Reding
2019-03-18  9:12   ` Thierry Reding
2019-03-18 16:40     ` Philipp Zabel
2019-03-18 16:59       ` Thierry Reding
2019-03-19 16:37   ` Philipp Zabel

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=1553013908.6482.10.camel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=jonathanh@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    /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).