1c66ec88fSEmmanuel Vadot.. SPDX-License-Identifier: GPL-2.0 2c66ec88fSEmmanuel Vadot 3c66ec88fSEmmanuel Vadot============================================================ 4c66ec88fSEmmanuel VadotDOs and DON'Ts for designing and writing Devicetree bindings 5c66ec88fSEmmanuel Vadot============================================================ 6c66ec88fSEmmanuel Vadot 7c66ec88fSEmmanuel VadotThis is a list of common review feedback items focused on binding design. With 8c66ec88fSEmmanuel Vadotevery rule, there are exceptions and bindings have many gray areas. 9c66ec88fSEmmanuel Vadot 10c66ec88fSEmmanuel VadotFor guidelines related to patches, see 11c66ec88fSEmmanuel VadotDocumentation/devicetree/bindings/submitting-patches.rst 12c66ec88fSEmmanuel Vadot 13c66ec88fSEmmanuel Vadot 14c66ec88fSEmmanuel VadotOverall design 15c66ec88fSEmmanuel Vadot============== 16c66ec88fSEmmanuel Vadot 17c66ec88fSEmmanuel Vadot- DO attempt to make bindings complete even if a driver doesn't support some 18c66ec88fSEmmanuel Vadot features. For example, if a device has an interrupt, then include the 19c66ec88fSEmmanuel Vadot 'interrupts' property even if the driver is only polled mode. 20c66ec88fSEmmanuel Vadot 21c66ec88fSEmmanuel Vadot- DON'T refer to Linux or "device driver" in bindings. Bindings should be 22c66ec88fSEmmanuel Vadot based on what the hardware has, not what an OS and driver currently support. 23c66ec88fSEmmanuel Vadot 24c66ec88fSEmmanuel Vadot- DO use node names matching the class of the device. Many standard names are 25c66ec88fSEmmanuel Vadot defined in the DT Spec. If there isn't one, consider adding it. 26c66ec88fSEmmanuel Vadot 27c66ec88fSEmmanuel Vadot- DO check that the example matches the documentation especially after making 28c66ec88fSEmmanuel Vadot review changes. 29c66ec88fSEmmanuel Vadot 30c66ec88fSEmmanuel Vadot- DON'T create nodes just for the sake of instantiating drivers. Multi-function 31c66ec88fSEmmanuel Vadot devices only need child nodes when the child nodes have their own DT 32c66ec88fSEmmanuel Vadot resources. A single node can be multiple providers (e.g. clocks and resets). 33c66ec88fSEmmanuel Vadot 34c66ec88fSEmmanuel Vadot- DON'T use 'syscon' alone without a specific compatible string. A 'syscon' 35c66ec88fSEmmanuel Vadot hardware block should have a compatible string unique enough to infer the 36c66ec88fSEmmanuel Vadot register layout of the entire block (at a minimum). 37c66ec88fSEmmanuel Vadot 38c66ec88fSEmmanuel Vadot 39c66ec88fSEmmanuel VadotProperties 40c66ec88fSEmmanuel Vadot========== 41c66ec88fSEmmanuel Vadot 42c66ec88fSEmmanuel Vadot- DO make 'compatible' properties specific. DON'T use wildcards in compatible 43c66ec88fSEmmanuel Vadot strings. DO use fallback compatibles when devices are the same as or a subset 44c66ec88fSEmmanuel Vadot of prior implementations. DO add new compatibles in case there are new 45c66ec88fSEmmanuel Vadot features or bugs. 46c66ec88fSEmmanuel Vadot 478cc087a1SEmmanuel Vadot- DO use a vendor prefix on device-specific property names. Consider if 48c66ec88fSEmmanuel Vadot properties could be common among devices of the same class. Check other 49c66ec88fSEmmanuel Vadot existing bindings for similar devices. 50c66ec88fSEmmanuel Vadot 51c66ec88fSEmmanuel Vadot- DON'T redefine common properties. Just reference the definition and define 52c66ec88fSEmmanuel Vadot constraints specific to the device. 53c66ec88fSEmmanuel Vadot 54c66ec88fSEmmanuel Vadot- DO use common property unit suffixes for properties with scientific units. 555956d97fSEmmanuel Vadot Recommended suffixes are listed at 56*b97ee269SEmmanuel Vadot https://github.com/devicetree-org/dt-schema/blob/main/dtschema/schemas/property-units.yaml 57c66ec88fSEmmanuel Vadot 58c66ec88fSEmmanuel Vadot- DO define properties in terms of constraints. How many entries? What are 59c66ec88fSEmmanuel Vadot possible values? What is the order? 60c66ec88fSEmmanuel Vadot 61d5b0e70fSEmmanuel VadotTypical cases and caveats 62d5b0e70fSEmmanuel Vadot========================= 63d5b0e70fSEmmanuel Vadot 64d5b0e70fSEmmanuel Vadot- Phandle entries, like clocks/dmas/interrupts/resets, should always be 65d5b0e70fSEmmanuel Vadot explicitly ordered. Include the {clock,dma,interrupt,reset}-names if there is 66d5b0e70fSEmmanuel Vadot more than one phandle. When used, both of these fields need the same 67d5b0e70fSEmmanuel Vadot constraints (e.g. list of items). 68d5b0e70fSEmmanuel Vadot 69d5b0e70fSEmmanuel Vadot- For names used in {clock,dma,interrupt,reset}-names, do not add any suffix, 70d5b0e70fSEmmanuel Vadot e.g.: "tx" instead of "txirq" (for interrupt). 71d5b0e70fSEmmanuel Vadot 72d5b0e70fSEmmanuel Vadot- Properties without schema types (e.g. without standard suffix or not defined 73d5b0e70fSEmmanuel Vadot by schema) need the type, even if this is an enum. 74d5b0e70fSEmmanuel Vadot 75d5b0e70fSEmmanuel Vadot- If schema includes other schema (e.g. /schemas/i2c/i2c-controller.yaml) use 76d5b0e70fSEmmanuel Vadot "unevaluatedProperties:false". In other cases, usually use 77d5b0e70fSEmmanuel Vadot "additionalProperties:false". 78d5b0e70fSEmmanuel Vadot 79d5b0e70fSEmmanuel Vadot- For sub-blocks/components of bigger device (e.g. SoC blocks) use rather 80d5b0e70fSEmmanuel Vadot device-based compatible (e.g. SoC-based compatible), instead of custom 81d5b0e70fSEmmanuel Vadot versioning of that component. 82d5b0e70fSEmmanuel Vadot For example use "vendor,soc1234-i2c" instead of "vendor,i2c-v2". 83d5b0e70fSEmmanuel Vadot 84d5b0e70fSEmmanuel Vadot- "syscon" is not a generic property. Use vendor and type, e.g. 85d5b0e70fSEmmanuel Vadot "vendor,power-manager-syscon". 86c66ec88fSEmmanuel Vadot 87c66ec88fSEmmanuel VadotBoard/SoC .dts Files 88c66ec88fSEmmanuel Vadot==================== 89c66ec88fSEmmanuel Vadot 90c66ec88fSEmmanuel Vadot- DO put all MMIO devices under a bus node and not at the top-level. 91c66ec88fSEmmanuel Vadot 92c66ec88fSEmmanuel Vadot- DO use non-empty 'ranges' to limit the size of child buses/devices. 64-bit 93c66ec88fSEmmanuel Vadot platforms don't need all devices to have 64-bit address and size. 94