From mboxrd@z Thu Jan 1 00:00:00 1970 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 CD487C6FD19 for ; Mon, 13 Mar 2023 00:33:35 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6F8D586120; Mon, 13 Mar 2023 01:33:33 +0100 (CET) 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="OThXCz3J"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C17598611E; Mon, 13 Mar 2023 01:33:29 +0100 (CET) Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) (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 7C20186119 for ; Mon, 13 Mar 2023 01:33:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jbx6244@gmail.com Received: by mail-ed1-x536.google.com with SMTP id x3so42207471edb.10 for ; Sun, 12 Mar 2023 17:33:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678667605; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=b9WsX3hxOwnqoMjONwMNqXJLrB+Fs8y+UpCyN/2j7ew=; b=OThXCz3JITkiYXN3MDdujz3KjoIHf0i/fLai6St42EBDNZX4J9oCYE/b2fR+ABEv4F iGu51WvFx3VbF4M0LJaQ+kQfTm8/e0kTaNnG47AnX/G7eFT90tj3ZjpoytgR1YXAgBCU YsdHazreBEn2UnLt33xIdkZeuCDIxt/weefHLQBNlbgtQt2OjSQiLaCZn+cvCtc3L8cR ZjpY30SOHYfJtfrrj+8cSKR0gak7m3veOxgp83I9HU7hhwbUzwQR1jtlqa0PyhEgR8Ab T/NDZN9DFZnAGaG3aHRVl7hU+54m9k3QBUtcK+V9nQDo6SsmZCx88iM1ZQJZTb1pHUz1 kf8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678667605; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=b9WsX3hxOwnqoMjONwMNqXJLrB+Fs8y+UpCyN/2j7ew=; b=omUxXpdqXcxFBBiryGuuHqbrEOgtfh6KVs2gqE25Q5N5DDw54Ovm63qjcU/puyYF0K bPF8aSnnGXUGrJrm3zqi8uu7MhTa07QKvi3jlAFnrIG66yevWxvbAGt+yrej23pjxwQB l7+5Z4Tge/QvbpP5koEckuJhAzsp9cygSANbnIl6tpCbceRZc8YsCyoSGSkr+MsbGIdz JdBGhE3fqFy3hgkS4h7jNwXsEiIzJbkqvvnrArCi6TR2BuKzz99wydqz01zw1VFN4x8w Bye8B2q/UqVv8YeAl34Eh5vhRlwBBxLdh7O4G2roPu9csr+NWeMtwdBw3vJCqIlhw2b6 5oaw== X-Gm-Message-State: AO0yUKXJh/s5UEW+9cNwg6HoxY9zpcUdl9Ys53mLQwW4ltPnlQ4FodpG XXKP6Aa8ynjolWSDRatvakE= X-Google-Smtp-Source: AK7set+6H4v20dlmkG3qpKNChP9Zmi+AZEhf19nLeSsHEXJaV6K1xPOi10J9Q9rioe/fXYR0VYkLBg== X-Received: by 2002:a17:906:d54d:b0:91d:a049:17a9 with SMTP id cr13-20020a170906d54d00b0091da04917a9mr9495943ejc.36.1678667605185; Sun, 12 Mar 2023 17:33:25 -0700 (PDT) Received: from [192.168.2.2] (81-204-249-205.fixed.kpn.net. [81.204.249.205]) by smtp.gmail.com with ESMTPSA id i11-20020a170906090b00b008edc39530fbsm2722441ejd.219.2023.03.12.17.33.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 12 Mar 2023 17:33:24 -0700 (PDT) Message-ID: Date: Mon, 13 Mar 2023 01:33:23 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 From: Johan Jonker Subject: [PATCH v8 24/24] include: fdtdec: decouple fdt_addr_t and phys_addr_t size To: dario.binacchi@amarulasolutions.com, michael@amarulasolutions.com, sjg@chromium.org, philipp.tomsich@vrull.eu, kever.yang@rock-chips.com Cc: u-boot@lists.denx.de, yifeng.zhao@rock-chips.com References: Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 The DT specification supports CPUs with both 32-bit and 64-bit addressing capabilities. In U-boot the fdt_addr_t and phys_addr_t size are coupled by a typedef. The MTD NAND drivers for 32-bit CPU's can describe partitions with a 64-bit reg property. These partitions synced from Linux end up with the wrong offset and sizes when only the lower 32-bit is passed. Decouple the fdt_addr_t and phys_addr_t size as they don't necessary match. Signed-off-by: Johan Jonker Reviewed-by: Simon Glass Reviewed-by: Kever Yang --- Note: Due to the large number of references to fdt_addr_t this patch serie fixes only some bugs, but not all. Apply only when all remaining errors and warnings due to this patch are fixed. Help with testing/debug appreciated. --- Kconfig | 8 ++++++++ include/fdtdec.h | 13 +++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Kconfig b/Kconfig index a75cce7e..7697dade 100644 --- a/Kconfig +++ b/Kconfig @@ -422,11 +422,19 @@ endif # EXPERT config PHYS_64BIT bool "64bit physical address support" + select FDT_64BIT help Say Y here to support 64bit physical memory address. This can be used not only for 64bit SoCs, but also for large physical address extension on 32bit SoCs. +config FDT_64BIT + bool "64bit fdt address support" + help + Say Y here to support 64bit fdt addresses. + This can be used not only for 64bit SoCs, but also + for large address extensions on 32bit SoCs. + config HAS_ROM bool select BINMAN diff --git a/include/fdtdec.h b/include/fdtdec.h index aa61a0fc..6b768ed5 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -18,15 +18,18 @@ #include /* - * A typedef for a physical address. Note that fdt data is always big + * Support for 64bit fdt addresses. + * This can be used not only for 64bit SoCs, but also + * for large address extensions on 32bit SoCs. + * Note that fdt data is always big * endian even on a litle endian machine. */ -typedef phys_addr_t fdt_addr_t; -typedef phys_size_t fdt_size_t; #define FDT_SIZE_T_NONE (-1U) -#ifdef CONFIG_PHYS_64BIT +#ifdef CONFIG_FDT_64BIT +typedef u64 fdt_addr_t; +typedef u64 fdt_size_t; #define FDT_ADDR_T_NONE ((ulong)(-1)) #define fdt_addr_to_cpu(reg) be64_to_cpu(reg) @@ -35,6 +38,8 @@ typedef phys_size_t fdt_size_t; #define cpu_to_fdt_size(reg) cpu_to_be64(reg) typedef fdt64_t fdt_val_t; #else +typedef u32 fdt_addr_t; +typedef u32 fdt_size_t; #define FDT_ADDR_T_NONE (-1U) #define fdt_addr_to_cpu(reg) be32_to_cpu(reg) -- 2.20.1