1 /* SPDX-License-Identifier: GPL-2.0
2  *
3  * Copyright 2016-2018 HabanaLabs, Ltd.
4  * All Rights Reserved.
5  *
6  */
7 
8 #ifndef INCLUDE_MMU_GENERAL_H_
9 #define INCLUDE_MMU_GENERAL_H_
10 
11 #define PAGE_SHIFT_4KB			12
12 #define PAGE_SHIFT_2MB			21
13 #define PAGE_SIZE_2MB			(_AC(1, UL) << PAGE_SHIFT_2MB)
14 #define PAGE_SIZE_4KB			(_AC(1, UL) << PAGE_SHIFT_4KB)
15 #define PAGE_MASK_2MB			(~(PAGE_SIZE_2MB - 1))
16 
17 #define PAGE_PRESENT_MASK		0x0000000000001ull
18 #define SWAP_OUT_MASK			0x0000000000004ull
19 #define LAST_MASK			0x0000000000800ull
20 #define PHYS_ADDR_MASK			0xFFFFFFFFFFFFF000ull
21 #define HOP0_MASK			0x3000000000000ull
22 #define HOP1_MASK			0x0FF8000000000ull
23 #define HOP2_MASK			0x0007FC0000000ull
24 #define HOP3_MASK			0x000003FE00000ull
25 #define HOP4_MASK			0x00000001FF000ull
26 #define OFFSET_MASK			0x0000000000FFFull
27 
28 #define HOP0_SHIFT			48
29 #define HOP1_SHIFT			39
30 #define HOP2_SHIFT			30
31 #define HOP3_SHIFT			21
32 #define HOP4_SHIFT			12
33 
34 #define PTE_PHYS_ADDR_SHIFT		12
35 #define PTE_PHYS_ADDR_MASK		~OFFSET_MASK
36 
37 #define HL_PTE_SIZE			sizeof(u64)
38 #define HOP_TABLE_SIZE			PAGE_SIZE_4KB
39 #define PTE_ENTRIES_IN_HOP		(HOP_TABLE_SIZE / HL_PTE_SIZE)
40 #define HOP0_TABLES_TOTAL_SIZE		(HOP_TABLE_SIZE * MAX_ASID)
41 
42 #define MMU_HOP0_PA43_12_SHIFT		12
43 #define MMU_HOP0_PA49_44_SHIFT		(12 + 32)
44 
45 #define MMU_CONFIG_TIMEOUT_USEC		2000 /* 2 ms */
46 
47 #endif /* INCLUDE_MMU_GENERAL_H_ */
48