xref: /openbmc/linux/arch/riscv/include/asm/fixmap.h (revision 677b9eb8)
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,
27e8a62cc2SAlexandre Ghiti 	FIX_PUD,
28*677b9eb8SQinglin Pan 	FIX_P4D,
29043cb41aSZong Li 	FIX_TEXT_POKE1,
30043cb41aSZong Li 	FIX_TEXT_POKE0,
31f2c17aabSAnup Patel 	FIX_EARLYCON_MEM_BASE,
326262f661SAtish Patra 
336262f661SAtish Patra 	__end_of_permanent_fixed_addresses,
346262f661SAtish Patra 	/*
356262f661SAtish Patra 	 * Temporary boot-time mappings, used by early_ioremap(),
366262f661SAtish Patra 	 * before ioremap() is functional.
376262f661SAtish Patra 	 */
386262f661SAtish Patra #define NR_FIX_BTMAPS		(SZ_256K / PAGE_SIZE)
396262f661SAtish Patra #define FIX_BTMAPS_SLOTS	7
406262f661SAtish Patra #define TOTAL_FIX_BTMAPS	(NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS)
416262f661SAtish Patra 
426262f661SAtish Patra 	FIX_BTMAP_END = __end_of_permanent_fixed_addresses,
436262f661SAtish Patra 	FIX_BTMAP_BEGIN = FIX_BTMAP_END + TOTAL_FIX_BTMAPS - 1,
446262f661SAtish Patra 
45f2c17aabSAnup Patel 	__end_of_fixed_addresses
46f2c17aabSAnup Patel };
47f2c17aabSAnup Patel 
48f2c17aabSAnup Patel #define FIXMAP_PAGE_IO		PAGE_KERNEL
49f2c17aabSAnup Patel 
50f2c17aabSAnup Patel #define __early_set_fixmap	__set_fixmap
51f2c17aabSAnup Patel 
52f2c17aabSAnup Patel #define __late_set_fixmap	__set_fixmap
53f2c17aabSAnup Patel #define __late_clear_fixmap(idx) __set_fixmap((idx), 0, FIXMAP_PAGE_CLEAR)
54f2c17aabSAnup Patel 
55f2c17aabSAnup Patel extern void __set_fixmap(enum fixed_addresses idx,
56f2c17aabSAnup Patel 			 phys_addr_t phys, pgprot_t prot);
57f2c17aabSAnup Patel 
58f2c17aabSAnup Patel #include <asm-generic/fixmap.h>
59f2c17aabSAnup Patel 
606bd33e1eSChristoph Hellwig #endif /* CONFIG_MMU */
61f2c17aabSAnup Patel #endif /* _ASM_RISCV_FIXMAP_H */
62