Flattened Device Tree
This page is dedicated to the project bringing the flattened device tree (FDT) technology to the FreeBSD. For details contact RafalJaworowski. Work on this project is kindly sponsored by the FreeBSD Foundation.
Abstract
The objective of this project is to provide FreeBSD with the ability to use flattened device trees for description of hardware resources of a computer system and their dependencies, in a platform-neutral and portable way. The primary consumer of this functionality are embedded systems (based on ARM, AVR32, MIPS, PowerPC), but the mechanism can be used in all cases when hardware resources cannot be self-enumerated (as such could be seen as a future replacement for device.hints used in the legacy PC world).
Problem description
In embedded world there is great variety of systems based on same silicon chips, but designed into custom boards and devices, where connections of individual components are different and there are no conventions or rules, even across members of the same family of products. Furthermore, some buses and interconnects are not self-enumerable by definition (unlike PCI or USB), and there has to be some prior knowledge about how they are connected and what their unique identification is. Some of the examples of typical problems are the following:
- memory layout (address offsets/sizes specification)
- assignment of resources and identification on non-enumerable devices (I2C, SPI buses, internal on-chip resources)
- MAC-PHY binding
- interrupts routing
- GPIO/multi-purpose pin routing and assignment
The concept of flattened device trees is an established and mature way of handling such problems and has been successfully used for Linux/powerpc. It has also been adopted as a basis for Power.org's embedded platform reference specification (ePAPR).
The idea is inherited from Open Firmware IEEE 1275 device-tree notion (part of the regular Open Firmware implementation), but it allows to use device tree mechanism on all systems (not based on OF). It boils down to the following:
- hardware platform (board) resources are described in a human readable text source format, where all non self-enumerating info is gathered
- this source description is converted ('compiled') into a binary object (flattened device tree), which is passed to the kernel at boot time
- the kernel (driver) learns about hardware resources details and dependencies from this [externally supplied] blob, which eliminates the need for embedding any info about the underlying platform's hardware resources in the kernel
Work break down
Description |
Status |
Comments |
dtc: build on FreeBSD host, integrate with build system, test compile example device tree sources, verify |
Mostly complete, pending cleanups. |
Minor adjustments were required for the dtc to build with yacc (default in FreeBSD base installation) instead of bison. All 1248 cases from the testsuite attached to the dtc package pass. |
libfdt: integrate with build system |
Complete. |
|
loader(8) extensions: device tree blob handling, commands to run-time modify the device tree properties, nodes etc. |
Read-only support ready. |
|
Handling of embedded device tree blob (statically included in the kernel image, for configurations when loader(8) cannot be run) |
|
|
Implementation of the ofw_bus I/F for the FDT back-end: integrate libfdt library in the kernel, potentially extend the ofw_bus framework |
Initial version of the FDT ofw_bus I/F implementation complete. All required OF_* routines work; user space interface (/dev/openfirm) works; device tree inspection with ofwdump(8) is now possible. |
|
Integration of the FDT support layer with newbus infrastructure |
|
|
Device tree handling in machdep |
|
|
Provide device tree sources for selected platforms: compile into blob, test basic parsing, debug |
|
|
Convert drivers attachment code to use OF-like interface (MPC85xx PowerPC, Marvell ARM) |
|
|
Documentation: device bindings, conventions, example sources; wiki, man |
|
|
Howto, documentation
Device tree and the FreeBSD loader(8)
Repository
The official project branch in P4.
References
A Symphony of Flavours: Using the device tree to describe embedded hardware.