bootlin / elixir

The Elixir Cross Referencer
GNU Affero General Public License v3.0
966 stars 143 forks source link

Improve devicetree file navigation #282

Open tleb opened 4 months ago

tleb commented 4 months ago

There are currently features to navigate devicetree files, but not much. Ideas to take this further:

fstachura commented 3 months ago

Have context-aware parsing of node aliases. Names such as vsys_3v3 give too many results to be useful. It should start with results in parent (/children?) DTS/DTSI.

I don't understand. Could you maybe describe what is the desired result for https://elixir.bootlin.com/linux/latest/A/ident/vsys_3v3 ? Or which results are the problem? Is this an issue with sorting? I don't have much experience with DTS files, so to clarify, my understanding is that node aliases are defined in the aliases section, and parent DTS files are basically (and I know that this is a major simplification) other DTS files, included into the processed file.

tleb commented 3 months ago

A .DTS file is a textual representation of a .DTB file. That latter is a binary file format many platforms use to describe hardware (in a tree structure).

The tricky part is twofold:

Most often, you have a .DTSI file that represents the SoC. Then all boards that use this SoC include this file and expand it to define what is contained on the boad. Almost always, the structure is more complex than that; it depends on the platform.

So if you want to get an overview of what a node contains, you must first find where the node is declared and then find all references to its alias. BUT you want to search for those aliases only in .DTS/.DTSI that are related to your platform.

Aliases are also used to point to nodes without modifying them. For example you pick GPIOs by using the GPIO controller alias (this is called a phandle).

Example: take this main_gpio0 phandle. It is in a .DTS file. To find where it comes from, you do not want to find all aliases named main_gpio0 in the kernel. You only want to look for it in its "parent" .DTSI files.

Some more complexities:

tpetazzoni commented 2 months ago

I think we want more than that, especially indexing of the compatible string. It'd be great if when clicking on a compatible string, one could easily get to:

  1. The driver supporting this compatible string
  2. The DT binding defining this compatible string
  3. The various Device Tree files that reference this compatible string
tleb commented 2 months ago

This is already supported though, see for example ti,sierra-phy-t0. You however need to specify precisely that you want a "DT compatible" search. I don't know why it doesn't match with the default "All symbols". I guess it is because the compatibles are stored in a separate database. This is, at first glance, a rather easy fix.

tpetazzoni commented 2 months ago

This is already supported though, see for example ti,sierra-phy-t0. You however need to specify precisely that you want a "DT compatible" search. I don't know why it doesn't match with the default "All symbols". I guess it is because the compatibles are stored in a separate database. This is, at first glance, a rather easy fix.

Wow, that's nice. I had forgotten about this! But if I click on a compatible string in a DT, does it use that database ?

tleb commented 2 months ago

Yes, it does use the right database. Example.