]> git.ipfire.org Git - thirdparty/u-boot.git/blame - arch/powerpc/cpu/mpc8xxx/pamu_table.c
Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""
[thirdparty/u-boot.git] / arch / powerpc / cpu / mpc8xxx / pamu_table.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
f698e9f3
AB
2/*
3 * Copyright 2012-2016 Freescale Semiconductor, Inc.
f698e9f3
AB
4 */
5
d678a59d 6#include <common.h>
f7ae49fc 7#include <log.h>
f698e9f3 8#include <asm/fsl_pamu.h>
401d1c4f 9#include <asm/global_data.h>
f698e9f3
AB
10
11DECLARE_GLOBAL_DATA_PTR;
12
13void construct_pamu_addr_table(struct pamu_addr_tbl *tbl, int *num_entries)
14{
15 int i = 0;
16 int j;
17
18 tbl->start_addr[i] =
aa6e94de 19 (uint64_t)virt_to_phys((void *)CFG_SYS_SDRAM_BASE);
1d457dbb 20 tbl->size[i] = (phys_size_t)(min(gd->ram_size, CFG_MAX_MEM_MAPPED));
f698e9f3
AB
21 tbl->end_addr[i] = tbl->start_addr[i] + tbl->size[i] - 1;
22
23 i++;
65cc0e2a 24#ifdef CFG_SYS_FLASH_BASE_PHYS
f698e9f3 25 tbl->start_addr[i] =
65cc0e2a 26 (uint64_t)virt_to_phys((void *)CFG_SYS_FLASH_BASE_PHYS);
f698e9f3
AB
27 tbl->size[i] = 256 * 1024 * 1024; /* 256MB flash */
28 tbl->end_addr[i] = tbl->start_addr[i] + tbl->size[i] - 1;
29
30 i++;
31#endif
65cc0e2a 32#if (defined(CONFIG_SPL_BUILD) && (CFG_SYS_INIT_L3_VADDR))
8f01397b 33 tbl->start_addr[i] =
65cc0e2a 34 (uint64_t)virt_to_phys((void *)CFG_SYS_INIT_L3_VADDR);
8f01397b
SG
35 tbl->size[i] = 256 * 1024; /* 256K CPC flash */
36 tbl->end_addr[i] = tbl->start_addr[i] + tbl->size[i] - 1;
37
38 i++;
39#endif
f698e9f3
AB
40 debug("PAMU address\t\t\tsize\n");
41 for (j = 0; j < i ; j++)
42 debug("%llx \t\t\t%llx\n", tbl->start_addr[j], tbl->size[j]);
43
44 *num_entries = i;
45}
46
47int sec_config_pamu_table(uint32_t liodn_ns, uint32_t liodn_s)
48{
49 struct pamu_addr_tbl tbl;
50 int num_entries = 0;
51 int ret = 0;
52
53 construct_pamu_addr_table(&tbl, &num_entries);
54
55 ret = config_pamu(&tbl, num_entries, liodn_ns);
56 if (ret)
57 return ret;
58
59 ret = config_pamu(&tbl, num_entries, liodn_s);
60 if (ret)
61 return ret;
62
63 return ret;
64}