From: nicolas.ferre@atmel.com (Nicolas Ferre)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH RESEND] pm: at91: Workaround DDRSDRC self-refresh bug with LPDDR1 memories
Date: Wed, 14 Jan 2015 17:47:39 +0100 [thread overview]
Message-ID: <54B69DAB.8010303@atmel.com> (raw)
In-Reply-To: <1421241632-2991-1-git-send-email-peda@lysator.liu.se>
Le 14/01/2015 14:20, Peter Rosin a ?crit :
> From: Peter Rosin <peda@axentia.se>
>
> The DDRSDR controller (on the ATSAMA5D31) fails miserably to put LPDDR1
> memories in self-refresh. Force the controller to think it has DDR2
> memories during the self-refresh period, as the DDR2 self-refresh spec
> is equivalent to LPDDR1, and is correctly implemented in the controller.
>
> Assume that the second controller has the same fault, and that other
> CPUs in the family has the same problem, but that is untested.
>
> Signed-off-by: Peter Rosin <peda@axentia.se>
I've just verified your code and the scope of this issue and your
implementation makes perfect sense.
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Peter,
Thanks for your patch. You will probably see it appearing in 3.20 or 3.21.
Wenyou,
Can you please integrate the patch from Peter in your current rework of
the PM routines (keeping his authorship of course)?
Please tell me if I can help with this.
Best regards,
> ---
> arch/arm/mach-at91/pm_slowclock.S | 43 +++++++++++++++++++++++++++++++-----
> include/soc/at91/at91sam9_ddrsdr.h | 2 +-
> 2 files changed, 39 insertions(+), 6 deletions(-)
>
> diff --git a/arch/arm/mach-at91/pm_slowclock.S b/arch/arm/mach-at91/pm_slowclock.S
> index 20018779bae7..63a9e0b0a17d 100644
> --- a/arch/arm/mach-at91/pm_slowclock.S
> +++ b/arch/arm/mach-at91/pm_slowclock.S
> @@ -143,6 +143,16 @@ ddr_sr_enable:
> cmp memctrl, #AT91_MEMCTRL_DDRSDR
> bne sdr_sr_enable
>
> + /* LPDDR1 --> force DDR2 mode during self-refresh */
> + ldr tmp1, [sdramc, #AT91_DDRSDRC_MDR]
> + str tmp1, .saved_sam9_mdr
> + bic tmp1, tmp1, #~AT91_DDRSDRC_MD
> + cmp tmp1, #AT91_DDRSDRC_MD_LOW_POWER_DDR
> + ldreq tmp1, [sdramc, #AT91_DDRSDRC_MDR]
> + biceq tmp1, tmp1, #AT91_DDRSDRC_MD
> + orreq tmp1, tmp1, #AT91_DDRSDRC_MD_DDR2
> + streq tmp1, [sdramc, #AT91_DDRSDRC_MDR]
> +
> /* prepare for DDRAM self-refresh mode */
> ldr tmp1, [sdramc, #AT91_DDRSDRC_LPR]
> str tmp1, .saved_sam9_lpr
> @@ -151,14 +161,26 @@ ddr_sr_enable:
>
> /* figure out if we use the second ram controller */
> cmp ramc1, #0
> - ldrne tmp2, [ramc1, #AT91_DDRSDRC_LPR]
> - strne tmp2, .saved_sam9_lpr1
> - bicne tmp2, #AT91_DDRSDRC_LPCB
> - orrne tmp2, #AT91_DDRSDRC_LPCB_SELF_REFRESH
> + beq ddr_no_2nd_ctrl
> +
> + ldr tmp2, [ramc1, #AT91_DDRSDRC_MDR]
> + str tmp2, .saved_sam9_mdr1
> + bic tmp2, tmp2, #~AT91_DDRSDRC_MD
> + cmp tmp2, #AT91_DDRSDRC_MD_LOW_POWER_DDR
> + ldreq tmp2, [ramc1, #AT91_DDRSDRC_MDR]
> + biceq tmp2, tmp2, #AT91_DDRSDRC_MD
> + orreq tmp2, tmp2, #AT91_DDRSDRC_MD_DDR2
> + streq tmp2, [ramc1, #AT91_DDRSDRC_MDR]
> +
> + ldr tmp2, [ramc1, #AT91_DDRSDRC_LPR]
> + str tmp2, .saved_sam9_lpr1
> + bic tmp2, #AT91_DDRSDRC_LPCB
> + orr tmp2, #AT91_DDRSDRC_LPCB_SELF_REFRESH
>
> /* Enable DDRAM self-refresh mode */
> + str tmp2, [ramc1, #AT91_DDRSDRC_LPR]
> +ddr_no_2nd_ctrl:
> str tmp1, [sdramc, #AT91_DDRSDRC_LPR]
> - strne tmp2, [ramc1, #AT91_DDRSDRC_LPR]
>
> b sdr_sr_done
>
> @@ -289,12 +311,17 @@ sdr_sr_done:
> */
> cmp memctrl, #AT91_MEMCTRL_DDRSDR
> bne sdr_en_restore
> + /* Restore MDR in case of LPDDR1 */
> + ldr tmp1, .saved_sam9_mdr
> + str tmp1, [sdramc, #AT91_DDRSDRC_MDR]
> /* Restore LPR on AT91 with DDRAM */
> ldr tmp1, .saved_sam9_lpr
> str tmp1, [sdramc, #AT91_DDRSDRC_LPR]
>
> /* if we use the second ram controller */
> cmp ramc1, #0
> + ldrne tmp2, .saved_sam9_mdr1
> + strne tmp2, [ramc1, #AT91_DDRSDRC_MDR]
> ldrne tmp2, .saved_sam9_lpr1
> strne tmp2, [ramc1, #AT91_DDRSDRC_LPR]
>
> @@ -328,5 +355,11 @@ ram_restored:
> .saved_sam9_lpr1:
> .word 0
>
> +.saved_sam9_mdr:
> + .word 0
> +
> +.saved_sam9_mdr1:
> + .word 0
> +
> ENTRY(at91_slow_clock_sz)
> .word .-at91_slow_clock
> diff --git a/include/soc/at91/at91sam9_ddrsdr.h b/include/soc/at91/at91sam9_ddrsdr.h
> index 0210797abf2e..cd2c18787833 100644
> --- a/include/soc/at91/at91sam9_ddrsdr.h
> +++ b/include/soc/at91/at91sam9_ddrsdr.h
> @@ -92,7 +92,7 @@
> #define AT91_DDRSDRC_UPD_MR (3 << 20) /* Update load mode register and extended mode register */
>
> #define AT91_DDRSDRC_MDR 0x20 /* Memory Device Register */
> -#define AT91_DDRSDRC_MD (3 << 0) /* Memory Device Type */
> +#define AT91_DDRSDRC_MD (7 << 0) /* Memory Device Type */
> #define AT91_DDRSDRC_MD_SDR 0
> #define AT91_DDRSDRC_MD_LOW_POWER_SDR 1
> #define AT91_DDRSDRC_MD_LOW_POWER_DDR 3
>
--
Nicolas Ferre
next prev parent reply other threads:[~2015-01-14 16:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-14 13:20 [PATCH RESEND] pm: at91: Workaround DDRSDRC self-refresh bug with LPDDR1 memories Peter Rosin
2015-01-14 16:47 ` Nicolas Ferre [this message]
2015-01-14 21:33 ` Peter Rosin
2015-01-15 5:54 ` Yang, Wenyou
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=54B69DAB.8010303@atmel.com \
--to=nicolas.ferre@atmel.com \
--cc=linux-arm-kernel@lists.infradead.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).