Re: Associating nodes with phandles for pci devices

Arnd Bergmann
2015-01-26T10:57:59Z

On Saturday 24 January 2015 08:38:12 Chris Packham wrote:
>
> Can you think of a good example. I found a few ppc boards that have an
> PCI-ISA bridge that get's enumerated in the .dts. I think I can make sense
> of them but because they are bridges there's a lot of extra stuff for the
> down stream devices.

I found a copy of the standard document at:

http://www.o3one.org/hwdocs/openfirmware/pci_supplement_2_1.pdf

I believe the only property we require in order to connect a Linux PCI
device to a device node is 'reg', which is in a very special format
for PCI devices, as there are three cells that encode all sorts of
information. In this case, you only need the 'device' and 'function'
bits to match. The bus numbers can be reassigned on probing the
buses, and the structure is implied by the device/function numbers of
the parents all the way up to the host bridge (if you have multiple
bridges at all).

Something like

pci@1230000 {
device_type = "pci";
ranges = ...
#address-cells = <3>;
#size-cells = <2>;

dsa@01,0 { /* device 1, function 0 */
reg = <0x00000800 0 0 0 0>;
};
dsa@01,1 { /* device 1, function 1 */
reg = <0x00000900 0 0 0 0>;
};
};

The above follows the "DD,F" naming for unit strings in PCI devices
as in section 2.2.1.2 of that document. If you only have one function,
this can be shortened to just the device number, which is in bits
11-15 of the first word of the reg property.

Note that the binding is meant to encode all the probing information,
so it documents how to represent everything from the config space
in properties, but we don't actually use that for probing in Linux
and instead rely on a very reduced interpretation of the binding.

Arnd