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 59AF9C61DA4 for ; Thu, 16 Feb 2023 17:58:26 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4D44885B7D; Thu, 16 Feb 2023 18:58:24 +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="n2v15lHM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 63B2485B81; Thu, 16 Feb 2023 18:58:22 +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 B079085B78 for ; Thu, 16 Feb 2023 18:58:19 +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 n20so6125265edy.0 for ; Thu, 16 Feb 2023 09:58:19 -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=n2v15lHMpmjGsdkBTW9k79Cm7Fs9kRmzHPvqg1k83+CLDjlNmEPsAXOaNY/AMOyuEJ rMQpIBZsYbZA94Q4o49FnUsCG87/M+LRAO+fB9xUN/P+Od6MD5ZiULKAaDGzFJEKS76j qfFbH7HoPFJVsfOjDq7Wk+903e8asqIFkpCvXe4JYfgXCnyPIR6ygyaPt9rGfBf4BdSa agZz5jBcETWoAAFFrczPlM0li/NddC+RQ6gKZSjG2MhQaGVJKkZ3ol8m/6LsCUzZiNgA It6ivetGJyqn5y8smLy6pM+z6t0FYaVvYELXnwUWwHeQjsWIzDQIeMdDKiQoD4Ost1vW y18g== 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=jZdJZpkF7+mwGogRuLVP6goz6f9yV+id896aZbuit9VQJEud7fZqwJ59h4Fw1PNwpK VRGOqQ4lcYzDRxcwSfAY1A0bFeIAO+3FhFDGnHE0FhqSB5g6C3dsvaiEPsSy6xt9yPSf 8YnSK0Q0dpdLxNckltO2b+gL5bj0OPU6Bieq7CqccerfVcKcy2+Mj8YVQ1sNJ8Qoyj+m J15RvN+aM0oTl0LQRGKdhMe9ZDfpxpUEx9+2TZoyglINtWiuRiqvPxIhWS/M99CtrPpq uDd+MqRjdNHk3v38YLySJn9WVdSo9ayUAV8EPfyNm+Jox0AJt32S7PqwwbOTCsfREiHf lLEw== X-Gm-Message-State: AO0yUKVqdigUd/NhuD3MbQwJPE/EE3o9OzOHpFNW9LqUZvnA7tqTjVhV mbjwPYd1E523iu+BluO6nUhOZ1O+WgE= X-Google-Smtp-Source: AK7set/VUgK4fVqwNavw5LvxD4GveFC0AbGU9gKLZ5QICslar0lKRuQThBSMEhv4hS8raneTx2ooAg== X-Received: by 2002:a17:906:b294:b0:8af:3922:ace6 with SMTP id q20-20020a170906b29400b008af3922ace6mr6789574ejz.40.1676570299190; Thu, 16 Feb 2023 09:58:19 -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 ha13-20020a170906a88d00b008b12823f0f7sm1073326ejb.88.2023.02.16.09.58.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Feb 2023 09:58:18 -0800 (PST) Message-ID: Date: Thu, 16 Feb 2023 18:58:17 +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 v3 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: <111b67cc-1ec6-14b2-31d4-d2261b8b7a03@gmail.com> Content-Language: en-US In-Reply-To: <111b67cc-1ec6-14b2-31d4-d2261b8b7a03@gmail.com> 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