18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci============================================================ 48c2ecf20Sopenharmony_ciDOs and DON'Ts for designing and writing Devicetree bindings 58c2ecf20Sopenharmony_ci============================================================ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ciThis is a list of common review feedback items focused on binding design. With 88c2ecf20Sopenharmony_cievery rule, there are exceptions and bindings have many gray areas. 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciFor guidelines related to patches, see 118c2ecf20Sopenharmony_ciDocumentation/devicetree/bindings/submitting-patches.rst 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ciOverall design 158c2ecf20Sopenharmony_ci============== 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci- DO attempt to make bindings complete even if a driver doesn't support some 188c2ecf20Sopenharmony_ci features. For example, if a device has an interrupt, then include the 198c2ecf20Sopenharmony_ci 'interrupts' property even if the driver is only polled mode. 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci- DON'T refer to Linux or "device driver" in bindings. Bindings should be 228c2ecf20Sopenharmony_ci based on what the hardware has, not what an OS and driver currently support. 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci- DO use node names matching the class of the device. Many standard names are 258c2ecf20Sopenharmony_ci defined in the DT Spec. If there isn't one, consider adding it. 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci- DO check that the example matches the documentation especially after making 288c2ecf20Sopenharmony_ci review changes. 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci- DON'T create nodes just for the sake of instantiating drivers. Multi-function 318c2ecf20Sopenharmony_ci devices only need child nodes when the child nodes have their own DT 328c2ecf20Sopenharmony_ci resources. A single node can be multiple providers (e.g. clocks and resets). 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci- DON'T use 'syscon' alone without a specific compatible string. A 'syscon' 358c2ecf20Sopenharmony_ci hardware block should have a compatible string unique enough to infer the 368c2ecf20Sopenharmony_ci register layout of the entire block (at a minimum). 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ciProperties 408c2ecf20Sopenharmony_ci========== 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci- DO make 'compatible' properties specific. DON'T use wildcards in compatible 438c2ecf20Sopenharmony_ci strings. DO use fallback compatibles when devices are the same as or a subset 448c2ecf20Sopenharmony_ci of prior implementations. DO add new compatibles in case there are new 458c2ecf20Sopenharmony_ci features or bugs. 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci- DO use a vendor prefix on device specific property names. Consider if 488c2ecf20Sopenharmony_ci properties could be common among devices of the same class. Check other 498c2ecf20Sopenharmony_ci existing bindings for similar devices. 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci- DON'T redefine common properties. Just reference the definition and define 528c2ecf20Sopenharmony_ci constraints specific to the device. 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci- DO use common property unit suffixes for properties with scientific units. 558c2ecf20Sopenharmony_ci See property-units.txt. 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci- DO define properties in terms of constraints. How many entries? What are 588c2ecf20Sopenharmony_ci possible values? What is the order? 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ciBoard/SoC .dts Files 628c2ecf20Sopenharmony_ci==================== 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci- DO put all MMIO devices under a bus node and not at the top-level. 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci- DO use non-empty 'ranges' to limit the size of child buses/devices. 64-bit 678c2ecf20Sopenharmony_ci platforms don't need all devices to have 64-bit address and size. 68