Skip to contentSkip to conversation

DT binding documents using text markup

RFC PATCH Superseded Matt Porter 8 participants 46 messages Aug 28, 2015 – Sep 22, 2015 21 messages not in the archive

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover DT binding documents using text markup

During the Device Tree microconference at Linux Plumbers 2015, we had a short discussion about how to improve DT Binding Documentation. A number of issues were raised (again, as these things have been discussed in the past) including:

* Inconsistency between binding documents due to prose text format.
* Inability to reliably machine read bindings for mass update or search.
* Bit rot of bindings as new conventions are agreed upon but only new bindings are changed.

Grant Likely probably summed up the issue best with "...as long as bindings are human readable, we'll have issues...". The context of that comment was, of course, regarding our current documents written in very inconsistent prose style. When the topic of needing the bindings in a rigid format was raised, there was general head nodding that this was needed. It was noted that this has been discussed many times before and nothing has been done.

My proposed solution to the problem is to convert all DT bindings a rigid text markup format. In choosing a text markup language my requirements were:

1) Human readable
2) Well documented
3) Easy to translate to other data formats
4) Well supported by tools and libraries

After looking at a number of markup options, YAML stood out as the one that meets all of these requirements. The YAML syntax is adopted in many projects specifically because of the high level of readability. A comprehensive spec is at http://www.yaml.org/spec/1.2/spec.html.
There's a number of tools to convert between YAML and other popular data formats such as JSON and XML. XML was cited by Behan Webster during the microconference as an important data format as the type of developers that may produce comprehensive DTS Binding validation tools will want to use XML. Every major scripting language has a high level binding to the low level libyaml C library to facilitate handling of YAML data files.

One caveat with YAML is it does not tolerate tabs. Yes, I said it. No tabs! This can be managed with proper editor modes and also with helper scripts to strip tabs to aid in people passing planned checkpatch.pl checks that would run YAML DT Binding specific tag validators for new bindings.

The scope of the initial YAML DT Binding format was specifically limited to supporting *only* the content we have in bindings today. The idea here is to propose and agree on something that will take us just a few steps in the right direction. If we move *all* current binding content to a machine parseable format, additional features can be added with more automation and scripting. As it stands today, because of the inconsistency of the wording of the files, we can't add a lot of new features to the content until we convert what we have today into a standard format.

With that said, it should be noted that some new features such as "type" tags to indicate cell types could be added to support additional DTS validation beyond what the current content supports. Another possibility is adding "range" type information to validate the legal values for a cell.

This series is broken up into three major parts:

1) The documentation defining the YAML DT binding format
2) A skeleton device binding example illustrating use of this format
3) Some real binding conversions (eeprom.txt, phy-bindings.txt, and ti-phy.txt

As a proof of concept of what can be done with a proper machine readable DT binding source file, there's a simple markdown document generator at https://github.com/konsulko/dtgendoc. Also, to see actual output from the generator, the generated markdown from those bindings is viewable at https://github.com/konsulko/dtgendoc/wiki

There's a lot of other possibilities for validation tools using only the data we have today in the bindings. In addition, Frank Rowand covered some DT debug techniques that would benefit from the binding documentation being 100% reliably searchable.

I found it useful to see a side-by-side view of a converted doc versus the original content, so here's a screenshot of eeprom.txt vs. eeprom.yaml:
https://github.com/konsulko/dtgendoc/wiki#eepromtxt-vs-eepromyaml

When we decide on a text markup format that is acceptable, then the next step is to convert all the bindings. That process would start with the complete set of generic bindings as they will be referenced by the actual device bindings.

If the RFC wasn't explicit enough...comments welcome.

-Matt

Matt Porter (5):
Documentation: dt-bindings: add documentation on new DT binding format
Documentation: dt-bindings: add example DT binding document
Documentation: dt-bindings: add YAML eeprom binding
Documentation: dt-bindings: phy: add YAML generic PHY binding
Documentation: dt-bindings: phy: add YAML TI PHY binding

 .../devicetree/bindings/dt-binding-format.txt      | 106 +++++++++++++
 Documentation/devicetree/bindings/eeprom.yaml      |  44 ++++++
 .../devicetree/bindings/phy/phy-bindings.yaml      |  89 +++++++++++
 Documentation/devicetree/bindings/phy/ti-phy.yaml  | 166 +++++++++++++++++++++
 Documentation/devicetree/bindings/skeleton.yaml    |  98 ++++++++++++
 5 files changed, 503 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dt-binding-format.txt
 create mode 100644 Documentation/devicetree/bindings/eeprom.yaml
 create mode 100644 Documentation/devicetree/bindings/phy/phy-bindings.yaml
 create mode 100644 Documentation/devicetree/bindings/phy/ti-phy.yaml
 create mode 100644 Documentation/devicetree/bindings/skeleton.yaml
Signature · 1 line
2.1.4

A message that is not in the archive (sent off-list or not yet received): 1440739433-6799-1-git-send-email-mporter-OWPKS81ov/FWk0Htik3J/[email protected]

#2 lore raw

RFC PATCH 1/5 Documentation: dt-bindings: add documentation on new DT binding format

Documentation explaining the syntax and format of the YAML-based DT binding documentation.

---
 .../devicetree/bindings/dt-binding-format.txt      | 106 +++++++++++++++++++++
 1 file changed, 106 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dt-binding-format.txt
Documentation/devicetree/bindings/dt-binding-format.txt new file +106 -0
new file mode 100644
index 0000000..f9acc22
@@ -0,0 +1,106 @@
+--------------------------
+Device Tree Binding Format
+--------------------------
+
+Background
+----------
+
+DT bindings historically were written as text in prose format which
+led to issues in usability of that source documentation. Some of
+these issues include the need to programmatically process binding
+source documentation to do DTS validation, perform mass updates to
+format/style, and to generate publishable documentation in HTML or
+PDF form.
+
+Overview
+--------
+
+The DT binding format is based on the YAML text markup language.
+Although there are many text markup options available, YAML
+fulfills all requirements considered for a DT binding source format
+which include:
+
+1) Must be human readable
+2) Must be easily translated to other data formats (XML, JSON, etc).
+3) Must have sufficient tools and libraries to enable developers to
+   build new tools for DT binding processing
+4) Must have a complete spec to refer to syntax
+
+YAML is documentated in the specification found at
+http://www.yaml.org/spec/1.2/spec.html
+
+The required YAML DT binding tag format and syntax are defined in
+the following sections.
+
+YAML DT Binding Syntax
+----------------------
+
+* Lines starting with "#" are comments and not part of the binding itself
+* "%YAML 1.2" starts a file, indicating the version of YAML in use
+* "---" starts a binding document
+* "..." ends a binding document
+* Multiple binding documents may exist in a single file
+* Tabs are not permitted
+* Scope is denoted by indentation of two spaces
+* Key value pairs are denoted by "key: value"
+* Sequences are denoted by "- "
+* Scalar values may convert newlines to spaces and preserve blank
+  lines for long description formatting using ">"
+* Scalar values may escape all reserved characters and preserve
+  newlines by using "|" to denote literal style
+
+For additional information on YAML syntax, refer to the specification
+at http://www.yaml.org/spec/1.2/spec.html
+
+YAML DT Binding Format
+----------------------
+
+The following YAML types are supported in the DT binding format:
+
+* [R] id: unique identifier in property form (e.g. skel-device)
+
+* [R] title: title of the binding
+
+* [O] maintainer: sequence of maintainers
+      [R] name: name and email of maintainer or mailing list in RFC822
+                form.
+
+* [O] description: full description of the binding
+
+* [O] compatible: sequence of valid compatible descriptors
+      [R] name: the compatible string surrounded in double quotes
+      [O] deprecated: a deprecated compatible string surrounded in
+                      double quotes
+      [O] description: description of the compatible string
+
+* [O] required: sequence of required properties:
+      [R] name: name of the property surrounded in double quotes
+      [R] description: description of the property
+      [O] reference: optional reference to a binding id
+
+* [O] optional: sequence of optional properties:
+      [R] name: name of the property surrounded in double quotes
+      [R] description: description of the property
+      [O] reference: optional reference to a binding id
+
+* [O] deprecated: sequence of deprecated properties:
+      [R] name: name of the property surrounded in double quotes
+      [R] description: description of the property
+      [O] reference: optional reference to a binding id
+
+* [R] example: sequence of examples:
+      [R] dts: DT source of example usage. The example text must use
+               literal style ("|") so that it retains indentation and
+               newlines.
+      [O] description: description of the example
+
+Note: [R] and [O] denote required and optional fields, respectively.
+
+Skeleton Binding
+----------------
+
+The skeleton.yaml binding found in the top of the DT binding tree
+is the canonical example of syntax and format to use when writing
+a DT binding document. It is maintained with the latest formatting
+conventions, making it the best starting point when writing a new DT
+binding.
Signature · 1 line
2.1.4

A message that is not in the archive (sent off-list or not yet received): 1440739433-6799-2-git-send-email-mporter-OWPKS81ov/FWk0Htik3J/[email protected]

#4 lore raw

Re: [RFC PATCH 1/5] Documentation: dt-bindings: add documentation on new DT binding format

Quoted 94 lines · Matt Porter

Documentation explaining the syntax and format of the YAML-based DT binding documentation.

---
 .../devicetree/bindings/dt-binding-format.txt      | 106 +++++++++++++++++++++
 1 file changed, 106 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dt-binding-format.txt
Documentation/devicetree/bindings/dt-binding-format.txt new file +79 -0
new file mode 100644
index 0000000..f9acc22
@@ -0,0 +1,106 @@
+--------------------------
+Device Tree Binding Format
+--------------------------
+
+Background
+----------
+
+DT bindings historically were written as text in prose format which
+led to issues in usability of that source documentation. Some of
+these issues include the need to programmatically process binding
+source documentation to do DTS validation, perform mass updates to
+format/style, and to generate publishable documentation in HTML or
+PDF form.
+
+Overview
+--------
+
+The DT binding format is based on the YAML text markup language.
+Although there are many text markup options available, YAML
+fulfills all requirements considered for a DT binding source format
+which include:
+
+1) Must be human readable
+2) Must be easily translated to other data formats (XML, JSON, etc).
+3) Must have sufficient tools and libraries to enable developers to
+   build new tools for DT binding processing
+4) Must have a complete spec to refer to syntax
+
+YAML is documentated in the specification found at
+http://www.yaml.org/spec/1.2/spec.html
+
+The required YAML DT binding tag format and syntax are defined in
+the following sections.
+
+YAML DT Binding Syntax
+----------------------
+
+* Lines starting with "#" are comments and not part of the binding itself
+* "%YAML 1.2" starts a file, indicating the version of YAML in use
+* "---" starts a binding document
+* "..." ends a binding document
+* Multiple binding documents may exist in a single file
+* Tabs are not permitted
+* Scope is denoted by indentation of two spaces
+* Key value pairs are denoted by "key: value"
+* Sequences are denoted by "- "
+* Scalar values may convert newlines to spaces and preserve blank
+  lines for long description formatting using ">"
+* Scalar values may escape all reserved characters and preserve
+  newlines by using "|" to denote literal style
+
+For additional information on YAML syntax, refer to the specification
+at http://www.yaml.org/spec/1.2/spec.html
+
+YAML DT Binding Format
+----------------------
+
+The following YAML types are supported in the DT binding format:
+
+* [R] id: unique identifier in property form (e.g. skel-device)
+
+* [R] title: title of the binding
+
+* [O] maintainer: sequence of maintainers
+      [R] name: name and email of maintainer or mailing list in RFC822
+                form.
+
+* [O] description: full description of the binding
+
+* [O] compatible: sequence of valid compatible descriptors
+      [R] name: the compatible string surrounded in double quotes
+      [O] deprecated: a deprecated compatible string surrounded in
+                      double quotes
+      [O] description: description of the compatible string
+
+* [O] required: sequence of required properties:
+      [R] name: name of the property surrounded in double quotes
+      [R] description: description of the property
+      [O] reference: optional reference to a binding id

Documentation/devicetree/bindings/dt-binding-format.txt line 89

Quoted 10 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +10 -0
+
+* [O] optional: sequence of optional properties:
+      [R] name: name of the property surrounded in double quotes
+      [R] description: description of the property
+      [O] reference: optional reference to a binding id
+
+* [O] deprecated: sequence of deprecated properties:
+      [R] name: name of the property surrounded in double quotes
+      [R] description: description of the property
+      [O] reference: optional reference to a binding id

I commented in reply to patch 0 that we should think through how this structure will support adding new features as the next step after converting existing bindings.

The specific case I started thinking about was the distinction between required, optional, required-if, and optional-if. A property might be required in all cases, optional in all cases, required in some specified cases, and/or optional in some specified cases. So a property could be both "required-if" and "optional-if". Or it might just be one of the two.

Here is where my YAML ignorance jumps out. I really do not know the best way to approach it. And I do not know if the syntax I am using is even remotely correct - I am trying to extrapolate from the examples in the spec, without having read past the examples yet. My naive knee jerk alternatives where (by example, because I can explain it more concisely that way instead of the way it should be described in this file):

---- (1)

required:
- &P1
name: "prop1"
required-if: < some condition >

optional:
- *P1
optional-if: < some other condition>
- name: "prop2"
required: true
- name: "prop3"
optional: true

---- (2)

property:
- name: "prop1"
required-if: < some condition >
optional-if: < some other condition >
- name: "prop2"
required: true
- name: "prop3"
optional: true

In a related question, I commented in my reply to patch 0 that some of the information about the compatible got lost in the conversion from the existing binding to the YAML format. That led me to wonder why the compatible property should be at the YAML top level (same as "optional" and "required"). My (again naive, YAML amateur) thought is that the form should be something like:

[O] property:
[R] optional: | required: | required-if: | optional-if: | required-if: optional-if:
[O] deprecated: a deprecated compatible string surrounded in
double quotes | ???
[R] name: name of the property surrounded in double quotes
[R] description: description of the property
[O] reference: optional reference to a binding id

Apologies for bizarre format for "optional:", but for the purposes of this comment, hopefully my intent will be clear.

Then "compatible" becomes just another "property:", just as it is in the .dts, but any processing or analysis tool knows that the name "compatible" is used in a very specific way and has magical meaning for .dts.

Then if compatible is just another "property:" then the information that lost was in the conversion process would not be lost, it would appear in "description:".

Quoted 7 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +7 -0
+
+* [R] example: sequence of examples:
+      [R] dts: DT source of example usage. The example text must use
+               literal style ("|") so that it retains indentation and
+               newlines.
+      [O] description: description of the example
+

Documentation/devicetree/bindings/dt-binding-format.txt line 106

Quoted 10 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +10 -0
+Note: [R] and [O] denote required and optional fields, respectively.
+
+Skeleton Binding
+----------------
+
+The skeleton.yaml binding found in the top of the DT binding tree
+is the canonical example of syntax and format to use when writing
+a DT binding document. It is maintained with the latest formatting
+conventions, making it the best starting point when writing a new DT
+binding.

It would be good to have a comment of YAML style. Looking at the spec, there appear to be multiple ways to format content that is functionally equivalent. For example:

   # a flow sequence
   - [name        , hr, avg  ]
   - [Mark McGwire, 65, 0.278]
   - [Sammy Sosa  , 63, 0.288]

vs.

   # a flow mapping
   Mark McGwire: {hr: 65, avg: 0.278}
   Sammy Sosa: {
       hr: 63,
       avg: 0.288
     }

This is my first quick reading of the YAML spec, so maybe a flow sequence and a flow mapping are not equivalent, but that was my naive impression.

I think that in the interest of human readability (requirement 1), that a specific formatting style should be specified. That will make life easier for people who do not know YAML, but are (1) merely copying from existing binding docs to create new ones, or (2) trying to understand how different bindings differ.

-Frank

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

Re: [RFC PATCH 1/5] Documentation: dt-bindings: add documentation on new DT binding format

Quoted 110 lines · Frank Rowand
Quoted 94 lines · Matt Porter

Documentation explaining the syntax and format of the YAML-based DT binding documentation.

---
 .../devicetree/bindings/dt-binding-format.txt      | 106 +++++++++++++++++++++
 1 file changed, 106 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dt-binding-format.txt
Documentation/devicetree/bindings/dt-binding-format.txt new file +79 -0
new file mode 100644
index 0000000..f9acc22
@@ -0,0 +1,106 @@
+--------------------------
+Device Tree Binding Format
+--------------------------
+
+Background
+----------
+
+DT bindings historically were written as text in prose format which
+led to issues in usability of that source documentation. Some of
+these issues include the need to programmatically process binding
+source documentation to do DTS validation, perform mass updates to
+format/style, and to generate publishable documentation in HTML or
+PDF form.
+
+Overview
+--------
+
+The DT binding format is based on the YAML text markup language.
+Although there are many text markup options available, YAML
+fulfills all requirements considered for a DT binding source format
+which include:
+
+1) Must be human readable
+2) Must be easily translated to other data formats (XML, JSON, etc).
+3) Must have sufficient tools and libraries to enable developers to
+   build new tools for DT binding processing
+4) Must have a complete spec to refer to syntax
+
+YAML is documentated in the specification found at
+http://www.yaml.org/spec/1.2/spec.html
+
+The required YAML DT binding tag format and syntax are defined in
+the following sections.
+
+YAML DT Binding Syntax
+----------------------
+
+* Lines starting with "#" are comments and not part of the binding itself
+* "%YAML 1.2" starts a file, indicating the version of YAML in use
+* "---" starts a binding document
+* "..." ends a binding document
+* Multiple binding documents may exist in a single file
+* Tabs are not permitted
+* Scope is denoted by indentation of two spaces
+* Key value pairs are denoted by "key: value"
+* Sequences are denoted by "- "
+* Scalar values may convert newlines to spaces and preserve blank
+  lines for long description formatting using ">"
+* Scalar values may escape all reserved characters and preserve
+  newlines by using "|" to denote literal style
+
+For additional information on YAML syntax, refer to the specification
+at http://www.yaml.org/spec/1.2/spec.html
+
+YAML DT Binding Format
+----------------------
+
+The following YAML types are supported in the DT binding format:
+
+* [R] id: unique identifier in property form (e.g. skel-device)
+
+* [R] title: title of the binding
+
+* [O] maintainer: sequence of maintainers
+      [R] name: name and email of maintainer or mailing list in RFC822
+                form.
+
+* [O] description: full description of the binding
+
+* [O] compatible: sequence of valid compatible descriptors
+      [R] name: the compatible string surrounded in double quotes
+      [O] deprecated: a deprecated compatible string surrounded in
+                      double quotes
+      [O] description: description of the compatible string
+
+* [O] required: sequence of required properties:
+      [R] name: name of the property surrounded in double quotes
+      [R] description: description of the property
+      [O] reference: optional reference to a binding id

Documentation/devicetree/bindings/dt-binding-format.txt line 89

Quoted 10 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +10 -0
+
+* [O] optional: sequence of optional properties:
+      [R] name: name of the property surrounded in double quotes
+      [R] description: description of the property
+      [O] reference: optional reference to a binding id
+
+* [O] deprecated: sequence of deprecated properties:
+      [R] name: name of the property surrounded in double quotes
+      [R] description: description of the property
+      [O] reference: optional reference to a binding id

I commented in reply to patch 0 that we should think through how this structure will support adding new features as the next step after converting existing bindings.

Quoted 6 lines

The specific case I started thinking about was the distinction between required, optional, required-if, and optional-if. A property might be required in all cases, optional in all cases, required in some specified cases, and/or optional in some specified cases. So a property could be both "required-if" and "optional-if". Or it might just be one of the two.

Ok, so this is similar to the issue Rob points out about AND and ORs of compatible strings.

Quoted 6 lines

Here is where my YAML ignorance jumps out. I really do not know the best way to approach it. And I do not know if the syntax I am using is even remotely correct - I am trying to extrapolate from the examples in the spec, without having read past the examples yet. My naive knee jerk alternatives where (by example, because I can explain it more concisely that way instead of the way it should be described in this file):

I will confess that I'm not an expert either so we can learn together. :)

Quoted 8 lines

---- (1)

required:
- &P1
name: "prop1"
required-if: < some condition >

Quoted 8 lines

optional:
- *P1
optional-if: < some other condition>
- name: "prop2"
required: true
- name: "prop3"
optional: true

Couple concerns here. First, we have to consider properties being inherited from a generic binding rather than repeating them in a peripheral binding. The conditions in which a generic property may be required can be different in a child peripheral binding. So you may have a property inhereit that is optional in the generic binding, but is required in a particular child peripheral binding.

Now, having said that, if we make use of the anchor/alias syntax as above, now we have to have unique anchor names across all generic bindings. Further, we have this issue of yaml parsers not having the ability now to directly include other files. Certainly we could make a wrapper to pull in each referenced generic binding into a single yaml document to be run through the parser.

The second thing is that in the example above we still have the required-if tag populated within the optional section which is not ideal.

Quoted 10 lines

---- (2)

property:
- name: "prop1"
required-if: < some condition >
optional-if: < some other condition >
- name: "prop2"
required: true
- name: "prop3"
optional: true

This looks better to me. If coupled with the C like constraint expressions it should work well for most cases.

I'm thinking of the resource-names.txt common case such as:

property:
- name: "reg"
required-if: iface(mmio)
- name "reg-names"
required-if: prop(reg)

Keep in mind I'm not sure yet what we'll allow in these conditional statements. I just believe that we'll want the same syntax for constraints and property conditionals

Quoted 9 lines

In a related question, I commented in my reply to patch 0 that some of the information about the compatible got lost in the conversion from the existing binding to the YAML format. That led me to wonder why the compatible property should be at the YAML top level (same as "optional" and "required"). My (again naive, YAML amateur) thought is that the form should be something like:

Quoted 7 lines

[O] property:
[R] optional: | required: | required-if: | optional-if: | required-if: optional-if:
[O] deprecated: a deprecated compatible string surrounded in
double quotes | ???
[R] name: name of the property surrounded in double quotes
[R] description: description of the property
[O] reference: optional reference to a binding id

TBH, compatible started getting treated separately from other properties simply because of my initial take on readability in the yaml source. There's technically no reason it can't be folded back in as yet another property as above. However, we need a way to show ands and ors for compatibles in a sane manner. Consider a device where the generic compatible string from the original part in the family is gendev1001 and subsequent family members requiring tweaks exist.

property:
- name: "foo,gendev1001"
required: true
- name: "foo,gendev1005"
required-or: true
- name: "foo,gendev1006"
required-or: true
- name: "foo,gendev1007"
required-or: true

Not sure here, but that's one way to do it with the keys driving it versus a conditional expression.

or

property:
- name: "foo,gendev1001"
required: true
- name: "foo,gendev1005" || "foo,gendev1006" || "foo,gendev1007"

    required-if: !"foo,gendev1001"

which seems to look a lot better to me. A not-yet-existing-smart-validator would check that a dts had:

compatible = "foo,gendev100[5|6|7]", "foo,gendev1001"

or simply

compatible = "foo,gendev1001"

Quoted 10 lines

Apologies for bizarre format for "optional:", but for the purposes of this comment, hopefully my intent will be clear.

Then "compatible" becomes just another "property:", just as it is in the .dts, but any processing or analysis tool knows that the name "compatible" is used in a very specific way and has magical meaning for .dts.

Then if compatible is just another "property:" then the information that lost was in the conversion process would not be lost, it would appear in "description:".

Sounds good.

Quoted 38 lines
Quoted 9 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +7 -0
+
+* [R] example: sequence of examples:
+      [R] dts: DT source of example usage. The example text must use
+               literal style ("|") so that it retains indentation and
+               newlines.
+      [O] description: description of the example
+

Documentation/devicetree/bindings/dt-binding-format.txt line 106

Quoted 10 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +10 -0
+Note: [R] and [O] denote required and optional fields, respectively.
+
+Skeleton Binding
+----------------
+
+The skeleton.yaml binding found in the top of the DT binding tree
+is the canonical example of syntax and format to use when writing
+a DT binding document. It is maintained with the latest formatting
+conventions, making it the best starting point when writing a new DT
+binding.

It would be good to have a comment of YAML style. Looking at the spec, there appear to be multiple ways to format content that is functionally equivalent. For example:

   # a flow sequence
   - [name        , hr, avg  ]
   - [Mark McGwire, 65, 0.278]
   - [Sammy Sosa  , 63, 0.288]

vs.

   # a flow mapping
   Mark McGwire: {hr: 65, avg: 0.278}
   Sammy Sosa: {
       hr: 63,
       avg: 0.288
     }
Quoted 2 lines

This is my first quick reading of the YAML spec, so maybe a flow sequence and a flow mapping are not equivalent, but that was my naive impression.

The examples section in the intro is incomplete and glosses over some stuff such that it's expected to get confused by this part. I got lost there at first as well.

The quick summary is that YAML allows either Flow Style or Block Style of describing nodes. The two example above use flow style as described in Chapter 7 to show a sequence construct and separately a mapping construct. I chose to use block style through the proposed YAML dt binding format as it's my personal preference for human readability. Compare, for example, the format of doing sequences in flow style (section 7.4.1) versus block style (section 8.2.1) and you'll see that I'm making heavy use of block style sequences throughout this format.

Quoted 5 lines

I think that in the interest of human readability (requirement 1), that a specific formatting style should be specified. That will make life easier for people who do not know YAML, but are (1) merely copying from existing binding docs to create new ones, or (2) trying to understand how different bindings differ.

Agreed. I'll explicitly mention that we use block style formatting now. Also, David asked that we explicitly mention the YAML schema used (which is the default core schema that also parsers have to implement).

-Matt

#7 lore raw

Re: [RFC PATCH 1/5] Documentation: dt-bindings: add documentation on new DT binding format

In reply to a message not in the archive
Quoted 44 lines · Matt Porter

Documentation explaining the syntax and format of the YAML-based DT binding documentation.

---
 .../devicetree/bindings/dt-binding-format.txt      | 106 +++++++++++++++++++++
 1 file changed, 106 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dt-binding-format.txt
