2 * head.S is the MMU enabled ColdFire specific initial boot code
4 * Copyright 2007-2009 Freescale Semiconductor, Inc. All Rights Reserved.
5 * Matt Waddel Matt.Waddel@freescale.com
6 * Kurt Mahan kmahan@freescale.com
7 * Jason Jin Jason.Jin@freescale.com
8 * Shrek Wu B16972@freescale.com
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * Parts of this code came from arch/m68k/kernel/head.S
17 #include <linux/linkage.h>
18 #include <linux/init.h>
19 #include <asm/bootinfo.h>
20 #include <asm/setup.h>
21 #include <asm/entry.h>
22 #include <asm/pgtable.h>
24 #include <asm/coldfire.h>
25 #include <asm/cfcache.h>
35 /* When debugging use readable names for labels */
37 #define L(name) .head.S.##name
39 #define L(name) .head.S./**/name
43 #define L(name) .L##name
45 #define L(name) .L/**/name
49 /* The __INITDATA stuff is a no-op when ftrace or kgdb are turned on */
51 #define __INITDATA .data
52 #define __FINIT .previous
55 #if CONFIG_SDRAM_BASE != PAGE_OFFSET
57 * Kernel mapped to virtual ram address.
60 * Data[0]: 0xF0000000 -> 0xFFFFFFFF System regs
61 * Data[1]: 0xA0000000 -> 0xAFFFFFFF PCI
66 * Data[0]: 0xF0000000 -> 0xFFFFFFFF System regs
71 #if defined(CONFIG_M5445X)
72 #define ACR0_DEFAULT #0xF00FA048 /* System regs */
73 #define ACR1_DEFAULT #0xA00FA048 /* PCI */
74 #define ACR2_DEFAULT #0x00000000 /* Not Mapped */
75 #define ACR3_DEFAULT #0x00000000 /* Not Mapped */
76 #elif defined(CONFIG_M547X_8X)
77 #define ACR0_DEFAULT #0xF00FA048 /* System Regs */
78 #define ACR1_DEFAULT #0x00000000 /* Not Mapped */
79 #define ACR2_DEFAULT #0x00000000 /* Not Mapped */
80 #define ACR3_DEFAULT #0x00000000 /* Not Mapped */
83 #else /* CONFIG_SDRAM_BASE = PAGE_OFFSET */
85 * Kernel mapped to physical ram address.
88 * Data[0]: 0xF0000000 -> 0xFFFFFFFF System regs
89 * Data[1]: 0x40000000 -> 0x4FFFFFFF SDRAM - uncached
91 * Code[1]: 0x40000000 -> 0x4FFFFFFF SDRAM - cached
94 * Data[0]: 0xF0000000 -> 0xFFFFFFFF System regs
95 * Data[1]: 0x00000000 -> 0x0FFFFFFF SDRAM - uncached
97 * Code[1]: 0x00000000 -> 0x0FFFFFFF SDRAM - cached
99 #if defined(CONFIG_M5445X)
100 #define ACR0_DEFAULT #0xF00FA048 /* System Regs uncached/precise */
101 #define ACR1_DEFAULT #0x400FA028 /* SDRAM cached/copyback */
102 #define ACR2_DEFAULT #0x00000000 /* Not mapped */
103 #define ACR3_DEFAULT #0x400FA028 /* SDRAM cached/copyback */
104 #elif defined(CONFIG_M547X_8X)
105 #define ACR0_DEFAULT #0xF00FA048 /* System Regs */
106 #define ACR1_DEFAULT #0x000FA028 /* SDRAM cached/copy-back */
107 #define ACR2_DEFAULT #0x00000000 /* Not mapped */
108 #define ACR3_DEFAULT #0x000FA028 /* Instruction cached/copy-back */
112 /* ACR mapping for FPGA (maps 0) */
113 #define ACR0_FPGA #0x000FA048 /* ACR0 enable FPGA */
115 /* Several macros to make the writing of subroutines easier:
116 * - func_start marks the beginning of the routine which setups the frame
117 * register and saves the registers, it also defines another macro
118 * to automatically restore the registers again.
119 * - func_return marks the end of the routine and simply calls the prepared
120 * macro to restore registers and jump back to the caller.
121 * - func_define generates another macro to automatically put arguments
122 * onto the stack call the subroutine and cleanup the stack again.
125 .macro load_symbol_address symbol,register
126 movel #\symbol,\register
129 .macro func_start name,saveregs,savesize,stack=0
132 subal #(\savesize),%sp
133 moveml \saveregs,%sp@
134 .set stackstart,-\stack
136 .macro func_return_\name
137 moveml %sp@,\saveregs
138 addal #(\savesize),%sp
144 .macro func_return name
148 .macro func_call name
152 .macro move_stack nr,arg1,arg2,arg3,arg4
154 move_stack "(\nr-1)",\arg2,\arg3,\arg4
159 .macro func_define name,nr=0
160 .macro \name arg1,arg2,arg3,arg4
161 move_stack \nr,\arg1,\arg2,\arg3,\arg4
169 func_define serial_putc,1
173 func_call serial_putc
192 mmu_map - creates a new TLB entry
194 virt_addr Must be on proper boundary
195 phys_addr Must be on proper boundary
196 itlb MMUOR_ITLB if instruction TLB or 0
197 asid address space ID
198 shared_global MMUTR_SG if shared between different ASIDs or 0
199 size_code MMUDR_SZ1M 1 MB
203 cache_mode MMUDR_INC instruction non-cacheable
204 MMUDR_IC instruction cacheable
205 MMUDR_DWT data writethrough
206 MMUDR_DCB data copyback
207 MMUDR_DNCP data non-cacheable, precise
208 MMUDR_DNCIP data non-cacheable, imprecise
209 super_prot MMUDR_SP if user mode generates exception or 0
210 readable MMUDR_R if permits read access (data TLB) or 0
211 writable MMUDR_W if permits write access (data TLB) or 0
212 executable MMUDR_X if permits execute access (instruction TLB) or 0
213 locked MMUDR_LK prevents TLB entry from being replaced or 0
214 temp_data_reg a data register to use for temporary values
216 .macro mmu_map virt_addr,phys_addr,itlb,asid,shared_global,size_code,cache_mode,super_prot,readable,writable,executable,locked,temp_data_reg
217 /* Set up search of TLB. */
218 movel #(\virt_addr+1), \temp_data_reg
219 movel \temp_data_reg, MMUAR
221 movel #(MMUOR_STLB + MMUOR_ADR +\itlb), \temp_data_reg
222 movew \temp_data_reg, (MMUOR)
223 /* Set up tag value. */
224 movel #(\virt_addr + \asid + \shared_global + MMUTR_V), \temp_data_reg
225 movel \temp_data_reg, MMUTR
226 /* Set up data value. */
227 movel #(\phys_addr + \size_code + \cache_mode + \super_prot + \readable + \writable + \executable + \locked), \temp_data_reg
228 movel \temp_data_reg, MMUDR
230 movel #(MMUOR_ACC + MMUOR_UAA + \itlb), \temp_data_reg
231 movew \temp_data_reg, (MMUOR)
234 .macro mmu_unmap virt_addr,itlb,temp_data_reg
235 /* Set up search of TLB. */
236 movel #(\virt_addr+1), \temp_data_reg
237 movel \temp_data_reg, MMUAR
239 movel #(MMUOR_STLB + MMUOR_ADR +\itlb), \temp_data_reg
240 movew \temp_data_reg, (MMUOR)
242 movel MMUSR,\temp_data_reg
243 btst #MMUSR_HITN,\temp_data_reg
246 movel #(MMUOR_RW + MMUOR_ACC +\itlb), \temp_data_reg
247 movew \temp_data_reg, (MMUOR)
248 movel MMUSR,\temp_data_reg
249 /* Set up tag value. */
250 movel #0, \temp_data_reg
251 movel \temp_data_reg, MMUTR
252 /* Set up data value. */
253 movel #0, \temp_data_reg
254 movel \temp_data_reg, MMUDR
256 movel #(MMUOR_ACC + MMUOR_UAA + \itlb), \temp_data_reg
257 movew \temp_data_reg, (MMUOR)
259 .endm /* mmu_unmap */
262 .section ".text.head","ax"
264 /* Version numbers of the bootinfo interface -- if we later pass info
265 * from boot ROM we might want to put something real here.
267 * The area from _stext to _start will later be used as kernel pointer table
269 bras 1f /* Jump over bootinfo version numbers */
271 .long BOOTINFOV_MAGIC
275 .equ kernel_pg_dir,_stext
282 /* Save the location of u-boot info - cmd line, bd_info, etc. */
283 movel %a7,%a4 /* Don't use %a4 before cf_early_init */
284 addl #0x00000004,%a4 /* offset past top */
285 addl #(PAGE_OFFSET-CONFIG_SDRAM_BASE),%a4 /* high mem offset */
287 /* Setup initial stack pointer */
288 movel #CONFIG_SDRAM_BASE+0x1000,%sp
294 #if defined(CONFIG_M5445X)
295 #if defined(CONFIG_SRAM)
296 movel #(CONFIG_SRAM_BASE+0x221), %d0
298 movel #0x80000000, %d0
301 #elif defined(CONFIG_M547X_8X)
304 move.l #(MCF_RAMBAR0 + 0x21), %d0
306 move.l #(MCF_RAMBAR1 + 0x21), %d0
313 movel #(CF_CACR_ICINVA + CF_CACR_DCINVA),%d0
316 movel #(MMU_BASE+1),%d0
318 movel #MMUOR_CA,%a0 /* Clear tlb entries */
320 movel #(MMUOR_CA + MMUOR_ITLB),%a0 /* Use ITLB for searches */
322 movel #0,%a0 /* Clear Addr Space User ID */
326 movel ACR0_DEFAULT, %d0 /* ACR0 (DATA) setup */
329 movel ACR1_DEFAULT, %d0 /* ACR1 (DATA) setup */
332 movel ACR2_DEFAULT, %d0 /* ACR2 (CODE) setup */
335 movel ACR3_DEFAULT, %d0 /* ACR3 (CODE) setup */
339 /* If you change the memory size to another value make a matching
340 change in paging_init(cf-mmu.c) to zones_size[]. */
342 #if CONFIG_SDRAM_BASE != PAGE_OFFSET
343 #if defined(CONFIG_M5445X)
344 /* Map 256MB as code */
345 mmu_map (PAGE_OFFSET+0*0x1000000), (PHYS_OFFSET+0*0x1000000), \
346 MMUOR_ITLB, 0, MMUTR_SG, MMUDR_SZ16M, MMUDR_IC, MMUDR_SP, \
347 0, 0, MMUDR_X, MMUDR_LK, %d0
348 mmu_map (PAGE_OFFSET+1*0x1000000), (PHYS_OFFSET+1*0x1000000), \
349 MMUOR_ITLB, 0, MMUTR_SG, MMUDR_SZ16M, MMUDR_IC, MMUDR_SP, \
350 0, 0, MMUDR_X, MMUDR_LK, %d0
351 mmu_map (PAGE_OFFSET+2*0x1000000), (PHYS_OFFSET+2*0x1000000), \
352 MMUOR_ITLB, 0, MMUTR_SG, MMUDR_SZ16M, MMUDR_IC, MMUDR_SP, \
353 0, 0, MMUDR_X, MMUDR_LK, %d0
354 mmu_map (PAGE_OFFSET+3*0x1000000), (PHYS_OFFSET+3*0x1000000), \
355 MMUOR_ITLB, 0, MMUTR_SG, MMUDR_SZ16M, MMUDR_IC, MMUDR_SP, \
356 0, 0, MMUDR_X, MMUDR_LK, %d0
357 mmu_map (PAGE_OFFSET+4*0x1000000), (PHYS_OFFSET+4*0x1000000), \
358 MMUOR_ITLB, 0, MMUTR_SG, MMUDR_SZ16M, MMUDR_IC, MMUDR_SP, \
359 0, 0, MMUDR_X, MMUDR_LK, %d0
360 mmu_map (PAGE_OFFSET+5*0x1000000), (PHYS_OFFSET+5*0x1000000), \
361 MMUOR_ITLB, 0, MMUTR_SG, MMUDR_SZ16M, MMUDR_IC, MMUDR_SP, \
362 0, 0, MMUDR_X, MMUDR_LK, %d0
363 mmu_map (PAGE_OFFSET+6*0x1000000), (PHYS_OFFSET+6*0x1000000), \
364 MMUOR_ITLB, 0, MMUTR_SG, MMUDR_SZ16M, MMUDR_IC, MMUDR_SP, \
365 0, 0, MMUDR_X, MMUDR_LK, %d0
366 mmu_map (PAGE_OFFSET+7*0x1000000), (PHYS_OFFSET+7*0x1000000), \
367 MMUOR_ITLB, 0, MMUTR_SG, MMUDR_SZ16M, MMUDR_IC, MMUDR_SP, \
368 0, 0, MMUDR_X, MMUDR_LK, %d0
369 mmu_map (PAGE_OFFSET+8*0x1000000), (PHYS_OFFSET+8*0x1000000), \
370 MMUOR_ITLB, 0, MMUTR_SG, MMUDR_SZ16M, MMUDR_IC, MMUDR_SP, \
371 0, 0, MMUDR_X, MMUDR_LK, %d0
372 mmu_map (PAGE_OFFSET+9*0x1000000), (PHYS_OFFSET+9*0x1000000), \
373 MMUOR_ITLB, 0, MMUTR_SG, MMUDR_SZ16M, MMUDR_IC, MMUDR_SP, \
374 0, 0, MMUDR_X, MMUDR_LK, %d0
375 mmu_map (PAGE_OFFSET+10*0x1000000), (PHYS_OFFSET+10*0x1000000), \
376 MMUOR_ITLB, 0, MMUTR_SG, MMUDR_SZ16M, MMUDR_IC, MMUDR_SP, \
377 0, 0, MMUDR_X, MMUDR_LK, %d0
378 mmu_map (PAGE_OFFSET+11*0x1000000), (PHYS_OFFSET+11*0x1000000), \
379 MMUOR_ITLB, 0, MMUTR_SG, MMUDR_SZ16M, MMUDR_IC, MMUDR_SP, \
380 0, 0, MMUDR_X, MMUDR_LK, %d0
381 mmu_map (PAGE_OFFSET+12*0x1000000), (PHYS_OFFSET+12*0x1000000), \
382 MMUOR_ITLB, 0, MMUTR_SG, MMUDR_SZ16M, MMUDR_IC, MMUDR_SP, \
383 0, 0, MMUDR_X, MMUDR_LK, %d0
384 mmu_map (PAGE_OFFSET+13*0x1000000), (PHYS_OFFSET+13*0x1000000), \
385 MMUOR_ITLB, 0, MMUTR_SG, MMUDR_SZ16M, MMUDR_IC, MMUDR_SP, \
386 0, 0, MMUDR_X, MMUDR_LK, %d0
387 mmu_map (PAGE_OFFSET+14*0x1000000), (PHYS_OFFSET+14*0x1000000), \
388 MMUOR_ITLB, 0, MMUTR_SG, MMUDR_SZ16M, MMUDR_IC, MMUDR_SP, \
389 0, 0, MMUDR_X, MMUDR_LK, %d0
390 mmu_map (PAGE_OFFSET+15*0x1000000), (PHYS_OFFSET+15*0x1000000), \
391 MMUOR_ITLB, 0, MMUTR_SG, MMUDR_SZ16M, MMUDR_IC, MMUDR_SP, \
392 0, 0, MMUDR_X, MMUDR_LK, %d0
394 /* Map 256MB as data also */
395 mmu_map (PAGE_OFFSET+0*0x1000000), (PHYS_OFFSET+0*0x1000000), 0, 0, \
396 MMUTR_SG, MMUDR_SZ16M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, MMUDR_W, \
398 mmu_map (PAGE_OFFSET+1*0x1000000), (PHYS_OFFSET+1*0x1000000), 0, 0, \
399 MMUTR_SG, MMUDR_SZ16M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, MMUDR_W, \
401 mmu_map (PAGE_OFFSET+2*0x1000000), (PHYS_OFFSET+2*0x1000000), 0, 0, \
402 MMUTR_SG, MMUDR_SZ16M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, MMUDR_W, \
404 mmu_map (PAGE_OFFSET+3*0x1000000), (PHYS_OFFSET+3*0x1000000), 0, 0, \
405 MMUTR_SG, MMUDR_SZ16M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, MMUDR_W, \
407 mmu_map (PAGE_OFFSET+4*0x1000000), (PHYS_OFFSET+4*0x1000000), 0, 0, \
408 MMUTR_SG, MMUDR_SZ16M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, MMUDR_W, \
410 mmu_map (PAGE_OFFSET+5*0x1000000), (PHYS_OFFSET+5*0x1000000), 0, 0, \
411 MMUTR_SG, MMUDR_SZ16M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, MMUDR_W, \
413 mmu_map (PAGE_OFFSET+6*0x1000000), (PHYS_OFFSET+6*0x1000000), 0, 0, \
414 MMUTR_SG, MMUDR_SZ16M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, MMUDR_W, \
416 mmu_map (PAGE_OFFSET+7*0x1000000), (PHYS_OFFSET+7*0x1000000), 0, 0, \
417 MMUTR_SG, MMUDR_SZ16M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, MMUDR_W, \
419 mmu_map (PAGE_OFFSET+8*0x1000000), (PHYS_OFFSET+8*0x1000000), 0, 0, \
420 MMUTR_SG, MMUDR_SZ16M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, MMUDR_W, \
422 mmu_map (PAGE_OFFSET+9*0x1000000), (PHYS_OFFSET+9*0x1000000), 0, 0, \
423 MMUTR_SG, MMUDR_SZ16M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, MMUDR_W, \
425 mmu_map (PAGE_OFFSET+10*0x1000000), (PHYS_OFFSET+10*0x1000000), 0, 0, \
426 MMUTR_SG, MMUDR_SZ16M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, MMUDR_W, \
428 mmu_map (PAGE_OFFSET+11*0x1000000), (PHYS_OFFSET+11*0x1000000), 0, 0, \
429 MMUTR_SG, MMUDR_SZ16M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, MMUDR_W, \
431 mmu_map (PAGE_OFFSET+12*0x1000000), (PHYS_OFFSET+12*0x1000000), 0, 0, \
432 MMUTR_SG, MMUDR_SZ16M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, MMUDR_W, \
434 mmu_map (PAGE_OFFSET+13*0x1000000), (PHYS_OFFSET+13*0x1000000), 0, 0, \
435 MMUTR_SG, MMUDR_SZ16M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, MMUDR_W, \
437 mmu_map (PAGE_OFFSET+14*0x1000000), (PHYS_OFFSET+14*0x1000000), 0, 0, \
438 MMUTR_SG, MMUDR_SZ16M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, MMUDR_W, \
440 mmu_map (PAGE_OFFSET+15*0x1000000), (PHYS_OFFSET+15*0x1000000), 0, 0, \
441 MMUTR_SG, MMUDR_SZ16M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, MMUDR_W, \
444 /* Map ATA registers -- sacrifice a data TLB due to the hw design */
445 mmu_map (0x90000000), (0x90000000), 0, 0, \
446 MMUTR_SG, MMUDR_SZ16M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, MMUDR_W, \
449 #elif defined(CONFIG_M547X_8X)
451 /* Map first 8 MB as code */
452 mmu_map (PAGE_OFFSET+0*1024*1024), (0*1024*1024), MMUOR_ITLB, 0, \
453 MMUTR_SG, MMUDR_SZ1M, MMUDR_IC, MMUDR_SP, 0, 0, MMUDR_X, \
455 mmu_map (PAGE_OFFSET+1*1024*1024), (1*1024*1024), MMUOR_ITLB, 0, \
456 MMUTR_SG, MMUDR_SZ1M, MMUDR_IC, MMUDR_SP, 0, 0, MMUDR_X, \
458 mmu_map (PAGE_OFFSET+2*1024*1024), (2*1024*1024), MMUOR_ITLB, 0, \
459 MMUTR_SG, MMUDR_SZ1M, MMUDR_IC, MMUDR_SP, 0, 0, MMUDR_X, \
461 mmu_map (PAGE_OFFSET+3*1024*1024), (3*1024*1024), MMUOR_ITLB, 0, \
462 MMUTR_SG, MMUDR_SZ1M, MMUDR_IC, MMUDR_SP, 0, 0, MMUDR_X, \
464 mmu_map (PAGE_OFFSET+4*1024*1024), (4*1024*1024), MMUOR_ITLB, 0, \
465 MMUTR_SG, MMUDR_SZ1M, MMUDR_IC, MMUDR_SP, 0, 0, MMUDR_X, \
467 mmu_map (PAGE_OFFSET+5*1024*1024), (5*1024*1024), MMUOR_ITLB, 0, \
468 MMUTR_SG, MMUDR_SZ1M, MMUDR_IC, MMUDR_SP, 0, 0, MMUDR_X, \
470 mmu_map (PAGE_OFFSET+6*1024*1024), (6*1024*1024), MMUOR_ITLB, 0, \
471 MMUTR_SG, MMUDR_SZ1M, MMUDR_IC, MMUDR_SP, 0, 0, MMUDR_X, \
473 mmu_map (PAGE_OFFSET+7*1024*1024), (7*1024*1024), MMUOR_ITLB, 0, \
474 MMUTR_SG, MMUDR_SZ1M, MMUDR_IC, MMUDR_SP, 0, 0, MMUDR_X, \
477 /* Map first 8 MB as data */
478 mmu_map (PAGE_OFFSET+0*1024*1024), (0*1024*1024), 0, 0, \
479 MMUTR_SG, MMUDR_SZ1M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, \
480 MMUDR_W, 0, MMUDR_LK, %d0
481 mmu_map (PAGE_OFFSET+1*1024*1024), (1*1024*1024), 0, 0, \
482 MMUTR_SG, MMUDR_SZ1M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, \
483 MMUDR_W, 0, MMUDR_LK, %d0
484 mmu_map (PAGE_OFFSET+2*1024*1024), (2*1024*1024), 0, 0, \
485 MMUTR_SG, MMUDR_SZ1M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, \
486 MMUDR_W, 0, MMUDR_LK, %d0
487 mmu_map (PAGE_OFFSET+3*1024*1024), (3*1024*1024), 0, 0, \
488 MMUTR_SG, MMUDR_SZ1M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, \
489 MMUDR_W, 0, MMUDR_LK, %d0
490 mmu_map (PAGE_OFFSET+4*1024*1024), (4*1024*1024), 0, 0, \
491 MMUTR_SG, MMUDR_SZ1M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, \
492 MMUDR_W, 0, MMUDR_LK, %d0
493 mmu_map (PAGE_OFFSET+5*1024*1024), (5*1024*1024), 0, 0, \
494 MMUTR_SG, MMUDR_SZ1M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, \
495 MMUDR_W, 0, MMUDR_LK, %d0
496 mmu_map (PAGE_OFFSET+6*1024*1024), (6*1024*1024), 0, 0, \
497 MMUTR_SG, MMUDR_SZ1M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, \
498 MMUDR_W, 0, MMUDR_LK, %d0
499 mmu_map (PAGE_OFFSET+7*1024*1024), (7*1024*1024), 0, 0, \
500 MMUTR_SG, MMUDR_SZ1M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, \
501 MMUDR_W, 0, MMUDR_LK, %d0
504 * Do unity mapping to enable the MMU. Map first chunk of memory
505 * in place as code/data. The TLBs will be deleted after the MMU is
506 * enabled and we are executing in high memory.
509 #if defined(CONFIG_M5445X)
510 /* Map first 16 MB as code */
511 mmu_map (PHYS_OFFSET+0*0x1000000), (PHYS_OFFSET+0*0x1000000), \
512 MMUOR_ITLB, 0, MMUTR_SG, MMUDR_SZ16M, MMUDR_INC, MMUDR_SP, 0, \
514 /* Map first 16 MB as data too */
515 mmu_map (PHYS_OFFSET+0*0x1000000), (PHYS_OFFSET+0*0x1000000), 0, 0, \
516 MMUTR_SG, MMUDR_SZ16M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, MMUDR_W, \
518 #elif defined(CONFIG_M547X_8X)
519 /* Map first 4 MB as code */
520 mmu_map (0*1024*1024), (0*1024*1024), MMUOR_ITLB, 0, \
521 MMUTR_SG, MMUDR_SZ1M, MMUDR_IC, MMUDR_SP, 0, 0, \
523 mmu_map (1*1024*1024), (1*1024*1024), MMUOR_ITLB, 0, \
524 MMUTR_SG, MMUDR_SZ1M, MMUDR_IC, MMUDR_SP, 0, 0, \
526 mmu_map (2*1024*1024), (2*1024*1024), MMUOR_ITLB, 0, \
527 MMUTR_SG, MMUDR_SZ1M, MMUDR_IC, MMUDR_SP, 0, 0, \
529 mmu_map (3*1024*1024), (3*1024*1024), MMUOR_ITLB, 0, \
530 MMUTR_SG, MMUDR_SZ1M, MMUDR_IC, MMUDR_SP, 0, 0, \
533 /* Map first 4 MB as data too */
534 mmu_map (0*1024*1024), (0*1024*1024), 0, 0, \
535 MMUTR_SG, MMUDR_SZ1M, MMUDR_DCB, MMUDR_SP, MMUDR_R, \
537 mmu_map (1*1024*1024), (1*1024*1024), 0, 0, \
538 MMUTR_SG, MMUDR_SZ1M, MMUDR_DCB, MMUDR_SP, MMUDR_R, \
540 mmu_map (2*1024*1024), (2*1024*1024), 0, 0, \
541 MMUTR_SG, MMUDR_SZ1M, MMUDR_DCB, MMUDR_SP, MMUDR_R, \
543 mmu_map (3*1024*1024), (3*1024*1024), 0, 0, \
544 MMUTR_SG, MMUDR_SZ1M, MMUDR_DCB, MMUDR_SP, MMUDR_R, \
547 #endif /* CONFIG_SDRAM_BASE != PAGE_OFFSET */
550 movel #(MMUCR_EN),%a0
552 nop /* This synchs the pipeline after a write to MMUCR */
554 movel #__running_high,%a0 /* Get around PC-relative addressing. */
557 ENTRY(__running_high)
558 load_symbol_address _stext,%sp
559 movel L(memory_start),%a0
561 load_symbol_address L(phys_kernel_start),%a0
562 load_symbol_address _stext,%a1
564 addl #PAGE_OFFSET,%a1
576 /* Unmap unity mappings */
577 #if CONFIG_SDRAM_BASE != PAGE_OFFSET
578 #if defined(CONFIG_M5445X)
579 mmu_unmap (PHYS_OFFSET+0*0x1000000), MMUOR_ITLB, %d0
580 mmu_unmap (PHYS_OFFSET+0*0x1000000), 0, %d0
581 #elif defined(CONFIG_M547X_8X)
582 mmu_unmap (PHYS_OFFSET+0*0x1000000), MMUOR_ITLB, %d0
583 mmu_unmap (PHYS_OFFSET+1*0x1000000), MMUOR_ITLB, %d0
584 mmu_unmap (PHYS_OFFSET+2*0x1000000), MMUOR_ITLB, %d0
585 mmu_unmap (PHYS_OFFSET+3*0x1000000), MMUOR_ITLB, %d0
586 mmu_unmap (PHYS_OFFSET+0*0x1000000), 0, %d0
587 mmu_unmap (PHYS_OFFSET+1*0x1000000), 0, %d0
588 mmu_unmap (PHYS_OFFSET+2*0x1000000), 0, %d0
589 mmu_unmap (PHYS_OFFSET+3*0x1000000), 0, %d0
591 #endif /* CONFIG_SDRAM_BASE != PAGE_OFFSET */
593 /* create dma memory mirror TLB mapping */
594 #if defined(CONFIG_M5445X)
595 mmu_map CONFIG_DMA_BASE, \
596 CONFIG_SDRAM_BASE, 0, 0, \
597 MMUTR_SG, MMUDR_SZ16M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, MMUDR_W, \
599 #elif defined(CONFIG_M547X_8X)
600 mmu_map (CONFIG_DMA_BASE + 0*1024*1024), \
601 (CONFIG_SDRAM_BASE + 0*1024*1024), 0, 0, \
602 MMUTR_SG, MMUDR_SZ1M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, \
603 MMUDR_W, 0, MMUDR_LK, %d0
604 mmu_map (CONFIG_DMA_BASE + 1*1024*1024), \
605 (CONFIG_SDRAM_BASE + 1*1024*1024), 0, 0, \
606 MMUTR_SG, MMUDR_SZ1M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, \
607 MMUDR_W, 0, MMUDR_LK, %d0
608 mmu_map (CONFIG_DMA_BASE + 2*1024*1024), \
609 (CONFIG_SDRAM_BASE + 2*1024*1024), 0, 0, \
610 MMUTR_SG, MMUDR_SZ1M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, \
611 MMUDR_W, 0, MMUDR_LK, %d0
612 mmu_map (CONFIG_DMA_BASE + 3*1024*1024), \
613 (CONFIG_SDRAM_BASE + 3*1024*1024), 0, 0, \
614 MMUTR_SG, MMUDR_SZ1M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, \
615 MMUDR_W, 0, MMUDR_LK, %d0
616 mmu_map (CONFIG_DMA_BASE + 4*1024*1024), \
617 (CONFIG_SDRAM_BASE + 4*1024*1024), 0, 0, \
618 MMUTR_SG, MMUDR_SZ1M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, \
619 MMUDR_W, 0, MMUDR_LK, %d0
620 mmu_map (CONFIG_DMA_BASE + 5*1024*1024), \
621 (CONFIG_SDRAM_BASE + 5*1024*1024), 0, 0, \
622 MMUTR_SG, MMUDR_SZ1M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, \
623 MMUDR_W, 0, MMUDR_LK, %d0
624 mmu_map (CONFIG_DMA_BASE + 6*1024*1024), \
625 (CONFIG_SDRAM_BASE + 6*1024*1024), 0, 0, \
626 MMUTR_SG, MMUDR_SZ1M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, \
627 MMUDR_W, 0, MMUDR_LK, %d0
628 mmu_map (CONFIG_DMA_BASE + 7*1024*1024), \
629 (CONFIG_SDRAM_BASE + 7*1024*1024), 0, 0, \
630 MMUTR_SG, MMUDR_SZ1M, MMUDR_DNCP, MMUDR_SP, MMUDR_R, \
631 MMUDR_W, 0, MMUDR_LK, %d0
634 /* Setup initial stack pointer */
636 lea init_thread_union+THREAD_SIZE,%sp
637 subl %a6,%a6 /* clear a6 for gdb */
639 #ifdef CONFIG_MCF_USER_HALT
640 /* Setup debug control reg to allow halts from user space */
645 movel %a4,uboot_info_stk /* save uboot info to variable */
649 .section ".text.head","ax"
651 func_start set_context,%d0,(1*4)
654 func_return set_context
658 * set_fpga(addr,val) on the M5445X
660 * Map in 0x00000000 -> 0x0fffffff and then do the write.
670 movel ACR0_DEFAULT, %d0
682 L(phys_kernel_start):
687 .long PAGE_OFFSET_RAW
689 #ifdef CONFIG_MCF_USER_HALT
691 * Enable User Halt Enable in the debug control register.
694 .word 0x2c80 /* DR0 */
695 .word 0x00b0 /* 31:16 */
696 .word 0x0400 /* 15:0 -- enable UHE */
697 .word 0x0000 /* unused */