Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2043125rdb; Sun, 19 Nov 2023 23:21:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNv5PvRTep/V1d7GAx7LUeN0oS/QKK4qsvam91LoTY0ENALKu9rwdrwrrcjTtMM7TFe210 X-Received: by 2002:a05:6a21:920a:b0:188:1df7:9afe with SMTP id tl10-20020a056a21920a00b001881df79afemr5698270pzb.30.1700464865118; Sun, 19 Nov 2023 23:21:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700464865; cv=none; d=google.com; s=arc-20160816; b=NI1k9pdIjBGnhs6lDSsQKDZ/lHm35ct027rA+RmZY6+YIgqdBPbEbZHLM375KI8x5Z LHmeCvb2OjcSr6BxLwAoxDZdBD9IrTgyOrSecwYxQw5x/cinwx3PSEoK/JoJ+vvQB6H1 yTT4+MZ3J21yNjHi1A+sC41pE4s0VV8UsarwNlj3IhwpvaYLy+GMglJ214eKoI/mEi+e yonR5U7MJaffAXsvFdrS3efo0kQkhvnPen6AjSzEjkMBQK3Hxvs6kkX1cxXZAT1TZF2A FgxI4fdMv54jzgpu/yVfvcyzGAl50BNCaEaScDZOXKrBeek1UsiexJ5A3PNyIsJvtksq AzCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:autocrypt :from:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=Hg+bpY74pcdJD4VqD9iJjZ8EPmhWBj00aMuwTv1+jZU=; fh=ovS1bGFB+U5H9jwWKpx6BCo64VrCvfrbJxSRd5Mhj+8=; b=E1rPi954BJAK21MeDvk+urk3nCSFQivhFzBE2jfGLe0XO6CAxoHQa8rRvF8f+KDxE6 YZD20gPYfTzoKOv5V+5yA/e4FDLw17hFcyCiZfXO/wocyXB3EjjvL8HZZuWLJB8NLE6H tEeMJ0d+How2LlZU4RzalA3bElGK7DcQyqi2gTxlg6nkxjSI8nCQJi24o8TZb/ahyL75 GxZiVVvirs9zuv6izctcQQyGzHILicWDueS7qvJpAIPXcodyZ+624tXsg2H0Go/KlfoE cNUITfOqy/kplstnAiJQofNS+8lbe+5KX1g+VwxpnspQATBro7UhJVlihzlR/f57oUkA PoHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uMjtz1YC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id y7-20020a636407000000b005acba4c9bf7si7283042pgb.770.2023.11.19.23.21.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 23:21:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uMjtz1YC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 5330F807C66D; Sun, 19 Nov 2023 23:20:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232040AbjKTHT6 (ORCPT + 99 others); Mon, 20 Nov 2023 02:19:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232033AbjKTHT5 (ORCPT ); Mon, 20 Nov 2023 02:19:57 -0500 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E7AFA2 for ; Sun, 19 Nov 2023 23:19:53 -0800 (PST) Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-53e751aeb3cso5687429a12.2 for ; Sun, 19 Nov 2023 23:19:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700464792; x=1701069592; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Hg+bpY74pcdJD4VqD9iJjZ8EPmhWBj00aMuwTv1+jZU=; b=uMjtz1YCTUFyadjjBshiuxPOTSu9jA7z0rsCz3vWZsJeg9P1Vw6lYXBdB2O6Jorq6n z23tQggDECSk4RB2jOEqL1LUd5L4CxsMa8u1mV7XvzVs0slVppBpxsrISR7ASHNyCqD8 mqsFMgsoG/ikUj4mcqrobIj3HOrRZyGoi/snCcwdx1/LmaFMAcwjQDT80M8rq9/9klzc 0ZDvXgSLReSMjXxE5lGZU7aHYzpK5hUj4tm5F0xfaPJE+KOI+Gn7ZkCec6kFHEwMkEbt rMr43aB+MK8WNXD+xDhz33xxaV+O5ks7R5fb8JoJVbXrQ0VgpV4J1muvm4CGG6ZUEUxR bAdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700464792; x=1701069592; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Hg+bpY74pcdJD4VqD9iJjZ8EPmhWBj00aMuwTv1+jZU=; b=qve0EyeZy96uxf1FUZszKVOjFiohvAtlF/RPWkkogUCujcOmyKfaWAh1H0YruEza4T xtozsYkLSsxRoIawPoTs0/pARX8MbjVJuXk2iw0VSND9eO4RWsrESo3tLjmCWLYD1iJd 8X4rFqaK7T/sz41y6x8jvtqTXSJdX8idKRTa0m6szp165eSM69myIvmLBBzRh5MlRjSE 6G1QeJhJrcI6czwvSzKvup8IGaLc8VWwRRRIDcjlJ0HF2rWePdMmQlT1luVdjWZLUr0Y 6zSoo9IA2YEPdGyLTaVIq0U8WIUlmVudKGMaK1We6m1kf44fks4Xf2db/9LINWgI8TjS 5D/g== X-Gm-Message-State: AOJu0Yy4V4jHdOOJOmwyDS4+fnAk/kPXn8uII4ze3srX2G6wLmUkhq7+ wRiHLZ4PZ4KiMAA2TaZF9p7cFQ== X-Received: by 2002:aa7:d68f:0:b0:548:92fb:d3bd with SMTP id d15-20020aa7d68f000000b0054892fbd3bdmr3335621edr.16.1700464792056; Sun, 19 Nov 2023 23:19:52 -0800 (PST) Received: from [192.168.1.20] ([178.197.222.11]) by smtp.gmail.com with ESMTPSA id s24-20020a056402165800b00548ab1abc75sm1120332edx.51.2023.11.19.23.19.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 19 Nov 2023 23:19:50 -0800 (PST) Message-ID: <0080b7cb-c23a-48b1-8e5e-02c80baf00e7@linaro.org> Date: Mon, 20 Nov 2023 08:19:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] docs: dt-bindings: add DTS Coding Style document Content-Language: en-US To: Rob Herring Cc: Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, AngeloGioacchino Del Regno , Arnd Bergmann , Bjorn Andersson , Geert Uytterhoeven , Heiko Stuebner , Konrad Dybcio , Matthias Brugger , Michal Simek , Neil Armstrong , Nishanth Menon , Olof Johansson References: <20231116181218.18886-1-krzysztof.kozlowski@linaro.org> From: Krzysztof Kozlowski Autocrypt: addr=krzysztof.kozlow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cVUqa+XdUEciwG/SgNyxBZepj41oVq FPSVE+Ni2tNrW/e16b8mgXNngHSnbsr6pAIXZH3qFW+4TKPMGZ2rZ6zITrMip+12jgw4mGjy 5y06JZvA02rZT2k9aa7i9dUUFggaanI09jNGbRA/ABEBAAHCwXwEGAEKACYCGwwWIQSb0H4O DFH41ZZ3t1Qbk0N9O0FimwUCYDzvagUJFF+UtgAKCRAbk0N9O0Fim9JzD/0auoGtUu4mgnna oEEpQEOjgT7l9TVuO3Qa/SeH+E0m55y5Fjpp6ZToc481za3xAcxK/BtIX5Wn1mQ6+szfrJQ6 59y2io437BeuWIRjQniSxHz1kgtFECiV30yHRgOoQlzUea7FgsnuWdstgfWi6LxstswEzxLZ Sj1EqpXYZE4uLjh6dW292sO+j4LEqPYr53hyV4I2LPmptPE9Rb9yCTAbSUlzgjiyyjuXhcwM qf3lzsm02y7Ooq+ERVKiJzlvLd9tSe4jRx6Z6LMXhB21fa5DGs/tHAcUF35hSJrvMJzPT/+u /oVmYDFZkbLlqs2XpWaVCo2jv8+iHxZZ9FL7F6AHFzqEFdqGnJQqmEApiRqH6b4jRBOgJ+cY qc+rJggwMQcJL9F+oDm3wX47nr6jIsEB5ZftdybIzpMZ5V9v45lUwmdnMrSzZVgC4jRGXzsU EViBQt2CopXtHtYfPAO5nAkIvKSNp3jmGxZw4aTc5xoAZBLo0OV+Ezo71pg3AYvq0a3/oGRG KQ06ztUMRrj8eVtpImjsWCd0bDWRaaR4vqhCHvAG9iWXZu4qh3ipie2Y0oSJygcZT7H3UZxq fyYKiqEmRuqsvv6dcbblD8ZLkz1EVZL6djImH5zc5x8qpVxlA0A0i23v5QvN00m6G9NFF0Le D2GYIS41Kv4Isx2dEFh+/Q== In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 19 Nov 2023 23:20:09 -0800 (PST) On 16/11/2023 21:44, Rob Herring wrote: >> >> Merging idea: Rob/DT bindings >> --- >> Documentation/devicetree/bindings/index.rst | 1 + >> .../devicetree/bindings/writing-dts.rst | 137 ++++++++++++++++++ >> 2 files changed, 138 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/writing-dts.rst > > Perhaps dts-coding-style.rst Ack > > After adding writing-schema, I realized the difference between > writing-schema and writing-bindings isn't all that clear. I never got > around to renaming things. > >> >> diff --git a/Documentation/devicetree/bindings/index.rst b/Documentation/devicetree/bindings/index.rst >> index d9002a3a0abb..975449be4862 100644 >> --- a/Documentation/devicetree/bindings/index.rst >> +++ b/Documentation/devicetree/bindings/index.rst >> @@ -5,5 +5,6 @@ >> >> ABI >> writing-bindings >> + writing-dts >> writing-schema >> submitting-patches >> diff --git a/Documentation/devicetree/bindings/writing-dts.rst b/Documentation/devicetree/bindings/writing-dts.rst >> new file mode 100644 >> index 000000000000..10c477ec1eed >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/writing-dts.rst >> @@ -0,0 +1,137 @@ >> +.. SPDX-License-Identifier: GPL-2.0 >> +.. _writingdts: >> + >> +=================================================== >> +Writing Devicetree Sources (DTS) - DTS Coding Style >> +=================================================== >> + >> +When writing Devicetree Sources (DTS) please observe below guidelines. They >> +should be considered complementary to any rules expressed already in Devicetree >> +Specification and dtc compiler (including W=1 and W=2 builds). >> + >> +Individual architectures and sub-architectures can add additional rules, making >> +the style stricter. >> + >> +Naming and Valid Characters >> +--------------------------- >> + >> +1. Node and property names are allowed to use only: >> + >> + * lowercase characters:: [a-z] >> + * digits:: [0-9] >> + * dash:: - >> + >> +2. Labels are allowed to use only: >> + >> + * lowercase characters:: [a-z] >> + * digits:: [0-9] >> + * underscore:: _ >> + >> +3. Unit addresses should use lowercase hex, without leading zeros (padding). > > Strictly speaking, the unit-address is whatever a bus defines, but > yes, by default, that is the format. > >> + >> +4. Hex values in properties, e.g. "reg", should use lowercase hex. Any address >> + part can be padded with leading zeros. >> + >> +Example:: >> + >> + gpi_dma2: dma-controller@800000 { >> + compatible = "qcom,sm8550-gpi-dma", "qcom,sm6350-gpi-dma"; >> + reg = <0x0 0x00800000 0x0 0x60000>; >> + } >> + >> +Order of Nodes >> +-------------- >> + >> +1. Nodes within any bus, thus using unit addresses for children, shall be >> + ordered incrementally by unit address. >> + >> +2. Nodes without unit addresses should be ordered alpha-numerically. >> + >> +3. When extending nodes in board DTS via &label, the entries should be ordered >> + alpha-numerically. > > Or matching the original node definition order? If there is any sub-arch using such style, then sure, why not. Otherwise if we do not have such examples, I find that a bit tricky to implement: for patches adding new board, one needs to check the original DTSI for order. > >> + >> +Example:: >> + >> + // SoC DTSI >> + >> + \ { > > / { > >> + cpus { >> + // ... >> + }; >> + >> + psci { >> + // ... >> + }; >> + >> + soc@ { >> + dma: dma-controller@10000 { >> + // ... >> + }; >> + >> + clk: clock-controller@80000 { >> + // ... >> + }; >> + }; >> + }; >> + >> + // Board DTS >> + >> + &clk { >> + // ... >> + }; >> + >> + &dma { >> + // ... >> + }; >> + >> + >> +Order of Properties in Device Node >> +---------------------------------- >> + >> +Following order of properties in device nodes is preferred: >> + >> +1. compatible >> +2. reg >> +3. ranges > >> +4. All properties with values >> +5. Boolean properties > > I make this like schemas, standard/common properties first, then > vendor specific properties. Sure. > >> +6. status (if applicable) >> +7. Child nodes >> + >> +The "status" property is by default "okay", thus it can be omitted. >> + >> +Example:: >> + >> + // SoC DTSI >> + >> + usb_1_hsphy: phy@88e3000 { >> + compatible = "qcom,sm8550-snps-eusb2-phy"; >> + reg = <0x0 0x088e3000 0x0 0x154>; >> + #phy-cells = <0>; >> + resets = <&gcc GCC_QUSB2PHY_PRIM_BCR>; >> + status = "disabled"; >> + }; >> + >> + // Board DTS >> + >> + &usb_1_hsphy { >> + clocks = <&tcsr TCSR_USB2_CLKREF_EN>; >> + clock-names = "ref"; >> + status = "okay"; >> + }; >> + >> + >> +Indentation >> +----------- >> + >> +1. Use indentation according to :ref:`codingstyle`. >> +2. For arrays spanning across lines, preferred is to align the continued >> + entries with opening < from first line. >> + >> +Example:: >> + >> + thermal-sensor@c271000 { >> + compatible = "qcom,sm8550-tsens", "qcom,tsens-v2"; >> + reg = <0x0 0x0c271000 0x0 0x1000>, >> + <0x0 0x0c222000 0x0 0x1000>; > > You should cover the <> style too, meaning <> around each logical entry. Ack. Best regards, Krzysztof