Documentation/devicetree/bindings/dt-binding-format.txt new file +29 -0
new file mode 100644
index 0000000..f9acc22
@@ -0,0 +1,106 @@
+--------------------------
+Device Tree Binding Format
+--------------------------
+
+Background
+----------
+
+DT bindings historically were written as text in prose format which
+led to issues in usability of that source documentation. Some of
+these issues include the need to programmatically process binding
+source documentation to do DTS validation, perform mass updates to
+format/style, and to generate publishable documentation in HTML or
+PDF form.
+
+Overview
+--------
+
+The DT binding format is based on the YAML text markup language.
+Although there are many text markup options available, YAML
+fulfills all requirements considered for a DT binding source format
+which include:
+
+1) Must be human readable
+2) Must be easily translated to other data formats (XML, JSON, etc).
+3) Must have sufficient tools and libraries to enable developers to
+   build new tools for DT binding processing
+4) Must have a complete spec to refer to syntax
+
+YAML is documentated in the specification found at

Documentation/devicetree/bindings/dt-binding-format.txt line 39

Quoted 10 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +10 -0
+http://www.yaml.org/spec/1.2/spec.html
+
+The required YAML DT binding tag format and syntax are defined in
+the following sections.
+
+YAML DT Binding Syntax
+----------------------
+
+* Lines starting with "#" are comments and not part of the binding itself
+* "%YAML 1.2" starts a file, indicating the version of YAML in use

I think it would be good to specify a DT Binding Format version as well. I would expect we may expand the syntax, or we may alter it, so it would be good to have a number for our specific syntax. This would help in some circumstances, if we make multiple passes over the documents to achieve our conversion. Maybe this should be added below.

Quoted 10 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +10 -0
+* "---" starts a binding document
+* "..." ends a binding document
+* Multiple binding documents may exist in a single file
+* Tabs are not permitted
+* Scope is denoted by indentation of two spaces
+* Key value pairs are denoted by "key: value"
+* Sequences are denoted by "- "
+* Scalar values may convert newlines to spaces and preserve blank
+  lines for long description formatting using ">"
+* Scalar values may escape all reserved characters and preserve

Documentation/devicetree/bindings/dt-binding-format.txt line 59

Quoted 10 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +10 -0
+  newlines by using "|" to denote literal style
+
+For additional information on YAML syntax, refer to the specification
+at http://www.yaml.org/spec/1.2/spec.html
+
+YAML DT Binding Format
+----------------------
+
+The following YAML types are supported in the DT binding format:
+

Based on my comment above, I recommend:
[R] binding-format: 1

Quoted 5 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +5 -0
+* [R] id: unique identifier in property form (e.g. skel-device)
+
+* [R] title: title of the binding
+
+* [O] maintainer: sequence of maintainers

Documentation/devicetree/bindings/dt-binding-format.txt line 74

Quoted 10 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +10 -0
+      [R] name: name and email of maintainer or mailing list in RFC822
+                form.
+
+* [O] description: full description of the binding
+
+* [O] compatible: sequence of valid compatible descriptors
+      [R] name: the compatible string surrounded in double quotes
+      [O] deprecated: a deprecated compatible string surrounded in
+                      double quotes
+      [O] description: description of the compatible string

compatible is a property like all the others, and I think it's confusing to have it in a separate section. For example, when listing other properties, the "name:" field specifies the property name, but for the compatible section the "name:" field specifies the possible values for the compatible property. This is (at least to me) quite confusing.

Can we make this a regular property, with an option 'deprecated' attribute. I guess we may need to distinguish between deprecated properties and deprecated vales of properties.
The above 'deprecated' specifies deprecated values for the compatible property, while
the section below specifies deprecated properties. I don't see a way to indicate a deprecated
value for a still-existing property, but that may be too much detail for now.

Documentation/devicetree/bindings/dt-binding-format.txt line 79

Quoted 4 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +4 -0
+* [O] required: sequence of required properties:
+      [R] name: name of the property surrounded in double quotes
+      [R] description: description of the property
+      [O] reference: optional reference to a binding id

I would recommend we add types and value constraints to the binding schema:

[O] type: type of value for this property, and if specified must be one of the following (without quotes):
"string", "number", "array", "phandle"
[O] value constraint: specifies a limit on the value for a property. This can be specified as English text, or be a range or choice constraint. The latter two should be expressed with the following exact english phrases (without quotes):
"must be in the range x to y, inclusive"
where x and y are numbers
"must be one of <choice 1>, <choice 2>, ..."
where <choice x> is a string, which should be quoted
if it includes a comma.

Any other constraint is expressed in free-form English text

I would recommend adding these to this binding schema doc, but not requiring them on the first conversion pass of the docs.

Basically my idea is that you want the each pass over the binding documents to be as painless as possible. Every time a user encounters something they're not sure about, it will slow them down. There will be lots of ambiguous situations, and we want the process to be as lossless as possible, so I would recommend a strategy of doing as much as people can, and if in doubt just put any outstanding text in the descriptions. The descriptions will always be free-form text, and we can come along later and convert these to types, constraints, as we see fit.

Quoted 6 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +6 -0
+* [O] optional: sequence of optional properties:
+      [R] name: name of the property surrounded in double quotes
+      [R] description: description of the property
+      [O] reference: optional reference to a binding id
+
+* [O] deprecated: sequence of deprecated properties:

Documentation/devicetree/bindings/dt-binding-format.txt line 96

Quoted 10 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +10 -0
+      [R] name: name of the property surrounded in double quotes
+      [R] description: description of the property
+      [O] reference: optional reference to a binding id
+
+* [R] example: sequence of examples:
+      [R] dts: DT source of example usage. The example text must use
+               literal style ("|") so that it retains indentation and
+               newlines.
+      [O] description: description of the example
+

I'd recommend having a top-level notes section:
* [O] note: any other notes about this node that are not covered by preceding property descriptions.

Documentation/devicetree/bindings/dt-binding-format.txt line 97

Quoted 1 line
Documentation/devicetree/bindings/dt-binding-format.txt new file +1 -0
+Note: [R] and [O] denote required and optional fields, respectively.

I'd put this note before the format description.

-- Tim

Quoted 10 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +9 -1
+
+Skeleton Binding
+----------------
+
+The skeleton.yaml binding found in the top of the DT binding tree
+is the canonical example of syntax and format to use when writing
+a DT binding document. It is maintained with the latest formatting
+conventions, making it the best starting point when writing a new DT
+binding.
--

A message that is not in the archive (sent off-list or not yet received): CA+bK7J76Z6H4gh-UXxMWqUYrdRx1GYKFkAAtDUszpT_8k=RCQw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#9 lore raw

Re: [RFC PATCH 1/5] Documentation: dt-bindings: add documentation on new DT binding format

Quoted 54 lines · Tim Bird
Quoted 53 lines · Matt Porter

Documentation explaining the syntax and format of the YAML-based DT binding documentation.

---
 .../devicetree/bindings/dt-binding-format.txt      | 106 +++++++++++++++++++++
 1 file changed, 106 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dt-binding-format.txt
Documentation/devicetree/bindings/dt-binding-format.txt new file +38 -0
new file mode 100644
index 0000000..f9acc22
@@ -0,0 +1,106 @@
+--------------------------
+Device Tree Binding Format
+--------------------------
+
+Background
+----------
+
+DT bindings historically were written as text in prose format which
+led to issues in usability of that source documentation. Some of
+these issues include the need to programmatically process binding
+source documentation to do DTS validation, perform mass updates to
+format/style, and to generate publishable documentation in HTML or
+PDF form.
+
+Overview
+--------
+
+The DT binding format is based on the YAML text markup language.
+Although there are many text markup options available, YAML
+fulfills all requirements considered for a DT binding source format
+which include:
+
+1) Must be human readable
+2) Must be easily translated to other data formats (XML, JSON, etc).
+3) Must have sufficient tools and libraries to enable developers to
+   build new tools for DT binding processing
+4) Must have a complete spec to refer to syntax
+
+YAML is documentated in the specification found at
+http://www.yaml.org/spec/1.2/spec.html
+
+The required YAML DT binding tag format and syntax are defined in
+the following sections.
+
+YAML DT Binding Syntax
+----------------------
+
+* Lines starting with "#" are comments and not part of the binding itself
Quoted 8 lines

Documentation/devicetree/bindings/dt-binding-format.txt line 39

Quoted 1 line
Documentation/devicetree/bindings/dt-binding-format.txt new file +1 -0
+* "%YAML 1.2" starts a file, indicating the version of YAML in use

I think it would be good to specify a DT Binding Format version as well. I would expect we may expand the syntax, or we may alter it, so it would be good to have a number for our specific syntax. This would help in some circumstances, if we make multiple passes over the documents to achieve our conversion. Maybe this should be added below.

Good point. In fact, I think it's absolutely essential that we include that. This is a complicated business and we're bound to make mistakes in the binding definition format - a version number gives us a way to fix them without requiring changing all the existing bindings at once.

[snip]

Quoted 12 lines

Documentation/devicetree/bindings/dt-binding-format.txt line 74

Quoted 5 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +5 -0
+* [O] compatible: sequence of valid compatible descriptors
+      [R] name: the compatible string surrounded in double quotes
+      [O] deprecated: a deprecated compatible string surrounded in
+                      double quotes
+      [O] description: description of the compatible string

compatible is a property like all the others, and I think it's confusing to have it in a separate section. For example, when listing other properties, the "name:" field specifies the property name, but for the compatible section the "name:" field specifies the possible values for the compatible property. This is (at least to me) quite confusing.

Quoted 8 lines

Can we make this a regular property, with an option 'deprecated' attribute. I guess we may need to distinguish between deprecated properties and deprecated vales of properties.
The above 'deprecated' specifies deprecated values for the compatible property, while
the section below specifies deprecated properties. I don't see a way to indicate a deprecated
value for a still-existing property, but that may be too much detail for now.

So, I think folding compatible in with the rest is a mistake. There are two important distinctions between compatible and the other property descriptions:

1) (See my other post for context) The most important is that compatible is the "key" for the binding. It's what lets you know the binding is in play, rather than just saying what the requirements are once you know it's a relevant binding.

2) The condition we're typically listing for compatible is that it must contain the given compatible string - it's valid and common to also have additional compatible strings (e.g. for the future, backwards-compatible revision of this device). For most other properties we're describing the *whole* value it should have.

Eventually I think we'll want a general way of expressing such "equals" versus "contains" conditions, but that's a pretty hard problem, so for the first cut I think it's reasonable to special case 'compatible'.

Incidentally, note that it would also be quite common for 'compatible' to appear in *both* the "key" and the requirements. e.g. the binding for "foo,bardev-revision-b" could require that compatible also list "foo,bardev-revision-a" if it's backwards compatible.

Quoted 11 lines

Documentation/devicetree/bindings/dt-binding-format.txt line 79

Quoted 4 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +4 -0
+* [O] required: sequence of required properties:
+      [R] name: name of the property surrounded in double quotes
+      [R] description: description of the property
+      [O] reference: optional reference to a binding id

I would recommend we add types and value constraints to the binding schema:

[O] type: type of value for this property, and if specified must be one of the following (without quotes):
"string", "number", "array", "phandle"

It might be worth re-using the type names used in old OF documents here. Although "prop-encoded-array" tends to cover an awful lot there.

Quoted 11 lines

[O] value constraint: specifies a limit on the value for a property. This can be specified as English text, or be a range or choice constraint. The latter two should be expressed with the following exact english phrases (without quotes):
"must be in the range x to y, inclusive"
where x and y are numbers
"must be one of <choice 1>, <choice 2>, ..."
where <choice x> is a string, which should be quoted
if it includes a comma.

Any other constraint is expressed in free-form English text

Requiring exact english phrases when we're already have a flexible encoding scheme with YAML is pretty horrid.

I'd suggest instead that English constraints just go in the description. We can add new fields for specific types of machine verifiable constraints as we implement them (e.g. "max", "min", "allowed-values").

Quoted 25 lines

I would recommend adding these to this binding schema doc, but not requiring them on the first conversion pass of the docs.

Basically my idea is that you want the each pass over the binding documents to be as painless as possible. Every time a user encounters something they're not sure about, it will slow them down. There will be lots of ambiguous situations, and we want the process to be as lossless as possible, so I would recommend a strategy of doing as much as people can, and if in doubt just put any outstanding text in the descriptions. The descriptions will always be free-form text, and we can come along later and convert these to types, constraints, as we see fit.

Quoted 12 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +12 -0
+* [O] optional: sequence of optional properties:
+      [R] name: name of the property surrounded in double quotes
+      [R] description: description of the property
+      [O] reference: optional reference to a binding id
+
+* [O] deprecated: sequence of deprecated properties:
+      [R] name: name of the property surrounded in double quotes
+      [R] description: description of the property
+      [O] reference: optional reference to a binding id
+
+* [R] example: sequence of examples:
+      [R] dts: DT source of example usage. The example text must use
Quoted 8 lines

Documentation/devicetree/bindings/dt-binding-format.txt line 96

Quoted 4 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +4 -0
+               literal style ("|") so that it retains indentation and
+               newlines.
+      [O] description: description of the example
+

I'd recommend having a top-level notes section:
* [O] note: any other notes about this node that are not covered by preceding property descriptions.

Good call. Although I'd suggest "description" to match the name used elsewhere.

Quoted 16 lines

Documentation/devicetree/bindings/dt-binding-format.txt line 97

Quoted 1 line
Documentation/devicetree/bindings/dt-binding-format.txt new file +1 -0
+Note: [R] and [O] denote required and optional fields, respectively.

I'd put this note before the format description.

-- Tim

Quoted 10 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +9 -1
+
+Skeleton Binding
+----------------
+
+The skeleton.yaml binding found in the top of the DT binding tree
+is the canonical example of syntax and format to use when writing
+a DT binding document. It is maintained with the latest formatting
+conventions, making it the best starting point when writing a new DT
+binding.
--
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#10 lore raw

Re: [RFC PATCH 1/5] Documentation: dt-bindings: add documentation on new DT binding format

In reply to a message not in the archive
Quoted 54 lines · Tim Bird
Quoted 53 lines · Matt Porter

Documentation explaining the syntax and format of the YAML-based DT binding documentation.

---
 .../devicetree/bindings/dt-binding-format.txt      | 106 +++++++++++++++++++++
 1 file changed, 106 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dt-binding-format.txt
Documentation/devicetree/bindings/dt-binding-format.txt new file +38 -0
new file mode 100644
index 0000000..f9acc22
@@ -0,0 +1,106 @@
+--------------------------
+Device Tree Binding Format
+--------------------------
+
+Background
+----------
+
+DT bindings historically were written as text in prose format which
+led to issues in usability of that source documentation. Some of
+these issues include the need to programmatically process binding
+source documentation to do DTS validation, perform mass updates to
+format/style, and to generate publishable documentation in HTML or
+PDF form.
+
+Overview
+--------
+
+The DT binding format is based on the YAML text markup language.
+Although there are many text markup options available, YAML
+fulfills all requirements considered for a DT binding source format
+which include:
+
+1) Must be human readable
+2) Must be easily translated to other data formats (XML, JSON, etc).
+3) Must have sufficient tools and libraries to enable developers to
+   build new tools for DT binding processing
+4) Must have a complete spec to refer to syntax
+
+YAML is documentated in the specification found at
+http://www.yaml.org/spec/1.2/spec.html
+
+The required YAML DT binding tag format and syntax are defined in
+the following sections.
+
+YAML DT Binding Syntax
+----------------------
+
+* Lines starting with "#" are comments and not part of the binding itself
Quoted 8 lines

Documentation/devicetree/bindings/dt-binding-format.txt line 39

Quoted 1 line
Documentation/devicetree/bindings/dt-binding-format.txt new file +1 -0
+* "%YAML 1.2" starts a file, indicating the version of YAML in use

I think it would be good to specify a DT Binding Format version as well. I would expect we may expand the syntax, or we may alter it, so it would be good to have a number for our specific syntax. This would help in some circumstances, if we make multiple passes over the documents to achieve our conversion. Maybe this should be added below.

Added this in v2, thanks.

Quoted 47 lines
Quoted 11 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +10 -0
+* "---" starts a binding document
+* "..." ends a binding document
+* Multiple binding documents may exist in a single file
+* Tabs are not permitted
+* Scope is denoted by indentation of two spaces
+* Key value pairs are denoted by "key: value"
+* Sequences are denoted by "- "
+* Scalar values may convert newlines to spaces and preserve blank
+  lines for long description formatting using ">"
+* Scalar values may escape all reserved characters and preserve

Documentation/devicetree/bindings/dt-binding-format.txt line 59

Quoted 10 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +10 -0
+  newlines by using "|" to denote literal style
+
+For additional information on YAML syntax, refer to the specification
+at http://www.yaml.org/spec/1.2/spec.html
+
+YAML DT Binding Format
+----------------------
+
+The following YAML types are supported in the DT binding format:
+

Based on my comment above, I recommend:
[R] binding-format: 1

Quoted 5 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +5 -0
+* [R] id: unique identifier in property form (e.g. skel-device)
+
+* [R] title: title of the binding
+
+* [O] maintainer: sequence of maintainers

Documentation/devicetree/bindings/dt-binding-format.txt line 74

Quoted 10 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +10 -0
+      [R] name: name and email of maintainer or mailing list in RFC822
+                form.
+
+* [O] description: full description of the binding
+
+* [O] compatible: sequence of valid compatible descriptors
+      [R] name: the compatible string surrounded in double quotes
+      [O] deprecated: a deprecated compatible string surrounded in
+                      double quotes
+      [O] description: description of the compatible string

compatible is a property like all the others, and I think it's confusing to have it in a separate section. For example, when listing other properties, the "name:" field specifies the property name, but for the compatible section the "name:" field specifies the possible values for the compatible property. This is (at least to me) quite confusing.

Quoted 8 lines

Can we make this a regular property, with an option 'deprecated' attribute. I guess we may need to distinguish between deprecated properties and deprecated vales of properties.
The above 'deprecated' specifies deprecated values for the compatible property, while
the section below specifies deprecated properties. I don't see a way to indicate a deprecated
value for a still-existing property, but that may be too much detail for now.

I've made an attempt at this in v2. There's some ugly fall-out I haven't decided the best way to handle. That is, I can show a allowable compatible strings including a specific, generic type syntax using C-like expressions. However, showing deprecated compatible requires a special key. I'll be interested if anybody can suggestion something cleaner. There's definitely a trade-off in folding compatibles into properties

Quoted 7 lines

Documentation/devicetree/bindings/dt-binding-format.txt line 79

Quoted 6 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +4 -0
+* [O] required: sequence of required properties:
+      [R] name: name of the property surrounded in double quotes
+      [R] description: description of the property
+      [O] reference: optional reference to a binding id
Quoted 6 lines

I would recommend we add types and value constraints to the binding schema:

[O] type: type of value for this property, and if specified must be one of the following (without quotes):
"string", "number", "array", "phandle"

I modified this a bit to be "string", "int", "array", "phandle", and "empty". I find "empty" to be useful for those properties and a validator will find that useful to validate those boolean type property switches it encounters i.e. skip constraint checking

Quoted 9 lines

[O] value constraint: specifies a limit on the value for a property. This can be specified as English text, or be a range or choice constraint. The latter two should be expressed with the following exact english phrases (without quotes):
"must be in the range x to y, inclusive"
where x and y are numbers
"must be one of <choice 1>, <choice 2>, ..."
where <choice x> is a string, which should be quoted
if it includes a comma.

Got them, but Pantelis' C syntax suggestion for constraints seemed popular and flexible so I went with that initially, please let me know what you think of that.

Quoted 2 lines

Any other constraint is expressed in free-form English text

Yes, I believe the description field can hold this information until bindings are fully converted with constraint info in the C-syntax (if we stick with that).

Quoted 2 lines

I would recommend adding these to this binding schema doc, but not requiring them on the first conversion pass of the docs.

Sounds good.

Quoted 9 lines

Basically my idea is that you want the each pass over the binding documents to be as painless as possible. Every time a user encounters something they're not sure about, it will slow them down. There will be lots of ambiguous situations, and we want the process to be as lossless as possible, so I would recommend a strategy of doing as much as people can, and if in doubt just put any outstanding text in the descriptions. The descriptions will always be free-form text, and we can come along later and convert these to types, constraints, as we see fit.

Agreed!

Quoted 12 lines
Quoted 12 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +12 -0
+* [O] optional: sequence of optional properties:
+      [R] name: name of the property surrounded in double quotes
+      [R] description: description of the property
+      [O] reference: optional reference to a binding id
+
+* [O] deprecated: sequence of deprecated properties:
+      [R] name: name of the property surrounded in double quotes
+      [R] description: description of the property
+      [O] reference: optional reference to a binding id
+
+* [R] example: sequence of examples:
+      [R] dts: DT source of example usage. The example text must use
Quoted 8 lines

Documentation/devicetree/bindings/dt-binding-format.txt line 96

Quoted 4 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +4 -0
+               literal style ("|") so that it retains indentation and
+               newlines.
+      [O] description: description of the example
+

I'd recommend having a top-level notes section:
* [O] note: any other notes about this node that are not covered by preceding property descriptions.

Added in v2, thanks.

Quoted 4 lines

Documentation/devicetree/bindings/dt-binding-format.txt line 97

Quoted 2 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +1 -0
+Note: [R] and [O] denote required and optional fields, respectively.

I'd put this note before the format description.

Done, thanks.

Quoted 13 lines

-- Tim

Quoted 10 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +9 -1
+
+Skeleton Binding
+----------------
+
+The skeleton.yaml binding found in the top of the DT binding tree
+is the canonical example of syntax and format to use when writing
+a DT binding document. It is maintained with the latest formatting
+conventions, making it the best starting point when writing a new DT
+binding.
--
#11 lore raw

Re: [RFC PATCH 1/5] Documentation: dt-bindings: add documentation on new DT binding format

In reply to a message not in the archive
Quoted 2 lines · Matt Porter

Documentation explaining the syntax and format of the YAML-based DT binding documentation.

Sorry I've taken so long to comment; I've had sickness and a backlog of day-job work to deal with.

Quoted 32 lines
---
 .../devicetree/bindings/dt-binding-format.txt      | 106 +++++++++++++++++++++
 1 file changed, 106 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dt-binding-format.txt
Documentation/devicetree/bindings/dt-binding-format.txt new file +20 -0
new file mode 100644
index 0000000..f9acc22
@@ -0,0 +1,106 @@
+--------------------------
+Device Tree Binding Format
+--------------------------
+
+Background
+----------
+
+DT bindings historically were written as text in prose format which
+led to issues in usability of that source documentation. Some of
+these issues include the need to programmatically process binding
+source documentation to do DTS validation, perform mass updates to
+format/style, and to generate publishable documentation in HTML or
+PDF form.
+
+Overview
+--------
+
+The DT binding format is based on the YAML text markup language.
+Although there are many text markup options available, YAML
+fulfills all requirements considered for a DT binding source format

Documentation/devicetree/bindings/dt-binding-format.txt line 30

Quoted 10 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +10 -0
+which include:
+
+1) Must be human readable
+2) Must be easily translated to other data formats (XML, JSON, etc).
+3) Must have sufficient tools and libraries to enable developers to
+   build new tools for DT binding processing
+4) Must have a complete spec to refer to syntax
+
+YAML is documentated in the specification found at
+http://www.yaml.org/spec/1.2/spec.html

I've read through this. At least tentatively, YAML seems like a pretty good choice to me. It seems to have a pretty good balance between human readability and machine parsability.

Documentation/devicetree/bindings/dt-binding-format.txt line 44

Quoted 13 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +13 -0
+The required YAML DT binding tag format and syntax are defined in
+the following sections.
+
+YAML DT Binding Syntax
+----------------------
+
+* Lines starting with "#" are comments and not part of the binding itself
+* "%YAML 1.2" starts a file, indicating the version of YAML in use
+* "---" starts a binding document
+* "..." ends a binding document
+* Multiple binding documents may exist in a single file
+* Tabs are not permitted
+* Scope is denoted by indentation of two spaces

I think the recommended indentation should be increased. At just 2 spaces it's easy to lose track of indentation level if you scroll down a page.

8 would match the kernel code style, but might get cumbersome since I think our YAML structures will probably be more deeply nested in practice than code blocks generally should be.

So, I'd suggest 4.

Quoted 4 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +4 -0
+* Key value pairs are denoted by "key: value"
+* Sequences are denoted by "- "
+* Scalar values may convert newlines to spaces and preserve blank
+  lines for long description formatting using ">"

Documentation/devicetree/bindings/dt-binding-format.txt line 58

Quoted 10 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +10 -0
+* Scalar values may escape all reserved characters and preserve
+  newlines by using "|" to denote literal style
+
+For additional information on YAML syntax, refer to the specification
+at http://www.yaml.org/spec/1.2/spec.html
+
+YAML DT Binding Format
+----------------------
+
+The following YAML types are supported in the DT binding format:

I find the wording above really confusing. Mentioning "types" makes me thinnk you're talking about the actual YAML tags, which usually have typing information, but actually you seem to be talking about the expected members of the top level YAML mapping.

Speaking of YAML tags, we really should specify the YAML schema we're using here. From the rest of the stuff, I'm assuming it's the "Core" schema described in section 10.3 of the YAML spec. That seems a reasonable first choice to me, although eventually we may want to define our own YAML schema.

Quoted 5 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +5 -0
+* [R] id: unique identifier in property form (e.g. skel-device)
+
+* [R] title: title of the binding
+
+* [O] maintainer: sequence of maintainers

Documentation/devicetree/bindings/dt-binding-format.txt line 74

Quoted 10 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +10 -0
+      [R] name: name and email of maintainer or mailing list in RFC822
+                form.
+
+* [O] description: full description of the binding
+
+* [O] compatible: sequence of valid compatible descriptors
+      [R] name: the compatible string surrounded in double quotes
+      [O] deprecated: a deprecated compatible string surrounded in
+                      double quotes
+      [O] description: description of the compatible string

So, when thinking about DT validation, I like to make a distinction between the binding's "key" and its requirements. By the "key" (because I haven't thought of a better term) I mean the thing that tells you this binding is in play. From a validator's point of view, given a DT node and a library of bindings, it needs to check that if the node matches the key, then it must match all the binding's requirements.

For most bindings that will be a particular value listed in 'compatible', but there are other cases. I'm fine if 'compatible' is the only style of "key" we support initially, but I'd like to see a higher level structural break between the "key" part of the binding and the requirements.

Quoted 4 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +4 -0
+* [O] required: sequence of required properties:
+      [R] name: name of the property surrounded in double quotes
+      [R] description: description of the property
+      [O] reference: optional reference to a binding id

Documentation/devicetree/bindings/dt-binding-format.txt line 89

