From patchwork Thu Dec 14 13:51:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 753926 Delivered-To: patch@linaro.org Received: by 2002:adf:ff85:0:b0:336:3f68:820c with SMTP id j5csp758267wrr; Thu, 14 Dec 2023 05:52:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IHq0WACk4MrlDeTLqYhwh1HPptEslElaRm5ThibKMLMQcnwzDP+fDB1durPALtcpyPiP7bi X-Received: by 2002:ac2:5ecf:0:b0:50b:f78b:d30e with SMTP id d15-20020ac25ecf000000b0050bf78bd30emr3084771lfq.153.1702561957881; Thu, 14 Dec 2023 05:52:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702561957; cv=none; d=google.com; s=arc-20160816; b=qQ/jssNjIUT+tk7QDA6QFL4hg8eJs6yINfHAFH6Blkc2OmPys/xiF5u084bELBpMyY 26Bg66vIvk6aKR+6sLRWpAOEpiRUmRbcYK+6mXQ3oVW01obJNDMcZtpRGfMfcjVMM6L0 C+LNWv1W+skOAlJqTEVJqncbhXkgYjU1EQU6HYhDVpTvN9NBnxphFkVRohJ8vWMmoBs5 gV+My/Qv5F+FTnqRQFUfoB/A7wdasAvMEhpX3yz7XC4MiTwns5G8RLac5Ka70xbBgYdy iljdqDzaUMXfMDpKuDTtFksNZU5/ENNmA3/KKK3GNpKaK2snYpDw+c7XzmXyx4jROgfX TaLw== 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=tZ0RqhubyDUCF2xX96gajzIW8IB+xNdVb3GHMNv714o=; fh=VZWdizSVWfhngo19Gt5nLjhnxzdtHBYWvcywp4ujR58=; b=VLMyswmEFlIezFDGjY0E9a8GNjrtxP25IOO6cA56byljkeCanET41OV5fqcUN58wMT Wd3i843Ued8s3NdlFrQYtuijohW5uq/1RuBkzKHJlVpTEU2x7yNi7L+TLjcOPeTadLtW QeGKWd4ANPU607Uqt3BVARRsNzNHHIJs750li+svkpg0ke2yESFRlsqGSUrOAQpu2eVD P8PBFqPwPQeAXzI8SIqLHqvTMJJD7ZOWFzCjFRSYgJz6AczrsKkxXaYrPdAZvO4jSOyb zcZJxYGZhIsEuDt1WapBcSHUlvc6KlOvddQoZmIxKdb+E1JSIQJs0Dbp+Puw8+5vpuRZ ENEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sr1ePytq; 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 i42-20020a0565123e2a00b0050bf37fd0ebsi4500463lfv.280.2023.12.14.05.52.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 05:52:37 -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=sr1ePytq; 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 737B887A97; Thu, 14 Dec 2023 14:52:26 +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="sr1ePytq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C402A87A9C; Thu, 14 Dec 2023 14:52:25 +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-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) (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 50D5F87A91 for ; Thu, 14 Dec 2023 14:52:17 +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-x636.google.com with SMTP id d9443c01a7336-1d367494c96so2317445ad.1 for ; Thu, 14 Dec 2023 05:52:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702561935; x=1703166735; 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=tZ0RqhubyDUCF2xX96gajzIW8IB+xNdVb3GHMNv714o=; b=sr1ePytqv1Bj8RQwqhHOHe2oatRXVJOCikJwrU3KjQHLvFF4uW21O7+JADnBAPLwS1 5E5I/Tyx486NXhnbKLovgj0PQ/XCd5dltmNGu3UlLboJCJDRhFHxkj9bidGrF4+VVpRq 2DN9kkQWeH50lt4/yoguQrRKKptoNGpiqAqH19SuI5hC3SCFHCGiV/AXwuMsjT1/DKLa WkM+AXYzohPw9+rkhNKbkXgZab7dwK81gFXr3tMCYwwcwbEf1TiVUG5HoNOpVMMZNjH4 zcsctApY1yUoc3yDUMSipnI53UlC/rFrvazk7qX+xewROqAhz6CRnSIr8TOPlYXj/td/ 3WyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702561935; x=1703166735; 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=tZ0RqhubyDUCF2xX96gajzIW8IB+xNdVb3GHMNv714o=; b=h+pDIjO/pk6jUlpo6G6rm+DLWuqb1uRuuX/jkGi/HgdHV2Q1RwvAy3nKHEEuAiwyww POD2CE1dgq/o0IzTxOTHIg8eOAs6n9ItY9qwHtyabyxZwEJ7Doje6aiXJwgs/PiBj5sv iIq1TFLmvGU+O3TOaTALnAju065zQla4OSna8KLQiAZ3fiVKrN5R1IkwtpRTEeYASntP VO6Yh67OoN+tXl4vQQGdEBOFKjrWkkwR2yTmToIXU+liw6VVZFgV10kyiZMuVDnWGSn1 Xting/6Ou2MRGJyrr8ZYCyTvD3Goxj87AMrQm6dYrWhw9on7Fe4OjmBVRz2pupeixs2A wYcQ== X-Gm-Message-State: AOJu0Yxa3m+goFKQC/+OhIs4wX/7BYo9OxqfpCJh34JtESX5G27ilxXz YlwD3pCHp44t7nZq3C8Ll0IAtDzmGtn6m5pgLLkWlA== X-Received: by 2002:a17:903:189:b0:1d2:ffba:2d47 with SMTP id z9-20020a170903018900b001d2ffba2d47mr5376455plg.77.1702561935434; Thu, 14 Dec 2023 05:52:15 -0800 (PST) Received: from sumit-X1.. ([223.178.213.6]) by smtp.gmail.com with ESMTPSA id j3-20020a170902c08300b001cfc68125desm12474956pld.203.2023.12.14.05.52.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 05:52:15 -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 5/8] doc: devicetree: Updates for devicetree-rebasing subtree Date: Thu, 14 Dec 2023 19:21:00 +0530 Message-Id: <20231214135103.1606605-6-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 Encourage SoC/board maintainers to migrate to using devicetree-rebasing subtree and maintain a regular sync with Linux kernel devicetree files and bindings. Along with that add documentation regarding how to run DT bindings schema checks. Signed-off-by: Sumit Garg --- doc/develop/devicetree/control.rst | 108 +++++++++++++++++++++++------ 1 file changed, 86 insertions(+), 22 deletions(-) diff --git a/doc/develop/devicetree/control.rst b/doc/develop/devicetree/control.rst index cbb65c9b177..12ef55ed368 100644 --- a/doc/develop/devicetree/control.rst +++ b/doc/develop/devicetree/control.rst @@ -1,5 +1,6 @@ .. SPDX-License-Identifier: GPL-2.0+ .. sectionauthor:: Copyright 2011 The Chromium OS Authors +.. Copyright 2023 Linaro Ltd. Devicetree Control in U-Boot ============================ @@ -22,12 +23,11 @@ for three reasons: hierarchical format - It is fairly efficient to read incrementally -The arch//dts directories contains a Makefile for building the devicetree -blob and embedding it in the U-Boot image. This is useful since it allows -U-Boot to configure itself according to what it finds there. If you have -a number of similar boards with different peripherals, you can describe -the features of each board in the devicetree file, and have a single -generic source base. +The U-boot Makefile infrastructure allows for building the devicetree blob +and embedding it in the U-Boot image. This is useful since it allows U-Boot +to configure itself according to what it finds there. If you have a number +of similar boards with different peripherals, you can describe the features +of each board in the devicetree file, and have a single generic source base. To enable this feature, add CONFIG_OF_CONTROL to your board config file. @@ -68,8 +68,21 @@ a binary file. U-Boot adds its own `fdtgrep` for creating subsets of the file. Where do I get a devicetree file for my board? ---------------------------------------------- -You may find that the Linux kernel has a suitable file. Look in the -kernel source in arch//boot/dts. +Linux kernel Git repository has been the place where devicetree files along +with devicetree bindings are stored and maintained. There is devicetee-rebasing +(dtrepo_) which maintains a forked copy of devicetree files along with bindings +at every Linux kernel major release or intermideate release candidates. + +In order to maintain devicetree files sync, U-boot maintains a Git subtree for +devicetee-rebasing repo as `devicetee-rebasing/` sub-directory. It is regularly +kept updated with every new kernel major release via subtree pull as follows:: + + git subtree pull --prefix devicetree-rebasing \ + git://git.kernel.org/pub/scm/linux/kernel/git/devicetree/devicetree-rebasing.git \ + --squash + +You may find that the `devicetee-rebasing/` sub-directory has a suitable +devicetree file for your board. Look in `devicetree-rebasing/src//`. If not you might find other boards with suitable files that you can modify to your needs. Look in the board directories for files with a @@ -81,18 +94,21 @@ Failing that, you could write one from scratch yourself! Configuration ------------- -Use:: +Traditionally, U-boot placed copies of devicetree source files from Linux +kernel into `arch//dts/.dts` which can be selected via:: - #define CONFIG_DEFAULT_DEVICE_TREE "" + #define CONFIG_DEFAULT_DEVICE_TREE "" -to set the filename of the devicetree source. Then put your devicetree -file into:: +However, it has become combersome over time for each SoC/board maintainer to +keep devicetree files in sync with Linux kernel. Thereby, SoC/board maintainers +are encouraged to migrate to use mirrored copies from `devicetree-rebasing/` +into `dts/arch//` via:: - arch//dts/.dts + #define CONFIG_OF_UPSTREAM=y + #define CONFIG_DEFAULT_DEVICE_TREE "/" -This should include your CPU or SOC's devicetree file, placed in -`arch//dts`, and then make any adjustments required using a u-boot-dtsi -file for your board. +This should include your CPU or SOC's devicetree file. On top of that any U-boot +specific tweaks (see: dttweaks_) can be made for your board. If CONFIG_OF_EMBED is defined, then it will be picked up and built into the U-Boot image (including u-boot.bin). This is suitable for debugging @@ -156,8 +172,9 @@ ways: Adding tweaks for U-Boot ------------------------ -It is strongly recommended that devicetree files in U-Boot are an exact copy of -those in Linux, so that it is easy to sync them up from time to time. +With devicetee-rebasing Git subtree, it is ensured that devicetree files in +U-Boot are an exact copy of those in Linux kernel via mirroring into +`dts/arch//`. U-Boot is of course a very different project from Linux, e.g. it operates under much more restrictive memory and code-size constraints. Where Linux may use a @@ -170,8 +187,8 @@ constraints are even more extreme and the devicetree is shrunk to remove unwanted nodes, or even turned into C code to avoid access overhead. U-Boot automatically looks for and includes a file with updates to the standard -devicetree for your board, searching for them in the same directory as the -main file, in this order:: +devicetree for your board, searching for them in `arch//dts/` in this +order:: -u-boot.dtsi -u-boot.dtsi @@ -200,6 +217,52 @@ to specify a list of .dtsi files that will also be included when building .dtb files. +Devicetree bindings schema checks +--------------------------------- + +With devicetee-rebasing Git subtree, the devicetree bindings are also regularly +synced with Linux kernel as `devicetree-rebasing/Bindings/` sub-directory. This +allows U-boot to run devicetree bindings schema checks which will bring +compliance to U-boot core/drivers regarding usage of devicetree. + +Dependencies +~~~~~~~~~~~~ + +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 + +Several executables (dt-doc-validate, dt-mk-schema, dt-validate) will be +installed. Ensure they are in your PATH (~/.local/bin by default). + +Recommended is also to install yamllint (used by dtschema when present). + +Running checks +~~~~~~~~~~~~~~ + +In order to perform validation of DTB files, use the ``dtbs_check`` target:: + + make dtbs_check + +It is also possible to run checks with a subset of matching schema files by +setting the ``DT_SCHEMA_FILES`` variable to 1 or more specific schema files or +patterns (partial match of a fixed string). Each file or pattern should be +separated by ':'. + +:: + + make dtbs_check DT_SCHEMA_FILES=trivial-devices.yaml:rtc.yaml + make dtbs_check DT_SCHEMA_FILES=/gpio/ + make dtbs_check DT_SCHEMA_FILES=trivial-devices.yaml + + Relocation, SPL and TPL ----------------------- @@ -261,8 +324,9 @@ used it before Linux (e.g. snow). The two projects developed in parallel and there are still some differences in the bindings for certain boards. While there has been discussion of having a separate repository for devicetree files, in practice the Linux kernel Git repository has become the place where -these are stored, with U-Boot taking copies and adding tweaks with u-boot.dtsi -files. +these are stored, with U-Boot taking copies via devicetree-rebasing repo +(see: dtrepo_) and adding tweaks with u-boot.dtsi files. .. _dtspec: https://www.devicetree.org/specifications/ .. _dtlist: https://www.spinics.net/lists/devicetree-compiler/ +.. _dtrepo: https://git.kernel.org/pub/scm/linux/kernel/git/devicetree/devicetree-rebasing.git