~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/devicetree/bindings/writing-schema.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/devicetree/bindings/writing-schema.rst (Version linux-6.12-rc7) and /Documentation/devicetree/bindings/writing-schema.rst (Version linux-5.15.171)


  1 .. SPDX-License-Identifier: GPL-2.0                 1 .. SPDX-License-Identifier: GPL-2.0
  2                                                     2 
  3 Writing Devicetree Bindings in json-schema          3 Writing Devicetree Bindings in json-schema
  4 ==========================================          4 ==========================================
  5                                                     5 
  6 Devicetree bindings are written using json-sch      6 Devicetree bindings are written using json-schema vocabulary. Schema files are
  7 written in a JSON-compatible subset of YAML. Y !!   7 written in a JSON compatible subset of YAML. YAML is used instead of JSON as it
  8 is considered more human readable and has some      8 is considered more human readable and has some advantages such as allowing
  9 comments (Prefixed with '#').                       9 comments (Prefixed with '#').
 10                                                    10 
 11 Also see :ref:`example-schema`.                    11 Also see :ref:`example-schema`.
 12                                                    12 
 13 Schema Contents                                    13 Schema Contents
 14 ---------------                                    14 ---------------
 15                                                    15 
 16 Each schema doc is a structured json-schema wh     16 Each schema doc is a structured json-schema which is defined by a set of
 17 top-level properties. Generally, there is one      17 top-level properties. Generally, there is one binding defined per file. The
 18 top-level json-schema properties used are:         18 top-level json-schema properties used are:
 19                                                    19 
 20 $id                                                20 $id
 21   A json-schema unique identifier string. The      21   A json-schema unique identifier string. The string must be a valid
 22   URI typically containing the binding's filen     22   URI typically containing the binding's filename and path. For DT schema, it must
 23   begin with "http://devicetree.org/schemas/".     23   begin with "http://devicetree.org/schemas/". The URL is used in constructing
 24   references to other files specified in schem     24   references to other files specified in schema "$ref" properties. A $ref value
 25   with a leading '/' will have the hostname pr !!  25   with a leading '/' will have the hostname prepended. A $ref value a relative
 26   relative path or filename will be prepended  !!  26   path or filename only will be prepended with the hostname and path components
 27   components of the current schema file's '$id !!  27   of the current schema file's '$id' value. A URL is used even for local files,
 28   local files, but there may not actually be f !!  28   but there may not actually be files present at those locations.
 29                                                    29 
 30 $schema                                            30 $schema
 31   Indicates the meta-schema the schema file ad     31   Indicates the meta-schema the schema file adheres to.
 32                                                    32 
 33 title                                              33 title
 34   A one-line description of the hardware being !!  34   A one line description on the contents of the binding schema.
 35                                                    35 
 36 maintainers                                        36 maintainers
 37   A DT specific property. Contains a list of e     37   A DT specific property. Contains a list of email address(es)
 38   for maintainers of this binding.                 38   for maintainers of this binding.
 39                                                    39 
 40 description                                        40 description
 41   Optional. A multi-line text block containing     41   Optional. A multi-line text block containing any detailed
 42   information about this hardware. It should c !!  42   information about this binding. It should contain things such as what the block
 43   or device does, standards the device conform     43   or device does, standards the device conforms to, and links to datasheets for
 44   more information.                                44   more information.
 45                                                    45 
 46 select                                             46 select
 47   Optional. A json-schema used to match nodes      47   Optional. A json-schema used to match nodes for applying the
 48   schema. By default, without 'select', nodes  !!  48   schema. By default without 'select', nodes are matched against their possible
 49   compatible-string values or node name. Most  !!  49   compatible string values or node name. Most bindings should not need select.
 50                                                    50 
 51 allOf                                              51 allOf
 52   Optional. A list of other schemas to include     52   Optional. A list of other schemas to include. This is used to
 53   include other schemas the binding conforms t     53   include other schemas the binding conforms to. This may be schemas for a
 54   particular class of devices such as I2C or S     54   particular class of devices such as I2C or SPI controllers.
 55                                                    55 
 56 properties                                         56 properties
 57   A set of sub-schema defining all the DT prop     57   A set of sub-schema defining all the DT properties for the
 58   binding. The exact schema syntax depends on      58   binding. The exact schema syntax depends on whether properties are known,
 59   common properties (e.g. 'interrupts') or are !!  59   common properties (e.g. 'interrupts') or are binding/vendor specific properties.
 60   properties.                                  << 
 61                                                    60 
 62 A property can also define a child DT node wit     61 A property can also define a child DT node with child properties defined
 63 under it.                                          62 under it.
 64                                                    63 
 65 For more details on properties sections, see '     64 For more details on properties sections, see 'Property Schema' section.
 66                                                    65 
 67 patternProperties                                  66 patternProperties
 68   Optional. Similar to 'properties', but names     67   Optional. Similar to 'properties', but names are regex.
 69                                                    68 
 70 required                                           69 required
 71   A list of DT properties from the 'properties     70   A list of DT properties from the 'properties' section that
 72   must always be present.                          71   must always be present.
 73                                                    72 
 74 additionalProperties / unevaluatedProperties   << 
 75   Keywords controlling how schema will validat << 
 76   schema's 'properties' or 'patternProperties' << 
 77   have exactly one of these keywords in top-le << 
 78   additionalProperties or unevaluatedPropertie << 
 79   being objects, are supposed to have one as w << 
 80                                                << 
 81   * additionalProperties: false                << 
 82       Most common case, where no additional sc << 
 83       binding allows subset of properties from << 
 84                                                << 
 85   * unevaluatedProperties: false               << 
 86       Used when this binding references other  << 
 87       should be allowed.                       << 
 88                                                << 
 89   * additionalProperties: true                 << 
 90       Rare case, used for schemas implementing << 
 91       schemas are supposed to be referenced by << 
 92       'unevaluatedProperties: false'.  Typical << 
 93                                                << 
 94 examples                                           73 examples
 95   Optional. A list of one or more DTS hunks im !!  74   Optional. A list of one or more DTS hunks implementing the
 96   Example should not contain unrelated device  !!  75   binding. Note: YAML doesn't allow leading tabs, so spaces must be used instead.
 97   provider binding, other nodes referenced by  << 
 98   Note: YAML doesn't allow leading tabs, so sp << 
 99                                                    76 
