u-boot/arch/powerpc/cpu/mpc8xxx/pamu_table.c
Aneesh Bansal f698e9f39a powerpc/SECURE_BOOT: Add PAMU driver
PAMU driver basic support for usage in Secure Boot.
In secure boot PAMU is not in bypass mode. Hence to use
any peripheral (SEC Job ring in our case), PAMU has to be
configured.

The patch reverts commit 7cad2e38d6.

The Header file pamu.h and few functions in driver have been derived
from Freescale Libos.

Signed-off-by: Ruchika Gupta <ruchika.gupta@nxp.com>
Signed-off-by: Aneesh Bansal <aneesh.bansal@nxp.com>
Reviewed-by: York Sun <york.sun@nxp.com>
2016-02-24 08:40:55 -08:00

55 lines
1.2 KiB
C

/*
* Copyright 2012-2016 Freescale Semiconductor, Inc.
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <asm/fsl_pamu.h>
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] =
(uint64_t)virt_to_phys((void *)CONFIG_SYS_SDRAM_BASE);
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++;
#ifdef CONFIG_SYS_FLASH_BASE_PHYS
tbl->start_addr[i] =
(uint64_t)virt_to_phys((void *)CONFIG_SYS_FLASH_BASE_PHYS);
tbl->size[i] = 256 * 1024 * 1024; /* 256MB flash */
tbl->end_addr[i] = tbl->start_addr[i] + tbl->size[i] - 1;
i++;
#endif
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;
}