From patchwork Thu Feb 15 20:52:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 773020 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp1036190wre; Thu, 15 Feb 2024 12:57:30 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXp0QLqMrwWhl573aFzh7x8/7KE3CVtN9Q4qPd5N4ejMo4eTdp/b3q/T/YP7Ma5+0qMXKGwuqW3FY+Vp4Vxc0bF X-Google-Smtp-Source: AGHT+IFYNdqmScB6RukW6bYOEqeHA9W2VO4izDXqrPA7w9fp3MkX6lBwj4Xxs6yPG+aasdfEven/ X-Received: by 2002:ac2:511c:0:b0:511:4dac:f1ab with SMTP id q28-20020ac2511c000000b005114dacf1abmr2158198lfb.40.1708030650320; Thu, 15 Feb 2024 12:57:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708030650; cv=none; d=google.com; s=arc-20160816; b=io4OSfS+e4TfKpi25R+yJVGsUWRQuNFNwZ5A8tED6ZpjLnaY+VkbB3nk1cSR6C/3x/ lh5tkTfJj7ATceQZiIX76q+ckwxqZRoRIUx6RiyMtYviq23H4iVAYeejZOpCNaEa70Xc tIFLgAW5Ga+MkayPxCoGCZBP8+x1QIMduMcjX0LdjgWnfv2L6vBoZRBgVZsLA4OraWRj mVsYivRdbGmDw3Z3CQPmZq2VtRatKloF6DvoIpWEAbt/8Bq7wxv6PBiYzkHdhYnMB9hr xKhBOJhmUj024hr/KCXvYWHBeoP/VnR78XOXDmrDo6vAP7UhaX4Ab8JM/NmPDetZ4sZ9 wnsQ== 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=1PjmJHGrMmgNK96s1iE0Iwl3eykzqZhpYlgGqc4S8MA=; fh=tZb9GpcrNmcOIMZxnRsBLSMrUd8nm2lNxXn2UbGfjN8=; b=xch2DmotVnfQsOz0IWsu9eFBvao81g5WFPI2+s1g7K92Dq09HrefjPF9P5u9PVmtCq RYg/Hh2DCpTTAum78lk94z+HpmMX9SneFAZO213vcvGWYz+TL3/vYmSr/5eQkU3/skFW 2SIxRmkQsqzMdc2f0L+iVNfsAhtVPEMBxBXic7Z6VSSnXR6/38oOESJLUNR4Qs+sOytW pKk4dk6SYjG6raQeKpckZ9c+lokVl27ovrlSqN3I/hbdPfJARxnCCuuEV8nZ5RtDqLhf JfN4CpnBxyy3bc52J2/5YPLk2WgKLeXjDIq6mVAFzuJ+gRAvXP/fL8wkhMTH2rnXQSUy x5Gw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s6RtT8zX; 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=pass (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 q21-20020aa7d455000000b005638b6eeab6si1012649edr.75.2024.02.15.12.57.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 12:57:30 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=s6RtT8zX; 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=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 6F1D987F6A; Thu, 15 Feb 2024 21:53:41 +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="s6RtT8zX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E1D0B87F2B; Thu, 15 Feb 2024 21:53:32 +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, T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) (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 96E8E87EE6 for ; Thu, 15 Feb 2024 21:52:46 +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-wr1-x42d.google.com with SMTP id ffacd0b85a97d-33aea66a31cso723625f8f.1 for ; Thu, 15 Feb 2024 12:52:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708030366; x=1708635166; 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=1PjmJHGrMmgNK96s1iE0Iwl3eykzqZhpYlgGqc4S8MA=; b=s6RtT8zXeqSx+nYf3N8YlIg2oBjHqqFd2IiX2AJH2SWee5s6qOlpkzDT7MiHmbFXLY OE4w0OkoTorgAqcvjaAkFTd5zzwXaBcNOZxLqPYkb5SPIJYc5uujR7jiXk+6wknww2h5 wkXBlVgouhfIa3htGbp3F0s7hyQPJsmH+roRWnxyG0ecsdYSPA8mm1xVJhyFnsfEo5TR SjlVVAV0Zac/PqCDeJ4XA8x9riwDKNE6w3Va/7FXBfelWpUpnGy2kilsPJ9Dm2uDHtFr tci2pzlKHOU7krVcRkGm3mZVvbn219Nugigx7xiRAxvmlycMXbIMtZRwIXktnEk6hPl2 4Qew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708030366; x=1708635166; 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=1PjmJHGrMmgNK96s1iE0Iwl3eykzqZhpYlgGqc4S8MA=; b=m3z66MsxqIig56piZvlQVEH9XWRmOdSwViTrUYSl4rKZMUgOQsUn/ONb9mvolOFvGg fyMH6FnNPsa960LDG/W/q7RdEPLcJlJ79H0MXdlTBJDbrtY/mPe8Yq4+qvPazvTqmrXe E5SGKTsR1M+mqkZHneSAsN+LIOA9DN0i/LrA0MQ0nzC5SUDTU/ThMujIGuN38zxWC7m3 UR/uyujldlPzUH8n41rHDnlfp1pQJfdaRw4loNNRsF8yRftV+I27tR8Br1OPDiGJ3v25 T/fUjqrgk3Tp7UNFPHdLewCMZNBdB3trybNw7BIyYQXa3rncQzHCWtGoHNiHKTGtYvco 0fhw== X-Forwarded-Encrypted: i=1; AJvYcCUkbvmL+FHM8SQAgOfs7KX2BxVsEMYozKDDCmOwk+vsvTCGv/Yj5wUdUK7AUX4Uuh9vbMlGJfsd4JF5Lo+dRhzCLmEtRQ== X-Gm-Message-State: AOJu0Yz9ciJDjsWrKZo/0vSaiFNPDQgNDjTWTnpFGAEWtPDf4Pq5eD2g R5+IFGx7k1+xLSB/MVqRRtjswdxLNQJPjX9sD/CLDuB1JJrbzKShiUBT2dBKZuWGosoucO2Lvp1 V X-Received: by 2002:a5d:5348:0:b0:33b:74a3:dcfb with SMTP id t8-20020a5d5348000000b0033b74a3dcfbmr1888014wrv.1.1708030365826; Thu, 15 Feb 2024 12:52:45 -0800 (PST) Received: from lion.localdomain (host-92-17-96-232.as13285.net. [92.17.96.232]) by smtp.gmail.com with ESMTPSA id e4-20020adfe384000000b0033cfa00e497sm194025wrm.64.2024.02.15.12.52.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 12:52:45 -0800 (PST) From: Caleb Connolly Date: Thu, 15 Feb 2024 20:52:39 +0000 Subject: [PATCH v4 21/39] mach-snapdragon: dynamic load addresses MIME-Version: 1.0 Message-Id: <20240215-b4-qcom-common-target-v4-21-ed06355c634a@linaro.org> References: <20240215-b4-qcom-common-target-v4-0-ed06355c634a@linaro.org> In-Reply-To: <20240215-b4-qcom-common-target-v4-0-ed06355c634a@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=WZF6iVYHmUW3FOBpBMLvxOHqM6h6OgAwaa5OH4FQNYc=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtRzlW1KF5x2MFWd3jq9Wdd9kqDPqvr1sdMWthxe5zA55 On3CSLRHaUsDIIcDLJiiiziJ5ZZNq29bK+xfcEFmDmsTCBDGLg4BWAi5h0Mf8X0XrdOWaJ+xNI7 MXOft/upDc+nt984EWzZL97jsDd3cgAjw67azhsTV/+t4fhzRUJ4tk/blcg1OiXCyaqxQqvcT7y YaQgA 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 Reviewed-by: Neil Armstrong Reviewed-by: Sumit Garg --- 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 672577d0ddcc..0dba77f86b49 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1095,6 +1095,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 a1867852bcca..f445bed3af00 100644 --- a/arch/arm/mach-snapdragon/board.c +++ b/arch/arm/mach-snapdragon/board.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -159,6 +160,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];