]>
git.ipfire.org Git - people/ms/u-boot.git/blob - cpu/mpc85xx/tlb.c
2 * Copyright 2008 Freescale Semiconductor, Inc.
5 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
7 * See file CREDITS for list of people who contributed to this
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 #include <asm/processor.h>
30 void set_tlb(u8 tlb
, u32 epn
, u64 rpn
,
32 u8 ts
, u8 esel
, u8 tsize
, u8 iprot
)
34 u32 _mas0
, _mas1
, _mas2
, _mas3
, _mas7
;
36 _mas0
= FSL_BOOKE_MAS0(tlb
, esel
, 0);
37 _mas1
= FSL_BOOKE_MAS1(1, iprot
, 0, ts
, tsize
);
38 _mas2
= FSL_BOOKE_MAS2(epn
, wimge
);
39 _mas3
= FSL_BOOKE_MAS3(rpn
, 0, perms
);
46 #ifdef CONFIG_ENABLE_36BIT_PHYS
49 asm volatile("isync;msync;tlbwe;isync");
52 void disable_tlb(u8 esel
)
54 u32 _mas0
, _mas1
, _mas2
, _mas3
, _mas7
;
56 _mas0
= FSL_BOOKE_MAS0(1, esel
, 0);
66 #ifdef CONFIG_ENABLE_36BIT_PHYS
69 asm volatile("isync;msync;tlbwe;isync");
72 void invalidate_tlb(u8 tlb
)
84 for (i
= 0; i
< num_tlb_entries
; i
++) {
85 set_tlb(tlb_table
[i
].tlb
, tlb_table
[i
].epn
, tlb_table
[i
].rpn
,
86 tlb_table
[i
].perms
, tlb_table
[i
].wimge
,
87 tlb_table
[i
].ts
, tlb_table
[i
].esel
, tlb_table
[i
].tsize
,
94 unsigned int setup_ddr_tlbs(unsigned int memsize_in_meg
)
96 unsigned int tlb_size
;
97 unsigned int ram_tlb_index
;
98 unsigned int ram_tlb_address
;
101 * Determine size of each TLB1 entry.
103 switch (memsize_in_meg
) {
106 tlb_size
= BOOKE_PAGESZ_16M
;
110 tlb_size
= BOOKE_PAGESZ_64M
;
114 tlb_size
= BOOKE_PAGESZ_256M
;
118 if (PVR_VER(get_pvr()) > PVR_VER(PVR_85xx
))
119 tlb_size
= BOOKE_PAGESZ_1G
;
121 tlb_size
= BOOKE_PAGESZ_256M
;
124 puts("DDR: only 16M, 32M, 64M, 128M, 256M, 512M, 1G"
125 " and 2G are supported.\n");
128 * The memory was not able to be mapped.
129 * Default to a small size.
131 tlb_size
= BOOKE_PAGESZ_64M
;
137 * Configure DDR TLB1 entries.
138 * Starting at TLB1 8, use no more than 8 TLB1 entries.
141 ram_tlb_address
= (unsigned int)CFG_DDR_SDRAM_BASE
;
142 while (ram_tlb_address
< (memsize_in_meg
* 1024 * 1024)
143 && ram_tlb_index
< 16) {
144 set_tlb(1, ram_tlb_address
, ram_tlb_address
,
145 MAS3_SX
|MAS3_SW
|MAS3_SR
, 0,
146 0, ram_tlb_index
, tlb_size
, 1);
148 ram_tlb_address
+= (0x1000 << ((tlb_size
- 1) * 2));
153 * Confirm that the requested amount of memory was mapped.
155 return memsize_in_meg
;