From patchwork Thu Nov 12 22:20:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: York Sun X-Patchwork-Id: 543726 X-Patchwork-Delegate: yorksun@freescale.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id B4E5914142B for ; Fri, 13 Nov 2015 09:33:56 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D8AF04B957; Thu, 12 Nov 2015 23:33:46 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id B1boTIHf0Eds; Thu, 12 Nov 2015 23:33:46 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C7D254B954; Thu, 12 Nov 2015 23:33:38 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E3BCC4B913 for ; Thu, 12 Nov 2015 23:20:48 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id d0ShR8ew6nT2 for ; Thu, 12 Nov 2015 23:20:48 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0132.outbound.protection.outlook.com [65.55.169.132]) by theia.denx.de (Postfix) with ESMTPS id 4444B4B839 for ; Thu, 12 Nov 2015 23:20:45 +0100 (CET) Received: from CH1PR03CA006.namprd03.prod.outlook.com (10.255.156.151) by BN3PR0301MB1299.namprd03.prod.outlook.com (10.161.210.154) with Microsoft SMTP Server (TLS) id 15.1.318.15; Thu, 12 Nov 2015 22:20:41 +0000 Received: from BN1BFFO11FD034.protection.gbl (10.255.156.132) by CH1PR03CA006.outlook.office365.com (10.255.156.151) with Microsoft SMTP Server (TLS) id 15.1.325.17 via Frontend Transport; Thu, 12 Nov 2015 22:20:41 +0000 Authentication-Results: spf=permerror (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; freescale.mail.onmicrosoft.com; dmarc=none action=none header.from=freescale.com; Received-SPF: PermError (protection.outlook.com: domain of freescale.com used an invalid SPF mechanism) Received: from az84smr01.freescale.net (192.88.158.2) by BN1BFFO11FD034.mail.protection.outlook.com (10.58.144.97) with Microsoft SMTP Server (TLS) id 15.1.325.5 via Frontend Transport; Thu, 12 Nov 2015 22:20:40 +0000 Received: from oslab-l1.am.freescale.net ([10.214.84.61]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id tACMKXPg017119; Thu, 12 Nov 2015 15:20:34 -0700 From: York Sun To: U-Boot Mailing List Date: Thu, 12 Nov 2015 14:20:32 -0800 Message-ID: <1447366832-16833-1-git-send-email-yorksun@freescale.com> X-Mailer: git-send-email 1.7.9.5 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD034; 1:PCRd52P84Sbuj3bru+QWumHKvrDuy+Of5oWh+NS09rEIGaUkHI+GPPcv628f+0OhUZogRou5OV0wzXmqsBmyL6GUdZ//MtEUdwTAjLq+z3ol0P4eflR6/a9M+CIw08ReOKadpl+M6tngJffBciyIdEQguSwi5vThpy+8JpyUREZZTiEPo4dkV42jrdEaAxWnCf3wjMlt22TLi4mvrQKnsn25sg5tPTgBzNHjNDVb0W0ogxYpg2n1E2rUh2Jq4TbvjgjeMkgajucKfPzytog8WOzOToz8h6g2HvLcfkPXki9F7cphHDgOGomTCVAEY4gC6Z++aClnZG5JSHZ23kHtQ86UxOQ9/GLPnqeZTbAroDPoHtWrI6cSgtIHkAGe9xpwgP/6o0PaMCW3nhSePHxdMR9rBgiaSo0odiyL2BrS9vRo8MWCPIr4D5fV36IhHjcUBkAxrGqWDQ0YGHb4CEla9Q== X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(1060300003)(2980300002)(448002)(3190300001)(199003)(189002)(106466001)(104016004)(6806005)(47776003)(77096005)(86362001)(97736004)(11100500001)(5008740100001)(110436001)(92566002)(36756003)(4290100001)(19580395003)(5001960100002)(107886002)(69596002)(110136002)(81156007)(50466002)(33646002)(19580405001)(5007970100001)(4001430100002)(5001920100001)(85326001)(87936001)(50226001)(5003940100001)(229853001)(50986999)(48376002); DIR:OUT; SFP:1102; SCL:1; SRVR:BN3PR0301MB1299; H:az84smr01.freescale.net; FPR:; SPF:PermError; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BN3PR0301MB1299; 2:GF+PHvnHDTYUx9i/LXAzD4lVV7S867bX/N/upSwbDitZ4QiviUpgRbAUyl6BUBM7cG7ljiQ/dEwsbPVP4RdixQfoyUekJiqw0qWewVaXy/akP6ty/dcNws9C0Xn001/MKl4aHJqh0xaAbAnnmhqhqG3HFGQjTQHPDTaedHXiIXk=; 3:tgw7QPzIOnhvO1+Zv6yNG0IjPaNxPWUv/3Nz95H9GUCmhd0e/XNdMLOqXcdrXHxifODW5Y13CpKQviJvRBtAhuTjnsyOoZPpyvFIS4F1tO2JPZu/9soyPPfJfDknbTSmZxva3rktj8lvl2c/GMnaMoK9q1p85sP5eigLwv1BvB41uaCXVQN3CPfGc6PKrP5d5U/DGxAQSg/28ThxJBuRe/i+aLWG99xM6WkH8NAkWMs=; 25:/WhSwgsceWuYh2ZU2vWJOfnXnE4Oxg//9+nR2+PUctc5WnaXqw03fbuldcaj2Z7rsGayL+09+KUEzBkIKmvH30bwyx0gVOF9P9YNPzDvahQydU9vIlrEikrNs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: UriScan:(101931422205132); X-Exchange-Antispam-Report-CFA-Test: BCL:1; PCL:0; RULEID:(601004)(2401047)(5005006)(1201001)(520078)(8121501046)(10201501046)(3002001); SRVR:BN3PR0301MB1299; BCL:1; PCL:0; RULEID:; SRVR:BN3PR0301MB1299; X-Forefront-PRVS: 07584EDBCD X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR0301MB1299; 23:d+Qu2z6TnX2mZ3PD9vAcAlAVPmjqQKu3Nz/I/Gk?= =?us-ascii?Q?trkz1QO7b4Y1BLU+882sVtODke7kamuAJYwufMXoE2LDTcwW71UXVKeOs8Bu?= =?us-ascii?Q?3DuH7Nh+IJAqja8S/rjcFKSTJaKWj/MZ/EViRJ+WV3hnNBhGu4pA4vZOPI8R?= =?us-ascii?Q?C9cGEB2aqAtDa6AkZxSt1+2k8oJGCYGkMoS12swIhcibP6GNSSPGuisWnDI4?= =?us-ascii?Q?FFy/2EkDoKDQNm8oS/7/2lvxpKX4/lGxzn23ZRY9tY57NT/yNMkCnr7aS6Vp?= =?us-ascii?Q?lyeWA28i5MxbAz8rL7oSVVkl3j+OYvakVCS6uhnsSw92PInEQpZWVIaeK6AX?= =?us-ascii?Q?VaC3BvHI3EMzjPt/cg93NI/jPJKonNXHulgc+GbwiRApKXX8qzGuSnIeTLsZ?= =?us-ascii?Q?vRPoWRrTJoBvkEOcykv8nWrIJ4i/JONtMY8zt+R6jLYxzPzPGbaT54Ho/ovM?= =?us-ascii?Q?uhpzrmTMUhWxFcyoMPdds/olppL8WZUKxwyCMIMP3RvBswlCky7Wg+ZamwhW?= =?us-ascii?Q?yihG2VO/CiN/qfB0YH/xVRgK742nL7KmX1fHDP0i4fwsxhwuqWmCNLNAfq1M?= =?us-ascii?Q?5Z4wdH+qyO+8xzetdVD/xYoapXtTUVs/+8U8dDdwcjZkBCjfffv8Ii40VWfN?= =?us-ascii?Q?GfQ3mT59uyjXqgymZoYudLHkkA/uNMPTga6FqGXNcCt2gZxlmUZroZTTIGUv?= =?us-ascii?Q?nhVPaL9WyNx0J6UAyrDmHnX3riB/b+lhTaAKjLT20+cyW6hWnMKa6J5amb2K?= =?us-ascii?Q?3g4U2nhEHAxHtu9uyEUYF/X6KhS1DT2tSLsVAiZzEHMKFtVpUH+de8T+MJGl?= =?us-ascii?Q?zLwjil9vDXCoo5zAnv8+9fqbcEqIhTk/7b+QSWEOyoShNmUfUWWj5zB6sfkG?= =?us-ascii?Q?+DZveB2Ho8mcYl8AzObwmOL132c1kOESFYxMNY52UGaPU6vOZm1pXtbILxJL?= =?us-ascii?Q?azDgG+YNc79DxkAmWxe466fvRKhDBDYZEpHXVRGmn13DoYEzNFKGjOFLF9Zn?= =?us-ascii?Q?VJ0zCmgXj9/uRGBg0xsqfrrm56JOFRQDWMShxxSkQm3STsbFIW4KUhF1id0t?= =?us-ascii?Q?lnBQUnJtOumjRDwCBEAGhZBWYen3w?= X-Microsoft-Exchange-Diagnostics: 1; BN3PR0301MB1299; 5:W0PKwxAvpqjRLUiFf2cvPw/6YaAEafyJBmhFnS5fPDs5pTBycX+fzdR/NGk46eNZUXuq6rBJDJR1YcBigZr/Z8vIvs55IVaTpg3VRrNWg071EV8GNeAf4+W5V9E88vP3wQ2sWxRjYLyXss1nhRgxwA==; 24:gxhqkbcHNd1B227NvMsX/un0jDJO08l+djDLXuKgpxlXwqDUhrPMFpOBUvv3IC5Gte8KKgBEm5qLri+wG+N3512rms1gKth1DJuS2IO6e94=; 20:hKKt9VCkAgLaSAt0dLzcQkf3pmNqcHxNobSbtzVAF5sWvbmC/DPigFQkOdPVS2cWICn04zvlHbWdP1pU8NI6MQ== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2015 22:20:40.4079 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0301MB1299 X-Mailman-Approved-At: Thu, 12 Nov 2015 23:33:32 +0100 Cc: Tom Rini , Stephen Warren , "angelo@sysam.it" , Hou Zhiqiang , Alexey Brodkin , Stuart Yoder , Scott Wood , Gong Qianyu , Thierry Reding , Joe Hershberger , "J. German Rivera" , York Sun Subject: [U-Boot] [PATCH v1] armv8: fsl-layerscale: Rewrite reserving memory for MC and debug server X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Introduce a new function to calculate reserved memory to replace macro CONFIG_SYS_MEM_TOP_HIDE for more flexibility. Legacy use of this macro is still supported. MC and debug server are not board-specific. Move the reservation function to SoC file. Reduce debug server memory by 2MB to make room for secure memory. Signed-off-by: York Sun --- README | 6 +++--- arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 18 ++++++++++++++++++ board/freescale/ls2085a/ls2085a.c | 17 ----------------- board/freescale/ls2085aqds/ls2085aqds.c | 17 ----------------- board/freescale/ls2085ardb/ls2085ardb.c | 17 ----------------- common/board_f.c | 14 +++++++++++--- include/configs/ls2085a_common.h | 5 ++--- 7 files changed, 34 insertions(+), 60 deletions(-) diff --git a/README b/README index 61cbc82..390ee10 100644 --- a/README +++ b/README @@ -3889,7 +3889,7 @@ Configuration Settings: the RAM base is not zero, or RAM is divided into banks, this variable needs to be recalcuated to get the address. -- CONFIG_SYS_MEM_TOP_HIDE (PPC only): +- CONFIG_SYS_MEM_TOP_HIDE: If CONFIG_SYS_MEM_TOP_HIDE is defined in the board config header, this specified memory area will get subtracted from the top (end) of RAM and won't get "touched" at all by U-Boot. By @@ -5068,8 +5068,8 @@ This firmware often needs to be loaded during U-Boot booting. - CONFIG_SYS_DEBUG_SERVER_DRAM_BLOCK_MIN_SIZE Define minimum DDR size required for debug server image -- CONFIG_SYS_MEM_TOP_HIDE_MIN - Define minimum DDR size to be hided from top of the DDR memory +- CONFIG_SYS_MC_RESERV_MEM_ALIGN + Define alignment of reserved memory MC requires Reproducible builds ------------------- diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c index cda8d9b..72cb9d9 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c @@ -663,3 +663,21 @@ void reset_cpu(ulong addr) val |= 0x02; scfg_out32(rstcr, val); } + +unsigned long board_reserve_ram_top(unsigned long ram_size) +{ + unsigned long ram_top = ram_size; + +/* Carve the Debug Server private DRAM block from the end of DRAM */ +#ifdef CONFIG_FSL_DEBUG_SERVER + ram_top -= debug_server_get_dram_block_size(); +#endif + +/* Carve the MC private DRAM block from the end of DRAM */ +#ifdef CONFIG_FSL_MC_ENET + ram_top -= mc_get_dram_block_size(); + ram_top &= ~(CONFIG_SYS_MC_RESERV_MEM_ALIGN - 1); +#endif + + return ram_size - ram_top; +} diff --git a/board/freescale/ls2085a/ls2085a.c b/board/freescale/ls2085a/ls2085a.c index 27481e2..6f4c3d4 100644 --- a/board/freescale/ls2085a/ls2085a.c +++ b/board/freescale/ls2085a/ls2085a.c @@ -66,23 +66,6 @@ int arch_misc_init(void) } #endif -unsigned long get_dram_size_to_hide(void) -{ - unsigned long dram_to_hide = 0; - -/* Carve the Debug Server private DRAM block from the end of DRAM */ -#ifdef CONFIG_FSL_DEBUG_SERVER - dram_to_hide += debug_server_get_dram_block_size(); -#endif - -/* Carve the MC private DRAM block from the end of DRAM */ -#ifdef CONFIG_FSL_MC_ENET - dram_to_hide += mc_get_dram_block_size(); -#endif - - return roundup(dram_to_hide, CONFIG_SYS_MEM_TOP_HIDE_MIN); -} - int board_eth_init(bd_t *bis) { int error = 0; diff --git a/board/freescale/ls2085aqds/ls2085aqds.c b/board/freescale/ls2085aqds/ls2085aqds.c index b02d6e8..8898cc3 100644 --- a/board/freescale/ls2085aqds/ls2085aqds.c +++ b/board/freescale/ls2085aqds/ls2085aqds.c @@ -251,23 +251,6 @@ int arch_misc_init(void) } #endif -unsigned long get_dram_size_to_hide(void) -{ - unsigned long dram_to_hide = 0; - -/* Carve the Debug Server private DRAM block from the end of DRAM */ -#ifdef CONFIG_FSL_DEBUG_SERVER - dram_to_hide += debug_server_get_dram_block_size(); -#endif - -/* Carve the MC private DRAM block from the end of DRAM */ -#ifdef CONFIG_FSL_MC_ENET - dram_to_hide += mc_get_dram_block_size(); -#endif - - return roundup(dram_to_hide, CONFIG_SYS_MEM_TOP_HIDE_MIN); -} - #ifdef CONFIG_FSL_MC_ENET void fdt_fixup_board_enet(void *fdt) { diff --git a/board/freescale/ls2085ardb/ls2085ardb.c b/board/freescale/ls2085ardb/ls2085ardb.c index 18953b8..efddf74 100644 --- a/board/freescale/ls2085ardb/ls2085ardb.c +++ b/board/freescale/ls2085ardb/ls2085ardb.c @@ -217,23 +217,6 @@ int arch_misc_init(void) } #endif -unsigned long get_dram_size_to_hide(void) -{ - unsigned long dram_to_hide = 0; - -/* Carve the Debug Server private DRAM block from the end of DRAM */ -#ifdef CONFIG_FSL_DEBUG_SERVER - dram_to_hide += debug_server_get_dram_block_size(); -#endif - -/* Carve the MC private DRAM block from the end of DRAM */ -#ifdef CONFIG_FSL_MC_ENET - dram_to_hide += mc_get_dram_block_size(); -#endif - - return roundup(dram_to_hide, CONFIG_SYS_MEM_TOP_HIDE_MIN); -} - #ifdef CONFIG_FSL_MC_ENET void fdt_fixup_board_enet(void *fdt) { diff --git a/common/board_f.c b/common/board_f.c index 8061105..369e6da 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -316,6 +316,15 @@ __weak ulong board_get_usable_ram_top(ulong total_size) return gd->ram_top; } +__weak ulong board_reserve_ram_top(ulong ram_size) +{ +#ifdef CONFIG_SYS_MEM_TOP_HIDE + return CONFIG_SYS_MEM_TOP_HIDE; +#else + return 0; +#endif +} + static int setup_dest_addr(void) { debug("Monitor len: %08lX\n", gd->mon_len); @@ -332,7 +341,6 @@ static int setup_dest_addr(void) */ gd->secure_ram = gd->ram_size; #endif -#if defined(CONFIG_SYS_MEM_TOP_HIDE) /* * Subtract specified amount of memory to hide so that it won't * get "touched" at all by U-Boot. By fixing up gd->ram_size @@ -343,8 +351,8 @@ static int setup_dest_addr(void) * memory size from the SDRAM controller setup will have to * get fixed. */ - gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE; -#endif + gd->ram_size -= board_reserve_ram_top(gd->ram_size); + #ifdef CONFIG_SYS_SDRAM_BASE gd->ram_top = CONFIG_SYS_SDRAM_BASE; #endif diff --git a/include/configs/ls2085a_common.h b/include/configs/ls2085a_common.h index 0011e72..55d6a53 100644 --- a/include/configs/ls2085a_common.h +++ b/include/configs/ls2085a_common.h @@ -193,10 +193,9 @@ unsigned long long get_qixis_addr(void); * 512MB aligned, so the min size to hide is 512MB. */ #if defined(CONFIG_FSL_MC_ENET) || defined(CONFIG_FSL_DEBUG_SERVER) -#define CONFIG_SYS_DEBUG_SERVER_DRAM_BLOCK_MIN_SIZE (256UL * 1024 * 1024) +#define CONFIG_SYS_DEBUG_SERVER_DRAM_BLOCK_MIN_SIZE (254UL * 1024 * 1024) #define CONFIG_SYS_LS_MC_DRAM_BLOCK_MIN_SIZE (256UL * 1024 * 1024) -#define CONFIG_SYS_MEM_TOP_HIDE_MIN (512UL * 1024 * 1024) -#define CONFIG_SYS_MEM_TOP_HIDE get_dram_size_to_hide() +#define CONFIG_SYS_MC_RESERV_MEM_ALIGN (512UL * 1024 * 1024) #endif /* PCIe */