Lines Matching refs: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 irq = irq_find_mapping(pp->irq_domain, in dw_handle_msi_irq()
92 struct pcie_port *pp; in dw_chained_msi_isr() local
96 pp = irq_desc_get_handler_data(desc); in dw_chained_msi_isr()
97 dw_handle_msi_irq(pp); in dw_chained_msi_isr()
104 struct pcie_port *pp = irq_data_get_irq_chip_data(d); in dw_pci_setup_msi_msg() local
105 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pci_setup_msi_msg()
108 msi_target = (u64)pp->msi_data; in dw_pci_setup_msi_msg()
127 struct pcie_port *pp = irq_data_get_irq_chip_data(d); in dw_pci_bottom_mask() local
128 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pci_bottom_mask()
132 raw_spin_lock_irqsave(&pp->lock, flags); in dw_pci_bottom_mask()
138 pp->irq_mask[ctrl] |= BIT(bit); in dw_pci_bottom_mask()
139 dw_pcie_writel_dbi(pci, PCIE_MSI_INTR0_MASK + res, pp->irq_mask[ctrl]); in dw_pci_bottom_mask()
141 raw_spin_unlock_irqrestore(&pp->lock, flags); in dw_pci_bottom_mask()
146 struct pcie_port *pp = irq_data_get_irq_chip_data(d); in dw_pci_bottom_unmask() local
147 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pci_bottom_unmask()
151 raw_spin_lock_irqsave(&pp->lock, flags); in dw_pci_bottom_unmask()
157 pp->irq_mask[ctrl] &= ~BIT(bit); in dw_pci_bottom_unmask()
158 dw_pcie_writel_dbi(pci, PCIE_MSI_INTR0_MASK + res, pp->irq_mask[ctrl]); in dw_pci_bottom_unmask()
160 raw_spin_unlock_irqrestore(&pp->lock, flags); in dw_pci_bottom_unmask()
165 struct pcie_port *pp = irq_data_get_irq_chip_data(d); in dw_pci_bottom_ack() local
166 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pci_bottom_ack()
189 struct pcie_port *pp = domain->host_data; in dw_pcie_irq_domain_alloc() local
194 raw_spin_lock_irqsave(&pp->lock, flags); in dw_pcie_irq_domain_alloc()
196 bit = bitmap_find_free_region(pp->msi_irq_in_use, pp->num_vectors, in dw_pcie_irq_domain_alloc()
199 raw_spin_unlock_irqrestore(&pp->lock, flags); in dw_pcie_irq_domain_alloc()
206 pp->msi_irq_chip, in dw_pcie_irq_domain_alloc()
207 pp, handle_edge_irq, in dw_pcie_irq_domain_alloc()
217 struct pcie_port *pp = domain->host_data; in dw_pcie_irq_domain_free() local
220 raw_spin_lock_irqsave(&pp->lock, flags); in dw_pcie_irq_domain_free()
222 bitmap_release_region(pp->msi_irq_in_use, d->hwirq, in dw_pcie_irq_domain_free()
225 raw_spin_unlock_irqrestore(&pp->lock, flags); in dw_pcie_irq_domain_free()
233 int dw_pcie_allocate_domains(struct pcie_port *pp) in dw_pcie_allocate_domains() argument
235 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pcie_allocate_domains()
238 pp->irq_domain = irq_domain_create_linear(fwnode, pp->num_vectors, in dw_pcie_allocate_domains()
239 &dw_pcie_msi_domain_ops, pp); in dw_pcie_allocate_domains()
240 if (!pp->irq_domain) { in dw_pcie_allocate_domains()
245 irq_domain_update_bus_token(pp->irq_domain, DOMAIN_BUS_NEXUS); in dw_pcie_allocate_domains()
247 pp->msi_domain = pci_msi_create_irq_domain(fwnode, in dw_pcie_allocate_domains()
249 pp->irq_domain); in dw_pcie_allocate_domains()
250 if (!pp->msi_domain) { in dw_pcie_allocate_domains()
252 irq_domain_remove(pp->irq_domain); in dw_pcie_allocate_domains()
259 void dw_pcie_free_msi(struct pcie_port *pp) in dw_pcie_free_msi() argument
261 if (pp->msi_irq) { in dw_pcie_free_msi()
262 irq_set_chained_handler(pp->msi_irq, NULL); in dw_pcie_free_msi()
263 irq_set_handler_data(pp->msi_irq, NULL); in dw_pcie_free_msi()
266 irq_domain_remove(pp->msi_domain); in dw_pcie_free_msi()
267 irq_domain_remove(pp->irq_domain); in dw_pcie_free_msi()
269 if (pp->msi_data) { in dw_pcie_free_msi()
270 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pcie_free_msi()
273 dma_unmap_single_attrs(dev, pp->msi_data, sizeof(pp->msi_msg), in dw_pcie_free_msi()
278 void dw_pcie_msi_init(struct pcie_port *pp) in dw_pcie_msi_init() argument
280 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pcie_msi_init()
281 u64 msi_target = (u64)pp->msi_data; in dw_pcie_msi_init()
292 int dw_pcie_host_init(struct pcie_port *pp) in dw_pcie_host_init() argument
294 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pcie_host_init()
303 raw_spin_lock_init(&pci->pp.lock); in dw_pcie_host_init()
307 pp->cfg0_size = resource_size(cfg_res); in dw_pcie_host_init()
308 pp->cfg0_base = cfg_res->start; in dw_pcie_host_init()
309 } else if (!pp->va_cfg0_base) { in dw_pcie_host_init()
317 pp->bridge = bridge; in dw_pcie_host_init()
323 pp->io_size = resource_size(win->res); in dw_pcie_host_init()
324 pp->io_bus_addr = win->res->start - win->offset; in dw_pcie_host_init()
325 pp->io_base = pci_pio_to_address(win->res->start); in dw_pcie_host_init()
329 pp->cfg0_size = resource_size(win->res); in dw_pcie_host_init()
330 pp->cfg0_base = win->res->start; in dw_pcie_host_init()
333 pp->cfg0_base, in dw_pcie_host_init()
334 pp->cfg0_size); in dw_pcie_host_init()
344 if (!pp->va_cfg0_base) { in dw_pcie_host_init()
345 pp->va_cfg0_base = devm_pci_remap_cfgspace(dev, in dw_pcie_host_init()
346 pp->cfg0_base, pp->cfg0_size); in dw_pcie_host_init()
347 if (!pp->va_cfg0_base) { in dw_pcie_host_init()
366 if (!pp->ops->set_num_vectors) { in dw_pcie_host_init()
367 pp->num_vectors = MSI_DEF_NUM_VECTORS; in dw_pcie_host_init()
369 pp->ops->set_num_vectors(pp); in dw_pcie_host_init()
371 if (pp->num_vectors > MAX_MSI_IRQS || in dw_pcie_host_init()
372 pp->num_vectors == 0) { in dw_pcie_host_init()
379 if (!pp->ops->msi_host_init) { in dw_pcie_host_init()
380 pp->msi_irq_chip = &dw_pci_msi_bottom_irq_chip; in dw_pcie_host_init()
382 ret = dw_pcie_allocate_domains(pp); in dw_pcie_host_init()
386 if (pp->msi_irq) in dw_pcie_host_init()
387 irq_set_chained_handler_and_data(pp->msi_irq, in dw_pcie_host_init()
389 pp); in dw_pcie_host_init()
391 pp->msi_data = dma_map_single_attrs(pci->dev, &pp->msi_msg, in dw_pcie_host_init()
392 sizeof(pp->msi_msg), in dw_pcie_host_init()
395 if (dma_mapping_error(pci->dev, pp->msi_data)) { in dw_pcie_host_init()
397 pp->msi_data = 0; in dw_pcie_host_init()
401 ret = pp->ops->msi_host_init(pp); in dw_pcie_host_init()
411 if (pp->ops->host_init) { in dw_pcie_host_init()
412 ret = pp->ops->host_init(pp); in dw_pcie_host_init()
417 bridge->sysdata = pp; in dw_pcie_host_init()
424 if (pci_msi_enabled() && !pp->ops->msi_host_init) in dw_pcie_host_init()
425 dw_pcie_free_msi(pp); in dw_pcie_host_init()
430 void dw_pcie_host_deinit(struct pcie_port *pp) in dw_pcie_host_deinit() argument
432 pci_stop_root_bus(pp->bridge->bus); in dw_pcie_host_deinit()
433 pci_remove_root_bus(pp->bridge->bus); in dw_pcie_host_deinit()
434 if (pci_msi_enabled() && !pp->ops->msi_host_init) in dw_pcie_host_deinit()
435 dw_pcie_free_msi(pp); in dw_pcie_host_deinit()
444 struct pcie_port *pp = bus->sysdata; in dw_pcie_other_conf_map_bus() local
445 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pcie_other_conf_map_bus()
468 type, pp->cfg0_base, in dw_pcie_other_conf_map_bus()
469 busdev, pp->cfg0_size); in dw_pcie_other_conf_map_bus()
471 return pp->va_cfg0_base + where; in dw_pcie_other_conf_map_bus()
478 struct pcie_port *pp = bus->sysdata; in dw_pcie_rd_other_conf() local
479 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pcie_rd_other_conf()
485 PCIE_ATU_TYPE_IO, pp->io_base, in dw_pcie_rd_other_conf()
486 pp->io_bus_addr, pp->io_size); in dw_pcie_rd_other_conf()
495 struct pcie_port *pp = bus->sysdata; in dw_pcie_wr_other_conf() local
496 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pcie_wr_other_conf()
502 PCIE_ATU_TYPE_IO, pp->io_base, in dw_pcie_wr_other_conf()
503 pp->io_bus_addr, pp->io_size); in dw_pcie_wr_other_conf()
516 struct pcie_port *pp = bus->sysdata; in dw_pcie_own_conf_map_bus() local
517 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pcie_own_conf_map_bus()
532 void dw_pcie_setup_rc(struct pcie_port *pp) in dw_pcie_setup_rc() argument
535 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in dw_pcie_setup_rc()
545 if (pci_msi_enabled() && !pp->ops->msi_host_init) { in dw_pcie_setup_rc()
546 num_ctrls = pp->num_vectors / MAX_MSI_IRQS_PER_CTRL; in dw_pcie_setup_rc()
550 pp->irq_mask[ctrl] = ~0; in dw_pcie_setup_rc()
553 pp->irq_mask[ctrl]); in dw_pcie_setup_rc()
588 if (pp->bridge->child_ops == &dw_child_pcie_ops) { in dw_pcie_setup_rc()
592 resource_list_for_each_entry(tmp, &pp->bridge->windows) in dw_pcie_setup_rc()
602 PCIE_ATU_TYPE_IO, pp->io_base, in dw_pcie_setup_rc()
603 pp->io_bus_addr, pp->io_size); in dw_pcie_setup_rc()