Add Broadcom's code for bcm63xx support
[project/bcm63xx/atf.git] / plat / bcm / include / bcm963xx / bcm_mem_reserve.h
1 /*
2 <:copyright-BRCM:2019:DUAL/GPL:standard
3
4 Copyright (c) 2019 Broadcom
5 All Rights Reserved
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License, version 2, as published by
9 the Free Software Foundation (the "GPL").
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16
17 A copy of the GPL is available at http://www.broadcom.com/licenses/GPLv2.php, or by
18 writing to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
20
21 :>
22
23 */
24 #ifndef _BCM_MEM_RESERVE_H
25 #define _BCM_MEM_RESERVE_H
26
27
28 /* Push DTB higher as it will be removed by Linux alter on */
29 /* Address range Size(KB)
30 0x00000000:0x00004000 16 to boot secondary ARM CPU
31 0x00004000:0x000C0000 752 to keep ATF firmware
32 0x000C0000:0x000F0000 192 to keep PMC firmware
33 0x000F0000:0x00100000 64 to keep PMC firmware log
34
35 Any change in the following defines must be reflected in Linux device tree (/memreserve)
36 */
37 #if defined(CONFIG_ARM64)
38 #define CFG_BOOT_AREA_ADDR 0
39 #else
40 #define CFG_BOOT_AREA_ADDR 0x1000
41 #define ARM_ATAG_LOC CFG_DTB_ADDRESS
42 #endif
43 #define CFG_BOOT_AREA_SIZE (0x4000 - CFG_BOOT_AREA_ADDR)
44
45 /* ATF reserved memory */
46 #define CFG_ATF_AREA_ADDR (CFG_BOOT_AREA_ADDR + CFG_BOOT_AREA_SIZE)
47 #define CFG_ATF_AREA_SIZE 0xBC000 // Total ATF reserved memory size 752KB
48
49 /* PMC reserved memory */
50 #define PMC_RESERVED_MEM_START (CFG_ATF_AREA_ADDR + CFG_ATF_AREA_SIZE)
51 #define PMC_RESERVED_MEM_SIZE 0x40000 // Total PMC reserved memory size 256KB
52
53 #ifdef CONFIG_BCM963148
54 /* Reuse unused PMC reserved memory for DSL */
55 #define DSL_RESERVED_MEM_START PMC_RESERVED_MEM_START
56 #define DSL_RESERVED_MEM_SIZE PMC_RESERVED_MEM_SIZE
57 #endif
58
59 #define CFG_BOOT_PMC_LOG_SIZE 0x10000 // Leave 64K reserved memory for PMC log
60 #define CFG_BOOT_PMC_ADDR (PMC_RESERVED_MEM_START)
61 #define CFG_BOOT_PMC_SIZE (PMC_RESERVED_MEM_SIZE - CFG_BOOT_PMC_LOG_SIZE) // Memory reserved for PMC firmware
62 #define CFG_BOOT_PMC_LOG_ADDR (PMC_RESERVED_MEM_START + CFG_BOOT_PMC_SIZE)
63
64
65 /* **NOTE** any change in CFG_BOOT_PMC_ADDR must be reflected in PMC makefiles */
66
67 /* OPTEE reserved memory */
68 #define CFG_OPTEE_AREA_ADDR (PMC_RESERVED_MEM_START + PMC_RESERVED_MEM_SIZE)
69 #define CFG_OPTEE_CORE_SIZE 0x400000 // Total OPTEE reserved memory size 4096KB
70 #define CFG_OPTEE_SHRM_SIZE 0x100000 // Shared memory 1024KB between OPTEE and Linux
71 #define CFG_OPTEE_SHRM_ADDR (CFG_OPTEE_AREA_ADDR + CFG_OPTEE_CORE_SIZE)
72 #define CFG_OPTEE_AREA_SIZE (CFG_OPTEE_CORE_SIZE + CFG_OPTEE_SHRM_SIZE)
73
74 #ifdef CONFIG_OPTEE
75 #define CFG_MAX_RESV_AREA (CFG_OPTEE_AREA_ADDR + CFG_OPTEE_AREA_SIZE)
76 #else
77 #define CFG_MAX_RESV_AREA (PMC_RESERVED_MEM_START + PMC_RESERVED_MEM_SIZE)
78 #endif
79
80 #if ( CFG_MAX_RESV_AREA > 0x600000 )
81 #error "Reserved memory exceeded the allowed (6MB) limit"
82 #endif
83
84
85 #if ( CFG_MAX_RESV_AREA != 0x100000 ) && ( CFG_MAX_RESV_AREA != 0x600000 )
86 #error "Time to update kernel/linux-4.x/arch/armxx/Makefile"
87 #endif
88
89 #if defined(CONFIG_ARM64)
90 #define LINUX_START_ADDR CFG_MAX_RESV_AREA
91 #else
92 /* For 32 bit ARM, Linux needs extra 32K head room for MMU table */
93 #define LINUX_START_ADDR (CFG_MAX_RESV_AREA + 0x8000)
94 #endif
95
96 #endif /* _BCM_MEM_RESERVE_H */