Skip to content

Commit a66cb34

Browse files
committed
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>
1 parent fee926b commit a66cb34

File tree

6 files changed

+28
-76
lines changed

6 files changed

+28
-76
lines changed

arch/arm/mach-omap1/devices.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <mach/hardware.h>
2222
#include <asm/mach/map.h>
2323

24+
#include <plat/common.h>
2425
#include <plat/tc.h>
2526
#include <plat/board.h>
2627
#include <plat/mux.h>
@@ -291,6 +292,8 @@ static int __init omap1_init_devices(void)
291292
if (!cpu_class_is_omap1())
292293
return -ENODEV;
293294

295+
omap_sram_init();
296+
294297
/* please keep these calls, and their implementations above,
295298
* in alphabetical order so they're easier to sort through.
296299
*/

arch/arm/mach-omap1/io.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "clock.h"
2222

2323
extern void omap_check_revision(void);
24-
extern void omap_sram_init(void);
2524

2625
/*
2726
* The machine specific code may provide the extra mapping besides the
@@ -133,7 +132,6 @@ void omap1_init_early(void)
133132
*/
134133
omap1_clk_init();
135134
omap1_mux_init();
136-
omap_sram_init();
137135
}
138136

139137
/*

arch/arm/mach-omap2/io.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
#include "clock2xxx.h"
3636
#include "clock3xxx.h"
3737
#include "clock44xx.h"
38-
#include "io.h"
3938

39+
#include <plat/common.h>
4040
#include <plat/omap-pm.h>
4141
#include "voltage.h"
4242
#include "powerdomain.h"
@@ -240,22 +240,11 @@ static struct map_desc omap44xx_io_desc[] __initdata = {
240240
};
241241
#endif
242242

243-
static void __init _omap2_map_common_io(void)
244-
{
245-
/* Normally devicemaps_init() would flush caches and tlb after
246-
* mdesc->map_io(), but we must also do it here because of the CPU
247-
* revision check below.
248-
*/
249-
local_flush_tlb_all();
250-
flush_cache_all();
251-
}
252-
253243
#ifdef CONFIG_SOC_OMAP2420
254244
void __init omap242x_map_common_io(void)
255245
{
256246
iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc));
257247
iotable_init(omap242x_io_desc, ARRAY_SIZE(omap242x_io_desc));
258-
_omap2_map_common_io();
259248
}
260249
#endif
261250

@@ -264,31 +253,27 @@ void __init omap243x_map_common_io(void)
264253
{
265254
iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc));
266255
iotable_init(omap243x_io_desc, ARRAY_SIZE(omap243x_io_desc));
267-
_omap2_map_common_io();
268256
}
269257
#endif
270258

271259
#ifdef CONFIG_ARCH_OMAP3
272260
void __init omap34xx_map_common_io(void)
273261
{
274262
iotable_init(omap34xx_io_desc, ARRAY_SIZE(omap34xx_io_desc));
275-
_omap2_map_common_io();
276263
}
277264
#endif
278265

279266
#ifdef CONFIG_SOC_OMAPTI816X
280267
void __init omapti816x_map_common_io(void)
281268
{
282269
iotable_init(omapti816x_io_desc, ARRAY_SIZE(omapti816x_io_desc));
283-
_omap2_map_common_io();
284270
}
285271
#endif
286272

287273
#ifdef CONFIG_ARCH_OMAP4
288274
void __init omap44xx_map_common_io(void)
289275
{
290276
iotable_init(omap44xx_io_desc, ARRAY_SIZE(omap44xx_io_desc));
291-
_omap2_map_common_io();
292277
}
293278
#endif
294279

@@ -337,7 +322,6 @@ void __iomem *omap_irq_base;
337322
static void __init omap_common_init_early(void)
338323
{
339324
omap2_check_revision();
340-
omap_sram_init();
341325
}
342326

343327
static void __init omap_hwmod_init_postsetup(void)
@@ -449,11 +433,12 @@ void __init omap4430_init_early(void)
449433
void __init omap_sdrc_init(struct omap_sdrc_params *sdrc_cs0,
450434
struct omap_sdrc_params *sdrc_cs1)
451435
{
436+
omap_sram_init();
437+
452438
if (cpu_is_omap24xx() || omap3_has_sdrc()) {
453439
omap2_sdrc_init(sdrc_cs0, sdrc_cs1);
454440
_omap2_init_reprogram_sdrc();
455441
}
456-
457442
}
458443

459444
/*

arch/arm/mach-omap2/io.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +0,0 @@
1-
2-
#ifndef __MACH_OMAP2_IO_H__
3-
#define __MACH_OMAP2_IO_H__
4-
5-
extern int __init omap_sram_init(void);
6-
7-
#endif /* __MACH_OMAP2_IO_H__ */

arch/arm/plat-omap/include/plat/common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ void am35xx_init_early(void);
5555
void ti816x_init_early(void);
5656
void omap4430_init_early(void);
5757

