From patchwork Wed Jan 10 10:35:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 761440 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp1807893wrz; Wed, 10 Jan 2024 02:37:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IFDRbe6/6wi/ZBYruHv72WJ0BOuVvmeC0edvH0eSUEpyhrscNUxeIBJssu51KNNjnScj/A7 X-Received: by 2002:a05:600c:4693:b0:40e:433e:8922 with SMTP id p19-20020a05600c469300b0040e433e8922mr382266wmo.96.1704883064993; Wed, 10 Jan 2024 02:37:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704883064; cv=none; d=google.com; s=arc-20160816; b=g7NGm2JQA7oUc1t/744uNY/Sa/k+24RJy5I3N/FtCWmhvJiGmBd42xdLW82NLCiRTL 7gUN26V5NEasyAG9RPStu/TSfctxWTeU6cnHjTfuiiV/wbgxCiJZTv9BSMrsRZmuoYwz xofP+h4O3oi5CUBAep6BOTyMK8gjAUoVx2uw+F5dRTnqdM0te2TeN98o5WpnK4k6WHIY b/p5MNBvXqBjeHdja+Rv0xw+9yV7wdDAcLuqupeRoBmXEzh2s0NiL1wkMiBTAIMB5ojn siqGw/LEpnubvZB2GQelbIbIxj0YRVH/md6E4H1jxtO78s8HqicLVwFGn2A/F0iILEQ/ PvQg== 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=ItGKytOu0pREVXvRcyIJk/dLNpJNwelGAbHY1//1MTE=; fh=g5mGBYdwcRCvgzx1fsOtMayuItbAc+o2ocuRoBH1vWU=; b=m64SzdqCoaIB1URLa1B5vqA/831fz55B+Ep+Asem0ETKH5cGBx0CWobaDGnA1g/SJn 8b2SJz0XoFnQPobr7VNAru7lbW0VoHK2Kt+gnxfZvoh12ZyYXRyaD63tGJK0UDQR9qU7 eUdHEUmUbt5iN2EQmyw5MyLOpFDVCOYntzSdWBdo8CwRA4GNMH3k5hpuO65zJLJw4ssy m9kZUAku0eqoWiiMNPXDnOONPYtEt+Jp9dcDd3s/G7MSJf6qJwDDkD+PyT4e4NGmaitB kvnHJdjdyAHFB3rMQnA8dz2uZc5JF6J2Yh8gSeA2slUAuuOxtBmnNRFHDfjsPzZXpC4R Z8TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="zhp8Wa/+"; 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 j1-20020a056000124100b0033770b4076asi1893493wrx.564.2024.01.10.02.37.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 02:37:44 -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="zhp8Wa/+"; 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 645F287B11; Wed, 10 Jan 2024 11:37:21 +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="zhp8Wa/+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2253D87B14; Wed, 10 Jan 2024 11:37:20 +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-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 A1A3687B01 for ; Wed, 10 Jan 2024 11:37:14 +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-1d3e8a51e6bso31848415ad.3 for ; Wed, 10 Jan 2024 02:37:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704883033; x=1705487833; 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=ItGKytOu0pREVXvRcyIJk/dLNpJNwelGAbHY1//1MTE=; b=zhp8Wa/+0aCwV0ODRU1BfF6JD5nIh2iqA2t0yEL7y8/aMlc5uvkaNZuPx61aN8V0DW eclWxHJRDDoBl8iBD6QVt3FjL439iGY9+R6mY9oGXPJk/t3M8ZsB6GP/1m+ec6BvA8Ny h7AX9EGdlHdv896PsEW2O+wDkz/mAtPZXwNRCUIXPfZhtC7HYNrPeWAkffsWAgTlk1Y4 +oVlY+EBGGYLitFA+wGIVJF+aE7ntFYDbwvlZXcK8IXaKqUki9jbZe5Ha9+gtbcT6Fd/ uKkbx2IozSENHmWt8i5ZUTcp88cJLBTH//HbIZ0A6O+Eh5h0YaQb2ab+21ccIPDFZo7j vfZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704883033; x=1705487833; 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=ItGKytOu0pREVXvRcyIJk/dLNpJNwelGAbHY1//1MTE=; b=Nfj1KEWKygk1Sld333W9glZ0HpJrfb8Dh9zcoXWJaIab3mv6+tNjmDTjJu4E6gfz0R nl02rO72d3tdc13cANzysEOBrXVTp/a9nmeJiKy7S3m8YcHt/qJY63qvmLEafQT92bbZ FyS3kqUmHq/ylkJlSvoz1+kA1hQHHed2Pt50cS9AgHZL0holPS+eRsf/93uoAE9Jgf+4 H+roP3Tqp/9zU61ZpL6vt6yF8H6twl1j3g1xcU7BCp0Qt7TyHanitTZUjkbCnOcZaJoi 4xR2Olw9iTIXa88MAKJVE2gjbI2a+7FZxLcnaXzKAJYNHUbnglJjor57rvlvb9jJmO+8 GDcA== X-Gm-Message-State: AOJu0Ywr8tgHip5YPWjKgLiZPVK66QGeJEULL8jvEVzEbaEOS4Hiio8P YvV70chF3zv/5nl9pUdc1K1xnlqOv5D22kPxWxifRTW5Rlc= X-Received: by 2002:a17:902:8646:b0:1d4:e208:9b0 with SMTP id y6-20020a170902864600b001d4e20809b0mr806137plt.44.1704883032690; Wed, 10 Jan 2024 02:37:12 -0800 (PST) Received: from sumit-X1.. ([223.178.208.66]) by smtp.gmail.com with ESMTPSA id i7-20020a17090332c700b001d38a7e6a30sm3332604plr.70.2024.01.10.02.37.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 02:37:12 -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, mibodhi@gmail.com, bb@ti.com, mark.kettenis@xs4all.nl, Sumit Garg Subject: [PATCH v4 08/11] doc: devicetree: Updates for devicetree-rebasing subtree Date: Wed, 10 Jan 2024 16:05:44 +0530 Message-Id: <20240110103547.719757-9-sumit.garg@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110103547.719757-1-sumit.garg@linaro.org> References: <20240110103547.719757-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 --- 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. - Since we now have v6.7-dts tag available now, so switch subtree to that from its beginning. - Clarify subtree uprev schedule as a separate documentation section. Also, fixed documentation typos. Changes in v3: - Replace CONFIG_* with Kconfig options Changes in v2: - s/U-boot/U-Boot/ doc/develop/devicetree/control.rst | 112 +++++++++++++++++++++++------ 1 file changed, 92 insertions(+), 20 deletions(-) diff --git a/doc/develop/devicetree/control.rst b/doc/develop/devicetree/control.rst index 75d5e02aaec..c8789ef7209 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-2024 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, select `OF_CONTROL` via Kconfig. @@ -68,8 +68,14 @@ 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 intermediate release candidates. + +U-Boot maintains a Git subtree for devicetee-rebasing repo as `dts/upstream/` +sub-directory. You may find that the `dts/upstream/` sub-directory has a +suitable devicetree file for your board. Look in `dts/upstream/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 @@ -78,17 +84,33 @@ modify to your needs. Look in the board directories for files with a Failing that, you could write one from scratch yourself! +Resyncing with devicetree-rebasing +---------------------------------- + +U-Boot regularly sync `dts/upstream/` subtree whenever the next window opens +with the next available kernel major release. `dts/update-dts-subtree.sh` script +provides a wrapper around git subtree pull command, usage from the top level +U-Boot source tree, run:: + + ./dts/update-dts-subtree.sh + + Configuration ------------- -Set up "" when prompted for `DEFAULT_DEVICE_TREE` by Kconfig. Then put -your devicetree file into:: +Traditionally, U-Boot placed copies of devicetree source files from Linux +kernel into `arch//dts/.dts` which can be selected via setting +"" when prompted for `DEFAULT_DEVICE_TREE` by Kconfig. - arch//dts/.dts +However, it has become cumbersome over time for each SoC/board maintainer to +keep devicetree files in sync with Linux kernel. Therefore, SoC/board +maintainers are encouraged to migrate to use synced copies from +`dts/upstream/src//`. To do that enable `OF_UPSTREAM` for the +SoC being used via Kconfig and set up "/" when prompted for +`DEFAULT_DEVICE_TREE` by Kconfig. -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 `OF_EMBED` is selected by Kconfig, then it will be picked up and built into the U-Boot image (including u-boot.bin). This is suitable for debugging @@ -155,8 +177,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 `dts/upstream` Git subtree, it is ensured that devicetree files in U-Boot +are an exact copy of those in Linux kernel available under +`dts/upstream/src//`. 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 @@ -169,8 +192,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 @@ -199,6 +222,54 @@ option 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 `dts/upstream/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. Please, refer to the GCC build documentation for installation +instructions :doc:`../../build/gcc`. + +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). On +Debian/Ubuntu systems:: + + apt install yamllint + +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 ----------------------- @@ -260,8 +331,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