2 * arch/xtensa/include/asm/initialize_mmu.h
6 * For the new V3 MMU we remap the TLB from virtual == physical
7 * to the standard Linux mapping used in earlier MMU's.
9 * The the MMU we also support a new configuration register that
10 * specifies how the S32C1I instruction operates with the cache
13 * This file is subject to the terms and conditions of the GNU General
14 * Public License. See the file "COPYING" in the main directory of
15 * this archive for more details.
17 * Copyright (C) 2008 - 2012 Tensilica, Inc.
19 * Marc Gauthier <marc@tensilica.com>
20 * Pete Delaney <piet@tensilica.com>
23 #ifndef _XTENSA_INITIALIZE_MMU_H
24 #define _XTENSA_INITIALIZE_MMU_H
26 #include <asm/pgtable.h>
27 #include <asm/vectors.h>
29 #if XCHAL_HAVE_PTP_MMU
30 #define CA_BYPASS (_PAGE_CA_BYPASS | _PAGE_HW_WRITE | _PAGE_HW_EXEC)
31 #define CA_WRITEBACK (_PAGE_CA_WB | _PAGE_HW_WRITE | _PAGE_HW_EXEC)
33 #define CA_WRITEBACK (0x4)
36 #ifndef XCHAL_SPANNING_WAY
37 #define XCHAL_SPANNING_WAY 0
42 #define XTENSA_HWVERSION_RC_2009_0 230000
46 #if XCHAL_HAVE_S32C1I && (XCHAL_HW_MIN_VERSION >= XTENSA_HWVERSION_RC_2009_0)
48 * We Have Atomic Operation Control (ATOMCTL) Register; Initialize it.
49 * For details see Documentation/xtensa/atomctl.txt
51 #if XCHAL_DCACHE_IS_COHERENT
52 movi a3
, 0x25 /* For SMP/MX -- internal for writeback,
56 movi a3
, 0x29 /* non-MX -- Most cores use Std Memory
57 * Controlers which usually can't use RCW
61 #endif /* XCHAL_HAVE_S32C1I &&
62 * (XCHAL_HW_MIN_VERSION >= XTENSA_HWVERSION_RC_2009_0)
65 #if defined(CONFIG_MMU) && XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY
70 #if !XCHAL_HAVE_VECBASE
71 # error "MMU v3 requires reloc vectors"
79 1: movi a2
, 0x10000000
81 #if CONFIG_KERNEL_LOAD_ADDRESS < 0x40000000ul
82 #define TEMP_MAPPING_VADDR 0x40000000
84 #define TEMP_MAPPING_VADDR 0x00000000
87 /* Step 1: invalidate mapping at 0x40000000..0x5FFFFFFF. */
89 movi a2
, TEMP_MAPPING_VADDR
| XCHAL_SPANNING_WAY
94 /* Step 2: map 0x40000000..0x47FFFFFF to paddr containing this code
95 * and jump to the new mapping.
100 addi a3
, a3
, CA_BYPASS
101 addi a7
, a2
, 5 - XCHAL_SPANNING_WAY
108 addi a5
, a2
, -XCHAL_SPANNING_WAY
112 /* Step 3: unmap everything other than current area.
113 * Start at 0x60000000, wrap around, and end with 0x20000000
115 2: movi a4
, 0x20000000
122 /* Step 4: Setup MMU with the requested static mappings. */
129 movi a5
, XCHAL_KSEG_CACHED_VADDR
+ XCHAL_KSEG_TLB_WAY
130 movi a4
, XCHAL_KSEG_PADDR
+ CA_WRITEBACK
134 movi a5
, XCHAL_KSEG_BYPASS_VADDR
+ XCHAL_KSEG_TLB_WAY
135 movi a4
, XCHAL_KSEG_PADDR
+ CA_BYPASS
139 #ifdef CONFIG_XTENSA_KSEG_512M
140 movi a5
, XCHAL_KSEG_CACHED_VADDR
+ 0x10000000 + XCHAL_KSEG_TLB_WAY
141 movi a4
, XCHAL_KSEG_PADDR
+ 0x10000000 + CA_WRITEBACK
145 movi a5
, XCHAL_KSEG_BYPASS_VADDR
+ 0x10000000 + XCHAL_KSEG_TLB_WAY
146 movi a4
, XCHAL_KSEG_PADDR
+ 0x10000000 + CA_BYPASS
151 movi a5
, XCHAL_KIO_CACHED_VADDR
+ XCHAL_KIO_TLB_WAY
152 movi a4
, XCHAL_KIO_DEFAULT_PADDR
+ CA_WRITEBACK
156 movi a5
, XCHAL_KIO_BYPASS_VADDR
+ XCHAL_KIO_TLB_WAY
157 movi a4
, XCHAL_KIO_DEFAULT_PADDR
+ CA_BYPASS
163 /* Jump to self, using final mappings. */
168 /* Step 5: remove temporary mapping. */
177 #endif /* defined(CONFIG_MMU) && XCHAL_HAVE_PTP_MMU &&
178 XCHAL_HAVE_SPANNING_WAY */
180 #if !defined(CONFIG_MMU) && XCHAL_HAVE_TLBS && \
181 (XCHAL_DCACHE_SIZE || XCHAL_ICACHE_SIZE)
182 /* Enable data and instruction cache in the DEFAULT_MEMORY region
183 * if the processor has DTLB and ITLB.
186 movi a5
, PLATFORM_DEFAULT_MEM_START
| XCHAL_SPANNING_WAY
187 movi a6
, ~_PAGE_ATTRIB_MASK
188 movi a7
, CA_WRITEBACK
190 movi a9
, PLATFORM_DEFAULT_MEM_SIZE
195 #if XCHAL_DCACHE_SIZE
201 #if XCHAL_ICACHE_SIZE
214 #endif /*__ASSEMBLY__*/
216 #endif /* _XTENSA_INITIALIZE_MMU_H */