linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Jon Hunter <jonathanh@nvidia.com>
Cc: Stephen Warren <swarren@wwwdotorg.org>,
	Alexandre Courbot <gnurou@gmail.com>,
	linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/6] soc/tegra: pmc: Fix early initialisation of PMC
Date: Thu, 30 Jun 2016 12:03:06 +0200	[thread overview]
Message-ID: <20160630100306.GE1776@ulmo.ba.sec> (raw)
In-Reply-To: <5773F485.8090504@nvidia.com>

[-- Attachment #1: Type: text/plain, Size: 3287 bytes --]

On Wed, Jun 29, 2016 at 05:17:09PM +0100, Jon Hunter wrote:
> 
> On 28/06/16 11:38, Jon Hunter wrote:
> > During early initialisation, the available power partitions for a given
> > device is configured as well as the polarity of the PMC interrupt. Both
> > of which should only be configured if there is a valid device node for
> > the PMC device. This is because the soc data used for configuring the
> > power partitions is only available if a device node for the PMC is found
> > and the code to configure the interrupt polarity uses the device node
> > pointer directly.
> > 
> > Some early device-tree images may not have this device node and so fix
> > this by ensuring the device node pointer is valid when configuring these
> > items.
> > 
> > Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
> > ---
> >  drivers/soc/tegra/pmc.c | 34 ++++++++++++++++++----------------
> >  1 file changed, 18 insertions(+), 16 deletions(-)
> > 
> > diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
> > index 52a9e9703668..2e031c4ad547 100644
> > --- a/drivers/soc/tegra/pmc.c
> > +++ b/drivers/soc/tegra/pmc.c
> > @@ -1550,27 +1550,29 @@ static int __init tegra_pmc_early_init(void)
> >  		return -ENXIO;
> >  	}
> >  
> > -	/* Create a bit-map of the available and valid partitions */
> > -	for (i = 0; i < pmc->soc->num_powergates; i++)
> > -		if (pmc->soc->powergates[i])
> > -			set_bit(i, pmc->powergates_available);
> > -
> >  	mutex_init(&pmc->powergates_lock);
> >  
> > -	/*
> > -	 * Invert the interrupt polarity if a PMC device tree node exists and
> > -	 * contains the nvidia,invert-interrupt property.
> > -	 */
> > -	invert = of_property_read_bool(np, "nvidia,invert-interrupt");
> > +	if (np) {
> > +		/* Create a bit-map of the available and valid partitions */
> > +		for (i = 0; i < pmc->soc->num_powergates; i++)
> > +			if (pmc->soc->powergates[i])
> > +				set_bit(i, pmc->powergates_available);
> >  
> > -	value = tegra_pmc_readl(PMC_CNTRL);
> > +		/*
> > +		 * Invert the interrupt polarity if a PMC device tree node
> > +		 * exists and contains the nvidia,invert-interrupt property.
> > +		 */
> > +		invert = of_property_read_bool(np, "nvidia,invert-interrupt");
> >  
> > -	if (invert)
> > -		value |= PMC_CNTRL_INTR_POLARITY;
> > -	else
> > -		value &= ~PMC_CNTRL_INTR_POLARITY;
> > +		value = tegra_pmc_readl(PMC_CNTRL);
> >  
> > -	tegra_pmc_writel(value, PMC_CNTRL);
> > +		if (invert)
> > +			value |= PMC_CNTRL_INTR_POLARITY;
> > +		else
> > +			value &= ~PMC_CNTRL_INTR_POLARITY;
> > +
> > +		tegra_pmc_writel(value, PMC_CNTRL);
> > +	}
> >  
> >  	return 0;
> >  }
> 
> By the way, the more I think about this, if there is no valid 'pmc'
> node in the device-tree blob, then I wonder if we should even bother
> mapping the pmc address space at all? The reason being, if there is
> no 'pmc' node then we cannot look-up the SoC data and so all the
> public PMC APIs are pretty useless AFAICT. I wonder if we should do
> something like ...

I think it's fine as-is. The PMC driver does more than just powergates
and it'd be useful to have the rest continue to work even on old DTBs.
Everything should already be properly guarded against this exception.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2016-06-30 10:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-28 10:38 [PATCH 0/6] soc/tegra: Various PMC fixes Jon Hunter
2016-06-28 10:38 ` [PATCH 1/6] soc/tegra: pmc: Ensure powergate is available when powering on Jon Hunter
2016-06-28 10:38 ` [PATCH 2/6] soc/tegra: pmc: Fix early initialisation of PMC Jon Hunter
2016-06-29 16:17   ` Jon Hunter
2016-06-30 10:03     ` Thierry Reding [this message]
2016-06-28 10:38 ` [PATCH 3/6] soc/tegra: pmc: Don't populate soc data until register space is mapped Jon Hunter
2016-06-28 10:38 ` [PATCH 4/6] soc/tegra: pmc: Ensure mutex is always initialised Jon Hunter
2016-06-28 10:38 ` [PATCH 5/6] soc/tegra: pmc: Add missing of_node_put Jon Hunter
2016-06-28 10:46   ` Jon Hunter
2016-06-28 10:38 ` [PATCH 6/6] soc/tegra: pmc: Don't probe pmc if early initialisation fails Jon Hunter
2016-06-28 10:40 ` [PATCH 0/6] soc/tegra: Various PMC fixes Jon Hunter
2016-06-30 10:04 ` Thierry Reding

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=20160630100306.GE1776@ulmo.ba.sec \
    --to=thierry.reding@gmail.com \
    --cc=gnurou@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=swarren@wwwdotorg.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).