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 97D29C61DA4 for ; Sat, 18 Feb 2023 15:26:53 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5E6F3851E0; Sat, 18 Feb 2023 16:26: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=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="SC8o9nr+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4C8FE851EB; Sat, 18 Feb 2023 16:26:48 +0100 (CET) Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) (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 85AE485162 for ; Sat, 18 Feb 2023 16:26:45 +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-wr1-x435.google.com with SMTP id u2so481158wrs.0 for ; Sat, 18 Feb 2023 07:26:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=fr8A3xiW7Mc/IvHZlWJC0Tq4DUoAi3CZLKzjhfYCwhs=; b=SC8o9nr+gcASHEaIj15jieF2fKRU/sVqCaPgx1nvlAjctvmkZ+XpwXfvpYhCWJFOvF iAB5xFoV9tV9GfdciSd9kglPFZJMunhTQf/7JvFAcW2clA4OnmT+V19Xdf2AXQyHbV7f eDP0NQYn2aRnhJPG49JAbHJdkontz2r7k2adQnvAgSxQJm20PbI1emfBGQHobiuAUAOz P+8hlSPYyofMZ/AmX2VMTdH80cuLizQUsDf68d6np8BsyIxLg0edYzr+RggnP8QuS/U9 I/8/QKOFiKpPDwtQ6fHPbTNt6aYP9xeDvFghT4OFpX3EUL9aLREMcE/Dj6mKAq4pf4Pj 4uvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=fr8A3xiW7Mc/IvHZlWJC0Tq4DUoAi3CZLKzjhfYCwhs=; b=F09eEp7OBENfmqA50PxSSkt46P0V0C8WbLpMjlTo2OKm0OSJi4zlmrJJlRXyGI36FI 8KOUZH9fy0h/px4SZEuFIJIeuuhYW5pI2aAiU3XVtu1C7geC218Z1qVbCV9FA+yvQuwx JCZLwKvfMalBbEnZ2TtOTr1ohiHHf1+3SXMaLuva83u++5axcFB7fGqGDh9m8bOFlS/Q kHgSxaJJ/DFK6KRiAZHfMNe1ciCkEjZhRbpq8XjWtb4CEjkZG4YcmPDIOdAoeDROn2eY zuUVxcmJa8iFHt5aTcFFIwA4TU0DOSBBU+jnBswQ/MoJXtZc9H4cDphAAYJlcC48aJwz 4Qng== X-Gm-Message-State: AO0yUKUr0uDj0Z5oQtoo+HFyYPmeoG/CCB21s9BViHwxNjudki5ZTR1V mZZWhn84z9leJAMrVeprsbk= X-Google-Smtp-Source: AK7set8zPXQ1UzsQRG3DkkDql6PRtV1wUheu3AokksUMgXPhhF2XgQqkpU6KoWquztaqOafjNMmnLw== X-Received: by 2002:a5d:65ca:0:b0:2c5:54fd:2667 with SMTP id e10-20020a5d65ca000000b002c554fd2667mr1912763wrw.65.1676734004977; Sat, 18 Feb 2023 07:26:44 -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 s10-20020a5d6a8a000000b002c577e2fc87sm7177002wru.15.2023.02.18.07.26.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 18 Feb 2023 07:26:44 -0800 (PST) Message-ID: Date: Sat, 18 Feb 2023 16:26:43 +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 v4 01/11] include: fdtdec: decouple fdt_addr_t and phys_addr_t size To: dario.binacchi@amarulasolutions.com, michael@amarulasolutions.com, sjg@chromium.org Cc: philipp.tomsich@vrull.eu, kever.yang@rock-chips.com, 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 --- Changed V2: reword --- Note: Most drivers still assume that FDT and CPU capabilities are identical. In order to use these variables a cast is needed. --- 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 12355afd..af29ac0c 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