From patchwork Tue Dec 7 00:11:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1564412 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=ZYPtme9a; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J7LNW6gqRz9sXS for ; Tue, 7 Dec 2021 11:12:57 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C6D7282A78; Tue, 7 Dec 2021 01:12:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ZYPtme9a"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0A8C58169D; Tue, 7 Dec 2021 01:12:40 +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.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) (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 901788307B for ; Tue, 7 Dec 2021 01:12:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-ot1-x333.google.com with SMTP id 35-20020a9d08a6000000b00579cd5e605eso15924935otf.0 for ; Mon, 06 Dec 2021 16:12:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KW5yjikdkgXd1cOVh/ZjvHs9za7ggQcI0HnuVjj4Ycs=; b=ZYPtme9aIUti6TbVvi6igt8rQy7CDde+idI0AjlkDuW9Wp+9YnHaNAxMiiHdCJY947 IqX0lXn3r/lHyfTEZa+lAmLBYE16Utpd8gIeYgz4/W0DpgP8BhGq1toAm+PZk3zZHe7z sEeNFJgDDWDsKEgRAsw9TY9k5OEO/kFJSjREw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KW5yjikdkgXd1cOVh/ZjvHs9za7ggQcI0HnuVjj4Ycs=; b=cp1Z1VxdKKkoDTvua59wunQBUq+dtriPiGA/wAsneRi214eNFWjR3k7cqV7RS6S5Za VEsODg1zSSfcrD6OXe905mxPmT8n4zZdmXf1Vlp69PcjNsztswp7f5cKaTxXWVMguDhf NgtfB/ntpqd75ypzZgySnmFQsTtoQBD5ifTSp7LydGIq3mi9ydBl8BtwBdwp8FR+8civ eZVzFUJvOu6gj/kcfPV2XFTIZzGFEzvRzThIVObtKGi86kFHRUOmB+yvVWDc8PDTJgBP D1+FCXYOWdZkn9NvwTsfdwLSNGUbyxiP4S+LzM5xtUK7/BMcfWhO2Vs78ZjXSOFcCYfH EJhQ== X-Gm-Message-State: AOAM531k9wcl9pXQUrvvTo8qrmkZRQLwKnlSPfmwjRJKKp4xihjwXIAv hd/qpw4aoq8GyIYJqR9RVaM9MBads+Y43w== X-Google-Smtp-Source: ABdhPJyi6K2M26kMi4pK1l1NVZINVsZ0QucTQ6myjt8lOTkHMD7lLoPmJxQKgWQOMGCvKY/XwBtEvg== X-Received: by 2002:a05:6830:449e:: with SMTP id r30mr32811376otv.120.1638835951492; Mon, 06 Dec 2021 16:12:31 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id g7sm2466410oon.27.2021.12.06.16.12.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Dec 2021 16:12:30 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Sean Anderson , Heinrich Schuchardt , Mark Kettenis , Tom Rini , =?utf-8?q?Fran=C3=A7ois_Ozog?= , Ilias Apalodimas , Simon Glass , Aaron Williams , Albert Aribaud , Alexander Graf , Anastasiia Lukianenko , Andre Przywara , Bin Meng , Jerry Van Baren , Linus Walleij , Marek Vasut , Matthias Brugger , Michal Simek , Oleksandr Andrushchenko , Pavel Herrmann , Peter Maydell , Stephen Warren , Stephen Warren , Thomas Fitzsimmons , Tuomas Tynkkynen Subject: [PATCH v7 00/31] fdt: Make OF_BOARD a boolean option Date: Mon, 6 Dec 2021 17:11:38 -0700 Message-Id: <20211207001209.3467163-1-sjg@chromium.org> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean With Ilias' efforts we have dropped OF_PRIOR_STAGE and OF_HOSTFILE so there are only three ways to obtain a devicetree: - OF_SEPARATE - the normal way, where the devicetree is built and appended to U-Boot - OF_EMBED - for development purposes, the devicetree is embedded in the ELF file (also used for EFI) - OF_BOARD - the board figures it out on its own The last one is currently set up so that no devicetree is needed at all in the U-Boot tree. Most boards do provide one, but some don't. Some don't even provide instructions on how to boot on the board. The problems with this approach are documented in another patch in this series: "doc: Add documentation about devicetree usage" In practice, OF_BOARD is not really distinct from OF_SEPARATE. Any board can obtain its devicetree at runtime, even it is has a devicetree built in U-Boot. This is because U-Boot may be a second-stage bootloader and its caller may have a better idea about the hardware available in the machine. This is the case with a few QEMU boards, for example. So it makes no sense to have OF_BOARD as a 'choice'. It should be an option, available with either OF_SEPARATE or OF_EMBED. This would allow rpi3, for example, to run with the devicetree provided by the prior bootloader. This series makes this change, adding various missing devicetree files (and placeholders) to make the build work. It also adds a run-time message showing where the devicetree came from, as well as warnings if the board's expected flow is not being used. This comes from the 'standard passage' series, which depends on this series. It also provides a few qemu clean-ups discovered along the way. The qemu-riscv64_spl problem is fixed. Please see [2] for discussion on the v6 series. I put Heinrich's Tested-by tag[3] for the series onto the three devicetree patches (ARM and RISC-V) that I think it most affects. It isn't possible to apply a tag to a whole series at present and in any case there are changes in v7. This series is available at u-boot-dm/ofb-working [1] https://patchwork.ozlabs.org/project/uboot/patch/20210919215111.3830278-3-sjg@chromium.org/ [2] https://lore.kernel.org/u-boot/20211205133207.GW1220664@bill-the-cat/T/#mcd8c0258827fbc1bb3000b7ff9ba0929df1ddcb2 [3] https://lore.kernel.org/u-boot/93913911-4d20-d28f-ee04-739985184c5e@canonical.com/raw Changes in v7: - Fix 'linst' typo - Switch to using an empty file for qemu virt - Switch to using an empty file for qemu virt - Switch to using an empty file for qemu virt - Reword commit message - Bring in files from Linux instead - Bring in files from Linux instead - Rewrite the commit message - Use 'empty' instead of 'fake' - Use 'empty' instead of 'fake' - Switch to using an empty file for qemu virt - Bring in files from Linux instead - Fix 'Is' typo in commit message - Drop FDTSRC_PASSAGE for now - Drop FDTSRC_PASSAGE for now - Add new patch to add a Kconfig for boards with a prior stage Changes in v6: - Fix description of OF_BOARD so it refers just to the current state - Explain that the 'two devicetrees' refers to two *control* devicetrees - Expand the commit message based on comments - Expand the commit message based on comments Changes in v5: - Bring into the OF_BOARD series - Rebase to master and drop mention of OF_PRIOR_STAGE, since removed - Refer to the 'control' DTB in the first paragraph - Use QEMU instead of qemu - Merge RISC-V and ARM patches since they are similar - Add new patches to clean up fdtdec_setup() and surrounds Changes in v3: - Clarify the 'bug' refered to at the top - Reword 'This means that there' paragraph to explain U-Boot-specific things - Move to doc/develop/devicetree now that OF_CONTROL is in the docs Changes in v2: - Fix typos per Sean (thank you!) and a few others - Add a 'Use of U-Boot /config node' section - Drop mention of dm-verity since that actually uses the kernel cmdline - Explain that OF_BOARD will still work after these changes (in 'Once this bug is fixed...' paragraph) - Expand a bit on the reason why the 'Current situation' is bad - Clarify in a second place that Linux and U-Boot use the same devicetree in 'To be clear, while U-Boot...' - Expand on why we should have rules for other projects in 'Devicetree in another project' - Add a comment as to why devicetree in U-Boot is not 'bad design' - Reword 'in-tree U-Boot devicetree' to 'devicetree source in U-Boot' - Rewrite 'Devicetree generated on-the-fly in another project' to cover points raised on v1 - Add 'Why does U-Boot have its nodes and properties?' - Add 'Why not have two devicetrees?' Simon Glass (31): doc: Add documentation about devicetree usage arm: qemu: Mention -nographic in the docs arm: riscv: qemu: Explain how to extract the generated dt arm: qemu: Add a devicetree file for qemu_arm arm: qemu: Add a devicetree file for qemu_arm64 virt riscv: qemu: Split devicetree files for qemu_riscv32/64 arm: rpi: Sync rpi dts files from Linux arm: vexpress: Add a devicetree files for juno arm: xenguest_arm64: Add a empty devicetree file arm: octeontx: Add an empty devicetree file arm: xilinx_versal_virt: Add a devicetree file arm: bcm7xxx: Add a devicetree file arm: qemu-ppce500: Add a devicetree file arm: highbank: Add devicetree files fdt: Make OF_BOARD a bool option Drop CONFIG_BINMAN_STANDALONE_FDT doc: Update info on devicetree update fdt: Move MULTI_DTB_FIT handling out of fdtdec_setup() fdt: Drop #ifdefs with MULTI_DTB_FIT fdt: Drop CONFIG_SPL_BUILD check in fdtdec_setup() fdt: Drop #ifdef around board_fdt_blob_setup() fdt: Use if() for fdtcontroladdr check fdt: Drop OF_CONTROL check in fdtdec_setup() fdt: Drop remaining preprocessor macros in fdtdec_setup() fdt: Don't call board_fdt_blob_setup() without OF_BOARD dm: core: Allow getting some basic stats fdt: Record where the devicetree came from fdt: Report the devicetree source fdt: Add a Kconfig for boards with a prior stage fdt: Avoid emitting an device tree when not needed fdt: Show build/runtime warnings based on devicetree source Makefile | 12 +- arch/arm/Kconfig | 8 + arch/arm/dts/Makefile | 20 +- arch/arm/dts/bcm2711-rpi-4-b.dts | 262 ++++ arch/arm/dts/bcm2711-rpi.dtsi | 74 ++ arch/arm/dts/bcm2711.dtsi | 1100 +++++++++++++++++ arch/arm/dts/bcm2835-common.dtsi | 207 ++++ arch/arm/dts/bcm2835-rpi-a-plus.dts | 18 +- arch/arm/dts/bcm2835-rpi-a.dts | 16 +- arch/arm/dts/bcm2835-rpi-b-plus.dts | 18 +- arch/arm/dts/bcm2835-rpi-b-rev2.dts | 16 +- arch/arm/dts/bcm2835-rpi-b.dts | 16 +- arch/arm/dts/bcm2835-rpi-cm1-io1.dts | 9 + arch/arm/dts/bcm2835-rpi-cm1.dtsi | 7 +- arch/arm/dts/bcm2835-rpi-common.dtsi | 12 + arch/arm/dts/bcm2835-rpi-zero-w.dts | 20 +- arch/arm/dts/bcm2835-rpi-zero.dts | 16 +- arch/arm/dts/bcm2835-rpi.dtsi | 35 +- arch/arm/dts/bcm2835.dtsi | 2 + arch/arm/dts/bcm2836-rpi-2-b.dts | 14 +- arch/arm/dts/bcm2836.dtsi | 2 + arch/arm/dts/bcm2837-rpi-3-a-plus.dts | 9 +- arch/arm/dts/bcm2837-rpi-3-b-plus.dts | 9 +- arch/arm/dts/bcm2837-rpi-3-b.dts | 5 +- arch/arm/dts/bcm2837-rpi-cm3-io3.dts | 9 + arch/arm/dts/bcm2837-rpi-cm3.dtsi | 9 + arch/arm/dts/bcm2837.dtsi | 2 + arch/arm/dts/bcm283x-rpi-usb-peripheral.dtsi | 7 + arch/arm/dts/bcm283x.dtsi | 224 +--- arch/arm/dts/bcm7xxx.dts | 15 + arch/arm/dts/ecx-common.dtsi | 231 ++++ arch/arm/dts/highbank.dts | 158 +++ arch/arm/dts/juno-base.dtsi | 831 +++++++++++++ arch/arm/dts/juno-clocks.dtsi | 46 + arch/arm/dts/juno-cs-r1r2.dtsi | 85 ++ arch/arm/dts/juno-motherboard.dtsi | 303 +++++ arch/arm/dts/juno-r2.dts | 322 +++++ arch/arm/dts/octeontx.dts | 14 + arch/arm/dts/qemu-arm.dts | 11 + arch/arm/dts/qemu-arm64.dts | 11 + arch/arm/dts/xenguest-arm64.dts | 15 + arch/arm/dts/xilinx-versal-virt.dts | 11 + arch/arm/mach-bcm283x/Kconfig | 1 + arch/powerpc/dts/Makefile | 1 + arch/powerpc/dts/qemu-ppce500.dts | 10 + arch/riscv/dts/Makefile | 2 +- .../dts/{qemu-virt.dts => qemu-virt32.dts} | 3 + arch/riscv/dts/qemu-virt64.dts | 11 + board/emulation/qemu-riscv/Kconfig | 1 + cmd/bdinfo.c | 2 + common/board_r.c | 24 + configs/bcm7260_defconfig | 1 + configs/bcm7445_defconfig | 1 + configs/highbank_defconfig | 2 +- configs/octeontx2_95xx_defconfig | 1 + configs/octeontx2_96xx_defconfig | 1 + configs/octeontx_81xx_defconfig | 1 + configs/octeontx_83xx_defconfig | 1 + configs/qemu-ppce500_defconfig | 2 + configs/qemu-riscv32_defconfig | 1 + configs/qemu-riscv32_smode_defconfig | 1 + configs/qemu-riscv32_spl_defconfig | 4 +- configs/qemu-riscv64_defconfig | 1 + configs/qemu-riscv64_smode_defconfig | 1 + configs/qemu-riscv64_spl_defconfig | 3 +- configs/qemu_arm64_defconfig | 1 + configs/qemu_arm_defconfig | 1 + configs/rpi_4_32b_defconfig | 1 + configs/rpi_4_defconfig | 1 + configs/rpi_arm64_defconfig | 1 + configs/vexpress_aemv8a_juno_defconfig | 1 + configs/xenguest_arm64_defconfig | 2 +- configs/xilinx_versal_virt_defconfig | 1 + doc/board/emulation/qemu-arm.rst | 10 +- doc/board/emulation/qemu-riscv.rst | 3 + doc/develop/devicetree/dt_qemu.rst | 48 + doc/develop/devicetree/dt_update.rst | 495 ++++++++ doc/develop/devicetree/index.rst | 2 + drivers/core/device.c | 11 + drivers/core/root.c | 7 + drivers/core/uclass.c | 13 + dts/Kconfig | 65 +- include/asm-generic/global_data.h | 12 + include/dm/device.h | 11 +- include/dm/root.h | 8 + include/dm/uclass-internal.h | 7 + include/dt-bindings/clock/bcm2835.h | 2 + include/fdtdec.h | 53 +- lib/fdtdec.c | 141 ++- test/dm/core.c | 41 + tools/binman/binman.rst | 20 - 91 files changed, 4879 insertions(+), 366 deletions(-) create mode 100644 arch/arm/dts/bcm2711-rpi-4-b.dts create mode 100644 arch/arm/dts/bcm2711-rpi.dtsi create mode 100644 arch/arm/dts/bcm2711.dtsi create mode 100644 arch/arm/dts/bcm2835-common.dtsi create mode 100644 arch/arm/dts/bcm2835-rpi-common.dtsi create mode 100644 arch/arm/dts/bcm283x-rpi-usb-peripheral.dtsi create mode 100644 arch/arm/dts/bcm7xxx.dts create mode 100644 arch/arm/dts/ecx-common.dtsi create mode 100644 arch/arm/dts/highbank.dts create mode 100644 arch/arm/dts/juno-base.dtsi create mode 100644 arch/arm/dts/juno-clocks.dtsi create mode 100644 arch/arm/dts/juno-cs-r1r2.dtsi create mode 100644 arch/arm/dts/juno-motherboard.dtsi create mode 100644 arch/arm/dts/juno-r2.dts create mode 100644 arch/arm/dts/octeontx.dts create mode 100644 arch/arm/dts/qemu-arm.dts create mode 100644 arch/arm/dts/qemu-arm64.dts create mode 100644 arch/arm/dts/xenguest-arm64.dts create mode 100644 arch/arm/dts/xilinx-versal-virt.dts create mode 100644 arch/powerpc/dts/qemu-ppce500.dts rename arch/riscv/dts/{qemu-virt.dts => qemu-virt32.dts} (94%) create mode 100644 arch/riscv/dts/qemu-virt64.dts create mode 100644 doc/develop/devicetree/dt_qemu.rst create mode 100644 doc/develop/devicetree/dt_update.rst