3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
10 #include <ppc_asm.tmpl>
12 #include <asm/cache.h>
14 #include "test_burst.h"
18 * void mmu_init(void);
20 * This function turns the MMU on
22 * Three 8 MByte regions are mapped 1:1, uncached
23 * - SDRAM lower 8 MByte
24 * - SDRAM higher 8 MByte
29 tlbia /* Invalidate all TLB entries */
31 mtspr MI_CTR, r8 /* Set instruction control to zero */
33 mtspr MD_CTR, r8 /* Set data TLB control */
35 /* Now map the lower 8 Meg into the TLBs. For this quick hack,
36 * we can load the instruction and data TLB registers with the
39 li r8, MI_EVALID /* Create EPN for address 0 */
42 li r8, MI_PS8MEG /* Set 8M byte page */
43 ori r8, r8, MI_SVALID /* Make it valid */
46 li r8, MI_BOOTINIT|0x2 /* Create RPN for address 0 */
47 mtspr MI_RPN, r8 /* Store TLB entry */
49 lis r8, MI_Kp@h /* Set the protection mode */
53 /* Now map the higher 8 Meg into the TLBs. For this quick hack,
54 * we can load the instruction and data TLB registers with the
57 lwz r9,20(r2) /* gd->ram_size */
60 mr r8, r9 /* Higher 8 Meg in SDRAM */
61 ori r8, r8, MI_EVALID /* Mark page valid */
64 li r8, MI_PS8MEG /* Set 8M byte page */
65 ori r8, r8, MI_SVALID /* Make it valid */
69 ori r8, r8, MI_BOOTINIT|0x2
70 mtspr MI_RPN, r8 /* Store TLB entry */
72 lis r8, MI_Kp@h /* Set the protection mode */
76 /* Map another 8 MByte at the IMMR to get the processor
77 * internal registers (among other things).
79 mfspr r9, 638 /* Get current IMMR */
80 andis. r9, r9, 0xff80 /* Get 8Mbyte boundary */
82 mr r8, r9 /* Create vaddr for TLB */
83 ori r8, r8, MD_EVALID /* Mark it valid */
85 li r8, MD_PS8MEG /* Set 8M byte page */
86 ori r8, r8, MD_SVALID /* Make it valid */
88 mr r8, r9 /* Create paddr for TLB */
89 ori r8, r8, MI_BOOTINIT|0x2 /* Inhibit cache -- Cort */
92 /* We now have the lower and higher 8 Meg mapped into TLB entries,
93 * and the caches ready to work.
96 ori r0,r0,MSR_DR|MSR_IR
101 rfi /* enables MMU */
104 * void caches_init(void);
110 mfspr r3, IC_CST /* Clear error bits */
113 lis r3, IDC_UNALL@h /* Unlock all */
117 lis r3, IDC_INVALL@h /* Invalidate all */
121 lis r3, IDC_ENABLE@h /* Enable all */
128 * void flush_dcache_range(unsigned long start, unsigned long stop);
130 .global flush_dcache_range
132 li r5,CACHE_LINE_SIZE-1
136 srwi. r4,r4,LG_CACHE_LINE_SIZE
141 addi r3,r3,CACHE_LINE_SIZE
143 sync /* wait for dcbf's to get to ram */
147 * void disable_interrupts(void);
149 .global disable_interrupts