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