Lines Matching refs:pci
60 struct gen_pci *pci = bus->sysdata; in gen_pci_map_cfg_bus_cam() local
61 resource_size_t idx = bus->number - pci->cfg.bus_range->start; in gen_pci_map_cfg_bus_cam()
63 return pci->cfg.win[idx] + ((devfn << 8) | where); in gen_pci_map_cfg_bus_cam()
79 struct gen_pci *pci = bus->sysdata; in gen_pci_map_cfg_bus_ecam() local
80 resource_size_t idx = bus->number - pci->cfg.bus_range->start; in gen_pci_map_cfg_bus_ecam()
82 return pci->cfg.win[idx] + ((devfn << 12) | where); in gen_pci_map_cfg_bus_ecam()
105 static void gen_pci_release_of_pci_ranges(struct gen_pci *pci) in gen_pci_release_of_pci_ranges() argument
107 pci_free_resource_list(&pci->resources); in gen_pci_release_of_pci_ranges()
110 static int gen_pci_parse_request_of_pci_ranges(struct gen_pci *pci) in gen_pci_parse_request_of_pci_ranges() argument
113 struct device *dev = pci->host.dev.parent; in gen_pci_parse_request_of_pci_ranges()
118 err = of_pci_get_host_bridge_resources(np, 0, 0xff, &pci->resources, in gen_pci_parse_request_of_pci_ranges()
123 resource_list_for_each_entry(win, &pci->resources) { in gen_pci_parse_request_of_pci_ranges()
141 pci->cfg.bus_range = res; in gen_pci_parse_request_of_pci_ranges()
160 gen_pci_release_of_pci_ranges(pci); in gen_pci_parse_request_of_pci_ranges()
164 static int gen_pci_parse_map_cfg_windows(struct gen_pci *pci) in gen_pci_parse_map_cfg_windows() argument
170 struct device *dev = pci->host.dev.parent; in gen_pci_parse_map_cfg_windows()
172 u32 sz = 1 << pci->cfg.ops->bus_shift; in gen_pci_parse_map_cfg_windows()
174 err = of_address_to_resource(np, 0, &pci->cfg.res); in gen_pci_parse_map_cfg_windows()
181 bus_max = pci->cfg.bus_range->start + in gen_pci_parse_map_cfg_windows()
182 (resource_size(&pci->cfg.res) >> pci->cfg.ops->bus_shift) - 1; in gen_pci_parse_map_cfg_windows()
183 pci->cfg.bus_range->end = min_t(resource_size_t, in gen_pci_parse_map_cfg_windows()
184 pci->cfg.bus_range->end, bus_max); in gen_pci_parse_map_cfg_windows()
186 pci->cfg.win = devm_kcalloc(dev, resource_size(pci->cfg.bus_range), in gen_pci_parse_map_cfg_windows()
187 sizeof(*pci->cfg.win), GFP_KERNEL); in gen_pci_parse_map_cfg_windows()
188 if (!pci->cfg.win) in gen_pci_parse_map_cfg_windows()
192 if (!devm_request_mem_region(dev, pci->cfg.res.start, in gen_pci_parse_map_cfg_windows()
193 resource_size(&pci->cfg.res), in gen_pci_parse_map_cfg_windows()
197 bus_range = pci->cfg.bus_range; in gen_pci_parse_map_cfg_windows()
201 pci->cfg.win[idx] = devm_ioremap(dev, in gen_pci_parse_map_cfg_windows()
202 pci->cfg.res.start + idx * sz, in gen_pci_parse_map_cfg_windows()
204 if (!pci->cfg.win[idx]) in gen_pci_parse_map_cfg_windows()
218 struct gen_pci *pci = devm_kzalloc(dev, sizeof(*pci), GFP_KERNEL); in gen_pci_probe() local
221 if (!pci) in gen_pci_probe()
233 pci->cfg.ops = (struct gen_pci_cfg_bus_ops *)of_id->data; in gen_pci_probe()
234 pci->host.dev.parent = dev; in gen_pci_probe()
235 INIT_LIST_HEAD(&pci->host.windows); in gen_pci_probe()
236 INIT_LIST_HEAD(&pci->resources); in gen_pci_probe()
239 err = gen_pci_parse_request_of_pci_ranges(pci); in gen_pci_probe()
244 err = gen_pci_parse_map_cfg_windows(pci); in gen_pci_probe()
246 gen_pci_release_of_pci_ranges(pci); in gen_pci_probe()
255 bus = pci_scan_root_bus(dev, pci->cfg.bus_range->start, in gen_pci_probe()
256 &pci->cfg.ops->ops, pci, &pci->resources); in gen_pci_probe()