All of lore.kernel.org
 help / color / mirror / Atom feed
From: Albert ARIBAUD <albert.u.boot@aribaud.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3] armv7:cache: D cache line size read method
Date: Wed, 17 Aug 2011 18:28:47 +0200	[thread overview]
Message-ID: <4E4BEC3F.3030505@aribaud.net> (raw)
In-Reply-To: <1313571104-18493-1-git-send-email-l.majewski@samsung.com>

Hi Lukasz,

Le 17/08/2011 10:51, Lukasz Majewski a ?crit :
> This commit adds support for reading the D cache line size for armv7
> architecture.
>
> The get_dcache_line_size() function is supposed to work in conjunction
> with memalign call to provide D cache aligned DMA buffers.
>
> Signed-off-by: Lukasz Majewski<l.majewski@samsung.com>
> Signed-off-by: Kyungmin Park<kyungmin.park@samsung.com>
> CC: Aneesh V<aneesh@ti.com>
> CC: Albert ARIBAUD<albert.u.boot@aribaud.net>
> ---
> Changes for v2:
> - Weak function get_dcache_line_size added to lib/cache.c for non armv7
> architectures
> Changes for v3:
> - __BIGGEST_ALIGNMENT__ GCC constant added
> ---
>   arch/arm/cpu/armv7/cache_v7.c |   14 ++++++++++++++
>   arch/arm/lib/cache.c          |   13 +++++++++++++
>   include/common.h              |    1 +
>   3 files changed, 28 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/cpu/armv7/cache_v7.c b/arch/arm/cpu/armv7/cache_v7.c
> index 3e1e1bf..ea5a3e4 100644
> --- a/arch/arm/cpu/armv7/cache_v7.c
> +++ b/arch/arm/cpu/armv7/cache_v7.c
> @@ -246,6 +246,20 @@ static void v7_inval_tlb(void)
>   	CP15ISB;
>   }
>
> +/* Read the cache line size (in bytes) */
> +int get_dcache_line_size(void)
> +{
> +	u32 ccsidr, log2_line_len;
> +
> +	ccsidr = get_ccsidr();
> +	log2_line_len = ((ccsidr&  CCSIDR_LINE_SIZE_MASK)>>
> +				CCSIDR_LINE_SIZE_OFFSET) + 2;
> +	/* Converting from words to bytes */
> +	log2_line_len += 2;
> +
> +	return 1<<  log2_line_len;
> +}
> +
>   void invalidate_dcache_all(void)
>   {
>   	v7_maint_dcache_all(ARMV7_DCACHE_INVAL_ALL);
> diff --git a/arch/arm/lib/cache.c b/arch/arm/lib/cache.c
> index 92b61a2..305f070 100644
> --- a/arch/arm/lib/cache.c
> +++ b/arch/arm/lib/cache.c
> @@ -53,3 +53,16 @@ void	__flush_dcache_all(void)
>   }
>   void	flush_dcache_all(void)
>   	__attribute__((weak, alias("__flush_dcache_all")));
> +
> +/* Default implementation: */
> +/* Read the default D CACHE LINE size */
> +int __attribute__((weak)) get_dcache_line_size(void)
> +{
> +#if defined(CONFIG_SYS_CACHE_LINE_SIZE)&&  !defined(CONFIG_SYS_DCACHE_OFF)
> +	return CONFIG_SYS_CACHE_LINE_SIZE;
> +#else
> +	/* The smallest alignment */
> +	/* for memalign() is 8 Bytes. */
> +	return __BIGGEST_ALIGNMENT__;  /* Constant defined by GCC compiler */

Fix the comment (still says 8 bytes, but that does not fit any more with 
the use of __BIGGEST_ALIGNMENT__).

> +#endif
> +}
> diff --git a/include/common.h b/include/common.h
> index 12a1074..b535300 100644
> --- a/include/common.h
> +++ b/include/common.h
> @@ -622,6 +622,7 @@ void	flush_dcache_range(unsigned long start, unsigned long stop);
>   void	invalidate_dcache_range(unsigned long start, unsigned long stop);
>   void	invalidate_dcache_all(void);
>   void	invalidate_icache_all(void);
> +int     get_dcache_line_size(void);
>
>   /* arch/$(ARCH)/lib/ticks.S */
>   unsigned long long get_ticks(void);

Amicalement,
-- 
Albert.

  reply	other threads:[~2011-08-17 16:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-12  8:24 [U-Boot] [PATCH] armv7:cache: D cache line size read method Lukasz Majewski
2011-08-12  8:58 ` Albert ARIBAUD
2011-08-12  9:16   ` Aneesh V
2011-08-12  9:48     ` Albert ARIBAUD
2011-08-16 18:32     ` Anton Staaf
2011-08-12  9:02 ` Aneesh V
2011-08-12  9:46   ` Lukasz Majewski
2011-08-16 10:31 ` [U-Boot] [PATCH v2] " Lukasz Majewski
2011-08-16 11:24   ` Sergei Shtylyov
2011-08-16 12:01 ` [U-Boot] [RESEND PATCH " Lukasz Majewski
2011-08-17  8:51 ` [U-Boot] [PATCH v3] " Lukasz Majewski
2011-08-17 16:28   ` Albert ARIBAUD [this message]
2011-08-18  6:46 ` [U-Boot] [RESEND PATCH " Lukasz Majewski
2011-08-23  6:13 ` [U-Boot] [PATCH v4] dcache: " Lukasz Majewski

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=4E4BEC3F.3030505@aribaud.net \
    --to=albert.u.boot@aribaud.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.