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 */
22
mmu_config_range
(_sram,
REGION_SIZE
(sram),
SECURE_CACHED_MEM
);
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 */
28
mmu_config_range
(_dma_coherent,
REGION_SIZE
(
dma_coherent
),
29
SECURE_UNCACHED_MEM
);
30
31
mmu_enable
();
32
}
33
34
void
mtk_mmu_after_dram
(
void
)
35
{
36
/* Map DRAM as cached now that it's up and running */
37
mmu_config_range
(
_dram
, (
uintptr_t
)
sdram_size
(),
NONSECURE_CACHED_MEM
);
38
39
mtk_soc_after_dram
();
40
}
41
42
void
mtk_mmu_disable_l2c_sram
(
void
)
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
51
mtk_soc_disable_l2c_sram
();
52
53
/* Re-enable MMU with now enlarged L2 cache. Page tables still valid. */
54
mmu_enable
();
55
}
mmu_enable
void mmu_enable(void)
Definition:
mmu.c:293
mmu.h
mmu_disable
void mmu_disable(void)
mmu_config_range
void mmu_config_range(u32 start_mb, u32 size_mb, enum dcache_policy policy)
Definition:
mmu.c:221
mmu_init
void mmu_init(void)
Definition:
mmu.c:242
GiB
#define GiB
Definition:
helpers.h:77
sdram_size
size_t sdram_size(void)
Definition:
emi.c:117
dma_coherent
int dma_coherent(void *ptr)
_dram
u8 _dram[]
REGION_SIZE
#define REGION_SIZE(name)
Definition:
symbols.h:10
SECURE_CACHED_MEM
@ SECURE_CACHED_MEM
Definition:
mmu_operations.h:11
NONSECURE_CACHED_MEM
@ NONSECURE_CACHED_MEM
Definition:
mmu_operations.h:13
SECURE_UNCACHED_MEM
@ SECURE_UNCACHED_MEM
Definition:
mmu_operations.h:12
mtk_mmu_init
void mtk_mmu_init(void)
Definition:
mmu_operations.c:10
mtk_soc_after_dram
__weak void mtk_soc_after_dram(void)
Definition:
mmu_operations.c:8
mtk_mmu_disable_l2c_sram
void mtk_mmu_disable_l2c_sram(void)
Definition:
mmu_operations.c:42
mtk_mmu_after_dram
void mtk_mmu_after_dram(void)
Definition:
mmu_operations.c:34
mtk_soc_disable_l2c_sram
void mtk_soc_disable_l2c_sram(void)
Definition:
mmu_operations.c:18
DEV_MEM
#define DEV_MEM
Definition:
mmu_common.h:11
__weak
const struct smm_save_state_ops *legacy_ops __weak
Definition:
save_state.c:8
uintptr_t
unsigned long uintptr_t
Definition:
stdint.h:21
src
soc
mediatek
common
mmu_operations.c
Generated by
1.9.1