Received: by 10.192.165.148 with SMTP id m20csp651699imm; Fri, 20 Apr 2018 12:59:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+7YzNscYavFciE49Om4szZI9mpyQcQQhz0VSYbJ5bJyjYC94Av7fvX/QrqA3m/PJ0eAk+X X-Received: by 2002:a17:902:8283:: with SMTP id y3-v6mr11673091pln.10.1524254381801; Fri, 20 Apr 2018 12:59:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524254381; cv=none; d=google.com; s=arc-20160816; b=KI/1BtM7PFil8GGWHgEm7M2Fehljq+08h2EdtOcy9aCbAH4jkIEJWRt4u+XajPvSxc f733qtzy9t7kpfDMRXeRkf4+IfZU0EcvJaQxC+YvSNpUcamyrGFN6pZrRpUI0dEqD1f4 Tz9gJelED0nL5HOOt9N4uC7USFCJ8voGa8gUFkIEqOt4L5LDuD/0v09HlY5XAKVRKX4H Cie0aX7oIo0LfKJaqdiv923tt0MP3NIOElyy7dQDthCRRKM3x+nhdln3rjIGG1UfjYss 8we/o3VsJYDclw5WEZgNKxLTW0z5KTEhWzsf4JxyPWEASWhiddH4vTasAZlcPb0WgCyI ptYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=kvaxOtoxQXkuAbiZHSygm/RWAL/bytWJTYwl8jxjfCk=; b=XxykjTlv9hBYvYuYyE7X1wboRn7+8dZXbRowlvhlfwLES3dHzUb3Lgsye4cZXFk8T5 1FbkWr8b7PhA+KvHK4ImiK9FrMrZW54Abo08d6m1nwIsNYHMuMFXkpX6h7j11Cnd3/+n +cTwlzrQ/ey5RSgGOEfBLT97N8e+QcR43GikUdafMsHymwrDEKbmIxVBtPb7RUmW9drh TvTGqkwm4g5Ru8h5xnFjU9NNMo/qhfW6O4Aln8xoVYKdV6/EIxOUOiXLlu3fyvlJavNu VJgTygL/q3fXzyq+qtUJwd1LYcnlg64NjVpwVfvv5SV27syDZdv+NgYD3nIEXxDenlcF Ueog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rTahFpY+; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 79si5437947pga.440.2018.04.20.12.59.04; Fri, 20 Apr 2018 12:59:41 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rTahFpY+; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752109AbeDTTxQ (ORCPT + 99 others); Fri, 20 Apr 2018 15:53:16 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:45135 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751092AbeDTTxN (ORCPT ); Fri, 20 Apr 2018 15:53:13 -0400 Received: by mail-pl0-f65.google.com with SMTP id w22-v6so1232550pll.12; Fri, 20 Apr 2018 12:53:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=kvaxOtoxQXkuAbiZHSygm/RWAL/bytWJTYwl8jxjfCk=; b=rTahFpY+T4H8+uEVqaKIjrfU5dhj7QfOTWTLVe5C3Nf90Io01PRxWK4IM0wdS7NZSn LBuXidEpBBuNV6aeayNBlJq7AkemIbErSd5i6ikjUZrWJB8qpHLNtcvubXFfo2u9EAof bXyYpjPYHKjHhbCO6+9ppnYYpPhOqqKxSc5ukqAxl2uXnuseMijKLDkbdkW2yXAXB30E W9R1iBokwbEbEmknUqCzyemt9f9yD799QhCuB6WYFq5XqJPEjQ4Mbm9Tsvi9t1ulBJoK duBKvF3HVAN7xXonraJsh9SNMlLW2iVxzQCiMffmiSNV+zrl3r4Sjyap71fDkED8MJHQ W1hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=kvaxOtoxQXkuAbiZHSygm/RWAL/bytWJTYwl8jxjfCk=; b=D/PS4qUWi5JBDc2gdAZAh89ZRQqZCNziN+lpr3eZKmTkWChbDHar/NY/YcqqCSZkVK FKTYGo0kRHUsHA5MWNkDGUYCUWl1HgVH0jwkR9VLQNaVZLwMqk+mpTIwd2p8sq/vUnHD TiZ8vbGb0WE+Tb6ueTxAktRqX0c48IuIElohlmbNCGUxjC96at329ZYhI12Ulx2vxAL7 31g8ON5qSMpXA0GX0+PQvM3/FSFSXKtjbOsKNiSIOa3nvMs43uMWFhIPuTYdp6AaM3qe FUKtbjWn3IlSBVUlmmQZPI0pz9zrjJxa1piDR4Ot/ULufOyGHLTgD+89vElkrw5td2wW 068Q== X-Gm-Message-State: ALQs6tDH4hATK774vP2ZiYO7LROuI65aSXkVWYK0djw61MldT36tYfTb twgRAtNOXwahBJdKeL3I06Q= X-Received: by 2002:a17:902:584:: with SMTP id f4-v6mr11293470plf.290.1524253992939; Fri, 20 Apr 2018 12:53:12 -0700 (PDT) Received: from [192.168.1.70] (c-24-6-192-50.hsd1.ca.comcast.net. [24.6.192.50]) by smtp.gmail.com with ESMTPSA id a3sm10339461pgc.2.2018.04.20.12.53.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 12:53:12 -0700 (PDT) Subject: Re: [RFC PATCH] dt-bindings: add a jsonschema binding example To: Rob Herring , Stephen Boyd Cc: devicetree-spec@vger.kernel.org, devicetree@vger.kernel.org, "linux-kernel@vger.kernel.org" , Grant Likely , Mark Rutland , Geert Uytterhoeven , Linus Walleij , Thierry Reding , Mark Brown , Shawn Guo , Bjorn Andersson , Arnd Bergmann , Jonathan Cameron References: <20180418222905.10414-1-robh@kernel.org> <152424282214.46528.2511757264045171935@swboyd.mtv.corp.google.com> From: Frank Rowand Message-ID: Date: Fri, 20 Apr 2018 12:53:10 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/20/18 11:15, Rob Herring wrote: > 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 @@ >>> +# SPDX-License-Identifier: BSD-2-Clause >>> +# Copyright 2018 Linaro Ltd. >>> +%YAML 1.2 >>> +--- >>> +# All the top-level keys are standard json-schema keywords except for >>> +# 'maintainers' and 'select' >>> + >>> +# $id is a unique idenifier based on the filename >>> +$id: "http://devicetree.org/schemas/example-schema.yaml#" >>> +$schema: "http://devicetree.org/meta-schemas/core.yaml#" >>> + >>> +# Only 1 version supported for now >>> +version: 1 >>> + >>> +title: An example schema annotated with jsonschema details >>> + >>> +maintainers: >>> + - Rob Herring >>> + >>> +description: | >>> + A more detailed multi-line description of the binding. >>> + >>> + Details about the hardware device and any links to datasheets can go here. >>> + >>> + 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. > >>> + >>> +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. > >>> + 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. > >>> + # The core checks this is a boolean, so just have to list it here to be >>> + # valid for this binding. >>> + >>> + clock-frequency: >>> + # The type is set in the core schema. Per device schema only need to set >>> + # constraints on the possible values. >>> + minimum: 100 >>> + maximum: 400000 >>> + # The value that should be used if the property is not present >>> + default: 200 >>> + >> >> The 'default' field is neat. I look forward to the compiler using the >> schema to insert defaults into the dtb if the properties aren't present >> in the input file. > > That wasn't really my intention, but it's what the OS should use if > property is not present. But at least for required properties, we > could certainly do as you suggest. I understand the thought of 'neat', but it would also add yet one more layer to the "how did this property get into my dtb?" stew. But more importantly, if this becomes a required part of the kernel build process, is it adding a new required tool (python)? (Or is python already required?) There is resistance to adding new tools. -Frank >>> + foo-gpios: >>> + maxItems: 1 >>> + description: A connection of the 'foo' gpio line. >>> + >>> + vendor,int-property: >>> + description: Vendor specific properties must have a description >>> + type: integer # A type is also required >>> + enum: [2, 4, 6, 8, 10] >>> + >>> + vendor,bool-property: >>> + description: Vendor specific properties must have a description >>> + type: boolean >>> + >>> +required: >>> + - compatible >>> + - reg >>> + - interrupts >>> + - interrupt-controller >> >> Can the required or optional parts go under each property instead of >> having a different section? > > No, because then it is not json-schema language. > >> Or does that make the schema parser >> difficult to implement? > > Yes, because then we have to implement a schema parser. > >> It may also make sense to negate this and >> specify only the optional properties, or to require both optional and >> required lists to make things more explicit at the cost of some >> verbosity. >> >>> + >>> +examples: >>> + - | >>> + /{ >> >> Is the first slash required here? > > No, just leftover from being the root node in the example. > > > Thanks for taking a look. > >>> + compatible = "vendor,soc4-ip", "vendor,soc1-ip"; >>> + reg = <0x1000 0x80>, >>> + <0x3000 0x80>; >>> + reg-names = "core", "aux"; >>> + interrupts = <10>; >>> + interrupt-controller; >>> + }; >