xref: /openbmc/linux/arch/riscv/include/asm/fixmap.h (revision ffcdf473)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) 2019 Western Digital Corporation or its affiliates.
4  */
5 
6 #ifndef _ASM_RISCV_FIXMAP_H
7 #define _ASM_RISCV_FIXMAP_H
8 
9 #include <linux/kernel.h>
10 #include <linux/sizes.h>
11 #include <linux/pgtable.h>
12 #include <asm/page.h>
13 
14 #ifdef CONFIG_MMU
15 /*
16  * Here we define all the compile-time 'special' virtual addresses.
17  * The point is to have a constant address at compile time, but to
18  * set the physical address only in the boot process.
19  *
20  * These 'compile-time allocated' memory buffers are page-sized. Use
21  * set_fixmap(idx,phys) to associate physical memory with fixmap indices.
22  */
23 enum fixed_addresses {
24 	FIX_HOLE,
25 	/*
26 	 * The fdt fixmap mapping must be PMD aligned and will be mapped
27 	 * using PMD entries in fixmap_pmd in 64-bit and a PGD entry in 32-bit.
28 	 */
29 	FIX_FDT_END,
30 	FIX_FDT = FIX_FDT_END + FIX_FDT_SIZE / PAGE_SIZE - 1,
31 
32 	/* Below fixmaps will be mapped using fixmap_pte */
33 	FIX_PTE,
34 	FIX_PMD,
35 	FIX_PUD,
36 	FIX_P4D,
37 	FIX_TEXT_POKE1,
38 	FIX_TEXT_POKE0,
39 	FIX_EARLYCON_MEM_BASE,
40 
41 	__end_of_permanent_fixed_addresses,
42 	/*
43 	 * Temporary boot-time mappings, used by early_ioremap(),
44 	 * before ioremap() is functional.
45 	 */
46 #define NR_FIX_BTMAPS		(SZ_256K / PAGE_SIZE)
47 #define FIX_BTMAPS_SLOTS	7
48 #define TOTAL_FIX_BTMAPS	(NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS)
49 
50 	FIX_BTMAP_END = __end_of_permanent_fixed_addresses,
51 	FIX_BTMAP_BEGIN = FIX_BTMAP_END + TOTAL_FIX_BTMAPS - 1,
52 
53 	__end_of_fixed_addresses
54 };
55 
56 #define __early_set_fixmap	__set_fixmap
57 
58 #define __late_set_fixmap	__set_fixmap
59 #define __late_clear_fixmap(idx) __set_fixmap((idx), 0, FIXMAP_PAGE_CLEAR)
60 
61 extern void __set_fixmap(enum fixed_addresses idx,
62 			 phys_addr_t phys, pgprot_t prot);
63 
64 #include <asm-generic/fixmap.h>
65 
66 #endif /* CONFIG_MMU */
67 #endif /* _ASM_RISCV_FIXMAP_H */
68