From patchwork Wed Aug 21 10:58:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 820975 Delivered-To: patch@linaro.org Received: by 2002:adf:e98a:0:b0:367:895a:4699 with SMTP id h10csp641161wrm; Wed, 21 Aug 2024 04:03:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWb36O8P5L3nOqwGF75ax675BuXJELWotbceQ4b2+mLpUAoZfNBaK5yLMG1B321aiVaWs+UYQ==@linaro.org X-Google-Smtp-Source: AGHT+IEZLPN1merT761g2xCIMAsT/jtxLdW8cKZ/NgLAlDUl9hv8jESGLzuR+J4xFrghZGDfNmh6 X-Received: by 2002:a05:6512:a91:b0:52e:7448:e137 with SMTP id 2adb3069b0e04-533485533edmr1227778e87.6.1724238201180; Wed, 21 Aug 2024 04:03:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724238201; cv=none; d=google.com; s=arc-20160816; b=vKP2cL4Gj6PsPWxSNsdGUqwF1yJs/4dt8RKqs8zN6E/EEx9hp0sk/b4ho6W4aVA5R/ 1ky9u1mQwOSu0yQdFI2wh4hlyMdm1N+lNO7OEq5wL/l4sUT9aMQuXpCtJv70aZpPcfZ4 8lsyh+YmYzQLhYW3FShFPe2ndZuZSU5TuHPFi0DiKyegPx6/vGbRLFlU4H6HO7pXgwP0 HasAunrCy/BjTsZYmZEx3K4F/7kkZqeNrH+VVrO2c7ov37un47cnXE4tUoYpw63d4Npa PZkfr9LYI84sBIyWNrueYmVERWKAdl5OPsJXfvhCEw7iu2pzrXGT9XILfmg2Ci1k1Ug6 DM2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=6LQ8olYz8L39nzVIMvWDhh1+Y+Ias5Kgzb/NzvC6iD8=; fh=pnMZGD6unUPoMrkOwzXlkuYg+kVwGnSNRCTlQoWqjVc=; b=kJETgo/sioC8RfcSl10XpRpQxZn4NqQsPYHkm4/K2p0nw2QTGlpEtmpTr4+fvtd5A+ aFcLgx5vtreWq++wHv+Ui9e6wx+/CIPk7TPg9VHwhjP3OskeOtJjuLz+8GT0VUlT3Xsm NSi9RQ6/UzeKw3OzSnavKXAjRlSSz9KGXzgXSutcvsXdEZKV6rOrJRV6dp5fzJiXRXml 6scVWL725dnw4MthaGZNtaNuS2OS6O4GqlNKn4/MCOQvee84M6zBkV72/T1k49P+6Y6q nnJQTBA/564VL1s+M6NTzoW5IZmyx3NK6Z+lLdfrAvj9Uie89qxvyeRME/IkbHSj2teN 7hbg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-a838398db83si814704966b.1052.2024.08.21.04.03.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 04:03:21 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 D835B88DDD; Wed, 21 Aug 2024 13:00:37 +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 6541388113; Wed, 21 Aug 2024 13:00:37 +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_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE 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 3A42988DDD for ; Wed, 21 Aug 2024 13:00:35 +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 B8CF4FEC; Wed, 21 Aug 2024 04:01:00 -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 56D8B3F73B; Wed, 21 Aug 2024 04:00:31 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Simon Glass , Tom Rini , Ilias Apalodimas , Heinrich Schuchardt , Marek Vasut , Mark Kettenis , Michal Simek , Patrick DELAUNAY , Patrice CHOTARD , Sughosh Ganu Subject: [PATCH v3 25/27] stm32mp: allow calling optee_get_reserved_memory() from U-Boot Date: Wed, 21 Aug 2024 16:28:37 +0530 Message-Id: <20240821105839.2870293-26-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240821105839.2870293-1-sughosh.ganu@linaro.org> References: <20240821105839.2870293-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 The optee_get_reserved_memory() function returns the OP-TEE base address and size. The function gets these values from the FDT. Currently, this function is defined only to be called in the SPL phase. Move this function to a place where it can be invoked from the main U-Boot phase, where it will be used to compute the ram_top address. Signed-off-by: Sughosh Ganu --- Changes since V2: None arch/arm/mach-stm32mp/dram_init.c | 17 +++++++++++++++++ arch/arm/mach-stm32mp/include/mach/stm32mp.h | 11 +++++++++++ arch/arm/mach-stm32mp/stm32mp1/spl.c | 17 +---------------- 3 files changed, 29 insertions(+), 16 deletions(-) create mode 100644 arch/arm/mach-stm32mp/include/mach/stm32mp.h diff --git a/arch/arm/mach-stm32mp/dram_init.c b/arch/arm/mach-stm32mp/dram_init.c index e8b0a38be1..b3dbd521b7 100644 --- a/arch/arm/mach-stm32mp/dram_init.c +++ b/arch/arm/mach-stm32mp/dram_init.c @@ -14,9 +14,26 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; +int optee_get_reserved_memory(uint32_t *start, uint32_t *size) +{ + fdt_addr_t fdt_mem_size; + fdt_addr_t fdt_start; + ofnode node; + + node = ofnode_path("/reserved-memory/optee"); + if (!ofnode_valid(node)) + return -ENOENT; + + fdt_start = ofnode_get_addr_size(node, "reg", &fdt_mem_size); + *start = fdt_start; + *size = fdt_mem_size; + return (fdt_start < 0) ? fdt_start : 0; +} + int dram_init(void) { struct ram_info ram; diff --git a/arch/arm/mach-stm32mp/include/mach/stm32mp.h b/arch/arm/mach-stm32mp/include/mach/stm32mp.h new file mode 100644 index 0000000000..afc03c9ba8 --- /dev/null +++ b/arch/arm/mach-stm32mp/include/mach/stm32mp.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */ +/* + * Copyright (C) 2024, STMicroelectronics - All Rights Reserved + */ + +#ifndef __MACH_STM32MP_H_ +#define __MACH_STM32MP_H_ + +int optee_get_reserved_memory(uint32_t *start, uint32_t *size); + +#endif diff --git a/arch/arm/mach-stm32mp/stm32mp1/spl.c b/arch/arm/mach-stm32mp/stm32mp1/spl.c index 6eae5c2f55..9c4fafbf47 100644 --- a/arch/arm/mach-stm32mp/stm32mp1/spl.c +++ b/arch/arm/mach-stm32mp/stm32mp1/spl.c @@ -18,6 +18,7 @@ #include #include #include +#include #include u32 spl_boot_device(void) @@ -110,22 +111,6 @@ uint32_t stm32mp_get_dram_size(void) return ram.size; } -static int optee_get_reserved_memory(uint32_t *start, uint32_t *size) -{ - fdt_addr_t fdt_mem_size; - fdt_addr_t fdt_start; - ofnode node; - - node = ofnode_path("/reserved-memory/optee"); - if (!ofnode_valid(node)) - return -ENOENT; - - fdt_start = ofnode_get_addr_size(node, "reg", &fdt_mem_size); - *start = fdt_start; - *size = fdt_mem_size; - return (fdt_start < 0) ? fdt_start : 0; -} - #define CFG_SHMEM_SIZE 0x200000 #define STM32_TZC_NSID_ALL 0xffff #define STM32_TZC_FILTER_ALL 3