From: Marek Vasut <marek.vasut@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] arm/pxa-devel: fix and cleanup of pxa_mem_setup macro
Date: Mon, 17 May 2010 11:12:06 +0200 [thread overview]
Message-ID: <201005171112.06506.marek.vasut@gmail.com> (raw)
In-Reply-To: <20100517102822.50b2fa4b@laska.campus-ws.pu.ru>
Dne Po 17. kv?tna 2010 08:28:22 Mikhail Kshevetskiy napsal(a):
> * strict following to section 6.4.10 of Intel PXA27xx Developer's Manual.
> * use r7 to store CONFIG_SYS_MDREFR_VAL as r6 is used in pxa_wait_ticks
>
> WARNING: This macro do not assume the values for K0DB4, KxDB2, KxFREE
> and APD bits of CONFIG_SYS_MDREFR_VAL as it was done early
> on many pxa platforms. All pxa developers that plan to use
> this macro should check the validity of their MDREFR values.
Exactly, I'd rather see the developers fix their configs instead of putting here
some weird goo. But I might be wrong ... see below please.
>
> Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@gmail.com>
> ---
> arch/arm/include/asm/arch-pxa/macro.h | 81
> +++++++++++++++++++++++---------- 1 files changed, 56 insertions(+), 25
> deletions(-)
>
> diff --git a/arch/arm/include/asm/arch-pxa/macro.h
> b/arch/arm/include/asm/arch-pxa/macro.h index 1f1759b..26d7a8d 100644
> --- a/arch/arm/include/asm/arch-pxa/macro.h
> +++ b/arch/arm/include/asm/arch-pxa/macro.h
> @@ -102,7 +102,11 @@
> /*
> * This macro sets up the Memory controller of the PXA2xx CPU
> *
> - * Clobbered regs: r3, r4, r5
> + * Clobbered regs: r3, r4, r5, r6, r7
> + *
> + * See section 6.4.10 of Intel PXA2xx Processor Developer's Manual
> + *
> http://www.marvell.com/products/processors/applications/pxa_family/pxa_27x
> _dev_man.pdf + *
> http://www.marvell.com/products/processors/applications/pxa_family/PXA3xx_
> Developers_Manual.zip */
Remove this, PXA3xx won't use this macro.
> .macro pxa_mem_setup
> /* This comes handy when setting MDREFR */
> @@ -149,27 +153,38 @@
> */
>
> /*
> - * Before accessing MDREFR we need a valid DRI field, so we set
> - * this to power on defaults + DRI field.
> + * Before accessing MDREFR we need a valid DRI field.
> + * Also we must properly configure MDREFR[K0DB2] and MDREFR[K0DB4].
> + * Optionaly we can set MDREFR[KxFREE] bits.
> + * So we set MDREFR to power on defaults + (DRI, K0DB2, K0DB4, KxFREE)
> + * fields from the config.
> + *
> + * WARNING: K0DB2 and K0DB4 bits are usually set, while KxFREE bits
> + * are usually unser.
> */
> ldr r5, [r3, #MDREFR_OFFSET]
> - bic r5, r5, #0x0ff
> - bic r5, r5, #0xf00 /* MDREFR user config with zeroed DRI */
> -
> - ldr r4, =CONFIG_SYS_MDREFR_VAL
> - mov r6, r4
> - lsl r4, #20
> - lsr r4, #20 /* Get a valid DRI field */
> + ldr r4, =( 0xFFF | MDREFR_K0DB4 | MDREFR_K0DB2 )
> + orr r4, #( MDREFR_K0FREE | MDREFR_K1FREE | MDREFR_K2FREE )
> + bic r5, r5, r4 /* clear DRI, K0DB2, K0DB4, KxFREE fields */
>
> - orr r5, r5, r4 /* MDREFR user config with correct DRI */
You can just wipe all the bits away, can't you ?
> + /*
> + * r3 is busy with MEMC_BASE,
> + * r4, r5, r6 used in pxa_wait_ticks and other places,
> + * so use r7 to store user specified MDREFR_VAL
> + */
> + ldr r7, =CONFIG_SYS_MDREFR_VAL
> + and r4, r7, r4
> + orr r5, r5, r4 /* use custom DRI, K0DB2, K0DB4, KxFREE */
And replace it with user config (if the user config is done correctly of course.
If the user config is incorrect, that's what should be fixed.)
>
> orr r5, #MDREFR_K0RUN
> orr r5, #MDREFR_SLFRSH
> bic r5, #MDREFR_APD
> bic r5, #MDREFR_E1PIN
> + bic r5, #MDREFR_K1RUN
> + bic r5, #MDREFR_K2RUN
Then just fine-tune the bits according 6.4.10 in PXA270 manual.
btw. these bic's are unneeded according to the manual.
Ok, please try explaining why is this solution better from what was here? I'm
kind of missing it, sorry.
>
> str r5, [r3, #MDREFR_OFFSET]
> - ldr r4, [r3, #MDREFR_OFFSET]
> + ldr r5, [r3, #MDREFR_OFFSET]
>
> /*
> * 5) Initialize Synchronous Static Memory (Flash/Peripherals)
> @@ -184,16 +199,29 @@
> write32rb (MEMC_BASE + SXCNFG_OFFSET), CONFIG_SYS_SXCNFG_VAL
>
> /*
> - * 6) Initialize SDRAM
> + * 6) Initialize SDRAM,
> + * also we must properly set MDREFR[K1DB2] and MDREFR[K2DB2]
> + *
> + * WARNING: K1DB2 and K2DB2 bits are usually set
> */
>
> - bic r6, #MDREFR_SLFRSH
> - str r6, [r3, #MDREFR_OFFSET]
> - ldr r4, [r3, #MDREFR_OFFSET]
> + and r4, r7, #( MDREFR_K1DB2 | MDREFR_K2DB2 )
> + ldr r5, [r3, #MDREFR_OFFSET]
> + bic r5, #( MDREFR_K1DB2 | MDREFR_K2DB2 )
> + orr r5, r5, r4
>
> - orr r6, #MDREFR_E1PIN
> - str r6, [r3, #MDREFR_OFFSET]
> - ldr r4, [r3, #MDREFR_OFFSET]
> + orr r5, #MDREFR_K1RUN
> + orr r5, #MDREFR_K2RUN
No, don't enable this unconditionally.
> + str r5, [r3, #MDREFR_OFFSET]
> + ldr r5, [r3, #MDREFR_OFFSET]
> +
> + bic r5, #MDREFR_SLFRSH
> + str r5, [r3, #MDREFR_OFFSET]
> + ldr r5, [r3, #MDREFR_OFFSET]
> +
> + orr r5, #MDREFR_E1PIN
> + str r5, [r3, #MDREFR_OFFSET]
> + ldr r5, [r3, #MDREFR_OFFSET]
>
> /*
> * 7) Write MDCNFG with MDCNFG:DEx deasserted (set to 0), to configure
> @@ -246,14 +274,17 @@
> ldr r4, [r3, #MDMRS_OFFSET]
>
> /*
> - * 11) Enable APD
> + * 11) Optionaly enable MDREFR[APD]
> + *
> + * WARNING: APD bit is usually set.
> */
>
> - ldr r4, [r3, #MDREFR_OFFSET]
> - and r6, r6, #MDREFR_APD
> - orr r4, r4, r6
> - str r4, [r3, #MDREFR_OFFSET]
> - ldr r4, [r3, #MDREFR_OFFSET]
> + and r7, #MDREFR_APD
> + ldr r5, [r3, #MDREFR_OFFSET]
> + bic r5, #MDREFR_APD
> + orr r5, r5, r7
> + str r5, [r3, #MDREFR_OFFSET]
> + ldr r5, [r3, #MDREFR_OFFSET]
Why are you adding complexity here ?
> .endm
>
> /*
Good work so far, cheers!
prev parent reply other threads:[~2010-05-17 9:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-17 6:28 [U-Boot] [PATCH] arm/pxa-devel: fix and cleanup of pxa_mem_setup macro Mikhail Kshevetskiy
2010-05-17 9:12 ` Marek Vasut [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=201005171112.06506.marek.vasut@gmail.com \
--to=marek.vasut@gmail.com \
--cc=u-boot@lists.denx.de \
/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