From patchwork Tue Jan 30 14:05:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 768081 Delivered-To: patch@linaro.org Received: by 2002:adf:ee41:0:b0:33a:e5bd:fedd with SMTP id w1csp1387096wro; Tue, 30 Jan 2024 06:08:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IEOfSVZjFz87INFCRWAL/pkUpo4FjG65mGQVqz9Qlvg85i9fPl1rtiejvs5XH4IMEC8hm5E X-Received: by 2002:adf:ead2:0:b0:337:c730:d7e3 with SMTP id o18-20020adfead2000000b00337c730d7e3mr5935397wrn.57.1706623726596; Tue, 30 Jan 2024 06:08:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1706623726; cv=none; d=google.com; s=arc-20160816; b=Yz7Jtw96b7kDTe+Ve6NmQ0zZYMUfzkoQbhOpEf65I6j5fE9Tv1QmYKX0FXbpPuhIk9 pk9EDve2JNZr23bAyXkPctfABQJ0m1hSQvaXnMkqz9C0afNSG5Gdh5RVth8mUXp8ZQvx ULoQtQ9wWBZnQiHmpthM5TUT5X0oYdRENetPY37LkmMkbTDOqDo9K+qsk8wOjukBLFBG UyYRQLMofA/qaydpeI4sLMth5CiX7FKHbgiP56rUGi8mwZ+ZtxItsnQm70zDXwXe/9Qu asY0cHYUB8+bjm9eu7zFedcw381duOUyhcVqNXU/ztX3/oN/ELPB9Q92FjObZub9Jwzk 8WCw== 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=8gb1u2H94rZEk9mGhCSonGNtRpGSlOkG3bOT+lHb6Bo=; fh=GB9E9KzRIiNXhkRWIZbZpSMjbCjxnqnvE8nYuQxq8UI=; b=DHld8Id7xxYHARmgvrDNbspkAEQuK0IGf4ZFvtBYhIDq4pOL26MiBIthcyjYLALItG YQTR1ofG5705Vz3IBdln2bC+xxLU9jwWuN6x2vFkv8wJddK07+psz8Xcuo352m9xrdr4 Aa60IJFftH2X8X2iSH4XAB+4CfCQNGiAgubO5W0K3Ke+iY1d4d3DXDcUDM5gs/x5KuEP Cy05PnEKSuC0xTCpK7cz+B0QwjaJEFFc60P3ukQu2mIbuZvqDO1spBCAFYF/xhswI8jm vxfAw/xZOb77j8vjYu2LE3BdgClTQOuSIVIt6xaH8+DqQwGGNc/GYa1LswvDVEBQES1b l6tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aMDThXF1; 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 j6-20020a5d4646000000b0033ae810f24bsi3387091wrs.824.2024.01.30.06.08.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 06:08:46 -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=aMDThXF1; 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 A6D9387E8D; Tue, 30 Jan 2024 15:05:40 +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="aMDThXF1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D344A87E31; Tue, 30 Jan 2024 15:05:37 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) (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 7997787E31 for ; Tue, 30 Jan 2024 15:05:27 +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-x32a.google.com with SMTP id 5b1f17b1804b1-40fafced243so2318675e9.0 for ; Tue, 30 Jan 2024 06:05:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706623527; x=1707228327; 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=8gb1u2H94rZEk9mGhCSonGNtRpGSlOkG3bOT+lHb6Bo=; b=aMDThXF1dLW0H1Szls9NN/Id7bmMprZ5G/8dXQgdJzFdNV1WK9G+7jfFWt/j9Ixk6f yzwdDcs4Wk5BI9MzMHvVjr5P3+7WzJgE8FfH0HWlm5PCle8TTdBSPfyjC1fGte7bmYwq xwRI32eazNy/WIdfZp1Y2rm1g4dHLWFcxqkk1hiVqlRJjPCk3L2aVpKymrJmd1np2j/q aHkxYpnS+6O9jOPjU0mQcKR0IrTj7B54jqt16p4sEJHPAAjBWj3v0z+DMLxHJF6WwhKa OfvhZ5rKcgXp62M7cP5rXMRVZ8yxWFe1v4Ba+OjbByiLh6UuNiFMV0sBFvaqUD5CrTi5 b66A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706623527; x=1707228327; 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=8gb1u2H94rZEk9mGhCSonGNtRpGSlOkG3bOT+lHb6Bo=; b=g3y6SZdWGTXeVyvrX0fV37Y/rTRVk9kRkff67YDGK5nL3FOCwSGsuM/qDcUlPJDv1n VHyfBgwFD/LKK1DgRSiZ8omB26YwKrBIbUvSCTSpTHm5QlqbYAlbpEoa7sVS01QYYMys tJzS1If6pxi4al5zmLrcwMDNFkCRGmZ3DPyDtkjQKY1HpfEYpw7VrMujXqwGmK11FdBh ZmGo9tfkRFgN0OxLkLYEFcPun6Il6WXcjzPtwvI1jDfiVsGpzOPHrXeqNyCoRw1aeuN5 x5K0N+vbq69g84dQz7VD9cIEJC0v7/w9UgmDuDtu0rXPrpjNNOPpLQ3F6TI4PlFW/2tv Zk2A== X-Gm-Message-State: AOJu0YyU3elQoCQajWtUWxaz4CrDE2SlaHpXjWea/Hpt/vV+DHuWJnfp JSFgx3DTXQE0B6XbCnvGGPrPqiX3wmbxhwM26Fjb9Ez1YBoGnKtcyL89RgQX6As= X-Received: by 2002:a05:600c:1e06:b0:40e:f693:94f8 with SMTP id ay6-20020a05600c1e0600b0040ef69394f8mr4892243wmb.40.1706623527040; Tue, 30 Jan 2024 06:05:27 -0800 (PST) Received: from lion.localdomain (host-92-17-96-232.as13285.net. [92.17.96.232]) by smtp.gmail.com with ESMTPSA id g11-20020a05600c310b00b0040f035bebfcsm1799017wmo.12.2024.01.30.06.05.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 06:05:26 -0800 (PST) From: Caleb Connolly Date: Tue, 30 Jan 2024 14:05:06 +0000 Subject: [PATCH v3 18/36] mach-snapdragon: dynamic load addresses MIME-Version: 1.0 Message-Id: <20240130-b4-qcom-common-target-v3-18-e523cbf9e556@linaro.org> References: <20240130-b4-qcom-common-target-v3-0-e523cbf9e556@linaro.org> In-Reply-To: <20240130-b4-qcom-common-target-v3-0-e523cbf9e556@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=2901; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=przxI8/7PZyFkZZFSLCCMOGz4UtgeSxzk00jFnxUd5c=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtSdTIKy3zMd3nI6zW8N/tCw6ZCr7ZLE0hS3B6LfG70Zb mkrSC7oKGVhEORgkBVTZBE/scyyae1le43tCy7AzGFlAhnCwMUpABNJcmBkmHOr0pCljSnQJzb2 0frANzWvgtLaT2l06065en7/wtm7YhkZ9varfn55xGj2Tt1HTkKNR48uCXjC6HEk9dFpjcWLi8X sFwMA 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 | 34 ++++++++++++++++++++++++ board/qualcomm/dragonboard410c/dragonboard410c.c | 2 +- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 03ea75cefc0d..c7a07c648fc0 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1085,6 +1085,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 3018cc462b8f..3f51c4ab42d6 100644 --- a/arch/arm/mach-snapdragon/board.c +++ b/arch/arm/mach-snapdragon/board.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -160,6 +161,39 @@ int board_init(void) return 0; } +void __weak qcom_late_init(void) +{ +} + +#define KERNEL_COMP_SIZE SZ_64M + +#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_128M)); + 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 0136cc2237de..fbbfc0e65e24 100644 --- a/board/qualcomm/dragonboard410c/dragonboard410c.c +++ b/board/qualcomm/dragonboard410c/dragonboard410c.c @@ -88,7 +88,7 @@ int misc_init_r(void) return 0; } -int board_late_init(void) +int qcom_late_init(void) { char serial[16];