From patchwork Thu Dec 14 13:50:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 753923 Delivered-To: patch@linaro.org Received: by 2002:adf:ff85:0:b0:336:3f68:820c with SMTP id j5csp758007wrr; Thu, 14 Dec 2023 05:52:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFs36cypdpnta/dyluduDI5ydRamm7iWi0ojVHKZnkFqx2U9JJyMK4Qkm86w94IrCbfJB0B X-Received: by 2002:a2e:b6d3:0:b0:2c9:f58b:703 with SMTP id m19-20020a2eb6d3000000b002c9f58b0703mr4661339ljo.77.1702561925695; Thu, 14 Dec 2023 05:52:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702561925; cv=none; d=google.com; s=arc-20160816; b=NzU5mhg83aLXh3/ecLME4JmS20sQNWZoClw45HBliYOTFEB3G+7PtHGHQS92kaFwIa m9U4FUIsnB9FDcjOtJQ7oUM/a1IL8sUN2dzCCn+WHbOkrAtcUCuYL/VJ815OovvWgnRz NmBGlcITQ4Sn3itlGxQQR7GOx9HKDHFrJ4oF6jkXbl8sresWri/Ff1FcnFQYwiGpPRYs uNLip4q5xHnJmWLueabPJw+fGqNMyP82if679XMGnDpYHDgEbkcbVYNZRYAusnwN55d1 eYqXfUYeoUQigcQS+Cq2CnUKz4tdSQXVTu3h1JTN1eH+5m/0VQzsa1BIcPTKYh01WBtC pd/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=u1OsPqfGmFH05ZPKbNH4dIRe46agPWiUEln2hoUy/k4=; fh=VZWdizSVWfhngo19Gt5nLjhnxzdtHBYWvcywp4ujR58=; b=IebvPva9Hh2eNX+jpUy+JDl0y+jEDf3tMdi/F9KmYiSRp+J5oEun/r0Wci/qPIi3vk i9vATpxog0TnQDE/dE17Y5beNKjbJJ4prriDXOTCauAZ1yJfff7LqRipq8JGHap7j1Cb W/XBn5vlhIeCAsjFCJdEu+ZXWFCTClA2oIxp5FahIcx3TQXXPT3QO4adilC+o9c6E9me OAJA06Kni4hHVv7LO3z7AYaPiQJSsneSAWlcS4GVCy8AqUg3p3LdpUfkZJWd1AFdn1ZO iWhuHYZZX1zR/BKDG9KxaZidxIBjtUmmhSDkrkWLnGCXADyyL0yuknaPupsfXZNTGzxN tQQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="vwcZRWD/"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id d4-20020a2e9284000000b002c9bf35881asi4467354ljh.247.2023.12.14.05.52.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 05:52:05 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="vwcZRWD/"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C554287A42; Thu, 14 Dec 2023 14:51:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="vwcZRWD/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A855787A72; Thu, 14 Dec 2023 14:51:57 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A6EC287A76 for ; Thu, 14 Dec 2023 14:51:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sumit.garg@linaro.org Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1d345b187bbso24297045ad.0 for ; Thu, 14 Dec 2023 05:51:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702561912; x=1703166712; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u1OsPqfGmFH05ZPKbNH4dIRe46agPWiUEln2hoUy/k4=; b=vwcZRWD/82KtlBuHx+vp41+IupfMcpGej4keWor0NSto2/ukLlAYE6RPeHrwylndZq Uad0AiBmJxV+lhW4BkNG+T83F7nmZIegn+oAsDytkR3KT+QOerPFDwJCnuhByxZGmSDe UnW23ZEnXdLiNQDWeqFtxPjH3FGzc3Zqv6OQjhOCmwBIg5nyrist7XUcZ+GXqFgqWqpZ Uma4GV4YoOXEzre5g5t/4kI4QBtvK500Gvl5N/hSzLzXKvcF0ypQ2GR1siofBGH/ulko 3L9jHkqzQKSK3j8uCLR1zz3YuPAh5HegBZ31mKalsTbc5GYJJK8Cu1+uTcIcjC+Jym2t 59qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702561912; x=1703166712; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u1OsPqfGmFH05ZPKbNH4dIRe46agPWiUEln2hoUy/k4=; b=NTdiebAGSBvDoODzK3mVdt5VH+WL7eyTG5weBlYn8ZWullxkQIulZfgo5kUioLQUKL 4i7GtDIR9tKGUJ/nZZ4Kyhrn0v2dqen43zXUtUB16AszSYOA1fm8WIevbc2yX4Ctdspm pnIkh7EGfaN6r5s92IZ6zkXHi+d8MJejFksjj7F8A4d1xnPz5P+Fc1hpZX9FowAacWDd J+gZ4sabeqTNxvBmMO/y2kq9wJT4qxs+JD7SPaSN2VbdnTAEuyy8bIfqMK6yvDwMkLJn Z4GeMgOl85REGqTPBIbM7xCU0KsR5dp7ARil+a3kExSa4CNr21hwsPaq04l95lkvXvcd r59Q== X-Gm-Message-State: AOJu0YypVhX+umlIqsbjjrnQenu0rpK81Y5733hHuf4RT9dsBkLaMn9I uwfiZyGvp4hJBGObNBRo1OYp1uUC68TtBZMKf0ktww== X-Received: by 2002:a17:903:2b0f:b0:1d3:44ad:2156 with SMTP id mc15-20020a1709032b0f00b001d344ad2156mr5126443plb.2.1702561911882; Thu, 14 Dec 2023 05:51:51 -0800 (PST) Received: from sumit-X1.. ([223.178.213.6]) by smtp.gmail.com with ESMTPSA id j3-20020a170902c08300b001cfc68125desm12474956pld.203.2023.12.14.05.51.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 05:51:51 -0800 (PST) From: Sumit Garg To: u-boot@lists.denx.de, u-boot-amlogic@groups.io, u-boot-custodians@lists.denx.de Cc: trini@konsulko.com, sjg@chromium.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor@kernel.org, neil.armstrong@linaro.org, caleb.connolly@linaro.org, ff@shokubai.tech, daniel.thompson@linaro.org, dgilmore@fedoraproject.org, pbrobinson@gmail.com, ilias.apalodimas@linaro.org, maxim.uvarov@linaro.org, b.galvani@gmail.com, xypron.glpk@gmx.de, michal.simek@amd.com, seanga2@gmail.com, rasmus.villemoes@prevas.dk, peng.fan@nxp.com, jh80.chung@samsung.com, rfried.dev@gmail.com, marex@denx.de, Sumit Garg Subject: [PATCH 2/8] Makefile: Add support for DT bindings schema checks Date: Thu, 14 Dec 2023 19:20:57 +0530 Message-Id: <20231214135103.1606605-3-sumit.garg@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231214135103.1606605-1-sumit.garg@linaro.org> References: <20231214135103.1606605-1-sumit.garg@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean This adds the build infrastructure for checking DT binding schema documents and validating dtb files using the binding schema. Here we use devicetree-rebasing directory to provide the DT bindings. Dependency: ----------- The DT schema project must be installed in order to validate the DT schema binding documents and validate DTS files using the DT schema. The DT schema project can be installed with pip:: pip3 install dtschema Note that 'dtschema' installation requires 'swig' and Python development files installed first. On Debian/Ubuntu systems:: apt install swig python3-dev Testing: -------- Build dts files and check using DT binding schema: $ make dtbs_check Optionally, DT_SCHEMA_FILES can be passed in with a schema file(s) to use for validation. This makes it easier to find and fix errors generated by a specific schema. Note, at this point dtbs_check is an optional build target as there are many warnings generated due to custom DT properties used by many platforms in u-boot. It is expected with these checks that compliance with DT bindings to take place. Once that's done it can be added to CI builds to remain compliant with DT bindings. Signed-off-by: Sumit Garg --- Makefile | 20 ++++++++++++++++++-- scripts/Makefile.lib | 17 +++++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 750bbdb1b71..d8d168cd4c3 100644 --- a/Makefile +++ b/Makefile @@ -1158,12 +1158,28 @@ endif @# disabling OF_BOARD. $(call cmd,ofcheck,$(KCONFIG_CONFIG)) -PHONY += dtbs +PHONY += dtbs dtbs_check dtbs: dts/dt.dtb @: -dts/dt.dtb: u-boot +dts/dt.dtb: dtbs_prepare u-boot $(Q)$(MAKE) $(build)=dts dtbs +dtbs_prepare: prepare3 + +ifneq ($(filter dtbs_check, $(MAKECMDGOALS)),) +export CHECK_DTBS=y +endif + +ifneq ($(CHECK_DTBS),) +dtbs_prepare: dt_binding_check +endif + +dtbs_check: dt_binding_check dtbs + +DT_BINDING_DIR := devicetree-rebasing/Bindings +dt_binding_check: scripts_dtc + $(Q)$(MAKE) $(build)=$(DT_BINDING_DIR) $(DT_BINDING_DIR)/processed-schema.json + quiet_cmd_copy = COPY $@ cmd_copy = cp $< $@ diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 16bbc277a9f..27b9437027c 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -356,8 +356,21 @@ endif dtsi_include_list_deps = $(addprefix $(obj)/,$(subst $(quote),,$(dtsi_include_list))) -$(obj)/%.dtb: $(src)/%.dts $(DTC) $(dtsi_include_list_deps) FORCE - $(call if_changed_dep,dtc) +ifneq ($(CHECK_DTBS),) +DT_CHECKER ?= dt-validate +DT_CHECKER_FLAGS ?= $(if $(DT_SCHEMA_FILES),-l $(DT_SCHEMA_FILES),-m) +DT_BINDING_DIR := devicetree-rebasing/Bindings +DT_TMP_SCHEMA := $(objtree)/$(DT_BINDING_DIR)/processed-schema.json + +quiet_cmd_dtb = DTC_CHK $@ + cmd_dtb = $(cmd_dtc) ; $(DT_CHECKER) $(DT_CHECKER_FLAGS) -u $(srctree)/$(DT_BINDING_DIR) -p $(DT_TMP_SCHEMA) $@ || true +else +quiet_cmd_dtb = $(quiet_cmd_dtc) + cmd_dtb = $(cmd_dtc) +endif + +$(obj)/%.dtb: $(src)/%.dts $(DTC) $(dtsi_include_list_deps) $(DT_TMP_SCHEMA) FORCE + $(call if_changed_dep,dtb) pre-tmp = $(subst $(comma),_,$(dot-target).pre.tmp) dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)