public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>,
	Alexandre Courbot
	<gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] soc/tegra: pmc: Use register definitions instead of magic values
Date: Fri, 10 Jun 2016 16:05:56 +0200	[thread overview]
Message-ID: <20160610140556.GM27142@ulmo.ba.sec> (raw)
In-Reply-To: <575926DA.50904-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

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

On Thu, Jun 09, 2016 at 09:20:42AM +0100, Jon Hunter wrote:
> 
> On 08/06/16 18:15, Thierry Reding wrote:
> > From: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> > 
> > Use register definitions for the main SoC reset operation instead of
> > hard-coding magic values. Note that the PMC_RST_STATUS register isn't
> > actually accessed, but since it is mentioned in a comment the
> > definitions are added for completeness.
> > 
> > Signed-off-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> > ---
> >  drivers/soc/tegra/pmc.c | 16 +++++++++++++---
> >  1 file changed, 13 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
> > index 852f8470d6e7..70acad7ceca0 100644
> > --- a/drivers/soc/tegra/pmc.c
> > +++ b/drivers/soc/tegra/pmc.c
> > @@ -51,6 +51,7 @@
> >  #define  PMC_CNTRL_CPU_PWRREQ_POLARITY	(1 << 15)  /* CPU pwr req polarity */
> >  #define  PMC_CNTRL_CPU_PWRREQ_OE	(1 << 16)  /* CPU pwr req enable */
> >  #define  PMC_CNTRL_INTR_POLARITY	(1 << 17)  /* inverts INTR polarity */
> > +#define  PMC_CNTRL_MAIN_RST		(1 <<  4)
> >  
> >  #define DPD_SAMPLE			0x020
> >  #define  DPD_SAMPLE_ENABLE		(1 << 0)
> > @@ -80,6 +81,14 @@
> >  #define PMC_SENSOR_CTRL_SCRATCH_WRITE	(1 << 2)
> >  #define PMC_SENSOR_CTRL_ENABLE_RST	(1 << 1)
> >  
> > +#define PMC_RST_STATUS			0x1b4
> > +#define  PMC_RST_STATUS_AOTAG		(1 << 5)
> > +#define  PMC_RST_STATUS_LP0		(1 << 4)
> > +#define  PMC_RST_STATUS_SW_MAIN		(1 << 3)
> > +#define  PMC_RST_STATUS_SENSOR		(1 << 2)
> > +#define  PMC_RST_STATUS_WATCHDOG	(1 << 1)
> > +#define  PMC_RST_STATUS_POR		(1 << 0)
> 
> Looking at the TRM, the PMC_RST_STATUS register only has one field
> called "RST_SOURCE" and the above are possible values for this field.
> However, these are integer values and not actual bits (as it is a 3-bit
> field). I believe that they should just be ...
> 
> #define PMC_RST_STATUS			0x1b4
> #define  PMC_RST_STATUS_AOTAG		5
> #define  PMC_RST_STATUS_LP0		4
> #define  PMC_RST_STATUS_SW_MAIN		3
> #define  PMC_RST_STATUS_SENSOR		2
> #define  PMC_RST_STATUS_WATCHDOG	1
> #define  PMC_RST_STATUS_POR		0

Ugh... indeed. No idea how I came up with this.

> >  #define IO_DPD_REQ			0x1b8
> >  #define  IO_DPD_REQ_CODE_IDLE		(0 << 30)
> >  #define  IO_DPD_REQ_CODE_OFF		(1 << 30)
> > @@ -638,9 +647,10 @@ static int tegra_pmc_restart_notify(struct notifier_block *this,
> >  
> >  	tegra_pmc_writel(value, PMC_SCRATCH0);
> >  
> > -	value = tegra_pmc_readl(0);
> > -	value |= 0x10;
> > -	tegra_pmc_writel(value, 0);
> > +	/* reset everything but PMC_SCRATCH0 and PMC_RST_STATUS */
> 
> Not sure I understand the comment about PMC_RST_STATUS because this is
> just a status register and it will log source of the reset. The TRM does
> show that it is a R/W register. Are you just saying that source of the
> reset will be preserved by the PMC_RST_STATUS register?

Yes, PMC_SCRATCH0 and PMC_RST_STATUS are the only two registers that are
preserved over the reset, whereas all other registers will be reset.

Thierry

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

      parent reply	other threads:[~2016-06-10 14:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-08 17:15 [PATCH] soc/tegra: pmc: Use register definitions instead of magic values Thierry Reding
     [not found] ` <20160608171530.19396-1-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-06-09  8:20   ` Jon Hunter
     [not found]     ` <575926DA.50904-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-06-10 14:05       ` Thierry Reding [this message]

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=20160610140556.GM27142@ulmo.ba.sec \
    --to=thierry.reding-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.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