Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp935430rdf; Wed, 22 Nov 2023 00:28:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGmRq/sFj0GIHkbR+VBzQdvI9mQdu+0hgPOlut+p7Xl4eeZ0Bs2EOYpHxftMBlKQtP/IS0 X-Received: by 2002:a17:902:b7c7:b0:1cc:6acc:8fa4 with SMTP id v7-20020a170902b7c700b001cc6acc8fa4mr1500268plz.32.1700641731674; Wed, 22 Nov 2023 00:28:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700641731; cv=none; d=google.com; s=arc-20160816; b=WFVEMhQGWOX0fYsPdpK4o/5pPr/kiYMOjRMCjoKI8c42mFAeZuBFep09FD3ZiWDMwc qU5CMilvEgrl4nTWBdGPRLN4oyan2GtBiuvKE3eupRSH6y0t5lja+k4lt4qek758VYrY gN0t/1SewfOx+rL7OIpGlsKElajezLubzTwvBdzHcH6HftDTj7cJcm+BTHxK8gkql7x9 Owh+oE1lF84B3LAisS2O7Hkm0ZKrcLuoyQTsrpM+MqhxgjB0JEeBo9x22pAEq7GhVQ3s d87Y2zSqHIs3kgjxsfp2Xs3eqrooL+UqmlhRGAjgOpCZyPK52GoNs//HTWmbxWV8gXHy 1b9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=4E6h6y+hIWq4B+tk4//RAnmDzo6OYZ7LWXX41DOL/6M=; fh=6fh3q9N+CFvKl19gv0q3of+prtG7IpWifyLm/gOVj48=; b=WloGMxvvP42lo4xDo31CBJkN4XgGuY7TrsycsRfJGvao40MedWKMeqfvrLmCOUfbqW uTbvByXEtvht1AJysGqHM541YXg9uNiykosh63v9WAVE2r4oNaVVHOkDBGoD/6fnNYFQ DetCgBGVzaAAlJvdO5j6pu4puPS6txhca50usy6uJZ2aWeuFzZCgrWO64Z6h0qp0cjK6 CEiDP+Q6AweQfu5aqYTqvrQ2k6N7wCSLpyegrHM3XYYwcZPqIvGZMkb0rDUWILL2IbQL jquWgkPZx6LvkeHi5fvsrx21hw//YGJaOcsMwrHOUe8C0rQ5+eEBshyLaHM2ey1Fmyt0 Cnfg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id z7-20020a1709028f8700b001b3bd85f54bsi11389195plo.35.2023.11.22.00.28.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 00:28:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 9B7668028A59; Wed, 22 Nov 2023 00:28:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230403AbjKVI2t convert rfc822-to-8bit (ORCPT + 99 others); Wed, 22 Nov 2023 03:28:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230257AbjKVI2r (ORCPT ); Wed, 22 Nov 2023 03:28:47 -0500 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA2B193; Wed, 22 Nov 2023 00:28:43 -0800 (PST) Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-5cb9407e697so15301867b3.3; Wed, 22 Nov 2023 00:28:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700641723; x=1701246523; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Gha+lhz98cqfqHPVBYNZIJYx9aE1nB2ARipNu2FhWYQ=; b=E4CX+G9g6PMBq61+FezDEPrbc3vEMCVfhrQTs9NqW3enepgaYnNsvjNWl91m/RaMll +zJqdWfnnTtRh8lI1nSjLcC7TmAGBmocoGlFGHAACas8nvTHcRKvlHj0ep75d1VT7HxZ m1yXtHOWxUkkq9qEK+jOGCSpv2+Cd9HEGAPHI93g+cv9UX0XHNVUGbjcQQ7o8O2vG/xm gF1hQLsOcMKDhIpkEQe8+8/tVmoXzMk7mY5A+f0UOPXMBtoblIRAytLx6DdAqTxVgjiS qQ1vtJhLuVXLXVq5BKsxjgYH4GAKeX150RjWHoeGsCbYvkkfhZQpiMbQ0hs063Y6cIVj G+CA== X-Gm-Message-State: AOJu0Ywl5qIYuFLG8PMVq1y22KseVkIW2KYTy2PY01gBWVZGJOE2wp1A WYPAMxwSVxp5QpBqn3DDClOsA4OchKlEeQ== X-Received: by 2002:a0d:d547:0:b0:5b3:26e1:320c with SMTP id x68-20020a0dd547000000b005b326e1320cmr1478260ywd.40.1700641722909; Wed, 22 Nov 2023 00:28:42 -0800 (PST) Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com. [209.85.219.182]) by smtp.gmail.com with ESMTPSA id a190-20020a0dd8c7000000b005a8d713a91esm3559623ywe.15.2023.11.22.00.28.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Nov 2023 00:28:41 -0800 (PST) Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-da3b4b7c6bdso6358915276.2; Wed, 22 Nov 2023 00:28:41 -0800 (PST) X-Received: by 2002:a25:cec5:0:b0:d9b:dae4:63fa with SMTP id x188-20020a25cec5000000b00d9bdae463famr1414014ybe.34.1700641720963; Wed, 22 Nov 2023 00:28:40 -0800 (PST) MIME-Version: 1.0 References: <20231120084044.23838-1-krzysztof.kozlowski@linaro.org> <6b288a2e-d147-4bd3-b1d4-daf56295d939@gmail.com> <01f9ce3b-e6e5-4b05-bf7f-0b3a5f74910a@linaro.org> <7232a48b-b9ad-44b5-ae6a-d12dad70b3c4@linaro.org> In-Reply-To: <7232a48b-b9ad-44b5-ae6a-d12dad70b3c4@linaro.org> From: Geert Uytterhoeven Date: Wed, 22 Nov 2023 09:28:22 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] docs: dt-bindings: add DTS Coding Style document To: Krzysztof Kozlowski Cc: wens@kernel.org, =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= , 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 , Geert Uytterhoeven , Heiko Stuebner , Konrad Dybcio , Michal Simek , Neil Armstrong , Nishanth Menon , Olof Johansson , linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-msm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 22 Nov 2023 00:28:50 -0800 (PST) On Wed, Nov 22, 2023 at 9:21 AM Krzysztof Kozlowski wrote: > On 22/11/2023 09:09, Chen-Yu Tsai wrote: > > On Wed, Nov 22, 2023 at 4:05 PM Krzysztof Kozlowski > > wrote: > >> On 21/11/2023 14:50, Rafał Miłecki wrote: > >>>> +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 should 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 should be > >>>> + ordered alpha-numerically. > >>> > >>> Just an idea. Would that make (more) sense to make &label-like entries > >>> match order of nodes in included .dts(i)? > >>> > >>> Adventages: > >>> 1. We keep unit address incremental order that is unlikely to change > >>> > >>> Disadventages: > >>> 1. More difficult to verify > >> > >> Rob also proposed this and I believe above disadvantage here is crucial. > >> If you add new SoC with board DTS you are fine. But if you add only new > >> board, the order of entries look random in the diff hunk. Reviewer must > >> open SoC DTSI to be able to review the patch with board DTS. > >> > >> If review is tricky and we do not have tool to perform it automatically, > >> I am sure submissions will have disordered board DTS. > >> > >>> > >>> > >>>> +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. Standard/common properties (defined by common bindings, e.g. without > >>>> + vendor-prefixes) > >>>> +5. Vendor-specific properties > >>>> +6. status (if applicable) > >>>> +7. Child nodes, where each node is preceded with a blank line > >>>> + > >>>> +The "status" property is by default "okay", thus it can be omitted. > >>> > >>> I think it would really help to include position of #address-cells and > >>> #size-cells here. In some files I saw them above "compatible" that seems > >>> unintuitive. Some prefer putting them at end which I think makes sense > >>> as they affect children nodes. > >>> > >>> Whatever you choose it'd be just nice to have things consistent. > >> > >> This is a standard/common property, thus it goes to (4) above. > > > > It's probably a mix, but AFAIK a lot of the device trees in tree have > > #*-cells after "status". In some cases they are added in the board > > .dts files, not the chip/module .dtsi files. > > Existing DTS is not a good example :) > > > > > +1 that it makes sense at the end as they affect child nodes. > > I still insist that status must be the last, because: > 1. Many SoC nodes have address/size cells but do not have any children > (I2C, SPI), so we put useless information at the end. > 2. Status should be the final information to say whether the node is > ready or is not. I read the node, check properties and then look at the end: > a. Lack of status means it is ready. > b. status=disabled means device still needs board resources/customization +1 for status at the end (before children), so it's easy to find. Also, reality can look like the example in the bindings, with an optional status property appended. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds