From patchwork Tue Oct 30 23:52:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 1674641 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 520E3DFB7B for ; Tue, 30 Oct 2012 23:54:54 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TTLcU-0005eC-14; Tue, 30 Oct 2012 23:53:18 +0000 Received: from mho-04-ewr.mailhop.org ([204.13.248.74] helo=mho-02-ewr.mailhop.org) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TTLbz-0005Zd-0X for linux-arm-kernel@lists.infradead.org; Tue, 30 Oct 2012 23:52:48 +0000 Received: from c-98-234-237-12.hsd1.ca.comcast.net ([98.234.237.12] helo=muffinssi.local) by mho-02-ewr.mailhop.org with esmtpa (Exim 4.72) (envelope-from ) id 1TTLbx-00087z-Sx; Tue, 30 Oct 2012 23:52:45 +0000 X-Mail-Handler: Dyn Standard SMTP by Dyn X-Originating-IP: 98.234.237.12 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/sendlabs/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX18TZuzdcmkW42SSkvc/+fxO Subject: [PATCH 02/11] ARM: OMAP: Introduce common omap_map_sram() and omap_sram_reset() To: linux-arm-kernel@lists.infradead.org From: Tony Lindgren Date: Tue, 30 Oct 2012 16:52:43 -0700 Message-ID: <20121030235243.25936.30078.stgit@muffinssi.local> In-Reply-To: <20121030234852.25936.12482.stgit@muffinssi.local> References: <20121030234852.25936.12482.stgit@muffinssi.local> User-Agent: StGit/0.16-2-g0d85 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121030_195247_133157_80087409 X-CRM114-Status: GOOD ( 16.59 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [204.13.248.74 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linux-omap@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This will allow us to separate out omap1 and omap2+ specific code in the later patches. Signed-off-by: Tony Lindgren --- arch/arm/plat-omap/include/plat/sram.h | 4 ++ arch/arm/plat-omap/sram.c | 64 +++++++++++++++++++++----------- 2 files changed, 46 insertions(+), 22 deletions(-) diff --git a/arch/arm/plat-omap/include/plat/sram.h b/arch/arm/plat-omap/include/plat/sram.h index c60025a..ba45250 100644 --- a/arch/arm/plat-omap/include/plat/sram.h +++ b/arch/arm/plat-omap/include/plat/sram.h @@ -1,5 +1,9 @@ int omap_sram_init(void); +void omap_map_sram(unsigned long start, unsigned long size, + unsigned long skip, int cached); +void omap_sram_reset(void); + extern void *omap_sram_push_address(unsigned long size); /* Macro to push a function to the internal SRAM, using the fncpy API */ diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c index 3372929..aa2644a 100644 --- a/arch/arm/plat-omap/sram.c +++ b/arch/arm/plat-omap/sram.c @@ -170,13 +170,10 @@ static void __init omap_detect_sram(void) /* * Note that we cannot use ioremap for SRAM, as clock init needs SRAM early. */ -static void __init omap_map_sram(void) +static void __init omap_fix_and_map_sram(void) { int cached = 1; - if (omap_sram_size == 0) - return; - #ifdef CONFIG_OMAP4_ERRATA_I688 if (cpu_is_omap44xx()) { omap_sram_start += PAGE_SIZE; @@ -194,22 +191,8 @@ static void __init omap_map_sram(void) cached = 0; } - omap_sram_start = ROUND_DOWN(omap_sram_start, PAGE_SIZE); - omap_sram_base = __arm_ioremap_exec(omap_sram_start, omap_sram_size, - cached); - if (!omap_sram_base) { - pr_err("SRAM: Could not map\n"); - return; - } - - omap_sram_ceil = omap_sram_base + omap_sram_size; - - /* - * Looks like we need to preserve some bootloader code at the - * beginning of SRAM for jumping to flash for reboot to work... - */ - memset_io(omap_sram_base + omap_sram_skip, 0, - omap_sram_size - omap_sram_skip); + omap_map_sram(omap_sram_start, omap_sram_size, + omap_sram_skip, cached); } /* @@ -237,6 +220,43 @@ void *omap_sram_push_address(unsigned long size) return (void *)omap_sram_ceil; } +/* + * The SRAM context is lost during off-idle and stack + * needs to be reset. + */ +void omap_sram_reset(void) +{ + omap_sram_ceil = omap_sram_base + omap_sram_size; +} + +/* + * Note that we cannot use ioremap for SRAM, as clock init needs SRAM early. + */ +void __init omap_map_sram(unsigned long start, unsigned long size, + unsigned long skip, int cached) +{ + if (size == 0) + return; + + start = ROUND_DOWN(start, PAGE_SIZE); + omap_sram_size = size; + omap_sram_skip = skip; + omap_sram_base = __arm_ioremap_exec(start, size, cached); + if (!omap_sram_base) { + pr_err("SRAM: Could not map\n"); + return; + } + + omap_sram_reset(); + + /* + * Looks like we need to preserve some bootloader code at the + * beginning of SRAM for jumping to flash for reboot to work... + */ + memset_io(omap_sram_base + omap_sram_skip, 0, + omap_sram_size - omap_sram_skip); +} + #ifdef CONFIG_ARCH_OMAP1 static void (*_omap_sram_reprogram_clock)(u32 dpllctl, u32 ckctl); @@ -362,7 +382,7 @@ u32 omap3_configure_core_dpll(u32 m2, u32 unlock_dll, u32 f, u32 inc, void omap3_sram_restore_context(void) { - omap_sram_ceil = omap_sram_base + omap_sram_size; + omap_sram_reset(); _omap3_sram_configure_core_dpll = omap_sram_push(omap3_sram_configure_core_dpll, @@ -390,7 +410,7 @@ static inline int am33xx_sram_init(void) int __init omap_sram_init(void) { omap_detect_sram(); - omap_map_sram(); + omap_fix_and_map_sram(); if (!(cpu_class_is_omap2())) omap1_sram_init();