sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget6/translations/zh_CN/devicetree/bindings/writing-schemamodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget6/translations/zh_TW/devicetree/bindings/writing-schemamodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget6/translations/it_IT/devicetree/bindings/writing-schemamodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget6/translations/ja_JP/devicetree/bindings/writing-schemamodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget6/translations/ko_KR/devicetree/bindings/writing-schemamodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget6/translations/sp_SP/devicetree/bindings/writing-schemamodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhcomment)}(h SPDX-License-Identifier: GPL-2.0h]h SPDX-License-Identifier: GPL-2.0}hhsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1hhhhhhP/var/lib/git/docbuild/linux/Documentation/devicetree/bindings/writing-schema.rsthKubhsection)}(hhh](htitle)}(h*Writing Devicetree Bindings in json-schemah]h*Writing Devicetree Bindings in json-schema}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh paragraph)}(hXDevicetree bindings are written using json-schema vocabulary. Schema files are written in a JSON-compatible subset of YAML. YAML is used instead of JSON as it is considered more human readable and has some advantages such as allowing comments (Prefixed with '#').h]hX Devicetree bindings are written using json-schema vocabulary. Schema files are written in a JSON-compatible subset of YAML. YAML is used instead of JSON as it is considered more human readable and has some advantages such as allowing comments (Prefixed with ‘#’).}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hAlso see :ref:`example-schema`.h](h Also see }(hhhhhNhNubh)}(h:ref:`example-schema`h]hinline)}(hhh]hexample-schema}(hhhhhNhNubah}(h]h ](xrefstdstd-refeh"]h$]h&]uh1hhhubah}(h]h ]h"]h$]h&]refdoc"devicetree/bindings/writing-schema refdomainhreftyperef refexplicitrefwarn reftargetexample-schemauh1hhhhK hhubh.}(hhhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh)}(hhh](h)}(hSchema Contentsh]hSchema Contents}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hEach schema doc is a structured json-schema which is defined by a set of top-level properties. Generally, there is one binding defined per file. The top-level json-schema properties used are:h]hEach schema doc is a structured json-schema which is defined by a set of top-level properties. Generally, there is one binding defined per file. The top-level json-schema properties used are:}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubhdefinition_list)}(hhh](hdefinition_list_item)}(hXa$id A json-schema unique identifier string. The string must be a valid URI typically containing the binding's filename and path. For DT schema, it must begin with "http://devicetree.org/schemas/". The URL is used in constructing references to other files specified in schema "$ref" properties. A $ref value with a leading '/' will have the hostname prepended. A $ref value with only a relative path or filename will be prepended with the hostname and path components of the current schema file's '$id' value. A URL is used even for local files, but there may not actually be files present at those locations. h](hterm)}(h$idh]h$id}(hj<hhhNhNubah}(h]h ]h"]h$]h&]uh1j:hhhKhj6ubh definition)}(hhh]h)}(hX\A json-schema unique identifier string. The string must be a valid URI typically containing the binding's filename and path. For DT schema, it must begin with "http://devicetree.org/schemas/". The URL is used in constructing references to other files specified in schema "$ref" properties. A $ref value with a leading '/' will have the hostname prepended. A $ref value with only a relative path or filename will be prepended with the hostname and path components of the current schema file's '$id' value. A URL is used even for local files, but there may not actually be files present at those locations.h](hA json-schema unique identifier string. The string must be a valid URI typically containing the binding’s filename and path. For DT schema, it must begin with “}(hjOhhhNhNubh reference)}(hhttp://devicetree.org/schemas/h]hhttp://devicetree.org/schemas/}(hjYhhhNhNubah}(h]h ]h"]h$]h&]refurij[uh1jWhjOubhX”. The URL is used in constructing references to other files specified in schema “$ref” properties. A $ref value with a leading ‘/’ will have the hostname prepended. A $ref value with only a relative path or filename will be prepended with the hostname and path components of the current schema file’s ‘$id’ value. A URL is used even for local files, but there may not actually be files present at those locations.}(hjOhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjLubah}(h]h ]h"]h$]h&]uh1jJhj6ubeh}(h]h ]h"]h$]h&]uh1j4hhhKhj1ubj5)}(h>$schema Indicates the meta-schema the schema file adheres to. h](j;)}(h$schemah]h$schema}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j:hhhKhj~ubjK)}(hhh]h)}(h5Indicates the meta-schema the schema file adheres to.h]h5Indicates the meta-schema the schema file adheres to.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jJhj~ubeh}(h]h ]h"]h$]h&]uh1j4hhhKhj1hhubj5)}(hTtitle A one-line description of the hardware being described in the binding schema. h](j;)}(htitleh]htitle}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j:hhhK"hjubjK)}(hhh]h)}(hMA one-line description of the hardware being described in the binding schema.h]hMA one-line description of the hardware being described in the binding schema.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK"hjubah}(h]h ]h"]h$]h&]uh1jJhjubeh}(h]h ]h"]h$]h&]uh1j4hhhK"hj1hhubj5)}(hjmaintainers A DT specific property. Contains a list of email address(es) for maintainers of this binding. h](j;)}(h maintainersh]h maintainers}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j:hhhK&hjubjK)}(hhh]h)}(h]A DT specific property. Contains a list of email address(es) for maintainers of this binding.h]h]A DT specific property. Contains a list of email address(es) for maintainers of this binding.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK%hjubah}(h]h ]h"]h$]h&]uh1jJhjubeh}(h]h ]h"]h$]h&]uh1j4hhhK&hj1hhubj5)}(hXdescription Optional. A multi-line text block containing any detailed information about this hardware. It should contain things such as what the block or device does, standards the device conforms to, and links to datasheets for more information. The YAML format has several options for defining the formatting of the text block. The options are controlled with indicator characters following the key (e.g. "description: \|"). The minimum formatting needed for a block should be used. The formatting controls can not only affect whether the YAML can be parsed correctly, but are important when the text blocks are rendered to another form. The options are as follows. The default without any indicators is flowed, plain scalar style where single line breaks and leading whitespace are stripped. Paragraphs are delimited by blank lines (i.e. double line break). This style cannot contain ": " in it as it will be interpretted as a key. Any " #" sequence will be interpretted as a comment. There's other restrictions on characters as well. Most restrictions are on what the first character can be. The second style is folded which is indicated by ">" character. In addition to maintaining line breaks on double line breaks, the folded style also maintains leading whitespace beyond indentation of the first line. The line breaks on indented lines are also maintained. The third style is literal which is indicated by "\|" character. The literal style maintains all line breaks and whitespace (beyond indentation of the first line). The above is not a complete description of YAML text blocks. More details on multi-line YAML text blocks can be found online: https://yaml-multiline.info/ https://www.yaml.info/learn/quote.html h](j;)}(h descriptionh]h description}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j:hhhKJhj ubjK)}(hhh](h)}(hOptional. A multi-line text block containing any detailed information about this hardware. It should contain things such as what the block or device does, standards the device conforms to, and links to datasheets for more information.h]hOptional. A multi-line text block containing any detailed information about this hardware. It should contain things such as what the block or device does, standards the device conforms to, and links to datasheets for more information.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK)hjubh)}(hXThe YAML format has several options for defining the formatting of the text block. The options are controlled with indicator characters following the key (e.g. "description: \|"). The minimum formatting needed for a block should be used. The formatting controls can not only affect whether the YAML can be parsed correctly, but are important when the text blocks are rendered to another form. The options are as follows.h]hXThe YAML format has several options for defining the formatting of the text block. The options are controlled with indicator characters following the key (e.g. “description: |”). The minimum formatting needed for a block should be used. The formatting controls can not only affect whether the YAML can be parsed correctly, but are important when the text blocks are rendered to another form. The options are as follows.}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK.hjubh)}(hXThe default without any indicators is flowed, plain scalar style where single line breaks and leading whitespace are stripped. Paragraphs are delimited by blank lines (i.e. double line break). This style cannot contain ": " in it as it will be interpretted as a key. Any " #" sequence will be interpretted as a comment. There's other restrictions on characters as well. Most restrictions are on what the first character can be.h]hXThe default without any indicators is flowed, plain scalar style where single line breaks and leading whitespace are stripped. Paragraphs are delimited by blank lines (i.e. double line break). This style cannot contain “: “ in it as it will be interpretted as a key. Any “ #” sequence will be interpretted as a comment. There’s other restrictions on characters as well. Most restrictions are on what the first character can be.}(hj<hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK5hjubh)}(hX The second style is folded which is indicated by ">" character. In addition to maintaining line breaks on double line breaks, the folded style also maintains leading whitespace beyond indentation of the first line. The line breaks on indented lines are also maintained.h]hXThe second style is folded which is indicated by “>” character. In addition to maintaining line breaks on double line breaks, the folded style also maintains leading whitespace beyond indentation of the first line. The line breaks on indented lines are also maintained.}(hjJhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhNhNubah}(h]h ]h"]h$]h&]uh1j<hj4ubh target:}(hj4hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj#hhubj)}(hmake dt_binding_checkh]hmake dt_binding_check}hjVsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhj#hhubh)}(hRIn order to perform validation of DT source files, use the ``dtbs_check`` target::h](h;In order to perform validation of DT source files, use the }(hjdhhhNhNubj=)}(h``dtbs_check``h]h dtbs_check}(hjlhhhNhNubah}(h]h ]h"]h$]h&]uh1j<hjdubh target:}(hjdhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj#hhubj)}(hmake dtbs_checkh]hmake dtbs_check}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhj#hhubh)}(hNote that ``dtbs_check`` will skip any binding schema files with errors. It is necessary to use ``dt_binding_check`` to get all the validation errors in the binding schema files.h](h Note that }(hjhhhNhNubj=)}(h``dtbs_check``h]h dtbs_check}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j<hjubhH will skip any binding schema files with errors. It is necessary to use }(hjhhhNhNubj=)}(h``dt_binding_check``h]hdt_binding_check}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j<hjubh> to get all the validation errors in the binding schema files.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj#hhubh)}(h0It is possible to run both in a single command::h]h/It is possible to run both in a single command:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj#hhubj)}(h make dt_binding_check dtbs_checkh]h make dt_binding_check dtbs_check}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhj#hhubh)}(hIt is also possible to run checks with a subset of matching schema files by setting the ``DT_SCHEMA_FILES`` variable to 1 or more specific schema files or patterns (partial match of a fixed string). Each file or pattern should be separated by ':'.h](hXIt is also possible to run checks with a subset of matching schema files by setting the }(hjhhhNhNubj=)}(h``DT_SCHEMA_FILES``h]hDT_SCHEMA_FILES}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j<hjubh variable to 1 or more specific schema files or patterns (partial match of a fixed string). Each file or pattern should be separated by ‘:’.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj#hhubj)}(hmake dt_binding_check DT_SCHEMA_FILES=trivial-devices.yaml make dt_binding_check DT_SCHEMA_FILES=trivial-devices.yaml:rtc.yaml make dt_binding_check DT_SCHEMA_FILES=/gpio/ make dtbs_check DT_SCHEMA_FILES=trivial-devices.yamlh]hmake dt_binding_check DT_SCHEMA_FILES=trivial-devices.yaml make dt_binding_check DT_SCHEMA_FILES=trivial-devices.yaml:rtc.yaml make dt_binding_check DT_SCHEMA_FILES=/gpio/ make dtbs_check DT_SCHEMA_FILES=trivial-devices.yaml}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhj#hhubeh}(h]running-checksah ]h"]running checksah$]h&]uh1hhjhhhhhKubeh}(h]testingah ]h"]testingah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hjson-schema Resourcesh]hjson-schema Resources}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(h7`JSON-Schema Specifications `_h](jX)}(hj1h]hJSON-Schema Specifications}(hj3hhhNhNubah}(h]h ]h"]h$]h&]nameJSON-Schema Specificationsrefurihttp://json-schema.org/uh1jWhj/ubhtarget)}(h h]h}(h]json-schema-specificationsah ]h"]json-schema specificationsah$]h&]refurijCuh1jD referencedKhj/ubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h7`Using JSON Schema Book `_h](jX)}(hj\h]hUsing JSON Schema Book}(hj^hhhNhNubah}(h]h ]h"]h$]h&]nameUsing JSON Schema BookjBhttp://usingjsonschema.com/uh1jWhjZubjE)}(h h]h}(h]using-json-schema-bookah ]h"]using json schema bookah$]h&]refurijmuh1jDjSKhjZubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubjE)}(h.. _example-schema:h]h}(h]h ]h"]h$]h&]refidexample-schemauh1jDhKhjhhhhubeh}(h]json-schema-resourcesah ]h"]json-schema resourcesah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hAnnotated Example Schemah]hAnnotated Example Schema}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hBAlso available as a separate file: :download:`example-schema.yaml`h](h#Also available as a separate file: }(hjhhhNhNubhdownload_reference)}(h:download:`example-schema.yaml`h]j=)}(hjh]hexample-schema.yaml}(hjhhhNhNubah}(h]h ](hdownloadeh"]h$]h&]uh1j<hjubah}(h]h ]h"]h$]h&]refdoch refdomainhreftypej refexplicitrefwarnjexample-schema.yamlfilename4bf29fbb4b15af5f11533d4e2b6a0e85b/example-schema.yamluh1jhhhKhjubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hX## SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) # Copyright 2018 Linaro Ltd. %YAML 1.2 --- # All the top-level keys are standard json-schema keywords except for # 'maintainers' and 'select' # $id is a unique identifier based on the filename. There may or may not be a # file present at the URL. $id: http://devicetree.org/schemas/example-schema.yaml# # $schema is the meta-schema this schema should be validated with. $schema: http://devicetree.org/meta-schemas/core.yaml# title: An Example Device maintainers: - Rob Herring description: | 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. select: false # 'select' is a schema applied to a DT node to determine if this binding # schema should be applied to the node. It is optional and by default the # possible compatible strings are extracted and used to match. # In this case, a 'false' schema will never match. properties: # A dictionary of DT properties for this binding schema compatible: # More complicated schema can use oneOf (XOR), anyOf (OR), or allOf (AND) # to handle different conditions. # In this case, it's needed to handle a variable number of values as there # isn't another way to express a constraint of the last string value. # The boolean schema must be a list of schemas. oneOf: - items: # items is a list of possible values for the property. The number of # values is determined by the number of elements in the list. # Order in lists is significant, order in dicts is not # Must be one of the 1st enums followed by the 2nd enum # # Each element in items should be 'enum' or 'const' - enum: - vendor,soc4-ip - vendor,soc3-ip - vendor,soc2-ip - const: vendor,soc1-ip # additionalItems being false is implied # minItems/maxItems equal to 2 is implied - items: # 'const' is just a special case of an enum with a single possible value - const: vendor,soc1-ip reg: # The core schema already checks that reg values are numbers, so device # specific schema don't need to do those checks. # The description of each element defines the order and implicitly defines # the number of reg entries. items: - description: core registers - description: aux registers # minItems/maxItems equal to 2 is implied reg-names: # The core schema enforces this (*-names) is a string array items: - const: core - const: aux clocks: # Cases that have only a single entry just need to express that with maxItems maxItems: 1 description: 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: # For single-entry lists in clocks, resets etc., the xxx-names often do not # bring any value, especially if they copy the IP block name. In such case # just skip the xxx-names. items: - const: bus interrupts: # Either 1 or 2 interrupts can be present minItems: 1 items: - description: tx or combined interrupt - description: rx interrupt description: 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: # minItems must be specified here because the default would be 2 minItems: 1 items: - const: tx irq - const: rx irq # Property names starting with '#' must be quoted '#interrupt-cells': # A simple case where the value must always be '2'. # The core schema handles that this must be a single integer. const: 2 interrupt-controller: true # The core checks this is a boolean, so just have to list it here to be # valid for this binding. clock-frequency: # The type is set in the core schema. Per-device schema only need to set # constraints on the possible values. minimum: 100 maximum: 400000 # The value that should be used if the property is not present default: 200 foo-gpios: maxItems: 1 description: A connection of the 'foo' gpio line. # *-supply is always a single phandle, so nothing more to define. foo-supply: true # Vendor-specific properties # # Vendor-specific properties have slightly different schema requirements than # common properties. They must have at least a type definition and # 'description'. vendor,int-property: description: Vendor-specific properties must have a description $ref: /schemas/types.yaml#/definitions/uint32 enum: [2, 4, 6, 8, 10] vendor,bool-property: description: Vendor-specific properties must have a description. Boolean properties are one case where the json-schema 'type' keyword can be used directly. type: boolean vendor,string-array-property: description: Vendor-specific properties should reference a type in the core schema. $ref: /schemas/types.yaml#/definitions/string-array items: - enum: [foo, bar] - enum: [baz, boo] vendor,property-in-standard-units-microvolt: description: Vendor-specific properties having a standard unit suffix don't need a type. enum: [ 100, 200, 300 ] vendor,int-array-variable-length-and-constrained-values: description: Array might define what type of elements might be used (e.g. their range). $ref: /schemas/types.yaml#/definitions/uint32-array minItems: 2 maxItems: 3 items: minimum: 0 maximum: 8 child-node: description: Child nodes are just another property from a json-schema perspective. type: object # DT nodes are json objects # Child nodes also need additionalProperties or unevaluatedProperties additionalProperties: false properties: vendor,a-child-node-property: description: Child node properties have all the same schema requirements. type: boolean required: - vendor,a-child-node-property # Describe the relationship between different properties dependencies: # 'vendor,bool-property' is only allowed when 'vendor,string-array-property' # is present vendor,bool-property: [ 'vendor,string-array-property' ] # Expressing 2 properties in both orders means all of the set of properties # must be present or none of them. vendor,string-array-property: [ 'vendor,bool-property' ] required: - compatible - reg - interrupts - interrupt-controller # if/then schema can be used to handle conditions on a property affecting # another property. A typical case is a specific 'compatible' value changes the # constraints on other properties. # # For multiple 'if' schema, group them under an 'allOf'. # # If the conditionals become too unweldy, then it may be better to just split # the binding into separate schema documents. allOf: - if: properties: compatible: contains: const: vendor,soc2-ip then: required: - foo-supply else: # If otherwise the property is not allowed: properties: foo-supply: false # Altering schema depending on presence of properties is usually done by # dependencies (see above), however some adjustments might require if: - if: required: - vendor,bool-property then: properties: vendor,int-property: enum: [2, 4, 6] # Ideally, the schema should have this line otherwise any other properties # present are allowed. There's a few common properties such as 'status' and # 'pinctrl-*' which are added automatically by the tooling. # # This can't be used in cases where another schema is referenced # (i.e. allOf: [{$ref: ...}]). # If and only if another schema is referenced and arbitrary children nodes can # appear, "unevaluatedProperties: false" could be used. A typical example is # an I2C controller where no name pattern matching for children can be added. additionalProperties: false examples: # Examples are now compiled with dtc and validated against the schemas # # Examples have a default #address-cells and #size-cells value of 1. This can # be overridden or an appropriate parent bus node should be shown (such as on # i2c buses). # # Any includes used have to be explicitly included. Use 4-space indentation. - | 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>; }; h]hX## SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) # Copyright 2018 Linaro Ltd. %YAML 1.2 --- # All the top-level keys are standard json-schema keywords except for # 'maintainers' and 'select' # $id is a unique identifier based on the filename. There may or may not be a # file present at the URL. $id: http://devicetree.org/schemas/example-schema.yaml# # $schema is the meta-schema this schema should be validated with. $schema: http://devicetree.org/meta-schemas/core.yaml# title: An Example Device maintainers: - Rob Herring description: | 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. select: false # 'select' is a schema applied to a DT node to determine if this binding # schema should be applied to the node. It is optional and by default the # possible compatible strings are extracted and used to match. # In this case, a 'false' schema will never match. properties: # A dictionary of DT properties for this binding schema compatible: # More complicated schema can use oneOf (XOR), anyOf (OR), or allOf (AND) # to handle different conditions. # In this case, it's needed to handle a variable number of values as there # isn't another way to express a constraint of the last string value. # The boolean schema must be a list of schemas. oneOf: - items: # items is a list of possible values for the property. The number of # values is determined by the number of elements in the list. # Order in lists is significant, order in dicts is not # Must be one of the 1st enums followed by the 2nd enum # # Each element in items should be 'enum' or 'const' - enum: - vendor,soc4-ip - vendor,soc3-ip - vendor,soc2-ip - const: vendor,soc1-ip # additionalItems being false is implied # minItems/maxItems equal to 2 is implied - items: # 'const' is just a special case of an enum with a single possible value - const: vendor,soc1-ip reg: # The core schema already checks that reg values are numbers, so device # specific schema don't need to do those checks. # The description of each element defines the order and implicitly defines # the number of reg entries. items: - description: core registers - description: aux registers # minItems/maxItems equal to 2 is implied reg-names: # The core schema enforces this (*-names) is a string array items: - const: core - const: aux clocks: # Cases that have only a single entry just need to express that with maxItems maxItems: 1 description: 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: # For single-entry lists in clocks, resets etc., the xxx-names often do not # bring any value, especially if they copy the IP block name. In such case # just skip the xxx-names. items: - const: bus interrupts: # Either 1 or 2 interrupts can be present minItems: 1 items: - description: tx or combined interrupt - description: rx interrupt description: 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: # minItems must be specified here because the default would be 2 minItems: 1 items: - const: tx irq - const: rx irq # Property names starting with '#' must be quoted '#interrupt-cells': # A simple case where the value must always be '2'. # The core schema handles that this must be a single integer. const: 2 interrupt-controller: true # The core checks this is a boolean, so just have to list it here to be # valid for this binding. clock-frequency: # The type is set in the core schema. Per-device schema only need to set # constraints on the possible values. minimum: 100 maximum: 400000 # The value that should be used if the property is not present default: 200 foo-gpios: maxItems: 1 description: A connection of the 'foo' gpio line. # *-supply is always a single phandle, so nothing more to define. foo-supply: true # Vendor-specific properties # # Vendor-specific properties have slightly different schema requirements than # common properties. They must have at least a type definition and # 'description'. vendor,int-property: description: Vendor-specific properties must have a description $ref: /schemas/types.yaml#/definitions/uint32 enum: [2, 4, 6, 8, 10] vendor,bool-property: description: Vendor-specific properties must have a description. Boolean properties are one case where the json-schema 'type' keyword can be used directly. type: boolean vendor,string-array-property: description: Vendor-specific properties should reference a type in the core schema. $ref: /schemas/types.yaml#/definitions/string-array items: - enum: [foo, bar] - enum: [baz, boo] vendor,property-in-standard-units-microvolt: description: Vendor-specific properties having a standard unit suffix don't need a type. enum: [ 100, 200, 300 ] vendor,int-array-variable-length-and-constrained-values: description: Array might define what type of elements might be used (e.g. their range). $ref: /schemas/types.yaml#/definitions/uint32-array minItems: 2 maxItems: 3 items: minimum: 0 maximum: 8 child-node: description: Child nodes are just another property from a json-schema perspective. type: object # DT nodes are json objects # Child nodes also need additionalProperties or unevaluatedProperties additionalProperties: false properties: vendor,a-child-node-property: description: Child node properties have all the same schema requirements. type: boolean required: - vendor,a-child-node-property # Describe the relationship between different properties dependencies: # 'vendor,bool-property' is only allowed when 'vendor,string-array-property' # is present vendor,bool-property: [ 'vendor,string-array-property' ] # Expressing 2 properties in both orders means all of the set of properties # must be present or none of them. vendor,string-array-property: [ 'vendor,bool-property' ] required: - compatible - reg - interrupts - interrupt-controller # if/then schema can be used to handle conditions on a property affecting # another property. A typical case is a specific 'compatible' value changes the # constraints on other properties. # # For multiple 'if' schema, group them under an 'allOf'. # # If the conditionals become too unweldy, then it may be better to just split # the binding into separate schema documents. allOf: - if: properties: compatible: contains: const: vendor,soc2-ip then: required: - foo-supply else: # If otherwise the property is not allowed: properties: foo-supply: false # Altering schema depending on presence of properties is usually done by # dependencies (see above), however some adjustments might require if: - if: required: - vendor,bool-property then: properties: vendor,int-property: enum: [2, 4, 6] # Ideally, the schema should have this line otherwise any other properties # present are allowed. There's a few common properties such as 'status' and # 'pinctrl-*' which are added automatically by the tooling. # # This can't be used in cases where another schema is referenced # (i.e. allOf: [{$ref: ...}]). # If and only if another schema is referenced and arbitrary children nodes can # appear, "unevaluatedProperties: false" could be used. A typical example is # an I2C controller where no name pattern matching for children can be added. additionalProperties: false examples: # Examples are now compiled with dtc and validated against the schemas # # Examples have a default #address-cells and #size-cells value of 1. This can # be overridden or an appropriate parent bus node should be shown (such as on # i2c buses). # # Any includes used have to be explicitly included. Use 4-space indentation. - | 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>; }; }hjsbah}(h]h ]h"]h$]h&]sourceQ/var/lib/git/docbuild/linux/Documentation/devicetree/bindings/example-schema.yamlhhforcehighlight_args} linenostartKsuh1jhhhKhjhhubeh}(h](annotated-example-schemajeh ]h"](annotated example schemaexample-schemaeh$]h&]uh1hhhhhhhhKexpect_referenced_by_name}jjsexpect_referenced_by_id}jjsubeh}(h]*writing-devicetree-bindings-in-json-schemaah ]h"]*writing devicetree bindings in json-schemaah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerj"error_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}j]jasnameids}(jjj j jyjvjjjjj jjjjjjOjLjwjtjjjju nametypes}(jj jyjjj jjjOjwjjuh}(jhj jjvjjj|jjjjjj#jjjLjFjtjnjjjju footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages]hsystem_message)}(hhh]h)}(hhh]h4Hyperlink target "example-schema" is not referenced.}hjsbah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]levelKtypeINFOsourcehlineKuh1juba transformerN include_log] decorationNhhub.