From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A32B3C77B7C for ; Fri, 5 May 2023 12:43:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231852AbjEEMn6 (ORCPT ); Fri, 5 May 2023 08:43:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231842AbjEEMn5 (ORCPT ); Fri, 5 May 2023 08:43:57 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 317771AECD for ; Fri, 5 May 2023 05:43:56 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-4f13ef4ad91so1991207e87.3 for ; Fri, 05 May 2023 05:43:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683290634; x=1685882634; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=SuYX5zR3BqGct76Msm/Q12tOnmEfYOVRBCf1o9KituA=; b=pXi1NF2hC8Mlyi9G5+hesmETmbCBHVsqsMSHgBikHhwlsraKEhENeSKFJMnwg/1etQ iH9dnNmI3vGwhdOBdV4j5kz6zYkRAjmvJvPmquJUnpELLF5EUteuUDaPNCeA+ya9EqOE RH16ymx4qSD873aVaskfmaacoP1yWD6iRXy6fJO0ifJx1pL1wCGMroDgS25UekdXSUDe hpHy7fNbjegegMoVERBKZ4krMNjBf3SqwXcefxa2M+1uTbfszNxvU9LcGUhU20q+vN4p 1sosMX+zrg6dqyDYIsq3wS4uSzjEPDXkvSV6hfR80PvZCOCb1+FDWlCcSH4q1AXyRyMk BgiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683290634; x=1685882634; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SuYX5zR3BqGct76Msm/Q12tOnmEfYOVRBCf1o9KituA=; b=eX3t+jzDodzhwR+D28UflTR5i6nB00XeZL7lt0fiZqkW1+pbuVbwsd36lZO1I6BDEF v2fm+9Xnt9hZyVUy/DW48lML59Kvbl/C2K7pgtDjV9MwDFGGkGA5ty+k4ldWVwfbENMI H/gTIuOdd4Dk2v1exDRvCCm0RuBRA6jl6RXjotcU3Poyd+DR601i328Qwj4IUlHdP7o3 NBVAJHwRtQz1qKif1bJiQPCQiBYESdWvIt9i/USReA6U9ZdkEXcP1rVPKJMmDNzd24WT qnnDLNVv3RqMhdhr6mJH/wuYGSpeKoSnLekL3URJthURmGZUnxdmUCJA1NoHOz98JsoY YUmA== X-Gm-Message-State: AC+VfDxu//4hh3cub/WBX16yOOyI7mNOgWI0IFQWPj+xsXeQ+QO6qmwA wRCx53jSaK3z5ybmswr/NUe09Yf7OWzGdy57G50= X-Google-Smtp-Source: ACHHUZ4asDX2x0oLz+jAca7e1zelHbDaspA1IEvg3iW85PoBEPjsKMFyfArzyUwWk4dV44SzBStKHA== X-Received: by 2002:a2e:8945:0:b0:2a8:d39b:1496 with SMTP id b5-20020a2e8945000000b002a8d39b1496mr413793ljk.24.1683290634359; Fri, 05 May 2023 05:43:54 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id p3-20020a2ea403000000b002ac7a25c001sm310838ljn.24.2023.05.05.05.43.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 05:43:53 -0700 (PDT) From: Linus Walleij Date: Fri, 05 May 2023 14:43:53 +0200 Subject: [PATCH v2] docs: dt: Make references and mention kernel abstractions MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230505-dt-docs-refresh-v2-1-56bf359c53b4@linaro.org> X-B4-Tracking: v=1; b=H4sIAAj6VGQC/x3NMQrDMAyF4asEzRU4Dl56ldLBtpRYQ+0glTYQc vc4GX94H28HYxU2eA47KP/EpNUe/jFALrEujEK9wTs/ueAC0hepZUPlWdkKhjEwJUqJ3AhdpWi MSWPN5XJr+7N+YsYl4CzbtVg7le3+fL2P4wR1vInZgwAAAA== To: Rob Herring , Krzysztof Kozlowski Cc: Grant Likely , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.1 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org This document is named "Linux and Devicetree" so I think we should write a bit more about how the device tree fits into the Linux kernel frameworks these days after we have created the fwnode and swnode. Signed-off-by: Linus Walleij --- These docs are old and outdated and need to be edited to reflect the current situation. --- ChangeLog v1->v2: - Spelling mistakes - Resend because nothing happens --- Documentation/devicetree/usage-model.rst | 45 +++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/usage-model.rst b/Documentation/devicetree/usage-model.rst index b6a287955ee5..37605cb549cf 100644 --- a/Documentation/devicetree/usage-model.rst +++ b/Documentation/devicetree/usage-model.rst @@ -75,7 +75,44 @@ out of mainline (nios) have some level of DT support. If you haven't already read the Device Tree Usage\ [1]_ page, then go read it now. It's okay, I'll wait.... -2.1 High Level View +2.1 Linux Kernel Firmware Abstractions +-------------------------------------- + +The Linux kernel supports several different hardware description +frameworks and DT is just one of them. The closest sibling is the +:ref:`Documentation/firmware-guide/acpi/index.rst ACPI` +DSDT (Differentiated System Description Table). + +To make it possible to write a device driver that will adapt to DT +or other hardware description models, the kernel has grown some +abstractions, first and foremost the firmware node API, exposing +device properties. The firmware node "fwnode" internals can be found +in ```` while the device driver-facing API can be +found in ````. The idea is that if a driver is using +the firmware node API, it should be trivial to support DT and ACPI +DSDT alike in the same driver. + +The fwnode framework also makes it possible to modify and extend the +Linux in-kernel model with software-managed nodes "swnodes" to apply +quirks or manage registration of devices that cannot be handled any +other way. This API can also be found in ````. + +Further, when the DT core register devices these need to fold into the +Linux device driver model, which essentially means that some kind of +``struct device`` has to be created to match a corresponding +``struct device_driver``. This API can be explored in +detail in :ref:`Documentation/driver-api/driver-model/index.rst the driver API documentation` +but what you need to know is that the Linux DT parser code will on its +own mostly spawn platform devices and AMBA devices on the platform +and AMBA bus respectively, and apart from that it will augment devices +spawn on other buses where applicable. + +Every Linux kernel subsystem that want to supply additional data to +detected devices using the device tree, or that want to provide +resources to other devices in the DT, will need to implement calls into +the DT abstractions. + +2.2 High Level View ------------------- The most important thing to understand is that the DT is simply a data structure that describes the hardware. There is nothing magical about @@ -97,7 +134,7 @@ Linux uses DT data for three major purposes: 2) runtime configuration, and 3) device population. -2.2 Platform Identification +2.3 Platform Identification --------------------------- First and foremost, the kernel will use data in the DT to identify the specific machine. In a perfect world, the specific platform shouldn't @@ -180,7 +217,7 @@ However, this approach does not take into account the priority of the compatible list, and probably should be avoided for new architecture support. -2.3 Runtime configuration +2.4 Runtime configuration ------------------------- In most cases, a DT will be the sole method of communicating data from firmware to the kernel, so also gets used to pass in runtime and @@ -217,7 +254,7 @@ On ARM, the function setup_machine_fdt() is responsible for early scanning of the device tree after selecting the correct machine_desc that supports the board. -2.4 Device population +2.5 Device population --------------------- After the board has been identified, and after the early configuration data has been parsed, then kernel initialization can proceed in the normal --- base-commit: 457391b0380335d5e9a5babdec90ac53928b23b4 change-id: 20230505-dt-docs-refresh-515edbdbbd01 Best regards, -- Linus Walleij