From patchwork Tue Aug 23 06:13:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Majewski?= X-Patchwork-Id: 111048 X-Patchwork-Delegate: albert.aribaud@free.fr Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id DD111B6F82 for ; Tue, 23 Aug 2011 16:14:19 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 96C1A2807B; Tue, 23 Aug 2011 08:14:16 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OQNEbF0vA5iC; Tue, 23 Aug 2011 08:14:16 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 87FC52807C; Tue, 23 Aug 2011 08:14:10 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 93EFE2807C for ; Tue, 23 Aug 2011 08:14:06 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7aYQR7izbX0V for ; Tue, 23 Aug 2011 08:14:03 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by theia.denx.de (Postfix) with ESMTP id 1964C2807B for ; Tue, 23 Aug 2011 08:14:01 +0200 (CEST) Received: from eu_spt1 (mailout2.w1.samsung.com [210.118.77.12]) by mailout2.w1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTP id <0LQD001PXANBMW@mailout2.w1.samsung.com> for u-boot@lists.denx.de; Tue, 23 Aug 2011 07:13:59 +0100 (BST) Received: from linux.samsung.com ([106.116.38.10]) by spt1.w1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0LQD001ENANA07@spt1.w1.samsung.com> for u-boot@lists.denx.de; Tue, 23 Aug 2011 07:13:58 +0100 (BST) Received: from mcdsrvbld02.digital.local (unknown [106.116.37.23]) by linux.samsung.com (Postfix) with ESMTP id 08004270003; Tue, 23 Aug 2011 08:14:28 +0200 (CEST) Date: Tue, 23 Aug 2011 08:13:54 +0200 From: Lukasz Majewski In-reply-to: <1313137442-8378-1-git-send-email-l.majewski@samsung.com> To: u-boot@lists.denx.de Message-id: <1314080034-31277-1-git-send-email-l.majewski@samsung.com> MIME-version: 1.0 X-Mailer: git-send-email 1.7.5.4 References: <1313137442-8378-1-git-send-email-l.majewski@samsung.com> Cc: Kyungmin Park , m.szyprowski@samsung.com Subject: [U-Boot] =?utf-8?q?_=5BPATCH_v4=5D_dcache=3A_D_cache_line_size_re?= =?utf-8?q?ad_method?= X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de The get_dcache_line_size() function is supposed to work in conjunction with memalign call to provide D cache aligned DMA buffers. This commit adds support for reading the D cache line size for armv7 architecture. Moreover a default implementation of get_dcache_line_size() is provided. Signed-off-by: Lukasz Majewski Signed-off-by: Kyungmin Park CC: Aneesh V CC: Albert ARIBAUD --- Changes for v2: - Weak function get_dcache_line_size added to arch/arm/lib/cache.c Changes for v3: - __BIGGEST_ALIGNMENT__ GCC constant added Changes for v4: - Weak function get_dcache_line_size added to arch/arm/lib/cache.c for non armv7 architectures --- arch/arm/cpu/armv7/cache_v7.c | 14 ++++++++++++++ include/common.h | 1 + lib/Makefile | 1 + lib/cache.c | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 0 deletions(-) create mode 100644 lib/cache.c 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/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); diff --git a/lib/Makefile b/lib/Makefile index 884f64c..c0070c2 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -49,6 +49,7 @@ COBJS-$(CONFIG_SHA1) += sha1.o COBJS-$(CONFIG_SHA256) += sha256.o COBJS-y += strmhz.o COBJS-$(CONFIG_RBTREE) += rbtree.o +COBJS-y += cache.o endif COBJS-y += ctype.o diff --git a/lib/cache.c b/lib/cache.c new file mode 100644 index 0000000..b8f49ce --- /dev/null +++ b/lib/cache.c @@ -0,0 +1,34 @@ +/* + * (C) Copyright 2011 SAMSUNG Electronics + * Ɓukasz Majewski + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include + +/* Read the default Data 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 + return __BIGGEST_ALIGNMENT__; /* Constant defined by GCC compiler */ +#endif +}