xref: /openbmc/linux/arch/xtensa/include/asm/vectors.h (revision 4f6cce39)
1 /*
2  * arch/xtensa/include/asm/xchal_vaddr_remap.h
3  *
4  * Xtensa macros for MMU V3 Support. Deals with re-mapping the Virtual
5  * Memory Addresses from "Virtual == Physical" to their prevvious V2 MMU
6  * mappings (KSEG at 0xD0000000 and KIO at 0XF0000000).
7  *
8  * This file is subject to the terms and conditions of the GNU General Public
9  * License.  See the file "COPYING" in the main directory of this archive
10  * for more details.
11  *
12  * Copyright (C) 2008 - 2012 Tensilica Inc.
13  *
14  * Pete Delaney <piet@tensilica.com>
15  * Marc Gauthier <marc@tensilica.com
16  */
17 
18 #ifndef _XTENSA_VECTORS_H
19 #define _XTENSA_VECTORS_H
20 
21 #include <variant/core.h>
22 #include <platform/hardware.h>
23 #include <asm/kmem_layout.h>
24 
25 #if XCHAL_HAVE_PTP_MMU
26 #define XCHAL_KIO_CACHED_VADDR		0xe0000000
27 #define XCHAL_KIO_BYPASS_VADDR		0xf0000000
28 #define XCHAL_KIO_DEFAULT_PADDR		0xf0000000
29 #else
30 #define XCHAL_KIO_BYPASS_VADDR		XCHAL_KIO_PADDR
31 #define XCHAL_KIO_DEFAULT_PADDR		0x90000000
32 #endif
33 #define XCHAL_KIO_SIZE			0x10000000
34 
35 #if (!XCHAL_HAVE_PTP_MMU || XCHAL_HAVE_SPANNING_WAY) && defined(CONFIG_OF)
36 #define XCHAL_KIO_PADDR			xtensa_get_kio_paddr()
37 #ifndef __ASSEMBLY__
38 extern unsigned long xtensa_kio_paddr;
39 
40 static inline unsigned long xtensa_get_kio_paddr(void)
41 {
42 	return xtensa_kio_paddr;
43 }
44 #endif
45 #else
46 #define XCHAL_KIO_PADDR			XCHAL_KIO_DEFAULT_PADDR
47 #endif
48 
49 #if defined(CONFIG_MMU)
50 
51 #if XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY
52 /* Image Virtual Start Address */
53 #define KERNELOFFSET			(XCHAL_KSEG_CACHED_VADDR + \
54 					 CONFIG_KERNEL_LOAD_ADDRESS - \
55 					 XCHAL_KSEG_PADDR)
56 #else
57 #define KERNELOFFSET			CONFIG_KERNEL_LOAD_ADDRESS
58 #endif
59 
60 #else /* !defined(CONFIG_MMU) */
61   /* MMU Not being used - Virtual == Physical */
62 
63 /* Location of the start of the kernel text, _start */
64 #define KERNELOFFSET			CONFIG_KERNEL_LOAD_ADDRESS
65 
66 
67 #endif /* CONFIG_MMU */
68 
69 #define RESET_VECTOR1_VADDR		(XCHAL_RESET_VECTOR1_VADDR)
70 #ifdef CONFIG_VECTORS_OFFSET
71 #define VECBASE_VADDR			(KERNELOFFSET - CONFIG_VECTORS_OFFSET)
72 #else
73 #define VECBASE_VADDR			_vecbase
74 #endif
75 
76 #if defined(XCHAL_HAVE_VECBASE) && XCHAL_HAVE_VECBASE
77 
78 #define VECTOR_VADDR(offset)		(VECBASE_VADDR + offset)
79 
80 #define USER_VECTOR_VADDR		VECTOR_VADDR(XCHAL_USER_VECOFS)
81 #define KERNEL_VECTOR_VADDR		VECTOR_VADDR(XCHAL_KERNEL_VECOFS)
82 #define DOUBLEEXC_VECTOR_VADDR		VECTOR_VADDR(XCHAL_DOUBLEEXC_VECOFS)
83 #define WINDOW_VECTORS_VADDR		VECTOR_VADDR(XCHAL_WINDOW_OF4_VECOFS)
84 #define INTLEVEL2_VECTOR_VADDR		VECTOR_VADDR(XCHAL_INTLEVEL2_VECOFS)
85 #define INTLEVEL3_VECTOR_VADDR		VECTOR_VADDR(XCHAL_INTLEVEL3_VECOFS)
86 #define INTLEVEL4_VECTOR_VADDR		VECTOR_VADDR(XCHAL_INTLEVEL4_VECOFS)
87 #define INTLEVEL5_VECTOR_VADDR		VECTOR_VADDR(XCHAL_INTLEVEL5_VECOFS)
88 #define INTLEVEL6_VECTOR_VADDR		VECTOR_VADDR(XCHAL_INTLEVEL6_VECOFS)
89 #define INTLEVEL7_VECTOR_VADDR		VECTOR_VADDR(XCHAL_INTLEVEL7_VECOFS)
90 #define DEBUG_VECTOR_VADDR		VECTOR_VADDR(XCHAL_DEBUG_VECOFS)
91 
92 /*
93  * These XCHAL_* #defines from varian/core.h
94  * are not valid to use with V3 MMU. Non-XCHAL
95  * constants are defined above and should be used.
96  */
97 #undef  XCHAL_VECBASE_RESET_VADDR
98 #undef  XCHAL_USER_VECTOR_VADDR
99 #undef  XCHAL_KERNEL_VECTOR_VADDR
100 #undef  XCHAL_DOUBLEEXC_VECTOR_VADDR
101 #undef  XCHAL_WINDOW_VECTORS_VADDR
102 #undef  XCHAL_INTLEVEL2_VECTOR_VADDR
103 #undef  XCHAL_INTLEVEL3_VECTOR_VADDR
104 #undef  XCHAL_INTLEVEL4_VECTOR_VADDR
105 #undef  XCHAL_INTLEVEL5_VECTOR_VADDR
106 #undef  XCHAL_INTLEVEL6_VECTOR_VADDR
107 #undef  XCHAL_INTLEVEL7_VECTOR_VADDR
108 #undef  XCHAL_DEBUG_VECTOR_VADDR
109 
110 #else
111 
112 #define USER_VECTOR_VADDR		XCHAL_USER_VECTOR_VADDR
113 #define KERNEL_VECTOR_VADDR		XCHAL_KERNEL_VECTOR_VADDR
114 #define DOUBLEEXC_VECTOR_VADDR		XCHAL_DOUBLEEXC_VECTOR_VADDR
115 #define WINDOW_VECTORS_VADDR		XCHAL_WINDOW_VECTORS_VADDR
116 #define INTLEVEL2_VECTOR_VADDR		XCHAL_INTLEVEL2_VECTOR_VADDR
117 #define INTLEVEL3_VECTOR_VADDR		XCHAL_INTLEVEL3_VECTOR_VADDR
118 #define INTLEVEL4_VECTOR_VADDR		XCHAL_INTLEVEL4_VECTOR_VADDR
119 #define INTLEVEL5_VECTOR_VADDR		XCHAL_INTLEVEL5_VECTOR_VADDR
120 #define INTLEVEL6_VECTOR_VADDR		XCHAL_INTLEVEL6_VECTOR_VADDR
121 #define INTLEVEL7_VECTOR_VADDR		XCHAL_INTLEVEL6_VECTOR_VADDR
122 #define DEBUG_VECTOR_VADDR		XCHAL_DEBUG_VECTOR_VADDR
123 
124 #endif
125 
126 #endif /* _XTENSA_VECTORS_H */
127