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
7063#define ROUND_DOWN (value ,boundary ) ((value) & (~((boundary)-1)))
7164
7265static unsigned long omap_sram_start ;
73- static unsigned long omap_sram_base ;
66+ static void __iomem * omap_sram_base ;
7467static 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 */
183159static 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 */
236202void * 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