xref: /openbmc/linux/arch/riscv/include/asm/fixmap.h (revision ef69d255)
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,
25*ef69d255SAlexandre Ghiti 	/*
26*ef69d255SAlexandre Ghiti 	 * The fdt fixmap mapping must be PMD aligned and will be mapped
27*ef69d255SAlexandre Ghiti 	 * using PMD entries in fixmap_pmd in 64-bit and a PGD entry in 32-bit.
28*ef69d255SAlexandre Ghiti 	 */
29*ef69d255SAlexandre Ghiti 	FIX_FDT_END,
30*ef69d255SAlexandre Ghiti 	FIX_FDT = FIX_FDT_END + FIX_FDT_SIZE / PAGE_SIZE - 1,
31*ef69d255SAlexandre Ghiti 
32*ef69d255SAlexandre Ghiti 	/* Below fixmaps will be mapped using fixmap_pte */
33671f9a3eSAnup Patel 	FIX_PTE,
34671f9a3eSAnup Patel 	FIX_PMD,
35e8a62cc2SAlexandre Ghiti 	FIX_PUD,
36677b9eb8SQinglin Pan 	FIX_P4D,
37043cb41aSZong Li 	FIX_TEXT_POKE1,
38043cb41aSZong Li 	FIX_TEXT_POKE0,
39f2c17aabSAnup Patel 	FIX_EARLYCON_MEM_BASE,
406262f661SAtish Patra 
416262f661SAtish Patra 	__end_of_permanent_fixed_addresses,
426262f661SAtish Patra 	/*
436262f661SAtish Patra 	 * Temporary boot-time mappings, used by early_ioremap(),
446262f661SAtish Patra 	 * before ioremap() is functional.
456262f661SAtish Patra 	 */
466262f661SAtish Patra #define NR_FIX_BTMAPS		(SZ_256K / PAGE_SIZE)
476262f661SAtish Patra #define FIX_BTMAPS_SLOTS	7
486262f661SAtish Patra #define TOTAL_FIX_BTMAPS	(NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS)
496262f661SAtish Patra 
506262f661SAtish Patra 	FIX_BTMAP_END = __end_of_permanent_fixed_addresses,
516262f661SAtish Patra 	FIX_BTMAP_BEGIN = FIX_BTMAP_END + TOTAL_FIX_BTMAPS - 1,
526262f661SAtish Patra 
53f2c17aabSAnup Patel 	__end_of_fixed_addresses
54f2c17aabSAnup Patel };
55f2c17aabSAnup Patel 
56f2c17aabSAnup Patel #define __early_set_fixmap	__set_fixmap
57f2c17aabSAnup Patel 
58f2c17aabSAnup Patel #define __late_set_fixmap	__set_fixmap
59f2c17aabSAnup Patel #define __late_clear_fixmap(idx) __set_fixmap((idx), 0, FIXMAP_PAGE_CLEAR)
60f2c17aabSAnup Patel 
61f2c17aabSAnup Patel extern void __set_fixmap(enum fixed_addresses idx,
62f2c17aabSAnup Patel 			 phys_addr_t phys, pgprot_t prot);
63f2c17aabSAnup Patel 
64f2c17aabSAnup Patel #include <asm-generic/fixmap.h>
65f2c17aabSAnup Patel 
666bd33e1eSChristoph Hellwig #endif /* CONFIG_MMU */
67f2c17aabSAnup Patel #endif /* _ASM_RISCV_FIXMAP_H */
68