xref: /freebsd/share/man/man4/fdt.4 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
142c8cbe1SRafal Jaworowski.\"
242c8cbe1SRafal Jaworowski.\" Copyright (c) 2010 The FreeBSD Foundation
342c8cbe1SRafal Jaworowski.\"
442c8cbe1SRafal Jaworowski.\" This software was developed by Semihalf under sponsorship from
542c8cbe1SRafal Jaworowski.\" the FreeBSD Foundation.
642c8cbe1SRafal Jaworowski.\"
742c8cbe1SRafal Jaworowski.\" Redistribution and use in source and binary forms, with or without
842c8cbe1SRafal Jaworowski.\" modification, are permitted provided that the following conditions
942c8cbe1SRafal Jaworowski.\" are met:
1042c8cbe1SRafal Jaworowski.\" 1. Redistributions of source code must retain the above copyright
1142c8cbe1SRafal Jaworowski.\"    notice, this list of conditions and the following disclaimer.
1242c8cbe1SRafal Jaworowski.\" 2. Redistributions in binary form must reproduce the above copyright
1342c8cbe1SRafal Jaworowski.\"    notice, this list of conditions and the following disclaimer in the
1442c8cbe1SRafal Jaworowski.\"    documentation and/or other materials provided with the distribution.
1542c8cbe1SRafal Jaworowski.\"
1642c8cbe1SRafal Jaworowski.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1742c8cbe1SRafal Jaworowski.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1842c8cbe1SRafal Jaworowski.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1942c8cbe1SRafal Jaworowski.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2042c8cbe1SRafal Jaworowski.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2142c8cbe1SRafal Jaworowski.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2242c8cbe1SRafal Jaworowski.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2342c8cbe1SRafal Jaworowski.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2442c8cbe1SRafal Jaworowski.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2542c8cbe1SRafal Jaworowski.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2642c8cbe1SRafal Jaworowski.\" SUCH DAMAGE.
2742c8cbe1SRafal Jaworowski.\"
28*924f8189SKyle Evans.Dd March 28, 2019
2942c8cbe1SRafal Jaworowski.Dt FDT 4
3042c8cbe1SRafal Jaworowski.Os
3142c8cbe1SRafal Jaworowski.Sh NAME
3242c8cbe1SRafal Jaworowski.Nm fdt
3342c8cbe1SRafal Jaworowski.Nd Flattened Device Tree support
3442c8cbe1SRafal Jaworowski.Sh SYNOPSIS
3542c8cbe1SRafal Jaworowski.Cd "options FDT"
3642c8cbe1SRafal Jaworowski.Cd "makeoptions FDT_DTS_FILE=<board name>.dts"
3742c8cbe1SRafal Jaworowski.Cd "options FDT_DTB_STATIC"
3842c8cbe1SRafal Jaworowski.Sh DESCRIPTION
3942c8cbe1SRafal Jaworowski.Em Flattened Device Tree
4042c8cbe1SRafal Jaworowskiis a mechanism for describing computer hardware resources, which cannot be
4125972509SEdward Tomasz Napieralaprobed or self enumerated, in a uniform and portable way.
4225972509SEdward Tomasz NapieralaThe primary consumers of this technology are
4342c8cbe1SRafal Jaworowski.Em embedded systems,
4442c8cbe1SRafal Jaworowskiwhere a lot of designs are based on similar chips, but have different
4542c8cbe1SRafal Jaworowskiassignment of pins, memory layout, addresses bindings, interrupts routing and
4642c8cbe1SRafal Jaworowskiother resources.
4742c8cbe1SRafal Jaworowski.Pp
4842c8cbe1SRafal JaworowskiConfiguration data, which cannot be self discovered in run-time, has to be
4925972509SEdward Tomasz Napieralasupplied from external source.
5025972509SEdward Tomasz NapieralaThe concept of a flattened device tree is a
5142c8cbe1SRafal Jaworowskiplatform and architecture independent approach for resolving such problems.
5242c8cbe1SRafal JaworowskiThe idea is inherited from Open Firmware IEEE 1275 device-tree notion, and has
5325972509SEdward Tomasz Napieralabeen successfully adopted by the embedded industry.
5425972509SEdward Tomasz NapieralaThe scheme works in the following way:
5542c8cbe1SRafal Jaworowski.Bl -bullet
5642c8cbe1SRafal Jaworowski.It
5742c8cbe1SRafal JaworowskiHardware platform resources are
5842c8cbe1SRafal Jaworowski.Em manually
5942c8cbe1SRafal Jaworowskidescribed in a human readable text source format, where all non
6042c8cbe1SRafal Jaworowskiself-enumerating information is gathered.
6142c8cbe1SRafal Jaworowski.It
6242c8cbe1SRafal JaworowskiThis source description is converted
6342c8cbe1SRafal Jaworowski.Em (compiled)
6442c8cbe1SRafal Jaworowskiinto a binary object i.e. a flattened device tree
6542c8cbe1SRafal Jaworowski.Em blob
6642c8cbe1SRafal Jaworowskiwhich is passed to the kernel at boot time.
6742c8cbe1SRafal Jaworowski.It
6842c8cbe1SRafal JaworowskiThe kernel (driver) learns about hardware resources details and dependencies
6942c8cbe1SRafal Jaworowskifrom this [externally supplied] blob, which eliminates the need for embedding
7042c8cbe1SRafal Jaworowskiany information about the underlying platform hardware resources in the kernel.
7142c8cbe1SRafal Jaworowski.It
7242c8cbe1SRafal JaworowskiThe flattened device tree mechanism in principle does not depend on any
7325972509SEdward Tomasz Napieralaparticular first-stage bootloader or firmware features.
7425972509SEdward Tomasz NapieralaThe only overall
7542c8cbe1SRafal Jaworowskirequirement for the environment is to provide a complete device tree
7642c8cbe1SRafal Jaworowskidescription to the kernel.
7742c8cbe1SRafal Jaworowski.El
7842c8cbe1SRafal Jaworowski.Pp
7942c8cbe1SRafal JaworowskiThe
8042c8cbe1SRafal Jaworowski.Nm
8142c8cbe1SRafal Jaworowskilayer allows any platform code in the kernel to retrieve information about
8242c8cbe1SRafal Jaworowskihardware resources from a unified origin, which brings advantages to the
8342c8cbe1SRafal Jaworowskiembedded applications (eliminates hard-coded configuration approach, enforces
8442c8cbe1SRafal Jaworowskicode to be data driven and extensible) leading to easier porting and
8542c8cbe1SRafal Jaworowskimaintenance.
8642c8cbe1SRafal Jaworowski.Sh DEFINITIONS
8742c8cbe1SRafal Jaworowski.Bl -tag -width Ar
8842c8cbe1SRafal Jaworowski.It Va Device tree source (DTS)
8942c8cbe1SRafal JaworowskiThe device tree source is a text file which describes hardware resources of a
9042c8cbe1SRafal Jaworowskicomputer system in a human-readable form, with certain hierarchical structure
9125972509SEdward Tomasz Napierala(a tree).
9225972509SEdward Tomasz NapieralaThe default location for DTS files in the
9342c8cbe1SRafal Jaworowski.Fx
9442c8cbe1SRafal Jaworowskisource repository is
952e36db14SWarner Losh.Pa sys/dts
9642c8cbe1SRafal Jaworowskidirectory.
9742c8cbe1SRafal Jaworowski.It Va Device tree blob (DTB)
9842c8cbe1SRafal JaworowskiThe textual device tree description (DTS file) is first converted (compiled)
9942c8cbe1SRafal Jaworowskiinto a binary object (the device tree blob) i.e. the DTB, which is handed over
10042c8cbe1SRafal Jaworowskito the final consumer (typically kernel) for parsing and processing of its
10142c8cbe1SRafal Jaworowskicontents.
10242c8cbe1SRafal Jaworowski.It Va Device tree compiler (DTC)
10342c8cbe1SRafal JaworowskiA utility program executed on the host, which transforms (compiles) a textual
10442c8cbe1SRafal Jaworowskidescription of a device tree (DTS) into a binary object (DTB).
10542c8cbe1SRafal Jaworowski.It Va Device tree bindings
10642c8cbe1SRafal JaworowskiWhile the device tree textual description and the binary object are media to
10742c8cbe1SRafal Jaworowskiconvey the hardware configuration information, an actual meaning and
10842c8cbe1SRafal Jaworowskiinterpretation of the contents are defined by the device tree
10942c8cbe1SRafal Jaworowski.Pa bindings .
11042c8cbe1SRafal JaworowskiThey are certain conventions describing definitions (encoding) of particular
11142c8cbe1SRafal Jaworowskinodes in a device tree and their properties, allowed values, ranges and so on.
11242c8cbe1SRafal JaworowskiSuch reference conventions were provided by the legacy Open Firmware bindings,
11342c8cbe1SRafal Jaworowskifurther supplemented by the ePAPR specification.
11442c8cbe1SRafal Jaworowski.El
11542c8cbe1SRafal Jaworowski.Sh "BUILDING THE WORLD"
11642c8cbe1SRafal JaworowskiIn order for the system to support
11742c8cbe1SRafal Jaworowski.Nm
11842c8cbe1SRafal Jaworowskiit is required that
11942c8cbe1SRafal Jaworowski.Fx
12042c8cbe1SRafal Jaworowskiworld be built with the
12142c8cbe1SRafal Jaworowski.Pa WITH_FDT
12242c8cbe1SRafal Jaworowskibuild knob supplied either via
12342c8cbe1SRafal Jaworowski.Xr src.conf 5
12442c8cbe1SRafal Jaworowskior command line defined with -D.
12542c8cbe1SRafal Jaworowski.Pp
12642c8cbe1SRafal JaworowskiThis creates the user space
12742c8cbe1SRafal Jaworowski.Pa dtc
12842c8cbe1SRafal Jaworowskicompiler and enables
12942c8cbe1SRafal Jaworowski.Nm
13042c8cbe1SRafal Jaworowskisupport in
13142c8cbe1SRafal Jaworowski.Xr loader 8 .
13242c8cbe1SRafal Jaworowski.Sh "BUILDING KERNEL"
13342c8cbe1SRafal JaworowskiThere is a couple of options for managing
13442c8cbe1SRafal Jaworowski.Nm
13542c8cbe1SRafal Jaworowskisupport at the
13642c8cbe1SRafal Jaworowski.Fx
13742c8cbe1SRafal Jaworowskikernel level.
13842c8cbe1SRafal Jaworowski.Bl -tag -width Ar
139*924f8189SKyle Evans.It Va makeoptions DTS+=<board name>.dts
140*924f8189SKyle EvansSpecifies device tree source (DTS) files for a given kernel.
141*924f8189SKyle EvansThe indicated DTS files will be converted (compiled) into a binary form
142*924f8189SKyle Evansalong with building the kernel itself.
143*924f8189SKyle EvansAny DTS file names not written as an absolute path must be specified relative
144*924f8189SKyle Evansto the default location of DTS sources i.e.,
145*924f8189SKyle Evans.Pa sys/dts .
146*924f8189SKyle Evans.It Va makeoptions DTSO+=<overlay name>.dtso
147*924f8189SKyle EvansSpecifies device tree source overlay (DTSO) files for a given kernel.
148*924f8189SKyle EvansOverlay files will be built with the kernel as with the makeoption
149*924f8189SKyle Evans.Va DTS
150*924f8189SKyle Evansdescribed above.
151*924f8189SKyle EvansOverlay files specified as relative paths will be relative to the default
152*924f8189SKyle Evanslocation of DTS overlays for the platform being built i.e.,
153*924f8189SKyle Evans.Pa sys/dts/arm/overlays .
15442c8cbe1SRafal Jaworowski.It Va options FDT
15542c8cbe1SRafal JaworowskiThe primary option for enabling
15642c8cbe1SRafal Jaworowski.Nm
15725972509SEdward Tomasz Napieralasupport in the kernel.
15825972509SEdward Tomasz NapieralaIt covers all low-level and infrastructure parts of
15942c8cbe1SRafal Jaworowski.Nm
16042c8cbe1SRafal Jaworowskikernel support, which primarily are the
16150d922a0SGlen Barber.Xr fdtbus 4
16250d922a0SGlen Barberand
16350d922a0SGlen Barber.Xr simplebus 4
16450d922a0SGlen Barberdrivers, as well as helper routines and libraries.
16542c8cbe1SRafal Jaworowski.It Va makeoptions FDT_DTS_FILE=<board name>.dts
16642c8cbe1SRafal JaworowskiSpecifies a preferred (default) device tree source (DTS) file for a given
16725972509SEdward Tomasz Napieralakernel.
168*924f8189SKyle EvansIt will be built along with the kernel as if it were supplied via the makeoption
169*924f8189SKyle Evans.Va DTS
170*924f8189SKyle Evansdescribed above.
17142c8cbe1SRafal JaworowskiThis makeoption is not mandatory unless FDT_DTB_STATIC is also defined (see
17242c8cbe1SRafal Jaworowskibelow).
17342c8cbe1SRafal Jaworowski.It Va options FDT_DTB_STATIC
17442c8cbe1SRafal JaworowskiTypically, the device tree blob (DTB) is a stand-alone file, physically
17542c8cbe1SRafal Jaworowskiseparate from the kernel, but this option lets statically embed a
17625972509SEdward Tomasz NapieralaDTB file into a kernel image.
17725972509SEdward Tomasz NapieralaNote that when this is specified the
17842c8cbe1SRafal JaworowskiFDT_DTS_FILE makeoption becomes mandatory (as there needs to be a DTS file
17942c8cbe1SRafal Jaworowskispecified in order to embed it into the kernel image).
18042c8cbe1SRafal Jaworowski.El
18142c8cbe1SRafal Jaworowski.Sh SEE ALSO
18242c8cbe1SRafal Jaworowski.Xr fdtbus 4 ,
18342c8cbe1SRafal Jaworowski.Xr openfirm 4 ,
18450d922a0SGlen Barber.Xr simplebus 4
18542c8cbe1SRafal Jaworowski.Sh STANDARDS
18642c8cbe1SRafal JaworowskiIEEE Std 1275: IEEE Standard for Boot (Initialization Configuration) Firmware:
18742c8cbe1SRafal JaworowskiCore Requirements and Practices
18842c8cbe1SRafal Jaworowski.Pq Vt Open Firmware .
18942c8cbe1SRafal Jaworowski.Pp
19042c8cbe1SRafal JaworowskiPower.org Standard for Embedded Power Architecture Platform Requirements
19142c8cbe1SRafal Jaworowski.Pq Vt ePAPR .
19242c8cbe1SRafal Jaworowski.Sh HISTORY
19342c8cbe1SRafal JaworowskiThe
19442c8cbe1SRafal Jaworowski.Nm
19542c8cbe1SRafal Jaworowskisupport first appeared in
19642c8cbe1SRafal Jaworowski.Fx 9.0 .
19742c8cbe1SRafal Jaworowski.Sh AUTHORS
19842c8cbe1SRafal JaworowskiThe
19942c8cbe1SRafal Jaworowski.Nm
20042c8cbe1SRafal Jaworowskisupport was developed by Semihalf under sponsorship from the FreeBSD
20125972509SEdward Tomasz NapieralaFoundation.
20225972509SEdward Tomasz NapieralaThis manual page was written by
20342c8cbe1SRafal Jaworowski.An Rafal Jaworowski .
204