dm: treewide: Rename auto_alloc_size members to be shorter
[platform/kernel/u-boot.git] / drivers / pci / pci-uclass.c
index 23135eb..6093072 100644 (file)
@@ -539,7 +539,8 @@ int pci_auto_config_devices(struct udevice *bus)
                int ret;
 
                debug("%s: device %s\n", __func__, dev->name);
-               if (dev_read_bool(dev, "pci,no-autoconfig"))
+               if (dev_of_valid(dev) &&
+                   dev_read_bool(dev, "pci,no-autoconfig"))
                        continue;
                ret = dm_pciauto_config_device(dev);
                if (ret < 0)
@@ -749,8 +750,8 @@ static int pci_find_and_bind_driver(struct udevice *parent,
                         * find another driver. For now this doesn't seem
                         * necesssary, so just bind the first match.
                         */
-                       ret = device_bind_ofnode(parent, drv, drv->name, NULL,
-                                                node, &dev);
+                       ret = device_bind(parent, drv, drv->name, NULL, node,
+                                         &dev);
                        if (ret)
                                goto error;
                        debug("%s: Match found: %s\n", __func__, drv->name);
@@ -798,6 +799,7 @@ int pci_bind_bus_devices(struct udevice *bus)
        ulong header_type;
        pci_dev_t bdf, end;
        bool found_multi;
+       int ari_off;
        int ret;
 
        found_multi = false;
@@ -871,6 +873,31 @@ int pci_bind_bus_devices(struct udevice *bus)
                pplat->vendor = vendor;
                pplat->device = device;
                pplat->class = class;
+
+               if (IS_ENABLED(CONFIG_PCI_ARID)) {
+                       ari_off = dm_pci_find_ext_capability(dev,
+                                                            PCI_EXT_CAP_ID_ARI);
+                       if (ari_off) {
+                               u16 ari_cap;
+
+                               /*
+                                * Read Next Function number in ARI Cap
+                                * Register
+                                */
+                               dm_pci_read_config16(dev, ari_off + 4,
+                                                    &ari_cap);
+                               /*
+                                * Update next scan on this function number,
+                                * subtract 1 in BDF to satisfy loop increment.
+                                */
+                               if (ari_cap & 0xff00) {
+                                       bdf = PCI_BDF(PCI_BUS(bdf),
+                                                     PCI_DEV(ari_cap),
+                                                     PCI_FUNC(ari_cap));
+                                       bdf = bdf - 0x100;
+                               }
+                       }
+               }
        }
 
        return 0;
@@ -884,8 +911,8 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node,
                           ofnode node)
 {
        int pci_addr_cells, addr_cells, size_cells;
-       struct bd_info *bd = gd->bd;
        int cells_per_record;
+       struct bd_info *bd;
        const u32 *prop;
        int max_regions;
        int len;
@@ -962,6 +989,7 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node,
        }
 
        /* Add a region for our local memory */
+       bd = gd->bd;
        if (!bd)
                return;
 
@@ -999,8 +1027,11 @@ static int pci_uclass_pre_probe(struct udevice *bus)
        hose->bus = bus;
        hose->first_busno = bus->seq;
        hose->last_busno = bus->seq;
-       hose->skip_auto_config_until_reloc =
-               dev_read_bool(bus, "u-boot,skip-auto-config-until-reloc");
+       if (dev_of_valid(bus)) {
+               hose->skip_auto_config_until_reloc =
+                       dev_read_bool(bus,
+                                     "u-boot,skip-auto-config-until-reloc");
+       }
 
        return 0;
 }
@@ -1765,8 +1796,8 @@ UCLASS_DRIVER(pci) = {
        .pre_probe      = pci_uclass_pre_probe,
        .post_probe     = pci_uclass_post_probe,
        .child_post_bind = pci_uclass_child_post_bind,
-       .per_device_auto_alloc_size = sizeof(struct pci_controller),
-       .per_child_platdata_auto_alloc_size =
+       .per_device_auto        = sizeof(struct pci_controller),
+       .per_child_platdata_auto        =
                        sizeof(struct pci_child_platdata),
 };