Quoted 10 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +10 -0
+
+* [O] optional: sequence of optional properties:
+      [R] name: name of the property surrounded in double quotes
+      [R] description: description of the property
+      [O] reference: optional reference to a binding id
+
+* [O] deprecated: sequence of deprecated properties:
+      [R] name: name of the property surrounded in double quotes
+      [R] description: description of the property
+      [O] reference: optional reference to a binding id

I'm not sure if it will work better to put require / optional etc. properties into different sections as you have here, or if it would be better to tag each property with "required", "optional", "required-when" and so forth.

Quoted 6 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +6 -0
+* [R] example: sequence of examples:
+      [R] dts: DT source of example usage. The example text must use
+               literal style ("|") so that it retains indentation and
+               newlines.
+      [O] description: description of the example
+

Documentation/devicetree/bindings/dt-binding-format.txt line 106

Quoted 10 lines
Documentation/devicetree/bindings/dt-binding-format.txt new file +10 -0
+Note: [R] and [O] denote required and optional fields, respectively.
+
+Skeleton Binding
+----------------
+
+The skeleton.yaml binding found in the top of the DT binding tree
+is the canonical example of syntax and format to use when writing
+a DT binding document. It is maintained with the latest formatting
+conventions, making it the best starting point when writing a new DT
+binding.

So the other thing I'd like to see in our very first implementation is at least minimal checking of the binding itself. Initially, just checking that it is valid YAML would be enough, I think. But the quoting and nesting rules in YAML are pretty subtle, so I could easily see someone writing something based on existing examples that looks ok to a human, but doesn't quite meet the YAML spec rules.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#12 lore raw

RFC PATCH 2/5 Documentation: dt-bindings: add example DT binding document

In reply to a message not in the archive

Add a skeleton DT binding document that serves as the canonical example for implementing YAML-based DT bindings documentation. The skeleton binding illustrates use of all fields and variations described in the dt-binding-format.txt documentation.

---
 Documentation/devicetree/bindings/skeleton.yaml | 98 +++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/skeleton.yaml
Documentation/devicetree/bindings/skeleton.yaml new file +98 -0
new file mode 100644
index 0000000..175965f
@@ -0,0 +1,98 @@
+%YAML 1.2
+---
+id: skel-device
+
+title: Skeleton Device
+
+maintainer:
+  - name: Skeleton Person <[email protected]>
+
+description: >
+  The Skeleton Device binding represents the SK11 device produced by
+  the Skeleton Corporation. The binding can also support compatible
+  clones made by second source vendors.
+
+compatible:
+  - name: "skel,sk11"
+  - name: "faux,fx11"
+    description: A clone of the original sk11 device
+
+required:
+  - name: "reg"
+    description: chip select address of skeleton device
+    reference: spi-slave
+  - name: "spi-max-frequency"
+    description: >
+      Maximum SPI clocking speed of skeleton device in Hz, must be
+      1000000
+    reference: spi-slave
+
+optional:
+  - name: "spi-cs-high"
+    description: >
+      Set if skeleton device configuration straps are set for chip
+      select polarity high
+    reference: spi-slave
+
+deprecated:
+  - name: "skel,deprecated1"
+    description: >
+      First of two deprecated properties.
+  - name: "skel,deprecated2"
+    description: >
+      Second of two deprecated properties.
+
+example:
+  - dts: |
+      sk11@0 {
+              compatible = "skel,sk11";
+              reg = <0>;
+              spi-max-frequency = <1000000>;
+              spi-cs-high;
+      };
+...
+
+---
+id: skel-mini
+
+title: Skeleton Mini Device
+
+maintainer:
+  - name: Rogue Developer <[email protected]>
+
+description: >
+  The Skeleton Mini Device binding represents the SK47x series devices
+  produced by the Skeleton Corporation.
+
+compatible:
+  - name: "skel,sk472"
+  - name: "skel,sk473"
+  - name: "skel,sk474"
+  - deprecated: "skel,sk47x"
+
+required:
+  - name: "reg"
+    description: offset and length of the registers
+
+optional:
+  - name: "skel,sync-mode"
+    description: Enable synchronous transfer mode
+
+example:
+  - dts: |
+      sk472@beef0000 {
+              compatible = "skel,sk472";
+              reg = <0xbeef0000 0x100>;
+      };
+    description: >
+      Demonstrates an SK472 in normal mode.
+
+  - dts: |
+      sk474@dead0000 {
+              compatible = "skel,sk474";
+              reg = <0xdead0000 0x100>;
+              skel,sync-mode;
+      };
+    description: >
+      Demonstrates an SK474 in synchronous mode.
+...
Signature · 1 line
2.1.4

A message that is not in the archive (sent off-list or not yet received): 1440739433-6799-3-git-send-email-mporter-OWPKS81ov/FWk0Htik3J/[email protected]

#14 lore raw

Re: [RFC PATCH 2/5] Documentation: dt-bindings: add example DT binding document

Quoted 17 lines · Matt Porter

Add a skeleton DT binding document that serves as the canonical example for implementing YAML-based DT bindings documentation. The skeleton binding illustrates use of all fields and variations described in the dt-binding-format.txt documentation.

---
 Documentation/devicetree/bindings/skeleton.yaml | 98 +++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/skeleton.yaml
Documentation/devicetree/bindings/skeleton.yaml new file +0 -0
new file mode 100644
index 0000000..175965f

Documentation/devicetree/bindings/skeleton.yaml line 8

Quoted 8 lines
Documentation/devicetree/bindings/skeleton.yaml new file +8 -0
@@ -0,0 +1,98 @@
+%YAML 1.2
+---
+id: skel-device
+
+title: Skeleton Device
+
+maintainer:
+  - name: Skeleton Person <[email protected]>

We'd want to tie this into get_maintainers.pl obviously.

Documentation/devicetree/bindings/skeleton.yaml line 17

Quoted 9 lines
Documentation/devicetree/bindings/skeleton.yaml new file +9 -0
+
+description: >
+  The Skeleton Device binding represents the SK11 device produced by
+  the Skeleton Corporation. The binding can also support compatible
+  clones made by second source vendors.
+
+compatible:
+  - name: "skel,sk11"
+  - name: "faux,fx11"

Is this an OR or AND? We need both.

The complicated case is "one of {specific names} followed by {generic name}."

Documentation/devicetree/bindings/skeleton.yaml line 21

Quoted 4 lines
Documentation/devicetree/bindings/skeleton.yaml new file +4 -0
+    description: A clone of the original sk11 device
+
+required:
+  - name: "reg"

We definitely need type info from the start.

Documentation/devicetree/bindings/skeleton.yaml line 23

Quoted 2 lines
Documentation/devicetree/bindings/skeleton.yaml new file +2 -0
+    description: chip select address of skeleton device
+    reference: spi-slave

I would like to not have to list properties if the inherited binding lists it. The problem is we need to say how many cells and the order (not a problem here, but for mmio devices).

Perhaps we can list the reference at the top level for the node instead of for every property.

Documentation/devicetree/bindings/skeleton.yaml line 28

Quoted 5 lines
Documentation/devicetree/bindings/skeleton.yaml new file +5 -0
+  - name: "spi-max-frequency"
+    description: >
+      Maximum SPI clocking speed of skeleton device in Hz, must be
+      1000000
+    reference: spi-slave

Rather than listing the property and having constraint in description, perhaps we could add constraints like this:

- spi-max-frequency-range: 1000000 1000000

Or groups of constraints:

- spi-max-frequency-constraints:
range: 1000000 1000000
some-other-constraint: <value>

Quoted 14 lines
Documentation/devicetree/bindings/skeleton.yaml new file +14 -0
+
+optional:
+  - name: "spi-cs-high"
+    description: >
+      Set if skeleton device configuration straps are set for chip
+      select polarity high
+    reference: spi-slave
+
+deprecated:
+  - name: "skel,deprecated1"
+    description: >
+      First of two deprecated properties.
+  - name: "skel,deprecated2"
+    description: >

Documentation/devicetree/bindings/skeleton.yaml line 52

Quoted 10 lines
Documentation/devicetree/bindings/skeleton.yaml new file +10 -0
+      Second of two deprecated properties.
+
+example:
+  - dts: |
+      sk11@0 {
+              compatible = "skel,sk11";
+              reg = <0>;
+              spi-max-frequency = <1000000>;
+              spi-cs-high;
+      };

At least in this example, we could generate it. Examples are nice, but we have dts files full of examples already. I get a fair number of "fix the example" patches, so maybe we should eliminate the simple ones.

Rob

A message that is not in the archive (sent off-list or not yet received): CAL_Jsq+FE4MCCfZC5hDhQBmM1gHibY82S9a8PC1GwsnWsPNxkg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#16 lore raw

Re: [RFC PATCH 2/5] Documentation: dt-bindings: add example DT binding document

Hi Rob,

Quoted 71 lines · Rob Herring
Quoted 17 lines · Matt Porter

Add a skeleton DT binding document that serves as the canonical example for implementing YAML-based DT bindings documentation. The skeleton binding illustrates use of all fields and variations described in the dt-binding-format.txt documentation.

---
Documentation/devicetree/bindings/skeleton.yaml | 98 +++++++++++++++++++++++++

1 file changed, 98 insertions(+)

create mode 100644 Documentation/devicetree/bindings/skeleton.yaml

Documentation/devicetree/bindings/skeleton.yaml new file +0 -0
new file mode 100644
index 0000000..175965f

Documentation/devicetree/bindings/skeleton.yaml line 8

Quoted 8 lines
Documentation/devicetree/bindings/skeleton.yaml new file +8 -0
@@ -0,0 +1,98 @@
+%YAML 1.2
+---
+id: skel-device
+
+title: Skeleton Device
+
+maintainer:
+  - name: Skeleton Person <[email protected]>

We'd want to tie this into get_maintainers.pl obviously.

Documentation/devicetree/bindings/skeleton.yaml line 17

Quoted 9 lines
Documentation/devicetree/bindings/skeleton.yaml new file +9 -0
+
+description: >
+  The Skeleton Device binding represents the SK11 device produced by
+  the Skeleton Corporation. The binding can also support compatible
+  clones made by second source vendors.
+
+compatible:
+  - name: "skel,sk11"
+  - name: "faux,fx11"

Is this an OR or AND? We need both.

The complicated case is "one of {specific names} followed by {generic name}."

Documentation/devicetree/bindings/skeleton.yaml line 21

Quoted 4 lines
Documentation/devicetree/bindings/skeleton.yaml new file +4 -0
+    description: A clone of the original sk11 device
+
+required:
+  - name: "reg"

We definitely need type info from the start.

Documentation/devicetree/bindings/skeleton.yaml line 23

Quoted 2 lines
Documentation/devicetree/bindings/skeleton.yaml new file +2 -0
+    description: chip select address of skeleton device
+    reference: spi-slave

I would like to not have to list properties if the inherited binding lists it. The problem is we need to say how many cells and the order (not a problem here, but for mmio devices).

Perhaps we can list the reference at the top level for the node instead of for every property.

Documentation/devicetree/bindings/skeleton.yaml line 28

Quoted 5 lines
Documentation/devicetree/bindings/skeleton.yaml new file +5 -0
+  - name: "spi-max-frequency"
+    description: >
+      Maximum SPI clocking speed of skeleton device in Hz, must be
+      1000000
+    reference: spi-slave

Rather than listing the property and having constraint in description, perhaps we could add constraints like this:

Quoted 8 lines

- spi-max-frequency-range: 1000000 1000000

Or groups of constraints:

- spi-max-frequency-constraints:
range: 1000000 1000000
some-other-constraint: <value>

I would like something that looks like a C expression.

For instance
- constraint: spi-max-frequency >= 1000000 && spi-max-frequency < 10000000

Quoted 21 lines
Quoted 21 lines
Documentation/devicetree/bindings/skeleton.yaml new file +21 -0
+
+optional:
+  - name: "spi-cs-high"
+    description: >
+      Set if skeleton device configuration straps are set for chip
+      select polarity high
+    reference: spi-slave
+
+deprecated:
+  - name: "skel,deprecated1"
+    description: >
+      First of two deprecated properties.
+  - name: "skel,deprecated2"
+    description: >
+      Second of two deprecated properties.
+
+example:
+  - dts: |
+      sk11@0 {
+              compatible = "skel,sk11";
+              reg = <0>;
Quoted 9 lines

Documentation/devicetree/bindings/skeleton.yaml line 52

Quoted 3 lines
Documentation/devicetree/bindings/skeleton.yaml new file +3 -0
+              spi-max-frequency = <1000000>;
+              spi-cs-high;
+      };

At least in this example, we could generate it. Examples are nice, but we have dts files full of examples already. I get a fair number of "fix the example" patches, so maybe we should eliminate the simple ones.

How about we make sure we parse the example in the binding always, so that we verify that it does much what the binding states?

Quoted 1 line

Rob

Regards

— Pantelis

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#17 lore raw

Re: [RFC PATCH 2/5] Documentation: dt-bindings: add example DT binding document

In reply to a message not in the archive
Quoted 12 lines · Rob Herring
Quoted 11 lines · Matt Porter

Add a skeleton DT binding document that serves as the canonical example for implementing YAML-based DT bindings documentation. The skeleton binding illustrates use of all fields and variations described in the dt-binding-format.txt documentation.

---
 Documentation/devicetree/bindings/skeleton.yaml | 98 +++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/skeleton.yaml
Quoted 16 lines
Quoted 6 lines
Documentation/devicetree/bindings/skeleton.yaml new file +0 -0
new file mode 100644
index 0000000..175965f

Documentation/devicetree/bindings/skeleton.yaml line 8

Quoted 8 lines
Documentation/devicetree/bindings/skeleton.yaml new file +8 -0
@@ -0,0 +1,98 @@
+%YAML 1.2
+---
+id: skel-device
+
+title: Skeleton Device
+
+maintainer:
+  - name: Skeleton Person <[email protected]>

We'd want to tie this into get_maintainers.pl obviously.

Right, I broke my rule of "no new tags for content we don't already have" by adding this. It stems out of the discussion at LPC where Mark suggested we could avoid the core bindings being moved by adding maintainer info into the binding itself.

This is an area where more docs are needed. Ideally, on the first pass conversion we would not attempt to populate these. I had considered that we *could* only add maintainer: tags on core bindings to and adjust get_maintainers.pl to use that info to override the standard directory-based info if it exists. I don't think it's necessary to add a specific maintainer for all of the peripheral bindings if the default is the subsystem maintainer and the dt list. We could at least start directing core binding discussion to the -spec list which is where I think you'd like it.

Quoted 11 lines

Documentation/devicetree/bindings/skeleton.yaml line 17

Quoted 9 lines
Documentation/devicetree/bindings/skeleton.yaml new file +9 -0
+
+description: >
+  The Skeleton Device binding represents the SK11 device produced by
+  the Skeleton Corporation. The binding can also support compatible
+  clones made by second source vendors.
+
+compatible:
+  - name: "skel,sk11"
+  - name: "faux,fx11"

Is this an OR or AND? We need both.

True, this only covers the OR case atm.

Quoted 1 line

The complicated case is "one of {specific names} followed by {generic name}."

I need to rethink these. I do have deprecated: tag for that case and possibly "name:" gets split to "generic:" and "specific:" and we can then do the right thing.

For the above I would have:

compatible:
- specific: "skel,sk11"
- specific: "faux,fx11"

and something like the Allwinner simple framebuffer would be:

compatible:
- generic: "simple-framebuffer"
- specific: "allwinner,simple-framebuffer"

where our validator would insist on seeing one of the specific: tags along with the generic: tag. A lot of bindings, given current doc patterns would just have two tags like above.

Quoted 6 lines

Documentation/devicetree/bindings/skeleton.yaml line 21

Quoted 4 lines
Documentation/devicetree/bindings/skeleton.yaml new file +4 -0
+    description: A clone of the original sk11 device
+
+required:
+  - name: "reg"

We definitely need type info from the start.

Are you sure? Ugh.

My big contention here is that we don't carry that content in the docs today so we shouldn't try to add it in the initial conversion.

I think you are right in that we should have it documented in the schema but I'm concerned that we make the starting conversion effort too large by adding type info to all converted docs.

I think we gain a lot even without at the start, but I understand why we need it and how it will help reduce the review firehose with the associated validation tools.

Quoted 7 lines

Documentation/devicetree/bindings/skeleton.yaml line 23

Quoted 3 lines
Documentation/devicetree/bindings/skeleton.yaml new file +2 -0
+    description: chip select address of skeleton device
+    reference: spi-slave

I would like to not have to list properties if the inherited binding lists it. The problem is we need to say how many cells and the order (not a problem here, but for mmio devices).

Yeah, make sense.

Quoted 2 lines

Perhaps we can list the reference at the top level for the node instead of for every property.

That's a good point. I was wondering if per prop references would get unwieldy once we actually add them into all the converted docs. There's a huge number of existing docs without proper references.

Ok, I'll take a look at collecting references per group of properties.

Quoted 10 lines

Documentation/devicetree/bindings/skeleton.yaml line 28

Quoted 6 lines
Documentation/devicetree/bindings/skeleton.yaml new file +5 -0
+  - name: "spi-max-frequency"
+    description: >
+      Maximum SPI clocking speed of skeleton device in Hz, must be
+      1000000
+    reference: spi-slave

Rather than listing the property and having constraint in description, perhaps we could add constraints like this:

Quoted 7 lines

- spi-max-frequency-range: 1000000 1000000

Or groups of constraints:

- spi-max-frequency-constraints:
range: 1000000 1000000
some-other-constraint: <value>

I was hoping to avoid this to start due to my argument for keeping it simple for the first pass at conversion. However, the latter looks flexible enough. We have cases with enumerated values as well to handle the require some thought.

Quoted 21 lines
Quoted 21 lines
Documentation/devicetree/bindings/skeleton.yaml new file +21 -0
+
+optional:
+  - name: "spi-cs-high"
+    description: >
+      Set if skeleton device configuration straps are set for chip
+      select polarity high
+    reference: spi-slave
+
+deprecated:
+  - name: "skel,deprecated1"
+    description: >
+      First of two deprecated properties.
+  - name: "skel,deprecated2"
+    description: >
+      Second of two deprecated properties.
+
+example:
+  - dts: |
+      sk11@0 {
+              compatible = "skel,sk11";
+              reg = <0>;
Quoted 8 lines

Documentation/devicetree/bindings/skeleton.yaml line 52

Quoted 3 lines
Documentation/devicetree/bindings/skeleton.yaml new file +3 -0
+              spi-max-frequency = <1000000>;
+              spi-cs-high;
+      };

At least in this example, we could generate it. Examples are nice, but we have dts files full of examples already. I get a fair number of "fix the example" patches, so maybe we should eliminate the simple ones.

Yeah, I would say that a huge majority of the examples we have now become useless with this format. I like that idea of just generating it for those users trying to read and understand what it looks like in dts form. Less room for error. We can retain the examples field for those complex examples that need human intervention to craft and describe them properly.

-Matt
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#18 lore raw

Re: [RFC PATCH 2/5] Documentation: dt-bindings: add example DT binding document

Quoted 30 lines · Matt Porter
Quoted 12 lines · Rob Herring
Quoted 11 lines · Matt Porter

Add a skeleton DT binding document that serves as the canonical example for implementing YAML-based DT bindings documentation. The skeleton binding illustrates use of all fields and variations described in the dt-binding-format.txt documentation.

---
 Documentation/devicetree/bindings/skeleton.yaml | 98 +++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/skeleton.yaml
Quoted 16 lines
Quoted 6 lines
Documentation/devicetree/bindings/skeleton.yaml new file +0 -0
new file mode 100644
index 0000000..175965f

Documentation/devicetree/bindings/skeleton.yaml line 8

Quoted 8 lines
Documentation/devicetree/bindings/skeleton.yaml new file +8 -0
@@ -0,0 +1,98 @@
+%YAML 1.2
+---
+id: skel-device
+
+title: Skeleton Device
+
+maintainer:
+  - name: Skeleton Person <[email protected]>

We'd want to tie this into get_maintainers.pl obviously.

Quoted 4 lines

Right, I broke my rule of "no new tags for content we don't already have" by adding this. It stems out of the discussion at LPC where Mark suggested we could avoid the core bindings being moved by adding maintainer info into the binding itself.

If you stated that rule, I missed it...

Quoted 9 lines

This is an area where more docs are needed. Ideally, on the first pass conversion we would not attempt to populate these. I had considered that we *could* only add maintainer: tags on core bindings to and adjust get_maintainers.pl to use that info to override the standard directory-based info if it exists. I don't think it's necessary to add a specific maintainer for all of the peripheral bindings if the default is the subsystem maintainer and the dt list. We could at least start directing core binding discussion to the -spec list which is where I think you'd like it.

Yes, certainly this can solve my problem around handling core bindings.

Some subsystem maintainers require a driver have a maintainer. We could certainly enforce that too. We could probably automatically populate this with the original author as a starting point. OTOH, bindings should not change frequently.

Quoted 21 lines
Quoted 12 lines

Documentation/devicetree/bindings/skeleton.yaml line 17

Quoted 10 lines
Documentation/devicetree/bindings/skeleton.yaml new file +9 -0
+
+description: >
+  The Skeleton Device binding represents the SK11 device produced by
+  the Skeleton Corporation. The binding can also support compatible
+  clones made by second source vendors.
+
+compatible:
+  - name: "skel,sk11"
+  - name: "faux,fx11"

Is this an OR or AND? We need both.

True, this only covers the OR case atm.

Quoted 1 line

The complicated case is "one of {specific names} followed by {generic name}."

I need to rethink these. I do have deprecated: tag for that case and possibly "name:" gets split to "generic:" and "specific:" and we can then do the right thing.

Quoted 5 lines

For the above I would have:

compatible:
- specific: "skel,sk11"
- specific: "faux,fx11"

This can still be an AND or OR relationship.

Quoted 10 lines

and something like the Allwinner simple framebuffer would be:

compatible:
- generic: "simple-framebuffer"
- specific: "allwinner,simple-framebuffer"

where our validator would insist on seeing one of the specific: tags along with the generic: tag. A lot of bindings, given current doc patterns would just have two tags like above.

We could follow Pantelis' suggestion and do C style logic expressions:

name: ("chip1-ipblock" || "chip2-ipblock") && "generic-ipblock"

Quoted 8 lines
Quoted 7 lines

Documentation/devicetree/bindings/skeleton.yaml line 21

Quoted 5 lines
Documentation/devicetree/bindings/skeleton.yaml new file +4 -0
+    description: A clone of the original sk11 device
+
+required:
+  - name: "reg"

We definitely need type info from the start.

Quoted 4 lines

Are you sure? Ugh.

My big contention here is that we don't carry that content in the docs today so we shouldn't try to add it in the initial conversion.

What? We have that all over the place. Boolean properties, phandles, etc.

Quoted 3 lines

I think you are right in that we should have it documented in the schema but I'm concerned that we make the starting conversion effort too large by adding type info to all converted docs.

How we do the conversion certainly needs to be worked out. However, first we need some sort of agreement that yes this looks promising before we spend too much time on it. We need to wait for all the YAML haters to come out of hiding. :) Once the direction is settled, then we can iron out the details of the structure. Finally, then we can determine how to do the conversion. Just because we define how type information looks doesn't mean it has to be there day 1.

Quoted 12 lines

I think we gain a lot even without at the start, but I understand why we need it and how it will help reduce the review firehose with the associated validation tools.

Quoted 7 lines

Documentation/devicetree/bindings/skeleton.yaml line 23

Quoted 3 lines
Documentation/devicetree/bindings/skeleton.yaml new file +2 -0
+    description: chip select address of skeleton device
+    reference: spi-slave

I would like to not have to list properties if the inherited binding lists it. The problem is we need to say how many cells and the order (not a problem here, but for mmio devices).

Quoted 8 lines

Yeah, make sense.

Quoted 2 lines

Perhaps we can list the reference at the top level for the node instead of for every property.

That's a good point. I was wondering if per prop references would get unwieldy once we actually add them into all the converted docs. There's a huge number of existing docs without proper references.

Yes, in many cases they are implied. It should be simple enough to generate the list though whether they point to the doc file or just list the properties.

Quoted 17 lines

Ok, I'll take a look at collecting references per group of properties.

Quoted 14 lines

Documentation/devicetree/bindings/skeleton.yaml line 28

Quoted 6 lines
Documentation/devicetree/bindings/skeleton.yaml new file +5 -0
+  - name: "spi-max-frequency"
+    description: >
+      Maximum SPI clocking speed of skeleton device in Hz, must be
+      1000000
+    reference: spi-slave

Rather than listing the property and having constraint in description, perhaps we could add constraints like this:

- spi-max-frequency-range: 1000000 1000000

Or groups of constraints:

Quoted 8 lines
Quoted 3 lines

- spi-max-frequency-constraints:
range: 1000000 1000000
some-other-constraint: <value>

I was hoping to avoid this to start due to my argument for keeping it simple for the first pass at conversion. However, the latter looks flexible enough. We have cases with enumerated values as well to handle the require some thought.

We can always add constraints as a second step, but I'd like to define the structure at least.

Rob

A message that is not in the archive (sent off-list or not yet received): CAL_JsqJy21yBGe161MrTEC1kL4UD=h+skH=mPm-vjwZ7yEHoUA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#20 lore raw

Re: [RFC PATCH 2/5] Documentation: dt-bindings: add example DT binding document

Quoted 31 lines · Rob Herring
Quoted 30 lines · Matt Porter
Quoted 28 lines · Rob Herring
Quoted 17 lines · Matt Porter

Add a skeleton DT binding document that serves as the canonical example for implementing YAML-based DT bindings documentation. The skeleton binding illustrates use of all fields and variations described in the dt-binding-format.txt documentation.

---
 Documentation/devicetree/bindings/skeleton.yaml | 98 +++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/skeleton.yaml
Documentation/devicetree/bindings/skeleton.yaml new file +0 -0
new file mode 100644
index 0000000..175965f

Documentation/devicetree/bindings/skeleton.yaml line 8

Quoted 8 lines
Documentation/devicetree/bindings/skeleton.yaml new file +8 -0
@@ -0,0 +1,98 @@
+%YAML 1.2
+---
+id: skel-device
+
+title: Skeleton Device
+
+maintainer:
+  - name: Skeleton Person <[email protected]>

We'd want to tie this into get_maintainers.pl obviously.

Quoted 16 lines
Quoted 4 lines

