An Example Device
Schema identifier ($id): "http://devicetree.org/schemas/example-schema.yaml#"
Schema dialect ($schema): "http://devicetree.org/meta-schemas/core.yaml#"
Maintainers (maintainers): "Rob Herring <robh@kernel.org>"
A more detailed multi-line description of the binding.
Details about the hardware device and any links to datasheets can go here.
Literal blocks are marked with the '|' at the beginning. The end is marked by indentation less than the first line of the literal block. Lines also cannot begin with a tab character.
Automatic schema selection (select) #
false
Not selected automatically by this rule.
Properties and child nodes (properties) #
compatible — required here #
Exactly one of these rules must match (oneOf) #
Rule 1
Array item rules (
items)Item 1
Allowed values (
enum):"vendor,soc4-ip","vendor,soc3-ip","vendor,soc2-ip"Item 2
Exact value (
const):"vendor,soc1-ip"
Rule 2
Array item rules (
items)Item 1
Exact value (
const):"vendor,soc1-ip"
reg — required here #
Array item rules (items) #
Item 1
core registers
Item 2
aux registers
reg-names — not listed as required here #
Array item rules (items) #
Item 1
Exact value (
const):"core"
Item 2
Exact value (
const):"aux"
clocks — not listed as required here #
Maximum number of items (maxItems): 1
bus clock. A description is only needed for a single item if there's something unique to add. The items should have a fixed order, so pattern matching names are discouraged.
clock-names — not listed as required here #
Array item rules (items) #
Item 1
Exact value (
const):"bus"
interrupts — required here #
Minimum number of items (minItems): 1
Array item rules (items) #
Item 1
tx or combined interrupt
Item 2
rx interrupt
A variable number of interrupts warrants a description of what conditions affect the number of interrupts. Otherwise, descriptions on standard properties are not necessary. The items should have a fixed order, so pattern matching names are discouraged.
interrupt-names — not listed as required here #
Minimum number of items (minItems): 1
Array item rules (items) #
Item 1
Exact value (
const):"tx irq"
Item 2
Exact value (
const):"rx irq"
#interrupt-cells — not listed as required here #
Exact value (const): 2
interrupt-controller — required here #
true — No constraints added by this property rule.
clock-frequency — not listed as required here #
Minimum value (minimum): 100
Maximum value (maximum): 400000
Default value (default): 200
foo-gpios — not listed as required here #
Maximum number of items (maxItems): 1
A connection of the 'foo' gpio line.
foo-supply — not listed as required here #
true — No constraints added by this property rule.
vendor,int-property — not listed as required here #
Vendor-specific properties must have a description
Shared schema rule ($ref): /schemas/types.yaml#/definitions/uint32
Allowed values (enum): 2, 4, 6, 8, 10
vendor,bool-property — not listed as required here #
Vendor-specific properties must have a description. Boolean properties are one case where the json-schema 'type' keyword can be used directly.
Value type (type): "boolean"
vendor,string-array-property — not listed as required here #
Vendor-specific properties should reference a type in the core schema.
Shared schema rule ($ref): /schemas/types.yaml#/definitions/string-array
Array item rules (items) #
Item 1
Item 2
vendor,property-in-standard-units-microvolt — not listed as required here #
Vendor-specific properties having a standard unit suffix don't need a type.
Allowed values (enum): 100, 200, 300
vendor,int-array-variable-length-and-constrained-values — not listed as required here #
Array might define what type of elements might be used (e.g. their range).
Shared schema rule ($ref): /schemas/types.yaml#/definitions/uint32-array
Minimum number of items (minItems): 2
Maximum number of items (maxItems): 3
Array item rules (items) #
Minimum value (
minimum):0Maximum value (
maximum):8
child-node — not listed as required here #
Child nodes are just another property from a json-schema perspective.
Value type (type): "object"
Properties not matched by properties or patternProperties in this schema (additionalProperties) #
false
Not allowed by this rule.
Properties and child nodes (properties) #
vendor,a-child-node-property — required here
Child node properties have all the same schema requirements.
Value type (type): "boolean"
Required in this object (required): "vendor,a-child-node-property"
child-node-with-own-schema — not listed as required here #
Child node with their own compatible and device schema which ends in 'additionalProperties: false' or 'unevaluatedProperties: false' can mention only the compatible and use here 'additionalProperties: true'.
Value type (type): "object"
Properties not matched by properties or patternProperties in this schema (additionalProperties) #
true
Allowed by this rule.
Properties and child nodes (properties) #
compatible — not listed as required here
Exact value (const): "vendor,sub-device"
Property dependencies (dependencies) #
vendor,bool-property — applies when this property is present #
Also requires: "vendor,string-array-property"
vendor,string-array-property — applies when this property is present #
Also requires: "vendor,bool-property"
Required in this object (required): "compatible", "reg", "interrupts", "interrupt-controller"
All of these rules must match (allOf) #
Rule 1 #
Condition (
if) #Properties and child nodes (
properties)
compatible— not listed as required hereRule for matching array elements (
contains)Exact value (
const):"vendor,soc2-ip"When the condition matches (
then) #When the condition does not match (
else) #Properties and child nodes (
properties)
foo-supply— not listed as required here
false— Not permitted by this property rule.
Rule 2 #
Condition (
if) #When the condition matches (
then) #Properties and child nodes (
properties)
vendor,int-property— not listed as required here
Properties not matched by properties or patternProperties in this schema (additionalProperties) #
false
Not allowed by this rule.
Examples (examples) #
node@1000 {
compatible = "vendor,soc4-ip", "vendor,soc1-ip";
reg = <0x1000 0x80>,
<0x3000 0x80>;
reg-names = "core", "aux";
interrupts = <10>;
interrupt-controller;
#interrupt-cells = <2>;
};
Source notes #
Annotations retained from the schema source
Line 1: SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
Line 2: Copyright 2018 Linaro Ltd.
Line 5: All the top-level keys are standard json-schema keywords except for
Line 6: 'maintainers' and 'select'
Line 8: $id is a unique identifier based on the filename. There may or may not be a
Line 9: file present at the URL.
Line 11: $schema is the meta-schema this schema should be validated with.
Line 29: 'select' is a schema applied to a DT node to determine if this binding
Line 30: schema should be applied to the node. It is optional and by default the
Line 31: possible compatible strings are extracted and used to match.
Line 33: In this case, a 'false' schema will never match.
Line 36: A dictionary of DT properties for this binding schema
Line 38: More complicated schema can use oneOf (XOR), anyOf (OR), or allOf (AND)
Line 39: to handle different conditions.
Line 40: In this case, it's needed to handle a variable number of values as there
Line 41: isn't another way to express a constraint of the last string value.
Line 42: The boolean schema must be a list of schemas.
Line 45: items is a list of possible values for the property. The number of
Line 46: values is determined by the number of elements in the list.
Line 47: Order in lists is significant, order in dicts is not
Line 48: Must be one of the 1st enums followed by the 2nd enum
Line 49:
Line 50: Each element in items should be 'enum' or 'const'
Line 56: additionalItems being false is implied
Line 57: minItems/maxItems equal to 2 is implied
Line 59: 'const' is just a special case of an enum with a single possible value
Line 63: The core schema already checks that reg values are numbers, so device
Line 64: specific schema don't need to do those checks.
Line 65: The description of each element defines the order and implicitly defines
Line 66: the number of reg entries.
Line 70: minItems/maxItems equal to 2 is implied
Line 73: The core schema enforces this (*-names) is a string array
Line 79: Cases that have only a single entry just need to express that with maxItems
Line 87: For single-entry lists in clocks, resets etc., the xxx-names often do not
Line 88: bring any value, especially if they copy the IP block name. In such case
Line 89: just skip the xxx-names.
Line 94: Either 1 or 2 interrupts can be present
Line 107: minItems must be specified here because the default would be 2
Line 113: Property names starting with '#' must be quoted
Line 115: A simple case where the value must always be '2'.
Line 116: The core schema handles that this must be a single integer.
Line 120: The core checks this is a boolean, so just have to list it here to be
Line 121: valid for this binding.
Line 124: The type is set in the core schema. Per-device schema only need to set
Line 125: constraints on the possible values.
Line 128: The value that should be used if the property is not present
Line 135: *-supply is always a single phandle, so nothing more to define.
Line 138: Vendor-specific properties
Line 139:
Line 140: Vendor-specific properties have slightly different schema requirements than
Line 141: common properties. They must have at least a type definition and
Line 142: 'description'.
Line 180: DT nodes are json objects
Line 181: Child nodes also need additionalProperties or unevaluatedProperties, where
Line 182: 'false' should be used in most cases (see 'child-node-with-own-schema'
Line 183: below).
Line 205: Describe the relationship between different properties
Line 207: 'vendor,bool-property' is only allowed when 'vendor,string-array-property'
Line 208: is present
Line 210: Expressing 2 properties in both orders means all of the set of properties
Line 211: must be present or none of them.
Line 220: if/then schema can be used to handle conditions on a property affecting
Line 221: another property. A typical case is a specific 'compatible' value changes the
Line 222: constraints on other properties.
Line 223:
Line 224: For multiple 'if' schema, group them under an 'allOf'.
Line 225:
Line 226: If the conditionals become too unwieldy, then it may be better to just split
Line 227: the binding into separate schema documents.
Line 238: If otherwise the property is not allowed:
Line 241: Altering schema depending on presence of properties is usually done by
Line 242: dependencies (see above), however some adjustments might require if:
Line 251: Ideally, the schema should have this line otherwise any other properties
Line 252: present are allowed. There's a few common properties such as 'status' and
Line 253: 'pinctrl-*' which are added automatically by the tooling.
Line 254:
Line 255: This can't be used in cases where another schema is referenced
Line 256: (i.e. allOf: [{$ref: ...}]).
Line 257: If and only if another schema is referenced and arbitrary children nodes can
Line 258: appear, "unevaluatedProperties: false" could be used. A typical example is
Line 259: an I2C controller where no name pattern matching for children can be added.
Line 263: Examples are now compiled with dtc and validated against the schemas
Line 264:
Line 265: Examples have a default #address-cells and #size-cells value of 1. This can
Line 266: be overridden or an appropriate parent bus node should be shown (such as on
Line 267: i2c buses).
Line 268:
Line 269: Any includes used have to be explicitly included. Use 4-space indentation.