1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#include <linux/init.h>
27#include <asm/mmu.h>
28#include <asm/system.h>
29#include <asm/page.h>
30#include <asm/cacheflush.h>
31
32#include "mmu_decl.h"
33
34
35
36
37unsigned int tlb_44x_index;
38unsigned int tlb_44x_hwater = PPC44x_TLB_SIZE - 1 - PPC44x_EARLY_TLBS;
39int icache_44x_need_flush;
40
41static void __init ppc44x_update_tlb_hwater(void)
42{
43 extern unsigned int tlb_44x_patch_hwater_D[];
44 extern unsigned int tlb_44x_patch_hwater_I[];
45
46
47
48
49
50
51 tlb_44x_patch_hwater_D[0] = (tlb_44x_patch_hwater_D[0] & 0xffff0000) |
52 tlb_44x_hwater;
53 flush_icache_range((unsigned long)&tlb_44x_patch_hwater_D[0],
54 (unsigned long)&tlb_44x_patch_hwater_D[1]);
55 tlb_44x_patch_hwater_I[0] = (tlb_44x_patch_hwater_I[0] & 0xffff0000) |
56 tlb_44x_hwater;
57 flush_icache_range((unsigned long)&tlb_44x_patch_hwater_I[0],
58 (unsigned long)&tlb_44x_patch_hwater_I[1]);
59}
60
61
62
63
64static void __init ppc44x_pin_tlb(unsigned int virt, unsigned int phys)
65{
66 unsigned int entry = tlb_44x_hwater--;
67
68 ppc44x_update_tlb_hwater();
69
70 __asm__ __volatile__(
71 "tlbwe %2,%3,%4\n"
72 "tlbwe %1,%3,%5\n"
73 "tlbwe %0,%3,%6\n"
74 :
75 : "r" (PPC44x_TLB_SW | PPC44x_TLB_SR | PPC44x_TLB_SX | PPC44x_TLB_G),
76 "r" (phys),
77 "r" (virt | PPC44x_TLB_VALID | PPC44x_TLB_256M),
78 "r" (entry),
79 "i" (PPC44x_TLB_PAGEID),
80 "i" (PPC44x_TLB_XLAT),
81 "i" (PPC44x_TLB_ATTRIB));
82}
83
84void __init MMU_init_hw(void)
85{
86 ppc44x_update_tlb_hwater();
87
88 flush_instruction_cache();
89}
90
91unsigned long __init mmu_mapin_ram(void)
92{
93 unsigned long addr;
94
95
96
97 for (addr = PPC_PIN_SIZE; addr < lowmem_end_addr;
98 addr += PPC_PIN_SIZE)
99 ppc44x_pin_tlb(addr + PAGE_OFFSET, addr);
100
101 return total_lowmem;
102}
103