100 Unless noted otherwise, all properties are req     77 Unless noted otherwise, all properties are required.
101                                                    78 
102 Property Schema                                    79 Property Schema
103 ---------------                                    80 ---------------
104                                                    81 
105 The 'properties' section of the schema contain     82 The 'properties' section of the schema contains all the DT properties for a
106 binding. Each property contains a set of const     83 binding. Each property contains a set of constraints using json-schema
107 vocabulary for that property. The properties s !!  84 vocabulary for that property. The properties schemas are what is used for
108 validation of DT files.                            85 validation of DT files.
109                                                    86 
110 For common properties, only additional constra !!  87 For common properties, only additional constraints not covered by the common
111 binding schema need to be defined such as how      88 binding schema need to be defined such as how many values are valid or what
112 possible values are valid.                         89 possible values are valid.
113                                                    90 
114 Vendor-specific properties will typically need !!  91 Vendor specific properties will typically need more detailed schema. With the
115 exception of boolean properties, they should h     92 exception of boolean properties, they should have a reference to a type in
116 schemas/types.yaml. A "description" property i     93 schemas/types.yaml. A "description" property is always required.
117                                                    94 
118 The Devicetree schemas don't exactly match the !!  95 The Devicetree schemas don't exactly match the YAML encoded DT data produced by
119 dtc. They are simplified to make them more com     96 dtc. They are simplified to make them more compact and avoid a bunch of
120 boilerplate. The tools process the schema file     97 boilerplate. The tools process the schema files to produce the final schema for
121 validation. There are currently 2 transformati     98 validation. There are currently 2 transformations the tools perform.
122                                                    99 
123 The default for arrays in json-schema is they  !! 100 The default for arrays in json-schema is they are variable sized and allow more
124 entries than explicitly defined. This can be r    101 entries than explicitly defined. This can be restricted by defining 'minItems',
125 'maxItems', and 'additionalItems'. However, fo    102 'maxItems', and 'additionalItems'. However, for DeviceTree Schemas, a fixed
126 size is desired in most cases, so these proper    103 size is desired in most cases, so these properties are added based on the
127 number of entries in an 'items' list.             104 number of entries in an 'items' list.
128                                                   105 
129 The YAML Devicetree format also makes all stri    106 The YAML Devicetree format also makes all string values an array and scalar
130 values a matrix (in order to define groupings)    107 values a matrix (in order to define groupings) even when only a single value
131 is present. Single entries in schemas are fixe    108 is present. Single entries in schemas are fixed up to match this encoding.
132                                                   109 
133 Coding style                                   << 
134 ------------                                   << 
135                                                << 
136 Use YAML coding style (two-space indentation). << 
137 preferred is four-space indentation.           << 
138                                                << 
139 Testing                                           110 Testing
140 -------                                           111 -------
141                                                   112 
142 Dependencies                                      113 Dependencies
143 ~~~~~~~~~~~~                                      114 ~~~~~~~~~~~~
144                                                   115 
145 The DT schema project must be installed in ord    116 The DT schema project must be installed in order to validate the DT schema
146 binding documents and validate DTS files using    117 binding documents and validate DTS files using the DT schema. The DT schema
147 project can be installed with pip::               118 project can be installed with pip::
148                                                   119 
149     pip3 install dtschema                      !! 120     pip3 install git+https://github.com/devicetree-org/dt-schema.git@master
150                                                << 
151 Note that 'dtschema' installation requires 'sw << 
152 installed first. On Debian/Ubuntu systems::    << 
153                                                << 
154     apt install swig python3-dev               << 
155                                                   121 
156 Several executables (dt-doc-validate, dt-mk-sc    122 Several executables (dt-doc-validate, dt-mk-schema, dt-validate) will be
157 installed. Ensure they are in your PATH (~/.lo    123 installed. Ensure they are in your PATH (~/.local/bin by default).
158                                                   124 
159 Recommended is also to install yamllint (used  !! 125 dtc must also be built with YAML output support enabled. This requires that
                                                   >> 126 libyaml and its headers be installed on the host system. For some distributions
                                                   >> 127 that involves installing the development package, such as:
                                                   >> 128 
                                                   >> 129 Debian::
                                                   >> 130 
                                                   >> 131   apt-get install libyaml-dev
                                                   >> 132 
                                                   >> 133 Fedora::
                                                   >> 134 
                                                   >> 135   dnf -y install libyaml-devel
160                                                   136 
161 Running checks                                    137 Running checks
162 ~~~~~~~~~~~~~~                                    138 ~~~~~~~~~~~~~~
163                                                   139 
164 The DT schema binding documents must be valida    140 The DT schema binding documents must be validated using the meta-schema (the
165 schema for the schema) to ensure they are both    141 schema for the schema) to ensure they are both valid json-schema and valid
166 binding schema. All of the DT binding document    142 binding schema. All of the DT binding documents can be validated using the
167 ``dt_binding_check`` target::                     143 ``dt_binding_check`` target::
168                                                   144 
169     make dt_binding_check                         145     make dt_binding_check
170                                                   146 
171 In order to perform validation of DT source fi    147 In order to perform validation of DT source files, use the ``dtbs_check`` target::
172                                                   148 
173     make dtbs_check                               149     make dtbs_check
174                                                   150 
175 Note that ``dtbs_check`` will skip any binding    151 Note that ``dtbs_check`` will skip any binding schema files with errors. It is
176 necessary to use ``dt_binding_check`` to get a    152 necessary to use ``dt_binding_check`` to get all the validation errors in the
177 binding schema files.                             153 binding schema files.
178                                                   154 
179 It is possible to run both in a single command    155 It is possible to run both in a single command::
180                                                   156 
181     make dt_binding_check dtbs_check              157     make dt_binding_check dtbs_check
182                                                   158 
183 It is also possible to run checks with a subse !! 159 It is also possible to run checks with a single schema file by setting the
184 setting the ``DT_SCHEMA_FILES`` variable to 1  !! 160 ``DT_SCHEMA_FILES`` variable to a specific schema file.
185 patterns (partial match of a fixed string). Ea << 
186 separated by ':'.                              << 
187                                                   161 
188 ::                                                162 ::
189                                                   163 
190     make dt_binding_check DT_SCHEMA_FILES=triv !! 164     make dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/trivial-devices.yaml
191     make dt_binding_check DT_SCHEMA_FILES=triv !! 165     make dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/trivial-devices.yaml
192     make dt_binding_check DT_SCHEMA_FILES=/gpi << 
193     make dtbs_check DT_SCHEMA_FILES=trivial-de << 
194                                                   166 
195                                                   167 
196 json-schema Resources                             168 json-schema Resources
197 ---------------------                             169 ---------------------
198                                                   170 
199                                                   171 
200 `JSON-Schema Specifications <http://json-schem    172 `JSON-Schema Specifications <http://json-schema.org/>`_
201                                                   173 
202 `Using JSON Schema Book <http://usingjsonschem    174 `Using JSON Schema Book <http://usingjsonschema.com/>`_
203                                                   175 
204 .. _example-schema:                               176 .. _example-schema:
205                                                   177 
206 Annotated Example Schema                          178 Annotated Example Schema
207 ------------------------                          179 ------------------------
208                                                   180 
209 Also available as a separate file: :download:`    181 Also available as a separate file: :download:`example-schema.yaml`
210                                                   182 
211 .. literalinclude:: example-schema.yaml           183 .. literalinclude:: example-schema.yaml
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php