zephyr/scripts/dts/test-bindings/props.yaml

48 lines
793 B
YAML
Raw Normal View History

dts: Add new DTS/binding parser Add a new DTS/binding parser to scripts/dts/ for generating generated_dts_board.conf and generated_dts_board_unfixed.h. The old code is kept to generate some deprecated defines, using the --deprecated-only flag. It will be removed later. The new parser is implemented in three files in scripts/dts/: dtlib.py: A low-level .dts parsing library. This is similar to devicetree.py in the old code, but is a general robust DTS parser that doesn't rely on preprocessing. edtlib.py (e for extended): A library built on top of dtlib.py that brings together data from DTS files and bindings and creates Device instances with all the data for a device. gen_defines.py: A script that uses edtlib.py to generate generated_dts_board.conf and generated_dts_board_unfixed.h. Corresponds to extract_dts_includes.py and the files in extract/ in the old code. testdtlib.py: Test suite for dtlib.py. Can be run directly as a script. testedtlib.py (uses test.dts and test-bindings/): Test suite for edtlib.py. Can be run directly as a script. The test suites will be run automatically in CI. The new code turns some things that were warnings (or not checked) in the old code into errors, like missing properties that are specified with 'category: required' in the binding for the node. The code includes lots of documentation and tries to give helpful error messages instead of Python errors. Co-authored-by: Kumar Gala <kumar.gala@linaro.org> Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-12-18 03:09:47 +08:00
# SPDX-License-Identifier: BSD-3-Clause
description: Device.props test
compatible: "props"
dts: Add new DTS/binding parser Add a new DTS/binding parser to scripts/dts/ for generating generated_dts_board.conf and generated_dts_board_unfixed.h. The old code is kept to generate some deprecated defines, using the --deprecated-only flag. It will be removed later. The new parser is implemented in three files in scripts/dts/: dtlib.py: A low-level .dts parsing library. This is similar to devicetree.py in the old code, but is a general robust DTS parser that doesn't rely on preprocessing. edtlib.py (e for extended): A library built on top of dtlib.py that brings together data from DTS files and bindings and creates Device instances with all the data for a device. gen_defines.py: A script that uses edtlib.py to generate generated_dts_board.conf and generated_dts_board_unfixed.h. Corresponds to extract_dts_includes.py and the files in extract/ in the old code. testdtlib.py: Test suite for dtlib.py. Can be run directly as a script. testedtlib.py (uses test.dts and test-bindings/): Test suite for edtlib.py. Can be run directly as a script. The test suites will be run automatically in CI. The new code turns some things that were warnings (or not checked) in the old code into errors, like missing properties that are specified with 'category: required' in the binding for the node. The code includes lots of documentation and tries to give helpful error messages instead of Python errors. Co-authored-by: Kumar Gala <kumar.gala@linaro.org> Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-12-18 03:09:47 +08:00
properties:
dts: dtlib/edtlib: Add a syntax-based type-checking system Property type-checking has been pretty rudimentary until now, only checking things like the length being divisible by 4 for 'type: array', and strings being null-terminated. In particular, no checking was done for 'type: uint8-array', letting jedec-id = < 0xc8 0x28 0x17 >; slip through when jedec-id = [ 0xc8 0x28 0x17 ]; was intended. Fix it by adding a syntax-based type checker: 1. Add Property.type, which gives a high-level type for the property, derived from the markers added in the previous commit. This includes types like TYPE_EMPTY ('foo;'), TYPE_NUM ('foo = < 3 >;'), TYPE_BYTES ('foo = [ 01 02 ];'), TYPE_STRINGS ('foo = "bar", "baz"'), TYPE_PHANDLE ('foo = < &bar >;'), and TYPE_COMPOUND (everything not recognized). See the Property.type docstring in dtlib for more info. 2. Use the high-level type in Property.to_num()/to_string()/to_node()/etc. to verify that the property was assigned in an expected way for the type. If the assignment looks bad, give a helpful error: expected property 'nums' on /foo/bar in some.dts to be assigned with 'nums = < (number) (number) ... >', not 'nums = "oops";' Some other related changes are included as well: - There's a new Property.to_bytes() function that works like accessing Property.bytes, except with an added check for the value being assigned like 'foo = [ ... ]'. This function solves problems like the jedec-id one. - There's a new Property.to_path() function for fetching the referenced node for assignments like 'foo = &node;', with type checking. (Strings are accepted too, as long as they give the path to an existing node.) This function is used for /chosen and /aliases. - A new 'type: phandle' type can now be given in bindings, for properties that are assigned like 'foo = < &node >;'. - Property.__str__() now displays phandles and path references as they were written (e.g. '< &foo >' instead of '< 0x1 >', if the allocated phandle happened to be 1). - Property.to_num() and Property.to_nums() no longer take a 'length' parameter, because it makes no sense with the type checking. - The global dtlib.to_string() and dtlib.to_strings() functions were removed, because they're not that useful. - More tests were added, along with misc. minor cleanup in various places. - Probably other stuff I forgot. The more strict type checking in dtlib indirectly makes some parts of edtlib more strict as well (wherever Property.to_*() is used). Fixes: #18131 Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-08-10 02:38:17 +08:00
nonexistent-boolean:
type: boolean
existent-boolean:
type: boolean
dts: Add new DTS/binding parser Add a new DTS/binding parser to scripts/dts/ for generating generated_dts_board.conf and generated_dts_board_unfixed.h. The old code is kept to generate some deprecated defines, using the --deprecated-only flag. It will be removed later. The new parser is implemented in three files in scripts/dts/: dtlib.py: A low-level .dts parsing library. This is similar to devicetree.py in the old code, but is a general robust DTS parser that doesn't rely on preprocessing. edtlib.py (e for extended): A library built on top of dtlib.py that brings together data from DTS files and bindings and creates Device instances with all the data for a device. gen_defines.py: A script that uses edtlib.py to generate generated_dts_board.conf and generated_dts_board_unfixed.h. Corresponds to extract_dts_includes.py and the files in extract/ in the old code. testdtlib.py: Test suite for dtlib.py. Can be run directly as a script. testedtlib.py (uses test.dts and test-bindings/): Test suite for edtlib.py. Can be run directly as a script. The test suites will be run automatically in CI. The new code turns some things that were warnings (or not checked) in the old code into errors, like missing properties that are specified with 'category: required' in the binding for the node. The code includes lots of documentation and tries to give helpful error messages instead of Python errors. Co-authored-by: Kumar Gala <kumar.gala@linaro.org> Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-12-18 03:09:47 +08:00
int:
type: int
const: 1
dts: Add new DTS/binding parser Add a new DTS/binding parser to scripts/dts/ for generating generated_dts_board.conf and generated_dts_board_unfixed.h. The old code is kept to generate some deprecated defines, using the --deprecated-only flag. It will be removed later. The new parser is implemented in three files in scripts/dts/: dtlib.py: A low-level .dts parsing library. This is similar to devicetree.py in the old code, but is a general robust DTS parser that doesn't rely on preprocessing. edtlib.py (e for extended): A library built on top of dtlib.py that brings together data from DTS files and bindings and creates Device instances with all the data for a device. gen_defines.py: A script that uses edtlib.py to generate generated_dts_board.conf and generated_dts_board_unfixed.h. Corresponds to extract_dts_includes.py and the files in extract/ in the old code. testdtlib.py: Test suite for dtlib.py. Can be run directly as a script. testedtlib.py (uses test.dts and test-bindings/): Test suite for edtlib.py. Can be run directly as a script. The test suites will be run automatically in CI. The new code turns some things that were warnings (or not checked) in the old code into errors, like missing properties that are specified with 'category: required' in the binding for the node. The code includes lots of documentation and tries to give helpful error messages instead of Python errors. Co-authored-by: Kumar Gala <kumar.gala@linaro.org> Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-12-18 03:09:47 +08:00
array:
type: array
uint8-array:
type: uint8-array
string:
type: string
const: "foo"
dts: Add new DTS/binding parser Add a new DTS/binding parser to scripts/dts/ for generating generated_dts_board.conf and generated_dts_board_unfixed.h. The old code is kept to generate some deprecated defines, using the --deprecated-only flag. It will be removed later. The new parser is implemented in three files in scripts/dts/: dtlib.py: A low-level .dts parsing library. This is similar to devicetree.py in the old code, but is a general robust DTS parser that doesn't rely on preprocessing. edtlib.py (e for extended): A library built on top of dtlib.py that brings together data from DTS files and bindings and creates Device instances with all the data for a device. gen_defines.py: A script that uses edtlib.py to generate generated_dts_board.conf and generated_dts_board_unfixed.h. Corresponds to extract_dts_includes.py and the files in extract/ in the old code. testdtlib.py: Test suite for dtlib.py. Can be run directly as a script. testedtlib.py (uses test.dts and test-bindings/): Test suite for edtlib.py. Can be run directly as a script. The test suites will be run automatically in CI. The new code turns some things that were warnings (or not checked) in the old code into errors, like missing properties that are specified with 'category: required' in the binding for the node. The code includes lots of documentation and tries to give helpful error messages instead of Python errors. Co-authored-by: Kumar Gala <kumar.gala@linaro.org> Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-12-18 03:09:47 +08:00
string-array:
type: string-array
dts: dtlib/edtlib: Add a syntax-based type-checking system Property type-checking has been pretty rudimentary until now, only checking things like the length being divisible by 4 for 'type: array', and strings being null-terminated. In particular, no checking was done for 'type: uint8-array', letting jedec-id = < 0xc8 0x28 0x17 >; slip through when jedec-id = [ 0xc8 0x28 0x17 ]; was intended. Fix it by adding a syntax-based type checker: 1. Add Property.type, which gives a high-level type for the property, derived from the markers added in the previous commit. This includes types like TYPE_EMPTY ('foo;'), TYPE_NUM ('foo = < 3 >;'), TYPE_BYTES ('foo = [ 01 02 ];'), TYPE_STRINGS ('foo = "bar", "baz"'), TYPE_PHANDLE ('foo = < &bar >;'), and TYPE_COMPOUND (everything not recognized). See the Property.type docstring in dtlib for more info. 2. Use the high-level type in Property.to_num()/to_string()/to_node()/etc. to verify that the property was assigned in an expected way for the type. If the assignment looks bad, give a helpful error: expected property 'nums' on /foo/bar in some.dts to be assigned with 'nums = < (number) (number) ... >', not 'nums = "oops";' Some other related changes are included as well: - There's a new Property.to_bytes() function that works like accessing Property.bytes, except with an added check for the value being assigned like 'foo = [ ... ]'. This function solves problems like the jedec-id one. - There's a new Property.to_path() function for fetching the referenced node for assignments like 'foo = &node;', with type checking. (Strings are accepted too, as long as they give the path to an existing node.) This function is used for /chosen and /aliases. - A new 'type: phandle' type can now be given in bindings, for properties that are assigned like 'foo = < &node >;'. - Property.__str__() now displays phandles and path references as they were written (e.g. '< &foo >' instead of '< 0x1 >', if the allocated phandle happened to be 1). - Property.to_num() and Property.to_nums() no longer take a 'length' parameter, because it makes no sense with the type checking. - The global dtlib.to_string() and dtlib.to_strings() functions were removed, because they're not that useful. - More tests were added, along with misc. minor cleanup in various places. - Probably other stuff I forgot. The more strict type checking in dtlib indirectly makes some parts of edtlib more strict as well (wherever Property.to_*() is used). Fixes: #18131 Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-08-10 02:38:17 +08:00
phandle-ref:
type: phandle
phandle-refs:
type: phandles
scripts: dts: Generalize handling of phandle-array types Generating generic information for 'type: phandle-array' properties in edtlib was difficult due to defining phandle-array as just a list of phandles and numbers. To make sense of a phandle-array property like 'pwms', you have to know that #pwm-cells is expected to appear on each referenced controller, and that the binding for the controller has a #cells. Because of this, handling of various 'type: phandle-array' properties was previously hardcoded in edtlib and exposed through properties like Node.pwms, instead of through the generic Node.props (though with a lot of shared code). In practice, it turns out that all 'type: phandle-array' properties in Zephyr work exactly the same way: They all have names that end in -s, the 's' is removed to derive the name of related properties, and they all look up #cells in the binding for the controller, which gives names to the data values. Strengthen the definition of 'type: phandle-array' to mean a property that works exactly like the existing phandle-array properties (which also means requiring that the name ends in -s). This removes a ton of hardcoding from edtlib and allows new 'type: phandle-array' properties to be added without making any code changes. If we ever need a property type that's a list of phandles and numbers but that doesn't follow this scheme, then we could add a separate type for it. We should check if the standard scheme is fine first though. The only property type for which no information is generated is now 'compound'. There's some inconsistency in how we generate identifiers for clocks compared to other 'type: phandle-array' properties, so keep special-casing them for now in gen_defines.py (see the comment in write_clocks()). This change also enabled a bunch of other simplifications, like reusing the ControllerAndData class for interrupts. Piggyback generalization of *-map properties so that they work for any phandle-array properties. It's now possible to have things like 'io-channel-map', if you need to. Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-23 15:10:22 +08:00
phandle-array-foos:
type: phandle-array
# There's some slight special-casing for GPIOs in that 'foo-gpios = ...'
# gets resolved to #gpio-cells rather than #foo-gpio-cells, so test that
# too
foo-gpios:
type: phandle-array
path:
type: path