All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
To: Joseph Lo <josephl-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: "linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
	<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>
Subject: Re: [PATCH V2 4/8] ARM: tegra: add common LP1 suspend support
Date: Tue, 06 Aug 2013 12:40:10 -0600	[thread overview]
Message-ID: <5201430A.2040408@wwwdotorg.org> (raw)
In-Reply-To: <1375782092.2261.92.camel-yx3yKKdKkHfc7b1ADBJPm0n48jw8i0AO@public.gmane.org>

On 08/06/2013 03:41 AM, Joseph Lo wrote:
> On Tue, 2013-08-06 at 01:48 +0800, Stephen Warren wrote:
>> On 08/05/2013 05:21 AM, Joseph Lo wrote:
>>> The LP1 suspending mode on Tegra means CPU rail off, devices and PLLs are
>>> clock gated and SDRAM in self-refresh mode. That means the low level LP1
>>> suspending and resuming code couldn't be run on DRAM and the CPU must
>>> switch to the always on clock domain (a.k.a. CLK_M 12MHz oscillator). And
>>> the system clock (SCLK) would be switched to CLK_S, a 32KHz oscillator.
>>> The LP1 low level handling code need to be moved to IRAM area first. And
>>> marking the LP1 mask for indicating the Tegra device is in LP1. The CPU
>>> power timer needs to be re-calculated based on 32KHz that was originally
>>> based on PCLK.
>>>
>>> When resuming from LP1, the LP1 reset handler will resume PLLs and then
>>> put DRAM to normal mode. Then jumping to the "tegra_resume" that will
>>> restore full context before back to kernel. The "tegra_resume" handler
>>> was expected to be found in PMC_SCRATCH41 register.
>>>
>>> This is common LP1 procedures for Tegra, so we do these jobs mainly in
>>> this patch:
>>> * moving LP1 low level handling code to IRAM
>>> * marking LP1 mask
>>> * copying the physical address of "tegra_resume" to PMC_SCRATCH41
>>> * re-calculate the CPU power timer based on 32KHz
>>
>>> diff --git a/arch/arm/mach-tegra/pm.c b/arch/arm/mach-tegra/pm.c

>>> @@ -174,14 +181,75 @@ enum tegra_suspend_mode tegra_pm_validate_suspend_mode(
>>>  				enum tegra_suspend_mode mode)
>>>  {
>>>  	/*
>>> -	 * The Tegra devices only support suspending to LP2 currently.
>>> +	 * The Tegra devices support suspending to LP1 or lower currently.
>>>  	 */
>>> -	if (mode > TEGRA_SUSPEND_LP2)
>>> -		return TEGRA_SUSPEND_LP2;
>>> +	if (mode > TEGRA_SUSPEND_LP1)
>>> +		return TEGRA_SUSPEND_LP1;
>>>  
>>>  	return mode;
>>>  }
>>
>> I think that change needs to happen after patch 7. At this point in the
>> series, LP1 doesn't work on any chip. After patch 7, it will work on all
>> chips.
>
> This code is safe here. Because we have some protection code.
...
> We have the function (tegra_lp1_iram_hook and tegra_sleep_core_init) to
> check if the system didn't support LP1 yet, then it will fall back to
> LP2. I verified this too.

Ah yes, that looks fine. Thanks very much for the explanation.

>> Note: You must assume that the DT changes are all checked in before any
>> of the code changes, so the code needs to work correctly even if the DT
>> contains the data that allows usage of LP1 before the driver actually
>> implements LP1.
>
> So should I still move them to the last patch?

No, I think given the check in tegra_lp1_iram_hook, everything will work
fine no matter which order the DT and code changes are applied.

WARNING: multiple messages have this Message-ID (diff)
From: swarren@wwwdotorg.org (Stephen Warren)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2 4/8] ARM: tegra: add common LP1 suspend support
Date: Tue, 06 Aug 2013 12:40:10 -0600	[thread overview]
Message-ID: <5201430A.2040408@wwwdotorg.org> (raw)
In-Reply-To: <1375782092.2261.92.camel@jlo-ubuntu-64.nvidia.com>

On 08/06/2013 03:41 AM, Joseph Lo wrote:
> On Tue, 2013-08-06 at 01:48 +0800, Stephen Warren wrote:
>> On 08/05/2013 05:21 AM, Joseph Lo wrote:
>>> The LP1 suspending mode on Tegra means CPU rail off, devices and PLLs are
>>> clock gated and SDRAM in self-refresh mode. That means the low level LP1
>>> suspending and resuming code couldn't be run on DRAM and the CPU must
>>> switch to the always on clock domain (a.k.a. CLK_M 12MHz oscillator). And
>>> the system clock (SCLK) would be switched to CLK_S, a 32KHz oscillator.
>>> The LP1 low level handling code need to be moved to IRAM area first. And
>>> marking the LP1 mask for indicating the Tegra device is in LP1. The CPU
>>> power timer needs to be re-calculated based on 32KHz that was originally
>>> based on PCLK.
>>>
>>> When resuming from LP1, the LP1 reset handler will resume PLLs and then
>>> put DRAM to normal mode. Then jumping to the "tegra_resume" that will
>>> restore full context before back to kernel. The "tegra_resume" handler
>>> was expected to be found in PMC_SCRATCH41 register.
>>>
>>> This is common LP1 procedures for Tegra, so we do these jobs mainly in
>>> this patch:
>>> * moving LP1 low level handling code to IRAM
>>> * marking LP1 mask
>>> * copying the physical address of "tegra_resume" to PMC_SCRATCH41
>>> * re-calculate the CPU power timer based on 32KHz
>>
>>> diff --git a/arch/arm/mach-tegra/pm.c b/arch/arm/mach-tegra/pm.c

