• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0
2  *
3  * Copyright 2016-2020 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_64KB			16
13 #define PAGE_SHIFT_2MB			21
14 #define PAGE_SHIFT_16MB			24
15 #define PAGE_SHIFT_64MB			26
16 #define PAGE_SHIFT_1GB			30
17 #define PAGE_SIZE_4KB			_BITUL(PAGE_SHIFT_4KB)
18 #define PAGE_SIZE_64KB			_BITUL(PAGE_SHIFT_64KB)
19 #define PAGE_SIZE_2MB			_BITUL(PAGE_SHIFT_2MB)
20 #define PAGE_SIZE_16MB			_BITUL(PAGE_SHIFT_16MB)
21 #define PAGE_SIZE_64MB			_BITUL(PAGE_SHIFT_64MB)
22 #define PAGE_SIZE_1GB			_BITUL(PAGE_SHIFT_1GB)
23 
24 #define PAGE_PRESENT_MASK		0x0000000000001ull
25 #define SWAP_OUT_MASK			0x0000000000004ull
26 #define LAST_MASK			0x0000000000800ull
27 #define FLAGS_MASK			0x0000000000FFFull
28 
29 #define MMU_ARCH_5_HOPS			5
30 #define MMU_ARCH_6_HOPS			6
31 
32 #define HOP_PHYS_ADDR_MASK		(~FLAGS_MASK)
33 
34 #define HL_PTE_SIZE			sizeof(u64)
35 
36 /* definitions for HOP with 512 PTE entries */
37 #define HOP_PTE_ENTRIES_512		512
38 #define HOP_TABLE_SIZE_512_PTE		(HOP_PTE_ENTRIES_512 * HL_PTE_SIZE)
39 #define HOP0_512_PTE_TABLES_TOTAL_SIZE	(HOP_TABLE_SIZE_512_PTE * MAX_ASID)
40 
41 #define MMU_HOP0_PA43_12_SHIFT		12
42 #define MMU_HOP0_PA49_44_SHIFT		(12 + 32)
43 #define MMU_HOP0_PA63_44_SHIFT		(12 + 32)
44 
45 #define MMU_CONFIG_TIMEOUT_USEC		2000 /* 2 ms */
46 
47 enum mmu_hop_num {
48 	MMU_HOP0,
49 	MMU_HOP1,
50 	MMU_HOP2,
51 	MMU_HOP3,
52 	MMU_HOP4,
53 	MMU_HOP5,
54 	MMU_HOP_MAX,
55 };
56 
57 #endif /* INCLUDE_MMU_GENERAL_H_ */
58