Right, I broke my rule of "no new tags for content we don't already have" by adding this. It stems out of the discussion at LPC where Mark suggested we could avoid the core bindings being moved by adding maintainer info into the binding itself.

If you stated that rule, I missed it...

Quoted 9 lines

This is an area where more docs are needed. Ideally, on the first pass conversion we would not attempt to populate these. I had considered that we *could* only add maintainer: tags on core bindings to and adjust get_maintainers.pl to use that info to override the standard directory-based info if it exists. I don't think it's necessary to add a specific maintainer for all of the peripheral bindings if the default is the subsystem maintainer and the dt list. We could at least start directing core binding discussion to the -spec list which is where I think you'd like it.

I think that adding the maintainer: tags for core bindings in the conversion process (and optionally add the tag for other bindings in the person converting has the driver and subsystem knowledge to intelligently do so -- not just a blind list from get_maintainer) would be a valid exception to your desire to not add new information on the conversion step. As much as other uses of information from bindings is near and dear to me, I think that throttling the binding review fire hose is the highest priority use of additional information.

Quoted 60 lines

Yes, certainly this can solve my problem around handling core bindings.

Some subsystem maintainers require a driver have a maintainer. We could certainly enforce that too. We could probably automatically populate this with the original author as a starting point. OTOH, bindings should not change frequently.

Quoted 21 lines
Quoted 12 lines

Documentation/devicetree/bindings/skeleton.yaml line 17

Quoted 10 lines
Documentation/devicetree/bindings/skeleton.yaml new file +9 -0
+
+description: >
+  The Skeleton Device binding represents the SK11 device produced by
+  the Skeleton Corporation. The binding can also support compatible
+  clones made by second source vendors.
+
+compatible:
+  - name: "skel,sk11"
+  - name: "faux,fx11"

Is this an OR or AND? We need both.

True, this only covers the OR case atm.

Quoted 1 line

The complicated case is "one of {specific names} followed by {generic name}."

I need to rethink these. I do have deprecated: tag for that case and possibly "name:" gets split to "generic:" and "specific:" and we can then do the right thing.

Quoted 5 lines

For the above I would have:

compatible:
- specific: "skel,sk11"
- specific: "faux,fx11"

This can still be an AND or OR relationship.

Quoted 10 lines

and something like the Allwinner simple framebuffer would be:

compatible:
- generic: "simple-framebuffer"
- specific: "allwinner,simple-framebuffer"

where our validator would insist on seeing one of the specific: tags along with the generic: tag. A lot of bindings, given current doc patterns would just have two tags like above.

We could follow Pantelis' suggestion and do C style logic expressions:

name: ("chip1-ipblock" || "chip2-ipblock") && "generic-ipblock"

Quoted 8 lines
Quoted 7 lines

Documentation/devicetree/bindings/skeleton.yaml line 21

Quoted 5 lines
Documentation/devicetree/bindings/skeleton.yaml new file +4 -0
+    description: A clone of the original sk11 device
+
+required:
+  - name: "reg"

We definitely need type info from the start.

Quoted 6 lines
Quoted 4 lines

Are you sure? Ugh.

My big contention here is that we don't carry that content in the docs today so we shouldn't try to add it in the initial conversion.

What? We have that all over the place. Boolean properties, phandles, etc.

Piling on... If the type information is obvious in the current binding doc, then it should be captured in the conversion and not lost. If the information is not currently present then it should not be required in the conversion step.

Which means that we need to define the how to specify the type information.

Quoted 58 lines
Quoted 3 lines

I think you are right in that we should have it documented in the schema but I'm concerned that we make the starting conversion effort too large by adding type info to all converted docs.

How we do the conversion certainly needs to be worked out. However, first we need some sort of agreement that yes this looks promising before we spend too much time on it. We need to wait for all the YAML haters to come out of hiding. :) Once the direction is settled, then we can iron out the details of the structure. Finally, then we can determine how to do the conversion. Just because we define how type information looks doesn't mean it has to be there day 1.

Quoted 12 lines

I think we gain a lot even without at the start, but I understand why we need it and how it will help reduce the review firehose with the associated validation tools.

Quoted 7 lines

Documentation/devicetree/bindings/skeleton.yaml line 23

Quoted 3 lines
Documentation/devicetree/bindings/skeleton.yaml new file +2 -0
+    description: chip select address of skeleton device
+    reference: spi-slave

I would like to not have to list properties if the inherited binding lists it. The problem is we need to say how many cells and the order (not a problem here, but for mmio devices).

Quoted 8 lines

Yeah, make sense.

Quoted 2 lines

Perhaps we can list the reference at the top level for the node instead of for every property.

That's a good point. I was wondering if per prop references would get unwieldy once we actually add them into all the converted docs. There's a huge number of existing docs without proper references.

Yes, in many cases they are implied. It should be simple enough to generate the list though whether they point to the doc file or just list the properties.

Quoted 21 lines

Ok, I'll take a look at collecting references per group of properties.

Quoted 17 lines

Documentation/devicetree/bindings/skeleton.yaml line 28

Quoted 6 lines
Documentation/devicetree/bindings/skeleton.yaml new file +5 -0
+  - name: "spi-max-frequency"
+    description: >
+      Maximum SPI clocking speed of skeleton device in Hz, must be
+      1000000
+    reference: spi-slave

Rather than listing the property and having constraint in description, perhaps we could add constraints like this:

- spi-max-frequency-range: 1000000 1000000

Or groups of constraints:

- spi-max-frequency-constraints:
range: 1000000 1000000
some-other-constraint: <value>

Quoted 7 lines
Quoted 4 lines

I was hoping to avoid this to start due to my argument for keeping it simple for the first pass at conversion. However, the latter looks flexible enough. We have cases with enumerated values as well to handle the require some thought.

We can always add constraints as a second step, but I'd like to define the structure at least.

Agreed, this is something that I would like to see defined, just to make sure that we can do it in a reasonable way with the proposed tool.

Quoted 2 lines

Rob

-Frank

A message that is not in the archive (sent off-list or not yet received): [email protected]

#22 lore raw

Re: [RFC PATCH 2/5] Documentation: dt-bindings: add example DT binding document

Quoted 49 lines · Frank Rowand
Quoted 31 lines · Rob Herring
Quoted 30 lines · Matt Porter
Quoted 28 lines · Rob Herring
Quoted 17 lines · Matt Porter

Add a skeleton DT binding document that serves as the canonical example for implementing YAML-based DT bindings documentation. The skeleton binding illustrates use of all fields and variations described in the dt-binding-format.txt documentation.

---
 Documentation/devicetree/bindings/skeleton.yaml | 98 +++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/skeleton.yaml
Documentation/devicetree/bindings/skeleton.yaml new file +0 -0
new file mode 100644
index 0000000..175965f

Documentation/devicetree/bindings/skeleton.yaml line 8

Quoted 8 lines
Documentation/devicetree/bindings/skeleton.yaml new file +8 -0
@@ -0,0 +1,98 @@
+%YAML 1.2
+---
+id: skel-device
+
+title: Skeleton Device
+
+maintainer:
+  - name: Skeleton Person <[email protected]>

We'd want to tie this into get_maintainers.pl obviously.

Quoted 16 lines
Quoted 4 lines

Right, I broke my rule of "no new tags for content we don't already have" by adding this. It stems out of the discussion at LPC where Mark suggested we could avoid the core bindings being moved by adding maintainer info into the binding itself.

If you stated that rule, I missed it...

Quoted 9 lines

This is an area where more docs are needed. Ideally, on the first pass conversion we would not attempt to populate these. I had considered that we *could* only add maintainer: tags on core bindings to and adjust get_maintainers.pl to use that info to override the standard directory-based info if it exists. I don't think it's necessary to add a specific maintainer for all of the peripheral bindings if the default is the subsystem maintainer and the dt list. We could at least start directing core binding discussion to the -spec list which is where I think you'd like it.

Quoted 8 lines

I think that adding the maintainer: tags for core bindings in the conversion process (and optionally add the tag for other bindings in the person converting has the driver and subsystem knowledge to intelligently do so -- not just a blind list from get_maintainer) would be a valid exception to your desire to not add new information on the conversion step. As much as other uses of information from bindings is near and dear to me, I think that throttling the binding review fire hose is the highest priority use of additional information.

Ok, and the other suggestion is to just populate it with the original author so that's straightforward enough to do.

Quoted 67 lines
Quoted 67 lines

Yes, certainly this can solve my problem around handling core bindings.

Some subsystem maintainers require a driver have a maintainer. We could certainly enforce that too. We could probably automatically populate this with the original author as a starting point. OTOH, bindings should not change frequently.

Quoted 21 lines
Quoted 12 lines

Documentation/devicetree/bindings/skeleton.yaml line 17

Quoted 10 lines
Documentation/devicetree/bindings/skeleton.yaml new file +9 -0
+
+description: >
+  The Skeleton Device binding represents the SK11 device produced by
+  the Skeleton Corporation. The binding can also support compatible
+  clones made by second source vendors.
+
+compatible:
+  - name: "skel,sk11"
+  - name: "faux,fx11"

Is this an OR or AND? We need both.

True, this only covers the OR case atm.

Quoted 1 line

The complicated case is "one of {specific names} followed by {generic name}."

I need to rethink these. I do have deprecated: tag for that case and possibly "name:" gets split to "generic:" and "specific:" and we can then do the right thing.

Quoted 5 lines

For the above I would have:

compatible:
- specific: "skel,sk11"
- specific: "faux,fx11"

This can still be an AND or OR relationship.

Quoted 10 lines

and something like the Allwinner simple framebuffer would be:

compatible:
- generic: "simple-framebuffer"
- specific: "allwinner,simple-framebuffer"

where our validator would insist on seeing one of the specific: tags along with the generic: tag. A lot of bindings, given current doc patterns would just have two tags like above.

We could follow Pantelis' suggestion and do C style logic expressions:

name: ("chip1-ipblock" || "chip2-ipblock") && "generic-ipblock"

Quoted 12 lines
Quoted 7 lines

Documentation/devicetree/bindings/skeleton.yaml line 21

Quoted 5 lines
Documentation/devicetree/bindings/skeleton.yaml new file +4 -0
+    description: A clone of the original sk11 device
+
+required:
+  - name: "reg"

We definitely need type info from the start.

Are you sure? Ugh.

My big contention here is that we don't carry that content in the docs today so we shouldn't try to add it in the initial conversion.

Quoted 6 lines
Quoted 1 line

What? We have that all over the place. Boolean properties, phandles, etc.

Piling on... If the type information is obvious in the current binding doc, then it should be captured in the conversion and not lost. If the information is not currently present then it should not be required in the conversion step.

Ok.

Quoted 1 line

Which means that we need to define the how to specify the type information.

Agreed, I'm adding that to the format in v2.

Quoted 63 lines
Quoted 63 lines
Quoted 3 lines

I think you are right in that we should have it documented in the schema but I'm concerned that we make the starting conversion effort too large by adding type info to all converted docs.

How we do the conversion certainly needs to be worked out. However, first we need some sort of agreement that yes this looks promising before we spend too much time on it. We need to wait for all the YAML haters to come out of hiding. :) Once the direction is settled, then we can iron out the details of the structure. Finally, then we can determine how to do the conversion. Just because we define how type information looks doesn't mean it has to be there day 1.

Quoted 12 lines

I think we gain a lot even without at the start, but I understand why we need it and how it will help reduce the review firehose with the associated validation tools.

Quoted 7 lines

Documentation/devicetree/bindings/skeleton.yaml line 23

Quoted 3 lines
Documentation/devicetree/bindings/skeleton.yaml new file +2 -0
+    description: chip select address of skeleton device
+    reference: spi-slave

I would like to not have to list properties if the inherited binding lists it. The problem is we need to say how many cells and the order (not a problem here, but for mmio devices).

Quoted 8 lines

Yeah, make sense.

Quoted 2 lines

Perhaps we can list the reference at the top level for the node instead of for every property.

That's a good point. I was wondering if per prop references would get unwieldy once we actually add them into all the converted docs. There's a huge number of existing docs without proper references.

Yes, in many cases they are implied. It should be simple enough to generate the list though whether they point to the doc file or just list the properties.

Quoted 25 lines

Ok, I'll take a look at collecting references per group of properties.

Quoted 10 lines

Documentation/devicetree/bindings/skeleton.yaml line 28

Quoted 6 lines
Documentation/devicetree/bindings/skeleton.yaml new file +5 -0
+  - name: "spi-max-frequency"
+    description: >
+      Maximum SPI clocking speed of skeleton device in Hz, must be
+      1000000
+    reference: spi-slave

Rather than listing the property and having constraint in description, perhaps we could add constraints like this:

Quoted 7 lines

- spi-max-frequency-range: 1000000 1000000

Or groups of constraints:

- spi-max-frequency-constraints:
range: 1000000 1000000
some-other-constraint: <value>

I was hoping to avoid this to start due to my argument for keeping it simple for the first pass at conversion. However, the latter looks flexible enough. We have cases with enumerated values as well to handle the require some thought.

Quoted 5 lines
Quoted 2 lines

We can always add constraints as a second step, but I'd like to define the structure at least.

Agreed, this is something that I would like to see defined, just to make sure that we can do it in a reasonable way with the proposed tool.

Will do, adding that in v2.

-Matt
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#23 lore raw

Re: [RFC PATCH 2/5] Documentation: dt-bindings: add example DT binding document

In reply to a message not in the archive
Quoted 31 lines · Rob Herring
Quoted 30 lines · Matt Porter
Quoted 28 lines · Rob Herring
Quoted 17 lines · Matt Porter

Add a skeleton DT binding document that serves as the canonical example for implementing YAML-based DT bindings documentation. The skeleton binding illustrates use of all fields and variations described in the dt-binding-format.txt documentation.

---
 Documentation/devicetree/bindings/skeleton.yaml | 98 +++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/skeleton.yaml
Documentation/devicetree/bindings/skeleton.yaml new file +0 -0
new file mode 100644
index 0000000..175965f

Documentation/devicetree/bindings/skeleton.yaml line 8

Quoted 8 lines
Documentation/devicetree/bindings/skeleton.yaml new file +8 -0
@@ -0,0 +1,98 @@
+%YAML 1.2
+---
+id: skel-device
+
+title: Skeleton Device
+
+maintainer:
+  - name: Skeleton Person <[email protected]>

We'd want to tie this into get_maintainers.pl obviously.

Quoted 6 lines
Quoted 4 lines

Right, I broke my rule of "no new tags for content we don't already have" by adding this. It stems out of the discussion at LPC where Mark suggested we could avoid the core bindings being moved by adding maintainer info into the binding itself.

If you stated that rule, I missed it...

Mental list of rules I made for my initial cut at this. I was trying really hard to have this be a cut and paste reformatting to start and then see where comments take us.

Quoted 10 lines
Quoted 9 lines

This is an area where more docs are needed. Ideally, on the first pass conversion we would not attempt to populate these. I had considered that we *could* only add maintainer: tags on core bindings to and adjust get_maintainers.pl to use that info to override the standard directory-based info if it exists. I don't think it's necessary to add a specific maintainer for all of the peripheral bindings if the default is the subsystem maintainer and the dt list. We could at least start directing core binding discussion to the -spec list which is where I think you'd like it.

Quoted 6 lines

Yes, certainly this can solve my problem around handling core bindings.

Some subsystem maintainers require a driver have a maintainer. We could certainly enforce that too. We could probably automatically populate this with the original author as a starting point. OTOH, bindings should not change frequently.

Populating with the original author seems easy enough.

Quoted 19 lines
Quoted 19 lines
Quoted 10 lines

Documentation/devicetree/bindings/skeleton.yaml line 16

Quoted 8 lines
Documentation/devicetree/bindings/skeleton.yaml new file +8 -0
+description: >
+  The Skeleton Device binding represents the SK11 device produced by
+  the Skeleton Corporation. The binding can also support compatible
+  clones made by second source vendors.
+
+compatible:
+  - name: "skel,sk11"
+  - name: "faux,fx11"

Is this an OR or AND? We need both.

True, this only covers the OR case atm.

Quoted 1 line

The complicated case is "one of {specific names} followed by {generic name}."

I need to rethink these. I do have deprecated: tag for that case and possibly "name:" gets split to "generic:" and "specific:" and we can then do the right thing.

Quoted 7 lines
Quoted 5 lines

For the above I would have:

compatible:
- specific: "skel,sk11"
- specific: "faux,fx11"

This can still be an AND or OR relationship.

Ok, so this might need to be sequences of and: and or:
key value pairs to reflect the combinations.

Quoted 6 lines
Quoted 6 lines

and something like the Allwinner simple framebuffer would be:

compatible:
- generic: "simple-framebuffer"
- specific: "allwinner,simple-framebuffer"

Quoted 7 lines
Quoted 3 lines

where our validator would insist on seeing one of the specific: tags along with the generic: tag. A lot of bindings, given current doc patterns would just have two tags like above.

We could follow Pantelis' suggestion and do C style logic expressions:

name: ("chip1-ipblock" || "chip2-ipblock") && "generic-ipblock"

That might work. More specialized parsing, but it probably is needed to handle property values ranges anyway.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

Documentation/devicetree/bindings/skeleton.yaml line 20

Quoted 4 lines
Documentation/devicetree/bindings/skeleton.yaml new file +4 -0
+    description: A clone of the original sk11 device
+
+required:
+  - name: "reg"

We definitely need type info from the start.

Quoted 6 lines
Quoted 4 lines

Are you sure? Ugh.

My big contention here is that we don't carry that content in the docs today so we shouldn't try to add it in the initial conversion.

What? We have that all over the place. Boolean properties, phandles, etc.

I mean that it's not always explicitly called out in peripheral DT bindings...it's inconsistently documented. I think that by properly documenting this in the generic bindings as you are suggesting and getting those properties by reference, the task of documenting these won't be so bad.

Quoted 8 lines
Quoted 3 lines

I think you are right in that we should have it documented in the schema but I'm concerned that we make the starting conversion effort too large by adding type info to all converted docs.

How we do the conversion certainly needs to be worked out. However, first we need some sort of agreement that yes this looks promising before we spend too much time on it. We need to wait for all the YAML haters to come out of hiding. :) Once the direction is settled, then

I was expecting the YAML haters by now, I'll give it another few days. :)

Quoted 3 lines

we can iron out the details of the structure. Finally, then we can determine how to do the conversion. Just because we define how type information looks doesn't mean it has to be there day 1.

Agreed.

Quoted 17 lines
Quoted 17 lines

I think we gain a lot even without at the start, but I understand why we need it and how it will help reduce the review firehose with the associated validation tools.

Quoted 7 lines

Documentation/devicetree/bindings/skeleton.yaml line 22

Quoted 3 lines
Documentation/devicetree/bindings/skeleton.yaml new file +2 -0
+    description: chip select address of skeleton device
+    reference: spi-slave

I would like to not have to list properties if the inherited binding lists it. The problem is we need to say how many cells and the order (not a problem here, but for mmio devices).

Yeah, make sense.

Quoted 2 lines

Perhaps we can list the reference at the top level for the node instead of for every property.

Quoted 7 lines
Quoted 3 lines

That's a good point. I was wondering if per prop references would get unwieldy once we actually add them into all the converted docs. There's a huge number of existing docs without proper references.

Yes, in many cases they are implied. It should be simple enough to generate the list though whether they point to the doc file or just list the properties.

Ok.

Quoted 22 lines
Quoted 22 lines

Ok, I'll take a look at collecting references per group of properties.

Quoted 17 lines

Documentation/devicetree/bindings/skeleton.yaml line 27

Quoted 6 lines
Documentation/devicetree/bindings/skeleton.yaml new file +5 -0
+  - name: "spi-max-frequency"
+    description: >
+      Maximum SPI clocking speed of skeleton device in Hz, must be
+      1000000
+    reference: spi-slave

Rather than listing the property and having constraint in description, perhaps we could add constraints like this:

- spi-max-frequency-range: 1000000 1000000

Or groups of constraints:

- spi-max-frequency-constraints:
range: 1000000 1000000
some-other-constraint: <value>

Quoted 7 lines
Quoted 4 lines

I was hoping to avoid this to start due to my argument for keeping it simple for the first pass at conversion. However, the latter looks flexible enough. We have cases with enumerated values as well to handle the require some thought.

We can always add constraints as a second step, but I'd like to define the structure at least.

Ok, this sounds reasonable, I'm goling to take a stab at reorganizing the format based on the big areas of references, property types, and property constraints.

-Matt

#24 lore raw

Re: [RFC PATCH 2/5] Documentation: dt-bindings: add example DT binding document

In reply to a message not in the archive
Quoted 1 line · Rob Herring

On Fri, Aug 28, 2015 at 12:23 AM, Matt Porter <mporter-OWPKS81ov/FWk0Htik3J/[email protected]> wrote:

...

Quoted 9 lines

Documentation/devicetree/bindings/skeleton.yaml line 52

Quoted 8 lines
Documentation/devicetree/bindings/skeleton.yaml new file +8 -0
+example:
+  - dts: |
+      sk11@0 {
+              compatible = "skel,sk11";
+              reg = <0>;
+              spi-max-frequency = <1000000>;
+              spi-cs-high;
+      };
Quoted 4 lines

At least in this example, we could generate it. Examples are nice, but we have dts files full of examples already. I get a fair number of "fix the example" patches, so maybe we should eliminate the simple ones.

I would hesitate to eliminate examples. I've been saved by them on a few occasions, when the dts files only had one or two instances of a type of binding, somewhat different from each other, and the example helped break the tie. If there's something wrong with the example, it's a sign of an out-of-date binding doc, just as much as if the text were wrong. It ought to be possible to validate the example versus the binding doc (as Pantelis says), so ultimately we should be able to catch errors here as well.
-- Tim

A message that is not in the archive (sent off-list or not yet received): CA+bK7J4x2vY-tzUFWjM9KFMtvE+qW6jzmz=ZxWU9L8Mpe8Lduw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#26 lore raw

Re: [RFC PATCH 2/5] Documentation: dt-bindings: add example DT binding document

Le 01/09/2015 19:35, Tim Bird a écrit :

Quoted 17 lines · Rob Herring
Quoted 1 line · Matt Porter

...

Quoted 9 lines

Documentation/devicetree/bindings/skeleton.yaml line 52

Quoted 8 lines
Documentation/devicetree/bindings/skeleton.yaml new file +8 -0
+example:
+  - dts: |
+      sk11@0 {
+              compatible = "skel,sk11";
+              reg = <0>;
+              spi-max-frequency = <1000000>;
+              spi-cs-high;
+      };
Quoted 4 lines

At least in this example, we could generate it. Examples are nice, but we have dts files full of examples already. I get a fair number of "fix the example" patches, so maybe we should eliminate the simple ones.

Quoted 8 lines

I would hesitate to eliminate examples. I've been saved by them on a few occasions, when the dts files only had one or two instances of a type of binding, somewhat different from each other, and the example helped break the tie. If there's something wrong with the example, it's a sign of an out-of-date binding doc, just as much as if the text were wrong. It ought to be possible to validate the example versus the binding doc (as Pantelis says), so ultimately we should be able to catch errors here as well.

I back Tim's advice.
Example are so important that I regularly find myself thinking "ah-ha, okay that's supposed to work like that" after having read the binding documentation.

Bye,

Signature · 1 line
Nicolas Ferre

A message that is not in the archive (sent off-list or not yet received): [email protected]

#28 lore raw

Re: [RFC PATCH 2/5] Documentation: dt-bindings: add example DT binding document

Quoted 27 lines · Nicolas Ferre
Quoted 17 lines · Tim Bird
Quoted 1 line · Rob Herring

On Fri, Aug 28, 2015 at 12:23 AM, Matt Porter <mporter-OWPKS81ov/HQFizaE/[email protected]> wrote:

...

Quoted 9 lines

Review

Quoted 8 lines
(quoted diff) +8 -0
+example:
+  - dts: |
+      sk11@0 {
+              compatible = "skel,sk11";
+              reg = <0>;
+              spi-max-frequency = <1000000>;
+              spi-cs-high;
+      };
Quoted 4 lines

At least in this example, we could generate it. Examples are nice, but we have dts files full of examples already. I get a fair number of "fix the example" patches, so maybe we should eliminate the simple ones.

Quoted 8 lines

I would hesitate to eliminate examples. I've been saved by them on a few occasions, when the dts files only had one or two instances of a type of binding, somewhat different from each other, and the example helped break the tie. If there's something wrong with the example, it's a sign of an out-of-date binding doc, just as much as if the text were wrong. It ought to be possible to validate the example versus the binding doc (as Pantelis says), so ultimately we should be able to catch errors here as well.

Quoted 4 lines

I back Tim's advice.
Example are so important that I regularly find myself thinking "ah-ha, okay that's supposed to work like that" after having read the binding documentation.

See my comments on Tim's post. In summary, we'd retain the complex type examples but allow the trivial ones to not bother with it in explicit source. OTOH, this would have to be a final change in the conversion process, most likely, because we need all the type: and constraints:
tags present in order to generate a working example.

Of course, that's the same info necessary to validate a dts as well.

Perhaps it's best to look at this as the automated conversion process that Rob suggested. That is, we'll have the current text (including all examples) brought into the .yaml file as comments. So we aren't eliminating examples. Later, if those examples are too trivial to bother capturing as above, we simply remove and one can dump an example via a doc generator not unlike my markdown example (which can spit out pasteable text).

-Matt

#29 lore raw

Re: [RFC PATCH 2/5] Documentation: dt-bindings: add example DT binding document

In reply to a message not in the archive
Quoted 17 lines · Tim Bird
Quoted 1 line · Rob Herring

On Fri, Aug 28, 2015 at 12:23 AM, Matt Porter <mporter-OWPKS81ov/FWk0Htik3J/[email protected]> wrote:

...

Quoted 9 lines

Documentation/devicetree/bindings/skeleton.yaml line 52

Quoted 8 lines
Documentation/devicetree/bindings/skeleton.yaml new file +8 -0
+example:
+  - dts: |
+      sk11@0 {
+              compatible = "skel,sk11";
+              reg = <0>;
+              spi-max-frequency = <1000000>;
+              spi-cs-high;
+      };
Quoted 4 lines

At least in this example, we could generate it. Examples are nice, but we have dts files full of examples already. I get a fair number of "fix the example" patches, so maybe we should eliminate the simple ones.

Quoted 8 lines

