public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stefano Babic <sbabic@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/9] ARM926EJS: Implement cache operations
Date: Tue, 20 Mar 2012 08:28:05 +0100	[thread overview]
Message-ID: <4F683185.50704@denx.de> (raw)
In-Reply-To: <1331872405-1451-2-git-send-email-marex@denx.de>

On 16/03/2012 05:33, Marek Vasut wrote:
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Stefano Babic <sbabic@denx.de>
> ---
>  arch/arm/cpu/arm926ejs/cache.c |   66 ++++++++++++++++++++++++++++++++-------
>  1 files changed, 54 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/arm/cpu/arm926ejs/cache.c b/arch/arm/cpu/arm926ejs/cache.c
> index 504f604..5b23e3a 100644
> --- a/arch/arm/cpu/arm926ejs/cache.c
> +++ b/arch/arm/cpu/arm926ejs/cache.c
> @@ -23,29 +23,71 @@
>  #include <common.h>
>  
>  #ifndef CONFIG_SYS_DCACHE_OFF
> -static inline void dcache_noop(void)
> +
> +#ifndef CONFIG_SYS_CACHELINE_SIZE
> +#define CONFIG_SYS_CACHELINE_SIZE	32
> +#endif
> +
> +void invalidate_dcache_all(void)
>  {
> -	if (dcache_status()) {
> -		puts("WARNING: cache operations are not implemented!\n"
> -		     "WARNING: disabling D-Cache now, you can re-enable it"
> -		     "later with 'dcache on' command\n");
> -		dcache_disable();
> -	}
> +	asm volatile("mcr p15, 0, %0, c7, c6, 0\n"::"r"(0));
>  }
>  
> -void invalidate_dcache_all(void)
> +void flush_dcache_all(void)
>  {
> -	dcache_noop();
> +	asm volatile(
> +		"0:"
> +		"mrc p15, 0, r15, c7, c14, 3\n"
> +		"bne 0b\n"
> +		"mcr p15, 0, %0, c7, c10, 4\n"
> +		::"r"(0):"memory"
> +	);
> +}
> +
> +static int check_cache_range(unsigned long start, unsigned long stop)
> +{
> +	int ok = 1;
> +
> +	if (start & (CONFIG_SYS_CACHELINE_SIZE - 1))
> +		ok = 0;
> +
> +	if (stop & (CONFIG_SYS_CACHELINE_SIZE - 1))
> +		ok = 0;
> +
> +	if (!ok)
> +		printf("CACHE: Misaligned operation at range [%08lx, %08lx]\n",
> +			start, stop);
> +
> +	return ok;
>  }
>  
>  void invalidate_dcache_range(unsigned long start, unsigned long stop)
>  {
> -	dcache_noop();
> +	if (!check_cache_range(start, stop))
> +		return;
> +
> +	while (start < stop) {
> +		asm volatile("mcr p15, 0, %0, c7, c6, 1\n"::"r"(start));
> +		start += CONFIG_SYS_CACHELINE_SIZE;
> +	}
>  }
>  
>  void flush_dcache_range(unsigned long start, unsigned long stop)
>  {
> -	dcache_noop();
> +	if (!check_cache_range(start, stop))
> +		return;
> +
> +	while (start < stop) {
> +		asm volatile("mcr p15, 0, %0, c7, c14, 1\n"::"r"(start));
> +		start += CONFIG_SYS_CACHELINE_SIZE;
> +	}
> +
> +	asm("mcr p15, 0, %0, c7, c10, 4\n"::"r"(0));
> +}
> +
> +void flush_cache(unsigned long start, unsigned long size)
> +{
> +	flush_dcache_range(start, start + size);
>  }
>  #else /* #ifndef CONFIG_SYS_DCACHE_OFF */
>  void invalidate_dcache_all(void)
> @@ -64,7 +106,7 @@ void flush_dcache_range(unsigned long start, unsigned long stop)
>  {
>  }
>  
> -void  flush_cache(unsigned long start, unsigned long size)
> +void flush_cache(unsigned long start, unsigned long size)
>  {
>  }
>  #endif /* #ifndef CONFIG_SYS_DCACHE_OFF */

Acked-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

  reply	other threads:[~2012-03-20  7:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-16  4:33 [U-Boot] [PATCH 0/9] iMX/MXS: Get ready for cache Marek Vasut
2012-03-16  4:33 ` [U-Boot] [PATCH 1/9] ARM926EJS: Implement cache operations Marek Vasut
2012-03-20  7:28   ` Stefano Babic [this message]
2012-03-16  4:33 ` [U-Boot] [PATCH 2/9] i.MX28: Add cache support into the APBH DMA driver Marek Vasut
2012-03-16  4:33 ` [U-Boot] [PATCH 3/9] i.MX28: Add cache support to MXS NAND driver Marek Vasut
2012-03-16  4:33 ` [U-Boot] [PATCH 4/9] MMC: Implement generic bounce buffer Marek Vasut
2012-03-16  4:33 ` [U-Boot] [PATCH 5/9] i.MX28: Do data transfers via DMA in MMC driver Marek Vasut
2012-03-16  4:33 ` [U-Boot] [PATCH 6/9] i.MX28: Make use of the bounce buffer Marek Vasut
2012-03-16  4:33 ` [U-Boot] [PATCH 7/9] i.MX28: Enable caches by default Marek Vasut
2012-03-16  4:33 ` [U-Boot] [PATCH 8/9] net: force PKTALIGN to ARCH_DMA_MINALIGN Marek Vasut
2012-03-16  4:33 ` [U-Boot] [PATCH 9/9] net: fec_mxc: allow use with cache enabled Marek Vasut
2012-03-16  4:36 ` [U-Boot] [PATCH 0/9] iMX/MXS: Get ready for cache Marek Vasut

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=4F683185.50704@denx.de \
    --to=sbabic@denx.de \
    --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