Lines Matching +full:bus +full:- +full:addr
1 // SPDX-License-Identifier: GPL-2.0
3 * mmconfig.c - Low-level direct PCI config space access via MMCONFIG
19 static char __iomem *pci_dev_base(unsigned int seg, unsigned int bus, unsigned int devfn) in pci_dev_base() argument
21 struct pci_mmcfg_region *cfg = pci_mmconfig_lookup(seg, bus); in pci_dev_base()
23 if (cfg && cfg->virt) in pci_dev_base()
24 return cfg->virt + (PCI_MMCFG_BUS_OFFSET(bus) | (devfn << 12)); in pci_dev_base()
28 static int pci_mmcfg_read(unsigned int seg, unsigned int bus, in pci_mmcfg_read() argument
31 char __iomem *addr; in pci_mmcfg_read() local
33 /* Why do we have this when nobody checks it. How about a BUG()!? -AK */ in pci_mmcfg_read()
34 if (unlikely((bus > 255) || (devfn > 255) || (reg > 4095))) { in pci_mmcfg_read()
35 err: *value = -1; in pci_mmcfg_read()
36 return -EINVAL; in pci_mmcfg_read()
40 addr = pci_dev_base(seg, bus, devfn); in pci_mmcfg_read()
41 if (!addr) { in pci_mmcfg_read()
48 *value = mmio_config_readb(addr + reg); in pci_mmcfg_read()
51 *value = mmio_config_readw(addr + reg); in pci_mmcfg_read()
54 *value = mmio_config_readl(addr + reg); in pci_mmcfg_read()
62 static int pci_mmcfg_write(unsigned int seg, unsigned int bus, in pci_mmcfg_write() argument
65 char __iomem *addr; in pci_mmcfg_write() local
67 /* Why do we have this when nobody checks it. How about a BUG()!? -AK */ in pci_mmcfg_write()
68 if (unlikely((bus > 255) || (devfn > 255) || (reg > 4095))) in pci_mmcfg_write()
69 return -EINVAL; in pci_mmcfg_write()
72 addr = pci_dev_base(seg, bus, devfn); in pci_mmcfg_write()
73 if (!addr) { in pci_mmcfg_write()
75 return -EINVAL; in pci_mmcfg_write()
80 mmio_config_writeb(addr + reg, value); in pci_mmcfg_write()
83 mmio_config_writew(addr + reg, value); in pci_mmcfg_write()
86 mmio_config_writel(addr + reg, value); in pci_mmcfg_write()
101 void __iomem *addr; in mcfg_ioremap() local
105 start = cfg->address + PCI_MMCFG_BUS_OFFSET(cfg->start_bus); in mcfg_ioremap()
106 num_buses = cfg->end_bus - cfg->start_bus + 1; in mcfg_ioremap()
108 addr = ioremap(start, size); in mcfg_ioremap()
109 if (addr) in mcfg_ioremap()
110 addr -= PCI_MMCFG_BUS_OFFSET(cfg->start_bus); in mcfg_ioremap()
111 return addr; in mcfg_ioremap()
139 cfg->virt = mcfg_ioremap(cfg); in pci_mmcfg_arch_map()
140 if (!cfg->virt) { in pci_mmcfg_arch_map()
141 pr_err(PREFIX "can't map MMCONFIG at %pR\n", &cfg->res); in pci_mmcfg_arch_map()
142 return -ENOMEM; in pci_mmcfg_arch_map()
150 if (cfg && cfg->virt) { in pci_mmcfg_arch_unmap()
151 iounmap(cfg->virt + PCI_MMCFG_BUS_OFFSET(cfg->start_bus)); in pci_mmcfg_arch_unmap()
152 cfg->virt = NULL; in pci_mmcfg_arch_unmap()