pci: Support parsing PCI controller DT subnodes
PATCH v3 1/2 pci: Support parsing PCI controller DT subnodes
The PCI controller can have DT subnodes describing extra properties of particular PCI devices, ie. a PHY attached to an EHCI controller on a PCI bus. This patch parses those DT subnodes and assigns a node to the PCI device instance, so that the driver can extract details from that node and ie. configure the PHY using the PHY subsystem.
---
V3: Reword the comment
V2: Move the whole machinery to pci_bind_bus_devices(), right after
the driver instance platform data are updated. This reduces the number of times the DT is traversed and works for both DT nodes with and without compat string.
--- drivers/pci/pci-uclass.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/pci/pci-uclass.c +15 -0
@@ -733,6 +733,7 @@ int pci_bind_bus_devices(struct udevice *bus)ulong vendor, device;ulong header_type;pci_dev_t bdf, end; +ofnode node;bool found_multi;int ret;
@@ -803,6 +804,20 @@ int pci_bind_bus_devices(struct udevice *bus) pplat->vendor = vendor; pplat->device = device; pplat->class = class; + +/* Associate optional OF node */ +dev_for_each_subnode (node, bus) { +phys_addr_t df, size; + df =ofnode_get_addr_size (node,"reg" , &size); +if (df ==FDT_ADDR_T_NONE ) +continue ; + +if (PCI_FUNC (df) ==PCI_FUNC (bdf) && +PCI_DEV (df) ==PCI_DEV (bdf)) { + dev->node = node; +break ; + } + } }return 0 ;
Signature · 1 line
2.18.0
PATCH v3 2/2 pci: Update documentation to make 'compatible' string optional
Reword the documentation to make it clear the compatible string is now optional, yet still matching on it takes precedence over PCI IDs and PCI classes.
---
V3: No change
V2: New patch
--- doc/driver-model/pci-info.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
doc/driver-model/pci-info.txt +9 -5
@@ -34,11 +34,15 @@ under that bus. Note that this is all done on a lazy basis, as needed, so until something is touched on PCI (eg: a call to pci_find_devices()) it will not be probed. -PCI devices can appear in the flattened device tree. If they do this serves to -specify the driver to use for the device. In this case they will be bound at -first. Each PCI device node must have a compatible string list as well as a -<reg> property, as defined by the IEEE Std 1275-1994 PCI bus binding document -v2.1. Note we must describe PCI devices with the same bus hierarchy as the +PCI devices can appear in the flattened device tree. If they do, their node +often contains extra information which cannot be derived from the PCI IDs or +PCI class of the device. Each PCI device node must have a <reg> property, as +defined by the IEEE Std 1275-1994 PCI bus binding document v2.1. Compatible +string list is optional and generally not needed, since PCI is discoverable +bus, albeit there are justified exceptions. If the compatible string is +present, matching on it takes precedence over PCI IDs and PCI classes. + +Note we must describe PCI devices with the same bus hierarchy as the hardware, otherwise driver model cannot detect the correct parent/children relationship during PCI bus enumeration thus PCI devices won't be bound to their drivers accordingly. A working example like below:
Signature · 1 line
2.18.0
PATCH v3 2/2 pci: Update documentation to make 'compatible' string optional
Hi Marex,
Quoted 22 lines · Marek Vasut
Reword the documentation to make it clear the compatible string is now optional, yet still matching on it takes precedence over PCI IDs and PCI classes.
Signed-off-by Marek Vasut <[email protected]>Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>---
V3: No change
V2: New patch--- doc/driver-model/pci-info.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)doc/driver-model/pci-info.txt +0
-0@@ -34,11 +34,15 @@ under that bus. Note that this is all done on a lazy basis, as needed, so until something is touched on PCI (eg: a call to pci_find_devices()) it will not be probed.
doc/driver-model/pci-info.txt under that bus. · line 41
Quoted 10 lines
doc/driver-model/pci-info.txt +5
-5-PCI devices can appear in the flattened device tree. If they do this serves to -specify the driver to use for the device. In this case they will be bound at -first. Each PCI device node must have a compatible string list as well as a -<reg> property, as defined by the IEEE Std 1275-1994 PCI bus binding document -v2.1. Note we must describe PCI devices with the same bus hierarchy as the +PCI devices can appear in the flattened device tree. If they do, their node +often contains extra information which cannot be derived from the PCI IDs or +PCI class of the device. Each PCI device node must have a <reg> property, as +defined by the IEEE Std 1275-1994 PCI bus binding document v2.1. Compatible +string list is optional and generally not needed, since PCI is discoverable
I really don't like 'generally not needed'. How about 'generally not essential'? Or that you can usually avoid it if desired.
I'd like to say that it is optional since U_BOOT_PCI_DEVICE() can be used to specific the driver based on conditions like the PCI vendor/, PCI class, etc. If U-Boot does not find a compatible string then it will search these U_BOOT_PCI_DEVICE() records to find a driver; assuming it finds one it will then search for the device-tree node whose reg property matches the bus/device/function of the device, and attached that node to the device so that it is accessible to the driver.
Quoted 10 lines
doc/driver-model/pci-info.txt +4
-1+bus, albeit there are justified exceptions. If the compatible string is +present, matching on it takes precedence over PCI IDs and PCI classes. + +Note we must describe PCI devices with the same bus hierarchy as the hardware, otherwise driver model cannot detect the correct parent/children relationship during PCI bus enumeration thus PCI devices won't be bound to their drivers accordingly. A working example like below: --2.18.0
Regards,
Simon
PATCH v3 2/2 pci: Update documentation to make 'compatible' string optional
Quoted 1 line · Simon Glass
Hi Marex,
It's Marek btw ...
Quoted 23 lines · Marek Vasut
Quoted 22 lines
Reword the documentation to make it clear the compatible string is now optional, yet still matching on it takes precedence over PCI IDs and PCI classes.
Signed-off-by Marek Vasut <[email protected]>Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>---
V3: No change
V2: New patch--- doc/driver-model/pci-info.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)doc/driver-model/pci-info.txt +0
-0@@ -34,11 +34,15 @@ under that bus. Note that this is all done on a lazy basis, as needed, so until something is touched on PCI (eg: a call to pci_find_devices()) it will not be probed.
Quoted 13 lines
doc/driver-model/pci-info.txt under that bus. · line 41
Quoted 10 lines
doc/driver-model/pci-info.txt +5
-5-PCI devices can appear in the flattened device tree. If they do this serves to -specify the driver to use for the device. In this case they will be bound at -first. Each PCI device node must have a compatible string list as well as a -<reg> property, as defined by the IEEE Std 1275-1994 PCI bus binding document -v2.1. Note we must describe PCI devices with the same bus hierarchy as the +PCI devices can appear in the flattened device tree. If they do, their node +often contains extra information which cannot be derived from the PCI IDs or +PCI class of the device. Each PCI device node must have a <reg> property, as +defined by the IEEE Std 1275-1994 PCI bus binding document v2.1. Compatible +string list is optional and generally not needed, since PCI is discoverableI really don't like 'generally not needed'. How about 'generally not essential'? Or that you can usually avoid it if desired.
Must be a language nuance, but the compatible string is really not needed. I am starting to understand where this mindset of "compat strings are generally needed" comes from, which is the design of the virtual PCI devices in sandbox, but that's not the usual case.
Quoted 8 lines
I'd like to say that it is optional since
U_BOOT_PCI_DEVICE()can be used to specific the driver based on conditions like the PCI vendor/, PCI class, etc. If U-Boot does not find a compatible string then it will search theseU_BOOT_PCI_DEVICE()records to find a driver; assuming it finds one it will then search for the device-tree node whose reg property matches the bus/device/function of the device, and attached that node to the device so that it is accessible to the driver.
Can you rephrase it better then ? I can paste it into the docs.
Quoted 14 lines
Quoted 10 lines
doc/driver-model/pci-info.txt +4
-1+bus, albeit there are justified exceptions. If the compatible string is +present, matching on it takes precedence over PCI IDs and PCI classes. + +Note we must describe PCI devices with the same bus hierarchy as the hardware, otherwise driver model cannot detect the correct parent/children relationship during PCI bus enumeration thus PCI devices won't be bound to their drivers accordingly. A working example like below: --2.18.0
Regards,
Simon
Signature · 2 lines
Best regards, Marek Vasut
PATCH v3 2/2 pci: Update documentation to make 'compatible' string optional
Hi Marek,
Quoted 43 lines · Marek Vasut
Quoted 1 line · Simon Glass
Hi Marex,
It's Marek btw ...
Quoted 23 lines · Marek Vasut
Quoted 22 lines
Reword the documentation to make it clear the compatible string is now optional, yet still matching on it takes precedence over PCI IDs and PCI classes.
Signed-off-by Marek Vasut <[email protected]>Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>---
V3: No change
V2: New patch--- doc/driver-model/pci-info.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)doc/driver-model/pci-info.txt +0
-0@@ -34,11 +34,15 @@ under that bus. Note that this is all done on a lazy basis, as needed, so until something is touched on PCI (eg: a call to pci_find_devices()) it will not be probed.Quoted 13 lines
doc/driver-model/pci-info.txt under that bus. · line 41
Quoted 10 lines
doc/driver-model/pci-info.txt +5
-5-PCI devices can appear in the flattened device tree. If they do this serves to -specify the driver to use for the device. In this case they will be bound at -first. Each PCI device node must have a compatible string list as well as a -<reg> property, as defined by the IEEE Std 1275-1994 PCI bus binding document -v2.1. Note we must describe PCI devices with the same bus hierarchy as the +PCI devices can appear in the flattened device tree. If they do, their node +often contains extra information which cannot be derived from the PCI IDs or +PCI class of the device. Each PCI device node must have a <reg> property, as +defined by the IEEE Std 1275-1994 PCI bus binding document v2.1. Compatible +string list is optional and generally not needed, since PCI is discoverableI really don't like 'generally not needed'. How about 'generally not essential'? Or that you can usually avoid it if desired.
Quoted 4 lines
Must be a language nuance, but the compatible string is really not needed. I am starting to understand where this mindset of "compat strings are generally needed" comes from, which is the design of the virtual PCI devices in sandbox, but that's not the usual case.
Well it's more than that, as I mentioned before. Finding a compatible string in the source code is easier, and if we are matching with a DT node anyway, makes more sense IMO. Anyway since DTs likely come from the newly pleasant Linux we'll just end up with what they have there. This mostly applies for things like x86 which don't use DT in Linux.
Quoted 11 lines
Quoted 9 lines
I'd like to say that it is optional since
U_BOOT_PCI_DEVICE()can be used to specific the driver based on conditions like the PCI vendor/, PCI class, etc. If U-Boot does not find a compatible string then it will search theseU_BOOT_PCI_DEVICE()records to find a driver; assuming it finds one it will then search for the device-tree node whose reg property matches the bus/device/function of the device, and attached that node to the device so that it is accessible to the driver.Can you rephrase it better then ? I can paste it into the docs.
How about:
The compatible string is optional since U_BOOT_PCI_DEVICE() can be used to specific the driver based on conditions like the PCI vendor/ PCI class, etc. If U-Boot does not find a compatible string then it will search these U_BOOT_PCI_DEVICE() records to find a driver; assuming it finds one it will then search for the device-tree node whose reg property matches the bus/device/function of the device, and attache that node to the device so that it is accessible to the driver.
Quoted 15 lines
Quoted 15 lines
Quoted 11 lines
doc/driver-model/pci-info.txt +4
-1+bus, albeit there are justified exceptions. If the compatible string is +present, matching on it takes precedence over PCI IDs and PCI classes. + +Note we must describe PCI devices with the same bus hierarchy as the hardware, otherwise driver model cannot detect the correct parent/children relationship during PCI bus enumeration thus PCI devices won't be bound to their drivers accordingly. A working example like below: --2.18.0
Regards,
Simon
Regards,
Simon
PATCH v3 2/2 pci: Update documentation to make 'compatible' string optional
Quoted 1 line · Simon Glass
Hi Marek,
Hi,
Quoted 44 lines · Marek Vasut
Quoted 43 lines · Simon Glass
Quoted 1 line
Hi Marex,
It's Marek btw ...
Quoted 36 lines · Marek Vasut
Quoted 22 lines
Reword the documentation to make it clear the compatible string is now optional, yet still matching on it takes precedence over PCI IDs and PCI classes.
Signed-off-by Marek Vasut <[email protected]>Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>---
V3: No change
V2: New patch--- doc/driver-model/pci-info.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)doc/driver-model/pci-info.txt +0
-0@@ -34,11 +34,15 @@ under that bus. Note that this is all done on a lazy basis, as needed, so until something is touched on PCI (eg: a call to pci_find_devices()) it will not be probed.doc/driver-model/pci-info.txt under that bus. · line 41
Quoted 10 lines
doc/driver-model/pci-info.txt +5
-5-PCI devices can appear in the flattened device tree. If they do this serves to -specify the driver to use for the device. In this case they will be bound at -first. Each PCI device node must have a compatible string list as well as a -<reg> property, as defined by the IEEE Std 1275-1994 PCI bus binding document -v2.1. Note we must describe PCI devices with the same bus hierarchy as the +PCI devices can appear in the flattened device tree. If they do, their node +often contains extra information which cannot be derived from the PCI IDs or +PCI class of the device. Each PCI device node must have a <reg> property, as +defined by the IEEE Std 1275-1994 PCI bus binding document v2.1. Compatible +string list is optional and generally not needed, since PCI is discoverableI really don't like 'generally not needed'. How about 'generally not essential'? Or that you can usually avoid it if desired.
Quoted 8 lines
Quoted 4 lines
Must be a language nuance, but the compatible string is really not needed. I am starting to understand where this mindset of "compat strings are generally needed" comes from, which is the design of the virtual PCI devices in sandbox, but that's not the usual case.
Well it's more than that, as I mentioned before. Finding a compatible string in the source code is easier, and if we are matching with a DT node anyway, makes more sense IMO.
It's about as easy as finding PCI ID.
And PCI is a discoverable bus, so using a compatible string is some obscure edge-case.
Quoted 14 lines
Anyway since DTs likely come from
the newly pleasant Linux we'll just end up with what they have there. This mostly applies for things like x86 which don't use DT in Linux.Quoted 10 lines
Quoted 9 lines
I'd like to say that it is optional since
U_BOOT_PCI_DEVICE()can be used to specific the driver based on conditions like the PCI vendor/, PCI class, etc. If U-Boot does not find a compatible string then it will search theseU_BOOT_PCI_DEVICE()records to find a driver; assuming it finds one it will then search for the device-tree node whose reg property matches the bus/device/function of the device, and attached that node to the device so that it is accessible to the driver.
Quoted 6 lines
Quoted 1 line
Can you rephrase it better then ? I can paste it into the docs.
How about:
The compatible string is optional since
U_BOOT_PCI_DEVICE()can be used to specific
specify ?
Quoted 3 lines
the driver based on conditions like the PCI vendor/
PCI class, etc. If U-Boot does not find a compatible string then it will search theseU_BOOT_PCI_DEVICE()records to find a driver;
This implies the compatible string is preferred, it is not.
Quoted 24 lines
assuming it finds one it will then search for the device-tree node whose reg property matches the bus/device/function of the device, and attache that node to the device so that it is accessible to the driver.
Quoted 15 lines
Quoted 15 lines
Quoted 11 lines
doc/driver-model/pci-info.txt +4
-1+bus, albeit there are justified exceptions. If the compatible string is +present, matching on it takes precedence over PCI IDs and PCI classes. + +Note we must describe PCI devices with the same bus hierarchy as the hardware, otherwise driver model cannot detect the correct parent/children relationship during PCI bus enumeration thus PCI devices won't be bound to their drivers accordingly. A working example like below: --2.18.0
Regards,
SimonRegards,
Simon
Signature · 2 lines
Best regards, Marek Vasut
PATCH v3 2/2 pci: Update documentation to make 'compatible' string optional
Hi Marek,
Quoted 85 lines · Marek Vasut
Quoted 1 line · Simon Glass
Hi Marek,
Hi,
Quoted 44 lines · Marek Vasut
Quoted 43 lines · Simon Glass
Quoted 1 line
Hi Marex,
It's Marek btw ...
Quoted 36 lines · Marek Vasut
Quoted 22 lines
Reword the documentation to make it clear the compatible string is now optional, yet still matching on it takes precedence over PCI IDs and PCI classes.
Signed-off-by Marek Vasut <[email protected]>Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>---
V3: No change
V2: New patch--- doc/driver-model/pci-info.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)doc/driver-model/pci-info.txt +0
-0@@ -34,11 +34,15 @@ under that bus. Note that this is all done on a lazy basis, as needed, so until something is touched on PCI (eg: a call to pci_find_devices()) it will not be probed.doc/driver-model/pci-info.txt under that bus. · line 41
Quoted 10 lines
doc/driver-model/pci-info.txt +5
-5-PCI devices can appear in the flattened device tree. If they do this serves to -specify the driver to use for the device. In this case they will be bound at -first. Each PCI device node must have a compatible string list as well as a -<reg> property, as defined by the IEEE Std 1275-1994 PCI bus binding document -v2.1. Note we must describe PCI devices with the same bus hierarchy as the +PCI devices can appear in the flattened device tree. If they do, their node +often contains extra information which cannot be derived from the PCI IDs or +PCI class of the device. Each PCI device node must have a <reg> property, as +defined by the IEEE Std 1275-1994 PCI bus binding document v2.1. Compatible +string list is optional and generally not needed, since PCI is discoverableI really don't like 'generally not needed'. How about 'generally not essential'? Or that you can usually avoid it if desired.
Quoted 8 lines
Quoted 4 lines
Must be a language nuance, but the compatible string is really not needed. I am starting to understand where this mindset of "compat strings are generally needed" comes from, which is the design of the virtual PCI devices in sandbox, but that's not the usual case.
Well it's more than that, as I mentioned before. Finding a compatible string in the source code is easier, and if we are matching with a DT node anyway, makes more sense IMO.
It's about as easy as finding PCI ID.
And PCI is a discoverable bus, so using a compatible string is some obscure edge-case.
Quoted 14 lines
Anyway since DTs likely come from
the newly pleasant Linux we'll just end up with what they have there. This mostly applies for things like x86 which don't use DT in Linux.Quoted 10 lines
Quoted 9 lines
I'd like to say that it is optional since
U_BOOT_PCI_DEVICE()can be used to specific the driver based on conditions like the PCI vendor/, PCI class, etc. If U-Boot does not find a compatible string then it will search theseU_BOOT_PCI_DEVICE()records to find a driver; assuming it finds one it will then search for the device-tree node whose reg property matches the bus/device/function of the device, and attached that node to the device so that it is accessible to the driver.Quoted 6 lines
Quoted 1 line
Can you rephrase it better then ? I can paste it into the docs.
How about:
The compatible string is optional since
U_BOOT_PCI_DEVICE()can be used to specific
Quoted 8 lines
specify ?
Quoted 3 lines
the driver based on conditions like the PCI vendor/
PCI class, etc. If U-Boot does not find a compatible string then it will search theseU_BOOT_PCI_DEVICE()records to find a driver;This implies the compatible string is preferred, it is not.
I think Simon was describing the *current* U-Boot implementation, that "compatible" string is looked up first, then U_BOOT_PCI_DEVICE().
Quoted 4 lines
Quoted 4 lines
assuming it finds one it will then search for the device-tree node whose reg property matches the bus/device/function of the device, and attache that node to the device so that it is accessible to the driver.
Regards,
Bin
PATCH v3 2/2 pci: Update documentation to make 'compatible' string optional
Quoted 94 lines · Bin Meng
Hi Marek,
Quoted 91 lines · Marek Vasut
Quoted 1 line · Simon Glass
Hi Marek,
Hi,
Quoted 44 lines · Marek Vasut
Quoted 43 lines · Simon Glass
Quoted 1 line
Hi Marex,
It's Marek btw ...
Quoted 36 lines · Marek Vasut
Quoted 22 lines
Reword the documentation to make it clear the compatible string is now optional, yet still matching on it takes precedence over PCI IDs and PCI classes.
Signed-off-by Marek Vasut <[email protected]>Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>---
V3: No change
V2: New patch--- doc/driver-model/pci-info.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)doc/driver-model/pci-info.txt +0
-0@@ -34,11 +34,15 @@ under that bus. Note that this is all done on a lazy basis, as needed, so until something is touched on PCI (eg: a call to pci_find_devices()) it will not be probed.doc/driver-model/pci-info.txt under that bus. · line 41
Quoted 10 lines
doc/driver-model/pci-info.txt +5
-5-PCI devices can appear in the flattened device tree. If they do this serves to -specify the driver to use for the device. In this case they will be bound at -first. Each PCI device node must have a compatible string list as well as a -<reg> property, as defined by the IEEE Std 1275-1994 PCI bus binding document -v2.1. Note we must describe PCI devices with the same bus hierarchy as the +PCI devices can appear in the flattened device tree. If they do, their node +often contains extra information which cannot be derived from the PCI IDs or +PCI class of the device. Each PCI device node must have a <reg> property, as +defined by the IEEE Std 1275-1994 PCI bus binding document v2.1. Compatible +string list is optional and generally not needed, since PCI is discoverableI really don't like 'generally not needed'. How about 'generally not essential'? Or that you can usually avoid it if desired.
Quoted 8 lines
Quoted 4 lines
Must be a language nuance, but the compatible string is really not needed. I am starting to understand where this mindset of "compat strings are generally needed" comes from, which is the design of the virtual PCI devices in sandbox, but that's not the usual case.
Well it's more than that, as I mentioned before. Finding a compatible string in the source code is easier, and if we are matching with a DT node anyway, makes more sense IMO.
It's about as easy as finding PCI ID.
And PCI is a discoverable bus, so using a compatible string is some obscure edge-case.
Quoted 14 lines
Anyway since DTs likely come from
the newly pleasant Linux we'll just end up with what they have there. This mostly applies for things like x86 which don't use DT in Linux.Quoted 10 lines
Quoted 9 lines
I'd like to say that it is optional since
U_BOOT_PCI_DEVICE()can be used to specific the driver based on conditions like the PCI vendor/, PCI class, etc. If U-Boot does not find a compatible string then it will search theseU_BOOT_PCI_DEVICE()records to find a driver; assuming it finds one it will then search for the device-tree node whose reg property matches the bus/device/function of the device, and attached that node to the device so that it is accessible to the driver.Quoted 6 lines
Quoted 1 line
Can you rephrase it better then ? I can paste it into the docs.
How about:
The compatible string is optional since
U_BOOT_PCI_DEVICE()can be used to specificspecify ?
Quoted 3 lines
the driver based on conditions like the PCI vendor/
PCI class, etc. If U-Boot does not find a compatible string then it will search theseU_BOOT_PCI_DEVICE()records to find a driver;
Quoted 5 lines
Quoted 2 lines
This implies the compatible string is preferred, it is not.
I think Simon was describing the *current* U-Boot implementation, that "compatible" string is looked up first, then
U_BOOT_PCI_DEVICE().
This patch updates the documentation to match reality though.
Signature · 2 lines
Best regards, Marek Vasut
PATCH v3 2/2 pci: Update documentation to make 'compatible' string optional
Hi Marek,
Quoted 96 lines · Marek Vasut
Quoted 94 lines · Bin Meng
Hi Marek,
Quoted 91 lines · Marek Vasut
Quoted 1 line · Simon Glass
Hi Marek,
Hi,
Quoted 44 lines · Marek Vasut
Quoted 43 lines · Simon Glass
Quoted 1 line
Hi Marex,
It's Marek btw ...
Quoted 36 lines · Marek Vasut
Quoted 22 lines
Reword the documentation to make it clear the compatible string is now optional, yet still matching on it takes precedence over PCI IDs and PCI classes.
Signed-off-by Marek Vasut <[email protected]>Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>---
V3: No change
V2: New patch--- doc/driver-model/pci-info.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)doc/driver-model/pci-info.txt +0
-0@@ -34,11 +34,15 @@ under that bus. Note that this is all done on a lazy basis, as needed, so until something is touched on PCI (eg: a call to pci_find_devices()) it will not be probed.doc/driver-model/pci-info.txt under that bus. · line 41
Quoted 10 lines
doc/driver-model/pci-info.txt +5
-5-PCI devices can appear in the flattened device tree. If they do this serves to -specify the driver to use for the device. In this case they will be bound at -first. Each PCI device node must have a compatible string list as well as a -<reg> property, as defined by the IEEE Std 1275-1994 PCI bus binding document -v2.1. Note we must describe PCI devices with the same bus hierarchy as the +PCI devices can appear in the flattened device tree. If they do, their node +often contains extra information which cannot be derived from the PCI IDs or +PCI class of the device. Each PCI device node must have a <reg> property, as +defined by the IEEE Std 1275-1994 PCI bus binding document v2.1. Compatible +string list is optional and generally not needed, since PCI is discoverableI really don't like 'generally not needed'. How about 'generally not essential'? Or that you can usually avoid it if desired.
Quoted 8 lines
Quoted 4 lines
Must be a language nuance, but the compatible string is really not needed. I am starting to understand where this mindset of "compat strings are generally needed" comes from, which is the design of the virtual PCI devices in sandbox, but that's not the usual case.
Well it's more than that, as I mentioned before. Finding a compatible string in the source code is easier, and if we are matching with a DT node anyway, makes more sense IMO.
It's about as easy as finding PCI ID.
And PCI is a discoverable bus, so using a compatible string is some obscure edge-case.
Quoted 14 lines
Anyway since DTs likely come from
the newly pleasant Linux we'll just end up with what they have there. This mostly applies for things like x86 which don't use DT in Linux.Quoted 10 lines
Quoted 9 lines
I'd like to say that it is optional since
U_BOOT_PCI_DEVICE()can be used to specific the driver based on conditions like the PCI vendor/, PCI class, etc. If U-Boot does not find a compatible string then it will search theseU_BOOT_PCI_DEVICE()records to find a driver; assuming it finds one it will then search for the device-tree node whose reg property matches the bus/device/function of the device, and attached that node to the device so that it is accessible to the driver.Quoted 6 lines
Quoted 1 line
Can you rephrase it better then ? I can paste it into the docs.
How about:
The compatible string is optional since
U_BOOT_PCI_DEVICE()can be used to specificspecify ?
Quoted 3 lines
the driver based on conditions like the PCI vendor/
PCI class, etc. If U-Boot does not find a compatible string then it will search theseU_BOOT_PCI_DEVICE()records to find a driver;
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
This implies the compatible string is preferred, it is not.
I think Simon was describing the *current* U-Boot implementation, that "compatible" string is looked up first, then
U_BOOT_PCI_DEVICE().This patch updates the documentation to match reality though.
Am I looking at a different pci uclass driver implementation from yours?
Currently in pci_bind_bus_devices(), we have:
/* Find this device in the device tree */
ret = pci_bus_find_devfn(bus, PCI_MASK_BUS(bdf), &dev);
This is "compatible" based driver binding, and it goes first.
And we have:
/* If nothing in the device tree, bind a device */ if (ret == -ENODEV) {
...
ret = pci_find_and_bind_driver(bus, &find_id, bdf,
&dev);
...
}
this is the dynamic driver binding based vid/pid, etc.
Your patch does not change the fact that "compatible" comes first than dynamic binding.
Regards,
Bin
PATCH v3 2/2 pci: Update documentation to make 'compatible' string optional
Quoted 123 lines · Bin Meng
Hi Marek,
Quoted 96 lines · Marek Vasut
Quoted 94 lines · Bin Meng
Hi Marek,
Quoted 91 lines · Marek Vasut
Quoted 1 line · Simon Glass
Hi Marek,
Hi,
Quoted 44 lines · Marek Vasut
Quoted 43 lines · Simon Glass
Quoted 1 line
Hi Marex,
It's Marek btw ...
Quoted 36 lines · Marek Vasut
Quoted 22 lines
Reword the documentation to make it clear the compatible string is now optional, yet still matching on it takes precedence over PCI IDs and PCI classes.
Signed-off-by Marek Vasut <[email protected]>Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>---
V3: No change
V2: New patch--- doc/driver-model/pci-info.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)doc/driver-model/pci-info.txt +0
-0@@ -34,11 +34,15 @@ under that bus. Note that this is all done on a lazy basis, as needed, so until something is touched on PCI (eg: a call to pci_find_devices()) it will not be probed.doc/driver-model/pci-info.txt under that bus. · line 41
Quoted 10 lines
doc/driver-model/pci-info.txt +5
-5-PCI devices can appear in the flattened device tree. If they do this serves to -specify the driver to use for the device. In this case they will be bound at -first. Each PCI device node must have a compatible string list as well as a -<reg> property, as defined by the IEEE Std 1275-1994 PCI bus binding document -v2.1. Note we must describe PCI devices with the same bus hierarchy as the +PCI devices can appear in the flattened device tree. If they do, their node +often contains extra information which cannot be derived from the PCI IDs or +PCI class of the device. Each PCI device node must have a <reg> property, as +defined by the IEEE Std 1275-1994 PCI bus binding document v2.1. Compatible +string list is optional and generally not needed, since PCI is discoverableI really don't like 'generally not needed'. How about 'generally not essential'? Or that you can usually avoid it if desired.
Quoted 8 lines
Quoted 4 lines
Must be a language nuance, but the compatible string is really not needed. I am starting to understand where this mindset of "compat strings are generally needed" comes from, which is the design of the virtual PCI devices in sandbox, but that's not the usual case.
Well it's more than that, as I mentioned before. Finding a compatible string in the source code is easier, and if we are matching with a DT node anyway, makes more sense IMO.
It's about as easy as finding PCI ID.
And PCI is a discoverable bus, so using a compatible string is some obscure edge-case.
Quoted 14 lines
Anyway since DTs likely come from
the newly pleasant Linux we'll just end up with what they have there. This mostly applies for things like x86 which don't use DT in Linux.Quoted 10 lines
Quoted 9 lines
I'd like to say that it is optional since
U_BOOT_PCI_DEVICE()can be used to specific the driver based on conditions like the PCI vendor/, PCI class, etc. If U-Boot does not find a compatible string then it will search theseU_BOOT_PCI_DEVICE()records to find a driver; assuming it finds one it will then search for the device-tree node whose reg property matches the bus/device/function of the device, and attached that node to the device so that it is accessible to the driver.Quoted 6 lines
Quoted 1 line
Can you rephrase it better then ? I can paste it into the docs.
How about:
The compatible string is optional since
U_BOOT_PCI_DEVICE()can be used to specificspecify ?
Quoted 3 lines
the driver based on conditions like the PCI vendor/
PCI class, etc. If U-Boot does not find a compatible string then it will search theseU_BOOT_PCI_DEVICE()records to find a driver;Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
This implies the compatible string is preferred, it is not.
I think Simon was describing the *current* U-Boot implementation, that "compatible" string is looked up first, then
U_BOOT_PCI_DEVICE().This patch updates the documentation to match reality though.
Am I looking at a different pci uclass driver implementation from yours?
Currently in
pci_bind_bus_devices(), we have:/* Find this device in the device tree */
ret =pci_bus_find_devfn(bus, PCI_MASK_BUS(bdf), &dev);This is "compatible" based driver binding, and it goes first.
And we have:
/* If nothing in the device tree, bind a device */ if (ret ==
-ENODEV) {
...
ret = pci_find_and_bind_driver(bus,&find_id, bdf,
Quoted 8 lines
&dev);...
}this is the dynamic driver binding based vid/pid, etc.
Your patch does not change the fact that "compatible" comes first than dynamic binding.
So how would the test look like ? I am asking because even if you do bind the driver here, the bind() function is called with a lot of missing stuff, like parent_plat_data (so dm_pci_*() calls do not work there), the DT node is not associated yet. Oh, and the swap-case driver is never probe()d, so you cannot perform the test in probe either ...
Signature · 2 lines
Best regards, Marek Vasut
PATCH v3 1/2 pci: Support parsing PCI controller DT subnodes
In reply to Marek VasutHi Marek,
Quoted 40 lines · Marek Vasut
The PCI controller can have DT subnodes describing extra properties of particular PCI devices, ie. a PHY attached to an EHCI controller on a PCI bus. This patch parses those DT subnodes and assigns a node to the PCI device instance, so that the driver can extract details from that node and ie. configure the PHY using the PHY subsystem.
Signed-off-by Marek Vasut <[email protected]>Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>---
V3: Reword the comment
V2: Move the whole machinery topci_bind_bus_devices(), right after
the driver instance platform data are updated. This reduces the number of times the DT is traversed and works for both DT nodes with and without compat string.--- drivers/pci/pci-uclass.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)drivers/pci/pci-uclass.c +6
-0@@ -733,6 +733,7 @@ int pci_bind_bus_devices(struct udevice *bus)ulong vendor, device;ulong header_type;pci_dev_t bdf, end; +ofnode node;bool found_multi;int ret;@@ -803,6 +804,20 @@ int pci_bind_bus_devices(struct udevice *bus) pplat->vendor = vendor; pplat->device = device; pplat->class = class; + +/* Associate optional OF node */ +dev_for_each_subnode (node, bus) { +phys_addr_t df, size; + df =ofnode_get_addr_size (node,"reg" , &size);
drivers/pci/pci-uclass.c int pci_bind_bus_devices(struct udevice *bus) · line 821
Quoted 10 lines
drivers/pci/pci-uclass.c +9
-0+if (df ==FDT_ADDR_T_NONE ) +continue ; + +if (PCI_FUNC (df) ==PCI_FUNC (bdf) && +PCI_DEV (df) ==PCI_DEV (bdf)) { + dev->node = node; +break ; + } + } }
You should only need to do this if dev->node is not already valid.
How about:
if (!ofnode_valid(dev->node))
find_ofnode_for_dev(dev);
then put your code in that fnuction...
Regards,
Simon