Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp2057568rdh; Sat, 25 Nov 2023 11:48:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IE7eJhvDH2T/5Nz4rg/SQ2eQ8T6D2xlYVbrV2pA8bi1+bFoXi8cWilSTW04acv4PUKq4Mau X-Received: by 2002:a05:6870:8197:b0:1f5:56b2:e502 with SMTP id k23-20020a056870819700b001f556b2e502mr8982385oae.0.1700941718040; Sat, 25 Nov 2023 11:48:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700941718; cv=none; d=google.com; s=arc-20160816; b=BoujzBsQmLfqp5/V5sQ1SZpcCyiD6srT59YTdW6ySqAlKyRW0owpV9KWFhZ6+DELAI h7DrkgWqh/ncJHwrcQnbpCf7NkQbtE38rsU3oglR527tfsCWctWblCFANymPT0Uc/hpa 046SXJxSGbShECS0wB3uqsPbjVepsUmjLHcQpr+pnX4uAu92XtFeNlliy01BQYwwwfZq LrhkDXkPaVdNBlIkOHJkr3pFaNgzaWf/8r9Z2pZxoap0+jFOPuwfFEsBE8QjrTfVlw6C p1hZ9Wr58TbhX0JCb/QY21rXolCEI83MW1TrE9TKrn12knBarS/Ahy3LyBZ3xcVX9nFC pngA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=4nRmKJdjQImKVKvkDXekyzERU99Y30X50Uk5jPOijCY=; fh=aLp+ctzarGjyLkZPc3X62gV2OM4I3QQNrD/oOnQ+9qo=; b=EOr7hmNwkgRX2t1fPWOSnXvTC4TVullIxI3CjYSec9HJ1tW52oCmZsDorQXq8ZPWHy anXHqP6o8wIfgfoQUqVsMMw+tIjTgNhD/+fK0LIj7addhdGyCxMx1CiiS8FF62miBjMW kQVI4cAOtuQgdpfD0r0sOp9Cp2TWI/6zkNxyguDB70/C0eXvmhfejVLqkDoNjhmcytuq enbQniGQFWg8f/V9XH6lhcVJJF9mJPVtpQhlAeKAstl+sF3Ztj2U6xKXbbtBOZsB5lEF yTULm1k1KFEfB/k9NNrn1yoR0clW2YqJ1US6UpXnp7wyHrqyrSUMii+aLqlLpeTQ97he X/aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=bUmqga52; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id n14-20020a17090ade8e00b002847b85bbeasi6778350pjv.150.2023.11.25.11.48.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Nov 2023 11:48:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=bUmqga52; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 9271E803DB2B; Sat, 25 Nov 2023 11:48:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229726AbjKYTsG (ORCPT + 99 others); Sat, 25 Nov 2023 14:48:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229653AbjKYTsD (ORCPT ); Sat, 25 Nov 2023 14:48:03 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2391B3; Sat, 25 Nov 2023 11:48:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=4nRmKJdjQImKVKvkDXekyzERU99Y30X50Uk5jPOijCY=; b=bUmqga52u5ZN8KifEwNMhDyiPA /TFQjbAbx8fGQdVoi5rxm3COj3rEclulLj+6FXL2nSiYCSRdIJATu8HKoN1nlR6IkXp7sCExgIBLI hFkayCNKWWXkftJV69lR8n3hiDzcRi5PHnunbIvWKayKCR9g0p4/sDxM6C9tR4lEehPc=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1r6yd5-001Czk-9T; Sat, 25 Nov 2023 20:47:51 +0100 Date: Sat, 25 Nov 2023 20:47:51 +0100 From: Andrew Lunn To: Krzysztof Kozlowski Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Andrew Davis , Arnd Bergmann , Bjorn Andersson , Chen-Yu Tsai , Dmitry Baryshkov , Geert Uytterhoeven , Heiko Stuebner , Jonathan Corbet , Konrad Dybcio , Michal Simek , Neil Armstrong , Nishanth Menon , Olof Johansson , =?utf-8?B?UmFmYcWCIE1pxYJlY2tp?= , linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-msm@vger.kernel.org, workflows@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [PATCH v3] docs: dt-bindings: add DTS Coding Style document Message-ID: References: <20231125184422.12315-1-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231125184422.12315-1-krzysztof.kozlowski@linaro.org> 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 morse.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 (morse.vger.email [0.0.0.0]); Sat, 25 Nov 2023 11:48:35 -0800 (PST) > +===================================== > +Devicetree Sources (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. It would be nice to add a pointer where such rules are documented. > +Naming and Valid Characters > +--------------------------- > + > +Devicetree specification allows broader range of characters in node and > +property names, but for code readability the choice shall be narrowed. > + > +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 shall use lowercase hex, without leading zeros (padding). > + > +4. Hex values in properties, e.g. "reg", shall use lowercase hex. The address > + part can be padded with leading zeros. > + > +Example:: > + > + gpi_dma2: dma-controller@800000 { Not the best of example. Upper case 8 does not exist, as far as i known. > + compatible = "qcom,sm8550-gpi-dma", "qcom,sm6350-gpi-dma"; > + reg = <0x0 0x00800000 0x0 0x60000>; Maybe introduce some [a-f] in the example reg? > +Order of Nodes > +-------------- > + > +1. Nodes within any bus, thus using unit addresses for children, shall be > + ordered incrementally by unit address. > + Alternatively for some sub-architectures, nodes of the same type can be > + grouped together (e.g. all I2C controllers one after another even if this > + breaks unit address ordering). > + > +2. Nodes without unit addresses shall be ordered alpha-numerically by the node > + name. For a few types of nodes, they can be ordered by the main property > + (e.g. pin configuration states ordered by value of "pins" property). > + > +3. When extending nodes in the board DTS via &label, the entries shall be > + ordered either alpha-numerically or by keeping the order from DTSI (choice > + depending on sub-architecture). Are these sub-architecture choices documented somewhere? Can you include a hint which they are? > +Example:: > + > + /* SoC DTSI */ > + > + / { Dumb question. Does this open { indicate the start of a bus? > + cpus { > + /* ... */ > + }; > + > + psci { > + /* ... */ > + }; If that does indicate a bus, the nodes above are ordered alpha-numerically, according to 2). > + > + soc@ { This has a unit address, even if its missing, so should be sorted by 1). Should there be something in the coding style that 2) comes before 1) on the bus? And if that is true, don't you think it would make sense to swap 1) and 2) in the description above? > + dma: dma-controller@10000 { > + /* ... */ > + }; > + > + clk: clock-controller@80000 { > + /* ... */ > + }; > + }; > + }; > + > + /* Board DTS - alphabetical order */ > + > + &clk { > + /* ... */ > + }; > + > + &dma { > + /* ... */ > + }; > + > + /* Board DTS - alternative order, keep as DTSI */ > + > + &dma { > + /* ... */ > + }; > + > + &clk { > + /* ... */ > + }; Do you imaging there will ever be a checkpatch for DT files? The second alternative seems pretty difficult to check for with tools. You need to include all the .dtsi files to determine the ordered tree, then flatten it to get the properties order. Should we discourage this alternative? > +Indentation > +----------- > + > +1. Use indentation according to :ref:`codingstyle`. > +2. For arrays spanning across lines, it is preferred to align the continued > + entries with opening < from the first line. > +3. Each entry in arrays with multiple cells (e.g. "reg" with two IO addresses) > + shall be enclosed in <>. > + > +Example:: > + > + thermal-sensor@c271000 { > + compatible = "qcom,sm8550-tsens", "qcom,tsens-v2"; > + reg = <0x0 0x0c271000 0x0 0x1000>, > + <0x0 0x0c222000 0x0 0x1000>; > + }; I'm not sure i understand this. Is this example correct? gpio-fan,speed-map = <0 0 3000 1 6000 2>; It exists a lot in todays files. > +The DTSI and DTS files shall be organized in a way representing the common > +(and re-usable) parts of the hardware. Typically this means organizing DTSI > +and DTS files into several files: > + > +1. DTSI with contents of the entire SoC (without nodes for hardware not present > + on the SoC). Maybe point out that SoC DTSI files can by hierarchical when there is a family of SoCs. You often have one .DTSI file for all the common parts of a family. And then each member of the family has a .dtsi file which includes the core, and then adds properties for that member of the family. The word 'entire' probably gives the wrong idea about this. Andrew