-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dts: bindings: Add lots more documentation
Add some information that would've saved me a lot of time: - Give an overview of how device tree nodes and bindings fit together, with examples. Assume people might be coming at it without knowing anything about device tree. - Explain how 'inherits' works in more detail - Explain what 'parent/child: bus: ...' does more concretely, and what problem it solves - Add more examples to show what things look like in the .dts file - Clean up the language a bit and make things more consistent Also fix some errors, like 'properties: compatible: ...' being wrong (missing 'constraint:' and compatible strings in the wrong place). Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
- Loading branch information
Showing
2 changed files
with
126 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,104 @@ | ||
title: <short description of the node> | ||
title: Short description of the node | ||
|
||
description: > | ||
Longer free-form description of the node, with spanning | ||
lines | ||
Longer free-form description of the node. | ||
Can go over multiple lines. | ||
|
||
# Bindings are often based on other bindings, which are given in 'inherits'. | ||
# The resulting binding is the union of the inherited bindings and this binding | ||
# (internally, it's a recursive dictionary merge). | ||
# | ||
# If a field appears both in this binding and in a binding it inherits, then | ||
# the value in this binding takes precedence. This can be used to change a | ||
# 'category: optional' from an inherited binding to a 'category: required' (see | ||
# the 'properties' description below). | ||
inherits: | ||
- !include other.yaml # or [other1.yaml, other2.yaml] | ||
# Files with other bindings that also apply to the node. If an attribute is set | ||
# both in an included file and in the file that includes it, then the value | ||
# from the including file (the file with the !include) is used. | ||
!include other.yaml # or [other1.yaml, other2.yaml] | ||
|
||
< parent | child >: | ||
# parent/child is used to document implicit relation between nodes. | ||
# This information is required to generate parent related bits in child | ||
# attributes. | ||
# In case parent has 'bus', slave inherits some information from master. | ||
# parent and child should share same bus-type value. | ||
bus: <bus-type> | ||
# If the node describes a bus, then the bus type should be given, like below | ||
parent: | ||
bus: <string describing bus type, e.g. "i2c"> | ||
|
||
sub-node: | ||
# Used for cases in which a dts node has children, and the children dont | ||
# require/specify a 'compatible' property. The sub-node is effective the | ||
# binding for the child. | ||
# If the node appears on a bus, then the bus type should be given, like below. | ||
# | ||
# Here's an example for a pwm-leds binding in which the child nodes | ||
# would be required to have 'pwms' properties. | ||
# When looking for a binding for a node, the code checks if the binding for the | ||
# parent node contains 'parent: bus: <bus type>'. If it does, then only | ||
# bindings with a matching 'child: bus: <bus type>' are considered. This allows | ||
# the same type of device to have different bindings depending on what bus it | ||
# appears on. | ||
child: | ||
bus: <string describing bus type, e.g. "i2c"> | ||
|
||
# 'sub-node' is used to simplify cases where a node has children that can all | ||
# use the same binding. The contents of 'sub-node' becomes the binding for each | ||
# child node. | ||
# | ||
# The example below is for a binding for pwm-leds where the child nodes are | ||
# required to have a 'pwms' property. | ||
sub-node: | ||
properties: | ||
pwms: | ||
type: compound | ||
category: required | ||
|
||
properties: | ||
|
||
# 'properties' describes properties on the node, e.g. | ||
# | ||
# reg = <1 2>; | ||
# current-speed = <115200>; | ||
# label = "foo"; | ||
# | ||
# This is used to check that required properties appear, and to | ||
# control the format of output generated for them. Except for some | ||
# special-cased properties like 'reg', only properties listed here will | ||
# generate output. | ||
# | ||
# A typical property entry looks like this: | ||
# | ||
# <name of the property in the device tree - regexes are supported>: | ||
# <property name>: | ||
# category: <required | optional> | ||
# type: <string | int | boolean | array | uint8-array | string-array | compound> | ||
# description: <description of property> | ||
# description: <description of the property> | ||
# | ||
# Note that uint8-array is the name for what devicetree standard calls | ||
# bytestring: its value is hexadecimal text with whitespace ignored, | ||
# enclosed in square brackets. | ||
# 'uint8-array' is our name for what the device tree specification calls | ||
# 'bytestring'. Properties of type 'uint8-array' should be set like this: | ||
# | ||
# The 'type' attribute is currently ignored. | ||
|
||
# At a minimum, an entry for the 'compatible' property is required, for | ||
# matching nodes | ||
compatible: <list of string compatible matches> | ||
category: required | ||
type: string | ||
description: compatible of node | ||
# foo = [89 AB CD]; | ||
# | ||
# Each value is a byte in hex. | ||
properties: | ||
# An entry for 'compatible' must appear, as it's used to map nodes to | ||
# bindings | ||
compatible: | ||
constraint: "foo-company,bar-device" | ||
|
||
# 'reg' describes mmio registers | ||
reg: | ||
category: required | ||
type: array | ||
description: mmio register space | ||
# Describes a property like 'current-speed = <115200>;'. We pretend that | ||
# it's obligatory for the example node and set 'category: required'. | ||
current-speed: | ||
type: int | ||
category: required | ||
description: Initial baud rate for bar-device | ||
|
||
# 'interrupts' specifies the interrupts that the driver may use | ||
interrupts: | ||
category: required | ||
type: array | ||
description: required interrupts | ||
# Describes an optional property like 'keys = "foo", "bar";' | ||
keys: | ||
type: string-array | ||
category: optional | ||
description: Keys for bar-device | ||
|
||
# If the binding describes an interrupt controller, GPIO controller, pinmux | ||
# device, or any other device referenced via a phandle plus a specifier (some | ||
# additional data besides the phandle), then the cells in the specifier must be | ||
# listed in '#cells', like below. | ||
|
||
# | ||
# If the specifier is empty (e.g. '#clock-cells = <0>'), then '#cells' can | ||
# either be omitted (recommended) or set to an empty array. Note that an empty | ||
# array is specified as '"#cells": []' in YAML. | ||
# | ||
# For example, say that some node has 'foo-gpios = <&gpio1 1 2>'. The <1 2> | ||
# part of the property value is the specifier, with two cells. The node pointed | ||
# at by &gpio1 is expected to have '#gpio-cells = <2>', and its binding should | ||
# have two elements in '#cells', corresponding to the 1 and 2 values above. | ||
"#cells": | ||
- cell0 # name of first cell | ||
- cell1 # name of second cell | ||
- cell2 # name of third cell | ||
- and so on and so forth | ||
|
||
# If the specifier is empty (e.g. '#clock-cells = <0>'), then '#cells' can | ||
# either be omitted (recommended) or set to an empty array. Note that an empty | ||
# array is specified as '"#cells": []' in YAML. | ||
# | ||
# For example, say that some device tree node has 'foo-gpios = <&gpio1 1 2>'. | ||
# The <1 2> part of the property value is the specifier, with two cells in this | ||
# example. The node pointed at by &gpio1 is expected to have | ||
# '#gpio-cells = <2>', and its binding should have two elements in '#cells', | ||
# corresponding to the 1 and 2 values above. |