diff mbox

[2/3] pm: at91: pm_slowclock: remove clocks which are already stopped when entering slow clock mode

Message ID 1423116083-5986-1-git-send-email-wenyou.yang@atmel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wenyou Yang Feb. 5, 2015, 6:01 a.m. UTC
From: Sylvain Rochet <sylvain.rochet@finsecur.com>

Assume USB PLL and PLL B are already stopped before entering sleep mode,
print a warning if this isn't the case.

Removed PLL B from slow clock code, all drivers are supposed to properly
unprepare clocks.

Signed-off-by: Sylvain Rochet <sylvain.rochet@finsecur.com>
Acked-by: Wenyou.Yang <wenyou.yang@atmel.com>
---
 arch/arm/mach-at91/pm.c           |   12 ++++++++++++
 arch/arm/mach-at91/pm_slowclock.S |   31 -------------------------------
 2 files changed, 12 insertions(+), 31 deletions(-)

Comments

Nicolas Ferre March 3, 2015, 6:42 p.m. UTC | #1
Le 05/02/2015 07:01, Wenyou Yang a écrit :
> From: Sylvain Rochet <sylvain.rochet@finsecur.com>
> 
> Assume USB PLL and PLL B are already stopped before entering sleep mode,
> print a warning if this isn't the case.
> 
> Removed PLL B from slow clock code, all drivers are supposed to properly
> unprepare clocks.
> 
> Signed-off-by: Sylvain Rochet <sylvain.rochet@finsecur.com>
> Acked-by: Wenyou.Yang <wenyou.yang@atmel.com>

I keep this one for 4.1 as all the USB drivers are not converted yet.

Bye,


