Lines Matching +full:cfg +full:- +full:space
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
10 #include <linux/pci-acpi.h>
11 #include <linux/pci-ecam.h>
19 struct pci_config_window *cfg; member
30 struct device *bus_dev = &bridge->bus->dev; in pcibios_root_bridge_prepare()
31 struct pci_config_window *cfg = bridge->bus->sysdata; in pcibios_root_bridge_prepare() local
34 adev = to_acpi_device(cfg->parent); in pcibios_root_bridge_prepare()
36 ACPI_COMPANION_SET(&bridge->dev, adev); in pcibios_root_bridge_prepare()
37 set_dev_node(bus_dev, pa_to_nid(cfg->res.start)); in pcibios_root_bridge_prepare()
44 struct pci_config_window *cfg = bus->sysdata; in acpi_pci_bus_find_domain_nr() local
45 struct acpi_device *adev = to_acpi_device(cfg->parent); in acpi_pci_bus_find_domain_nr()
48 return root->segment; in acpi_pci_bus_find_domain_nr()
56 pci_ecam_free(info->cfg); in acpi_release_root_info()
57 kfree(ci->ops); in acpi_release_root_info()
65 struct acpi_device *device = ci->bridge; in acpi_prepare_root_resources()
69 resource_list_for_each_entry_safe(entry, tmp, &ci->resources) { in acpi_prepare_root_resources()
70 if (entry->res->flags & IORESOURCE_MEM) { in acpi_prepare_root_resources()
71 entry->offset = ci->root->mcfg_addr & GENMASK_ULL(63, 40); in acpi_prepare_root_resources()
72 entry->res->start |= entry->offset; in acpi_prepare_root_resources()
73 entry->res->end |= entry->offset; in acpi_prepare_root_resources()
79 resource_list_for_each_entry_safe(entry, tmp, &ci->resources) { in acpi_prepare_root_resources()
80 dev_dbg(&device->dev, in acpi_prepare_root_resources()
81 "host bridge window %pR (ignored)\n", entry->res); in acpi_prepare_root_resources()
89 * Create a PCI config space window
90 * - reserve mem region
91 * - alloc struct pci_config_window with space for all mappings
92 * - ioremap the config space
99 struct pci_config_window *cfg; in arch_pci_ecam_create() local
101 if (busr->start > busr->end) in arch_pci_ecam_create()
102 return ERR_PTR(-EINVAL); in arch_pci_ecam_create()
104 cfg = kzalloc(sizeof(*cfg), GFP_KERNEL); in arch_pci_ecam_create()
105 if (!cfg) in arch_pci_ecam_create()
106 return ERR_PTR(-ENOMEM); in arch_pci_ecam_create()
108 cfg->parent = dev; in arch_pci_ecam_create()
109 cfg->ops = ops; in arch_pci_ecam_create()
110 cfg->busr.start = busr->start; in arch_pci_ecam_create()
111 cfg->busr.end = busr->end; in arch_pci_ecam_create()
112 cfg->busr.flags = IORESOURCE_BUS; in arch_pci_ecam_create()
113 bus_range = resource_size(cfgres) >> ops->bus_shift; in arch_pci_ecam_create()
115 bsz = 1 << ops->bus_shift; in arch_pci_ecam_create()
117 cfg->res.start = cfgres->start; in arch_pci_ecam_create()
118 cfg->res.end = cfgres->end; in arch_pci_ecam_create()
119 cfg->res.flags = IORESOURCE_MEM | IORESOURCE_BUSY; in arch_pci_ecam_create()
120 cfg->res.name = "PCI ECAM"; in arch_pci_ecam_create()
122 conflict = request_resource_conflict(&iomem_resource, &cfg->res); in arch_pci_ecam_create()
124 err = -EBUSY; in arch_pci_ecam_create()
126 &cfg->res, conflict->name, conflict); in arch_pci_ecam_create()
130 cfg->win = pci_remap_cfgspace(cfgres->start, bus_range * bsz); in arch_pci_ecam_create()
131 if (!cfg->win) in arch_pci_ecam_create()
134 if (ops->init) { in arch_pci_ecam_create()
135 err = ops->init(cfg); in arch_pci_ecam_create()
139 dev_info(dev, "ECAM at %pR for %pR\n", &cfg->res, &cfg->busr); in arch_pci_ecam_create()
141 return cfg; in arch_pci_ecam_create()
144 err = -ENOMEM; in arch_pci_ecam_create()
147 pci_ecam_free(cfg); in arch_pci_ecam_create()
152 * Lookup the bus range for the domain in MCFG, and set up config space
159 u16 seg = root->segment; in pci_acpi_setup_ecam_mapping()
160 struct device *dev = &root->device->dev; in pci_acpi_setup_ecam_mapping()
162 struct resource *bus_res = &root->secondary; in pci_acpi_setup_ecam_mapping()
163 struct pci_config_window *cfg; in pci_acpi_setup_ecam_mapping() local
170 root->mcfg_addr = mcfg_addr_init(0); in pci_acpi_setup_ecam_mapping()
173 bus_shift = ecam_ops->bus_shift ? : 20; in pci_acpi_setup_ecam_mapping()
176 cfg = pci_ecam_create(dev, &cfgres, bus_res, ecam_ops); in pci_acpi_setup_ecam_mapping()
178 cfgres.start = root->mcfg_addr + (bus_res->start << bus_shift); in pci_acpi_setup_ecam_mapping()
179 cfgres.end = cfgres.start + (resource_size(bus_res) << bus_shift) - 1; in pci_acpi_setup_ecam_mapping()
180 cfgres.end |= BIT(28) + (((PCI_CFG_SPACE_EXP_SIZE - 1) & 0xf00) << 16); in pci_acpi_setup_ecam_mapping()
182 cfg = arch_pci_ecam_create(dev, &cfgres, bus_res, ecam_ops); in pci_acpi_setup_ecam_mapping()
185 if (IS_ERR(cfg)) { in pci_acpi_setup_ecam_mapping()
186 dev_err(dev, "%04x:%pR error %ld mapping ECAM\n", seg, bus_res, PTR_ERR(cfg)); in pci_acpi_setup_ecam_mapping()
190 return cfg; in pci_acpi_setup_ecam_mapping()
198 int domain = root->segment; in pci_acpi_scan_root()
199 int busnum = root->secondary.start; in pci_acpi_scan_root()
213 info->cfg = pci_acpi_setup_ecam_mapping(root); in pci_acpi_scan_root()
214 if (!info->cfg) { in pci_acpi_scan_root()
220 root_ops->release_info = acpi_release_root_info; in pci_acpi_scan_root()
221 root_ops->prepare_resources = acpi_prepare_root_resources; in pci_acpi_scan_root()
222 root_ops->pci_ops = (struct pci_ops *)&info->cfg->ops->pci_ops; in pci_acpi_scan_root()
226 memcpy(bus->sysdata, info->cfg, sizeof(struct pci_config_window)); in pci_acpi_scan_root()
233 &info->common, info->cfg); in pci_acpi_scan_root()
242 list_for_each_entry(child, &bus->children, node) in pci_acpi_scan_root()