coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
mmu_operations.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <arch/mmu.h>
4 #include <symbols.h>
5 #include <soc/emi.h>
6 #include <soc/mmu_operations.h>
7 
8 __weak void mtk_soc_after_dram(void) { /* do nothing */ }
9 
10 void mtk_mmu_init(void)
11 {
12  mmu_init();
13 
14  /*
15  * Set 0x0 to 8GB address as device memory. We want to config IO_PHYS
16  * address to DEV_MEM, and map a proper range of dram for the memory
17  * test during calibration.
18  */
19  mmu_config_range((void *)0, (uintptr_t)8U * GiB, DEV_MEM);
20 
21  /* SRAM is cached */
23 
24  /* L2C SRAM is cached */
25  mmu_config_range(_sram_l2c, REGION_SIZE(sram_l2c), SECURE_CACHED_MEM);
26 
27  /* DMA is non-cached and is reserved for TPM & da9212 I2C DMA */
30 
31  mmu_enable();
32 }
33 
35 {
36  /* Map DRAM as cached now that it's up and running */
38 
40 }
41 
43 {
44  /* Unmap L2C SRAM so it can be reclaimed by L2 cache */
45  /* TODO: Implement true unmapping, and also use it for the zero-page! */
46  mmu_config_range(_sram_l2c, REGION_SIZE(sram_l2c), DEV_MEM);
47 
48  /* Careful: changing cache geometry while it's active is a bad idea! */
49  mmu_disable();
50 
52 
53  /* Re-enable MMU with now enlarged L2 cache. Page tables still valid. */
54  mmu_enable();
55 }
void mmu_enable(void)
Definition: mmu.c:293
void mmu_disable(void)
void mmu_config_range(u32 start_mb, u32 size_mb, enum dcache_policy policy)
Definition: mmu.c:221
void mmu_init(void)
Definition: mmu.c:242
#define GiB
Definition: helpers.h:77
size_t sdram_size(void)
Definition: emi.c:117
int dma_coherent(void *ptr)
u8 _dram[]
#define REGION_SIZE(name)
Definition: symbols.h:10
@ SECURE_CACHED_MEM
@ NONSECURE_CACHED_MEM
@ SECURE_UNCACHED_MEM
void mtk_mmu_init(void)
__weak void mtk_soc_after_dram(void)
Definition: mmu_operations.c:8
void mtk_mmu_disable_l2c_sram(void)
void mtk_mmu_after_dram(void)
void mtk_soc_disable_l2c_sram(void)
#define DEV_MEM
Definition: mmu_common.h:11
const struct smm_save_state_ops *legacy_ops __weak
Definition: save_state.c:8
unsigned long uintptr_t
Definition: stdint.h:21