From patchwork Mon Feb 26 17:26:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 775926 Delivered-To: patch@linaro.org Received: by 2002:ab3:621a:0:b0:258:3251:9e33 with SMTP id w26csp1494593lte; Mon, 26 Feb 2024 09:30:34 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVgblO/WUx/WAaz9zdMqxburiNaOcm4rfyr6sP3eOqAiBlIlzVmp1fAIggdeQUZFxbipDL9hoK+GRZPEz9hy/NY X-Google-Smtp-Source: AGHT+IFsikSNtJtax1SOGB8y1NHvFfc0Fjx/WFilwEARlogXpwbpuVdBxWFllVxcvTKyhdQ+ofLJ X-Received: by 2002:a2e:9ada:0:b0:2d2:37e6:501b with SMTP id p26-20020a2e9ada000000b002d237e6501bmr4165387ljj.43.1708968634757; Mon, 26 Feb 2024 09:30:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708968634; cv=none; d=google.com; s=arc-20160816; b=PEHf0nZAYjEG8rtjjlcHIPn1D08sw+xI8KZlBHVthwfbldHIm8Evi6e1PPz+Gdt5Tb tX5sl8rMK76zFB2khMZkglZX06GHB3i7eIucxjCJkB34D9Tc9JqufK8Pw/D2CrEmdGk1 hPBXRmPITe5MThWPAbA4N8hJJHe43/JmCAIf7GC6kq2Oj9Wdwk1/6rPmtFPTneykwXiF GVDKS64jkuf2DihHz2pFKnXTIl8BNT/d1NFYtM3J3IHtjt3CJ2Tiv349UyfW4A0NfDoz 7NExXiqmObJL9f349r95Jg6YUhiD09mpPOfxQWgTV+P7PQGXT48T86LqaB4s7M2jq8n8 KZow== 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=mqX9gKzmz6CkmphhXhiOjQ+DBhpxEkZuaVr/s5JSveI=; fh=uQWpBkrt0qZFYFCPlMUMueI/qDi8Xvj0xVwY2ZSXEHU=; b=pUnIy/e6QoOjalE6ildjCzFMz4Gk/F/TF1u0YpZUi54ycS8VFJJw4Eu00eUmyEJTl2 ovQYxJr0cfFG7WNoMYCeYlBE5Wgu90jp/qhSLdb86kSnDJ0icvcSi5Xl6OAo5D07E69W HEYAApYJg1BDUNxok7OvX7ISmhTVnjAaN4pZE+g78oU6iTqKj1lBUtdRSU0ein49ihUo W0BbdMwxpLtRcaW8tWnRYgDv1wDhjva4t3iQ0CguwN5/LgpQC8JtHOkPeahAvQDD6L95 6lhNuwcj53x9llUVMppLwRVOmkUZu6y7lvsU1FaCn0EforshVnNuRZwtR/RHwHQt1aKN CxqA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LoUDCb5e; 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 23-20020a05600c025700b00411d13b2064si2940884wmj.92.2024.02.26.09.30.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:30:34 -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=LoUDCb5e; 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 947CD88008; Mon, 26 Feb 2024 18:26:57 +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="LoUDCb5e"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 97F4788008; Mon, 26 Feb 2024 18:26:56 +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-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) (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 8480F87F6D for ; Mon, 26 Feb 2024 18:26:42 +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-x430.google.com with SMTP id ffacd0b85a97d-33d2b354c72so2449790f8f.1 for ; Mon, 26 Feb 2024 09:26:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708968402; x=1709573202; 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=mqX9gKzmz6CkmphhXhiOjQ+DBhpxEkZuaVr/s5JSveI=; b=LoUDCb5eZ35UAip8+kbgRNdV3OlK4szjq3xxcDE1mKzMAbTppbzml0aqx1avNl5wUB YMvyk6B882PEXc8m+rmnKf4g+klo6KfEKBeSzEZ/KBmmFHIWFqwiH3spXJ4MdMHaN+la ovY5gPBN447qE10GJDgWzk2ZZEal7YaUuol95C9mTN9yng0XXfsWjoXDUonpF2VpzlM8 LlkcCdnxELB71cE6e4Y6t45HummwLJLk9Ois/MuyvZAi2L/L4sA97H97Npb4+sjdt/ZW mUw1hSitUFv0mUX/koeWoCSXwPg75SnCTjcTb9vEWHGk57cFbyNTqFzIpggtB5vE9Qhe 6xiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708968402; x=1709573202; 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=mqX9gKzmz6CkmphhXhiOjQ+DBhpxEkZuaVr/s5JSveI=; b=r/uQ7Rf+khFYiZQLqqQgBEUfmG7R4EgFRrO4a7Te0driL53XQy8LaT6eRnsT1XlWHo P6rkvov/oXKKrPu/FEhqKi7rdoODI2MoLOJFz4aMM7I2lcoGd2k2U0GGHnD6QM/QS8y3 aTfzuj972Unojv4MhvSoMuPFCsdEcRSq3B/AASnCJwsx6pC3vZtSk7VRzzVw1ce4tBtK 16+6l/227WuMmIo8Re+g0Dmb/6kWWJlxG5ewaYrIwBUxOYWmxEyBo+70NzwijIYU1hB1 tfhl3Ni3YGe2jlCHPM/tNPXnFNmirUoFt9BoYnTzMoxxutnDzxjIwec1LmgBbBspGlCz YWyg== X-Forwarded-Encrypted: i=1; AJvYcCVjhgfewR9HmxbE6Q3zQfwUzOIH+4UNxaxRANecXEcv6H3bnc0w6sUJsBJ/rCZriiKvw9xTRA8f+lyhulUf/q5t3EGufg== X-Gm-Message-State: AOJu0YylItYGM6CfjdjNSwoW/QpPXaI8FiNXG/hiQAn1F0TqiA9u/Jq8 26vA9+rxoWCNPMHXixo+CC4baTRTpG8XxyzHD9xffD6EGDbq8+y0AZnZ+CpWcPo= X-Received: by 2002:adf:f08b:0:b0:33d:2012:a2a7 with SMTP id n11-20020adff08b000000b0033d2012a2a7mr4648510wro.64.1708968402100; Mon, 26 Feb 2024 09:26:42 -0800 (PST) Received: from lion.localdomain (host-92-17-96-232.as13285.net. [92.17.96.232]) by smtp.gmail.com with ESMTPSA id bt1-20020a056000080100b0033d9c7eb63csm9142256wrb.84.2024.02.26.09.26.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:26:41 -0800 (PST) From: Caleb Connolly Date: Mon, 26 Feb 2024 17:26:25 +0000 Subject: [PATCH v5 21/39] mach-snapdragon: dynamic load addresses MIME-Version: 1.0 Message-Id: <20240226-b4-qcom-common-target-v5-21-10c8e078befb@linaro.org> References: <20240226-b4-qcom-common-target-v5-0-10c8e078befb@linaro.org> In-Reply-To: <20240226-b4-qcom-common-target-v5-0-10c8e078befb@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=3211; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=f/T3E5TW/4ttTFWkAjM1QFvva3NY1zLyeF0dfoxuyJo=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtQ7J3f/Xz3dT1tV9JuInHKLrplHo9Hixsj61LWmIWtmG WR/fpndUcrCIMjBICumyCJ+Ypll09rL9hrbF1yAmcPKBDKEgYtTACYit4nhv4fsrrZgBZvKrOo/ n//0nZkyY6VjidPrf4G1DrtLJ9q2KjEyzGCbsfrxumdPhPbxylmr+fMcmO/f9jNi/nTLmdsiRLr c1wAA 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. Reviewed-by: Neil Armstrong Reviewed-by: Sumit Garg Tested-by: Sumit Garg #qcs404 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 0c78c1b8e6b4..c7c236bada7a 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1095,8 +1095,9 @@ config ARCH_SNAPDRAGON select OF_CONTROL 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 imply CMD_DM 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 @@ -21,8 +21,9 @@ #include #include #include #include +#include #include #include DECLARE_GLOBAL_DATA_PTR; @@ -158,8 +159,41 @@ int board_init(void) qcom_board_init(); 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 @@ -87,9 +87,9 @@ int misc_init_r(void) return 0; } -int board_late_init(void) +int qcom_late_init(void) { char serial[16]; memset(serial, 0, 16);