2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2016-01-22 11:35:59 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012-2016 Freescale Semiconductor, Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2016-01-22 11:35:59 +00:00
|
|
|
#include <asm/fsl_pamu.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2016-01-22 11:35:59 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
void construct_pamu_addr_table(struct pamu_addr_tbl *tbl, int *num_entries)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
int j;
|
|
|
|
|
|
|
|
tbl->start_addr[i] =
|
2022-11-16 18:10:37 +00:00
|
|
|
(uint64_t)virt_to_phys((void *)CFG_SYS_SDRAM_BASE);
|
2016-01-22 11:35:59 +00:00
|
|
|
tbl->size[i] = (phys_size_t)(min(gd->ram_size, CONFIG_MAX_MEM_MAPPED));
|
|
|
|
tbl->end_addr[i] = tbl->start_addr[i] + tbl->size[i] - 1;
|
|
|
|
|
|
|
|
i++;
|
2022-11-16 18:10:41 +00:00
|
|
|
#ifdef CFG_SYS_FLASH_BASE_PHYS
|
2016-01-22 11:35:59 +00:00
|
|
|
tbl->start_addr[i] =
|
2022-11-16 18:10:41 +00:00
|
|
|
(uint64_t)virt_to_phys((void *)CFG_SYS_FLASH_BASE_PHYS);
|
2016-01-22 11:35:59 +00:00
|
|
|
tbl->size[i] = 256 * 1024 * 1024; /* 256MB flash */
|
|
|
|
tbl->end_addr[i] = tbl->start_addr[i] + tbl->size[i] - 1;
|
|
|
|
|
|
|
|
i++;
|
|
|
|
#endif
|
2022-11-16 18:10:41 +00:00
|
|
|
#if (defined(CONFIG_SPL_BUILD) && (CFG_SYS_INIT_L3_VADDR))
|
2016-07-14 16:27:51 +00:00
|
|
|
tbl->start_addr[i] =
|
2022-11-16 18:10:41 +00:00
|
|
|
(uint64_t)virt_to_phys((void *)CFG_SYS_INIT_L3_VADDR);
|
2016-07-14 16:27:51 +00:00
|
|
|
tbl->size[i] = 256 * 1024; /* 256K CPC flash */
|
|
|
|
tbl->end_addr[i] = tbl->start_addr[i] + tbl->size[i] - 1;
|
|
|
|
|
|
|
|
i++;
|
|
|
|
#endif
|
2016-01-22 11:35:59 +00:00
|
|
|
debug("PAMU address\t\t\tsize\n");
|
|
|
|
for (j = 0; j < i ; j++)
|
|
|
|
debug("%llx \t\t\t%llx\n", tbl->start_addr[j], tbl->size[j]);
|
|
|
|
|
|
|
|
*num_entries = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
int sec_config_pamu_table(uint32_t liodn_ns, uint32_t liodn_s)
|
|
|
|
{
|
|
|
|
struct pamu_addr_tbl tbl;
|
|
|
|
int num_entries = 0;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
construct_pamu_addr_table(&tbl, &num_entries);
|
|
|
|
|
|
|
|
ret = config_pamu(&tbl, num_entries, liodn_ns);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = config_pamu(&tbl, num_entries, liodn_s);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|