Lines Matching full:pp

56 irqreturn_t dw_handle_msi_irq(struct pcie_port *pp)  in dw_handle_msi_irq()  argument
62 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_handle_msi_irq()
64 num_ctrls = pp->num_vectors / MAX_MSI_IRQS_PER_CTRL; in dw_handle_msi_irq()
77 generic_handle_domain_irq(pp->irq_domain, in dw_handle_msi_irq()
91 struct pcie_port *pp; in dw_chained_msi_isr() local
95 pp = irq_desc_get_handler_data(desc); in dw_chained_msi_isr()
96 dw_handle_msi_irq(pp); in dw_chained_msi_isr()
103 struct pcie_port *pp = irq_data_get_irq_chip_data(d); in dw_pci_setup_msi_msg() local
104 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pci_setup_msi_msg()
107 msi_target = (u64)pp->msi_data; in dw_pci_setup_msi_msg()
126 struct pcie_port *pp = irq_data_get_irq_chip_data(d); in dw_pci_bottom_mask() local
127 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pci_bottom_mask()
131 raw_spin_lock_irqsave(&pp->lock, flags); in dw_pci_bottom_mask()
137 pp->irq_mask[ctrl] |= BIT(bit); in dw_pci_bottom_mask()
138 dw_pcie_writel_dbi(pci, PCIE_MSI_INTR0_MASK + res, pp->irq_mask[ctrl]); in dw_pci_bottom_mask()
140 raw_spin_unlock_irqrestore(&pp->lock, flags); in dw_pci_bottom_mask()
145 struct pcie_port *pp = irq_data_get_irq_chip_data(d); in dw_pci_bottom_unmask() local
146 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pci_bottom_unmask()
150 raw_spin_lock_irqsave(&pp->lock, flags); in dw_pci_bottom_unmask()
156 pp->irq_mask[ctrl] &= ~BIT(bit); in dw_pci_bottom_unmask()
157 dw_pcie_writel_dbi(pci, PCIE_MSI_INTR0_MASK + res, pp->irq_mask[ctrl]); in dw_pci_bottom_unmask()
159 raw_spin_unlock_irqrestore(&pp->lock, flags); in dw_pci_bottom_unmask()
164 struct pcie_port *pp = irq_data_get_irq_chip_data(d); in dw_pci_bottom_ack() local
165 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pci_bottom_ack()
188 struct pcie_port *pp = domain->host_data; in dw_pcie_irq_domain_alloc() local
193 raw_spin_lock_irqsave(&pp->lock, flags); in dw_pcie_irq_domain_alloc()
195 bit = bitmap_find_free_region(pp->msi_irq_in_use, pp->num_vectors, in dw_pcie_irq_domain_alloc()
198 raw_spin_unlock_irqrestore(&pp->lock, flags); in dw_pcie_irq_domain_alloc()
205 pp->msi_irq_chip, in dw_pcie_irq_domain_alloc()
206 pp, handle_edge_irq, in dw_pcie_irq_domain_alloc()
216 struct pcie_port *pp = domain->host_data; in dw_pcie_irq_domain_free() local
219 raw_spin_lock_irqsave(&pp->lock, flags); in dw_pcie_irq_domain_free()
221 bitmap_release_region(pp->msi_irq_in_use, d->hwirq, in dw_pcie_irq_domain_free()
224 raw_spin_unlock_irqrestore(&pp->lock, flags); in dw_pcie_irq_domain_free()
232 int dw_pcie_allocate_domains(struct pcie_port *pp) in dw_pcie_allocate_domains() argument
234 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pcie_allocate_domains()
237 pp->irq_domain = irq_domain_create_linear(fwnode, pp->num_vectors, in dw_pcie_allocate_domains()
238 &dw_pcie_msi_domain_ops, pp); in dw_pcie_allocate_domains()
239 if (!pp->irq_domain) { in dw_pcie_allocate_domains()
244 irq_domain_update_bus_token(pp->irq_domain, DOMAIN_BUS_NEXUS); in dw_pcie_allocate_domains()
246 pp->msi_domain = pci_msi_create_irq_domain(fwnode, in dw_pcie_allocate_domains()
248 pp->irq_domain); in dw_pcie_allocate_domains()
249 if (!pp->msi_domain) { in dw_pcie_allocate_domains()
251 irq_domain_remove(pp->irq_domain); in dw_pcie_allocate_domains()
258 static void dw_pcie_free_msi(struct pcie_port *pp) in dw_pcie_free_msi() argument
260 if (pp->msi_irq) in dw_pcie_free_msi()
261 irq_set_chained_handler_and_data(pp->msi_irq, NULL, NULL); in dw_pcie_free_msi()
263 irq_domain_remove(pp->msi_domain); in dw_pcie_free_msi()
264 irq_domain_remove(pp->irq_domain); in dw_pcie_free_msi()
266 if (pp->msi_data) { in dw_pcie_free_msi()
267 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pcie_free_msi()
270 dma_unmap_single_attrs(dev, pp->msi_data, sizeof(pp->msi_msg), in dw_pcie_free_msi()
275 static void dw_pcie_msi_init(struct pcie_port *pp) in dw_pcie_msi_init() argument
277 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pcie_msi_init()
278 u64 msi_target = (u64)pp->msi_data; in dw_pcie_msi_init()
280 if (!pci_msi_enabled() || !pp->has_msi_ctrl) in dw_pcie_msi_init()
288 int dw_pcie_host_init(struct pcie_port *pp) in dw_pcie_host_init() argument
290 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pcie_host_init()
299 raw_spin_lock_init(&pci->pp.lock); in dw_pcie_host_init()
303 pp->cfg0_size = resource_size(cfg_res); in dw_pcie_host_init()
304 pp->cfg0_base = cfg_res->start; in dw_pcie_host_init()
306 pp->va_cfg0_base = devm_pci_remap_cfg_resource(dev, cfg_res); in dw_pcie_host_init()
307 if (IS_ERR(pp->va_cfg0_base)) in dw_pcie_host_init()
308 return PTR_ERR(pp->va_cfg0_base); in dw_pcie_host_init()
325 pp->bridge = bridge; in dw_pcie_host_init()
330 pp->io_size = resource_size(win->res); in dw_pcie_host_init()
331 pp->io_bus_addr = win->res->start - win->offset; in dw_pcie_host_init()
332 pp->io_base = pci_pio_to_address(win->res->start); in dw_pcie_host_init()
339 pp->has_msi_ctrl = !(pp->ops->msi_host_init || in dw_pcie_host_init()
343 if (!pp->num_vectors) { in dw_pcie_host_init()
344 pp->num_vectors = MSI_DEF_NUM_VECTORS; in dw_pcie_host_init()
345 } else if (pp->num_vectors > MAX_MSI_IRQS) { in dw_pcie_host_init()
350 if (pp->ops->msi_host_init) { in dw_pcie_host_init()
351 ret = pp->ops->msi_host_init(pp); in dw_pcie_host_init()
354 } else if (pp->has_msi_ctrl) { in dw_pcie_host_init()
355 if (!pp->msi_irq) { in dw_pcie_host_init()
356 pp->msi_irq = platform_get_irq_byname_optional(pdev, "msi"); in dw_pcie_host_init()
357 if (pp->msi_irq < 0) { in dw_pcie_host_init()
358 pp->msi_irq = platform_get_irq(pdev, 0); in dw_pcie_host_init()
359 if (pp->msi_irq < 0) in dw_pcie_host_init()
360 return pp->msi_irq; in dw_pcie_host_init()
364 pp->msi_irq_chip = &dw_pci_msi_bottom_irq_chip; in dw_pcie_host_init()
366 ret = dw_pcie_allocate_domains(pp); in dw_pcie_host_init()
370 if (pp->msi_irq > 0) in dw_pcie_host_init()
371 irq_set_chained_handler_and_data(pp->msi_irq, in dw_pcie_host_init()
373 pp); in dw_pcie_host_init()
379 pp->msi_data = dma_map_single_attrs(pci->dev, &pp->msi_msg, in dw_pcie_host_init()
380 sizeof(pp->msi_msg), in dw_pcie_host_init()
383 if (dma_mapping_error(pci->dev, pp->msi_data)) { in dw_pcie_host_init()
385 pp->msi_data = 0; in dw_pcie_host_init()
395 if (pp->ops->host_init) { in dw_pcie_host_init()
396 ret = pp->ops->host_init(pp); in dw_pcie_host_init()
402 dw_pcie_setup_rc(pp); in dw_pcie_host_init()
413 bridge->sysdata = pp; in dw_pcie_host_init()
420 if (pp->has_msi_ctrl) in dw_pcie_host_init()
421 dw_pcie_free_msi(pp); in dw_pcie_host_init()
426 void dw_pcie_host_deinit(struct pcie_port *pp) in dw_pcie_host_deinit() argument
428 pci_stop_root_bus(pp->bridge->bus); in dw_pcie_host_deinit()
429 pci_remove_root_bus(pp->bridge->bus); in dw_pcie_host_deinit()
430 if (pp->has_msi_ctrl) in dw_pcie_host_deinit()
431 dw_pcie_free_msi(pp); in dw_pcie_host_deinit()
440 struct pcie_port *pp = bus->sysdata; in dw_pcie_other_conf_map_bus() local
441 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pcie_other_conf_map_bus()
463 dw_pcie_prog_outbound_atu(pci, 0, type, pp->cfg0_base, busdev, pp->cfg0_size); in dw_pcie_other_conf_map_bus()
465 return pp->va_cfg0_base + where; in dw_pcie_other_conf_map_bus()
472 struct pcie_port *pp = bus->sysdata; in dw_pcie_rd_other_conf() local
473 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pcie_rd_other_conf()
478 dw_pcie_prog_outbound_atu(pci, 0, PCIE_ATU_TYPE_IO, pp->io_base, in dw_pcie_rd_other_conf()
479 pp->io_bus_addr, pp->io_size); in dw_pcie_rd_other_conf()
488 struct pcie_port *pp = bus->sysdata; in dw_pcie_wr_other_conf() local
489 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pcie_wr_other_conf()
494 dw_pcie_prog_outbound_atu(pci, 0, PCIE_ATU_TYPE_IO, pp->io_base, in dw_pcie_wr_other_conf()
495 pp->io_bus_addr, pp->io_size); in dw_pcie_wr_other_conf()
508 struct pcie_port *pp = bus->sysdata; in dw_pcie_own_conf_map_bus() local
509 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pcie_own_conf_map_bus()
524 void dw_pcie_setup_rc(struct pcie_port *pp) in dw_pcie_setup_rc() argument
528 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pcie_setup_rc()
538 if (pp->has_msi_ctrl) { in dw_pcie_setup_rc()
539 num_ctrls = pp->num_vectors / MAX_MSI_IRQS_PER_CTRL; in dw_pcie_setup_rc()
543 pp->irq_mask[ctrl] = ~0; in dw_pcie_setup_rc()
546 pp->irq_mask[ctrl]); in dw_pcie_setup_rc()
553 dw_pcie_msi_init(pp); in dw_pcie_setup_rc()
587 if (pp->bridge->child_ops == &dw_child_pcie_ops) { in dw_pcie_setup_rc()
592 resource_list_for_each_entry(entry, &pp->bridge->windows) { in dw_pcie_setup_rc()
605 if (pp->io_size) { in dw_pcie_setup_rc()
608 PCIE_ATU_TYPE_IO, pp->io_base, in dw_pcie_setup_rc()
609 pp->io_bus_addr, pp->io_size); in dw_pcie_setup_rc()