[PATCH v8 00/32] fdt: Make OF_BOARD a boolean option

Simon Glass sjg at chromium.org
Fri Dec 17 04:59:07 CET 2021


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 were covered in another patch[1], since
removed from this series.

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.

To make the 'prior stage' side of things more deterministic, a new
OF_HAS_PRIOR_STAGE is added, which cannot be disabled by updated a board's
defconfig. This should help to prevent mistakes.

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 originally 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/20211207001209.3467163-2-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 v8:
- Add a new patch to make it easier to debug u-boot.dtsi files
- Add an fdt: tag
- Add new patch to ensure that OF_BOARD is used when needed
- Drop documentation patches
- Drop the build-time warning, since people may ignore it
- Drop the devicetree docs in the README
- Enable the flash as suggested by Linus Walleij
- Fix devicetree logic so that just u-boot.dtb is omitted
- Mention that this is empty, rather than a dummy file
- Mention the follower patch
- Move board-config changes to a separate patch
- Rebase patch
- Reword commit message to mention the dynamic devicetree
- Use an empty tree due to maintainer objections

Changes in v7:
- Add new patch to add a Kconfig for boards with a prior stage
- Bring in files from Linux instead
- Drop FDTSRC_PASSAGE for now
- Fix 'Is' typo in commit message
- Reword commit message
- Rewrite the commit message
- Switch to using an empty file for qemu virt
- Use 'empty' instead of 'fake'

Changes in v6:
- Expand the commit message based on comments

Changes in v5:
- Add new patches to clean up fdtdec_setup() and surrounds
- Merge RISC-V and ARM patches since they are similar

Simon Glass (32):
  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
  fdt: Drop CONFIG_BINMAN_STANDALONE_FDT
  fdt: Make it easier to debug u-boot.dtsi files
  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: Enable OF_HAS_PRIOR_STAGE for most boards with OF_BOARD
  fdt: Makefile: Ensure that OF_BOARD is used when needed
  fdt: Avoid emitting an device tree when not needed
  fdt: Show a runtime warning based on devicetree source

 Makefile                                      |   16 +-
 README                                        |   29 -
 arch/arm/Kconfig                              |   12 +-
 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/highbank.dts                     |    9 +
 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-u-boot.dtsi              |   20 +
 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/cpu/mpc85xx/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/ae350_rv32_defconfig                  |    1 -
 configs/ae350_rv32_spl_defconfig              |    1 -
 configs/ae350_rv32_spl_xip_defconfig          |    1 -
 configs/ae350_rv64_defconfig                  |    1 -
 configs/ae350_rv64_spl_defconfig              |    1 -
 configs/ae350_rv64_spl_xip_defconfig          |    1 -
 configs/bcm7260_defconfig                     |    2 +-
 configs/bcm7445_defconfig                     |    2 +-
 configs/highbank_defconfig                    |    2 +-
 configs/octeontx2_95xx_defconfig              |    2 +-
 configs/octeontx2_96xx_defconfig              |    2 +-
 configs/octeontx_81xx_defconfig               |    2 +-
 configs/octeontx_83xx_defconfig               |    2 +-
 configs/qemu-ppce500_defconfig                |    3 +-
 configs/qemu-riscv32_defconfig                |    2 +-
 configs/qemu-riscv32_smode_defconfig          |    2 +-
 configs/qemu-riscv32_spl_defconfig            |    5 +-
 configs/qemu-riscv64_defconfig                |    2 +-
 configs/qemu-riscv64_smode_defconfig          |    2 +-
 configs/qemu-riscv64_spl_defconfig            |    4 +-
 configs/qemu_arm64_defconfig                  |    2 +-
 configs/qemu_arm_defconfig                    |    2 +-
 configs/rpi_4_32b_defconfig                   |    2 +-
 configs/rpi_4_defconfig                       |    2 +-
 configs/rpi_arm64_defconfig                   |    2 +-
 configs/vexpress_aemv8a_juno_defconfig        |    2 +-
 configs/xenguest_arm64_defconfig              |    3 +-
 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/index.rst              |    1 +
 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 ++-
 scripts/Makefile.lib                          |    4 +-
 scripts/check-of.sh                           |   42 +
 scripts/of_whitelist.txt                      |    1 +
 test/dm/core.c                                |   41 +
 tools/binman/binman.rst                       |   34 +-
 101 files changed, 4082 insertions(+), 432 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/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-u-boot.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 100755 scripts/check-of.sh
 create mode 100644 scripts/of_whitelist.txt

-- 
2.34.1.173.g76aa8bc2d0-goog



More information about the U-Boot mailing list