aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-omap/sram.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/plat-omap/sram.c')
-rw-r--r--arch/arm/plat-omap/sram.c85
1 files changed, 20 insertions, 65 deletions
diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
index 363c91e44efb..8b28664d1c62 100644
--- a/arch/arm/plat-omap/sram.c
+++ b/arch/arm/plat-omap/sram.c
@@ -19,7 +19,6 @@
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/omapfb.h>
23 22
24#include <asm/tlb.h> 23#include <asm/tlb.h>
25#include <asm/cacheflush.h> 24#include <asm/cacheflush.h>
@@ -29,10 +28,8 @@
29#include <plat/sram.h> 28#include <plat/sram.h>
30#include <plat/board.h> 29#include <plat/board.h>
31#include <plat/cpu.h> 30#include <plat/cpu.h>
32#include <plat/vram.h>
33 31
34#include "sram.h" 32#include "sram.h"
35#include "fb.h"
36 33
37/* XXX These "sideways" includes are a sign that something is wrong */ 34/* XXX These "sideways" includes are a sign that something is wrong */
38#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) 35#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
@@ -41,16 +38,9 @@
41#endif 38#endif
42 39
43#define OMAP1_SRAM_PA 0x20000000 40#define OMAP1_SRAM_PA 0x20000000
44#define OMAP1_SRAM_VA VMALLOC_END
45#define OMAP2_SRAM_PUB_PA (OMAP2_SRAM_PA + 0xf800) 41#define OMAP2_SRAM_PUB_PA (OMAP2_SRAM_PA + 0xf800)
46#define OMAP2_SRAM_VA 0xfe400000
47#define OMAP2_SRAM_PUB_VA (OMAP2_SRAM_VA + 0x800)
48#define OMAP3_SRAM_VA 0xfe400000
49#define OMAP3_SRAM_PUB_PA (OMAP3_SRAM_PA + 0x8000) 42#define OMAP3_SRAM_PUB_PA (OMAP3_SRAM_PA + 0x8000)
50#define OMAP3_SRAM_PUB_VA (OMAP3_SRAM_VA + 0x8000)
51#define OMAP4_SRAM_VA 0xfe400000
52#define OMAP4_SRAM_PUB_PA (OMAP4_SRAM_PA + 0x4000) 43#define OMAP4_SRAM_PUB_PA (OMAP4_SRAM_PA + 0x4000)
53#define OMAP4_SRAM_PUB_VA (OMAP4_SRAM_VA + 0x4000)
54 44
55#if defined(CONFIG_ARCH_OMAP2PLUS) 45#if defined(CONFIG_ARCH_OMAP2PLUS)
56#define SRAM_BOOTLOADER_SZ 0x00 46#define SRAM_BOOTLOADER_SZ 0x00
@@ -73,9 +63,9 @@
73#define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1))) 63#define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1)))
74 64
75static unsigned long omap_sram_start; 65static unsigned long omap_sram_start;
76static unsigned long omap_sram_base; 66static void __iomem *omap_sram_base;
77static unsigned long omap_sram_size; 67static unsigned long omap_sram_size;
78static unsigned long omap_sram_ceil; 68static void __iomem *omap_sram_ceil;
79 69
80/* 70/*
81 * Depending on the target RAMFS firewall setup, the public usable amount of 71 * Depending on the target RAMFS firewall setup, the public usable amount of
@@ -112,12 +102,9 @@ static int is_sram_locked(void)
112 */ 102 */
113static void __init omap_detect_sram(void) 103static void __init omap_detect_sram(void)
114{ 104{
115 unsigned long reserved;
116
117 if (cpu_class_is_omap2()) { 105 if (cpu_class_is_omap2()) {
118 if (is_sram_locked()) { 106 if (is_sram_locked()) {
119 if (cpu_is_omap34xx()) { 107 if (cpu_is_omap34xx()) {
120 omap_sram_base = OMAP3_SRAM_PUB_VA;
121 omap_sram_start = OMAP3_SRAM_PUB_PA; 108 omap_sram_start = OMAP3_SRAM_PUB_PA;
122 if ((omap_type() == OMAP2_DEVICE_TYPE_EMU) || 109 if ((omap_type() == OMAP2_DEVICE_TYPE_EMU) ||
123 (omap_type() == OMAP2_DEVICE_TYPE_SEC)) { 110 (omap_type() == OMAP2_DEVICE_TYPE_SEC)) {
@@ -126,25 +113,20 @@ static void __init omap_detect_sram(void)
126 omap_sram_size = 0x8000; /* 32K */ 113 omap_sram_size = 0x8000; /* 32K */
127 } 114 }
128 } else if (cpu_is_omap44xx()) { 115 } else if (cpu_is_omap44xx()) {
129 omap_sram_base = OMAP4_SRAM_PUB_VA;
130 omap_sram_start = OMAP4_SRAM_PUB_PA; 116 omap_sram_start = OMAP4_SRAM_PUB_PA;
131 omap_sram_size = 0xa000; /* 40K */ 117 omap_sram_size = 0xa000; /* 40K */
132 } else { 118 } else {
133 omap_sram_base = OMAP2_SRAM_PUB_VA;
134 omap_sram_start = OMAP2_SRAM_PUB_PA; 119 omap_sram_start = OMAP2_SRAM_PUB_PA;
135 omap_sram_size = 0x800; /* 2K */ 120 omap_sram_size = 0x800; /* 2K */
136 } 121 }
137 } else { 122 } else {
138 if (cpu_is_omap34xx()) { 123 if (cpu_is_omap34xx()) {
139 omap_sram_base = OMAP3_SRAM_VA;
140 omap_sram_start = OMAP3_SRAM_PA; 124 omap_sram_start = OMAP3_SRAM_PA;
141 omap_sram_size = 0x10000; /* 64K */ 125 omap_sram_size = 0x10000; /* 64K */
142 } else if (cpu_is_omap44xx()) { 126 } else if (cpu_is_omap44xx()) {
143 omap_sram_base = OMAP4_SRAM_VA;
144 omap_sram_start = OMAP4_SRAM_PA; 127 omap_sram_start = OMAP4_SRAM_PA;
145 omap_sram_size = 0xe000; /* 56K */ 128 omap_sram_size = 0xe000; /* 56K */
146 } else { 129 } else {
147 omap_sram_base = OMAP2_SRAM_VA;
148 omap_sram_start = OMAP2_SRAM_PA; 130 omap_sram_start = OMAP2_SRAM_PA;
149 if (cpu_is_omap242x()) 131 if (cpu_is_omap242x())
150 omap_sram_size = 0xa0000; /* 640K */ 132 omap_sram_size = 0xa0000; /* 640K */
@@ -153,7 +135,6 @@ static void __init omap_detect_sram(void)
153 } 135 }
154 } 136 }
155 } else { 137 } else {
156 omap_sram_base = OMAP1_SRAM_VA;
157 omap_sram_start = OMAP1_SRAM_PA; 138 omap_sram_start = OMAP1_SRAM_PA;
158 139
159 if (cpu_is_omap7xx()) 140 if (cpu_is_omap7xx())
@@ -170,35 +151,14 @@ static void __init omap_detect_sram(void)
170 omap_sram_size = 0x4000; 151 omap_sram_size = 0x4000;
171 } 152 }
172 } 153 }
173 reserved = omapfb_reserve_sram(omap_sram_start, omap_sram_base,
174 omap_sram_size,
175 omap_sram_start + SRAM_BOOTLOADER_SZ,
176 omap_sram_size - SRAM_BOOTLOADER_SZ);
177 omap_sram_size -= reserved;
178
179 reserved = omap_vram_reserve_sram(omap_sram_start, omap_sram_base,
180 omap_sram_size,
181 omap_sram_start + SRAM_BOOTLOADER_SZ,
182 omap_sram_size - SRAM_BOOTLOADER_SZ);
183 omap_sram_size -= reserved;
184
185 omap_sram_ceil = omap_sram_base + omap_sram_size;
186} 154}
187 155
188static struct map_desc omap_sram_io_desc[] __initdata = {
189 { /* .length gets filled in at runtime */
190 .virtual = OMAP1_SRAM_VA,
191 .pfn = __phys_to_pfn(OMAP1_SRAM_PA),
192 .type = MT_MEMORY
193 }
194};
195
196/* 156/*
197 * Note that we cannot use ioremap for SRAM, as clock init needs SRAM early. 157 * Note that we cannot use ioremap for SRAM, as clock init needs SRAM early.
198 */ 158 */
199static void __init omap_map_sram(void) 159static void __init omap_map_sram(void)
200{ 160{
201 unsigned long base; 161 int cached = 1;
202 162
203 if (omap_sram_size == 0) 163 if (omap_sram_size == 0)
204 return; 164 return;
@@ -211,28 +171,18 @@ static void __init omap_map_sram(void)
211 * the ARM may attempt to write cache lines back to SDRAM 171 * the ARM may attempt to write cache lines back to SDRAM
212 * which will cause the system to hang. 172 * which will cause the system to hang.
213 */ 173 */
214 omap_sram_io_desc[0].type = MT_MEMORY_NONCACHED; 174 cached = 0;
215 } 175 }
216 176
217 omap_sram_io_desc[0].virtual = omap_sram_base; 177 omap_sram_start = ROUND_DOWN(omap_sram_start, PAGE_SIZE);
218 base = omap_sram_start; 178 omap_sram_base = __arm_ioremap_exec(omap_sram_start, omap_sram_size,
219 base = ROUND_DOWN(base, PAGE_SIZE); 179 cached);
220 omap_sram_io_desc[0].pfn = __phys_to_pfn(base); 180 if (!omap_sram_base) {
221 omap_sram_io_desc[0].length = ROUND_DOWN(omap_sram_size, PAGE_SIZE); 181 pr_err("SRAM: Could not map\n");
222 iotable_init(omap_sram_io_desc, ARRAY_SIZE(omap_sram_io_desc)); 182 return;
223 183 }
224 pr_info("SRAM: Mapped pa 0x%08llx to va 0x%08lx size: 0x%lx\n",
225 (long long) __pfn_to_phys(omap_sram_io_desc[0].pfn),
226 omap_sram_io_desc[0].virtual,
227 omap_sram_io_desc[0].length);
228 184
229 /* 185 omap_sram_ceil = omap_sram_base + omap_sram_size;
230 * Normally devicemaps_init() would flush caches and tlb after
231 * mdesc->map_io(), but since we're called from map_io(), we
232 * must do it here.
233 */
234 local_flush_tlb_all();
235 flush_cache_all();
236 186
237 /* 187 /*
238 * Looks like we need to preserve some bootloader code at the 188 * Looks like we need to preserve some bootloader code at the
@@ -251,13 +201,18 @@ static void __init omap_map_sram(void)
251 */ 201 */
252void *omap_sram_push_address(unsigned long size) 202void *omap_sram_push_address(unsigned long size)
253{ 203{
254 if (size > (omap_sram_ceil - (omap_sram_base + SRAM_BOOTLOADER_SZ))) { 204 unsigned long available, new_ceil = (unsigned long)omap_sram_ceil;
205
206 available = omap_sram_ceil - (omap_sram_base + SRAM_BOOTLOADER_SZ);
207
208 if (size > available) {
255 pr_err("Not enough space in SRAM\n"); 209 pr_err("Not enough space in SRAM\n");
256 return NULL; 210 return NULL;
257 } 211 }
258 212
259 omap_sram_ceil -= size; 213 new_ceil -= size;
260 omap_sram_ceil = ROUND_DOWN(omap_sram_ceil, FNCPY_ALIGN); 214 new_ceil = ROUND_DOWN(new_ceil, FNCPY_ALIGN);
215 omap_sram_ceil = IOMEM(new_ceil);
261 216
262 return (void *)omap_sram_ceil; 217 return (void *)omap_sram_ceil;
263} 218}