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