From patchwork Tue Dec 19 16:04:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 755925 Delivered-To: patch@linaro.org Received: by 2002:adf:b181:0:b0:336:6142:bf13 with SMTP id q1csp1501589wra; Tue, 19 Dec 2023 08:07:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IET0i4FcA/2LG/AZanoUqubeCXWSVnDpAJPUcNpi3BeJuVfSbH2h56jrticiTj1eaXmreBM X-Received: by 2002:a05:600c:1913:b0:40c:366a:598a with SMTP id j19-20020a05600c191300b0040c366a598amr9664930wmq.107.1703002043026; Tue, 19 Dec 2023 08:07:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703002043; cv=none; d=google.com; s=arc-20160816; b=cJcHWaAm1mDrTbBha+dAAk5nhGEB9n/YLNlkcCQx/EpsfGR92yiwHAexpZ2LcEN1fO BukHku4kOzwTs39L3tyiALsbo3KZSTsGK1cUxdKQJPaemgCosHTOeyqJP8Qy3LXLn+ol lI5Szq3ua44EmY/NDMqAEZ0LCqSXguofqO+JNXW1cp41h0YTVIrJhU3yNb6GwfATnSWH 4yYtIPGI2OzHzlAGdlqVfn8WTsi9L90J7q/qRO/Kutf+pFQvbnaIeDYcwTAvP++8fbcI H+o+7xbp9sxnmO0MOCOUjLN3L8DM1MqVfGi81wvC5J/qO1OEE1Qg7TnBDfXeZIm2hSU/ b30A== 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:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=wgMWuDvGVcEVx9PLuavCvO43mXySJWj1lDk62kGmP7c=; fh=GB9E9KzRIiNXhkRWIZbZpSMjbCjxnqnvE8nYuQxq8UI=; b=m1kJjXzN/U6He8bJcJrfgTc56Ez4EQ2dfdvw9dkqAhFaUOpNEFKD+UJvH8YZy5gmdg d80iceoWTSuQdJZch/gw/IXM6/M6N5Gmz7fj/fKLcPHeU4VetxeyfWR6u0JQDhuwGjC2 P+wUO3xhO/sINpK/oiyMrQA8FEti/hkaS3s9u5k/Q3hNg7sIP4zaK+fZZdGK3TazK+rx KZ7oOqcbTa0Wzy/YBV0ny0lFZSBCzqPbzazVPrWDgF7GszKHb41SMUNsbFeD0J+tkNi8 CngftcMeMPi0cjGTC4qwYBYji2HJFtAKI+EQ8Kqa/PtdVkPKERTPs3ljvlqbqaO06jcH LD2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J+zjEoWl; 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=pass (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 a4-20020a05600c348400b0040c4620ba2fsi921630wmq.217.2023.12.19.08.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 08:07:23 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=J+zjEoWl; 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=pass (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 AA70E878AC; Tue, 19 Dec 2023 17:05:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.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=linaro.org header.i=@linaro.org header.b="J+zjEoWl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 340F6877CB; Tue, 19 Dec 2023 17:04:57 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) (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 5DA3D87817 for ; Tue, 19 Dec 2023 17:04:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-40c339d2b88so50896505e9.3 for ; Tue, 19 Dec 2023 08:04:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703001879; x=1703606679; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=wgMWuDvGVcEVx9PLuavCvO43mXySJWj1lDk62kGmP7c=; b=J+zjEoWloGWm8s60HXhG4Mc6vWKeD7adb9tuHK6rmxRSroQJ5RHaAMGYyNU741oVmS FePUuiThlckSULzJoISBSdEBrj+d3eT69QI7RAzZYXXoky2d/2EPqIYso3FHvzmxc2hj 4rtHCGHvTbDqUFCdLBykFmSafLIkWeuPXmczsHXC+8qudlZR9oKzojVM+Dr107pNtq38 HSIBtAEcm6A3q5KkaZhFNmAmiyea/aQDTv4dZBrOQvDKNLOCO6aeOEu9rAwwfiROywMC nm+NgR/XCN+hRL/X0F7/BLV0oyv7xuk6iu+AW/ZvDTYLBhGd6SrXKcIfI5Rr5aPdN8IX fcjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703001879; x=1703606679; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wgMWuDvGVcEVx9PLuavCvO43mXySJWj1lDk62kGmP7c=; b=bh4aggMVDtomU7mFgRx2nKw3/0tsYO2Q8pQxxaagtv7vyLnXhuwyBTpu4S4XzRLh6C gZL8EmK0szQHePa9dktHHgTlpv0JOZDpbpLX2TAlGTdRT9Vc+2NGKg03FUG3WrV8yrSa KbkB52mitp+bn5LzKCIZQLbfyxmWsQqZXnPE80Nbft3n2kxnkcWCEO+2AsmGGp7pv6pk wxe19nItD9gE6YuYthXoDJaVzR1FsikEfzk1e03CHOrV3fqSBgXN1zX/Qrkaz+D9Ln+f +I0wqIemIf4xE1cZBMP1KnvKSCCZ5UslJ+jc33QwwQj/DjQ0qdPkNRe4IP3pNKolHalZ Tv9A== X-Gm-Message-State: AOJu0YyQlJ+J4XEX3/7AiUYwE2yQsV01Ln87TF72QWS2JWg49fScoVdX 3WJh9V+STYi2V2SZ/scJ8t1MAg== X-Received: by 2002:a05:600c:3b8a:b0:40b:35aa:bfdd with SMTP id n10-20020a05600c3b8a00b0040b35aabfddmr8511577wms.27.1703001878908; Tue, 19 Dec 2023 08:04:38 -0800 (PST) Received: from lion.localdomain (host-92-17-96-230.as13285.net. [92.17.96.230]) by smtp.gmail.com with ESMTPSA id je17-20020a05600c1f9100b0040d1450ca7esm3429723wmb.7.2023.12.19.08.04.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 08:04:38 -0800 (PST) From: Caleb Connolly Date: Tue, 19 Dec 2023 16:04:17 +0000 Subject: [PATCH v2 16/32] mach-snapdragon: dynamic load addresses MIME-Version: 1.0 Message-Id: <20231219-b4-qcom-common-target-v2-16-b6dd9704219e@linaro.org> References: <20231219-b4-qcom-common-target-v2-0-b6dd9704219e@linaro.org> In-Reply-To: <20231219-b4-qcom-common-target-v2-0-b6dd9704219e@linaro.org> To: Neil Armstrong , Sumit Garg , Ramon Fried , Dzmitry Sankouski , Caleb Connolly , Peng Fan , Jaehoon Chung , Rayagonda Kokatanur , Lukasz Majewski , Sean Anderson , Jorge Ramirez-Ortiz , Stephan Gerhold Cc: Marek Vasut , u-boot@lists.denx.de X-Mailer: b4 0.13-dev-4bd13 X-Developer-Signature: v=1; a=openpgp-sha256; l=2945; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=txcnT6R4iyi/uw1WyGnpA/FiKqq7joOZV7jXyneMllI=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtTG/czrOfbNbng4hYNJfKaks3ym7OOkH9r8UanR7vlhz BMnBq/qKGVhEORgkBVTZBE/scyyae1le43tCy7AzGFlAhnCwMUpABPxF2Zk2DCte7/91N+cBZIt vx/rZf7VKDOunvWP97zckp1uUszMigz/bB82X9ny5u2DTzd+73D8sY+tYuuPV6HToj8e+3Q6eUu NhgIA X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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 Heavily inspired by Apple board code. Use the LMB allocator to configure load addresses at runtime, and implement a lookup table for selecting a devicetree. As some Qualcomm RBx boards have different RAM capacities and base addresses, it isn't possible to hardcode these regions. Signed-off-by: Caleb Connolly --- arch/arm/Kconfig | 1 + arch/arm/mach-snapdragon/board.c | 35 ++++++++++++++++++++++++ board/qualcomm/dragonboard410c/dragonboard410c.c | 2 +- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index e814910cb495..5ed9cbf378fa 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1075,6 +1075,7 @@ config ARCH_SNAPDRAGON select OF_SEPARATE select SMEM select SPMI + select BOARD_LATE_INIT select OF_BOARD select SAVE_PREV_BL_FDT_ADDR select LINUX_KERNEL_IMAGE_HEADER diff --git a/arch/arm/mach-snapdragon/board.c b/arch/arm/mach-snapdragon/board.c index bf9b57682178..b00f536d38b4 100644 --- a/arch/arm/mach-snapdragon/board.c +++ b/arch/arm/mach-snapdragon/board.c @@ -20,6 +20,7 @@ #include #include #include +#include #include DECLARE_GLOBAL_DATA_PTR; @@ -112,6 +113,40 @@ int board_init(void) return 0; } +void __weak qcom_late_init(void) +{ +} + +#define KERNEL_COMP_SIZE SZ_64M +#define SZ_96M (SZ_64M + SZ_32M) + +#define addr_alloc(lmb, size) lmb_alloc(lmb, size, SZ_2M) + +/* Stolen from arch/arm/mach-apple/board.c */ +int board_late_init(void) +{ + struct lmb lmb; + u32 status = 0; + + lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob); + + /* We need to be fairly conservative here as we support boards with just 1G of TOTAL RAM */ + status |= env_set_hex("kernel_addr_r", addr_alloc(&lmb, SZ_128M)); + status |= env_set_hex("ramdisk_addr_r", addr_alloc(&lmb, SZ_96M)); + status |= env_set_hex("kernel_comp_addr_r", addr_alloc(&lmb, KERNEL_COMP_SIZE)); + status |= env_set_hex("kernel_comp_size", KERNEL_COMP_SIZE); + status |= env_set_hex("scriptaddr", addr_alloc(&lmb, SZ_4M)); + status |= env_set_hex("pxefile_addr_r", addr_alloc(&lmb, SZ_4M)); + status |= env_set_hex("fdt_addr_r", addr_alloc(&lmb, SZ_2M)); + + if (status) + log_warning("%s: Failed to set run time variables\n", __func__); + + qcom_late_init(); + + return 0; +} + static void build_mem_map(void) { int i; diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c b/board/qualcomm/dragonboard410c/dragonboard410c.c index e403ecf0ad7c..2a502c7c2841 100644 --- a/board/qualcomm/dragonboard410c/dragonboard410c.c +++ b/board/qualcomm/dragonboard410c/dragonboard410c.c @@ -77,7 +77,7 @@ int misc_init_r(void) return 0; } -int board_late_init(void) +int qcom_late_init(void) { char serial[16];