aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r--drivers/pci/pci.c57
1 files changed, 50 insertions, 7 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 2c9ac70254e2..625a4ace10b4 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1003,12 +1003,19 @@ int pci_save_state(struct pci_dev *dev)
1003 for (i = 0; i < 16; i++) 1003 for (i = 0; i < 16; i++)
1004 pci_read_config_dword(dev, i * 4, &dev->saved_config_space[i]); 1004 pci_read_config_dword(dev, i * 4, &dev->saved_config_space[i]);
1005 dev->state_saved = true; 1005 dev->state_saved = true;
1006 if ((i = pci_save_pcie_state(dev)) != 0) 1006
1007 i = pci_save_pcie_state(dev);
1008 if (i != 0)
1007 return i; 1009 return i;
1008 if ((i = pci_save_pcix_state(dev)) != 0) 1010
1011 i = pci_save_pcix_state(dev);
1012 if (i != 0)
1009 return i; 1013 return i;
1010 if ((i = pci_save_vc_state(dev)) != 0) 1014
1015 i = pci_save_vc_state(dev);
1016 if (i != 0)
1011 return i; 1017 return i;
1018
1012 return 0; 1019 return 0;
1013} 1020}
1014EXPORT_SYMBOL(pci_save_state); 1021EXPORT_SYMBOL(pci_save_state);
@@ -1907,10 +1914,6 @@ int pci_prepare_to_sleep(struct pci_dev *dev)
1907 if (target_state == PCI_POWER_ERROR) 1914 if (target_state == PCI_POWER_ERROR)
1908 return -EIO; 1915 return -EIO;
1909 1916
1910 /* D3cold during system suspend/hibernate is not supported */
1911 if (target_state > PCI_D3hot)
1912 target_state = PCI_D3hot;
1913
1914 pci_enable_wake(dev, target_state, device_may_wakeup(&dev->dev)); 1917 pci_enable_wake(dev, target_state, device_may_wakeup(&dev->dev));
1915 1918
1916 error = pci_set_power_state(dev, target_state); 1919 error = pci_set_power_state(dev, target_state);
@@ -2704,6 +2707,37 @@ int pci_request_regions_exclusive(struct pci_dev *pdev, const char *res_name)
2704} 2707}
2705EXPORT_SYMBOL(pci_request_regions_exclusive); 2708EXPORT_SYMBOL(pci_request_regions_exclusive);
2706 2709
2710/**
2711 * pci_remap_iospace - Remap the memory mapped I/O space
2712 * @res: Resource describing the I/O space
2713 * @phys_addr: physical address of range to be mapped
2714 *
2715 * Remap the memory mapped I/O space described by the @res
2716 * and the CPU physical address @phys_addr into virtual address space.
2717 * Only architectures that have memory mapped IO functions defined
2718 * (and the PCI_IOBASE value defined) should call this function.
2719 */
2720int __weak pci_remap_iospace(const struct resource *res, phys_addr_t phys_addr)
2721{
2722#if defined(PCI_IOBASE) && defined(CONFIG_MMU)
2723 unsigned long vaddr = (unsigned long)PCI_IOBASE + res->start;
2724
2725 if (!(res->flags & IORESOURCE_IO))
2726 return -EINVAL;
2727
2728 if (res->end > IO_SPACE_LIMIT)
2729 return -EINVAL;
2730
2731 return ioremap_page_range(vaddr, vaddr + resource_size(res), phys_addr,
2732 pgprot_device(PAGE_KERNEL));
2733#else
2734 /* this architecture does not have memory mapped I/O space,
2735 so this function should never be called */
2736 WARN_ONCE(1, "This architecture does not support memory mapped I/O\n");
2737 return -ENODEV;
2738#endif
2739}
2740
2707static void __pci_set_master(struct pci_dev *dev, bool enable) 2741static void __pci_set_master(struct pci_dev *dev, bool enable)
2708{ 2742{
2709 u16 old_cmd, cmd; 2743 u16 old_cmd, cmd;
@@ -4406,6 +4440,15 @@ static void pci_no_domains(void)
4406#endif 4440#endif
4407} 4441}
4408 4442
4443#ifdef CONFIG_PCI_DOMAINS
4444static atomic_t __domain_nr = ATOMIC_INIT(-1);
4445
4446int pci_get_new_domain_nr(void)
4447{
4448 return atomic_inc_return(&__domain_nr);
4449}
4450#endif
4451
4409/** 4452/**
4410 * pci_ext_cfg_avail - can we access extended PCI config space? 4453 * pci_ext_cfg_avail - can we access extended PCI config space?
4411 * 4454 *