Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C4FB8C54EE9 for ; Tue, 13 Sep 2022 18:32:13 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9339D84AD5; Tue, 13 Sep 2022 20:31:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="qvLSik/Z"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8BAA184A9C; Tue, 13 Sep 2022 20:31:50 +0200 (CEST) Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 665C784809 for ; Tue, 13 Sep 2022 20:31:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ovpanait@gmail.com Received: by mail-wr1-x42e.google.com with SMTP id b5so22140521wrr.5 for ; Tue, 13 Sep 2022 11:31:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=HjoN9GjNmhWcMMaEa2lS97i21V5odhx/DjxPdfTQxFs=; b=qvLSik/ZFWmIqBONzBoSoGY/NqBJMU+c+Hqt329aSPqBwI0uQr8my/qvVq6l5UTTNo sZyijZxg7V2kIfUl1BUX6nYsio+YHS9Ksl/hUdM56Mdcio2HTRLdqqftmcMZZtd0i1UM EjEu+h/XX5y9HEVj7D4N04HS6z4cjS7kL2QgCpdWu1+7V9erevHqvj8a1H3feYrAPKjh fU318fAXPph3QFViiwxjGoCYIJ/XdPxrGQsxaBlmxKWPw53g0q3biW92VG5UGfs+JLsd bSpOzFKnoBtxTi3UfDd9cOPArtZWy2OAE+OM63ut/fnpQtX8AV5ZK5PVdW6RPO8TbIG4 KVCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=HjoN9GjNmhWcMMaEa2lS97i21V5odhx/DjxPdfTQxFs=; b=nO0c6EkY4Lyb+hmj2qAhUxVWLsiPy90vVwypq8Upn/hhc1lZNgg+vAockj4/QNXQNF F84Jh0AmmhvK5ZAHUQZAzsr3kXw4aUX0+s9rDct0tP2kagLCH7sucAUVaEhttsrUG0yM NPbO+vvKJg/3YKXO7bcez6GHPJYC6fcC2c6xhBlDT4Pzf5Ku1/oQW33jHENrlvo9NgrZ eZLWK8YsQQNnHGScQRFRmd1FWNvctovSpWGOlfeRzXbmWllVsl98X6UNSjOj1Y/JIGvD +e9NqZtCiEgGCZw9LrySXujQ8rV82RrJlBxX+xR/zBYUTvwW3lIPr8TYQsHy5FqJk1zw oLKA== X-Gm-Message-State: ACgBeo0TUED9aoClzQdycMrTT+TuckqUldOvHhV2MldmNFKbwc+nVBOs 0nTt96ih7TM65dEDsTSzZE83HOxIlLE= X-Google-Smtp-Source: AA6agR7AcOKMbG7nfARhRJ8q0MTA3vcS4DteOs6ScEai5X88TIbHtS6Xz7lmvLzy1LrFTU1LKHdMTw== X-Received: by 2002:a05:6000:1f83:b0:228:6278:796b with SMTP id bw3-20020a0560001f8300b002286278796bmr18448279wrb.520.1663093905870; Tue, 13 Sep 2022 11:31:45 -0700 (PDT) Received: from localhost.localdomain ([2a02:2f0e:c700:bc00:2edf:22a1:3a82:86b4]) by smtp.gmail.com with ESMTPSA id o14-20020a5d684e000000b002287d99b455sm11156044wrw.15.2022.09.13.11.31.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Sep 2022 11:31:45 -0700 (PDT) From: Ovidiu Panait To: u-boot@lists.denx.de Cc: Ovidiu Panait , Simon Glass , Andy Shevchenko , Dzmitry Sankouski , Heinrich Schuchardt , Marek Vasut , Michal Simek , Rick Chen , Wolfgang Denk Subject: [PATCH v2 3/4] common/board_f: introduce arch_setup_dest_addr() Date: Tue, 13 Sep 2022 21:31:28 +0300 Message-Id: <20220913183129.14184-3-ovpanait@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913183129.14184-1-ovpanait@gmail.com> References: <20220913183129.14184-1-ovpanait@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.6 at phobos.denx.de X-Virus-Status: Clean In order to move ppc-specific code out of setup_dest_addr(), provide an arch-specific variant arch_setup_dest_addr(), that can be used by architecture code to fix up the initial reloc address. It is called at the end of setup_dest_addr() initcall and the default implementation is a nop stub. Reviewed-by: Simon Glass Signed-off-by: Ovidiu Panait --- Changes in v2: - add "Reviewed-by" tag from Simon arch/powerpc/lib/stack.c | 17 +++++++++++++++++ common/board_f.c | 21 +++++++-------------- include/init.h | 13 +++++++++++++ 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/lib/stack.c b/arch/powerpc/lib/stack.c index f2a4652e08..2e731aa870 100644 --- a/arch/powerpc/lib/stack.c +++ b/arch/powerpc/lib/stack.c @@ -13,6 +13,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -30,3 +31,19 @@ int arch_reserve_stacks(void) return 0; } + +int arch_setup_dest_addr(void) +{ +#if defined(CONFIG_MP) && (defined(CONFIG_MPC86xx) || defined(CONFIG_E500)) + /* + * We need to make sure the location we intend to put secondary core + * boot code is reserved and not used by any part of u-boot + */ + if (gd->relocaddr > determine_mp_bootpg(NULL)) { + gd->relocaddr = determine_mp_bootpg(NULL); + debug("Reserving MP boot page to %08lx\n", gd->relocaddr); + } +#endif + + return 0; +} diff --git a/common/board_f.c b/common/board_f.c index 3789708a30..96458c5151 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -45,9 +45,6 @@ #include #include #include -#if defined(CONFIG_MP) && defined(CONFIG_PPC) -#include -#endif #include #include #include @@ -307,6 +304,11 @@ __weak ulong board_get_usable_ram_top(ulong total_size) return gd->ram_top; } +__weak int arch_setup_dest_addr(void) +{ + return 0; +} + static int setup_dest_addr(void) { debug("Monitor len: %08lX\n", gd->mon_len); @@ -334,17 +336,8 @@ static int setup_dest_addr(void) gd->ram_top = board_get_usable_ram_top(gd->mon_len); gd->relocaddr = gd->ram_top; debug("Ram top: %08lX\n", (ulong)gd->ram_top); -#if defined(CONFIG_MP) && (defined(CONFIG_MPC86xx) || defined(CONFIG_E500)) - /* - * We need to make sure the location we intend to put secondary core - * boot code is reserved and not used by any part of u-boot - */ - if (gd->relocaddr > determine_mp_bootpg(NULL)) { - gd->relocaddr = determine_mp_bootpg(NULL); - debug("Reserving MP boot page to %08lx\n", gd->relocaddr); - } -#endif - return 0; + + return arch_setup_dest_addr(); } #ifdef CONFIG_PRAM diff --git a/include/init.h b/include/init.h index 7b8f62c121..448da34b46 100644 --- a/include/init.h +++ b/include/init.h @@ -103,6 +103,19 @@ phys_size_t get_effective_memsize(void); int testdram(void); +/** + * arch_setup_dest_addr() - Fix up initial reloc address + * + * This is called in generic board init sequence in common/board_f.c at the end + * of the setup_dest_addr() initcall. Each architecture could provide this + * function to make adjustments to the initial reloc address. + * + * If an implementation is not provided, it will just be a nop stub. + * + * Return: 0 if OK + */ +int arch_setup_dest_addr(void); + /** * arch_reserve_stacks() - Reserve all necessary stacks * -- 2.25.1