From patchwork Mon Aug 26 11:59:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 822459 Delivered-To: patch@linaro.org Received: by 2002:adf:e044:0:b0:367:895a:4699 with SMTP id w4csp1478724wrh; Mon, 26 Aug 2024 05:04:22 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWULWt9pUEvwrM3/N4lPSViWeJInG2veIgSwExIJYfdnK3JNuaQMgk5I3MagEGxGcs5CsTqXA==@linaro.org X-Google-Smtp-Source: AGHT+IGG12USm5cxV2FAo4A5YU49irj5wCkdyorTE+OVDarKs51sFpMvSzmwFaDGKxm6Ib02F39K X-Received: by 2002:a5d:588d:0:b0:371:8688:1660 with SMTP id ffacd0b85a97d-373118eccefmr7569640f8f.51.1724673862410; Mon, 26 Aug 2024 05:04:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724673862; cv=none; d=google.com; s=arc-20240605; b=VRQCvNNOyaqi1oY3c2THAuywtQY2AZLW4YChHxcFdhhAd21K+mI1sO996OTBoXtzGv 4OgCVbXGbvRb2g9HZp+oyPbgYFYPmzIpLDd69gvxd56DaNIO2RJjfoecP6Zs6AuwFB5H ZQop+Muc1kRn5ullC6I6uZMa1gQdaaUhS2MXu6KYxRsWKimlvFulJI51RFtIC/xcyL5A 1rW3AgW3aXfwK3+i3Np3chtKAntL4wk38amnraICxJmkP3z7yglycEw7gVlan+Opaq2C kLHc+oEu/fbUSkKWAqMzuDCuODtWuEkvEY8wCLRz4Ti+v+SD82SDxxU0S2MA5CLKixMu zkiw== 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=mMqGD9bWXJyM0whk+PzJwN6kNlNourdzw7fizusckvw=; fh=8IbOOFAUJYCfGYrzM0jWqtoOP7AaZuPOmdHZ5mvNk1Q=; b=lhrGK5DHPNM9Wu3bMfX25m+W5iRMG91j7yIeTpQOLMsuw6sSmNlp0b0TGiiYg0/KNt gzoPr6dfBKPzu049qrpEg8NB4/XRyddNy7+vmJI9DT4CLOTRzzDVPamAAa1c//36A8zW MGjCszvJWhNsKYtxxsPzGo7kRZrvK5C9yphKr8PqkK6HeHvJNQDJPkMYlwU5R/qC5f0+ qIF/g49XKTYbHMblcTR5zkwUCcpI/x1HFBSJdn4znkssaz+qb3A3pZbBSUQZ8twUgBXH Efxdni5yAkDmrWg/CWz2Qg28eonOyP7XAl09l+aO3k/SxtNObVrkLrPfCW4xO7Qwl+YM slkA==; 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 5b1f17b1804b1-42abefdb775si57434525e9.173.2024.08.26.05.04.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 05:04:22 -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 5A89188BE4; Mon, 26 Aug 2024 14:01:56 +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 625FD88BE4; Mon, 26 Aug 2024 14:01:55 +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 0100688C3A for ; Mon, 26 Aug 2024 14:01:53 +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 99949DA7; Mon, 26 Aug 2024 05:02:18 -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 B5EDC3F762; Mon, 26 Aug 2024 05:01:48 -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 , =?utf-8?q?Marek_Beh=C3=BAn?= , Sughosh Ganu Subject: [PATCH v4 25/27] stm32mp: allow calling optee_get_reserved_memory() from U-Boot Date: Mon, 26 Aug 2024 17:29:38 +0530 Message-Id: <20240826115940.3233167-26-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240826115940.3233167-1-sughosh.ganu@linaro.org> References: <20240826115940.3233167-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 V3: * s/uint32_t/u32 in optee_get_reserved_memory() as suggested by checkpatch. 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..286791be2e 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(u32 *start, u32 *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..506a42559b --- /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(u32 *start, u32 *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