1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (C) 2022, Ovidiu Panait <ovpanait@gmail.com>
6 #ifndef __ASM_MICROBLAZE_PVR_H
7 #define __ASM_MICROBLAZE_PVR_H
11 #define PVR_FULL_COUNT 13 /* PVR0 - PVR12 */
13 #define __get_pvr(val, reg) \
14 __asm__ __volatile__ ("mfs %0," #reg : "=r" (val) :: "memory")
15 #define get_pvr(pvrid, val) \
16 __get_pvr(val, rpvr ## pvrid)
18 #define PVR_MSR_BIT 0x00000400
21 #define PVR0_PVR_FULL_MASK 0x80000000
22 #define PVR0_VERSION_MASK 0x0000FF00
24 /* PVR4 masks - ICache configs */
25 #define PVR4_ICACHE_LINE_LEN_MASK 0x00E00000 /* ICLL */
26 #define PVR4_ICACHE_BYTE_SIZE_MASK 0x001F0000 /* ICBS */
28 /* PVR5 masks - DCache configs */
29 #define PVR5_DCACHE_LINE_LEN_MASK 0x00E00000 /* DCLL */
30 #define PVR5_DCACHE_BYTE_SIZE_MASK 0x001F0000 /* DCBS */
32 /* PVR10 masks - FPGA family */
33 #define PVR10_TARGET_FAMILY_MASK 0xFF000000
35 /* PVR11 masks - MMU */
36 #define PVR11_USE_MMU 0xC0000000
38 /* PVR access macros */
39 #define PVR_VERSION(pvr) \
40 ((pvr[0] & PVR0_VERSION_MASK) >> 8)
42 #define PVR_ICACHE_LINE_LEN(pvr) \
43 ((1 << ((pvr[4] & PVR4_ICACHE_LINE_LEN_MASK) >> 21)) << 2)
44 #define PVR_ICACHE_BYTE_SIZE(pvr) \
45 (1 << ((pvr[4] & PVR4_ICACHE_BYTE_SIZE_MASK) >> 16))
47 #define PVR_DCACHE_LINE_LEN(pvr) \
48 ((1 << ((pvr[5] & PVR5_DCACHE_LINE_LEN_MASK) >> 21)) << 2)
49 #define PVR_DCACHE_BYTE_SIZE(pvr) \
50 (1 << ((pvr[5] & PVR5_DCACHE_BYTE_SIZE_MASK) >> 16))
52 #define PVR_USE_MMU(pvr) \
53 ((pvr[11] & PVR11_USE_MMU) >> 30)
55 #define PVR_TARGET_FAMILY(pvr) \
56 ((pvr[10] & PVR10_TARGET_FAMILY_MASK) >> 24)
59 * microblaze_cpu_has_pvr_full() - Check for full PVR support
61 * Check MSR register for PVR support and, if applicable, check the PVR0
62 * register for full PVR support.
64 * Return: 1 if there is full PVR support, 0 otherwise.
66 int microblaze_cpu_has_pvr_full(void);
69 * microblaze_get_all_pvrs() - Copy PVR0-PVR12 to destination array
71 * @pvr: destination array of size PVR_FULL_COUNT
73 void microblaze_get_all_pvrs(u32 pvr[PVR_FULL_COUNT]);
75 #endif /* __ASM_MICROBLAZE_PVR_H */