>>> @@ -174,14 +181,75 @@ enum tegra_suspend_mode tegra_pm_validate_suspend_mode(
>>>  				enum tegra_suspend_mode mode)
>>>  {
>>>  	/*
>>> -	 * The Tegra devices only support suspending to LP2 currently.
>>> +	 * The Tegra devices support suspending to LP1 or lower currently.
>>>  	 */
>>> -	if (mode > TEGRA_SUSPEND_LP2)
>>> -		return TEGRA_SUSPEND_LP2;
>>> +	if (mode > TEGRA_SUSPEND_LP1)
>>> +		return TEGRA_SUSPEND_LP1;
>>>  
>>>  	return mode;
>>>  }
>>
>> I think that change needs to happen after patch 7. At this point in the
>> series, LP1 doesn't work on any chip. After patch 7, it will work on all
>> chips.
>
> This code is safe here. Because we have some protection code.
...
> We have the function (tegra_lp1_iram_hook and tegra_sleep_core_init) to
> check if the system didn't support LP1 yet, then it will fall back to
> LP2. I verified this too.

Ah yes, that looks fine. Thanks very much for the explanation.

>> Note: You must assume that the DT changes are all checked in before any
>> of the code changes, so the code needs to work correctly even if the DT
>> contains the data that allows usage of LP1 before the driver actually
>> implements LP1.
>
> So should I still move them to the last patch?

No, I think given the check in tegra_lp1_iram_hook, everything will work
fine no matter which order the DT and code changes are applied.

  parent reply	other threads:[~2013-08-06 18:40 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-05 11:20 [PATCH V2 0/8] ARM: tegra: support LP1 suspend mode Joseph Lo
2013-08-05 11:20 ` Joseph Lo
     [not found] ` <1375701664-14965-1-git-send-email-josephl-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-08-05 11:20   ` [PATCH V2 1/8] ARM: tegra: add common resume handling code for LP1 resuming Joseph Lo
2013-08-05 11:20     ` Joseph Lo
2013-08-05 11:20   ` [PATCH V2 2/8] ARM: tegra: config the polarity of the request of sys clock Joseph Lo
2013-08-05 11:20     ` Joseph Lo
2013-08-05 11:20   ` [PATCH V2 3/8] clk: tegra114: add LP1 suspend/resume support Joseph Lo
2013-08-05 11:20     ` Joseph Lo
2013-08-05 11:21   ` [PATCH V2 4/8] ARM: tegra: add common LP1 suspend support Joseph Lo
2013-08-05 11:21     ` Joseph Lo
     [not found]     ` <1375701664-14965-5-git-send-email-josephl-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-08-05 17:48       ` Stephen Warren
2013-08-05 17:48         ` Stephen Warren
     [not found]         ` <51FFE557.4000103-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-08-06  9:41           ` Joseph Lo
2013-08-06  9:41             ` Joseph Lo
     [not found]             ` <1375782092.2261.92.camel-yx3yKKdKkHfc7b1ADBJPm0n48jw8i0AO@public.gmane.org>
2013-08-06 18:40               ` Stephen Warren [this message]
2013-08-06 18:40                 ` Stephen Warren
2013-08-05 11:21   ` [PATCH V2 5/8] ARM: tegra: add LP1 suspend support for Tegra30 Joseph Lo
2013-08-05 11:21     ` Joseph Lo
     [not found]     ` <1375701664-14965-6-git-send-email-josephl-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-08-05 17:53       ` Stephen Warren
2013-08-05 17:53         ` Stephen Warren
     [not found]         ` <51FFE6A1.5090701-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-08-06  9:47           ` Joseph Lo
2013-08-06  9:47             ` Joseph Lo
2013-08-05 11:21   ` [PATCH V2 6/8] ARM: tegra: add LP1 suspend support for Tegra20 Joseph Lo
2013-08-05 11:21     ` Joseph Lo
2013-08-05 11:21   ` [PATCH V2 7/8] ARM: tegra: add LP1 suspend support for Tegra114 Joseph Lo
2013-08-05 11:21     ` Joseph Lo
2013-08-05 11:21   ` [PATCH V2 8/8] ARM: tegra: enable LP1 suspend mode Joseph Lo
2013-08-05 11:21     ` Joseph Lo
     [not found]     ` <1375701664-14965-9-git-send-email-josephl-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-08-05 17:56       ` Stephen Warren
2013-08-05 17:56         ` Stephen Warren
2013-08-05 17:56   ` [PATCH V2 0/8] ARM: tegra: support " Stephen Warren
2013-08-05 17:56     ` Stephen Warren
     [not found]     ` <51FFE732.10703-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-08-06  9:49       ` Joseph Lo
2013-08-06  9:49         ` Joseph Lo

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=5201430A.2040408@wwwdotorg.org \
    --to=swarren-3lzwwm7+weoh9zmkesr00q@public.gmane.org \
    --cc=josephl-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.