[PATCH v7 00/31] fdt: Make OF_BOARD a boolean option

Simon Glass sjg at chromium.org
Tue Dec 7 01:11:38 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 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

-- 
2.34.1.400.ga245620fadb-goog



More information about the U-Boot mailing list