diff options
author | Tony Lindgren <tony@atomide.com> | 2011-10-04 16:52:57 -0400 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2011-10-19 19:34:10 -0400 |
commit | a66cb3454f220f49f900646ebdc76cb943319eb7 (patch) | |
tree | bc5f79989a037e3b3d0b067bc9cac9868291b490 /arch/arm/plat-omap/sram.c | |
parent | fee926bb0d399b1eaaf38f9f694bbf2747c4b8a2 (diff) |
ARM: OMAP: Map SRAM later on with ioremap_exec()
This allows us to remove omap hacks for map_io.
Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Tested-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/plat-omap/sram.c')
-rw-r--r-- | arch/arm/plat-omap/sram.c | 69 |
1 files changed, 20 insertions, 49 deletions
diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c index 3c8aa44f14da..8b28664d1c62 100644 --- a/arch/arm/plat-omap/sram.c +++ b/arch/arm/plat-omap/sram.c | |||
@@ -38,16 +38,9 @@ | |||
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #define OMAP1_SRAM_PA 0x20000000 | 40 | #define OMAP1_SRAM_PA 0x20000000 |
41 | #define OMAP1_SRAM_VA VMALLOC_END | ||
42 | #define OMAP2_SRAM_PUB_PA (OMAP2_SRAM_PA + 0xf800) | 41 | #define OMAP2_SRAM_PUB_PA (OMAP2_SRAM_PA + 0xf800) |
43 | #define OMAP2_SRAM_VA 0xfe400000 | ||
44 | #define OMAP2_SRAM_PUB_VA (OMAP2_SRAM_VA + 0x800) | ||
45 | #define OMAP3_SRAM_VA 0xfe400000 | ||
46 | #define OMAP3_SRAM_PUB_PA (OMAP3_SRAM_PA + 0x8000) | 42 | #define OMAP3_SRAM_PUB_PA (OMAP3_SRAM_PA + 0x8000) |
47 | #define OMAP3_SRAM_PUB_VA (OMAP3_SRAM_VA + 0x8000) | ||
48 | #define OMAP4_SRAM_VA 0xfe400000 | ||
49 | #define OMAP4_SRAM_PUB_PA (OMAP4_SRAM_PA + 0x4000) | 43 | #define OMAP4_SRAM_PUB_PA (OMAP4_SRAM_PA + 0x4000) |
50 | #define OMAP4_SRAM_PUB_VA (OMAP4_SRAM_VA + 0x4000) | ||
51 | 44 | ||
52 | #if defined(CONFIG_ARCH_OMAP2PLUS) | 45 | #if defined(CONFIG_ARCH_OMAP2PLUS) |
53 | #define SRAM_BOOTLOADER_SZ 0x00 | 46 | #define SRAM_BOOTLOADER_SZ 0x00 |
@@ -70,9 +63,9 @@ | |||
70 | #define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1))) | 63 | #define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1))) |
71 | 64 | ||
72 | static unsigned long omap_sram_start; | 65 | static unsigned long omap_sram_start; |
73 | static unsigned long omap_sram_base; | 66 | static void __iomem *omap_sram_base; |
74 | static unsigned long omap_sram_size; | 67 | static unsigned long omap_sram_size; |
75 | static unsigned long omap_sram_ceil; | 68 | static void __iomem *omap_sram_ceil; |
76 | 69 | ||
77 | /* | 70 | /* |
78 | * 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,7 +105,6 @@ static void __init omap_detect_sram(void) | |||
112 | if (cpu_class_is_omap2()) { | 105 | if (cpu_class_is_omap2()) { |
113 | if (is_sram_locked()) { | 106 | if (is_sram_locked()) { |
114 | if (cpu_is_omap34xx()) { | 107 | if (cpu_is_omap34xx()) { |
115 | omap_sram_base = OMAP3_SRAM_PUB_VA; | ||
116 | omap_sram_start = OMAP3_SRAM_PUB_PA; | 108 | omap_sram_start = OMAP3_SRAM_PUB_PA; |
117 | if ((omap_type() == OMAP2_DEVICE_TYPE_EMU) || | 109 | if ((omap_type() == OMAP2_DEVICE_TYPE_EMU) || |
118 | (omap_type() == OMAP2_DEVICE_TYPE_SEC)) { | 110 | (omap_type() == OMAP2_DEVICE_TYPE_SEC)) { |
@@ -121,25 +113,20 @@ static void __init omap_detect_sram(void) | |||
121 | omap_sram_size = 0x8000; /* 32K */ | 113 | omap_sram_size = 0x8000; /* 32K */ |
122 | } | 114 | } |
123 | } else if (cpu_is_omap44xx()) { | 115 | } else if (cpu_is_omap44xx()) { |
124 | omap_sram_base = OMAP4_SRAM_PUB_VA; | ||
125 | omap_sram_start = OMAP4_SRAM_PUB_PA; | 116 | omap_sram_start = OMAP4_SRAM_PUB_PA; |
126 | omap_sram_size = 0xa000; /* 40K */ | 117 | omap_sram_size = 0xa000; /* 40K */ |
127 | } else { | 118 | } else { |
128 | omap_sram_base = OMAP2_SRAM_PUB_VA; | ||
129 | omap_sram_start = OMAP2_SRAM_PUB_PA; | 119 | omap_sram_start = OMAP2_SRAM_PUB_PA; |
130 | omap_sram_size = 0x800; /* 2K */ | 120 | omap_sram_size = 0x800; /* 2K */ |
131 | } | 121 | } |
132 | } else { | 122 | } else { |
133 | if (cpu_is_omap34xx()) { | 123 | if (cpu_is_omap34xx()) { |
134 | omap_sram_base = OMAP3_SRAM_VA; | ||
135 | omap_sram_start = OMAP3_SRAM_PA; | 124 | omap_sram_start = OMAP3_SRAM_PA; |
136 | omap_sram_size = 0x10000; /* 64K */ | 125 | omap_sram_size = 0x10000; /* 64K */ |
137 | } else if (cpu_is_omap44xx()) { | 126 | } else if (cpu_is_omap44xx()) { |
138 | omap_sram_base = OMAP4_SRAM_VA; | ||
139 | omap_sram_start = OMAP4_SRAM_PA; | 127 | omap_sram_start = OMAP4_SRAM_PA; |
140 | omap_sram_size = 0xe000; /* 56K */ | 128 | omap_sram_size = 0xe000; /* 56K */ |
141 | } else { | 129 | } else { |
142 | omap_sram_base = OMAP2_SRAM_VA; | ||
143 | omap_sram_start = OMAP2_SRAM_PA; | 130 | omap_sram_start = OMAP2_SRAM_PA; |
144 | if (cpu_is_omap242x()) | 131 | if (cpu_is_omap242x()) |
145 | omap_sram_size = 0xa0000; /* 640K */ | 132 | omap_sram_size = 0xa0000; /* 640K */ |
@@ -148,7 +135,6 @@ static void __init omap_detect_sram(void) | |||
148 | } | 135 | } |
149 | } | 136 | } |
150 | } else { | 137 | } else { |
151 | omap_sram_base = OMAP1_SRAM_VA; | ||
152 | omap_sram_start = OMAP1_SRAM_PA; | 138 | omap_sram_start = OMAP1_SRAM_PA; |
153 | 139 | ||
154 | if (cpu_is_omap7xx()) | 140 | if (cpu_is_omap7xx()) |
@@ -165,24 +151,14 @@ static void __init omap_detect_sram(void) | |||
165 | omap_sram_size = 0x4000; | 151 | omap_sram_size = 0x4000; |
166 | } | 152 | } |
167 | } | 153 | } |
168 | |||
169 | omap_sram_ceil = omap_sram_base + omap_sram_size; | ||
170 | } | 154 | } |
171 | 155 | ||
172 | static struct map_desc omap_sram_io_desc[] __initdata = { | ||
173 | { /* .length gets filled in at runtime */ | ||
174 | .virtual = OMAP1_SRAM_VA, | ||
175 | .pfn = __phys_to_pfn(OMAP1_SRAM_PA), | ||
176 | .type = MT_MEMORY | ||
177 | } | ||
178 | }; | ||
179 | |||
180 | /* | 156 | /* |
181 | * 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. |
182 | */ | 158 | */ |
183 | static void __init omap_map_sram(void) | 159 | static void __init omap_map_sram(void) |
184 | { | 160 | { |
185 | unsigned long base; | 161 | int cached = 1; |
186 | 162 | ||
187 | if (omap_sram_size == 0) | 163 | if (omap_sram_size == 0) |
188 | return; | 164 | return; |
@@ -195,28 +171,18 @@ static void __init omap_map_sram(void) | |||
195 | * the ARM may attempt to write cache lines back to SDRAM | 171 | * the ARM may attempt to write cache lines back to SDRAM |
196 | * which will cause the system to hang. | 172 | * which will cause the system to hang. |
197 | */ | 173 | */ |
198 | omap_sram_io_desc[0].type = MT_MEMORY_NONCACHED; | 174 | cached = 0; |
199 | } | 175 | } |
200 | 176 | ||
201 | omap_sram_io_desc[0].virtual = omap_sram_base; | 177 | omap_sram_start = ROUND_DOWN(omap_sram_start, PAGE_SIZE); |
202 | base = omap_sram_start; | 178 | omap_sram_base = __arm_ioremap_exec(omap_sram_start, omap_sram_size, |
203 | base = ROUND_DOWN(base, PAGE_SIZE); | 179 | cached); |
204 | omap_sram_io_desc[0].pfn = __phys_to_pfn(base); | 180 | if (!omap_sram_base) { |
205 | omap_sram_io_desc[0].length = ROUND_DOWN(omap_sram_size, PAGE_SIZE); | 181 | pr_err("SRAM: Could not map\n"); |
206 | iotable_init(omap_sram_io_desc, ARRAY_SIZE(omap_sram_io_desc)); | 182 | return; |
207 | 183 | } | |
208 | pr_info("SRAM: Mapped pa 0x%08llx to va 0x%08lx size: 0x%lx\n", | ||
209 | (long long) __pfn_to_phys(omap_sram_io_desc[0].pfn), | ||
210 | omap_sram_io_desc[0].virtual, | ||
211 | omap_sram_io_desc[0].length); | ||
212 | 184 | ||
213 | /* | 185 | omap_sram_ceil = omap_sram_base + omap_sram_size; |
214 | * Normally devicemaps_init() would flush caches and tlb after | ||
215 | * mdesc->map_io(), but since we're called from map_io(), we | ||
216 | * must do it here. | ||
217 | */ | ||
218 | local_flush_tlb_all(); | ||
219 | flush_cache_all(); | ||
220 | 186 | ||
221 | /* | 187 | /* |
222 | * Looks like we need to preserve some bootloader code at the | 188 | * Looks like we need to preserve some bootloader code at the |
@@ -235,13 +201,18 @@ static void __init omap_map_sram(void) | |||
235 | */ | 201 | */ |
236 | void *omap_sram_push_address(unsigned long size) | 202 | void *omap_sram_push_address(unsigned long size) |
237 | { | 203 | { |
238 | 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) { | ||
239 | pr_err("Not enough space in SRAM\n"); | 209 | pr_err("Not enough space in SRAM\n"); |
240 | return NULL; | 210 | return NULL; |
241 | } | 211 | } |
242 | 212 | ||
243 | omap_sram_ceil -= size; | 213 | new_ceil -= size; |
244 | 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); | ||
245 | 216 | ||
246 | return (void *)omap_sram_ceil; | 217 | return (void *)omap_sram_ceil; |
247 | } | 218 | } |