From patchwork Fri Oct 25 12:15:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 838340 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp239957wri; Fri, 25 Oct 2024 05:16:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW+P1Ol6gHOa+NIjI7jFwT8Is9bsy/SbBZj1p/y9HiVIwnHfY9RLHjC+NBomaiNdRQsWT8FHw==@linaro.org X-Google-Smtp-Source: AGHT+IFwB+T0+kXfzrAK316Yv00+iHp+PE1HO00uGcWrmnkZMIDzdwrHvRverCnFFE5EATrhx+xJ X-Received: by 2002:a05:6512:3da3:b0:53a:44c:615a with SMTP id 2adb3069b0e04-53b1a36c5a1mr6225545e87.43.1729858581259; Fri, 25 Oct 2024 05:16:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729858581; cv=none; d=google.com; s=arc-20240605; b=imGhE8y871i+m2Yo6aUkXPaaU/Tg/njyJallNCA3sBThzOBvj+6EtE9B9vYYUX1cdw bC8xorvBC4gGAkYRr/wrq+MWC/RmpZFFdRtcJl01FDpVUW1cHz+7dBiZxWyuNvuj9ayc twVO3ETOImIFen7O3Oh6YpZBtvVw7wKxTA1HWf7+ahpLrslTUIM3ua0Sh1LazYEFEfTZ eTu2U3th7rnTOfObtWDU9Ly1w3rix2dBAgduixSA6IPYPIwzRKJctzTwU0BuY7HyXEil Lq478dvseK6Al/NZ3ixYBPNo0N0pDXb4eKC+JEOxKIBU+2IO0acTOATscQGhnabdeDcx P5Bw== 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=JGAaDaIR+PDLJsx4HBCORq0lsUA066ADWVaQBp46fKA=; fh=4qhjWgg9bHeH/GNOfE5X3jcKCWXNzATraddlwAAhC5s=; b=N/jaQa8LyQIBOVtf4VzA+u3OZVprjhdVSvm5aRZJFlQekWgLvqecXLmUlXdRN6UpIN mngKi/nbgGdBq5wmHIVqEidtexfrJVZcvIrBWSiFNE/HmKd+cmtDJVedqcD19Qj45+Aw 348OmgAIz8YEQEc5P7dJJGFXCu2lbm0xJrIImsQrhnMwGbzXmx3UGj+V1qMvZZq/75H7 IM01uAzeJAgb/85O8w42VK6RHW6oDnB7AKtHzPZkBK0+ucyWOO/+qcDet6YIaXEFzj64 6UG/0wTesbI8vvHaJdcijaMDx9hS03/ksUV5WwGt3hI3hw+11Wy4ssVm57pSox4bcJnc /+JA==; 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 2adb3069b0e04-53b2e1c94fcsi417200e87.345.2024.10.25.05.16.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 05:16:21 -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 2B84989016; Fri, 25 Oct 2024 14:16:16 +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 8567588C10; Fri, 25 Oct 2024 14:16:15 +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 13BCE88FC5 for ; Fri, 25 Oct 2024 14:16:10 +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 3741612FC; Fri, 25 Oct 2024 05:16:39 -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 851593F71E; Fri, 25 Oct 2024 05:16:07 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Michal Simek , love.kumar@amd.com, Tom Rini , Sughosh Ganu Subject: [PATCH 2/2] xilinx: use get_mem_top() to compute ram_top Date: Fri, 25 Oct 2024 17:45:47 +0530 Message-Id: <20241025121547.181633-3-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025121547.181633-1-sughosh.ganu@linaro.org> References: <20241025121547.181633-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; +}