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 38852C64EC7 for ; Tue, 28 Feb 2023 21:22:57 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4D96685C3C; Tue, 28 Feb 2023 22:22:55 +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="Z0dxhQ4u"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AE25285C5A; Tue, 28 Feb 2023 22:22:53 +0100 (CET) Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) (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 E635085C30 for ; Tue, 28 Feb 2023 22:22:50 +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-x530.google.com with SMTP id d30so45791820eda.4 for ; Tue, 28 Feb 2023 13:22:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677619370; 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=Z0dxhQ4u3HTbMbgDbY9F8cUgVyvOZBFOZqY4SvUw29Ms2jdoZscQwe+9Vz0Li5IkI8 yPQNFWvHv469Bzp8rMXGDEE2bxplQCCX/YIRvzPHe+KoRU/AquAUnJF6IhGoBxkt2KEp AvBrm/sgfwFNj8EYxpwacTLPwKWM9Nv8PO1Of9La7c7buxfTqMbXDx/poel7VsR/zJdA Ku7yHgCRn6rgq/51MntbArJpCpfHb2ToUVxl7/bHxTZtnxlLbW0WdgYcXubG9VK6eMuy QLOnhLmBsKgrE26Gkh3p3JHMgHzu35RSMitqPraKD+14C+m8sJ60x6GyPtzhpOamx1cG uAQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677619370; 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=8BPBgfunBZgg1BZdffLACL7HqyY6MPafQWD/kmB+j4ITIOB2nDzaHO6sVVigqHvWRP PAH87RCGBAMVCbUNsQUU+94cJ2N1Gsz0uFeS+1UX9UUYWa6caRG3hkVfAU++1efto3cH fd3wAHvMl9ynjNqOThZKb+adsbGsCB97VSUEW7v9e3LacEi8iMdaczTQodtNtCQlBeFR CKB+c6QTUIGPL4VgbbEM6TYIPw/rraQY/y2yZUoCb6jnd0FyolpWCCpHDJ+XgcJweeqp eJgdkAxCSUhZDO+RaiUs9ehGKWkBxZWYD5jvH9LSv384Rq9DrnfUDofdAXr+/XpgubIW 1hgQ== X-Gm-Message-State: AO0yUKVKfUWTIOYskU36Fk/24ydLWcW3o+/5P1ul2bwf7wNnBxfl+vHK hUaRGxEBzBPWOteTx5UliGw= X-Google-Smtp-Source: AK7set96SgRbqUijnRLfBYY92pmR3ujvax3Op+BYFnjajpNPM9y0rNmWKWa/gNIU2mJHQpGz75A4Hw== X-Received: by 2002:a17:906:6dc7:b0:881:f614:44ed with SMTP id j7-20020a1709066dc700b00881f61444edmr4528348ejt.30.1677619370609; Tue, 28 Feb 2023 13:22:50 -0800 (PST) Received: from [192.168.2.1] (81-204-249-205.fixed.kpn.net. [81.204.249.205]) by smtp.gmail.com with ESMTPSA id d9-20020a170906174900b008d3abe8726bsm4886834eje.154.2023.02.28.13.22.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Feb 2023 13:22:50 -0800 (PST) Message-ID: Date: Tue, 28 Feb 2023 22:22:49 +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 v5 21/21] 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.6 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