From: Ian Campbell <ijc@hellion.org.uk>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 11/14] sunxi: Fill memory before comparing it when doing dram init on sun6i
Date: Thu, 18 Dec 2014 19:12:13 +0000 [thread overview]
Message-ID: <1418929933.26985.106.camel@hellion.org.uk> (raw)
In-Reply-To: <1418761900-14035-11-git-send-email-hdegoede@redhat.com>
On Tue, 2014-12-16 at 21:31 +0100, Hans de Goede wrote:
> The sun8i boot0 code fills the DRAM with a "random" pattern before comparing
> it at different offsets to do columns, etc. detection. The sun6i boot0 code
> does not do it, but it seems like a good idea to do this regardless.
Is this the right way round? The existing sun6i code (which you are
moving here) seems to _rely_ on something having written a useful
pattern, which I would have assumed to have been boot0. Or else how does
it work now? Chance?
> The new mctl_mem_fill function this introduces is added as an inline helper
> in dram.h, so that it can be shared with the sun8i dram code.
>
> While at it move mctl_mem_matches to dram.h for re-use in sun8i too.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> arch/arm/cpu/armv7/sunxi/dram_sun6i.c | 15 +--------------
> arch/arm/include/asm/arch-sunxi/dram.h | 29 +++++++++++++++++++++++++++++
> 2 files changed, 30 insertions(+), 14 deletions(-)
>
> diff --git a/arch/arm/cpu/armv7/sunxi/dram_sun6i.c b/arch/arm/cpu/armv7/sunxi/dram_sun6i.c
> index e1670e5..4675c48 100644
> --- a/arch/arm/cpu/armv7/sunxi/dram_sun6i.c
> +++ b/arch/arm/cpu/armv7/sunxi/dram_sun6i.c
> @@ -326,20 +326,6 @@ static void mctl_port_cfg(void)
> writel(0x00000307, &mctl_com->mbagcr[5]);
> }
>
> -static bool mctl_mem_matches(u32 offset)
> -{
> - const int match_count = 64;
> - int i, matches = 0;
> -
> - for (i = 0; i < match_count; i++) {
> - if (readl(CONFIG_SYS_SDRAM_BASE + i * 4) ==
> - readl(CONFIG_SYS_SDRAM_BASE + offset + i * 4))
> - matches++;
> - }
> -
> - return matches == match_count;
> -}
> -
> unsigned long sunxi_dram_init(void)
> {
> struct sunxi_mctl_com_reg * const mctl_com =
> @@ -391,6 +377,7 @@ unsigned long sunxi_dram_init(void)
> MCTL_CR_BANK(1) | MCTL_CR_RANK(1));
>
> /* Detect and set page size */
> + mctl_mem_fill();
> for (columns = 7; columns < 20; columns++) {
> if (mctl_mem_matches(1 << columns))
> break;
> diff --git a/arch/arm/include/asm/arch-sunxi/dram.h b/arch/arm/include/asm/arch-sunxi/dram.h
> index 18924f5..0bf718c 100644
> --- a/arch/arm/include/asm/arch-sunxi/dram.h
> +++ b/arch/arm/include/asm/arch-sunxi/dram.h
> @@ -22,6 +22,8 @@
> #include <asm/arch/dram_sun4i.h>
> #endif
>
> +#define MCTL_MEM_FILL_MATCH_COUNT 64
> +
> unsigned long sunxi_dram_init(void);
>
> /*
> @@ -37,4 +39,31 @@ static inline void mctl_await_completion(u32 *reg, u32 mask, u32 val)
> }
> }
>
> +/*
> + * Fill beginning of DRAM with "random" data for mctl_mem_matches()
> + */
> +static inline void mctl_mem_fill(void)
> +{
> + int i;
> +
> + for (i = 0; i < MCTL_MEM_FILL_MATCH_COUNT; i++)
> + writel(0xaa55aa55 + i, CONFIG_SYS_SDRAM_BASE + i * 4);
> +}
> +
> +/*
> + * Test if memory at offset offset matches memory at begin of DRAM
> + */
> +static inline bool mctl_mem_matches(u32 offset)
> +{
> + int i, matches = 0;
> +
> + for (i = 0; i < MCTL_MEM_FILL_MATCH_COUNT; i++) {
> + if (readl(CONFIG_SYS_SDRAM_BASE + i * 4) ==
> + readl(CONFIG_SYS_SDRAM_BASE + offset + i * 4))
> + matches++;
> + }
> +
> + return matches == MCTL_MEM_FILL_MATCH_COUNT;
> +}
> +
> #endif /* _SUNXI_DRAM_H */
next prev parent reply other threads:[~2014-12-18 19:12 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-16 20:31 [U-Boot] [PATCH 01/14] sun6i: s/SUNXI_GPL0_R_P2WI/SUN6I_GPL0_R_P2WI/ Hans de Goede
2014-12-16 20:31 ` [U-Boot] [PATCH 02/14] sunxi: Add support for the rsb (Reduced Serial Bus) Hans de Goede
2014-12-17 2:22 ` Chen-Yu Tsai
2014-12-17 12:56 ` Hans de Goede
2014-12-18 18:57 ` Ian Campbell
2014-12-18 18:59 ` Ian Campbell
2014-12-19 15:26 ` Hans de Goede
2014-12-16 20:31 ` [U-Boot] [PATCH 03/14] sunxi: axp221: Add axp223 support Hans de Goede
2014-12-17 2:34 ` Chen-Yu Tsai
2014-12-18 10:44 ` Hans de Goede
2014-12-18 19:00 ` Ian Campbell
2014-12-16 20:31 ` [U-Boot] [PATCH 04/14] sunxi: axp221: Add Kconfig help and sane defaults for typical ldo usage Hans de Goede
2014-12-18 19:02 ` Ian Campbell
2014-12-16 20:31 ` [U-Boot] [PATCH 05/14] sunxi: axp221: Make dcdc1 voltage configurable Hans de Goede
2014-12-18 19:03 ` Ian Campbell
2014-12-16 20:31 ` [U-Boot] [PATCH 06/14] sunxi: axp221: Explicitly turn off unused voltages Hans de Goede
2014-12-18 19:04 ` Ian Campbell
2014-12-16 20:31 ` [U-Boot] [PATCH 07/14] sunxi: axp221: Disable dcdc4 on sun8i (A23) Hans de Goede
2014-12-18 19:05 ` Ian Campbell
2014-12-16 20:31 ` [U-Boot] [PATCH 08/14] sun6i: Add a sigma_delta_enable paramter to clock_set_pll5() Hans de Goede
2014-12-18 19:07 ` Ian Campbell
2014-12-19 10:02 ` Siarhei Siamashka
2014-12-16 20:31 ` [U-Boot] [PATCH 09/14] sun6i: Add k and m parameters " Hans de Goede
2014-12-18 19:07 ` Ian Campbell
2014-12-19 10:03 ` Siarhei Siamashka
2014-12-19 16:40 ` Hans de Goede
2014-12-22 7:25 ` Siarhei Siamashka
2014-12-16 20:31 ` [U-Boot] [PATCH 10/14] sunxi: Move await_completion dram helper to dram.h Hans de Goede
2014-12-18 19:08 ` Ian Campbell
2014-12-19 10:06 ` Siarhei Siamashka
2014-12-19 16:42 ` Hans de Goede
2014-12-22 7:28 ` Siarhei Siamashka
2014-12-16 20:31 ` [U-Boot] [PATCH 11/14] sunxi: Fill memory before comparing it when doing dram init on sun6i Hans de Goede
2014-12-18 19:12 ` Ian Campbell [this message]
2014-12-19 10:08 ` Siarhei Siamashka
2014-12-19 16:56 ` Hans de Goede
2014-12-22 7:39 ` Siarhei Siamashka
2014-12-19 16:55 ` Hans de Goede
2014-12-22 14:19 ` Ian Campbell
2014-12-22 14:32 ` Siarhei Siamashka
2014-12-22 14:34 ` Ian Campbell
2014-12-22 15:47 ` Hans de Goede
2014-12-16 20:31 ` [U-Boot] [PATCH 12/14] sunxi: Use memcmp for mctl_mem_matches Hans de Goede
2014-12-18 19:13 ` Ian Campbell
2014-12-16 20:31 ` [U-Boot] [PATCH 13/14] sun8i: Add dram initialization support Hans de Goede
2014-12-18 11:12 ` Chen-Yu Tsai
2014-12-18 19:17 ` Ian Campbell
2014-12-19 16:51 ` Hans de Goede
2014-12-19 10:20 ` Siarhei Siamashka
2014-12-19 17:05 ` Hans de Goede
2014-12-22 7:43 ` Siarhei Siamashka
2014-12-16 20:31 ` [U-Boot] [PATCH 14/14] sun8i: Add defconfig for Ippo_q8h v1.2 Hans de Goede
2014-12-18 19:19 ` Ian Campbell
2014-12-18 18:56 ` [U-Boot] [PATCH 01/14] sun6i: s/SUNXI_GPL0_R_P2WI/SUN6I_GPL0_R_P2WI/ Ian Campbell
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=1418929933.26985.106.camel@hellion.org.uk \
--to=ijc@hellion.org.uk \
--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