> ---
>  arch/arm/mach-at91/pm.c           |   12 ++++++++++++
>  arch/arm/mach-at91/pm_slowclock.S |   31 -------------------------------
>  2 files changed, 12 insertions(+), 31 deletions(-)
> 
> diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
> index 9b15169..1cfd6e9 100644
> --- a/arch/arm/mach-at91/pm.c
> +++ b/arch/arm/mach-at91/pm.c
> @@ -98,6 +98,18 @@ static int at91_pm_verify_clocks(void)
>  		}
>  	}
>  
> +	/* Drivers should have previously suspended USB PLL */
> +	if (at91_pmc_read(AT91_CKGR_UCKR) & AT91_PMC_UPLLEN) {
> +		pr_err("AT91: PM - Suspend-to-RAM with USB PLL running\n");
> +		return 0;
> +	}
> +
> +	/* Drivers should have previously suspended PLL B */
> +	if (at91_pmc_read(AT91_PMC_SR) & AT91_PMC_LOCKB) {
> +		pr_err("AT91: PM - Suspend-to-RAM with PLL B running\n");
> +		return 0;
> +	}
> +
>  	return 1;
>  }
>  
> diff --git a/arch/arm/mach-at91/pm_slowclock.S b/arch/arm/mach-at91/pm_slowclock.S
> index 79dfdbe..75d8b19 100644
> --- a/arch/arm/mach-at91/pm_slowclock.S
> +++ b/arch/arm/mach-at91/pm_slowclock.S
> @@ -68,15 +68,6 @@ tmp2	.req	r5
>  	beq	1b
>  	.endm
>  
> -/*
> - * Wait until PLLB has locked.
> - */
> -	.macro wait_pllblock
> -1:	ldr	tmp1, [pmc, #AT91_PMC_SR]
> -	tst	tmp1, #AT91_PMC_LOCKB
> -	beq	1b
> -	.endm
> -
>  	.text
>  
>  /* void at91_slow_clock(void __iomem *pmc, void __iomem *sdramc,
> @@ -182,13 +173,6 @@ sdr_sr_done:
>  	orr	tmp1, tmp1, #(1 << 29)		/* bit 29 always set */
>  	str	tmp1, [pmc, #AT91_CKGR_PLLAR]
>  
> -	/* Save PLLB setting and disable it */
> -	ldr	tmp1, [pmc, #AT91_CKGR_PLLBR]
> -	str	tmp1, .saved_pllbr
> -
> -	mov	tmp1, #AT91_PMC_PLLCOUNT
> -	str	tmp1, [pmc, #AT91_CKGR_PLLBR]
> -
>  	/* Turn off the main oscillator */
>  	ldr	tmp1, [pmc, #AT91_CKGR_MOR]
>  	bic	tmp1, tmp1, #AT91_PMC_MOSCEN
> @@ -204,18 +188,6 @@ sdr_sr_done:
>  
>  	wait_moscrdy
>  
> -	/* Restore PLLB setting */
> -	ldr	tmp1, .saved_pllbr
> -	str	tmp1, [pmc, #AT91_CKGR_PLLBR]
> -
> -	tst	tmp1, #(AT91_PMC_MUL &  0xff0000)
> -	bne	1f
> -	tst	tmp1, #(AT91_PMC_MUL & ~0xff0000)
> -	beq	2f
> -1:
> -	wait_pllblock
> -2:
> -
>  	/* Restore PLLA setting */
>  	ldr	tmp1, .saved_pllar
>  	str	tmp1, [pmc, #AT91_CKGR_PLLAR]
> @@ -294,9 +266,6 @@ ram_restored:
>  .saved_pllar:
>  	.word 0
>  
> -.saved_pllbr:
> -	.word 0
> -
>  .saved_sam9_lpr:
>  	.word 0
>  
>
Sylvain Rochet March 3, 2015, 10:50 p.m. UTC | #2
Hello Nicolas,

On Tue, Mar 03, 2015 at 07:42:26PM +0100, Nicolas Ferre wrote:
> Le 05/02/2015 07:01, Wenyou Yang a écrit :
> > From: Sylvain Rochet <sylvain.rochet@finsecur.com>
> > 
> > Assume USB PLL and PLL B are already stopped before entering sleep mode,
> > print a warning if this isn't the case.
> > 
> > Removed PLL B from slow clock code, all drivers are supposed to properly
> > unprepare clocks.
> > 
> > Signed-off-by: Sylvain Rochet <sylvain.rochet@finsecur.com>
> > Acked-by: Wenyou.Yang <wenyou.yang@atmel.com>
> 
> I keep this one for 4.1 as all the USB drivers are not converted yet.

I agree we should wait to prevent a regression, in case you missed that 
I sent a v7 of my USBA PM support a few weeks ago (ping ;-).

Sylvain
Nicolas Ferre March 12, 2015, 3:37 p.m. UTC | #3
Le 03/03/2015 23:50, Sylvain Rochet a écrit :
> Hello Nicolas,
> 
> On Tue, Mar 03, 2015 at 07:42:26PM +0100, Nicolas Ferre wrote:
>> Le 05/02/2015 07:01, Wenyou Yang a écrit :
>>> From: Sylvain Rochet <sylvain.rochet@finsecur.com>
>>>
>>> Assume USB PLL and PLL B are already stopped before entering sleep mode,
>>> print a warning if this isn't the case.
>>>
>>> Removed PLL B from slow clock code, all drivers are supposed to properly
>>> unprepare clocks.
>>>
>>> Signed-off-by: Sylvain Rochet <sylvain.rochet@finsecur.com>
>>> Acked-by: Wenyou.Yang <wenyou.yang@atmel.com>
>>
>> I keep this one for 4.1 as all the USB drivers are not converted yet.
> 
> I agree we should wait to prevent a regression, in case you missed that 
> I sent a v7 of my USBA PM support a few weeks ago (ping ;-).
> 

Sylvain, your series are in linux-next so I take this patch for 4.1 in
at91-4.1-cleanup with my:

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

But... I remove the arch/arm/mach-at91/pm.c part of this patch as it is
not really needed and adds a too strong dependency on the PMC in an
unrelated file...

Bye,
diff mbox

Patch

diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index 9b15169..1cfd6e9 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -98,6 +98,18 @@  static int at91_pm_verify_clocks(void)
 		}
 	}
 
+	/* Drivers should have previously suspended USB PLL */
+	if (at91_pmc_read(AT91_CKGR_UCKR) & AT91_PMC_UPLLEN) {
+		pr_err("AT91: PM - Suspend-to-RAM with USB PLL running\n");
+		return 0;
+	}
+
+	/* Drivers should have previously suspended PLL B */
+	if (at91_pmc_read(AT91_PMC_SR) & AT91_PMC_LOCKB) {
+		pr_err("AT91: PM - Suspend-to-RAM with PLL B running\n");
+		return 0;
+	}
+
 	return 1;
 }
 
diff --git a/arch/arm/mach-at91/pm_slowclock.S b/arch/arm/mach-at91/pm_slowclock.S
index 79dfdbe..75d8b19 100644
--- a/arch/arm/mach-at91/pm_slowclock.S
+++ b/arch/arm/mach-at91/pm_slowclock.S
@@ -68,15 +68,6 @@  tmp2	.req	r5
 	beq	1b
 	.endm
 
-/*
- * Wait until PLLB has locked.
- */
-	.macro wait_pllblock
-1:	ldr	tmp1, [pmc, #AT91_PMC_SR]
-	tst	tmp1, #AT91_PMC_LOCKB
-	beq	1b
-	.endm
-
 	.text
 
 /* void at91_slow_clock(void __iomem *pmc, void __iomem *sdramc,
@@ -182,13 +173,6 @@  sdr_sr_done:
 	orr	tmp1, tmp1, #(1 << 29)		/* bit 29 always set */
 	str	tmp1, [pmc, #AT91_CKGR_PLLAR]
 
-	/* Save PLLB setting and disable it */
-	ldr	tmp1, [pmc, #AT91_CKGR_PLLBR]
-	str	tmp1, .saved_pllbr
-
-	mov	tmp1, #AT91_PMC_PLLCOUNT
-	str	tmp1, [pmc, #AT91_CKGR_PLLBR]
-
 	/* Turn off the main oscillator */
 	ldr	tmp1, [pmc, #AT91_CKGR_MOR]
 	bic	tmp1, tmp1, #AT91_PMC_MOSCEN
@@ -204,18 +188,6 @@  sdr_sr_done:
 
 	wait_moscrdy
 
-	/* Restore PLLB setting */
-	ldr	tmp1, .saved_pllbr
-	str	tmp1, [pmc, #AT91_CKGR_PLLBR]
-
-	tst	tmp1, #(AT91_PMC_MUL &  0xff0000)
-	bne	1f
-	tst	tmp1, #(AT91_PMC_MUL & ~0xff0000)
-	beq	2f
-1:
-	wait_pllblock
-2:
-
 	/* Restore PLLA setting */
 	ldr	tmp1, .saved_pllar
 	str	tmp1, [pmc, #AT91_CKGR_PLLAR]
@@ -294,9 +266,6 @@  ram_restored:
 .saved_pllar:
 	.word 0
 
-.saved_pllbr:
-	.word 0
-
 .saved_sam9_lpr:
 	.word 0