diff options
Diffstat (limited to 'drivers/pci')
29 files changed, 199 insertions, 192 deletions
diff --git a/drivers/pci/pci-aardvark.c b/drivers/pci/pci-aardvark.c index 5c6e30e667..1534efb88e 100644 --- a/drivers/pci/pci-aardvark.c +++ b/drivers/pci/pci-aardvark.c @@ -638,7 +638,7 @@ static int pcie_advk_probe(struct udevice *dev) dev_warn(pcie->dev, "PCIE Reset on GPIO support is missing\n"); } - pcie->first_busno = dev->seq; + pcie->first_busno = dev_seq(dev); pcie->dev = pci_get_controller(dev); return pcie_advk_setup_hw(pcie); @@ -657,7 +657,7 @@ static int pcie_advk_remove(struct udevice *dev) } /** - * pcie_advk_ofdata_to_platdata() - Translate from DT to device state + * pcie_advk_of_to_plat() - Translate from DT to device state * * @dev: A pointer to the device being operated on * @@ -667,7 +667,7 @@ static int pcie_advk_remove(struct udevice *dev) * * Return: 0 on success, else -EINVAL */ -static int pcie_advk_ofdata_to_platdata(struct udevice *dev) +static int pcie_advk_of_to_plat(struct udevice *dev) { struct pcie_advk *pcie = dev_get_priv(dev); @@ -694,9 +694,9 @@ U_BOOT_DRIVER(pcie_advk) = { .id = UCLASS_PCI, .of_match = pcie_advk_ids, .ops = &pcie_advk_ops, - .ofdata_to_platdata = pcie_advk_ofdata_to_platdata, + .of_to_plat = pcie_advk_of_to_plat, .probe = pcie_advk_probe, .remove = pcie_advk_remove, .flags = DM_FLAG_OS_PREPARE, - .priv_auto_alloc_size = sizeof(struct pcie_advk), + .priv_auto = sizeof(struct pcie_advk), }; diff --git a/drivers/pci/pci-emul-uclass.c b/drivers/pci/pci-emul-uclass.c index a52064341e..756d8ad744 100644 --- a/drivers/pci/pci-emul-uclass.c +++ b/drivers/pci/pci-emul-uclass.c @@ -105,14 +105,14 @@ UCLASS_DRIVER(pci_emul) = { .name = "pci_emul", .post_probe = sandbox_pci_emul_post_probe, .pre_remove = sandbox_pci_emul_pre_remove, - .priv_auto_alloc_size = sizeof(struct sandbox_pci_emul_priv), - .per_device_auto_alloc_size = sizeof(struct pci_emul_uc_priv), + .priv_auto = sizeof(struct sandbox_pci_emul_priv), + .per_device_auto = sizeof(struct pci_emul_uc_priv), }; /* - * This uclass is a child of the pci bus. Its platdata is not defined here so - * is defined by its parent, UCLASS_PCI, which uses struct pci_child_platdata. - * See per_child_platdata_auto_alloc_size in UCLASS_DRIVER(pci). + * This uclass is a child of the pci bus. Its plat is not defined here so + * is defined by its parent, UCLASS_PCI, which uses struct pci_child_plat. + * See per_child_plat_auto in UCLASS_DRIVER(pci). */ UCLASS_DRIVER(pci_emul_parent) = { .id = UCLASS_PCI_EMUL_PARENT, diff --git a/drivers/pci/pci-rcar-gen2.c b/drivers/pci/pci-rcar-gen2.c index e76abc1f84..dc11402781 100644 --- a/drivers/pci/pci-rcar-gen2.c +++ b/drivers/pci/pci-rcar-gen2.c @@ -231,7 +231,7 @@ static int rcar_gen2_pci_probe(struct udevice *dev) return 0; } -static int rcar_gen2_pci_ofdata_to_platdata(struct udevice *dev) +static int rcar_gen2_pci_of_to_plat(struct udevice *dev) { struct rcar_gen2_pci_priv *priv = dev_get_priv(dev); @@ -259,6 +259,6 @@ U_BOOT_DRIVER(rcar_gen2_pci) = { .of_match = rcar_gen2_pci_ids, .ops = &rcar_gen2_pci_ops, .probe = rcar_gen2_pci_probe, - .ofdata_to_platdata = rcar_gen2_pci_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct rcar_gen2_pci_priv), + .of_to_plat = rcar_gen2_pci_of_to_plat, + .priv_auto = sizeof(struct rcar_gen2_pci_priv), }; diff --git a/drivers/pci/pci-rcar-gen3.c b/drivers/pci/pci-rcar-gen3.c index 1f51854ccc..0d5b01f9f8 100644 --- a/drivers/pci/pci-rcar-gen3.c +++ b/drivers/pci/pci-rcar-gen3.c @@ -129,7 +129,7 @@ struct rcar_gen3_pcie_priv { static void rcar_rmw32(struct udevice *dev, int where, u32 mask, u32 data) { - struct rcar_gen3_pcie_priv *priv = dev_get_platdata(dev); + struct rcar_gen3_pcie_priv *priv = dev_get_plat(dev); int shift = 8 * (where & 3); clrsetbits_le32(priv->regs + (where & ~3), @@ -138,7 +138,7 @@ static void rcar_rmw32(struct udevice *dev, int where, u32 mask, u32 data) static u32 rcar_read_conf(const struct udevice *dev, int where) { - struct rcar_gen3_pcie_priv *priv = dev_get_platdata(dev); + struct rcar_gen3_pcie_priv *priv = dev_get_plat(dev); int shift = 8 * (where & 3); return readl(priv->regs + (where & ~3)) >> shift; @@ -148,7 +148,7 @@ static int rcar_pcie_config_access(const struct udevice *udev, unsigned char access_type, pci_dev_t bdf, int where, ulong *data) { - struct rcar_gen3_pcie_priv *priv = dev_get_platdata(udev); + struct rcar_gen3_pcie_priv *priv = dev_get_plat(udev); u32 reg = where & ~3; /* Clear errors */ @@ -241,7 +241,7 @@ static int rcar_gen3_pcie_write_config(struct udevice *dev, pci_dev_t bdf, static int rcar_gen3_pcie_wait_for_phyrdy(struct udevice *dev) { - struct rcar_gen3_pcie_priv *priv = dev_get_platdata(dev); + struct rcar_gen3_pcie_priv *priv = dev_get_plat(dev); return wait_for_bit_le32((void *)priv->regs + PCIEPHYSR, PHYRDY, true, 50, false); @@ -249,7 +249,7 @@ static int rcar_gen3_pcie_wait_for_phyrdy(struct udevice *dev) static int rcar_gen3_pcie_wait_for_dl(struct udevice *dev) { - struct rcar_gen3_pcie_priv *priv = dev_get_platdata(dev); + struct rcar_gen3_pcie_priv *priv = dev_get_plat(dev); return wait_for_bit_le32((void *)priv->regs + PCIETSTR, DATA_LINK_ACTIVE, true, 50, false); @@ -257,7 +257,7 @@ static int rcar_gen3_pcie_wait_for_dl(struct udevice *dev) static int rcar_gen3_pcie_hw_init(struct udevice *dev) { - struct rcar_gen3_pcie_priv *priv = dev_get_platdata(dev); + struct rcar_gen3_pcie_priv *priv = dev_get_plat(dev); int ret; /* Begin initialization */ @@ -313,7 +313,7 @@ static int rcar_gen3_pcie_hw_init(struct udevice *dev) static int rcar_gen3_pcie_probe(struct udevice *dev) { - struct rcar_gen3_pcie_priv *priv = dev_get_platdata(dev); + struct rcar_gen3_pcie_priv *priv = dev_get_plat(dev); struct pci_controller *hose = dev_get_uclass_priv(dev); struct clk pci_clk; u32 mask; @@ -372,9 +372,9 @@ static int rcar_gen3_pcie_probe(struct udevice *dev) return 0; } -static int rcar_gen3_pcie_ofdata_to_platdata(struct udevice *dev) +static int rcar_gen3_pcie_of_to_plat(struct udevice *dev) { - struct rcar_gen3_pcie_priv *priv = dev_get_platdata(dev); + struct rcar_gen3_pcie_priv *priv = dev_get_plat(dev); priv->regs = devfdt_get_addr_index(dev, 0); if (!priv->regs) @@ -399,6 +399,6 @@ U_BOOT_DRIVER(rcar_gen3_pcie) = { .of_match = rcar_gen3_pcie_ids, .ops = &rcar_gen3_pcie_ops, .probe = rcar_gen3_pcie_probe, - .ofdata_to_platdata = rcar_gen3_pcie_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct rcar_gen3_pcie_priv), + .of_to_plat = rcar_gen3_pcie_of_to_plat, + .plat_auto = sizeof(struct rcar_gen3_pcie_priv), }; diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index eb07d25301..914217d0c9 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -14,6 +14,7 @@ #include <asm/io.h> #include <dm/device-internal.h> #include <dm/lists.h> +#include <dm/uclass-internal.h> #if defined(CONFIG_X86) && defined(CONFIG_HAVE_FSP) #include <asm/fsp/fsp_support.h> #endif @@ -49,7 +50,7 @@ struct udevice *pci_get_controller(struct udevice *dev) pci_dev_t dm_pci_get_bdf(const struct udevice *dev) { - struct pci_child_platdata *pplat = dev_get_parent_platdata(dev); + struct pci_child_plat *pplat = dev_get_parent_plat(dev); struct udevice *bus = dev->parent; /* @@ -58,14 +59,14 @@ pci_dev_t dm_pci_get_bdf(const struct udevice *dev) * will produce a bad BDF> * * A common cause of this problem is that this function is called in the - * ofdata_to_platdata() method of @dev. Accessing the PCI bus in that + * of_to_plat() method of @dev. Accessing the PCI bus in that * method is not allowed, since it has not yet been probed. To fix this, * move that access to the probe() method of @dev instead. */ if (!device_active(bus)) log_err("PCI: Device '%s' on unprobed bus '%s'\n", dev->name, bus->name); - return PCI_ADD_BUS(bus->seq, pplat->devfn); + return PCI_ADD_BUS(dev_seq(bus), pplat->devfn); } /** @@ -81,8 +82,8 @@ static int pci_get_bus_max(void) ret = uclass_get(UCLASS_PCI, &uc); uclass_foreach_dev(bus, uc) { - if (bus->seq > ret) - ret = bus->seq; + if (dev_seq(bus) > ret) + ret = dev_seq(bus); } debug("%s: ret=%d\n", __func__, ret); @@ -136,9 +137,9 @@ int pci_bus_find_devfn(const struct udevice *bus, pci_dev_t find_devfn, for (device_find_first_child(bus, &dev); dev; device_find_next_child(&dev)) { - struct pci_child_platdata *pplat; + struct pci_child_plat *pplat; - pplat = dev_get_parent_platdata(dev); + pplat = dev_get_parent_plat(dev); if (pplat && pplat->devfn == find_devfn) { *devp = dev; return 0; @@ -162,10 +163,10 @@ int dm_pci_bus_find_bdf(pci_dev_t bdf, struct udevice **devp) static int pci_device_matches_ids(struct udevice *dev, struct pci_device_id *ids) { - struct pci_child_platdata *pplat; + struct pci_child_plat *pplat; int i; - pplat = dev_get_parent_platdata(dev); + pplat = dev_get_parent_plat(dev); if (!pplat) return -EINVAL; for (i = 0; ids[i].vendor != 0; i++) { @@ -218,13 +219,13 @@ static int dm_pci_bus_find_device(struct udevice *bus, unsigned int vendor, unsigned int device, int *indexp, struct udevice **devp) { - struct pci_child_platdata *pplat; + struct pci_child_plat *pplat; struct udevice *dev; for (device_find_first_child(bus, &dev); dev; device_find_next_child(&dev)) { - pplat = dev_get_parent_platdata(dev); + pplat = dev_get_parent_plat(dev); if (pplat->vendor == vendor && pplat->device == device) { if (!(*indexp)--) { *devp = dev; @@ -261,7 +262,7 @@ int dm_pci_find_class(uint find_class, int index, struct udevice **devp) for (pci_find_first_device(&dev); dev; pci_find_next_device(&dev)) { - struct pci_child_platdata *pplat = dev_get_parent_platdata(dev); + struct pci_child_plat *pplat = dev_get_parent_plat(dev); if (pplat->class == find_class && !index--) { *devp = dev; @@ -513,7 +514,7 @@ static void set_vga_bridge_bits(struct udevice *dev) struct udevice *parent = dev->parent; u16 bc; - while (parent->seq != 0) { + while (dev_seq(parent) != 0) { dm_pci_read_config16(parent, PCI_BRIDGE_CONTROL, &bc); bc |= PCI_BRIDGE_CTL_VGA; dm_pci_write_config16(parent, PCI_BRIDGE_CONTROL, bc); @@ -524,12 +525,12 @@ static void set_vga_bridge_bits(struct udevice *dev) int pci_auto_config_devices(struct udevice *bus) { struct pci_controller *hose = bus->uclass_priv; - struct pci_child_platdata *pplat; + struct pci_child_plat *pplat; unsigned int sub_bus; struct udevice *dev; int ret; - sub_bus = bus->seq; + sub_bus = dev_seq(bus); debug("%s: start\n", __func__); pciauto_config_init(hose); for (ret = device_find_first_child(bus, &dev); @@ -544,17 +545,17 @@ int pci_auto_config_devices(struct udevice *bus) continue; ret = dm_pciauto_config_device(dev); if (ret < 0) - return ret; + return log_msg_ret("auto", ret); max_bus = ret; sub_bus = max(sub_bus, max_bus); - pplat = dev_get_parent_platdata(dev); + pplat = dev_get_parent_plat(dev); if (pplat->class == (PCI_CLASS_DISPLAY_VGA << 8)) set_vga_bridge_bits(dev); } debug("%s: done\n", __func__); - return sub_bus; + return log_msg_ret("sub", sub_bus); } int pci_generic_mmap_write_config( @@ -641,17 +642,9 @@ int dm_pci_hose_probe_bus(struct udevice *bus) if (ret) { debug("%s: Cannot probe bus %s: %d\n", __func__, bus->name, ret); - return ret; + return log_msg_ret("probe", ret); } - if (!ea_pos) { - if (sub_bus != bus->seq) { - debug("%s: Internal error, bus '%s' got seq %d, expected %d\n", - __func__, bus->name, bus->seq, sub_bus); - return -EPIPE; - } - sub_bus = pci_get_bus_max(); - } dm_pciauto_postscan_setup_bridge(bus, sub_bus); return sub_bus; @@ -714,7 +707,7 @@ static int pci_find_and_bind_driver(struct udevice *parent, if (ofnode_valid(node) && !ofnode_is_available(node)) { debug("%s: Ignoring disabled device\n", __func__); - return -EPERM; + return log_msg_ret("dis", -EPERM); } start = ll_entry_start(struct pci_driver_entry, pci_driver_entry); @@ -740,18 +733,18 @@ static int pci_find_and_bind_driver(struct udevice *parent, */ if (!(gd->flags & GD_FLG_RELOC) && !(drv->flags & DM_FLAG_PRE_RELOC)) - return -EPERM; + return log_msg_ret("pre", -EPERM); /* * We could pass the descriptor to the driver as - * platdata (instead of NULL) and allow its bind() + * plat (instead of NULL) and allow its bind() * method to return -ENOENT if it doesn't support this * device. That way we could continue the search to * 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); @@ -768,10 +761,10 @@ static int pci_find_and_bind_driver(struct udevice *parent, * limited (ie: using Cache As RAM). */ if (!(gd->flags & GD_FLG_RELOC) && !bridge) - return -EPERM; + return log_msg_ret("notbr", -EPERM); /* Bind a generic driver so that the device can be used */ - sprintf(name, "pci_%x:%x.%x", parent->seq, PCI_DEV(bdf), + sprintf(name, "pci_%x:%x.%x", dev_seq(parent), PCI_DEV(bdf), PCI_FUNC(bdf)); str = strdup(name); if (!str) @@ -803,11 +796,11 @@ int pci_bind_bus_devices(struct udevice *bus) int ret; found_multi = false; - end = PCI_BDF(bus->seq, PCI_MAX_PCI_DEVICES - 1, + end = PCI_BDF(dev_seq(bus), PCI_MAX_PCI_DEVICES - 1, PCI_MAX_PCI_FUNCTIONS - 1); - for (bdf = PCI_BDF(bus->seq, 0, 0); bdf <= end; + for (bdf = PCI_BDF(dev_seq(bus), 0, 0); bdf <= end; bdf += PCI_BDF(0, 0, 1)) { - struct pci_child_platdata *pplat; + struct pci_child_plat *pplat; struct udevice *dev; ulong class; @@ -832,7 +825,7 @@ int pci_bind_bus_devices(struct udevice *bus) found_multi = header_type & 0x80; debug("%s: bus %d/%s: found device %x, function %d", __func__, - bus->seq, bus->name, PCI_DEV(bdf), PCI_FUNC(bdf)); + dev_seq(bus), bus->name, PCI_DEV(bdf), PCI_FUNC(bdf)); pci_bus_read_config(bus, bdf, PCI_DEVICE_ID, &device, PCI_SIZE_16); pci_bus_read_config(bus, bdf, PCI_CLASS_REVISION, &class, @@ -868,7 +861,7 @@ int pci_bind_bus_devices(struct udevice *bus) return ret; /* Update the platform data */ - pplat = dev_get_parent_platdata(dev); + pplat = dev_get_parent_plat(dev); pplat->devfn = PCI_MASK_BUS(bdf); pplat->vendor = vendor; pplat->device = device; @@ -1009,11 +1002,26 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node, static int pci_uclass_pre_probe(struct udevice *bus) { struct pci_controller *hose; + struct uclass *uc; + int ret; - debug("%s, bus=%d/%s, parent=%s\n", __func__, bus->seq, bus->name, + debug("%s, bus=%d/%s, parent=%s\n", __func__, dev_seq(bus), bus->name, bus->parent->name); hose = bus->uclass_priv; + /* + * Set the sequence number, if device_bind() doesn't. We want control + * of this so that numbers are allocated as devices are probed. That + * ensures that sub-bus numbered is correct (sub-buses must get numbers + * higher than their parents) + */ + if (dev_seq(bus) == -1) { + ret = uclass_get(UCLASS_PCI, &uc); + if (ret) + return ret; + bus->sqq = uclass_find_next_free_seq(uc); + } + /* For bridges, use the top-level PCI controller */ if (!device_is_on_pci_bus(bus)) { hose->ctlr = bus; @@ -1024,9 +1032,10 @@ static int pci_uclass_pre_probe(struct udevice *bus) parent_hose = dev_get_uclass_priv(bus->parent); hose->ctlr = parent_hose->bus; } + hose->bus = bus; - hose->first_busno = bus->seq; - hose->last_busno = bus->seq; + hose->first_busno = dev_seq(bus); + hose->last_busno = dev_seq(bus); if (dev_of_valid(bus)) { hose->skip_auto_config_until_reloc = dev_read_bool(bus, @@ -1041,17 +1050,17 @@ static int pci_uclass_post_probe(struct udevice *bus) struct pci_controller *hose = dev_get_uclass_priv(bus); int ret; - debug("%s: probing bus %d\n", __func__, bus->seq); + debug("%s: probing bus %d\n", __func__, dev_seq(bus)); ret = pci_bind_bus_devices(bus); if (ret) - return ret; + return log_msg_ret("bind", ret); if (CONFIG_IS_ENABLED(PCI_PNP) && ll_boot_init() && (!hose->skip_auto_config_until_reloc || (gd->flags & GD_FLG_RELOC))) { ret = pci_auto_config_devices(bus); if (ret < 0) - return log_msg_ret("pci auto-config", ret); + return log_msg_ret("cfg", ret); } #if defined(CONFIG_X86) && defined(CONFIG_HAVE_FSP) @@ -1068,10 +1077,10 @@ static int pci_uclass_post_probe(struct udevice *bus) * Note we only call this 1) after U-Boot is relocated, and 2) * root bus has finished probing. */ - if ((gd->flags & GD_FLG_RELOC) && bus->seq == 0 && ll_boot_init()) { + if ((gd->flags & GD_FLG_RELOC) && dev_seq(bus) == 0 && ll_boot_init()) { ret = fsp_init_phase_pci(); if (ret) - return ret; + return log_msg_ret("fsp", ret); } #endif @@ -1080,12 +1089,12 @@ static int pci_uclass_post_probe(struct udevice *bus) static int pci_uclass_child_post_bind(struct udevice *dev) { - struct pci_child_platdata *pplat; + struct pci_child_plat *pplat; if (!dev_of_valid(dev)) return 0; - pplat = dev_get_parent_platdata(dev); + pplat = dev_get_parent_plat(dev); /* Extract vendor id and device id if available */ ofnode_read_pci_vendev(dev_ofnode(dev), &pplat->vendor, &pplat->device); @@ -1441,7 +1450,7 @@ pci_addr_t dm_pci_phys_to_bus(struct udevice *dev, phys_addr_t phys_addr, } static phys_addr_t dm_pci_map_ea_virt(struct udevice *dev, int ea_off, - struct pci_child_platdata *pdata) + struct pci_child_plat *pdata) { phys_addr_t addr = 0; @@ -1472,7 +1481,7 @@ static phys_addr_t dm_pci_map_ea_virt(struct udevice *dev, int ea_off, } static void *dm_pci_map_ea_bar(struct udevice *dev, int bar, int flags, - int ea_off, struct pci_child_platdata *pdata) + int ea_off, struct pci_child_plat *pdata) { int ea_cnt, i, entry_size; int bar_id = (bar - PCI_BASE_ADDRESS_0) >> 2; @@ -1523,7 +1532,7 @@ static void *dm_pci_map_ea_bar(struct udevice *dev, int bar, int flags, void *dm_pci_map_bar(struct udevice *dev, int bar, int flags) { - struct pci_child_platdata *pdata = dev_get_parent_platdata(dev); + struct pci_child_plat *pdata = dev_get_parent_plat(dev); struct udevice *udev = dev; pci_addr_t pci_bus_addr; u32 bar_response; @@ -1725,14 +1734,14 @@ int pci_sriov_init(struct udevice *pdev, int vf_en) bdf += PCI_BDF(0, 0, vf_offset); for (vf = 0; vf < num_vfs; vf++) { - struct pci_child_platdata *pplat; + struct pci_child_plat *pplat; ulong class; pci_bus_read_config(bus, bdf, PCI_CLASS_DEVICE, &class, PCI_SIZE_16); debug("%s: bus %d/%s: found VF %x:%x\n", __func__, - bus->seq, bus->name, PCI_DEV(bdf), PCI_FUNC(bdf)); + dev_seq(bus), bus->name, PCI_DEV(bdf), PCI_FUNC(bdf)); /* Find this device in the device tree */ ret = pci_bus_find_devfn(bus, PCI_MASK_BUS(bdf), &dev); @@ -1753,7 +1762,7 @@ int pci_sriov_init(struct udevice *pdev, int vf_en) } /* Update the platform data */ - pplat = dev_get_parent_platdata(dev); + pplat = dev_get_parent_plat(dev); pplat->devfn = PCI_MASK_BUS(bdf); pplat->vendor = vendor; pplat->device = device; @@ -1763,7 +1772,7 @@ int pci_sriov_init(struct udevice *pdev, int vf_en) pplat->virtid = vf * vf_stride + vf_offset; debug("%s: bus %d/%s: found VF %x:%x %x:%x class %lx id %x\n", - __func__, dev->seq, dev->name, PCI_DEV(bdf), + __func__, dev_seq(dev), dev->name, PCI_DEV(bdf), PCI_FUNC(bdf), vendor, device, class, pplat->virtid); bdf += PCI_BDF(0, 0, vf_stride); } @@ -1791,14 +1800,13 @@ int pci_sriov_get_totalvfs(struct udevice *pdev) UCLASS_DRIVER(pci) = { .id = UCLASS_PCI, .name = "pci", - .flags = DM_UC_FLAG_SEQ_ALIAS, + .flags = DM_UC_FLAG_SEQ_ALIAS | DM_UC_FLAG_NO_AUTO_SEQ, .post_bind = dm_scan_fdt_dev, .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 = - sizeof(struct pci_child_platdata), + .per_device_auto = sizeof(struct pci_controller), + .per_child_plat_auto = sizeof(struct pci_child_plat), }; static const struct dm_pci_ops pci_bridge_ops = { diff --git a/drivers/pci/pci_auto.c b/drivers/pci/pci_auto.c index 3f46b7697d..68ef4e8092 100644 --- a/drivers/pci/pci_auto.c +++ b/drivers/pci/pci_auto.c @@ -189,8 +189,8 @@ void dm_pciauto_prescan_setup_bridge(struct udevice *dev, int sub_bus) /* Configure bus number registers */ dm_pci_write_config8(dev, PCI_PRIMARY_BUS, - PCI_BUS(dm_pci_get_bdf(dev)) - ctlr->seq); - dm_pci_write_config8(dev, PCI_SECONDARY_BUS, sub_bus - ctlr->seq); + PCI_BUS(dm_pci_get_bdf(dev)) - dev_seq(ctlr)); + dm_pci_write_config8(dev, PCI_SECONDARY_BUS, sub_bus - dev_seq(ctlr)); dm_pci_write_config8(dev, PCI_SUBORDINATE_BUS, 0xff); if (pci_mem) { @@ -265,7 +265,7 @@ void dm_pciauto_postscan_setup_bridge(struct udevice *dev, int sub_bus) pci_io = ctlr_hose->pci_io; /* Configure bus number registers */ - dm_pci_write_config8(dev, PCI_SUBORDINATE_BUS, sub_bus - ctlr->seq); + dm_pci_write_config8(dev, PCI_SUBORDINATE_BUS, sub_bus - dev_seq(ctlr)); if (pci_mem) { /* Round memory allocator to 1MB boundary */ @@ -321,7 +321,7 @@ int dm_pciauto_config_device(struct udevice *dev) bool enum_only = false; struct udevice *ctlr = pci_get_controller(dev); struct pci_controller *ctlr_hose = dev_get_uclass_priv(ctlr); - int n; + int ret; #ifdef CONFIG_PCI_ENUM_ONLY enum_only = true; @@ -341,10 +341,10 @@ int dm_pciauto_config_device(struct udevice *dev) dm_pciauto_setup_device(dev, 2, pci_mem, pci_prefetch, pci_io, enum_only); - n = dm_pci_hose_probe_bus(dev); - if (n < 0) - return n; - sub_bus = (unsigned int)n; + ret = dm_pci_hose_probe_bus(dev); + if (ret < 0) + return log_msg_ret("probe", ret); + sub_bus = ret; break; case PCI_CLASS_BRIDGE_CARDBUS: diff --git a/drivers/pci/pci_mpc85xx.c b/drivers/pci/pci_mpc85xx.c index 6576f53f52..ab6ff45a51 100644 --- a/drivers/pci/pci_mpc85xx.c +++ b/drivers/pci/pci_mpc85xx.c @@ -122,7 +122,7 @@ static int mpc85xx_pci_dm_remove(struct udevice *dev) return 0; } -static int mpc85xx_pci_ofdata_to_platdata(struct udevice *dev) +static int mpc85xx_pci_of_to_plat(struct udevice *dev) { struct mpc85xx_pci_priv *priv = dev_get_priv(dev); fdt_addr_t addr; @@ -154,6 +154,6 @@ U_BOOT_DRIVER(mpc85xx_pci) = { .ops = &mpc85xx_pci_ops, .probe = mpc85xx_pci_dm_probe, .remove = mpc85xx_pci_dm_remove, - .ofdata_to_platdata = mpc85xx_pci_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct mpc85xx_pci_priv), + .of_to_plat = mpc85xx_pci_of_to_plat, + .priv_auto = sizeof(struct mpc85xx_pci_priv), }; diff --git a/drivers/pci/pci_mvebu.c b/drivers/pci/pci_mvebu.c index c9afe75150..cf6e0a2e7c 100644 --- a/drivers/pci/pci_mvebu.c +++ b/drivers/pci/pci_mvebu.c @@ -143,7 +143,7 @@ static int mvebu_pcie_read_config(const struct udevice *bus, pci_dev_t bdf, uint offset, ulong *valuep, enum pci_size_t size) { - struct mvebu_pcie *pcie = dev_get_platdata(bus); + struct mvebu_pcie *pcie = dev_get_plat(bus); int local_bus = PCI_BUS(pcie->dev); int local_dev = PCI_DEV(pcie->dev); u32 reg; @@ -187,7 +187,7 @@ static int mvebu_pcie_write_config(struct udevice *bus, pci_dev_t bdf, uint offset, ulong value, enum pci_size_t size) { - struct mvebu_pcie *pcie = dev_get_platdata(bus); + struct mvebu_pcie *pcie = dev_get_plat(bus); int local_bus = PCI_BUS(pcie->dev); int local_dev = PCI_DEV(pcie->dev); u32 data; @@ -277,7 +277,7 @@ static void mvebu_pcie_setup_wins(struct mvebu_pcie *pcie) static int mvebu_pcie_probe(struct udevice *dev) { - struct mvebu_pcie *pcie = dev_get_platdata(dev); + struct mvebu_pcie *pcie = dev_get_plat(dev); struct udevice *ctlr = pci_get_controller(dev); struct pci_controller *hose = dev_get_uclass_priv(ctlr); static int bus; @@ -410,9 +410,9 @@ static int mvebu_get_tgt_attr(ofnode node, int devfn, return -ENOENT; } -static int mvebu_pcie_ofdata_to_platdata(struct udevice *dev) +static int mvebu_pcie_of_to_plat(struct udevice *dev) { - struct mvebu_pcie *pcie = dev_get_platdata(dev); + struct mvebu_pcie *pcie = dev_get_plat(dev); int ret = 0; /* Get port number, lane number and memory target / attr */ @@ -470,8 +470,8 @@ static struct driver pcie_mvebu_drv = { .id = UCLASS_PCI, .ops = &mvebu_pcie_ops, .probe = mvebu_pcie_probe, - .ofdata_to_platdata = mvebu_pcie_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct mvebu_pcie), + .of_to_plat = mvebu_pcie_of_to_plat, + .plat_auto = sizeof(struct mvebu_pcie), }; /* @@ -501,8 +501,8 @@ static int mvebu_pcie_bind(struct udevice *parent) return -ENOMEM; /* Create child device UCLASS_PCI and bind it */ - device_bind_ofnode(parent, &pcie_mvebu_drv, pcie->name, pcie, - subnode, &dev); + device_bind(parent, &pcie_mvebu_drv, pcie->name, pcie, subnode, + &dev); } return 0; diff --git a/drivers/pci/pci_octeontx.c b/drivers/pci/pci_octeontx.c index 30537543a0..16932839a5 100644 --- a/drivers/pci/pci_octeontx.c +++ b/drivers/pci/pci_octeontx.c @@ -311,7 +311,7 @@ int pci_octeontx_write_config(struct udevice *bus, pci_dev_t bdf, return ret; } -static int pci_octeontx_ofdata_to_platdata(struct udevice *dev) +static int pci_octeontx_of_to_plat(struct udevice *dev) { return 0; } @@ -357,8 +357,8 @@ U_BOOT_DRIVER(pci_octeontx) = { .id = UCLASS_PCI, .of_match = pci_octeontx_ids, .ops = &pci_octeontx_ops, - .ofdata_to_platdata = pci_octeontx_ofdata_to_platdata, + .of_to_plat = pci_octeontx_of_to_plat, .probe = pci_octeontx_probe, - .priv_auto_alloc_size = sizeof(struct octeontx_pci), + .priv_auto = sizeof(struct octeontx_pci), .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c index fa29d69e85..4a21813a82 100644 --- a/drivers/pci/pci_rom.c +++ b/drivers/pci/pci_rom.c @@ -68,7 +68,7 @@ __weak uint32_t board_map_oprom_vendev(uint32_t vendev) static int pci_rom_probe(struct udevice *dev, struct pci_rom_header **hdrp) { - struct pci_child_platdata *pplat = dev_get_parent_platdata(dev); + struct pci_child_plat *pplat = dev_get_parent_plat(dev); struct pci_rom_header *rom_header; struct pci_rom_data *rom_data; u16 rom_vendor, rom_device; @@ -236,7 +236,7 @@ void setup_video(struct screen_info *screen_info) int dm_pci_run_vga_bios(struct udevice *dev, int (*int15_handler)(void), int exec_method) { - struct pci_child_platdata *pplat = dev_get_parent_platdata(dev); + struct pci_child_plat *pplat = dev_get_parent_plat(dev); struct pci_rom_header *rom = NULL, *ram = NULL; int vesa_mode = -1; bool emulate, alloced; @@ -328,7 +328,7 @@ err: #ifdef CONFIG_DM_VIDEO int vbe_setup_video_priv(struct vesa_mode_info *vesa, struct video_priv *uc_priv, - struct video_uc_platdata *plat) + struct video_uc_plat *plat) { if (!vesa->x_resolution) return log_msg_ret("No x resolution", -ENXIO); @@ -363,7 +363,7 @@ int vbe_setup_video_priv(struct vesa_mode_info *vesa, int vbe_setup_video(struct udevice *dev, int (*int15_handler)(void)) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); struct video_priv *uc_priv = dev_get_uclass_priv(dev); int ret; diff --git a/drivers/pci/pci_sandbox.c b/drivers/pci/pci_sandbox.c index 8745f286bd..ca44d00237 100644 --- a/drivers/pci/pci_sandbox.c +++ b/drivers/pci/pci_sandbox.c @@ -128,10 +128,9 @@ U_BOOT_DRIVER(pci_sandbox) = { .of_match = sandbox_pci_ids, .ops = &sandbox_pci_ops, .probe = sandbox_pci_probe, - .priv_auto_alloc_size = sizeof(struct sandbox_pci_priv), + .priv_auto = sizeof(struct sandbox_pci_priv), /* Attach an emulator if we can */ .child_post_bind = dm_scan_fdt_dev, - .per_child_platdata_auto_alloc_size = - sizeof(struct pci_child_platdata), + .per_child_plat_auto = sizeof(struct pci_child_plat), }; diff --git a/drivers/pci/pci_tegra.c b/drivers/pci/pci_tegra.c index 82f5c59d91..9cb4414836 100644 --- a/drivers/pci/pci_tegra.c +++ b/drivers/pci/pci_tegra.c @@ -1092,7 +1092,7 @@ static const struct tegra_pcie_soc pci_tegra_soc[] = { }, }; -static int pci_tegra_ofdata_to_platdata(struct udevice *dev) +static int pci_tegra_of_to_plat(struct udevice *dev) { struct tegra_pcie *pcie = dev_get_priv(dev); enum tegra_pci_id id; @@ -1197,7 +1197,7 @@ U_BOOT_DRIVER(pci_tegra) = { .id = UCLASS_PCI, .of_match = pci_tegra_ids, .ops = &pci_tegra_ops, - .ofdata_to_platdata = pci_tegra_ofdata_to_platdata, + .of_to_plat = pci_tegra_of_to_plat, .probe = pci_tegra_probe, - .priv_auto_alloc_size = sizeof(struct tegra_pcie), + .priv_auto = sizeof(struct tegra_pcie), }; diff --git a/drivers/pci/pcie_brcmstb.c b/drivers/pci/pcie_brcmstb.c index dade79e9c8..dd2a4ef629 100644 --- a/drivers/pci/pcie_brcmstb.c +++ b/drivers/pci/pcie_brcmstb.c @@ -579,7 +579,7 @@ static int brcm_pcie_probe(struct udevice *dev) return 0; } -static int brcm_pcie_ofdata_to_platdata(struct udevice *dev) +static int brcm_pcie_of_to_plat(struct udevice *dev) { struct brcm_pcie *pcie = dev_get_priv(dev); ofnode dn = dev_ofnode(dev); @@ -618,6 +618,6 @@ U_BOOT_DRIVER(pcie_brcm_base) = { .ops = &brcm_pcie_ops, .of_match = brcm_pcie_ids, .probe = brcm_pcie_probe, - .ofdata_to_platdata = brcm_pcie_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct brcm_pcie), + .of_to_plat = brcm_pcie_of_to_plat, + .priv_auto = sizeof(struct brcm_pcie), }; diff --git a/drivers/pci/pcie_dw_mvebu.c b/drivers/pci/pcie_dw_mvebu.c index c773f8d28d..7ec149d178 100644 --- a/drivers/pci/pcie_dw_mvebu.c +++ b/drivers/pci/pcie_dw_mvebu.c @@ -500,13 +500,13 @@ static int pcie_dw_mvebu_probe(struct udevice *dev) debug("PCIE Reset on GPIO support is missing\n"); #endif /* DM_GPIO */ - pcie->first_busno = dev->seq; + pcie->first_busno = dev_seq(dev); /* Don't register host if link is down */ if (!pcie_dw_mvebu_pcie_link_up(pcie->ctrl_base, LINK_SPEED_GEN_3)) { - printf("PCIE-%d: Link down\n", dev->seq); + printf("PCIE-%d: Link down\n", dev_seq(dev)); } else { - printf("PCIE-%d: Link up (Gen%d-x%d, Bus%d)\n", dev->seq, + printf("PCIE-%d: Link up (Gen%d-x%d, Bus%d)\n", dev_seq(dev), pcie_dw_get_link_speed(pcie->ctrl_base), pcie_dw_get_link_width(pcie->ctrl_base), hose->first_busno); @@ -535,7 +535,7 @@ static int pcie_dw_mvebu_probe(struct udevice *dev) } /** - * pcie_dw_mvebu_ofdata_to_platdata() - Translate from DT to device state + * pcie_dw_mvebu_of_to_plat() - Translate from DT to device state * * @dev: A pointer to the device being operated on * @@ -545,7 +545,7 @@ static int pcie_dw_mvebu_probe(struct udevice *dev) * * Return: 0 on success, else -EINVAL */ -static int pcie_dw_mvebu_ofdata_to_platdata(struct udevice *dev) +static int pcie_dw_mvebu_of_to_plat(struct udevice *dev) { struct pcie_dw_mvebu *pcie = dev_get_priv(dev); @@ -578,7 +578,7 @@ U_BOOT_DRIVER(pcie_dw_mvebu) = { .id = UCLASS_PCI, .of_match = pcie_dw_mvebu_ids, .ops = &pcie_dw_mvebu_ops, - .ofdata_to_platdata = pcie_dw_mvebu_ofdata_to_platdata, + .of_to_plat = pcie_dw_mvebu_of_to_plat, .probe = pcie_dw_mvebu_probe, - .priv_auto_alloc_size = sizeof(struct pcie_dw_mvebu), + .priv_auto = sizeof(struct pcie_dw_mvebu), }; diff --git a/drivers/pci/pcie_dw_ti.c b/drivers/pci/pcie_dw_ti.c index 742dd93633..5e00fcda97 100644 --- a/drivers/pci/pcie_dw_ti.c +++ b/drivers/pci/pcie_dw_ti.c @@ -634,7 +634,7 @@ static int pcie_dw_ti_probe(struct udevice *dev) generic_phy_init(&phy1); generic_phy_power_on(&phy1); - pci->first_busno = dev->seq; + pci->first_busno = dev_seq(dev); pci->dev = dev; pcie_dw_setup_host(pci); @@ -644,11 +644,11 @@ static int pcie_dw_ti_probe(struct udevice *dev) pcie_am654_set_mode(pci, DW_PCIE_RC_TYPE); if (!pcie_dw_ti_pcie_link_up(pci, LINK_SPEED_GEN_2)) { - printf("PCIE-%d: Link down\n", dev->seq); + printf("PCIE-%d: Link down\n", dev_seq(dev)); return -ENODEV; } - printf("PCIE-%d: Link up (Gen%d-x%d, Bus%d)\n", dev->seq, + printf("PCIE-%d: Link up (Gen%d-x%d, Bus%d)\n", dev_seq(dev), pcie_dw_get_link_speed(pci), pcie_dw_get_link_width(pci), hose->first_busno); @@ -671,7 +671,7 @@ static int pcie_dw_ti_probe(struct udevice *dev) } /** - * pcie_dw_ti_ofdata_to_platdata() - Translate from DT to device state + * pcie_dw_ti_of_to_plat() - Translate from DT to device state * * @dev: A pointer to the device being operated on * @@ -681,7 +681,7 @@ static int pcie_dw_ti_probe(struct udevice *dev) * * Return: 0 on success, else -EINVAL */ -static int pcie_dw_ti_ofdata_to_platdata(struct udevice *dev) +static int pcie_dw_ti_of_to_plat(struct udevice *dev) { struct pcie_dw_ti *pcie = dev_get_priv(dev); @@ -724,7 +724,7 @@ U_BOOT_DRIVER(pcie_dw_ti) = { .id = UCLASS_PCI, .of_match = pcie_dw_ti_ids, .ops = &pcie_dw_ti_ops, - .ofdata_to_platdata = pcie_dw_ti_ofdata_to_platdata, + .of_to_plat = pcie_dw_ti_of_to_plat, .probe = pcie_dw_ti_probe, - .priv_auto_alloc_size = sizeof(struct pcie_dw_ti), + .priv_auto = sizeof(struct pcie_dw_ti), }; diff --git a/drivers/pci/pcie_ecam_generic.c b/drivers/pci/pcie_ecam_generic.c index 890b6a8fb6..7d1f13d637 100644 --- a/drivers/pci/pcie_ecam_generic.c +++ b/drivers/pci/pcie_ecam_generic.c @@ -113,7 +113,7 @@ static int pci_generic_ecam_write_config(struct udevice *bus, pci_dev_t bdf, } /** - * pci_generic_ecam_ofdata_to_platdata() - Translate from DT to device state + * pci_generic_ecam_of_to_plat() - Translate from DT to device state * @dev: A pointer to the device being operated on * * Translate relevant data from the device tree pertaining to device @dev into @@ -122,7 +122,7 @@ static int pci_generic_ecam_write_config(struct udevice *bus, pci_dev_t bdf, * * Return: 0 on success, else -EINVAL */ -static int pci_generic_ecam_ofdata_to_platdata(struct udevice *dev) +static int pci_generic_ecam_of_to_plat(struct udevice *dev) { struct generic_ecam_pcie *pcie = dev_get_priv(dev); struct fdt_resource reg_res; @@ -146,7 +146,7 @@ static int pci_generic_ecam_probe(struct udevice *dev) { struct generic_ecam_pcie *pcie = dev_get_priv(dev); - pcie->first_busno = dev->seq; + pcie->first_busno = dev_seq(dev); return 0; } @@ -167,6 +167,6 @@ U_BOOT_DRIVER(pci_generic_ecam) = { .of_match = pci_generic_ecam_ids, .ops = &pci_generic_ecam_ops, .probe = pci_generic_ecam_probe, - .ofdata_to_platdata = pci_generic_ecam_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct generic_ecam_pcie), + .of_to_plat = pci_generic_ecam_of_to_plat, + .priv_auto = sizeof(struct generic_ecam_pcie), }; diff --git a/drivers/pci/pcie_fsl.c b/drivers/pci/pcie_fsl.c index fb50b8f518..b061b31cae 100644 --- a/drivers/pci/pcie_fsl.c +++ b/drivers/pci/pcie_fsl.c @@ -29,16 +29,16 @@ static int fsl_pcie_addr_valid(struct fsl_pcie *pcie, pci_dev_t bdf) if (!pcie->enabled) return -ENXIO; - if (PCI_BUS(bdf) < bus->seq) + if (PCI_BUS(bdf) < dev_seq(bus)) return -EINVAL; - if (PCI_BUS(bdf) > bus->seq && (!fsl_pcie_link_up(pcie) || pcie->mode)) + if (PCI_BUS(bdf) > dev_seq(bus) && (!fsl_pcie_link_up(pcie) || pcie->mode)) return -EINVAL; - if (PCI_BUS(bdf) == bus->seq && (PCI_DEV(bdf) > 0 || PCI_FUNC(bdf) > 0)) + if (PCI_BUS(bdf) == dev_seq(bus) && (PCI_DEV(bdf) > 0 || PCI_FUNC(bdf) > 0)) return -EINVAL; - if (PCI_BUS(bdf) == (bus->seq + 1) && (PCI_DEV(bdf) > 0)) + if (PCI_BUS(bdf) == (dev_seq(bus) + 1) && (PCI_DEV(bdf) > 0)) return -EINVAL; return 0; @@ -57,7 +57,7 @@ static int fsl_pcie_read_config(const struct udevice *bus, pci_dev_t bdf, return 0; } - bdf = bdf - PCI_BDF(bus->seq, 0, 0); + bdf = bdf - PCI_BDF(dev_seq(bus), 0, 0); val = bdf | (offset & 0xfc) | ((offset & 0xf00) << 16) | 0x80000000; out_be32(®s->cfg_addr, val); @@ -93,7 +93,7 @@ static int fsl_pcie_write_config(struct udevice *bus, pci_dev_t bdf, if (fsl_pcie_addr_valid(pcie, bdf)) return 0; - bdf = bdf - PCI_BDF(bus->seq, 0, 0); + bdf = bdf - PCI_BDF(dev_seq(bus), 0, 0); val = bdf | (offset & 0xfc) | ((offset & 0xf00) << 16) | 0x80000000; out_be32(®s->cfg_addr, val); @@ -123,7 +123,7 @@ static int fsl_pcie_hose_read_config(struct fsl_pcie *pcie, uint offset, int ret; struct udevice *bus = pcie->bus; - ret = fsl_pcie_read_config(bus, PCI_BDF(bus->seq, 0, 0), + ret = fsl_pcie_read_config(bus, PCI_BDF(dev_seq(bus), 0, 0), offset, valuep, size); return ret; @@ -134,7 +134,7 @@ static int fsl_pcie_hose_write_config(struct fsl_pcie *pcie, uint offset, { struct udevice *bus = pcie->bus; - return fsl_pcie_write_config(bus, PCI_BDF(bus->seq, 0, 0), + return fsl_pcie_write_config(bus, PCI_BDF(dev_seq(bus), 0, 0), offset, value, size); } @@ -593,7 +593,7 @@ static int fsl_pcie_probe(struct udevice *dev) return 0; } -static int fsl_pcie_ofdata_to_platdata(struct udevice *dev) +static int fsl_pcie_of_to_plat(struct udevice *dev) { struct fsl_pcie *pcie = dev_get_priv(dev); struct fsl_pcie_data *info; @@ -661,7 +661,7 @@ U_BOOT_DRIVER(fsl_pcie) = { .id = UCLASS_PCI, .of_match = fsl_pcie_ids, .ops = &fsl_pcie_ops, - .ofdata_to_platdata = fsl_pcie_ofdata_to_platdata, + .of_to_plat = fsl_pcie_of_to_plat, .probe = fsl_pcie_probe, - .priv_auto_alloc_size = sizeof(struct fsl_pcie), + .priv_auto = sizeof(struct fsl_pcie), }; diff --git a/drivers/pci/pcie_imx.c b/drivers/pci/pcie_imx.c index cbf12371a0..d9c2325a22 100644 --- a/drivers/pci/pcie_imx.c +++ b/drivers/pci/pcie_imx.c @@ -799,7 +799,7 @@ static int imx_pcie_dm_remove(struct udevice *dev) return 0; } -static int imx_pcie_ofdata_to_platdata(struct udevice *dev) +static int imx_pcie_of_to_plat(struct udevice *dev) { struct imx_pcie_priv *priv = dev_get_priv(dev); @@ -829,8 +829,8 @@ U_BOOT_DRIVER(imx_pcie) = { .ops = &imx_pcie_ops, .probe = imx_pcie_dm_probe, .remove = imx_pcie_dm_remove, - .ofdata_to_platdata = imx_pcie_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct imx_pcie_priv), + .of_to_plat = imx_pcie_of_to_plat, + .priv_auto = sizeof(struct imx_pcie_priv), .flags = DM_FLAG_OS_PREPARE, }; #endif diff --git a/drivers/pci/pcie_intel_fpga.c b/drivers/pci/pcie_intel_fpga.c index 9f102c64c6..b4964757c7 100644 --- a/drivers/pci/pcie_intel_fpga.c +++ b/drivers/pci/pcie_intel_fpga.c @@ -369,7 +369,7 @@ static int pcie_intel_fpga_probe(struct udevice *dev) struct intel_fpga_pcie *pcie = dev_get_priv(dev); pcie->bus = pci_get_controller(dev); - pcie->first_busno = dev->seq; + pcie->first_busno = dev_seq(dev); /* clear all interrupts */ cra_writel(pcie, P2A_INT_STS_ALL, P2A_INT_STATUS); @@ -379,7 +379,7 @@ static int pcie_intel_fpga_probe(struct udevice *dev) return 0; } -static int pcie_intel_fpga_ofdata_to_platdata(struct udevice *dev) +static int pcie_intel_fpga_of_to_plat(struct udevice *dev) { struct intel_fpga_pcie *pcie = dev_get_priv(dev); struct fdt_resource reg_res; @@ -428,7 +428,7 @@ U_BOOT_DRIVER(pcie_intel_fpga) = { .id = UCLASS_PCI, .of_match = pcie_intel_fpga_ids, .ops = &pcie_intel_fpga_ops, - .ofdata_to_platdata = pcie_intel_fpga_ofdata_to_platdata, + .of_to_plat = pcie_intel_fpga_of_to_plat, .probe = pcie_intel_fpga_probe, - .priv_auto_alloc_size = sizeof(struct intel_fpga_pcie), + .priv_auto = sizeof(struct intel_fpga_pcie), }; diff --git a/drivers/pci/pcie_iproc.c b/drivers/pci/pcie_iproc.c index d77735fcf2..6725ff6437 100644 --- a/drivers/pci/pcie_iproc.c +++ b/drivers/pci/pcie_iproc.c @@ -1282,6 +1282,6 @@ U_BOOT_DRIVER(pci_iproc) = { .ops = &iproc_pcie_ops, .probe = iproc_pcie_probe, .remove = iproc_pcie_remove, - .priv_auto_alloc_size = sizeof(struct iproc_pcie), + .priv_auto = sizeof(struct iproc_pcie), .flags = DM_REMOVE_OS_PREPARE, }; diff --git a/drivers/pci/pcie_layerscape_ep.c b/drivers/pci/pcie_layerscape_ep.c index d7d4a44b22..041a526f0b 100644 --- a/drivers/pci/pcie_layerscape_ep.c +++ b/drivers/pci/pcie_layerscape_ep.c @@ -332,5 +332,5 @@ U_BOOT_DRIVER(pci_layerscape_ep) = { .ops = &ls_pcie_ep_ops, .probe = ls_pcie_ep_probe, .remove = ls_pcie_ep_remove, - .priv_auto_alloc_size = sizeof(struct ls_pcie_ep), + .priv_auto = sizeof(struct ls_pcie_ep), }; diff --git a/drivers/pci/pcie_layerscape_fixup.c b/drivers/pci/pcie_layerscape_fixup.c index c75cf26e0a..a58e7a3892 100644 --- a/drivers/pci/pcie_layerscape_fixup.c +++ b/drivers/pci/pcie_layerscape_fixup.c @@ -479,7 +479,7 @@ static int fdt_fixup_pci_vfs(void *blob, struct extra_iommu_entry *entry, for (bus = dev; device_is_on_pci_bus(bus);) bus = bus->parent; - bdf = entry->bdf - PCI_BDF(bus->seq, 0, 0) + (vf_offset << 8); + bdf = entry->bdf - PCI_BDF(dev_seq(bus), 0, 0) + (vf_offset << 8); for (i = 0; i < entry->num_vfs; i++) { if (fdt_fixup_pcie_device_ls(blob, bdf, pcie_rc) < 0) @@ -518,7 +518,7 @@ static void fdt_fixup_pcie_ls(void *blob) pcie_rc = dev_get_priv(bus); /* the DT fixup must be relative to the hose first_busno */ - bdf = dm_pci_get_bdf(dev) - PCI_BDF(bus->seq, 0, 0); + bdf = dm_pci_get_bdf(dev) - PCI_BDF(dev_seq(bus), 0, 0); if (fdt_fixup_pcie_device_ls(blob, bdf, pcie_rc) < 0) break; diff --git a/drivers/pci/pcie_layerscape_gen4.c b/drivers/pci/pcie_layerscape_gen4.c index 6e71173621..be9cb6285c 100644 --- a/drivers/pci/pcie_layerscape_gen4.c +++ b/drivers/pci/pcie_layerscape_gen4.c @@ -191,13 +191,13 @@ static int ls_pcie_g4_addr_valid(struct ls_pcie_g4 *pcie, pci_dev_t bdf) if (!pcie->enabled) return -ENXIO; - if (PCI_BUS(bdf) < bus->seq) + if (PCI_BUS(bdf) < dev_seq(bus)) return -EINVAL; - if ((PCI_BUS(bdf) > bus->seq) && (!ls_pcie_g4_link_up(pcie))) + if ((PCI_BUS(bdf) > dev_seq(bus)) && (!ls_pcie_g4_link_up(pcie))) return -EINVAL; - if (PCI_BUS(bdf) <= (bus->seq + 1) && (PCI_DEV(bdf) > 0)) + if (PCI_BUS(bdf) <= (dev_seq(bus) + 1) && (PCI_DEV(bdf) > 0)) return -EINVAL; return 0; @@ -209,7 +209,7 @@ void *ls_pcie_g4_conf_address(struct ls_pcie_g4 *pcie, pci_dev_t bdf, struct udevice *bus = pcie->bus; u32 target; - if (PCI_BUS(bdf) == bus->seq) { + if (PCI_BUS(bdf) == dev_seq(bus)) { if (offset < INDIRECT_ADDR_BNDRY) { ccsr_set_page(pcie, 0); return pcie->ccsr + offset; @@ -219,7 +219,7 @@ void *ls_pcie_g4_conf_address(struct ls_pcie_g4 *pcie, pci_dev_t bdf, return pcie->ccsr + OFFSET_TO_PAGE_ADDR(offset); } - target = PAB_TARGET_BUS(PCI_BUS(bdf) - bus->seq) | + target = PAB_TARGET_BUS(PCI_BUS(bdf) - dev_seq(bus)) | PAB_TARGET_DEV(PCI_DEV(bdf)) | PAB_TARGET_FUNC(PCI_FUNC(bdf)); @@ -580,5 +580,5 @@ U_BOOT_DRIVER(pcie_layerscape_gen4) = { .of_match = ls_pcie_g4_ids, .ops = &ls_pcie_g4_ops, .probe = ls_pcie_g4_probe, - .priv_auto_alloc_size = sizeof(struct ls_pcie_g4), + .priv_auto = sizeof(struct ls_pcie_g4), }; diff --git a/drivers/pci/pcie_layerscape_gen4_fixup.c b/drivers/pci/pcie_layerscape_gen4_fixup.c index 148b5d17ed..e9ee15558e 100644 --- a/drivers/pci/pcie_layerscape_gen4_fixup.c +++ b/drivers/pci/pcie_layerscape_gen4_fixup.c @@ -166,7 +166,7 @@ static void fdt_fixup_pcie_ls_gen4(void *blob) } /* the DT fixup must be relative to the hose first_busno */ - bdf = dm_pci_get_bdf(dev) - PCI_BDF(bus->seq, 0, 0); + bdf = dm_pci_get_bdf(dev) - PCI_BDF(dev_seq(bus), 0, 0); /* map PCI b.d.f to streamID in LUT */ ls_pcie_g4_lut_set_mapping(pcie, index, bdf >> 8, streamid); /* update msi-map in device tree */ diff --git a/drivers/pci/pcie_layerscape_rc.c b/drivers/pci/pcie_layerscape_rc.c index cdfcad6b0b..517e7b5ceb 100644 --- a/drivers/pci/pcie_layerscape_rc.c +++ b/drivers/pci/pcie_layerscape_rc.c @@ -130,13 +130,13 @@ static int ls_pcie_addr_valid(struct ls_pcie_rc *pcie_rc, pci_dev_t bdf) if (!pcie_rc->enabled) return -ENXIO; - if (PCI_BUS(bdf) < bus->seq) + if (PCI_BUS(bdf) < dev_seq(bus)) return -EINVAL; - if ((PCI_BUS(bdf) > bus->seq) && (!ls_pcie_link_up(pcie))) + if ((PCI_BUS(bdf) > dev_seq(bus)) && (!ls_pcie_link_up(pcie))) return -EINVAL; - if (PCI_BUS(bdf) <= (bus->seq + 1) && (PCI_DEV(bdf) > 0)) + if (PCI_BUS(bdf) <= (dev_seq(bus) + 1) && (PCI_DEV(bdf) > 0)) return -EINVAL; return 0; @@ -152,16 +152,16 @@ int ls_pcie_conf_address(const struct udevice *bus, pci_dev_t bdf, if (ls_pcie_addr_valid(pcie_rc, bdf)) return -EINVAL; - if (PCI_BUS(bdf) == bus->seq) { + if (PCI_BUS(bdf) == dev_seq(bus)) { *paddress = pcie->dbi + offset; return 0; } - busdev = PCIE_ATU_BUS(PCI_BUS(bdf) - bus->seq) | + busdev = PCIE_ATU_BUS(PCI_BUS(bdf) - dev_seq(bus)) | PCIE_ATU_DEV(PCI_DEV(bdf)) | PCIE_ATU_FUNC(PCI_FUNC(bdf)); - if (PCI_BUS(bdf) == bus->seq + 1) { + if (PCI_BUS(bdf) == dev_seq(bus) + 1) { ls_pcie_cfg0_set_busdev(pcie_rc, busdev); *paddress = pcie_rc->cfg0 + offset; } else { @@ -383,5 +383,5 @@ U_BOOT_DRIVER(pci_layerscape) = { .of_match = ls_pcie_ids, .ops = &ls_pcie_ops, .probe = ls_pcie_probe, - .priv_auto_alloc_size = sizeof(struct ls_pcie_rc), + .priv_auto = sizeof(struct ls_pcie_rc), }; diff --git a/drivers/pci/pcie_mediatek.c b/drivers/pci/pcie_mediatek.c index 55b6a40f25..f555671387 100644 --- a/drivers/pci/pcie_mediatek.c +++ b/drivers/pci/pcie_mediatek.c @@ -251,7 +251,7 @@ static struct mtk_pcie_port *mtk_pcie_find_port(const struct udevice *bus, struct mtk_pcie *pcie = dev_get_priv(bus); struct mtk_pcie_port *port; struct udevice *dev; - struct pci_child_platdata *pplat = NULL; + struct pci_child_plat *pplat = NULL; int ret = 0; if (PCI_BUS(bdf) != 0) { @@ -261,10 +261,10 @@ static struct mtk_pcie_port *mtk_pcie_find_port(const struct udevice *bus, return NULL; } - while (dev->parent->seq != 0) + while (dev_seq(dev->parent) != 0) dev = dev->parent; - pplat = dev_get_parent_platdata(dev); + pplat = dev_get_parent_plat(dev); } list_for_each_entry(port, &pcie->ports, list) { @@ -728,7 +728,7 @@ U_BOOT_DRIVER(pcie_mediatek_v1) = { .of_match = mtk_pcie_ids, .ops = &mtk_pcie_ops, .probe = mtk_pcie_probe, - .priv_auto_alloc_size = sizeof(struct mtk_pcie), + .priv_auto = sizeof(struct mtk_pcie), }; static const struct udevice_id mtk_pcie_ids_v2[] = { @@ -742,5 +742,5 @@ U_BOOT_DRIVER(pcie_mediatek_v2) = { .of_match = mtk_pcie_ids_v2, .ops = &mtk_pcie_ops_v2, .probe = mtk_pcie_probe_v2, - .priv_auto_alloc_size = sizeof(struct mtk_pcie), + .priv_auto = sizeof(struct mtk_pcie), }; diff --git a/drivers/pci/pcie_phytium.c b/drivers/pci/pcie_phytium.c index 51b2171f9f..03ea04ceaa 100644 --- a/drivers/pci/pcie_phytium.c +++ b/drivers/pci/pcie_phytium.c @@ -147,7 +147,7 @@ static int pci_phytium_write_config(struct udevice *bus, pci_dev_t bdf, } /** - * pci_phytium_ofdata_to_platdata() - Translate from DT to device state + * pci_phytium_of_to_plat() - Translate from DT to device state * @dev: A pointer to the device being operated on * * Translate relevant data from the device tree pertaining to device @dev into @@ -156,7 +156,7 @@ static int pci_phytium_write_config(struct udevice *bus, pci_dev_t bdf, * * Return: 0 on success, else -EINVAL */ -static int pci_phytium_ofdata_to_platdata(struct udevice *dev) +static int pci_phytium_of_to_plat(struct udevice *dev) { struct phytium_pcie *pcie = dev_get_priv(dev); struct fdt_resource reg_res; @@ -194,6 +194,6 @@ U_BOOT_DRIVER(pci_phytium) = { .id = UCLASS_PCI, .of_match = pci_phytium_ids, .ops = &pci_phytium_ops, - .ofdata_to_platdata = pci_phytium_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct phytium_pcie), + .of_to_plat = pci_phytium_of_to_plat, + .priv_auto = sizeof(struct phytium_pcie), }; diff --git a/drivers/pci/pcie_rockchip.c b/drivers/pci/pcie_rockchip.c index 04609f1296..027745e42e 100644 --- a/drivers/pci/pcie_rockchip.c +++ b/drivers/pci/pcie_rockchip.c @@ -373,7 +373,7 @@ static int rockchip_pcie_init_port(struct udevice *dev) /* Configure Address Translation. */ ret = rockchip_pcie_atr_init(priv); if (ret) { - dev_err(dev, "PCIE-%d: ATR init failed\n", dev->seq); + dev_err(dev, "PCIE-%d: ATR init failed\n", dev_seq(dev)); goto err_power_off_phy; } @@ -528,7 +528,7 @@ static int rockchip_pcie_probe(struct udevice *dev) struct pci_controller *hose = dev_get_uclass_priv(ctlr); int ret; - priv->first_busno = dev->seq; + priv->first_busno = dev_seq(dev); priv->dev = dev; ret = rockchip_pcie_parse_dt(dev); @@ -544,7 +544,7 @@ static int rockchip_pcie_probe(struct udevice *dev) return ret; dev_info(dev, "PCIE-%d: Link up (Bus%d)\n", - dev->seq, hose->first_busno); + dev_seq(dev), hose->first_busno); return 0; } @@ -565,5 +565,5 @@ U_BOOT_DRIVER(rockchip_pcie) = { .of_match = rockchip_pcie_ids, .ops = &rockchip_pcie_ops, .probe = rockchip_pcie_probe, - .priv_auto_alloc_size = sizeof(struct rockchip_pcie), + .priv_auto = sizeof(struct rockchip_pcie), }; diff --git a/drivers/pci/pcie_xilinx.c b/drivers/pci/pcie_xilinx.c index 713ad49d04..00879a2d72 100644 --- a/drivers/pci/pcie_xilinx.c +++ b/drivers/pci/pcie_xilinx.c @@ -129,7 +129,7 @@ static int pcie_xilinx_write_config(struct udevice *bus, pci_dev_t bdf, } /** - * pcie_xilinx_ofdata_to_platdata() - Translate from DT to device state + * pcie_xilinx_of_to_plat() - Translate from DT to device state * @dev: A pointer to the device being operated on * * Translate relevant data from the device tree pertaining to device @dev into @@ -138,7 +138,7 @@ static int pcie_xilinx_write_config(struct udevice *bus, pci_dev_t bdf, * * Return: 0 on success, else -EINVAL */ -static int pcie_xilinx_ofdata_to_platdata(struct udevice *dev) +static int pcie_xilinx_of_to_plat(struct udevice *dev) { struct xilinx_pcie *pcie = dev_get_priv(dev); struct fdt_resource reg_res; @@ -174,6 +174,6 @@ U_BOOT_DRIVER(pcie_xilinx) = { .id = UCLASS_PCI, .of_match = pcie_xilinx_ids, .ops = &pcie_xilinx_ops, - .ofdata_to_platdata = pcie_xilinx_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct xilinx_pcie), + .of_to_plat = pcie_xilinx_of_to_plat, + .priv_auto = sizeof(struct xilinx_pcie), }; |