From patchwork Tue May 11 08:30:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 1476950 X-Patchwork-Delegate: lokeshvutla@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=UGFGWPhK; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfWTW6rMJz9sWp for ; Tue, 11 May 2021 18:35:43 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0ED2C82FB7; Tue, 11 May 2021 10:32:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="UGFGWPhK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1AE3682F80; Tue, 11 May 2021 10:32:03 +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=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2D2E482F65 for ; Tue, 11 May 2021 10:31:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kristo@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id 89BF061107; Tue, 11 May 2021 08:31:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620721913; bh=6gV2TXhWlckxSAvbWBzOcYSbyjhwYhNqezaW8f3asBY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UGFGWPhKFv3HVn1xMGDS+AvDoAJwzaSNOiH/hORMFuaPn5igKO43lbYhcXWThS/sF f7XLLUI1uGI4DVEhtmGxVnKtzkH6zQN3CRrO0/H1uTN87f3GwnCTs9f9pvRXWYBKbx RUSv665U+yukdOz7QZYcqJOI0G21Z5UYEnACEwA5/Zp7EUiC1g3zWjWdUcf0ticgXt MwGZpC8oBPPWOlQB0s79t0ChDBTD6JZnUVNfWP0PIlMUM94FrpjRIHAgayKexxhTtk A+Jo9zzPqie1zyYG6BQ5DmRlxauAt58p5iDckxRVyyhY2LmIMujGcFCUv3QSd66s2u dYw7VSh+MgIAA== From: Tero Kristo To: u-boot@lists.denx.de, lokeshvutla@ti.com Cc: trini@konsulko.com, praneeth@ti.com, d-gerlach@ti.com Subject: [PATCHv4 21/26] arm: mach-k3: sysfw-loader: pass boardcfg to sciserver Date: Tue, 11 May 2021 11:30:59 +0300 Message-Id: <20210511083104.10868-22-kristo@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210511083104.10868-1-kristo@kernel.org> References: <20210511083104.10868-1-kristo@kernel.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.4 at phobos.denx.de X-Virus-Status: Clean From: Tero Kristo Copy the contents of the board config loaded from sysfw.itb into an EXTBOOT shared memory buffer that gets passed to sciserver. This only needs to be done if EXTBOOT area has not been populated by ROM code yet. Signed-off-by: Tero Kristo Signed-off-by: Tero Kristo --- arch/arm/mach-k3/sysfw-loader.c | 103 ++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/arch/arm/mach-k3/sysfw-loader.c b/arch/arm/mach-k3/sysfw-loader.c index c6af205163..ac719cd46f 100644 --- a/arch/arm/mach-k3/sysfw-loader.c +++ b/arch/arm/mach-k3/sysfw-loader.c @@ -40,6 +40,46 @@ DECLARE_GLOBAL_DATA_PTR; */ #define K3_SYSTEM_CONTROLLER_RPROC_ID 0 +#define COMMON_HEADER_ADDRESS 0x41cffb00 +#define BOARDCFG_ADDRESS 0x41c80000 + +#define COMP_TYPE_SBL_DATA 0x11 +#define DESC_TYPE_BOARDCFG_PM_INDEX 0x2 +#define DESC_TYPE_BOARDCFG_RM_INDEX 0x3 + +#define BOARD_CONFIG_RM_DESC_TYPE 0x000c +#define BOARD_CONFIG_PM_DESC_TYPE 0x000e + +struct extboot_comp { + u32 comp_type; + u32 boot_core; + u32 comp_opts; + u64 dest_addr; + u32 comp_size; +}; + +struct extboot_header { + u8 magic[8]; + u32 num_comps; + struct extboot_comp comps[5]; + u32 reserved; +}; + +struct bcfg_desc { + u16 type; + u16 offset; + u16 size; + u8 devgrp; + u8 reserved; +} __packed; + +struct bcfg_header { + u8 num_elems; + u8 sw_rev; + struct bcfg_desc descs[4]; + u16 reserved; +} __packed; + static bool sysfw_loaded; static void *sysfw_load_address; @@ -131,6 +171,15 @@ static void k3_sysfw_configure_using_fit(void *fit, const void *cfg_fragment_addr; size_t cfg_fragment_size; int ret; +#ifdef CONFIG_K3_DM_FW + u8 *buf; + struct extboot_header *common_header; + struct bcfg_header *bcfg_header; + struct extboot_comp *comp; + struct bcfg_desc *desc; + u32 addr; + bool copy_bcfg = false; +#endif /* Find the node holding the images information */ images = fdt_path_offset(fit, FIT_IMAGES_PATH); @@ -165,6 +214,46 @@ static void k3_sysfw_configure_using_fit(void *fit, (u32)cfg_fragment_size); if (ret) panic("Failed to set board PM configuration (%d)\n", ret); +#else + /* Initialize shared memory boardconfig buffer */ + buf = (u8 *)COMMON_HEADER_ADDRESS; + common_header = (struct extboot_header *)buf; + + /* Check if we have a struct populated by ROM in memory already */ + if (strcmp((char *)common_header->magic, "EXTBOOT")) + copy_bcfg = true; + + if (copy_bcfg) { + strcpy((char *)common_header->magic, "EXTBOOT"); + common_header->num_comps = 1; + + comp = &common_header->comps[0]; + + comp->comp_type = COMP_TYPE_SBL_DATA; + comp->boot_core = 0x10; + comp->comp_opts = 0; + addr = (u32)BOARDCFG_ADDRESS; + comp->dest_addr = addr; + comp->comp_size = sizeof(*bcfg_header); + + bcfg_header = (struct bcfg_header *)addr; + + bcfg_header->num_elems = 2; + bcfg_header->sw_rev = 0; + + desc = &bcfg_header->descs[0]; + + desc->type = BOARD_CONFIG_PM_DESC_TYPE; + desc->offset = sizeof(*bcfg_header); + desc->size = cfg_fragment_size; + comp->comp_size += desc->size; + desc->devgrp = 0; + desc->reserved = 0; + memcpy((u8 *)bcfg_header + desc->offset, cfg_fragment_addr, + cfg_fragment_size); + + bcfg_header->descs[1].offset = desc->offset + desc->size; + } #endif /* Extract resource management (RM) specific configuration from FIT */ @@ -174,6 +263,20 @@ static void k3_sysfw_configure_using_fit(void *fit, panic("Error accessing %s node in FIT (%d)\n", SYSFW_CFG_RM, ret); +#ifdef CONFIG_K3_DM_FW + if (copy_bcfg) { + desc = &bcfg_header->descs[1]; + + desc->type = BOARD_CONFIG_RM_DESC_TYPE; + desc->size = cfg_fragment_size; + comp->comp_size += desc->size; + desc->devgrp = 0; + desc->reserved = 0; + memcpy((u8 *)bcfg_header + desc->offset, cfg_fragment_addr, + cfg_fragment_size); + } +#endif + /* Apply resource management (RM) configuration to SYSFW */ ret = board_ops->board_config_rm(ti_sci, (u64)(u32)cfg_fragment_addr,