I would hesitate to eliminate examples. I've been saved by them on a few occasions, when the dts files only had one or two instances of a type of binding, somewhat different from each other, and the example helped break the tie. If there's something wrong with the example, it's a sign of an out-of-date binding doc, just as much as if the text were wrong. It ought to be possible to validate the example versus the binding doc (as Pantelis says), so ultimately we should be able to catch errors here as well.

I think part of the suggestion is that we can simply generate the common examples from the tags (as part of formatted doc generation) rather than it being a verbatim paste from a dts file. This has the benefit of not getting that verbatim text of of sync with a dts (because we'll eventually validating the dts files versus the binding doc). Does that still achieve what you want? Keep in mind that we aren't talking about taking away the ability to put an explicit verbatim example, but rather making it an exception case to demonstrate some variants where an author wants to point out different common use cases.

-Matt

#30 lore raw

Re: [RFC PATCH 2/5] Documentation: dt-bindings: add example DT binding document

In reply to a message not in the archive
Quoted 29 lines · Rob Herring
Quoted 17 lines · Matt Porter

Add a skeleton DT binding document that serves as the canonical example for implementing YAML-based DT bindings documentation. The skeleton binding illustrates use of all fields and variations described in the dt-binding-format.txt documentation.

---
 Documentation/devicetree/bindings/skeleton.yaml | 98 +++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/skeleton.yaml
Documentation/devicetree/bindings/skeleton.yaml new file +0 -0
new file mode 100644
index 0000000..175965f

Documentation/devicetree/bindings/skeleton.yaml line 8

Quoted 8 lines
Documentation/devicetree/bindings/skeleton.yaml new file +8 -0
@@ -0,0 +1,98 @@
+%YAML 1.2
+---
+id: skel-device
+
+title: Skeleton Device
+
+maintainer:
+  - name: Skeleton Person <[email protected]>

We'd want to tie this into get_maintainers.pl obviously.

Quoted 11 lines

Documentation/devicetree/bindings/skeleton.yaml line 17

Quoted 9 lines
Documentation/devicetree/bindings/skeleton.yaml new file +9 -0
+
+description: >
+  The Skeleton Device binding represents the SK11 device produced by
+  the Skeleton Corporation. The binding can also support compatible
+  clones made by second source vendors.
+
+compatible:
+  - name: "skel,sk11"
+  - name: "faux,fx11"

Is this an OR or AND? We need both.

Hrm. So, from the example below it's an OR. But.. I think the considerations here change when you separate out "tag" information as I've suggested elsewhere.

The command AND case, I can think of is where you want both "foo,new-model-device" and "foo,old-model-device". I think the first belongs in the "tag", but the second in the body of the requirements.

The OR case demonstrated here strikes me as very poor binding design - but that doesn't mean we can totally avoid it, since we do have poor bindings we want to convert.

Fwiw, I think the right way to encode "OR" at least in the "tag" is to pick just the preferred form, then have additional bindings tagged on the alternative forms and inheriting the main binding. I don't know if that's practical in the short term though.

Quoted 8 lines

The complicated case is "one of {specific names} followed by {generic name}."

Documentation/devicetree/bindings/skeleton.yaml line 21

Quoted 4 lines
Documentation/devicetree/bindings/skeleton.yaml new file +4 -0
+    description: A clone of the original sk11 device
+
+required:
+  - name: "reg"

We definitely need type info from the start.

It's interesting you should mention that here, because 'reg' is actually a hard case for describint the type: because it's format is determined as much by the parent bus binding as this node's binding.

I suspect it will be worth special-casing "reg" in order to make common bindings more compact, but again, probably not in the first pass.

Quoted 9 lines

Documentation/devicetree/bindings/skeleton.yaml line 23

Quoted 2 lines
Documentation/devicetree/bindings/skeleton.yaml new file +2 -0
+    description: chip select address of skeleton device
+    reference: spi-slave

I would like to not have to list properties if the inherited binding lists it. The problem is we need to say how many cells and the order (not a problem here, but for mmio devices).

Perhaps we can list the reference at the top level for the node instead of for every property.

Yeah, I think it would be worth having a top-level "inherits" field.

Quoted 9 lines

Documentation/devicetree/bindings/skeleton.yaml line 28

Quoted 5 lines
Documentation/devicetree/bindings/skeleton.yaml new file +5 -0
+  - name: "spi-max-frequency"
+    description: >
+      Maximum SPI clocking speed of skeleton device in Hz, must be
+      1000000
+    reference: spi-slave

Rather than listing the property and having constraint in description, perhaps we could add constraints like this:

Quoted 7 lines

- spi-max-frequency-range: 1000000 1000000

Or groups of constraints:

- spi-max-frequency-constraints:
range: 1000000 1000000
some-other-constraint: <value>

Not for the first pass I think. What I would suggest is having "description" for pure informational stuff, and "constraint" or maybe just "extra" for normative constraints expressed in English.

The idea here is that over time we can add new ways of expressing constraints. In the meantime tools can use the "extra" field to preseve any difficult text in the current versions and at least let tools know that they won't be able to check everything.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#31 lore raw

Re: [RFC PATCH 2/5] Documentation: dt-bindings: add example DT binding document

Quoted 46 lines · David Gibson
Quoted 29 lines · Rob Herring
Quoted 17 lines · Matt Porter

Add a skeleton DT binding document that serves as the canonical example for implementing YAML-based DT bindings documentation. The skeleton binding illustrates use of all fields and variations described in the dt-binding-format.txt documentation.

---
 Documentation/devicetree/bindings/skeleton.yaml | 98 +++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/skeleton.yaml
Documentation/devicetree/bindings/skeleton.yaml new file +0 -0
new file mode 100644
index 0000000..175965f

Documentation/devicetree/bindings/skeleton.yaml line 8

Quoted 8 lines
Documentation/devicetree/bindings/skeleton.yaml new file +8 -0
@@ -0,0 +1,98 @@
+%YAML 1.2
+---
+id: skel-device
+
+title: Skeleton Device
+
+maintainer:
+  - name: Skeleton Person <[email protected]>

We'd want to tie this into get_maintainers.pl obviously.

Quoted 11 lines

Documentation/devicetree/bindings/skeleton.yaml line 17

Quoted 9 lines
Documentation/devicetree/bindings/skeleton.yaml new file +9 -0
+
+description: >
+  The Skeleton Device binding represents the SK11 device produced by
+  the Skeleton Corporation. The binding can also support compatible
+  clones made by second source vendors.
+
+compatible:
+  - name: "skel,sk11"
+  - name: "faux,fx11"

Is this an OR or AND? We need both.

Hrm. So, from the example below it's an OR. But.. I think the considerations here change when you separate out "tag" information as I've suggested elsewhere.

Quoted 7 lines

The command AND case, I can think of is where you want both "foo,new-model-device" and "foo,old-model-device". I think the first belongs in the "tag", but the second in the body of the requirements.

The OR case demonstrated here strikes me as very poor binding design - but that doesn't mean we can totally avoid it, since we do have poor bindings we want to convert.

I don't think so. Often "old" is a singleton, and "new" is one of several newer chips. It is also very common for licensed IP blocks. All the vendors have different quirks and possibly different versions of the IP. In the better cases, we can have a vendor compat for each vendor and then a generic compat.

Quoted 14 lines

Fwiw, I think the right way to encode "OR" at least in the "tag" is to pick just the preferred form, then have additional bindings tagged on the alternative forms and inheriting the main binding. I don't know if that's practical in the short term though.

Quoted 8 lines

The complicated case is "one of {specific names} followed by {generic name}."

Documentation/devicetree/bindings/skeleton.yaml line 21

Quoted 4 lines
Documentation/devicetree/bindings/skeleton.yaml new file +4 -0
+    description: A clone of the original sk11 device
+
+required:
+  - name: "reg"

We definitely need type info from the start.

Quoted 3 lines

It's interesting you should mention that here, because 'reg' is actually a hard case for describint the type: because it's format is determined as much by the parent bus binding as this node's binding.

And reg is well defined, so that's one I'm least worried about.

Quoted 3 lines

I suspect it will be worth special-casing "reg" in order to make common bindings more compact, but again, probably not in the first pass.

Yes, I would fully expect reg to just be flagged as used and how many addresses.

Quoted 26 lines
Quoted 10 lines

Documentation/devicetree/bindings/skeleton.yaml line 23

Quoted 3 lines
Documentation/devicetree/bindings/skeleton.yaml new file +2 -0
+    description: chip select address of skeleton device
+    reference: spi-slave

I would like to not have to list properties if the inherited binding lists it. The problem is we need to say how many cells and the order (not a problem here, but for mmio devices).

Perhaps we can list the reference at the top level for the node instead of for every property.

Yeah, I think it would be worth having a top-level "inherits" field.

Quoted 13 lines

Documentation/devicetree/bindings/skeleton.yaml line 28

Quoted 5 lines
Documentation/devicetree/bindings/skeleton.yaml new file +5 -0
+  - name: "spi-max-frequency"
+    description: >
+      Maximum SPI clocking speed of skeleton device in Hz, must be
+      1000000
+    reference: spi-slave

Rather than listing the property and having constraint in description, perhaps we could add constraints like this:

- spi-max-frequency-range: 1000000 1000000

Or groups of constraints:

Quoted 7 lines
Quoted 3 lines

- spi-max-frequency-constraints:
range: 1000000 1000000
some-other-constraint: <value>

Not for the first pass I think. What I would suggest is having "description" for pure informational stuff, and "constraint" or maybe just "extra" for normative constraints expressed in English.

At least for simple constraints, I don't see the point of manually converting to something still not machine parse-able. We should be able to figure out a syntax. Sure, there may be complex examples we just punt on, but we can address most common cases. But if we can't define a syntax, then lets do nothing until we do.

Quoted 4 lines

The idea here is that over time we can add new ways of expressing constraints. In the meantime tools can use the "extra" field to preseve any difficult text in the current versions and at least let tools know that they won't be able to check everything.

Just keeping the existing doc text will preserve things.

Rob

A message that is not in the archive (sent off-list or not yet received): [email protected]

#33 lore raw

Re: [RFC PATCH 2/5] Documentation: dt-bindings: add example DT binding document

Quoted 51 lines · Rob Herring
Quoted 50 lines · David Gibson
Quoted 29 lines · Rob Herring
Quoted 17 lines · Matt Porter

Add a skeleton DT binding document that serves as the canonical example for implementing YAML-based DT bindings documentation. The skeleton binding illustrates use of all fields and variations described in the dt-binding-format.txt documentation.

---
 Documentation/devicetree/bindings/skeleton.yaml | 98 +++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/skeleton.yaml
Documentation/devicetree/bindings/skeleton.yaml new file +0 -0
new file mode 100644
index 0000000..175965f

Documentation/devicetree/bindings/skeleton.yaml line 8

Quoted 8 lines
Documentation/devicetree/bindings/skeleton.yaml new file +8 -0
@@ -0,0 +1,98 @@
+%YAML 1.2
+---
+id: skel-device
+
+title: Skeleton Device
+
+maintainer:
+  - name: Skeleton Person <[email protected]>

We'd want to tie this into get_maintainers.pl obviously.

Quoted 11 lines

Documentation/devicetree/bindings/skeleton.yaml line 17

Quoted 9 lines
Documentation/devicetree/bindings/skeleton.yaml new file +9 -0
+
+description: >
+  The Skeleton Device binding represents the SK11 device produced by
+  the Skeleton Corporation. The binding can also support compatible
+  clones made by second source vendors.
+
+compatible:
+  - name: "skel,sk11"
+  - name: "faux,fx11"

Is this an OR or AND? We need both.

Hrm. So, from the example below it's an OR. But.. I think the considerations here change when you separate out "tag" information as I've suggested elsewhere.

The command AND case, I can think of is where you want both "foo,new-model-device" and "foo,old-model-device". I think the first belongs in the "tag", but the second in the body of the requirements.

Quoted 6 lines
Quoted 3 lines

The OR case demonstrated here strikes me as very poor binding design - but that doesn't mean we can totally avoid it, since we do have poor bindings we want to convert.

I don't think so. Often "old" is a singleton, and "new" is one of several newer chips.

Yeah, so the trouble is bindings like that are kind of unclear (although you can generally figure it out by convention). Giving AND and OR conditions gives more detail, but still doesn't really express what you want here.

Supposeyou have the SK33 device, and its backwards compatible revisions the SK34 and SK35. There's also the SK38, which is compatible with the original SK33, but not the revised versions.

So really, you have a cluster of related bindings:

SK33 binding:
Applies when compatible contains "skel,sk33"
Requires compatible contain "skel,sk33"
Describes all the basic properties of the device
SK34 binding:
Applies when compatible contains "skel,sk34"
Requires compatible contain "skel,sk34" AND "skel,sk33" Inherits the SK33 binding
Describes any properties necessary for SK34 extensions
SK35 binding
Applies when compatible contains "skel,sk35"
Requires compatible contains "skel,sk35", "skel,sk34" AND "skel,sk33" Inherits the SK34 binding
Describes any properties for SK35 extensions
SK38 binding
Applies when compatible contains "skel,sk38"
Requires compatible contains "skel,sk38" AND "skel,sk33" Requires compatible DOES NOT contain "skel,sk34" or
"skel,sk35" (arguably you don't need to specify that, though)
Inherits the SK33 binding
Describes any properties for SK38 extensions

Plus, for backwards compatibility you might have to have the:

SK3x binding
Deprecated
Applies when compatible contains "skel,sk3x" Inherits the SK33 binding

Quoted 4 lines

It is also very common for licensed IP blocks. All
the vendors have different quirks and possibly different versions of the IP. In the better cases, we can have a vendor compat for each vendor and then a generic compat.

So, similar considerations here. You really have a bunch of at least potentially different bindings for each licensed variant, but all based on the core common binding.

Quoted 4 lines
Quoted 4 lines

Fwiw, I think the right way to encode "OR" at least in the "tag" is to pick just the preferred form, then have additional bindings tagged on the alternative forms and inheriting the main binding. I don't know if that's practical in the short term though.

But, yeah, these are common cases so we need a less verbose way of describing it than the full version above. At least when the differences between the devices don't require any new properties at all.

I think we want to special case this for the compatible property though. I thinkAND and OR conditions will be complex, while still not really expressing what we need for compatible.

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines

The complicated case is "one of {specific names} followed by {generic name}."

Documentation/devicetree/bindings/skeleton.yaml line 21

Quoted 4 lines
Documentation/devicetree/bindings/skeleton.yaml new file +4 -0
+    description: A clone of the original sk11 device
+
+required:
+  - name: "reg"

We definitely need type info from the start.

Quoted 5 lines
Quoted 3 lines

It's interesting you should mention that here, because 'reg' is actually a hard case for describint the type: because it's format is determined as much by the parent bus binding as this node's binding.

And reg is well defined, so that's one I'm least worried about.

True/

Quoted 41 lines
Quoted 3 lines

I suspect it will be worth special-casing "reg" in order to make common bindings more compact, but again, probably not in the first pass.

Yes, I would fully expect reg to just be flagged as used and how many addresses.

Quoted 26 lines
Quoted 10 lines

Documentation/devicetree/bindings/skeleton.yaml line 23

Quoted 3 lines
Documentation/devicetree/bindings/skeleton.yaml new file +2 -0
+    description: chip select address of skeleton device
+    reference: spi-slave

I would like to not have to list properties if the inherited binding lists it. The problem is we need to say how many cells and the order (not a problem here, but for mmio devices).

Perhaps we can list the reference at the top level for the node instead of for every property.

Yeah, I think it would be worth having a top-level "inherits" field.

Quoted 13 lines

Documentation/devicetree/bindings/skeleton.yaml line 28

Quoted 5 lines
Documentation/devicetree/bindings/skeleton.yaml new file +5 -0
+  - name: "spi-max-frequency"
+    description: >
+      Maximum SPI clocking speed of skeleton device in Hz, must be
+      1000000
+    reference: spi-slave

Rather than listing the property and having constraint in description, perhaps we could add constraints like this:

- spi-max-frequency-range: 1000000 1000000

Or groups of constraints:

Quoted 7 lines
Quoted 3 lines

- spi-max-frequency-constraints:
range: 1000000 1000000
some-other-constraint: <value>

Not for the first pass I think. What I would suggest is having "description" for pure informational stuff, and "constraint" or maybe just "extra" for normative constraints expressed in English.

Quoted 5 lines

At least for simple constraints, I don't see the point of manually converting to something still not machine parse-able. We should be able to figure out a syntax. Sure, there may be complex examples we just punt on, but we can address most common cases. But if we can't define a syntax, then lets do nothing until we do.

Sure.

Quoted 6 lines
Quoted 4 lines

The idea here is that over time we can add new ways of expressing constraints. In the meantime tools can use the "extra" field to preseve any difficult text in the current versions and at least let tools know that they won't be able to check everything.

Just keeping the existing doc text will preserve things.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#34 lore raw

Re: [RFC PATCH 2/5] Documentation: dt-bindings: add example DT binding document

In reply to David Gibson
Quoted 50 lines · David Gibson
Quoted 29 lines · Rob Herring
Quoted 17 lines · Matt Porter

Add a skeleton DT binding document that serves as the canonical example for implementing YAML-based DT bindings documentation. The skeleton binding illustrates use of all fields and variations described in the dt-binding-format.txt documentation.

---
 Documentation/devicetree/bindings/skeleton.yaml | 98 +++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/skeleton.yaml
Documentation/devicetree/bindings/skeleton.yaml new file +0 -0
new file mode 100644
index 0000000..175965f

Documentation/devicetree/bindings/skeleton.yaml line 8

Quoted 8 lines
Documentation/devicetree/bindings/skeleton.yaml new file +8 -0
@@ -0,0 +1,98 @@
+%YAML 1.2
+---
+id: skel-device
+
+title: Skeleton Device
+
+maintainer:
+  - name: Skeleton Person <[email protected]>

We'd want to tie this into get_maintainers.pl obviously.

Quoted 11 lines

Documentation/devicetree/bindings/skeleton.yaml line 17

Quoted 9 lines
Documentation/devicetree/bindings/skeleton.yaml new file +9 -0
+
+description: >
+  The Skeleton Device binding represents the SK11 device produced by
+  the Skeleton Corporation. The binding can also support compatible
+  clones made by second source vendors.
+
+compatible:
+  - name: "skel,sk11"
+  - name: "faux,fx11"

Is this an OR or AND? We need both.

Hrm. So, from the example below it's an OR. But.. I think the considerations here change when you separate out "tag" information as I've suggested elsewhere.

The command AND case, I can think of is where you want both "foo,new-model-device" and "foo,old-model-device". I think the first belongs in the "tag", but the second in the body of the requirements.

Quoted 8 lines

The OR case demonstrated here strikes me as very poor binding design - but that doesn't mean we can totally avoid it, since we do have poor bindings we want to convert.

Fwiw, I think the right way to encode "OR" at least in the "tag" is to pick just the preferred form, then have additional bindings tagged on the alternative forms and inheriting the main binding. I don't know if that's practical in the short term though.

I reworked this as a constraint key with C-like syntax to express allowable compatible strings. It's got some warts but let's take a look at v2 and see if good constraint syntax can handle all these cases. I use some macro like constructs to denote a generic compatible string that must be included in addition to the part-specific string.

Quoted 10 lines
Quoted 9 lines

The complicated case is "one of {specific names} followed by {generic name}."

Documentation/devicetree/bindings/skeleton.yaml line 21

Quoted 4 lines
Documentation/devicetree/bindings/skeleton.yaml new file +4 -0
+    description: A clone of the original sk11 device
+
+required:
+  - name: "reg"

We definitely need type info from the start.

Quoted 7 lines

It's interesting you should mention that here, because 'reg' is actually a hard case for describint the type: because it's format is determined as much by the parent bus binding as this node's binding.

I suspect it will be worth special-casing "reg" in order to make common bindings more compact, but again, probably not in the first pass.

I've added type in v2 and in comments note the "reg" is indeed a special case and derived not so much from the inherited binding but from the actual parent node as used in an implementation.

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Documentation/devicetree/bindings/skeleton.yaml new file +2 -0
+    description: chip select address of skeleton device
+    reference: spi-slave
Quoted 8 lines
Quoted 6 lines

I would like to not have to list properties if the inherited binding lists it. The problem is we need to say how many cells and the order (not a problem here, but for mmio devices).

Perhaps we can list the reference at the top level for the node instead of for every property.

Yeah, I think it would be worth having a top-level "inherits" field.

Added in v2

Quoted 17 lines
Quoted 9 lines

Documentation/devicetree/bindings/skeleton.yaml line 28

Quoted 5 lines
Documentation/devicetree/bindings/skeleton.yaml new file +5 -0
+  - name: "spi-max-frequency"
+    description: >
+      Maximum SPI clocking speed of skeleton device in Hz, must be
+      1000000
+    reference: spi-slave

Rather than listing the property and having constraint in description, perhaps we could add constraints like this:

Quoted 7 lines

- spi-max-frequency-range: 1000000 1000000

Or groups of constraints:

- spi-max-frequency-constraints:
range: 1000000 1000000
some-other-constraint: <value>

Quoted 8 lines

Not for the first pass I think. What I would suggest is having "description" for pure informational stuff, and "constraint" or maybe just "extra" for normative constraints expressed in English.

The idea here is that over time we can add new ways of expressing constraints. In the meantime tools can use the "extra" field to preseve any difficult text in the current versions and at least let tools know that they won't be able to check everything.

I added the definitions of these and an example of use. This by no means indicates that we plan to add constraints for every converted binding. However, in some cases it's very easy to add with a C-like constraint syntax. I'm sure there's cases where this will fall over and needs to be extended but let's review that in the context of the v2 posting.

-Matt

#35 lore raw

RFC PATCH 3/5 Documentation: dt-bindings: add YAML eeprom binding

In reply to a message not in the archive

Convert the eeprom.txt binding to standard YAML DT binding format.

---
 Documentation/devicetree/bindings/eeprom.yaml | 44 +++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/eeprom.yaml
Documentation/devicetree/bindings/eeprom.yaml new file +44 -0
new file mode 100644
index 0000000..bf1244b
@@ -0,0 +1,44 @@
+%YAML 1.2
+---
+id: eeprom-i2c
+
+title: EEPROMs (I2C)
+
+compatible:
+  - name: "<manufacturer>,24c00"
+  - name: "<manufacturer>,24c01"
+  - name: "<manufacturer>,24c02"
+  - name: "<manufacturer>,24c04"
+  - name: "<manufacturer>,24c08"
+  - name: "<manufacturer>,24c16"
+  - name: "<manufacturer>,24c32"
+  - name: "<manufacturer>,24c64"
+  - name: "<manufacturer>,24c128"
+  - name: "<manufacturer>,24c256"
+  - name: "<manufacturer>,24c512"
+  - name: "<manufacturer>,24c1024"
+  - name: "<manufacturer>,spd"
+
+required:
+  - name: "reg"
+    description: the I2c address of the EEPROM
+
+optional:
+  - name: "pagesize"
+    description: >
+      the length of the pagesize for writing. Please consult the
+      manual of your device, that value varies a lot. A wrong value
+      may result in data loss! If not specified, a safety value of
+      '1' is used which will be very slow.
+  - name: "read-only"
+    description: >
+      this parameterless property disables writes to the eeprom
+
+example:
+  - dts: |
+      eeprom@52 {
+              compatible = "atmel,24c32";
+              reg = <0x52>;
+              pagesize = <32>;
+       };
+...
Signature · 1 line
2.1.4
#36 lore raw

RFC PATCH 4/5 Documentation: dt-bindings: phy: add YAML generic PHY binding

In reply to a message not in the archive

Convert the generic phy-bindings.txt binding to standard YAML DT binding format.

---
 .../devicetree/bindings/phy/phy-bindings.yaml      | 89 ++++++++++++++++++++++
 1 file changed, 89 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-bindings.yaml
Documentation/devicetree/bindings/phy/phy-bindings.yaml new file +89 -0
new file mode 100644
index 0000000..9b164d1
@@ -0,0 +1,89 @@
+%YAML 1.2
+---
+id: phy-device
+
+title: PHY device
+
+description: >
+  This document explains only the device tree data binding.  For general
+  information about PHY subsystem refer to Documentation/phy.txt
+
+required:
+  - name: "#phy-cells"
+    description: >
+      number of cells in a PHY specifier. The meaning of all those
+      cells is defined by the binding for the phy node. The PHY
+      provider can use the values in cells to find the appropriate
+      PHY.
+
+optional:
+  - name: "phy-supply"
+    description: >
+      phandle to a regulator that provides power to the PHY. This
+      regulator will be managed during the PHY power on/off sequence.
+
+example:
+  - dts: |
+      phys: phy {
+          compatible = "xxx";
+          reg = <...>;
+          .
+          .
+          #phy-cells = <1>;
+          .
+          .
+      };
+    description: >
+      Describes an IP block (PHY provider) that implements 2 different
+      PHYs. In order to differentiate between these 2 PHYs, an
+      additional specifier should be given while trying to get a
+      reference to it.
+...
+
+---
+id: phy-user
+
+title: PHY user
+
+required:
+  - name: "phys"
+    description: >
+      the phandle for the PHY device (used by the PHY subsystem)
+  - name: "phy-names"
+    description: >
+      the names of the PHY corresponding to the PHYs present in the
+      *phys* phandle
+
+example:
+  - dts: |
+      usb1: usb_otg_ss@xxx {
+          compatible = "xxx";
+          reg = <xxx>;
+          .
+          .
+          phys = <&usb2_phy>, <&usb3_phy>;
+          phy-names = "usb2phy", "usb3phy";
+          .
+          .
+      };
+    description: >
+       Represents a controller that uses two PHYs, one for usb2 and one
+       for usb3.
+
+  - dts: |
+      usb2: usb_otg_ss@xxx {
+          compatible = "xxx";
+          reg = <xxx>;
+          .
+          .
+          phys = <&phys 1>;
+          phy-names = "usbphy";
+          .
+          .
+      };
+    description: >
+      Represents a controller that uses one of the PHYs of the PHY
+      provider device defined previously. Note that the phy handle
+      has an additional specifier "1" to differentiate between the
+      two PHYs.
+...
Signature · 1 line
2.1.4
#37 lore raw

RFC PATCH 5/5 Documentation: dt-bindings: phy: add YAML TI PHY binding

In reply to a message not in the archive

Convert the ti-phy.txt binding to standard YAML DT binding format. This binding references the YAML generic PHY binding.

---
 Documentation/devicetree/bindings/phy/ti-phy.yaml | 166 ++++++++++++++++++++++
 1 file changed, 166 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/ti-phy.yaml
Documentation/devicetree/bindings/phy/ti-phy.yaml new file +166 -0
new file mode 100644
index 0000000..ec93501
@@ -0,0 +1,166 @@
+%YAML 1.2
+---
+id: omap-control-phy
+
+title: OMAP Control PHY
+
+compatible:
+  - name: "ti,control-phy-otghs"
+    description: if it has otghs_control mailbox register as on OMAP4.
+  - name: "ti,control-phy-usb2"
+    description: if it has Power down bit in control_dev_conf register
+                 e.g. USB2_PHY on OMAP5.
+  - name: "ti,control-phy-pipe3"
+    description: if it has DPLL and individual Rx & Tx power control
+                 e.g. USB3 PHY and SATA PHY on OMAP5.
+  - name: "ti,control-phy-pcie"
+    description: for pcie to support external clock for pcie and to
+                 set PCS delay value. e.g. PCIE PHY in DRA7x
+  - name: "ti,control-phy-usb2-dra7"
+    description: if it has power down register like USB2 PHY on DRA7
+                 DRA7 platform.
+  - name: "ti,control-phy-usb2-am437"
+    description: if it has power down register like USB2 PHY on AM437
+                 platform.
+required:
+  - name: "reg"
+    description: register ranges as listed in the reg-names property
+  - name: "reg-names"
+    description: >
+                 "otghs_control" for control-phy-otghs "power",
+                 "pcie_pcs" and "control_sma" for control-phy-pcie
+                 "power" for all other types
+
+example:
+  - dts: |
+      omap_control_usb: omap-control-usb@4a002300 {
+              compatible = "ti,control-phy-otghs";
+              reg = <0x4a00233c 0x4>;
+              reg-names = "otghs_control";
+      };
+...
+
+---
+id: omap-usb2-phy
+
+title: OMAP USB2 PHY
+
+compatible:
+  - name: "ti,omap-usb2"
+
+required:
+  - name: "reg"
+    description: >
+                 Address and length of the register set for the device.
+  - name: "#phy-cells"
+    description: >
+                 determine the number of cells that should be given in
+                 the phandle while referencing this phy.
+    reference: phy-device
+  - name: "clocks"
+    description: >
+                 a list of phandles and clock-specifier pairs, one for
+                 each entry in clock-names.
+    reference: clock-consumer
+  - name: "clock-names"
+    description: >
+                 should include:
+                 * "wkupclk" - wakeup clock.
+                 * "refclk" - reference clock (optional).
+    reference: clock-consumer
+
+optional:
+  - name: "ctrl-module"
+    description: >
+                 phandle of the control module used by PHY driver to
+                 power on the PHY.
+
+example:
+  - dts: |
+      usb2phy@4a0ad080 {
+                compatible = "ti,omap-usb2";
+                reg = <0x4a0ad080 0x58>;
+                ctrl-module = <&omap_control_usb>;
+                #phy-cells = <0>;
+                clocks = <&usb_phy_cm_clk32k>, <&usb_otg_ss_refclk960m>;
+                clock-names = "wkupclk", "refclk";
+      };
+    description: >
+                 This is usually a subnode of ocp2scp to which it is
+                 connected.
+...
+
+---
+id: ti-pipe3-phy
+
+title: TI Pipe3 PHY
+
+compatible:
+  - name: "ti,phy-usb3"
+  - name: "ti,phy-pipe3-sata"
+  - name: "ti,phy-pipe3-pcie"
+  - deprecated: "ti,omap-usb3"
+
+required:
+  - name: "reg"
+    description: >
+                 Address and length of the register set for the device.
+  - name: "reg-names"
+    description: >
+                 The names of the register addresses corresponding to
+                 the registers filled in "reg".
+  - name: "#phy-cells"
+    description: >
+                 determine the number of cells that should be given in
+                 the phandle while referencing this phy.
+    reference: phy-device
+  - name: "clocks"
+    description: >
+                 a list of phandles and clock-specifier pairs, one for
+                 each entry in clock-names.
+    reference: clock-consumer
+  - name: "clock-names"
+    description: >
+                 should include:
+                 * "wkupclk" - wakeup clock.
+                 * "sysclk" - system clock.
+                 * "refclk" - reference clock.
+                 * "dpll_ref" - external dpll ref clk
+                 * "dpll_ref_m2" - external dpll ref clk
+                 * "phy-div" - divider for apll
+                 * "div-clk" - apll clock
+    reference: clock-consumer
+
+optional:
+  - name: "ctrl-module"
+    description: >
+                 phandle of the control module used by PHY driver to
+                 power on the PHY.
+  - name: "id"
+    description: >
+                 If there are multiple instance of the same type, in
+                 order to differentiate between each instance "id"
+                 can be used (e.g., multi-lane PCIe PHY). If "id" is
+                 not provided, it is set to default value of '1'.
+
+example:
+  - dts: |
+      usb3phy@4a084400 {
+              compatible = "ti,phy-usb3";
+              reg = <0x4a084400 0x80>,
+                    <0x4a084800 0x64>,
+                    <0x4a084c00 0x40>;
+              reg-names = "phy_rx", "phy_tx", "pll_ctrl";
+              ctrl-module = <&omap_control_usb>;
+              #phy-cells = <0>;
+              clocks = <&usb_phy_cm_clk32k>,
+                       <&sys_clkin>,
+                       <&usb_otg_ss_refclk960m>;
+              clock-names = "wkupclk",
+                            "sysclk",
+                            "refclk";
+      };
+    description: >
+                 This is usually a subnode of ocp2scp to which it is
+                 connected.
+...
Signature · 1 line
2.1.4

A message that is not in the archive (sent off-list or not yet received): 1440739433-6799-6-git-send-email-mporter-OWPKS81ov/FWk0Htik3J/[email protected]

#39 lore raw

Re: [RFC PATCH 5/5] Documentation: dt-bindings: phy: add YAML TI PHY binding

Quoted 29 lines · Matt Porter

Convert the ti-phy.txt binding to standard YAML DT binding format. This binding references the YAML generic PHY binding.

---
 Documentation/devicetree/bindings/phy/ti-phy.yaml | 166 ++++++++++++++++++++++
 1 file changed, 166 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/ti-phy.yaml
Documentation/devicetree/bindings/phy/ti-phy.yaml new file +14 -0
new file mode 100644
index 0000000..ec93501
@@ -0,0 +1,166 @@
+%YAML 1.2
+---
+id: omap-control-phy
+
+title: OMAP Control PHY
+
+compatible:
+  - name: "ti,control-phy-otghs"
+    description: if it has otghs_control mailbox register as on OMAP4.
+  - name: "ti,control-phy-usb2"
+    description: if it has Power down bit in control_dev_conf register
+                 e.g. USB2_PHY on OMAP5.
+  - name: "ti,control-phy-pipe3"
+    description: if it has DPLL and individual Rx & Tx power control

Documentation/devicetree/bindings/phy/ti-phy.yaml line 24

Quoted 10 lines
Documentation/devicetree/bindings/phy/ti-phy.yaml new file +10 -0
+                 e.g. USB3 PHY and SATA PHY on OMAP5.
+  - name: "ti,control-phy-pcie"
+    description: for pcie to support external clock for pcie and to
+                 set PCS delay value. e.g. PCIE PHY in DRA7x
+  - name: "ti,control-phy-usb2-dra7"
+    description: if it has power down register like USB2 PHY on DRA7
+                 DRA7 platform.
+  - name: "ti,control-phy-usb2-am437"
+    description: if it has power down register like USB2 PHY on AM437
+                 platform.

I'm confused. If these descriptions are multi-line, don't they need the '>' syntax?

Also, I'm still confused by the "name:" field in this section. These are possible *values* for the compatible property, not the name of the field, as all other property descriptions are.

...
-- Tim

A message that is not in the archive (sent off-list or not yet received): CA+bK7J5jz0wxgA-0jY4LFUWWoTk4YzGaGSQZsdF83BnomoBx6w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#41 lore raw

Re: [RFC PATCH 5/5] Documentation: dt-bindings: phy: add YAML TI PHY binding

Quoted 35 lines · Tim Bird
Quoted 34 lines · Matt Porter

Convert the ti-phy.txt binding to standard YAML DT binding format. This binding references the YAML generic PHY binding.

---
 Documentation/devicetree/bindings/phy/ti-phy.yaml | 166 ++++++++++++++++++++++
 1 file changed, 166 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/ti-phy.yaml
Documentation/devicetree/bindings/phy/ti-phy.yaml new file +19 -0
new file mode 100644
index 0000000..ec93501
@@ -0,0 +1,166 @@
+%YAML 1.2
+---
+id: omap-control-phy
+
+title: OMAP Control PHY
+
+compatible:
+  - name: "ti,control-phy-otghs"
+    description: if it has otghs_control mailbox register as on OMAP4.
+  - name: "ti,control-phy-usb2"
+    description: if it has Power down bit in control_dev_conf register
+                 e.g. USB2_PHY on OMAP5.
+  - name: "ti,control-phy-pipe3"
+    description: if it has DPLL and individual Rx & Tx power control
+                 e.g. USB3 PHY and SATA PHY on OMAP5.
+  - name: "ti,control-phy-pcie"
+    description: for pcie to support external clock for pcie and to
+                 set PCS delay value. e.g. PCIE PHY in DRA7x
+  - name: "ti,control-phy-usb2-dra7"
Quoted 8 lines

Documentation/devicetree/bindings/phy/ti-phy.yaml line 24

Quoted 5 lines
Documentation/devicetree/bindings/phy/ti-phy.yaml new file +5 -0
+    description: if it has power down register like USB2 PHY on DRA7
+                 DRA7 platform.
+  - name: "ti,control-phy-usb2-am437"
+    description: if it has power down register like USB2 PHY on AM437
+                 platform.

I'm confused. If these descriptions are multi-line, don't they need the '>' syntax?

Consider that a bug ;) Yes, they should have '>'. Since I'm just using the default core yaml schema validator this is perfectly legal when I run it through yaml. It would mess up formating when output to a document.

Quoted 3 lines

Also, I'm still confused by the "name:" field in this section. These are possible *values* for the compatible property, not the name of the field, as all other property descriptions are.

Ok, so that's a legacy artifact of several incarnations of these tags before I posted initially. I agree, it should be "string" or "value", probably the latter as you suggest.

-Matt
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#42 lore raw
In reply to a message not in the archive
Quoted 11 lines · Matt Porter

During the Device Tree microconference at Linux Plumbers 2015, we had a short discussion about how to improve DT Binding Documentation. A number of issues were raised (again, as these things have been discussed in the past) including:

* Inconsistency between binding documents due to prose text format.
* Inability to reliably machine read bindings for mass update or search.
* Bit rot of bindings as new conventions are agreed upon but only new bindings are changed.

Thanks for pulling this together.

Quoted 17 lines

Grant Likely probably summed up the issue best with "...as long as bindings are human readable, we'll have issues...". The context of that comment was, of course, regarding our current documents written in very inconsistent prose style. When the topic of needing the bindings in a rigid format was raised, there was general head nodding that this was needed. It was noted that this has been discussed many times before and nothing has been done.

My proposed solution to the problem is to convert all DT bindings a rigid text markup format. In choosing a text markup language my requirements were:

1) Human readable
2) Well documented
3) Easy to translate to other data formats
4) Well supported by tools and libraries

