Lines Matching defs:pdev
184 * @pdev: the PCI device
188 int pci_status_get_and_clear_errors(struct pci_dev *pdev)
193 ret = pci_read_config_word(pdev, PCI_STATUS, &status);
199 pci_write_config_word(pdev, PCI_STATUS, status);
206 void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar)
208 struct resource *res = &pdev->resource[bar];
214 pci_warn(pdev, "can't ioremap BAR %d: %pR\n", bar, res);
221 void __iomem *pci_ioremap_wc_bar(struct pci_dev *pdev, int bar)
226 if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) {
230 return ioremap_wc(pci_resource_start(pdev, bar),
231 pci_resource_len(pdev, bar));
1570 static void pci_restore_config_dword(struct pci_dev *pdev, int offset,
1575 pci_read_config_dword(pdev, offset, &val);
1580 pci_dbg(pdev, "restoring config space at offset %#x (was %#x, writing %#x)\n",
1582 pci_write_config_dword(pdev, offset, saved_val);
1586 pci_read_config_dword(pdev, offset, &val);
1594 static void pci_restore_config_space_range(struct pci_dev *pdev,
1601 pci_restore_config_dword(pdev, 4 * index,
1602 pdev->saved_config_space[index],
1606 static void pci_restore_config_space(struct pci_dev *pdev)
1608 if (pdev->hdr_type == PCI_HEADER_TYPE_NORMAL) {
1609 pci_restore_config_space_range(pdev, 10, 15, 0, false);
1611 pci_restore_config_space_range(pdev, 4, 9, 10, false);
1612 pci_restore_config_space_range(pdev, 0, 3, 0, false);
1613 } else if (pdev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
1614 pci_restore_config_space_range(pdev, 12, 15, 0, false);
1621 pci_restore_config_space_range(pdev, 9, 11, 0, true);
1622 pci_restore_config_space_range(pdev, 0, 8, 0, false);
1624 pci_restore_config_space_range(pdev, 0, 15, 0, false);
1628 static void pci_restore_rebar_state(struct pci_dev *pdev)
1633 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_REBAR);
1637 pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl);
1645 pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl);
1647 res = pdev->resource + bar_idx;
1651 pci_write_config_dword(pdev, pos + PCI_REBAR_CTRL, ctrl);
1988 static struct pci_devres *get_pci_dr(struct pci_dev *pdev)
1992 dr = devres_find(&pdev->dev, pcim_release, NULL, NULL);
1999 return devres_get(&pdev->dev, new_dr, NULL, NULL);
2002 static struct pci_devres *find_pci_dr(struct pci_dev *pdev)
2004 if (pci_is_managed(pdev))
2005 return devres_find(&pdev->dev, pcim_release, NULL, NULL);
2011 * @pdev: PCI device to be initialized
2015 int pcim_enable_device(struct pci_dev *pdev)
2020 dr = get_pci_dr(pdev);
2026 rc = pci_enable_device(pdev);
2028 pdev->is_managed = 1;
2037 * @pdev: PCI device to pin
2039 * Pin managed PCI device @pdev. Pinned device won't be disabled on
2040 * driver detach. @pdev must have been enabled with
2043 void pcim_pin_device(struct pci_dev *pdev)
2047 dr = find_pci_dr(pdev);
2783 void pci_config_pm_runtime_get(struct pci_dev *pdev)
2785 struct device *dev = &pdev->dev;
2792 * pdev->current_state is set to PCI_D3cold during suspending,
2801 if (pdev->current_state == PCI_D3cold)
2805 void pci_config_pm_runtime_put(struct pci_dev *pdev)
2807 struct device *dev = &pdev->dev;
3397 static bool pci_acs_flags_enabled(struct pci_dev *pdev, u16 acs_flags)
3402 pos = pdev->acs_cap;
3411 pci_read_config_word(pdev, pos + PCI_ACS_CAP, &cap);
3414 pci_read_config_word(pdev, pos + PCI_ACS_CTRL, &ctrl);
3420 * @pdev: device to test
3434 bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags)
3438 ret = pci_dev_specific_acs_enabled(pdev, acs_flags);
3447 if (!pci_is_pcie(pdev))
3450 switch (pci_pcie_type(pdev)) {
3473 return pci_acs_flags_enabled(pdev, acs_flags);
3485 if (!pdev->multifunction)
3488 return pci_acs_flags_enabled(pdev, acs_flags);
3510 struct pci_dev *pdev, *parent = start;
3513 pdev = parent;
3515 if (!pci_acs_enabled(pdev, acs_flags))
3518 if (pci_is_root_bus(pdev->bus))
3521 parent = pdev->bus->self;
3522 } while (pdev != end);
3546 * @pdev: PCI device
3553 static int pci_rebar_find_pos(struct pci_dev *pdev, int bar)
3558 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_REBAR);
3562 pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl);
3569 pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl);
3580 * @pdev: PCI device
3586 u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar)
3591 pos = pci_rebar_find_pos(pdev, bar);
3595 pci_read_config_dword(pdev, pos + PCI_REBAR_CAP, &cap);
3599 if (pdev->vendor == PCI_VENDOR_ID_ATI && pdev->device == 0x731f &&
3608 * @pdev: PCI device
3614 int pci_rebar_get_current_size(struct pci_dev *pdev, int bar)
3619 pos = pci_rebar_find_pos(pdev, bar);
3623 pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl);
3629 * @pdev: PCI device
3636 int pci_rebar_set_size(struct pci_dev *pdev, int bar, int size)
3641 pos = pci_rebar_find_pos(pdev, bar);
3645 pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl);
3648 pci_write_config_dword(pdev, pos + PCI_REBAR_CTRL, ctrl);
3789 * @pdev: PCI device whose resources were previously reserved by
3797 void pci_release_region(struct pci_dev *pdev, int bar)
3801 if (pci_resource_len(pdev, bar) == 0)
3803 if (pci_resource_flags(pdev, bar) & IORESOURCE_IO)
3804 release_region(pci_resource_start(pdev, bar),
3805 pci_resource_len(pdev, bar));
3806 else if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM)
3807 release_mem_region(pci_resource_start(pdev, bar),
3808 pci_resource_len(pdev, bar));
3810 dr = find_pci_dr(pdev);
3818 * @pdev: PCI device whose resources are to be reserved
3823 * Mark the PCI region associated with PCI device @pdev BAR @bar as
3835 static int __pci_request_region(struct pci_dev *pdev, int bar,
3840 if (pci_resource_len(pdev, bar) == 0)
3843 if (pci_resource_flags(pdev, bar) & IORESOURCE_IO) {
3844 if (!request_region(pci_resource_start(pdev, bar),
3845 pci_resource_len(pdev, bar), res_name))
3847 } else if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) {
3848 if (!__request_mem_region(pci_resource_start(pdev, bar),
3849 pci_resource_len(pdev, bar), res_name,
3854 dr = find_pci_dr(pdev);
3861 pci_warn(pdev, "BAR %d: can't reserve %pR\n", bar,
3862 &pdev->resource[bar]);
3868 * @pdev: PCI device whose resources are to be reserved
3872 * Mark the PCI region associated with PCI device @pdev BAR @bar as
3880 int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name)
3882 return __pci_request_region(pdev, bar, res_name, 0);
3888 * @pdev: PCI device whose resources were previously reserved
3894 void pci_release_selected_regions(struct pci_dev *pdev, int bars)
3900 pci_release_region(pdev, i);
3904 static int __pci_request_selected_regions(struct pci_dev *pdev, int bars,
3911 if (__pci_request_region(pdev, i, res_name, excl))
3918 pci_release_region(pdev, i);
3926 * @pdev: PCI device whose resources are to be reserved
3930 int pci_request_selected_regions(struct pci_dev *pdev, int bars,
3933 return __pci_request_selected_regions(pdev, bars, res_name, 0);
3937 int pci_request_selected_regions_exclusive(struct pci_dev *pdev, int bars,
3940 return __pci_request_selected_regions(pdev, bars, res_name,
3947 * @pdev: PCI device whose resources were previously reserved by
3955 void pci_release_regions(struct pci_dev *pdev)
3957 pci_release_selected_regions(pdev, (1 << PCI_STD_NUM_BARS) - 1);
3963 * @pdev: PCI device whose resources are to be reserved
3966 * Mark all PCI regions associated with PCI device @pdev as
3974 int pci_request_regions(struct pci_dev *pdev, const char *res_name)
3976 return pci_request_selected_regions(pdev,
3983 * @pdev: PCI device whose resources are to be reserved
3986 * Mark all PCI regions associated with PCI device @pdev as being reserved
3996 int pci_request_regions_exclusive(struct pci_dev *pdev, const char *res_name)
3998 return pci_request_selected_regions_exclusive(pdev,
4199 * res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
4200 * base = devm_pci_remap_cfg_resource(&pdev->dev, res);
4448 * @pdev: the PCI device to operate on
4451 * Enables/disables PCI INTx for device @pdev
4453 void pci_intx(struct pci_dev *pdev, int enable)
4457 pci_read_config_word(pdev, PCI_COMMAND, &pci_command);
4467 pci_write_config_word(pdev, PCI_COMMAND, new);
4469 dr = find_pci_dr(pdev);
4705 * @pdev: Bridge device
4711 static bool pcie_wait_for_link_delay(struct pci_dev *pdev, bool active,
4722 if (!pdev->link_active_reporting) {
4739 pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnk_status);
4756 * @pdev: Bridge device
4761 bool pcie_wait_for_link(struct pci_dev *pdev, bool active)
4763 return pcie_wait_for_link_delay(pdev, active, 100);
4775 const struct pci_dev *pdev;
4779 list_for_each_entry(pdev, &bus->devices, bus_list) {
4780 if (pdev->d3cold_delay < min_delay)
4781 min_delay = pdev->d3cold_delay;
4782 if (pdev->d3cold_delay > max_delay)
4783 max_delay = pdev->d3cold_delay;
4934 struct pci_dev *pdev;
4940 list_for_each_entry(pdev, &dev->bus->devices, bus_list)
4941 if (pdev != dev)
5613 * @pdev: top level PCI device to reset via slot/bus
5617 int pci_reset_bus(struct pci_dev *pdev)
5619 return (!pci_probe_reset_slot(pdev->slot)) ?
5620 __pci_reset_slot(pdev->slot) : __pci_reset_bus(pdev->bus);
6092 bool pci_pr3_present(struct pci_dev *pdev)
6099 adev = ACPI_COMPANION(&pdev->dev);
6164 bool pci_device_is_present(struct pci_dev *pdev)
6168 /* Check PF if pdev is a VF, since VF Vendor/Device IDs are 0xffff */
6169 pdev = pci_physfn(pdev);
6170 if (pci_dev_is_disconnected(pdev))
6172 return pci_bus_read_dev_vendor_id(pdev->bus, pdev->devfn, &v, 0);