From patchwork Fri Oct 25 17:27:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 838368 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp415089wri; Fri, 25 Oct 2024 10:28:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU/aNU5rEdXFD/uUGOR/0ccdykDEaHQnxLk5IXOBmmWIZwQMXIo0mQL/72ZHeV31V+/iZovGQ==@linaro.org X-Google-Smtp-Source: AGHT+IGUuQaa4lcaTMqX5CO9p/hnib5EKUY6DqJfTLA9BaIQNkp5Z6qzU1IcygE6kqmqL38TZmr1 X-Received: by 2002:a2e:b8c2:0:b0:2fb:565a:d93c with SMTP id 38308e7fff4ca-2fcbdf5ea76mr631071fa.1.1729877295253; Fri, 25 Oct 2024 10:28:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729877295; cv=none; d=google.com; s=arc-20240605; b=NbkCu2GGgrzBGzh6LD0w8FPy3VbtzYQVRRGAJoblBh+Whvos1uT508z6uWblfffk2z hb9BpjhnN1Nz9+iuJkR1de/KGvj/cvhxkGkc4tN40Wb61l0WgzRFi8hCg22fxmFQmCkz FOshRNQtdAQ2eZ5w23ETVImZfGiJCmwmtFhEj1m7eAck/Ae5q/HjQP6MBPFLh76by+Fi 1cWZ1NLFPxC/hIQ2WmZUd7JBbLRxPY6dR5tOI1SrfO8kCsP7zy1ajWmIhJZ0zbvkq6b0 LrgzEn+PSOqWv3aZ1u6NVqbQ3QdY6/nUW+eEcfYso9PODXpsesgAVVjzi+ZLmYR9eYXh yP+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=5s4uToBrQknXC9IoJW/4442r9opXD7JwP/Tp1aTRyH0=; fh=4qhjWgg9bHeH/GNOfE5X3jcKCWXNzATraddlwAAhC5s=; b=FId2BBIIoT9PwI+MpWtQGIMyz2G65jh473KT13dNqNysJU3CEDjbOG90MlqCqZtMto XMQ+oZbFkNlJ+Veirv2QacJDO1SExYIrDiN03wdlXqcMjPDp+sa9fRxe/bYRp433Vkun hm8D67WOEwq8+ssWksk4WhWprr5OavtGZNlnFkBBMJqsQ/yIMQRrAFtOFdxNHeOIj4jp ubLnVzZzTNfYg4iOsUpWUW1DWllN0877BoAkNlSE8beMYC4hDwrBsJCBKfSm1pXXW/RL pUILodetuB9LdH+PkjxgK445f+wiT19DslbMJN3wm/b3Ith11WLd8wvh4rBbWsh7tWyq v3Tw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 38308e7fff4ca-2fcb4625b87si5050721fa.469.2024.10.25.10.28.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 10:28:15 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 80A1989020; Fri, 25 Oct 2024 19:27:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 69E5689043; Fri, 25 Oct 2024 19:27:51 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id BD16E88A4C for ; Fri, 25 Oct 2024 19:27:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EB846497; Fri, 25 Oct 2024 10:28:11 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 689D43F71E; Fri, 25 Oct 2024 10:27:40 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Michal Simek , love.kumar@amd.com, Tom Rini , Sughosh Ganu Subject: [PATCH v2 2/2] xilinx: use get_mem_top() to compute ram_top Date: Fri, 25 Oct 2024 22:57:24 +0530 Message-Id: <20241025172724.195093-3-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025172724.195093-1-sughosh.ganu@linaro.org> References: <20241025172724.195093-1-sughosh.ganu@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Use the get_mem_top function to compute the value of ram_top. This was earlier done through LMB API's, which are no longer available till after relocation. Use get_mem_top() instead to compute the ram_top value. Signed-off-by: Sughosh Ganu Reviewed-by: Michal Simek --- board/xilinx/common/board.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c index 38dd80533fa..e14ed2cff00 100644 --- a/board/xilinx/common/board.c +++ b/board/xilinx/common/board.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "board.h" #include @@ -676,3 +677,27 @@ int ft_board_setup(void *blob, struct bd_info *bd) return 0; } #endif + +#ifndef MMU_SECTION_SIZE +#define MMU_SECTION_SIZE (1 * 1024 * 1024) +#endif + +phys_addr_t board_get_usable_ram_top(phys_size_t total_size) +{ + phys_size_t size; + phys_addr_t reg; + + if (!total_size) + return gd->ram_top; + + if (!IS_ALIGNED((ulong)gd->fdt_blob, 0x8)) + panic("Not 64bit aligned DT location: %p\n", gd->fdt_blob); + + size = ALIGN(CONFIG_SYS_MALLOC_LEN + total_size, MMU_SECTION_SIZE); + reg = get_mem_top(gd->ram_base, gd->ram_size, size, + (void *)gd->fdt_blob); + if (!reg) + reg = gd->ram_top - size; + + return reg + size; +}