Quoted 11 lines

After looking at a number of markup options, YAML stood out as the one that meets all of these requirements. The YAML syntax is adopted in many projects specifically because of the high level of readability. A comprehensive spec is at http://www.yaml.org/spec/1.2/spec.html.
There's a number of tools to convert between YAML and other popular data formats such as JSON and XML. XML was cited by Behan Webster during the microconference as an important data format as the type of developers that may produce comprehensive DTS Binding validation tools will want to use XML. Every major scripting language has a high level binding to the low level libyaml C library to facilitate handling of YAML data files.

Being markup language novice, this looks good to me.

Quoted 5 lines

One caveat with YAML is it does not tolerate tabs. Yes, I said it. No tabs! This can be managed with proper editor modes and also with helper scripts to strip tabs to aid in people passing planned checkpatch.pl checks that would run YAML DT Binding specific tag validators for new bindings.

What do parsers do with tabs? Throw an error?

Beyond tabs, how do we check files can be parsed both generically and for any binding specific requirements. We now need a schema for checking the schema. We need some equivalent to compile testing.

An example such as checking that compatible strings are documented as checkpatch.pl does would be nice. Roughly, that would be just list all compatible values.

Quoted 23 lines

The scope of the initial YAML DT Binding format was specifically limited to supporting *only* the content we have in bindings today. The idea here is to propose and agree on something that will take us just a few steps in the right direction. If we move *all* current binding content to a machine parseable format, additional features can be added with more automation and scripting. As it stands today, because of the inconsistency of the wording of the files, we can't add a lot of new features to the content until we convert what we have today into a standard format.

With that said, it should be noted that some new features such as "type" tags to indicate cell types could be added to support additional DTS validation beyond what the current content supports. Another possibility is adding "range" type information to validate the legal values for a cell.

This series is broken up into three major parts:

1) The documentation defining the YAML DT binding format
2) A skeleton device binding example illustrating use of this format
3) Some real binding conversions (eeprom.txt, phy-bindings.txt, and ti-phy.txt

Quoted 5 lines

As a proof of concept of what can be done with a proper machine readable DT binding source file, there's a simple markdown document generator at https://github.com/konsulko/dtgendoc. Also, to see actual output from the generator, the generated markdown from those bindings is viewable at https://github.com/konsulko/dtgendoc/wiki

Nice.

Quoted 10 lines

There's a lot of other possibilities for validation tools using only the data we have today in the bindings. In addition, Frank Rowand covered some DT debug techniques that would benefit from the binding documentation being 100% reliably searchable.

I found it useful to see a side-by-side view of a converted doc versus the original content, so here's a screenshot of eeprom.txt vs. eeprom.yaml:
https://github.com/konsulko/dtgendoc/wiki#eepromtxt-vs-eepromyaml

Quoted 4 lines

When we decide on a text markup format that is acceptable, then the next step is to convert all the bindings. That process would start with the complete set of generic bindings as they will be referenced by the actual device bindings.

You are going to do that for everyone, right? ;)

I've got some comments on the specific format as well.

Rob

A message that is not in the archive (sent off-list or not yet received): CAL_Jsq+qCJfLYxVfyQ4gAxPWLZ2=WNa0H21+cRcBi7dGVG0PMA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#44 lore raw
Quoted 46 lines · Rob Herring
Quoted 11 lines · Matt Porter

During the Device Tree microconference at Linux Plumbers 2015, we had a short discussion about how to improve DT Binding Documentation. A number of issues were raised (again, as these things have been discussed in the past) including:

* Inconsistency between binding documents due to prose text format.
* Inability to reliably machine read bindings for mass update or search.
* Bit rot of bindings as new conventions are agreed upon but only new bindings are changed.

Thanks for pulling this together.

Quoted 17 lines

Grant Likely probably summed up the issue best with "...as long as bindings are human readable, we'll have issues...". The context of that comment was, of course, regarding our current documents written in very inconsistent prose style. When the topic of needing the bindings in a rigid format was raised, there was general head nodding that this was needed. It was noted that this has been discussed many times before and nothing has been done.

My proposed solution to the problem is to convert all DT bindings a rigid text markup format. In choosing a text markup language my requirements were:

1) Human readable
2) Well documented
3) Easy to translate to other data formats
4) Well supported by tools and libraries

Quoted 11 lines

After looking at a number of markup options, YAML stood out as the one that meets all of these requirements. The YAML syntax is adopted in many projects specifically because of the high level of readability. A comprehensive spec is at http://www.yaml.org/spec/1.2/spec.html.
There's a number of tools to convert between YAML and other popular data formats such as JSON and XML. XML was cited by Behan Webster during the microconference as an important data format as the type of developers that may produce comprehensive DTS Binding validation tools will want to use XML. Every major scripting language has a high level binding to the low level libyaml C library to facilitate handling of YAML data files.

Being markup language novice, this looks good to me.

Quoted 7 lines
Quoted 5 lines

One caveat with YAML is it does not tolerate tabs. Yes, I said it. No tabs! This can be managed with proper editor modes and also with helper scripts to strip tabs to aid in people passing planned checkpatch.pl checks that would run YAML DT Binding specific tag validators for new bindings.

What do parsers do with tabs? Throw an error?

Yes, they throw an error. Keep in mind that most of what I used to start are general purpose conversion tools on top of a particular scripting languages's high level binding to libyaml. The error output leaves a bit to be desired for our use case. In any case, when I was developing the skeleton.yaml I used the yaml script from
https://github.com/ryo/yamltools to catch all these syntax errors I was inserting..like tabs. the PyYaml binding being used in my PoC dtgendoc does the same thing but I don't gracefully handle those errors like we could.

Quoted 3 lines

Beyond tabs, how do we check files can be parsed both generically and for any binding specific requirements. We now need a schema for checking the schema. We need some equivalent to compile testing.

Right. So, I think what you are touching on is something I should have expanded on in the TODO list. Basically, we need a scripted tool that we run from checkpatch.pl that 1) reads the .yaml and validates the YAML itself (that comes for free in the high level parsers) reporting errors in a sensical manner 2) validates our DT binding specific tags

Now, I would caution about trying to do too much on Day 1 or we could end up back at the "never doing anything" stage. It would be an improvement to simply check that the basic tags exist as shown in the [R] or [O] fields in the documentation. One thing I should point out is that I carefully avoided marking some tags as [R] where existing bindings don't have them...even if logically, a description should be required on every binding. The idea here is to avoid updating content at the same time that we are updating the format. Rather, I think it would be better to get the base format updated, then come back with a janitorial team and add descriptions (since now we can generate a worklist of those bindings missing a top-level description) and systematically fix those and review with the appropriate maintainers.

Quoted 3 lines

An example such as checking that compatible strings are documented as checkpatch.pl does would be nice. Roughly, that would be just list all compatible values.

Ok, so my comments above were strictly about a validator for the binding doc submission itself. I can add an example based on your checkpatch.pl to adapt it to the .yaml compatible tags.

Quoted 41 lines
Quoted 23 lines

The scope of the initial YAML DT Binding format was specifically limited to supporting *only* the content we have in bindings today. The idea here is to propose and agree on something that will take us just a few steps in the right direction. If we move *all* current binding content to a machine parseable format, additional features can be added with more automation and scripting. As it stands today, because of the inconsistency of the wording of the files, we can't add a lot of new features to the content until we convert what we have today into a standard format.

With that said, it should be noted that some new features such as "type" tags to indicate cell types could be added to support additional DTS validation beyond what the current content supports. Another possibility is adding "range" type information to validate the legal values for a cell.

This series is broken up into three major parts:

1) The documentation defining the YAML DT binding format
2) A skeleton device binding example illustrating use of this format
3) Some real binding conversions (eeprom.txt, phy-bindings.txt, and ti-phy.txt

Quoted 5 lines

As a proof of concept of what can be done with a proper machine readable DT binding source file, there's a simple markdown document generator at https://github.com/konsulko/dtgendoc. Also, to see actual output from the generator, the generated markdown from those bindings is viewable at https://github.com/konsulko/dtgendoc/wiki

Nice.

Quoted 10 lines

There's a lot of other possibilities for validation tools using only the data we have today in the bindings. In addition, Frank Rowand covered some DT debug techniques that would benefit from the binding documentation being 100% reliably searchable.

I found it useful to see a side-by-side view of a converted doc versus the original content, so here's a screenshot of eeprom.txt vs. eeprom.yaml:
https://github.com/konsulko/dtgendoc/wiki#eepromtxt-vs-eepromyaml

Quoted 6 lines
Quoted 4 lines

When we decide on a text markup format that is acceptable, then the next step is to convert all the bindings. That process would start with the complete set of generic bindings as they will be referenced by the actual device bindings.

You are going to do that for everyone, right? ;)

Let's just say that I'm banking on others helping here once we have a format agreed upon. If we can hold the binding doc schema definition initially to just define tags for content that already exists in our textual binding docs, the effort for conversion is tolerable. To give an example, that phy-bindings.txt, it took 15 minutes to convert and and pass through the yaml parser and dtgendoc. The reason is that it's pure reformatting work. It doesn't take any special knowledge of the hardware and it doesn't involve reviewing dts files to extra additional information. Some of the annoyances can be streamlined like tab stripping and handling the two space indentation to make this process faster. One of my next things is to get a simple tool going that reports problems with conversions, essentially what I said was needed to integrate with checkpatch, so this process of conversion is even faster. Trivial peripheral bindings like eeprom.txt can be done in 5 minutes or so right now.

If we decide we must have tags like "type:" in the initial binding doc schema definition *and* we must add that content in each conversion, then this becomes more time consuming to validate that information against working dts files. IMHO, we'd be better off to get the base format straight, addressing missing pieces like all the compatible permutations, and convert them all with just that content. After that, we come back and add new content features like type: tagging. I'm trying to find a reasonable place to do this incrementally since the volume of bindings to convert is enormous.

But to answer your question, if we get a format I'll do conversions and hope I'm not alone.

Quoted 1 line

I've got some comments on the specific format as well.

Great, thanks.

-Matt

#45 lore raw
Quoted 4 lines · Matt Porter
Quoted 3 lines · Rob Herring
Quoted 2 lines · Matt Porter

During the Device Tree microconference at Linux Plumbers 2015, we had a short discussion about how to improve DT Binding Documentation. A

[...]

Quoted 22 lines
Quoted 7 lines
Quoted 5 lines

One caveat with YAML is it does not tolerate tabs. Yes, I said it. No tabs! This can be managed with proper editor modes and also with helper scripts to strip tabs to aid in people passing planned checkpatch.pl checks that would run YAML DT Binding specific tag validators for new bindings.

What do parsers do with tabs? Throw an error?

Yes, they throw an error. Keep in mind that most of what I used to start are general purpose conversion tools on top of a particular scripting languages's high level binding to libyaml. The error output leaves a bit to be desired for our use case. In any case, when I was developing the skeleton.yaml I used the yaml script from
https://github.com/ryo/yamltools to catch all these syntax errors I was inserting..like tabs. the PyYaml binding being used in my PoC dtgendoc does the same thing but I don't gracefully handle those errors like we could.

Quoted 3 lines

Beyond tabs, how do we check files can be parsed both generically and for any binding specific requirements. We now need a schema for checking the schema. We need some equivalent to compile testing.

Quoted 6 lines

Right. So, I think what you are touching on is something I should have expanded on in the TODO list. Basically, we need a scripted tool that we run from checkpatch.pl that 1) reads the .yaml and validates the YAML itself (that comes for free in the high level parsers) reporting errors in a sensical manner 2) validates our DT binding specific tags

We all know that no one runs checkpatch.pl. ;) I really want the basic checking of the doc files to run from make (and run by 0-day). The tool dependency could be an issue though. However, DocBook builds from make and I don't think many people check that regularly. Then there is using the binding docs to check dts files. That should probably be part of the dtb building.

Quoted 2 lines

Now, I would caution about trying to do too much on Day 1 or we could end up back at the "never doing anything" stage.

Certainly, but I would like to have a plan for what Day 2 and 3 look like.

Quoted 4 lines

It would
be an improvement to simply check that the basic tags exist as shown in the [R] or [O] fields in the documentation. One thing I should point out is that I carefully avoided marking some tags

Quoted 8 lines

as [R] where existing bindings don't have them...even if logically, a description should be required on every binding. The idea here is to avoid updating content at the same time that we are updating the format. Rather, I think it would be better to get the base format updated, then come back with a janitorial team and add descriptions (since now we can generate a worklist of those bindings missing a top-level description) and systematically fix those and review with the appropriate maintainers.

Yes. Any checking would be a great improvement.

[...]

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines

When we decide on a text markup format that is acceptable, then the next step is to convert all the bindings. That process would start with the complete set of generic bindings as they will be referenced by the actual device bindings.

You are going to do that for everyone, right? ;)

Quoted 15 lines

Let's just say that I'm banking on others helping here once we have a format agreed upon. If we can hold the binding doc schema definition initially to just define tags for content that already exists in our textual binding docs, the effort for conversion is tolerable. To give an example, that phy-bindings.txt, it took 15 minutes to convert and and pass through the yaml parser and dtgendoc. The reason is that it's pure reformatting work. It doesn't take any special knowledge of the hardware and it doesn't involve reviewing dts files to extra additional information. Some of the annoyances can be streamlined like tab stripping and handling the two space indentation to make this process faster. One of my next things is to get a simple tool going that reports problems with conversions, essentially what I said was needed to integrate with checkpatch, so this process of conversion is even faster. Trivial peripheral bindings like eeprom.txt can be done in 5 minutes or so right now.

What if instead of using the docs as a starting point, we use dts files as a starting point? They give us something parse-able that we can do some automation with.

Additionaly, perhaps we can do a mass conversion of all the doc files from txt to yaml where all the current text is converted to comments and we fill in boilerplate and whatever we can convert with some automation? The downside here would be it will be hard to tell which conversions are complete.

Putting both together, we could then fairly easily for example extract compatible strings from dts files, lookup which doc file they are in and fill in the compatible string info.

Quoted 10 lines

If we decide we must have tags like "type:" in the initial binding doc schema definition *and* we must add that content in each conversion, then this becomes more time consuming to validate that information against working dts files. IMHO, we'd be better off to get the base format straight, addressing missing pieces like all the compatible permutations, and convert them all with just that content. After that, we come back and add new content features like type: tagging. I'm trying to find a reasonable place to do this incrementally since the volume of bindings to convert is enormous.

I wouldn't say we have to add it, but we need to maintain type info.

Are you proposing we can actually validate dts files on day 1? That I would expect to come later.

Rob

A message that is not in the archive (sent off-list or not yet received): CAL_JsqJ7C4JtjGjFJjLQpLEdzbs2rw0K0TzVNB2VjOz4Sr9Nbw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#47 lore raw
Quoted 37 lines · Rob Herring
Quoted 4 lines · Matt Porter
Quoted 3 lines · Rob Herring
Quoted 2 lines · Matt Porter

During the Device Tree microconference at Linux Plumbers 2015, we had a short discussion about how to improve DT Binding Documentation. A

[...]

Quoted 22 lines
Quoted 7 lines
Quoted 5 lines

