xref: /linux/arch/microblaze/include/asm/pvr.h (revision ead5d1f4d877e92c051e1a1ade623d0d30e71619)
1*4726dd60SMichal Simek /* SPDX-License-Identifier: GPL-2.0 */
2b0c62724SMichal Simek /*
3b0c62724SMichal Simek  * Support for the MicroBlaze PVR (Processor Version Register)
4b0c62724SMichal Simek  *
5990dbcc6Sroel kluin  * Copyright (C) 2009 - 2011 Michal Simek <monstr@monstr.eu>
6b0c62724SMichal Simek  * Copyright (C) 2007 John Williams <john.williams@petalogix.com>
7990dbcc6Sroel kluin  * Copyright (C) 2007 - 2011 PetaLogix
8b0c62724SMichal Simek  */
9b0c62724SMichal Simek 
10b0c62724SMichal Simek #ifndef _ASM_MICROBLAZE_PVR_H
11b0c62724SMichal Simek #define _ASM_MICROBLAZE_PVR_H
12b0c62724SMichal Simek 
13b0c62724SMichal Simek #define PVR_MSR_BIT 0x400
14b0c62724SMichal Simek 
15b0c62724SMichal Simek struct pvr_s {
16aee04d76SMichal Simek 	unsigned pvr[12];
17b0c62724SMichal Simek };
18b0c62724SMichal Simek 
19b0c62724SMichal Simek /* The following taken from Xilinx's standalone BSP pvr.h */
20b0c62724SMichal Simek 
21b0c62724SMichal Simek /* Basic PVR mask */
22b0c62724SMichal Simek #define PVR0_PVR_FULL_MASK		0x80000000
23b0c62724SMichal Simek #define PVR0_USE_BARREL_MASK		0x40000000
24b0c62724SMichal Simek #define PVR0_USE_DIV_MASK		0x20000000
25b0c62724SMichal Simek #define PVR0_USE_HW_MUL_MASK		0x10000000
26b0c62724SMichal Simek #define PVR0_USE_FPU_MASK		0x08000000
27b0c62724SMichal Simek #define PVR0_USE_EXC_MASK		0x04000000
28b0c62724SMichal Simek #define PVR0_USE_ICACHE_MASK		0x02000000
29b0c62724SMichal Simek #define PVR0_USE_DCACHE_MASK		0x01000000
306d5f2f6dSMichal Simek #define PVR0_USE_MMU			0x00800000
316d5f2f6dSMichal Simek #define PVR0_USE_BTC			0x00400000
328e2ad016SMichal Simek #define PVR0_ENDI			0x00200000
33b0c62724SMichal Simek #define PVR0_VERSION_MASK		0x0000FF00
34b0c62724SMichal Simek #define PVR0_USER1_MASK			0x000000FF
35b0c62724SMichal Simek 
36b0c62724SMichal Simek /* User 2 PVR mask */
37b0c62724SMichal Simek #define PVR1_USER2_MASK			0xFFFFFFFF
38b0c62724SMichal Simek 
39b0c62724SMichal Simek /* Configuration PVR masks */
40b4dcaee5SMichal Simek #define PVR2_D_OPB_MASK			0x80000000 /* or AXI */
41b0c62724SMichal Simek #define PVR2_D_LMB_MASK			0x40000000
42b4dcaee5SMichal Simek #define PVR2_I_OPB_MASK			0x20000000 /* or AXI */
43b0c62724SMichal Simek #define PVR2_I_LMB_MASK			0x10000000
44b0c62724SMichal Simek #define PVR2_INTERRUPT_IS_EDGE_MASK	0x08000000
45b0c62724SMichal Simek #define PVR2_EDGE_IS_POSITIVE_MASK	0x04000000
46b0c62724SMichal Simek #define PVR2_D_PLB_MASK			0x02000000 /* new */
47b0c62724SMichal Simek #define PVR2_I_PLB_MASK			0x01000000 /* new */
48b0c62724SMichal Simek #define PVR2_INTERCONNECT		0x00800000 /* new */
49b0c62724SMichal Simek #define PVR2_USE_EXTEND_FSL		0x00080000 /* new */
50b0c62724SMichal Simek #define PVR2_USE_FSL_EXC		0x00040000 /* new */
51b0c62724SMichal Simek #define PVR2_USE_MSR_INSTR		0x00020000
52b0c62724SMichal Simek #define PVR2_USE_PCMP_INSTR		0x00010000
53b0c62724SMichal Simek #define PVR2_AREA_OPTIMISED		0x00008000
54b0c62724SMichal Simek #define PVR2_USE_BARREL_MASK		0x00004000
55b0c62724SMichal Simek #define PVR2_USE_DIV_MASK		0x00002000
56b0c62724SMichal Simek #define PVR2_USE_HW_MUL_MASK		0x00001000
57b0c62724SMichal Simek #define PVR2_USE_FPU_MASK		0x00000800
58b0c62724SMichal Simek #define PVR2_USE_MUL64_MASK		0x00000400
59b0c62724SMichal Simek #define PVR2_USE_FPU2_MASK		0x00000200 /* new */
60b0c62724SMichal Simek #define PVR2_USE_IPLBEXC 		0x00000100
61b0c62724SMichal Simek #define PVR2_USE_DPLBEXC		0x00000080
62b0c62724SMichal Simek #define PVR2_OPCODE_0x0_ILL_MASK	0x00000040
63b0c62724SMichal Simek #define PVR2_UNALIGNED_EXC_MASK		0x00000020
64b0c62724SMichal Simek #define PVR2_ILL_OPCODE_EXC_MASK	0x00000010
65b4dcaee5SMichal Simek #define PVR2_IOPB_BUS_EXC_MASK		0x00000008 /* or AXI */
66b4dcaee5SMichal Simek #define PVR2_DOPB_BUS_EXC_MASK		0x00000004 /* or AXI */
67b0c62724SMichal Simek #define PVR2_DIV_ZERO_EXC_MASK		0x00000002
68b0c62724SMichal Simek #define PVR2_FPU_EXC_MASK		0x00000001
69b0c62724SMichal Simek 
70b0c62724SMichal Simek /* Debug and exception PVR masks */
71b0c62724SMichal Simek #define PVR3_DEBUG_ENABLED_MASK		0x80000000
72b0c62724SMichal Simek #define PVR3_NUMBER_OF_PC_BRK_MASK	0x1E000000
73b0c62724SMichal Simek #define PVR3_NUMBER_OF_RD_ADDR_BRK_MASK	0x00380000
74b0c62724SMichal Simek #define PVR3_NUMBER_OF_WR_ADDR_BRK_MASK	0x0000E000
75b0c62724SMichal Simek #define PVR3_FSL_LINKS_MASK		0x00000380
76b0c62724SMichal Simek 
77b0c62724SMichal Simek /* ICache config PVR masks */
78f6e1f1b4SMichal Simek #define PVR4_USE_ICACHE_MASK		0x80000000 /* ICU */
79f6e1f1b4SMichal Simek #define PVR4_ICACHE_ADDR_TAG_BITS_MASK	0x7C000000 /* ICTS */
80f6e1f1b4SMichal Simek #define PVR4_ICACHE_ALLOW_WR_MASK	0x01000000 /* ICW */
81f6e1f1b4SMichal Simek #define PVR4_ICACHE_LINE_LEN_MASK	0x00E00000 /* ICLL */
82f6e1f1b4SMichal Simek #define PVR4_ICACHE_BYTE_SIZE_MASK	0x001F0000 /* ICBS */
83f6e1f1b4SMichal Simek #define PVR4_ICACHE_ALWAYS_USED		0x00008000 /* IAU */
84f6e1f1b4SMichal Simek #define PVR4_ICACHE_INTERFACE		0x00002000 /* ICI */
85b0c62724SMichal Simek 
86b0c62724SMichal Simek /* DCache config PVR masks */
87f6e1f1b4SMichal Simek #define PVR5_USE_DCACHE_MASK		0x80000000 /* DCU */
88f6e1f1b4SMichal Simek #define PVR5_DCACHE_ADDR_TAG_BITS_MASK	0x7C000000 /* DCTS */
89f6e1f1b4SMichal Simek #define PVR5_DCACHE_ALLOW_WR_MASK	0x01000000 /* DCW */
90f6e1f1b4SMichal Simek #define PVR5_DCACHE_LINE_LEN_MASK	0x00E00000 /* DCLL */
91f6e1f1b4SMichal Simek #define PVR5_DCACHE_BYTE_SIZE_MASK	0x001F0000 /* DCBS */
92f6e1f1b4SMichal Simek #define PVR5_DCACHE_ALWAYS_USED		0x00008000 /* DAU */
93f6e1f1b4SMichal Simek #define PVR5_DCACHE_USE_WRITEBACK	0x00004000 /* DWB */
94f6e1f1b4SMichal Simek #define PVR5_DCACHE_INTERFACE		0x00002000 /* DCI */
95b0c62724SMichal Simek 
96b0c62724SMichal Simek /* ICache base address PVR mask */
97b0c62724SMichal Simek #define PVR6_ICACHE_BASEADDR_MASK	0xFFFFFFFF
98b0c62724SMichal Simek 
99b0c62724SMichal Simek /* ICache high address PVR mask */
100b0c62724SMichal Simek #define PVR7_ICACHE_HIGHADDR_MASK	0xFFFFFFFF
101b0c62724SMichal Simek 
102b0c62724SMichal Simek /* DCache base address PVR mask */
103b0c62724SMichal Simek #define PVR8_DCACHE_BASEADDR_MASK	0xFFFFFFFF
104b0c62724SMichal Simek 
105b0c62724SMichal Simek /* DCache high address PVR mask */
106b0c62724SMichal Simek #define PVR9_DCACHE_HIGHADDR_MASK	0xFFFFFFFF
107b0c62724SMichal Simek 
108b0c62724SMichal Simek /* Target family PVR mask */
109b0c62724SMichal Simek #define PVR10_TARGET_FAMILY_MASK	0xFF000000
110b0c62724SMichal Simek 
1115db34eb9SMichal Simek /* MMU description */
112b0c62724SMichal Simek #define PVR11_USE_MMU			0xC0000000
113b0c62724SMichal Simek #define PVR11_MMU_ITLB_SIZE		0x38000000
114b0c62724SMichal Simek #define PVR11_MMU_DTLB_SIZE		0x07000000
115b0c62724SMichal Simek #define PVR11_MMU_TLB_ACCESS		0x00C00000
116b0c62724SMichal Simek #define PVR11_MMU_ZONES			0x003C0000
1178904976eSJohn A. Williams #define PVR11_MMU_PRIVINS		0x00010000
118b0c62724SMichal Simek /* MSR Reset value PVR mask */
119b0c62724SMichal Simek #define PVR11_MSR_RESET_VALUE_MASK	0x000007FF
120b0c62724SMichal Simek 
121b0c62724SMichal Simek /* PVR access macros */
122990dbcc6Sroel kluin #define PVR_IS_FULL(_pvr)	(_pvr.pvr[0] & PVR0_PVR_FULL_MASK)
123990dbcc6Sroel kluin #define PVR_USE_BARREL(_pvr)	(_pvr.pvr[0] & PVR0_USE_BARREL_MASK)
124990dbcc6Sroel kluin #define PVR_USE_DIV(_pvr)	(_pvr.pvr[0] & PVR0_USE_DIV_MASK)
125990dbcc6Sroel kluin #define PVR_USE_HW_MUL(_pvr)	(_pvr.pvr[0] & PVR0_USE_HW_MUL_MASK)
126990dbcc6Sroel kluin #define PVR_USE_FPU(_pvr)	(_pvr.pvr[0] & PVR0_USE_FPU_MASK)
127990dbcc6Sroel kluin #define PVR_USE_FPU2(_pvr)	(_pvr.pvr[2] & PVR2_USE_FPU2_MASK)
128990dbcc6Sroel kluin #define PVR_USE_ICACHE(_pvr)	(_pvr.pvr[0] & PVR0_USE_ICACHE_MASK)
129990dbcc6Sroel kluin #define PVR_USE_DCACHE(_pvr)	(_pvr.pvr[0] & PVR0_USE_DCACHE_MASK)
130990dbcc6Sroel kluin #define PVR_VERSION(_pvr)	((_pvr.pvr[0] & PVR0_VERSION_MASK) >> 8)
131990dbcc6Sroel kluin #define PVR_USER1(_pvr)		(_pvr.pvr[0] & PVR0_USER1_MASK)
132990dbcc6Sroel kluin #define PVR_USER2(_pvr)		(_pvr.pvr[1] & PVR1_USER2_MASK)
133b0c62724SMichal Simek 
134990dbcc6Sroel kluin #define PVR_D_OPB(_pvr)		(_pvr.pvr[2] & PVR2_D_OPB_MASK)
135990dbcc6Sroel kluin #define PVR_D_LMB(_pvr)		(_pvr.pvr[2] & PVR2_D_LMB_MASK)
136990dbcc6Sroel kluin #define PVR_I_OPB(_pvr)		(_pvr.pvr[2] & PVR2_I_OPB_MASK)
137990dbcc6Sroel kluin #define PVR_I_LMB(_pvr)		(_pvr.pvr[2] & PVR2_I_LMB_MASK)
138990dbcc6Sroel kluin #define PVR_INTERRUPT_IS_EDGE(_pvr) \
139990dbcc6Sroel kluin 			(_pvr.pvr[2] & PVR2_INTERRUPT_IS_EDGE_MASK)
140990dbcc6Sroel kluin #define PVR_EDGE_IS_POSITIVE(_pvr) \
141990dbcc6Sroel kluin 			(_pvr.pvr[2] & PVR2_EDGE_IS_POSITIVE_MASK)
142990dbcc6Sroel kluin #define PVR_USE_MSR_INSTR(_pvr)		(_pvr.pvr[2] & PVR2_USE_MSR_INSTR)
143990dbcc6Sroel kluin #define PVR_USE_PCMP_INSTR(_pvr)	(_pvr.pvr[2] & PVR2_USE_PCMP_INSTR)
144990dbcc6Sroel kluin #define PVR_AREA_OPTIMISED(_pvr)	(_pvr.pvr[2] & PVR2_AREA_OPTIMISED)
145990dbcc6Sroel kluin #define PVR_USE_MUL64(_pvr)		(_pvr.pvr[2] & PVR2_USE_MUL64_MASK)
146990dbcc6Sroel kluin #define PVR_OPCODE_0x0_ILLEGAL(_pvr) \
147990dbcc6Sroel kluin 			(_pvr.pvr[2] & PVR2_OPCODE_0x0_ILL_MASK)
148990dbcc6Sroel kluin #define PVR_UNALIGNED_EXCEPTION(_pvr) \
149990dbcc6Sroel kluin 			(_pvr.pvr[2] & PVR2_UNALIGNED_EXC_MASK)
150990dbcc6Sroel kluin #define PVR_ILL_OPCODE_EXCEPTION(_pvr) \
151990dbcc6Sroel kluin 			(_pvr.pvr[2] & PVR2_ILL_OPCODE_EXC_MASK)
152990dbcc6Sroel kluin #define PVR_IOPB_BUS_EXCEPTION(_pvr) \
153990dbcc6Sroel kluin 			(_pvr.pvr[2] & PVR2_IOPB_BUS_EXC_MASK)
154990dbcc6Sroel kluin #define PVR_DOPB_BUS_EXCEPTION(_pvr) \
155990dbcc6Sroel kluin 			(_pvr.pvr[2] & PVR2_DOPB_BUS_EXC_MASK)
156990dbcc6Sroel kluin #define PVR_DIV_ZERO_EXCEPTION(_pvr) \
157990dbcc6Sroel kluin 			(_pvr.pvr[2] & PVR2_DIV_ZERO_EXC_MASK)
158990dbcc6Sroel kluin #define PVR_FPU_EXCEPTION(_pvr)		(_pvr.pvr[2] & PVR2_FPU_EXC_MASK)
159990dbcc6Sroel kluin #define PVR_FSL_EXCEPTION(_pvr)		(_pvr.pvr[2] & PVR2_USE_EXTEND_FSL)
160b0c62724SMichal Simek 
161990dbcc6Sroel kluin #define PVR_DEBUG_ENABLED(_pvr)		(_pvr.pvr[3] & PVR3_DEBUG_ENABLED_MASK)
162990dbcc6Sroel kluin #define PVR_NUMBER_OF_PC_BRK(_pvr) \
163990dbcc6Sroel kluin 			((_pvr.pvr[3] & PVR3_NUMBER_OF_PC_BRK_MASK) >> 25)
164990dbcc6Sroel kluin #define PVR_NUMBER_OF_RD_ADDR_BRK(_pvr) \
165990dbcc6Sroel kluin 			((_pvr.pvr[3] & PVR3_NUMBER_OF_RD_ADDR_BRK_MASK) >> 19)
166990dbcc6Sroel kluin #define PVR_NUMBER_OF_WR_ADDR_BRK(_pvr) \
167990dbcc6Sroel kluin 			((_pvr.pvr[3] & PVR3_NUMBER_OF_WR_ADDR_BRK_MASK) >> 13)
168990dbcc6Sroel kluin #define PVR_FSL_LINKS(_pvr)	((_pvr.pvr[3] & PVR3_FSL_LINKS_MASK) >> 7)
169b0c62724SMichal Simek 
170990dbcc6Sroel kluin #define PVR_ICACHE_ADDR_TAG_BITS(_pvr) \
171990dbcc6Sroel kluin 		((_pvr.pvr[4] & PVR4_ICACHE_ADDR_TAG_BITS_MASK) >> 26)
172990dbcc6Sroel kluin #define PVR_ICACHE_USE_FSL(_pvr) \
173990dbcc6Sroel kluin 		(_pvr.pvr[4] & PVR4_ICACHE_USE_FSL_MASK)
174990dbcc6Sroel kluin #define PVR_ICACHE_ALLOW_WR(_pvr) \
175990dbcc6Sroel kluin 		(_pvr.pvr[4] & PVR4_ICACHE_ALLOW_WR_MASK)
176990dbcc6Sroel kluin #define PVR_ICACHE_LINE_LEN(_pvr) \
177990dbcc6Sroel kluin 		(1 << ((_pvr.pvr[4] & PVR4_ICACHE_LINE_LEN_MASK) >> 21))
178990dbcc6Sroel kluin #define PVR_ICACHE_BYTE_SIZE(_pvr) \
179990dbcc6Sroel kluin 		(1 << ((_pvr.pvr[4] & PVR4_ICACHE_BYTE_SIZE_MASK) >> 16))
180b0c62724SMichal Simek 
181990dbcc6Sroel kluin #define PVR_DCACHE_ADDR_TAG_BITS(_pvr) \
182990dbcc6Sroel kluin 			((_pvr.pvr[5] & PVR5_DCACHE_ADDR_TAG_BITS_MASK) >> 26)
183990dbcc6Sroel kluin #define PVR_DCACHE_USE_FSL(_pvr)	(_pvr.pvr[5] & PVR5_DCACHE_USE_FSL_MASK)
184990dbcc6Sroel kluin #define PVR_DCACHE_ALLOW_WR(_pvr) \
185990dbcc6Sroel kluin 			(_pvr.pvr[5] & PVR5_DCACHE_ALLOW_WR_MASK)
186f6e1f1b4SMichal Simek /* FIXME two shifts on one line needs any comment */
187990dbcc6Sroel kluin #define PVR_DCACHE_LINE_LEN(_pvr) \
188990dbcc6Sroel kluin 		(1 << ((_pvr.pvr[5] & PVR5_DCACHE_LINE_LEN_MASK) >> 21))
189990dbcc6Sroel kluin #define PVR_DCACHE_BYTE_SIZE(_pvr) \
190990dbcc6Sroel kluin 		(1 << ((_pvr.pvr[5] & PVR5_DCACHE_BYTE_SIZE_MASK) >> 16))
191b0c62724SMichal Simek 
192990dbcc6Sroel kluin #define PVR_DCACHE_USE_WRITEBACK(_pvr) \
193990dbcc6Sroel kluin 			((_pvr.pvr[5] & PVR5_DCACHE_USE_WRITEBACK) >> 14)
194b0c62724SMichal Simek 
195990dbcc6Sroel kluin #define PVR_ICACHE_BASEADDR(_pvr) \
196990dbcc6Sroel kluin 			(_pvr.pvr[6] & PVR6_ICACHE_BASEADDR_MASK)
197990dbcc6Sroel kluin #define PVR_ICACHE_HIGHADDR(_pvr) \
198990dbcc6Sroel kluin 			(_pvr.pvr[7] & PVR7_ICACHE_HIGHADDR_MASK)
199990dbcc6Sroel kluin #define PVR_DCACHE_BASEADDR(_pvr) \
200990dbcc6Sroel kluin 			(_pvr.pvr[8] & PVR8_DCACHE_BASEADDR_MASK)
201990dbcc6Sroel kluin #define PVR_DCACHE_HIGHADDR(_pvr) \
202990dbcc6Sroel kluin 			(_pvr.pvr[9] & PVR9_DCACHE_HIGHADDR_MASK)
203b0c62724SMichal Simek 
204990dbcc6Sroel kluin #define PVR_TARGET_FAMILY(_pvr) \
205990dbcc6Sroel kluin 			((_pvr.pvr[10] & PVR10_TARGET_FAMILY_MASK) >> 24)
206b0c62724SMichal Simek 
207990dbcc6Sroel kluin #define PVR_MSR_RESET_VALUE(_pvr) \
208990dbcc6Sroel kluin 			(_pvr.pvr[11] & PVR11_MSR_RESET_VALUE_MASK)
209b0c62724SMichal Simek 
210b0c62724SMichal Simek /* mmu */
211990dbcc6Sroel kluin #define PVR_USE_MMU(_pvr)		((_pvr.pvr[11] & PVR11_USE_MMU) >> 30)
212990dbcc6Sroel kluin #define PVR_MMU_ITLB_SIZE(_pvr)		(_pvr.pvr[11] & PVR11_MMU_ITLB_SIZE)
213990dbcc6Sroel kluin #define PVR_MMU_DTLB_SIZE(_pvr)		(_pvr.pvr[11] & PVR11_MMU_DTLB_SIZE)
214990dbcc6Sroel kluin #define PVR_MMU_TLB_ACCESS(_pvr)	(_pvr.pvr[11] & PVR11_MMU_TLB_ACCESS)
215990dbcc6Sroel kluin #define PVR_MMU_ZONES(_pvr)		(_pvr.pvr[11] & PVR11_MMU_ZONES)
2168904976eSJohn A. Williams #define PVR_MMU_PRIVINS(pvr)		(pvr.pvr[11] & PVR11_MMU_PRIVINS)
217b0c62724SMichal Simek 
2188e2ad016SMichal Simek /* endian */
219990dbcc6Sroel kluin #define PVR_ENDIAN(_pvr)	(_pvr.pvr[0] & PVR0_ENDI)
220b0c62724SMichal Simek 
221b0c62724SMichal Simek int cpu_has_pvr(void);
222b0c62724SMichal Simek void get_pvr(struct pvr_s *pvr);
223b0c62724SMichal Simek 
224b0c62724SMichal Simek #endif /* _ASM_MICROBLAZE_PVR_H */
225