···11+/*22+ * OMAP SRAM detection and management33+ *44+ * Copyright (C) 2005 Nokia Corporation55+ * Written by Tony Lindgren <tony@atomide.com>66+ *77+ * This program is free software; you can redistribute it and/or modify88+ * it under the terms of the GNU General Public License version 2 as99+ * published by the Free Software Foundation.1010+ */1111+1212+#include <linux/module.h>1313+#include <linux/kernel.h>1414+#include <linux/init.h>1515+#include <linux/io.h>1616+1717+#include <asm/fncpy.h>1818+#include <asm/tlb.h>1919+#include <asm/cacheflush.h>2020+2121+#include <asm/mach/map.h>2222+2323+#include "soc.h"2424+#include "sram.h"2525+2626+#define OMAP1_SRAM_PA 0x200000002727+#define SRAM_BOOTLOADER_SZ 0x802828+2929+/*3030+ * The amount of SRAM depends on the core type.3131+ * Note that we cannot try to test for SRAM here because writes3232+ * to secure SRAM will hang the system. Also the SRAM is not3333+ * yet mapped at this point.3434+ */3535+static void __init omap_detect_and_map_sram(void)3636+{3737+ unsigned long omap_sram_skip = SRAM_BOOTLOADER_SZ;3838+ unsigned long omap_sram_start = OMAP1_SRAM_PA;3939+ unsigned long omap_sram_size;4040+4141+ if (cpu_is_omap7xx())4242+ omap_sram_size = 0x32000; /* 200K */4343+ else if (cpu_is_omap15xx())4444+ omap_sram_size = 0x30000; /* 192K */4545+ else if (cpu_is_omap1610() || cpu_is_omap1611() ||4646+ cpu_is_omap1621() || cpu_is_omap1710())4747+ omap_sram_size = 0x4000; /* 16K */4848+ else {4949+ pr_err("Could not detect SRAM size\n");5050+ omap_sram_size = 0x4000;5151+ }5252+5353+ omap_map_sram(omap_sram_start, omap_sram_size,5454+ omap_sram_skip, 1);5555+}5656+5757+static void (*_omap_sram_reprogram_clock)(u32 dpllctl, u32 ckctl);5858+5959+void omap_sram_reprogram_clock(u32 dpllctl, u32 ckctl)6060+{6161+ BUG_ON(!_omap_sram_reprogram_clock);6262+ /* On 730, bit 13 must always be 1 */6363+ if (cpu_is_omap7xx())6464+ ckctl |= 0x2000;6565+ _omap_sram_reprogram_clock(dpllctl, ckctl);6666+}6767+6868+int __init omap_sram_init(void)6969+{7070+ omap_detect_and_map_sram();7171+ _omap_sram_reprogram_clock =7272+ omap_sram_push(omap1_sram_reprogram_clock,7373+ omap1_sram_reprogram_clock_sz);7474+7575+ return 0;7676+}
+3-46
arch/arm/plat-omap/sram.c
···26262727#include <asm/mach/map.h>28282929-#include "../mach-omap1/soc.h"3030-#include "../mach-omap1/sram.h"3129#include "../mach-omap2/soc.h"3230#include "../mach-omap2/sram.h"3331···3436#include "../mach-omap2/prm2xxx_3xxx.h"3537#include "../mach-omap2/sdrc.h"36383737-#define OMAP1_SRAM_PA 0x200000003839#define OMAP2_SRAM_PUB_PA (OMAP2_SRAM_PA + 0xf800)3940#define OMAP3_SRAM_PUB_PA (OMAP3_SRAM_PA + 0x8000)4041#ifdef CONFIG_OMAP4_ERRATA_I688···147150 omap_sram_size = 0x10000; /* 64K */148151 }149152 }150150- } else {151151- omap_sram_start = OMAP1_SRAM_PA;152152-153153- if (cpu_is_omap7xx())154154- omap_sram_size = 0x32000; /* 200K */155155- else if (cpu_is_omap15xx())156156- omap_sram_size = 0x30000; /* 192K */157157- else if (cpu_is_omap1610() || cpu_is_omap1611() ||158158- cpu_is_omap1621() || cpu_is_omap1710())159159- omap_sram_size = 0x4000; /* 16K */160160- else {161161- pr_err("Could not detect SRAM size\n");162162- omap_sram_size = 0x4000;163163- }164153 }165154}166155···239256 memset_io(omap_sram_base + omap_sram_skip, 0,240257 omap_sram_size - omap_sram_skip);241258}242242-243243-#ifdef CONFIG_ARCH_OMAP1244244-245245-static void (*_omap_sram_reprogram_clock)(u32 dpllctl, u32 ckctl);246246-247247-void omap_sram_reprogram_clock(u32 dpllctl, u32 ckctl)248248-{249249- BUG_ON(!_omap_sram_reprogram_clock);250250- /* On 730, bit 13 must always be 1 */251251- if (cpu_is_omap7xx())252252- ckctl |= 0x2000;253253- _omap_sram_reprogram_clock(dpllctl, ckctl);254254-}255255-256256-static int __init omap1_sram_init(void)257257-{258258- _omap_sram_reprogram_clock =259259- omap_sram_push(omap1_sram_reprogram_clock,260260- omap1_sram_reprogram_clock_sz);261261-262262- return 0;263263-}264264-265265-#else266266-#define omap1_sram_init() do {} while (0)267267-#endif268259269260#if defined(CONFIG_ARCH_OMAP2)270261···364407 return 0;365408}366409410410+#ifdef CONFIG_ARCH_OMAP2PLUS367411int __init omap_sram_init(void)368412{369413 omap_detect_sram();370414 omap_fix_and_map_sram();371415372372- if (!(cpu_class_is_omap2()))373373- omap1_sram_init();374374- else if (cpu_is_omap242x())416416+ if (cpu_is_omap242x())375417 omap242x_sram_init();376418 else if (cpu_is_omap2430())377419 omap243x_sram_init();···381425382426 return 0;383427}428428+#endif