From patchwork Thu Feb 22 09:35:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 774837 Delivered-To: patch@linaro.org Received: by 2002:a5d:6ac2:0:b0:33b:4db1:f5b3 with SMTP id u2csp714124wrw; Thu, 22 Feb 2024 03:25:00 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVW1wDilERucYaH0eRcNYo1PJgAjUaTFJz2jD3BvN4EWUKCZjeYfFgKYiRJaGm1ItZwg1T4x44xx5aASfVYM36m X-Google-Smtp-Source: AGHT+IG//dvkPpR3Z0zDJ2hq7Htzwd18+HUapo5Z5+lfaX839FkAS7xzaABnXYGPchPcDujzM56n X-Received: by 2002:a05:6402:75a:b0:564:606a:c830 with SMTP id p26-20020a056402075a00b00564606ac830mr8306570edy.5.1708601100730; Thu, 22 Feb 2024 03:25:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708601100; cv=none; d=google.com; s=arc-20160816; b=ETTZpAEsDA6JG5wQCN/p9HC5OAJ5cNOp3EStOuXA4VL6s/efTSX5eVxbRzYvp09C+o PZZ5Kyepdh5o7zwJHG9FN3rHM/kVedBYh+E6BL4ONJvfvNehBXOUj+Ri9Pjamnu1wkFk AzL3z3WIuVCWjgeAZhGlZb89siFFcfzfDga9hugKP2tK18j2bxH10ndP04hnVzJoaKHQ taM6ePMr461Y2ZlQHOhkSkOPg8NDIzFeN7V9zdlJFLRp1ybjrcZagAxioEKSiuIVTByg /x46+pNOaTK0MNd3z0gBCkMWCtCkp4ahs8et6AeacvHGwtPTOYan/oDD0VdBoDyReqq+ IwYA== 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=aGR4wADzfSH9X0XpfjFR/OCL+oRi4FieX+1QxGsZgGE=; fh=Yy8GFNbqEhl9MerJz1LfYQ39XksX1Ui9qbEvUBg6hMU=; b=Qkmgkc+JZIGY5h+ybmN1Doe4YIQ5huDwpjMCCGs81zk9dJVosZqSYmRxZYPazQDOlz xHQlpEgYEnIWXy+V09uKDUgfB7ueDygiWZz6d/9OwZHQrC6IWWQ+4VBE8sMCFCiU5t4L Kemchh9uN2maNDMfTrwalSWA4B0U1q1XjlMEfBeMVwdxBqRaw2P/aUEOG3ixJ33PlTBH EY4c6A+eZYz96CgGTk2X05NBhhIcnKw5Vl9uzawL/Fk8WZhDI8X4mN1x8oDVqwuMX4+E E25Apssl1+NCfFaNX/Vv4ktLrG10LRT/5WBTr3CwFQnurxq+WrgxifD1CyWYxXX1uqrp AB+w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=r70Jktu6; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id c19-20020a50f613000000b00564762e5ba5si3518864edn.462.2024.02.22.03.25.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:25:00 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=r70Jktu6; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 0BE8C880AA; Thu, 22 Feb 2024 12:24:23 +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="r70Jktu6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DE15B8805F; Thu, 22 Feb 2024 10:36:55 +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=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_SBL_CSS,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) (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 59CC78807D for ; Thu, 22 Feb 2024 10:36:45 +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-oi1-x232.google.com with SMTP id 5614622812f47-3c15dd2a1fdso3036495b6e.2 for ; Thu, 22 Feb 2024 01:36:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708594603; x=1709199403; 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=aGR4wADzfSH9X0XpfjFR/OCL+oRi4FieX+1QxGsZgGE=; b=r70Jktu6npHgscmvo1MIwZYN9ovher/K17We26dW5VGOKNVQlNvfUhRgeInfQWsTUy v3EPqvUhnKiJRQNTfRQsWMkpsiC4IKxkH5UMyWZoo7VGxxDoLgHPX2iRFppGMQrJY0FS FRapBvPKIlfLZWTPtrpmfs1z6r9qTAxF84hEmzar1NJPJohL9gHeLgTewymaHPBdCkCx iD2JggA/mA+tDqA7KEWLTvFYPUqSXpbqstplAlThMa9rOFAyivTEqWVmqQSYLaJ3hWRX GIgScEWG3lobTMLW5UiuJiPEoCFaTvSExJnCc67rune5uPdc8nXAy5OAFNWzT2mLkvTW dfuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708594603; x=1709199403; 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=aGR4wADzfSH9X0XpfjFR/OCL+oRi4FieX+1QxGsZgGE=; b=MxC8iP14139WFgEj7kCHXG349m2Fd3iLmOV2iefi70oMUhHQgmI+qzX/8QLq1xQIfn 6Mu54OeMCWrkhZQGYWI02R5C3z+llLXnFp6+2IhxmMLcUG1QFqiFoFWDe/rh3a0BKpqA 8gb7ACpzYeamx45IhH4bHEnAWeQIkk4Wh1L47ya2NL3rcQ/OCc0jpXTSqyQkjNNJP+D5 hb0AYh3j12f7LSsIKWsWnWqNQ5KlV+zFsgmyuk1wj0R3v5XaYGmuI6f2B3JG7hOBGEn8 lbQ+vBMPgclQk8pC5UBD9EtLBbUnOTNbHAPIgHwblhRD8nRqTNSWgYjD4tw2seRHy/em /Lhw== X-Gm-Message-State: AOJu0YzExBW4HBeznKTy8Is3ZRORCRO3Tg5RrPwdDkW2dcDVA/UKn/PC RgMbbYhMu6qFCB7tYYuuegdXZzd2xfkXzz1XoO5kDefCeWmWC8a7emH9zXrZoO/F6Bj62p79c2L k X-Received: by 2002:a05:6808:f11:b0:3c1:4b06:7ac2 with SMTP id m17-20020a0568080f1100b003c14b067ac2mr16408912oiw.12.1708594603568; Thu, 22 Feb 2024 01:36:43 -0800 (PST) Received: from sumit-X1.. ([223.178.212.115]) by smtp.gmail.com with ESMTPSA id u20-20020a056a00099400b006e47300e4edsm6208404pfg.183.2024.02.22.01.36.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 01:36:43 -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, 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, mibodhi@gmail.com, bb@ti.com, mark.kettenis@xs4all.nl, festevam@gmail.com, nm@ti.com, andre.przywara@arm.com, ijc@hellion.org.uk, paul.barker.ct@bp.renesas.com, Sumit Garg Subject: [PATCH v6 02/11] Makefile: Add support for DT bindings schema checks Date: Thu, 22 Feb 2024 15:05:58 +0530 Message-Id: <20240222093607.3085545-3-sumit.garg@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240222093607.3085545-1-sumit.garg@linaro.org> References: <20240222093607.3085545-1-sumit.garg@linaro.org> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 22 Feb 2024 12:24:08 +0100 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 subtree to provide the DT bindings. Along with that adapt dts/upstream/Bindings/Makefile to align with old U-Boot Kbuild infrastructure. 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. Reviewed-by: Simon Glass Tested-by: Simon Glass Signed-off-by: Sumit Garg --- Changes in v6: - None Changes in v5: - None Changes in v4: - Switched subtree to be imported as dts/upstream sub-directory rather than devicetree-rebasing sub-directory to better suite U-Boot directory structure. - Incorporate build fix to adjust Bindings Makefile rules to old U-Boot Kbuild infrastructure. Changes in v3: - None Changes in v2: - None Makefile | 20 ++++++++++++++++++-- dts/upstream/Bindings/Makefile | 6 +++--- scripts/Makefile.lib | 17 +++++++++++++++-- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 3b5db90df6f9..9604a4c517e5 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 := dts/upstream/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/dts/upstream/Bindings/Makefile b/dts/upstream/Bindings/Makefile index 3e886194b043..e799963a599d 100644 --- a/dts/upstream/Bindings/Makefile +++ b/dts/upstream/Bindings/Makefile @@ -47,9 +47,9 @@ quiet_cmd_mk_schema = SCHEMA $@ rm -f $$f define rule_chkdt - $(if $(DT_SCHEMA_LINT),$(call cmd,yamllint),) - $(call cmd,chk_bindings) - $(call cmd,mk_schema) + $(if $(DT_SCHEMA_LINT),$(call echo-cmd,yamllint) $(cmd_yamllint),); \ + $(call echo-cmd,chk_bindings) $(cmd_chk_bindings); \ + $(call echo-cmd,mk_schema) $(cmd_mk_schema) endef DT_DOCS = $(patsubst $(srctree)/%,%,$(shell $(find_all_cmd))) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 1ca84195c997..f82b3169e874 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 := dts/upstream/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)