| 1 |
|
| 2 |
|
| 3 |
#include <arch/mmu.h> |
| 4 |
#include <console/console.h> |
| 5 |
#include <soc/mmu.h> |
| 6 |
#include <soc/mmu_common.h> |
| 7 |
#include <soc/symbols_common.h> |
| 8 |
|
| 9 |
|
| 10 |
#define MAX_DRAM_SPACE_INDEX 3 |
| 11 |
|
| 12 |
__weak bool soc_modem_carve_out(void **start, void **end) { return false; } |
| 13 |
|
| 14 |
struct region *qc_get_soc_dram_space_config(size_t ddr_size, int *count) |
| 15 |
{ |
| 16 |
static struct region config[MAX_DRAM_SPACE_INDEX]; |
| 17 |
static int populated_count = 0; |
| 18 |
int i; |
| 19 |
|
| 20 |
if (!populated_count) { |
| 21 |
void *region_start[MAX_DRAM_SPACE_INDEX] = { |
| 22 |
_dram, |
| 23 |
_dram_space_1, |
| 24 |
_dram_space_2 |
| 25 |
}; |
| 26 |
size_t size[MAX_DRAM_SPACE_INDEX] = { |
| 27 |
REGION_SIZE(dram), |
| 28 |
REGION_SIZE(dram_space_1), |
| 29 |
REGION_SIZE(dram_space_2) |
| 30 |
}; |
| 31 |
|
| 32 |
|
| 33 |
if (!_edram) |
| 34 |
size[0] = ddr_size; |
| 35 |
|
| 36 |
for (i = 0; i < MAX_DRAM_SPACE_INDEX && ddr_size > 0; i++) { |
| 37 |
config[i].offset = (size_t)region_start[i]; |
| 38 |
size_t to_map = MIN(ddr_size, size[i]); |
| 39 |
config[i].size = to_map; |
| 40 |
ddr_size -= to_map; |
| 41 |
} |
| 42 |
|
| 43 |
populated_count = i; |
| 44 |
|
| 45 |
if (ddr_size) |
| 46 |
printk(BIOS_CRIT, "Too much DRAM for available windows (%zu bytes left over)!\n", |
| 47 |
ddr_size); |
| 48 |
} |
| 49 |
|
| 50 |
*count = populated_count; |
| 51 |
|
| 52 |
return config; |
| 53 |
} |
| 54 |
|
| 55 |
void qc_mmu_dram_config_post_dram_init(size_t ddr_size) |
| 56 |
{ |
| 57 |
void *start = NULL; |
| 58 |
void *end = NULL; |
| 59 |
|
| 60 |
if (soc_modem_carve_out(&start, &end)) { |
| 61 |
if (_dram_space_1) |
| 62 |
die("Using carve out together with DRAM windows not supported"); |
| 63 |
mmu_config_range((void *)_dram, start - (void *)_dram, CACHED_RAM); |
| 64 |
mmu_config_range(end, (void *)_dram + ddr_size - end, CACHED_RAM); |
| 65 |
} else { |
| 66 |
int count; |
| 67 |
struct region *config = qc_get_soc_dram_space_config(ddr_size, &count); |
| 68 |
for (int i = 0; i < count; i++) |
| 69 |
mmu_config_range((void *)config[i].offset, config[i].size, CACHED_RAM); |
| 70 |
} |
| 71 |
|
| 72 |
mmu_config_range((void *)_aop_code_ram, REGION_SIZE(aop_code_ram), |
| 73 |
CACHED_RAM); |
| 74 |
mmu_config_range((void *)_aop_data_ram, REGION_SIZE(aop_data_ram), |
| 75 |
CACHED_RAM); |
| 76 |
} |