Received: by 10.192.165.148 with SMTP id m20csp883000imm; Fri, 20 Apr 2018 18:41:15 -0700 (PDT) X-Google-Smtp-Source: AIpwx49KYGhE98nFrAPLFfYc3/OEoocrdFq4fiwRk00sVr76ZnfbpCKQeGEvXvz/u/c0qQg3x6cY X-Received: by 10.98.88.194 with SMTP id m185mr11322276pfb.167.1524274875210; Fri, 20 Apr 2018 18:41:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524274875; cv=none; d=google.com; s=arc-20160816; b=FigifMcMTfsUY4p+V/K8a1pXJJlBw5g+l62rSBNOsD3/qcY7rakw0Fp2f1SFt94wFA BTPHZZsA1c4vrsNSYpc+kEuYIDeiSbNG3mvw66IuEdLyMN7lr8fXCpFunkQnjnF78cjf sUAub3qjDK4lhNCMg3To6Kj1RjnTPBXV69WTHM4DD9+wHhXg96B8M+sMwu/8W85bKfYR Qt+rg1YR1Y6BHOJGm3ZXgi0CeSdHAcG5KI8vUltIvvbHMOACu1o5MBXAlIFoAPdXReyL 0VDNl/vYTl6+VnRc0eyLhctoHQxsQ4zbaxLuN2wevTQb83ie59ynazmbQFxykQw6NY/V 8hPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dmarc-filter :arc-authentication-results; bh=brCzNxroF2E6xxqfQpJfZwM49rXbZtJK2GbcnpHOQEU=; b=v1fb4YvQO7l3SLqjmb4K6qSIvVQE6v3KazDSbDRR+qODXG5GiGbX+5v9rts01kmg2X p14j5VNTF2dWGT7izl0/cSxN+rFSgOMAHeHCVUqDrWAgI/vXzN79NnC1fTER/AddyamM O7tVLNDwz+OuDyfRa/0qWmtUWITvZO/b9epAIFWVBwalyXuP+XpevarERy+rxlr/Gkl7 ihHmuvAcyHiFAfbRD6NlotXxd/4AeB6dvfmmGl7CZlxJ/IL6jfTynejQcdtK1wfCp/uF 24QAIihKkZTtMoZUdm1jL6uWvS7gubBpg/LMq8xGzn2Z1GIGQ6YA5gnBLAV26fV1mvxO 8eLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v7si5748995pgr.443.2018.04.20.18.40.36; Fri, 20 Apr 2018 18:41:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752722AbeDUBek (ORCPT + 99 others); Fri, 20 Apr 2018 21:34:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:55024 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752096AbeDUBei (ORCPT ); Fri, 20 Apr 2018 21:34:38 -0400 Received: from mail-qk0-f169.google.com (mail-qk0-f169.google.com [209.85.220.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 30DA621742; Sat, 21 Apr 2018 01:34:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 30DA621742 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=robh@kernel.org Received: by mail-qk0-f169.google.com with SMTP id i73so10574561qke.6; Fri, 20 Apr 2018 18:34:38 -0700 (PDT) X-Gm-Message-State: ALQs6tC4g4vJVR0vJteTxbafFeL1pZLV/iaFZpAB0eHDdQAYoo637nEs pka2NQF+OlPC9IJ6VW3kzDUyjxsRnbIgF/8aJQ== X-Received: by 10.55.44.70 with SMTP id s67mr7711411qkh.120.1524274477340; Fri, 20 Apr 2018 18:34:37 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.163.228 with HTTP; Fri, 20 Apr 2018 18:34:16 -0700 (PDT) In-Reply-To: <152426770474.46528.1592920281091105196@swboyd.mtv.corp.google.com> References: <20180418222905.10414-1-robh@kernel.org> <152424282214.46528.2511757264045171935@swboyd.mtv.corp.google.com> <152426770474.46528.1592920281091105196@swboyd.mtv.corp.google.com> From: Rob Herring Date: Fri, 20 Apr 2018 20:34:16 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH] dt-bindings: add a jsonschema binding example To: Stephen Boyd Cc: devicetree-spec@vger.kernel.org, devicetree@vger.kernel.org, "linux-kernel@vger.kernel.org" , Grant Likely , Frank Rowand , Mark Rutland , Geert Uytterhoeven , Linus Walleij , Thierry Reding , Mark Brown , Shawn Guo , Bjorn Andersson , Arnd Bergmann , Jonathan Cameron Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 20, 2018 at 6:41 PM, Stephen Boyd wrote: > Quoting Rob Herring (2018-04-20 11:15:04) >> On Fri, Apr 20, 2018 at 11:47 AM, Stephen Boyd wrote: >> > Quoting Rob Herring (2018-04-18 15:29:05) >> >> diff --git a/Documentation/devicetree/bindings/example-schema.yaml b/Documentation/devicetree/bindings/example-schema.yaml >> >> new file mode 100644 >> >> index 000000000000..fe0a3bd1668e >> >> --- /dev/null >> >> +++ b/Documentation/devicetree/bindings/example-schema.yaml >> >> @@ -0,0 +1,149 @@ >> >> + >> >> + The end of the description is marked by indentation less than the first line >> >> + in the description. >> >> + >> >> +select: false >> >> + # 'select' is a schema applied to a DT node to determine if this binding >> >> + # schema should be applied to the node. It is optional and by default the >> >> + # possible compatible strings are extracted and used to match. >> > >> > Can we get a concrete example here? >> >> select: true >> >> :) Which is apply to every node. >> >> A better one is from the memory node schema ('$nodename' gets added : >> >> select: >> required: ["$nodename"] >> properties: >> $nodename: >> oneOf: >> - pattern: "^memory@[0-9a-f]*" >> - const: "memory" # 'memory' only allowed for selecting >> >> >> I expect the vast majority of device bindings will not use select at >> all and rely on compatible string matching. > > Thanks! I was looking to see how the select syntax would work and this > shows one example nicely. I suppose another way would be to show how a > compatible string would be matched through select, even though it's > redundant. > > Is there a way we can enforce node names through the schema too? For > example to enforce that a clock controller is called 'clock-controller' > or a spi master is called 'spi'. Yes, that's something I'd like to do. I think the easiest is to just treat node name as a property. We already generate a $nodename property when parsing the yaml format DT. >> >> >> + >> >> +properties: >> > [...] >> >> + >> >> + interrupts: >> >> + # Either 1 or 2 interrupts can be present >> >> + minItems: 1 >> >> + maxItems: 2 >> >> + items: >> >> + - description: tx or combined interrupt >> >> + - description: rx interrupt >> >> + >> >> + description: | >> > >> > The '|' is needed to make yaml happy? >> >> Yes, this is simply how you do literal text blocks in yaml. >> >> We don't really need for this one really, but for the top-level >> 'description' we do. The long term intent is 'description' would be >> written in sphinx/rst and can be extracted into the DT spec (for >> common bindings). Grant has experimented with that some. > > Ok. That sounds cool. Then we could embed links to datasheets and SVGs > too. > >> >> >> + A variable number of interrupts warrants a description of what conditions >> >> + affect the number of interrupts. Otherwise, descriptions on standard >> >> + properties are not necessary. >> >> + >> >> + interrupt-names: >> >> + # minItems must be specified here because the default would be 2 >> >> + minItems: 1 >> >> + items: >> >> + - const: "tx irq" >> >> + - const: "rx irq" >> >> + >> >> + # Property names starting with '#' must be quoted >> >> + '#interrupt-cells': >> >> + # A simple case where the value must always be '2'. >> >> + # The core schema handles that this must be a single integer. >> >> + const: 2 >> >> + >> >> + interrupt-controller: {} >> > >> > Does '{}' mean nothing to see here? >> >> Yes. It's just an empty schema that's always valid. > > Could we include another schema to indicate that this is an interrupt > controller? I'm sort of asking for multi-schema inheritance. Yes, but there's no need to do that here. Another schema can select on "interrupt-controller" property and be applied independently. There's already an example of that for the root node in my yaml-bindings repo. Rob