One caveat with YAML is it does not tolerate tabs. Yes, I said it. No tabs! This can be managed with proper editor modes and also with helper scripts to strip tabs to aid in people passing planned checkpatch.pl checks that would run YAML DT Binding specific tag validators for new bindings.

What do parsers do with tabs? Throw an error?

Yes, they throw an error. Keep in mind that most of what I used to start are general purpose conversion tools on top of a particular scripting languages's high level binding to libyaml. The error output leaves a bit to be desired for our use case. In any case, when I was developing the skeleton.yaml I used the yaml script from
https://github.com/ryo/yamltools to catch all these syntax errors I was inserting..like tabs. the PyYaml binding being used in my PoC dtgendoc does the same thing but I don't gracefully handle those errors like we could.

Quoted 3 lines

Beyond tabs, how do we check files can be parsed both generically and for any binding specific requirements. We now need a schema for checking the schema. We need some equivalent to compile testing.

Quoted 6 lines

Right. So, I think what you are touching on is something I should have expanded on in the TODO list. Basically, we need a scripted tool that we run from checkpatch.pl that 1) reads the .yaml and validates the YAML itself (that comes for free in the high level parsers) reporting errors in a sensical manner 2) validates our DT binding specific tags

Quoted 6 lines

We all know that no one runs checkpatch.pl. ;) I really want the basic checking of the doc files to run from make (and run by 0-day). The tool dependency could be an issue though. However, DocBook builds from make and I don't think many people check that regularly. Then there is using the binding docs to check dts files. That should probably be part of the dtb building.

Ok, makes sense. We can do that. I get this uneasy feeling about what happens to all of this *when* bindings and dts files move out of the kernel.

Quoted 4 lines
Quoted 2 lines

Now, I would caution about trying to do too much on Day 1 or we could end up back at the "never doing anything" stage.

Certainly, but I would like to have a plan for what Day 2 and 3 look like.

Sure.

Quoted 41 lines
Quoted 13 lines

It would
be an improvement to simply check that the basic tags exist as shown in the [R] or [O] fields in the documentation. One thing I should point out is that I carefully avoided marking some tags as [R] where existing bindings don't have them...even if logically, a description should be required on every binding. The idea here is to avoid updating content at the same time that we are updating the format. Rather, I think it would be better to get the base format updated, then come back with a janitorial team and add descriptions (since now we can generate a worklist of those bindings missing a top-level description) and systematically fix those and review with the appropriate maintainers.

Yes. Any checking would be a great improvement.

[...]

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines

When we decide on a text markup format that is acceptable, then the next step is to convert all the bindings. That process would start with the complete set of generic bindings as they will be referenced by the actual device bindings.

You are going to do that for everyone, right? ;)

Quoted 15 lines

Let's just say that I'm banking on others helping here once we have a format agreed upon. If we can hold the binding doc schema definition initially to just define tags for content that already exists in our textual binding docs, the effort for conversion is tolerable. To give an example, that phy-bindings.txt, it took 15 minutes to convert and and pass through the yaml parser and dtgendoc. The reason is that it's pure reformatting work. It doesn't take any special knowledge of the hardware and it doesn't involve reviewing dts files to extra additional information. Some of the annoyances can be streamlined like tab stripping and handling the two space indentation to make this process faster. One of my next things is to get a simple tool going that reports problems with conversions, essentially what I said was needed to integrate with checkpatch, so this process of conversion is even faster. Trivial peripheral bindings like eeprom.txt can be done in 5 minutes or so right now.

Quoted 3 lines

What if instead of using the docs as a starting point, we use dts files as a starting point? They give us something parse-able that we can do some automation with.

That's doable, and we know that the dts files actually work.

Quoted 5 lines

Additionaly, perhaps we can do a mass conversion of all the doc files from txt to yaml where all the current text is converted to comments and we fill in boilerplate and whatever we can convert with some automation? The downside here would be it will be hard to tell which conversions are complete.

Yes, basically we get a template and just have some human editing of the text into proper tags to do.

Quoted 3 lines

Putting both together, we could then fairly easily for example extract compatible strings from dts files, lookup which doc file they are in and fill in the compatible string info.

Ok.

Quoted 12 lines
Quoted 11 lines

If we decide we must have tags like "type:" in the initial binding doc schema definition *and* we must add that content in each conversion, then this becomes more time consuming to validate that information against working dts files. IMHO, we'd be better off to get the base format straight, addressing missing pieces like all the compatible permutations, and convert them all with just that content. After that, we come back and add new content features like type: tagging. I'm trying to find a reasonable place to do this incrementally since the volume of bindings to convert is enormous.

Quoted 1 line

I wouldn't say we have to add it, but we need to maintain type info.

You already changed my opinion here. I think from generating the template via working dts files, also have type info will not be challenging. The other factor is we've already agreed that we need to inhereit generic bindings so the volume of properties that have to have types defined is lower as most properties will be inherited from generic bindings.

Quoted 2 lines

Are you proposing we can actually validate dts files on day 1? That I would expect to come later.

No, I expect that to come later. I was speaking only of "human validation" of types while creating docs but I think now it's not a big burden.

-Matt
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#48 lore raw
In reply to Matt Porter
Quoted 2 lines · Matt Porter

Now, I would caution about trying to do too much on Day 1 or we could end up back at the "never doing anything" stage.

I strongly agree with that (despite my having just sent a bunch of comments on the binding format document).

Quoted 8 lines

It would
be an improvement to simply check that the basic tags exist as shown in the [R] or [O] fields in the documentation. One thing I should point out is that I carefully avoided marking some tags as [R] where existing bindings don't have them...even if logically, a description should be required on every binding. The idea here is to avoid updating content at the same time that we are updating the format.

I strongly agree with this as well. I think that the goal for the first pass should be "no lost text". That is, if it doesn't convert into something in the binding format, it should still be preserved somewhere, for evaluation and formatting on a subsequent pass.

Quoted 5 lines

Rather, I think it would be better to get the base format updated, then come back with a janitorial team and add descriptions (since now we can generate a worklist of those bindings missing a top-level description) and systematically fix those and review with the appropriate maintainers.

Agreed. It will be very useful, once we get our first pass done, to be able to find: 1) documents not converted yet, 2) property definitions that are missing certain fields, 3) things that could still be formatted, from text that is remaining in the description strings or other free-form text. This should be easy to script.

Quoted 83 lines
Quoted 3 lines

An example such as checking that compatible strings are documented as checkpatch.pl does would be nice. Roughly, that would be just list all compatible values.

Ok, so my comments above were strictly about a validator for the binding doc submission itself. I can add an example based on your checkpatch.pl to adapt it to the .yaml compatible tags.

Quoted 41 lines
Quoted 23 lines

The scope of the initial YAML DT Binding format was specifically limited to supporting *only* the content we have in bindings today. The idea here is to propose and agree on something that will take us just a few steps in the right direction. If we move *all* current binding content to a machine parseable format, additional features can be added with more automation and scripting. As it stands today, because of the inconsistency of the wording of the files, we can't add a lot of new features to the content until we convert what we have today into a standard format.

With that said, it should be noted that some new features such as "type" tags to indicate cell types could be added to support additional DTS validation beyond what the current content supports. Another possibility is adding "range" type information to validate the legal values for a cell.

This series is broken up into three major parts:

1) The documentation defining the YAML DT binding format
2) A skeleton device binding example illustrating use of this format
3) Some real binding conversions (eeprom.txt, phy-bindings.txt, and ti-phy.txt

Quoted 5 lines

As a proof of concept of what can be done with a proper machine readable DT binding source file, there's a simple markdown document generator at https://github.com/konsulko/dtgendoc. Also, to see actual output from the generator, the generated markdown from those bindings is viewable at https://github.com/konsulko/dtgendoc/wiki

Nice.

Quoted 10 lines

There's a lot of other possibilities for validation tools using only the data we have today in the bindings. In addition, Frank Rowand covered some DT debug techniques that would benefit from the binding documentation being 100% reliably searchable.

I found it useful to see a side-by-side view of a converted doc versus the original content, so here's a screenshot of eeprom.txt vs. eeprom.yaml:
https://github.com/konsulko/dtgendoc/wiki#eepromtxt-vs-eepromyaml

Quoted 6 lines
Quoted 4 lines

When we decide on a text markup format that is acceptable, then the next step is to convert all the bindings. That process would start with the complete set of generic bindings as they will be referenced by the actual device bindings.

You are going to do that for everyone, right? ;)

Let's just say that I'm banking on others helping here once we have a format agreed upon. If we can hold the binding doc schema definition initially to just define tags for content that already exists in our textual binding docs, the effort for conversion is tolerable. To give an example, that phy-bindings.txt, it took 15 minutes to convert and and pass through the yaml parser and dtgendoc. The reason is that it's pure reformatting work. It doesn't take any special knowledge of the hardware and it doesn't involve reviewing dts files to extra additional information. Some of the annoyances can be streamlined like tab stripping and handling the two space indentation to make this process faster. One of my next things is to get a simple tool going that reports problems with conversions, essentially what I said was needed to integrate with checkpatch, so this process of conversion is even faster. Trivial peripheral bindings like eeprom.txt can be done in 5 minutes or so right now.

If we decide we must have tags like "type:" in the initial binding doc schema definition *and* we must add that content in each conversion, then this becomes more time consuming to validate that information against working dts files. IMHO, we'd be better off to get the base format straight, addressing missing pieces like all the compatible permutations, and convert them all with just that content. After that, we come back and add new content features like type: tagging. I'm trying to find a reasonable place to do this incrementally since the volume of bindings to convert is enormous.

Quoted 2 lines

But to answer your question, if we get a format I'll do conversions and hope I'm not alone.

I'm sure others will help out. I will, and I'm pretty sure we can get some conversion sprints set up at conferences (I know I can set aside some time or resources at ELC in the spring - it might be too late for ELCE in October to set up a scheduled block of time, but we can start getting the word out.) As I said in my other e-mail, one doesn't have to be a kernel coder to do this, and the conversions should be pretty straight-forward.
-- Tim

A message that is not in the archive (sent off-list or not yet received): CA+bK7J4Ha55oFhCYDnUcBu8ZHCP3ReB6B=7Y9Fw7CknxPcaoWQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#50 lore raw
Quoted 1 line · Tim Bird

On Fri, Aug 28, 2015 at 10:13 AM, Matt Porter <mporter-OWPKS81ov/FWk0Htik3J/[email protected]> wrote:

< snip >

Quoted 4 lines
Quoted 3 lines

But to answer your question, if we get a format I'll do conversions and hope I'm not alone.

Quoted 9 lines

I'm sure others will help out. I will, and I'm pretty sure we can get some conversion sprints set up at conferences (I know I can set aside some time or resources at ELC in the spring - it might be too late for ELCE in October to set up a scheduled block of time, but we can start getting the word out.) As I said in my other e-mail, one doesn't have to be a kernel coder to do this, and the conversions should be pretty straight-forward.
-- Tim

A conversion sprint at ELCE sounds like a good idea if we can find a good time to schedule it. I can help, so there will be at least two of us who can help people as they encounter issues.

-Frank

A message that is not in the archive (sent off-list or not yet received): [email protected]

#52 lore raw
Quoted 19 lines · Frank Rowand
Quoted 1 line · Tim Bird

On Fri, Aug 28, 2015 at 10:13 AM, Matt Porter <mporter-OWPKS81ov/FWk0Htik3J/[email protected]> wrote:

< snip >

Quoted 4 lines
Quoted 3 lines

But to answer your question, if we get a format I'll do conversions and hope I'm not alone.

Quoted 9 lines

I'm sure others will help out. I will, and I'm pretty sure we can get some conversion sprints set up at conferences (I know I can set aside some time or resources at ELC in the spring - it might be too late for ELCE in October to set up a scheduled block of time, but we can start getting the word out.) As I said in my other e-mail, one doesn't have to be a kernel coder to do this, and the conversions should be pretty straight-forward.
-- Tim

Quoted 3 lines

A conversion sprint at ELCE sounds like a good idea if we can find a good time to schedule it. I can help, so there will be at least two of us who can help people as they encounter issues.

Even if we don't find a block of time, we can do something like announce a "contest", ask people to do something in their spare time, and find some way to get them a raffle ticket if they submit a patch with a conversion. Then hold an extra prize drawing during the closing session, with just those raffle tickets, and give someone a nice award for contributing. Of course, there's always the adage that you should be careful what you measure and reward... We don't want a flood of crappy conversions, with a time constraint on the review. I'll think some more about this. An alternative would be to have a contest announced ahead of the event, with enough time for people to submit and get reviewed.

By the way - I presume the new docs will replace the existing ones, but I could imagine wanting to have them live side-by-side temporarily. Any thoughts on this? Will file name or location changes be allowed during the conversion?
-- Tim

A message that is not in the archive (sent off-list or not yet received): CA+bK7J6kErnKPHs=r+X9T8KBn45HptPmtMe31CoapunKpuY34Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#54 lore raw
Quoted 24 lines · Tim Bird
Quoted 19 lines · Frank Rowand
Quoted 1 line · Tim Bird

On Fri, Aug 28, 2015 at 10:13 AM, Matt Porter <mporter-OWPKS81ov/FWk0Htik3J/[email protected]> wrote:

< snip >

Quoted 4 lines
Quoted 3 lines

But to answer your question, if we get a format I'll do conversions and hope I'm not alone.

Quoted 9 lines

I'm sure others will help out. I will, and I'm pretty sure we can get some conversion sprints set up at conferences (I know I can set aside some time or resources at ELC in the spring - it might be too late for ELCE in October to set up a scheduled block of time, but we can start getting the word out.) As I said in my other e-mail, one doesn't have to be a kernel coder to do this, and the conversions should be pretty straight-forward.
-- Tim

Quoted 3 lines

A conversion sprint at ELCE sounds like a good idea if we can find a good time to schedule it. I can help, so there will be at least two of us who can help people as they encounter issues.

Quoted 11 lines

Even if we don't find a block of time, we can do something like announce a "contest", ask people to do something in their spare time, and find some way to get them a raffle ticket if they submit a patch with a conversion. Then hold an extra prize drawing during the closing session, with just those raffle tickets, and give someone a nice award for contributing. Of course, there's always the adage that you should be careful what you measure and reward... We don't want a flood of crappy conversions, with a time constraint on the review. I'll think some more about this. An alternative would be to have a contest announced ahead of the event, with enough time for people to submit and get reviewed.

Sounds like a review nightmare. That's another reason why as much automated conversion we can do, the better.

Quoted 4 lines

By the way - I presume the new docs will replace the existing ones, but I could imagine wanting to have them live side-by-side temporarily. Any thoughts on this? Will file name or location changes be allowed during the conversion?

I proposed some ideas earlier in the thread. Either we can have both side by side or do a mass conversion to YAML making the existing doc a comment (add # prefix).

Any renames/moving should be separate (there's some clean-up I'd like to there as well). Exact rules depend on the approach, but we need to be able to tell which bindings conversions are not started, in progress, or complete.

Rob

A message that is not in the archive (sent off-list or not yet received): CAL_Jsq+7NQdZivTpwRDwcGrCzpcQQoV5gvSkjz3NNOWNXdBhMA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#56 lore raw
Quoted 37 lines · Rob Herring
Quoted 24 lines · Tim Bird
Quoted 19 lines · Frank Rowand
Quoted 1 line · Tim Bird

On Fri, Aug 28, 2015 at 10:13 AM, Matt Porter <mporter-OWPKS81ov/FWk0Htik3J/[email protected]> wrote:

< snip >

Quoted 4 lines
Quoted 3 lines

But to answer your question, if we get a format I'll do conversions and hope I'm not alone.

Quoted 9 lines

I'm sure others will help out. I will, and I'm pretty sure we can get some conversion sprints set up at conferences (I know I can set aside some time or resources at ELC in the spring - it might be too late for ELCE in October to set up a scheduled block of time, but we can start getting the word out.) As I said in my other e-mail, one doesn't have to be a kernel coder to do this, and the conversions should be pretty straight-forward.
-- Tim

Quoted 3 lines

A conversion sprint at ELCE sounds like a good idea if we can find a good time to schedule it. I can help, so there will be at least two of us who can help people as they encounter issues.

Quoted 11 lines

Even if we don't find a block of time, we can do something like announce a "contest", ask people to do something in their spare time, and find some way to get them a raffle ticket if they submit a patch with a conversion. Then hold an extra prize drawing during the closing session, with just those raffle tickets, and give someone a nice award for contributing. Of course, there's always the adage that you should be careful what you measure and reward... We don't want a flood of crappy conversions, with a time constraint on the review. I'll think some more about this. An alternative would be to have a contest announced ahead of the event, with enough time for people to submit and get reviewed.

Quoted 2 lines

Sounds like a review nightmare. That's another reason why as much automated conversion we can do, the better.

I don't want to discount the value of interested people getting together f2f to review these and potentially clean them up for submission. That depends on what we thinking is the minimal "in progress" conversion that can be place upstream. i.e. is it simply compatible strings autoconverted to tags and the entire current document in comments?

Quoted 9 lines
Quoted 4 lines

By the way - I presume the new docs will replace the existing ones, but I could imagine wanting to have them live side-by-side temporarily. Any thoughts on this? Will file name or location changes be allowed during the conversion?

I proposed some ideas earlier in the thread. Either we can have both side by side or do a mass conversion to YAML making the existing doc a comment (add # prefix).

Were you thinking that this automated conversion would be sufficient for an initial commit? I'm not sure if I misunderstood in your separate comments and was looking at this as something that would be hand edited to move the existing doc (# prefix) into description tags where appropriate.

Quoted 4 lines

Any renames/moving should be separate (there's some clean-up I'd like to there as well). Exact rules depend on the approach, but we need to be able to tell which bindings conversions are not started, in progress, or complete.

If we add .yaml in place we can identify what's in progress by the fact that a .yaml exists with the same filename and then based on which tags have been populated (such as type: and constraints: not yet populated) then we know the state.

-Matt

#57 lore raw
Quoted 38 lines · Matt Porter
Quoted 37 lines · Rob Herring
Quoted 35 lines · Tim Bird
Quoted 19 lines · Frank Rowand
Quoted 1 line · Tim Bird

On Fri, Aug 28, 2015 at 10:13 AM, Matt Porter <mporter-OWPKS81ov/FWk0Htik3J/[email protected]> wrote:

< snip >

Quoted 4 lines
Quoted 3 lines

But to answer your question, if we get a format I'll do conversions and hope I'm not alone.

Quoted 9 lines

I'm sure others will help out. I will, and I'm pretty sure we can get some conversion sprints set up at conferences (I know I can set aside some time or resources at ELC in the spring - it might be too late for ELCE in October to set up a scheduled block of time, but we can start getting the word out.) As I said in my other e-mail, one doesn't have to be a kernel coder to do this, and the conversions should be pretty straight-forward.
-- Tim

Quoted 3 lines

A conversion sprint at ELCE sounds like a good idea if we can find a good time to schedule it. I can help, so there will be at least two of us who can help people as they encounter issues.

Even if we don't find a block of time, we can do something like announce a "contest", ask people to do something in their spare time, and find some way to get them a raffle ticket if they submit a patch with a conversion. Then hold an extra prize drawing during the closing session, with just those raffle tickets, and give someone a nice award for contributing. Of course, there's always the adage that you should be careful what you measure and reward... We don't want a flood of crappy conversions, with a time constraint on the review. I'll think some more about this. An alternative would be to have a contest announced ahead of the event, with enough time for people to submit and get reviewed.

Quoted 8 lines
Quoted 2 lines

Sounds like a review nightmare. That's another reason why as much automated conversion we can do, the better.

I don't want to discount the value of interested people getting together f2f to review these and potentially clean them up for submission. That depends on what we thinking is the minimal "in progress" conversion that can be place upstream. i.e. is it simply compatible strings autoconverted to tags and the entire current document in comments?

That is sufficient for me (I reserve the right to change my mind). Logistically, it needs to be a script that can be run before/during the merge window and perhaps again after. I'd guess the long pole here is how we validate the .yaml files.

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

By the way - I presume the new docs will replace the existing ones, but I could imagine wanting to have them live side-by-side temporarily. Any thoughts on this? Will file name or location changes be allowed during the conversion?

I proposed some ideas earlier in the thread. Either we can have both side by side or do a mass conversion to YAML making the existing doc a comment (add # prefix).

Quoted 5 lines

Were you thinking that this automated conversion would be sufficient for an initial commit? I'm not sure if I misunderstood in your separate comments and was looking at this as something that would be hand edited to move the existing doc (# prefix) into description tags where appropriate.

Yes, I think it is more important to have infrastructure in place to enable others than how much is converted initially. Certainly any changes based on existing docs will have to be manual, but we may be able to do multiple passes of automated conversions. Sharing any conversion scripts is important to enable others for that as well.

Quoted 9 lines
Quoted 4 lines

Any renames/moving should be separate (there's some clean-up I'd like to there as well). Exact rules depend on the approach, but we need to be able to tell which bindings conversions are not started, in progress, or complete.

If we add .yaml in place we can identify what's in progress by the fact that a .yaml exists with the same filename and then based on which tags have been populated (such as type: and constraints: not yet populated) then we know the state.

You mean keeping the .txt and .yaml until done? If we are copying in the current doc, then I'd rather not do that. I don't think looking at the tags will work as it would be hard to distinguish incomplete from done. However, we could simply have an "in-progress" tag that is removed when done (might as well take advantage of our new found structured docs).

Rob

#58 lore raw
In reply to a message not in the archive
Quoted 36 lines · Tim Bird
Quoted 19 lines · Frank Rowand
Quoted 1 line · Tim Bird

On Fri, Aug 28, 2015 at 10:13 AM, Matt Porter <mporter-OWPKS81ov/FWk0Htik3J/[email protected]> wrote:

< snip >

Quoted 4 lines
Quoted 3 lines

But to answer your question, if we get a format I'll do conversions and hope I'm not alone.

Quoted 9 lines

I'm sure others will help out. I will, and I'm pretty sure we can get some conversion sprints set up at conferences (I know I can set aside some time or resources at ELC in the spring - it might be too late for ELCE in October to set up a scheduled block of time, but we can start getting the word out.) As I said in my other e-mail, one doesn't have to be a kernel coder to do this, and the conversions should be pretty straight-forward.
-- Tim

Quoted 3 lines

A conversion sprint at ELCE sounds like a good idea if we can find a good time to schedule it. I can help, so there will be at least two of us who can help people as they encounter issues.

Even if we don't find a block of time, we can do something like announce a "contest", ask people to do something in their spare time, and find some way to get them a raffle ticket if they submit a patch with a conversion. Then hold an extra prize drawing during the closing session, with just those raffle tickets, and give someone a nice award for contributing. Of course, there's always the adage that you should be careful what you measure and reward... We don't want a flood of crappy conversions, with a time constraint on the review. I'll think some more about this. An alternative would be to have a contest announced ahead of the event, with enough time for people to submit and get reviewed.

Quoted 4 lines

By the way - I presume the new docs will replace the existing ones, but I could imagine wanting to have them live side-by-side temporarily. Any thoughts on this? Will file name or location changes be allowed during the conversion?

Good question. As a starting point I simply changed the file extension and they live in the same directory structure with the .txt versions. I can't think of an advantage to moving locations or file names initially. Certainly some file names could use improvement but changing them introduces confusion.

-Matt

#59 lore raw
In reply to a message not in the archive
Quoted 19 lines · Frank Rowand
Quoted 1 line · Tim Bird

On Fri, Aug 28, 2015 at 10:13 AM, Matt Porter <mporter-OWPKS81ov/FWk0Htik3J/[email protected]> wrote:

< snip >

Quoted 4 lines
Quoted 3 lines

But to answer your question, if we get a format I'll do conversions and hope I'm not alone.

Quoted 9 lines

I'm sure others will help out. I will, and I'm pretty sure we can get some conversion sprints set up at conferences (I know I can set aside some time or resources at ELC in the spring - it might be too late for ELCE in October to set up a scheduled block of time, but we can start getting the word out.) As I said in my other e-mail, one doesn't have to be a kernel coder to do this, and the conversions should be pretty straight-forward.
-- Tim

Quoted 3 lines

A conversion sprint at ELCE sounds like a good idea if we can find a good time to schedule it. I can help, so there will be at least two of us who can help people as they encounter issues.

I'll be there as well.

-Matt
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#60 lore raw
In reply to a message not in the archive
Quoted 28 lines · Tim Bird
Quoted 2 lines · Matt Porter

Now, I would caution about trying to do too much on Day 1 or we could end up back at the "never doing anything" stage.

I strongly agree with that (despite my having just sent a bunch of comments on the binding format document).

Quoted 8 lines

It would
be an improvement to simply check that the basic tags exist as shown in the [R] or [O] fields in the documentation. One thing I should point out is that I carefully avoided marking some tags as [R] where existing bindings don't have them...even if logically, a description should be required on every binding. The idea here is to avoid updating content at the same time that we are updating the format.

I strongly agree with this as well. I think that the goal for the first pass should be "no lost text". That is, if it doesn't convert into something in the binding format, it should still be preserved somewhere, for evaluation and formatting on a subsequent pass.

Quoted 5 lines

Rather, I think it would be better to get the base format updated, then come back with a janitorial team and add descriptions (since now we can generate a worklist of those bindings missing a top-level description) and systematically fix those and review with the appropriate maintainers.

Quoted 5 lines

Agreed. It will be very useful, once we get our first pass done, to be able to find: 1) documents not converted yet, 2) property definitions that are missing certain fields, 3) things that could still be formatted, from text that is remaining in the description strings or other free-form text. This should be easy to script.

Exactly, if we were to avoid populating type: and constraints: flags then it is very easy to identify those bindings not yet converted to using those tags.

Quoted 86 lines
Quoted 83 lines
Quoted 3 lines

An example such as checking that compatible strings are documented as checkpatch.pl does would be nice. Roughly, that would be just list all compatible values.

Ok, so my comments above were strictly about a validator for the binding doc submission itself. I can add an example based on your checkpatch.pl to adapt it to the .yaml compatible tags.

Quoted 41 lines
Quoted 23 lines

The scope of the initial YAML DT Binding format was specifically limited to supporting *only* the content we have in bindings today. The idea here is to propose and agree on something that will take us just a few steps in the right direction. If we move *all* current binding content to a machine parseable format, additional features can be added with more automation and scripting. As it stands today, because of the inconsistency of the wording of the files, we can't add a lot of new features to the content until we convert what we have today into a standard format.

