1360275b3SKumar Gala /*
2360275b3SKumar Gala  * Copyright 2008-2011 Freescale Semiconductor, Inc.
3360275b3SKumar Gala  *
4360275b3SKumar Gala  * (C) Copyright 2000
5360275b3SKumar Gala  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6360275b3SKumar Gala  *
7360275b3SKumar Gala  * See file CREDITS for list of people who contributed to this
8360275b3SKumar Gala  * project.
9360275b3SKumar Gala  *
10360275b3SKumar Gala  * This program is free software; you can redistribute it and/or
11360275b3SKumar Gala  * modify it under the terms of the GNU General Public License as
12360275b3SKumar Gala  * published by the Free Software Foundation; either version 2 of
13360275b3SKumar Gala  * the License, or (at your option) any later version.
14360275b3SKumar Gala  *
15360275b3SKumar Gala  * This program is distributed in the hope that it will be useful,
16360275b3SKumar Gala  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17360275b3SKumar Gala  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18360275b3SKumar Gala  * GNU General Public License for more details.
19360275b3SKumar Gala  *
20360275b3SKumar Gala  * You should have received a copy of the GNU General Public License
21360275b3SKumar Gala  * along with this program; if not, write to the Free Software
22360275b3SKumar Gala  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23360275b3SKumar Gala  * MA 02111-1307 USA
24360275b3SKumar Gala  */
25360275b3SKumar Gala 
26360275b3SKumar Gala #include <common.h>
27360275b3SKumar Gala #include <asm/mmu.h>
28360275b3SKumar Gala 
29360275b3SKumar Gala struct fsl_e_tlb_entry tlb_table[] = {
30360275b3SKumar Gala 	/* TLB 0 - for temp stack in cache */
31360275b3SKumar Gala 	SET_TLB_ENTRY(0, CONFIG_SYS_INIT_RAM_ADDR,
32360275b3SKumar Gala 		      CONFIG_SYS_INIT_RAM_ADDR_PHYS,
33360275b3SKumar Gala 		      MAS3_SW|MAS3_SR, 0,
34360275b3SKumar Gala 		      0, 0, BOOKE_PAGESZ_4K, 0),
35360275b3SKumar Gala 	SET_TLB_ENTRY(0, CONFIG_SYS_INIT_RAM_ADDR + 4 * 1024,
36360275b3SKumar Gala 		      CONFIG_SYS_INIT_RAM_ADDR_PHYS + 4 * 1024,
37360275b3SKumar Gala 		      MAS3_SW|MAS3_SR, 0,
38360275b3SKumar Gala 		      0, 0, BOOKE_PAGESZ_4K, 0),
39360275b3SKumar Gala 	SET_TLB_ENTRY(0, CONFIG_SYS_INIT_RAM_ADDR + 8 * 1024,
40360275b3SKumar Gala 		      CONFIG_SYS_INIT_RAM_ADDR_PHYS + 8 * 1024,
41360275b3SKumar Gala 		      MAS3_SW|MAS3_SR, 0,
42360275b3SKumar Gala 		      0, 0, BOOKE_PAGESZ_4K, 0),
43360275b3SKumar Gala 	SET_TLB_ENTRY(0, CONFIG_SYS_INIT_RAM_ADDR + 12 * 1024,
44360275b3SKumar Gala 		      CONFIG_SYS_INIT_RAM_ADDR_PHYS + 12 * 1024,
45360275b3SKumar Gala 		      MAS3_SW|MAS3_SR, 0,
46360275b3SKumar Gala 		      0, 0, BOOKE_PAGESZ_4K, 0),
47f8bc7bb5SKumar Gala #ifdef CPLD_BASE
48f8bc7bb5SKumar Gala 	SET_TLB_ENTRY(0, CPLD_BASE, CPLD_BASE_PHYS,
49f8bc7bb5SKumar Gala 		      MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
50f8bc7bb5SKumar Gala 		      0, 0, BOOKE_PAGESZ_4K, 0),
51f8bc7bb5SKumar Gala #endif
52360275b3SKumar Gala 
53f8bc7bb5SKumar Gala #ifdef PIXIS_BASE
54360275b3SKumar Gala 	SET_TLB_ENTRY(0, PIXIS_BASE, PIXIS_BASE_PHYS,
55360275b3SKumar Gala 		      MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
56360275b3SKumar Gala 		      0, 0, BOOKE_PAGESZ_4K, 0),
57f8bc7bb5SKumar Gala #endif
58360275b3SKumar Gala 
59360275b3SKumar Gala 	/* TLB 1 */
60360275b3SKumar Gala 	/* *I*** - Covers boot page */
61360275b3SKumar Gala #if defined(CONFIG_SYS_RAMBOOT) && defined(CONFIG_SYS_INIT_L3_ADDR)
62360275b3SKumar Gala 	/*
63360275b3SKumar Gala 	 * *I*G - L3SRAM. When L3 is used as 1M SRAM, the address of the
64360275b3SKumar Gala 	 * SRAM is at 0xfff00000, it covered the 0xfffff000.
65360275b3SKumar Gala 	 */
66360275b3SKumar Gala 	SET_TLB_ENTRY(1, CONFIG_SYS_INIT_L3_ADDR, CONFIG_SYS_INIT_L3_ADDR,
67360275b3SKumar Gala 			MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
68360275b3SKumar Gala 			0, 0, BOOKE_PAGESZ_1M, 1),
69*292dc6c5SLiu Gang #elif defined(CONFIG_SRIOBOOT_SLAVE)
70*292dc6c5SLiu Gang 	/*
71*292dc6c5SLiu Gang 	 * SRIOBOOT-SLAVE. When slave boot, the address of the
72*292dc6c5SLiu Gang 	 * space is at 0xfff00000, it covered the 0xfffff000.
73*292dc6c5SLiu Gang 	 */
74*292dc6c5SLiu Gang 	SET_TLB_ENTRY(1, CONFIG_SYS_SRIOBOOT_SLAVE_ADDR,
75*292dc6c5SLiu Gang 			CONFIG_SYS_SRIOBOOT_SLAVE_ADDR_PHYS,
76*292dc6c5SLiu Gang 			MAS3_SX|MAS3_SW|MAS3_SR, MAS2_W|MAS2_G,
77*292dc6c5SLiu Gang 			0, 0, BOOKE_PAGESZ_1M, 1),
78360275b3SKumar Gala #else
79360275b3SKumar Gala 	SET_TLB_ENTRY(1, 0xfffff000, 0xfffff000,
80360275b3SKumar Gala 		      MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
81360275b3SKumar Gala 		      0, 0, BOOKE_PAGESZ_4K, 1),
82360275b3SKumar Gala #endif
83360275b3SKumar Gala 
84360275b3SKumar Gala 	/* *I*G* - CCSRBAR */
85360275b3SKumar Gala 	SET_TLB_ENTRY(1, CONFIG_SYS_CCSRBAR, CONFIG_SYS_CCSRBAR_PHYS,
86360275b3SKumar Gala 		      MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
87360275b3SKumar Gala 		      0, 1, BOOKE_PAGESZ_16M, 1),
88360275b3SKumar Gala 
89360275b3SKumar Gala 	/* *I*G* - Flash, localbus */
90360275b3SKumar Gala 	/* This will be changed to *I*G* after relocation to RAM. */
91360275b3SKumar Gala 	SET_TLB_ENTRY(1, CONFIG_SYS_FLASH_BASE, CONFIG_SYS_FLASH_BASE_PHYS,
92360275b3SKumar Gala 		      MAS3_SX|MAS3_SR, MAS2_W|MAS2_G,
93360275b3SKumar Gala 		      0, 2, BOOKE_PAGESZ_256M, 1),
94360275b3SKumar Gala 
95360275b3SKumar Gala 	/* *I*G* - PCI */
96360275b3SKumar Gala 	SET_TLB_ENTRY(1, CONFIG_SYS_PCIE1_MEM_VIRT, CONFIG_SYS_PCIE1_MEM_PHYS,
97360275b3SKumar Gala 		      MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
98360275b3SKumar Gala 		      0, 3, BOOKE_PAGESZ_1G, 1),
99360275b3SKumar Gala 
100360275b3SKumar Gala 	/* *I*G* - PCI */
101360275b3SKumar Gala 	SET_TLB_ENTRY(1, CONFIG_SYS_PCIE1_MEM_VIRT + 0x40000000,
102360275b3SKumar Gala 		      CONFIG_SYS_PCIE1_MEM_PHYS + 0x40000000,
103360275b3SKumar Gala 		      MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
104360275b3SKumar Gala 		      0, 4, BOOKE_PAGESZ_256M, 1),
105360275b3SKumar Gala 
106360275b3SKumar Gala 	SET_TLB_ENTRY(1, CONFIG_SYS_PCIE1_MEM_VIRT + 0x50000000,
107360275b3SKumar Gala 		      CONFIG_SYS_PCIE1_MEM_PHYS + 0x50000000,
108360275b3SKumar Gala 		      MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
109360275b3SKumar Gala 		      0, 5, BOOKE_PAGESZ_256M, 1),
110360275b3SKumar Gala 
111360275b3SKumar Gala 	/* *I*G* - PCI I/O */
112360275b3SKumar Gala 	SET_TLB_ENTRY(1, CONFIG_SYS_PCIE1_IO_VIRT, CONFIG_SYS_PCIE1_IO_PHYS,
113360275b3SKumar Gala 		      MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
114360275b3SKumar Gala 		      0, 6, BOOKE_PAGESZ_256K, 1),
115360275b3SKumar Gala 
116360275b3SKumar Gala 	/* Bman/Qman */
117360275b3SKumar Gala #ifdef CONFIG_SYS_BMAN_MEM_PHYS
118360275b3SKumar Gala 	SET_TLB_ENTRY(1, CONFIG_SYS_BMAN_MEM_BASE, CONFIG_SYS_BMAN_MEM_PHYS,
119360275b3SKumar Gala 		      MAS3_SW|MAS3_SR, 0,
120360275b3SKumar Gala 		      0, 9, BOOKE_PAGESZ_1M, 1),
121360275b3SKumar Gala 	SET_TLB_ENTRY(1, CONFIG_SYS_BMAN_MEM_BASE + 0x00100000,
122360275b3SKumar Gala 		      CONFIG_SYS_BMAN_MEM_PHYS + 0x00100000,
123360275b3SKumar Gala 		      MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
124360275b3SKumar Gala 		      0, 10, BOOKE_PAGESZ_1M, 1),
125360275b3SKumar Gala #endif
126360275b3SKumar Gala #ifdef CONFIG_SYS_QMAN_MEM_PHYS
127360275b3SKumar Gala 	SET_TLB_ENTRY(1, CONFIG_SYS_QMAN_MEM_BASE, CONFIG_SYS_QMAN_MEM_PHYS,
128360275b3SKumar Gala 		      MAS3_SW|MAS3_SR, 0,
129360275b3SKumar Gala 		      0, 11, BOOKE_PAGESZ_1M, 1),
130360275b3SKumar Gala 	SET_TLB_ENTRY(1, CONFIG_SYS_QMAN_MEM_BASE + 0x00100000,
131360275b3SKumar Gala 		      CONFIG_SYS_QMAN_MEM_PHYS + 0x00100000,
132360275b3SKumar Gala 		      MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
133360275b3SKumar Gala 		      0, 12, BOOKE_PAGESZ_1M, 1),
134360275b3SKumar Gala #endif
135360275b3SKumar Gala #ifdef CONFIG_SYS_DCSRBAR_PHYS
136360275b3SKumar Gala 	SET_TLB_ENTRY(1, CONFIG_SYS_DCSRBAR, CONFIG_SYS_DCSRBAR_PHYS,
137360275b3SKumar Gala 		      MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
138360275b3SKumar Gala 		      0, 13, BOOKE_PAGESZ_4M, 1),
139360275b3SKumar Gala #endif
140360275b3SKumar Gala #ifdef CONFIG_SYS_NAND_BASE
141360275b3SKumar Gala 	/*
142360275b3SKumar Gala 	 * *I*G - NAND
143360275b3SKumar Gala 	 * entry 14 and 15 has been used hard coded, they will be disabled
144360275b3SKumar Gala 	 * in cpu_init_f, so we use entry 16 for nand.
145360275b3SKumar Gala 	 */
146360275b3SKumar Gala 	SET_TLB_ENTRY(1, CONFIG_SYS_NAND_BASE, CONFIG_SYS_NAND_BASE_PHYS,
147360275b3SKumar Gala 			MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
148360275b3SKumar Gala 			0, 16, BOOKE_PAGESZ_1M, 1),
149360275b3SKumar Gala #endif
150360275b3SKumar Gala };
151360275b3SKumar Gala 
152360275b3SKumar Gala int num_tlb_entries = ARRAY_SIZE(tlb_table);
153