Re: [Q] devicetree overlays

From: Sven Van Asbroeck
Date: Fri Aug 07 2020 - 10:17:39 EST


Hello Enrico,

On Fri, Aug 7, 2020 at 7:27 AM Enrico Weigelt, metux IT consult
<info@xxxxxxxxx> wrote:
>
> In both cases it would be nice to have the actual device configuration
> written as a DT snippet, which just needs to be loaded.
>

I believe you're asking: "how do I associate device tree nodes to
devices on a dynamically discoverable bus such as USB or PCI" right ?

I believe that already exists. You can describe the _expected_ pci or
usb topology in the
devicetree. If a device gets detected in a spot on the bus described
in the tree, that
snippet will be automatically associated with this device.

How to for usb:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/usb/usb-device.txt?h=v5.8

How to for pci:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/pci/pci.txt?h=v5.8

For example, associate a mac address to an ethernet controller
on a pcie bus via the devicetree.
"reg" (which describes pcie topology/address) still needs filling in.

&pcie {
host@0 {
#address-cells = <3>;
#size-cells = <2>;
reg = <0 0 0 0 0>;
bcm5778: bcm5778@0 {
reg = <0 0 0 0 0>;
mac-address = [CA 11 AB 1E 10 01];
};
};
};