With that said, it should be noted that some new features such as "type" tags to indicate cell types could be added to support additional DTS validation beyond what the current content supports. Another possibility is adding "range" type information to validate the legal values for a cell.

This series is broken up into three major parts:

1) The documentation defining the YAML DT binding format
2) A skeleton device binding example illustrating use of this format
3) Some real binding conversions (eeprom.txt, phy-bindings.txt, and ti-phy.txt

Quoted 5 lines

As a proof of concept of what can be done with a proper machine readable DT binding source file, there's a simple markdown document generator at https://github.com/konsulko/dtgendoc. Also, to see actual output from the generator, the generated markdown from those bindings is viewable at https://github.com/konsulko/dtgendoc/wiki

Nice.

Quoted 10 lines

There's a lot of other possibilities for validation tools using only the data we have today in the bindings. In addition, Frank Rowand covered some DT debug techniques that would benefit from the binding documentation being 100% reliably searchable.

I found it useful to see a side-by-side view of a converted doc versus the original content, so here's a screenshot of eeprom.txt vs. eeprom.yaml:
https://github.com/konsulko/dtgendoc/wiki#eepromtxt-vs-eepromyaml

Quoted 6 lines
Quoted 4 lines

When we decide on a text markup format that is acceptable, then the next step is to convert all the bindings. That process would start with the complete set of generic bindings as they will be referenced by the actual device bindings.

You are going to do that for everyone, right? ;)

Let's just say that I'm banking on others helping here once we have a format agreed upon. If we can hold the binding doc schema definition initially to just define tags for content that already exists in our textual binding docs, the effort for conversion is tolerable. To give an example, that phy-bindings.txt, it took 15 minutes to convert and and pass through the yaml parser and dtgendoc. The reason is that it's pure reformatting work. It doesn't take any special knowledge of the hardware and it doesn't involve reviewing dts files to extra additional information. Some of the annoyances can be streamlined like tab stripping and handling the two space indentation to make this process faster. One of my next things is to get a simple tool going that reports problems with conversions, essentially what I said was needed to integrate with checkpatch, so this process of conversion is even faster. Trivial peripheral bindings like eeprom.txt can be done in 5 minutes or so right now.

If we decide we must have tags like "type:" in the initial binding doc schema definition *and* we must add that content in each conversion, then this becomes more time consuming to validate that information against working dts files. IMHO, we'd be better off to get the base format straight, addressing missing pieces like all the compatible permutations, and convert them all with just that content. After that, we come back and add new content features like type: tagging. I'm trying to find a reasonable place to do this incrementally since the volume of bindings to convert is enormous.

Quoted 2 lines

But to answer your question, if we get a format I'll do conversions and hope I'm not alone.

Quoted 7 lines

I'm sure others will help out. I will, and I'm pretty sure we can get some conversion sprints set up at conferences (I know I can set aside some time or resources at ELC in the spring - it might be too late for ELCE in October to set up a scheduled block of time, but we can start getting the word out.) As I said in my other e-mail, one doesn't have to be a kernel coder to do this, and the conversions should be pretty straight-forward.

Agreed, a f2f session would probably kick out a number of things we hadn't yet considered as well. We'll see if we're actually ready with a yaml schema that people are happy with by then though...

-Matt

#61 lore raw
In reply to a message not in the archive
Quoted 20 lines · Matt Porter

During the Device Tree microconference at Linux Plumbers 2015, we had a short discussion about how to improve DT Binding Documentation. A number of issues were raised (again, as these things have been discussed in the past) including:

* Inconsistency between binding documents due to prose text format.
* Inability to reliably machine read bindings for mass update or search.
* Bit rot of bindings as new conventions are agreed upon but only new bindings are changed.

Grant Likely probably summed up the issue best with "...as long as bindings are human readable, we'll have issues...". The context of that comment was, of course, regarding our current documents written in very inconsistent prose style. When the topic of needing the bindings in a rigid format was raised, there was general head nodding that this was needed. It was noted that this has been discussed many times before and nothing has been done.

Quoted 8 lines

My proposed solution to the problem is to convert all DT bindings a rigid text markup format. In choosing a text markup language my requirements were:

1) Human readable
2) Well documented
3) Easy to translate to other data formats
4) Well supported by tools and libraries

Thanks for taking this on! The proposal looks like a great start. The requirements look good.

Quoted 12 lines

After looking at a number of markup options, YAML stood out as the one that meets all of these requirements. The YAML syntax is adopted in many projects specifically because of the high level of readability. A comprehensive spec is at http://www.yaml.org/spec/1.2/spec.html.
There's a number of tools to convert between YAML and other popular data formats such as JSON and XML. XML was cited by Behan Webster during the microconference as an important data format as the type of developers that may produce comprehensive DTS Binding validation tools will want to use XML. Every major scripting language has a high level binding to the low level libyaml C library to facilitate handling of YAML data files.

Quoted 5 lines

One caveat with YAML is it does not tolerate tabs. Yes, I said it. No tabs! This can be managed with proper editor modes and also with helper scripts to strip tabs to aid in people passing planned checkpatch.pl checks that would run YAML DT Binding specific tag validators for new bindings.

I'm just a casual user of some markup languages, nowhere near knowledgeable or an expert, so will be listening to reasoned opinions on the choice of YAML. But a quick look at the spec you referenced and the examples you provided gives me some confidence that YAML will work.

Quoted 4 lines

The scope of the initial YAML DT Binding format was specifically limited to supporting *only* the content we have in bindings today. The idea here is to propose and agree on something that will take us just a few steps in the right direction. If we move *all* current

Yes, this is a great approach so we can start making reasonable progress. (Caveat below.)

Quoted 11 lines

binding content to a machine parseable format, additional features can be added with more automation and scripting. As it stands today, because of the inconsistency of the wording of the files, we can't add a lot of new features to the content until we convert what we have today into a standard format.

With that said, it should be noted that some new features such as "type" tags to indicate cell types could be added to support additional DTS validation beyond what the current content supports. Another possibility is adding "range" type information to validate the legal values for a cell.

The caveat: I think we should look at some obvious features (such as "type" that you mention) to make sure that YAML and the chosen structuring will easily and effectively support the features.

Thinking about how some features might be implemented led to comments that I will make in replies to the other patches.

I agree that we should not attempt to add the additional information enabled by the new features if the information is not in the present bindings. Adding the new information in a subsequent pass seems to be a good strategy.

Quoted 19 lines

This series is broken up into three major parts:

1) The documentation defining the YAML DT binding format
2) A skeleton device binding example illustrating use of this format
3) Some real binding conversions (eeprom.txt, phy-bindings.txt, and ti-phy.txt

As a proof of concept of what can be done with a proper machine readable DT binding source file, there's a simple markdown document generator at https://github.com/konsulko/dtgendoc. Also, to see actual output from the generator, the generated markdown from those bindings is viewable at https://github.com/konsulko/dtgendoc/wiki

There's a lot of other possibilities for validation tools using only the data we have today in the bindings. In addition, Frank Rowand covered some DT debug techniques that would benefit from the binding documentation being 100% reliably searchable.

Quoted 4 lines

I found it useful to see a side-by-side view of a converted doc versus the original content, so here's a screenshot of eeprom.txt vs. eeprom.yaml:
https://github.com/konsulko/dtgendoc/wiki#eepromtxt-vs-eepromyaml

This binding is your patch 3, but the side by side example you provide makes it much easier to follow along, so I'll comment here.

Part of the information about compatible got lost in the conversion. The part that is lost is:

If there is no specific driver for <manufacturer>, a generic driver based on <type> is selected.

I will discuss this a little more in response to patch 1, where I will ask whether compatible should be treated differently than other properties. So maybe any further discussion of this should be in reply to that email.

Quoted 28 lines

When we decide on a text markup format that is acceptable, then the next step is to convert all the bindings. That process would start with the complete set of generic bindings as they will be referenced by the actual device bindings.

If the RFC wasn't explicit enough...comments welcome.

-Matt

Matt Porter (5):
Documentation: dt-bindings: add documentation on new DT binding format
Documentation: dt-bindings: add example DT binding document
Documentation: dt-bindings: add YAML eeprom binding
Documentation: dt-bindings: phy: add YAML generic PHY binding
Documentation: dt-bindings: phy: add YAML TI PHY binding

 .../devicetree/bindings/dt-binding-format.txt      | 106 +++++++++++++
 Documentation/devicetree/bindings/eeprom.yaml      |  44 ++++++
 .../devicetree/bindings/phy/phy-bindings.yaml      |  89 +++++++++++
 Documentation/devicetree/bindings/phy/ti-phy.yaml  | 166 +++++++++++++++++++++
 Documentation/devicetree/bindings/skeleton.yaml    |  98 ++++++++++++
 5 files changed, 503 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dt-binding-format.txt
 create mode 100644 Documentation/devicetree/bindings/eeprom.yaml
 create mode 100644 Documentation/devicetree/bindings/phy/phy-bindings.yaml
 create mode 100644 Documentation/devicetree/bindings/phy/ti-phy.yaml
 create mode 100644 Documentation/devicetree/bindings/skeleton.yaml

A message that is not in the archive (sent off-list or not yet received): [email protected]

#63 lore raw
Quoted 82 lines · Frank Rowand
Quoted 20 lines · Matt Porter

During the Device Tree microconference at Linux Plumbers 2015, we had a short discussion about how to improve DT Binding Documentation. A number of issues were raised (again, as these things have been discussed in the past) including:

* Inconsistency between binding documents due to prose text format.
* Inability to reliably machine read bindings for mass update or search.
* Bit rot of bindings as new conventions are agreed upon but only new bindings are changed.

Grant Likely probably summed up the issue best with "...as long as bindings are human readable, we'll have issues...". The context of that comment was, of course, regarding our current documents written in very inconsistent prose style. When the topic of needing the bindings in a rigid format was raised, there was general head nodding that this was needed. It was noted that this has been discussed many times before and nothing has been done.

Quoted 8 lines

My proposed solution to the problem is to convert all DT bindings a rigid text markup format. In choosing a text markup language my requirements were:

1) Human readable
2) Well documented
3) Easy to translate to other data formats
4) Well supported by tools and libraries

Thanks for taking this on! The proposal looks like a great start. The requirements look good.

Quoted 12 lines

After looking at a number of markup options, YAML stood out as the one that meets all of these requirements. The YAML syntax is adopted in many projects specifically because of the high level of readability. A comprehensive spec is at http://www.yaml.org/spec/1.2/spec.html.
There's a number of tools to convert between YAML and other popular data formats such as JSON and XML. XML was cited by Behan Webster during the microconference as an important data format as the type of developers that may produce comprehensive DTS Binding validation tools will want to use XML. Every major scripting language has a high level binding to the low level libyaml C library to facilitate handling of YAML data files.

Quoted 5 lines

One caveat with YAML is it does not tolerate tabs. Yes, I said it. No tabs! This can be managed with proper editor modes and also with helper scripts to strip tabs to aid in people passing planned checkpatch.pl checks that would run YAML DT Binding specific tag validators for new bindings.

I'm just a casual user of some markup languages, nowhere near knowledgeable or an expert, so will be listening to reasoned opinions on the choice of YAML. But a quick look at the spec you referenced and the examples you provided gives me some confidence that YAML will work.

Quoted 4 lines

The scope of the initial YAML DT Binding format was specifically limited to supporting *only* the content we have in bindings today. The idea here is to propose and agree on something that will take us just a few steps in the right direction. If we move *all* current

Yes, this is a great approach so we can start making reasonable progress. (Caveat below.)

Quoted 11 lines

binding content to a machine parseable format, additional features can be added with more automation and scripting. As it stands today, because of the inconsistency of the wording of the files, we can't add a lot of new features to the content until we convert what we have today into a standard format.

With that said, it should be noted that some new features such as "type" tags to indicate cell types could be added to support additional DTS validation beyond what the current content supports. Another possibility is adding "range" type information to validate the legal values for a cell.

The caveat: I think we should look at some obvious features (such as "type" that you mention) to make sure that YAML and the chosen structuring will easily and effectively support the features.

Quoted 7 lines

Thinking about how some features might be implemented led to comments that I will make in replies to the other patches.

I agree that we should not attempt to add the additional information enabled by the new features if the information is not in the present bindings. Adding the new information in a subsequent pass seems to be a good strategy.

Ok, I think Rob had a good point that we need to get the format for these additional pieces of information in place even if we don't populate them to start. Sounds like there's some agreement on this approach.

Quoted 31 lines
Quoted 20 lines

This series is broken up into three major parts:

1) The documentation defining the YAML DT binding format
2) A skeleton device binding example illustrating use of this format
3) Some real binding conversions (eeprom.txt, phy-bindings.txt, and ti-phy.txt

As a proof of concept of what can be done with a proper machine readable DT binding source file, there's a simple markdown document generator at https://github.com/konsulko/dtgendoc. Also, to see actual output from the generator, the generated markdown from those bindings is viewable at https://github.com/konsulko/dtgendoc/wiki

There's a lot of other possibilities for validation tools using only the data we have today in the bindings. In addition, Frank Rowand covered some DT debug techniques that would benefit from the binding documentation being 100% reliably searchable.

Quoted 4 lines

I found it useful to see a side-by-side view of a converted doc versus the original content, so here's a screenshot of eeprom.txt vs. eeprom.yaml:
https://github.com/konsulko/dtgendoc/wiki#eepromtxt-vs-eepromyaml

This binding is your patch 3, but the side by side example you provide makes it much easier to follow along, so I'll comment here.

Part of the information about compatible got lost in the conversion. The part that is lost is:

Quoted 7 lines

If there is no specific driver for <manufacturer>, a generic driver based on <type> is selected.

I will discuss this a little more in response to patch 1, where I will ask whether compatible should be treated differently than other properties. So maybe any further discussion of this should be in reply to that email.

Ok, yes, this is an area the needs additional work as Rob pointed out with handling various AND and OR type constraints. I'll move discussion to that patch though.

Quoted 29 lines
Quoted 28 lines

When we decide on a text markup format that is acceptable, then the next step is to convert all the bindings. That process would start with the complete set of generic bindings as they will be referenced by the actual device bindings.

If the RFC wasn't explicit enough...comments welcome.

-Matt

Matt Porter (5):
Documentation: dt-bindings: add documentation on new DT binding format
Documentation: dt-bindings: add example DT binding document
Documentation: dt-bindings: add YAML eeprom binding
Documentation: dt-bindings: phy: add YAML generic PHY binding
Documentation: dt-bindings: phy: add YAML TI PHY binding

 .../devicetree/bindings/dt-binding-format.txt      | 106 +++++++++++++
 Documentation/devicetree/bindings/eeprom.yaml      |  44 ++++++
 .../devicetree/bindings/phy/phy-bindings.yaml      |  89 +++++++++++
 Documentation/devicetree/bindings/phy/ti-phy.yaml  | 166 +++++++++++++++++++++
 Documentation/devicetree/bindings/skeleton.yaml    |  98 ++++++++++++
 5 files changed, 503 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dt-binding-format.txt
 create mode 100644 Documentation/devicetree/bindings/eeprom.yaml
 create mode 100644 Documentation/devicetree/bindings/phy/phy-bindings.yaml
 create mode 100644 Documentation/devicetree/bindings/phy/ti-phy.yaml
 create mode 100644 Documentation/devicetree/bindings/skeleton.yaml
#64 lore raw
In reply to a message not in the archive
Quoted 12 lines · Matt Porter

During the Device Tree microconference at Linux Plumbers 2015, we had a short discussion about how to improve DT Binding Documentation. A number of issues were raised (again, as these things have been discussed in the past) including:

* Inconsistency between binding documents due to prose text format.
* Inability to reliably machine read bindings for mass update or search.
* Bit rot of bindings as new conventions are agreed upon but only new bindings are changed.

Quoted 2 lines

Grant Likely probably summed up the issue best with "...as long as bindings are human readable, we'll have issues...".

I'd rephrase that to "... as long as bindings are not machine readable, we'll have issues...". Human readable and machine readable are not mutually exclusive. XML is not, IMHO, human readable, but YAML looks pretty good, so I think it's a good choice.

Quoted 28 lines

The context
of that comment was, of course, regarding our current documents written in very inconsistent prose style. When the topic of needing the bindings in a rigid format was raised, there was general head nodding that this was needed. It was noted that this has been discussed many times before and nothing has been done.

My proposed solution to the problem is to convert all DT bindings a rigid text markup format. In choosing a text markup language my requirements were:

1) Human readable
2) Well documented
3) Easy to translate to other data formats
4) Well supported by tools and libraries

After looking at a number of markup options, YAML stood out as the one that meets all of these requirements. The YAML syntax is adopted in many projects specifically because of the high level of readability. A comprehensive spec is at http://www.yaml.org/spec/1.2/spec.html.
There's a number of tools to convert between YAML and other popular data formats such as JSON and XML. XML was cited by Behan Webster during the microconference as an important data format as the type of developers that may produce comprehensive DTS Binding validation tools will want to use XML. Every major scripting language has a high level binding to the low level libyaml C library to facilitate handling of YAML data files.

Quoted 5 lines

One caveat with YAML is it does not tolerate tabs. Yes, I said it. No tabs! This can be managed with proper editor modes and also with helper scripts to strip tabs to aid in people passing planned checkpatch.pl checks that would run YAML DT Binding specific tag validators for new bindings.

This will be an endless source of pain. Based on your examples, it looks like we only need a very small subset of YAML. I'd be willing to write a parser for the language, but we might lose the ability to do conversions to other formats. It depends on how comprehensive and automatic the helper scripts to strip tabs would be.

Quoted 11 lines

The scope of the initial YAML DT Binding format was specifically limited to supporting *only* the content we have in bindings today. The idea here is to propose and agree on something that will take us just a few steps in the right direction. If we move *all* current binding content to a machine parseable format, additional features can be added with more automation and scripting. As it stands today, because of the inconsistency of the wording of the files, we can't add a lot of new features to the content until we convert what we have today into a standard format.

Quoted 5 lines

With that said, it should be noted that some new features such as "type" tags to indicate cell types could be added to support additional DTS validation beyond what the current content supports. Another possibility is adding "range" type information to validate the legal values for a cell.

I would recommend we add type and something for value constraints. Even if we don't add populate those immediately, I think thinking through some of the possible uses will be helpful to avoid doing something dumb.
'choices' or 'enums' seem frequently used. I see lots of "must be one of..." in the binding docs I read.

Another important thing to document would be a 'superclass' or 'inherit-from' attribute, for things that are of a specific type (i2c, regulator, clock, etc.)

Quoted 23 lines

This series is broken up into three major parts:

1) The documentation defining the YAML DT binding format
2) A skeleton device binding example illustrating use of this format
3) Some real binding conversions (eeprom.txt, phy-bindings.txt, and ti-phy.txt

As a proof of concept of what can be done with a proper machine readable DT binding source file, there's a simple markdown document generator at https://github.com/konsulko/dtgendoc. Also, to see actual output from the generator, the generated markdown from those bindings is viewable at https://github.com/konsulko/dtgendoc/wiki

There's a lot of other possibilities for validation tools using only the data we have today in the bindings. In addition, Frank Rowand covered some DT debug techniques that would benefit from the binding documentation being 100% reliably searchable.

I found it useful to see a side-by-side view of a converted doc versus the original content, so here's a screenshot of eeprom.txt vs. eeprom.yaml:
https://github.com/konsulko/dtgendoc/wiki#eepromtxt-vs-eepromyaml

Quoted 4 lines

When we decide on a text markup format that is acceptable, then the next step is to convert all the bindings. That process would start with the complete set of generic bindings as they will be referenced by the actual device bindings.

Although there are a lot of files to convert, I think the job is manageable, and can be done with conversion sprints at conferences and the like. You don't have to be a kernel 'C' coder to do a conversion, so I think a lot of non-traditional contributers can help out. I'm already thinking about what could be done at an Embedded Linux Conference.

One thing that would help would be a conversion guide. It would have things like: "if you see this type of language, put that in the description, some examples are ..."

I'll have more comments on individual patches.
-- Tim

A message that is not in the archive (sent off-list or not yet received): CA+bK7J5MriF95d2OGAZRT8PyJkK_x5r1J1yPq2Ke=SZkit6xHA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#66 lore raw
Quoted 13 lines · Tim Bird
Quoted 12 lines · Matt Porter

During the Device Tree microconference at Linux Plumbers 2015, we had a short discussion about how to improve DT Binding Documentation. A number of issues were raised (again, as these things have been discussed in the past) including:

* Inconsistency between binding documents due to prose text format.
* Inability to reliably machine read bindings for mass update or search.
* Bit rot of bindings as new conventions are agreed upon but only new bindings are changed.

Quoted 6 lines
Quoted 2 lines

Grant Likely probably summed up the issue best with "...as long as bindings are human readable, we'll have issues...".

I'd rephrase that to "... as long as bindings are not machine readable, we'll have issues...". Human readable and machine readable are not mutually exclusive. XML is not, IMHO, human readable, but YAML looks pretty good, so I think it's a good choice.

Yes, that's exactly what I hoped to find with this experiment...that we can have both.

Quoted 34 lines
Quoted 28 lines

The context
of that comment was, of course, regarding our current documents written in very inconsistent prose style. When the topic of needing the bindings in a rigid format was raised, there was general head nodding that this was needed. It was noted that this has been discussed many times before and nothing has been done.

My proposed solution to the problem is to convert all DT bindings a rigid text markup format. In choosing a text markup language my requirements were:

1) Human readable
2) Well documented
3) Easy to translate to other data formats
4) Well supported by tools and libraries

After looking at a number of markup options, YAML stood out as the one that meets all of these requirements. The YAML syntax is adopted in many projects specifically because of the high level of readability. A comprehensive spec is at http://www.yaml.org/spec/1.2/spec.html.
There's a number of tools to convert between YAML and other popular data formats such as JSON and XML. XML was cited by Behan Webster during the microconference as an important data format as the type of developers that may produce comprehensive DTS Binding validation tools will want to use XML. Every major scripting language has a high level binding to the low level libyaml C library to facilitate handling of YAML data files.

Quoted 5 lines

One caveat with YAML is it does not tolerate tabs. Yes, I said it. No tabs! This can be managed with proper editor modes and also with helper scripts to strip tabs to aid in people passing planned checkpatch.pl checks that would run YAML DT Binding specific tag validators for new bindings.

Quoted 5 lines

This will be an endless source of pain. Based on your examples, it looks like we only need a very small subset of YAML. I'd be willing to write a parser for the language, but we might lose the ability to do conversions to other formats. It depends on how comprehensive and automatic the helper scripts to strip tabs would be.

We need something to validate that a binding meets our binding schema so it shouldn't a huge problem to have it warn and by option, reformat the binding with tabs stripped. Having an appropriate mode available for vim/emacs would go a long way to helping here too.

Quoted 16 lines
Quoted 10 lines

The scope of the initial YAML DT Binding format was specifically limited to supporting *only* the content we have in bindings today. The idea here is to propose and agree on something that will take us just a few steps in the right direction. If we move *all* current binding content to a machine parseable format, additional features can be added with more automation and scripting. As it stands today, because of the inconsistency of the wording of the files, we can't add a lot of new features to the content until we convert what we have today into a standard format.

Quoted 5 lines

With that said, it should be noted that some new features such as "type" tags to indicate cell types could be added to support additional DTS validation beyond what the current content supports. Another possibility is adding "range" type information to validate the legal values for a cell.

Quoted 6 lines

I would recommend we add type and something for value constraints. Even if we don't add populate those immediately, I think thinking through some of the possible uses will be helpful to avoid doing something dumb.
'choices' or 'enums' seem frequently used. I see lots of "must be one of..." in the binding docs I read.

Yes, so definitely after initial feedback, we're going to define some kind of type and constraint tags. Whether we use C-like expressions for constraints or something else is still up for debate.

And as you point out (and Rob also did) we need some type of AND and OR expressions for constraint enums which also include the regular case of defining how compatibles must be handled (e.g. one of the specific strings AND the generic string).

Quoted 4 lines

Another important thing to document would be a 'superclass' or 'inherit-from' attribute, for things that are of a specific type (i2c, regulator, clock, etc.)

There's an attempt at that with the reference tag. Based on this and other comments we'll expand that usage to inherit all the properties from a generic binding (a 'superclass' as used above) rather than repeating those within each peripheral binding document.

Quoted 28 lines
Quoted 23 lines

This series is broken up into three major parts:

1) The documentation defining the YAML DT binding format
2) A skeleton device binding example illustrating use of this format
3) Some real binding conversions (eeprom.txt, phy-bindings.txt, and ti-phy.txt

As a proof of concept of what can be done with a proper machine readable DT binding source file, there's a simple markdown document generator at https://github.com/konsulko/dtgendoc. Also, to see actual output from the generator, the generated markdown from those bindings is viewable at https://github.com/konsulko/dtgendoc/wiki

There's a lot of other possibilities for validation tools using only the data we have today in the bindings. In addition, Frank Rowand covered some DT debug techniques that would benefit from the binding documentation being 100% reliably searchable.

I found it useful to see a side-by-side view of a converted doc versus the original content, so here's a screenshot of eeprom.txt vs. eeprom.yaml:
https://github.com/konsulko/dtgendoc/wiki#eepromtxt-vs-eepromyaml

Quoted 4 lines

When we decide on a text markup format that is acceptable, then the next step is to convert all the bindings. That process would start with the complete set of generic bindings as they will be referenced by the actual device bindings.

Quoted 5 lines

Although there are a lot of files to convert, I think the job is manageable, and can be done with conversion sprints at conferences and the like. You don't have to be a kernel 'C' coder to do a conversion, so I think a lot of non-traditional contributers can help out. I'm already thinking about what could be done at an Embedded Linux Conference.

I think this would be great and completely agree that it allows a lot of people to get involved. If we can get to a tolerable schema in the next month then we should be ready for some f2f conversion hacking at ELCE.

Quoted 3 lines

One thing that would help would be a conversion guide. It would have things like: "if you see this type of language, put that in the description, some examples are ..."

Ok, that's very good. I'll add to the TODO list that we need to have this is our guidelines document. I think most of this will fall out initially in agreeing on our format/schema and then whatever we miss can be added as we do the large scale conversion of bindings.

Quoted 1 line

I'll have more comments on individual patches.

Thanks for reviewing!

-Matt