58+
void omap_sram_init(void);
59+
5860
/*
5961
* IO bases for various OMAP processors
6062
* Except the tap base, rest all the io bases

arch/arm/plat-omap/sram.c

Lines changed: 20 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,9 @@
3838
#endif
3939

4040
#define OMAP1_SRAM_PA 0x20000000
41-
#define OMAP1_SRAM_VA VMALLOC_END
4241
#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
4642
#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
4943
#define OMAP4_SRAM_PUB_PA (OMAP4_SRAM_PA + 0x4000)
50-
#define OMAP4_SRAM_PUB_VA (OMAP4_SRAM_VA + 0x4000)
5144

5245
#if defined(CONFIG_ARCH_OMAP2PLUS)
5346
#define SRAM_BOOTLOADER_SZ 0x00
@@ -70,9 +63,9 @@
7063
#define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1)))
7164

7265
static unsigned long omap_sram_start;
73-
static unsigned long omap_sram_base;
66+
static void __iomem *omap_sram_base;
7467
static unsigned long omap_sram_size;
75-
static unsigned long omap_sram_ceil;
68+
static void __iomem *omap_sram_ceil;
7669

7770
/*
7871
* Depending on the target RAMFS firewall setup, the public usable amount of
@@ -112,7 +105,6 @@ static void __init omap_detect_sram(void)
112105
if (cpu_class_is_omap2()) {
113106
if (is_sram_locked()) {
114107
if (cpu_is_omap34xx()) {
115-
omap_sram_base = OMAP3_SRAM_PUB_VA;
116108
omap_sram_start = OMAP3_SRAM_PUB_PA;
117109
if ((omap_type() == OMAP2_DEVICE_TYPE_EMU) ||
118110
(omap_type() == OMAP2_DEVICE_TYPE_SEC)) {
@@ -121,25 +113,20 @@ static void __init omap_detect_sram(void)
121113
omap_sram_size = 0x8000; /* 32K */
122114
}
123115
} else if (cpu_is_omap44xx()) {
124-
omap_sram_base = OMAP4_SRAM_PUB_VA;
125116
omap_sram_start = OMAP4_SRAM_PUB_PA;
126117
omap_sram_size = 0xa000; /* 40K */
127118
} else {
128-
omap_sram_base = OMAP2_SRAM_PUB_VA;
129119
omap_sram_start = OMAP2_SRAM_PUB_PA;
130120
omap_sram_size = 0x800; /* 2K */
131121
}
132122
} else {
133123
if (cpu_is_omap34xx()) {
134-
omap_sram_base = OMAP3_SRAM_VA;
135124
omap_sram_start = OMAP3_SRAM_PA;
136125
omap_sram_size = 0x10000; /* 64K */
137126
} else if (cpu_is_omap44xx()) {
138-
omap_sram_base = OMAP4_SRAM_VA;
139127
omap_sram_start = OMAP4_SRAM_PA;
140128
omap_sram_size = 0xe000; /* 56K */
141129
} else {
142-
omap_sram_base = OMAP2_SRAM_VA;
143130
omap_sram_start = OMAP2_SRAM_PA;
144131
if (cpu_is_omap242x())
145132
omap_sram_size = 0xa0000; /* 640K */
@@ -148,7 +135,6 @@ static void __init omap_detect_sram(void)
148135
}
149136
}
150137
} else {
151-
omap_sram_base = OMAP1_SRAM_VA;
152138
omap_sram_start = OMAP1_SRAM_PA;
153139

154140
if (cpu_is_omap7xx())
@@ -165,24 +151,14 @@ static void __init omap_detect_sram(void)
165151
omap_sram_size = 0x4000;
166152
}
167153
}
168-
169-
omap_sram_ceil = omap_sram_base + omap_sram_size;
170154
}
171155

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-
180156
/*
181157
* Note that we cannot use ioremap for SRAM, as clock init needs SRAM early.
182158
*/
183159
static void __init omap_map_sram(void)
184160
{
185-
unsigned long base;
161+
int cached = 1;
186162

187163
if (omap_sram_size == 0)
188164
return;
@@ -195,28 +171,18 @@ static void __init omap_map_sram(void)
195171
* the ARM may attempt to write cache lines back to SDRAM
196172
* which will cause the system to hang.
197173
*/
198-
omap_sram_io_desc[0].type = MT_MEMORY_NONCACHED;
174+
cached = 0;
199175
}
200176

201-
omap_sram_io_desc[0].virtual = omap_sram_base;
202-
base = omap_sram_start;
203-
base = ROUND_DOWN(base, PAGE_SIZE);
204-
omap_sram_io_desc[0].pfn = __phys_to_pfn(base);
205-
omap_sram_io_desc[0].length = ROUND_DOWN(omap_sram_size, PAGE_SIZE);
206-
iotable_init(omap_sram_io_desc, ARRAY_SIZE(omap_sram_io_desc));
207-
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);
177+
omap_sram_start = ROUND_DOWN(omap_sram_start, PAGE_SIZE);
178+
omap_sram_base = __arm_ioremap_exec(omap_sram_start, omap_sram_size,
179+
cached);
180+
if (!omap_sram_base) {
181+
pr_err("SRAM: Could not map\n");
182+
return;
183+
}
212184

213-
/*
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();
185+
omap_sram_ceil = omap_sram_base + omap_sram_size;
220186

221187
/*
222188
* Looks like we need to preserve some bootloader code at the
@@ -235,13 +201,18 @@ static void __init omap_map_sram(void)
235201
*/
236202
void *omap_sram_push_address(unsigned long size)
237203
{
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) {
239209
pr_err("Not enough space in SRAM\n");
240210
return NULL;
241211
}
242212

243-
omap_sram_ceil -= size;
244-
omap_sram_ceil = ROUND_DOWN(omap_sram_ceil, FNCPY_ALIGN);
213+
new_ceil -= size;
214+
new_ceil = ROUND_DOWN(new_ceil, FNCPY_ALIGN);
215+
omap_sram_ceil = IOMEM(new_ceil);
245216

246217
return (void *)omap_sram_ceil;
247218
}

0 commit comments

Comments
 (0)